Patchwork [2,of,3,V4] revset: add helper function to get revset parse tree depth

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 4, 2013, 7:12 p.m.
Message ID <327bee4dc0ccf28853b9.1378321941@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2324/
State Superseded
Commit 2f9d5c5256ea4db1b7c52a892b9e2e977ceb7af4
Delegated to: Kevin Bullock
Headers show

Comments

Alexander Plavin - Sept. 4, 2013, 7:12 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1376074378 -14400
#      Fri Aug 09 22:52:58 2013 +0400
# Node ID 327bee4dc0ccf28853b979072187989c4abf82df
# Parent  06cc57487670cc3801de227fa179d61de3f1dd4a
revset: add helper function to get revset parse tree depth

Patch

diff -r 06cc57487670 -r 327bee4dc0cc mercurial/revset.py
--- a/mercurial/revset.py	Wed Sep 04 19:40:04 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()