diff mercurial/templater.py @ 29848:b1f69dbdd76b

templater: add template path to __base__ search This does a fall-back check for style files or directories that are in Mercurial's template path for user convenience. We intentionally don't use this for the built-in coal style because we don't want the style to mysteriously break if the working directory just happens to have a file named "paper".
author Matt Mackall <mpm@selenic.com>
date Wed, 24 Aug 2016 17:43:45 -0700
parents 407879b0893b
children e83f89d3b1f7
line wrap: on
line diff
--- a/mercurial/templater.py	Tue Aug 23 16:40:08 2016 -0400
+++ b/mercurial/templater.py	Wed Aug 24 17:43:45 2016 -0700
@@ -1047,6 +1047,19 @@
         elif key == "__base__":
             # treat as a pointer to a base class for this style
             path = util.normpath(os.path.join(base, val))
+
+            # fallback check in template paths
+            if not os.path.exists(path):
+                for p in templatepaths():
+                    p2 = util.normpath(os.path.join(p, val))
+                    if os.path.isfile(p2):
+                        path = p2
+                        break
+                    p3 = util.normpath(os.path.join(p2, "map"))
+                    if os.path.isfile(p3):
+                        path = p3
+                        break
+
             bcache, btmap = _readmapfile(path)
             for k in bcache:
                 if k not in cache: