[PATCH] hgweb: add inheritance support to style maps

Augie Fackler raf at durin42.com
Wed Aug 17 15:56:52 EDT 2016


On Wed, Aug 17, 2016 at 02:31:45PM -0500, Matt Mackall wrote:
> # HG changeset patch
> # User Matt Mackall <mpm at selenic.com>
> # Date 1471459227 18000
> #      Wed Aug 17 13:40:27 2016 -0500
> # Node ID f2bb8352d994be9bb9ca55d49dacba35c996d8cf
> # Parent  73ff159923c1f05899c27238409ca398342d9ae0
> hgweb: add inheritance support to style maps

I like it.

Can I get a simple test that changes something simple in paper and
shows that it works?

>
> We can now specify a base map file:
>
> __base__ = path/to/map/file
>
> That map file will be read and used to populate unset elements of the
> current map. Unlike using %include, elements in the inherited class
> will be read relative to that path.
>
> This makes it much easier to make custom local tweaks to a style.
>
> diff -r 73ff159923c1 -r f2bb8352d994 mercurial/templater.py
> --- a/mercurial/templater.py	Mon Aug 01 13:14:13 2016 -0400
> +++ b/mercurial/templater.py	Wed Aug 17 13:40:27 2016 -0500
> @@ -1026,6 +1026,16 @@
>                  raise error.ParseError(_('unmatched quotes'),
>                                         conf.source('', key))
>              cache[key] = unquotestring(val)
> +        elif key == "__base__":
> +            # treat as a pointer to a base class for this style
> +            path = util.normpath(os.path.join(base, val))
> +            bcache, btmap = _readmapfile(path)
> +            for k in bcache:
> +                if k not in cache:
> +                    cache[k] = bcache[k]
> +            for k in btmap:
> +                if k not in tmap:
> +                    tmap[k] = btmap[k]
>          else:
>              val = 'default', val
>              if ':' in val[1]:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list