Show More
@@ -532,6 +532,14 b' def date(context, mapping, args):' | |||||
532 | # i18n: "date" is a keyword |
|
532 | # i18n: "date" is a keyword | |
533 | raise error.ParseError(_("date expects a date information")) |
|
533 | raise error.ParseError(_("date expects a date information")) | |
534 |
|
534 | |||
|
535 | @templatefunc('dict([key=value...])', argspec='**kwargs') | |||
|
536 | def dict_(context, mapping, args): | |||
|
537 | """Construct a dict from key-value pairs.""" | |||
|
538 | data = util.sortdict() | |||
|
539 | data.update((k, evalfuncarg(context, mapping, v)) | |||
|
540 | for k, v in args['kwargs'].iteritems()) | |||
|
541 | return templatekw.hybriddict(data) | |||
|
542 | ||||
535 | @templatefunc('diff([includepattern [, excludepattern]])') |
|
543 | @templatefunc('diff([includepattern [, excludepattern]])') | |
536 | def diff(context, mapping, args): |
|
544 | def diff(context, mapping, args): | |
537 | """Show a diff, optionally |
|
545 | """Show a diff, optionally |
@@ -3404,6 +3404,22 b' Test branches inside if statement:' | |||||
3404 | $ hg log -r 0 --template '{if(branches, "yes", "no")}\n' |
|
3404 | $ hg log -r 0 --template '{if(branches, "yes", "no")}\n' | |
3405 | no |
|
3405 | no | |
3406 |
|
3406 | |||
|
3407 | Test dict constructor: | |||
|
3408 | ||||
|
3409 | $ hg log -r 0 -T '{dict(y=node|short, x=rev)}\n' | |||
|
3410 | y=f7769ec2ab97 x=0 | |||
|
3411 | $ hg log -r 0 -T '{dict(x=rev, y=node|short) % "{key}={value}\n"}' | |||
|
3412 | x=0 | |||
|
3413 | y=f7769ec2ab97 | |||
|
3414 | $ hg log -r 0 -T '{dict(x=rev, y=node|short)|json}\n' | |||
|
3415 | {"x": 0, "y": "f7769ec2ab97"} | |||
|
3416 | $ hg log -r 0 -T '{dict()|json}\n' | |||
|
3417 | {} | |||
|
3418 | ||||
|
3419 | $ hg log -r 0 -T '{dict(x=rev, x=node)}' | |||
|
3420 | hg: parse error: dict got multiple values for keyword argument 'x' | |||
|
3421 | [255] | |||
|
3422 | ||||
3407 | Test get function: |
|
3423 | Test get function: | |
3408 |
|
3424 | |||
3409 | $ hg log -r 0 --template '{get(extras, "branch")}\n' |
|
3425 | $ hg log -r 0 --template '{get(extras, "branch")}\n' |
General Comments 0
You need to be logged in to leave comments.
Login now