diff mercurial/wireproto.py @ 37538:89fed81bbb6c

wireproto: port lookup to wire protocol v2 This is pretty straightforward. We don't yet handle errors because we don't have an error handling mechanism in place yet. I'm also tempted to fold this into `known`. We'll come back to this later. Differential Revision: https://phab.mercurial-scm.org/D3205
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 06 Apr 2018 17:48:07 -0700
parents be5d4749edc0
children 4a0d58d6faba
line wrap: on
line diff
--- a/mercurial/wireproto.py	Fri Apr 06 17:39:40 2018 -0700
+++ b/mercurial/wireproto.py	Fri Apr 06 17:48:07 2018 -0700
@@ -1120,7 +1120,8 @@
     d = sorted(repo.listkeys(encoding.tolocal(namespace)).items())
     return wireprototypes.bytesresponse(pushkeymod.encodekeys(d))
 
-@wireprotocommand('lookup', 'key', permission='pull')
+@wireprotocommand('lookup', 'key', permission='pull',
+                  transportpolicy=POLICY_V1_ONLY)
 def lookup(repo, proto, key):
     try:
         k = encoding.tolocal(key)
@@ -1378,6 +1379,20 @@
 
     return wireprototypes.cborresponse(keys)
 
+@wireprotocommand('lookup',
+                  args={
+                      'key': b'foo',
+                  },
+                  permission='pull',
+                  transportpolicy=POLICY_V2_ONLY)
+def lookupv2(repo, proto, key):
+    key = encoding.tolocal(key)
+
+    # TODO handle exception.
+    node = repo.lookup(key)
+
+    return wireprototypes.cborresponse(node)
+
 @wireprotocommand('pushkey',
                   args={
                       'namespace': b'ns',