Mercurial > hg
comparison tests/test-wireproto-command-capabilities.t @ 39378:0f549da54379
stringutil: teach pprint() to indent
This will make data structure dumping in various places a bit
easier to read and diff. Since I wanted this for `hg debugwireproto`
output, I added indentation to it.
A more advanced pretty printer implementation would conditionally
add newlines if output is too long. But it is vastly simpler to
be consistent and always add newlines when indenting.
Again, I'm not crazy about the verbosity of the code and there is
room to consolidate logic for "print a collection." But this isn't
the most complicated code in the world and I'm not convinced it is
worth doing.
Differential Revision: https://phab.mercurial-scm.org/D4399
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 27 Aug 2018 09:13:58 -0700 |
parents | 538e850ae737 |
children | 5f4a9ada5ab5 |
comparison
equal
deleted
inserted
replaced
39377:b4e7e1f09c09 | 39378:0f549da54379 |
---|---|
144 s> Date: $HTTP_DATE$\r\n | 144 s> Date: $HTTP_DATE$\r\n |
145 s> Content-Type: application/mercurial-cbor\r\n | 145 s> Content-Type: application/mercurial-cbor\r\n |
146 s> Content-Length: *\r\n (glob) | 146 s> Content-Length: *\r\n (glob) |
147 s> \r\n | 147 s> \r\n |
148 s> \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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 | 148 s> \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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 |
149 cbor> {b'apibase': b'api/', b'apis': {}, b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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'} | 149 cbor> { |
150 b'apibase': b'api/', | |
151 b'apis': {}, | |
152 b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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' | |
153 } | |
150 | 154 |
151 Restart server to enable HTTPv2 | 155 Restart server to enable HTTPv2 |
152 | 156 |
153 $ killdaemons.py | 157 $ killdaemons.py |
154 $ enablehttpv2 server | 158 $ enablehttpv2 server |
177 s> Date: $HTTP_DATE$\r\n | 181 s> Date: $HTTP_DATE$\r\n |
178 s> Content-Type: application/mercurial-cbor\r\n | 182 s> Content-Type: application/mercurial-cbor\r\n |
179 s> Content-Length: *\r\n (glob) | 183 s> Content-Length: *\r\n (glob) |
180 s> \r\n | 184 s> \r\n |
181 s> \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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 | 185 s> \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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 |
182 cbor> {b'apibase': b'api/', b'apis': {}, b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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'} | 186 cbor> { |
187 b'apibase': b'api/', | |
188 b'apis': {}, | |
189 b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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' | |
190 } | |
183 | 191 |
184 Request for HTTPv2 service returns information about it | 192 Request for HTTPv2 service returns information about it |
185 | 193 |
186 $ sendhttpraw << EOF | 194 $ sendhttpraw << EOF |
187 > httprequest GET ?cmd=capabilities | 195 > httprequest GET ?cmd=capabilities |
203 s> Date: $HTTP_DATE$\r\n | 211 s> Date: $HTTP_DATE$\r\n |
204 s> Content-Type: application/mercurial-cbor\r\n | 212 s> Content-Type: application/mercurial-cbor\r\n |
205 s> Content-Length: *\r\n (glob) | 213 s> Content-Length: *\r\n (glob) |
206 s> \r\n | 214 s> \r\n |
207 s> \xa3Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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 | 215 s> \xa3Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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 |
208 cbor> {b'apibase': b'api/', b'apis': {b'exp-http-v2-0001': {b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, 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'compression': [{b'name': b'zlib'}], b'framingmediatypes': [b'application/mercurial-exp-framing-0005'], b'rawrepoformats': [b'generaldelta', b'revlogv1']}}, b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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'} | 216 cbor> { |
217 b'apibase': b'api/', | |
218 b'apis': { | |
219 b'exp-http-v2-0001': { | |
220 b'commands': { | |
221 b'branchmap': { | |
222 b'args': {}, | |
223 b'permissions': [ | |
224 b'pull' | |
225 ] | |
226 }, | |
227 b'capabilities': { | |
228 b'args': {}, | |
229 b'permissions': [ | |
230 b'pull' | |
231 ] | |
232 }, | |
233 b'heads': { | |
234 b'args': { | |
235 b'publiconly': False | |
236 }, | |
237 b'permissions': [ | |
238 b'pull' | |
239 ] | |
240 }, | |
241 b'known': { | |
242 b'args': { | |
243 b'nodes': [ | |
244 b'deadbeef' | |
245 ] | |
246 }, | |
247 b'permissions': [ | |
248 b'pull' | |
249 ] | |
250 }, | |
251 b'listkeys': { | |
252 b'args': { | |
253 b'namespace': b'ns' | |
254 }, | |
255 b'permissions': [ | |
256 b'pull' | |
257 ] | |
258 }, | |
259 b'lookup': { | |
260 b'args': { | |
261 b'key': b'foo' | |
262 }, | |
263 b'permissions': [ | |
264 b'pull' | |
265 ] | |
266 }, | |
267 b'pushkey': { | |
268 b'args': { | |
269 b'key': b'key', | |
270 b'namespace': b'ns', | |
271 b'new': b'new', | |
272 b'old': b'old' | |
273 }, | |
274 b'permissions': [ | |
275 b'push' | |
276 ] | |
277 } | |
278 }, | |
279 b'compression': [ | |
280 { | |
281 b'name': b'zlib' | |
282 } | |
283 ], | |
284 b'framingmediatypes': [ | |
285 b'application/mercurial-exp-framing-0005' | |
286 ], | |
287 b'rawrepoformats': [ | |
288 b'generaldelta', | |
289 b'revlogv1' | |
290 ] | |
291 } | |
292 }, | |
293 b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ 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' | |
294 } | |
209 | 295 |
210 capabilities command returns expected info | 296 capabilities command returns expected info |
211 | 297 |
212 $ sendhttpv2peerhandshake << EOF | 298 $ sendhttpv2peerhandshake << EOF |
213 > command capabilities | 299 > command capabilities |
252 s> \xa1FstatusBok\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005 | 338 s> \xa1FstatusBok\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005 |
253 s> \r\n | 339 s> \r\n |
254 received frame(size=463; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) | 340 received frame(size=463; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos) |
255 s> 0\r\n | 341 s> 0\r\n |
256 s> \r\n | 342 s> \r\n |
257 response: [{b'status': b'ok'}, {b'commands': {b'branchmap': {b'args': {}, b'permissions': [b'pull']}, b'capabilities': {b'args': {}, 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'compression': [{b'name': b'zlib'}], b'framingmediatypes': [b'application/mercurial-exp-framing-0005'], b'rawrepoformats': [b'generaldelta', b'revlogv1']}] | 343 response: [ |
344 { | |
345 b'status': b'ok' | |
346 }, | |
347 { | |
348 b'commands': { | |
349 b'branchmap': { | |
350 b'args': {}, | |
351 b'permissions': [ | |
352 b'pull' | |
353 ] | |
354 }, | |
355 b'capabilities': { | |
356 b'args': {}, | |
357 b'permissions': [ | |
358 b'pull' | |
359 ] | |
360 }, | |
361 b'heads': { | |
362 b'args': { | |
363 b'publiconly': False | |
364 }, | |
365 b'permissions': [ | |
366 b'pull' | |
367 ] | |
368 }, | |
369 b'known': { | |
370 b'args': { | |
371 b'nodes': [ | |
372 b'deadbeef' | |
373 ] | |
374 }, | |
375 b'permissions': [ | |
376 b'pull' | |
377 ] | |
378 }, | |
379 b'listkeys': { | |
380 b'args': { | |
381 b'namespace': b'ns' | |
382 }, | |
383 b'permissions': [ | |
384 b'pull' | |
385 ] | |
386 }, | |
387 b'lookup': { | |
388 b'args': { | |
389 b'key': b'foo' | |
390 }, | |
391 b'permissions': [ | |
392 b'pull' | |
393 ] | |
394 }, | |
395 b'pushkey': { | |
396 b'args': { | |
397 b'key': b'key', | |
398 b'namespace': b'ns', | |
399 b'new': b'new', | |
400 b'old': b'old' | |
401 }, | |
402 b'permissions': [ | |
403 b'push' | |
404 ] | |
405 } | |
406 }, | |
407 b'compression': [ | |
408 { | |
409 b'name': b'zlib' | |
410 } | |
411 ], | |
412 b'framingmediatypes': [ | |
413 b'application/mercurial-exp-framing-0005' | |
414 ], | |
415 b'rawrepoformats': [ | |
416 b'generaldelta', | |
417 b'revlogv1' | |
418 ] | |
419 } | |
420 ] | |
258 | 421 |
259 $ cat error.log | 422 $ cat error.log |