hg shows files modified that are unchanged, why might that be?
Asked Answered
G

2

12

My question is this: what might be causing Mercurial to indicate (via "status" or TortoiseHgWorkbench) files as "Modified" when they are unchanged?

Here's the situation: I have a repository local to a Linux machine. I only work with the repository on the Linux machine. I do, however, have an exact copy of the repository (and the working file) on a Windows machine (I synchronize via a flash drive, using BeyondCompare). To my best recollection, I never invoke mercurial on the Windows machine, though it is installed there.

I recently wanted to do a commit on the Linux machine, and many files that I didn't expect to show up were listed as "Modified". I did a visual diff (using BeyondCompare) which indicates that the working directory copy is "binary identical" to the parent in the repository. TortoiseHgWorkbench shows the file "modified", and the differences window shows the entire file, in green, (as if the repository had an empty file, I guess). On the file in question, the file date on the file system is months old, whereas my last commit (I commit all changed files) was a couple weeks ago. Some unchanged files show as "modified", but some do not. I have not ever seen this behavior previously, so I'm a little confused.

I ran "hg verify" on the repository and it didn't note anything interesting.

I guess it is not a big deal since all the files in the working directory are intact, and if I were to commit the files (even though they are unchanged), I'm not sure anything would be hurt. But I am keen to understand what has happened.

Thanks in advance for any ideas what to look for.

[EDIT]

Still haven't found a root cause (file permissions and access dates unchanged) but @barjak's response pointed me in the direction where I found this:Why does "hg status" show changed files when "hg diff -g" doesn't? (One parent). My situation is the same as described there (both hg diff and hg diff --git only show files that really have changed, while hg status shows a few unchanged files). BTW I'm using Hg 2.6.

[EDIT]

If it is helpful to anyone, here is how I got back to a normal repository:

in a shell:

cd src
hg diff --git > ../junk
grep "\-\-git" ../junk

in tortoiseHgWorkbench

uncheck all files marked "M"
check all files indicated in the grep results above (i.e., have real diffs)
commit

in a shell:

hg revert --all

then clean up the working directory (revert --all generated some defunct files. Also reset some file dates (I'm the only person using this repository and file dates are useful to me. Yes there is an Hg extension to restore file dates but I've not installed it yet).

This process got me all lined up again.

Graupel answered 3/10, 2013 at 19:54 Comment(3)
In BC3, under Session->Session Settings, on the Comparison tab is it set to "Binary Comparison" or "Rules Based". What type of files are you comparing?Arenicolous
Comparison is set to "Rules Based". The file is a C++ source file. The BC3 result of "binary same" is indeed correct. I am now going to look at the "permissions" possibility as @barjak suggests. (first inspection looks like permissions have not changed but I'll dig a bit further...)Graupel
For me this happens if I have to use Microsoft's windows. If I use it to commit, then if I ever update to this revision, then files are shown us changed. (Maybe MS windows is saving something to the repo, that is not / or can not be represented by Unix).Magnum
I
12

A file can be marked as modified when the Unix permissions are changed, too. Try hg diff -g to check for the permissions.

Isatin answered 3/10, 2013 at 21:53 Comment(2)
I still don't know the root cause of this problem (if anybody has any additional ideas, I'm still interested), but this answer pointed me in a useful direction.Graupel
Had the same problem and using -g option showed me that the permissions where changed for the file.Holotype
G
4

Just doing a revert did not help me. The files would remain in the Modified state even though I had committed them. If I tried to commit it again. So I just deleted the files that showed up as modified (make a backup if needed) which caused all the files to show up with an ! next to it when I ran

hg st

After that I ran the following command to revert the files (which were already checked in):

hg revert --all --no-backup

and that fixed the problem

Godolphin answered 16/11, 2015 at 21:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.