[PATCH 1 of 4 V5] revset: add helper function to get revset parse tree depth

Alexander Plavin alexander at plav.in
Fri Sep 6 09:35:34 UTC 2013


# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1376074378 -14400
#      Fri Aug 09 22:52:58 2013 +0400
# Node ID e87a93bf4c2fb8229fe39acdfdfb54ba8736eef2
# Parent  f0f63ed56acb6c2f0c2bd69c48282c9e91c21395
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.

diff -r f0f63ed56acb -r e87a93bf4c2f mercurial/revset.py
--- a/mercurial/revset.py	Wed Jul 24 03:20:26 2013 +0400
+++ b/mercurial/revset.py	Fri Aug 09 22:52:58 2013 +0400
@@ -1945,5 +1945,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()


More information about the Mercurial-devel mailing list