--- a/mercurial/revsetlang.py Sat Apr 01 17:18:31 2017 +0900
+++ b/mercurial/revsetlang.py Sat Apr 01 17:25:45 2017 +0900
@@ -634,15 +634,27 @@
d = expr[pos]
if d == '%':
ret.append(d)
- elif d == 'l':
+ pos += 1
+ continue
+
+ try:
+ arg = next(argiter)
+ except StopIteration:
+ raise error.ParseError(_('missing argument for revspec'))
+ if d == 'l':
# a list of some type
pos += 1
d = expr[pos]
- ret.append(listexp(list(next(argiter)), d))
+ ret.append(listexp(list(arg), d))
else:
- ret.append(argtype(d, next(argiter)))
+ ret.append(argtype(d, arg))
pos += 1
+ try:
+ next(argiter)
+ raise error.ParseError(_('too many revspec arguments specified'))
+ except StopIteration:
+ pass
return ''.join(ret)
def prettyformat(tree):
--- a/tests/test-command-template.t Sat Apr 01 17:18:31 2017 +0900
+++ b/tests/test-command-template.t Sat Apr 01 17:25:45 2017 +0900
@@ -4088,6 +4088,15 @@
$ hg log -T '{revset("%lwhatever", files)}\n'
hg: parse error: unexpected revspec format character w
[255]
+ $ hg log -T '{revset("%s %s", 0)}\n'
+ hg: parse error: missing argument for revspec
+ [255]
+ $ hg log -T '{revset("", 0)}\n'
+ hg: parse error: too many revspec arguments specified
+ [255]
+ $ hg log -T '{revset("%s", 0, 1)}\n'
+ hg: parse error: too many revspec arguments specified
+ [255]
Test files function