Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.py @ 16218:81a1a00f5738
debugrevspec: pretty print output
Before:
('func', ('symbol', 'reverse'), ('func', ('symbol', 'sort'), ('list', ('or',
('symbol', '2'), ('symbol', '3')), ('symbol', 'date'))))
After:
(func
('symbol', 'reverse')
(func
('symbol', 'sort')
(list
(or
('symbol', '2')
('symbol', '3'))
('symbol', 'date'))))
v2:
- Rebased on stable to avoid having to merge tests output
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Fri, 24 Feb 2012 11:02:21 +0100 |
parents | 352053e6cd8e |
children | 1fb2f1400ea8 |
line wrap: on
line diff
--- 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()