##// END OF EJS Templates
templater: load template fragments from [templates] section in map file...
Yuya Nishihara -
r34715:f4aeb952 default
parent child Browse files
Show More
@@ -1340,12 +1340,12 b' def _readmapfile(mapfile):'
1340
1340
1341 base = os.path.dirname(mapfile)
1341 base = os.path.dirname(mapfile)
1342 conf = config.config(includepaths=templatepaths())
1342 conf = config.config(includepaths=templatepaths())
1343 conf.read(mapfile)
1343 conf.read(mapfile, remap={'': 'templates'})
1344
1344
1345 cache = {}
1345 cache = {}
1346 tmap = {}
1346 tmap = {}
1347
1347
1348 val = conf.get('', '__base__')
1348 val = conf.get('templates', '__base__')
1349 if val and val[0] not in "'\"":
1349 if val and val[0] not in "'\"":
1350 # treat as a pointer to a base class for this style
1350 # treat as a pointer to a base class for this style
1351 path = util.normpath(os.path.join(base, val))
1351 path = util.normpath(os.path.join(base, val))
@@ -1364,13 +1364,14 b' def _readmapfile(mapfile):'
1364
1364
1365 cache, tmap = _readmapfile(path)
1365 cache, tmap = _readmapfile(path)
1366
1366
1367 for key, val in conf[''].items():
1367 for key, val in conf['templates'].items():
1368 if not val:
1368 if not val:
1369 raise error.ParseError(_('missing value'), conf.source('', key))
1369 raise error.ParseError(_('missing value'),
1370 conf.source('templates', key))
1370 if val[0] in "'\"":
1371 if val[0] in "'\"":
1371 if val[0] != val[-1]:
1372 if val[0] != val[-1]:
1372 raise error.ParseError(_('unmatched quotes'),
1373 raise error.ParseError(_('unmatched quotes'),
1373 conf.source('', key))
1374 conf.source('templates', key))
1374 cache[key] = unquotestring(val)
1375 cache[key] = unquotestring(val)
1375 elif key != '__base__':
1376 elif key != '__base__':
1376 val = 'default', val
1377 val = 'default', val
@@ -1,5 +1,6 b''
1 %include map-cmdline.default
1 %include map-cmdline.default
2
2
3 [templates]
3 changeset = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}\n'
4 changeset = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}\n'
4 changeset_quiet = '{lshortbisect} {rev}:{node|short}\n'
5 changeset_quiet = '{lshortbisect} {rev}:{node|short}\n'
5 changeset_verbose = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
6 changeset_verbose = '{cset}{lbisect}{branches}{bookmarks}{tags}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
@@ -1,3 +1,4 b''
1 [templates]
1 header = '{date|shortdate} {author|person} <{author|email}>\n\n'
2 header = '{date|shortdate} {author|person} <{author|email}>\n\n'
2 header_verbose = ''
3 header_verbose = ''
3 changeset = '\t* {files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\t[{node|short}]{tags}{branches}\n\n'
4 changeset = '\t* {files|stringify|fill68|tabindent}{desc|fill68|tabindent|strip}\n\t[{node|short}]{tags}{branches}\n\n'
@@ -1,3 +1,4 b''
1 [templates]
1 ldate = '{label("log.date",
2 ldate = '{label("log.date",
2 "{date|isodate}")}'
3 "{date|isodate}")}'
3
4
@@ -1,5 +1,7 b''
1 # Base templates. Due to name clashes with existing keywords, we have
1 # Base templates. Due to name clashes with existing keywords, we have
2 # to replace some keywords with 'lkeyword', for 'labelled keyword'
2 # to replace some keywords with 'lkeyword', for 'labelled keyword'
3
4 [templates]
3 changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{summary}\n'
5 changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{summary}\n'
4 changeset_quiet = '{lnode}'
6 changeset_quiet = '{lnode}'
5 changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{lfiles}{lfile_copies_switch}{description}\n'
7 changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{lfiles}{lfile_copies_switch}{description}\n'
@@ -1,3 +1,5 b''
1 %include map-cmdline.default
1 %include map-cmdline.default
2
3 [templates]
2 changeset = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{summary}\n'
4 changeset = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{summary}\n'
3 changeset_verbose = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
5 changeset_verbose = '{cset}{branches}{bookmarks}{tags}{lphase}{parents}{user}{ldate}{lfiles}{lfile_copies_switch}{description}\n'
@@ -3,6 +3,8 b''
3 # piggyback on existing values so color works.
3 # piggyback on existing values so color works.
4 # * Obsolescence isn't considered for node labels. See _cset_labels in
4 # * Obsolescence isn't considered for node labels. See _cset_labels in
5 # map-cmdline.default.
5 # map-cmdline.default.
6
7 [templates]
6 showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, nodelen)}\n'
8 showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, nodelen)}\n'
7
9
8 showwork = '{cset_shortnode}{namespaces % cset_namespace} {cset_shortdesc}'
10 showwork = '{cset_shortnode}{namespaces % cset_namespace} {cset_shortdesc}'
@@ -1,5 +1,6 b''
1 %include map-cmdline.default
1 %include map-cmdline.default
2
2
3 [templates]
3 # Override base templates
4 # Override base templates
4 changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}{lfiles}\n'
5 changeset = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{summary}{lfiles}\n'
5 changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{description}{lfiles}\n'
6 changeset_verbose = '{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{description}{lfiles}\n'
@@ -1,3 +1,4 b''
1 [templates]
1 docheader = '<?xml version="1.0"?>\n<log>\n'
2 docheader = '<?xml version="1.0"?>\n<log>\n'
2 docfooter = '</log>\n'
3 docfooter = '</log>\n'
3
4
@@ -259,6 +259,25 b' Test templates and style maps in files:'
259 $ hg log -l1 -T./map-simple
259 $ hg log -l1 -T./map-simple
260 8
260 8
261
261
262 a map file may have [templates] section:
263
264 $ cat <<'EOF' > map-simple
265 > [templates]
266 > changeset = "{rev}\n"
267 > EOF
268 $ hg log -l1 -T./map-simple
269 8
270
271 so it can be included in hgrc
272
273 $ cat <<'EOF' > myhgrc
274 > %include map-simple
275 > [templates]
276 > foo = "{changeset}"
277 > EOF
278 $ HGRCPATH=./myhgrc hg log -l1 -Tfoo
279 8
280
262 Test template map inheritance
281 Test template map inheritance
263
282
264 $ echo "__base__ = map-cmdline.default" > map-simple
283 $ echo "__base__ = map-cmdline.default" > map-simple
General Comments 0
You need to be logged in to leave comments. Login now