revset: check for collisions between alias argument names in the declaration
Before this patch, collisions between alias argument names in the
declaration are ignored, and this silently causes unexpected alias
evaluation.
This patch checks for such collisions, and aborts (or shows a warning) when
collisions are detected.
This patch doesn't add a test to "test-revset.t", because a doctest is
enough to test the collisions detection itself.
--- a/mercurial/revset.py Sat Jan 10 23:18:11 2015 +0900
+++ b/mercurial/revset.py Sat Jan 10 23:18:11 2015 +0900
@@ -2203,6 +2203,8 @@
('foo($1, $2', None, None, 'at 10: unexpected token: end')
>>> _parsealiasdecl('foo("string')
('foo("string', None, None, 'at 5: unterminated string')
+ >>> _parsealiasdecl('foo($1, $2, $1)')
+ ('foo', None, None, 'argument names collide with each other')
"""
p = parser.parser(_tokenizealias, elements)
try:
@@ -2227,6 +2229,9 @@
if not isvalidsymbol(arg):
return (decl, None, None, _("invalid argument list"))
args.append(getsymbol(arg))
+ if len(args) != len(set(args)):
+ return (name, None, None,
+ _("argument names collide with each other"))
return (name, ('func', ('symbol', name)), args, None)
return (decl, None, None, _("invalid format"))