Mercurial 2.2.1 on Windows Server 2003 x64

This is a quick run-through of how I installed Mercurial 2.2.1 on Windows Server 2003 64-bit edition and used IIS 6.0 to serve the repositories.

Install Python 2.6.6 with Windows X86-64 MSI Installer (2.6.6) found here.

Install Mercurial 2.2.1 with Mercurial 2.2.1 Python 2.6 package – x64 Windows and Mercurial 2.2.1 MSI installer – x64 Windows, both found here. The former of these installs Mercurial native for Python which we need for the web. The other one installs the command line tools necessary for managing repositories.

Create a directory to hold the repositories. I chose C:\Repositories. Create another directory to hold the files IIS will use to serve the repositories. This should be separate from the repositories themselves. I chose C:\Mercurial\Website. Create a new file in that directory named hgweb.cgi with the following content:

config = "C:\\Mercurial\\Website\\hgweb.config"
import cgitb; cgitb.enable()

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)

Create another file in the same directory called hgweb.config with the following content:

Test = C:\Repositories\Test
Main = C:\Repositories\Main
style = monoblue

Adjust the paths and names for your repositories. You should also create hgrc files within each repository to configure access. You can chose another style if you want to.

IIS Configuration

Now that all files are in place it is time to set up IIS with the help of the IIS Manager. Create a new virtual directory under the default web site. Call it hg and point it to the directory with the hgweb files (C:\Mercurial\Website in my case).

Open the properties for the new virtual directory and go to the Virtual Directory tab. It should look like this:

Click the Configuration button then click Add in the new window. Enter the following:

Executable: "C:\Program Files\Python\python.exe" -u "%s %s"
Extension: .cgi

Click OK on all windows. Back in the IIS Manager right click Web Service Extension and add a new web service extension. Give the extension the name Python and add the following as required files:

C:\Program Files\Python\python.exe
C:\Program Files\Python\python.exe -u "%s %s"

You should now be able to browse the repositories on http://servername/hg/hgweb.cgi and be able to clone the repositories from http://servername/hg/hgweb.cgi/Test (for example).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s