keyword: versioning my homedir and ~/.hgrc

Christian Ebert blacktrash at gmx.net
Sun Jul 5 17:26:49 CDT 2009


Hi Giorgios,

* 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:
> 
> keyword.py:kwtools{} 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:
> 
>    # $GKer$
> 
>    syntax: glob
> 
>    # Ignore everything by default; this makes it easier to version-control
>    # only the stuff I'm really interested in keeping under mercurial.
>    **
> 
> The `.hg/hgrc' file at `/home/keramida/.hg/hgrc' enables the keyword
> extension and includes the following patterns:
> 
>    # $GKer: hgadmin/conf/hgrc 2763b12c44a3 2009/07/05 12:02:51 keramida $
> 
>    [extensions]
>    keyword =
> 
>    [keywordmaps]
>    Date = {date|utcdate}
>    GKer = {file} {node|short} {date|utcdate} {author|user}
> 
>    [keyword]
>    ** =
>    .bbdb = ignore
>    .gnupg/pubring.gpg = ignore
>    .gnupg/random_seed = ignore
>    .gnupg/secring.gpg = ignore
>    .gnupg/trustdb.gpg = ignore
> 
> With this setup in place, I can't get keywords to expand in my `~/.hgrc'
> file.  By editing keyword.py to remove '.hg*' from the 'exc' key, or by
> setting the 'exc' list to include only '.hgtags' this is fixed:
> 
>     # make keyword tools accessible
>    -kwtools = {'templater': None, 'hgcmd': '', 'inc': [], 'exc': ['.hg*']}
>    +kwtools = {'templater': None, 'hgcmd': '', 'inc': [], 'exc': ['.hgtags']}
> 
> and I can expand my local $Gker$ keyword in .hgrc and .hgignore:
> 
>    keramida at kobe:/home/keramida$ ident .hgrc .hgignore
>    .hgrc:
>         $GKer: .hgrc ccb3925ebc56 2009/07/05 12:27:30 keramida $
> 
>    .hgignore:
>         $GKer: .hgignore ccb3925ebc56 2009/07/05 12:27:30 keramida $
> 
> Does this look like a safe change?  Is there some other, better way to
> make sure .hgrc and .hgignore are not auto-excluded and always skipped
> from keyword expansion?

.hg* is excluded on purpose:

a) for safety reasons:

changeset:   6051:1038b1458d7a
user:        Christian Ebert <blacktrash at gmx.net>
date:        Wed Feb 06 23:14:33 2008 +0100
files:       hgext/keyword.py tests/test-keyword tests/test-keyword.out
description:
keyword: safeguards against erroneous behaviour or aborts

prevent issues due to global [keyword] filename patterns:
- add email to nokwcommands
- protect everything under .hg from expansion
  (tested with qcommit)
- exclude everything starting with .hg* just in case

prevent abort when pulling from bundlerepo:
- do not set up kwrepo for bundlerepo
  expansion inside a bundle is nonsense

bundlerepo issue spotted and test case provided by pmezard.


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".


b) because it doesn't make sense to include .hg* files:

These are Mercurial files and make only sense in the context of
Mercurial. So you don't need a changeset id, you just do:

$ hg log -l1 .hgignore

.hgrc, .hgignore etc. are useless outside a Mercurial repo.


So there ;-)

c
-- 
\black\trash movie    _C O W B O Y_  _C A N O E_  _C O M A_
Ein deutscher Western/A German Western
-->> http://www.blacktrash.org/underdogma/ccc.html
-->> http://www.blacktrash.org/underdogma/ccc-en.html


More information about the Mercurial-devel mailing list