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?
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 brancheswill put those inactive branches at the bottom of the list. You can also close a branch by usinghg commit --close-branch, which will remove the branch from thehg brancheslist (unless the-cparameter 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.