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

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 16, 2013, 8:03 p.m.
Message ID <3d00be09128534292148.1376683405@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2183/
State Superseded
Headers show

Comments

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

Patch

diff -r 1520c3c2bfff -r 3d00be091285 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()