comparison mercurial/formatter.py @ 32832:11e667a8fcba

formatter: factor out function to create templater from literal or map file (tmpl, mapfile) will be packed into a named tuple later.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 22 Apr 2017 15:06:06 +0900
parents 470820c2418d
children 99df35499cae
comparison
equal deleted inserted replaced
32831:de7dc25ecf2e 32832:11e667a8fcba
406 # constant string? 406 # constant string?
407 return tmpl, None 407 return tmpl, None
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)
414 return maketemplater(ui, topic, tmpl, cache=cache) 420 return maketemplater(ui, topic, tmpl, cache=cache)
415 421