[Updated] D8899: hgweb: open mapfile using templater.open_template()
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Thu Aug 6 00:49:57 UTC 2020
Closed by commit rHG1b983985edd9: hgweb: open mapfile using templater.open_template() (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8899?vs=22281&id=22298
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8899/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8899
AFFECTED FILES
mercurial/hgweb/hgweb_mod.py
mercurial/templater.py
CHANGE DETAILS
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1084,14 +1084,15 @@
return path if os.path.isdir(path) else None
-def open_template(name):
+def open_template(name, templatepath=None):
'''returns a file-like object for the given template, and its full path
If the name is a relative path and we're in a frozen binary, the template
will be read from the mercurial.templates package instead. The returned path
will then be the relative path.
'''
- templatepath = templatedir()
+ if templatepath is None:
+ templatepath = templatedir()
if templatepath is not None or os.path.isabs(name):
f = os.path.join(templatepath, name)
try:
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -82,8 +82,8 @@
locations = (os.path.join(style, b'map'), b'map-' + style, b'map')
for location in locations:
- mapfile = os.path.join(path, location)
- if os.path.isfile(mapfile):
+ mapfile, fp = templater.open_template(location, path)
+ if mapfile:
return style, mapfile
raise RuntimeError(b"No hgweb templates found in %r" % path)
To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200806/7ed02ac9/attachment-0002.html>
More information about the Mercurial-patches
mailing list