changeset 45313:fef64d7a4a84

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
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 30 Jul 2020 21:36:29 -0700
parents d9a502a0a9ca
children d12fba074cc6
files mercurial/templater.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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(