##// END OF EJS Templates
formatter: factor out function to create templater from literal or map file...
Yuya Nishihara -
r32831:11e667a8 default
parent child Browse files
Show More
@@ -1580,15 +1580,8 b' class changeset_templater(changeset_prin'
1580
1580
1581 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
1581 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
1582 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
1582 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
1583 assert not (tmpl and mapfile)
1583 self.t = formatter.loadtemplater(ui, 'changeset', (tmpl, mapfile),
1584 defaulttempl = templatekw.defaulttempl
1584 cache=templatekw.defaulttempl)
1585 if mapfile:
1586 self.t = templater.templater.frommapfile(mapfile,
1587 cache=defaulttempl)
1588 else:
1589 self.t = formatter.maketemplater(ui, 'changeset', tmpl,
1590 cache=defaulttempl)
1591
1592 self._counter = itertools.count()
1585 self._counter = itertools.count()
1593 self.cache = {}
1586 self.cache = {}
1594
1587
@@ -408,6 +408,12 b' def lookuptemplate(ui, topic, tmpl):'
408
408
409 def gettemplater(ui, topic, spec, cache=None):
409 def gettemplater(ui, topic, spec, cache=None):
410 tmpl, mapfile = lookuptemplate(ui, topic, spec)
410 tmpl, mapfile = lookuptemplate(ui, topic, spec)
411 return loadtemplater(ui, topic, (tmpl, mapfile), cache=cache)
412
413 def loadtemplater(ui, topic, spec, cache=None):
414 """Create a templater from either a literal template or loading from
415 a map file"""
416 tmpl, mapfile = spec
411 assert not (tmpl and mapfile)
417 assert not (tmpl and mapfile)
412 if mapfile:
418 if mapfile:
413 return templater.templater.frommapfile(mapfile, cache=cache)
419 return templater.templater.frommapfile(mapfile, cache=cache)
General Comments 0
You need to be logged in to leave comments. Login now