修复错误合并 [英] Fix bad merge in mercurial

查看:95
本文介绍了修复错误合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的日常项目配置中,我们在一个存储库中有3个分支.一个是稳定版本分支,其中完成了紧急错误修复,一个是功能分支,其中包含新功能代码,一个是UAT分支,其中将错误修复和新功能合并到一起,以提供最新的代码库

In our mercurial project configuration we have 3 branches in a single repository. One is a stable release branch where urgent bug fixes are done, one is a feature branch which contains new feature code and one is a UAT branch where both bug fixes and new features are merged into to provide the most up-to-date code base.

我们已经将全部新功能代码合并到UAT分支中,而没有任何问题.之后,我们将带有错误修复的稳定分支合并到了UAT分支中,但这似乎具有删除新功能代码的效果.我发现此问题是由某人将UAT合并到稳定状态中引起的(这本来是不会发生的!).现在,当我尝试将错误修复程序合并到UAT中时,它将删除所有新功能代码.

We have merged a whole load of new feature code into the UAT branch without any issues at all. Following that we merged the stable branch with the bug fixes into the UAT branch but this seems to have the effect of removing the new feature code. I have discovered that this problem has been caused by someone merging UAT into stable a while ago (which should have never happened!!). Now when I try to merge the bug fixes into UAT it removes all the new feature code.

是否有一种方法可以将合并的影响从UAT移除到稳定状态,同时仍保留此不良合并"后代的错误修复?我曾尝试撤消合并,但似乎根本没有任何效果.我可以剥离并重新添加所需的变更集吗?

Is there a way of removing the effects of the merge from UAT into stable, whilst still retaining the bug fixes that are descendents after this 'bad merge'? I've tried backing out the merge but it seems to have no effect at all. Can I do a strip and re-add the required changesets back in?

谢谢.

推荐答案

我实际上已经通过反复试验来解决这个问题.

I've actually managed to fix this one myself through a bit of trial and error.

首先,您需要在mercurial.ini文件中启用移植和mqMerge扩展名.在扩展标题下面的行下面添加行

First you need to enable the transplant and mqMerge extensions in your mercurial.ini file. Add the lines following lines below the extension header

   transplant=
   mq=

将存储库克隆到新位置. 在您的新仓库中,使用strip命令清除历史记录以删除不良合并,从而消除不良合并的影响. (请注意,这将删除所有后代变更集)

Clone a your repository to a new location. In your new repo, remove the bad merge by using the strip command to clear history the effect of the bad merge is removed. (Beware that this will remove all descendent changesets)

然后,您需要使用与下面类似的命令,按时间顺序从另一个存储库中挑选所有必需的变更集

Then you need to cherrypick all the required changesets in chronological order from the other repo by using a command similar to below

    hg transplant -s "otherRepo" -b "branchName" "changesetHexNumber"

为所有必需的变更集重复移植命令.哇拉!

Repeat the transplant command for all the required changesets. Ouila!

注意:如果您使用的是中央存储库,则也需要在该存储库上删除有问题的合并/更改集,否则本地存储库将认为您有待处理的变更集.

NB: If you are using a central repository you will need to strip the offending merge/changset on there too otherwise your local repo will think you have outstanding changesets to pull.

这篇关于修复错误合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