# HG changeset patch # User Yuya Nishihara # Date 1570331085 14400 # Node ID f1c5358f0d6590a17223dc8bb49006256b97274d # Parent 9691fc764bdc3163782e55fc724fd2d80ca56560 formatter: pass in template spec to templateformatter as argument Prepare for the next patch, which will unify handling of the formatter names and the template names. diff -r 9691fc764bdc -r f1c5358f0d65 hgext/patchbomb.py --- a/hgext/patchbomb.py Sat Oct 05 15:47:38 2019 -0400 +++ b/hgext/patchbomb.py Sat Oct 05 23:04:45 2019 -0400 @@ -213,8 +213,8 @@ if not tmpl: return b' '.join(flags) out = util.stringio() - opts = {b'template': templater.unquotestring(tmpl)} - with formatter.templateformatter(ui, out, b'patchbombflag', opts) as fm: + spec = formatter.templatespec(b'', templater.unquotestring(tmpl), None) + with formatter.templateformatter(ui, out, b'patchbombflag', {}, spec) as fm: fm.startitem() fm.context(ctx=repo[rev]) fm.write(b'flags', b'%s', fm.formatlist(flags, name=b'flag')) diff -r 9691fc764bdc -r f1c5358f0d65 mercurial/formatter.py --- a/mercurial/formatter.py Sat Oct 05 15:47:38 2019 -0400 +++ b/mercurial/formatter.py Sat Oct 05 23:04:45 2019 -0400 @@ -475,10 +475,9 @@ class templateformatter(baseformatter): - def __init__(self, ui, out, topic, opts): + def __init__(self, ui, out, topic, opts, spec): baseformatter.__init__(self, ui, topic, opts, _templateconverter) self._out = out - spec = lookuptemplate(ui, topic, opts.get(b'template', b'')) self._tref = spec.ref self._t = loadtemplater( ui, @@ -723,7 +722,8 @@ elif template == b"debug": return debugformatter(ui, out, topic, opts) elif template != b"": - return templateformatter(ui, out, topic, opts) + spec = lookuptemplate(ui, topic, opts.get(b'template', b'')) + return templateformatter(ui, out, topic, opts, spec) # developer config: ui.formatdebug elif ui.configbool(b'ui', b'formatdebug'): return debugformatter(ui, out, topic, opts)