Mercurial > hg
comparison mercurial/templater.py @ 34073:7bbc4e113e5f
parser: stabilize output of prettyformat() by using byte-safe repr()
The format of leaf nodes is slightly changed so they look more similar to
internal nodes.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 03 Sep 2017 21:17:25 +0900 |
parents | f55769e41803 |
children | 0fa781320203 |
comparison
equal
deleted
inserted
replaced
34072:30535fe47e78 | 34073:7bbc4e113e5f |
---|---|
192 """Expand list of templates to node tuple | 192 """Expand list of templates to node tuple |
193 | 193 |
194 >>> def f(tree): | 194 >>> def f(tree): |
195 ... print prettyformat(_unnesttemplatelist(tree)) | 195 ... print prettyformat(_unnesttemplatelist(tree)) |
196 >>> f(('template', [])) | 196 >>> f(('template', [])) |
197 ('string', '') | 197 (string '') |
198 >>> f(('template', [('string', 'foo')])) | 198 >>> f(('template', [('string', 'foo')])) |
199 ('string', 'foo') | 199 (string 'foo') |
200 >>> f(('template', [('string', 'foo'), ('symbol', 'rev')])) | 200 >>> f(('template', [('string', 'foo'), ('symbol', 'rev')])) |
201 (template | 201 (template |
202 ('string', 'foo') | 202 (string 'foo') |
203 ('symbol', 'rev')) | 203 (symbol 'rev')) |
204 >>> f(('template', [('symbol', 'rev')])) # template(rev) -> str | 204 >>> f(('template', [('symbol', 'rev')])) # template(rev) -> str |
205 (template | 205 (template |
206 ('symbol', 'rev')) | 206 (symbol 'rev')) |
207 >>> f(('template', [('template', [('string', 'foo')])])) | 207 >>> f(('template', [('template', [('string', 'foo')])])) |
208 ('string', 'foo') | 208 (string 'foo') |
209 """ | 209 """ |
210 if not isinstance(tree, tuple): | 210 if not isinstance(tree, tuple): |
211 return tree | 211 return tree |
212 op = tree[0] | 212 op = tree[0] |
213 if op != 'template': | 213 if op != 'template': |