[Request] [+ ] D8874: hgweb: simplify staticfile() now that we always pass it a single directory

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Aug 4 07:00:14 UTC 2020


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

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(



To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200804/e8bbd013/attachment-0001.html>


More information about the Mercurial-patches mailing list