Aug 18, 2011

OSX に、Mercurial のリポジトリを構築

macports を使って、mercurial をインストール
sudo port install mercurial


リポジトリの作成
※ パーミッション等、Apacheのユーザが書き込めるようにしておく
mkdir -p /path/to/hg/repo

cd /path/to/hg/repo
hg init someproject


hgrc の設置
vi /path/to/hg/repo/someproject/.hg/hgrc


# こんな感じ
[web]
contact = me@me.com
description = Some Project

allow_push = *
allow_archive = zip
push_ssl = true

# 詳しくは
man hgrc


hgweb.config の設置
vi /path/to/hg/hgweb.config


# こんな感じ
[paths]
/ = /path/to/hg/repo/*


hgweb.cgi の設置
cp /opt/local/share/mercurial/hgweb.cgi /path/to/hg/

vi /path/to/hg/hgweb.cgi

# 設定ファイルのパスを修正
config = "/path/to/hg/hgweb.config"

# 文字化けする場合は以下を追加
import os
os.environ["HGENCODING"] = "UTF-8"

# 以下必要に応じて書き換え
import sys; sys.path.insert(0, "/opt/local/Library/Frameworks/Python.framework/Versions/Current/lib/python2.6/site-packages")


Apacheの設定
sudo vi /etc/apache2/other/hg.config


# こんな感じ
Alias /hg /path/to/hg

<Directory "/path/to/hg">
Options ExecCGI FollowSymLinks
DirectoryIndex hgweb.cgi
AddHandler cgi-script .cgi

AuthType Basic
AuthName "Repository"
AuthUserFile /private/etc/apache2/.htpasswd
AuthGroupFile /dev/null

Order deny,allow
Deny from all
Allow from xxx.xxx.xxx.xxx/24

Require valid-user
</Directory>

# Apache再起動
sudo /usr/sbin/apachectl restart


参考サイト

http://www.neutralworks.com/blog/osx/mecurial-on-mac.html
http://blog.bluegold.me/2010/02/setup-mercurial-hgwebdir-fcgi-on-nginx/
http://d.hatena.ne.jp/eldesh/20110125/1295938971
http://www.proton.jp/main/programming/mercurial.html

No comments:

Post a Comment