[Updated] D8895: templater: unroll loop over mapfile directories

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Aug 6 00:49:04 UTC 2020


Closed by commit rHGd9a502a0a9ca: templater: unroll loop over mapfile directories (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8895?vs=22277&id=22293

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8895/new/

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

AFFECTED FILES
  mercurial/templater.py

CHANGE DETAILS

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -829,17 +829,22 @@
     conf = config.config()
 
     def include(rel, remap, sections):
-        templatedirs = [base, templatedir()]
-        for dir in templatedirs:
-            if dir is None:
-                continue
-            abs = os.path.normpath(os.path.join(dir, rel))
+        subresource = None
+        if base:
+            abs = os.path.normpath(os.path.join(base, rel))
             if os.path.isfile(abs):
-                data = util.posixfile(abs, b'rb').read()
-                conf.parse(
-                    abs, data, sections=sections, remap=remap, include=include
-                )
-                break
+                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 subresource:
+            data = subresource.read()
+            conf.parse(
+                abs, data, sections=sections, remap=remap, include=include,
+            )
 
     data = fp.read()
     conf.parse(mapfile, data, remap={b'': b'templates'}, include=include)



To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200806/b1432d1a/attachment-0002.html>


More information about the Mercurial-patches mailing list