hgignore syntax

Evan Powers evan.powers+hg at gmail.com
Thu Jul 12 12:17:22 CDT 2007


On 7/12/07, Michael P. Soulier <msoulier at digitaltorque.ca> wrote:
> According to others, you are incorrect, the syntax is fine, the issue is that
> hgignore doesn't ignore files under source control.

Serves me right for my quick reply. There's still some nuances in the
docs that I suspect you've missed, however; as written, your .hgignore
will ignore way more than I suspect you want it to. I'll demonstrate:

$ mkdir testrepo; cd testrepo; hg init
$ mkdir c
$ touch a.txt a_txt ba.txt c/a.txt
$ hg status
? a.txt
? a_txt
? ba.txt
? c/a.txt
$ echo a.txt > .hgignore
$ hg status
? .hgignore

Changing to glob syntax (regexp is the default) helps, sorta:

$ echo -e "syntax: glob\na.txt" > .hgignore
$ hg status
? .hgignore
? a_txt
? ba.txt

But to ignore ONLY a.txt, you have to use:

$ echo -e "^a\.txt" > .hgignore
$ hg status
? .hgignore
? a_txt
? ba.txt
? c\a.txt

So, I suspect you really want your .hgignore file to contain:

syntax: regexp
^opag/urls\.py
^opag/settings\.py

Hope that was helpful,
- Evan


More information about the Mercurial mailing list