简体   繁体   English

Mercurial:跨版本合并/大规模采摘樱桃

[英]Mercurial: cross-version merges / massive cherry-picking

Situation 情况

We have 2 versions (1.0 and 2.0) of a project that are both actively maintained. 我们有2个版本(1.0和2.0)的项目都得到了积极维护。 It is basically the same project (as far as changes go), but being based on different base versions (base1.0 and base2.0). 它基本上是同一项目(就更改而言),但是基于不同的基本版本(base1.0和base2.0)。 Everything that is changed in 1.0 has also to be ported to 2.0. 在1.0中更改的所有内容也必须移植到2.0。 The same goes for base1.0 and base2.0. base1.0和base2.0也是如此。

In mercurial we have 4 branches: base1.0 , 1.0 , base2.0 and 2.0 . 在水银我们有4个分支:base1.0,1.0,base2.02.0。 Something like this: 像这样:

                         __2.0
             __base2.0__/
            /
__base1.0__/___1.0____________

Now everytime we change something in the base version, we make the change in base1.0 and do a hg merge to base2.0 . 现在,每次我们在基本版本中进行更改时, 都会base1.0中进行更改,并进行hg合并到base2.0中 No problems here. 没问题

Now when we do the same for 1.0 and want to merge them into 2.0 , we also have to re-merge the entire base1.0 branch into 2.0 , although that has already been done creating base2.0 out of base1.0 . 现在,当我们对1.0进行同样的操作并想将它们合并到2.0中时 ,我们也必须将整个base1.0分支重新合并到2.0中 ,尽管已经从base1.0中创建了base2.0了。

Question

What is the most efficient way to solve this? 解决此问题的最有效方法是什么? I had a few approaches: 我有几种方法:

  1. Merge : as explained above, this causes a lot of overhead and work to be re-done that has already been done 合并 :如上所述,这会导致大量的开销,并且已经完成的工作需要重做
  2. graft aka cherry-pick: Select every single change we make on 1.0 and port them to 2.0 using hg graft. 嫁接又名Cherry-pick:选择我们对1.0所做的每个更改,然后使用hg嫁接将其移植到2.0 While it does work in some cases, it creates duplicate changesets because it ports them 1:1. 尽管在某些情况下确实可以工作,但它会创建重复的变更集,因为它以1:1的方式移植它们。 What I'd like would be 1 single commit containing all updates made on 1.0 grafted to 2.0 . 我想要的是1个单独的提交,其中包含对1.0移植到2.0的所有更新。
  3. diff export : I also tried to make a export a diff between the original 1.0 and the most recent 1.0 and then import it onto 2.0 . 差异导出 :我还尝试了导出原始1.0和最新的1.0之间的差异,然后将其导入2.0 But it's a patch, and patches are evil. 但这是一个补丁,而补丁是邪恶的。 And not very handy to handle. 而且不是很方便处理。

Any ideas? 有任何想法吗? Being relatively new to the whole SCM concept I just wanted to hear what others do in such scenarios. 作为整个SCM概念的新手,我只是想听听其他人在这种情况下所做的事情。 Thanks. 谢谢。

I actually resolved my problem. 我实际上解决了我的问题。 I'll add it as an answer, maybe someone else finds it useful. 我将其添加为答案,也许其他人会发现它很有用。

What I really needed was cherry-picking all my changes from 1.0 to 2.0 . 我真正需要的是挑选所有从1.02.0的更改。 hg graft does that pretty well, but creates an additional commit on 2.0 for each changeset grafted and messes up my graph. hg嫁接效果很好,但是为嫁接的每个变更集在2.0上创建了一个额外的提交,并弄乱了我的图。

So what I did was creating a clone of my repo and then grafting all the changesets using hg graft from 1.0 onto 2.0 . 所以我要做的是创建仓库的克隆,然后使用从1.02.0的 hg嫁接移植所有变更集。 Then I exported a diff of pre-graft and post-graft and imported that diff as a patch onto the original repo. 然后,我导出了移植前和移植后的差异,并将该差异作为补丁导入到原始存储库中。

Essentially a cumulative "graft" without any information about where it came from. 本质上是累积的“嫁接”,没有任何有关其来源的信息。 This was exactly what I needed and worked for me in this case. 在这种情况下,这正是我需要的并为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM