Mercurialの複数のリポジトリをhgweb.cgiで公開する
自宅のサーバのリポジトリをweb経由で見れるようにした.
公式ページに手取り足取り書いてあるかと思いきや, 情報が分散してたり, 旧いバージョンの話が混在してたりして微妙に分かりづらかった.
python読めるなら設定ファイル眺めるだけでなんとかなる気もする.
環境
- FreeBSD6.2(まだ6だった…
- apache2.2.8
- hg 1.7.1
Mercurialの設定
- mercural インストール
$ portsinstall devel/mercurial
- 設定ファイルをコピー
# /path/to/hg/repos/ は公開したいリポジトリの親ディレクトリ $ cp /usr/local/share/mercurial/www/hgweb.cgi /path/to/hg/repos/index.cgi
- 設定ファイルを書き換える
- config = "/path/to/repo/or/config" + config = "/path/to/hg/repos/hgweb.config" + import os + os.environ["HGRCPATH"] = "/etc/mercurial/hgrc" # デフォルトはどこか知らん + application = hgweb(config)
- /path/to/hg/repos/hgweb.configを編集
$ cat /path/to/hg/repos/hgweb.config [paths] <project-name0> = /path/to/hg/repo/project0 <project-name1> = /path/to/hg/repo/project1 . . . . . . <project-namen> = /path/to/hg/repo/projectN
apacheの設定
$ cat /usr/local/etc/apache22/httpd.conf ... ScriptAlias /hgweb /path/to/hg/repos/index.cgi <Directory "/path/to/hg/repos"> # 必要なら認証 AuthType Digest AuthName "Mercurial Public Repos" AuthDigestDomain /hgweb AuthUserFile /usr/local/www/apache22/auth/hg.digest Order deny,allow Deny from all Allow from 192.168. Require valid-user Satisfy any </Directory> ...
ScriptAliasを使うとAddHandler cgiもExecCGIも必要ない.
リポジトリの概要
各リポジトリのhgrcファイルで, hgweb経由で表示されるリポジトリの概要を設定する.
$ cat /path/to/hg/repos/project0/.hg/hgrc ... [web] contact = kinoko@example.com name = Project/Zero description = rin kawaiiyo rin ...
まとめ
- デフォルトでweb公開の手段が付いてくるのはお手軽で嬉しい
- 公式ページを鵜呑みにするとmod_rewriteガリガリ書かされてめんどい><
- hgweb.configを置く場所はapacheが公開する範囲に入ってるので移動した方がいいかも知れない