views:

118

answers:

4

I want to ignore everything BUT a subfolder in Mercurial.

The folder I want to keep:

a/b/c/d/e/f

Everything else under:

a/b

Should be ignored.

I'm using regexp mode in the .hgignore file. This is what I've so far:

a/b/(?!c)
a/b/c/(?!d)
a/b/c/d/(?!e)
a/b/c/d/e/(?!f)

Even if this works fine, I would like to shrink it to a single line:

a/b/(?!c/d/e/f)

Except this doesn't work. I tried to escape the slashes in several ways, but it didn't help.

Any hint?

+1  A: 

have you tried this:

a/b/(?!c).*
Kimvais
This won't ignore a/b/c/doom, for example... :(
Roberto Aloi
A: 
^a/b/(?!c/d/e/f).*$
Tomalak
This didn't work either :(
Roberto Aloi
A: 

Why not just create the hg repo in a/b/c/d/e/f?

Joe Schneider
Because a is the main repo, b is an external dependency and a/b/c/d/e/f is a component of b.
Roberto Aloi
+1  A: 

You probably know this already, but you can just add the stuff in a/b/c/d/e/f without adding an exception to the .hgignore. It's not perfect, you have to remember to add any new files, but I thought I'd mention it since it's non-obvious to we CVS/SVN refugees.

Ry4an
Eheh. Yes, I knew about this but I'd prefer to avoid this habit. It's really error-prone and I usually forget things...
Roberto Aloi
Fair enough. You can automate it with something like `hg status -i -n | grep '^/a/b/c/d/e/f' | xargs hg add` which you could even put into a pre-commit hook.Really though, if you have any control over this project's layout you should probably just move whatever is important and 5 levels deep up to a more top-level directory. :)
Ry4an