Hosting Mercurial on IIS7

Posted by Lasse V. Karlsen on Stack Overflow See other posts from Stack Overflow or by Lasse V. Karlsen
Published on 2010-05-19T18:42:56Z Indexed on 2010/05/19 19:30 UTC
Read the original article Hit count: 645

Filed under:
|
|

Note, this might perhaps be best suited on serverfault.com, but since it is about hosting a programmer source code repository, I am not entirely sure. I'm posting here first, trusting that it'll be migrated if necessary.

I'm attempting to host clones of my Mercurial repositories on my own server (I have the main repo somewhere else), and I'm attempting to set up Mercurial under IIS.

I followed the guide here, but I get an error message.

Solved: See bottom of this question for details.

The error message is:

mercurial.error.RepoError: repository /path/to/repo/or/config not found

Here's what I did.

  1. I installed Mercurial 1.5.2
  2. I created c:\inetpub\hg
  3. I downloaded the hg source as per the instructions of the webpage, and copied the hgweb.cgi file into c:\inetpub\hg (note, the webpage says hgwebdir.cgi, but this particular file does not exist, hgweb.cgi does, however, can this be the source of the problem?)
  4. I added a hgweb.config, with the following contents:

    [paths]
    repo1 = C:/hg/**
    [web]
    style = monoblue
    
  5. I created c:\hg, created a sub-directory test, and created a repository inside it

  6. I installed python 2.6.5, latest 2.6 version from the website (the webpage mentions I need to install the correct version or I'll get a specific error message, since I don't get an error message that looks remotely like the one mentioned, I assume that 2.6.5 is not the problem)
  7. I added a new virtual host hg.vkarlsen.no, pointing it to c:\inetpub\hg
  8. For this host, I added a script mapping under the Handler Mappings section, mapping *.cgi to c:\python26\python.exe -u %s %s as per the instructions on the website.

I then tested it by navigating to http://hg.vkarlsen.no/hgweb.cgi, but I get an error message.

To make it easier to test, I dropped to a command prompt, navigated to c:\inetpub\hg, and executed the following command (error message is part of the text below):

C:\inetpub\hg>c:\python26\python.exe -u hgweb.cgi
Traceback (most recent call last):
  File "hgweb.cgi", line 16, in <module>
    application = hgweb(config)
  File "mercurial\hgweb\__init__.pyc", line 12, in hgweb

  File "mercurial\hgweb\hgweb_mod.pyc", line 30, in __init__

  File "mercurial\hg.pyc", line 82, in repository

  File "mercurial\localrepo.pyc", line 2221, in instance

  File "mercurial\localrepo.pyc", line 62, in __init__

mercurial.error.RepoError: repository /path/to/repo/or/config not found

Does anyone know what I need to look at in order to fix this?


Edit: Ok, I think I managed to get one step closer to the solution, but I'm still stumped.

I realized the .cgi file is a python script file, and not something compile, so I opened it for editing, and these lines was sitting in it:

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/path/to/repo/or/config"

So this was my source for the specific error message.

If I change the line to this:

config = "c:\\hg\\test"

Then I can navigate the empty repository through the Mercurial web interface.

However, I want to host multiple repositories, and seeing as the line says that I can also link to a hgweb config file, I tried this:

config = "c:\\inetpub\\hg\\hgweb.config"

But then I get the following error message:

mercurial.error.Abort: c:\inetpub\hg\hgweb.config: not a Mercurial bundle file
Exception ImportError: 'No module named shutil' in <bound method bundlerepository.__del__
of <mercurial.bundlerepo.bundlerepository object at 0x0260A110>> ignored

Nothing I've tried for the config variable seems to work:

config = "hgweb.config"
config = "c:\\hg\\hgweb.config"
  • various other variations I don't remember.

So, still stumped, pointers anyone?


Solved:

I ended up having to edit the hgweb.cgi file:

from:  from mercurial.hgweb import hgweb, wsgicgi
       application = hgweb(config)

to:    from mercurial.hgweb import hgweb, hgwebdir, wsgicgi
       application = hgwebdir(config)

Note the added hgwebdir parts there. Here's my hgweb.config file, located in the same directory as hgweb.cgi file:

[collections]
C:/hg/ = C:/hg/

[web]
style = gitweb

This now serves my repositories successfully.

Hopefully this question will give others some information if they're stumped as I was.

© Stack Overflow or respective owner

Related posts about mercurial

Related posts about iis7