strip: use bundle2 + cg2 by default when repository use general delta
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 29 Sep 2015 13:16:51 -0700
changeset 26423 c93f91c1db1c
parent 26422 41436beaf463
child 26424 60825fbe2be1
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.
mercurial/repair.py
tests/test-generaldelta.t
tests/test-rebase-pull.t
tests/test-strip.t
--- a/mercurial/repair.py	Wed Sep 30 16:01:19 2015 -0400
+++ b/mercurial/repair.py	Tue Sep 29 13:16:51 2015 -0700
@@ -21,18 +21,9 @@
 
 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 @@
     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"
--- a/tests/test-generaldelta.t	Wed Sep 30 16:01:19 2015 -0400
+++ b/tests/test-generaldelta.t	Tue Sep 29 13:16:51 2015 -0700
@@ -102,4 +102,13 @@
        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 ..
--- a/tests/test-rebase-pull.t	Wed Sep 30 16:01:19 2015 -0400
+++ b/tests/test-rebase-pull.t	Tue Sep 29 13:16:51 2015 -0700
@@ -185,7 +185,7 @@
   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
--- a/tests/test-strip.t	Wed Sep 30 16:01:19 2015 -0400
+++ b/tests/test-strip.t	Tue Sep 29 13:16:51 2015 -0700
@@ -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