在 Mercurial 中,如何查看合并变更集和一个父级之间的差异,而无需另一父级的更改?
考虑这个简单的存储库:
mkdir temp
cd temp
hg init
echo abc > file1
hg ci -A -m init
echo def >> file1
echo hey > file2
hg ci -A -m A
hg up -r0
echo ghi >> file1
echo hey > file3
hg ci -A -m B
hg merge
hg ci -m merge
在合并期间,采用“ghi”(哪一边并不重要)。
DAG 为:
0 - 2 - 3
\- 1 -/
hg diff -r1:3
显示 file1 更改和新 file3。
hg diff -r2:3
显示新文件2。 hg log -p -r3
和 hg st --change 3
相同,因为 2 是第一个父级。
我的问题是:如何查看 1 和 3 之间的变化减去 2 的变化,这在概念上是d(1:3) - d(0:2)
?
我预计只会看到 file1 发生变化。 hg log -r3 -v
仅显示“files: file1”(我猜是因为它是更改 ctx 中的唯一文件),但奇怪的是,hg log -r3 --debug
还显示“files+: file2”。
如果我运行 hg view
(由捆绑的 hgk
扩展提供)并单击 r3,它只显示 file1。我无法阅读 tcl/tk 代码,但似乎技巧在于 contmergediff
函数,它获取合并中的文件列表,其中它以某种方式省略了 file2。
FWIW,TortoiseHg 与上述所有内容不同:单击 r3 在文件列表中显示“M file1”和“A file2”,但在 file1 中没有显示任何实际更改。点击“Other Parent”显示“M file1”和“A file3”,与“diff -r1:3”相同。
现实世界的用例是这样的:r1 是我的,r2 是同事的。早些时候,同事审查了r1(diff 0:1),但他在要求审查r2之前没有合并它。所以我审查了r2(diff 0:2),后来他做了合并。然后当我看到 diff 1:3 时,我不得不忘记我曾经评论过 r2。如果合并差异很小,我可以使用 hgk。但如果它很大,我真的需要在 vdiff 中查看它。
(更新)现在有一个 mergediff 扩展。如果有人尝试并发现它有效,请添加答案。
Consider this trivial repo:
mkdir temp
cd temp
hg init
echo abc > file1
hg ci -A -m init
echo def >> file1
echo hey > file2
hg ci -A -m A
hg up -r0
echo ghi >> file1
echo hey > file3
hg ci -A -m B
hg merge
hg ci -m merge
During merge, take "ghi" (doesn't really matter which side).
The DAG is:
0 - 2 - 3
\- 1 -/
hg diff -r1:3
shows file1 change and new file3.
hg diff -r2:3
shows new file2. Same for hg log -p -r3
and hg st --change 3
, because 2 is the first parent.
My question is: how can I see the changes between 1 and 3 minus the changes in 2, which is conceptually d(1:3) - d(0:2)
?
I expect to see only file1 change. hg log -r3 -v
only shows "files: file1" (I guess because it's the only file in the change ctx), but curiously, hg log -r3 --debug
also shows "files+: file2".
If I run hg view
(provided by the bundled hgk
extension) and click on r3, it shows only file1. I can't read tcl/tk code, but it seems like the trick is in a contmergediff
function where it gets the list of files in a merge, in which it somehow omits file2.
FWIW, TortoiseHg is different from all of the above: clicking on r3 shows "M file1" and "A file2" in the file list, but shows no actual change in file1. Click "Other Parent" shows "M file1" and "A file3", which is the same as "diff -r1:3".
A real world use case is this: r1 is mine, and r2 is a colleague's. Earlier, the colleague reviewed r1 (diff 0:1), but he didn't merge it before asking for review of r2. So I reviewed r2 (diff 0:2), and later he did the merge. Then when I see diff 1:3, I have to forget about that I've ever reviewed r2. If the merge diff is small, I can just use hgk. But if it's big, I really need to see it in vdiff.
(UPDATE) Now there's a mergediff extension. If someone tries and finds it work, please add an answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个猜测(尽管我不确定它是否真的符合您的要求)。该命令
列出了已通过合并更改的文件。此输出可用作 diff 命令的文件列表,以仅显示您感兴趣的更改。
应用于您的示例,以下内容应显示合并对 执行的操作您在修订版 1 中的贡献:
同样,下面的命令应该向您显示合并如何影响您同事在修订版 2 中的更改:
Here's a guess (though I'm not sure if it really does what you want). The command
lists the files, which have been changed by a merge. This output could be used as a list of files for the diff command, to show only the changes you're interested in.
Applied to your example, the following should show what the merge did with your contributions in revision 1:
Similarly, the command below should show you how the merge affected your colleague's changes in revision 2: