templater: try to read %include in mapfiles from resources
The "show" style is an example of a style that uses an "%include"
statement in its definition. This patch makes `hg log --style show`
work.
This takes the number of failing tests with PyOxidizer from 72 to 62.
Differential Revision: https://phab.mercurial-scm.org/D8896
--- a/mercurial/templater.py Thu Jul 30 15:29:06 2020 -0700
+++ b/mercurial/templater.py Thu Jul 30 21:36:29 2020 -0700
@@ -835,11 +835,17 @@
if os.path.isfile(abs):
subresource = util.posixfile(abs, b'rb')
if not subresource:
- dir = templatedir()
- if dir:
- abs = os.path.normpath(os.path.join(dir, rel))
- if os.path.isfile(abs):
- subresource = util.posixfile(abs, b'rb')
+ if pycompat.ossep not in rel:
+ abs = rel
+ subresource = resourceutil.open_resource(
+ b'mercurial.templates', rel
+ )
+ else:
+ dir = templatedir()
+ if dir:
+ abs = os.path.normpath(os.path.join(dir, rel))
+ if os.path.isfile(abs):
+ subresource = util.posixfile(abs, b'rb')
if subresource:
data = subresource.read()
conf.parse(