I have a Python regular expression that matches a set of filenames. How to change it so that I can use it in Mercurial's .hgignore file to ignore files that do not match the expression?
Full story:
I have a big source tree with *.ml
files scattered everywhere. I want to put them into a new repository. There are other, less important files which are too heavy to be included in the repository. I'm trying to find the corresponding expression for .hgignore
file.
1st observation: Python doesn't have regular language complement operator (AFAIK it can complement only a set of characters). (BTW, why?)
2nd observation: The following regex in Python:
re.compile("^.*(?<!\.ml)$")
works as expected:
abcabc - match
abc.ml - no match
x/abcabc - match
x/abc.ml - no match
However, when I put exactly the same expression in the .hgignore
file, I get this:
$ hg st --all
? abc.ml
I .hgignore
I abcabc
I x/xabc
I x/xabc.ml
According to .hgignore
manpage, Mercurial uses just normal Python regular expressions. How is that I get different results then?
How is it possible that Mercurial found a match for the x/xabc.ml
?
Does anybody know less ugly way around the lack of regular language complement operator?