Patchwork D8874: hgweb: simplify staticfile() now that we always pass it a single directory

login
register
mail settings
Submitter phabricator
Date Aug. 4, 2020, 7 a.m.
Message ID <differential-rev-PHID-DREV-wgrhnp5mz2rhcm3dd5rv-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46972/
State Superseded
Headers show

Comments

phabricator - Aug. 4, 2020, 7 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I didn't realize this further simplifications enabled by D8786 <https://phab.mercurial-scm.org/D8786> until
  now.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/hgweb/common.py
  mercurial/hgweb/hgwebdir_mod.py
  mercurial/hgweb/webcommands.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -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()
diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -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()
diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -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(