Show More
@@ -248,9 +248,9 b' def if_(context, mapping, args):' | |||||
248 |
|
248 | |||
249 | test = evalboolean(context, mapping, args[0]) |
|
249 | test = evalboolean(context, mapping, args[0]) | |
250 | if test: |
|
250 | if test: | |
251 |
|
|
251 | return evalrawexp(context, mapping, args[1]) | |
252 | elif len(args) == 3: |
|
252 | elif len(args) == 3: | |
253 |
|
|
253 | return evalrawexp(context, mapping, args[2]) | |
254 |
|
254 | |||
255 | @templatefunc('ifcontains(needle, haystack, then[, else])') |
|
255 | @templatefunc('ifcontains(needle, haystack, then[, else])') | |
256 | def ifcontains(context, mapping, args): |
|
256 | def ifcontains(context, mapping, args): | |
@@ -269,9 +269,9 b' def ifcontains(context, mapping, args):' | |||||
269 | found = False |
|
269 | found = False | |
270 |
|
270 | |||
271 | if found: |
|
271 | if found: | |
272 |
|
|
272 | return evalrawexp(context, mapping, args[2]) | |
273 | elif len(args) == 4: |
|
273 | elif len(args) == 4: | |
274 |
|
|
274 | return evalrawexp(context, mapping, args[3]) | |
275 |
|
275 | |||
276 | @templatefunc('ifeq(expr1, expr2, then[, else])') |
|
276 | @templatefunc('ifeq(expr1, expr2, then[, else])') | |
277 | def ifeq(context, mapping, args): |
|
277 | def ifeq(context, mapping, args): | |
@@ -284,9 +284,9 b' def ifeq(context, mapping, args):' | |||||
284 | test = evalstring(context, mapping, args[0]) |
|
284 | test = evalstring(context, mapping, args[0]) | |
285 | match = evalstring(context, mapping, args[1]) |
|
285 | match = evalstring(context, mapping, args[1]) | |
286 | if test == match: |
|
286 | if test == match: | |
287 |
|
|
287 | return evalrawexp(context, mapping, args[2]) | |
288 | elif len(args) == 4: |
|
288 | elif len(args) == 4: | |
289 |
|
|
289 | return evalrawexp(context, mapping, args[3]) | |
290 |
|
290 | |||
291 | @templatefunc('join(list, sep)') |
|
291 | @templatefunc('join(list, sep)') | |
292 | def join(context, mapping, args): |
|
292 | def join(context, mapping, args): |
@@ -3242,6 +3242,35 b' Test min/max of integers' | |||||
3242 | $ hg log -R latesttag -l1 -T '{max(revset("9:10"))}\n' |
|
3242 | $ hg log -R latesttag -l1 -T '{max(revset("9:10"))}\n' | |
3243 | 10 |
|
3243 | 10 | |
3244 |
|
3244 | |||
|
3245 | Test min/max of if() result | |||
|
3246 | ||||
|
3247 | $ cd latesttag | |||
|
3248 | $ hg log -l1 -T '{min(if(true, revset("9:10"), ""))}\n' | |||
|
3249 | 9 | |||
|
3250 | $ hg log -l1 -T '{max(if(false, "", revset("9:10")))}\n' | |||
|
3251 | 10 | |||
|
3252 | $ hg log -l1 -T '{min(ifcontains("a", "aa", revset("9:10"), ""))}\n' | |||
|
3253 | 9 | |||
|
3254 | $ hg log -l1 -T '{max(ifcontains("a", "bb", "", revset("9:10")))}\n' | |||
|
3255 | 10 | |||
|
3256 | $ hg log -l1 -T '{min(ifeq(0, 0, revset("9:10"), ""))}\n' | |||
|
3257 | 9 | |||
|
3258 | $ hg log -l1 -T '{max(ifeq(0, 1, "", revset("9:10")))}\n' | |||
|
3259 | 10 | |||
|
3260 | $ cd .. | |||
|
3261 | ||||
|
3262 | Test laziness of if() then/else clause | |||
|
3263 | ||||
|
3264 | $ hg debugtemplate '{count(0)}' | |||
|
3265 | abort: incompatible use of template filter 'count' | |||
|
3266 | [255] | |||
|
3267 | $ hg debugtemplate '{if(true, "", count(0))}' | |||
|
3268 | $ hg debugtemplate '{if(false, count(0), "")}' | |||
|
3269 | $ hg debugtemplate '{ifcontains("a", "aa", "", count(0))}' | |||
|
3270 | $ hg debugtemplate '{ifcontains("a", "bb", count(0), "")}' | |||
|
3271 | $ hg debugtemplate '{ifeq(0, 0, "", count(0))}' | |||
|
3272 | $ hg debugtemplate '{ifeq(0, 1, count(0), "")}' | |||
|
3273 | ||||
3245 | Test dot operator precedence: |
|
3274 | Test dot operator precedence: | |
3246 |
|
3275 | |||
3247 | $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n' |
|
3276 | $ hg debugtemplate -R latesttag -r0 -v '{manifest.node|short}\n' |
General Comments 0
You need to be logged in to leave comments.
Login now