Question

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.

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.

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?

Thanks in advance.

Was it helpful?

Solution

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

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=

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top