I do not understand your question, since you switch branches (without quotes), even if they are not called branches, they are still branches when you use bookmarks.
The error you had was an honest mistake, and I donβt see Mercurial protecting you from this again with bookmarks (marking the same turn with different bookmarks and making the wrong settings). However, I can tell you how to do private local branching with Mercurial , and that way you can avoid the consequences you just had:
You use named branches and phases
Mercurial Phases are really sweet, let me explain them very quickly. You can note changes in three special states called phases, and these are secret, draft, and public.
- a secret . Do not click. It can be changed by editing the story.
- draft : click. It can be changed by editing the story. This is the default state for any version.
- public : click. Throws a warning when using extensions for editing history (strip, rebase, histedit, ...).
As already mentioned, all local versions of the default draft, when you click them, become public . You can use the hg phase command to mark changes for a specific phase, but if you go from # 3 to # 2 or from # 2 to # 1 (according to the previous numbering), you need the -f argument to force this change:
secret β draft β public
To go left, you need to use --force or -f.
Here is what you do:
hg branch experiment hg commit -m "Opening experimental branch" //say this creates revision 123 hg phase -sf tip //s is for secret, f is for force //... hack hack hack hg commit -m "Uh oh screwed up here" hg push //no secret revisions are pushed
Now you can simply abandon this branch and leave it that way, it will never be forced. Forget about it and even just close it so that it does not bother you when you list your branches. He will not push, he will not be on the list, so just do not worry about it.
However, if you have an OCD, just split the ( hg strip ) branch into a commit where the branch was opened and it disappeared:
hg strip 123
If you already have a branch, you can change several of these changes several times:
hg phase <start revision>::<end revision> -sf
To make your secret project or publish it, just follow the last revision phase of these steps:
hg phase -d tip
Then click and the branch will become public.
Mercurial is increasingly getting better at modifying a story without changing its overall philosophy that prevents it. Phases are designed to protect against accidental modification of a story, as well as from sharing what you do not mean.
How * i * use bookmarks
Personally, I use bookmarks for debugging and when I want to try two different ways to do one. Bookmarks are useful to me when you want to make anonymous branches (update the previous revision, fix and fork history), but want everything to be clear.