##// END OF EJS Templates
changeset_templater: remove use_template method
Matt Mackall -
r20667:e96e9f80 default
parent child Browse files
Show More
@@ -879,14 +879,13 class bugzilla(object):
879
879
880 mapfile = self.ui.config('bugzilla', 'style')
880 mapfile = self.ui.config('bugzilla', 'style')
881 tmpl = self.ui.config('bugzilla', 'template')
881 tmpl = self.ui.config('bugzilla', 'template')
882 t = cmdutil.changeset_templater(self.ui, self.repo,
883 False, None, mapfile, False)
884 if not mapfile and not tmpl:
882 if not mapfile and not tmpl:
885 tmpl = _('changeset {node|short} in repo {root} refers '
883 tmpl = _('changeset {node|short} in repo {root} refers '
886 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
884 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
887 if tmpl:
885 if tmpl:
888 tmpl = templater.parsestring(tmpl, quoted=False)
886 tmpl = templater.parsestring(tmpl, quoted=False)
889 t.use_template(tmpl)
887 t = cmdutil.changeset_templater(self.ui, self.repo,
888 False, None, tmpl, mapfile, False)
890 self.ui.pushbuffer()
889 self.ui.pushbuffer()
891 t.show(ctx, changes=ctx.changeset(),
890 t.show(ctx, changes=ctx.changeset(),
892 bug=str(bugid),
891 bug=str(bugid),
@@ -18,10 +18,10 testedwith = 'internal'
18 def maketemplater(ui, repo, tmpl):
18 def maketemplater(ui, repo, tmpl):
19 tmpl = templater.parsestring(tmpl, quoted=False)
19 tmpl = templater.parsestring(tmpl, quoted=False)
20 try:
20 try:
21 t = cmdutil.changeset_templater(ui, repo, False, None, None, False)
21 t = cmdutil.changeset_templater(ui, repo, False, None, tmpl,
22 None, False)
22 except SyntaxError, inst:
23 except SyntaxError, inst:
23 raise util.Abort(inst.args[0])
24 raise util.Abort(inst.args[0])
24 t.use_template(tmpl)
25 return t
25 return t
26
26
27 def changedlines(ui, repo, ctx1, ctx2, fns):
27 def changedlines(ui, repo, ctx1, ctx2, fns):
@@ -202,8 +202,7 class hgcia(object):
202 template = self.diffstat and self.dstemplate or self.deftemplate
202 template = self.diffstat and self.dstemplate or self.deftemplate
203 template = templater.parsestring(template, quoted=False)
203 template = templater.parsestring(template, quoted=False)
204 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
204 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
205 style, False)
205 template, style, False)
206 t.use_template(template)
207 self.templater = t
206 self.templater = t
208
207
209 def strip(self, path):
208 def strip(self, path):
@@ -218,9 +218,8 class kwtemplater(object):
218 '''Replaces keywords in data with expanded template.'''
218 '''Replaces keywords in data with expanded template.'''
219 def kwsub(mobj):
219 def kwsub(mobj):
220 kw = mobj.group(1)
220 kw = mobj.group(1)
221 ct = cmdutil.changeset_templater(self.ui, self.repo,
221 ct = cmdutil.changeset_templater(self.ui, self.repo, False, None
222 False, None, '', False)
222 self.templates[kw], '', False)
223 ct.use_template(self.templates[kw])
224 self.ui.pushbuffer()
223 self.ui.pushbuffer()
225 ct.show(ctx, root=self.repo.root, file=path)
224 ct.show(ctx, root=self.repo.root, file=path)
226 ekw = templatefilters.firstline(self.ui.popbuffer())
225 ekw = templatefilters.firstline(self.ui.popbuffer())
@@ -188,13 +188,12 class notifier(object):
188 mapfile = self.ui.config('notify', 'style')
188 mapfile = self.ui.config('notify', 'style')
189 template = (self.ui.config('notify', hooktype) or
189 template = (self.ui.config('notify', hooktype) or
190 self.ui.config('notify', 'template'))
190 self.ui.config('notify', 'template'))
191 self.t = cmdutil.changeset_templater(self.ui, self.repo,
192 False, None, mapfile, False)
193 if not mapfile and not template:
191 if not mapfile and not template:
194 template = deftemplates.get(hooktype) or single_template
192 template = deftemplates.get(hooktype) or single_template
195 if template:
193 if template:
196 template = templater.parsestring(template, quoted=False)
194 template = templater.parsestring(template, quoted=False)
197 self.t.use_template(template)
195 self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
196 template, mapfile, False)
198
197
199 def strip(self, path):
198 def strip(self, path):
200 '''strip leading slashes from local path, turn into web-safe path.'''
199 '''strip leading slashes from local path, turn into web-safe path.'''
@@ -948,7 +948,7 class changeset_printer(object):
948 class changeset_templater(changeset_printer):
948 class changeset_templater(changeset_printer):
949 '''format changeset information.'''
949 '''format changeset information.'''
950
950
951 def __init__(self, ui, repo, patch, diffopts, mapfile, buffered):
951 def __init__(self, ui, repo, patch, diffopts, tmpl, mapfile, buffered):
952 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered)
952 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered)
953 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
953 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
954 defaulttempl = {
954 defaulttempl = {
@@ -961,11 +961,10 class changeset_templater(changeset_prin
961 defaulttempl['filecopy'] = defaulttempl['file_copy']
961 defaulttempl['filecopy'] = defaulttempl['file_copy']
962 self.t = templater.templater(mapfile, {'formatnode': formatnode},
962 self.t = templater.templater(mapfile, {'formatnode': formatnode},
963 cache=defaulttempl)
963 cache=defaulttempl)
964 self.cache = {}
964 if tmpl:
965 self.t.cache['changeset'] = tmpl
965
966
966 def use_template(self, t):
967 self.cache = {}
967 '''set template string to use'''
968 self.t.cache['changeset'] = t
969
968
970 def _meaningful_parentrevs(self, ctx):
969 def _meaningful_parentrevs(self, ctx):
971 """Return list of meaningful (or all if debug) parentrevs for rev.
970 """Return list of meaningful (or all if debug) parentrevs for rev.
@@ -1096,11 +1095,9 def show_changeset(ui, repo, opts, buffe
1096 return changeset_printer(ui, repo, patch, opts, buffered)
1095 return changeset_printer(ui, repo, patch, opts, buffered)
1097
1096
1098 try:
1097 try:
1099 t = changeset_templater(ui, repo, patch, opts, mapfile, buffered)
1098 t = changeset_templater(ui, repo, patch, opts, tmpl, mapfile, buffered)
1100 except SyntaxError, inst:
1099 except SyntaxError, inst:
1101 raise util.Abort(inst.args[0])
1100 raise util.Abort(inst.args[0])
1102 if tmpl:
1103 t.use_template(tmpl)
1104 return t
1101 return t
1105
1102
1106 def showmarker(ui, marker):
1103 def showmarker(ui, marker):
General Comments 0
You need to be logged in to leave comments. Login now