开发者

hg diff -g shows different output between a merge (pre-commit) and the change log (post-commit)

开发者 https://www.devze.com 2023-01-19 16:48 出处:网络
I am using branches in our mercurial repository and have noticed renames done in separate branches are not shown pre-commit after merging to the default branch. However after a commit when you issue t

I am using branches in our mercurial repository and have noticed renames done in separate branches are not shown pre-commit after merging to the default branch. However after a commit when you issue the hg diff -g command it shows the rename correctly.

The following snippet shows what I mean. A new repository being created. I create a single file in default. I then create a branch called branch-one. I rename the file in branch one and merge this change back to default. Prior to committing to default I do a diff to see what the changes are and note it doesn't pick up the rename but instead reports a delete then an add. But after the commit I check the diff again and this time the rename is correctly reported.

Is there a way to have the diff reported correctly before the commit?

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 r开发者_开发百科emoved, 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

I am on version 1.6.3 on Windows XP.


NOTE: diff may generate unexpected results for merges, as it will default to comparing against the working directory's first parent changeset if no revisions are specified.

http://linux.die.net/man/1/hg

0

精彩评论

暂无评论...
验证码 换一张
取 消