comparison mercurial/revset.py @ 24518:dd5e56f08d13

revset: add hook after tree parsing This will be useful to execute actions after the tree is parsed and before the revset returns a match. Finding symbols in the parse tree will later allow hashes of hidden revisions to work on the command line without the --hidden flag.
author Laurent Charignon <lcharignon@fb.com>
date Tue, 24 Mar 2015 14:24:55 -0700
parents 7d369fae098e
children fb47816e1a9c
comparison
equal deleted inserted replaced
24517:c2c1ce5e6db1 24518:dd5e56f08d13
2491 2491
2492 def parse(spec, lookup=None): 2492 def parse(spec, lookup=None):
2493 p = parser.parser(tokenize, elements) 2493 p = parser.parser(tokenize, elements)
2494 return p.parse(spec, lookup=lookup) 2494 return p.parse(spec, lookup=lookup)
2495 2495
2496 def posttreebuilthook(tree, repo):
2497 # hook for extensions to execute code on the optimized tree
2498 pass
2499
2496 def match(ui, spec, repo=None): 2500 def match(ui, spec, repo=None):
2497 if not spec: 2501 if not spec:
2498 raise error.ParseError(_("empty query")) 2502 raise error.ParseError(_("empty query"))
2499 lookup = None 2503 lookup = None
2500 if repo: 2504 if repo:
2504 raise error.ParseError(_("invalid token"), pos) 2508 raise error.ParseError(_("invalid token"), pos)
2505 if ui: 2509 if ui:
2506 tree = findaliases(ui, tree, showwarning=ui.warn) 2510 tree = findaliases(ui, tree, showwarning=ui.warn)
2507 tree = foldconcat(tree) 2511 tree = foldconcat(tree)
2508 weight, tree = optimize(tree, True) 2512 weight, tree = optimize(tree, True)
2513 posttreebuilthook(tree, repo)
2509 def mfunc(repo, subset=None): 2514 def mfunc(repo, subset=None):
2510 if subset is None: 2515 if subset is None:
2511 subset = fullreposet(repo) 2516 subset = fullreposet(repo)
2512 if util.safehasattr(subset, 'isascending'): 2517 if util.safehasattr(subset, 'isascending'):
2513 result = getset(repo, subset, tree) 2518 result = getset(repo, subset, tree)