changeset 33820:d765ad56081f

bundle: make combinechangegroupresults() take a bundleoperation Both callers have a bundleoperation. Passing it in lets us share a bit more code.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 22 Jun 2017 14:04:13 -0700
parents 52c7060b707a
children f0efd2bffe1e
files mercurial/bundle2.py mercurial/commands.py mercurial/exchange.py
diffstat 3 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -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
+++ b/mercurial/commands.py
@@ -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
+++ b/mercurial/exchange.py
@@ -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']: