[PATCH] templater: add template path to __base__ search

Yuya Nishihara yuya at tcha.org
Fri Aug 26 10:14:42 EDT 2016


On Fri, 26 Aug 2016 11:51:40 +0200, Pierre-Yves David wrote:
> On 08/26/2016 11:43 AM, Matt Mackall wrote:
> > On Fri, 2016-08-26 at 11:23 +0200, Pierre-Yves David wrote:
> >>
> >> On 08/25/2016 02:48 AM, Matt Mackall wrote:
> >>>
> >>> # HG changeset patch
> >>> # User Matt Mackall <mpm at selenic.com>
> >>> # Date 1472085825 25200
> >>> #      Wed Aug 24 17:43:45 2016 -0700
> >>> # Node ID 1ec871261bb777e24f21cb180fce199cb49c55ea
> >>> # Parent  5f86818c95e5ea59c48dfceca2e286cd11f9a800
> >>> templater: add template path to __base__ search
> >>>
> >>> This does a fall-back check for style files or directories that are
> >>> in Mercurial's template path for user convenience.
> >> So this seems to mean we are looking for __base__ the same way we search
> >> for style. This seems very sensible.
> >>
> >>>
> >>> We intentionally don't use this for the built-in coal style because we don't
> >>> want the style to mysteriously break if the working directory just
> >>> happens to have a file named "paper".
> >> I'm a bit more confused here. First, I would imagine our search priority
> >> would help two style next to each other be able to to work together.
> >> Second, does this means the working directory is in the template search
> >> path? If so how is it not an issue already?
> >
> >> The new feature is definitly neat and shiny, but if -we- cannot even use
> >> it for our most common template this looks like an hatching disaster.
> >
> > Scenario I'm slightly worried about:
> >
> > - someone has a working hgweb setup with coal, has never heard of "paper"
> > - a file named "paper" gets added to hgweb working directory (improbable)
> > - coal theme mysteriously stops working due to action at a distance
> >
> > Scenario I'm not worried about:
> >
> > - user creates a new style that derives from paper
> > - user now has knowledge of how templater works and the significance of "paper"
> > - a file named "paper" gets added to hgweb working directory
> > - system breaks, but it's much less mysterious
> >
> > The first scenario is unlikely, but we might as well avoid it.
> 
> I got that, but my question is more: how do get in a situation where the 
> first scenario is a loosing case in he first place?
> 
> 1) Why do we have the hgweb working directory in the search path?
> 2) Why do the search priority makes it possible for coal to get confused?

Good catch. I misread the working directory as a user-specified search path.
If web.templates is specified, and if the user template directory has "paper",
"coal" could be broken. But which seems the scenario mpm's not worried about.

Also, web.templates isn't honored when looking for base templates nor %include
files, which is another bug.


More information about the Mercurial-devel mailing list