Show More
@@ -2297,7 +2297,7 b' def _graphnodeformatter(ui, displayer):' | |||
|
2297 | 2297 | return templatekw.showgraphnode # fast path for "{graphnode}" |
|
2298 | 2298 | |
|
2299 | 2299 | spec = templater.unquotestring(spec) |
|
2300 |
templ = formatter.maketemplater(ui, |
|
|
2300 | templ = formatter.maketemplater(ui, spec) | |
|
2301 | 2301 | cache = {} |
|
2302 | 2302 | if isinstance(displayer, changeset_templater): |
|
2303 | 2303 | cache = displayer.cache # reuse cache of slow templates |
@@ -2309,7 +2309,7 b' def _graphnodeformatter(ui, displayer):' | |||
|
2309 | 2309 | props['repo'] = repo |
|
2310 | 2310 | props['ui'] = repo.ui |
|
2311 | 2311 | props['revcache'] = {} |
|
2312 | return templater.stringify(templ('graphnode', **props)) | |
|
2312 | return templ.render(props) | |
|
2313 | 2313 | return formatnode |
|
2314 | 2314 | |
|
2315 | 2315 | def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, |
@@ -2121,9 +2121,9 b' def debugtemplate(ui, repo, tmpl, **opts' | |||
|
2121 | 2121 | ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
|
2122 | 2122 | |
|
2123 | 2123 | if revs is None: |
|
2124 | k = 'debugtemplate' | |
|
2125 | t = formatter.maketemplater(ui, k, tmpl) | |
|
2126 |
ui.write(t |
|
|
2124 | t = formatter.maketemplater(ui, tmpl) | |
|
2125 | props['ui'] = ui | |
|
2126 | ui.write(t.render(props)) | |
|
2127 | 2127 | else: |
|
2128 | 2128 | displayer = cmdutil.makelogtemplater(ui, repo, tmpl) |
|
2129 | 2129 | for r in revs: |
@@ -534,10 +534,10 b' def _formatconflictmarker(repo, ctx, tem' | |||
|
534 | 534 | props['templ'] = template |
|
535 | 535 | props['ctx'] = ctx |
|
536 | 536 | props['repo'] = repo |
|
537 |
templateresult = template( |
|
|
537 | templateresult = template.render(props) | |
|
538 | 538 | |
|
539 | 539 | label = ('%s:' % label).ljust(pad + 1) |
|
540 |
mark = '%s %s' % (label, |
|
|
540 | mark = '%s %s' % (label, templateresult) | |
|
541 | 541 | |
|
542 | 542 | if mark: |
|
543 | 543 | mark = mark.splitlines()[0] # split for safety |
@@ -566,7 +566,7 b' def _formatlabels(repo, fcd, fco, fca, l' | |||
|
566 | 566 | ui = repo.ui |
|
567 | 567 | template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) |
|
568 | 568 | template = templater.unquotestring(template) |
|
569 |
tmpl = formatter.maketemplater(ui, |
|
|
569 | tmpl = formatter.maketemplater(ui, template) | |
|
570 | 570 | |
|
571 | 571 | pad = max(len(l) for l in labels) |
|
572 | 572 |
@@ -431,10 +431,13 b' def loadtemplater(ui, spec, cache=None):' | |||
|
431 | 431 | assert not (spec.tmpl and spec.mapfile) |
|
432 | 432 | if spec.mapfile: |
|
433 | 433 | return templater.templater.frommapfile(spec.mapfile, cache=cache) |
|
434 | return maketemplater(ui, spec.ref, spec.tmpl, cache=cache) | |
|
434 | return _maketemplater(ui, spec.ref, spec.tmpl, cache=cache) | |
|
435 | 435 | |
|
436 |
def maketemplater(ui |
|
|
436 | def maketemplater(ui, tmpl, cache=None): | |
|
437 | 437 | """Create a templater from a string template 'tmpl'""" |
|
438 | return _maketemplater(ui, '', tmpl, cache=cache) | |
|
439 | ||
|
440 | def _maketemplater(ui, topic, tmpl, cache=None): | |
|
438 | 441 | aliases = ui.configitems('templatealias') |
|
439 | 442 | t = templater.templater(cache=cache, aliases=aliases) |
|
440 | 443 | if tmpl: |
@@ -1298,6 +1298,10 b' class templater(object):' | |||
|
1298 | 1298 | (self.map[t][1], inst.args[1])) |
|
1299 | 1299 | return self.cache[t] |
|
1300 | 1300 | |
|
1301 | def render(self, mapping): | |
|
1302 | """Render the default unnamed template and return result as string""" | |
|
1303 | return stringify(self('', **mapping)) | |
|
1304 | ||
|
1301 | 1305 | def __call__(self, t, **mapping): |
|
1302 | 1306 | ttype = t in self.map and self.map[t][0] or 'default' |
|
1303 | 1307 | if ttype not in self.ecache: |
General Comments 0
You need to be logged in to leave comments.
Login now