I am creating named Mercurial branches for new features in my application, and after I finish a particular feature, I merge that branch into default branch, and close this feature branch.
But I wonder if there is way to remove those named branches completely, without losing changes that are merged into default branch?
When you're done with a branch and it has been merged into master, delete it. A new branch can be made off of the most recent commit on the master branch. Also, while it is ok to hang onto branches after you've merged them into the master they will begin to pile up.
You cannot. You can close the branch to hide it from the list of active branches, but you cannot completely delete it. This happens because in mercurial and in git the "branch" term means different things.
If you DELETE the branch after merging it, just be aware that all hyperlinks, URLs, and references of your DELETED branch will be BROKEN.
The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.
No there isn't.
When you have merged the two branches, the merge commit depends on the existence of its two parent commits. That means that you can't remove the commits making up the merged branch, unless you also delete the merge commit, which you don't want to do.
This is also not the "Mercurial way" to do things. When a branch has been merged into another branch, and no further development has been done on that branch, Mercurial recognizes that that branch is not active anymore; hg branches
will put those inactive branches at the bottom of the list. You can also close a branch by using hg commit --close-branch
, which will remove the branch from the hg branches
list (unless the -c
parameter is given).
It sounds like you should look into Mercurial queues (MQ), because this supports a similar workflow to what you describe. E.g., you can set up multiple MQ queues, and each of these represents a branch of development.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With