Mercurial チュートリアル hginit.com の和訳 (Setting up for a Team)

Mercurial を使うことで得られる恩恵の一つはチームで同じコードを担当できることだ。
Mercurial はそれぞれ別々に作業させてくれるし、変更があればそれを一つにマージさせてくれる。

Setting up for a Team

Mercurial を使った共同作業で最も一般的な方法は、中央リポジトリを設定し、さらに私たち一人一人は各自のコンピュータにプライベートなリポジトリを持つことだ。
私たちは中央リポジトリフリーマーケットように使うことが出来て、そこで私たちは私たちの作った物を交換したり変更したり出来る。


やっつけで中央リポジトリを作る方法は Mercurial 組み込みの web サーバを使うことである。
あなたがすべきことの全ては、リポジトリを hg init で作成し、hg serve で web 上にそれを公開することだ。デフォルトでは port 8000 に公開される。

hg serve

web サーバを走らせて、現在のリポジトリをインターネット経由でアクセス出来るようにする。

C:\> mkdir CentralRepo

C:\> cd CentralRepo

C:\CentralRepo> hg init

C:\CentralRepo> hg serve

このコンピュータの名前は joel.example.com なので、web ブラウザで http://joel.example.com:8000/ に行くと、サーバが上がっている事がわかる。リポジトリは完全に空だけれど。


中央の web サーバが走っているのなら、私はこのリポジトリをサーバから私のコンピュータへ私が使うために clone することが出来る。このリポジトリは今は空なので、clone してもただ空のリポジトリが手に入るだけだけど。

hg clone

完全なリポジトリのコピーを作成する。

C:\Users\joel> hg clone http://joel.example.com:8000/ recipes
no changes found
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

C:\Users\joel> cd recipes

C:\Users\joel\recipes> dir
 Volume in drive C has no label.
 Volume Serial Number is 84BD-9C2C

 Directory of C:\Users\joel\recipes

02/08/2010  02:46 PM              .
02/08/2010  02:46 PM              ..
02/08/2010  02:46 PM              .hg
               0 File(s)              0 bytes
               3 Dir(s)  41,852,125,184 bytes free

じゃあ、私は guac と呼ぶ、私の大好きなグアカマロのレシピのファイルを作ろう。

guac :

*1272596177* 2 ripe avocados
*1272596178* 1/2 red onion, minced (about 1/2 cup)
*1272596179* 1-2 serrano chiles, stems and seeds removed, minced
*1272596180* 2 tablespoons cilantro leaves, finely chopped
*1272596181* 1 tablespoon of fresh lime or lemon juice
*1272596182* 1/2 teaspoon coarse salt
*1272596183* A dash of freshly grated black pepper
*1272596184* 1/2 ripe tomato, seeds and pulp removed, chopped

Crunch all ingredients together.
Serve with tortilla chips.

私はこのファイルを追加して、最初のオフィシャルバージョンにするためにコミットする。

C:\Users\joel\recipes> hg add
adding guac

C:\Users\joel\recipes> hg commit

コミットコメントを書く。

私はすばやく編集して小さな変更を作ると、私たちはリポジトリに小さな履歴を持つことになる。

guac :

…
* A dash of freshly grated black pepper
* 1/2 ripe tomato, seeds and pulp removed, chopped

Crunch all ingredients together.
Serve with tortilla chips.

・・・このようにちょと変更する。

guac :

…
* A dash of freshly grated black pepper
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with tortilla chips.

そして今、この変更をコミットする。

C:\Users\joel\recipes> hg status
M guac

C:\Users\joel\recipes> hg diff guac
diff -r c1fb7e7fbe50 guac
--- a/guac      Mon Feb 08 14:50:08 2010 -0500
+++ b/guac      Mon Feb 08 14:51:08 2010 -0500
@@ -7,5 +7,5 @@
 * A dash of freshly grated black pepper
 * 1/2 ripe tomato, seeds and pulp removed, chopped

-Crunch all ingredients together.
+Smoosh all ingredients together.
 Serve with tortilla chips.

