Using Mercurial

From GeeklogWiki
Revision as of 08:13, 18 June 2008 by Dirk (talk | contribs) (Started page on Mercurial)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

Mercurial is a distributed version control system (DVCS). The differences to a "traditional" centralized VCS (like CVS or Subversion) include:

  • Users get a self-contained repository that they can commit changes to, even when being offline.
  • Changes can be pushed back to the parent repository or even to other repositories.

As an experiment, we are going to use Mercurial during the 2008 Google Summer of Code. The distributed model fits this scenario nicely, as each of our students will work on a separate feature. So now they have a local repository to check in to (giving them all the benefits of a version control system). Once a feature or part of a feature is done, it can be pushed back to the parent repository. And in the meantime, it's easy to let other people, e.g. their mentor or interested members of the Geeklog community, pull the changes from the student's repository to show things off or get help on a problem.


Setup

Geeklog's Mercurial repository is available from this URL:

http://project.geeklog.net/cgi-bin/hgweb.cgi

This repository was converted from the CVS repository right after the release of Geeklog 1.5.0.

To create a copy of that repository, simply do

hg clone http://project.geeklog.net/cgi-bin/hgweb.cgi geeklog

Where "geeklog" is just a directory name for the local copy (and can be changed at will). This will give you a fully working local repository that you can commit changes to.

SSH Setup

For ssh access, you need an account on the server. So this is only of interest for the core developers and SoC students.

The repository can also be checked out via ssh. Since Mercurial is currently only installed in a user's directory on the server, this requires the following entry in your local(!) ~/.hgrc file:

[ui]
remotecmd = /usr/home/geeklog2/hg/mercurial/hg

Now you should be able to clone the repository like so:

hg clone ssh://username@cvs.geeklog.net//cvsroot/geeklog/Geeklog-SoC geeklog

Where "username" is your login name and the "geeklog" at the end of the command line is again simply a name for your local directory.

Please note the slightly odd path syntax with the two slashes after cvs.geeklog.net - those are required.


Pushing back

Being able to push changes back to the repository again requires an account on the server. You can either do

hg push ssh://username@cvs.geeklog.net//cvsroot/geeklog/Geeklog-SoC

or, to make your life easier, set the default-push repository in the .hg/hgrc file of your local repository like so:

default-push = ssh://username@cvs.geeklog.net//cvsroot/geeklog/Geeklog-SoC

(Again, in the ssh: URLs above, replace "username" with your login name)


Best practices

Since we're all new to Mercurial, this is something we will have to establish as we go along. For starters, the Mercurial Wiki has a page on Working Practices that we may want to adopt.

(More tips and tricks to be added here)