changeset 32839:b425ec7fb7f6

cmdutil: pass templatespec tuple directly to changeset_templater (API) A fewer number of arguments should be better.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 22 Apr 2017 19:02:47 +0900
parents 615ec3f14aa9
children 57c13c0d1cde
files hgext/bugzilla.py hgext/notify.py mercurial/cmdutil.py
diffstat 3 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/bugzilla.py	Sat Apr 22 18:48:38 2017 +0900
+++ b/hgext/bugzilla.py	Sat Apr 22 19:02:47 2017 +0900
@@ -1040,8 +1040,9 @@
         if not mapfile and not tmpl:
             tmpl = _('changeset {node|short} in repo {root} refers '
                      'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
-        t = cmdutil.changeset_templater(self.ui, self.repo,
-                                        False, None, tmpl, mapfile, False)
+        spec = cmdutil.logtemplatespec(tmpl, mapfile)
+        t = cmdutil.changeset_templater(self.ui, self.repo, spec,
+                                        False, None, False)
         self.ui.pushbuffer()
         t.show(ctx, changes=ctx.changeset(),
                bug=str(bugid),
--- a/hgext/notify.py	Sat Apr 22 18:48:38 2017 +0900
+++ b/hgext/notify.py	Sat Apr 22 19:02:47 2017 +0900
@@ -203,8 +203,9 @@
             mapfile = self.ui.config('notify', 'style')
         if not mapfile and not template:
             template = deftemplates.get(hooktype) or single_template
-        self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
-                                             template, mapfile, False)
+        spec = cmdutil.logtemplatespec(template, mapfile)
+        self.t = cmdutil.changeset_templater(self.ui, self.repo, spec,
+                                             False, None, False)
 
     def strip(self, path):
         '''strip leading slashes from local path, turn into web-safe path.'''
--- a/mercurial/cmdutil.py	Sat Apr 22 18:48:38 2017 +0900
+++ b/mercurial/cmdutil.py	Sat Apr 22 19:02:47 2017 +0900
@@ -1578,9 +1578,8 @@
 class changeset_templater(changeset_printer):
     '''format changeset information.'''
 
-    def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
+    def __init__(self, ui, repo, tmplspec, matchfn, diffopts, buffered):
         changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
-        tmplspec = logtemplatespec(tmpl, mapfile)
         self.t = formatter.loadtemplater(ui, 'changeset', tmplspec,
                                          cache=templatekw.defaulttempl)
         self._counter = itertools.count()
@@ -1679,8 +1678,9 @@
 
 def makelogtemplater(ui, repo, tmpl, buffered=False):
     """Create a changeset_templater from a literal template 'tmpl'"""
-    return changeset_templater(ui, repo, matchfn=None, diffopts={},
-                               tmpl=tmpl, mapfile=None, buffered=buffered)
+    spec = logtemplatespec(tmpl, None)
+    return changeset_templater(ui, repo, spec, matchfn=None, diffopts={},
+                               buffered=buffered)
 
 def show_changeset(ui, repo, opts, buffered=False):
     """show one changeset using template or regular display.
@@ -1702,12 +1702,11 @@
         return jsonchangeset(ui, repo, matchfn, opts, buffered)
 
     spec = _lookuplogtemplate(ui, opts.get('template'), opts.get('style'))
-    tmpl, mapfile = spec
-
-    if not tmpl and not mapfile:
+
+    if not spec.tmpl and not spec.mapfile:
         return changeset_printer(ui, repo, matchfn, opts, buffered)
 
-    return changeset_templater(ui, repo, matchfn, opts, tmpl, mapfile, buffered)
+    return changeset_templater(ui, repo, spec, matchfn, opts, buffered)
 
 def showmarker(fm, marker, index=None):
     """utility function to display obsolescence marker in a readable way
@@ -2954,9 +2953,8 @@
 
 def buildcommittemplate(repo, ctx, subs, extramsg, tmpl):
     ui = repo.ui
-    tmpl, mapfile = _lookuplogtemplate(ui, tmpl, None)
-
-    t = changeset_templater(ui, repo, None, {}, tmpl, mapfile, False)
+    spec = _lookuplogtemplate(ui, tmpl, None)
+    t = changeset_templater(ui, repo, spec, None, {}, False)
 
     for k, v in repo.ui.configitems('committemplate'):
         if k != 'changeset':