Mercurial > public > mercurial-scm > hg
diff mercurial/bundle2.py @ 20998:93a3c5b58635
bundle2: use reply part to return result of addchangegroup
We now have an official way to return the result of addchangegroup. The tests are
updated to check that the return bundle is properly created. It will be used
when push is bundle2 enabled.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 25 Mar 2014 15:05:11 -0700 |
parents | d7df4b7378ae |
children | 4cae06ae1562 |
line wrap: on
line diff
--- a/mercurial/bundle2.py Fri Apr 04 14:24:11 2014 -0700 +++ b/mercurial/bundle2.py Tue Mar 25 15:05:11 2014 -0700 @@ -558,7 +558,7 @@ yield _pack(_fpayloadsize, 0) @parthandler('changegroup') -def handlechangegroup(op, part): +def handlechangegroup(op, inpart): """apply a changegroup part on the repo This is a very early implementation that will massive rework before being @@ -570,10 +570,21 @@ # we need to make sure we trigger the creation of a transaction object used # for the whole processing scope. op.gettransaction() - data = StringIO.StringIO(part.data) + data = StringIO.StringIO(inpart.data) data.seek(0) cg = changegroup.readbundle(data, 'bundle2part') ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2') op.records.add('changegroup', {'return': ret}) + if op.reply is not None: + # This is definitly not the final form of this + # return. But one need to start somewhere. + op.reply.addpart(part('reply:changegroup', (), + [('in-reply-to', str(inpart.id)), + ('return', '%i' % ret)])) +@parthandler('reply:changegroup') +def handlechangegroup(op, inpart): + p = dict(inpart.advisoryparams) + ret = int(p['return']) + op.records.add('changegroup', {'return': ret}, int(p['in-reply-to']))