在 mercurial 中有没有办法告诉 hg log 和 diff 跳过二进制差异?

In mercurial is there a way to tell hg log and diff to skip binary diffs?

如果我使用 hg log -phg diff 来梳理差异,那么看到 "binary file differs" 之类的东西会很好,而不是必须滚动浏览满屏的乱码才能获得到下一个文件。有配置技巧吗?

(在预览时,如果没有简单的 hg 选项可以设置,那么 this question 中可能会有一些正确方向的提示。我仍然需要更多帮助才能得到我想要的东西'不过我在问。)

这是我得到的,检查mercurial版本,以防万一

我想也许您有一个扩展程序可以用 blob 制作花哨的东西,因为我无法理解您所描述的内容。我刚得到 Binary file doc.pdf has changed

$ hg version
Mercurial Distributed SCM (version 3.9.2)
...
$ mkdir hg-test
$ cd hg-test
$ hg init
$ echo a text line > text.txt
$ hg add text.txt
$ hg commit -m "1st"
$ echo another text line >> text.txt
$ hg commit -m "2nd"
$ hg add doc.pdf
$ hg commit -m "a binary file"
$ hg commit -m "modified the binary file"
$ hg diff --change 3
diff -r 2fd7730bc3bb -r 155aefdccfbe doc.pdf
Binary file doc.pdf has changed
$ hg diff --change 1
diff -r 9e171966ad0d -r 105aa77984c0 text.txt
--- a/text.txt  Sat Dec 17 12:18:46 2016 +0100
+++ b/text.txt  Sat Dec 17 12:19:28 2016 +0100
@@ -1,1 +1,2 @@
 a text line
+another text line
$ hg log -pr0:3
changeset:   0:9e171966ad0d
user:        arhak
date:        Sat Dec 17 12:18:46 2016 +0100
summary:     1st

diff -r 000000000000 -r 9e171966ad0d text.txt
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/text.txt  Sat Dec 17 12:18:46 2016 +0100
@@ -0,0 +1,1 @@
+a text line

changeset:   1:105aa77984c0
user:        arhak
date:        Sat Dec 17 12:19:28 2016 +0100
summary:     2nd

diff -r 9e171966ad0d -r 105aa77984c0 text.txt
--- a/text.txt  Sat Dec 17 12:18:46 2016 +0100
+++ b/text.txt  Sat Dec 17 12:19:28 2016 +0100
@@ -1,1 +1,2 @@
 a text line
+another text line

changeset:   2:2fd7730bc3bb
user:        arhak
date:        Sat Dec 17 12:27:38 2016 +0100
summary:     a binary file

diff -r 105aa77984c0 -r 2fd7730bc3bb doc.pdf
Binary file doc.pdf has changed

changeset:   3:155aefdccfbe
tag:         tip
user:        arhak
date:        Sat Dec 17 12:28:50 2016 +0100
summary:     modified the binary file

diff -r 2fd7730bc3bb -r 155aefdccfbe doc.pdf
Binary file doc.pdf has changed

在@arhak 的帮助下,我在我的 .hgrc

中看到了问题所在
[diff]
git = True

我忘了我在阅读 this advice 后补充说 git-style 差异比 Mercurial 默认的 patch-style 差异更具可读性。我找不到差异的描述,但现在看一些差异,--git (-g) 似乎在文件名 headers 中遗漏了日期,显然,它也强制二进制文件的完整 uuencode-style 差异。我想我会将其保留为默认值,但如果我正在查看包含大量二进制文件更改的补丁程序等异常情况,请将其关闭。

在不编辑 .hgrc 的情况下向 override at the commandline 添加 --config diff.git=False

我很好奇是否有一种方法可以跳过二进制文件,但在 diff 中保留 git 常规文本文件的格式。