Show More
@@ -0,0 +1,125 b'' | |||||
|
1 | $ . $TESTDIR/wireprotohelpers.sh | |||
|
2 | ||||
|
3 | $ hg init server | |||
|
4 | $ enablehttpv2 server | |||
|
5 | $ cd server | |||
|
6 | $ hg debugdrawdag << EOF | |||
|
7 | > C D | |||
|
8 | > |/ | |||
|
9 | > B | |||
|
10 | > | | |||
|
11 | > A | |||
|
12 | > EOF | |||
|
13 | ||||
|
14 | $ hg phase --public -r C | |||
|
15 | $ hg book -r C @ | |||
|
16 | ||||
|
17 | $ hg log -T '{rev}:{node} {desc}\n' | |||
|
18 | 3:be0ef73c17ade3fc89dc41701eb9fc3a91b58282 D | |||
|
19 | 2:26805aba1e600a82e93661149f2313866a221a7b C | |||
|
20 | 1:112478962961147124edd43549aedd1a335e44bf B | |||
|
21 | 0:426bada5c67598ca65036d57d9e4b64b0c1ce7a0 A | |||
|
22 | ||||
|
23 | $ hg serve -p $HGPORT -d --pid-file hg.pid -E error.log | |||
|
24 | $ cat hg.pid > $DAEMON_PIDS | |||
|
25 | ||||
|
26 | Request for namespaces works | |||
|
27 | ||||
|
28 | $ sendhttpv2peer << EOF | |||
|
29 | > command listkeys | |||
|
30 | > namespace namespaces | |||
|
31 | > EOF | |||
|
32 | creating http peer for wire protocol version 2 | |||
|
33 | sending listkeys command | |||
|
34 | s> POST /api/exp-http-v2-0001/ro/listkeys HTTP/1.1\r\n | |||
|
35 | s> Accept-Encoding: identity\r\n | |||
|
36 | s> accept: application/mercurial-exp-framing-0003\r\n | |||
|
37 | s> content-type: application/mercurial-exp-framing-0003\r\n | |||
|
38 | s> content-length: 50\r\n | |||
|
39 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
40 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
41 | s> \r\n | |||
|
42 | s> *\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa1InamespaceJnamespacesDnameHlistkeys | |||
|
43 | s> makefile('rb', None) | |||
|
44 | s> HTTP/1.1 200 OK\r\n | |||
|
45 | s> Server: testing stub value\r\n | |||
|
46 | s> Date: $HTTP_DATE$\r\n | |||
|
47 | s> Content-Type: application/mercurial-exp-framing-0003\r\n | |||
|
48 | s> Transfer-Encoding: chunked\r\n | |||
|
49 | s> \r\n | |||
|
50 | s> 28\r\n | |||
|
51 | s> \x00\x00\x01\x00\x02\x01F | |||
|
52 | s> \xa3Fphases@Ibookmarks@Jnamespaces@ | |||
|
53 | s> \r\n | |||
|
54 | received frame(size=32; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor) | |||
|
55 | s> 0\r\n | |||
|
56 | s> \r\n | |||
|
57 | response: [{b'bookmarks': b'', b'namespaces': b'', b'phases': b''}] | |||
|
58 | ||||
|
59 | Request for phases works | |||
|
60 | ||||
|
61 | $ sendhttpv2peer << EOF | |||
|
62 | > command listkeys | |||
|
63 | > namespace phases | |||
|
64 | > EOF | |||
|
65 | creating http peer for wire protocol version 2 | |||
|
66 | sending listkeys command | |||
|
67 | s> POST /api/exp-http-v2-0001/ro/listkeys HTTP/1.1\r\n | |||
|
68 | s> Accept-Encoding: identity\r\n | |||
|
69 | s> accept: application/mercurial-exp-framing-0003\r\n | |||
|
70 | s> content-type: application/mercurial-exp-framing-0003\r\n | |||
|
71 | s> content-length: 46\r\n | |||
|
72 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
73 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
74 | s> \r\n | |||
|
75 | s> &\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa1InamespaceFphasesDnameHlistkeys | |||
|
76 | s> makefile('rb', None) | |||
|
77 | s> HTTP/1.1 200 OK\r\n | |||
|
78 | s> Server: testing stub value\r\n | |||
|
79 | s> Date: $HTTP_DATE$\r\n | |||
|
80 | s> Content-Type: application/mercurial-exp-framing-0003\r\n | |||
|
81 | s> Transfer-Encoding: chunked\r\n | |||
|
82 | s> \r\n | |||
|
83 | s> 45\r\n | |||
|
84 | s> =\x00\x00\x01\x00\x02\x01F | |||
|
85 | s> \xa2JpublishingDTrueX(be0ef73c17ade3fc89dc41701eb9fc3a91b58282A1 | |||
|
86 | s> \r\n | |||
|
87 | received frame(size=61; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor) | |||
|
88 | s> 0\r\n | |||
|
89 | s> \r\n | |||
|
90 | response: [{b'be0ef73c17ade3fc89dc41701eb9fc3a91b58282': b'1', b'publishing': b'True'}] | |||
|
91 | ||||
|
92 | Request for bookmarks works | |||
|
93 | ||||
|
94 | $ sendhttpv2peer << EOF | |||
|
95 | > command listkeys | |||
|
96 | > namespace bookmarks | |||
|
97 | > EOF | |||
|
98 | creating http peer for wire protocol version 2 | |||
|
99 | sending listkeys command | |||
|
100 | s> POST /api/exp-http-v2-0001/ro/listkeys HTTP/1.1\r\n | |||
|
101 | s> Accept-Encoding: identity\r\n | |||
|
102 | s> accept: application/mercurial-exp-framing-0003\r\n | |||
|
103 | s> content-type: application/mercurial-exp-framing-0003\r\n | |||
|
104 | s> content-length: 49\r\n | |||
|
105 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
106 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
107 | s> \r\n | |||
|
108 | s> )\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa1InamespaceIbookmarksDnameHlistkeys | |||
|
109 | s> makefile('rb', None) | |||
|
110 | s> HTTP/1.1 200 OK\r\n | |||
|
111 | s> Server: testing stub value\r\n | |||
|
112 | s> Date: $HTTP_DATE$\r\n | |||
|
113 | s> Content-Type: application/mercurial-exp-framing-0003\r\n | |||
|
114 | s> Transfer-Encoding: chunked\r\n | |||
|
115 | s> \r\n | |||
|
116 | s> 35\r\n | |||
|
117 | s> -\x00\x00\x01\x00\x02\x01F | |||
|
118 | s> \xa1A@X(26805aba1e600a82e93661149f2313866a221a7b | |||
|
119 | s> \r\n | |||
|
120 | received frame(size=45; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor) | |||
|
121 | s> 0\r\n | |||
|
122 | s> \r\n | |||
|
123 | response: [{b'@': b'26805aba1e600a82e93661149f2313866a221a7b'}] | |||
|
124 | ||||
|
125 | $ cat error.log |
@@ -1702,3 +1702,17 b' The response is a bytestring where each ' | |||||
1702 | corresponding requested node at the same index. |
|
1702 | corresponding requested node at the same index. | |
1703 |
|
1703 | |||
1704 | TODO use a bit array for even more compact response |
|
1704 | TODO use a bit array for even more compact response | |
|
1705 | ||||
|
1706 | listkeys | |||
|
1707 | -------- | |||
|
1708 | ||||
|
1709 | List values in a specified ``pushkey`` namespace. | |||
|
1710 | ||||
|
1711 | The command receives the following arguments: | |||
|
1712 | ||||
|
1713 | namespace | |||
|
1714 | (bytestring) Pushkey namespace to query. | |||
|
1715 | ||||
|
1716 | The response is a map with bytestring keys and values. | |||
|
1717 | ||||
|
1718 | TODO consider using binary to represent nodes in certain pushkey namespaces. |
@@ -1024,7 +1024,8 b' def hello(repo, proto):' | |||||
1024 | caps = capabilities(repo, proto).data |
|
1024 | caps = capabilities(repo, proto).data | |
1025 | return wireprototypes.bytesresponse('capabilities: %s\n' % caps) |
|
1025 | return wireprototypes.bytesresponse('capabilities: %s\n' % caps) | |
1026 |
|
1026 | |||
1027 |
@wireprotocommand('listkeys', 'namespace', permission='pull' |
|
1027 | @wireprotocommand('listkeys', 'namespace', permission='pull', | |
|
1028 | transportpolicy=POLICY_V1_ONLY) | |||
1028 | def listkeys(repo, proto, namespace): |
|
1029 | def listkeys(repo, proto, namespace): | |
1029 | d = sorted(repo.listkeys(encoding.tolocal(namespace)).items()) |
|
1030 | d = sorted(repo.listkeys(encoding.tolocal(namespace)).items()) | |
1030 | return wireprototypes.bytesresponse(pushkeymod.encodekeys(d)) |
|
1031 | return wireprototypes.bytesresponse(pushkeymod.encodekeys(d)) | |
@@ -1223,3 +1224,12 b' def knownv2(repo, proto, nodes=None):' | |||||
1223 | nodes = nodes or [] |
|
1224 | nodes = nodes or [] | |
1224 | result = b''.join(b'1' if n else b'0' for n in repo.known(nodes)) |
|
1225 | result = b''.join(b'1' if n else b'0' for n in repo.known(nodes)) | |
1225 | return wireprototypes.cborresponse(result) |
|
1226 | return wireprototypes.cborresponse(result) | |
|
1227 | ||||
|
1228 | @wireprotocommand('listkeys', 'namespace', permission='pull', | |||
|
1229 | transportpolicy=POLICY_V2_ONLY) | |||
|
1230 | def listkeysv2(repo, proto, namespace=None): | |||
|
1231 | keys = repo.listkeys(encoding.tolocal(namespace)) | |||
|
1232 | keys = {encoding.fromlocal(k): encoding.fromlocal(v) | |||
|
1233 | for k, v in keys.iteritems()} | |||
|
1234 | ||||
|
1235 | return wireprototypes.cborresponse(keys) |
@@ -509,13 +509,11 b' Interleaved requests to "multirequest" a' | |||||
509 | s> Content-Type: application/mercurial-exp-framing-0003\r\n |
|
509 | s> Content-Type: application/mercurial-exp-framing-0003\r\n | |
510 | s> Transfer-Encoding: chunked\r\n |
|
510 | s> Transfer-Encoding: chunked\r\n | |
511 | s> \r\n |
|
511 | s> \r\n | |
512 |
s> 2 |
|
512 | s> 28\r\n | |
513 |
s> |
|
513 | s> \x00\x00\x03\x00\x02\x01F\xa3Fphases@Ibookmarks@Jnamespaces@ | |
514 | s> namespaces\t\n |
|
|||
515 | s> phases\t |
|
|||
516 |
|
|
514 | s> \r\n | |
517 |
s> |
|
515 | s> 9\r\n | |
518 |
s> \x0 |
|
516 | s> \x01\x00\x00\x01\x00\x02\x00F\xa0 | |
519 | s> \r\n |
|
517 | s> \r\n | |
520 | s> 0\r\n |
|
518 | s> 0\r\n | |
521 | s> \r\n |
|
519 | s> \r\n |
General Comments 0
You need to be logged in to leave comments.
Login now