Search code examples
mercurialhgweb

Mercurial hgweb using without CGI not working in IIS 6.0


I am trying to get Mercurial hgweb working using ISAPI following those two links http://blog.jaredreisinger.com and Vampire Basic. The server is a IIS 6.0 Windows server 2003.

On the same machine I had successfully got Mercurial hgweb running using CGI for TortoiseHG 1.0 as a experiment a year ago, but for some reasons when I tried to add TortoiseHG 1.9+ projects the repository website will broken, and seems like the .hg directory had quite different file structures for 1.0 and 1.9+, I think the simplest way is create new repository and web directory.

So this time after looking for more updated information for setting up Mercurial, I decided to take ISAPI route instead of CGI as it seems easier to setup and should be faster to run (not that it matter much for me).

But after following both articles step by step I always end up with error message in Chrome: "The system could not find the environment option that was entered." every first time after I restarted IIS, and then the message will changed to "Unspecified error" if I refresh the page.

If I view this page in IE, the error message will be "The website cannot display the page HTTP 500".

In both cases the error message are not very helpful and I really don't have any clue about what could be the problem. Don't know is there any way I could get more detailed log/debug information? Otherwise without enough information it would be hard for anyone trying to help me as well.

For my hgwebdir_wsgi.py I only changed this line:

# Configuration file location
hgweb_config = r'c:\Inetpub\HgWeb\hgweb.config'

and for my hgweb.config I am using the minimum config

[paths]
/ = I:\CompanyName\Development\SVCProjects\*

I am using Python 2.6.6, PyWin32 2.16 for Python 2.6, Mercurial 1.9 for Windows for Py2.6 and ISAPI_WSGI for Windows 0.42.

Edit: Looking at the IIS log, I got following lines:

2011-07-19 03:42:51 W3SVC1 127.0.0.1 GET /hg/hgwebdir.cgi - 443 pstar 127.0.0.1 Mozilla/5.0+(Windows+NT+5.2)+AppleWebKit/534.30+(KHTML,+like+Gecko)+Chrome/12.0.742.122+Safari/534.30 500 0 203 333 435

2011-07-19 03:42:51 W3SVC1 127.0.0.1 GET /favicon.ico - 443 - 127.0.0.1 Mozilla/5.0+(Windows+NT+5.2)+AppleWebKit/534.30+(KHTML,+like+Gecko)+Chrome/12.0.742.122+Safari/534.30 404 0 2 1830 358

So looks like IIS is still trying to use hgwebdir.cgi which I already removed, don't know how to fix that.


Solution

  • I find out the reason by using "python -m win32traceutil" (got this from hgwebdir_wsgi.py source code comments). Basically it failed to load module 'hgwebdir_wsgi'. The reason is Mercurial Python module 1.9 was not installed properly using win32 installer. I tried method from here another SO question solution except I didn't copy MFC71.dll, and that does not work for me. Finally I found this link issue2582, and following the temporary solution by downloading an unofficial build of Mercurial Python win32 installer and it works.