keyword: versioning my homedir and ~/.hgrc

Giorgos Keramidas keramida at
Sun Jul 5 19:41:06 CDT 2009

On Mon, 6 Jul 2009 00:26:49 +0200, Christian Ebert <blacktrash at> wrote:
> * Giorgos Keramidas on Monday, July 06, 2009 at 00:17:41 +0300
>> I've just enabled the keyword extension to my HOME directory's .hg
>> repository and noticed something odd:
>>{} in the latest crew repository is set to:
>> # make keyword tools accessible
>> kwtools = {'templater': None, 'hgcmd': '', 'inc': [], 'exc': ['.hg*']}
>                                                                  ^^^
>                                                yes, this is intended
>> My home directory is a Mercurial repository with an .hgignore file that
>> ignores everything by default, until I "hg add" something:

> .hg* is excluded on purpose:

I can understand why '.hg/**' shouldn't be allowed to expand, but I am
not sure I fully agree with <workspace>/.hgrc and <workspace>/.hgignore.

> As the keyword extension allows the expansion of _arbitrary_ keywords
> (albeit within $...$) the risk of inadvertent expansion in files that
> contain configuration regexes is even higher than "normal".

A mercurial repository can contain all sorts of files that can have
problems with automagic expansion.  A perl script that lives inside a
Mercurial repository and includes:

    #!/usr/bin/perl -Tw

    my $id = "$Custom: 1.2 keramida $";
    print "$id\n";

will fail to execute at all:

    $ perl -Tw
    Final $ should be \$ or $name at line 3, within string
    syntax error at line 3, near "= "$Custom: 1.2 keramida $""
    Execution of aborted due to compilation errors.

As a user of the keyword extension I feel responsible for not adding
keywords to places where they may cause such problems.  I agree that
allowing keywords in <workspace>/.hgignore is risky, but it is not more
dangerous than allowing keywords in Perl scripts, in shell scripts, in
XML documents, in Lisp code, or a *lot* of other files whose syntax
may be broken by a misplaced keyword.

Would it be very bad to at least make the '.hg*' exclusion pattern
optional/tunable and default to yes?

More information about the Mercurial-devel mailing list