Why does my regexp not get the files I want in Mercurial's .hgignore?
I've been chasing around regular expressions for my .hgignore
file, and found several very useful answers on SO (like this) and come up with a regexp I think should work to exclude all files and directories except the ones listed in the negative lookahead.
^(?!(certs/|config/|\.hgignore)).+
It seems to work on RegExr, and follows the pattern from the other SO answer, but the only file shown if I do hg status
is the .hgignore开发者_开发技巧
itself; nothing in certs
or config
is seen by Mercurial. (There are certainly files in there that appear if I remove the .hgignore
.)
What have I got wrong here?
Whitelists aren't easy because they're seldom necessary. Once you add a file it's tracked and the .hgignore file affects it not at all. That doesn't apply to directories (directories aren't tracking in Mercurial or git), but it does handle files like .hgignore. So just adding it once completely allows you to omit it from your whitelist even if you do try one.
If you really want most thing ignored, just go with this .hgignore file:
.*
And then add the cert and config files as new ones are created (just going out on a limb but one doesn't tend to add new certs and configs files version often). Once they're added they'll be tracked and their changes will show up in hg status
as modified when they have been.
Just a guess. Are you using a @"literal string" or a "regular string" You may need to make that \ into a \\
精彩评论