Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 32873:2ecce24dfcd3
templater: add simple interface for unnamed template (API)
This provides a simpler API for callers which don't need full templating
stack. Instead of storing the given template as the name specified by topic,
use '' as the default template to be rendered.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Apr 2017 19:56:47 +0900 |
parents | e4a43b810528 |
children | c8f2cf18b82e |
comparison
equal
deleted
inserted
replaced
32872:9fcb6df413c9 | 32873:2ecce24dfcd3 |
---|---|
2295 spec = ui.config('ui', 'graphnodetemplate') | 2295 spec = ui.config('ui', 'graphnodetemplate') |
2296 if not spec: | 2296 if not spec: |
2297 return templatekw.showgraphnode # fast path for "{graphnode}" | 2297 return templatekw.showgraphnode # fast path for "{graphnode}" |
2298 | 2298 |
2299 spec = templater.unquotestring(spec) | 2299 spec = templater.unquotestring(spec) |
2300 templ = formatter.maketemplater(ui, 'graphnode', spec) | 2300 templ = formatter.maketemplater(ui, spec) |
2301 cache = {} | 2301 cache = {} |
2302 if isinstance(displayer, changeset_templater): | 2302 if isinstance(displayer, changeset_templater): |
2303 cache = displayer.cache # reuse cache of slow templates | 2303 cache = displayer.cache # reuse cache of slow templates |
2304 props = templatekw.keywords.copy() | 2304 props = templatekw.keywords.copy() |
2305 props['templ'] = templ | 2305 props['templ'] = templ |
2307 def formatnode(repo, ctx): | 2307 def formatnode(repo, ctx): |
2308 props['ctx'] = ctx | 2308 props['ctx'] = ctx |
2309 props['repo'] = repo | 2309 props['repo'] = repo |
2310 props['ui'] = repo.ui | 2310 props['ui'] = repo.ui |
2311 props['revcache'] = {} | 2311 props['revcache'] = {} |
2312 return templater.stringify(templ('graphnode', **props)) | 2312 return templ.render(props) |
2313 return formatnode | 2313 return formatnode |
2314 | 2314 |
2315 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, | 2315 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, |
2316 filematcher=None): | 2316 filematcher=None): |
2317 formatnode = _graphnodeformatter(ui, displayer) | 2317 formatnode = _graphnodeformatter(ui, displayer) |