# HG changeset patch # User Martin von Zweigbergk # Date 1498172347 25200 # Node ID f0efd2bffe1e493b7833519f1e93142837f7b2d6 # Parent d765ad56081f8d2ad2398f6c0514a39e69f0b8b9 bundle: extract _processchangegroup() method The new method applies the changegroup and fills in op.records, sharing a little bit of code between the two callers. We'll add another caller soon. diff -r d765ad56081f -r f0efd2bffe1e mercurial/bundle2.py --- a/mercurial/bundle2.py Thu Jun 22 14:04:13 2017 -0700 +++ b/mercurial/bundle2.py Thu Jun 22 15:59:07 2017 -0700 @@ -395,6 +395,14 @@ return op +def _processchangegroup(op, cg, tr, source, url, **kwargs): + ret, addednodes = cg.apply(op.repo, tr, source, url, **kwargs) + op.records.add('changegroup', { + 'return': ret, + 'addednodes': addednodes, + }) + return ret + def _processpart(op, part): """process a single part from a bundle @@ -1524,12 +1532,8 @@ op.repo.requirements.add('treemanifest') op.repo._applyopenerreqs() op.repo._writerequirements() - ret, addednodes = cg.apply(op.repo, tr, 'bundle2', 'bundle2', - expectedtotal=nbchangesets) - op.records.add('changegroup', { - 'return': ret, - 'addednodes': addednodes, - }) + ret = _processchangegroup(op, cg, tr, 'bundle2', 'bundle2', + expectedtotal=nbchangesets) if op.reply is not None: # This is definitely not the final form of this # return. But one need to start somewhere. @@ -1592,11 +1596,7 @@ if not isinstance(cg, changegroup.cg1unpacker): raise error.Abort(_('%s: not a bundle version 1.0') % util.hidepassword(raw_url)) - ret, addednodes = cg.apply(op.repo, tr, 'bundle2', 'bundle2') - op.records.add('changegroup', { - 'return': ret, - 'addednodes': addednodes, - }) + ret = _processchangegroup(op, cg, tr, 'bundle2', 'bundle2') if op.reply is not None: # This is definitely not the final form of this # return. But one need to start somewhere.