Mercurial > hg
changeset 23847:71402bb8d8b2
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 10 Jan 2015 23:18:11 +0900 |
parents | aac4a1a7920e |
children | c5456b64eb07 |
files | mercurial/revset.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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"))