hgwebdir configuration problem

Paul Boddie paul.boddie at biotek.uio.no
Wed Jan 6 08:31:34 CST 2010


gda wrote:
> Dear all,
>
> I'm new to mercurial and probably my problem is trivial.
>   

I haven't seen any public responses to your mail, so here's my belated 
attempt to help you out!

> I have a configuration problem of the cgi script  hgwebdir.cgi
>
> I have several repositories located in the folder
> /home/myuser/prog_development let's say:
> /home/myuser/prog_development/rep1
> /home/myuser/prog_development/rep2
> /home/myuser/prog_development/rep3
> ...
>
> I have created a public_html folder in the home of myuser with the following
> files and link:
> hgweb.config
> hgwebdir.cgi
> prog_development -> /home/myuser/prog_development/
>   

I don't think you need to create a link to your repository collection 
from the public HTML directory. It all depends on how that directory is 
configured within your Web server, but if static files within the public 
HTML directory are being served up as static content, you run the risk 
of publishing your repositories the simple (and inefficient) way, as I 
think we see below.

> The hgweb.config is:
>
> [collections]
> /home/myuser/public_html=/home/myuser/public_html/prog_development
>   

This will probably work, but I don't see why you can't use...

/home/myuser/prog_development


...instead. In fact, doing so (and not exposing the repository via a 
symbolic link) is a lot cleaner.

> With this configuration http://mypc/~myuser gets me a page reporting the
> list of all my repositories without any error. Anyway there are two annoying
> problems:
>   

I guess that the public HTML directory has hgwebdir.cgi set up as the 
default script.

> 1) When I click on a link of one of my repositories I get a html page
> containing the list of all files of the selected repository instead of the
> expected interface to hg. I have solved this problem inserting in all my
> repository folders a file hgweb.cgi properly configurated. But as far as I
> have understood hgwebdir.cgi does not need any hgweb.cgi so what is wrong in
> my configuration?
>   

I'm guessing that http://mypc/~myuser invokes the hgwebdir.cgi script 
which then lists the repositories thus:

http://mypc/~myuser/rep1
http://mypc/~myuser/rep2
http://mypc/~myuser/rep3

But since you've exposed the repositories as static content (probably - 
see my note above), your Web server will probably notice that actual 
files in the filesystem exist and can be used to satisfy requests to 
these locations. In other words, the hgwebdir.cgi script isn't being 
asked to handle requests to these locations at this point.

On the Wiki, I've written up the easiest way of serving multiple 
repositories as follows:

http://mercurial.selenic.com/wiki/PublishingRepositories#Publishing_the_CGI_Script_Directly

Since you're perhaps wanting to do this within a public HTML directory, 
which may be more limited, the following .htaccess configuration method 
might be more suitable:

http://mercurial.selenic.com/wiki/PublishingRepositories#Using_an_.htaccess_File

Generally, I recommend ScriptAlias (the first method) as it doesn't let 
things evade the script as easily as some of the more advanced Apache magic.

> 2) When I want to download an archive on one of my repository I'm redirect
> to the following link:
> http://mypc/~myuser/prog_development/repo1/archive/tip.zip
> and my apache server gives me the following error message:
> The requested URL /~myuser/prog_development/repo1/archive/tip.zip was not
> found on this server.
> On the other hand if I first go on the page related to the repository repo1
> and from there (so using the script hgweb.cgi) I download the archive I'm
> redirected to:
> http://mypc/~myuser/prog_development/repo1/?archive/tip.zip
> (note the presence of a question mark before archive) and everything works
> fine! 
> Why the question mark is not present also in the archive links of the page
> containing the list of all the repositories?
>   

At this point, I'm hoping that changes to solve (1) will help solve (2). 
To summarise:

* Make Apache use the script for everything under /~myuser
* Don't expose the repositories as static content

Please let us know how you get on, though. :-)

Paul


More information about the Mercurial mailing list