Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.py @ 16772:30e46d7138de stable
revset: fix infinite alias expansion detection
The alias expansion code it changed from:
1- Get replacement tree
2- Substitute arguments in the replacement tree
3- Expand the replacement tree again
into:
1- Get the replacement tree
2- Expand the replacement tree
3- Expand the arguments
4- Substitute the expanded arguments in the replacement tree
and fixes cases like:
[revsetalias]
level1($1, $2) = $1 or $2
level2($1, $2) = level1($2, $1)
$ hg log -r "level2(level1(1, 2), 3)"
where the original version incorrectly aborted on infinite expansion
error, because it was confusing the expanded aliases with their
arguments.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Sat, 19 May 2012 17:19:55 +0200 |
parents | 2f3317d53d51 |
children | 2ac08d8b21aa |
line wrap: on
line diff
--- a/mercurial/revset.py Sat May 19 17:18:29 2012 +0200 +++ b/mercurial/revset.py Sat May 19 17:19:55 2012 +0200 @@ -1377,16 +1377,15 @@ raise error.ParseError(_('infinite expansion of revset alias "%s" ' 'detected') % alias.name) expanding.append(alias) - result = alias.replacement + result = _expandaliases(aliases, alias.replacement, expanding) + expanding.pop() if alias.args is not None: l = getlist(tree[2]) if len(l) != len(alias.args): raise error.ParseError( _('invalid number of arguments: %s') % len(l)) + l = [_expandaliases(aliases, a, []) for a in l] result = _expandargs(result, dict(zip(alias.args, l))) - # Recurse in place, the base expression may have been rewritten - result = _expandaliases(aliases, result, expanding) - expanding.pop() else: result = tuple(_expandaliases(aliases, t, expanding) for t in tree)