comparison mercurial/revset.py @ 19720:f0b992a9be9c

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.
author Alexander Plavin <alexander@plav.in>
date Wed, 07 Aug 2013 01:21:31 +0400
parents 2f9d5c5256ea
children d8ca6d965230
comparison
equal deleted inserted replaced
19719:2f9d5c5256ea 19720:f0b992a9be9c
1939 if isinstance(tree, tuple): 1939 if isinstance(tree, tuple):
1940 return max(map(depth, tree)) + 1 1940 return max(map(depth, tree)) + 1
1941 else: 1941 else:
1942 return 0 1942 return 0
1943 1943
1944 def funcsused(tree):
1945 if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'):
1946 return set()
1947 else:
1948 funcs = set()
1949 for s in tree[1:]:
1950 funcs |= funcsused(s)
1951 if tree[0] == 'func':
1952 funcs.add(tree[1][1])
1953 return funcs
1954
1944 # tell hggettext to extract docstrings from these functions: 1955 # tell hggettext to extract docstrings from these functions:
1945 i18nfunctions = symbols.values() 1956 i18nfunctions = symbols.values()