Mercurial 如何判断文件已被修改?

发布于 2024-11-07 22:33:13 字数 380 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北风几吹夏 2024-11-14 22:33:13

Mercurial 不使用修改日期来确定状态。这可以通过一个简单的实验来验证:

hg init
echo "This is a test" > test.txt
hg commit -Am "commit"
touch test.txt
hg status

执行状态检查的代码位于 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 文本有一些可能有帮助的线索:

状态可能看起来不同意
diff 权限是否已更改或
合并发生了。标准差异
格式不报告权限
Changes 和 diff 仅报告更改
相对于一个合并父级。

当您运行 hg diff 时,您是否指定了任何命令行选项?

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?

抹茶夏天i‖ 2024-11-14 22:33:13

是否有可能文件的权限已更改?尝试 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 default hg diff shows only patch-friendly diffs, which don't show permissions changes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文