4

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 <user@email.com>
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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
crlane
  • 521
  • 5
  • 16
  • what happens if you `hg forget` the file to ignore? – Paul Nathan Jul 13 '10 at 19:50
  • 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 Jul 13 '10 at 20:11
  • 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 Jul 13 '10 at 20:13
  • 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 Jul 13 '10 at 20:31
  • @Polycode are you manually adding the .hgignore file?! – Paul Nathan Jul 14 '10 at 16:51
  • Manually adding? You mean did I create the .hgignore file in my home directory? Yes. Is that wrong? I thought you had to create a .hgignore file because mercurial does not ignore anything by default. – crlane Jul 14 '10 at 22:20
  • @Ry4an - I figured it out...I think there is an error in the regex at the bottom of the post I linked to above. I believe there is an extra underscore at the end of the last pattern you posted. I was using that one and it was not matching. The one from higher up in your post without the trailing underscore matches fine. Thanks. – crlane Jul 16 '10 at 13:46

1 Answers1

7

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.

Geoffrey Zheng
  • 6,562
  • 2
  • 38
  • 47
  • 1
    On my system it didn't seem to pick up ~/.hgignore unless it was referenced in a .hgrc file. But the `ignore.*` trick works beautifully. – Mu Mind Mar 09 '11 at 18:32
  • Excellent. I'm using this in individual repositories .hg/hgrc files. Adding "ignore.shared = .hgignore-shared" will cause Mercurial to look at both .hgignore and .hgignore-shared. – SystemParadox Nov 14 '11 at 11:53