RCS から GIT へ移行

どうもいっす。
例の,コミット時のユーザ名問題の原因は,.gitconfig を慣れないviで編集したせいで,
正常に書かれていなかったからのようです。
git config -l したら,おかしなことになってた。
修正後,適当なファイルでC-xvv でコミットしてみて,
git log したら治ってたお。
よかった。


さて,shell-pop.el をRCSで管理していたのですが,
githubに登録しよういうことで,RCSからGITへの移行方法を調べて,
できたっぽいので,メモしておきます。
できただけで,正攻法ではない可能性もあるので,正攻法を知っていたら,
教えて下さいな。


でですね,簡単に言うと,rcs-fast-export.rb を入手して,
git fast-import すればおっけ。

rcs-fast-export.rb の入手

http://git.oblomov.eu/rcs-fast-export の snapshot から最新版を取得。
適当に伸張して配置。
ワタシの場合は,~/bin においた。


この時点で試してみたら,怒られた。

% ~/bin/rcs-fast-export.rb ./shell-pop.el
/home/whitypig/bin/rcs-fast-export.rb:697:in `expand_path': can't convert nil into String (TypeError)
	from /home/whitypig/bin/rcs-fast-export.rb:697:in `steal_username'
	from /home/whitypig/bin/rcs-fast-export.rb:691:in `each'
	from /home/whitypig/bin/rcs-fast-export.rb:691:in `steal_username'
	from /home/whitypig/bin/rcs-fast-export.rb:720
authors-file を作成する

よくわからんが,authors-file というのを指定すればできるだろうと
目算してみたら,できた。
rcs-fast-export.rb から引用。

Options:
	--help, -h, -?		display this help text
	--authors-file, -A	specify a file containing username = Full Name <email> mappings
	--rcs-commit-fuzz	fuzziness in RCS commits to be considered a single one when
				importing multiple files
				(in seconds, defaults to 300, i.e. 5 minutes)
	--[no-]tag-each-rev	[do not] create a lightweight tag for each RCS revision when
				importing a single file
	--[no-]log-filename	[do not] prepend the filename to the commit log when importing
				a single file

フォーマットは,
username = Full Name
とすればよし。
ワタシは,AUTHOR というファイル名にして,中身を

whitypig = whitypig <whitypig@gmail.com>

としました。

リポジトリの初期化とfast-import

リポジトリを作成して,git init しときましょ。
ほいで,動くことを確認。

% ~/bin/rcs-fast-export.rb --authors-file ./AUTHOR ./shell-pop.el
commit export loop #1
	4 to export: 1.1, 1.2, 1.3, 1.4
blob
# ... このあといっぱいでてくるので注意。


で,git fast-import を実行します。
マニュアルによると,標準入力から入力をうけとるらしいです。
なので,渡してあげたらできた。

% pwd
/home/whitypig/repos/git_repos/shell-pop

% ~/bin/rcs-fast-export.rb -A ~/.emacs.d/AUTHOR ~/.emacs.d/shell-pop.el | git fast-import
commit export loop #1
	4 to export: 1.1, 1.2, 1.3, 1.4
git-fast-import statistics:
---------------------------------------------------------------------
Alloc'd objects:       5000
Total objects:           12 (         0 duplicates                  )
      blobs  :            4 (         0 duplicates          3 deltas)
      trees  :            4 (         0 duplicates          3 deltas)
      commits:            4 (         0 duplicates          0 deltas)
      tags   :            0 (         0 duplicates          0 deltas)
Total branches:           1 (         1 loads     )
      marks:           1024 (         8 unique    )
      atoms:              1
Memory total:          2255 KiB
       pools:          2098 KiB
     objects:           156 KiB
---------------------------------------------------------------------
pack_report: getpagesize()            =      65536
pack_report: core.packedGitWindowSize =   33554432
pack_report: core.packedGitLimit      =  268435456
pack_report: pack_used_ctr            =          1
pack_report: pack_mmap_calls          =          1
pack_report: pack_open_windows        =          1 /          1
pack_report: pack_mapped              =       4136 /       4136
---------------------------------------------------------------------


という感じで結果が表示されればたぶん,オッケー牧場。
その後,git log してみたり,git checkout してみたけど,
大丈夫そうだった。

まとめ

お疲れ様でした。
rcs-fast-export.rb の作者様に感謝ですね。
あとは,github に登録すれば目的達成ですね。
それはまた今度。