changeset 45327:9a5c4875a88c

hgweb: simplify staticfile() now that we always pass it a single directory I didn't realize this further simplifications enabled by D8786 until now. Differential Revision: https://phab.mercurial-scm.org/D8874
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 03 Aug 2020 22:15:45 -0700
parents e2320bb7a99f
children ba50c8a95e2b
files mercurial/hgweb/common.py mercurial/hgweb/hgwebdir_mod.py mercurial/hgweb/webcommands.py
diffstat 3 files changed, 3 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Fri Jul 31 10:05:07 2020 -0700
+++ b/mercurial/hgweb/common.py	Mon Aug 03 22:15:45 2020 -0700
@@ -191,12 +191,7 @@
         return
 
     fpath = os.path.join(*fname.split(b'/'))
-    if isinstance(directory, bytes):
-        directory = [directory]
-    for d in directory:
-        path = os.path.join(d, fpath)
-        if os.path.exists(path):
-            break
+    path = os.path.join(directory, fpath)
     try:
         os.stat(path)
         ct = pycompat.sysbytes(
--- a/mercurial/hgweb/hgwebdir_mod.py	Fri Jul 31 10:05:07 2020 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Mon Aug 03 22:15:45 2020 -0700
@@ -416,7 +416,7 @@
                 if not static:
                     tp = self.templatepath or templater.templatedir()
                     if tp is not None:
-                        static = [os.path.join(tp, b'static')]
+                        static = os.path.join(tp, b'static')
 
                 staticfile(static, fname, res)
                 return res.sendresponse()
--- a/mercurial/hgweb/webcommands.py	Fri Jul 31 10:05:07 2020 -0700
+++ b/mercurial/hgweb/webcommands.py	Mon Aug 03 22:15:45 2020 -0700
@@ -1320,7 +1320,7 @@
     static = web.config(b"web", b"static", untrusted=False)
     if not static:
         tp = web.templatepath or templater.templatedir()
-        static = [os.path.join(tp, b'static')]
+        static = os.path.join(tp, b'static')
 
     staticfile(static, fname, web.res)
     return web.res.sendresponse()