Patchwork D8896: templater: try to read %include in mapfiles from resources

login
register
mail settings
Submitter phabricator
Date Aug. 5, 2020, 5:10 p.m.
Message ID <differential-rev-PHID-DREV-ugcumh72nhlfuxdbm3y5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46995/
State Superseded
Headers show

Comments

phabricator - Aug. 5, 2020, 5:10 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8896

AFFECTED FILES
  mercurial/templater.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -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(