Svn-resolve-conflicts

提供:Dev Guides
移動先:案内検索

SVN-競合の解決

_Tom_は、プロジェクトのREADMEファイルを追加することにしました。 そこで彼は_README_ファイルを作成し、それにTODOリストを追加します。 これを追加すると、ファイルリポジトリはリビジョン6になります。

[tom@CentOS trunk]$ cat README
/*TODO: Add contents in README file*/

[tom@CentOS trunk]$ svn status
?       README

[tom@CentOS trunk]$ svn add README
A         README

[tom@CentOS trunk]$ svn commit -m "Added README file. Will update it's content in future."
Adding         trunk/README
Transmitting file data .
Committed revision 6.

_Jerry_は、リビジョン6にある最新のコードをチェックアウトします。 そしてすぐに彼は働き始めます。 数時間後、_Tom_はREADMEファイルを更新し、変更をコミットします。 変更されたREADMEは次のようになります。

[tom@CentOS trunk]$ cat README
* Supported operations:

1) Accept input
2) Display array elements

[tom@CentOS trunk]$ svn status
M       README

[tom@CentOS trunk]$ svn commit -m "Added supported operation in README"
Sending        trunk/README
Transmitting file data .
Committed revision 7.

現在、リポジトリはリビジョン7にあり、_Jerry’s_作業コピーは古くなっています。 _Jerry_はREADMEファイルも更新し、変更をコミットしようとします。

Jerry’s READMEファイルは次のようになります。

[jerry@CentOS trunk]$ cat README
* File list

1) array.c  Implementation of array operation.
2) README   Instructions for user.

[jerry@CentOS trunk]$ svn status
M       README

[jerry@CentOS trunk]$ svn commit -m "Updated README"
Sending        trunk/README
svn: Commit failed (details follow):
svn: File or directory 'README' is out of date; try updating
svn: resource out of date; try updating

ステップ1:競合を表示する

Subversionは、READMEファイルが最後に更新されてから変更されたことを検出しました。 そのため、_Jerry_は作業コピーを更新する必要があります。

[jerry@CentOS trunk]$ svn up
Conflict discovered in 'README'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options:

SubversionはREADMEファイルとの競合があると不平を言っており、Subversionはこれを解決する方法を知りません。 したがって、_Jerry_は_df_オプションを選択して競合を確認します。

[jerry@CentOS trunk]$ svn up
Conflict discovered in 'README'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: df
--- .svn/text-base/README.svn-base  Sat Aug 24 18:07:13 2013
+++ .svn/tmp/README.tmp Sat Aug 24 18:13:03 2013
@@ -1 +1,11 @@
-/*TODO: Add contents in README file*/
+<<<<<<< .mine
+* File list

+1) array.c Implementation of array operation.
+2) README  Instructions for user.
+=======
+* Supported operations:

+1) Accept input
+2) Display array elements
+>>>>>>> .r7
Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options:

ステップ2:競合を延期する

次に、_Jerry_は_postpone(p)_オプションを選択し、競合を解決できるようにします。

Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: p
C    README
Updated to revision 7.
Summary of conflicts:
  Text conflicts: 1

テキストエディターでREADMEを開いた後、彼はSubversionに_Tom’s_コードと競合マーカー付きのコードの両方が含まれていることに気付きました。

[jerry@CentOS trunk]$ cat README
<<<<<<< .min
* File list

1) array.c  Implementation of array operation.
2) README   Instructions for user.
=======
* Supported operations:

1) Accept input
2) Display array elements
>>>>>>> .r7

_Jerry_は彼と同様に_Tom’s_の変更を望んでいるため、競合マーカーを含む行を削除するだけです。

したがって、変更されたREADMEは次のようになります。

[jerry@CentOS trunk]$ cat README
* File list

1) array.c  Implementation of array operation.
2) README   Instructions for user.

* Supported operations:

1) Accept input
2) Display array elements

_Jerry_は競合を解決し、コミットを再試行しました。

[jerry@CentOS trunk]$ svn commit -m "Updated README"
svn: Commit failed (details follow):
svn: Aborting commit: '/home/jerry/project_repo/trunk/README' remains in conflict

[jerry@CentOS trunk]$ svn status
?       README.r6
?       README.r7
?       README.mine
C       README

ステップ3:競合を解決する

上記のコミットでは、文字 C はREADMEファイルに競合があることを示しています。 _Jerry_は競合を解決しましたが、Subversionに競合を解決したことを伝えませんでした。 彼はresolveコマンドを使用して、競合の解決についてSubversionに通知します。

[jerry@CentOS trunk]$ svn resolve --accept=working README
Resolved conflicted state of 'README'

[jerry@CentOS trunk]$ svn status
M       README

[jerry@CentOS trunk]$ svn commit -m "Updated README"
Sending        trunk/README
Transmitting file data .
Committed revision 8.