##// END OF EJS Templates
revsetlang: check number of arguments passed to formatspec()
Yuya Nishihara -
r35610:0fd617af default
parent child Browse files
Show More
@@ -634,15 +634,27 b' def formatspec(expr, *args):'
634 d = expr[pos]
634 d = expr[pos]
635 if d == '%':
635 if d == '%':
636 ret.append(d)
636 ret.append(d)
637 elif d == 'l':
637 pos += 1
638 continue
639
640 try:
641 arg = next(argiter)
642 except StopIteration:
643 raise error.ParseError(_('missing argument for revspec'))
644 if d == 'l':
638 # a list of some type
645 # a list of some type
639 pos += 1
646 pos += 1
640 d = expr[pos]
647 d = expr[pos]
641 ret.append(listexp(list(next(argiter)), d))
648 ret.append(listexp(list(arg), d))
642 else:
649 else:
643 ret.append(argtype(d, next(argiter)))
650 ret.append(argtype(d, arg))
644 pos += 1
651 pos += 1
645
652
653 try:
654 next(argiter)
655 raise error.ParseError(_('too many revspec arguments specified'))
656 except StopIteration:
657 pass
646 return ''.join(ret)
658 return ''.join(ret)
647
659
648 def prettyformat(tree):
660 def prettyformat(tree):
@@ -4088,6 +4088,15 b' Invalid arguments passed to revset()'
4088 $ hg log -T '{revset("%lwhatever", files)}\n'
4088 $ hg log -T '{revset("%lwhatever", files)}\n'
4089 hg: parse error: unexpected revspec format character w
4089 hg: parse error: unexpected revspec format character w
4090 [255]
4090 [255]
4091 $ hg log -T '{revset("%s %s", 0)}\n'
4092 hg: parse error: missing argument for revspec
4093 [255]
4094 $ hg log -T '{revset("", 0)}\n'
4095 hg: parse error: too many revspec arguments specified
4096 [255]
4097 $ hg log -T '{revset("%s", 0, 1)}\n'
4098 hg: parse error: too many revspec arguments specified
4099 [255]
4091
4100
4092 Test files function
4101 Test files function
4093
4102
General Comments 0
You need to be logged in to leave comments. Login now