Monday, February 6, 2012

Mercurial (as of 2.1) Now Has Phases

In my last post I pondered (ranted?) on the reluctance of Mercurial people to edit repository history, especially as compared to git people. Today I noticed that Mercurial 2.1 has been released, and it has a new feature that makes editing your local repository much safer, phases (more detail here).

To me this looks like a really cool idea. Phases explicitly mark changesets as either public (have been pushed or pulled, and should not be edited) or draft (still local to your repository and can be freely edited). Changesets are given a phase automatically behind the scenes (though you can override this, of course), and history editing tools respect phases so that now it is even harder to shoot yourself in the foot when editing your repository history with tools like rebase or mq.

There is also one more phase, secret, that can be enabled for use with patches in your Mercurial Queues. Secret changesets will not be pushed, pulled, or cloned (or even show up in the output of incoming or outgoing). That's a nice touch too.

I wonder if git will ever pick this idea up? Git users seem to already be pretty comfortable with history editing procedures, but I have also read (old?) debates about when it is a good idea and when it is definitely a bad idea to use rebase with git repositories. It seems like phases could clear up confusion in the git world too.