[PATCH 5 of 6] parser: move _relabelaliasargs() to common rule-set class
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Apr 1 17:35:16 EDT 2016
On 04/01/2016 08:37 AM, Yuya Nishihara wrote:
> # 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):
Can we get some details about what this function is about, that would
help me following what is going on here.
> + 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)
Urg, that's not a very pretty call, I assume this is temporary. What
would this looks like eventually?
Cheers,
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list