##// END OF EJS Templates
wireprotov2: implement commands as a generator of objects...
Gregory Szorc -
r39595:07b58266 default
parent child Browse files
Show More
@@ -308,3 +308,14 b' class PeerTransportError(Abort):'
308 308 class InMemoryMergeConflictsError(Exception):
309 309 """Exception raised when merge conflicts arose during an in-memory merge."""
310 310 __bytes__ = _tobytes
311
312 class WireprotoCommandError(Exception):
313 """Represents an error during execution of a wire protocol command.
314
315 Should only be thrown by wire protocol version 2 commands.
316
317 The error is a formatter string and an optional iterable of arguments.
318 """
319 def __init__(self, message, args=None):
320 self.message = message
321 self.messageargs = args
@@ -514,3 +514,6 b' error (optional)'
514 514 message
515 515 (array of maps) A message describing the error. The message uses the
516 516 same format as those in the ``Human Output Side-Channel`` frame.
517
518 TODO formalize when error frames can be seen and how errors can be
519 recognized midway through a command response.
@@ -388,16 +388,14 b' def createcommandresponseframesfrombytes'
388 388
389 389 def createbytesresponseframesfromgen(stream, requestid, gen,
390 390 maxframesize=DEFAULT_MAX_FRAME_SIZE):
391 overall = b''.join(cborutil.streamencode({b'status': b'ok'}))
391 """Generator of frames from a generator of byte chunks.
392 392
393 yield stream.makeframe(requestid=requestid,
394 typeid=FRAME_TYPE_COMMAND_RESPONSE,
395 flags=FLAG_COMMAND_RESPONSE_CONTINUATION,
396 payload=overall)
397
393 This assumes that another frame will follow whatever this emits. i.e.
394 this always emits the continuation flag and never emits the end-of-stream
395 flag.
396 """
398 397 cb = util.chunkbuffer(gen)
399
400 flags = 0
398 flags = FLAG_COMMAND_RESPONSE_CONTINUATION
401 399
402 400 while True:
403 401 chunk = cb.read(maxframesize)
@@ -411,12 +409,20 b' def createbytesresponseframesfromgen(str'
411 409
412 410 flags |= FLAG_COMMAND_RESPONSE_CONTINUATION
413 411
414 flags ^= FLAG_COMMAND_RESPONSE_CONTINUATION
415 flags |= FLAG_COMMAND_RESPONSE_EOS
416 yield stream.makeframe(requestid=requestid,
417 typeid=FRAME_TYPE_COMMAND_RESPONSE,
418 flags=flags,
419 payload=b'')
412 def createcommandresponseokframe(stream, requestid):
413 overall = b''.join(cborutil.streamencode({b'status': b'ok'}))
414
415 return stream.makeframe(requestid=requestid,
416 typeid=FRAME_TYPE_COMMAND_RESPONSE,
417 flags=FLAG_COMMAND_RESPONSE_CONTINUATION,
418 payload=overall)
419
420 def createcommandresponseeosframe(stream, requestid):
421 """Create an empty payload frame representing command end-of-stream."""
422 return stream.makeframe(requestid=requestid,
423 typeid=FRAME_TYPE_COMMAND_RESPONSE,
424 flags=FLAG_COMMAND_RESPONSE_EOS,
425 payload=b'')
420 426
421 427 def createcommanderrorresponse(stream, requestid, message, args=None):
422 428 # TODO should this be using a list of {'msg': ..., 'args': {}} so atom
@@ -686,14 +692,69 b' class serverreactor(object):'
686 692 'framegen': result,
687 693 }
688 694
689 def oncommandresponsereadygen(self, stream, requestid, gen):
690 """Signal that a bytes response is ready, with data as a generator."""
695 def oncommandresponsereadyobjects(self, stream, requestid, objs):
696 """Signal that objects are ready to be sent to the client.
697
698 ``objs`` is an iterable of objects (typically a generator) that will
699 be encoded via CBOR and added to frames, which will be sent to the
700 client.
701 """
691 702 ensureserverstream(stream)
692 703
704 # We need to take care over exception handling. Uncaught exceptions
705 # when generating frames could lead to premature end of the frame
706 # stream and the possibility of the server or client process getting
707 # in a bad state.
708 #
709 # Keep in mind that if ``objs`` is a generator, advancing it could
710 # raise exceptions that originated in e.g. wire protocol command
711 # functions. That is why we differentiate between exceptions raised
712 # when iterating versus other exceptions that occur.
713 #
714 # In all cases, when the function finishes, the request is fully
715 # handled and no new frames for it should be seen.
716
693 717 def sendframes():
694 for frame in createbytesresponseframesfromgen(stream, requestid,
695 gen):
696 yield frame
718 emitted = False
719 while True:
720 try:
721 o = next(objs)
722 except StopIteration:
723 if emitted:
724 yield createcommandresponseeosframe(stream, requestid)
725 break
726
727 except error.WireprotoCommandError as e:
728 for frame in createcommanderrorresponse(
729 stream, requestid, e.message, e.messageargs):
730 yield frame
731 break
732
733 except Exception as e:
734 for frame in createerrorframe(stream, requestid,
735 '%s' % e,
736 errtype='server'):
737 yield frame
738
739 break
740
741 try:
742 if not emitted:
743 yield createcommandresponseokframe(stream, requestid)
744 emitted = True
745
746 # TODO buffer chunks so emitted frame payloads can be
747 # larger.
748 for frame in createbytesresponseframesfromgen(
749 stream, requestid, cborutil.streamencode(o)):
750 yield frame
751 except Exception as e:
752 for frame in createerrorframe(stream, requestid,
753 '%s' % e,
754 errtype='server'):
755 yield frame
756
757 break
697 758
698 759 self._activecommands.remove(requestid)
699 760
@@ -106,27 +106,6 b' class streamreslegacy(object):'
106 106 def __init__(self, gen=None):
107 107 self.gen = gen
108 108
109 class cborresponse(object):
110 """Encode the response value as CBOR."""
111 def __init__(self, v):
112 self.value = v
113
114 class v2errorresponse(object):
115 """Represents a command error for version 2 transports."""
116 def __init__(self, message, args=None):
117 self.message = message
118 self.args = args
119
120 class v2streamingresponse(object):
121 """A response whose data is supplied by a generator.
122
123 The generator can either consist of data structures to CBOR
124 encode or a stream of already-encoded bytes.
125 """
126 def __init__(self, gen, compressible=True):
127 self.gen = gen
128 self.compressible = compressible
129
130 109 # list of nodes encoding / decoding
131 110 def decodelist(l, sep=' '):
132 111 if l:
@@ -124,6 +124,8 b' class clienthandler(object):'
124 124 else:
125 125 raise e
126 126
127 return
128
127 129 if frame.requestid not in self._requests:
128 130 raise error.ProgrammingError(
129 131 'received frame for unknown request; this is either a bug in '
@@ -19,7 +19,6 b' from . import ('
19 19 wireprototypes,
20 20 )
21 21 from .utils import (
22 cborutil,
23 22 interfaceutil,
24 23 )
25 24
@@ -295,31 +294,19 b' def _httpv2runcommand(ui, repo, req, res'
295 294 res.setbodybytes(_('command in frame must match command in URL'))
296 295 return True
297 296
298 rsp = dispatch(repo, proto, command['command'])
299
300 297 res.status = b'200 OK'
301 298 res.headers[b'Content-Type'] = FRAMINGTYPE
302 299
303 # TODO consider adding a type to represent an iterable of values to
304 # be CBOR encoded.
305 if isinstance(rsp, wireprototypes.cborresponse):
306 # TODO consider calling oncommandresponsereadygen().
307 encoded = b''.join(cborutil.streamencode(rsp.value))
308 action, meta = reactor.oncommandresponseready(outstream,
309 command['requestid'],
310 encoded)
311 elif isinstance(rsp, wireprototypes.v2streamingresponse):
312 action, meta = reactor.oncommandresponsereadygen(outstream,
313 command['requestid'],
314 rsp.gen)
315 elif isinstance(rsp, wireprototypes.v2errorresponse):
316 action, meta = reactor.oncommanderror(outstream,
317 command['requestid'],
318 rsp.message,
319 rsp.args)
320 else:
300 try:
301 objs = dispatch(repo, proto, command['command'])
302
303 action, meta = reactor.oncommandresponsereadyobjects(
304 outstream, command['requestid'], objs)
305
306 except Exception as e:
321 307 action, meta = reactor.onservererror(
322 _('unhandled response type from wire proto command'))
308 outstream, command['requestid'],
309 _('exception when invoking command: %s') % e)
323 310
324 311 if action == 'sendframes':
325 312 res.setbodygen(meta['framegen'])
@@ -430,6 +417,12 b' def wireprotocommand(name, args=None, pe'
430 417 respectively. Default is to assume command requires ``push`` permissions
431 418 because otherwise commands not declaring their permissions could modify
432 419 a repository that is supposed to be read-only.
420
421 Wire protocol commands are generators of objects to be serialized and
422 sent to the client.
423
424 If a command raises an uncaught exception, this will be translated into
425 a command error.
433 426 """
434 427 transports = {k for k, v in wireprototypes.TRANSPORTS.items()
435 428 if v['version'] == 2}
@@ -460,16 +453,12 b' def wireprotocommand(name, args=None, pe'
460 453
461 454 @wireprotocommand('branchmap', permission='pull')
462 455 def branchmapv2(repo, proto):
463 branchmap = {encoding.fromlocal(k): v
464 for k, v in repo.branchmap().iteritems()}
465
466 return wireprototypes.cborresponse(branchmap)
456 yield {encoding.fromlocal(k): v
457 for k, v in repo.branchmap().iteritems()}
467 458
468 459 @wireprotocommand('capabilities', permission='pull')
469 460 def capabilitiesv2(repo, proto):
470 caps = _capabilitiesv2(repo, proto)
471
472 return wireprototypes.cborresponse(caps)
461 yield _capabilitiesv2(repo, proto)
473 462
474 463 @wireprotocommand('heads',
475 464 args={
@@ -480,7 +469,7 b' def headsv2(repo, proto, publiconly=Fals'
480 469 if publiconly:
481 470 repo = repo.filtered('immutable')
482 471
483 return wireprototypes.cborresponse(repo.heads())
472 yield repo.heads()
484 473
485 474 @wireprotocommand('known',
486 475 args={
@@ -490,7 +479,7 b' def headsv2(repo, proto, publiconly=Fals'
490 479 def knownv2(repo, proto, nodes=None):
491 480 nodes = nodes or []
492 481 result = b''.join(b'1' if n else b'0' for n in repo.known(nodes))
493 return wireprototypes.cborresponse(result)
482 yield result
494 483
495 484 @wireprotocommand('listkeys',
496 485 args={
@@ -502,7 +491,7 b' def listkeysv2(repo, proto, namespace=No'
502 491 keys = {encoding.fromlocal(k): encoding.fromlocal(v)
503 492 for k, v in keys.iteritems()}
504 493
505 return wireprototypes.cborresponse(keys)
494 yield keys
506 495
507 496 @wireprotocommand('lookup',
508 497 args={
@@ -515,7 +504,7 b' def lookupv2(repo, proto, key):'
515 504 # TODO handle exception.
516 505 node = repo.lookup(key)
517 506
518 return wireprototypes.cborresponse(node)
507 yield node
519 508
520 509 @wireprotocommand('pushkey',
521 510 args={
@@ -527,9 +516,7 b' def lookupv2(repo, proto, key):'
527 516 permission='push')
528 517 def pushkeyv2(repo, proto, namespace, key, old, new):
529 518 # TODO handle ui output redirection
530 r = repo.pushkey(encoding.tolocal(namespace),
531 encoding.tolocal(key),
532 encoding.tolocal(old),
533 encoding.tolocal(new))
534
535 return wireprototypes.cborresponse(r)
519 yield repo.pushkey(encoding.tolocal(namespace),
520 encoding.tolocal(key),
521 encoding.tolocal(old),
522 encoding.tolocal(new))
@@ -176,8 +176,14 b' Request to read-only command works out o'
176 176 s> Content-Type: application/mercurial-exp-framing-0005\r\n
177 177 s> Transfer-Encoding: chunked\r\n
178 178 s> \r\n
179 s> 32\r\n
180 s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response
179 s> 13\r\n
180 s> \x0b\x00\x00\x01\x00\x02\x011\xa1FstatusBok
181 s> \r\n
182 s> 27\r\n
183 s> \x1f\x00\x00\x01\x00\x02\x001X\x1dcustomreadonly bytes response
184 s> \r\n
185 s> 8\r\n
186 s> \x00\x00\x00\x01\x00\x02\x002
181 187 s> \r\n
182 188 s> 0\r\n
183 189 s> \r\n
@@ -203,13 +209,22 b' Request to read-only command works out o'
203 209 s> Content-Type: application/mercurial-exp-framing-0005\r\n
204 210 s> Transfer-Encoding: chunked\r\n
205 211 s> \r\n
206 s> 32\r\n
207 s> *\x00\x00\x01\x00\x02\x012
208 s> \xa1FstatusBokX\x1dcustomreadonly bytes response
212 s> 13\r\n
213 s> \x0b\x00\x00\x01\x00\x02\x011
214 s> \xa1FstatusBok
209 215 s> \r\n
210 received frame(size=42; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
216 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
217 s> 27\r\n
218 s> \x1f\x00\x00\x01\x00\x02\x001
219 s> X\x1dcustomreadonly bytes response
220 s> \r\n
221 received frame(size=31; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
222 s> 8\r\n
223 s> \x00\x00\x00\x01\x00\x02\x002
224 s> \r\n
211 225 s> 0\r\n
212 226 s> \r\n
227 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
213 228 response: [
214 229 {
215 230 b'status': b'ok'
@@ -322,8 +337,14 b' Authorized request for valid read-write '
322 337 s> Content-Type: application/mercurial-exp-framing-0005\r\n
323 338 s> Transfer-Encoding: chunked\r\n
324 339 s> \r\n
325 s> 32\r\n
326 s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response
340 s> 13\r\n
341 s> \x0b\x00\x00\x01\x00\x02\x011\xa1FstatusBok
342 s> \r\n
343 s> 27\r\n
344 s> \x1f\x00\x00\x01\x00\x02\x001X\x1dcustomreadonly bytes response
345 s> \r\n
346 s> 8\r\n
347 s> \x00\x00\x00\x01\x00\x02\x002
327 348 s> \r\n
328 349 s> 0\r\n
329 350 s> \r\n
@@ -445,8 +466,14 b' Multiple requests to regular command URL'
445 466 s> Content-Type: application/mercurial-exp-framing-0005\r\n
446 467 s> Transfer-Encoding: chunked\r\n
447 468 s> \r\n
448 s> 32\r\n
449 s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response
469 s> 13\r\n
470 s> \x0b\x00\x00\x01\x00\x02\x011\xa1FstatusBok
471 s> \r\n
472 s> 27\r\n
473 s> \x1f\x00\x00\x01\x00\x02\x001X\x1dcustomreadonly bytes response
474 s> \r\n
475 s> 8\r\n
476 s> \x00\x00\x00\x01\x00\x02\x002
450 477 s> \r\n
451 478 s> 0\r\n
452 479 s> \r\n
@@ -478,11 +505,23 b' Multiple requests to "multirequest" URL '
478 505 s> Content-Type: application/mercurial-exp-framing-0005\r\n
479 506 s> Transfer-Encoding: chunked\r\n
480 507 s> \r\n
481 s> 32\r\n
482 s> *\x00\x00\x01\x00\x02\x012\xa1FstatusBokX\x1dcustomreadonly bytes response
508 s> 13\r\n
509 s> \x0b\x00\x00\x01\x00\x02\x011\xa1FstatusBok
510 s> \r\n
511 s> 27\r\n
512 s> \x1f\x00\x00\x01\x00\x02\x001X\x1dcustomreadonly bytes response
513 s> \r\n
514 s> 8\r\n
515 s> \x00\x00\x00\x01\x00\x02\x002
483 516 s> \r\n
484 s> 32\r\n
485 s> *\x00\x00\x03\x00\x02\x002\xa1FstatusBokX\x1dcustomreadonly bytes response
517 s> 13\r\n
518 s> \x0b\x00\x00\x03\x00\x02\x001\xa1FstatusBok
519 s> \r\n
520 s> 27\r\n
521 s> \x1f\x00\x00\x03\x00\x02\x001X\x1dcustomreadonly bytes response
522 s> \r\n
523 s> 8\r\n
524 s> \x00\x00\x00\x03\x00\x02\x002
486 525 s> \r\n
487 526 s> 0\r\n
488 527 s> \r\n
@@ -516,11 +555,23 b' Interleaved requests to "multirequest" a'
516 555 s> Content-Type: application/mercurial-exp-framing-0005\r\n
517 556 s> Transfer-Encoding: chunked\r\n
518 557 s> \r\n
519 s> 33\r\n
520 s> +\x00\x00\x03\x00\x02\x012\xa1FstatusBok\xa3Ibookmarks@Jnamespaces@Fphases@
558 s> 13\r\n
559 s> \x0b\x00\x00\x03\x00\x02\x011\xa1FstatusBok
560 s> \r\n
561 s> 28\r\n
562 s> \x00\x00\x03\x00\x02\x001\xa3Ibookmarks@Jnamespaces@Fphases@
563 s> \r\n
564 s> 8\r\n
565 s> \x00\x00\x00\x03\x00\x02\x002
521 566 s> \r\n
522 s> 14\r\n
523 s> \x0c\x00\x00\x01\x00\x02\x002\xa1FstatusBok\xa0
567 s> 13\r\n
568 s> \x0b\x00\x00\x01\x00\x02\x001\xa1FstatusBok
569 s> \r\n
570 s> 9\r\n
571 s> \x01\x00\x00\x01\x00\x02\x001\xa0
572 s> \r\n
573 s> 8\r\n
574 s> \x00\x00\x00\x01\x00\x02\x002
524 575 s> \r\n
525 576 s> 0\r\n
526 577 s> \r\n
@@ -331,13 +331,22 b' Client with HTTPv2 enabled automatically'
331 331 s> Content-Type: application/mercurial-exp-framing-0005\r\n
332 332 s> Transfer-Encoding: chunked\r\n
333 333 s> \r\n
334 s> 29\r\n
335 s> !\x00\x00\x01\x00\x02\x012
336 s> \xa1FstatusBok\x81T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
334 s> 13\r\n
335 s> \x0b\x00\x00\x01\x00\x02\x011
336 s> \xa1FstatusBok
337 337 s> \r\n
338 received frame(size=33; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
338 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
339 s> 1e\r\n
340 s> \x16\x00\x00\x01\x00\x02\x001
341 s> \x81T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
342 s> \r\n
343 received frame(size=22; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
344 s> 8\r\n
345 s> \x00\x00\x00\x01\x00\x02\x002
346 s> \r\n
339 347 s> 0\r\n
340 348 s> \r\n
349 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
341 350 response: [
342 351 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
343 352 ]
@@ -59,14 +59,23 b' No arguments returns something reasonabl'
59 59 s> Content-Type: application/mercurial-exp-framing-0005\r\n
60 60 s> Transfer-Encoding: chunked\r\n
61 61 s> \r\n
62 s> 83\r\n
63 s> {\x00\x00\x01\x00\x02\x012
64 s> \xa1FstatusBok\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
62 s> 13\r\n
63 s> \x0b\x00\x00\x01\x00\x02\x011
64 s> \xa1FstatusBok
65 s> \r\n
66 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
67 s> 78\r\n
68 s> p\x00\x00\x01\x00\x02\x001
69 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 70 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 71 s> \r\n
67 received frame(size=123; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
72 received frame(size=112; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
73 s> 8\r\n
74 s> \x00\x00\x00\x01\x00\x02\x002
75 s> \r\n
68 76 s> 0\r\n
69 77 s> \r\n
78 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
70 79 response: {
71 80 b'branch1': [
72 81 b'\xb5\xfa\xac\xdf\xd2c7h\xcb1R3l\xc0\x953\x81&f\x88'
@@ -333,13 +333,22 b' capabilities command returns expected in'
333 333 s> Content-Type: application/mercurial-exp-framing-0005\r\n
334 334 s> Transfer-Encoding: chunked\r\n
335 335 s> \r\n
336 s> 1d7\r\n
337 s> \xcf\x01\x00\x01\x00\x02\x012
338 s> \xa1FstatusBok\xa4Hcommands\xa7Ibranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyInamespaceBnsCnewCnewColdColdKpermissions\x81DpushKcompression\x81\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Nrawrepoformats\x82LgeneraldeltaHrevlogv1
336 s> 13\r\n
337 s> \x0b\x00\x00\x01\x00\x02\x011
338 s> \xa1FstatusBok
339 339 s> \r\n
340 received frame(size=463; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
340 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
341 s> 1cc\r\n
342 s> \xc4\x01\x00\x01\x00\x02\x001
343 s> \xa4Hcommands\xa7Ibranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyInamespaceBnsCnewCnewColdColdKpermissions\x81DpushKcompression\x81\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Nrawrepoformats\x82LgeneraldeltaHrevlogv1
344 s> \r\n
345 received frame(size=452; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
346 s> 8\r\n
347 s> \x00\x00\x00\x01\x00\x02\x002
348 s> \r\n
341 349 s> 0\r\n
342 350 s> \r\n
351 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
343 352 response: [
344 353 {
345 354 b'status': b'ok'
@@ -51,13 +51,22 b' All non-secret heads returned by default'
51 51 s> Content-Type: application/mercurial-exp-framing-0005\r\n
52 52 s> Transfer-Encoding: chunked\r\n
53 53 s> \r\n
54 s> 53\r\n
55 s> K\x00\x00\x01\x00\x02\x012
56 s> \xa1FstatusBok\x83T\x1dok\x91\xd4J\xab\xa6\xd5\xe5\x80\xbc0\xa9\x94\x850\xdb\xe0\x0bT\xaeI.6\xb0\xc83\x9f\xfa\xf3(\xd0\x0b\x85\xb4R]\xe1\x16^T)Dm-\xc5A\x9c_\x97Dz\x8b\xc0b\xe4\xcc2\x8b\xf2A
54 s> 13\r\n
55 s> \x0b\x00\x00\x01\x00\x02\x011
56 s> \xa1FstatusBok
57 57 s> \r\n
58 received frame(size=75; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
58 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
59 s> 48\r\n
60 s> @\x00\x00\x01\x00\x02\x001
61 s> \x83T\x1dok\x91\xd4J\xab\xa6\xd5\xe5\x80\xbc0\xa9\x94\x850\xdb\xe0\x0bT\xaeI.6\xb0\xc83\x9f\xfa\xf3(\xd0\x0b\x85\xb4R]\xe1\x16^T)Dm-\xc5A\x9c_\x97Dz\x8b\xc0b\xe4\xcc2\x8b\xf2A
62 s> \r\n
63 received frame(size=64; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
64 s> 8\r\n
65 s> \x00\x00\x00\x01\x00\x02\x002
66 s> \r\n
59 67 s> 0\r\n
60 68 s> \r\n
69 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
61 70 response: [
62 71 b'\x1dok\x91\xd4J\xab\xa6\xd5\xe5\x80\xbc0\xa9\x94\x850\xdb\xe0\x0b',
63 72 b'\xaeI.6\xb0\xc83\x9f\xfa\xf3(\xd0\x0b\x85\xb4R]\xe1\x16^',
@@ -88,13 +97,22 b' Requesting just the public heads works'
88 97 s> Content-Type: application/mercurial-exp-framing-0005\r\n
89 98 s> Transfer-Encoding: chunked\r\n
90 99 s> \r\n
91 s> 29\r\n
92 s> !\x00\x00\x01\x00\x02\x012
93 s> \xa1FstatusBok\x81Tx\xd2\xdc\xa46\xb2\xf5\xb1\x88\xac&~)\xb8\x1e\x07&m8\xfc
100 s> 13\r\n
101 s> \x0b\x00\x00\x01\x00\x02\x011
102 s> \xa1FstatusBok
94 103 s> \r\n
95 received frame(size=33; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
104 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
105 s> 1e\r\n
106 s> \x16\x00\x00\x01\x00\x02\x001
107 s> \x81Tx\xd2\xdc\xa46\xb2\xf5\xb1\x88\xac&~)\xb8\x1e\x07&m8\xfc
108 s> \r\n
109 received frame(size=22; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
110 s> 8\r\n
111 s> \x00\x00\x00\x01\x00\x02\x002
112 s> \r\n
96 113 s> 0\r\n
97 114 s> \r\n
115 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
98 116 response: [
99 117 b'x\xd2\xdc\xa46\xb2\xf5\xb1\x88\xac&~)\xb8\x1e\x07&m8\xfc'
100 118 ]
@@ -43,13 +43,22 b' No arguments returns something reasonabl'
43 43 s> Content-Type: application/mercurial-exp-framing-0005\r\n
44 44 s> Transfer-Encoding: chunked\r\n
45 45 s> \r\n
46 s> 14\r\n
47 s> \x0c\x00\x00\x01\x00\x02\x012
48 s> \xa1FstatusBok@
46 s> 13\r\n
47 s> \x0b\x00\x00\x01\x00\x02\x011
48 s> \xa1FstatusBok
49 49 s> \r\n
50 received frame(size=12; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
50 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
51 s> 9\r\n
52 s> \x01\x00\x00\x01\x00\x02\x001
53 s> @
54 s> \r\n
55 received frame(size=1; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
56 s> 8\r\n
57 s> \x00\x00\x00\x01\x00\x02\x002
58 s> \r\n
51 59 s> 0\r\n
52 60 s> \r\n
61 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
53 62 response: []
54 63
55 64 Single known node works
@@ -76,13 +85,22 b' Single known node works'
76 85 s> Content-Type: application/mercurial-exp-framing-0005\r\n
77 86 s> Transfer-Encoding: chunked\r\n
78 87 s> \r\n
79 s> 15\r\n
80 s> \r\x00\x00\x01\x00\x02\x012
81 s> \xa1FstatusBokA1
88 s> 13\r\n
89 s> \x0b\x00\x00\x01\x00\x02\x011
90 s> \xa1FstatusBok
82 91 s> \r\n
83 received frame(size=13; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
92 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
93 s> a\r\n
94 s> \x02\x00\x00\x01\x00\x02\x001
95 s> A1
96 s> \r\n
97 received frame(size=2; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
98 s> 8\r\n
99 s> \x00\x00\x00\x01\x00\x02\x002
100 s> \r\n
84 101 s> 0\r\n
85 102 s> \r\n
103 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
86 104 response: [
87 105 True
88 106 ]
@@ -111,13 +129,22 b' Multiple nodes works'
111 129 s> Content-Type: application/mercurial-exp-framing-0005\r\n
112 130 s> Transfer-Encoding: chunked\r\n
113 131 s> \r\n
114 s> 17\r\n
115 s> \x0f\x00\x00\x01\x00\x02\x012
116 s> \xa1FstatusBokC101
132 s> 13\r\n
133 s> \x0b\x00\x00\x01\x00\x02\x011
134 s> \xa1FstatusBok
117 135 s> \r\n
118 received frame(size=15; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
136 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
137 s> c\r\n
138 s> \x04\x00\x00\x01\x00\x02\x001
139 s> C101
140 s> \r\n
141 received frame(size=4; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
142 s> 8\r\n
143 s> \x00\x00\x00\x01\x00\x02\x002
144 s> \r\n
119 145 s> 0\r\n
120 146 s> \r\n
147 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
121 148 response: [
122 149 True,
123 150 False,
@@ -47,13 +47,22 b' Request for namespaces works'
47 47 s> Content-Type: application/mercurial-exp-framing-0005\r\n
48 48 s> Transfer-Encoding: chunked\r\n
49 49 s> \r\n
50 s> 33\r\n
51 s> +\x00\x00\x01\x00\x02\x012
52 s> \xa1FstatusBok\xa3Ibookmarks@Jnamespaces@Fphases@
50 s> 13\r\n
51 s> \x0b\x00\x00\x01\x00\x02\x011
52 s> \xa1FstatusBok
53 53 s> \r\n
54 received frame(size=43; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
54 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
55 s> 28\r\n
56 s> \x00\x00\x01\x00\x02\x001
57 s> \xa3Ibookmarks@Jnamespaces@Fphases@
58 s> \r\n
59 received frame(size=32; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
60 s> 8\r\n
61 s> \x00\x00\x00\x01\x00\x02\x002
62 s> \r\n
55 63 s> 0\r\n
56 64 s> \r\n
65 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
57 66 response: {
58 67 b'bookmarks': b'',
59 68 b'namespaces': b'',
@@ -84,13 +93,22 b' Request for phases works'
84 93 s> Content-Type: application/mercurial-exp-framing-0005\r\n
85 94 s> Transfer-Encoding: chunked\r\n
86 95 s> \r\n
87 s> 50\r\n
88 s> H\x00\x00\x01\x00\x02\x012
89 s> \xa1FstatusBok\xa2X(be0ef73c17ade3fc89dc41701eb9fc3a91b58282A1JpublishingDTrue
96 s> 13\r\n
97 s> \x0b\x00\x00\x01\x00\x02\x011
98 s> \xa1FstatusBok
90 99 s> \r\n
91 received frame(size=72; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
100 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
101 s> 45\r\n
102 s> =\x00\x00\x01\x00\x02\x001
103 s> \xa2X(be0ef73c17ade3fc89dc41701eb9fc3a91b58282A1JpublishingDTrue
104 s> \r\n
105 received frame(size=61; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
106 s> 8\r\n
107 s> \x00\x00\x00\x01\x00\x02\x002
108 s> \r\n
92 109 s> 0\r\n
93 110 s> \r\n
111 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
94 112 response: {
95 113 b'be0ef73c17ade3fc89dc41701eb9fc3a91b58282': b'1',
96 114 b'publishing': b'True'
@@ -120,13 +138,22 b' Request for bookmarks works'
120 138 s> Content-Type: application/mercurial-exp-framing-0005\r\n
121 139 s> Transfer-Encoding: chunked\r\n
122 140 s> \r\n
123 s> 40\r\n
124 s> 8\x00\x00\x01\x00\x02\x012
125 s> \xa1FstatusBok\xa1A@X(26805aba1e600a82e93661149f2313866a221a7b
141 s> 13\r\n
142 s> \x0b\x00\x00\x01\x00\x02\x011
143 s> \xa1FstatusBok
126 144 s> \r\n
127 received frame(size=56; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
145 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
146 s> 35\r\n
147 s> -\x00\x00\x01\x00\x02\x001
148 s> \xa1A@X(26805aba1e600a82e93661149f2313866a221a7b
149 s> \r\n
150 received frame(size=45; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
151 s> 8\r\n
152 s> \x00\x00\x00\x01\x00\x02\x002
153 s> \r\n
128 154 s> 0\r\n
129 155 s> \r\n
156 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
130 157 response: {
131 158 b'@': b'26805aba1e600a82e93661149f2313866a221a7b'
132 159 }
@@ -43,13 +43,22 b' lookup for known node works'
43 43 s> Content-Type: application/mercurial-exp-framing-0005\r\n
44 44 s> Transfer-Encoding: chunked\r\n
45 45 s> \r\n
46 s> 28\r\n
47 s> \x00\x00\x01\x00\x02\x012
48 s> \xa1FstatusBokTBk\xad\xa5\xc6u\x98\xcae\x03mW\xd9\xe4\xb6K\x0c\x1c\xe7\xa0
46 s> 13\r\n
47 s> \x0b\x00\x00\x01\x00\x02\x011
48 s> \xa1FstatusBok
49 49 s> \r\n
50 received frame(size=32; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
50 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
51 s> 1d\r\n
52 s> \x15\x00\x00\x01\x00\x02\x001
53 s> TBk\xad\xa5\xc6u\x98\xcae\x03mW\xd9\xe4\xb6K\x0c\x1c\xe7\xa0
54 s> \r\n
55 received frame(size=21; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
56 s> 8\r\n
57 s> \x00\x00\x00\x01\x00\x02\x002
58 s> \r\n
51 59 s> 0\r\n
52 60 s> \r\n
61 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
53 62 response: b'Bk\xad\xa5\xc6u\x98\xcae\x03mW\xd9\xe4\xb6K\x0c\x1c\xe7\xa0'
54 63
55 64 $ cat error.log
@@ -46,13 +46,22 b' pushkey for a bookmark works'
46 46 s> Content-Type: application/mercurial-exp-framing-0005\r\n
47 47 s> Transfer-Encoding: chunked\r\n
48 48 s> \r\n
49 s> 14\r\n
50 s> \x0c\x00\x00\x01\x00\x02\x012
51 s> \xa1FstatusBok\xf5
49 s> 13\r\n
50 s> \x0b\x00\x00\x01\x00\x02\x011
51 s> \xa1FstatusBok
52 52 s> \r\n
53 received frame(size=12; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
53 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
54 s> 9\r\n
55 s> \x01\x00\x00\x01\x00\x02\x001
56 s> \xf5
57 s> \r\n
58 received frame(size=1; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
59 s> 8\r\n
60 s> \x00\x00\x00\x01\x00\x02\x002
61 s> \r\n
54 62 s> 0\r\n
55 63 s> \r\n
64 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
56 65 response: True
57 66
58 67 $ sendhttpv2peer << EOF
@@ -77,13 +86,22 b' pushkey for a bookmark works'
77 86 s> Content-Type: application/mercurial-exp-framing-0005\r\n
78 87 s> Transfer-Encoding: chunked\r\n
79 88 s> \r\n
80 s> 40\r\n
81 s> 8\x00\x00\x01\x00\x02\x012
82 s> \xa1FstatusBok\xa1A@X(426bada5c67598ca65036d57d9e4b64b0c1ce7a0
89 s> 13\r\n
90 s> \x0b\x00\x00\x01\x00\x02\x011
91 s> \xa1FstatusBok
83 92 s> \r\n
84 received frame(size=56; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
93 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
94 s> 35\r\n
95 s> -\x00\x00\x01\x00\x02\x001
96 s> \xa1A@X(426bada5c67598ca65036d57d9e4b64b0c1ce7a0
97 s> \r\n
98 received frame(size=45; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
99 s> 8\r\n
100 s> \x00\x00\x00\x01\x00\x02\x002
101 s> \r\n
85 102 s> 0\r\n
86 103 s> \r\n
104 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
87 105 response: {
88 106 b'@': b'426bada5c67598ca65036d57d9e4b64b0c1ce7a0'
89 107 }
@@ -26,7 +26,7 b' def customreadonlyv1(repo, proto):'
26 26
27 27 @wireprotov2server.wireprotocommand(b'customreadonly', permission=b'pull')
28 28 def customreadonlyv2(repo, proto):
29 return wireprototypes.cborresponse(b'customreadonly bytes response')
29 yield b'customreadonly bytes response'
30 30
31 31 @wireprotov1server.wireprotocommand(b'customreadwrite', permission=b'push')
32 32 def customreadwrite(repo, proto):
@@ -34,7 +34,7 b' def customreadwrite(repo, proto):'
34 34
35 35 @wireprotov2server.wireprotocommand(b'customreadwrite', permission=b'push')
36 36 def customreadwritev2(repo, proto):
37 return wireprototypes.cborresponse(b'customreadwrite bytes response')
37 yield b'customreadwrite bytes response'
38 38 EOF
39 39
40 40 cat >> $HGRCPATH << EOF
General Comments 0
You need to be logged in to leave comments. Login now