Show More
This diff has been collapsed as it changes many lines, (601 lines changed) Show them Hide them | |||||
@@ -0,0 +1,601 b'' | |||||
|
1 | $ . $TESTDIR/wireprotohelpers.sh | |||
|
2 | ||||
|
3 | $ hg init server | |||
|
4 | $ enablehttpv2 server | |||
|
5 | $ cd server | |||
|
6 | $ cat >> .hg/hgrc << EOF | |||
|
7 | > [extensions] | |||
|
8 | > simplecache = $TESTDIR/wireprotosimplecache.py | |||
|
9 | > EOF | |||
|
10 | ||||
|
11 | $ echo a0 > a | |||
|
12 | $ echo b0 > b | |||
|
13 | $ hg -q commit -A -m 'commit 0' | |||
|
14 | $ echo a1 > a | |||
|
15 | $ hg commit -m 'commit 1' | |||
|
16 | ||||
|
17 | $ hg --debug debugindex -m | |||
|
18 | rev linkrev nodeid p1 p2 | |||
|
19 | 0 0 992f4779029a3df8d0666d00bb924f69634e2641 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 | |||
|
20 | 1 1 a988fb43583e871d1ed5750ee074c6d840bbbfc8 992f4779029a3df8d0666d00bb924f69634e2641 0000000000000000000000000000000000000000 | |||
|
21 | ||||
|
22 | $ hg --config simplecache.redirectsfile=redirects.py serve -p $HGPORT -d --pid-file hg.pid -E error.log | |||
|
23 | $ cat hg.pid > $DAEMON_PIDS | |||
|
24 | ||||
|
25 | $ cat > redirects.py << EOF | |||
|
26 | > [ | |||
|
27 | > { | |||
|
28 | > b'name': b'target-a', | |||
|
29 | > b'protocol': b'http', | |||
|
30 | > b'snirequired': False, | |||
|
31 | > b'tlsversions': [b'1.2', b'1.3'], | |||
|
32 | > b'uris': [b'http://example.com/'], | |||
|
33 | > }, | |||
|
34 | > ] | |||
|
35 | > EOF | |||
|
36 | ||||
|
37 | Redirect targets advertised when configured | |||
|
38 | ||||
|
39 | $ sendhttpv2peerhandshake << EOF | |||
|
40 | > command capabilities | |||
|
41 | > EOF | |||
|
42 | creating http peer for wire protocol version 2 | |||
|
43 | s> GET /?cmd=capabilities HTTP/1.1\r\n | |||
|
44 | s> Accept-Encoding: identity\r\n | |||
|
45 | s> vary: X-HgProto-1,X-HgUpgrade-1\r\n | |||
|
46 | s> x-hgproto-1: cbor\r\n | |||
|
47 | s> x-hgupgrade-1: exp-http-v2-0002\r\n | |||
|
48 | s> accept: application/mercurial-0.1\r\n | |||
|
49 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
50 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
51 | s> \r\n | |||
|
52 | s> makefile('rb', None) | |||
|
53 | s> HTTP/1.1 200 OK\r\n | |||
|
54 | s> Server: testing stub value\r\n | |||
|
55 | s> Date: $HTTP_DATE$\r\n | |||
|
56 | s> Content-Type: application/mercurial-cbor\r\n | |||
|
57 | s> Content-Length: 1970\r\n | |||
|
58 | s> \r\n | |||
|
59 | s> \xa3GapibaseDapi/Dapis\xa1Pexp-http-v2-0002\xa6Hcommands\xaaIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullMchangesetdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x84IbookmarksGparentsEphaseHrevisionInoderange\xa3Gdefault\xf6Hrequired\xf4DtypeDlistEnodes\xa3Gdefault\xf6Hrequired\xf4DtypeDlistJnodesdepth\xa3Gdefault\xf6Hrequired\xf4DtypeCintKpermissions\x81DpullHfiledata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDpath\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xa3Gdefault\xf4Hrequired\xf4DtypeDboolKpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\xa3Gdefault\x80Hrequired\xf4DtypeDlistKpermissions\x81DpullHlistkeys\xa2Dargs\xa1Inamespace\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullFlookup\xa2Dargs\xa1Ckey\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullLmanifestdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDtree\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullGpushkey\xa2Dargs\xa4Ckey\xa2Hrequired\xf5DtypeEbytesInamespace\xa2Hrequired\xf5DtypeEbytesCnew\xa2Hrequired\xf5DtypeEbytesCold\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpushKcompression\x82\xa1DnameDzstd\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Rpathfilterprefixes\xd9\x01\x02\x82Epath:Lrootfilesin:Nrawrepoformats\x82LgeneraldeltaHrevlogv1Hredirect\xa2Fhashes\x82Fsha256Dsha1Gtargets\x81\xa5DnameHtarget-aHprotocolDhttpKsnirequired\xf4Ktlsversions\x82C1.2C1.3Duris\x81Shttp://example.com/Nv1capabilitiesY\x01\xd8batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | |||
|
60 | sending capabilities command | |||
|
61 | s> POST /api/exp-http-v2-0002/ro/capabilities HTTP/1.1\r\n | |||
|
62 | s> Accept-Encoding: identity\r\n | |||
|
63 | s> accept: application/mercurial-exp-framing-0005\r\n | |||
|
64 | s> content-type: application/mercurial-exp-framing-0005\r\n | |||
|
65 | s> content-length: 27\r\n | |||
|
66 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
67 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
68 | s> \r\n | |||
|
69 | s> \x13\x00\x00\x01\x00\x01\x01\x11\xa1DnameLcapabilities | |||
|
70 | s> makefile('rb', None) | |||
|
71 | s> HTTP/1.1 200 OK\r\n | |||
|
72 | s> Server: testing stub value\r\n | |||
|
73 | s> Date: $HTTP_DATE$\r\n | |||
|
74 | s> Content-Type: application/mercurial-exp-framing-0005\r\n | |||
|
75 | s> Transfer-Encoding: chunked\r\n | |||
|
76 | s> \r\n | |||
|
77 | s> 13\r\n | |||
|
78 | s> \x0b\x00\x00\x01\x00\x02\x011 | |||
|
79 | s> \xa1FstatusBok | |||
|
80 | s> \r\n | |||
|
81 | received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation) | |||
|
82 | s> 5ab\r\n | |||
|
83 | s> \xa3\x05\x00\x01\x00\x02\x001 | |||
|
84 | s> \xa6Hcommands\xaaIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullMchangesetdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x84IbookmarksGparentsEphaseHrevisionInoderange\xa3Gdefault\xf6Hrequired\xf4DtypeDlistEnodes\xa3Gdefault\xf6Hrequired\xf4DtypeDlistJnodesdepth\xa3Gdefault\xf6Hrequired\xf4DtypeCintKpermissions\x81DpullHfiledata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDpath\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xa3Gdefault\xf4Hrequired\xf4DtypeDboolKpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\xa3Gdefault\x80Hrequired\xf4DtypeDlistKpermissions\x81DpullHlistkeys\xa2Dargs\xa1Inamespace\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullFlookup\xa2Dargs\xa1Ckey\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullLmanifestdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDtree\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullGpushkey\xa2Dargs\xa4Ckey\xa2Hrequired\xf5DtypeEbytesInamespace\xa2Hrequired\xf5DtypeEbytesCnew\xa2Hrequired\xf5DtypeEbytesCold\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpushKcompression\x82\xa1DnameDzstd\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Rpathfilterprefixes\xd9\x01\x02\x82Epath:Lrootfilesin:Nrawrepoformats\x82LgeneraldeltaHrevlogv1Hredirect\xa2Fhashes\x82Fsha256Dsha1Gtargets\x81\xa5DnameHtarget-aHprotocolDhttpKsnirequired\xf4Ktlsversions\x82C1.2C1.3Duris\x81Shttp://example.com/ | |||
|
85 | s> \r\n | |||
|
86 | received frame(size=1443; request=1; stream=2; streamflags=; type=command-response; flags=continuation) | |||
|
87 | s> 8\r\n | |||
|
88 | s> \x00\x00\x00\x01\x00\x02\x002 | |||
|
89 | s> \r\n | |||
|
90 | s> 0\r\n | |||
|
91 | s> \r\n | |||
|
92 | received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos) | |||
|
93 | response: gen[ | |||
|
94 | { | |||
|
95 | b'commands': { | |||
|
96 | b'branchmap': { | |||
|
97 | b'args': {}, | |||
|
98 | b'permissions': [ | |||
|
99 | b'pull' | |||
|
100 | ] | |||
|
101 | }, | |||
|
102 | b'capabilities': { | |||
|
103 | b'args': {}, | |||
|
104 | b'permissions': [ | |||
|
105 | b'pull' | |||
|
106 | ] | |||
|
107 | }, | |||
|
108 | b'changesetdata': { | |||
|
109 | b'args': { | |||
|
110 | b'fields': { | |||
|
111 | b'default': set([]), | |||
|
112 | b'required': False, | |||
|
113 | b'type': b'set', | |||
|
114 | b'validvalues': set([ | |||
|
115 | b'bookmarks', | |||
|
116 | b'parents', | |||
|
117 | b'phase', | |||
|
118 | b'revision' | |||
|
119 | ]) | |||
|
120 | }, | |||
|
121 | b'noderange': { | |||
|
122 | b'default': None, | |||
|
123 | b'required': False, | |||
|
124 | b'type': b'list' | |||
|
125 | }, | |||
|
126 | b'nodes': { | |||
|
127 | b'default': None, | |||
|
128 | b'required': False, | |||
|
129 | b'type': b'list' | |||
|
130 | }, | |||
|
131 | b'nodesdepth': { | |||
|
132 | b'default': None, | |||
|
133 | b'required': False, | |||
|
134 | b'type': b'int' | |||
|
135 | } | |||
|
136 | }, | |||
|
137 | b'permissions': [ | |||
|
138 | b'pull' | |||
|
139 | ] | |||
|
140 | }, | |||
|
141 | b'filedata': { | |||
|
142 | b'args': { | |||
|
143 | b'fields': { | |||
|
144 | b'default': set([]), | |||
|
145 | b'required': False, | |||
|
146 | b'type': b'set', | |||
|
147 | b'validvalues': set([ | |||
|
148 | b'parents', | |||
|
149 | b'revision' | |||
|
150 | ]) | |||
|
151 | }, | |||
|
152 | b'haveparents': { | |||
|
153 | b'default': False, | |||
|
154 | b'required': False, | |||
|
155 | b'type': b'bool' | |||
|
156 | }, | |||
|
157 | b'nodes': { | |||
|
158 | b'required': True, | |||
|
159 | b'type': b'list' | |||
|
160 | }, | |||
|
161 | b'path': { | |||
|
162 | b'required': True, | |||
|
163 | b'type': b'bytes' | |||
|
164 | } | |||
|
165 | }, | |||
|
166 | b'permissions': [ | |||
|
167 | b'pull' | |||
|
168 | ] | |||
|
169 | }, | |||
|
170 | b'heads': { | |||
|
171 | b'args': { | |||
|
172 | b'publiconly': { | |||
|
173 | b'default': False, | |||
|
174 | b'required': False, | |||
|
175 | b'type': b'bool' | |||
|
176 | } | |||
|
177 | }, | |||
|
178 | b'permissions': [ | |||
|
179 | b'pull' | |||
|
180 | ] | |||
|
181 | }, | |||
|
182 | b'known': { | |||
|
183 | b'args': { | |||
|
184 | b'nodes': { | |||
|
185 | b'default': [], | |||
|
186 | b'required': False, | |||
|
187 | b'type': b'list' | |||
|
188 | } | |||
|
189 | }, | |||
|
190 | b'permissions': [ | |||
|
191 | b'pull' | |||
|
192 | ] | |||
|
193 | }, | |||
|
194 | b'listkeys': { | |||
|
195 | b'args': { | |||
|
196 | b'namespace': { | |||
|
197 | b'required': True, | |||
|
198 | b'type': b'bytes' | |||
|
199 | } | |||
|
200 | }, | |||
|
201 | b'permissions': [ | |||
|
202 | b'pull' | |||
|
203 | ] | |||
|
204 | }, | |||
|
205 | b'lookup': { | |||
|
206 | b'args': { | |||
|
207 | b'key': { | |||
|
208 | b'required': True, | |||
|
209 | b'type': b'bytes' | |||
|
210 | } | |||
|
211 | }, | |||
|
212 | b'permissions': [ | |||
|
213 | b'pull' | |||
|
214 | ] | |||
|
215 | }, | |||
|
216 | b'manifestdata': { | |||
|
217 | b'args': { | |||
|
218 | b'fields': { | |||
|
219 | b'default': set([]), | |||
|
220 | b'required': False, | |||
|
221 | b'type': b'set', | |||
|
222 | b'validvalues': set([ | |||
|
223 | b'parents', | |||
|
224 | b'revision' | |||
|
225 | ]) | |||
|
226 | }, | |||
|
227 | b'haveparents': { | |||
|
228 | b'default': False, | |||
|
229 | b'required': False, | |||
|
230 | b'type': b'bool' | |||
|
231 | }, | |||
|
232 | b'nodes': { | |||
|
233 | b'required': True, | |||
|
234 | b'type': b'list' | |||
|
235 | }, | |||
|
236 | b'tree': { | |||
|
237 | b'required': True, | |||
|
238 | b'type': b'bytes' | |||
|
239 | } | |||
|
240 | }, | |||
|
241 | b'permissions': [ | |||
|
242 | b'pull' | |||
|
243 | ] | |||
|
244 | }, | |||
|
245 | b'pushkey': { | |||
|
246 | b'args': { | |||
|
247 | b'key': { | |||
|
248 | b'required': True, | |||
|
249 | b'type': b'bytes' | |||
|
250 | }, | |||
|
251 | b'namespace': { | |||
|
252 | b'required': True, | |||
|
253 | b'type': b'bytes' | |||
|
254 | }, | |||
|
255 | b'new': { | |||
|
256 | b'required': True, | |||
|
257 | b'type': b'bytes' | |||
|
258 | }, | |||
|
259 | b'old': { | |||
|
260 | b'required': True, | |||
|
261 | b'type': b'bytes' | |||
|
262 | } | |||
|
263 | }, | |||
|
264 | b'permissions': [ | |||
|
265 | b'push' | |||
|
266 | ] | |||
|
267 | } | |||
|
268 | }, | |||
|
269 | b'compression': [ | |||
|
270 | { | |||
|
271 | b'name': b'zstd' | |||
|
272 | }, | |||
|
273 | { | |||
|
274 | b'name': b'zlib' | |||
|
275 | } | |||
|
276 | ], | |||
|
277 | b'framingmediatypes': [ | |||
|
278 | b'application/mercurial-exp-framing-0005' | |||
|
279 | ], | |||
|
280 | b'pathfilterprefixes': set([ | |||
|
281 | b'path:', | |||
|
282 | b'rootfilesin:' | |||
|
283 | ]), | |||
|
284 | b'rawrepoformats': [ | |||
|
285 | b'generaldelta', | |||
|
286 | b'revlogv1' | |||
|
287 | ], | |||
|
288 | b'redirect': { | |||
|
289 | b'hashes': [ | |||
|
290 | b'sha256', | |||
|
291 | b'sha1' | |||
|
292 | ], | |||
|
293 | b'targets': [ | |||
|
294 | { | |||
|
295 | b'name': b'target-a', | |||
|
296 | b'protocol': b'http', | |||
|
297 | b'snirequired': False, | |||
|
298 | b'tlsversions': [ | |||
|
299 | b'1.2', | |||
|
300 | b'1.3' | |||
|
301 | ], | |||
|
302 | b'uris': [ | |||
|
303 | b'http://example.com/' | |||
|
304 | ] | |||
|
305 | } | |||
|
306 | ] | |||
|
307 | } | |||
|
308 | } | |||
|
309 | ] | |||
|
310 | ||||
|
311 | $ cat > redirects.py << EOF | |||
|
312 | > [ | |||
|
313 | > { | |||
|
314 | > b'name': b'target-a', | |||
|
315 | > b'protocol': b'http', | |||
|
316 | > b'uris': [b'http://example.com/'], | |||
|
317 | > }, | |||
|
318 | > { | |||
|
319 | > b'name': b'target-b', | |||
|
320 | > b'protocol': b'unknown', | |||
|
321 | > b'uris': [b'unknown://example.com/'], | |||
|
322 | > }, | |||
|
323 | > ] | |||
|
324 | > EOF | |||
|
325 | ||||
|
326 | $ sendhttpv2peerhandshake << EOF | |||
|
327 | > command capabilities | |||
|
328 | > EOF | |||
|
329 | creating http peer for wire protocol version 2 | |||
|
330 | s> GET /?cmd=capabilities HTTP/1.1\r\n | |||
|
331 | s> Accept-Encoding: identity\r\n | |||
|
332 | s> vary: X-HgProto-1,X-HgUpgrade-1\r\n | |||
|
333 | s> x-hgproto-1: cbor\r\n | |||
|
334 | s> x-hgupgrade-1: exp-http-v2-0002\r\n | |||
|
335 | s> accept: application/mercurial-0.1\r\n | |||
|
336 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
337 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
338 | s> \r\n | |||
|
339 | s> makefile('rb', None) | |||
|
340 | s> HTTP/1.1 200 OK\r\n | |||
|
341 | s> Server: testing stub value\r\n | |||
|
342 | s> Date: $HTTP_DATE$\r\n | |||
|
343 | s> Content-Type: application/mercurial-cbor\r\n | |||
|
344 | s> Content-Length: 1997\r\n | |||
|
345 | s> \r\n | |||
|
346 | s> \xa3GapibaseDapi/Dapis\xa1Pexp-http-v2-0002\xa6Hcommands\xaaIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullMchangesetdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x84IbookmarksGparentsEphaseHrevisionInoderange\xa3Gdefault\xf6Hrequired\xf4DtypeDlistEnodes\xa3Gdefault\xf6Hrequired\xf4DtypeDlistJnodesdepth\xa3Gdefault\xf6Hrequired\xf4DtypeCintKpermissions\x81DpullHfiledata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDpath\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xa3Gdefault\xf4Hrequired\xf4DtypeDboolKpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\xa3Gdefault\x80Hrequired\xf4DtypeDlistKpermissions\x81DpullHlistkeys\xa2Dargs\xa1Inamespace\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullFlookup\xa2Dargs\xa1Ckey\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullLmanifestdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDtree\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullGpushkey\xa2Dargs\xa4Ckey\xa2Hrequired\xf5DtypeEbytesInamespace\xa2Hrequired\xf5DtypeEbytesCnew\xa2Hrequired\xf5DtypeEbytesCold\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpushKcompression\x82\xa1DnameDzstd\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Rpathfilterprefixes\xd9\x01\x02\x82Epath:Lrootfilesin:Nrawrepoformats\x82LgeneraldeltaHrevlogv1Hredirect\xa2Fhashes\x82Fsha256Dsha1Gtargets\x82\xa3DnameHtarget-aHprotocolDhttpDuris\x81Shttp://example.com/\xa3DnameHtarget-bHprotocolGunknownDuris\x81Vunknown://example.com/Nv1capabilitiesY\x01\xd8batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | |||
|
347 | sending capabilities command | |||
|
348 | s> POST /api/exp-http-v2-0002/ro/capabilities HTTP/1.1\r\n | |||
|
349 | s> Accept-Encoding: identity\r\n | |||
|
350 | s> accept: application/mercurial-exp-framing-0005\r\n | |||
|
351 | s> content-type: application/mercurial-exp-framing-0005\r\n | |||
|
352 | s> content-length: 27\r\n | |||
|
353 | s> host: $LOCALIP:$HGPORT\r\n (glob) | |||
|
354 | s> user-agent: Mercurial debugwireproto\r\n | |||
|
355 | s> \r\n | |||
|
356 | s> \x13\x00\x00\x01\x00\x01\x01\x11\xa1DnameLcapabilities | |||
|
357 | s> makefile('rb', None) | |||
|
358 | s> HTTP/1.1 200 OK\r\n | |||
|
359 | s> Server: testing stub value\r\n | |||
|
360 | s> Date: $HTTP_DATE$\r\n | |||
|
361 | s> Content-Type: application/mercurial-exp-framing-0005\r\n | |||
|
362 | s> Transfer-Encoding: chunked\r\n | |||
|
363 | s> \r\n | |||
|
364 | s> 13\r\n | |||
|
365 | s> \x0b\x00\x00\x01\x00\x02\x011 | |||
|
366 | s> \xa1FstatusBok | |||
|
367 | s> \r\n | |||
|
368 | received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation) | |||
|
369 | s> 5c6\r\n | |||
|
370 | s> \xbe\x05\x00\x01\x00\x02\x001 | |||
|
371 | s> \xa6Hcommands\xaaIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullMchangesetdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x84IbookmarksGparentsEphaseHrevisionInoderange\xa3Gdefault\xf6Hrequired\xf4DtypeDlistEnodes\xa3Gdefault\xf6Hrequired\xf4DtypeDlistJnodesdepth\xa3Gdefault\xf6Hrequired\xf4DtypeCintKpermissions\x81DpullHfiledata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDpath\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xa3Gdefault\xf4Hrequired\xf4DtypeDboolKpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\xa3Gdefault\x80Hrequired\xf4DtypeDlistKpermissions\x81DpullHlistkeys\xa2Dargs\xa1Inamespace\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullFlookup\xa2Dargs\xa1Ckey\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullLmanifestdata\xa2Dargs\xa4Ffields\xa4Gdefault\xd9\x01\x02\x80Hrequired\xf4DtypeCsetKvalidvalues\xd9\x01\x02\x82GparentsHrevisionKhaveparents\xa3Gdefault\xf4Hrequired\xf4DtypeDboolEnodes\xa2Hrequired\xf5DtypeDlistDtree\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpullGpushkey\xa2Dargs\xa4Ckey\xa2Hrequired\xf5DtypeEbytesInamespace\xa2Hrequired\xf5DtypeEbytesCnew\xa2Hrequired\xf5DtypeEbytesCold\xa2Hrequired\xf5DtypeEbytesKpermissions\x81DpushKcompression\x82\xa1DnameDzstd\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Rpathfilterprefixes\xd9\x01\x02\x82Epath:Lrootfilesin:Nrawrepoformats\x82LgeneraldeltaHrevlogv1Hredirect\xa2Fhashes\x82Fsha256Dsha1Gtargets\x82\xa3DnameHtarget-aHprotocolDhttpDuris\x81Shttp://example.com/\xa3DnameHtarget-bHprotocolGunknownDuris\x81Vunknown://example.com/ | |||
|
372 | s> \r\n | |||
|
373 | received frame(size=1470; request=1; stream=2; streamflags=; type=command-response; flags=continuation) | |||
|
374 | s> 8\r\n | |||
|
375 | s> \x00\x00\x00\x01\x00\x02\x002 | |||
|
376 | s> \r\n | |||
|
377 | s> 0\r\n | |||
|
378 | s> \r\n | |||
|
379 | received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos) | |||
|
380 | response: gen[ | |||
|
381 | { | |||
|
382 | b'commands': { | |||
|
383 | b'branchmap': { | |||
|
384 | b'args': {}, | |||
|
385 | b'permissions': [ | |||
|
386 | b'pull' | |||
|
387 | ] | |||
|
388 | }, | |||
|
389 | b'capabilities': { | |||
|
390 | b'args': {}, | |||
|
391 | b'permissions': [ | |||
|
392 | b'pull' | |||
|
393 | ] | |||
|
394 | }, | |||
|
395 | b'changesetdata': { | |||
|
396 | b'args': { | |||
|
397 | b'fields': { | |||
|
398 | b'default': set([]), | |||
|
399 | b'required': False, | |||
|
400 | b'type': b'set', | |||
|
401 | b'validvalues': set([ | |||
|
402 | b'bookmarks', | |||
|
403 | b'parents', | |||
|
404 | b'phase', | |||
|
405 | b'revision' | |||
|
406 | ]) | |||
|
407 | }, | |||
|
408 | b'noderange': { | |||
|
409 | b'default': None, | |||
|
410 | b'required': False, | |||
|
411 | b'type': b'list' | |||
|
412 | }, | |||
|
413 | b'nodes': { | |||
|
414 | b'default': None, | |||
|
415 | b'required': False, | |||
|
416 | b'type': b'list' | |||
|
417 | }, | |||
|
418 | b'nodesdepth': { | |||
|
419 | b'default': None, | |||
|
420 | b'required': False, | |||
|
421 | b'type': b'int' | |||
|
422 | } | |||
|
423 | }, | |||
|
424 | b'permissions': [ | |||
|
425 | b'pull' | |||
|
426 | ] | |||
|
427 | }, | |||
|
428 | b'filedata': { | |||
|
429 | b'args': { | |||
|
430 | b'fields': { | |||
|
431 | b'default': set([]), | |||
|
432 | b'required': False, | |||
|
433 | b'type': b'set', | |||
|
434 | b'validvalues': set([ | |||
|
435 | b'parents', | |||
|
436 | b'revision' | |||
|
437 | ]) | |||
|
438 | }, | |||
|
439 | b'haveparents': { | |||
|
440 | b'default': False, | |||
|
441 | b'required': False, | |||
|
442 | b'type': b'bool' | |||
|
443 | }, | |||
|
444 | b'nodes': { | |||
|
445 | b'required': True, | |||
|
446 | b'type': b'list' | |||
|
447 | }, | |||
|
448 | b'path': { | |||
|
449 | b'required': True, | |||
|
450 | b'type': b'bytes' | |||
|
451 | } | |||
|
452 | }, | |||
|
453 | b'permissions': [ | |||
|
454 | b'pull' | |||
|
455 | ] | |||
|
456 | }, | |||
|
457 | b'heads': { | |||
|
458 | b'args': { | |||
|
459 | b'publiconly': { | |||
|
460 | b'default': False, | |||
|
461 | b'required': False, | |||
|
462 | b'type': b'bool' | |||
|
463 | } | |||
|
464 | }, | |||
|
465 | b'permissions': [ | |||
|
466 | b'pull' | |||
|
467 | ] | |||
|
468 | }, | |||
|
469 | b'known': { | |||
|
470 | b'args': { | |||
|
471 | b'nodes': { | |||
|
472 | b'default': [], | |||
|
473 | b'required': False, | |||
|
474 | b'type': b'list' | |||
|
475 | } | |||
|
476 | }, | |||
|
477 | b'permissions': [ | |||
|
478 | b'pull' | |||
|
479 | ] | |||
|
480 | }, | |||
|
481 | b'listkeys': { | |||
|
482 | b'args': { | |||
|
483 | b'namespace': { | |||
|
484 | b'required': True, | |||
|
485 | b'type': b'bytes' | |||
|
486 | } | |||
|
487 | }, | |||
|
488 | b'permissions': [ | |||
|
489 | b'pull' | |||
|
490 | ] | |||
|
491 | }, | |||
|
492 | b'lookup': { | |||
|
493 | b'args': { | |||
|
494 | b'key': { | |||
|
495 | b'required': True, | |||
|
496 | b'type': b'bytes' | |||
|
497 | } | |||
|
498 | }, | |||
|
499 | b'permissions': [ | |||
|
500 | b'pull' | |||
|
501 | ] | |||
|
502 | }, | |||
|
503 | b'manifestdata': { | |||
|
504 | b'args': { | |||
|
505 | b'fields': { | |||
|
506 | b'default': set([]), | |||
|
507 | b'required': False, | |||
|
508 | b'type': b'set', | |||
|
509 | b'validvalues': set([ | |||
|
510 | b'parents', | |||
|
511 | b'revision' | |||
|
512 | ]) | |||
|
513 | }, | |||
|
514 | b'haveparents': { | |||
|
515 | b'default': False, | |||
|
516 | b'required': False, | |||
|
517 | b'type': b'bool' | |||
|
518 | }, | |||
|
519 | b'nodes': { | |||
|
520 | b'required': True, | |||
|
521 | b'type': b'list' | |||
|
522 | }, | |||
|
523 | b'tree': { | |||
|
524 | b'required': True, | |||
|
525 | b'type': b'bytes' | |||
|
526 | } | |||
|
527 | }, | |||
|
528 | b'permissions': [ | |||
|
529 | b'pull' | |||
|
530 | ] | |||
|
531 | }, | |||
|
532 | b'pushkey': { | |||
|
533 | b'args': { | |||
|
534 | b'key': { | |||
|
535 | b'required': True, | |||
|
536 | b'type': b'bytes' | |||
|
537 | }, | |||
|
538 | b'namespace': { | |||
|
539 | b'required': True, | |||
|
540 | b'type': b'bytes' | |||
|
541 | }, | |||
|
542 | b'new': { | |||
|
543 | b'required': True, | |||
|
544 | b'type': b'bytes' | |||
|
545 | }, | |||
|
546 | b'old': { | |||
|
547 | b'required': True, | |||
|
548 | b'type': b'bytes' | |||
|
549 | } | |||
|
550 | }, | |||
|
551 | b'permissions': [ | |||
|
552 | b'push' | |||
|
553 | ] | |||
|
554 | } | |||
|
555 | }, | |||
|
556 | b'compression': [ | |||
|
557 | { | |||
|
558 | b'name': b'zstd' | |||
|
559 | }, | |||
|
560 | { | |||
|
561 | b'name': b'zlib' | |||
|
562 | } | |||
|
563 | ], | |||
|
564 | b'framingmediatypes': [ | |||
|
565 | b'application/mercurial-exp-framing-0005' | |||
|
566 | ], | |||
|
567 | b'pathfilterprefixes': set([ | |||
|
568 | b'path:', | |||
|
569 | b'rootfilesin:' | |||
|
570 | ]), | |||
|
571 | b'rawrepoformats': [ | |||
|
572 | b'generaldelta', | |||
|
573 | b'revlogv1' | |||
|
574 | ], | |||
|
575 | b'redirect': { | |||
|
576 | b'hashes': [ | |||
|
577 | b'sha256', | |||
|
578 | b'sha1' | |||
|
579 | ], | |||
|
580 | b'targets': [ | |||
|
581 | { | |||
|
582 | b'name': b'target-a', | |||
|
583 | b'protocol': b'http', | |||
|
584 | b'uris': [ | |||
|
585 | b'http://example.com/' | |||
|
586 | ] | |||
|
587 | }, | |||
|
588 | { | |||
|
589 | b'name': b'target-b', | |||
|
590 | b'protocol': b'unknown', | |||
|
591 | b'uris': [ | |||
|
592 | b'unknown://example.com/' | |||
|
593 | ] | |||
|
594 | } | |||
|
595 | ] | |||
|
596 | } | |||
|
597 | } | |||
|
598 | ] | |||
|
599 | ||||
|
600 | $ cat error.log | |||
|
601 | $ killdaemons.py |
@@ -517,8 +517,66 b' def _capabilitiesv2(repo, proto):' | |||||
517 | caps['rawrepoformats'] = sorted(repo.requirements & |
|
517 | caps['rawrepoformats'] = sorted(repo.requirements & | |
518 | repo.supportedformats) |
|
518 | repo.supportedformats) | |
519 |
|
519 | |||
|
520 | targets = getadvertisedredirecttargets(repo, proto) | |||
|
521 | if targets: | |||
|
522 | caps[b'redirect'] = { | |||
|
523 | b'targets': [], | |||
|
524 | b'hashes': [b'sha256', b'sha1'], | |||
|
525 | } | |||
|
526 | ||||
|
527 | for target in targets: | |||
|
528 | entry = { | |||
|
529 | b'name': target['name'], | |||
|
530 | b'protocol': target['protocol'], | |||
|
531 | b'uris': target['uris'], | |||
|
532 | } | |||
|
533 | ||||
|
534 | for key in ('snirequired', 'tlsversions'): | |||
|
535 | if key in target: | |||
|
536 | entry[key] = target[key] | |||
|
537 | ||||
|
538 | caps[b'redirect'][b'targets'].append(entry) | |||
|
539 | ||||
520 | return proto.addcapabilities(repo, caps) |
|
540 | return proto.addcapabilities(repo, caps) | |
521 |
|
541 | |||
|
542 | def getadvertisedredirecttargets(repo, proto): | |||
|
543 | """Obtain a list of content redirect targets. | |||
|
544 | ||||
|
545 | Returns a list containing potential redirect targets that will be | |||
|
546 | advertised in capabilities data. Each dict MUST have the following | |||
|
547 | keys: | |||
|
548 | ||||
|
549 | name | |||
|
550 | The name of this redirect target. This is the identifier clients use | |||
|
551 | to refer to a target. It is transferred as part of every command | |||
|
552 | request. | |||
|
553 | ||||
|
554 | protocol | |||
|
555 | Network protocol used by this target. Typically this is the string | |||
|
556 | in front of the ``://`` in a URL. e.g. ``https``. | |||
|
557 | ||||
|
558 | uris | |||
|
559 | List of representative URIs for this target. Clients can use the | |||
|
560 | URIs to test parsing for compatibility or for ordering preference | |||
|
561 | for which target to use. | |||
|
562 | ||||
|
563 | The following optional keys are recognized: | |||
|
564 | ||||
|
565 | snirequired | |||
|
566 | Bool indicating if Server Name Indication (SNI) is required to | |||
|
567 | connect to this target. | |||
|
568 | ||||
|
569 | tlsversions | |||
|
570 | List of bytes indicating which TLS versions are supported by this | |||
|
571 | target. | |||
|
572 | ||||
|
573 | By default, clients reflect the target order advertised by servers | |||
|
574 | and servers will use the first client-advertised target when picking | |||
|
575 | a redirect target. So targets should be advertised in the order the | |||
|
576 | server prefers they be used. | |||
|
577 | """ | |||
|
578 | return [] | |||
|
579 | ||||
522 | def wireprotocommand(name, args=None, permission='push', cachekeyfn=None): |
|
580 | def wireprotocommand(name, args=None, permission='push', cachekeyfn=None): | |
523 | """Decorator to declare a wire protocol command. |
|
581 | """Decorator to declare a wire protocol command. | |
524 |
|
582 |
@@ -17,6 +17,7 b' from mercurial import (' | |||||
17 | ) |
|
17 | ) | |
18 | from mercurial.utils import ( |
|
18 | from mercurial.utils import ( | |
19 | interfaceutil, |
|
19 | interfaceutil, | |
|
20 | stringutil, | |||
20 | ) |
|
21 | ) | |
21 |
|
22 | |||
22 | CACHE = None |
|
23 | CACHE = None | |
@@ -26,6 +27,8 b' configitem = registrar.configitem(config' | |||||
26 |
|
27 | |||
27 | configitem('simplecache', 'cacheobjects', |
|
28 | configitem('simplecache', 'cacheobjects', | |
28 | default=False) |
|
29 | default=False) | |
|
30 | configitem('simplecache', 'redirectsfile', | |||
|
31 | default=None) | |||
29 |
|
32 | |||
30 | @interfaceutil.implementer(repository.iwireprotocolcommandcacher) |
|
33 | @interfaceutil.implementer(repository.iwireprotocolcommandcacher) | |
31 | class memorycacher(object): |
|
34 | class memorycacher(object): | |
@@ -91,6 +94,19 b' class memorycacher(object):' | |||||
91 | def makeresponsecacher(orig, repo, proto, command, args, objencoderfn): |
|
94 | def makeresponsecacher(orig, repo, proto, command, args, objencoderfn): | |
92 | return memorycacher(repo.ui, command, objencoderfn) |
|
95 | return memorycacher(repo.ui, command, objencoderfn) | |
93 |
|
96 | |||
|
97 | def loadredirecttargets(ui): | |||
|
98 | path = ui.config('simplecache', 'redirectsfile') | |||
|
99 | if not path: | |||
|
100 | return [] | |||
|
101 | ||||
|
102 | with open(path, 'rb') as fh: | |||
|
103 | s = fh.read() | |||
|
104 | ||||
|
105 | return stringutil.evalpythonliteral(s) | |||
|
106 | ||||
|
107 | def getadvertisedredirecttargets(orig, repo, proto): | |||
|
108 | return loadredirecttargets(repo.ui) | |||
|
109 | ||||
94 | def extsetup(ui): |
|
110 | def extsetup(ui): | |
95 | global CACHE |
|
111 | global CACHE | |
96 |
|
112 | |||
@@ -98,3 +114,5 b' def extsetup(ui):' | |||||
98 |
|
114 | |||
99 | extensions.wrapfunction(wireprotov2server, 'makeresponsecacher', |
|
115 | extensions.wrapfunction(wireprotov2server, 'makeresponsecacher', | |
100 | makeresponsecacher) |
|
116 | makeresponsecacher) | |
|
117 | extensions.wrapfunction(wireprotov2server, 'getadvertisedredirecttargets', | |||
|
118 | getadvertisedredirecttargets) |
General Comments 0
You need to be logged in to leave comments.
Login now