For instance I have a folder
PR开发者_运维知识库OJECT/db/
Where a lot of files are created, I want to prevent hg from keeping track of those files but keeping the db folder ?
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/
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.
精彩评论