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.
Showing
- mercurial/formatter.py 1 addition, 3 deletionsmercurial/formatter.py
- mercurial/registrar.py 16 additions, 0 deletionsmercurial/registrar.py
- mercurial/templatekw.py 4 additions, 11 deletionsmercurial/templatekw.py
- mercurial/templater.py 9 additions, 3 deletionsmercurial/templater.py
- tests/test-command-template.t 2 additions, 0 deletionstests/test-command-template.t
- tests/test-template-engine.t 12 additions, 1 deletiontests/test-template-engine.t
Loading
Please register or sign in to comment