Mercurial is my first serious foray into distributed version control systems (dvcs). When I started gathering my notes for this entry I knew that this would be a really negative review of Mercurial. The first version control system I actually liked was Perforce. Several years later I encountered Subversion, it took a while to adjust but eventually I grew really fond of it. For the past 3 months, I’ve been using Mercurial… definitely not impressed. Or so I thought, but as I looked through my cons, I saw pros all over the place. So here are my [not-so-negative-after-all] thoughts on using Mercurial!
As background, the setup I’m working with uses BitBucket as a central repository.
Con: When I clone the repository, I get the whole repository. I don’t need the whole repository. The project I work on is growing, there are lots of files, and I just don’t want or need all of them. Old images that aren’t used any more, get downloaded to my machine. Files that were created and deleted long before I ever joined the project, get downloaded to my machine. Developers discuss whether to push large files to the system or not, because they don’t want them to get downloaded to their machines. It’s a pain!
Pro: or… at least I thought it was a pain. Waiting half an hour for that initial clone is a pain, but I really appreciated having access to the entire repository one day when I had no internet access. I could easily look up the changes made, and to be honest, it was great having the history on files that were long removed. That’s the point right, that you can delete instead of commenting out because you have access to the entire history in the version control system. I had that access in a car without internet. It was great!
Con: Mercurial is so good at merging. This is one huge selling point for Mercurial, but it just annoyed me. Of course Mercurial has to be good at merging.. since it’s merging all the time. A good 75% of my commits are merges. All I want to do is to push my changes, but I can’t, because I need to merge!! Aaaargh!
Pro: Well… Mercurial is good at merging! When I do change a file that someone else has also changed, it’s a much simpler process to merge and resolve conflicts in Mercurial, what would have taken quite a while in Subversion, ends up being a piece of cake 🙂 And to be honest, the extra step of auto-merging after an update and pull is painless since it usually doesn’t fail.
Pushing partial changes
Con: I can’t push if I have uncommitted files, and I can’t just push some of my commits but not others!! Sometimes, you have to make a quick change that has nothing to do with what you’re working on. You notice that there’s a spelling mistake, or you want to push formatting fixes to a file so you can keep working in it, but you can’t, because you have other uncommitted changes. It’s a pain!
Pro: Well, I actually really like the ideology behind this feature. Really, how do you know if the partial code you want to push actually works without all the other changes you’ve made. Of course it makes sense that you can only push everything. You should have tested the exact configuration that you now want to force on everyone else. How can you not like this feature?! Gone are the days of forgetting to add a file to subversion, committing and only realizing that you forgot the file when the CI build lets you know. Now you know. And if you just want to make a one-off change, it’s pretty easy to make a local clone from your repository, and just push that one little change. So it’s a couple of more steps, but it’s worth knowing that you aren’t accidentally breaking the build.
Con: Working with branches and tags is a pain! The BitBucket view is not good at showing you the history for a branch, you definitely have to use a different tool. The tags are not “intuitive”, the whole process is frustrating..
Pro: Get over it, I don’t even work with branches that often, and don’t particularly care for them, not sure how this made my con list to begin with!! This is one area where the cons were just a matter of letting go of my Subversion idea of tags and branches. Once you understand how tags and branches work in Mercurial, the whole thing is pretty easy and painless. Moving between branches in particular is so conveniently easy! hg up [branch-name], what’s not to love?
Plugins and tools
Con: Lack of plugin support in IntelliJ. I miss seeing incoming changes in the changes tab. I miss being able to easily see all changes made in a changelist. I also get annoyed at having to see the three separate commits one person made as part of the single bigger push. Sometimes it’s interesting to see the different steps that the person took, but really I mostly just want to see the difference between the original file and the final commit.
Pro: You know, this is one con that I can’t find a pro for. I’ve tried different tools (MacHG) is currently my favorite, but support is still far from perfect. I’ve gotten used to the BitBucket web UI and can get the information I want, but I’m still on the look out for a better solution here.
So, while I still can’t say that I love Mercurial, I definitely don’t hate it, and after writing up this post I can honestly say that I like it.
Anyone else out there making the transition to Mercurial? What about other dvcs?
p.s. A good resource for learning about Mercurial is Brian O’Sullivan’s book “Mercurial: The Definitive Guide”