Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial via TortoiseHg - Merge a named branch then close it

I have a named branch, NewFeature, that I made off of the default branch. I've made a couple commits to that branch, and now I'd like to merge it to rejoin the default branch.

Now (each letter is a commit):

   default: A---B
NewFeature:      \--C---D

What I'd like:

   default: A---B-----------E
NewFeature:      \--C---D--/

I tried right clicking the directory and selecting "Hg Commit...". I then selected "Close Current Named Branch". I got this error: abort: can only close branch heads

I also looked for a "close branch" option in the repository explorer, but I couldn't find anything.

Could someone please help? Thanks in advance!

Edit: I posted an issue to TortoiseHg

like image 456
sharoz Avatar asked Feb 01 '11 00:02

sharoz


People also ask

How do I close a branch on TortoiseHg?

when you are on your NewFeature branch (no need to have anything to commit - or you do it with your final merge) click "Branch: NewFeature" (it's at the top in bold) select "Close current branch".

How do I merge branches in Mercurial branch?

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.

How to change branch in TortoiseHg?

As shown in the docs, all you should need to do is just click on the branch: default button near the top of the commit dialog, and change to a new branch name.


2 Answers

The example you give is more a Merge than really a Close. Also, if it's that simple, you probably don't want/need to create a named branch.

But if you really want to close a branch through TortoiseHg, eg

  1. you created the NewFeature branch
  2. then both the Default branch and NewFeature branches were modified
  3. then if the NewFeature branch takes quite some time you might have also already merged several time Default into NewFeature (to avoid having too many differences when you'll want to finally merge the NewFeature branch into the Default one)
  4. eventually your new feature is entirely implemented or stable enough, you merged the NewFeature branch into the Default one

From now on, no one is supposed to commit anything on the NewFeature branch, so you'd like to close it.

You can do so in TortoiseHg (I have version 2.3.2):

  1. click Hg Commit... when you are on your NewFeature branch (no need to have anything to commit - or you do it with your final merge)
  2. click "Branch: NewFeature" (it's at the top in bold)
  3. select "Close current branch".
like image 50
user276648 Avatar answered Oct 12 '22 21:10

user276648


To merge, you need a clean working copy - no uncommitted changes. The merge will be placed in the working copy for review and then you commit the working copy to "complete" the merge.

If you have uncommitted changes you are not prepared to commit, you can see about shelving those changes temporarily (if you have that appropriate extension) or checkout a new working copy somewhere else to use for the merge.

Using the Repository Explorer:

  1. Update the working copy to rev B.

  2. Select rev D row in the revision history.

  3. Right-click on rev D and choose Merge with.... The dialog should show rev B should be the local rev and D should be the other rev.

  4. Click Merge in the merge dialog and resolve any conflicts, if any.

Up to now, nothing has been changed in the repository - your merge is in the working copy. So if something is wrong, you can cancel the merge, revert your working directory, and start over at later time or after making some other additional branch or trunk changes.

If everything is good after steps 1-4, click Commit in the merge dialog to commit the merge.

like image 23
Bert F Avatar answered Oct 12 '22 20:10

Bert F