Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial - Is it possible to merge changes from the trunk to a branch, within the same repo?

Mercurial - Is it possible to merge changes from the trunk to a branch, within the same repository?

If yes, is it possible with TortoiseHg?

like image 805
Joshua Enfield Avatar asked Jun 23 '10 21:06

Joshua Enfield


People also ask

How do I merge two branches in Mercurial?

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.

How do I merge commits in Mercurial?

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.

How can I change branch in Mercurial?

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.


1 Answers

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)
like image 151
Jerub Avatar answered Sep 18 '22 16:09

Jerub