Patchwork D8907: templater: teach template loader to use open_template() function

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

Comments

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

REVISION SUMMARY
  The template loader can apparently load templates from relative paths,
  so I needed to add that support to `open_template()`.
  
  This takes the number of failing tests with PyOxidizer from 54 to 34.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -913,7 +913,8 @@ 
         """Get parsed tree for the given template name. Use a local cache."""
         if t not in self.cache:
             try:
-                self.cache[t] = util.readfile(self._map[t])
+                mapfile, fp = open_template(self._map[t])
+                self.cache[t] = fp.read()
             except KeyError as inst:
                 raise templateutil.TemplateNotFound(
                     _(b'"%s" not in template map') % inst.args[0]
@@ -1092,7 +1093,7 @@ 
     will then be the relative path.
     '''
     # Does the name point directly to a map file?
-    if os.path.isabs(name):
+    if os.path.isfile(name) or os.path.isabs(name):
         return name, open(name, mode='rb')
 
     # Does the name point to a template in the provided templatepath, or