diff tests/test-branches.t @ 32952: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 abf91c4f9608
line wrap: on
line diff
--- a/tests/test-branches.t	Sat Jun 17 16:32:20 2017 +0900
+++ b/tests/test-branches.t	Sat Apr 22 21:29:00 2017 +0900
@@ -544,6 +544,31 @@
    {"branch": "default", "node": "19709c5a4e75"}
   }
 
+  $ cat <<'EOF' >> .hg/hgrc
+  > [templates]
+  > myjson = ' {dict(branch, node|short)|json}'
+  > myjson:docheader = '\{\n'
+  > myjson:docfooter = '\n}\n'
+  > myjson:separator = ',\n'
+  > EOF
+  $ hg branches -T myjson
+  {
+   {"branch": "b", "node": "e23b5505d1ad"},
+   {"branch": "a branch *", "node": "10ff5895aa57"}, (glob)
+   {"branch": "a", "node": "d8cbc61dbaa6"},
+   {"branch": "default", "node": "19709c5a4e75"}
+  }
+
+  $ cat <<'EOF' >> .hg/hgrc
+  > [templates]
+  > :docheader = 'should not be selected as a docheader for literal templates\n'
+  > EOF
+  $ hg branches -T '{branch}\n'
+  b
+  a branch name much longer than the default justification used by branches
+  a
+  default
+
 Tests of revision branch name caching
 
 We rev branch cache is updated automatically. In these tests we use a trick to