Patchwork [4,of,4,STABLE] shelve: use cg3 for treemanifests

login
register
mail settings
Submitter Martin von Zweigbergk
Date Jan. 21, 2016, 4:42 a.m.
Message ID <9506143ce3a40e7c6e01.1453351366@waste.org>
Download mbox | patch
Permalink /patch/12859/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Jan. 21, 2016, 4:42 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1453246627 28800
#      Tue Jan 19 15:37:07 2016 -0800
# Branch stable
# Node ID 9506143ce3a40e7c6e01a27a7ec1b8a462b73959
# Parent  eaeaf246d84ef23131204cbc39e72b44ab923336
shelve: use cg3 for treemanifests

Similar to previous change, this teaches shelve to pick the right
changegroup version for repos that use treemanifests.
Pierre-Yves David - Jan. 22, 2016, 8:40 p.m.
On 01/20/2016 08:42 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1453246627 28800
> #      Tue Jan 19 15:37:07 2016 -0800
> # Branch stable
> # Node ID 9506143ce3a40e7c6e01a27a7ec1b8a462b73959
> # Parent  eaeaf246d84ef23131204cbc39e72b44ab923336
> shelve: use cg3 for treemanifests

Theses are pushed to the clowncopter, thanks.

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -112,12 +112,12 @@ 
         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',
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -963,7 +963,8 @@ 
 
 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')
diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -296,6 +296,22 @@ 
   $ 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 ..