Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 525
adt_Jeff Avatar asked Oct 03 '13 19:10

adt_Jeff


People also ask

What HG status means?

hg status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.

How to remove file from hg?

To undo added files, see hg forget. -A/--after can be used to remove only files that have already been deleted, -f/--force can be used to force deletion, and -Af can be used to remove files from the next revision without deleting them from the working directory.


2 Answers

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

like image 65
barjak Avatar answered Sep 27 '22 17:09

barjak


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

like image 35
RPM Avatar answered Sep 27 '22 19:09

RPM