Show More
@@ -188,7 +188,7 b' class baseformatter(object):' | |||
|
188 | 188 | def context(self, **ctxs): |
|
189 | 189 | '''insert context objects to be used to render template keywords''' |
|
190 | 190 | ctxs = pycompat.byteskwargs(ctxs) |
|
191 |
assert all(k |
|
|
191 | assert all(k in {'ctx', 'fctx'} for k in ctxs) | |
|
192 | 192 | if self._converter.storecontext: |
|
193 | 193 | self._item.update(ctxs) |
|
194 | 194 | def data(self, **data): |
@@ -395,13 +395,11 b' class templateformatter(baseformatter):' | |||
|
395 | 395 | return |
|
396 | 396 | ref = self._parts[part] |
|
397 | 397 | |
|
398 | # TODO: add support for filectx | |
|
399 | 398 | props = {} |
|
400 | 399 | # explicitly-defined fields precede templatekw |
|
401 | 400 | props.update(item) |
|
402 | if 'ctx' in item: | |
|
401 | if 'ctx' in item or 'fctx' in item: | |
|
403 | 402 | # but template resources must be always available |
|
404 | props['repo'] = props['ctx'].repo() | |
|
405 | 403 | props['revcache'] = {} |
|
406 | 404 | props = pycompat.strkwargs(props) |
|
407 | 405 | g = self._t(ref, **props) |
@@ -513,10 +511,25 b' def templateresources(ui, repo=None):' | |||
|
513 | 511 | return v |
|
514 | 512 | return resmap.get(key) |
|
515 | 513 | |
|
514 | def getctx(context, mapping, key): | |
|
515 | ctx = mapping.get('ctx') | |
|
516 | if ctx is not None: | |
|
517 | return ctx | |
|
518 | fctx = mapping.get('fctx') | |
|
519 | if fctx is not None: | |
|
520 | return fctx.changectx() | |
|
521 | ||
|
522 | def getrepo(context, mapping, key): | |
|
523 | ctx = getctx(context, mapping, 'ctx') | |
|
524 | if ctx is not None: | |
|
525 | return ctx.repo() | |
|
526 | return getsome(context, mapping, key) | |
|
527 | ||
|
516 | 528 | return { |
|
517 | 529 | 'cache': getsome, |
|
518 |
'ctx': get |
|
|
519 |
' |
|
|
530 | 'ctx': getctx, | |
|
531 | 'fctx': getsome, | |
|
532 | 'repo': getrepo, | |
|
520 | 533 | 'revcache': getsome, # per-ctx cache; set later |
|
521 | 534 | 'ui': getsome, |
|
522 | 535 | } |
General Comments 0
You need to be logged in to leave comments.
Login now