comparison 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
comparison
equal deleted inserted replaced
39811:ae20f52437e9 39812:8e7e822e85ec
434 } 434 }
435 435
436 # TODO expose available changesetdata fields. 436 # TODO expose available changesetdata fields.
437 437
438 for command, entry in COMMANDS.items(): 438 for command, entry in COMMANDS.items():
439 args = {arg: meta['example'] for arg, meta in entry.args.items()} 439 args = {}
440
441 for arg, meta in entry.args.items():
442 args[arg] = {
443 # TODO should this be a normalized type using CBOR's
444 # terminology?
445 b'type': meta['type'],
446 b'required': meta['required'],
447 }
448
449 if not meta['required']:
450 args[arg][b'default'] = meta['default']()
440 451
441 caps['commands'][command] = { 452 caps['commands'][command] = {
442 'args': args, 453 'args': args,
443 'permissions': [entry.permission], 454 'permissions': [entry.permission],
444 } 455 }