Show More
@@ -11,6 +11,7 b' import os' | |||
|
11 | 11 | import re |
|
12 | 12 | import time |
|
13 | 13 | |
|
14 | from .i18n import _ | |
|
14 | 15 | from . import ( |
|
15 | 16 | encoding, |
|
16 | 17 | error, |
@@ -101,7 +102,10 b' def basename(path):' | |||
|
101 | 102 | @templatefilter('count') |
|
102 | 103 | def count(i): |
|
103 | 104 | """List or text. Returns the length as an integer.""" |
|
104 | return len(i) | |
|
105 | try: | |
|
106 | return len(i) | |
|
107 | except TypeError: | |
|
108 | raise error.ParseError(_('not countable')) | |
|
105 | 109 | |
|
106 | 110 | @templatefilter('dirname', intype=bytes) |
|
107 | 111 | def dirname(path): |
@@ -2277,6 +2277,11 b' Count filter:' | |||
|
2277 | 2277 | o 0: children: 1, tags: 0, file_adds: 1, ancestors: 1 |
|
2278 | 2278 | |
|
2279 | 2279 | |
|
2280 | $ hg log -l1 -T '{termwidth|count}\n' | |
|
2281 | hg: parse error: not countable | |
|
2282 | (template filter 'count' is not compatible with keyword 'termwidth') | |
|
2283 | [255] | |
|
2284 | ||
|
2280 | 2285 | Upper/lower filters: |
|
2281 | 2286 | |
|
2282 | 2287 | $ hg log -r0 --template '{branch|upper}\n' |
@@ -3266,7 +3271,8 b' Test min/max of if() result' | |||
|
3266 | 3271 | Test laziness of if() then/else clause |
|
3267 | 3272 | |
|
3268 | 3273 | $ hg debugtemplate '{count(0)}' |
|
3269 | abort: incompatible use of template filter 'count' | |
|
3274 | hg: parse error: not countable | |
|
3275 | (incompatible use of template filter 'count') | |
|
3270 | 3276 | [255] |
|
3271 | 3277 | $ hg debugtemplate '{if(true, "", count(0))}' |
|
3272 | 3278 | $ hg debugtemplate '{if(false, count(0), "")}' |
General Comments 0
You need to be logged in to leave comments.
Login now