revset: add helper function to get revset parse tree depth
authorAlexander Plavin <alexander@plav.in>
Fri, 09 Aug 2013 22:52:58 +0400
changeset 19719 2f9d5c5256ea
parent 19718 d69e06724b96
child 19720 f0b992a9be9c
revset: add helper function to get revset parse tree depth Will be used to determine if a hgweb search query actually uses any revset syntax.
mercurial/revset.py
--- a/mercurial/revset.py	Sat Sep 07 00:59:24 2013 -0700
+++ b/mercurial/revset.py	Fri Aug 09 22:52:58 2013 +0400
@@ -1935,5 +1935,11 @@
     output = '\n'.join(('  '*l + s) for l, s in lines)
     return output
 
+def depth(tree):
+    if isinstance(tree, tuple):
+        return max(map(depth, tree)) + 1
+    else:
+        return 0
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()