views:

65

answers:

2

For instance I have a folder

PROJECT/db/

Where a lot of files are created, I want to prevent hg from keeping track of those files but keeping the db folder ?

A: 

As far as I know Mercurial's ignore files are not rooted, hence just list one or more patterns to exclude the content of the DB folder.

Lawrence Oluyede
+4  A: 

Empty folders are not inherently supported in mercurial so if you ignore all files in a folder the folder will not be tracked.

From the hg book: http://hgbook.red-bean.com/read/mercurial-in-daily-use.html

Empty directories are rarely useful, and there are unintrusive workarounds that you can use to achieve an appropriate effect. The developers of Mercurial thus felt that the complexity that would be required to manage empty directories was not worth the limited benefit this feature would bring.

If you need an empty directory in your repository, there are a few ways to achieve this. One is to create a directory, then hg add a “hidden” file to that directory. On Unix-like systems, any file name that begins with a period (“.”) is treated as hidden by most commands and GUI tools. This approach is illustrated below.

$ hg init hidden-example
$ cd hidden-example
$ mkdir empty
$ touch empty/.hidden
$ hg add empty/.hidden
$ hg commit -m 'Manage an empty-looking directory'
$ ls empty
$ cd ..
$ hg clone hidden-example tmp
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ ls tmp
empty
$ ls tmp/empty

Another way to tackle a need for an empty directory is to simply create one in your automated build scripts before they will need it.

Edit: I'm assuming you know how to do an hgignore in your repo to ignore the whole directory:
Create a file called .hgignore in your repo root. Put in the follwing text:

syntax: glob
db/
jwsample
rather than a hidden file i'd use a readme file that explains why the otherwise empty directory exists in the repo
jk