Skip to content

Keep every revision and its metadata when streaming a dump#4

Open
tamnd wants to merge 1 commit into
mainfrom
dump-lossless
Open

Keep every revision and its metadata when streaming a dump#4
tamnd wants to merge 1 commit into
mainfrom
dump-lossless

Conversation

@tamnd

@tamnd tamnd commented Jun 13, 2026

Copy link
Copy Markdown
Owner

What

A streamed dump page used to flatten to a single revision: one id, one timestamp, the text, and a redirect bool. That dropped most of what the MediaWiki XML schema carries, and it could not represent a pages-meta-history dump at all, where a page holds its full revision list.

This makes the dump output lossless.

Changes

  • DumpPage now keeps a Revisions slice plus the page's RedirectTitle and Restrictions.
  • New DumpRevision carries id, parent id, timestamp, contributor, minor flag, comment, content model and format, origin, sha1, and byte length.
  • New Contributor distinguishes a registered user (username + id), an anonymous edit (IP), and a deleted author.
  • Latest() / LatestText() return the current revision, which is what pages, grep, and export use on a pages-articles dump.
  • dump list output gained md5, the job status, and the job updated time, so -o json mirrors dumpstatus.json.

Before / after

A history page now round-trips in full:

```json
{
"id": 25202,
"ns": 0,
"title": "Quantum mechanics",
"restrictions": "edit=sysop",
"revisions": [
{"id": 100, "timestamp": "2020-01-01T00:00:00Z",
"contributor": {"username": "Alice", "id": 42},
"minor": true, "comment": "first", "model": "wikitext",
"format": "text/x-wiki", "origin": 100, "sha1": "abc",
"textbytes": 9, "text": "old text."},
{"id": 101, "parentid": 100, "timestamp": "2021-02-03T04:05:06Z",
"contributor": {"ip": "10.0.0.1"},
"comment": "second", "model": "wikitext", "format": "text/x-wiki",
"origin": 101, "sha1": "def", "textbytes": 9, "text": "new text."}
]
}
```

Before, that page emitted only {id, ns, title, revid: 100, timestamp, redirect} and could not show the second revision, the contributors, or the restrictions.

Tests

  • New TestStreamPagesFullRevisionMetadata asserts multiple revisions, registered and anonymous contributors, redirect target, restrictions, and the per-revision fields all survive the parse.
  • Existing stream tests updated to the new model.
  • go build, go vet, go test ./..., and golangci-lint run all clean.

A page record used to flatten to a single revision: one id, one
timestamp, the text, and a redirect bool. That threw away most of what
the XML schema carries, and it could not represent a meta-history dump
at all, where a page holds its whole revision list.

DumpPage now keeps a Revisions slice. Each revision carries its id,
parent id, timestamp, contributor (a registered user's name and id, or
an anonymous edit's IP, or a deleted marker), minor flag, comment,
content model and format, origin, sha1, and byte length. The page keeps
its redirect target title and edit/move restrictions. Latest() and
LatestText() give callers the current revision, which is what the
pages/grep/export commands want for a pages-articles dump.

The dump list output also gained md5, the job status, and the job's
updated time, so -o json mirrors dumpstatus.json.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant