Mercurial > hg-stable
changeset 33042:3e102a8dd52c
bundle2: record changegroup data in 'op.records' (API)
When adding support for bundling and unbundling phases, it will be
useful to have the list of added changesets. To do that, we return the
list from changegroup.apply().
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 16 Jun 2017 16:56:16 -0700 |
parents | b482d80e041b |
children | e8c8d81eb864 |
files | mercurial/bundle2.py mercurial/changegroup.py mercurial/commands.py mercurial/exchange.py |
diffstat | 4 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Thu Jun 22 10:15:15 2017 -0700 +++ b/mercurial/bundle2.py Fri Jun 16 16:56:16 2017 -0700 @@ -1492,9 +1492,12 @@ op.repo.requirements.add('treemanifest') op.repo._applyopenerreqs() op.repo._writerequirements() - ret = cg.apply(op.repo, tr, 'bundle2', 'bundle2', - expectedtotal=nbchangesets) - op.records.add('changegroup', {'return': ret}) + ret, addednodes = cg.apply(op.repo, tr, 'bundle2', 'bundle2', + expectedtotal=nbchangesets) + op.records.add('changegroup', { + 'return': ret, + 'addednodes': addednodes, + }) if op.reply is not None: # This is definitely not the final form of this # return. But one need to start somewhere. @@ -1557,8 +1560,11 @@ if not isinstance(cg, changegroup.cg1unpacker): raise error.Abort(_('%s: not a bundle version 1.0') % util.hidepassword(raw_url)) - ret = cg.apply(op.repo, tr, 'bundle2', 'bundle2') - op.records.add('changegroup', {'return': ret}) + ret, addednodes = cg.apply(op.repo, tr, 'bundle2', 'bundle2') + op.records.add('changegroup', { + 'return': ret, + 'addednodes': addednodes, + }) if op.reply is not None: # This is definitely not the final form of this # return. But one need to start somewhere.
--- a/mercurial/changegroup.py Thu Jun 22 10:15:15 2017 -0700 +++ b/mercurial/changegroup.py Fri Jun 16 16:56:16 2017 -0700 @@ -426,9 +426,10 @@ repo.ui.flush() # never return 0 here: if deltaheads < 0: - return deltaheads - 1 + ret = deltaheads - 1 else: - return deltaheads + 1 + ret = deltaheads + 1 + return ret, added class cg2unpacker(cg1unpacker): """Unpacker for cg2 streams.
--- a/mercurial/commands.py Thu Jun 22 10:15:15 2017 -0700 +++ b/mercurial/commands.py Fri Jun 16 16:56:16 2017 -0700 @@ -5218,7 +5218,7 @@ else: txnname = 'unbundle\n%s' % util.hidepassword(url) with repo.transaction(txnname) as tr: - modheads = gen.apply(repo, tr, 'unbundle', url) + modheads, addednodes = gen.apply(repo, tr, 'unbundle', url) return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
--- a/mercurial/exchange.py Thu Jun 22 10:15:15 2017 -0700 +++ b/mercurial/exchange.py Fri Jun 16 16:56:16 2017 -0700 @@ -1449,7 +1449,8 @@ "changegroupsubset.")) else: cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull') - pullop.cgresult = cg.apply(pullop.repo, tr, 'pull', pullop.remote.url()) + pullop.cgresult, addednodes = cg.apply(pullop.repo, tr, 'pull', + pullop.remote.url()) def _pullphase(pullop): # Get remote phases data from remote @@ -1737,7 +1738,7 @@ # legacy case: bundle1 (changegroup 01) txnname = "\n".join([source, util.hidepassword(url)]) with repo.lock(), repo.transaction(txnname) as tr: - r = cg.apply(repo, tr, source, url) + r, addednodes = cg.apply(repo, tr, source, url) else: r = None try: