Mercurial > hg
comparison mercurial/logcmdutil.py @ 37072:d64ae4fef471
log: do no expect templateresources() returning a dict
The resources dict will be replaced with new resource mapper object, which
won't implement __getitem__(key). Share the whole resources object with
_graphnodeformater() to make porting easier.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 15 Mar 2018 20:27:38 +0900 |
parents | de117f579431 |
children | f0b6fbea00cf |
comparison
equal
deleted
inserted
replaced
37071:d3f7930a9563 | 37072:d64ae4fef471 |
---|---|
414 # Arguments before "buffered" used to be positional. Consider not | 414 # Arguments before "buffered" used to be positional. Consider not |
415 # adding/removing arguments before "buffered" to not break callers. | 415 # adding/removing arguments before "buffered" to not break callers. |
416 def __init__(self, ui, repo, tmplspec, differ=None, diffopts=None, | 416 def __init__(self, ui, repo, tmplspec, differ=None, diffopts=None, |
417 buffered=False): | 417 buffered=False): |
418 changesetprinter.__init__(self, ui, repo, differ, diffopts, buffered) | 418 changesetprinter.__init__(self, ui, repo, differ, diffopts, buffered) |
419 tres = formatter.templateresources(ui, repo) | 419 # tres is shared with _graphnodeformatter() |
420 self._tresources = tres = formatter.templateresources(ui, repo) | |
420 self.t = formatter.loadtemplater(ui, tmplspec, | 421 self.t = formatter.loadtemplater(ui, tmplspec, |
421 defaults=templatekw.keywords, | 422 defaults=templatekw.keywords, |
422 resources=tres, | 423 resources=tres, |
423 cache=templatekw.defaulttempl) | 424 cache=templatekw.defaulttempl) |
424 self._counter = itertools.count() | 425 self._counter = itertools.count() |
425 self._getcache = tres['cache'] # shared with _graphnodeformatter() | |
426 | 426 |
427 self._tref = tmplspec.ref | 427 self._tref = tmplspec.ref |
428 self._parts = {'header': '', 'footer': '', | 428 self._parts = {'header': '', 'footer': '', |
429 tmplspec.ref: tmplspec.ref, | 429 tmplspec.ref: tmplspec.ref, |
430 'docheader': '', 'docfooter': '', | 430 'docheader': '', 'docfooter': '', |
842 spec = ui.config('ui', 'graphnodetemplate') | 842 spec = ui.config('ui', 'graphnodetemplate') |
843 if not spec: | 843 if not spec: |
844 return templatekw.getgraphnode # fast path for "{graphnode}" | 844 return templatekw.getgraphnode # fast path for "{graphnode}" |
845 | 845 |
846 spec = templater.unquotestring(spec) | 846 spec = templater.unquotestring(spec) |
847 tres = formatter.templateresources(ui) | |
848 if isinstance(displayer, changesettemplater): | 847 if isinstance(displayer, changesettemplater): |
849 # reuse cache of slow templates | 848 # reuse cache of slow templates |
850 tres['cache'] = displayer._getcache | 849 tres = displayer._tresources |
850 else: | |
851 tres = formatter.templateresources(ui) | |
851 templ = formatter.maketemplater(ui, spec, defaults=templatekw.keywords, | 852 templ = formatter.maketemplater(ui, spec, defaults=templatekw.keywords, |
852 resources=tres) | 853 resources=tres) |
853 def formatnode(repo, ctx): | 854 def formatnode(repo, ctx): |
854 props = {'ctx': ctx, 'repo': repo, 'revcache': {}} | 855 props = {'ctx': ctx, 'repo': repo, 'revcache': {}} |
855 return templ.renderdefault(props) | 856 return templ.renderdefault(props) |