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

login
register
mail settings
Submitter via Mercurial-devel
Date March 28, 2016, 9:59 p.m.
Message ID <81830ed82404df76ca15.1459202343@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/14114/
State Accepted
Headers show

Comments

via Mercurial-devel - March 28, 2016, 9:59 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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.
Pierre-Yves David - March 29, 2016, 2:20 a.m.
On 03/28/2016 02:59 PM, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@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.

Sure why not.

Pushed, thanks.

Patch

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')