Difference between revisions of "Using Mercurial"

From GeeklogWiki
Jump to: navigation, search
(Use a clean incoming repository)
Line 60: Line 60:
  
 
Since we're all new to Mercurial, this is something we will have to establish as we go along. For starters, the [http://www.selenic.com/mercurial/wiki/ Mercurial Wiki] has a page on [http://www.selenic.com/mercurial/wiki/index.cgi/WorkingPractices Working Practices] that we may want to adopt.
 
Since we're all new to Mercurial, this is something we will have to establish as we go along. For starters, the [http://www.selenic.com/mercurial/wiki/ Mercurial Wiki] has a page on [http://www.selenic.com/mercurial/wiki/index.cgi/WorkingPractices Working Practices] that we may want to adopt.
 +
 +
=== Use a clean incoming repository ===
 +
 +
Pull changes to a local "incoming" repository but don't work on that repository. Cloning that repository locally is a cheap operation and allows you to easily create multiple copies if necessary, e.g. when working on different features in parallel.
 +
 +
Push directly from you working repositories, then sync back by pulling the changes back down via your incoming repository.
 +
  
 
''(More tips and tricks to be added here)''
 
''(More tips and tricks to be added here)''
  
 
[[Category:Development]]
 
[[Category:Development]]

Revision as of 08:49, 23 July 2008

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.

Installing Mercurial

Installation instructions are provided for Windows, Mac OS X, and Linux

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.

Use a clean incoming repository

Pull changes to a local "incoming" repository but don't work on that repository. Cloning that repository locally is a cheap operation and allows you to easily create multiple copies if necessary, e.g. when working on different features in parallel.

Push directly from you working repositories, then sync back by pulling the changes back down via your incoming repository.


(More tips and tricks to be added here)