Mercurial > hg
comparison mercurial/wireprotoserver.py @ 37061:884a0c1604ad
wireproto: define attr-based classes for representing frames
When frames only had 3 attributes, it was reasonable to
represent them as a tuple. With them growing more attributes,
it will be easier to pass them around as a more formal type.
So let's define attr-based classes to represent frame headers and
full frames.
Differential Revision: https://phab.mercurial-scm.org/D2899
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 15 Mar 2018 16:03:14 -0700 |
parents | bbea991635d0 |
children | a8a902d7176e |
comparison
equal
deleted
inserted
replaced
37060:0a6c5cc09a88 | 37061:884a0c1604ad |
---|---|
398 | 398 |
399 if not frame: | 399 if not frame: |
400 states.append(b'received: <no frame>') | 400 states.append(b'received: <no frame>') |
401 break | 401 break |
402 | 402 |
403 requestid, frametype, frameflags, payload = frame | 403 states.append(b'received: %d %d %d %s' % (frame.typeid, frame.flags, |
404 states.append(b'received: %d %d %d %s' % (frametype, frameflags, | 404 frame.requestid, |
405 requestid, payload)) | 405 frame.payload)) |
406 | 406 |
407 action, meta = reactor.onframerecv(requestid, frametype, frameflags, | 407 action, meta = reactor.onframerecv(frame) |
408 payload) | |
409 states.append(json.dumps((action, meta), sort_keys=True, | 408 states.append(json.dumps((action, meta), sort_keys=True, |
410 separators=(', ', ': '))) | 409 separators=(', ', ': '))) |
411 | 410 |
412 action, meta = reactor.oninputeof() | 411 action, meta = reactor.oninputeof() |
413 meta['action'] = action | 412 meta['action'] = action |
432 while True: | 431 while True: |
433 frame = wireprotoframing.readframe(req.bodyfh) | 432 frame = wireprotoframing.readframe(req.bodyfh) |
434 if not frame: | 433 if not frame: |
435 break | 434 break |
436 | 435 |
437 action, meta = reactor.onframerecv(*frame) | 436 action, meta = reactor.onframerecv(frame) |
438 | 437 |
439 if action == 'wantframe': | 438 if action == 'wantframe': |
440 # Need more data before we can do anything. | 439 # Need more data before we can do anything. |
441 continue | 440 continue |
442 elif action == 'runcommand': | 441 elif action == 'runcommand': |