How does Mercurial tell a file was modified?
The reason I am asking is because when I run hg status
its telling me several files are modified.
However, when I run hg diff
there are no changes to report.
I have a th开发者_JAVA百科eory as why this is happening: (but I am not positive)
I am using NetBeans which has Mercurial support built in. When I edit a file, it shows it as modified, although if I undo (rather than revert) those changes and save it, NetBeans tells me there are no local changes. So I am guessing NetBeans uses diffs to check for modifications while Mercurial is using something else like modification-date.
Is this correct or is something else the cause?
Mercurial does not use modification date to determine the status. This can be verified with a simple experiment:
hg init
echo "This is a test" > test.txt
hg commit -Am "commit"
touch test.txt
hg status
The code which performs the status check is in dirstate.py
. If the dirstate
is unsure about a file's status (e.g. because only the modification time differs, then it passes it up to localrepo.status
for further analysis as seen here.
The hg help status
text has some clues that may help:
status may appear to disagree with diff if permissions have changed or a merge has occurred. The standard diff format does not report permission changes and diff only reports changes relative to one merge parent.
When you run hg diff
, are you specifying any command-line options?
Is it possible the permissions of the file changed? Try hg diff --git
which shows the git-style extended diffs that support permissions and binaries. By default hg diff
shows only patch-friendly diffs, which don't show permissions changes.
精彩评论