revset: add hook after tree parsing
authorLaurent Charignon <lcharignon@fb.com>
Tue, 24 Mar 2015 14:24:55 -0700
changeset 24518 dd5e56f08d13
parent 24517 c2c1ce5e6db1
child 24519 de3acfabaddc
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.
mercurial/revset.py
--- a/mercurial/revset.py	Mon Mar 30 14:58:42 2015 -0400
+++ b/mercurial/revset.py	Tue Mar 24 14:24:55 2015 -0700
@@ -2493,6 +2493,10 @@
     p = parser.parser(tokenize, elements)
     return p.parse(spec, lookup=lookup)
 
+def posttreebuilthook(tree, repo):
+    # hook for extensions to execute code on the optimized tree
+    pass
+
 def match(ui, spec, repo=None):
     if not spec:
         raise error.ParseError(_("empty query"))
@@ -2506,6 +2510,7 @@
         tree = findaliases(ui, tree, showwarning=ui.warn)
     tree = foldconcat(tree)
     weight, tree = optimize(tree, True)
+    posttreebuilthook(tree, repo)
     def mfunc(repo, subset=None):
         if subset is None:
             subset = fullreposet(repo)