Question

I use Mercurial Queues to work with patches.

There was no .hgignore initially. I'm not sure if I first created an MQ patch and then created my .hgignore or the other way round.

(By "creating a patch" I mean hg qnew patch_name -m "...")

Anyway, I made some changes to .hgignore after I created the MQ patch.

When I did hg qrefresh; hg export qtip I got the changed contents of .hgignore also in my patch. So, tried adding an .hgignore entry to .hgignore itself. But that didn't work. The changes persisted.

So, I tried hg forget .hgignore and this made a bigger mess. It nows shows that I deleted .hgignore in my patch. Like so:

--- a/.hgignore
+++ /dev/null
- all 
- the lines of .hgignore
- the lines of .hgignore

How do I resolve this problem? I just want .hgignore to be part of my local repo and help in not tracking some files.

Was it helpful?

Solution

.hgignore is designed to be tracked by Mercurial (doc). The standard way to ignore files in local clone only is to use ui.ignore setting:

# .hg/hgrc
[ui]
ignore = /path/to/repo/.hg/hgignore

If you have multiple local ignore files then you can write

[ui]
ignore.first = /path/to/repo/.hg/firstignore
ignore.second = /path/to/repo/.hg/secondignore

Additional global ignore files can be configured in this way:

[ui]
ignore.first = /path/to/repo/.hg/firstignore
ignore.second = /path/to/repo/.hg/secondignore
ignore.third = ~/thirdignore

All settings live in hgrc file. More details here:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top