3
votes

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?

4

4 Answers

1
votes

have you tried this:

a/b/(?!c).*
1
votes

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.

0
votes
^a/b/(?!c/d/e/f).*$
0
votes

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