A year ago, I wrote about adding a user (global) hgignore file, which is very helpful for the general development environment, working well for favorite editor or developer’s personal taste of chosen tools. For example, Vim’s swap file or other tools’ temporary or configuration files.

But it’s still not enough. I have a project using API, so I would have to do some live test. In order to do that, I create a directory within the repository, which isn’t suitable to be added to user (~/.hgignore) or repository (/path/to/repo/.hgignore) hgignore files. Because the directory name is just a random pick and the content of the directory is also random stuff, it’s not some rigorous test like unit test.

After digging into hgrc(5), I learned you can add as many as you like in user (~/.hgrc) and repository (.hg/hgrc) configuration files under the [ui] section like:


[ui]
ignore.local = .hgignore.local
ignore.outside = ~/somewhere/.hgignore

The “local” and “outside” are freely chosen, you can name whatever you like. When it’s relative path — set in repository’s configuration file, it’s based off the root of repository as you can see in “local” hgignore.

In this .hgignore.local, it could be like:


syntax: glob
.hgignore.local
more patterns here

It ignores itself, so it wouldn’t be accidentally committed into the repository as it shouldn’t be.