.hgignore regexp oddity

Mads Kiilerich mads at kiilerich.com
Thu Jan 28 16:01:34 CST 2010


>
>    #
>    # 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)
>    

See The Fine Manual, hgrc(5):

        An untracked file is ignored if its path relative to the reposi-
        tory root directory, or any prefix path of that path, is matched
        against any pattern in .hgignore.

        For  example,  say  we  have  an  untracked  file,  file.c,   at
        a/b/file.c  inside  our repository. Mercurial will ignore file.c
        if any pattern in .hgignore matches a/b/file.c, a/b or a.

Your ignore pattern matches aaa, and thus everything below it is ignored.

/Mads


More information about the Mercurial mailing list