@@ -1340,12 +1340,12 @@ def _readmapfile(mapfile):
base = os.path.dirname(mapfile)
conf = config.config(includepaths=templatepaths())
- conf.read(mapfile)
+ conf.read(mapfile, remap={'': 'templates'})
cache = {}
tmap = {}
- val = conf.get('', '__base__')
+ val = conf.get('templates', '__base__')
if val and val[0] not in "'\"":
# treat as a pointer to a base class for this style
path = util.normpath(os.path.join(base, val))
@@ -1364,13 +1364,14 @@ def _readmapfile(mapfile):
cache, tmap = _readmapfile(path)
- for key, val in conf[''].items():
+ for key, val in conf['templates'].items():
if not val:
- raise error.ParseError(_('missing value'), conf.source('', key))
+ raise error.ParseError(_('missing value'),
+ conf.source('templates', key))
if val[0] in "'\"":
if val[0] != val[-1]:
raise error.ParseError(_('unmatched quotes'),
- conf.source('', key))
+ conf.source('templates', key))
cache[key] = unquotestring(val)
elif key != '__base__':
val = 'default', val
@@ -1,5 +1,6 @@
%include map-cmdline.default
+[templates]
changeset = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}\n'
changeset_quiet = '{lshortbisect} {rev}:{node|short}\n'
changeset_verbose = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
@@ -1,3 +1,4 @@
+[templates]
header = '{date|shortdate} {author|person} <{author|email}>\n\n'
header_verbose = ''
changeset = '\t* {files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\t[{node|short}]{tags}{branches}\n\n'
@@ -1,3 +1,4 @@
+[templates]
ldate = '{label("log.date",
"{date|isodate}")}'
@@ -1,5 +1,7 @@
# Base templates. Due to name clashes with existing keywords, we have
# to replace some keywords with 'lkeyword', for 'labelled keyword'
+
+[templates]
changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{summary}\n'
changeset_quiet = '{lnode}'
changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{lfiles}{lfile_copies_switch}{description}\n'
@@ -1,3 +1,5 @@
%include map-cmdline.default
+
+[templates]
changeset = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{summary}\n'
changeset_verbose = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
@@ -3,6 +3,8 @@
# piggyback on existing values so color works.
# * Obsolescence isn't considered for node labels. See _cset_labels in
# map-cmdline.default.
+
+[templates]
showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, nodelen)}\n'
showwork = '{cset_shortnode}{namespaces % cset_namespace} {cset_shortdesc}'
@@ -1,5 +1,6 @@
%include map-cmdline.default
+[templates]
# Override base templates
changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}{lfiles}\n'
changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{description}{lfiles}\n'
@@ -1,3 +1,4 @@
+[templates]
docheader = '<?xml version="1.0"?>\n<log>\n'
docfooter = '</log>\n'
@@ -259,6 +259,25 @@ Test templates and style maps in files:
$ hg log -l1 -T./map-simple
8
+ a map file may have [templates] section:
+
+ $ cat <<'EOF' > map-simple
+ > [templates]
+ > changeset = "{rev}\n"
+ > EOF
+ $ hg log -l1 -T./map-simple
+ 8
+
+ so it can be included in hgrc
+
+ $ cat <<'EOF' > myhgrc
+ > %include map-simple
+ > [templates]
+ > foo = "{changeset}"
+ > EOF
+ $ HGRCPATH=./myhgrc hg log -l1 -Tfoo
+ 8
+
Test template map inheritance
$ echo "__base__ = map-cmdline.default" > map-simple