Steve
Steve

Reputation: 849

How to do a Mercurial merge in case multiple branches are active?

I have following structure of branches in my Mercurial repository

               ----------B-------
              /
             /
-----default----------------------------
             \    \            /
              \    \          /
               --------A------
                     \
                      \
                       ------C------

I would like to do a merge of the default branch with the B branch (where the B branch is my "working" branch). My idea how to do that was to "switch" onto the default branch at first. So I intended to do following steps

  1. hg update default (for switching onto the default branch)
  2. hg merge B (for "pulling" the changes on the B branch onto the default branch)
  3. resolving the conflicts
  4. hg commit (for making the merge persistent)

Please can anybody tell me whether the steps which I am going to use can work also in my situation i.e. in case I have default branch and two other active (open) branches from which only one of them is intended to be merged with the default?

Upvotes: 1

Views: 105

Answers (1)

StayOnTarget
StayOnTarget

Reputation: 12998

The result of your proposed workflow would be this:

               ----------B------- - - 
              /                       \
             /                         \
-----default----------------------------(*)
             \    \            /
              \    \          /
               --------A------
                     \
                      \
                       ------C------

Where the (*) marks the current working directory immediately afterwards.

The fact that there is a branch C shouldn't cause any concern. There could be any # of other branches like C and until you merge with them individually, they would have no effect on your merge of B into default.

Assuming that A and B are no longer needed, you can close them. This just serves as a marker / reminder that work on them is finished but it doesn't have much other practical effect. For instance, you could resume work on a closed branch later and even re-merge it back to default if needed. (On the other hand you could also branch off from default again and do that work there.)

Upvotes: 1

Related Questions