Patchwork [4,of,4] revset: make _parsealiasdecl() simply return the original parsed tree

login
register
mail settings
Submitter Yuya Nishihara
Date March 30, 2016, 3:38 p.m.
Message ID <744b168050832926b97d.1459352301@mimosa>
Download mbox | patch
Permalink /patch/14190/
State Accepted
Headers show

Comments

Yuya Nishihara - March 30, 2016, 3:38 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1456735566 -32400
#      Mon Feb 29 17:46:06 2016 +0900
# Node ID 744b168050832926b97dfefe486d6f33bcc7d8b2
# Parent  ab9445ee0dbe55f4258645e065f7121df2c6f83a
revset: make _parsealiasdecl() simply return the original parsed tree

It wasn't necessary to reconstruct the same tuple.
Pierre-Yves David - April 1, 2016, 3:46 a.m.
On 03/30/2016 08:38 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1456735566 -32400
> #      Mon Feb 29 17:46:06 2016 +0900
> # Node ID 744b168050832926b97dfefe486d6f33bcc7d8b2
> # Parent  ab9445ee0dbe55f4258645e065f7121df2c6f83a
> revset: make _parsealiasdecl() simply return the original parsed tree

I've taken this.

Dropping all this checks is a bit scary, but no test complains so I 
guess we can trust the parser. inlining all this functions are a bit sad 
as this make the code less readable.
However unifying these two code paths seems a noble goal as this will 
reduce code duplication and help maintainance and evolution.

Cheers

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2297,7 +2297,7 @@  def _parsealiasdecl(decl):
             name = tree[1]
             if name.startswith('$'):
                 return (decl, None, None, _("'$' not for alias arguments"))
-            return (name, ('symbol', name), None, None)
+            return (name, tree, None, None)
 
         if tree[0] == 'func' and tree[1][0] == 'symbol':
             # "name(arg, ....) = ...." style
@@ -2312,7 +2312,7 @@  def _parsealiasdecl(decl):
             if len(args) != len(set(args)):
                 return (name, None, None,
                         _("argument names collide with each other"))
-            return (name, ('func', ('symbol', name)), args, None)
+            return (name, tree[:2], args, None)
 
         return (decl, None, None, _("invalid format"))
     except error.ParseError as inst: