comparison mercurial/formatter.py @ 31805:dca9b6922514

formatter: reorder code that builds template mapping This makes the future patch slightly simpler.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 02 Apr 2017 22:43:18 +0900
parents 654e9a1c8a6c
children e6eb86b154c5
comparison
equal deleted inserted replaced
31804:726f24123f02 31805:dca9b6922514
345 self._item.update(ctxs) 345 self._item.update(ctxs)
346 def _showitem(self): 346 def _showitem(self):
347 # TODO: add support for filectx. probably each template keyword or 347 # TODO: add support for filectx. probably each template keyword or
348 # function will have to declare dependent resources. e.g. 348 # function will have to declare dependent resources. e.g.
349 # @templatekeyword(..., requires=('ctx',)) 349 # @templatekeyword(..., requires=('ctx',))
350 props = {}
350 if 'ctx' in self._item: 351 if 'ctx' in self._item:
351 props = templatekw.keywords.copy() 352 props.update(templatekw.keywords)
352 # explicitly-defined fields precede templatekw 353 # explicitly-defined fields precede templatekw
353 props.update(self._item) 354 props.update(self._item)
355 if 'ctx' in self._item:
354 # but template resources must be always available 356 # but template resources must be always available
355 props['templ'] = self._t 357 props['templ'] = self._t
356 props['repo'] = props['ctx'].repo() 358 props['repo'] = props['ctx'].repo()
357 props['revcache'] = {} 359 props['revcache'] = {}
358 else:
359 props = self._item
360 g = self._t(self._topic, ui=self._ui, cache=self._cache, **props) 360 g = self._t(self._topic, ui=self._ui, cache=self._cache, **props)
361 self._out.write(templater.stringify(g)) 361 self._out.write(templater.stringify(g))
362 362
363 def lookuptemplate(ui, topic, tmpl): 363 def lookuptemplate(ui, topic, tmpl):
364 # looks like a literal template? 364 # looks like a literal template?