Patchwork [1,of,6,V3] revset: add helper function to get revset parse tree depth

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 22, 2013, 3:11 p.m.
Message ID <f32bf1774cc3e6cd7ee9.1377184272@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2245/
State Superseded
Commit 2f9d5c5256ea4db1b7c52a892b9e2e977ceb7af4
Headers show

Comments

Alexander Plavin - Aug. 22, 2013, 3:11 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376074378 -14400
#      Fri Aug 09 22:52:58 2013 +0400
# Node ID f32bf1774cc3e6cd7ee99a7be2724daa23223a98
# Parent  04c91751cbf8abc1f3ea56c67ca4988e0e8e61a5
revset: add helper function to get revset parse tree depth

Patch

diff -r 04c91751cbf8 -r f32bf1774cc3 mercurial/revset.py
--- a/mercurial/revset.py	Fri Jul 19 02:09:13 2013 +0400
+++ b/mercurial/revset.py	Fri Aug 09 22:52:58 2013 +0400
@@ -1972,5 +1972,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()