Patchwork [2,of,5] templater: rename .render(mapping) to .renderdefault(mapping) (API)

login
register
mail settings
Submitter Yuya Nishihara
Date March 18, 2018, 4:39 a.m.
Message ID <3cc6b81c3c742e32662b.1521347978@mimosa>
Download mbox | patch
Permalink /patch/29594/
State Accepted
Headers show

Comments

Yuya Nishihara - March 18, 2018, 4:39 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521253384 -32400
#      Sat Mar 17 11:23:04 2018 +0900
# Node ID 3cc6b81c3c742e32662b35c74ccc81e1950c5ecb
# Parent  8d89720b2d9c819d3357c4c82e31fb7eceb79e66
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)``.

Patch

diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -260,7 +260,7 @@  def showstack(ui, repo, displayer):
     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
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -907,7 +907,7 @@  def rendertemplate(ctx, tmpl, props=None
     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
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2455,7 +2455,7 @@  def debugtemplate(ui, repo, tmpl, **opts
     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:
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -563,7 +563,7 @@  def _formatconflictmarker(ctx, template,
         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)
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -285,7 +285,7 @@  class changesetprinter(object):
         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 @@  def _graphnodeformatter(ui, displayer):
                                     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):
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -723,7 +723,7 @@  class templater(object):
                 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))