======Mercurial======
* [[http://www.selenic.com/mercurial/wiki/ ]]
* [[http://www.selenic.com/mercurial/wiki/index.cgi/JapaneseTutorial | 日本語チュートリアル]]
* [[http://randt.jp/?page_id=262]]
* [[http://www.proton.jp/programming/mercurial.html]]
=====設定ファイル=====
設定は~/.hgrcに書く.\\
常に適用させたい除外ファイルは
~/.hgrcの[ui]にignore=~/.hgignoreを追加して
~/.hgignoreで無視するファイルを設定します。\\
特定のリポジトリに適用させる場合はそれぞれ
repo/.hg/hgrc \\
repo/.hgignore \\
に書きます。
.hgrcにとりあえず全部utf8を使うための設定。こうしないとservでの日本語が全滅します。
$ emacs ~/.hgrc
[ui]
username = foo
ignore= ~/.hgignore
[defaults]
add = --encoding=utf-8
clone = --encoding=utf-8
commit = --encoding=utf-8
pull = --encoding=utf-8
push = --encoding=utf-8
remove = --encoding=utf-8
revert = --encoding=utf-8
[extensions]
~/.hgignoreには
syntax: glob
.DS_Store
.svn
*~
TAGS
.hgignore
syntax:globはシェルのワイルドカードみたいな動きを使う場合
===== リポジトリ作成 =====
$ cd myproject
$ hg init
だけ・・・楽。
=====既存プロジェクトの登録=====
既存プロジェクトがmyprojectフォルダだとして、
$ cd myproject
$ hg init
$ hg commit -A -m "import"
"hg init"でmyprojectがワーキングディレクトリになって、\\
"hg commit -A"でワーキングディレクトリ内の全てのファイルを登録する。\\
やっぱり楽。
=====コミットしちゃったあとの取り消し=====
$ hg rollback
間違ってcommitした場合も一回分だけ戻せます。
=====新規ファイルの追加と消したファイルの削除=====
$ hg addremove
新規ファイルを全て追加し、!がついている消えたファイルを全て削除してくれます。
=====ブランチ(コピー)=====
Mercurialの場合ブランチはただのコピー。
$ hg clone src_directory clone_directory
#とか
$ hg clone ssh://username@host:port/directory
#例 sshをport10022で使っているmyexample.jpの/var/www/myprojectを複製する場合
$ hg clone ssh://myadmin@myexample.jp:10022//var/www/myproject
#そのあとリモート側で
$ hg update
=====ローカルの変更をリモートに反映=====
pushコマンドでリモートリポジトリにファイルをあげる。
$ hg push ssh://remoteuser@remotehost//var/www/myproject
でリモート側でupdateする
$ hg update
=====リモートの変更をローカルに反映=====
逆にリモート側の変更をローカルに適用させたい場合。pullを使う。
$ hg pull ssh://remoteuser@remotehost//var/www/myproject
#成功したらローカル側でupdate
$ hg update
=====さくらインターネットにMercurialをインストール=====
さくらインターネットにMercurialをインストールするときのめも。
まずvirtual-pythonで個人のpython環境を作る。
$ cd src
$ wget http://peak.telecommunity.com/dist/virtual-python.py
$ python virtual-python.py
で~/binにpythonがインストールされるので.zshrcとか.cshrcにパスを通しておく。
お次ぎにpythonのcpanみたいなeasy_installをインストール
$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ python ez_setup.py
そのあとにeasy_installでMercurialをインストール
$ easy_install mercurial
#追記
さくらインターネットのFreeBSDのバージョンが7.1にあがったらなんかmercurialが動かなくなったのでその対策。pythonが2.5になったせい?わかりません。
下記ではいろいろ環境変数を設定していますがわかんないんで色々書いとけ作戦です。
とりあえず今入ってるMercurialを消しとく。なんとなく。
* $HOME/lib/python2.4/site-packages/easy-install.pthにあるmercurialを参照している行を消す。
* $HOME/bin/pythonを消すか名前変更。
* インストールされたeggファイルとかフォルダを削除。下みたいな場所にあるやつ。
$ rm -R /home/user/lib/python2.4/site-packages/mercurial-1.1.2-py2.4-freebsd-6.1-RELEASE-p23-i386.egg/
ようやくインストール。 \\
まず~/.zshrcかなんかに下記を追加。
export PYTHONHOME=/usr/local/
export PYTHONLIB=/usr/local/lib/python2.5
export PYTHONPATH=/usr/local/lib/python2.5
そしたら
$ /usr/local/bin/python2.5 virtual-python.py
Creating /home/user/lib/python2.5
Creating /home/user/lib/python2.5/site-packages
Creating /home/user/include/python2.5
Copying /usr/local/bin/python2.5 to /home/user/bin
You're now ready to download ez_setup.py, and run
/home/user/bin/python ez_setup.py
次にまた~/.zshrcを編集。さっきの/usr/local/で設定したpathを全部消して$HOMEのpythonに設定し直します。
#export PYTHONHOME=/usr/local/
#export PYTHONLIB=/usr/local/lib/python2.5
#export PYTHONPATH=/usr/local/lib/python2.5
#上のやつはコメントアウトするか消す。
export PYTHONHOME=$HOME
export PYTHONLIB=$HOME/lib/python2.5
export PYTHONPATH=$HOME/lib/python2.5
その次に~/binにpathを通しておいてから
$ python ez_setup.py
$ easy_install Mercurial
で完了