在mercurial中有一种方法可以告诉hg log和diff跳过二进制差异吗?

时间:2016-12-15 17:54:21

标签: mercurial diff binaryfiles

如果我使用hg log -phg diff梳理差异,那么很高兴看到类似"二进制文件不同的东西,而不是必须滚动浏览屏幕上的胡言乱语来到下一个文件。有没有配置技巧呢?

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

2 个答案:

答案 0 :(得分:3)

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

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

我忘了我在阅读this advice后添加了git-style diffs比Mercurial默认的补丁风格差异更具可读性。我找不到差异的描述,但现在看一些差异,--git-g)似乎在文件头中省略了日期,显然,它也强制完整的uuencode二进制文件的样式差异。我想我会将它保留为默认值,但是如果我在寻找具有大量二进制文件更改的补丁的异常情况下将其关闭。

override at the commandline而不修改.hgrc,请添加--config diff.git=False

我很好奇是否有办法跳过二进制文件,但保留差异中常规文本文件的git格式。

答案 1 :(得分:1)

这是我得到的,检查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