[PATCH 2 of 2] exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()

Martin von Zweigbergk martinvonz at google.com
Mon Mar 28 17:59:03 EDT 2016


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1458947608 25200
#      Fri Mar 25 16:13:28 2016 -0700
# Node ID 81830ed82404df76ca15b7f1ec6e4b0518e7a6eb
# Parent  2f99e84dc6a77f890e0821480325da7c86b2ede7
exchange: make _pushb2ctx() look more like _getbundlechangegrouppart()

The functions already have a lot in common, but were structured a
little differently.

diff -r 2f99e84dc6a7 -r 81830ed82404 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')


More information about the Mercurial-devel mailing list