Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ignoring folders in mercurial

Caveat: I try all the posibilities listed here: How can I ignore everything under a folder in Mercurial.
None works as I hope.

I want to ignore every thing under the folder test. But not ignore srcProject\test\TestManager

I try

syntax: glob test/** 

And it ignores test and srcProject\test\TestManager

With:

syntax: regexp ^/test/ 

It's the same thing.

Also with:

syntax: regexp test\\* 

I have install TortoiseHG 0.4rc2 with Mercurial-626cb86a6523+tortoisehg, Python-2.5.1, PyGTK-2.10.6, GTK-2.10.11 in Windows

like image 324
user2427 Avatar asked Nov 21 '08 20:11

user2427


People also ask

How do I ignore a mercurial file?

The working directory of a Mercurial repository will often contain files that should not be tracked by Mercurial. These include backup files created by editors and build products created by compilers. These files can be ignored by listing them in a . hgignore file in the root of the working directory.

What is hgignore File?

hgignore file sits in the working directory, next to the . hg folder. It is a file versioned as any other versioned file in the working directory, which is used to hold the content of the ignore patterns that are used for any command operating on the working directory.


2 Answers

Try it without the slash after the caret in the regexp version.

^test/ 

Here's a test:

~$ mkdir hg-folder-ignore ~$ cd hg-folder-ignore ~/hg-folder-ignore$ echo '^test/' > .hgignore ~/hg-folder-ignore$ hg init ~/hg-folder-ignore$ mkdir test ~/hg-folder-ignore$ touch test/ignoreme ~/hg-folder-ignore$ mkdir -p srcProject/test/TestManager ~/hg-folder-ignore$ touch srcProject/test/TestManager/dont-ignore ~/hg-folder-ignore$ hg stat ? .hgignore ? srcProject/test/TestManager/dont-ignore 

Notice that ignoreme isn't showing up and dont-ignore is.

like image 160
Ry4an Brase Avatar answered Sep 18 '22 15:09

Ry4an Brase


Both cases worked for me (on linux and windows):

syntax: regexp ^backup/     #root folder nbproject/   #any folder 

or

syntax: glob ./backup/*   #root folder nbproject/*  #any folder 

However, it wasn't before I added a link to .hgignore file to .hgrc file in my repo:

[ui] ignore = .hg/.hgignore 

Also worth mentioning that mercurial ignores files that it is not currently tracking, which are those added before you configured it to ignore them. So, don't be put off by hg status saying some filed are M (modified) or ! (missing) in the folders that you have just added to the ignore list!

like image 31
Dziamid Avatar answered Sep 18 '22 15:09

Dziamid