Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templater.py @ 34715:f17a0e18c47e
templater: load aliases from [templatealias] section in map file
This seems sometimes useful as an alias can be a function, but a template
fragment can't.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 14 Oct 2017 18:06:42 +0900 |
parents | f4aeb952ab77 |
children | b13c95919ff5 |
line wrap: on
line diff
--- a/mercurial/templater.py Sat Oct 14 17:51:01 2017 +0900 +++ b/mercurial/templater.py Sat Oct 14 18:06:42 2017 +0900 @@ -1344,6 +1344,7 @@ cache = {} tmap = {} + aliases = [] val = conf.get('templates', '__base__') if val and val[0] not in "'\"": @@ -1362,7 +1363,7 @@ path = p3 break - cache, tmap = _readmapfile(path) + cache, tmap, aliases = _readmapfile(path) for key, val in conf['templates'].items(): if not val: @@ -1378,7 +1379,8 @@ if ':' in val[1]: val = val[1].split(':', 1) tmap[key] = val[0], os.path.join(base, val[1]) - return cache, tmap + aliases.extend(conf['templatealias'].items()) + return cache, tmap, aliases class TemplateNotFound(error.Abort): pass @@ -1412,9 +1414,10 @@ minchunk=1024, maxchunk=65536): """Create templater from the specified map file""" t = cls(filters, defaults, cache, [], minchunk, maxchunk) - cache, tmap = _readmapfile(mapfile) + cache, tmap, aliases = _readmapfile(mapfile) t.cache.update(cache) t.map = tmap + t._aliases = aliases return t def __contains__(self, key):