[PATCH 1 of 4 V2] revset: add helper function to get tree depth

Augie Fackler raf at durin42.com
Mon Aug 12 09:29:12 CDT 2013


On Fri, Aug 09, 2013 at 10:54:55PM +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <alexander at plav.in>
> # Date 1376074378 -14400
> #      Fri Aug 09 22:52:58 2013 +0400
> # Node ID 10862e95f769e7555ee54c0647595d508d5672ef
> # Parent  da2209742e39683a5a42672e69133b1a20898973
> revset: add helper function to get tree depth

I might mention that it's the depth of the parse tree for the revset -
that wasn't immediately obvious to me.

>
> diff -r da2209742e39 -r 10862e95f769 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()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list