Mercurial > hg
diff mercurial/wireproto.py @ 37487:68915b9f8e96
wireproto: port listkeys commands to wire protocol v2
Differential Revision: https://phab.mercurial-scm.org/D3181
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 28 Mar 2018 16:00:02 -0700 |
parents | 6847542bb8d7 |
children | 3b99eb028859 |
line wrap: on
line diff
--- a/mercurial/wireproto.py Wed Mar 28 15:44:47 2018 -0700 +++ b/mercurial/wireproto.py Wed Mar 28 16:00:02 2018 -0700 @@ -1024,7 +1024,8 @@ caps = capabilities(repo, proto).data return wireprototypes.bytesresponse('capabilities: %s\n' % caps) -@wireprotocommand('listkeys', 'namespace', permission='pull') +@wireprotocommand('listkeys', 'namespace', permission='pull', + transportpolicy=POLICY_V1_ONLY) def listkeys(repo, proto, namespace): d = sorted(repo.listkeys(encoding.tolocal(namespace)).items()) return wireprototypes.bytesresponse(pushkeymod.encodekeys(d)) @@ -1223,3 +1224,12 @@ nodes = nodes or [] result = b''.join(b'1' if n else b'0' for n in repo.known(nodes)) return wireprototypes.cborresponse(result) + +@wireprotocommand('listkeys', 'namespace', permission='pull', + transportpolicy=POLICY_V2_ONLY) +def listkeysv2(repo, proto, namespace=None): + keys = repo.listkeys(encoding.tolocal(namespace)) + keys = {encoding.fromlocal(k): encoding.fromlocal(v) + for k, v in keys.iteritems()} + + return wireprototypes.cborresponse(keys)