Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revsetlang.py @ 33336:4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Previously repo.anyrevs only expand aliases in [revsetalias] config. This
patch makes it more flexible to accept a customized dict defining aliases
without having to couple with ui.
revsetlang.expandaliases now has the signature (tree, aliases, warn=None)
which is more consistent with templater.expandaliases. revsetlang.py is now
free from "ui", which seems to be a good thing.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sat, 24 Jun 2017 15:29:42 -0700 |
parents | 3292c0df64f7 |
children | 371f59c6a89e |
line wrap: on
line diff
--- a/mercurial/revsetlang.py Fri Jul 07 01:05:20 2017 -0400 +++ b/mercurial/revsetlang.py Sat Jun 24 15:29:42 2017 -0700 @@ -561,14 +561,16 @@ if tree[0] == 'func' and tree[1][0] == 'symbol': return tree[1][1], getlist(tree[2]) -def expandaliases(ui, tree): - aliases = _aliasrules.buildmap(ui.configitems('revsetalias')) +def expandaliases(tree, aliases, warn=None): + """Expand aliases in a tree, aliases is a list of (name, value) tuples""" + aliases = _aliasrules.buildmap(aliases) tree = _aliasrules.expand(aliases, tree) # warn about problematic (but not referred) aliases - for name, alias in sorted(aliases.iteritems()): - if alias.error and not alias.warned: - ui.warn(_('warning: %s\n') % (alias.error)) - alias.warned = True + if warn is not None: + for name, alias in sorted(aliases.iteritems()): + if alias.error and not alias.warned: + warn(_('warning: %s\n') % (alias.error)) + alias.warned = True return tree def foldconcat(tree):