SAKURA internetにmercurialをインストールした後、Webからのアクセスを可能にしました。
その時の記録です。
使用出来るようにするにはsshで接続して作業します。
以下、SAKURAのアカウントをfooとし、コマンドラインの入力は行頭を%で表します。
リポジトリのディレクトリを$HOME/repos、WebのURLはhttp://foo.sakura.ne.jp/repos/以下にプロジェクトのディレクトリを作ってアクセス出来るようにします。
プロジェクトはhelloとし、以下のファイルが含まれているとします。
Makefile
all: hello
hello: hello.o
$(CC) -o $@ $<
hello.c
#include %lt;stdio.h%gt;
int main(int argc, char** argv)
{
printf("Hello, world¥n");
}まずは、リポジトリのディレクトリとWeb用のディレクトリを作成します。
(クライアントマシン)% ssh foo@foo.sakura.ne.jp
% mkdir -p ~/repos/hello
% mkdir -p ~/www/repos/helloリポジトリ内にファイルを作成します。
上記で示した内容のファイルを作成します。
% cd ~/repos
% vi Makefile
% vi hello.cリポジトリを機能させます。
init:初期化、add:ファイルを追加、commit:内容を反映、です。
% hg init
% hg add
% hg commitWeb用のディレクトリにリポジトリ名のパスとアクセス用のスクリプトを配置します。
% mkdir ~/www/repos/hello
% cp ~/work/mercurial-1.0.1/hgweb.cgi ~/www/hello/index.cgiWebアクセス用のスクリプトの内容を変更します。
% vi ~/www/repos/hello/index.cgi変更内容は、以下のようになります。
#!/usr/bin/env python
#
# An example CGI script to use hgweb, edit as necessary
# adjust python path if not a system-wide install:
import sys
sys.path.insert(0, "/home/foo/local/lib/python2.4/site-packages")
# enable importing on demand to reduce startup time
from mercurial import demandimport; demandimport.enable()
# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb
#cgitb.enable()
# If you'd like to serve pages with UTF-8 instead of your default
# locale charset, you can do so by uncommenting the following lines.
# Note that this will cause your .hgrc files to be interpreted in
# UTF-8 and all your repo files to be displayed using UTF-8.
#
import os
os.environ["HGENCODING"] = "UTF-8"
from mercurial.hgweb.hgweb_mod import hgweb
import mercurial.hgweb.wsgicgi as wsgicgi
application = hgweb("/home/foo/repos/hello", "hello world")
wsgicgi.launch(application)
変更内容は以下のようになります。
- 7行目を自分のlocal/libの中のpythonのライブラリのパスを指定するようにする
- 21、22行目でUTF-8を使用するように指定する(一応の念のため)
- 27行目でリポジトリの位置を指定する
この修正をし、http://foo.sakura.ne.jp/repos/hello/にアクセスしたときに修正内容のページが表示されればOKです。
クライアントマシンからコマンドラインのhgでリポジトリを複製してみましょう。
(クライアントマシン)% hg clone http://foo.sakura.ne.jp/repos/hello/これでmercurialをWebインターフェイスを使用してアクセスできるようになりました。
[...] SAKURAにインストールしたmercurialをWebから使う。 [...]