Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireproto.py @ 37537:be5d4749edc0
wireproto: port pushkey command to wire protocol version 2
It doesn't do output redirection yet. And I'd love to generally overhaul
the pushkey protocol for wire protocol version 2. But this will be a bit
of effort. Let's do it as a follow-up.
Differential Revision: https://phab.mercurial-scm.org/D3204
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 06 Apr 2018 17:39:40 -0700 |
parents | 2003da12f49b |
children | 89fed81bbb6c |
line wrap: on
line diff
--- a/mercurial/wireproto.py Fri Apr 06 17:21:16 2018 -0700 +++ b/mercurial/wireproto.py Fri Apr 06 17:39:40 2018 -0700 @@ -1145,7 +1145,8 @@ proto._protocaps = set(caps.split(' ')) return wireprototypes.bytesresponse('OK') -@wireprotocommand('pushkey', 'namespace key old new', permission='push') +@wireprotocommand('pushkey', 'namespace key old new', permission='push', + transportpolicy=POLICY_V1_ONLY) def pushkey(repo, proto, namespace, key, old, new): # compatibility with pre-1.8 clients which were accidentally # sending raw binary nodes rather than utf-8-encoded hex @@ -1376,3 +1377,21 @@ for k, v in keys.iteritems()} return wireprototypes.cborresponse(keys) + +@wireprotocommand('pushkey', + args={ + 'namespace': b'ns', + 'key': b'key', + 'old': b'old', + 'new': b'new', + }, + permission='push', + transportpolicy=POLICY_V2_ONLY) +def pushkeyv2(repo, proto, namespace, key, old, new): + # TODO handle ui output redirection + r = repo.pushkey(encoding.tolocal(namespace), + encoding.tolocal(key), + encoding.tolocal(old), + encoding.tolocal(new)) + + return wireprototypes.cborresponse(r)