[英]Can I merge multiple consecutive changesets into a changeset in Mercurial
Let's say I have changeset A, and I make changesets B1, B2, and B3 on top of A, while another developer makes changesets C1, C2, and C3 on top of A: 假设我有变更集A,我在A之上创建变更集B1,B2和B3,而另一个开发人员在A之上创建变更集C1,C2和C3:
B1 --- B2 --- B3
/
--- A
\
C1 --- C2 --- C3
The other developer pushes his code to the central repository, and now I want to push my code, but I can't because there are multiple heads. 另一个开发人员将他的代码推送到中央存储库,现在我想推送我的代码,但我不能因为有多个头。 I could rebase my changesets to go on top of his (and this is what I've been doing), but it would be more accurate to merge. 我可以改变我的变更集以继续他的(这是我一直在做的),但合并会更准确。
However, as far as I'm aware, I can only merge one changeset at a time. 但是,据我所知,我一次只能合并一个变更集。 So I'd have to merge B1 onto C3 creating M1, and B2 onto M1 creating M2, and and B3 onto M2 creating M3. 所以我必须将B1合并到C3上创建M1,将B2合并到M1上创建M2,并将B3合并到M2上创建M3。 That's three merges I have to perform, and three new merge changesets cluttering up the repository! 这是我必须执行的三个合并,以及三个新的合并更改集使存储库混乱! Is there a way that I can merge B1, B2, and B3 onto C3 all at once, or do I have to settle for modifying history using a rebase? 有没有办法可以同时将B1,B2和B3合并到C3上,或者我是否需要使用rebase修改历史记录?
You can merge B3 and C3 to get: 您可以合并B3和C3以获得:
B1 --- B2 --- B3
/ \
--- A M
\ /
C1 --- C2 --- C3
That is the traditional way to reconsile the two lines of development. 这是重建两条发展线的传统方式。 The merge changeset will have two parents (merges always have two parents in Mercurial) B3 and C3, but you're still merging the combined effect of B1 to B3 with the combined effect of C1 to C3. 合并变更集将有两个父项(合并在Mercurial中总是有两个父项)B3和C3,但是你仍然将B1和B3的组合效果与C1和C3的组合效果合并。
In fact, merges are only concerned with three states : A, B3, and C3. 实际上,合并只涉及三种状态 :A,B3和C3。 Since the state B3 include the changes you made in B1 and B2, you end up merging the changes in B1 to B3 into the state C3. 由于状态B3包含您在B1和B2中所做的更改,因此您最终将B1到B3中的更改合并到状态C3中。
What you describe with three merges is actually what rebase does internally! 你用三个合并描述的内容实际上是rebase内部的作用! After creating M1 to M3, it deletes the second parent of these merge commits and deletes B1 to B3. 在创建M1到M3之后,它删除这些合并提交的第二个父级并删除B1到B3。 That leaves you with 这让你失望
--- A --- C1 --- C2 --- C3 --- M1 --- M2 --- M3
where Mi ~= Bi. 其中Mi~ = Bi。 As you note, this is a less accurate picture of what actually happened in the repository because you've linearized history what was really done in parallel. 正如您所注意到的,这是对存储库中实际发生的事情的准确描述不太准确,因为您已经将历史记录的线性化并行化了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.