diff 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
line wrap: on
line diff
--- a/mercurial/formatter.py	Sat Jun 17 16:32:20 2017 +0900
+++ b/mercurial/formatter.py	Sat Apr 22 21:29:00 2017 +0900
@@ -453,6 +453,11 @@
     partsmap = {spec.ref: spec.ref}  # initial ref must exist in t
     if spec.mapfile:
         partsmap.update((p, p) for p in partnames if p in t)
+    elif spec.ref:
+        for part in partnames:
+            ref = '%s:%s' % (spec.ref, part)  # select config sub-section
+            if ref in t:
+                partsmap[part] = ref
     return partsmap
 
 def loadtemplater(ui, spec, cache=None):