Mercurial > hg
changeset 45210:4ccd5ec565c2
templater: do search for include of unqualified builtin outside of config code
Commit 081b08e4ea13 (templater: look for mapfiles in template paths,
2015-05-15) added support for using things like `%include
map-cmdline.default` to include built-in map files without using a
valid path to them. This patch rewrites that support by moving it into
`_readmapfile()` so it can later be adapted for reading from a
non-file resource.
Differential Revision: https://phab.mercurial-scm.org/D8792
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 22 Jul 2020 00:09:17 -0700 |
parents | 8ec3062b7047 |
children | d5ccc059fbcd |
files | mercurial/templater.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templater.py Tue Jul 21 21:59:12 2020 -0700 +++ b/mercurial/templater.py Wed Jul 22 00:09:17 2020 -0700 @@ -823,11 +823,18 @@ ) base = os.path.dirname(mapfile) - conf = config.config(includepaths=[templatedir()]) + conf = config.config() def include(rel, abs, remap, sections): - data = util.posixfile(abs, b'rb').read() - conf.parse(abs, data, sections=sections, remap=remap, include=include) + templatedirs = [base, templatedir()] + for dir in templatedirs: + abs = os.path.normpath(os.path.join(dir, rel)) + if os.path.isfile(abs): + data = util.posixfile(abs, b'rb').read() + conf.parse( + abs, data, sections=sections, remap=remap, include=include + ) + break data = util.posixfile(mapfile, b'rb').read() conf.parse(mapfile, data, remap={b'': b'templates'}, include=include)