C:\Users\joel\recipes> hg com -m "Change crunch to smoosh"

C:\Users\joel\recipes> hg log
changeset:   1:a52881ed530d
tag:         tip
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:51:18 2010 -0500
summary:     Change crunch to smoosh

changeset:   0:c1fb7e7fbe50
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:50:08 2010 -0500
summary:     Initial version of guacamole recipe

私がコミットした時に、私が -m 引数を使っていて、以前は使っていなかったことに気づいて欲しい。これはコミットメッセージをコマンドラインからエディタを使わずに提供する方法だ。

OK,どこまで話したっけ? 今までのところ、私たちは中央リポジトリを得て、それから自分用のクローンを得た。私は2つの変更をした後でそれらをコミットしたが、これらの変更は私のクローンにだけある。中央リポジトリにはまだ無いんだ。そういうわけで、世界はこんな感じに見える。

それでは hg push コマンドを使って、私のリポジトリにある私の変更を中央リポジトリに push する。

hg push

現在のリポジトリの新しい変更を他のリポジトリに push する。

C:\Users\joel\recipes> hg push
pushing to http://joel.example.com:8000/
searching for changes
ssl required


おお、すごい。どうも動かなかったようだ。私は行き当たりばったりに web サーバを走らせたことによるセキュリティ関連の事項と、世界中の誰に対しても愚かな変更を push 出来るようにすることを忘れていた。ちょっとの間我慢して欲しいのだが、世界中の誰に対してでもやりたい事を許可するようにサーバを設定しよう。これにはサーバの .hg\hgrc ファイルを編集すればよい。

.hg\hgrc :

[web]
push_ssl=False
allow_push=*

言うまでも無くこれはかなり危険だが、もしあなたが素晴らしい保護のあるLANで働いていて、そこには素晴らしいファイアウォールがあって、あなたのLAN内で働いている全ての人を信用するのであれば、このやり方でOKだ。そうでないのならセキュリティに関する追加の項目を読んだほうがよい。

OK,サーバを再点火だ。

C:\CentralRepo> hg serve

今なら push 出来るはずだ。

C:\Users\joel\recipes> hg push
pushing to http://joel.example.com:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files

Yay! 今、世界はこんな感じだ。

私にはあなたが何を考えているのかわかる。あなたはこう考えている。「あれ、ジョエル、これはおかしいよ。なぜリポジトリにはファイルではなく変更が含まれているんだ? どこに guac ファイルがあるんだ?」

そう、変な感じだ。だけどそれが分散バージョン管理のやり方なんだ。リポジトリはただ変更の巨大な積み重ねを収容しているだけなんだ。変更をきれいな透明のシートの一つだと思って欲しい。あなたは透明なシートの束を持っていて、最新の更新が一番上に来るように、それを積み重ねていく。そして上からそれを見下ろすと
-ジャジャーン!-
あなたは現在のバージョンのファイルを見ているんだ。あなたが積み重なりの一番上のところから透明なものを剥がしていくと、あなたはだんだんと古いバージョンを見るようになる。

私たちは web ブラウザを使って中央リポジトリの現在を覗き込むことが出来る。

まさにあなたが期待している通りだ。

今、私がレシピへの取り組みにローズの助けが欲しいとしよう。ローズはテストチームの一員だ。彼女のソフトウェアをテストしている様子は、中年女性がベガスで一時間くらい馬鹿みたいに口をあけてスロットマシーンにコインをつぎ込んでいるのに似ていると、誰もが同意する。あなたが彼女にあなたのコードの新しいバージョンを投げると、彼女はそれを23の異なる linux ディストリビューションでテストしていく。次々と、無感情に、動かずに、あなたと話をするのをやめて、トルコバージョンの Ubuntu linux にまで注意深くだ。ローズは素晴らしいテスターだが、私は彼女のゾンビのような振る舞いに時々悪態をついてしまう。

C:\Users\rose> hg clone http://joel.example.com:8000/ recipes
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

