开发者

How to serve Mercurial repositories in the browser correctly?

开发者 https://www.devze.com 2023-01-15 09:16 出处:网络
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 ho

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: https://www.mercurial-scm.org/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.


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: https://www.mercurial-scm.org/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;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号