comparison mercurial/templater.py @ 46492:5272542196cc

config: use the right API to access template access Preventing direct access to the underlying dict will help a coming refactoring of `config`. Differential Revision: https://phab.mercurial-scm.org/D9922
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 29 Jan 2021 14:03:39 +0100
parents c000eff2c635
children d4ba4d51f85f
comparison
equal deleted inserted replaced
46491:271dfcb98544 46492:5272542196cc
889 path = p3 889 path = p3
890 890
891 fp = _open_mapfile(path) 891 fp = _open_mapfile(path)
892 cache, tmap, aliases = _readmapfile(fp, path) 892 cache, tmap, aliases = _readmapfile(fp, path)
893 893
894 for key, val in conf[b'templates'].items(): 894 for key, val in conf.items(b'templates'):
895 if not val: 895 if not val:
896 raise error.ParseError( 896 raise error.ParseError(
897 _(b'missing value'), conf.source(b'templates', key) 897 _(b'missing value'), conf.source(b'templates', key)
898 ) 898 )
899 if val[0] in b"'\"": 899 if val[0] in b"'\"":
902 _(b'unmatched quotes'), conf.source(b'templates', key) 902 _(b'unmatched quotes'), conf.source(b'templates', key)
903 ) 903 )
904 cache[key] = unquotestring(val) 904 cache[key] = unquotestring(val)
905 elif key != b'__base__': 905 elif key != b'__base__':
906 tmap[key] = os.path.join(base, val) 906 tmap[key] = os.path.join(base, val)
907 aliases.extend(conf[b'templatealias'].items()) 907 aliases.extend(conf.items(b'templatealias'))
908 return cache, tmap, aliases 908 return cache, tmap, aliases
909 909
910 910
911 class loader(object): 911 class loader(object):
912 """Load template fragments optionally from a map file""" 912 """Load template fragments optionally from a map file"""