Version Control Systems: Mercurial

Forest Bond

Overview

Author:
Matt Mackall
Model:
distributed
Language:
Python / C
License:
GPL

History

Concept

Mercurial is a fully distributed version control system, like Bazaar-NG in some ways, but unlike it in a few ways.

User Interface

The primary Mercurial interface is the hg command-line utility:

User Interface (cont'd)

Data Management

Data Management (cont'd)

A RevLog is stored for each file object. This is an index file that points to the exact location of the data for each revision of the object. From a design document on the Mercurial wiki:

Advantages & Disadvantages

Advantages:

Disadvantages:

Advantages – Small Code Size

Mercurial is significantly smaller than comparable packages:

Package Language Lines Of Code
Mercurial (hg) 0.9.3 Python/C 20013
Monotone 0.31 C/C++ 63462
Bazaar-NG (bzr) 0.14 Python 63807
git 1.4.4.2 C with helper scripts 78233

Note: these numbers are mine. I tried to be as fair as possible.

Advantages – Cross-Platform

Mercurial should run on just about any system with a reasonably complete Python implementation. Binary packages are available from the Mercurial website for the following platforms:

Advantages & Disadvantages – Performance

From a page at Jst's Blog:

Operation bzr (0.12.0c1) hg (0.9) git (1.4.2.4)
diff (top level) 16.957 5.600 1.572
diff dom/ 10.596 2.240 0.140
diff dom/src/ 10.504 2.212 0.124
diff dom/src/base/ 10.468 2.212 0.124
diff dom/src/base/nsDOMClassInfo.cpp 10.472 2.084 0.116
diff dom/src/base/nsGlobalWindow.cpp 10.012 2.024 0.088
diff in dom/ 16.833 5.548 0.136
diff in dom/src/base/ 16.881 5.504 0.112

Advantages & Disadvantages – Performance

The (dated and somewhat anecdotal) evidence on the previous slide suggests that Mercurial is 3-5 times faster than Bazaar-NG and 5-25 times slower than git.

Conclusion

Mercurial is a (relatively) fast & light distributed version control system that suits a branch-merge, peer-to-peer workflow.