Saturday, January 23, 2010

Mercurial on IIS 5.1 (XP) in 12 easy steps

Yes, I know W7 is out, but some of us are still using XP for some things.

With the upsurge in the use of Mercurial for version control (Even Codeplex is using it), I thought it was time to give it a try. It will take some getting used to, but a distributed VCS should fit my development style well. I carry an external drive between home and work. Right now it holds my latest code. I have to remember to commit the changes occasionally and don't always do so in a timely manner. Also, if I want to go back to an earlier version, I have to do it at work (instead of my home office when I really need it)

There are several pages showing how you can install Mercurial or HG, but my searching found none showing a straightforward "get it done set" of directions. Here's my instruction book. I've done this several times and found no issue. If you find a difference in your install, please let me know.

On with the show:
1. Install Python 2.5 - don't argue. don't resist. Mercurial is built with 2.5. Anything else WILL break it. (

2. Download and install Mercurial ( (Select the Windows installer)

3. Clone the Mercurial repository - you'll need some of the source code
hg clone

Create a folder to hold all the mercurial scripts
mkdir c:\hg_iis

5. Create a folder to hold your repositories (mkdir c:\hg_repos)

6. Create a virtual folder in IIS
  • Name it HG
  • Local path = c:\hg_iis
  • Execute permissions = Scripts and Executables
  • Click the configuration button
  • Click on the mappings tab
  • click the add button
  • In the Executable field enter c:\Python25\python.exe -u "%s"
  • In the Extension field enter .cgi
  • Under Verbs select All Verbs
  • Check Script engine
  • DO NOT Check Check that file exists
  • Click OK
  • Click OK
  • Click OK

7. copy the web page script to your IIS directory
copy c:\hg\hgwebdir.cgi c:\hg_iis

8. Change directories c:\program files\mercurial and unzip the file to c:\hg_iis. If you have problems with the .zip file download and run unzip.exe from ( as pointed to by Selenic's site)

9. Copy the templates
copy C:\Program Files\Mercurial\Templates c:\hg_iis\Templates

10. In a text editor open hgwebdir.cgi and edit the last few lines

application = hgwebdir('hgweb.config')

import os
os.environ["SCRIPT_NAME"] = '/hg/hgwebdir.cgi'
os.environ["REQUEST_URI"] = os.environ["SCRIPT_NAME"]

if os.environ.has_key("PATH_INFO"):
os.environ["REQUEST_URI"] += os.environ["PATH_INFO"]
if os.environ.has_key("QUERY_STRING"):
os.environ["REQUEST_URI"] += "?" + os.environ["QUERY_STRING"]

application = hgwebdir('hgweb.config')

(indentation is important)

11. In a text editor edit or create the file hgweb.config
# Mercurial web interface config file
# To add a repository to be published, add an entry here for it.

/ = /HG_Repos/**

style = coal

12. Now, open a browser and navigate to http://localhost/hg/hgwebdir.cgi

13. (optional) Download and install TortoiseHG

No comments:

Post a Comment