exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()
authorMartin von Zweigbergk <martinvonz@google.com>
Fri, 25 Mar 2016 16:13:28 -0700
changeset 28668 07f1fbf1f758
parent 28667 e7bf227e33a5
child 28669 c4b727795d6a
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart() The functions already have a lot in common, but were structured a little differently.
mercurial/exchange.py
--- 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')