From patchwork Tue Aug 4 07:00:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D8874: hgweb: simplify staticfile() now that we always pass it a single directory From: phabricator X-Patchwork-Id: 46972 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 4 Aug 2020 07:00:14 +0000 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 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 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(