Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.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 | a53bfc2845f2 |
children | 5d63e5f40bea |
line wrap: on
line diff
--- a/mercurial/revset.py Fri Jul 07 01:05:20 2017 -0400 +++ b/mercurial/revset.py Sat Jun 24 15:29:42 2017 -0700 @@ -2001,12 +2001,15 @@ """ return matchany(ui, [spec], repo=repo, order=order) -def matchany(ui, specs, repo=None, order=defineorder): +def matchany(ui, specs, repo=None, order=defineorder, localalias=None): """Create a matcher that will include any revisions matching one of the given specs If order=followorder, a matcher takes the ordering specified by the input set. + + If localalias is not None, it is a dict {name: definitionstring}. It takes + precedence over [revsetalias] config section. """ if not specs: def mfunc(repo, subset=None): @@ -2023,8 +2026,15 @@ tree = ('or', ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs)) + aliases = [] + warn = None if ui: - tree = revsetlang.expandaliases(ui, tree) + aliases.extend(ui.configitems('revsetalias')) + warn = ui.warn + if localalias: + aliases.extend(localalias.items()) + if aliases: + tree = revsetlang.expandaliases(tree, aliases, warn=warn) tree = revsetlang.foldconcat(tree) tree = revsetlang.analyze(tree, order) tree = revsetlang.optimize(tree)