Mercurial - Is it possible to merge changes from the trunk to a branch, within the same repository?
If yes, is it possible with TortoiseHg?
To merge two branches, you pull their heads into the same repository, update to one of them and merge the other, and then commit the result once you're happy with the merge. The resulting changeset has two parents.
Once the commits are in draft, run the hg histedit rev-id command, specifying the earliest draft commit. This will open the history edit function in your terminal, allowing you to fold the commit messages into one. Select a commit to use as the one into which the others will be squashed.
From the main menu, select Hg | Mercurial | Update to. In the Switch Working Directory dialog that opens, specify the target working directory: To switch to another line of development, choose Branch and select the desired branch from the list.
There are two things you can do, merge or transplant. These answers assume the command line, you may have to search through your menus in tortoise to find similar functionality.
You can merge all the changes from one branch to another. The procedure for this is:
hg update mybranch
hg merge default
hg commit -m "Merging with default"
This will bring all commits from default into your branch, but not the other way around. Later you can reintegrate your branch with default by doing the opposite
hg update default
hg merge mybranch
hg commit -m "Bringing in changes from mybranch"
If you want to bring in one or more specific commits that were committed in another branch, you can do that with 'transplant', which is a mercurial extension.
# reqiured in ~/.hgrc
[extensions]
transplant =
These are the commands you can use to use transplant:
hg log | less
# (find revision number, the part after the colon, i.e. "88660cca467d")
hg update mybranch
hg transplant 88660cca467d
# (no commit required)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With