[PATCH] Check for .hgrc files in ancestor directories above the repository

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Mon Jan 14 04:18:54 CST 2008


On Jan 14, 2008 8:25 AM, Peter Arrenbrecht <peter.arrenbrecht at gmail.com> wrote:
> What do you guys think of this slightly modified version of the
> proposal I made earlier:
>
> In the parent dirs, scan not for .hgrc files, but for .hgrc-* files.
> When one is found, say .hgrc-netbeans, don't read it, but look for
> ~/.hgrc-netbeans. Read that. This way, parent repos can at most add an
> undesired reference to one of the ~/.hgrc-* files you already have. No
> one can plant arbitrary code in new hooks.
>
> This would easily go together with also detecting ~/.hgrc-`rev0` to
> achieve what Jesse wants (given we can get at `rev0` early enough).
>
> Now I know Maxim doesn't like the fact that this is triggered
> automatically, without explicitly being turned on. I think that
>
> * It only trigger if (a) a .hgrc-* file exists in one of the parent
> dirs, and (b) a corresponding ~/.hgrc-* file exists. Not likely to
> happen by accident, is it.
>
> * It could be made to require explicit activation in ~/.hgrc, like
> [config] scanparents = true.
>
> * It does however lose the advantage of my previous proposal (where
> the contents, not the name, of the .hgrc-activate files identified the
> ~/.hgrc-xy to use) that one could reuse custom configs for repo ids.
> But I think the slight gain in simplicity of setup outweighs this.
> It's just `touch .hgrc-netbeans` in a parent dir of your netbeans
> repos to activate ~/.hgrc-netbeans.
>
> And I realize Jesse wants the config in ~/.hgrc as such, not in
> parallel files. So the scheme might also be changed to using
> [section at suffix] style instead of ~/.hgrc-suffix style. But while not
> very important to me, I would prefer the latter. As Maxim said, you
> can trivially reuse the current config parser with separate files.

Continuing this, one could even (in a parent dir for clones), do something like

touch .hgrc-keywords-enabled
touch .hgrc-email-enabled
touch .hgrc-email-from-private-acct
touch .hgrc-pre-commit-tests-via-nt

etc. So one could configure different aspects independently and mix
and match per project tree. If we not only scan for these in parent
dirs, but also in .hg, then one can do this for individual repos as
well.

Finally, I chose .hgrc-* over hgrc-* for symmetry (slightly easier to
remember, I think). But we could, of course, also decide that hgrc-*
is better because visible to ls.

-peo


More information about the Mercurial-devel mailing list