ローズは hg clone コマンドを使って彼女用のリポジトリの完全コピーを取得する。 hg clone は2つの引数を取る。リポジトリのURLとあなたがクローンを作りたいディレクトリのパス名だ。彼女は彼女用の recipes フォルダを作った。

C:\Users\rose> cd recipes

C:\Users\rose\recipes> dir
 Volume in drive C has no label.
 Volume Serial Number is 84BD-9C2C

 Directory of C:\Users\rose\recipes

02/08/2010  03:23 PM    <DIR>          .
02/08/2010  03:23 PM    <DIR>          ..
02/08/2010  03:23 PM    <DIR>          .hg
02/08/2010  03:23 PM               394 guac
               1 File(s)            394 bytes
               3 Dir(s)  41,871,872,000 bytes free

C:\Users\rose\recipes> hg log
changeset:   1:a52881ed530d
tag:         tip
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:51:18 2010 -0500
summary:     Change crunch to smoosh

changeset:   0:c1fb7e7fbe50
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:50:08 2010 -0500
summary:     Initial version of guacamole recipe

彼女が全体のログを見るために hg log とタイプした事に注目して欲しい。彼女は実際に、今まで起こった全ての完全な履歴を保持しているリポジトリ全体をダウンロードしたんだ。

ローズは変更を一つ作って、チェックインした。

guac :

* 2 ripe avocados
* 1/2 red onion, minced (about 1/2 cup)
* 1-2 serrano chiles, stems and seeds removed, minced
* 2 tablespoons cilantro leaves, finely chopped
* 1 tablespoon of fresh lime or lemon juice
…

・・・こんな感じに変更する。

guac :

* 2 ripe avocados
* 1/2 red onion, minced (about 1/2 cup)
* 1-2 habanero chiles, stems and seeds removed, minced
* 2 tablespoons cilantro leaves, finely chopped
* 1 tablespoon of fresh lime or lemon juice
…

彼女がコミットをする。彼女はあたかもサーバが走っていないかのように、これを行ったことに注目して欲しい。
コミットは完全に彼女のマシンで起こったことなのだ。

C:\Users\rose\recipes> hg diff
diff -r a52881ed530d guac
--- a/guac      Mon Feb 08 14:51:18 2010 -0500
+++ b/guac      Mon Feb 08 15:28:57 2010 -0500
@@ -1,6 +1,6 @@
 * 2 ripe avocados
 * 1/2 red onion, minced (about 1/2 cup)
-* 1-2 serrano chiles, stems and seeds removed, minced
+* 1-2 habanero chiles, stems and seeds removed, minced
 * 2 tablespoons cilantro leaves, finely chopped
 * 1 tablespoon of fresh lime or lemon juice
 * 1/2 teaspoon coarse salt

C:\Users\rose\recipes> hg com -m "spicier kind of chile"

C:\Users\rose\recipes> hg log
changeset:   2:689026657682
tag:         tip
user:        Rose Hillman <rose@example.com>
date:        Mon Feb 08 15:29:09 2010 -0500
summary:     spicier kind of chile

changeset:   1:a52881ed530d
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:51:18 2010 -0500
summary:     Change crunch to smoosh

changeset:   0:c1fb7e7fbe50
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:50:08 2010 -0500
summary:     Initial version of guacamole recipe

彼女が彼女の変更を作っている間、私も同じ時に変更を作ることが出来る。

guac :

…
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with tortilla chips.

・・・こんな感じに変更する。

guac :

…
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with potato chips.

私がそれをチェックインした後で、私の#2のログがローズのログと違っている箇所を見てほしい。

C:\Users\joel\recipes> hg com -m "potato chips. No one can eat just one."

C:\Users\joel\recipes> hg log
changeset:   2:4ecdb2401ab4
tag:         tip
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 15:32:01 2010 -0500
summary:     potato chips. No one can eat just one.

changeset:   1:a52881ed530d
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:51:18 2010 -0500
summary:     Change crunch to smoosh

changeset:   0:c1fb7e7fbe50
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:50:08 2010 -0500
summary:     Initial version of guacamole recipe

