Search code examples
mercurial

hg status returns blank but file has changed


I have a file that I've copied over the top of a file in my hg repo with xcopy. I've done this literally 1000's of times with different files and no issue. When I copy this specific file and try to commit, I get the 'nothing changed' message.

The file has definitely changed. If I open it in Notepad, make no changes and then resave it, mercurial recognizes the changes. If I open it in Notepad++, edit it, undo the edit and then save it, mercurial recognizes the changes.

If I restart the process (copying files into a new hg repo and committing), it fails at the same point every time. There is something about these files, but what? I thought it might be date modified as they were the exact same millisecond, but after editing my copied file to add 1 minute to the date modified, it still doesn't work.

What can cause this? What should I look for?

hg status

hg status -A
C file.txt

hg commit file.txt
nothing changed

On Windows, using Mercurial 2.2.2 with NO extensions enabled (inotify extension is known to cause a similar issue)


Solution

  • It appears that Mercurial (2.2.2 at least), only checks a file when it gets edited/replaced. It does this by checking the date modified. As my files had the exact same timestamp, it didn't check the contents.

    When I edited the timestamp so it was different, that only changes the metadata and not the file itself. So Mercurial wasn't notified of the change, so it never looked and saw that the timestamp was different.

    Solution: Changing the timestamp of the new file BEFORE copying the file (or copy it somewhere else, edit it, then copy to the repo) allows Mercurial to see the that the timestamp has changed and it will then check the contents for what's changed.