Tuesday, October 02, 2007

Mercurial - not "hg"

After a long debate over this list, we decided to use Mercurial as the new revision control system.

Personally, I ignored hunting for better revision control systems for a long time in the past. CVS is my choice since I started using revision control, although CVS has been criticized for many things, such as bad support for binary files, complicated structure, no atomic commit and so on so forth. However, you know, people just don't want to change, which is bad though.

Mercurial gave me fresh air and I couldn't help go through it manual. It is cool!

First thing first, Mercurial is distributed, which means there is essentially no "centralized" repository. Everyone can have local repository and do development on it. You can freely create tags, branches, unstable commits, even "push" their temporary changes to other people without polluting the main repository. After everything is done and tested, they "push" their changes into the main repository. This is extremely convenient for distributed development.

Mercurial is easy. It is easy to learn and have a clear structure. I especially love the idea of changeset, which is for both identification and integrity.

Mercurial is fast. It's key part is written in C, though most of it is written by Python. It borrows the idea of I, P frames from video compression. For each revision, it saves the delta data instead of a complete copy of a file, for saving space. After a period of time, it takes a snapshot to make retrieval fast. It also use "copy-on-write" to save space from cloning repository.

Mercurial makes commit atomic. It actually uses a simple trick to achieve this. All writes follow the order of writing real file changes, manifest data and finally change log. So there will never be a change log which contains partial manifest data or file changes.

Mercurial has a queue. MQ is a powerful extension of Mercurial for solving the patch management problems. It over-performs previous tools since MQ knows revisions.

To sum up, Mercurial looks very powerful and nature. If you are still using CVS, try Mercurial and you're gonna like it.

For those who are new to Mercurial, I would recommend "Distributed revision control with Mercurial" as your first read.

No comments: