changeset 45200:4e9b39033d3f

templater: simplify stylemap() now that templatedir() returns a single path Differential Revision: https://phab.mercurial-scm.org/D8787
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 21 Jul 2020 13:41:26 -0700
parents 91aa9bba3dc9
children 86f9b25d750b
files mercurial/templater.py
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templater.py	Tue Jul 21 13:11:49 2020 -0700
+++ b/mercurial/templater.py	Tue Jul 21 13:41:26 2020 -0700
@@ -1057,7 +1057,7 @@
     return None
 
 
-def stylemap(styles, paths=None):
+def stylemap(styles, path=None):
     """Return path to mapfile for a given style.
 
     Searches mapfile in the following locations:
@@ -1066,10 +1066,8 @@
     3. templatepath/map
     """
 
-    if paths is None:
-        paths = [templatedir()]
-    elif isinstance(paths, bytes):
-        paths = [paths]
+    if path is None:
+        path = templatedir()
 
     if isinstance(styles, bytes):
         styles = [styles]
@@ -1087,10 +1085,9 @@
         locations = [os.path.join(style, b'map'), b'map-' + style]
         locations.append(b'map')
 
-        for path in paths:
-            for location in locations:
-                mapfile = os.path.join(path, location)
-                if os.path.isfile(mapfile):
-                    return style, mapfile
+        for location in locations:
+            mapfile = os.path.join(path, location)
+            if os.path.isfile(mapfile):
+                return style, mapfile
 
-    raise RuntimeError(b"No hgweb templates found in %r" % paths)
+    raise RuntimeError(b"No hgweb templates found in %r" % path)