さくらインターネットにMercurialを入れてみる。
といっても、ほぼ
さくらとPythonとMercurial。 - オレの劣化が止まらない さんのところと、
さくらインターネットにインストールしたMercurialをバージョンアップ : サルノオボエガキ さんのところを参考に真似ただけという。
pythonは手探り感が否めない。ま、はじめたばっかだし!
まぁ、個人的なメモでもあるので一応手順を残します。
- easy_install 使うための下準備
$ cd $ mkdir $HOME/local/lib/python2.6 $ cd $HOME/local/lib $ ln -s python2.6 python
- 下準備その2、この作業後いったん繋ぎ直し(ログアウト)したほうがいい。
$ vi ~/.bashrc export PYTHONPATH=$HOME/local/lib/python:$HOME/local/lib/python/site-packages $ cd $ ln -s local/bin bin
- 再接続後、easy_installのインストール・設定
$ cd $ mkdir tmp $ cd tmp $ wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz $ tar xzf setuptools-0.6c11.tar.gz $ cd setuptools-0.6c11 $ python setup.py install --home=~/local $ cd $ vi .pydistutils.cfg [easy_install] install_dir=~/local/lib/python
$ easy_install Mercurial Searching for Mercurial Reading http://pypi.python.org/simple/Mercurial/ Reading http://www.selenic.com/mercurial Best match: mercurial 1.6 ... easy_install Mercurial Searching for Mercurial Reading http://pypi.python.org/simple/Mercurial/ Reading http://www.selenic.com/mercurial Best match: mercurial 1.6
- Mercurial本体を入れる。
$ cd $ cd tmp $ wget http://mercurial.selenic.com/release/mercurial-1.6.tar.gz $ tar xzf mercurial-1.6.tar.gz $ cd mercurial-1.6 $ vi Makefile PREFIX=/home/ユーザ名/local < 書き換え $ gmake install-bin $ hg --version
こんな感じでやると、さくらでMercurialが入ります。
次に、hgweb.cgiの設定についてごにょごにょします。
- とりあえず、テストのリポジトリを作ります。
$ cd $ mkdir hgrepo $ cd hgrepo $ hg init hoge $ cd hoge $ vi .hg/hgrc [web] push_ssl = false allow_push = * $ pwd /home/ユーザ名/hgrepo/hoge/ $ ls -a . .. .hg
- hgweb.cgiをDocumentRoot直下にコピーします(任意の場所でOK)
$ cd $ cd tmp $ cd mercurial-1.6 $ cp hgweb.cgi ~/www/index.cgi
- ちょろっと設定書き換えます。
$ cd ~/www $ chmod +x index.cgi $ vi index.cgi #!/usr/bin/env python # # An example hgweb CGI script, edit as necessary # Path to repo or hgweb config to serve (see 'hg help hgweb') #ここに表示させたいリポジトリの絶対パスを入れます。 config = "/home/ユーザ名/hgrepo/hoge/" # Uncomment and adjust if Mercurial is not installed system-wide: #コメント取り、上記で設定したPYTHONPATHの右側のフルパスを書きます import sys; sys.path.insert(0, "/home/ユーザ名/local/lib/python/site-packages/") #日本語扱うのに必要・・・らしい? import os; os.environ["HGENCODING"] = "UTF-8" # Uncomment to send python tracebacks to the browser if an error occurs: #import cgitb; cgitb.enable() from mercurial import demandimport; demandimport.enable() from mercurial.hgweb import hgweb, wsgicgi application = hgweb(config) wsgicgi.launch(application)
日本語で書いたコメントは書かないようにしましょう。
これで動くと思います。
(例)http://ユーザ名.sakura.ne.jp/index.cgi
で見れたら成功です。
だめだったら、「#import cgitb;〜」のコメントもはずしてエラーを確認しましょう。
さて、こっからはクライアント側での作業をちょろっとだけ
- クライアント側からサーバへのアクセス方法
$ hg clone http://ユーザ名.sakura.ne.jp/index.cgi hogehoge 差分はありません ブランチ default へ更新中 ファイル状態: 更新数 0、マージ数 0、削除数 0、衝突未解決数 0 $ cd hogehoge $ vi a.txt テストなのですよ〜 $ hg add a.txt $ hg ci -m "add a.txtなのですよ〜" $ hg push http://ユーザ名.sakura.ne.jp/index.cgi http://ユーザ名.sakura.ne.jp/index.cgi への反映中 変更点を探索中 遠隔ホスト: adding changesets 遠隔ホスト: adding manifests 遠隔ホスト: adding file changes 遠隔ホスト: added 1 changesets with 1 changes to 1 files
てな感じに操作できますよ〜。
まぁ、セキュリティに関しては何も対策講じてないので、そっちはいろいろと探してみてください