# HG changeset patch # User Alexander Plavin # Date 1375824091 -14400 # Node ID f0b992a9be9c3a5574de8abb9219a2897619516f # Parent 2f9d5c5256ea4db1b7c52a892b9e2e977ceb7af4 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. diff -r 2f9d5c5256ea -r f0b992a9be9c mercurial/revset.py --- 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()