How to delete Mercurial branch after merge
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.
Related videos on Youtube
Ivica
Updated on June 18, 2022Comments
-
Ivica about 2 years
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?
-
Ry4an Brase almost 12 yearsYour answer is near perfect (and I've upvoted it) but @lvica should look at bookmarks before MQ. MQ is hard. It's a real powertool, and it's falling out of favor now that phases (and soon obsolete) are here. Bookmarks on the other hand, are perfect for per-feature split-offs, where permanent named branches might be overkill.
-
daniel kullmann almost 12 years@Ry4an Yes, I forgot about them (because I've never used them). How do you handle the delete-after-merge with bookmarks?
-
Ry4an Brase almost 12 yearsYou just delete the bookmark with
hg bookmark --delete bookmark_name
. Lots of great info here: mercurial.selenic.com/wiki/Bookmarks -
Kevin over 9 yearsMQ is almost deprecated and shouldn't be a first resort.