私たちの履歴は分岐し始めた。

ご心配無く。・・・一分以内にこれらの分岐が元通り一つなって、一つのおいしいハバネロベースのポテトチップディップになる方法を理解するようになる。

hg outgoing

現在のリポジトリで push されるのを待っている変更の一覧を作成する。

ローズは仕事を続けて、未接続のまま、彼女が望むだけたくさんの変更を作り、彼女のリポジトリにそれらをまたコミットし、時には元に戻したり出来る。ある時点で、しかし、彼女は外の世界と彼女がコミットした全ての変更を共有したくなるだろう。彼女は中央リポジトリ送られるのを待っている変更のリストを表示するコマンド hg outgoing をタイプすることが出来る。これらは、もし彼女が hg push をしたら、hg push が送信する事になる変更である。

C:\Users\rose\recipes> hg outgoing
comparing with http://joel.example.com:8000/
searching for changes
changeset:   2:689026657682
tag:         tip
user:        Rose Hillman <rose@example.com>
date:        Mon Feb 08 15:29:09 2010 -0500
summary:     spicier kind of chile

hg outgoing の考えている内容はこんな感じだ。現在のリポジトリにある変更のうち、中央リポジトリに無いものを単純に一覧にする。

OK, それではローズが彼女の変更を push するよ。

C:\Users\rose\recipes> hg push
pushing to http://joel.example.com:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files

この時の世界はこのように見える。

私が夜明けの4杯目のカフェラテから戻ると、私はポテトチップの変更を push する覚悟も出来ていた。

C:\Users\joel\recipes> hg outgoing
comparing with http://joel.example.com:8000/
searching for changes
changeset:   2:4ecdb2401ab4
tag:         tip
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 15:32:01 2010 -0500
summary:     potato chips. No one can eat just one.


C:\Users\joel\recipes> hg push
pushing to http://joel.example.com:8000/
searching for changes
abort: push creates new remote heads!
(did you forget to merge? use push -f to force)


あああああああ!!失敗した!・・・ところで、そこにメッセージが出てるのはわかる?それは 強制実行するために -f を使えって言っているのかな?なんとも恐ろしいアドバイスだ。絶対に、絶対に、絶対に、強制実行の push -f を使ってはいけない。後悔することになる。今は信じて欲しい。

ローズの push が成功して、私の方では失敗した理由はポテトチップがアボガドのディップに合わないからだ。冗談だよ!もし気づいたら見て欲しい。

push が失敗したのは私たちの両方で変更を作成したので、どうにかしてそれをマージする必要があり、そして Mercurial がそれを知っているからだ。

まず私がやらなければならない事は、私が持っていない中央リポジトリに置いてある全ての変更を手に入れることであり、そうすることで私はマージすることが出来る。

C:\Users\joel\recipes> hg incoming
comparing with http://joel.example.com:8000/
searching for changes
changeset:   3:689026657682
tag:         tip
parent:      1:a52881ed530d
user:        Rose Hillman <rose@example.com>
date:        Mon Feb 08 15:29:09 2010 -0500
summary:     spicier kind of chile


C:\Users\joel\recipes> hg pull
pulling from http://joel.example.com:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)

+1 された head についてわけがわからないところがある。私のリポジトリには、3つの変更がきちんと積み重なっていたのに、今では双頭の化け物になってしまって、2つの異なる変更が不安定に積み重なっている。

私は今、両方のバージョンを取得して私のリポジトリに入れた。・・・私のバージョンを得るやり方はこうだ。

C:\Users\joel\recipes> type guac
* 2 ripe avocados
* 1/2 red onion, minced (about 1/2 cup)
* 1-2 serrano chiles, stems and seeds removed, minced
* 2 tablespoons cilantro leaves, finely chopped
* 1 tablespoon of fresh lime or lemon juice
* 1/2 teaspoon coarse salt
* A dash of freshly grated black pepper
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with potato chips.

そしてローズのバージョンを得る時はこうだ。

