Reputation: 6345
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
Upvotes: 32
Views: 30597
Reputation: 23690
For anyone that's confused by the answers to this question, here are the instructions on how to do this from within the TortoiseHg Workbench:
NewFeature
branch into default
:NewFeature
branch as we no longer need it:NewFeature
:Click commit, the big green tick at the top of the workbench.
In the commit window, you should see the branch that you want to close above the comment text box. Click the branch name:
Upvotes: 28
Reputation: 2298
You also seem to get this error is the branch is already closed, i.e. trying to close a closed branch. A more helpful error message would be useful.
Upvotes: 1
Reputation: 6383
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
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):
Upvotes: 44
Reputation: 87603
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:
Update
the working copy to rev B
.
Select rev D
row in the revision history.
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.
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.
Upvotes: 24
Reputation: 62218
In TortoiseHg, your working copy must be updated to the tip of the branch you want to close before using the commit dialog.
Closing a branch will create a new changeset on top of the branch tip.
The error you described (abort: can only close branch heads
) typically occurs if you have updated to a changeset not at the tip of a named branch.
Upvotes: 1