Mercurial > hg-stable
changeset 24073:ff5caa8dfd99
bundlerepo: basic bundle2 support
For bundlerepo to work with bundle2 files, we need to find the part that
contains the bundle's changegroup data and work with that instead of the
entire bundle. Future work can add separate processing for other bundle2
parts.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Fri, 06 Feb 2015 11:27:25 -0800 |
parents | 145b823f5ce7 |
children | 4d9c738d942f |
files | mercurial/bundlerepo.py tests/test-strip.t |
diffstat | 2 files changed, 81 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Thu Feb 05 16:03:26 2015 -0800 +++ b/mercurial/bundlerepo.py Fri Feb 06 11:27:25 2015 -0800 @@ -15,7 +15,7 @@ from i18n import _ import os, tempfile, shutil import changegroup, util, mdiff, discovery, cmdutil, scmutil, exchange -import localrepo, changelog, manifest, filelog, revlog, error, phases +import localrepo, changelog, manifest, filelog, revlog, error, phases, bundle2 class bundlerevlog(revlog.revlog): def __init__(self, opener, indexfile, bundle, linkmapper): @@ -238,6 +238,24 @@ bundlename, self.vfs) + if isinstance(self.bundle, bundle2.unbundle20): + cgparts = [part for part in self.bundle.iterparts() + if (part.type == 'b2x:changegroup') + and (part.params.get('version', '01') + in changegroup.packermap)] + + if not cgparts: + raise util.Abort('No changegroups found') + version = cgparts[0].params.get('version', '01') + cgparts = [p for p in cgparts + if p.params.get('version', '01') == version] + if len(cgparts) > 1: + raise NotImplementedError("Can't process multiple changegroups") + part = cgparts[0] + + part.seek(0) + self.bundle = changegroup.packermap[version][1](part, 'UN') + # dict with the mapping 'filename' -> position in the bundle self.bundlefilespos = {}
--- a/tests/test-strip.t Thu Feb 05 16:03:26 2015 -0800 +++ b/tests/test-strip.t Fri Feb 06 11:27:25 2015 -0800 @@ -220,8 +220,69 @@ Stream params: {} b2x:changegroup -- "{'version': '02'}" 264128213d290d868c54642d13aeaa3675551a78 + $ hg incoming .hg/strip-backup/* + comparing with .hg/strip-backup/264128213d29-0b39d6bf-backup.hg + searching for changes + changeset: 4:264128213d29 + tag: tip + parent: 1:ef3a871183d7 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: c + $ restore - + $ hg up -C 4 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=02 --traceback strip 4 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob) + $ hg parents + changeset: 1:ef3a871183d7 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: b + + $ hg debugbundle .hg/strip-backup/* + Stream params: {} + b2x:changegroup -- "{'version': '02'}" + 264128213d290d868c54642d13aeaa3675551a78 + $ hg pull .hg/strip-backup/* + pulling from .hg/strip-backup/264128213d29-0b39d6bf-backup.hg + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files (+1 heads) + (run 'hg heads' to see heads, 'hg merge' to merge) + $ rm .hg/strip-backup/* + $ hg log --graph + o changeset: 4:264128213d29 + | tag: tip + | parent: 1:ef3a871183d7 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: c + | + | o changeset: 3:443431ffac4f + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: e + | | + | o changeset: 2:65bd5f99a4a3 + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: d + | + @ changeset: 1:ef3a871183d7 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: b + | + o changeset: 0:9ab35a2d17cb + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: a + $ hg up -C 2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg merge 4