Reputation: 2895
Been fighting with Mercurial's .hgignore for a while under Windows.
I have a folder named Upload which is currently empty. I do want it tracked so I added a .empty file in it which work fine. I want this so that new developers doing an hg clone get the Upload document required for the application.
Thing is I never want the folder to be populated with anything on the source control itself (test uploads from a development machine).
Example: If I add Public/image.jpg it wouldn't be tracked.
Additionally I would like it for sub directory to be tracked. So if developer adds
Upload/users/.empty I would like this to be tracked.
Is this possible with regex voodoo?
Upvotes: 0
Views: 541
Reputation: 336468
Try
^Uploads\b.*/(?!\.empty)[^/]+$
This should match any path starting with Uploads
where the text after the last slash (=filename) is anything but .empty
.
Upvotes: 0
Reputation: 78350
In mercurial (and unlike in svn and cvs) adding a file overrides the .hgignore
file, so you can put this in your .hgignore
:
^Uploads/.*
and your Upload/.empty
that you added will still be created on update and thus they'll get the directory.
Getting it to ignore files in upload but not not ignore files in subdirectories in Upload could be done with:
^Uploads/[^/]*$
which says: ignore anything that Starts with Uploads and has no further slashes in it.
Really though, you should be creating Uploads with your build/install/configure script when possible, not with the clone/update.
Upvotes: 4
Reputation: 8915
Try putting
Uploads/(?!.empty)
in .hgignore
in the root of the repository
Upvotes: 1