changeset 19719:2f9d5c5256ea

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.
author Alexander Plavin <alexander@plav.in>
date Fri, 09 Aug 2013 22:52:58 +0400
parents d69e06724b96
children f0b992a9be9c
files mercurial/revset.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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()