Can anyone tell me why mercurial is displaying ignored files for the 'hg status' command?
Here's the confirmation that mercurial is indeed ignoring the files:
$ hg addremove
$ hg commit
nothing changed
Now, have a look at the status output. I ran this immediately after the lines above. (Prinout is partial, with identifiable text removed)
$ hg status
? Core/target/Core-0.0.1-SNAPSHOT-tests.jar
? Core/target/Core-0.0.1-SNAPSHOT.jar
? Core/target/classes/META-INF/MANIFEST.MF
? Core/target/classes/xxx/yyy/zzz/X.class
? Core/target/classes/xxx/yyy/zzz/XBackup.class
? Core/target/classes/xxx/yyy/zzz/XBackupInput.class
? Core/target/classes/xxx/yyy/zzz/XBackupOutput.class
? Core/target/classes/xxx/yyy/zzz/XImpl$GetResultsAndStatistics.class
? Core/target/classes/xxx/yyy/zzz/XImpl$MonitoringMode.class
? Core/target/classes/xxx/yyy/zzz/XImpl$UpdateMode.class
? Core/target/classes/xxx/yyy/zzz/XImpl.class
? Core/target/classes/xxx/yyy/zzz/XIsFullException.class
? Core/target/classes/xxx/yyy/zzz/XSource.class
? Core/target/classes/xxx/yyy/zzz/XUsageException.class
? Core/target/classes/xxx/yyy/zzz/CheckResults.class
? Core/target/classes/xxx/yyy/zzz/Noise.class
? Core/target/classes/xxx/yyy/zzz/core/DateTimeGenerator$TemporalMeasure.class
? Core/target/classes/xxx/yyy/zzz/core/DateTimeGenerator.class
? Core/target/classes/xxx/yyy/zzz/core/LoggingConfigurator.class
? Core/target/classes/xxx/yyy/zzz/core/ManagedIterator.class
? Core/target/classes/xxx/yyy/zzz/core/NetworkUtils.class
? Core/target/classes/xxx/yyy/zzz/core/StackTraceUtils.class
? Core/target/classes/xxx/yyy/zzz/core/Summarisable.class
? Core/target/classes/xxx/yyy/zzz/core/TimingUtils.class
? Core/target/classes/xxx/yyy/zzz/core/XMLStaticStringUtils.class
? Core/target/classes/xxx/yyy/zzz/core/Zipper.class
...
There's something like a thousand lines of these ignored files showing in the status printout; that's some serious guff.
How can I get rid of this?
Thanks
UPDATE:
Here's my .hgignore file.
syntax:glob
.metadata*
syntax:regexp
^target.*$
^[^/]*/target.*$
^[^/]*/[^/]*/target.*$
^bin.*$
^[^/]*/bin.*$
^[^/]*/[^/]*/bin.*$
UPDATE:
Modified regexps a wee bit * -> .*
Your regexp syntax is wrong. You have this:
syntax:regexp
^target*$
which means "ignore anything beginning with target and ending with an asterisk
Which fails to ignore these:
Core/target/classes/META-INF/MANIFEST.MF
Core/target/classes/xxx/yyy/zzz/X.class
for two reasons -- they begin with Core/
not target
and they don't end with an asterisk.
What you probably meant was this:
syntax:regexp
^.*/target/.*$
which matches anything that has /target/
in it (notice it's .*
in a regexp *
is for glob style). However the ^
and $
only serve to root your regex and you don't want it rooted -- you want to find it anywhere in the string, so just do this:
syntax:regexp
/target/
The clue in all this was that the files were marked with ?
which means not ignored and not added, if they were ignored you wouldn't see them at all without adding --ignored
to the status command.
I got similar issue because I changed letter case for some files. So previously I got file called "sitenav.ext", renamed it to "siteNav.ext" and started to have same sort of issues - when I tried to "hg st" I got "? siteNav.ext". Fix was easy rename to "_siteNav.ext", addremove, commit, rename back to "siteNav.ext", addremove, commit -> profit!
As commented by Jerome in the question, providing your config might help.
One (admittedly strange) reason for your problem could be a permission issue with the .hgignore
file combined with exclude defaults for the addremove
command.
I could reproduce your situation by revoking any read permission from the ignore file and by using -X "**/target/**"
as a default option for the addremove
command (which might be set in any of the possible Mercurial configuration files):
$ hg st
# no output, as expected
$ chmod 000 .hgignore
$ hg addremove # with '-X "**/target/**"' set as default somewhere
$ hg commit
nothing changed
$ hg st
? Core/target/Core-0.0.1-SNAPSHOT-tests.jar
? Core/target/Core-0.0.1-SNAPSHOT.jar
...
hg
fails in reading the ignore file and thus does not know that the target stuff should be ignored. A corresponding warning from hg
would be helpful here.
This question has been updated in response to Jerome's comment.
Many thanks for everyone's help on this. I haven't found an answer to the problem but I did find a workaround that got rid of it. So I'm assuming that at some point when modifying the hgignore regexps mercurial got confused and corrupted it's internal data... or something. I don't know enough internals to know what this could have been.
Anyway, should you find yourself in the same boat, here's what I did:
Revert all added files. I used the following because I'm on linux. (thanks to another poster on a separate question here on SO - which I can now no longer find unfortunately)
hg status -an0 | xargs -0 hg revert
repeat the above step until it no longer works. In my case this was sometimes up to as many as 3 reverts in a row! (No idea what it was actually doing though :( )
You should now no longer see the ignored files in the hg status output.
I'm sorry, I have no idea why this worked, or what the original problem was. If anyone does, I'd be very interested to know your thoughts.
Many thanks again to everyone :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With