[Request] [+ ] D8933: hgweb: handle None from templatedir() equally bad in webcommands.py
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Aug 19 04:42:29 UTC 2020
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
The following paragraph is based just on my reading of the code; I
have not tried to test it.
Before my recent work on templates in frozen binaries, it seems both
`hgwebdir_mod.py` and `webcommands.py` would pass in an empty list
into `staticfile()` when running in a frozen binary. That would then
result in a variable in that function (`path`) not getting bound
before its first use. I then changed that without thinking in D8786 <https://phab.mercurial-scm.org/D8786> so
we passed a `None` value into the function, which made it break in
another way (trying to iterate over `None`). Then I tried to fix it up
in D8810 <https://phab.mercurial-scm.org/D8810>, but I only changed `hgwebdir_mod.py` for some reason, and it
still doesn't actually work in frozen binaries (which seems fair,
since was broken before my changes too).
This patch just replicates the half-assed "fix" from D8810 <https://phab.mercurial-scm.org/D8810> in
`webcommands.py`, so they look more similar so I can start refactoring
them in the same way.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8933
AFFECTED FILES
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,8 @@
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')
+ if tp is not None:
+ static = os.path.join(tp, b'static')
staticfile(static, fname, web.res)
return web.res.sendresponse()
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/20200819/32657578/attachment-0001.html>
More information about the Mercurial-patches
mailing list