##// END OF EJS Templates
formatter: fill missing resources by formatter, not by resource mapper...
Yuya Nishihara -
r39619:ee1e74ee default
parent child Browse files
Show More
@@ -199,8 +199,13 b' class baseformatter(object):'
199 def context(self, **ctxs):
199 def context(self, **ctxs):
200 '''insert context objects to be used to render template keywords'''
200 '''insert context objects to be used to render template keywords'''
201 ctxs = pycompat.byteskwargs(ctxs)
201 ctxs = pycompat.byteskwargs(ctxs)
202 assert all(k in {'ctx', 'fctx'} for k in ctxs)
202 assert all(k in {'repo', 'ctx', 'fctx'} for k in ctxs)
203 if self._converter.storecontext:
203 if self._converter.storecontext:
204 # populate missing resources in fctx -> ctx -> repo order
205 if 'fctx' in ctxs and 'ctx' not in ctxs:
206 ctxs['ctx'] = ctxs['fctx'].changectx()
207 if 'ctx' in ctxs and 'repo' not in ctxs:
208 ctxs['repo'] = ctxs['ctx'].repo()
204 self._item.update(ctxs)
209 self._item.update(ctxs)
205 def datahint(self):
210 def datahint(self):
206 '''set of field names to be referenced'''
211 '''set of field names to be referenced'''
@@ -578,27 +583,13 b' class templateresources(templater.resour'
578 return self._resmap.get(key)
583 return self._resmap.get(key)
579
584
580 def _hasctx(self, mapping):
585 def _hasctx(self, mapping):
581 return 'ctx' in mapping or 'fctx' in mapping
586 return 'ctx' in mapping
582
583 def _getctx(self, mapping, key):
584 ctx = mapping.get('ctx')
585 if ctx is not None:
586 return ctx
587 fctx = mapping.get('fctx')
588 if fctx is not None:
589 return fctx.changectx()
590
591 def _getrepo(self, mapping, key):
592 ctx = self._getctx(mapping, 'ctx')
593 if ctx is not None:
594 return ctx.repo()
595 return self._getsome(mapping, key)
596
587
597 _gettermap = {
588 _gettermap = {
598 'cache': _getsome,
589 'cache': _getsome,
599 'ctx': _getctx,
590 'ctx': _getsome,
600 'fctx': _getsome,
591 'fctx': _getsome,
601 'repo': _getrepo,
592 'repo': _getsome,
602 'revcache': _getsome,
593 'revcache': _getsome,
603 'ui': _getsome,
594 'ui': _getsome,
604 }
595 }
General Comments 0
You need to be logged in to leave comments. Login now