Question

I'm looking for a way to modify my .hgignore file to ignore all "Properties/AssemblyInfo.cs" files except those in either the "Test/" or the "Tests/" subfolders.

I tried using the negative look-behind expression (?<!Test)/Properties/AssemblyInfo\.cs$, but I didn't find a way to "un-ignore" in both folders "Test/" and "Tests/".

Was it helpful?

Solution

Python doesn't support variable-length lookbehind.

But \b(?<!Test)(?<!Tests)/Properties/AssemblyInfo\.cs$ should work.

OTHER TIPS

Just to get this out there for any future searchers: Regex contortions like this are only necessary if you expect a lot more exception files to be added to the working directory in the future.

If you just want to make the current ones exceptions, you can just hg add them. Unlike svn and cvs, in mercurial you can add an ignored file and it overrides the .hgignore -- future changes will be automatically tracked.

It's not unheard of to have .* in your .hgignore file and then hg add the files you want tracked.

In this case, The more traditional mercurial way to do this would be a .hgignore file like this:

/Properties/AssemblyInfo\.cs

followed by:

$ hg add Test/Properties/AssemblyInfo.cs
$ hg add Tests/Properties/AssemblyInfo.cs

If you have hundreds of Test and Tests you can add them with a find, but if you create new ones every day then the regex is definitely the way to go.

Normally you'd just do Tests?, but since depending on the regexp engine, dynamic look-behinds aren't allowed, you can simply use two branches:

(?<!Test|Tests)/Properties/AssemblyInfo\.cs$

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top