Mercurial > hg
changeset 28872:5f31d2248745
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.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 29 Feb 2016 18:00:51 +0900 |
parents | 6d6201fc5aae |
children | 2ca3b7c563f3 |
files | mercurial/parser.py mercurial/revset.py |
diffstat | 2 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/parser.py Mon Feb 29 17:54:03 2016 +0900 +++ b/mercurial/parser.py Mon Feb 29 18:00:51 2016 +0900 @@ -369,3 +369,20 @@ return (name, tree[:2], args, None) return (decl, None, None, _("invalid format")) + + @classmethod + def _relabelargs(cls, tree, args): + """Mark alias arguments as ``_aliasarg``""" + if not isinstance(tree, tuple): + return tree + op = tree[0] + if op != cls._symbolnode: + return (op,) + tuple(cls._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)
--- a/mercurial/revset.py Mon Feb 29 17:54:03 2016 +0900 +++ b/mercurial/revset.py Mon Feb 29 18:00:51 2016 +0900 @@ -2251,19 +2251,7 @@ 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 _aliasrules._relabelargs(tree, args) def _parsealiasdefn(defn, args): """Parse alias definition ``defn``