Mercurial doesn't ignore files in directory I specify

445 views Asked by At

I have mercurial repository. There is .hgignore file:

λ ~/workspace/kompgrafika/nurbs/ cat .hgignore 
syntax: regexp
^Makefile
^bin/.*$
CMakeFiles/.*$
^CMakeCache\.txt
^cmake_install\.cmake

There is directory named CMakeFiles that I want to ignore:

λ ~/workspace/kompgrafika/nurbs/ tree CMakeFiles 
CMakeFiles
├── 3dfractals.dir
│   ├── build.make
│   ├── cmake_clean.cmake
│   ├── CXX.includecache
│   ├── DependInfo.cmake
│   ├── depend.internal
│   ├── depend.make
│   ├── flags.make
│   ├── link.txt
│       ├── progress.make
│   └── src
│       ├── DisplayControl.cpp.o
│       ├── Drawer.cpp.o
│       ├── main.cpp.o
│       ├── PointFileReader.cpp.o
│       ├── PointGenerator.cpp.o
│       └── Program.cpp.o
├── CMakeCCompiler.cmake
├── cmake.check_cache
├── CMakeCXXCompiler.cmake
├── CMakeDetermineCompilerABI_C.bin
├── CMakeDetermineCompilerABI_CXX.bin
├── CMakeDirectoryInformation.cmake
├── CMakeOutput.log
├── CMakeSystem.cmake
├── CMakeTmp
│   └── CMakeFiles
│       └── cmTryCompileExec.dir
├── CompilerIdC
│   ├── a.out
│   └── CMakeCCompilerId.c
├── CompilerIdCXX
│   ├── a.out
│   └── CMakeCXXCompilerId.cpp
├── Makefile2
├── Makefile.cmake
├── progress.marks
└── TargetDirectories.txt

7 directories, 31 files

But running hg status it does not ignore 3dfractals.dir for some reason.

λ ~/workspace/kompgrafika/nurbs/ hg st
A .hgignore
A docs/pol_10.wings
? CMakeFiles/3dfractals.dir/src/DisplayControl.cpp.o
? CMakeFiles/3dfractals.dir/src/Drawer.cpp.o
? CMakeFiles/3dfractals.dir/src/PointFileReader.cpp.o
? CMakeFiles/3dfractals.dir/src/PointGenerator.cpp.o
? CMakeFiles/3dfractals.dir/src/Program.cpp.o
? CMakeFiles/3dfractals.dir/src/main.cpp.o

I am using:

λ ~/workspace/kompgrafika/nurbs/ hg --version
Mercurial Distributed SCM (version 2.0.2+5-1f9f9b4c2923)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2011 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I also tried changing CMakeFiles/.*$ to ^CMakeFiles$. No results.

Any ideas what's wrong?

2

There are 2 answers

4
Martin Geisler On BEST ANSWER

Hmm, it works here:

$ cat .hgignore
syntax:regexp
^Makefile
^bin/.*$
CMakeFiles/.*$
^CMakeCache\.txt
^cmake_install\.cmake
$ hg init
$ mkdir -p $(dirname CMakeFiles/3dfractals.dir/src/DisplayControl.cpp.o)
$ touch CMakeFiles/3dfractals.dir/src/DisplayControl.cpp.o
$ touch CMakeFiles/cmake.check_cache
$ hg status
? .hgignore
$ hg status -A
? .hgignore
I CMakeFiles/3dfractals.dir/src/DisplayControl.cpp.o
I CMakeFiles/cmake.check_cache

This is with Mercurial 2.0.2+59, so it should work the same as your version.

One thing that can trip up hg status in the way you see is the inotify extension. As mentioned on its wiki page, it's still to be considered experimental because it's still buggy. Check for inotify with

$ hg showconfig extensions.inotify

and disable it if necessary. If the extension is loaded from your own configuration file (check with hg showconfig --debug) then you can just remove the line that loads it. If it's loaded in a system-wide config file that you cannot change, then add

[extensions]
inotify = !

to your own config file to disable it.

0
Terence Lewis On

I'm on Windows, but usually

CMakeFiles/*

would do the trick for me...