views:

201

answers:

4

I want to ignore all directories "_notes" throughout a repository. _notes is generated by dreamweaver and is not part of the project itself, but these directories are scattered throughout the project.

Somehow ^_notes$ is not doing the job in .hgignore ... Do I have to direct .hgignore to each and every directory "_notes" or does it do it recursively?

I am not quite sure about the man pages

+5  A: 

Try:

syntax: glob
_notes/*

I should probably mention that if the directories have already been added you cannot ignore them. Use hg forget if you are on a newer Mercurial version, be this the case.

erisco
does not seem to work ... do I have to remove the "_notes" directories for mercurial to ignore it? I have added these folders before and then added the .hgignore afterwards.
Subu
It did work for me, other than it did not ignore ./_notes like I thought it would. The change I made fixes this, and it should be specific to the directories.
erisco
+1  A: 

.hgignore

syntax: glob
_notes

This isn't specific to directories, so if you have any files with that exact name, they will be ignored too.

Example:

$ hg init subu && cd subu
$ mkdir _notes
$ mkdir a && mkdir a/_notes
$ echo 'syntax: glob' >>.hgignore
$ echo '_notes' >>.hgignore
$ touch file.txt
$ touch _notes/file.txt
$ touch a/file.txt
$ touch a/_notes/file.txt
$ hg st -A
? .hgignore
? a/file.txt
? file.txt
I _notes/file.txt
I a/_notes/file.txt
Roger Pate
+1  A: 

As your comment reveals, the reason you can't get it to work is that already being in the repository takes precedence over .hgignore. (Imagine the nasty issues that could arise if .hgignore took precedence! Mess up a regexp and you might stop tracking half your repo)

To remove stuff from the repo you can use hg remove or hg forget (which is an alias for hg remove -Af). You probably want to use hg forget as this will remove it from the repository but not delete the local copy; hg remove will (without -Af) delete the local copy as well

jk
A: 

This will do the job:

syntax: regexp
/_notes/

In case you want to check what files are being ignored by your repository, you can try: hg stat -i

This will list all files that are successfully ignored by hg through .hgignore, it is nice for debugging before you add anything to the repository.

!Previously added files to the repository will not be ignored!

mahatmanich
I don’t think this works properly; it will ignore any file and directory starting with _notes, not just those named exactly _notes.
Laurens Holst
Is that better, Laurens? It worked before, I tested it! If you are satisfied with this answer can you vote it up pls :-).
mahatmanich