##// END OF EJS Templates
formatter: add support for parts map of [templates] section...
Yuya Nishihara -
r32952:61b60b28 default
parent child Browse files
Show More
@@ -453,6 +453,11 b' def templatepartsmap(spec, t, partnames)'
453 453 partsmap = {spec.ref: spec.ref} # initial ref must exist in t
454 454 if spec.mapfile:
455 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 461 return partsmap
457 462
458 463 def loadtemplater(ui, spec, cache=None):
@@ -117,6 +117,15 b' another template::'
117 117 but be aware that the keywords cannot be overridden by templates. For example,
118 118 a template defined as ``templates.rev`` cannot be referenced as ``{rev}``.
119 119
120 A template defined in ``templates`` section may have sub templates which
121 are inserted before/after/between items::
122
123 [templates]
124 myjson = ' {dict(rev, node|short)|json}'
125 myjson:docheader = '\{\n'
126 myjson:docfooter = '\n}\n'
127 myjson:separator = ',\n'
128
120 129 Examples
121 130 ========
122 131
@@ -544,6 +544,31 b' template output:'
544 544 {"branch": "default", "node": "19709c5a4e75"}
545 545 }
546 546
547 $ cat <<'EOF' >> .hg/hgrc
548 > [templates]
549 > myjson = ' {dict(branch, node|short)|json}'
550 > myjson:docheader = '\{\n'
551 > myjson:docfooter = '\n}\n'
552 > myjson:separator = ',\n'
553 > EOF
554 $ hg branches -T myjson
555 {
556 {"branch": "b", "node": "e23b5505d1ad"},
557 {"branch": "a branch *", "node": "10ff5895aa57"}, (glob)
558 {"branch": "a", "node": "d8cbc61dbaa6"},
559 {"branch": "default", "node": "19709c5a4e75"}
560 }
561
562 $ cat <<'EOF' >> .hg/hgrc
563 > [templates]
564 > :docheader = 'should not be selected as a docheader for literal templates\n'
565 > EOF
566 $ hg branches -T '{branch}\n'
567 b
568 a branch name much longer than the default justification used by branches
569 a
570 default
571
547 572 Tests of revision branch name caching
548 573
549 574 We rev branch cache is updated automatically. In these tests we use a trick to
General Comments 0
You need to be logged in to leave comments. Login now