templater: add exception-raising version of open_template()
I'm about to add another caller of `open_template()` (in the template
loader). That caller will want to get exceptions instead of `(None,
None)` if the template doesn't exist. This patch therefore changes
`open_template()` to raise exceptions and adds a new
`try_open_template()` that returns the `(None, None)` value.
Differential Revision: https://phab.mercurial-scm.org/D8905
templater: replace Py3-only exception types by super-types available in Py2
As noted by @indygreg, `test-check-pyflakes.t` started failing on Py2
after my recent D8894, because that introduced catching of the
Py3-only types `ModuleNotFoundError` and `FileNotFoundError`. Let's
switch to less precise types that are also available in Py2.
Differential Revision: https://phab.mercurial-scm.org/D8902
hgweb: enable reading styles from resources in frozen binaries
All we need to do to read styles from resources is to pass the
file-like object we get from `open_template()` on to `frommapfile()`.
This takes the number of failing tests with PyOxidizer from 62 to 54.
Differential Revision: https://phab.mercurial-scm.org/D8901
hgweb: rely on open_template()'s fallback to using templatedir()
Differential Revision: https://phab.mercurial-scm.org/D8900
hgweb: open mapfile using templater.open_template()
This will help us read templates from resources in frozen binaries.
Differential Revision: https://phab.mercurial-scm.org/D8899
hgweb: simplify a constant-length list by converting to literal tuple
The call to `.append()` has been unnecessary since
d3dbdca92458
(hgweb: don't choke when an inexistent style is requested (
issue1901),
2009-11-12).
Differential Revision: https://phab.mercurial-scm.org/D8898