formatter: map -Tjson(...) and -Tcbor(...) to templater
Even though custom JSON output could be generated by using
--config template.json="{dict(...)|json}" ..., doing that is tedious because
of the trailing comma handling.
This patch introduces special syntax for JSON/CBOR formats. -Tjson(...) is
translated to template as if function-style template definition were
supported:
[templates]
json(...) = "{dict(...)|json}"
json(...):docheader = "[\n "
json(...):docfooter = "\n]\n"
json(...):separator = ",\n "
formatter: parse name of built-in formatter templates in standard way
This slightly makes it easier to add "-Tjson(...)" handling, which should
be enabled only if the template specifier doesn't look like a literal
template. In other words, it should be handled after "if '{' in tmpl".
This makes "log -Tpickle" and "log -Tdebug" abort, which I think is better
than just printing "picklepicklepickle...".
formatter: pass in template spec to templateformatter as argument
Prepare for the next patch, which will unify handling of the formatter
names and the template names.
templater: add public parseexpr() function to parse "-Tjson(...)"
Extracted _addparseerrorhint() to show nicer hint on error.
import: read X-Mercurial-Node email header to determine nodeid
This would be useful to import and obsolete patches sent using 'hg email
--plain', using evolve's --obsolete option of 'hg import'.
If email body contains Mercurial patch header ('# HG changeset patch'
block), nodeid parsed from X-Mercurial-Node header will still be
overridden by respective value found in body.
patchbomb: use procutil.shellquote() instead of shlex to escape email address
This basically backs out
2cc453284d5c, and inserts procutil.shellquote()
instead. I don't care about Windows compatibility here, but shlex.quote()
can't handle byte strings on Python 3.
formatting: introduce a `test-check-format-black.t` that enforce formatting
This should prevent use to drift away from the expect format.
formatting: run black on all file again
Apparently, since the blackgnarok, we divergence from the expected formatting.
Formatted using::
grey.py -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/** - contrib/grey.py')
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions