[collections]
C:\work\hg = C:\work\hg
[web]
allow_push = *
style = monoblue
contact = kazunori@kzc.biglobe.ne.jp
push_ssl = false
[collections]
C:\work\hg = C:\work\hg
[web]
allow_push = *
style = monoblue
contact = kazunori@kzc.biglobe.ne.jp
push_ssl = false
#!c:/usr/local/xampp/python/python.exe -u
#
# An example hgweb CGI script, edit as necessary
# See also http://mercurial.selenic.com/wiki/PublishingRepositories
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "C:/usr/local/Mercurial/hgweb.config"
# Uncomment and adjust if Mercurial is not installed system-wide:
import sys; sys.path.insert(0, "C:/usr/local/Mercurial/lib")
# 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)
<<目的>>
・Windows環境にMercurial Serverをapacheベースで構築し、NetBeans IDEから接続する。
<<ソフトおよびバージョン>>
・Windows 7 Home Premium 64bit
・Mercurial 2.5.4
・Python 2.7.4
・apache 2.4.3 (xampp 1.8.1)
・NetBeans IDE 7.3
<<前提条件>>
・apache (xampp)はすでにインストールされているものとして話を進めます。
※c:\usr\local\xampp\apacheにインストールされているものとして話を進めます。
<<やりかた>>
・Mercurialのインストール
・http://mercurial.selenic.com/release/windows/から
Mercurial-2.5.4.exe
をダウンロードしてインストール。
※ここではc:\usr\local\Mercurialにインストールしたものとして話を進めます。
・コマンドプロンプトを起動し、以下を入力。
hg
情報が表示されたらOK。
・Pythonのインストール
・http://www.python.org/download/から
Python 2.7.4 Windows Installer
をダウンロードしてインストール。
※ここではc:\usr\local\xampp\pythonにインストールしたものとして話を進めます。
※最新版の3.3.1を使うと実行時にbad magic numberのエラーが発生するので、
少し古いですが、2.7.4を使用しています。
・Mercurialの構成変更
・Mercurial のインストールディレクトリをエクスプローラで開く。
・libディレクトリを新規に作成する。
・library.zipをlibディレクトリに解凍する。
※解凍する際に余計なディレクトリなどを作成しないこと。例えば、zipfile.zpyは
libディレクトリの直下に配置される。
・Mercurial のインストールディレクトリのTemplatesディレクトリを
libディレクトリに移動する。
・プロジェクトディレクトリの作成
・Mercurialがソースコードを管理するディレクトリを作成します。
ここではc:\work\hgとします。
・apacheの構成変更
・以下の内容でhgweb.cgiを作成し、apacheのcgi-binディレクトリに放り込む。
hgweb.cgiの例
・以下の内容でhgweb.configを作成し、Mercurialのインストールディレクトリに放り込む。
hgweb.configの例
・httpd.confを開き、以下のAddHandlerを追加(コメントアウト)する。
AddHandler cgi-script .cgi .py
・apacheを起動(すでに起動している場合は再起動)する。
・プロジェクトの初期化
・コマンドプロンプトを管理者で起動し、プロジェクトディレクトリに移動後、以下を実行する。
hg init プロジェクト名
・ブラウザでの動作確認
・ブラウザで
http://localhost/cgi-bin/hgweb.cgi
と入力し、Mercurialのページが正常に表示されることを確認する。
・環境変数PATHへ追加
・Mercurialのインストールディレクトリを環境変数PATHへ追加する。
・プラグインの追加(NetBeans IDE)
・NetBeans IDEを起動する。
・メニューから「ツール」→「プラグイン」を選択。
・「使用可能なプラグイン」から
Mercurial
を選択して「インストール」
※すでにインストールしてある場合は「インストール済み」のタブに表示されるので、何もしなくて良い。
・プラグインの追加(NetBeans IDE)
・NetBeans IDEを起動する。
・メニューから「ツール」→「プラグイン」を選択。
・「使用可能なプラグイン」から
Mercurial
を選択して「インストール」
※すでにインストールしてある場合は「インストール済み」のタブに表示されるので、何もしなくて良い。
・ローカルリポジトリの初期化(NetBeans IDE)
・Mercurialに追加したいプロジェクトを右クリックし、
「バージョン管理」「Mercurialプロジェクトを初期化」を選択。
・そのまま「OK」。
・Mercurialプロパティの編集(NetBeans IDE)
・プロジェクトを右クリックし、「Mercurial」「プロパティ」を選択。
・default-pullが選択された状態で、プロパティ値に
http://localhost/cgi-bin/hgweb.cgi/プロジェクト名
と入力して、「OK」
・設定が反映されるまでしばらく待ちます。
・再度、プロジェクトを右クリックし、「Mercurial」「プロパティ」を選択。
・default-pullおよびdefault-pushに同一の値が入っていることを確認。
・確認
・ファイルを右クリックし、「Mercurial」「コミット」でローカルにコミットできることを確認。
・プロジェクトを右クリックし、「Mercurial」「共有」「デフォルトにプッシュ」で
サーバーにプッシュできることを確認。
・ブラウザで
http://localhost/cgi-bin/hgweb.cgi/プロジェクト名
にアクセスして、「files」タブをクリックし、該当のファイルが表示されることを確認。
<<参考資料>>
・Mercurial server on Windows with Apache
http://blog.m1key.me/2010/11/mercurial-server-on-windows-with-apache.html