comparison 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
comparison
equal deleted inserted replaced
33335:72f051f9a7d8 33336:4672db164c98
559 @staticmethod 559 @staticmethod
560 def _trygetfunc(tree): 560 def _trygetfunc(tree):
561 if tree[0] == 'func' and tree[1][0] == 'symbol': 561 if tree[0] == 'func' and tree[1][0] == 'symbol':
562 return tree[1][1], getlist(tree[2]) 562 return tree[1][1], getlist(tree[2])
563 563
564 def expandaliases(ui, tree): 564 def expandaliases(tree, aliases, warn=None):
565 aliases = _aliasrules.buildmap(ui.configitems('revsetalias')) 565 """Expand aliases in a tree, aliases is a list of (name, value) tuples"""
566 aliases = _aliasrules.buildmap(aliases)
566 tree = _aliasrules.expand(aliases, tree) 567 tree = _aliasrules.expand(aliases, tree)
567 # warn about problematic (but not referred) aliases 568 # warn about problematic (but not referred) aliases
568 for name, alias in sorted(aliases.iteritems()): 569 if warn is not None:
569 if alias.error and not alias.warned: 570 for name, alias in sorted(aliases.iteritems()):
570 ui.warn(_('warning: %s\n') % (alias.error)) 571 if alias.error and not alias.warned:
571 alias.warned = True 572 warn(_('warning: %s\n') % (alias.error))
573 alias.warned = True
572 return tree 574 return tree
573 575
574 def foldconcat(tree): 576 def foldconcat(tree):
575 """Fold elements to be concatenated by `##` 577 """Fold elements to be concatenated by `##`
576 """ 578 """