我在mercurial存储库中使用了分支,并注意到在合并到默认分支后,在单独的分支中完成的重命名未显示在提交之前。但是,在您发出hg diff -g
命令后,它会正确显示重命名。
以下代码段显示了我的意思。正在创建一个新的存储库。我默认创建一个文件。然后我创建一个名为branch-one的分支。我在分支1中重命名该文件,并将此更改合并回默认值。在提交默认值之前,我会进行差异以查看更改的内容,并注意它不会获取重命名,而是报告删除然后添加。但是在提交之后我再次检查差异,这次正确报告了重命名。
有没有办法在提交之前正确报告差异?
D:\hgsource>hg init SO-question
D:\hgsource>cd SO-question
D:\hgsource\SO-question>echo test file content > test.txt
D:\hgsource\SO-question>hg commit -A -m "first commit"
adding test.txt
D:\hgsource\SO-question>hg branch branch-one
marked working directory as branch branch-one
D:\hgsource\SO-question>hg rename test.txt new-file.txt
D:\hgsource\SO-question>hg status
A new-file.txt
R test.txt
D:\hgsource\SO-question>hg commit -m "renamed file in branch-one"
D:\hgsource\SO-question>hg update default
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
D:\hgsource\SO-question>hg merge branch-one
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
(branch merge, don't forget to commit)
D:\hgsource\SO-question>hg diff -g
diff --git a/new-file.txt b/new-file.txt
--- /dev/null
+++ b/new-file.txt
@@ -0,0 +1,1 @@
+test file content
diff --git a/test.txt b/test.txt
deleted file mode 100644
--- a/test.txt
+++ /dev/null
@@ -1,1 +0,0 @@
-test file content
D:\hgsource\SO-question>hg commit -m "merged from branch-one"
D:\hgsource\SO-question>hg diff -c tip
diff --git a/test.txt b/new-file.txt
rename from test.txt
rename to new-file.txt
我在Windows XP上的1.6.3版本。
答案 0 :(得分:1)
注意:diff可能会为合并生成意外的结果 默认为与工作目录的第一个父进行比较 如果没有指定修订,则变更集。