# HG changeset patch # User FUJIWARA Katsunori # Date 2015-01-10 14:18:11 # 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 --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2203,6 +2203,8 @@ def _parsealiasdecl(decl): ('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 @@ def _parsealiasdecl(decl): 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"))