Mercurial - 为已提交和未提交的更改生成补丁

时间:2016-08-05 13:49:50

标签: mercurial

有时在开发中,对于我来说,看到已提交的更改和未提交的更改的差异是很有用的。

例如,好像它们都是未提交的并且我使用了hg diff, 或两者都未提交,我使用了hg diff -c REV

有办法吗?我尝试过diff,export和log的变种。

1 个答案:

答案 0 :(得分:1)

对于这种状态下的玩具回购

>hg st
M a.txt
>hg log --style compact
1[tip]   4d554db9595b   2016-08-05 23:56 +0500   lazybadger
  Change 1

0   8bc9bcf8b736   2016-08-05 23:55 +0500   lazybadger
  Initial state

4d554db9595b

的差异
>hg diff -c 1
diff -r 8bc9bcf8b736 -r 4d554db9595b a.txt
--- a/a.txt     Fri Aug 05 23:55:46 2016 +0500
+++ b/a.txt     Fri Aug 05 23:56:19 2016 +0500
@@ -1,1 +1,2 @@
 Line 1
+Line 2

和workdir

>hg diff
diff -r 4d554db9595b a.txt
--- a/a.txt     Fri Aug 05 23:56:19 2016 +0500
+++ b/a.txt     Fri Aug 05 23:57:59 2016 +0500
@@ -1,2 +1,3 @@
 Line 1
 Line 2
+Line 3

显然是

>hg diff -r "parents(1)"
diff -r 8bc9bcf8b736 a.txt
--- a/a.txt     Fri Aug 05 23:55:46 2016 +0500
+++ b/a.txt     Sat Aug 06 00:06:20 2016 +0500
@@ -1,1 +1,3 @@
 Line 1
+Line 2
+Line 3

PS:只是快速阅读hg help diff,没有什么比这更难了......最后使用大脑!