ノード: Detecting And Resolving Conflicts, 次: Finding Out Who Did What (Browsing Log Messages), 前: Revision Numbers, 上: A Day With CVS
コンフリクトを発見するのは簡単です。 CVS は update を実行する前に、間違 えようのない言葉で「コンフリクトがあるよ」と知らせてくれます。まずコンフ リクトを作ってみましょう。hello.c を編集して、次のような行を追加して下さ い:
printf ("this change will conflict\n");
qsmith がこういう行をコミットしたその場所にです:
printf ("between hello and goodbye\n");
この時点で、作業コピーの hello.c のステータスは次のようになります
floss$ cvs status hello.c =================================================================== File: hello.c Status: Needs Merge Working revision: 1.2 Mon Apr 19 02:17:07 1999 Repository revision: 1.3 /usr/local/cvs/myproj/hello.c,v Sticky Tag: (none) Sticky Date: (none) Sticky Options: (none) floss$
リポジトリも作業コピーも変更されていて、それらの変更をマージしなければな らない、という意味です。(CVS は変更がコンフリクトしていることはまだ気づ いてません、update をまだ実行していないですからね) update を走らせた時に はこうなります:
floss$ cvs update hello.c RCS file: /usr/local/cvs/myproj/hello.c,v retrieving revision 1.2 retrieving revision 1.3 Merging differences between 1.2 and 1.3 into hello.c rcsmerge: warning: conflicts during merge cvs update: conflicts found in hello.c C hello.c floss$
最後の行は giveaway 。ファイル名の横にある C は変更がマージされたけれど もコンフリクトした、ということを示します。 hello.c の内容には両方の変更 が示されています:
#include <stdio.h> void main () { printf ("Hello, world!\n"); <<<<<<< hello.c printf ("this change will conflict\n"); ======= printf ("between hello and goodbye\n"); >>>>>>> 1.3 printf ("Goodbye, world!\n"); }
コンフリクトはつねにコンフリクトマーカで区切られ、次の形式で示されます:
<<<<<<< (filename) 作業コピーの未コミットの変更 blah blah blah ======= リポジトリからきた新しい変更 blah blah blah などなど (リポジトリの最新リビジョン番号など) >>>>>>> (latest revision number in the repository)
Entries ファイルには、ファイルが現在中途半端な状態になっていることが書い てあります。
floss$ cat CVS/Entries /README.txt/1.1.1.1/Sun Apr 18 18:18:22 1999// D/a-subdir//// D/b-subdir//// /hello.c/1.3/Result of merge+Tue Apr 20 03:59:09 1999// floss$
コンフリクトを解消するには、ファイルを編集して、あるべき姿にし、コンフリ クトマーカを取り除き、そしてコミットします。必ずしも変更のうちどちらかを 選んでもう片方を捨てたりする必要はありません、どちらの変更もいまいちだと 思えば、コンフリクトしているところ(ファイル全部でもかまわないんですが)を すっかり書き換えてしまってもいいのです。今回は最初の変更に合わせることに して、でもキャピタライズと句読点の打ちかたを少しだけ変えておくことにしま しょう。
floss$ emacs hello.c (make the edits...) floss$ cat hello.c #include <stdio.h> void main () { printf ("Hello, world!\n"); printf ("BETWEEN HELLO AND GOODBYE.\n"); printf ("Goodbye, world!\n"); } floss$ cvs ci -m "adjusted middle line" cvs commit: Examining . cvs commit: Examining a-subdir cvs commit: Examining a-subdir/subsubdir cvs commit: Examining b-subdir Checking in hello.c; /usr/local/cvs/myproj/hello.c,v <- hello.c new revision: 1.4; previous revision: 1.3 done floss$