Show More
@@ -199,8 +199,13 b' class baseformatter(object):' | |||
|
199 | 199 | def context(self, **ctxs): |
|
200 | 200 | '''insert context objects to be used to render template keywords''' |
|
201 | 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 | 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 | 209 | self._item.update(ctxs) |
|
205 | 210 | def datahint(self): |
|
206 | 211 | '''set of field names to be referenced''' |
@@ -578,27 +583,13 b' class templateresources(templater.resour' | |||
|
578 | 583 | return self._resmap.get(key) |
|
579 | 584 | |
|
580 | 585 | def _hasctx(self, mapping): |
|
581 |
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) | |
|
586 | return 'ctx' in mapping | |
|
596 | 587 | |
|
597 | 588 | _gettermap = { |
|
598 | 589 | 'cache': _getsome, |
|
599 |
'ctx': _get |
|
|
590 | 'ctx': _getsome, | |
|
600 | 591 | 'fctx': _getsome, |
|
601 |
'repo': _get |
|
|
592 | 'repo': _getsome, | |
|
602 | 593 | 'revcache': _getsome, |
|
603 | 594 | 'ui': _getsome, |
|
604 | 595 | } |
General Comments 0
You need to be logged in to leave comments.
Login now