##// END OF EJS Templates
formatter: pass in template spec to templateformatter as argument...
Yuya Nishihara -
r43369:f1c5358f default
parent child Browse files
Show More
@@ -213,8 +213,8 b' def _formatflags(ui, repo, rev, flags):'
213 if not tmpl:
213 if not tmpl:
214 return b' '.join(flags)
214 return b' '.join(flags)
215 out = util.stringio()
215 out = util.stringio()
216 opts = {b'template': templater.unquotestring(tmpl)}
216 spec = formatter.templatespec(b'', templater.unquotestring(tmpl), None)
217 with formatter.templateformatter(ui, out, b'patchbombflag', opts) as fm:
217 with formatter.templateformatter(ui, out, b'patchbombflag', {}, spec) as fm:
218 fm.startitem()
218 fm.startitem()
219 fm.context(ctx=repo[rev])
219 fm.context(ctx=repo[rev])
220 fm.write(b'flags', b'%s', fm.formatlist(flags, name=b'flag'))
220 fm.write(b'flags', b'%s', fm.formatlist(flags, name=b'flag'))
@@ -475,10 +475,9 b' class _templateconverter(object):'
475
475
476
476
477 class templateformatter(baseformatter):
477 class templateformatter(baseformatter):
478 def __init__(self, ui, out, topic, opts):
478 def __init__(self, ui, out, topic, opts, spec):
479 baseformatter.__init__(self, ui, topic, opts, _templateconverter)
479 baseformatter.__init__(self, ui, topic, opts, _templateconverter)
480 self._out = out
480 self._out = out
481 spec = lookuptemplate(ui, topic, opts.get(b'template', b''))
482 self._tref = spec.ref
481 self._tref = spec.ref
483 self._t = loadtemplater(
482 self._t = loadtemplater(
484 ui,
483 ui,
@@ -723,7 +722,8 b' def formatter(ui, out, topic, opts):'
723 elif template == b"debug":
722 elif template == b"debug":
724 return debugformatter(ui, out, topic, opts)
723 return debugformatter(ui, out, topic, opts)
725 elif template != b"":
724 elif template != b"":
726 return templateformatter(ui, out, topic, opts)
725 spec = lookuptemplate(ui, topic, opts.get(b'template', b''))
726 return templateformatter(ui, out, topic, opts, spec)
727 # developer config: ui.formatdebug
727 # developer config: ui.formatdebug
728 elif ui.configbool(b'ui', b'formatdebug'):
728 elif ui.configbool(b'ui', b'formatdebug'):
729 return debugformatter(ui, out, topic, opts)
729 return debugformatter(ui, out, topic, opts)
General Comments 0
You need to be logged in to leave comments. Login now