diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py --- a/hgext/bugzilla.py +++ b/hgext/bugzilla.py @@ -879,14 +879,13 @@ class bugzilla(object): mapfile = self.ui.config('bugzilla', 'style') tmpl = self.ui.config('bugzilla', 'template') - t = cmdutil.changeset_templater(self.ui, self.repo, - False, None, mapfile, False) if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') if tmpl: tmpl = templater.parsestring(tmpl, quoted=False) - t.use_template(tmpl) + t = cmdutil.changeset_templater(self.ui, self.repo, + False, None, tmpl, mapfile, False) self.ui.pushbuffer() t.show(ctx, changes=ctx.changeset(), bug=str(bugid), diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -18,10 +18,10 @@ testedwith = 'internal' def maketemplater(ui, repo, tmpl): tmpl = templater.parsestring(tmpl, quoted=False) try: - t = cmdutil.changeset_templater(ui, repo, False, None, None, False) + t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, + None, False) except SyntaxError, inst: raise util.Abort(inst.args[0]) - t.use_template(tmpl) return t def changedlines(ui, repo, ctx1, ctx2, fns): diff --git a/hgext/hgcia.py b/hgext/hgcia.py --- a/hgext/hgcia.py +++ b/hgext/hgcia.py @@ -202,8 +202,7 @@ class hgcia(object): template = self.diffstat and self.dstemplate or self.deftemplate template = templater.parsestring(template, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, - style, False) - t.use_template(template) + template, style, False) self.templater = t def strip(self, path): diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -218,9 +218,8 @@ class kwtemplater(object): '''Replaces keywords in data with expanded template.''' def kwsub(mobj): kw = mobj.group(1) - ct = cmdutil.changeset_templater(self.ui, self.repo, - False, None, '', False) - ct.use_template(self.templates[kw]) + ct = cmdutil.changeset_templater(self.ui, self.repo, False, None + self.templates[kw], '', False) self.ui.pushbuffer() ct.show(ctx, root=self.repo.root, file=path) ekw = templatefilters.firstline(self.ui.popbuffer()) diff --git a/hgext/notify.py b/hgext/notify.py --- a/hgext/notify.py +++ b/hgext/notify.py @@ -188,13 +188,12 @@ class notifier(object): mapfile = self.ui.config('notify', 'style') template = (self.ui.config('notify', hooktype) or self.ui.config('notify', 'template')) - self.t = cmdutil.changeset_templater(self.ui, self.repo, - False, None, mapfile, False) if not mapfile and not template: template = deftemplates.get(hooktype) or single_template if template: template = templater.parsestring(template, quoted=False) - self.t.use_template(template) + self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None, + template, mapfile, 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 @@ -948,7 +948,7 @@ class changeset_printer(object): class changeset_templater(changeset_printer): '''format changeset information.''' - def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): + def __init__(self, ui, repo, patch, diffopts, tmpl, mapfile, buffered): changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) defaulttempl = { @@ -961,11 +961,10 @@ class changeset_templater(changeset_prin defaulttempl['filecopy'] = defaulttempl['file_copy'] self.t = templater.templater(mapfile, {'formatnode': formatnode}, cache=defaulttempl) - self.cache = {} + if tmpl: + self.t.cache['changeset'] = tmpl - def use_template(self, t): - '''set template string to use''' - self.t.cache['changeset'] = t + self.cache = {} def _meaningful_parentrevs(self, ctx): """Return list of meaningful (or all if debug) parentrevs for rev. @@ -1096,11 +1095,9 @@ def show_changeset(ui, repo, opts, buffe return changeset_printer(ui, repo, patch, opts, buffered) try: - t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) + t = changeset_templater(ui, repo, patch, opts, tmpl, mapfile, buffered) except SyntaxError, inst: raise util.Abort(inst.args[0]) - if tmpl: - t.use_template(tmpl) return t def showmarker(ui, marker):