C:\Users\joel\recipes> hg cat -r 3 guac
* 2 ripe avocados
* 1/2 red onion, minced (about 1/2 cup)
* 1-2 habanero chiles, stems and seeds removed, minced
* 2 tablespoons cilantro leaves, finely chopped
* 1 tablespoon of fresh lime or lemon juice
* 1/2 teaspoon coarse salt
* A dash of freshly grated black pepper
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with tortilla chips.

そして、それらをマージするのは私次第だ。幸運なことに、これは簡単だ。

C:\Users\joel\recipes> hg merge
merging guac
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)

C:\Users\joel\recipes> type guac
* 2 ripe avocados
* 1/2 red onion, minced (about 1/2 cup)
* 1-2 habanero chiles, stems and seeds removed, minced
* 2 tablespoons cilantro leaves, finely chopped
* 1 tablespoon of fresh lime or lemon juice
* 1/2 teaspoon coarse salt
* A dash of freshly grated black pepper
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with potato chips.

見て!hg merge コマンドは私の2つの head を統合して一つにした。このケースでは、私たちの両方でファイルの別々の部分を編集したので、すべてにおいて衝突する箇所は無く、マージは問題も無く進んだ。

hg merge

2つの head をマージする。

私はまだコミットしなければならない。これは重要なことだ。もしマージに失敗したら、私はいつでも再び revert するのを試みてもよい。マージは成功したため、私はコミットする。そうすると、私は中央リポジトリに私の変更を push する事が出来る。

C:\Users\joel\recipes> hg commit -m "merge"

C:\Users\joel\recipes> hg log
changeset:   4:0849ca96c304
tag:         tip
parent:      2:4ecdb2401ab4
parent:      3:689026657682
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 16:07:23 2010 -0500
summary:     merge

changeset:   3:689026657682
parent:      1:a52881ed530d
user:        Rose Hillman <rose@example.com>
date:        Mon Feb 08 15:29:09 2010 -0500
summary:     spicier kind of chile

changeset:   2:4ecdb2401ab4
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 15:32:01 2010 -0500
summary:     potato chips. No one can eat just one.

changeset:   1:a52881ed530d
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:51:18 2010 -0500
summary:     Change crunch to smoosh

changeset:   0:c1fb7e7fbe50
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:50:08 2010 -0500
summary:     Initial version of guacamole recipe


C:\Users\joel\recipes> hg out
comparing with http://joel.example.com:8000/
searching for changes
changeset:   2:4ecdb2401ab4
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 15:32:01 2010 -0500
summary:     potato chips. No one can eat just one.

changeset:   4:0849ca96c304
tag:         tip
parent:      2:4ecdb2401ab4
parent:      3:689026657682
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 16:07:23 2010 -0500
summary:     merge


C:\Users\joel\recipes> hg push
pushing to http://joel.example.com:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files

そして今、中央リポジトリは私がした内容と同じになっている。

OK,私はローズの変更と、そして私の変更を手に入れたが、ローズはまだ私の変更を持っていない。

一つだけ私はローズに関してあなたに話すのを忘れていたことがある。彼女は医者だ。変な事でも無いだろう?彼女はシナイ山で腕利きの小児科医で、たぶんこのくだらないテスターの仕事で得られる報酬の5倍は稼いでいた。なぜ彼女が医療の現場を離れたのかは誰も知らない。他のテスターは何か悲惨な事があったと考えている。彼女はかつて家庭を持っていてた。彼女のデスクには10歳のかわいい子供の写真が置いてあるが、彼女は今は独りで生活をしていて、私たちは詮索したくないと思っている。

ローズはサインの、新しい材料をリポジトリから pull して手に入れる必要がある。

C:\Users\rose\recipes> hg pull
pulling from http://joel.example.com:8000/
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
(run 'hg update' to get a working copy)

了解。今、あなたはちょっと変なことを見つけたかもしれないが、それでもローズはこれらの新しい変更を彼女のリポジトリに pull した。しかし、彼女の作業中のディレクトリにはまだこれらのファイルは無い。

