# HG changeset patch # User Alexander Plavin # Date 2013-08-09 18:52:58 # Node ID 2f9d5c5256ea4db1b7c52a892b9e2e977ceb7af4 # Parent d69e06724b96a985f29fd493a5dfe356a75af387 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 --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -1935,5 +1935,11 @@ def prettyformat(tree): 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()