How to check which files are being ignored because of .hgignore?
Asked Answered
L

4

19

I'm quite often concerned that my hgignore file may be excluding important files. For example I just noticed that I was excluding all .exe files which excluded some little executable tools which should be kept with the source. It was a simple change to include them but makes me worried that the rules could have un-intended consequences.

Is there a way to view a list of all the files which are not being tracked due to the .hgignore file? Just so I can periodically review the list to check I'm happy with it.

Lu answered 3/9, 2012 at 9:14 Comment(0)
F
30

The command hg status -i does exactly that.

Flavour answered 3/9, 2012 at 9:16 Comment(3)
beat me because I was too busy typing in the other characters to meet minimum character requirement :) "body must be 30 characters you entered 28"Doriadorian
@BurhanKhalid: I 've had that issue too... lesson: "if in doubt, be verbose" ;)Flavour
I always give answers using the --long-options anyway. Better for teaching. :)Cobby
D
16

@Jon beat me to the punch with the right answer, but its worth nothing that along with status -i, there is:

  • hg status -m (only modified files)
  • hg status -a (only files that were added)
  • hg status -r (only files that were removed)
  • hg status -d (only files that were deleted)
  • hg status -u (all non-tracked files)
  • hg status -c (files with no changes, ie. "clean")
  • hg status -A (all files, ie, everything)
Doriadorian answered 3/9, 2012 at 9:28 Comment(0)
F
10

If you want to do manual inspection on the file names, then use the -i/--ignored flag to status:

$ hg status -i
I ignored file.exe

If you want the file names alone, then use -n/--no-status to suppress the I status code printed in front of each filename:

$ hg status -n -i
ignored file.exe

If you need to process the files with xargs, then use the -0/--print0 flag in addition:

$ hg status -n -0 | xargs -0 touch

That will take care of handling spaces correctly — with using -0, there is a risk that you'll end up treating ignored file.exe as two files: ignored and file.exe since shells normally split on spaces.

The above commands show you untracked files matching .hgignore. If you want to solve the related problem of finding tracked files matching .hgignore, then you need to use a fileset query. That looks like this:

$ hg locate "set:hgignore()"

You can use filesets with all commands that operate on files, so you can for example do:

$ hg forget "set:hgignore()"

to schedule the files found for removal (with a copy left behind in your working copy).

Furnish answered 5/9, 2012 at 20:58 Comment(0)
W
4

Yes, it is Possible. If You're using smth like TortoiseHg, You can select what files You wanna see.

Here's a sample

enter image description here

Washbowl answered 3/9, 2012 at 9:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.