views:

43

answers:

1

Hello.

I'm setting up my freelance server which will be using Mercurial for all the version controlling. Each project will have it's own folder, with it's own repository. Which I can then clone from my home computer, work computer or any other computer by going to that particular folder.

I'm wanting to serve these repositories up into a web browser for me to browse visually when I need to. I've looked around and seen this: http://mercurial.selenic.com/wiki/HgServeNginx

That looks like it's along the right tracks, as I will be using Nginx on this server anyhow. But I'm curious to know how I would correctly set this up. What do I need to do in particular to efficiently serve up multiple repositories on my server through the web browser?

Any help or experienced insight on this would be very helpful to make sure I'm doing this correctly.

Many thanks.

+1  A: 

Using that link, you can configure as many locations as you will have repos. In every repo directory, you need to run hg serve:

cd repos/repo1;        
nohup hg serve -p 8000 &
cd repos/repo2;
nohup hg serve -p 8001 &

Then you can just proxy all request via nginx to that running hg servers. This is not very good way. This method need manually edit nginx config, run hg serve etc. But this method allow to you create separate auth settings for each repo. So if you plan to share repo with customer, you can easily manage this.

Instead, you can use special script, which is contributed with mercurial -- hgwebdir. Detailed info, you can fine on this page: http://mercurial.selenic.com/wiki/PublishingRepositories#Publishing_Multiple_Repositories

UPDATE: I have mercurial version 1.6 on server, and for runnung repo web UI we use this script hgwebdir.py:

#!/usr/bin/env python
import sys 
import os
os.environ["HGENCODING"] = "UTF-8"
from mercurial.hgweb.hgwebdir_mod import hgwebdir
from mercurial.hgweb.request import wsgiapplication
from flup.server.fcgi import WSGIServer

def make_web_app():
   return hgwebdir('/home/hg/hgwebdir.conf')

WSGIServer(wsgiapplication(make_web_app),
       umask=0000,
       bindAddress='/home/hg/hg.sock').run()

hgwebdir.conf is looks like this:

[web]
allow_push = some_useronly
baseurl = 
push_ssl = false
[collections]
/home/hg/repos = /home/hg/repos

To run: nohup hgwebdir.py &, you need flup python module, so: easy_install flup

Related nginx.conf part is:

server {
    listen 80;
    server_name hg.example.com;
    gzip off;
    include fastcgi_params;
    location / {
        client_max_body_size 30m;
        auth_basic  "Restricted Area";
        auth_basic_user_file /home/hg/hg.password;
        fastcgi_pass unix:/home/hg/hg.sock;
    }
}
Zada Zorg
@zada-zorg This looks a lot more complicated. Seeing that I will using Nginx (and not Apache) would I need to use something like FastCGI instead to run the .cgi script? I'm not quite sure how to set that up with Nginx.
littlejim84
It also says at the top of that linked page: "Note that starting with version 1.6 of Mercurial, the hgwebdir.cgi script no longer exists, and its functionality has been merged into the hgweb.cgi script. If you want to publish multiple repositories, follow the appropriate instructions, substituting hgweb.cgi for hgwebdir.cgi."
littlejim84