Mercurial > hg
comparison mercurial/wireprotoserver.py @ 37535:69e46c1834ac
wireproto: define and expose types of wire command arguments
Exposing the set of argument names is cool. But with wire protocol
version 2, we're using CBOR to transport arguments and this allows us
to have typing for arguments.
Typed arguments are much nicer because they will cut down on transfer
overhead and processing overhead for decoding values.
This commit teaches @wireprotocommand to accept a dictionary for
arguments. The arguments registered for version 2 transports are
canonically stored as dictionaries rather than a space-delimited string.
It is an error to defined arguments with a dictionary for commands using
version 1 transports. This reinforces my intent to fully decouple command
handlers for version 2 transports.
Differential Revision: https://phab.mercurial-scm.org/D3202
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 06 Apr 2018 17:14:06 -0700 |
parents | df4985497986 |
children | 93397c4633f6 |
comparison
equal
deleted
inserted
replaced
37534:465187fec06f | 37535:69e46c1834ac |
---|---|
604 def name(self): | 604 def name(self): |
605 return HTTPV2 | 605 return HTTPV2 |
606 | 606 |
607 def getargs(self, args): | 607 def getargs(self, args): |
608 data = {} | 608 data = {} |
609 for k in args.split(): | 609 for k, typ in args.items(): |
610 if k == '*': | 610 if k == '*': |
611 raise NotImplementedError('do not support * args') | 611 raise NotImplementedError('do not support * args') |
612 elif k in self._args: | 612 elif k in self._args: |
613 # TODO consider validating value types. | |
613 data[k] = self._args[k] | 614 data[k] = self._args[k] |
614 | 615 |
615 return data | 616 return data |
616 | 617 |
617 def getprotocaps(self): | 618 def getprotocaps(self): |