#pragma section-numbers off
[[TableOfContents]]

= 概要 =

= 公式サイト =
[http://www.selenic.com/hg/ Mercurial: shortlog]

[http://www.selenic.com/mercurial/wiki/ Mercurial Wiki]

[http://mercurial.berkwood.com/ Mercurial binary packages for Windows and Mac OS X]

http://www.selenic.com/mercurial/release/

http://www.selenic.com/mercurial/wiki/index.cgi/BinaryPackages

= 関連サイト =
[http://hgbook.red-bean.com/ Mercurial: The Definitive Guide]

[http://tortoisehg.sourceforge.net/ TortoiseHg @ SourceForge]

[http://trac.edgewall.org/wiki/TracMercurial TracMercurial - The Trac Project - Trac]

[http://www.selenic.com/mercurial/wiki/index.cgi/JapaneseTutorial JapaneseTutorial - Mercurial]

= 利用プロジェクト =
[http://opensolaris.org/os/community/tools/scm/ OpenSolaris Source Code Management at OpenSolaris.org]:{{{OpenSolaris}}}で利用

= インストール =
http://www.selenic.com/mercurial/release/

{{{
tar xvfz mercurial-1.2.1.tar.gz
cd mercurial-1.2.1
sudo python setup.py install
}}}


yumなら以下
{{{
yum install -y mercurial
}}}

参考:[http://python.matrix.jp/modules/mercurial.html Pythonで分散バージョン管理]

= 設定 =
最低限の設定はだいたい以下です

== コミット者情報 ==
$HOME/.hgrc にコミット時の名前とメルアドを設定します
{{{
[ui]
username = yourname <sample@sample.com>
}}}

== 無視ファイル設定 ==
$HOME/.hgignoreに無視ファイルを設定します
{{{
syntax: glob
*~
*.elc
*.pyc
*.class
.svn
.semantic.cache
.DS_Store
TAGS

}}}

== $Id$ とかを展開する ==
cvsとかsvn propset とか利用して $Id$ 等のプロパティを利用している場合hgでも利用したいかもしれない。

hgextフォルダ以下にkeyword.pyが必要。

.hgrc に設定する。

全部有効にする場合は以下みたいな設定になる。
{{{
[extensions]
hgext.keyword =
[keyword]
* =
}}}

設定したら
{{{
hg kwexpand ファイル名
}}}
として展開を指定してあげないと有効にならない。

詳細は

http://www.selenic.com/mercurial/wiki/index.cgi/KeywordPlan

http://www.selenic.com/mercurial/wiki/index.cgi/KeywordExtension

に記述がある。

== 色付ける ==
{{{
[extensions]
color=
}}}

http://mercurial.selenic.com/wiki/ColorExtension

== グラフログ ==
{{{
[extensions]
hgext.graphlog=
}}}

{{{hg glog}}}

== パッチ管理 ==
{{{
[extensions]
mq=
}}}

http://mercurial.selenic.com/wiki/MqExtension

= コマンド =
{{{hg help コマンド}}}のようにすると英語だけど説明がでます。

== レポジトリ ==
||hg clone path||リモートよりコピー||
||hg init||初期化||
||hg paths||push、pull先確認||
||hg push||パスのレボジトリに反映||
||hg pull||パスのレボジトリより取得||


== 情報 ==
||hg status||ステータス||
||hg diff file.txt||比較||
||hg log||履歴||
||hg annotate file.txt||どのリビジョンでどこが変更されたか||
||hg tip||tipリビジョン||
||hg parents||いまいじってる物の親の情報||
||hg heads||レポジトリ先端情報||

== コミット ==
||hg add file.txt||追加||
||hg ci -m "コメント" file.txt||コミット||
||hg remove file.txt||削除||
||hg update||更新||
||hg mv form to||名前変更(copy+removeになる)||
||hg revert||先端に戻す(ローカルは削除される)||
||hg revert -rREV file.txt||特定リビジョンを取得||
||hg rollback||最後のci,pull等を取り消し||

== パッチ ==
||hg import patch||パッチの適用||
||hg export||パッチ作成||
||hg incoming||pullされるファイル||
||hg outgoing||pushされるファイル||
||hg fetch||pull+update+merge||

== タグ・ブランチ ==
||hg copy from to||コピーする||
||hg tags||タグ一覧||
||hg tag タグ名||タグ付与||

branchの考え方とかは以下が詳しい
[http://d.hatena.ne.jp/dayflower/20080314/1205395287 Mercurial 勉強中 (6) - named branch と update -C - daily dayflower]

= log =
{{{
hg log -l1 で最後のログ
hg log -d-1 24時間以内
}}}

{{{
[alias]
l = log -r 0:tip
}}}

{{{
[extension]
hgext.pager =
}}}

ログを簡易出力にしたいならオプションに style 指定すると良い。
{{{
hg log --style=compact
}}

毎回なら hgrcに設定すると良い
{{{
[ui]
style=compact
}}}


= hook =
コミットした場合等になんらかの動作を連携させたい場合「hook」を利用します。

詳細は http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html に記述があります。

{{{
.hg/hgrc
}}}

に {{{[hooks]}}} を追加して処理を記述すれば良いことになります。

= MQ =
[http://dailyhacking.blogspot.com/2007/08/hg-mq.html Daily Hacking: HG MQ]

[http://d.hatena.ne.jp/dayflower/20090520/1242794877 Mercurial MQ について - daily dayflower]

= 他のSCMからの移行 =
hg convert を利用します。

.hgrc に以下を追加

{{{
[extensions]
hgext.convert=
}}}

== Subversionからの移行 ==
レポジトリをチェックアウトしながら変換します。変換前に変換対象の物が全部コミットされている事を確認した方が良いでしょう。

python bindingsが必要です。

http://www.open.collab.net/downloads/community/ からバイナリを取得してインストールするのが楽です。

{{{
sudo echo /opt/subversion/lib/svn-python >/Library/Python/2.5/site-packages/svn-python.pth
とか
sudo echo /opt/subversion/lib/svn-python >/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/svn-python.pth 
}}}

python bindingsのを自力でインストールする場合は http://trac.edgewall.org/wiki/TracOnOsxNoFink が参考になります。

{{{
hg convert -s svn http://exsample.com/svn/trunk/ hoge
とか
hg convert -s svn file://exsample/svn/trunk/ hoge
cd hoge
hg update
}}}

ログが多いと結構時間がかかります

= Emacs =
== aHg ==
[https://disi.unitn.it/~griggio/ahg.html aHg: An Emacs front-end for the Mercurial SCM]

微妙に変な所があるけれどシンプル

== mvc.el ==
[http://umiushi.org/~wac/mvc/ wac's webpage./mvc.el]

インターフェースが独特だったり、colorの変更に追随していなかったりしている

== DVC.el ==
[http://download.gna.org/dvc/ DVC: Distributed Version Control for Emacs]

[http://www.xsteve.at/prg/emacs_dvc/ XSteve's Emacs DVC.el page]

[http://www-aos.eps.s.u-tokyo.ac.jp/~takagi/dvc.html DVC - Distributed Version Control for Emacs]

初期設定だと微妙だったのでいろいろ変更すると良いのかもしれない

= Trac連携 =
[http://it.kndb.jp/entry/show/id/2363 CentOSにTrac+TracMercurialをインストールする - Knowledge Database IT]

= Git との連携 =
[http://hg-git.github.com/ Hg-Git Mercurial Plugin]

{{{
sudo easy_install -UZ hg-git
もしくは 
sudo env ARCHFLAGS='-Os -arch i386 -arch x86_64 -arch ppc -fno-common' easy_install -UZ hg-git
}}}

.hgrc に以下を記述
{{{
[extensions]
hggit=
}}}

動作確認。開発者のテスト用レポジトリを clone
{{{
hg clone git://github.com/schacon/munger.git
}}}

Gitのブランチつけたい場合は、以下を書いて、hg のbookmark を付けると Git のブランチに変換される。
{{{
[extensions]
hgext.bookmarks=
}}}

例えば以下のようにする
{{{
hg bookmark -r default master
hg bookmark -r 0.01 0.01-git
}}}

付与した bookmark は以下のコマンドで参照できる。
{{{
hg bookmarks
}}}

ブックマークはブランチと同名にできない物と思われる

[http://x.zpuppet.org/2009/02/27/mercurial-bookmarks/ x.zpuppet.org » mercurial bookmarks]

= Eclipse =
[http://www.vectrace.com/mercurialeclipse/ Mercurial Eclipse]

Mac で SSH認証が上手く通らない場合は以下を利用する

[http://josh-in-antarctica.blogspot.com/2008/06/mercurial-push-from-intellij.html Josh (Formerly) In Antarctica: Mercurial Push from IntelliJ]

== XREAとかSakraとかにインストール ==
[http://www.horaguchi.net/article.php/2520/ www.horaguchi.net - tako3 のソースは今まで、Free Subversion Hosting の Unfuddle に上げてたんだけど、]

{{{
python setup.py install --home=~
}}}

= 共有サイト =
[http://www.bitbucket.org/ Mercurial hosting — bitbucket.org]:無償

[http://sourcerepo.com/ Secure, Simple, Affordable Source Hosting - SourceRepo - Git Hosting, Subversion Hosting, Mercurial Hosting]:有償

= 参考サイト =
[http://hgtip.com/ Quick, easy-to-understand tips for using Mercurial / hg tip]

[http://dodgson.org/omo/t/?date=20070519#p02 steps to phantasien t(2007-05-19)  Mercurial で手軽な共有レポジトリをつくろう]

[http://po3a.blogspot.com/2006/10/mercurial-trac.html satolog: Mercurial と Trac のメモ]

[http://miau.s9.xrea.com/blog/rsd.php?itemid=818 XREA FREE で Mercurial を - miau's blog?]

[http://sarabande.info/2008/01/04/xrea%E3%81%A7mercurial%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB/ XREAでMercurialをインストール | Sarabande]

[http://www.selenic.com/mercurial/wiki/index.cgi/JapaneseCGI_Install JapaneseCGI Install - Mercurial]

[http://mono.kmc.gr.jp/~yhara/w/?MercurialTutorial Greenbear Laboratory - Mercurialを使ってみよう]

----
CategoryProgramingTools