Fix bad merge in mercurial


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.


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.


  • Avoid merging master into development branch
  • After Installing PMD in Luna in Prespective it is Not Showing?
  • Get pretty git rev name
  • How to make Java compiler generate line numbers in compiled code
  • Hadoop shuffle uses which protocol?
  • How can I allow tags through rails 4 sanitize?
  • Java, will (low + high) >>> 1 overflow?
  • How to Configure Log4Net Custom Object Renderer for Generic Objects?
  • JPA/Hibernate - Entity name seems to be important. If I rename to “Bob” works fine
  • Use neo4j server instead of embedded mode
  • Removing event listeners on automatically created multiple elements
  • How do you SELECT several columns with one distinct column
  • CKeditor stripping font tags instead of converting to span
  • What is the best way to debug Bootstrap.groovy?
  • What is this strange character in chrome's resource css viewer?
  • Ionic Slide Up Slide Down Animation for only one view in sidebar
  • Is there any way to call saveCurrentTurnWithMatchData without sending a push notification?
  • Avoid registering duplicate broadcast receivers in Android
  • How to merge keras sequential models with same input?
  • c++ regex_replace not doing intended substitution
  • hibernate sets dirty flag (and issues update) even though client did not change value
  • LESS CSS how to modify parent property in mixin
  • How can Delete be both a DDL and a DML statement
  • User messaging system
  • How can I tell a form not to dispose a particular control when it closes?
  • Prevent Tomcat from caching request during starup
  • Can't remove headers after they are sent
  • SonarQube: Cannot deactivate rule with missing quality profile
  • ASP.NET MVC 2 Preview 2 - display directory list rather than home/index
  • Remove changes from one element when event occurs on another element?
  • How to generate and display a QR Code in ionic 2
  • Remove final comma from string in vb.net
  • Atlas images wrong size on iPad iOS 9
  • Join two tables and save into third-sql
  • How to model a transition system with SPIN
  • ORA-29908: missing primary invocation for ancillary operator
  • SVN: Merging two branches together
  • Is there any way to bind data to data.frame by some index?
  • Converting MP3 duration time
  • git trying to push non-existent file … after clearing cache