This week I have been looking at revision control systems. I currently use Darcs and I am very happy with it, but I’m also interested in Monotone because it has an integrity assurance that I like (backed by cryptographic signatures). So I set out to choose a revicion control system. My basic criteria are simple:
- It has to be open source.
- It has to be easy to understand, and easy to use.
The latter requirement automatically limits the search to distributed revision control systems. I have no desire to setup a CVS or Subversion sever (if my web host even allows it). I don’t want to depend on a network connection to be able to commit. I want easy branches, so if I’m going to work on a large new feature I can develop it in a new branch without affecting my main work.
I searched a little and a lot of people say that Git is very complicated and poorly documented. So I won’t bother with Git either. This leaves four options: Darcs, Monotone, Mercurial and Bazaar.
Darcs is my current RCS and it is very good. It really stands out for how well it can handle patches. With Darcs you can apply make change A, then B, then C, then D, then E, and then you decide that you don’t like B after all. You can remove B without affecting C,D and E. I don’t think any other RCS can do that.
I actually use this feature often. I might be working on a Feature A and then an issue comes up (Issue B) that requires immediate attention. I can commit my incomplete work for Feature A, work on B, commit B, and then uncommit A and continue working as I was before.
Another feature of Darcs is that when you commit you can select individual changes inside a given file that you want to commit. In other words, if you change two lines in the same file, you can tell darcs to include the first line in the changeset but not the second. AFAIK Darcs is the only revision control system that has this feature.
Monotone looks very easy to use. It doesn’t have Darcs’ brilliant patch management (no one does) but it has very easy branches and easy merging between branches. You can even have two separate sets of changes on the same branch and merge them later. This is great for simple changes. It works like this:
- I’m working on feature A and haven’t committed yet.
- A customer reports a bug B that’s easy to fix.
- I make a new directory called BugB/ and I checkout the branch.
- I fix bug B, commit and upload the fix to the server.
- I can delete the directory BugB/ because the changes are stored in the Monotone database.
- When I finish feature A I commit and then run ‘mtn merge’. Now this directory has both feature A and bugfix B.
What makes Monotone stand out is that it can assure data integrity. It can ensure that you files have not been corrupted or tampered. Every change is hashed with SHA1 and digitally signed with an RSA key. And Mtn makes this process very easy. When you setup Mtn you generate a key (which takes 2 seconds) and from then on all your changes are digitally signed without your having to think about it.
I am less familiar with Mercurial. A lot of major projects use it (e.g. Mozilla) so it must be good. Like Monotone, changesets are hashed with SHA1, but Mercurial doesn’t seem to use digital signatures like Monotone does. So, while Mercurial can give you assurance against accidental corruption, it may not protect as well against intentional tampering.
One feature I really like about Mercurial is the ability to push changes to a server through SSH without installing anything else on the server. This makes it easier to keep the server updated and be confident that you didn’t forget to upload any files that have changed. Mercurial also ensures that no file is partially updated. Either the entire changeset is applied or none of it is. So the server won’t be left in an inconsistent state.
hg push ssh://email@example.com/public_html/main
Monotone can do something similar, but it requires that you run monotone on the remote server (not as a server process though) and not all web hosts allow that. Darcs also has this feature, and like Mercurial, it does not require running Darcs on the server.
- Bazaar also looks very easy to use, but I know even less about it than I do about Mercurial. But as far as I can tell, it has broadly the same features and abiliies. I believe that Mozilla chose Mercurial over Bazaar because Mercurial was faster.