getbundle: have a single getchangegroupraw call site
authorPierre-Yves David <pierre-yves.david@fb.com>
Sun, 07 Jun 2015 15:47:07 -0700
changeset 25503 1b7853a1f04e
parent 25502 bd41c19383db
child 25504 60f4e7022ffe
getbundle: have a single getchangegroupraw call site Having a single call site will simplify the code and help with coming refactoring.
mercurial/exchange.py
--- a/mercurial/exchange.py	Wed May 27 22:25:51 2015 -0700
+++ b/mercurial/exchange.py	Sun Jun 07 15:47:07 2015 -0700
@@ -1288,19 +1288,16 @@
         # build changegroup bundle here.
         version = None
         cgversions = b2caps.get('changegroup')
-        if not cgversions:  # 3.1 and 3.2 ship with an empty value
-            cg = changegroup.getchangegroupraw(repo, source, heads=heads,
-                                               common=common,
-                                               bundlecaps=bundlecaps)
-        else:
+        getcgkwargs = {}
+        if cgversions:  # 3.1 and 3.2 ship with an empty value
             cgversions = [v for v in cgversions if v in changegroup.packermap]
             if not cgversions:
                 raise ValueError(_('no common changegroup version'))
-            version = max(cgversions)
-            cg = changegroup.getchangegroupraw(repo, source, heads=heads,
-                                               common=common,
-                                               bundlecaps=bundlecaps,
-                                               version=version)
+            version = getcgkwargs['version'] = max(cgversions)
+        cg = changegroup.getchangegroupraw(repo, source, heads=heads,
+                                           common=common,
+                                           bundlecaps=bundlecaps,
+                                           **getcgkwargs)
 
     if cg:
         part = bundler.newpart('changegroup', data=cg)