Patchwork D8787: templater: simplify stylemap() now that templatedir() returns a single path

login
register
mail settings
Submitter phabricator
Date July 22, 2020, 5:24 a.m.
Message ID <differential-rev-PHID-DREV-6hjekd2tfokx2ipkvtui-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46830/
State Superseded
Headers show

Comments

phabricator - July 22, 2020, 5:24 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -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)