revset: add helper function to get functions used in a revset parse tree
Will be used to determine whether all functions used in a hgweb search query
are allowed there.
--- a/mercurial/revset.py Fri Aug 09 22:52:58 2013 +0400
+++ b/mercurial/revset.py Wed Aug 07 01:21:31 2013 +0400
@@ -1941,5 +1941,16 @@
else:
return 0
+def funcsused(tree):
+ if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'):
+ return set()
+ else:
+ funcs = set()
+ for s in tree[1:]:
+ funcs |= funcsused(s)
+ if tree[0] == 'func':
+ funcs.add(tree[1][1])
+ return funcs
+
# tell hggettext to extract docstrings from these functions:
i18nfunctions = symbols.values()