secretbase.log

.NET/C#/Pythonなど

最新 Mercurial 2.0 を 導入する方法 (Cygwin編)

現時点の CygwinMercurial のバージョンは 1.9.3 ですが、最新2.0 をソースコードからインストールして導入する手順です。
(Linuxでも同じ手順でいけると思いますが...)

f:id:cointoss1973:20111130144808p:image

インストール前の環境

CygwinMercurial をインストールする

Cygwin Terminalを右クリックして、"管理者として実行(A)"にて起動します。
管理者モードでないとインストールできませんので注意。
ソースコードを ダウンロードして解凍して install します。

$ cd ~/src
$ wget http://mercurial.selenic.com/release/mercurial-2.0.tar.gz
$ tar xvzf mercurial-2.0.tar.gz
$ cd mercurial-2.0
$ make install
....

...
running install_scripts
copying build/scripts-2.6/hg -> /usr/local/bin
changing mode of /usr/local/bin/hg to 755
running install_egg_info
Removing /usr/local/lib/python2.6/site-packages/mercurial-2.0-py2.6.egg-info
Writing /usr/local/lib/python2.6/site-packages/mercurial-2.0-py2.6.egg-info
make -C doc
make[1]: ディレクトリ `/home/tkondou/src/mercurial-2.0/doc' に入ります
python runrst hgmanpage --halt warning \
--strip-elements-with-class htmlonly hg.1.txt hg.1
abort: couldn't generate documentation: docutils module is missing
please install python-docutils or see http://docutils.sourceforge.net/
make[1]: *** [hg.1] エラー 255
make[1]: ディレクトリ `/home/tkondou/src/mercurial-2.0/doc' から出ます
make: *** [doc] エラー 2

なにやらエラーがでました。
python-docutils が入っていない、とのエラーです。


Docutils を Cygwin上にインストールする

Docutils は Python で書かれたテキストを処理するユーティリティのようです。
snapshot版がおすすめ、ということで、docutils-snapshot.tgz をダウンロードしてインストールすることにします。

$ cd ~/src
$ wget http://docutils.sourceforge.net/docutils-snapshot.tgz
$ tar xvzf docutils-snapshot.tgz
$ ./setup.py install

入ったようです。( /usr/bin 以下に rst2なんとか.py というファイルがあった)

再度 Mercurial をインストールする

再度、make install しましょう。

$ cd ~/src/mercurial-2.0
$ make install
...
make -C doc
make[1]: ディレクトリ `/home/tkondou/src/mercurial-2.0/doc' に入ります
python runrst hgmanpage --halt warning \
--strip-elements-with-class htmlonly hg.1.txt hg.1
python runrst html --halt warning \
--link-stylesheet --stylesheet-path style.css hg.1.txt hg.1.html
make[1]: ディレクトリ `/home/tkondou/src/mercurial-2.0/doc' から出ます
cd doc && make install
make[1]: ディレクトリ `/home/tkondou/src/mercurial-2.0/doc' に入ります
for i in hg.1 hgignore.5 hgrc.5 ; do \
subdir=`echo $i | sed -n 's/^.*\.\([0-9]\)$/man\1/p'` ; \
mkdir -p /usr/local/share/man/$subdir ; \
install -c -m 644 $i /usr/local/share/man/$subdir ; \
done
make[1]: ディレクトリ `/home/tkondou/src/mercurial-2.0/doc' から出ます

Mercurial のバージョンを確認する

doc も含めて install できたので、hg version にてバージョン確認してみましょう。

$ hg version
Mercurial - 分散構成管理ツール(バージョン 2.0)
(詳細は http://mercurial.selenic.com を参照のこと)

Copyright (C) 2005-2011 Matt Mackall 他
本製品はフリーソフトウェアです。
頒布条件に関しては同梱されるライセンス条項をお読みください。
市場適合性や特定用途への可否を含め、 本製品は無保証です。

最新2.0が入りました!

Mercurial を簡単に使ってみる

テストを兼ねて、ローカルに簡単に mercurialリポジトリをつくってテストしてみましょう。

tkondou@medusa ~/hgrepo
$ mkdir test

tkondou@medusa ~/hgrepo
$ cd test

tkondou@medusa ~/hgrepo/test
$ ls

tkondou@medusa ~/hgrepo/test
$ hg init

tkondou@medusa ~/hgrepo/test
$ echo hogehoge > README

tkondou@medusa ~/hgrepo/test
$ cat README
hogehoge

tkondou@medusa ~/hgrepo/test
$ hg add README

tkondou@medusa ~/hgrepo/test
$ hg status
A README

tkondou@medusa ~/hgrepo/test
$ hg commit -m "README追加"

tkondou@medusa ~/hgrepo/test
$ hg status

tkondou@medusa ~/hgrepo/test
$ hg log
チェンジセット: 0:c02f68b2440e
タグ: tip
ユーザ: tkondou
日付: Wed Nov 30 14:26:29 2011 +0900
要約: README追加

いい感じです。 clone も試してみます。

tkondou@medusa ~/hgrepo
$ hg clone ~/hgrepo/test hoge
ブランチ default へ更新中
ファイル状態: 更新数 1、 マージ数 0、 削除数 0、 衝突未解消数 0

tkondou@medusa ~/hgrepo/hoge
$ cat README
hogehoge

Mercurialも含めて、Cygwin上で動作するプログラムは遅いとの評判ですが使える状態にしておくのはいいと思います。

入門Mercurial Linux/Windows対応

入門Mercurial Linux/Windows対応