parser: verify excessive number of args excluding kwargs in buildargsdict()
This makes the next patch slightly simpler. We don't need to check the
excessive number of keyword arguments since unknown and duplicated kwargs
are rejected.
--- a/mercurial/parser.py Mon Apr 10 16:50:23 2017 +0200
+++ b/mercurial/parser.py Sat Apr 08 20:07:37 2017 +0900
@@ -135,8 +135,9 @@
raise error.ParseError(_("%(func)s takes at least %(nargs)d positional "
"arguments")
% {'func': funcname, 'nargs': len(poskeys)})
- if not varkey and len(trees) > len(poskeys) + len(keys):
- raise error.ParseError(_("%(func)s takes at most %(nargs)d arguments")
+ if not varkey and kwstart > len(poskeys) + len(keys):
+ raise error.ParseError(_("%(func)s takes at most %(nargs)d positional "
+ "arguments")
% {'func': funcname,
'nargs': len(poskeys) + len(keys)})
args = {}
--- a/tests/test-revset.t Mon Apr 10 16:50:23 2017 +0200
+++ b/tests/test-revset.t Sat Apr 08 20:07:37 2017 +0900
@@ -454,7 +454,7 @@
0
$ log 'extra(branch, a, b)'
- hg: parse error: extra takes at most 2 arguments
+ hg: parse error: extra takes at most 2 positional arguments
[255]
$ log 'extra(a, label=b)'
hg: parse error: extra got multiple values for keyword argument 'label'