diff mercurial/revset.py @ 24458:7d87f672d069

debugrevspec: show nesting structure of smartsets if verbose This shows how smartsets are constructed from the query. It will be somewhat useful to track problems such as stack overflow.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 16 Mar 2015 18:36:53 +0900
parents c5022f3579b9
children 7d369fae098e
line wrap: on
line diff
--- a/mercurial/revset.py	Mon Mar 16 18:15:06 2015 +0900
+++ b/mercurial/revset.py	Mon Mar 16 18:36:53 2015 +0900
@@ -3419,5 +3419,19 @@
         other.sort(reverse=self.isdescending())
         return other
 
+def prettyformatset(revs):
+    lines = []
+    rs = repr(revs)
+    p = 0
+    while p < len(rs):
+        q = rs.find('<', p + 1)
+        if q < 0:
+            q = len(rs)
+        l = rs.count('<', 0, p) - rs.count('>', 0, p)
+        assert l >= 0
+        lines.append((l, rs[p:q].rstrip()))
+        p = q
+    return '\n'.join('  ' * l + s for l, s in lines)
+
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()