# HG changeset patch # User Pierre-Yves David # Date 2015-09-29 20:16:51 # Node ID c93f91c1db1c0b1374403967298e7a88bfeff9c9 # Parent 41436beaf463e6e04df56b97965b9c9e35f28099 strip: use bundle2 + cg2 by default when repository use general delta The bundle10 format (plain changegroup-01) does not support general delta and result into expensive delta re-computation when stripping. If the repository is general delta, we store backups as bundle20 containing a changegroup-02 payload. We remove the experimental feature related to strip backup bundle format because this achieve the same goal in a leaner way. Removing the experimental option is fine, that is why it experimental in the first place. Compression of these bundles are coming in later changesets. diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -21,18 +21,9 @@ from . import ( def _bundle(repo, bases, heads, node, suffix, compress=True): """create a bundle with the specified revisions as a backup""" - usebundle2 = (repo.ui.configbool('experimental', 'bundle2-exp', True) and - repo.ui.config('experimental', 'strip-bundle2-version')) - if usebundle2: - cgversion = repo.ui.config('experimental', 'strip-bundle2-version') - if cgversion not in changegroup.packermap: - repo.ui.warn(_('unknown strip-bundle2-version value %r; ' - 'should be one of %r\n') % - (cgversion, sorted(changegroup.packermap.keys()),)) - cgversion = '01' - usebundle2 = False - else: - cgversion = '01' + cgversion = '01' + if 'generaldelta' in repo.requirements: + cgversion = '02' cg = changegroup.changegroupsubset(repo, bases, heads, 'strip', version=cgversion) @@ -47,7 +38,7 @@ def _bundle(repo, bases, heads, node, su totalhash = util.sha1(''.join(allhashes)).hexdigest() name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix) - if usebundle2: + if cgversion != '01': bundletype = "HG20" elif compress: bundletype = "HG10BZ" diff --git a/tests/test-generaldelta.t b/tests/test-generaldelta.t --- a/tests/test-generaldelta.t +++ b/tests/test-generaldelta.t @@ -102,4 +102,13 @@ Test format.aggressivemergedeltas 1 59 59 -1 1 315c023f341d 000000000000 000000000000 2 118 62 0 2 2ab389a983eb 315c023f341d 8dde941edb6e +Test that strip bundle use bundle2 + $ hg --config extensions.strip= strip . + 0 files updated, 0 files merged, 5 files removed, 0 files unresolved + saved backup bundle to $TESTTMP/aggressive/.hg/strip-backup/1c5d4dc9a8b8-6c68e60c-backup.hg (glob) + $ hg debugbundle .hg/strip-backup/* + Stream params: {} + changegroup -- "{'version': '02'}" + 1c5d4dc9a8b8d6e1750966d343e94db665e7a1e9 + $ cd .. diff --git a/tests/test-rebase-pull.t b/tests/test-rebase-pull.t --- a/tests/test-rebase-pull.t +++ b/tests/test-rebase-pull.t @@ -185,7 +185,7 @@ pull --rebase works with bundle2 turned o 0: 'C1' $ cd ../c - $ hg pull --rebase --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=02 + $ hg pull --rebase pulling from $TESTTMP/a (glob) searching for changes adding changesets diff --git a/tests/test-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -197,17 +197,8 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: c - $ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=INVALID strip 4 - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved - unknown strip-bundle2-version value 'INVALID'; should be one of ['01', '02'] - saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob) - $ hg debugbundle .hg/strip-backup/* - 264128213d290d868c54642d13aeaa3675551a78 - $ 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 + $ hg --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 @@ -217,35 +208,7 @@ summary: b $ hg debugbundle .hg/strip-backup/* - Stream params: {} - 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: {} - changegroup -- "{'version': '02'}" - 264128213d290d868c54642d13aeaa3675551a78 + 264128213d290d868c54642d13aeaa3675551a78 $ hg pull .hg/strip-backup/* pulling from .hg/strip-backup/264128213d29-0b39d6bf-backup.hg searching for changes