Hacker News new | ask | show | jobs
by pacemkr 5632 days ago
I've been using Mercurial for a few years and am now turning to git (one week in, so I won't say much about it) for a very specific and fundamental reason: short lived local branches.

Say you have a repository, fix a few bugs on it, and now you want to work on a crazy feature. What you need is a short lived local branch, because you don't know if crazy feature even makes sense. Unfortunately, there is no built in way to do this in hg. [1] Deleting a branch is not a fundamental concept in hg, and so the advice is to create a new local "clone" of the entire repo. [2] Great, now you have to change the config files for your dev environment to point to a new folder just so you can test out crazy feature. Also, by default all your branches get pushed (although hg will complain about creating remote branches).

In practice, all this turned "branching" into an expensive concept in my mind. That's bad, very bad.

I still prefer the hg elegance and ui to git -- even the output of "hg st" vs "git status" tells a great deal about the philosophy behind both. However, I think hg got branching wrong and that is a fundamental flaw that no amount of elegance at the UI level can compensate for.

I remember when I was making my first choice between hg and git and the advice was "they're pretty much the same, pick one." I think that advice is incorrect based on what I've said above.

[1] http://mercurial.selenic.com/wiki/LocalbranchExtension [2] http://mercurial.selenic.com/wiki/PruningDeadBranches

3 comments

I use patch queue[1] to manage these short lived branch, and it works for my purpose. You just pop the patches and delete them all when you want to prunge the branch. It also make it easy for others to review your code.

If these short-lived branch will be merged back shortly. Bookmark is another alternatives.

[1] http://mercurial.selenic.com/wiki/MqExtension [2] http://mercurial.selenic.com/wiki/BookmarksExtension

I'm aware of both. Personally I find this to be an inferior solution. Using a patch queue as a local branch just feels wrong. Neither is using bookmarks an effective solution. Both solution make the decision to branch a much more deliberate process, and in the end you still don't get a branch that is equal to its peers.

As the result, in hg, you have to decide in advance "what kind of branch" it will be -- or you have to get in the habit of using mq's for everything -- and this just not a natural experience especially for a DVCS where branching is just fundamental.

I love Mercurial, but I agree with this. I tried using the bookmarks extension with a colleague who wanted to use branches this way and we had trouble figuring it out. Definitely not as easy as git (though getting new remote branches with git is another thing that drives me crazy and I have to look up every time).

git stash is another thing I really like about git. There are hg alternatives but they are not as easy to use (and if you go the mq route things become so complicated you might as well just use git).

Mercurial bookmarks are roughly equivalent to Git branches. They are local only unless you explicitly push them and you can delete them when done.