[PATCH 4 of 7 V2] parser: move _relabelaliasargs() to common rule-set class
Yuya Nishihara
yuya at tcha.org
Sat Apr 2 04:30:19 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 80cdd9af74b7da045d2eed7236dedbb8cad66fee
# Parent 1ec19dfcfbcfed50e8c3a5beacf7e8ea2171390c
parser: move _relabelaliasargs() to common rule-set class
This has no doctest because it will be covered by _builddefn() introduced
by the next patch.
revset._relabelaliasargs() will be removed soon.
diff --git a/mercurial/parser.py b/mercurial/parser.py
--- a/mercurial/parser.py
+++ b/mercurial/parser.py
@@ -355,3 +355,19 @@ class aliasrules(object):
return (name, tree[:2], args, None)
return (decl, None, None, _("invalid format"))
+
+ def _relabelargs(self, tree, args):
+ """Mark alias arguments as ``_aliasarg``"""
+ 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
@@ -2255,19 +2255,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