目次
文書の過去の版を表示しています。
Mercurial - 分散バージョン管理システム
前提条件
ここでは Python と pip の導入が完了していることを前提とする。
Python のインストール
easy_install、setuptools、pip - パッケージ管理
CentOS の場合は gcc と python-devel をインストールしておく。
$ sudo yum install gcc python-devel
インストール
$ sudo pip install mercurial
動作確認
$ hg version Mercurial - 分散構成管理ツール(バージョン 3.4.1) (詳細は http://mercurial.selenic.com を参照) Copyright (C) 2005-2015 Matt Mackall 他 本製品はフリーソフトウェアです。 頒布条件に関しては同梱されるライセンス条項をお読みください。 市場適合性や特定用途への可否を含め、 本製品は無保証です。
使い方
初期設定
vi ~/.hgrc
[ui] username = Tomoyan <tomoyan@example.com>
リポジトリの作成
既存のディレクトリでリポジトリを作成する。
$ mkdir repos $ cd repos $ hg init
新たにリポジトリのディレクトリを作成する。
$ hg init repos
ソース管理から除外するファイルの設定
$ vi .hgignore
# Shell 形式パターンマッチ syntax: glob *.pyc
# 正規表現パターンマッチ syntax: regexp ^\.git/
ファイルの追加
$ hg add file.txt
ステータスの確認
$ hg status A file.txt
コミット
$ hg commit
差分表示
$ hg diff
編集取り消し
$ hg revert file.txt
コミット取り消し
$ hg rollback
コミットログ表示
$ hg log
リモートリポジトリの複製
ssh経由でリモートリポジトリをローカルに複製する。
$ hg clone ssh://user@server:port//var/hg/hoge/fuga my-fuga
リモートリポジトリの変更取得
$ hg pull $ hg update
作業領域の変更を破棄する場合
$ hg update -C
リモートリポジトリへ変更反映
$ hg push ssh://user@server:port//var/hg/hoge/fuga
※push先にリポジトリが存在している必要がある。存在しない場合は作成するかcloneしておくこと。
.hg/hgrc に以下の記載があるなら省略できる。
[paths] default = ssh://user@server:port//var/hg/hoge/fuga
$ hg push
サーバーでリポジトリを作成する場合。
$ hg init fuga
クライアントからサーバーへクローンする場合。
$ hg clone . ssh://user@server:port//var/hg/hoge/fuga
git を Mercurial へリポジトリ変換
convert エクステンションを有効化する。
$ vi ~/.hgrc
- ~/.hgrc
[extensions] convert =
git を Mercurial へ変換
$ hg convert [repository] [new-repository] $ cd new-repository $ hg update
トラブルシューティング
インストール時に「gcc: エラー」が発生する
日本語では、gcc: エラー: /usr/lib/rpm/redhat/redhat-hardened-cc1: そのようなファイルやディレクトリはありません
英語では、g++: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory が発生する。
redhat-rpm-config パッケージをインストールしてから行う。
$ sudo dnf install redhat-rpm-config