templater: rename .render(mapping) to .renderdefault(mapping) (API)
authorYuya Nishihara <yuya@tcha.org>
Sat, 17 Mar 2018 11:23:04 +0900
changeset 36988 317382151ac3
parent 36987 4b744c7b35ce
child 36989 de117f579431
templater: rename .render(mapping) to .renderdefault(mapping) (API) I'm going to add templ.render(t, mapping) and templ.generate(t, mapping) in place of stringify(templ(t, **mapping)) and templ(t, **mapping) respectively. .. api:: The ``render(mapping)`` method of the templater has been renamed to ``renderdefault(mapping)``.
hgext/show.py
mercurial/cmdutil.py
mercurial/debugcommands.py
mercurial/filemerge.py
mercurial/logcmdutil.py
mercurial/templater.py
--- a/hgext/show.py	Sat Mar 17 15:22:14 2018 +0900
+++ b/hgext/show.py	Sat Mar 17 11:23:04 2018 +0900
@@ -260,7 +260,7 @@
     shortesttmpl = formatter.maketemplater(ui, '{shortest(node, %d)}' % nodelen,
                                            resources=tres)
     def shortest(ctx):
-        return shortesttmpl.render({'ctx': ctx, 'node': ctx.hex()})
+        return shortesttmpl.renderdefault({'ctx': ctx, 'node': ctx.hex()})
 
     # We write out new heads to aid in DAG awareness and to help with decision
     # making on how the stack should be reconciled with commits made since the
--- a/mercurial/cmdutil.py	Sat Mar 17 15:22:14 2018 +0900
+++ b/mercurial/cmdutil.py	Sat Mar 17 11:23:04 2018 +0900
@@ -907,7 +907,7 @@
     mapping = {'ctx': ctx, 'revcache': {}}
     if props:
         mapping.update(props)
-    return t.render(mapping)
+    return t.renderdefault(mapping)
 
 def _buildfntemplate(pat, total=None, seqno=None, revwidth=None, pathname=None):
     r"""Convert old-style filename format string to template string
--- a/mercurial/debugcommands.py	Sat Mar 17 15:22:14 2018 +0900
+++ b/mercurial/debugcommands.py	Sat Mar 17 11:23:04 2018 +0900
@@ -2455,7 +2455,7 @@
     if revs is None:
         tres = formatter.templateresources(ui, repo)
         t = formatter.maketemplater(ui, tmpl, resources=tres)
-        ui.write(t.render(props))
+        ui.write(t.renderdefault(props))
     else:
         displayer = logcmdutil.maketemplater(ui, repo, tmpl)
         for r in revs:
--- a/mercurial/filemerge.py	Sat Mar 17 15:22:14 2018 +0900
+++ b/mercurial/filemerge.py	Sat Mar 17 11:23:04 2018 +0900
@@ -563,7 +563,7 @@
         ctx = ctx.p1()
 
     props = {'ctx': ctx}
-    templateresult = template.render(props)
+    templateresult = template.renderdefault(props)
 
     label = ('%s:' % label).ljust(pad + 1)
     mark = '%s %s' % (label, templateresult)
--- a/mercurial/logcmdutil.py	Sat Mar 17 15:22:14 2018 +0900
+++ b/mercurial/logcmdutil.py	Sat Mar 17 11:23:04 2018 +0900
@@ -285,7 +285,7 @@
         t = formatter.maketemplater(self.repo.ui, '{join(obsfate, "\n")}',
                                     defaults=templatekw.keywords,
                                     resources=tres)
-        obsfate = t.render({'ctx': ctx, 'revcache': {}}).splitlines()
+        obsfate = t.renderdefault({'ctx': ctx, 'revcache': {}}).splitlines()
 
         if obsfate:
             for obsfateline in obsfate:
@@ -858,7 +858,7 @@
                                     resources=tres)
     def formatnode(repo, ctx):
         props = {'ctx': ctx, 'repo': repo, 'revcache': {}}
-        return templ.render(props)
+        return templ.renderdefault(props)
     return formatnode
 
 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, props=None):
--- a/mercurial/templater.py	Sat Mar 17 15:22:14 2018 +0900
+++ b/mercurial/templater.py	Sat Mar 17 11:23:04 2018 +0900
@@ -723,7 +723,7 @@
                 raise IOError(inst.args[0], encoding.strfromlocal(reason))
         return self.cache[t]
 
-    def render(self, mapping):
+    def renderdefault(self, mapping):
         """Render the default unnamed template and return result as string"""
         mapping = pycompat.strkwargs(mapping)
         return templateutil.stringify(self('', **mapping))