为什么“汞状态"显示"hg diff -g"时更改的文件不是吗(一位家长) [英] Why does "hg status" show changed files when "hg diff -g" doesn't? (One parent)

查看:124
本文介绍了为什么“汞状态"显示"hg diff -g"时更改的文件不是吗(一位家长)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,其中:

I have a repository where:

> hg st

显示我的工作目录有一些未提交的更改,而

shows that my working directory has some uncommitted changes, while

> hg diff


> hg diff -g


> hg diff --git

不显示任何内容.

我在这里阅读: 4.10.汞状态显示更改的文件,但汞差异不显示!以下内容:

I read here: 4.10. hg status shows changed files but hg diff doesn't! the following:

hg状态报告文件内容或标志相对于任何一个父文件的更改. hg diff仅报告相对于第一个父项的更改内容.您可以使用--git选项查看标志信息,以使用-r相对于另一父级查看hg diff和delta.

hg status reports when file contents or flags have changed relative to either parent. hg diff only reports changed contents relative to the first parent. You can see flag information with the --git option to hg diff and deltas relative to the other parent with -r.

但是,如果我运行hg parents,它将仅显示一个父级(提示).正如我上面提到的,我也尝试过hg diff --git,它仍然不显示任何内容.

However, if I run hg parents it shows only one parent (the tip). As I mention above, I have also tried hg diff --git and it still displays nothing.

注意:

  • 以上内容为 Mercurial版本2.0.1
  • hg status仅在常规文件旁边显示M.
  • hg diffhg diff -g什么都不打印
  • 文件系统是NFS.
  • hg parents仅打印一位家长
  • The above is on Mercurial version 2.0.1
  • hg status only shows M next to a regular file.
  • hg diff and hg diff -g print nothing
  • The filesystem is NFS.
  • hg parents prints only one parent

推荐答案

日常使用的Mercurial(Mercurial:权威指南)(此处复制是因为似乎无法在页面末尾提供方便的链接):

Some excerpts from Mercurial in daily use (Mercurial: the definitive guide) (copying here because there seems to be no way to give a convinient link to the end of the page):

hg diff命令的默认输出与常规的diff命令向后兼容,但这有一些缺点.

The default output of the hg diff command is backwards compatible with the regular diff command, but this has some drawbacks.

以上hg diff的输出掩盖了我们仅重命名文件的事实. hg diff命令接受--git-g选项,以使用更新的diff格式,以更易读的形式显示此类信息.

The output of hg diff above obscures the fact that we simply renamed a file. The hg diff command accepts an option, --git or -g, to use a newer diff format that displays such information in a more readable form.

此选项还有助于解决可能引起混淆的情况:似乎已根据hg status进行了修改的文件,但对于hg diff,该文件不打印任何内容.如果我们更改文件的执行权限,则会出现这种情况.

This option also helps with a case that can otherwise be confusing: a file that appears to be modified according to hg status, but for which hg diff prints nothing. This situation can arise if we change the file's execute permissions.

普通的diff命令不注意文件权限,这就是为什么hg diff默认情况下不打印任何内容的原因.如果我们提供-g选项,它将告诉我们真正发生了什么.

The normal diff command pays no attention to file permissions, which is why hg diff prints nothing by default. If we supply it with the -g option, it tells us what really happened.

总而言之,hg diff命令会丢失有关更改的多种信息:属性,权限,文件名等.即使您只有一个父级,这些更改也可能存在.并且hg status正确地考虑了所有更改.要查看发生了什么,请使用hg diff -g.这是会发生什么"问题的答案.

To summarize, hg diff command misses several kinds of information on changes: attributes, permissions, file names, etc. These changes may exist even if you have a single parent. And hg status correctly takes into account all changes. To see what has happened, use hg diff -g. It's the answer to the question 'what happens'.

似乎向后兼容是为什么".我不确定,但是我认为正常差异"是一些广泛使用或内置的Unix/Linux工具(从hg和git都来自该世界这一事实来看).

Seems like backwards compatibility is the 'why'. I'm not sure, but I suppose that the 'normal diff' is some widespread or built-in Unix/Linux tool (judging from the fact that both hg and git come from that world).

这篇关于为什么“汞状态"显示"hg diff -g"时更改的文件不是吗(一位家长)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