[PATCH] templates: let extensions add own template maps

Yuya Nishihara yuya at tcha.org
Fri Sep 9 09:22:30 EDT 2016


On Fri, 09 Sep 2016 08:41:45 +0200, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1473403080 -7200
> #      Fri Sep 09 08:38:00 2016 +0200
> # Node ID 972114f70fb6f57265299aa16d590f79d8ed1a1a
> # Parent  b42c26b0a78550d1b238674b5ffad6123ec9b76c
> templates: let extensions add own template maps
> 
> Before this patch template maps were checked only in templates
> directory in mercurial sources. This commit add possibility for
> extension to add own template paths by exttemplatepaths list.
> 
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -24,6 +24,8 @@ from . import (
>      util,
>  )
>  
> +exttemplatepaths = []
> +
>  # template parsing
>  
>  elements = {
> @@ -1149,6 +1151,7 @@ def templatepaths():
>      pathsrel = ['templates']
>      paths = [os.path.normpath(os.path.join(util.datapath, f))
>               for f in pathsrel]
> +    paths.extend(exttemplatepaths)

Seems okay, but we'll want to extend the other data paths such as help/, and
might eventually need more general way to resolve data paths.

Another (a little) concern is that the file layout is likely to be changed
on packaging for Windows or Linux, so package maintainers will have to patch
extension codes. I have no idea how to avoid that, though.


More information about the Mercurial-devel mailing list