[PATCH 3 of 6] cmdutil: pass templatespec tuple directly to changeset_templater (API)
Yuya Nishihara
yuya at tcha.org
Thu Jun 15 10:52:29 EDT 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1492855367 -32400
# Sat Apr 22 19:02:47 2017 +0900
# Node ID 5fc9194c72e9a2882403f77ac66e364e50425ce0
# Parent 019d918605ade79f498235167af488130c9f74e9
cmdutil: pass templatespec tuple directly to changeset_templater (API)
A fewer number of arguments should be better.
diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
--- a/hgext/bugzilla.py
+++ b/hgext/bugzilla.py
@@ -1040,8 +1040,9 @@ class bugzilla(object):
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),
diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -203,8 +203,9 @@ class notifier(object):
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.'''
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1578,9 +1578,8 @@ class jsonchangeset(changeset_printer):
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 _lookuplogtemplate(ui, tmpl, style):
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 @@ def show_changeset(ui, repo, opts, buffe
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 commitforceeditor(repo, ctx, subs, f
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':
More information about the Mercurial-devel
mailing list