# HG changeset patch # User Martin von Zweigbergk # Date 2017-06-22 21:04:13 # Node ID d765ad56081f8d2ad2398f6c0514a39e69f0b8b9 # Parent 52c7060b707ab199657c21af670199fb6325cf35 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 @@ def writebundle(ui, cg, filename, bundle # 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 @@ def unbundle(ui, repo, fname1, *fnames, 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 @@ def _pullbundle2(pullop): 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']: