Mercurial hg status displays ignored files

Can someone tell me why mercurial displays ignored files for the "hg status" command?

Here's the confirmation that mercurial is really ignoring files:

$ hg addremove $ hg commit nothing changed 

Now let's look at the status output. I ran this right after the lines above. (Prinout is partial, with 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 is something like a thousand lines of these ignored files displayed in the status listing; that some serious guf.

How can I get rid of this?

thanks

UPDATE:

Here is my .hgignore file.

 syntax:glob .metadata* syntax:regexp ^target.*$ ^[^/]*/target.*$ ^[^/]*/[^/]*/target.*$ ^bin.*$ ^[^/]*/bin.*$ ^[^/]*/[^/]*/bin.*$ 

UPDATE:

Modified regular expressions: bit * →. *

+7
source share
7 answers

Thanks so much for helping with this. I did not find the answer to the problem, but I found a workaround that got rid of it. Therefore, I assume that at some point when the hgignore regexps mercurial change got confused and messed up its internal data ... or something else. I do not know enough internal knowledge to know what it could be.

In any case, if you find yourself in the same boat, here is what I did:

  • Make sure your .hgignore file says what you want and that all files displayed in hg status are the ones you want to ignore.
  • Add all files that you want to ignore. hg addremove does not work because it reads the contents of hgignore, so I used the Eclipse hg plugin and made each file manually (well, I selected them all and Eclipse applied adding them all separately).
  • Discard all added files. I used the following because I'm on Linux. (thanks to another poster on a separate issue here on SO - which I can no longer find unfortunately now)

    hg status -an0 | xargs -0 hg revert

  • repeat the above step until it no longer works. In my case, it was sometimes up to 3 reverts in a row! (I don’t know what he actually did, though :()

  • commit

Now you should not see ignored files in hg status output.

Sorry, I have no idea why this worked or what the original problem was. If anyone does, I would be very interested to know your thoughts.

Thanks again everyone :)

+1
source

Your regexp syntax is incorrect. You have the following:

 syntax:regexp ^target*$ 

which means "ignore everything from the goal to the asterisk

Which cannot ignore them:

 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 do not end with an asterisk.

What do you probably mean:

 syntax:regexp ^.*/target/.*$ 

which matches any that has /target/ in it (note that .* in regexp * for the glob style). However, ^ and $ only serve to enlist your regular expression, and you do not want it to be embedded - you want to find it anywhere on the line, so just do the following:

 syntax:regexp /target/ 

The key to all this was that the files were marked ? , which means it is not ignored or added , if they were ignored, you will not see them at all without adding --ignored to the status command.

+4
source

I had a similar problem because I changed the case with a letter for some files. So before I got a file called "sitenav.ext", renamed it to "siteNav.ext" and started having the same problems - when I tried "hg st" I got "? SiteNav.ext". The fix was easy to rename to "_siteNav.ext", addremove, commit, rename back to "siteNav.ext", addremove, commit → profit!

+2
source

As Jerome commented on the issue, your config might help.

One (admittedly strange) reason for your problem might be the permission issue with the .hgignore file in combination with the defaults exception for addremove .

I could reproduce your situation by revoking any permission to read from the ignore file and using -X "**/target/**" as the default parameter for the addremove (which can 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 cannot read the ignore file and therefore does not know that the target material should be ignored. An appropriate warning from hg will be helpful here.

This question has been updated in response to Jerome's comment.

+1
source

? does not mean ignoring.

It just means that mercurial is not tracking the file.

If you do not want to see them, just follow

hg status -mard

i.e. only show modified, added, deleted, deleted

0
source

The .hgignore file indicates that "^ target" is ignored, but the files are in Core / target. Thus, the ignore string should rather be “target” (without ^) or “^ Kernel / target”.

Or am I skipped here?

(Note: ^ implies that regular expression matching starts at the beginning of the path, i.e. only paths starting at the target will be matched!)

0
source

If the same problem and Bob’s answer did the trick for me.

If you use TortoiseHg, you can select "edit ignore filter" in the context menu (s) to check and change the .hgignore settings.

0
source

All Articles