# HG changeset patch # User FUJIWARA Katsunori # Date 1420899491 -32400 # Node ID 71402bb8d8b274d82169cf26253e38ef793794f5 # Parent aac4a1a7920e3cd7b1810f3d067ea6fa30aca9da 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. diff -r aac4a1a7920e -r 71402bb8d8b2 mercurial/revset.py --- 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"))