These instructions are based on a Windows 2008 R2 Datacentre install, with IIS7 already installed and setup. The server is 64bit, but I’m using the 32 bit versions of all the installers.
- Install Python 2.6.6. Using the MSI and default settings.
- Install Mercurial 2.2.1 (32 bit exe).
- Install Mercurial 2.2.1 (32 bit py2.6).Ensure you are using the py2.6 version, marked as “recommended for hgweb setups”. This installs the mercurial source as python scripts.
- Ensure CGI and Basic Authentication are installed for IIS. You can check this in Server Manager. If either are listed as “Not Installed” click “Add Role Services”. Click “Next”, then “Install” to complete the installation.
- Create a new site in IIS. This could be a virtual directory, but I prefer to have a separate site running off an arbitrary port (8989 in this case). Remember to add any additional firewall rules.
- As the site will be using Basic Authentication, it’s also a good idea to force it to run under SSL, even if it is only using a self signed certificate.
- Change the authentication options for the site to disable “Anonymous Authentication” and enable “Basic Authentication”. This will require all visitors to login before being able to use repositories.
- Enable Python for IIS. Select “Handler Mappings” for your site, and then “Add Script Map”.Enter the following values:
Request path: *.cgi
Executable: C:\Python26\python.exe -u “%s”
Click OK, When prompted select “Yes”.
- Copy the “Templates” folder, and the “library.zip” file from “C:\Program Files (x86)\Mercurial” to the website root.
- Get a copy of the hgweb.cgi file from the Mercurial Repository, and copy it to the website root.
- Create a new file named “hgweb.config”, leave this empty for now. Update the config variable in “hgweb.cgi” to point to this new file, for example:config = “C:\Mercurial\Website\hgweb.config”
- Visit https://your-site.co.uk:8989/hgweb.cgi, you should be prompted to login (with windows credentials from the server) and then see a page titled “Mercurial Repositories” with no repositories listed.
- Make a folder to contain your repositories, and make a new repository using the hg command line:hg init C:\Mercurial\Repositories\test
- Edit the “hgweb.config” file you created earlier, entering the following content:
C:\Mercurial\Repositories = C:\Mercurial\Repositories[web]
allow_push = *
push_ssl = trueN.B. The collections file path is case sensitive
- Reload the page, you should now see your “test” repository listed
The repository is now ready to use! As a self signed SSL certificate is used you will need to ensure you enable “insecure” mode when using hg/TortoiseHg.