[PATCH 3 of 4] revset: inline isvalidfunc(), getfuncname() and getfuncargs()

Yuya Nishihara yuya at tcha.org
Wed Mar 30 11:38:20 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1456731358 -32400
#      Mon Feb 29 16:35:58 2016 +0900
# Node ID ab9445ee0dbe55f4258645e065f7121df2c6f83a
# Parent  47f49b9d2307e21c32147b8b5006fa5498cd87c9
revset: inline isvalidfunc(), getfuncname() and getfuncargs()

See the previous commit for why. These functions are also trivial.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -337,25 +337,6 @@ def getargsdict(x, funcname, keys):
     return parser.buildargsdict(getlist(x), funcname, keys.split(),
                                 keyvaluenode='keyvalue', keynode='symbol')
 
-def isvalidfunc(tree):
-    """Examine whether specified ``tree`` is valid ``func`` or not
-    """
-    return tree[0] == 'func' and tree[1][0] == 'symbol'
-
-def getfuncname(tree):
-    """Get function name from valid ``func`` in ``tree``
-
-    This assumes that ``tree`` is already examined by ``isvalidfunc``.
-    """
-    return tree[1][1]
-
-def getfuncargs(tree):
-    """Get list of function arguments from valid ``func`` in ``tree``
-
-    This assumes that ``tree`` is already examined by ``isvalidfunc``.
-    """
-    return getlist(tree[2])
-
 def getset(repo, subset, x):
     if not x:
         raise error.ParseError(_("missing argument"))
@@ -2318,13 +2299,13 @@ def _parsealiasdecl(decl):
                 return (decl, None, None, _("'$' not for alias arguments"))
             return (name, ('symbol', name), None, None)
 
-        if isvalidfunc(tree):
+        if tree[0] == 'func' and tree[1][0] == 'symbol':
             # "name(arg, ....) = ...." style
-            name = getfuncname(tree)
+            name = tree[1][1]
             if name.startswith('$'):
                 return (decl, None, None, _("'$' not for alias arguments"))
             args = []
-            for arg in getfuncargs(tree):
+            for arg in getlist(tree[2]):
                 if arg[0] != 'symbol':
                     return (decl, None, None, _("invalid argument list"))
                 args.append(arg[1])


More information about the Mercurial-devel mailing list