diff --git a/mercurial/wireprotov2server.py b/mercurial/wireprotov2server.py --- a/mercurial/wireprotov2server.py +++ b/mercurial/wireprotov2server.py @@ -362,7 +362,7 @@ ', '.join(sorted(extra))) # And look for required arguments that are missing. - missing = {a for a in args if args[a].get('required')} - set(self._args) + missing = {a for a in args if args[a]['required']} - set(self._args) if missing: raise error.WireprotoCommandError( @@ -374,7 +374,7 @@ for k, meta in sorted(args.items()): # This argument wasn't passed by the client. if k not in self._args: - data[k] = meta.get('default', lambda: None)() + data[k] = meta['default']() continue v = self._args[k] @@ -543,7 +543,8 @@ or ``bool``. ``default`` - A callable returning the default value for this argument. + A callable returning the default value for this argument. If not + specified, ``None`` will be the default value. ``required`` Bool indicating whether the argument is required. @@ -600,6 +601,9 @@ raise error.ProgrammingError('%s argument for command %s does not ' 'declare example field' % (arg, name)) + meta.setdefault('default', lambda: None) + meta.setdefault('required', False) + def register(func): if name in COMMANDS: raise error.ProgrammingError('%s command already registered '