diff -r df5ecb813426 -r 81a1a00f5738 mercurial/revset.py --- a/mercurial/revset.py Fri Mar 02 21:43:55 2012 +0200 +++ b/mercurial/revset.py Fri Feb 24 11:02:21 2012 +0100 @@ -1319,5 +1319,20 @@ return ret +def prettyformat(tree): + def _prettyformat(tree, level, lines): + if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'): + lines.append((level, str(tree))) + else: + lines.append((level, '(%s' % tree[0])) + for s in tree[1:]: + _prettyformat(s, level + 1, lines) + lines[-1:] = [(lines[-1][0], lines[-1][1] + ')')] + + lines = [] + _prettyformat(tree, 0, lines) + output = '\n'.join((' '*l + s) for l, s in lines) + return output + # tell hggettext to extract docstrings from these functions: i18nfunctions = symbols.values()