4
votes

I am trying to get mercurial to ignore hidden files for a specific user. I used the directions here:

How to make mercurial ignore all hidden files?

and got it to ignore files in a specific repo. I want to extend this behavior to all hg repos for a specific user.

The hgrc man page says you can link a user specific ignore file (e.g., ~/.hgignore) by including something like this in your ~/.hgrc:

[ui]
username = Some User <[email protected]>
ignore = ~/.hgignore

but that doesn't seem to be working.

I have also tried

ignore = /home/someuser/.hgignore
ignore = $HOME/.hgignore
ignore = ~/.hgignore2

But that doesn't seem to be working either. Am I missing something? I can't find anything on the Mercurial site or anywhere else. Please help, thanks.

**EDIT - I am on Linux. hg showconfig indicates that hg is reading my .hgrc file correctly, the ignore behavior outlined therein is not working though.

**EDIT2 - I also tried restarting my machine, just to see if that would update things. It did not.

1
what happens if you hg forget the file to ignore?Paul Nathan
The selenic site covers this in the manpage for 'hgrc' which should also be on your system. I don't see anything obviously wrong with what you're doing though provided file permissions/ownership are correct and you're on Unix. Does 'hg showconfig' show your entries?Ry4an Brase
Paul has a great point. Unlike in svn, with mercurial you can 'hg add' a file that overrides ignore -- ignore only acts on unadded files -- so if the file is already added no ignore will affect it at all. That always freaks people out at first until they see how easy it makes exceptions.Ry4an Brase
the manpage is where I got the idea to do this...there aren't really detailed instructions for this behavior, they just refer you to the hgignore manpage, which is about glob v. regexp syntax hg showconfig does show my entries, and they are listed correctly. Removing the files with hg forget only helps temporarily, because the next time I hg add they will come back.crlane
@Polycode are you manually adding the .hgignore file?!Paul Nathan

1 Answers

7
votes

You don't need to specify ~/.hgignore. It is automatically applied after system hgignore and before repo hgignore.

I use many ignore files in ~/.hgrc without problem with hg 1.5 on linux.

[ui]
ignore = /home/geoffz/bin/hgext/hgignore
ignore.local = /home/geoffz/bin/hgext/hgignore.local
ignore.java = /home/geoffz/bin/hgext/hgignore.java

Create a trivial repo with a few files you want to ignore, setup your ignore entries, and do hg st -A. If those files are shown as ? and not I, then you have a serious problem in your hg/linux setup.