##// END OF EJS Templates
cmdutil: factor out helper to create changeset_templater with literal template...
Yuya Nishihara -
r32837:50586a0a default
parent child Browse files
Show More
@@ -32,9 +32,6 b' command = registrar.command(cmdtable)'
32 # leave the attribute unspecified.
32 # leave the attribute unspecified.
33 testedwith = 'ships-with-hg-core'
33 testedwith = 'ships-with-hg-core'
34
34
35 def maketemplater(ui, repo, tmpl):
36 return cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False)
37
38 def changedlines(ui, repo, ctx1, ctx2, fns):
35 def changedlines(ui, repo, ctx1, ctx2, fns):
39 added, removed = 0, 0
36 added, removed = 0, 0
40 fmatch = scmutil.matchfiles(repo, fns)
37 fmatch = scmutil.matchfiles(repo, fns)
@@ -55,7 +52,7 b' def countrate(ui, repo, amap, *pats, **o'
55 return date.strftime(opts['dateformat'])
52 return date.strftime(opts['dateformat'])
56 else:
53 else:
57 tmpl = opts.get('oldtemplate') or opts.get('template')
54 tmpl = opts.get('oldtemplate') or opts.get('template')
58 tmpl = maketemplater(ui, repo, tmpl)
55 tmpl = cmdutil.makelogtemplater(ui, repo, tmpl)
59 def getkey(ctx):
56 def getkey(ctx):
60 ui.pushbuffer()
57 ui.pushbuffer()
61 tmpl.show(ctx)
58 tmpl.show(ctx)
@@ -239,8 +239,8 b' class kwtemplater(object):'
239 '''Replaces keywords in data with expanded template.'''
239 '''Replaces keywords in data with expanded template.'''
240 def kwsub(mobj):
240 def kwsub(mobj):
241 kw = mobj.group(1)
241 kw = mobj.group(1)
242 ct = cmdutil.changeset_templater(self.ui, self.repo, False, None,
242 ct = cmdutil.makelogtemplater(self.ui, self.repo,
243 self.templates[kw], '', False)
243 self.templates[kw])
244 self.ui.pushbuffer()
244 self.ui.pushbuffer()
245 ct.show(ctx, root=self.repo.root, file=path)
245 ct.show(ctx, root=self.repo.root, file=path)
246 ekw = templatefilters.firstline(self.ui.popbuffer())
246 ekw = templatefilters.firstline(self.ui.popbuffer())
@@ -196,9 +196,8 b' def showwork(ui, repo, fm):'
196 revs = repo.revs('sort(_underway(), topo)')
196 revs = repo.revs('sort(_underway(), topo)')
197
197
198 revdag = graphmod.dagwalker(repo, revs)
198 revdag = graphmod.dagwalker(repo, revs)
199 displayer = cmdutil.changeset_templater(ui, repo, None, None,
199 tmpl = fm._t.load(fm._topic)
200 tmpl=fm._t.load(fm._topic),
200 displayer = cmdutil.makelogtemplater(ui, repo, tmpl, buffered=True)
201 mapfile=None, buffered=True)
202
201
203 ui.setconfig('experimental', 'graphshorten', True)
202 ui.setconfig('experimental', 'graphshorten', True)
204 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
203 cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
@@ -1674,6 +1674,11 b' def _lookuplogtemplate(ui, tmpl, style):'
1674
1674
1675 return formatter.lookuptemplate(ui, 'changeset', tmpl)
1675 return formatter.lookuptemplate(ui, 'changeset', tmpl)
1676
1676
1677 def makelogtemplater(ui, repo, tmpl, buffered=False):
1678 """Create a changeset_templater from a literal template 'tmpl'"""
1679 return changeset_templater(ui, repo, matchfn=None, diffopts={},
1680 tmpl=tmpl, mapfile=None, buffered=buffered)
1681
1677 def show_changeset(ui, repo, opts, buffered=False):
1682 def show_changeset(ui, repo, opts, buffered=False):
1678 """show one changeset using template or regular display.
1683 """show one changeset using template or regular display.
1679
1684
@@ -2120,14 +2120,12 b' def debugtemplate(ui, repo, tmpl, **opts'
2120 if newtree != tree:
2120 if newtree != tree:
2121 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n')
2121 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n')
2122
2122
2123 mapfile = None
2124 if revs is None:
2123 if revs is None:
2125 k = 'debugtemplate'
2124 k = 'debugtemplate'
2126 t = formatter.maketemplater(ui, k, tmpl)
2125 t = formatter.maketemplater(ui, k, tmpl)
2127 ui.write(templater.stringify(t(k, ui=ui, **props)))
2126 ui.write(templater.stringify(t(k, ui=ui, **props)))
2128 else:
2127 else:
2129 displayer = cmdutil.changeset_templater(ui, repo, None, opts, tmpl,
2128 displayer = cmdutil.makelogtemplater(ui, repo, tmpl)
2130 mapfile, buffered=False)
2131 for r in revs:
2129 for r in revs:
2132 displayer.show(repo[r], **props)
2130 displayer.show(repo[r], **props)
2133 displayer.close()
2131 displayer.close()
General Comments 0
You need to be logged in to leave comments. Login now