Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
16217:df5ecb813426 | 16218:81a1a00f5738 |
---|---|
1317 ret += c | 1317 ret += c |
1318 pos += 1 | 1318 pos += 1 |
1319 | 1319 |
1320 return ret | 1320 return ret |
1321 | 1321 |
1322 def prettyformat(tree): | |
1323 def _prettyformat(tree, level, lines): | |
1324 if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'): | |
1325 lines.append((level, str(tree))) | |
1326 else: | |
1327 lines.append((level, '(%s' % tree[0])) | |
1328 for s in tree[1:]: | |
1329 _prettyformat(s, level + 1, lines) | |
1330 lines[-1:] = [(lines[-1][0], lines[-1][1] + ')')] | |
1331 | |
1332 lines = [] | |
1333 _prettyformat(tree, 0, lines) | |
1334 output = '\n'.join((' '*l + s) for l, s in lines) | |
1335 return output | |
1336 | |
1322 # tell hggettext to extract docstrings from these functions: | 1337 # tell hggettext to extract docstrings from these functions: |
1323 i18nfunctions = symbols.values() | 1338 i18nfunctions = symbols.values() |