Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/formatter.py @ 32970:61b60b28c381
formatter: add support for parts map of [templates] section
Unlike a mapfile whose template is looked up by spec -> mapfile -> topic,
[templates] section is global. We use :sub-section syntax to define parts
per template.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Apr 2017 21:29:00 +0900 |
parents | 5100ce217dfa |
children | 04b3743c1d7c |
comparison
equal
deleted
inserted
replaced
32969:050efe9a1644 | 32970:61b60b28c381 |
---|---|
451 def templatepartsmap(spec, t, partnames): | 451 def templatepartsmap(spec, t, partnames): |
452 """Create a mapping of {part: ref}""" | 452 """Create a mapping of {part: ref}""" |
453 partsmap = {spec.ref: spec.ref} # initial ref must exist in t | 453 partsmap = {spec.ref: spec.ref} # initial ref must exist in t |
454 if spec.mapfile: | 454 if spec.mapfile: |
455 partsmap.update((p, p) for p in partnames if p in t) | 455 partsmap.update((p, p) for p in partnames if p in t) |
456 elif spec.ref: | |
457 for part in partnames: | |
458 ref = '%s:%s' % (spec.ref, part) # select config sub-section | |
459 if ref in t: | |
460 partsmap[part] = ref | |
456 return partsmap | 461 return partsmap |
457 | 462 |
458 def loadtemplater(ui, spec, cache=None): | 463 def loadtemplater(ui, spec, cache=None): |
459 """Create a templater from either a literal template or loading from | 464 """Create a templater from either a literal template or loading from |
460 a map file""" | 465 a map file""" |