Thu, 06 Aug 2020 10:53:00 -0700 templater: teach template loader to use open_template() function
Martin von Zweigbergk <martinvonz@google.com> [Thu, 06 Aug 2020 10:53:00 -0700] rev 45322
templater: teach template loader to use open_template() function The template loader can apparently load templates from relative paths, so I needed to add that support to `open_template()`. This takes the number of failing tests with PyOxidizer from 54 to 34. Differential Revision: https://phab.mercurial-scm.org/D8907
Thu, 06 Aug 2020 10:52:52 -0700 templater: restructure open_template() a little to prepare for relative paths
Martin von Zweigbergk <martinvonz@google.com> [Thu, 06 Aug 2020 10:52:52 -0700] rev 45321
templater: restructure open_template() a little to prepare for relative paths I found that it was easier to add support for relative paths after this restructuring. It also made it easier to explain each case with a code comment (which I did). Differential Revision: https://phab.mercurial-scm.org/D8906
Thu, 06 Aug 2020 09:50:10 -0700 templater: add exception-raising version of open_template()
Martin von Zweigbergk <martinvonz@google.com> [Thu, 06 Aug 2020 09:50:10 -0700] rev 45320
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
Wed, 05 Aug 2020 22:13:51 -0700 templater: replace Py3-only exception types by super-types available in Py2
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 22:13:51 -0700] rev 45319
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
Wed, 05 Aug 2020 14:19:42 -0700 hgweb: enable reading styles from resources in frozen binaries
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 14:19:42 -0700] rev 45318
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
Wed, 05 Aug 2020 14:03:45 -0700 hgweb: rely on open_template()'s fallback to using templatedir()
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 14:03:45 -0700] rev 45317
hgweb: rely on open_template()'s fallback to using templatedir() Differential Revision: https://phab.mercurial-scm.org/D8900
Wed, 05 Aug 2020 14:03:14 -0700 hgweb: open mapfile using templater.open_template()
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 14:03:14 -0700] rev 45316
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
Wed, 05 Aug 2020 13:58:30 -0700 hgweb: simplify a constant-length list by converting to literal tuple
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 13:58:30 -0700] rev 45315
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
Wed, 05 Aug 2020 13:33:07 -0700 hgweb: remove some accesses to private member uimod._unset
Martin von Zweigbergk <martinvonz@google.com> [Wed, 05 Aug 2020 13:33:07 -0700] rev 45314
hgweb: remove some accesses to private member uimod._unset Differential Revision: https://phab.mercurial-scm.org/D8897
Thu, 30 Jul 2020 21:36:29 -0700 templater: try to read %include in mapfiles from resources
Martin von Zweigbergk <martinvonz@google.com> [Thu, 30 Jul 2020 21:36:29 -0700] rev 45313
templater: try to read %include in mapfiles from resources The "show" style is an example of a style that uses an "%include" statement in its definition. This patch makes `hg log --style show` work. This takes the number of failing tests with PyOxidizer from 72 to 62. Differential Revision: https://phab.mercurial-scm.org/D8896
Thu, 30 Jul 2020 15:29:06 -0700 templater: unroll loop over mapfile directories
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
Tue, 04 Aug 2020 10:51:25 -0700 templater: make open_template() read from resources if in frozen binary
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
Tue, 04 Aug 2020 13:22:00 -0700 templater: pass opened file-like object to templatespec
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
Tue, 04 Aug 2020 13:21:29 -0700 templater: replace templatepath() with function that also opens the file
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
Thu, 30 Jul 2020 13:44:06 -0700 templater: start passing resource to read from into _readmapfile()
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
Tue, 04 Aug 2020 09:13:10 -0700 templater: move stylemap() to hgweb_mod, since that's its only user
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
(0) -30000 -10000 -3000 -1000 -300 -100 -16 +16 +100 +300 +1000 +3000 tip