How to merge and close my branch in TortoiseHG?

Developer
Jan 14, 2011 at 11:04 PM

Hi,

I'm having trouble with creating a branch and merging it back to the default in TortoiseHG. I created a branch 'Ribbon control changes' and committed it to the repository using synchronize -- push. Then, I did 'HG update' and 'merge with default'. Now there are two branches: 'default' and 'Ribbon control changes'. How can I close the 'Ribbon control changes' branch and move the tip to the default?

Is there any simple step-by step manual how to create the branch and correctly merge it to the default?

Thanks,

Jiri

Developer
Jan 14, 2011 at 11:14 PM

Hi Jiri.  No I have had lots of issues with this, and for the most part have given up.  But here is what I typically do.  Lets say you create a named branch by committing changes to a named branch.  You can then commit changes to this branch and other folks can continue to commit changes to the other branch.  The next time you pull from the repository, you should see default ahead of your changes with any changes made by someone else.  At that point, you can right click on your named branch and use the "merge with" option in order to merge back into the default branch.  I have found that this doesn't always manage to kill off the named branch as a valid tip.  So once you have completed the merge (so that your changes now exist in the default tip) you can right click on the little tail of a named branch that is still sticking out and right click and I think you can commit again (with no code changes necessary) only select the option "Close Branch".

If no one else has made changes to merge to, this is slightly more complicated, but goes like this:  You update to your latest changes in the named branch.  Then commit, (even with no further changes) and pick the option of committing to a named branch.  Only when you pick the name, you pick "default".  This will ensure that your changes are now back on the default thread.  However, your named branch will still be sitting out there as a valid tip.  So you now go back and close it like before I think.

Anyway, my interactions with Tortoise HG as far as committing named branches has been that it almost is never worth naming the stupid branch.  It will happily separate branches out based on the user that is committing code, even if every user is committing to default.  The only purpose for having a named branch is if you need to collaborate with someone else on a change before it is ready to be committed to the repository.  If this is something that will only be seen on your machine, then just commit to default and when you pull from the repository you will discover you are no longer on default and can merge back in if any changes have happened in the interim.  If not, then you are already synchronized with default, and you are good to go.

Ted

 

Developer
Jan 14, 2011 at 11:16 PM

Note... you may have to update back to the open tip on the not yet closed named branch before you can commit in a way to close the branch.

Ted