hg diff -g 显示合并(提交前)和更改日志(提交后)之间的不同输出

发布于 2024-09-27 01:39:09 字数 1599 浏览 1 评论 0原文

我正在 Mercurial 存储库中使用分支,并注意到在合并到默认分支后,在单独分支中完成的重命名不会在提交前显示。但是,提交后,当您发出 hg diff -g 命令时,它会正确显示重命名。

下面的代码片段展示了我的意思。正在创建一个新的存储库。我默认创建一个文件。然后我创建一个名为“branch-one”的分支。我重命名分支一中的文件并将此更改合并回默认值。在提交默认值之前,我会进行比较以查看更改内容,并注意它不会选择重命名,而是报告删除然后添加。但提交后,我再次检查差异,这次重命名被正确报告。

有没有办法在提交之前正确报告差异?

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 版本。

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 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

I am on version 1.6.3 on Windows XP.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘味果▽酱 2024-10-04 01:39:09

注意: diff 可能会生成意外的合并结果,因为它会
默认与工作目录的第一个父目录进行比较
如果未指定修订,则更改集。

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文