Heh, @vonC is right, I couldn't let this go by. There isn't a way to turn hgignore into a whitelist instead of a blacklist. I gather it's that way by design (I certainly didn't design it).
You have a few options:
Add everything (.*
) to your .hgignore
and then hg add
file you want to be tracked -- adding always overrides ignoring
Just break down and make a proper black list: hg status --no-status --unknown >> .hgignore
is a great starting point.
The bottom line is accidentally tracking something you didn't want tracked is less dangerous a situation than accidentally forgetting to track something you wished was tracked. The former creates a little noise in the your repo, while the latter results in potential data loss.
If you really wanted to get fancy you could add '.*
' to your .hgignore
and then create a hook like this:
[hooks]
precommit.add = hg add $(hg status --unknown --no-status -I '**.c' -I '**.h')
which would automatically add any new .c and .h files when you commit.