Subversionの履歴をMercurialに引き継ぐ

Google CodeでMercurialを使う - 0xFFで、「ver1.1時点では変更履歴の引き継ぎはサポートしていない」と書いたところ、id:kzys

Subversion レポジトリのデータを引き継ぎたい場合は
1. hg convert でもとの Subversion レポジトリMercurial レポジトリに変換
2. Google Code 側を Mercurial に切り替え
3. 切り替えたレポジトリに hg convert でつくったレポジトリを push
とやれば、うまくいきそうだと思いました。ごめんなさい、未検証です。

http://d.hatena.ne.jp/os0x/20090604/1244085244#c1244253413

と情報を頂きました。
折角の機会なので試したところ、確かに上記の方法で履歴を引き継ぐことができました。

以下、もう少し詳しい手順(Mercurialへの理解度が浅いので間違っている箇所などあるかもしれません。ご了承ください。)です。

Google Code の SubversionMercurial の切り替えについて

2009/06/08時点ではSubversionからMercurialに切り替えた場合、Subversion はそのまま使用可能な状態のようです。なので、特にSubversionに戻す必要はありません。

Subversion Python bindings

Subversionリポジトリ を convert するには、Python bindingsが必要になります。Windowsで作業しようとしたときはここで嵌りました。
また、

So you'll need to use a Mercurial installed on top of a stand-alone Python, and you may also need to do something like "set HG=python c:\Python25\Scripts\hg" to override the default Win32 binaries if you have those installed also.

http://www.selenic.com/mercurial/wiki/ConvertExtension#Converting_from_Subversion

など、Windowsで動かすのは少々骨が折れそうでした。
なので、今回はUbuntu8.10にPythonを入れて、easy_installでMercurialをインストールしました。
http://www.selenic.com/mercurial/wiki/BinaryPackages#Any_system_with_modern_Python_and_SetupTools_installed
この方法が手軽で確実と思われます。

Perforce

さらに、マージにPerforceが必要となります。-s svnをつければ不要でした。
今回は紫陽花観察日記の方法でインストールしました。

hg convert

ConvertExtension - Mercurialより、.hgrc(Windowsの場合、Mercurial.ini)に

[extensions]
hgext.convert=

と記述します。

以上で下準備は完了です。
あとは、

hg convert -s svn http://autopatchwork.googlecode.com/svn/trunk/ autopatchwork

を実行すれば、.hgディレクトリが作られるので、この.hgを使ってPushしてあげれば無事 Subversion での履歴を引き継ぐことができました。