[PATCH 5 of 6] parser: move _relabelaliasargs() to common rule-set class

Yuya Nishihara yuya at tcha.org
Fri Apr 1 11:37:11 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1456736451 -32400
#      Mon Feb 29 18:00:51 2016 +0900
# Node ID d5414d3c08bbffc3ef6ad3fa3268d3d43b25afad
# Parent  2a3e01c30ddc08a5ff331b8d9b30ac8c014090d6
parser: move _relabelaliasargs() to common rule-set class

revset._relabelaliasargs() will be removed soon.

diff --git a/mercurial/parser.py b/mercurial/parser.py
--- a/mercurial/parser.py
+++ b/mercurial/parser.py
@@ -290,3 +290,18 @@ class aliasrules(object):
             return (name, tree[:2], args, None)
 
         return (decl, None, None, _("invalid format"))
+
+    def _relabelargs(self, tree, args):
+        if not isinstance(tree, tuple):
+            return tree
+        op = tree[0]
+        if op != self._symbolnode:
+            return (op,) + tuple(self._relabelargs(x, args) for x in tree[1:])
+
+        assert len(tree) == 2
+        sym = tree[1]
+        if sym in args:
+            op = '_aliasarg'
+        elif sym.startswith('$'):
+            raise error.ParseError(_("'$' not for alias arguments"))
+        return (op, sym)
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2278,19 +2278,7 @@ def _parsealiasdecl(decl):
     return parser.simplifyinfixops(tree, ('list',))
 
 def _relabelaliasargs(tree, args):
-    if not isinstance(tree, tuple):
-        return tree
-    op = tree[0]
-    if op != 'symbol':
-        return (op,) + tuple(_relabelaliasargs(x, args) for x in tree[1:])
-
-    assert len(tree) == 2
-    sym = tree[1]
-    if sym in args:
-        op = '_aliasarg'
-    elif sym.startswith('$'):
-        raise error.ParseError(_("'$' not for alias arguments"))
-    return (op, sym)
+    return parser.aliasrules('', None, None, None)._relabelargs(tree, args)
 
 def _parsealiasdefn(defn, args):
     """Parse alias definition ``defn``


More information about the Mercurial-devel mailing list