Re: [PATCH] hgweb: add inheritance support to style maps

2016-08-19 Thread Yuya Nishihara
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" :
> > > > # HG changeset patch
> > > > # User Matt Mackall 
> > > > # 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__ =  self-explanatory
> > > enough.
> > It makes some sense because a mapfile value is |'"'  '"'. 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.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] hgweb: add inheritance support to style maps

2016-08-18 Thread Matt Mackall
On Wed, 2016-08-17 at 15:56 -0400, Augie Fackler wrote:
> On Wed, Aug 17, 2016 at 02:31:45PM -0500, Matt Mackall wrote:
> > 
> > # HG changeset patch
> > # User Matt Mackall 
> > # 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?

Derp, I only sent the first patch.

-- 
Mathematics is the supreme nostalgia of our time.

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] hgweb: add inheritance support to style maps

2016-08-18 Thread Matt Mackall
On Thu, 2016-08-18 at 11:52 +0800, Anton Shestakov wrote:
> 18.08.2016, 03:32, "Matt Mackall" :
> > 
> > # HG changeset patch
> > # User Matt Mackall 
> > # 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__ =  self-explanatory
> enough.
> 
> Why not something like %extend ? It would look on the same level of
> "special" as %include, which may help understanding what it does at a glance.

%include is/must be implemented in the config file parser. This is implemented
in the templater, where it can apply the specific semantics of the template
value rules (like files vs quoted strings).

-- 
Mathematics is the supreme nostalgia of our time.

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] hgweb: add inheritance support to style maps

2016-08-18 Thread Matt Mackall
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" :
> > > 
> > > # HG changeset patch
> > > # User Matt Mackall 
> > > # 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__ =  self-explanatory
> > enough.
> It makes some sense because a mapfile value is |'"'  '"'. 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.

___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] hgweb: add inheritance support to style maps

2016-08-18 Thread Yuya Nishihara
On Thu, 18 Aug 2016 11:52:11 +0800, Anton Shestakov wrote:
> 18.08.2016, 03:32, "Matt Mackall" :
> > # HG changeset patch
> > # User Matt Mackall 
> > # 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__ =  self-explanatory 
> enough.

It makes some sense because a mapfile value is |'"'  '"'. But
I'd rather change %include to behave like __base__.

--- 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
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] hgweb: add inheritance support to style maps

2016-08-17 Thread Matt Mackall
# HG changeset patch
# User Matt Mackall 
# 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.

diff -r 73ff159923c1 -r f2bb8352d994 mercurial/templater.py
--- a/mercurial/templater.pyMon Aug 01 13:14:13 2016 -0400
+++ b/mercurial/templater.pyWed 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@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel