Mercurial:特定变更集中的差异?

发布于 2024-10-24 22:30:03 字数 367 浏览 2 评论 0原文

这几乎与检查 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 技术交流群。

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

发布评论

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

评论(4

极致的悲 2024-10-31 22:30:03

修订版 2580 不一定是 2581 的父修订版。当然,检查它是否是父修订版很容易,但更简单的是这样做:

hg log -p -r 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:

hg log -p -r 2581

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

锦上情书 2024-10-31 22:30:03

尝试hg diff -r 2580 -r 2581

Try hg diff -r 2580 -r 2581.

寻找我们的幸福 2024-10-31 22:30:03
hg diff -r 2580 -r 2581

这是一个错误的例子。修订版 2580 可以位于另一个分支中,并且您可以在两个分支之间获得差异。

使用

hg log -p -r 2581

hg diff -c 2581

在第一行中比较它们之间的差异。 Hg log 还显示有关变更集的信息(父级、作者、日期...)

我更喜欢第二个变体 hg diff -c ... 因为它可以存储到补丁文件。

hg diff -c 2581 > revision_2581.patch

hg diff -r 2580 -r 2581

This is a wrong example. The revision 2580 can be in another branch and you get diff between two branches.

Use

hg log -p -r 2581

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

友谊不毕业 2024-10-31 22:30:03

另一个解决方案是使用 revset 表示法,IMO 是一个更好的解决方案,因为您可以在更多地方一致地使用它(即您不需要了解 diff -clog -p< /代码>)。

hg diff -r 'last(ancestors(2581),2)'

是的,与 -c (用于 diff)和 -p (用于 log)相比,这相当冗长。

创建 revset 别名

但是,mercurial 允许您在 .hgrc

[revsetalias]

next(s) = descendants(s, 1)
prev(s) = last(ancestors(s),2)

:现在您可以执行以下操作:

hg diff -r 'prev(2581)'
hg log -r 'prev(2581)'

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 and log -p ).

hg diff -r 'last(ancestors(2581),2)'

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:

[revsetalias]

next(s) = descendants(s, 1)
prev(s) = last(ancestors(s),2)

Now you can do

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