Hosting a Mercurial Server on IIS7
February 19, 2010 – 22:42
I’ve recently been playing with using IIS7 to host a Mercurial server. The process was not particularly complicated but involved lots of steps.
I decided to document the process that I went through. The guide can be found here.
13 Responses
[...] Using Mercurial with CodePlex and GitHub – Jeremy Skinner talks about the Mercurial Version Control system, reviewing its differences from GIT, and showing it in operation against GitHub and CodePlex repositories. Jeremy also has a guide to getting a Mercurial Server up and running on IIS7 located here: Technical Jargon » Hosting a Mercurial Server on IIS7 [...]
Also works with Mercurial 1.5 / Python 2.6.4
I’ve tried following your steps, but I’m getting some problems with the configuration. I’m getting this error:
HTTP Error 502.2 – Bad Gateway
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are “Traceback (most recent call last): File “C:\inetpub\wwwroot\hg\hgwebdir.cgi”, line 66, in application = hgwebdir(‘C:\inetpub\wwwroot\hg\hgweb.config’) File “mercurial\hgweb\hgwebdir_mod.pyc”, line 52, in __init__ File “mercurial\hgweb\hgwebdir_mod.pyc”, line 61, in refresh File “mercurial\ui.pyc”, line 38, in __init__ File “mercurial\demandimport.pyc”, line 75, in __getattribute__ File “mercurial\demandimport.pyc”, line 47, in _load File “mercurial\util.pyc”, line 550, in File “mercurial\demandimport.pyc”, line 85, in _demandimport File “mercurial\windows.pyc”, line 21, in File “mercurial\demandimport.pyc”, line 75, in __getattribute__ File “mercurial\demandimport.pyc”, line 47, in _load ImportError: DLL load failed: %1 is not a valid Win32 application. “.
when loading the hgwebdir.cgi script.
I’ve started with python 2.5.4, but I’ve went with Python 2.6.4 because 2.5.4 was always giving the bad magic number error while trying to load the cgi file. any ideas? thanks.
Strange…I haven’t seen that before. Which version of Mercurial are you running, and have you tried running hgwebdir.cgi through the command line python interpreter to see if it gives a more useful error?
Hello again Jeremy. Thanks for the quick reply.
I’ve managed to see what’s wrong: I was using the 64 bits version of python. I did install the x86 version when I tried python 2.5.4. However, I forgot about it when I tried using python 2.6.4 (btw, it seems like the last version of mercurial won’t work with python 2.5.4 since it gives the bad magic error message when loading the page on the browser).
thanks again.
Yes, that was an issue I ran into – you need to ensure that you use whichever version of Python that was used to compile mercurial. For v1.4.3 you need python 2.5, but for v1.5 you need python 2.6. I should probably update the guide to make this more clear.
Hello again Jeremy. Yes, I’d say that a small note about it would really be helpful for others
I am getting the same error as Luis did in the 3rd response on this thread. Has anyone figured out a cause/solution?
Nevermind, I reread and installed the proper version of python.
Hi,
I am getting the following error while loading the hgwebdir.cgi script
HTTP Error 502.2 – Bad Gateway
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are “Traceback (most recent call last): File “C:\inetpub\wwwroot\hg\hgwebdir.cgi”, line 67, in wsgicgi.launch(application) File “mercurial\hgweb\wsgicgi.pyc”, line 71, in launch File “mercurial\hgweb\hgwebdir_mod.pyc”, line 104, in __call__ File “mercurial\hgweb\hgwebdir_mod.pyc”, line 134, in run_wsgi File “mercurial\hgweb\hgwebdir_mod.pyc”, line 321, in templater File “mercurial\templater.pyc”, line 258, in stylemap RuntimeError: No hgweb templates found in [] “.
Pl.note that I have tried with Python 2.6.5 (32-bit) version
My system configuration: Mercurial-1.5.4 and IIS7.
Request you to provide inputs in resolving this issue.
Regards,
Dev
Dev,
Take a look at the last line in the stacktrace – the hgweb templates are missing.
Copying hgweb “templates” was missed earlier, it is working fine after copy.
Thanks, great article – been a bit of a nightmare getting it up and running and have gone through a number of outdated or incomplete articles already!
One major difference in recent versions of Mercurial, hgwebdir.cgi no longer exists and hgweb.cgi can now be configured to perform all functions. Everything in this tutorial works, just replace “hgwebdir.cgi” with “hgweb.cgi”
When editing hgweb.cgi it also looks a bit different to how you describe but it’s easy to work out.
All the hgweb.config options you listed seem to work anyway.
Thanks again for helping out