Martin von Zweigbergk <martinvonz@google.com> [Thu, 30 Jul 2020 15:29:06 -0700] rev 45312
templater: unroll loop over mapfile directories
I'll rewrite the handling of the `templatedir()` case in the next
patch, so the two cases will be more different and the loop won't make
as much sense.
Differential Revision: https://phab.mercurial-scm.org/D8895
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 10:51:25 -0700] rev 45311
templater: make open_template() read from resources if in frozen binary
This takes the number of failing tests with PyOxidizer from 87 to 72.
Differential Revision: https://phab.mercurial-scm.org/D8894
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 13:22:00 -0700] rev 45310
templater: pass opened file-like object to templatespec
I think I said earlier that I planned to create a special templatespec
variant for built-in templates. That was true (I planned that), but I
ended up (in this patch) just adding a file-like object to the
`mapfile_templatespec()` variant instead.
Differential Revision: https://phab.mercurial-scm.org/D8893
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 13:21:29 -0700] rev 45309
templater: replace templatepath() with function that also opens the file
For frozen binaries, such as those created by PyOxidizer, I plan to
make it so the templatespec can keep an opened file/resource to read
from instead of needing a file path. Having `templatepath()` return an
opened file should help with that. At this point, it's just a wasteful
extra opening of mapfiles that we'll open again later. I'll update the
read-side next so it reads from the file-like object without opening
the file again.
Differential Revision: https://phab.mercurial-scm.org/D8892
Martin von Zweigbergk <martinvonz@google.com> [Thu, 30 Jul 2020 13:44:06 -0700] rev 45308
templater: start passing resource to read from into _readmapfile()
This patch makes it so we pass in a file-like resource to read from
instead of having `_readmapfile()` open the file. This is one more
step towards making `_readmapfile()` able to read resources opened by
from `importlib.resources`. We still need to pass in the mapfile path
because it's used for loading dependent mapfiles from `%include` and
`__base__`, and it's also used for giving the user better error
messages. Besides that, one can safely call `_readmapfile()` with any
file-like resource after this patch.
Differential Revision: https://phab.mercurial-scm.org/D8891
Martin von Zweigbergk <martinvonz@google.com> [Tue, 04 Aug 2020 09:13:10 -0700] rev 45307
templater: move stylemap() to hgweb_mod, since that's its only user
`stylemap()` even has an error message that mentions "hgweb
templates", so it seems that it's meant specifically for hgweb.
Differential Revision: https://phab.mercurial-scm.org/D8890