Patchwork [1,of,3] strip: use bundle2 + cg2 by default when repository use general delta

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 29, 2015, 10:28 p.m.
Message ID <4e5c7e8778bfa9114d7e.1443565680@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/10690/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 29, 2015, 10:28 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1443557811 25200
#      Tue Sep 29 13:16:51 2015 -0700
# Node ID 4e5c7e8778bfa9114d7e37719cb2009d5a9d284b
# Parent  1cfd337ef697249576f5bbac782c6299a6efc195
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.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -19,22 +19,13 @@  from . import (
     util,
 )
 
 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)
     backupdir = "strip-backup"
     vfs = repo.vfs
@@ -45,11 +36,11 @@  def _bundle(repo, bases, heads, node, su
     allcommits = repo.set('%ln::%ln', bases, heads)
     allhashes = sorted(c.hex() for c in allcommits)
     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"
     else:
         bundletype = "HG10UN"
diff --git a/tests/test-generaldelta.t b/tests/test-generaldelta.t
--- a/tests/test-generaldelta.t
+++ b/tests/test-generaldelta.t
@@ -100,6 +100,15 @@  Test format.aggressivemergedeltas
      rev    offset  length  delta linkrev nodeid       p1           p2
        0         0      59     -1       0 8dde941edb6e 000000000000 000000000000
        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
@@ -183,11 +183,11 @@  pull --rebase works with bundle2 turned 
   o  1: 'C2'
   |
   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
   adding manifests
   adding file changes
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -195,59 +195,22 @@ 
   parent:      1:ef3a871183d7
   user:        test
   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
   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
-  $ 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
   adding changesets
   adding manifests