Lyubomyr Shaydariv
Lyubomyr Shaydariv

Reputation: 21105

How do I drop a Mercurial bookmark with all its changesets?

I use Git at work because Git is the team's choice. However, I prefer Mercurial for my personal projects. It's not a secret that Git and Mercurial branching models differ, and bookmarks in Mercurial are like branches in Git. I really like Git branches and use Mercurial branches rarely, just when I really need it, preferring Mercurial bookmarks. However, I miss something like git branch -d in Mercurial, because deleting a bookmark in Mercurial removes the bookmark only and preserves the immutable history. Is it possible to drop a bookmark in Mercurial with all of its changesets to the changeset where the bookmark has been diverged from?

Upvotes: 0

Views: 105

Answers (1)

Kevin
Kevin

Reputation: 30151

In general:

hg strip revisions_to_drop

For your problem:

hg strip 'not ancestors(heads(all()) - bookmark(name_of_bookmark))'

(i.e. "strip all revisions which are not ancestors of heads other than the bookmarked head")

Assuming a sufficiently recent version of hg:

hg strip -B name_of_bookmark

Upvotes: 2

Related Questions