Submitter | Yuya Nishihara |
---|---|
Date | Aug. 18, 2016, 8:48 a.m. |
Message ID | <20160818174849.b0740b3859ede8f34e1cfd6a@tcha.org> |
Download | mbox | patch |
Permalink | /patch/16347/ |
State | Not Applicable |
Headers | show |
Comments
On Thu, 2016-08-18 at 17:48 +0900, Yuya Nishihara wrote: > On Thu, 18 Aug 2016 11:52:11 +0800, Anton Shestakov wrote: > > > > 18.08.2016, 03:32, "Matt Mackall" <mpm@selenic.com>: > > > > > > # HG changeset patch > > > # User Matt Mackall <mpm@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 > > > > > > 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. > > I like the idea, but I just don't find __base__ = <file> self-explanatory > > enough. > It makes some sense because a mapfile value is <file>|'"' <string> '"'. But > I'd rather change %include to behave like __base__. That'll break anything that has learned from what coal is currently doing. -- Mathematics is the supreme nostalgia of our time.
On Thu, 18 Aug 2016 13:04:05 -0500, Matt Mackall wrote: > On Thu, 2016-08-18 at 17:48 +0900, Yuya Nishihara wrote: > > On Thu, 18 Aug 2016 11:52:11 +0800, Anton Shestakov wrote: > > > 18.08.2016, 03:32, "Matt Mackall" <mpm@selenic.com>: > > > > # HG changeset patch > > > > # User Matt Mackall <mpm@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 > > > > > > > > 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. > > > I like the idea, but I just don't find __base__ = <file> self-explanatory > > > enough. > > It makes some sense because a mapfile value is <file>|'"' <string> '"'. But > > I'd rather change %include to behave like __base__. > > That'll break anything that has learned from what coal is currently doing. What coal is doing should be valid even if we change the way of path resolution of %include source. However, that's true someone could do %include paper/map to replace all *.tmpl files by theirs.
Patch
--- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -1022,7 +1022,6 @@ def _readmapfile(mapfile): raise error.Abort(_("style '%s' not found") % mapfile, hint=_("available styles: %s") % stylelist()) - base = os.path.dirname(mapfile) conf = config.config(includepaths=templatepaths()) conf.read(mapfile) @@ -1040,6 +1039,7 @@ def _readmapfile(mapfile): val = 'default', val if ':' in val[1]: val = val[1].split(':', 1) + base = os.path.dirname(conf.source('', key).rsplit(':', 1)[0]) tmap[key] = val[0], os.path.join(base, val[1]) return cache, tmap