How do I set up Mercurial and hgweb on IIS? How do I set up Mercurial and hgweb on IIS? windows windows

How do I set up Mercurial and hgweb on IIS?


I just had to install a fresh Mercurial instance yesterday, here's updated instructions for 1.7:

  1. Install Mercurial (these instructions were tested with 1.7)
  2. Install Python (for Mercurial 1.7, you must use the x86 version of Python 2.6.6)
  3. You will need to download the hgweb.cgi file from the Mercurial source. You can download the source by running: hg clone https://www.mercurial-scm.org/repo/hg/
  4. Create a folder that will be your web application folder. You will need to copy three things into this folder:

    • The hgweb.cgi file
    • The contents of the Library.zip from your "C:\Program Files\Mercurial" folder
    • The Templates folder from your "C:\Program Files\Mercurial"
  5. You will need to make sure you have Python set up in IIS.

    • Enable CGI via the following: Control Panel -> Turn Windows Features On or Off -> Roles -> Web Server (IIS) -> Add Role Services -> Check CGI
    • Create a new Web Site in IIS and make sure the physical path is the folder you created above
    • In the Handler Mappings for the new website, select "Add Script Map". Enter *.cgi for the request path, c:\Python26\python.exe -u "%s" for the Executable, and Python for the Name.
  6. You will also need to create a file named "hgweb.config" with contents similar to below. The path within the file needs to be the location on your drive where you want to store the Mercurial repositories:

    [collections]
    c:\Mercurial\repos = c:\Mercurial\repos

  7. Edit the hgweb.cgi file and change the line where it sets the path to your hgweb.config to something like the following (wherever the hgweb.config file is):

    config = "C:\Mercurial\hgweb.config"

  8. Now, open a browser and navigate to http://localhost/mercurial/hgweb.cgi (or whatever is the appropriate URL path you set up in IIS) and you should see the Mercurial Repositories page.

Also, check out Jeremy Skinners blog post . It's a little outdated, but has some extra nice steps like setting up URL re-writing for cleaner URL's.


It seems since Mercurial 1.5.2 was released, these tutorials don't work exactly right. For one thing, hgwebdir.cgi has been removed, and is now replaced with hgweb.cgi.

The instructions that worked best for me is at eworldui.net:

http://www.eworldui.net/blog/post/2010/04/08/Setting-up-Mercurial-server-in-IIS7-using-a-ISAPI-module.aspx

Those instructions are meant for IIS 7 or greater. If you're setting this up on IIS 6, I wrote up similar instructions geared toward Win2k3 and IIS 6.0:

http://partialclass.blogspot.com/2010/05/setting-up-mercurial-server-on-win2k3.html

UPDATE: Shortly after getting this working I learned that BitBucket changed their pricing scheme to offer free, unlimited, private hosting: https://bitbucket.org/. I would've opted for that in a heartbeat when I was originally working on this project.


I found that the blog post at Vampire Basic was a good start, but it didn't go into nearly enough detail for what I was after.

I did a 4 part blog post on this that gets you up and running from scratch with IIS, including Active Directory integration, setting up of security privileges for push/pull, customization of the template, I'd reproduce it here, but it's quite long winded being that Mercurial was really designed to be hosted on Linux/Apache:

http://www.endswithsaurus.com/2010/05/setting-up-and-configuring-mercurial-in.html