[PATCH 1 of 4 V2] revset: add helper function to get tree depth
Alexander Plavin
alexander at plav.in
Fri Aug 9 18:54:55 UTC 2013
# 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
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()
More information about the Mercurial-devel
mailing list