Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Importing a Mercurial repository

brygge imports what the repository would publish: the changesets hg clone would share. Secret and hidden (obsolete) changesets stay behind, and the report counts them. brygge reads the local store directly (no hg binary is needed), and it never modifies anything it reads.

brygge decode hg <repository> --out <artifact>

<repository> is the working directory that contains .hg (or the .hg directory itself).

Memory while decoding

brygge keeps file content on disk while decoding, not in memory: a large repository needs free disk space of roughly its content’s uncompressed size while decoding (the spill file, removed when brygge exits), plus the artifact, which is several times smaller. --spill-dir <DIR> chooses where; the default is --out’s own directory. A RAM-backed directory (tmpfs) moves the memory cost rather than removing it. The option never changes the artifact. Compressing the artifact uses up to 8 threads and about 100 MiB more memory than before (not growing with the repository), and makes decoding take about 1.5× as long.

What brygge carries

  • Every published changeset, as a stated atom: its parents, its file operations, and its message, byte for byte.
    • The user is carried as the author, with the email split out when present. Mercurial records one user and one date, so there is no separate committer or commit time: brygge never invents one.
    • The time keeps its timezone offset.
  • Renames and copies that Mercurial recorded (hg mv, hg cp), as stated copies. Each copy names the changeset its source really came from: the first parent, the second parent in a merge, or an earlier changeset. A copy is never placed on a guess.
  • Changeset extras (every one, branch included), carried as labelled bytes in their stored order.
    • branch names the changeset’s named branch. Mercurial stores it only on changesets that are not on default, and brygge carries it exactly where it is stored, so every changeset’s branch is stated in the artifact.
    • a close extra (Mercurial writes 1) means the changeset closed its branch (hg commit --close-branch).
  • Refs:
    • every bookmark that names a published changeset;
    • one ref per named branch, at Mercurial’s branch tip (branchmap.branchtip, which is what hg update <branch> checks out): the tipmost open head of the branch among the published changesets, or, when every head is closed, the tipmost head. A branch may have several heads; every one of them is recoverable from the changesets’ branch extras (a changeset of the branch with no published child on it), and a closed head’s close extra says it was closed.
    • “Tipmost” is the highest revision number in this repository, as it is for hg update. Two clones that pulled in a different order can therefore name different tips: that is Mercurial’s own behaviour, stated here and not hidden.
  • Tags travel as the .hgtags file in the history, as Mercurial stores them, not as refs.
  • Verified identity. Every revision brygge reads (changeset, manifest, file) is re-hashed the way Mercurial hashes it, and a store whose content does not match its node is refused. The repository’s identity is taken from its smallest published root, so a repository and its hg clone get the same identity.

What it does not carry

Each of these is recorded in the artifact’s loss boundary, never dropped silently. inspect shows them:

RecordWhen
revlog physical layout and delta chainsalways: storage detail; the logical revisions are all carried
dirstate and working copyalways: local state, not history
phases (public/draft/secret)the repository has phase data
obsolescence markersthe repository has an obsstore; the markers are advisory and never become ancestry
changesets not published: secret or archived (N)secret or archived changesets were left out
hidden (obsolete) changesets (N)rewritten or pruned changesets were left out. A changeset that is both secret and obsolete is counted once, as not published
copy sources not resolvable (N)a recorded copy whose source could not be placed on an imported changeset; the copy is omitted, and the file is still carried
copy metadata on an existing path not carried (N)a copy recorded onto a path that already existed (hg cp -f); the file’s change is carried, the copy relationship is not
bookmarks naming unimported changesets (N)a bookmark names a secret, hidden or missing changeset
unrepresentable timezone offsets (N)a stored offset that is not a whole number of minutes; the time is carried, the offset is not

The first two are storage representation only. If anything else is recorded, decode exits 10 (recorded loss) instead of 0.

Options

  • --infer-renames does not apply to Mercurial: Mercurial records its renames itself, and brygge carries them as stated. Giving it is a usage error (exit 2).
  • --reconstruct-refs does not apply to Mercurial (it has real branches and bookmarks). Giving it is a usage error (exit 2).

Repositories brygge refuses

A refusal exits 20, names what was refused, and writes nothing (an existing artifact at --out is left untouched).

RefusedIdentifierWhat you can do
subrepositories (.hgsub, .hgsubstate)subrepodecode each subrepository separately
the largefiles extensionlargefilesconvert the large files to ordinary files (hg lfconvert --to-normal <repository> <new copy> writes a converted copy), then decode the copy
the lfs extensionlfsin a copy of the repository, convert the tracked files back to ordinary files, then decode the copy
a censored revisioncensored-revisionnone: the content no longer exists; keep the source repository
a merge in progress (.hg/merge/state2)unfinished-mergefinish the merge (hg resolve, then hg commit) or abort it (hg merge --abort), then decode again
a changeset extra whose key is not valid UTF-8non-utf8-extra-keynone without rewriting history; keep the source repository
a file path that is not valid UTF-8 (shown as \xNN)non-utf8-pathrename the file in a copy of the repository
a narrow clone’s ellipsis revisionellipsis-revisiondecode the full repository the narrow clone came from
an externally stored revisionexternal-storage-revisionas for lfs
a revision flag Mercurial does not defineunknown-revision-flagnone; Mercurial refuses it too

These also exit 20:

  • A format this build does not read: a .hg/requires entry such as revlogv2, treemanifest, a narrow clone, or anything unrecognized; or an obsstore other than version 1.
  • A store without fncache (Mercurial before 1.1, from 2008), whose file names are encoded differently (store-without-fncache). Clone it with a current Mercurial (hg clone --pull <old> <new> writes a current store), then decode the clone.
  • A size ceiling: a revision over 1 GiB once decompressed, or an obsstore or a small metadata file (phaseroots, bookmarks, localtags) over 64 MiB.

A corrupt or crafted store (for example, a revision that does not match its node) is a read error, exit 1.

Checking an import

  • brygge inspect <artifact> prints the fidelity report: what was carried, derived, dropped and refused.
  • brygge verify <artifact> checks the artifact’s own honesty and integrity, with no source needed.
  • brygge verify <artifact> --against-source <repository> decodes the repository again and confirms the artifact corresponds to it (corresponds). Authorship is always Unverifiable: brygge carries what the source says, and verifies no one’s identity.