Book review: Mercurial – The Definitive Guide

Thre is two ways of getting this book: the electronic one or the paper one. If you plan of using Mercurial, the paper may be better suited.

Mercurial (also called hg as the Mendeleiev symbol for mercurial) is one of the three DVCS (Distributed Version Control System) that are in the mood nowadays. Written in Python, its life started at the time as git’s when BitKepper was dumped as the Linux kernel’s VCS. Now it is a mature product, and the book tries to explain how to use it and also the differences with Git. Bazaar, the third DVCS, is not even mentionned, although it is also written in Python.

Content and opinions

The book starts with a small introduction to revision control, and then gets to the basics of version control with Mercurial. This chapter and the following one really are the only things to fully master before starting with hg. With them, you can track your changes, send them to other repositories, …, and the third chapter helps you merging different changes together. In this case, you may encounter some small “glitches” of Mercurial, and the book explains them correctly.

The remainign of the book is more dedicated to small additions that can make your life better. For instance, the fourth chapter is about the efficient repository storage. If a repository with Subversion could get really big, Mercurial keeps things small and doesn’t use garbage collectors like Git. The next chapter that was interesting was the eigth (the other deal with daily use, that is, copy, rename, …, web servers, selecting several files through regexp). It deals with organizing the branches and giving names to revisions. I think it could have deserved a better place, as I find the last three chapters of less interest (in fact, other book on DVCS deal with the web server part at the end, so I think it’s not just me).

The next chapter is about fixing some mistakes you may make. Mercurial has some useful tools, and there is also the bisect command. I had to use it several times, and it is really efficient. Some tips are given to help using this command efficiently, and it may be the most important topic in this chapter. Reverting or “removing” a commit (they are never really removed, they will stay in a hidden branch of some sort) can help sorting a situation, but you shouldn’t use it anyway. The book should have big red/orange warnings in this chapter (which is obviously has not). An important part of VCS is everything related to automation with hooks. Mercurial delivers several places where you can launch your scripts (for instance to update your web site), and the book has a good tutorial on how to write simple hooks.

Another not so important part is how you can customize Mercurial’s output. Interesting, but not that much. A topic that helped Mercurial gaining momentum is MQ (Management Queues). I don’t have the need myself, so the two chapters on that subject were a little bit boring. Besides, to use MQ, you have to set up another repository inside the hidden folder of Mercurial, which is not as efficient as having the queues directly inside the first repository. A good point is that it shows that extensions can really change the way Mercurial can be used (which is the subject of the last chapter).


All things considered, the book managed browsing through the capabilities of Mercurial. The contents may not be organized in the best way, but one can still find what it needs, and even more. If you want to use a DVCS, try Mercurial with this book, you won’t be disappointed (by neither of them).

Leave a Reply