Mercurial on Windows

Last updated by Adam West on August 28, 2019 16:40

This page will guide you through the process of installing Mercurial (specifically, TortoiseHg) on a windows computer and get you ready to start using it with Codebase.

Installing TortoiseHg

To start with, you need to download the latest version of TortoiseHg and install it. The installation is completely straight-forward, just keep hitting "Next" until it has finished.

Once TortoiseHg is installed, right-click anywhere on the desktop, select "TortoiseHg" then "Global Settings".

You don't need to change any of the settings here, but just clicking "OK" will generate a file called mercurial.ini inside your user folder (C:\Documents and Settings\YourUserName on Windows XP) which is useful later when you want to use Codebase - when you create a new repository you will be told to Edit ~/.hgrc, instead just edit this mercurial.ini file using notepad.

Setting up SSH Keys

Generating SSH Keys is slightly more time-consuming on windows, but the best way to do it is download PuttyGen, run it and click "Generate" (you don't have to install anything).

To generate a unique key, PuttyGen needs you to move the mouse curser randomly over the area directly below the progress bar, so just do that and watch the progress bar fill all the way up.

When it's finished, it will have generated two keys: a Public Key and a Private Key. The Public Key (the one that it displays on the screen) is the one that you need to give to Codebase (just copy it from the screen then follow the instructions in the  Getting Started guide to paste it into your Codebase profile, to allow full access to any Hg repositories that you are assigned to).

The Private Key has to be be used by Mercurial to allow you to connect to Codebase. To do this, it must first be saved from PuttyGen to a sensible location (it doesn't matter where, just best to keep it where you know where it is). All you have to do to save it is click "Save private key", and hit "Yes" when it asks if you want to save without a passphrase. Now you need to choose a place to save it and give it a name such as rsa-private.

Once the key has been saved, browse to the installation folder of TortoiseHg (usually C:\Program Files\TortoiseHg) and run Pageant.exe, right-click on the new icon that appears next to the clock and select "Add Key".

In the dialog box that opens, find the Private Key that you saved earlier and open it.

That's it! You should now have successfully created your SSH key and, providing you gave it to Codebase, you should be able to use Mercurial.

Using Mercurial

Now it's installed, Mercurial will work the same way as it does on Linux or OS X. All you have to do is load Command Prompt (Load the Start menu, then click "Run", type cmd and hit enter), then you can use Mercurial commands as normal.