1

When I do hg status I see:

[jiewmeng@JM Code]$ hg status
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/SPA.lib
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/UnitTesting.exe
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/UnitTesting.ilk
M examples/SampleTestingSolution/EmptyGeneralTesting/Debug/UnitTesting.pdb
M examples/SampleTestingSolution/EmptyGeneralTesting/EmptyGeneralTesting.suo
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/AST.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/CL.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/CL.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/DesignExtractor.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Lib-link.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Lib-link.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Node.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/PKB.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Parser.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Query Evaluator.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/Query Processor.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.Build.CppClean.log
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.lastbuildstate
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.log
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/VarTable.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/cl.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/lib.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/vc100.idb
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/vc100.pdb
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/SPA.vcxproj
M examples/SampleTestingSolution/EmptyGeneralTesting/SPA/SPA.vcxproj.filters
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/CL.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/CL.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/NodeTest.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTest.obj
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTesting.lastbuildstate
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTesting.log
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/cl.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/link.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/link.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/link.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/mt.command.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/mt.read.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/mt.write.1.tlog
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/vc100.idb
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/vc100.pdb
M examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/source/UnitTest.cpp
M examples/SampleTestingSolution/EmptyGeneralTesting/source/Parser.cpp
M examples/SampleTestingSolution/EmptyGeneralTesting/source/Parser.h
A .hgignore
? examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Debug/SPA.write.1.tlog
? examples/SampleTestingSolution/EmptyGeneralTesting/SPA/Parser.h
? examples/SampleTestingSolution/EmptyGeneralTesting/UnitTesting/Debug/UnitTesting.write.1.tlog

So I made .hgignore look like

syntax: glob

*.lib
*.tlog
*.log
*.obj
*.tlog
*.idb
*.pdb
*.exe
*.ilk
*.filters

When I do hg status again, I see a similar/non noticeable difference in output. Why? I expected all those to be gone from hg status

Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
  • When I run into things like this I use procmon (www.systeminternals.com) to check which files are used and how the the program searches for them. It is usually faster than searching documentation, settings etc. – adrianm Oct 30 '12 at 06:55

1 Answers1

5

If you have already added those files, you need to "hg forget" them before seing the hgignore directives applied.
See "What is the difference between hg forget and hg remove?": hg remove -Af (ie hg forget) will remove them without deleting them from the working directory.
See also this thread:

Un-tracked files show up with a question mark in 'hg status', unless they are matched by the .hgignore file.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Ok I dont really get what forgot or remove does actually, remove will remove the file right? I understand `forget` is a shorthand for `remove -Af`? I did `remove -Af` and `hg status` now gives similar output except lines are prepended with `R`. Files doesnt appear deleted but will they be removed from the repo or something? – Jiew Meng Oct 30 '12 at 06:45
  • Tried commiting and then hg status again ... returned to similar output with ? in front of those lines. They should be matched by my .hgignore? – Jiew Meng Oct 30 '12 at 06:48
  • @JiewMeng `hg forget` is a shortcut for `hg remove -Af`, which un-track the file while keeping it on the disk. `hg status` should display it with a '`?`' unless your `.hgignore` matches that untracked file (in which case, `hg status` won't display it at all) – VonC Oct 30 '12 at 06:52
  • @JiewMeng see an example at http://boredzo.org/blog/archives/2008-03-20/hgignore-for-mac-os-x-applications. Put your `.hgignore` at the root directory of your repo. (http://mercurial.selenic.com/wiki/.hgignore and http://stackoverflow.com/a/4965250/6309) – VonC Oct 30 '12 at 06:55
  • @JiewMeng did you hg add the `.hgignore` file? (http://stackoverflow.com/questions/3472866/funny-that-when-hgignore-is-added-for-mercurial-this-file-itself-shows-up-as). You don't need to add it for hgignore to work, but if it does work, you should add it and commit it (http://stackoverflow.com/a/965344/6309) – VonC Oct 30 '12 at 06:59