[PATCH 03 of 10] bundle: make combinechangegroupresults() take a bundleoperation

Martin von Zweigbergk martinvonz at google.com
Sat Jun 24 15:38:31 UTC 2017


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1498165453 25200
#      Thu Jun 22 14:04:13 2017 -0700
# Node ID 601a13f9ae1e94fa76fda7b9819c065c31771325
# Parent  5067327cec7040b82dc87d093545532e28869763
bundle: make combinechangegroupresults() take a bundleoperation

Both callers have a bundleoperation. Passing it in lets us share a bit
more code.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- 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:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- 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:
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- 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']:



More information about the Mercurial-devel mailing list