Show More
@@ -0,0 +1,72 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 up B | |||
|
15 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
16 | $ hg branch branch1 | |||
|
17 | marked working directory as branch branch1 | |||
|
18 | (branches are permanent and global, did you want a bookmark?) | |||
|
19 | $ echo b1 > foo | |||
|
20 | $ hg -q commit -A -m 'branch 1' | |||
|
21 | $ hg up B | |||
|
22 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |||
|
23 | $ hg branch branch2 | |||
|
24 | marked working directory as branch branch2 | |||
|
25 | $ echo b2 > foo | |||
|
26 | $ hg -q commit -A -m 'branch 2' | |||
|
27 | ||||
|
28 | $ hg log -T '{rev}:{node} {branch} {desc}\n' | |||
|
29 | 5:224161c7589aa48fa83a48feff5e95b56ae327fc branch2 branch 2 | |||
|
30 | 4:b5faacdfd2633768cb3152336cc0953381266688 branch1 branch 1 | |||
|
31 | 3:be0ef73c17ade3fc89dc41701eb9fc3a91b58282 default D | |||
|
32 | 2:26805aba1e600a82e93661149f2313866a221a7b default C | |||
|
33 | 1:112478962961147124edd43549aedd1a335e44bf default B | |||
|
34 | 0:426bada5c67598ca65036d57d9e4b64b0c1ce7a0 default A | |||
|
35 | ||||
|
36 | $ hg serve -p $HGPORT -d --pid-file hg.pid -E error.log | |||
|
37 | $ cat hg.pid > $DAEMON_PIDS | |||
|
38 | ||||
|
39 | No arguments returns something reasonable | |||
|
40 | ||||
|
41 | $ sendhttpv2peer << EOF | |||
|
42 | > command branchmap | |||
|
43 | > EOF | |||
|
44 | creating http peer for wire protocol version 2 | |||
|
45 | sending branchmap command | |||
|
46 | s> POST /api/exp-http-v2-0001/ro/branchmap HTTP/1.1\r\n | |||
|
47 | s> Accept-Encoding: identity\r\n | |||
|
48 | s> accept: application/mercurial-exp-framing-0003\r\n | |||
|
49 | s> content-type: application/mercurial-exp-framing-0003\r\n | |||
|
50 | s> content-length: 24\r\n | |||
|
51 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
52 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
53 | s> \r\n | |||
|
54 | s> \x10\x00\x00\x01\x00\x01\x01\x11\xa1DnameIbranchmap | |||
|
55 | s> makefile('rb', None) | |||
|
56 | s> HTTP/1.1 200 OK\r\n | |||
|
57 | s> Server: testing stub value\r\n | |||
|
58 | s> Date: $HTTP_DATE$\r\n | |||
|
59 | s> Content-Type: application/mercurial-exp-framing-0003\r\n | |||
|
60 | s> Transfer-Encoding: chunked\r\n | |||
|
61 | s> \r\n | |||
|
62 | s> 78\r\n | |||
|
63 | s> p\x00\x00\x01\x00\x02\x01F | |||
|
64 | s> \xa3Gbranch1\x81T\xb5\xfa\xac\xdf\xd2c7h\xcb1R3l\xc0\x953\x81&f\x88Gbranch2\x81T"Aa\xc7X\x9a\xa4\x8f\xa8:H\xfe\xff^\x95\xb5j\xe3\'\xfcGdefault\x82T&\x80Z\xba\x1e`\n | |||
|
65 | s> \x82\xe96a\x14\x9f#\x13\x86j"\x1a{T\xbe\x0e\xf7<\x17\xad\xe3\xfc\x89\xdcAp\x1e\xb9\xfc:\x91\xb5\x82\x82 | |||
|
66 | s> \r\n | |||
|
67 | received frame(size=112; request=1; stream=2; streamflags=stream-begin; type=bytes-response; flags=eos|cbor) | |||
|
68 | s> 0\r\n | |||
|
69 | s> \r\n | |||
|
70 | response: [{b'branch1': [b'\xb5\xfa\xac\xdf\xd2c7h\xcb1R3l\xc0\x953\x81&f\x88'], b'branch2': [b'"Aa\xc7X\x9a\xa4\x8f\xa8:H\xfe\xff^\x95\xb5j\xe3\'\xfc'], b'default': [b'&\x80Z\xba\x1e`\n\x82\xe96a\x14\x9f#\x13\x86j"\x1a{', b'\xbe\x0e\xf7<\x17\xad\xe3\xfc\x89\xdcAp\x1e\xb9\xfc:\x91\xb5\x82\x82']}] | |||
|
71 | ||||
|
72 | $ cat error.log |
@@ -1670,6 +1670,16 b' format: each command defines its own res' | |||||
1670 | TODO require node type be specified, as N bytes of binary node value |
|
1670 | TODO require node type be specified, as N bytes of binary node value | |
1671 | could be ambiguous once SHA-1 is replaced. |
|
1671 | could be ambiguous once SHA-1 is replaced. | |
1672 |
|
1672 | |||
|
1673 | branchmap | |||
|
1674 | --------- | |||
|
1675 | ||||
|
1676 | Obtain heads in named branches. | |||
|
1677 | ||||
|
1678 | Receives no arguments. | |||
|
1679 | ||||
|
1680 | The response is a map with bytestring keys defining the branch name. | |||
|
1681 | Values are arrays of bytestring defining raw changeset nodes. | |||
|
1682 | ||||
1673 | heads |
|
1683 | heads | |
1674 | ----- |
|
1684 | ----- | |
1675 |
|
1685 |
@@ -828,7 +828,8 b' def between(repo, proto, pairs):' | |||||
828 |
|
828 | |||
829 | return wireprototypes.bytesresponse(''.join(r)) |
|
829 | return wireprototypes.bytesresponse(''.join(r)) | |
830 |
|
830 | |||
831 |
@wireprotocommand('branchmap', permission='pull' |
|
831 | @wireprotocommand('branchmap', permission='pull', | |
|
832 | transportpolicy=POLICY_V1_ONLY) | |||
832 | def branchmap(repo, proto): |
|
833 | def branchmap(repo, proto): | |
833 | branchmap = repo.branchmap() |
|
834 | branchmap = repo.branchmap() | |
834 | heads = [] |
|
835 | heads = [] | |
@@ -1210,6 +1211,14 b' def unbundle(repo, proto, heads):' | |||||
1210 |
|
1211 | |||
1211 | # Wire protocol version 2 commands only past this point. |
|
1212 | # Wire protocol version 2 commands only past this point. | |
1212 |
|
1213 | |||
|
1214 | @wireprotocommand('branchmap', permission='pull', | |||
|
1215 | transportpolicy=POLICY_V2_ONLY) | |||
|
1216 | def branchmapv2(repo, proto): | |||
|
1217 | branchmap = {encoding.fromlocal(k): v | |||
|
1218 | for k, v in repo.branchmap().iteritems()} | |||
|
1219 | ||||
|
1220 | return wireprototypes.cborresponse(branchmap) | |||
|
1221 | ||||
1213 | @wireprotocommand('heads', args='publiconly', permission='pull', |
|
1222 | @wireprotocommand('heads', args='publiconly', permission='pull', | |
1214 | transportpolicy=POLICY_V2_ONLY) |
|
1223 | transportpolicy=POLICY_V2_ONLY) | |
1215 | def headsv2(repo, proto, publiconly=False): |
|
1224 | def headsv2(repo, proto, publiconly=False): |
General Comments 0
You need to be logged in to leave comments.
Login now