Using %include

Georges Racinet georges.racinet at octobus.net
Thu Feb 24 09:09:52 UTC 2022


Hi,

On 2/23/22 20:33, Ernie Rael wrote:
> Greetings,
>
> I'm not sure if I'm running into a bug,
>
> I'm experimenting with color themes (thanks again Marcin and Craig). I 
> thought using an "include theme" mechanism would be a good way to go.
>
> Sure enough, found mercurial's "%include", so I did
>
>    [color]
>    %include ~/themes/play
>
> I was surprised when it didn't work. "hg config --source" doesn't show 
> things in the order they are encountered. Putting [color] into theme 
> file, fixed the issue. Is this expected? When it doesn't work "hg 
> config --source" shows
>
>    themes/play:3: .status.modified=yellow

As far as I know, the `%include%` directive is meant to include a whole 
config, not just the content of a section. So what you did here amount 
to 1. enter the `color` section 2. exit the `color` section 3. include a 
file whose items are not in the `color` section.

The result is similar to this one:

    ~ $ cat /tmp/hgrc
    foo=bar
    ~ $ HGRCPATH=/tmp/hgrc hg config --source | g foo=
    /tmp/hgrc:1: .foo=bar

(I was actually mildly surprised that this isn't a syntax error)

>
> and when it works (with [color] in the included file)
>
>    themes/play:4: color.status.modified=yellow
>
> I don't see any mention of this behavior in "he help config" where it 
> discusses %include.

Yes, probably it would be better to state that

- `%include` is meant for whole configurations

- if a section appears several times after resolution of all inclusions, 
its content is merged (so that it wouldn't bring anything to allow for 
inclusion inside a section like your first attempt tried to do). This is 
already stated earlier in the help, but it's worth recalling it there.

Best,


-- 
Georges Racinet
https://octobus.net,https://heptapod.net
GPG: BF5456F4DC625443849B6E58EE20CA44EF691D39, sur serveurs publics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20220224/336e12ab/attachment-0002.html>


More information about the Mercurial mailing list