outten.net - random thoughts

Mercurial - Distributed Revision Control

Recently, I have tried several other version control systems to see what they were like as opposed to the normal one. After trying these, I have come to like Mercurial (or “hg” from the command line). It is a distributed revision control application. Why would I be interested especially when there is subversion? Let’s take a quick look.

I have a scripts directory that is in “~/.bin”. I wanted to version all the files in that directory and back them up somewhere. Here is what I did:

  $ cd ~/.bin
  $ hg init                # initialize the repository
  $ hg add .               # add all of the files in the current directory
  $ hg commit              # commit the file to hg

Now if I change any file, I can run hg status or hg diff with similar results as svn. Once I am done, I just run hg commit to update the local repository.

What about backing up the files?

  $ hg push ssh://someothercomputer.cam/backup_bin  # push the repository to a server

Pretty easy. No svn import and then checkout. Visit the site or read the book to see the other powerful features.