Mercurial > public > mercurial-scm > hg
diff mercurial/wireprotov2server.py @ 39812:8e7e822e85ec
wireprotov2: expose rich arguments metadata
Now that we internally store rich metadata about arguments, it makes
sense to make that metadata available to the client. This will allow
clients to validate outgoing command requests before they are sent
over the wire.
Strictly speaking, we should bump the wire protocol version for this
change since it is backwards incompatible. But no client-side code
touches the arguments map and I don't want to incur the work.
Differential Revision: https://phab.mercurial-scm.org/D4618
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 17 Sep 2018 10:15:27 -0700 |
parents | ae20f52437e9 |
children | c30faea8d02d |
line wrap: on
line diff
--- a/mercurial/wireprotov2server.py Mon Sep 17 09:49:28 2018 -0700 +++ b/mercurial/wireprotov2server.py Mon Sep 17 10:15:27 2018 -0700 @@ -436,7 +436,18 @@ # TODO expose available changesetdata fields. for command, entry in COMMANDS.items(): - args = {arg: meta['example'] for arg, meta in entry.args.items()} + args = {} + + for arg, meta in entry.args.items(): + args[arg] = { + # TODO should this be a normalized type using CBOR's + # terminology? + b'type': meta['type'], + b'required': meta['required'], + } + + if not meta['required']: + args[arg][b'default'] = meta['default']() caps['commands'][command] = { 'args': args,