##// END OF EJS Templates
wireproto: port lookup to wire protocol v2...
Gregory Szorc -
r37556:89fed81b default
parent child Browse files
Show More
@@ -0,0 +1,55 b''
1 $ . $TESTDIR/wireprotohelpers.sh
2
3 $ hg init server
4 $ enablehttpv2 server
5 $ cd server
6 $ cat >> .hg/hgrc << EOF
7 > [web]
8 > push_ssl = false
9 > allow-push = *
10 > EOF
11 $ hg debugdrawdag << EOF
12 > C D
13 > |/
14 > B
15 > |
16 > A
17 > EOF
18
19 $ hg serve -p $HGPORT -d --pid-file hg.pid -E error.log
20 $ cat hg.pid > $DAEMON_PIDS
21
22 lookup for known node works
23
24 $ sendhttpv2peer << EOF
25 > command lookup
26 > key 426bada5c67598ca65036d57d9e4b64b0c1ce7a0
27 > EOF
28 creating http peer for wire protocol version 2
29 sending lookup command
30 s> *\r\n (glob)
31 s> Accept-Encoding: identity\r\n
32 s> accept: application/mercurial-exp-framing-0003\r\n
33 s> content-type: application/mercurial-exp-framing-0003\r\n
34 s> content-length: 73\r\n
35 s> host: $LOCALIP:$HGPORT\r\n (glob)
36 s> user-agent: Mercurial debugwireproto\r\n
37 s> \r\n
38 s> A\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa1CkeyX(426bada5c67598ca65036d57d9e4b64b0c1ce7a0DnameFlookup
39 s> makefile('rb', None)
40 s> HTTP/1.1 200 OK\r\n
41 s> Server: testing stub value\r\n
42 s> Date: $HTTP_DATE$\r\n
43 s> Content-Type: application/mercurial-exp-framing-0003\r\n
44 s> Transfer-Encoding: chunked\r\n
45 s> \r\n
46 s> 1d\r\n
47 s> *\x00\x01\x00\x02\x01F (glob)
48 s> TBk\xad\xa5\xc6u\x98\xcae\x03mW\xd9\xe4\xb6K\x0c\x1c\xe7\xa0
49 s> \r\n
50 received frame(size=*; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor) (glob)
51 s> 0\r\n
52 s> \r\n
53 response: [b'Bk\xad\xa5\xc6u\x98\xcae\x03mW\xd9\xe4\xb6K\x0c\x1c\xe7\xa0']
54
55 $ cat error.log
@@ -1778,6 +1778,21 b' The response is a map with bytestring ke'
1778
1778
1779 TODO consider using binary to represent nodes in certain pushkey namespaces.
1779 TODO consider using binary to represent nodes in certain pushkey namespaces.
1780
1780
1781 lookup
1782 ------
1783
1784 Try to resolve a value to a changeset revision.
1785
1786 Unlike ``known`` which operates on changeset nodes, lookup operates on
1787 node fragments and other names that a user may use.
1788
1789 The command receives the following arguments:
1790
1791 key
1792 (bytestring) Value to try to resolve.
1793
1794 On success, returns a bytestring containing the resolved node.
1795
1781 pushkey
1796 pushkey
1782 -------
1797 -------
1783
1798
@@ -1120,7 +1120,8 b' def listkeys(repo, proto, namespace):'
1120 d = sorted(repo.listkeys(encoding.tolocal(namespace)).items())
1120 d = sorted(repo.listkeys(encoding.tolocal(namespace)).items())
1121 return wireprototypes.bytesresponse(pushkeymod.encodekeys(d))
1121 return wireprototypes.bytesresponse(pushkeymod.encodekeys(d))
1122
1122
1123 @wireprotocommand('lookup', 'key', permission='pull')
1123 @wireprotocommand('lookup', 'key', permission='pull',
1124 transportpolicy=POLICY_V1_ONLY)
1124 def lookup(repo, proto, key):
1125 def lookup(repo, proto, key):
1125 try:
1126 try:
1126 k = encoding.tolocal(key)
1127 k = encoding.tolocal(key)
@@ -1378,6 +1379,20 b' def listkeysv2(repo, proto, namespace=No'
1378
1379
1379 return wireprototypes.cborresponse(keys)
1380 return wireprototypes.cborresponse(keys)
1380
1381
1382 @wireprotocommand('lookup',
1383 args={
1384 'key': b'foo',
1385 },
1386 permission='pull',
1387 transportpolicy=POLICY_V2_ONLY)
1388 def lookupv2(repo, proto, key):
1389 key = encoding.tolocal(key)
1390
1391 # TODO handle exception.
1392 node = repo.lookup(key)
1393
1394 return wireprototypes.cborresponse(node)
1395
1381 @wireprotocommand('pushkey',
1396 @wireprotocommand('pushkey',
1382 args={
1397 args={
1383 'namespace': b'ns',
1398 'namespace': b'ns',
@@ -30,11 +30,11 b' capabilities request returns an array of'
30 s> \r\n
30 s> \r\n
31 s> *\r\n (glob)
31 s> *\r\n (glob)
32 s> *\x00\x01\x00\x02\x01F (glob)
32 s> *\x00\x01\x00\x02\x01F (glob)
33 s> \xa2Hcommands\xa9Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyFlegacyKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpullHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullHunbundle\xa2Dargs\xa1EheadsFlegacyKpermissions\x81DpushIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullIgetbundle\xa2Dargs\xa1A*FlegacyKpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x82\xa1DnameDzstd\xa1DnameDzlib
33 s> \xa2Hcommands\xa9Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullHunbundle\xa2Dargs\xa1EheadsFlegacyKpermissions\x81DpushIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullIgetbundle\xa2Dargs\xa1A*FlegacyKpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x82\xa1DnameDzstd\xa1DnameDzlib
34 s> \r\n
34 s> \r\n
35 received frame(size=*; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor) (glob)
35 received frame(size=*; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor) (glob)
36 s> 0\r\n
36 s> 0\r\n
37 s> \r\n
37 s> \r\n
38 response: [{b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, b'permissions': [b'pull']}, b'getbundle': {b'args': {b'*': b'legacy'}, b'permissions': [b'pull']}, b'heads': {b'args': {b'publiconly': False}, b'permissions': [b'pull']}, b'known': {b'args': {b'nodes': [b'deadbeef']}, b'permissions': [b'pull']}, b'listkeys': {b'args': {b'namespace': b'ns'}, b'permissions': [b'pull']}, b'lookup': {b'args': {b'key': b'legacy'}, b'permissions': [b'pull']}, b'pushkey': {b'args': {b'key': b'key', b'namespace': b'ns', b'new': b'new', b'old': b'old'}, b'permissions': [b'pull']}, b'unbundle': {b'args': {b'heads': b'legacy'}, b'permissions': [b'push']}}, b'compression': [{b'name': b'zstd'}, {b'name': b'zlib'}]}]
38 response: [{b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, b'permissions': [b'pull']}, b'getbundle': {b'args': {b'*': b'legacy'}, b'permissions': [b'pull']}, b'heads': {b'args': {b'publiconly': False}, b'permissions': [b'pull']}, b'known': {b'args': {b'nodes': [b'deadbeef']}, b'permissions': [b'pull']}, b'listkeys': {b'args': {b'namespace': b'ns'}, b'permissions': [b'pull']}, b'lookup': {b'args': {b'key': b'foo'}, b'permissions': [b'pull']}, b'pushkey': {b'args': {b'key': b'key', b'namespace': b'ns', b'new': b'new', b'old': b'old'}, b'permissions': [b'push']}, b'unbundle': {b'args': {b'heads': b'legacy'}, b'permissions': [b'push']}}, b'compression': [{b'name': b'zstd'}, {b'name': b'zlib'}]}]
39
39
40 $ cat error.log
40 $ cat error.log
General Comments 0
You need to be logged in to leave comments. Login now