Killer Web Development

by Marco Laspe

2.3 Version control with Mercurial

From now we will put our code under version_control. Version control system help us to track changes of our code, help us to collaborate and revert to any errors (like deleted files). Using version control is considered good practices and is exspected by any serious software developer.

There different options for version control systems; we will use Mercurial because it's the standard in the Python and web2py world and it's very user friendly.

To install Mercurial in Ubuntu:

$ sudo apt-get install mercurial

On Windows install the TortoiseHg version of Mercurial. It is probably the easiest way to install Mercurial on Windows systems.

On Macs install the Mercurial version from Lee Cantey.

For more information on installing Mercurial see Mercurial: The Definitive Guide by Bryan O'Sullivan - Chapter 4.

First time setup

After installing Mercurial you need to put a text-file called .hgrc in your home directory, (On Windows your home directory is one above the "My Documents" directory.) Fire up gedit and put the following content in it:

username = Your Name <>
editor = gedit

What does it do? The .hgrc file does set an editor für your commit messages (we get to this later) and your username. If you are collaborating with others on a project the username tells Mercurial who made changes to the project and is responsible for that part of code.

Now you should be set. In the next chapter we will actually develop the pitch application.

Books often read by web2py and Python experts:


  1. A great guide to Mercurial that a friend showed me:

Leave a Reply

Required fields are marked *.