Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bundle2.py @ 21660:e87d2a12d41b
bundle2: add ``pushkey`` support
After ``listkeys`` we can now include ``pushkey`` request in a bundle2. The part
uses a very simple scheme closest as possible to the current wireproto command
for ``pushkey``. We may eventually decide for a more sophisticated part format
before the protocol becomes final.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 27 May 2014 16:32:50 -0700 |
parents | 35095f332846 |
children | b8bd97085ec9 |
line wrap: on
line diff
--- a/mercurial/bundle2.py Thu May 29 15:23:25 2014 -0700 +++ b/mercurial/bundle2.py Tue May 27 16:32:50 2014 -0700 @@ -868,3 +868,29 @@ namespace = inpart.params['namespace'] r = pushkey.decodekeys(inpart.read()) op.records.add('listkeys', (namespace, r)) + +@parthandler('b2x:pushkey', ('namespace', 'key', 'old', 'new')) +def handlepushkey(op, inpart): + """process a pushkey request""" + dec = pushkey.decode + namespace = dec(inpart.params['namespace']) + key = dec(inpart.params['key']) + old = dec(inpart.params['old']) + new = dec(inpart.params['new']) + ret = op.repo.pushkey(namespace, key, old, new) + record = {'namespace': namespace, + 'key': key, + 'old': old, + 'new': new} + op.records.add('pushkey', record) + if op.reply is not None: + rpart = op.reply.newpart('b2x:reply:pushkey') + rpart.addparam('in-reply-to', str(inpart.id), mandatory=False) + rpart.addparam('return', '%i' % ret, mandatory=False) + +@parthandler('b2x:reply:pushkey', ('return', 'in-reply-to')) +def handlepushkeyreply(op, inpart): + """retrieve the result of a pushkey request""" + ret = int(inpart.params['return']) + partid = int(inpart.params['in-reply-to']) + op.records.add('pushkey', {'return': ret}, partid)