<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bluegold &#187; mercurial</title>
	<atom:link href="http://blog.bluegold.me/tag/mercurial/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bluegold.me</link>
	<description>OpenSolaris と MacBook で自宅ネットワークを構築するメモ</description>
	<lastBuildDate>Thu, 26 Aug 2010 14:38:53 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Mercurial: nginx で hgwebdir.fcgi のセットアップ</title>
		<link>http://blog.bluegold.me/2010/02/setup-mercurial-hgwebdir-fcgi-on-nginx/</link>
		<comments>http://blog.bluegold.me/2010/02/setup-mercurial-hgwebdir-fcgi-on-nginx/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 15:04:09 +0000</pubDate>
		<dc:creator>bg</dc:creator>
				<category><![CDATA[技術]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[opensolaris]]></category>

		<guid isPermaLink="false">http://blog.bluegold.me/?p=379</guid>
		<description><![CDATA[Mercurial の hgwebdir.fcgi を nginx で使う際の設定例]]></description>
			<content:encoded><![CDATA[<h2>Mercurial 付属の hgwebdir.fcgi を nginx で動かすメモ</h2>
<p>CVS（やSubversion）をバージョン管理システムに使っていた頃はリポジトリの情報を見るのに<a href="http://www.viewvc.org/">ViewVC</a>を使っていましたが、ViewVCはMercurialをサポートしていません。Mercurial にはウェブ用の管理画面(hgweb/hgwebdir)が付属しているので、別のツールを使うニーズが少ないんでしょうね。</p>
<p>Mercurial のリポジトリ毎に対応する Redmine のプロジェクトが存在するので、そちらを見ればおおよその事は分かるのですが、Redmineのリポジトリブラウザはブランチを意識して作られていないので不便といえば不便です。
</p>
<p>hgwebの事は Mercurial への移行を検討していたときにも調べていたんですが、Django, flup, setuptools, ez_setup.py, easy_install, .. とPythonに不慣れな人間にはなじみのない単語が続々と出てきたので、ちょっと敬遠していましたが、ちょっと時間が取れたのでチャレンジしてみました。</p>
<p><span id="more-379"></span></p>
<p>hgwebdir のセットアップをする前に必要なソフトウェアのインストールを行います。環境は OpenSolaris 2009.06 で、可能な限り pkg を使ってインストールしていきます。インストールしたのは以下のパッケージです。</p>
<pre class="bq">
SUNWPython26
SUNWPython26-extra
SUNWpython26-setuptools
</pre>
</p>
<p>OpenSolaris 2009.06 のパッケージ管理システムにも Mercurial はありますが、バージョンが 1.1.2 と古く、クライアントの環境と合わないので、最新バージョンを easy_install からインストールします。</p>
<pre class="brush: bash;">
$ pfexec easy_install Mercurial
$ hg --version
Mercurial Distributed SCM (version 1.4.2)

Copyright (C) 2005-2009 Matt Mackall &lt;mpm@selenic.com&gt; and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
</pre>
</p>
<p>次に flup が必要だそうなのでインストールします。</p>
<pre class="brush: bash;">
$ pfexec easy_install flup
</pre>
</p>
<p>hgwebdir を FastCGI で動作させるのにはいろいろな方法があるらしいのですが、Python特有のやり方はよく分からないので、lighttpd の <a href="http://redmine.lighttpd.net/projects/spawn-fcgi">spawn-fcgi</a>を使いました。インストールは以下の通り簡単です。</p>
<pre class="brush: bash;">
$ wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz
$ gzip -dc spawn-fcgi-1.6.3.tar.gz | tar xvf -
$ cd pawn-fcgi-1.6.3
$ ./configure
$ make
$ pfexec make install
</pre>
</p>
<p>ここまででようやく下準備がおわりました。<br />
hgwebdir.fcgi は /usr/demo/mercurial/hgwebdir.fcgi をコピーして使っています。<br />
UTF-8 で表示するために、HGENCODING の設定を行う部分のコメントをはずしています。</p>
<pre class="bq">
os.environ["HGENCODING"] = "UTF-8"
</pre>
</p>
<p>hgweb.config は単純です。</p>
<pre class="bq">
[paths]
/ = /path/to/repos/*
</pre>
<p>これを以下のようなスクリプトで起動しています。</p>
<pre class="bq">
#!/bin/sh

LANG=ja_JP.UTF-8
export LANG

FCGI=/opt/local/bin/spawn-fcgi
exec $FCGI -s /tmp/.fcgi_hgwebdir -G webserved -M 0660 ./hgwebdir.fcgi
</pre>
</p>
<p>nginx の設定ファイルは以下のようになりました。<br />
初めて try_files を使ってみましたが、設定がとてもシンプルになりますね。<br />
hgwebdir は PATH_INFO を利用してブラウズするリポジトリを探すようなので、その部分の置き換えにちょっと手を入れています。</p>
<pre class="bq">
server {
    listen       80;
    server_name  hg.example.com;
    root   /path/to/public;
    index  index.html;

    access_log  /var/log/nginx/hg-access.log  main;

    location / {
        try_files $uri @hgweb;
    }

    location @hgweb {
        fastcgi_pass   unix:/tmp/.fcgi_hgwebdir;
        fastcgi_read_timeout    5m;
        set $path_info "";
        if ($fastcgi_script_name ~ "^/(.*)$") {
            set $path_info $1;
        }
        fastcgi_param PATH_INFO $path_info;
    }
}
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluegold.me/2010/02/setup-mercurial-hgwebdir-fcgi-on-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mercurial で削除してしまったファイルを元に戻す</title>
		<link>http://blog.bluegold.me/2010/02/revert-missing-file-with-mercurial/</link>
		<comments>http://blog.bluegold.me/2010/02/revert-missing-file-with-mercurial/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:43:10 +0000</pubDate>
		<dc:creator>bg</dc:creator>
				<category><![CDATA[技術]]></category>
		<category><![CDATA[mercurial]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[メモ]]></category>

		<guid isPermaLink="false">http://blog.bluegold.me/?p=348</guid>
		<description><![CDATA[Mercurial で誤って削除してしまったファイルを元に戻す方法を説明します。]]></description>
			<content:encoded><![CDATA[<div>
<p>3ヶ月ほど前に、10年以上使い続けたCVSからMercurialにソース管理を移行しました。（Subversion は手になじまなかった。）</p>
<p>移行して不便に感じるのは<a href="http://www.viewvc.org/">ViewVC</a>が使えなくなった事くらいで、普段はあまり違いは感じていませんが、１つだけ直感的にやり方が分からなくて困る事があります。</p>
<p>ワーキングディレクトリで作業中に誤って必要なファイルを削除してしまった場合、例えば</p>
<pre class="bq">
$ ls -l
total 8
-rw-r--r--  1 user  staff  1345 Jan 16 22:33 Makefile
drwxr-xr-x  5 user  staff   170 Jan 16 22:45 help/
drwxr-xr-x  5 user  staff   170 Jan 16 22:33 tutorial/
$ rm Makefile
</pre>
<p>としてしまった場合、必要なファイルが存在しない事は hg status コマンドで調べる事ができます。</p>
<pre class="bq">
$ hg status
! Makefile
</pre>
</p>
<p>CVS(やSubversion)では、誤って削除したファイルは<strong>cvs update(svn up)</strong>で元に戻すことができますが、Mercurial ではそうはいきません。</p>
<p><span id="more-348"></span></p>
<p><pre class="bq">
$ hg update
ファイル状態: 更新数 0、マージ数 0、削除数 0、衝突未解決数 0
$ ls -l
total 0
drwxr-xr-x  5 user  staff  170 Jan 16 22:45 help/
drwxr-xr-x  5 user  staff  170 Jan 16 22:33 tutorial/
</pre>
<p>このように削除されたファイルはそのままです。
</p>
<p>Mercurial では update コマンドはワーキングディレクトリのリビジョンを変更するコマンドなので、この動きで正しいらしいのですが、CVS等から乗り換えてくるとちょっとビックリします。</p>
<p>このような場合は<strong>hg revert</strong>を使うのが正しいらしいです。</p>
<pre class="bq">
$ hg revert Makefile
$ ls -l
total 8
-rw-r--r--  1 user  staff  1345 Feb  2 02:41 Makefile
drwxr-xr-x  5 user  staff   170 Jan 16 22:45 help/
drwxr-xr-x  5 user  staff   170 Jan 16 22:33 tutorial/
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluegold.me/2010/02/revert-missing-file-with-mercurial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