C:\Users\rose\recipes> type guac
* 2 ripe avocados
* 1/2 red onion, minced (about 1/2 cup)
* 1-2 habanero chiles, stems and seeds removed, minced
* 2 tablespoons cilantro leaves, finely chopped
* 1 tablespoon of fresh lime or lemon juice
* 1/2 teaspoon coarse salt
* A dash of freshly grated black pepper
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with tortilla chips.

わかった? 彼女はまだトルティーリャチップスで作業しているんだ。トルティーリャチップス!

彼女は彼女のリポジトリのどこかに確かに私の新しい更新を持っているのだが・・・

C:\Users\rose\recipes> hg log
changeset:   4:0849ca96c304
tag:         tip
parent:      3:4ecdb2401ab4
parent:      2:689026657682
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 16:07:23 2010 -0500
summary:     merge

changeset:   3:4ecdb2401ab4
parent:      1:a52881ed530d
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 15:32:01 2010 -0500
summary:     potato chips. No one can eat just one.

changeset:   2:689026657682
user:        Rose Hillman <rose@example.com>
date:        Mon Feb 08 15:29:09 2010 -0500
summary:     spicier kind of chile

changeset:   1:a52881ed530d
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:51:18 2010 -0500
summary:     Change crunch to smoosh

changeset:   0:c1fb7e7fbe50
user:        Joel Spolsky <joel@joelonsoftware.com>
date:        Mon Feb 08 14:50:08 2010 -0500
summary:     Initial version of guacamole recipe

hg parent

show the changeset that’s in the working directory

これらはただ作業中のディレクトリに無いだけだ。なぜなら彼女はまだ changeset #2 で作業しているからだ。あなたはこのことを "parent" コマンドで確認する事が出来る。

C:\Users\rose\recipes> hg parent
changeset:   2:689026657682
user:        Rose Hillman <rose@example.com>
date:        Mon Feb 08 15:29:09 2010 -0500
summary:     spicier kind of chile

Mercurial は私たちにとって素晴らしいものだ。 pullの実行 、すなわち人々が作成した最新の変更を手に入れる操作は常に安全だ。後で好きな時にそれらを切り替えて作業する事も出来る。

引数無しの hg up コマンドは作業中のディレクトリを tip (完全にTOPのchangeset)に変えることを思い出して欲しい。このケースの番号は 4 だ。

C:\Users\rose\recipes> hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

C:\Users\rose\recipes> type guac
* 2 ripe avocados
* 1/2 red onion, minced (about 1/2 cup)
* 1-2 habanero chiles, stems and seeds removed, minced
* 2 tablespoons cilantro leaves, finely chopped
* 1 tablespoon of fresh lime or lemon juice
* 1/2 teaspoon coarse salt
* A dash of freshly grated black pepper
* 1/2 ripe tomato, seeds and pulp removed, chopped

Smoosh all ingredients together.
Serve with potato chips.

そして今、彼女はすべて変更された最新のバージョンを見ている。

あなたがチームで働いているのなら、あなたの作業フローは次のようになるだろう。

  1. もしあなたがしばらく作業をしていなかったのなら、他の全員が作業した最新のバージョンを手に入れる。
    • hg pull
    • hg up
  2. 変更する
  3. コミットする (ローカルで)
  4. 他の全員に迷惑をかけない素晴らしいコードが出来るまで2-3のステップを繰り返す
  5. あなたに共有する用意が出来た時、
    • hg pull で他の全員の変更を手に入れる (もしあるなら)
    • hg merge であなたの変更とそれらをマージする
    • テスト! してマージがなにものもぶち壊しにしてしまっていないことを確認する
    • hg commit (マージしたものを)
    • hg push

自己診断テスト

このチュートリアルを読んだ後であなたが理解しておくべきやり方は以下の通りだ。

  1. 中央リポジトリを設定して、チームにそのクローンを作る許可をする
  2. 中央リポジトリに変更を push する
  3. 中央リポジトリから変更を pull する
  4. 他の貢献者との違いをマージする

次回は過ちちをどのように修正するのかについて話そう。

目次へ