comparison mercurial/templater.py @ 29812:01f036f0e40b

templater: add inheritance support to style maps We can now specify a base map file: __base__ = path/to/map/file That map file will be read and used to populate unset elements of the current map. Unlike using %include, elements in the inherited class will be read relative to that path. This makes it much easier to make custom local tweaks to a style.
author Matt Mackall <mpm@selenic.com>
date Wed, 17 Aug 2016 13:40:27 -0500
parents 84ef4517de03
children 0d5cc0c18b4e
comparison
equal deleted inserted replaced
29811:4ddfb730789d 29812:01f036f0e40b
1024 if val[0] in "'\"": 1024 if val[0] in "'\"":
1025 if val[0] != val[-1]: 1025 if val[0] != val[-1]:
1026 raise error.ParseError(_('unmatched quotes'), 1026 raise error.ParseError(_('unmatched quotes'),
1027 conf.source('', key)) 1027 conf.source('', key))
1028 cache[key] = unquotestring(val) 1028 cache[key] = unquotestring(val)
1029 elif key == "__base__":
1030 # treat as a pointer to a base class for this style
1031 path = util.normpath(os.path.join(base, val))
1032 bcache, btmap = _readmapfile(path)
1033 for k in bcache:
1034 if k not in cache:
1035 cache[k] = bcache[k]
1036 for k in btmap:
1037 if k not in tmap:
1038 tmap[k] = btmap[k]
1029 else: 1039 else:
1030 val = 'default', val 1040 val = 'default', val
1031 if ':' in val[1]: 1041 if ':' in val[1]:
1032 val = val[1].split(':', 1) 1042 val = val[1].split(':', 1)
1033 tmap[key] = val[0], os.path.join(base, val[1]) 1043 tmap[key] = val[0], os.path.join(base, val[1])