テスト用に分散管理システムを導入しようと思いMercuryを導入してみることに。
別途、サーバーをわざわざ用意する必要もないので、今借りている海外のホスティングプラン内で運用する事にしました。
ちなみに、Host Monster なんですが、容量が「Unlimited」と無制限にも関わらず、月額$5,95と格安です。
http://.hostmonster.com/
レスポンスは多少悪いものの、かなり有効活用させて頂いております。
Mercury公式サイト
http://www.selenic.com/mercurial/wiki/index.cgi/Mercurial
【 Mercuryインストール方法 】
かなり簡単でした。
1 2 3 4 5 6 7 8 |
<textarea class="ruby" cols="60" rows="5" name="code"> $ wget wget http://www.selenic.com/mercurial/release/mercurial-1.1.2.tar.gz $ tar zxvf mercurial-1.1.2.tar.gz $ cd mercurial-1.1.2 $ make install-home # add PYTHON=/path/to/python2.3-or-newer if necessary $ export PYTHONPATH=${HOME}/lib/python # bash syntax, ymmv $ export PATH=${HOME}/bin:$PATH # add these to your .bashrc </textarea> |
http://www.selenic.com/mercurial/wiki/index.cgi/UnixInstall
【 Mercury使い方&設定方法 】
1. ユーザーネームを設定
mercury用のユーザーネームを設定しましょう。
デフォルトでは、{userna,e}@{hostname}になっています。
設定するには.hgrcファイルを追加して以下のように表記すればOKです。
vim ~/.hgrc
1 2 3 4 |
<textarea class="ruby" cols="60" rows="5" name="code"> [ui] username = John Doe <john@example.com> </textarea> |
2. レポジトリを作成
testという名前で作成します。
1 2 3 4 |
<textarea class="ruby" cols="60" rows="5" name="code"> hg init test cd test </textarea> |
3. 初期設定ファイルhgrcを作成・設定
初期設定ファイルを作成して以下の行を追加します。
デフォルトではpushは不可になっているので変更します。
vim .hg/hgrc
1 2 3 4 5 6 |
<textarea class="ruby" cols="60" rows="5" name="code"> vim .hg/hgrc [web] push_ssl = false allow_push = * </textarea> |
4. htaccessでapacheの設定
次にhtaccessの設定をします。
ただ、ここで設定するPYTHONPATHはCGI経由だとなぜか適応されないので、cgiファイルで別途指定する必要があります。
vim .htaccess
1 2 3 4 5 |
<textarea class="ruby" cols="60" rows="5" name="code"> setenv PYTHONPATH /home/{user}/public_html/mercury/sources/mercurial-1.1.2/ AddHandler cgi-script .cgi .rb Options ExecCGI +Indexes </textarea> |
5. hgweb.cgiの設定・設定
hgweb.cgiファイルをmercurialフォルダからコピーしてきます。
mercurialをコンパイルした場所によってパスがかわりますが、{home}/sources/mercurial-1.1.2に
コンパイルしたので、、
1 2 3 |
<textarea class="ruby" cols="60" rows="5" name="code"> cp /home/{user}/public_html/sources/mercurial-1.1.2/hgweb.cgi ./hgweb.cgi </textarea> |
vim hgweb.cgi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<textarea class="ruby" cols="60" rows="5" name="code"> #!/ramdisk/bin/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/{user}/public_html/mercury/sources/mercurial-1.1.2/") # 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/{user}/public_html/mercury/projects/wine_site/", "repository name") wsgicgi.launch(application) </textarea> |
ブラウザ上からhgweb.cgiにアクセスして以下のような画面ができれば完成。