changeset 28668:07f1fbf1f758

exchange: make _pushb2ctx() look more like _getbundlechangegrouppart() The functions already have a lot in common, but were structured a little differently.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 25 Mar 2016 16:13:28 -0700
parents e7bf227e33a5
children c4b727795d6a
files mercurial/exchange.py
diffstat 1 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Fri Mar 25 16:01:40 2016 -0700
+++ b/mercurial/exchange.py	Fri Mar 25 16:13:28 2016 -0700
@@ -701,23 +701,20 @@
     _pushb2ctxcheckheads(pushop, bundler)
 
     b2caps = bundle2.bundle2caps(pushop.remote)
-    version = None
+    version = '01'
     cgversions = b2caps.get('changegroup')
-    if not cgversions:  # 3.1 and 3.2 ship with an empty value
-        cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
-                                                pushop.outgoing)
-    else:
+    if cgversions:  # 3.1 and 3.2 ship with an empty value
         cgversions = [v for v in cgversions
                       if v in changegroup.supportedoutgoingversions(
                           pushop.repo)]
         if not cgversions:
             raise ValueError(_('no common changegroup version'))
         version = max(cgversions)
-        cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
-                                                pushop.outgoing,
-                                                version=version)
+    cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push',
+                                            pushop.outgoing,
+                                            version=version)
     cgpart = bundler.newpart('changegroup', data=cg)
-    if version is not None:
+    if cgversions:
         cgpart.addparam('version', version)
     if 'treemanifest' in pushop.repo.requirements:
         cgpart.addparam('treemanifest', '1')