exchange: set 'treemanifest' param on pushed changegroups too stable
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 22 Jan 2016 16:31:50 -0800
branchstable
changeset 29887 cabac7dfc6214e915908912678ff8e84f5dc7488
parent 29886 3d3b4ac369f2352a48114a8dd73a25da3766e957
child 29888 7ed3a3c0cef18f11b57aa9fcd38e30dc8ffc6c88
push id175
push usergszorc@mozilla.com
push dateWed, 10 Feb 2016 01:24:28 +0000
exchange: set 'treemanifest' param on pushed changegroups too In 5c0fd878779c (treemanifests: set bundle2 part parameter indicating treemanifest, 2016-01-08), I didn't realize I had to set the parameter separately for getbundle and unbundle. Having the parameter there on push allows us to push to an empty repo and have the requirements updated correctly.
mercurial/exchange.py
tests/test-treemanifest.t
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -712,16 +712,18 @@ def _pushb2ctx(pushop, bundler):
             raise ValueError(_('no common changegroup version'))
         version = max(cgversions)
         cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
                                                 pushop.outgoing,
                                                 version=version)
     cgpart = bundler.newpart('changegroup', data=cg)
     if version is not None:
         cgpart.addparam('version', version)
+    if 'treemanifest' in pushop.repo.requirements:
+        cgpart.addparam('treemanifest', '1')
     def handlereply(op):
         """extract addchangegroup returns from server reply"""
         cgreplies = op.records.getreplies(cgpart.id)
         assert len(cgreplies['changegroup']) == 1
         pushop.cgresult = cgreplies['changegroup'][0]['return']
     return handlereply
 
 @b2partsgenerator('phase')
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -307,19 +307,38 @@ Shelving and unshelving should work
   $ hg diff --nodates
   diff -r 708a273da119 dir1/a
   --- a/dir1/a
   +++ b/dir1/a
   @@ -1,1 +1,2 @@
    1
   +foo
 
+Pushing from treemanifest repo to an empty repo makes that a treemanifest repo
+
+  $ cd ..
+  $ hg init empty-repo
+  $ cat << EOF >> empty-repo/.hg/hgrc
+  > [experimental]
+  > changegroup3=yes
+  > EOF
+  $ grep treemanifest empty-repo/.hg/requires
+  [1]
+  $ hg push -R repo -r 0 empty-repo
+  pushing to empty-repo
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 2 changes to 2 files
+  $ grep treemanifest empty-repo/.hg/requires
+  treemanifest
+
 Create deeper repo with tree manifests.
 
-  $ cd ..
   $ hg --config experimental.treemanifest=True init deeprepo
   $ cd deeprepo
 
   $ mkdir a
   $ mkdir b
   $ mkdir b/bar
   $ mkdir b/bar/orange
   $ mkdir b/bar/orange/fly