Show More
@@ -531,6 +531,7 b' def lookuptemplate(ui, topic, tmpl):' | |||||
531 | 'tmpl' can be any of the following: |
|
531 | 'tmpl' can be any of the following: | |
532 |
|
532 | |||
533 | - a literal template (e.g. '{rev}') |
|
533 | - a literal template (e.g. '{rev}') | |
|
534 | - a reference to built-in template (i.e. formatter) | |||
534 | - a map-file name or path (e.g. 'changelog') |
|
535 | - a map-file name or path (e.g. 'changelog') | |
535 | - a reference to [templates] in config file |
|
536 | - a reference to [templates] in config file | |
536 | - a path to raw template file |
|
537 | - a path to raw template file | |
@@ -544,10 +545,17 b' def lookuptemplate(ui, topic, tmpl):' | |||||
544 | available as well as aliases in [templatealias]. |
|
545 | available as well as aliases in [templatealias]. | |
545 | """ |
|
546 | """ | |
546 |
|
547 | |||
|
548 | if not tmpl: | |||
|
549 | return templatespec(None, None, None) | |||
|
550 | ||||
547 | # looks like a literal template? |
|
551 | # looks like a literal template? | |
548 | if b'{' in tmpl: |
|
552 | if b'{' in tmpl: | |
549 | return templatespec(b'', tmpl, None) |
|
553 | return templatespec(b'', tmpl, None) | |
550 |
|
554 | |||
|
555 | # a reference to built-in (formatter) template | |||
|
556 | if tmpl in {b'cbor', b'json', b'pickle', b'debug'}: | |||
|
557 | return templatespec(tmpl, None, None) | |||
|
558 | ||||
551 | # perhaps a stock style? |
|
559 | # perhaps a stock style? | |
552 | if not os.path.split(tmpl)[0]: |
|
560 | if not os.path.split(tmpl)[0]: | |
553 | mapname = templater.templatepath( |
|
561 | mapname = templater.templatepath( | |
@@ -712,17 +720,16 b' class templateresources(templater.resour' | |||||
712 |
|
720 | |||
713 |
|
721 | |||
714 | def formatter(ui, out, topic, opts): |
|
722 | def formatter(ui, out, topic, opts): | |
715 |
|
|
723 | spec = lookuptemplate(ui, topic, opts.get(b'template', b'')) | |
716 |
if |
|
724 | if spec.ref == b"cbor": | |
717 | return cborformatter(ui, out, topic, opts) |
|
725 | return cborformatter(ui, out, topic, opts) | |
718 |
elif |
|
726 | elif spec.ref == b"json": | |
719 | return jsonformatter(ui, out, topic, opts) |
|
727 | return jsonformatter(ui, out, topic, opts) | |
720 |
elif |
|
728 | elif spec.ref == b"pickle": | |
721 | return pickleformatter(ui, out, topic, opts) |
|
729 | return pickleformatter(ui, out, topic, opts) | |
722 |
elif |
|
730 | elif spec.ref == b"debug": | |
723 | return debugformatter(ui, out, topic, opts) |
|
731 | return debugformatter(ui, out, topic, opts) | |
724 | elif template != b"": |
|
732 | elif spec.ref or spec.tmpl or spec.mapfile: | |
725 | spec = lookuptemplate(ui, topic, opts.get(b'template', b'')) |
|
|||
726 | return templateformatter(ui, out, topic, opts, spec) |
|
733 | return templateformatter(ui, out, topic, opts, spec) | |
727 | # developer config: ui.formatdebug |
|
734 | # developer config: ui.formatdebug | |
728 | elif ui.configbool(b'ui', b'formatdebug'): |
|
735 | elif ui.configbool(b'ui', b'formatdebug'): |
@@ -617,9 +617,6 b' def _lookuptemplate(ui, tmpl, style):' | |||||
617 | mapfile = mapname |
|
617 | mapfile = mapname | |
618 | return templatespec(None, mapfile) |
|
618 | return templatespec(None, mapfile) | |
619 |
|
619 | |||
620 | if not tmpl: |
|
|||
621 | return templatespec(None, None) |
|
|||
622 |
|
||||
623 | return formatter.lookuptemplate(ui, b'changeset', tmpl) |
|
620 | return formatter.lookuptemplate(ui, b'changeset', tmpl) | |
624 |
|
621 | |||
625 |
|
622 | |||
@@ -642,12 +639,15 b' def changesetdisplayer(ui, repo, opts, d' | |||||
642 | regular display via changesetprinter() is done. |
|
639 | regular display via changesetprinter() is done. | |
643 | """ |
|
640 | """ | |
644 | postargs = (differ, opts, buffered) |
|
641 | postargs = (differ, opts, buffered) | |
645 | if opts.get(b'template') in {b'cbor', b'json'}: |
|
642 | spec = _lookuptemplate(ui, opts.get(b'template'), opts.get(b'style')) | |
|
643 | ||||
|
644 | # machine-readable formats have slightly different keyword set than | |||
|
645 | # plain templates, which are handled by changesetformatter. | |||
|
646 | # note that {b'pickle', b'debug'} can also be added to the list if needed. | |||
|
647 | if spec.ref in {b'cbor', b'json'}: | |||
646 | fm = ui.formatter(b'log', opts) |
|
648 | fm = ui.formatter(b'log', opts) | |
647 | return changesetformatter(ui, repo, fm, *postargs) |
|
649 | return changesetformatter(ui, repo, fm, *postargs) | |
648 |
|
650 | |||
649 | spec = _lookuptemplate(ui, opts.get(b'template'), opts.get(b'style')) |
|
|||
650 |
|
||||
651 | if not spec.ref and not spec.tmpl and not spec.mapfile: |
|
651 | if not spec.ref and not spec.tmpl and not spec.mapfile: | |
652 | return changesetprinter(ui, repo, *postargs) |
|
652 | return changesetprinter(ui, repo, *postargs) | |
653 |
|
653 |
@@ -1101,6 +1101,15 b' honor --git but not format-breaking diff' | |||||
1101 | } |
|
1101 | } | |
1102 | ] |
|
1102 | ] | |
1103 |
|
1103 | |||
|
1104 | Other unsupported formatter styles: | |||
|
1105 | ||||
|
1106 | $ hg log -qr . -Tpickle | |||
|
1107 | abort: "pickle" not in template map | |||
|
1108 | [255] | |||
|
1109 | $ hg log -qr . -Tdebug | |||
|
1110 | abort: "debug" not in template map | |||
|
1111 | [255] | |||
|
1112 | ||||
1104 | Error if style not readable: |
|
1113 | Error if style not readable: | |
1105 |
|
1114 | |||
1106 | #if unix-permissions no-root |
|
1115 | #if unix-permissions no-root |
General Comments 0
You need to be logged in to leave comments.
Login now