Show More
@@ -386,9 +386,7 b' def templatelabel(context, mapping, args' | |||||
386 | # i18n: "label" is a keyword |
|
386 | # i18n: "label" is a keyword | |
387 | raise error.ParseError(_("label expects two arguments")) |
|
387 | raise error.ParseError(_("label expects two arguments")) | |
388 |
|
388 | |||
389 |
thing = templater. |
|
389 | thing = templater._evalifliteral(args[1], context, mapping) | |
390 | thing = templater.runtemplate(context, mapping, |
|
|||
391 | templater.compiletemplate(thing, context)) |
|
|||
392 |
|
390 | |||
393 | # apparently, repo could be a string that is the favicon? |
|
391 | # apparently, repo could be a string that is the favicon? | |
394 | repo = mapping.get('repo', '') |
|
392 | repo = mapping.get('repo', '') |
@@ -258,6 +258,13 b' def get(context, mapping, args):' | |||||
258 | key = args[1][0](context, mapping, args[1][1]) |
|
258 | key = args[1][0](context, mapping, args[1][1]) | |
259 | yield dictarg.get(key) |
|
259 | yield dictarg.get(key) | |
260 |
|
260 | |||
|
261 | def _evalifliteral(arg, context, mapping): | |||
|
262 | t = stringify(arg[0](context, mapping, arg[1])) | |||
|
263 | if arg[0] == runstring: | |||
|
264 | yield runtemplate(context, mapping, compiletemplate(t, context)) | |||
|
265 | else: | |||
|
266 | yield t | |||
|
267 | ||||
261 | def if_(context, mapping, args): |
|
268 | def if_(context, mapping, args): | |
262 | if not (2 <= len(args) <= 3): |
|
269 | if not (2 <= len(args) <= 3): | |
263 | # i18n: "if" is a keyword |
|
270 | # i18n: "if" is a keyword | |
@@ -265,11 +272,9 b' def if_(context, mapping, args):' | |||||
265 |
|
272 | |||
266 | test = stringify(args[0][0](context, mapping, args[0][1])) |
|
273 | test = stringify(args[0][0](context, mapping, args[0][1])) | |
267 | if test: |
|
274 | if test: | |
268 |
|
|
275 | yield _evalifliteral(args[1], context, mapping) | |
269 | yield runtemplate(context, mapping, compiletemplate(t, context)) |
|
|||
270 | elif len(args) == 3: |
|
276 | elif len(args) == 3: | |
271 |
|
|
277 | yield _evalifliteral(args[2], context, mapping) | |
272 | yield runtemplate(context, mapping, compiletemplate(t, context)) |
|
|||
273 |
|
278 | |||
274 | def ifeq(context, mapping, args): |
|
279 | def ifeq(context, mapping, args): | |
275 | if not (3 <= len(args) <= 4): |
|
280 | if not (3 <= len(args) <= 4): | |
@@ -279,11 +284,9 b' def ifeq(context, mapping, args):' | |||||
279 | test = stringify(args[0][0](context, mapping, args[0][1])) |
|
284 | test = stringify(args[0][0](context, mapping, args[0][1])) | |
280 | match = stringify(args[1][0](context, mapping, args[1][1])) |
|
285 | match = stringify(args[1][0](context, mapping, args[1][1])) | |
281 | if test == match: |
|
286 | if test == match: | |
282 |
|
|
287 | yield _evalifliteral(args[2], context, mapping) | |
283 | yield runtemplate(context, mapping, compiletemplate(t, context)) |
|
|||
284 | elif len(args) == 4: |
|
288 | elif len(args) == 4: | |
285 |
|
|
289 | yield _evalifliteral(args[3], context, mapping) | |
286 | yield runtemplate(context, mapping, compiletemplate(t, context)) |
|
|||
287 |
|
290 | |||
288 | def join(context, mapping, args): |
|
291 | def join(context, mapping, args): | |
289 | if not (1 <= len(args) <= 2): |
|
292 | if not (1 <= len(args) <= 2): | |
@@ -313,8 +316,7 b' def label(context, mapping, args):' | |||||
313 | raise error.ParseError(_("label expects two arguments")) |
|
316 | raise error.ParseError(_("label expects two arguments")) | |
314 |
|
317 | |||
315 | # ignore args[0] (the label string) since this is supposed to be a a no-op |
|
318 | # ignore args[0] (the label string) since this is supposed to be a a no-op | |
316 | t = stringify(args[1][0](context, mapping, args[1][1])) |
|
319 | yield _evalifliteral(args[1], context, mapping) | |
317 | yield runtemplate(context, mapping, compiletemplate(t, context)) |
|
|||
318 |
|
320 | |||
319 | def rstdoc(context, mapping, args): |
|
321 | def rstdoc(context, mapping, args): | |
320 | if len(args) != 2: |
|
322 | if len(args) != 2: |
@@ -1594,3 +1594,15 b' Test string escaping:' | |||||
1594 | <>\n<[> |
|
1594 | <>\n<[> | |
1595 | <>\n<]> |
|
1595 | <>\n<]> | |
1596 | <>\n< |
|
1596 | <>\n< | |
|
1597 | ||||
|
1598 | Test recursive evaluation: | |||
|
1599 | ||||
|
1600 | $ hg init r | |||
|
1601 | $ cd r | |||
|
1602 | $ echo a > a | |||
|
1603 | $ hg ci -Am '{rev}' | |||
|
1604 | adding a | |||
|
1605 | $ hg log -r 0 --template '{if(rev, desc)}\n' | |||
|
1606 | {rev} | |||
|
1607 | $ hg log -r 0 --template '{if(rev, "{author} {rev}")}\n' | |||
|
1608 | test 0 |
General Comments 0
You need to be logged in to leave comments.
Login now