templatekw: add 'requires' flag to switch to exception-safe interface
The current templatekw interface, f(repo, ctx, templ, **args), is horrible
because it's quite easy to encounter TypeError, ValueError, etc. It's also
bad for Python 3 porting due to the **kwargs issue.
This patch introduces a flag to switch to new f(context, mapping) API seen
in templater functions. The requirement spec isn't verified (yet) because
context.resource() can gracefully raise a ResourceUnavailable exception,
but it's planned to be used as a filter in the help, such as "Revision
Keywords" (if 'ctx' in requires), "File Keywords" (if 'fctx' in requires),
etc.
showauthor() is ported to the new API as an example. 20 more follows.
templater: specialize ResourceUnavailable error so that it can be caught
See the next patch how it will be used.
templater: move specialized exception types to top
I'm going to add one more exception type.
templatekw: minimize resource dependency of {envvars} and {termwidth}
These keywords can be evaluated without a repo.
remotenames: drop redundant templatekw names from help text
Also removed the second "List of" phrase, which is obvious from the type
"List of strings."
narrow: drop redundant templatekw/revset names from help text
":<name>:" is automatically added by the registrar.
run-tests: don't mask errors when a server fails to start
There are sporadic instances of this on Windows. They seem to happen more
frequently after the test machine is rebooted, although the only way to hit it
on my laptop is to loop certain tests with -j9 for hours. The problem with
masking out the specific failure is that there's no way to know if it's the same
line in the test that's failing, or if it is random.
The justification for adding this masking in
52e9e63f1495 was that the failures
occur regularly, but that's not the case anymore. The port number is still
printed, in case that turns out to be useful.
py3: use bytes instead of str in isinstance
Internally we use bytes everywhere, and str on Python 3 is unicodes, so we need
to make sure we are doing the right check.
Differential Revision: https://phab.mercurial-scm.org/D2458
py3: convert a map expression into list comprehension
map returns a map object on Python 3 and here we wanted a list instead.
Differential Revision: https://phab.mercurial-scm.org/D2456