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

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 6, 2013, 9:35 a.m.
Message ID <e87a93bf4c2fb8229fe3.1378460134@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2393/
State Accepted
Commit 2f9d5c5256ea4db1b7c52a892b9e2e977ceb7af4
Headers show

Comments

Alexander Plavin - Sept. 6, 2013, 9:35 a.m.
# HG changeset patch
# User Alexander Plavin <alexander@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.

Patch

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()