Patchwork [6,of,6,V2] revset: check collision between alias argument names in the declaration

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Jan. 10, 2015, 2:25 p.m.
Message ID <c623e015a449750d89ca.1420899946@feefifofum>
Download mbox | patch
Permalink /patch/7423/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Jan. 10, 2015, 2:25 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1420899491 -32400
#      Sat Jan 10 23:18:11 2015 +0900
# Node ID c623e015a449750d89ca412a1c26f0175362c778
# Parent  950ed266b47516098bc350b1b835c3de085c5e9f
revset: check collision between alias argument names in the declaration

Before this patch, collision between alias argument names in the
declaration is ignored, and this silently causes unexpected alias
evaluation.

This patch checks such collision, and aborts (or show warning) when
collision is detected.

This patch doesn't add test to "test-revset.t", because doctest is
enough to test error detection itself.
Pierre-Yves David - Jan. 14, 2015, 9:57 p.m.
On 01/10/2015 06:25 AM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1420899491 -32400
> #      Sat Jan 10 23:18:11 2015 +0900
> # Node ID c623e015a449750d89ca412a1c26f0175362c778
> # Parent  950ed266b47516098bc350b1b835c3de085c5e9f
> revset: check collision between alias argument names in the declaration

This series looks good to me and have been pushed tot he clowncopter. 
I've done some english fixing, butthere is multiple other place where I 
feel like there is adjustement to be made.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2166,6 +2166,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:
@@ -2190,6 +2192,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"))