Show More
@@ -2297,7 +2297,7 b' def _graphnodeformatter(ui, displayer):' | |||||
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, |
|
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 | |
@@ -2309,7 +2309,7 b' def _graphnodeformatter(ui, displayer):' | |||||
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, |
@@ -2121,9 +2121,9 b' def debugtemplate(ui, repo, tmpl, **opts' | |||||
2121 | ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
|
2121 | ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') | |
2122 |
|
2122 | |||
2123 | if revs is None: |
|
2123 | if revs is None: | |
2124 | k = 'debugtemplate' |
|
2124 | t = formatter.maketemplater(ui, tmpl) | |
2125 | t = formatter.maketemplater(ui, k, tmpl) |
|
2125 | props['ui'] = ui | |
2126 |
ui.write(t |
|
2126 | ui.write(t.render(props)) | |
2127 | else: |
|
2127 | else: | |
2128 | displayer = cmdutil.makelogtemplater(ui, repo, tmpl) |
|
2128 | displayer = cmdutil.makelogtemplater(ui, repo, tmpl) | |
2129 | for r in revs: |
|
2129 | for r in revs: |
@@ -534,10 +534,10 b' def _formatconflictmarker(repo, ctx, tem' | |||||
534 | props['templ'] = template |
|
534 | props['templ'] = template | |
535 | props['ctx'] = ctx |
|
535 | props['ctx'] = ctx | |
536 | props['repo'] = repo |
|
536 | props['repo'] = repo | |
537 |
templateresult = template( |
|
537 | templateresult = template.render(props) | |
538 |
|
538 | |||
539 | label = ('%s:' % label).ljust(pad + 1) |
|
539 | label = ('%s:' % label).ljust(pad + 1) | |
540 |
mark = '%s %s' % (label, |
|
540 | mark = '%s %s' % (label, templateresult) | |
541 |
|
541 | |||
542 | if mark: |
|
542 | if mark: | |
543 | mark = mark.splitlines()[0] # split for safety |
|
543 | mark = mark.splitlines()[0] # split for safety | |
@@ -566,7 +566,7 b' def _formatlabels(repo, fcd, fco, fca, l' | |||||
566 | ui = repo.ui |
|
566 | ui = repo.ui | |
567 | template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) |
|
567 | template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) | |
568 | template = templater.unquotestring(template) |
|
568 | template = templater.unquotestring(template) | |
569 |
tmpl = formatter.maketemplater(ui, |
|
569 | tmpl = formatter.maketemplater(ui, template) | |
570 |
|
570 | |||
571 | pad = max(len(l) for l in labels) |
|
571 | pad = max(len(l) for l in labels) | |
572 |
|
572 |
@@ -431,10 +431,13 b' def loadtemplater(ui, spec, cache=None):' | |||||
431 | assert not (spec.tmpl and spec.mapfile) |
|
431 | assert not (spec.tmpl and spec.mapfile) | |
432 | if spec.mapfile: |
|
432 | if spec.mapfile: | |
433 | return templater.templater.frommapfile(spec.mapfile, cache=cache) |
|
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 | """Create a templater from a string template 'tmpl'""" |
|
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 | aliases = ui.configitems('templatealias') |
|
441 | aliases = ui.configitems('templatealias') | |
439 | t = templater.templater(cache=cache, aliases=aliases) |
|
442 | t = templater.templater(cache=cache, aliases=aliases) | |
440 | if tmpl: |
|
443 | if tmpl: |
@@ -1298,6 +1298,10 b' class templater(object):' | |||||
1298 | (self.map[t][1], inst.args[1])) |
|
1298 | (self.map[t][1], inst.args[1])) | |
1299 | return self.cache[t] |
|
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 | def __call__(self, t, **mapping): |
|
1305 | def __call__(self, t, **mapping): | |
1302 | ttype = t in self.map and self.map[t][0] or 'default' |
|
1306 | ttype = t in self.map and self.map[t][0] or 'default' | |
1303 | if ttype not in self.ecache: |
|
1307 | if ttype not in self.ecache: |
General Comments 0
You need to be logged in to leave comments.
Login now