1/21/2012

Git と Mercurial のほんとの違い

Jason Chu さんが The Real Difference Between Git and Mercurial という記事を書いていたので、ちょっとお勉強。

僕は Mercurial をほとんど使ったことないから Mercurial の解説部分は実感が持てなかったけど、最近使い始めた Git のほうは「ほほぉー」とちょっとはわかった気になった。

Git は各 commit がひとつのファイルになっていて、branch は commit に対するポインタになってるってことが Git のポイントの一つなんだっ!おぉー。。
Another great example is git commit --amend. If you want to modify the most recent commit, to add something you forgot or just change the commit message, git commit --amend will create a whole new set of file objects, tree objects, and a commit object. After it’s done those things, it updates the branch pointer. If you then decide that that wasn’t really what you wanted to do, you can just point the branch pointer back at the previous commit with git reset --hard HEAD@{1} (or by looking through the reflog for the commit hash that the branch used to point at).
以下、Jason Chu さんの記事を読みながらとったメモ:

[共通点]
  • 2005年に開発開始
  • ファイルの revision の参照にファイルのハッシュ値を使う
  • ハッシュ値は manifest (tree) 内に管理される
  • 履歴を Directed Acyclic Graphs (DAGs) として管理
  • bisect, history rewriting, branch, selective commit などの高度な機能を提供 
 
[Mercurial の特徴]
  • 性能を向上させるため、Revlog というファイルフォーマットを開発
  • すべてのファイルはインデックスとデータファイルをまとめたもの
  • データファイルはスナップショットを含む
  • 差分のスナップショットはそのファイルのデルタの数がある閾値を超えたら作られる
  • インデックスはデータファイルの一部で、ファイルのリビジョンを表す
  • file revision から manifest が作られ、manifest から commit が生成される
  • この構造のおかげで、ファイルの生成や検索、(差分の?)計算は高速
  • ディスク使用量が比較的少なく、ネットワーク転送時も効率がいい
  • mercurial の branch は、commit をある branch に関連付ける感じ

[Git の特徴]
  • file blobs の形式で各種情報を格納
  • revision をすばやく保存するために、revision ごとに完全なファイルのコピーが作られる
  • ファイルのコピーは圧縮されるが、それでも多くの重複がでるため、データ量を減らすための packing がされる
  • それぞれの内容を個々のファイルに格納するため、hisotory がより扱いやすく、rsync などでコピーすることも可能
  • git の history は線形ではない(簡単に入れ替えたりもできるってことかな、差分じゃないから)
  • git の branch は commit へのポインタを管理する感じ --> だから rollabac とかしやすいぽい

0 件のコメント:

コメントを投稿