changeset 45338:c37ab438ff31

hgweb: rely on open_template()'s fallback to using templatedir() Differential Revision: https://phab.mercurial-scm.org/D8900
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 05 Aug 2020 14:03:45 -0700
parents 1b983985edd9
children 1a4f925f72c3
files mercurial/hgweb/hgweb_mod.py
diffstat 1 files changed, 15 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Wed Aug 05 14:03:14 2020 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Aug 05 14:03:45 2020 -0700
@@ -65,26 +65,22 @@
     3. templatepath/map
     """
 
-    if path is None:
-        path = templater.templatedir()
+    for style in styles:
+        # only plain name is allowed to honor template paths
+        if (
+            not style
+            or style in (pycompat.oscurdir, pycompat.ospardir)
+            or pycompat.ossep in style
+            or pycompat.osaltsep
+            and pycompat.osaltsep in style
+        ):
+            continue
+        locations = (os.path.join(style, b'map'), b'map-' + style, b'map')
 
-    if path is not None:
-        for style in styles:
-            # only plain name is allowed to honor template paths
-            if (
-                not style
-                or style in (pycompat.oscurdir, pycompat.ospardir)
-                or pycompat.ossep in style
-                or pycompat.osaltsep
-                and pycompat.osaltsep in style
-            ):
-                continue
-            locations = (os.path.join(style, b'map'), b'map-' + style, b'map')
-
-            for location in locations:
-                mapfile, fp = templater.open_template(location, path)
-                if mapfile:
-                    return style, mapfile
+        for location in locations:
+            mapfile, fp = templater.open_template(location, path)
+            if mapfile:
+                return style, mapfile
 
     raise RuntimeError(b"No hgweb templates found in %r" % path)