Patchwork [6,of,8] formatter: inline gettemplater()

login
register
mail settings
Submitter Yuya Nishihara
Date June 14, 2017, 1:40 p.m.
Message ID <9cbdd6d4990b16046aaf.1497447637@mimosa>
Download mbox | patch
Permalink /patch/21376/
State Accepted
Headers show

Comments

Yuya Nishihara - June 14, 2017, 1:40 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1492841513 -32400
#      Sat Apr 22 15:11:53 2017 +0900
# Node ID 9cbdd6d4990b16046aaf861a7ef7ecafe559e99e
# Parent  2e1a9d997e10ebbfba747ceacac0c514ea0a4524
formatter: inline gettemplater()

Since it's highly use-case dependent how template should be looked up,
gettemplater() function isn't useful. Keeping it would introduce another
bug I've made and fixed earlier in this series.

Patch

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -347,8 +347,8 @@  class templateformatter(baseformatter):
         baseformatter.__init__(self, ui, topic, opts, _templateconverter)
         self._out = out
         self._topic = topic
-        self._t = gettemplater(ui, topic, opts.get('template', ''),
-                               cache=templatekw.defaulttempl)
+        spec = lookuptemplate(ui, topic, opts.get('template', ''))
+        self._t = loadtemplater(ui, topic, spec, cache=templatekw.defaulttempl)
         self._counter = itertools.count()
         self._cache = {}  # for templatekw/funcs to store reusable data
     def context(self, **ctxs):
@@ -406,10 +406,6 @@  def lookuptemplate(ui, topic, tmpl):
     # constant string?
     return tmpl, None
 
-def gettemplater(ui, topic, spec, cache=None):
-    tmpl, mapfile = lookuptemplate(ui, topic, spec)
-    return loadtemplater(ui, topic, (tmpl, mapfile), cache=cache)
-
 def loadtemplater(ui, topic, spec, cache=None):
     """Create a templater from either a literal template or loading from
     a map file"""