Mercurial > hg
diff mercurial/logcmdutil.py @ 43100:90b9a7e06c2c
formatter: parse name of built-in formatter templates in standard way
This slightly makes it easier to add "-Tjson(...)" handling, which should
be enabled only if the template specifier doesn't look like a literal
template. In other words, it should be handled after "if '{' in tmpl".
This makes "log -Tpickle" and "log -Tdebug" abort, which I think is better
than just printing "picklepicklepickle...".
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 05 Oct 2019 23:20:35 -0400 |
parents | 687b865b95ad |
children | 829088e87032 |
line wrap: on
line diff
--- a/mercurial/logcmdutil.py Sat Oct 05 23:04:45 2019 -0400 +++ b/mercurial/logcmdutil.py Sat Oct 05 23:20:35 2019 -0400 @@ -617,9 +617,6 @@ mapfile = mapname return templatespec(None, mapfile) - if not tmpl: - return templatespec(None, None) - return formatter.lookuptemplate(ui, b'changeset', tmpl) @@ -642,12 +639,15 @@ regular display via changesetprinter() is done. """ postargs = (differ, opts, buffered) - if opts.get(b'template') in {b'cbor', b'json'}: + spec = _lookuptemplate(ui, opts.get(b'template'), opts.get(b'style')) + + # machine-readable formats have slightly different keyword set than + # plain templates, which are handled by changesetformatter. + # note that {b'pickle', b'debug'} can also be added to the list if needed. + if spec.ref in {b'cbor', b'json'}: fm = ui.formatter(b'log', opts) return changesetformatter(ui, repo, fm, *postargs) - spec = _lookuptemplate(ui, opts.get(b'template'), opts.get(b'style')) - if not spec.ref and not spec.tmpl and not spec.mapfile: return changesetprinter(ui, repo, *postargs)