bundle: make combinechangegroupresults() take a bundleoperation
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 22 Jun 2017 14:04:13 -0700
changeset 33037 d765ad56081f
parent 33036 52c7060b707a
child 33038 f0efd2bffe1e
bundle: make combinechangegroupresults() take a bundleoperation Both callers have a bundleoperation. Passing it in lets us share a bit more code.
mercurial/bundle2.py
mercurial/commands.py
mercurial/exchange.py
--- a/mercurial/bundle2.py	Thu Jun 22 13:58:20 2017 -0700
+++ b/mercurial/bundle2.py	Thu Jun 22 14:04:13 2017 -0700
@@ -1478,8 +1478,10 @@
     # in case of sshrepo because we don't know the end of the stream
     return changegroup.writechunks(ui, chunkiter, filename, vfs=vfs)
 
-def combinechangegroupresults(results):
+def combinechangegroupresults(op):
     """logic to combine 0 or more addchangegroup results into one"""
+    results = [r.get('return', 0)
+               for r in op.records['changegroup']]
     changedheads = 0
     result = 1
     for ret in results:
--- a/mercurial/commands.py	Thu Jun 22 13:58:20 2017 -0700
+++ b/mercurial/commands.py	Thu Jun 22 14:04:13 2017 -0700
@@ -5214,9 +5214,7 @@
                             hint=_("see https://mercurial-scm.org/"
                                    "wiki/BundleFeature for more "
                                    "information"))
-                changes = [r.get('return', 0)
-                           for r in op.records['changegroup']]
-                modheads = bundle2.combinechangegroupresults(changes)
+                modheads = bundle2.combinechangegroupresults(op)
             else:
                 txnname = 'unbundle\n%s' % util.hidepassword(url)
                 with repo.transaction(txnname) as tr:
--- a/mercurial/exchange.py	Thu Jun 22 13:58:20 2017 -0700
+++ b/mercurial/exchange.py	Thu Jun 22 14:04:13 2017 -0700
@@ -1397,8 +1397,7 @@
         raise error.Abort(_('missing support for %s') % exc)
 
     if pullop.fetch:
-        results = [cg['return'] for cg in op.records['changegroup']]
-        pullop.cgresult = bundle2.combinechangegroupresults(results)
+        pullop.cgresult = bundle2.combinechangegroupresults(op)
 
     # processing phases change
     for namespace, value in op.records['listkeys']: