Hosting Mercurial on IIS7

独自空忆成欢 提交于 2020-01-12 07:06:22

问题


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?

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


回答1:


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.



来源:https://stackoverflow.com/questions/2868365/hosting-mercurial-on-iis7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!