templatespec: create a factory function for each type there is
Most of the arguments to the `templatespec` constructor are mutually
exclusive, so each combination creates a different type of
templatespec. Let's clarify that by creating factory functions.
I've left the callers in `logcmdutil` unchanged for now because they
are more complex and `logcmdutil.templatespec()` is slightly higher
level in that it is specific to changesets.
My larger goal is to add support frozen binaries (specifically
PyOxidizer) by adding a specific type of `templatespec` for built-in
templates. That will get its own factory function.
Differential Revision: https://phab.mercurial-scm.org/D8845
templater: stop accepting a single style to stylemap()
The code seems to have been for compatibility across
d3dbdca92458
(hgweb: don't choke when an inexistent style is requested (
issue1901),
2009-11-12).
Differential Revision: https://phab.mercurial-scm.org/D8844
formatter: inline a variable assigned from `templater.templater.frommapfile`
The variable doesn't get reused and it doesn't help formatting, so I
don't see any reason for it.
Differential Revision: https://phab.mercurial-scm.org/D8807
templater: don't normalize path separators to '/' when interacting with OS
`_readmapfile()` is about reading a map file from the file system, so
we shouldn't use our `util.normpath()`, which also normalizes `os.sep`
to '/'.
Differential Revision: https://phab.mercurial-scm.org/D8806
formatter: remove now-unnecessary check for file-ness
`templater.templatepath()` now returns non-`None` only for files, so
the caller doesn't have to check.
Differential Revision: https://phab.mercurial-scm.org/D8805
templater: make templatepath() not return directory paths
The previous patch added a test showing an unusal error message. This
make it more like other error messages.
Differential Revision: https://phab.mercurial-scm.org/D8804
tests: show unusual error message for `hg log --style coal`
It turns out that we show the full path when the given style name
matches a subdirectory of `mercurial/templates/`.
Differential Revision: https://phab.mercurial-scm.org/D8803