shelve: use cg3 for treemanifests stable
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 19 Jan 2016 15:37:07 -0800
branchstable
changeset 29880 1289a122cf3f55ed8c37be11157fe8acf06abfe5
parent 29879 7cbb3a01fa38190d986741117a867a2e8586c668
child 29881 6bc2299cc12f95faa295dc93ada6a862c7be59e6
push id175
push usergszorc@mozilla.com
push dateWed, 10 Feb 2016 01:24:28 +0000
shelve: use cg3 for treemanifests Similar to previous change, this teaches shelve to pick the right changegroup version for repos that use treemanifests.
hgext/shelve.py
mercurial/changegroup.py
tests/test-treemanifest.t
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -107,22 +107,22 @@ class shelvedfile(object):
                                     url='bundle:' + self.vfs.join(self.fname))
         finally:
             fp.close()
 
     def bundlerepo(self):
         return bundlerepo.bundlerepository(self.repo.baseui, self.repo.root,
                                            self.vfs.join(self.fname))
     def writebundle(self, bases, node):
-        btype = 'HG10BZ'
-        cgversion = '01'
-        compression = None
-        if 'generaldelta' in self.repo.requirements:
+        cgversion = changegroup.safeversion(self.repo)
+        if cgversion == '01':
+            btype = 'HG10BZ'
+            compression = None
+        else:
             btype = 'HG20'
-            cgversion = '02'
             compression = 'BZ'
 
         cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve',
                                            version=cgversion)
         changegroup.writebundle(self.ui, cg, self.fname, btype, self.vfs,
                                 compression=compression)
 
 class shelvedstate(object):
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -958,17 +958,18 @@ def supportedversions(repo):
         versions.discard('01')
         versions.discard('02')
     elif not repo.ui.configbool('experimental', 'changegroup3'):
         versions.discard('03')
     return versions
 
 def safeversion(repo):
     # Finds the smallest version that it's safe to assume clients of the repo
-    # will support.
+    # will support. For example, all hg versions that support generaldelta also
+    # support changegroup 02.
     versions = supportedversions(repo)
     if 'generaldelta' in repo.requirements:
         versions.discard('01')
     assert versions
     return min(versions)
 
 def getbundler(version, repo, bundlecaps=None):
     assert version in supportedversions(repo)
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -291,16 +291,32 @@ Stripping and recovering changes should 
   M dir1/a
   $ hg --config extensions.strip= strip tip
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/repo-mixed/.hg/strip-backup/51cfd7b1e13b-78a2f3ed-backup.hg (glob)
   $ hg unbundle -q .hg/strip-backup/*
   $ hg st --change tip
   M dir1/a
 
+Shelving and unshelving should work
+
+  $ echo foo >> dir1/a
+  $ hg --config extensions.shelve= shelve
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg --config extensions.shelve= unshelve
+  unshelving change 'default'
+  $ hg diff --nodates
+  diff -r 708a273da119 dir1/a
+  --- a/dir1/a
+  +++ b/dir1/a
+  @@ -1,1 +1,2 @@
+   1
+  +foo
+
 Create deeper repo with tree manifests.
 
   $ cd ..
   $ hg --config experimental.treemanifest=True init deeprepo
   $ cd deeprepo
 
   $ mkdir a
   $ mkdir b