.hgignore regexp oddity

John W jwdevel at gmail.com
Thu Jan 28 14:15:37 CST 2010


Hello,
I've been banging my head trying to get syntax:regexp working in .hgignore.
I have a pattern that works if run directly in python, but is not
working when in .hgignore, so I'm not sure what transformations go on
inside mercurial on those regexps before they get compiled...

Here's a repro case:

  #
  # here's the dir structure with no .hgignore in effect at all
  #
$ hg st
? .hgignore_try
? aaa/bbb/ccc/foo
? aaa/bbb/ccc/foo.txt
? foo
? foo.txt

  #
  # I'm trying to do "any path without a dot in it"
  #
$ cat .hgignore_try
^[^.]*$
$ mv .hgignore_try .hgignore
$ hg st
? .hgignore
? foo.txt

  #
  # For some reason, aaa/bbb/ccc/foo.txt is ignored, even though it
should not match that regexp (AFAIK)
  #
  # Notice that the same regexp tried directly in python does NOT
match, as expected.
  #

$ python
Python 2.5.4 (r254:67916, Aug 15 2009, 00:17:39)
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> re.compile(r'^[^.]*$').match('aaa/bbb/ccc/foo.txt').group(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'group'
>>>


Any ideas on this?

-John


More information about the Mercurial mailing list