Mercurial 如何判断文件已被修改?
Mercurial 如何判断文件已被修改?
我问的原因是因为当我运行 hg status
时,它告诉我有几个文件被修改了。 但是,当我运行 hg diff
时,没有要报告的更改。
我有一个关于为什么会发生这种情况的理论:(但我并不肯定)
我正在使用内置了 Mercurial 支持的 NetBeans。当我编辑文件时,它会显示它已修改,尽管如果我撤消(而不是恢复)这些更改并保存它,NetBeans 告诉我没有本地更改。因此,我猜测 NetBeans 使用 diffs 来检查修改,而 Mercurial 使用其他内容,例如修改日期。
这是正确的还是其他原因?
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 theory 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Mercurial 不使用修改日期来确定状态。这可以通过一个简单的实验来验证:
执行状态检查的代码位于
dirstate.py
。如果dirstate
不确定文件的状态(例如,因为只有修改时间不同,那么它会将其传递给localrepo.status
进行进一步分析,如此处。“ http://www.selenic.com/hg/file/bf85c2639700/mercurial/localrepo.py#l1194 .com/hg/help/status" rel="nofollow">
hg help status
文本有一些可能有帮助的线索:当您运行
hg diff
时,您是否指定了任何命令行选项?Mercurial does not use modification date to determine the status. This can be verified with a simple experiment:
The code which performs the status check is in
dirstate.py
. If thedirstate
is unsure about a file's status (e.g. because only the modification time differs, then it passes it up tolocalrepo.status
for further analysis as seen here.The
hg help status
text has some clues that may help:When you run
hg diff
, are you specifying any command-line options?是否有可能文件的权限已更改?尝试
hg diff --git
它显示支持权限和二进制文件的 git 风格的扩展差异。默认情况下,hg diff
仅显示补丁友好的差异,不显示权限更改。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 defaulthg diff
shows only patch-friendly diffs, which don't show permissions changes.