Mercurial:特定变更集中的差异?
这几乎与检查 Mercurial 中的单个变更集完全相同,并且没有怀疑我无法仅通过谷歌找到另一个问题的重复项。
我正在回顾 Mercurial 存储库,我想看看两个修订版(比如说 2580 和 2581)之间究竟发生了什么变化:
hg log -v -r 2581
为我提供了所有已更改的文件。
我怎样才能看到这些文件的差异?
谢谢。
This is almost exactly a duplicate of Examining a single changeset in Mercurial, and without doubt a duplicate of another question I can't find on SO through Google alone.
I'm looking back through a Mercurial repo, and I want to see what exactly changed between two revisions (let's say 2580 and 2581):
hg log -v -r 2581
gives me all the files that changed.
How can I also see the diffs of these files?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
修订版 2580 不一定是 2581 的父修订版。当然,检查它是否是父修订版很容易,但更简单的是这样做:
将 2581 与其(第一个)父修订版进行比较,无论它是什么,而且最清楚包含了问题的答案“2581 到底做了什么?”
Revision 2580 isn't necessasrily the parent revision of 2581. It's easy to check if it is, of course, but easier yet is to just do:
That compares 2581 to its (first) parent revision no matter what it is, and most clearly encompasses the answer to the question "what the hell did 2581 do?"
尝试
hg diff -r 2580 -r 2581
。Try
hg diff -r 2580 -r 2581
.这是一个错误的例子。修订版 2580 可以位于另一个分支中,并且您可以在两个分支之间获得差异。
使用
或
hg diff -c 2581
在第一行中比较它们之间的差异。 Hg log 还显示有关变更集的信息(父级、作者、日期...)
我更喜欢第二个变体
hg diff -c ...
因为它可以存储到补丁文件。hg diff -c 2581 > revision_2581.patch
This is a wrong example. The revision 2580 can be in another branch and you get diff between two branches.
Use
or
hg diff -c 2581
The difference between them in the first lines. Hg log also show information about changeset (parent, author, date, ...)
I prefer second variant
hg diff -c ...
because it can store to patch files.hg diff -c 2581 > revision_2581.patch
另一个解决方案是使用 revset 表示法,IMO 是一个更好的解决方案,因为您可以在更多地方一致地使用它(即您不需要了解
diff -c
和log -p< /代码>)。
是的,与 -c (用于 diff)和 -p (用于 log)相比,这相当冗长。
创建 revset 别名
但是,mercurial 允许您在
.hgrc
中:现在您可以执行以下操作:
Another solution is to use revset notation which IMO is a better solution as you can use it in more places consistently (ie you don't need to know about
diff -c
andlog -p
).Yes that is rather verbose compared to -c (for diff) and -p (for log).
However mercurial allows you to create revset aliases
In your
.hgrc
:Now you can do