Mercurial 中合并方向重要吗?
举一个简单的例子:我正在默认分支上工作,在本地提交了一些变更集,并且我从主存储库中提取了更多变更集。我已经在独立的本地存储库中工作了几天,因此在我将结果推回主版本之前,需要合并相当多的更改。
default ---o-o-o-o-o-o-o-o-o-o-o (pulled stuff)
\
o----o------------o (my stuff)
我现在可以做两件事。
选项#1:
hg pull
hg merge
结果#1:
default ---o-o-o-o-o-o-o-o-o-o-o
\ \
o----o------------o-O
选项#2:
hg pull
hg update
hg merge
结果#2:
default ---o-o-o-o-o-o-o-o-o-o-o-O
\ /
o----o------------o
这两个结果对我来说看起来是同构的,但实际上,选项#2 似乎会产生更小的变更集(因为它只将我的一些更改应用于主线)将所有主线更改应用到我的少数)。
我的问题是:这有关系吗?我应该关心合并的方向吗?如果我这样做,我会节省空间吗? (合并后执行 hg log --patch --rev Tip
表明是这样。)
Take a simple example: I'm working on the default branch, have some changesets committed locally, and I pulled a few more from the master repository. I've been working for a few days in my isolated local repository, so there's quite a few changes to merge before I can push my results back into master.
default ---o-o-o-o-o-o-o-o-o-o-o (pulled stuff)
\
o----o------------o (my stuff)
I can do two things now.
Option #1:
hg pull
hg merge
Result #1:
default ---o-o-o-o-o-o-o-o-o-o-o
\ \
o----o------------o-O
Option #2:
hg pull
hg update
hg merge
Result #2:
default ---o-o-o-o-o-o-o-o-o-o-o-O
\ /
o----o------------o
These two results look isomorphic to me, but in practice it seems that option #2 results in way smaller changesets (because it only applies my few changes to the mainline instead of applying all the mainline changes to my few).
My question is: does this matter? Should I care about the direction of my merges? Am I saving space if I do this? (Doing hg log --patch --rev tip
after the merge suggests so.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们(实际上)是相同的。您会看到 hg log --patch --rev X 输出大小存在差异,因为 log 显示结果及其(任意)其“左”父级(正式为 p1)的差异,但事实并非如此它被存储(Mercurial 有一个二进制 diff 存储格式,不是基于 patch/diff),现在它是如何计算的(p1、p2 和最近的共同祖先都被使用)。
唯一真正的区别是,如果您使用命名分支,则分支名称将是左父级的名称。
They're (effectively) identical. You see a difference in the
hg log --patch --rev X
output size because log shows the diff of the result and (arbitrarily) its 'left' parent (officially p1), but that's not how it's stored (Mercurial has a binary diff storage format that isn't patch/diff based) and it's now how it's computed (p1, p2, and most-recent-common-ancestor are all used).The only real difference is, if you're using named branches, the branch name will be that of the left parent.
如果您使用书签,也会有区别。进行合并时,您所在的分支是接收更改的分支,因此新的更改集将成为该分支的一部分。假设您遇到这种情况:
如果您将 Rev 200 合并到 Rev 195,则书签
my-stuff
将移至 Rev 201,因为您在具有该书签的同一分支中生成新的变更集。另一方面,如果将 195 合并到 200,则会在没有书签的分支中生成变更集。
my-stuff
书签将保留在 Rev 195 中。There is also a difference if you are using Bookmarks. When doing a merge, the branch that you are is the branch that is receiving the changes, so the new changeset will be part of that branch. Supose you have this situation:
If you merge Rev 200 into Rev 195, the bookmark
my-stuff
will move on to Rev 201, as you are generating a new changeset in the same branch that has the bookmark.On the other hand, if you merge 195 into 200, you are generating a changeset in the branch that don't have the bookmark. The
my-stuff
bookmark will remain in Rev 195.