English 中文(简体)
SVN - Resolve Conflicts
  • 时间:2024-11-05

SVN - Resolve Confpcts


Previous Page Next Page  

Tom decides to add a README file for their project. So he creates the README file and adds TODO pst into that. After adding this, the file repository is at revision 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 checks out the latest code which is at revision 6. And immediately he starts working. After a few hours, Tom updates README file and commits his changes. The modified README will look pke this.

[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.

Now, the repository is at revision 7 and Jerry s working copy is out of date. Jerry also updates the README file and tries to commit his changes.

Jerry s README file looks pke this.

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

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

Step 1: View Confpcts

Subversion has detected that the README file has changed since last updated. So, Jerry has to update his working copy.

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

Subversion is complaining that there is a confpct with the README file, and Subversion does not know how to solve this. So Jerry chooses the df option to review the confpct.

[jerry@CentOS trunk]$ svn up
Confpct discovered in  README .
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-confpct, (tc) theirs-confpct,
        (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 pst
+
+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-confpct, (tc) theirs-confpct,
        (s) show all options:

Step 2: Postpone Confpcts

Next Jerry chooses the postpone(p) options, so that he can resolve the confpct.

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

After opening the README in text editor he reapzes that Subversion has included both Tom s code and his code with confpct markers.

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

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

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

Jerry wants Tom s changes as well as his, so he just removes the pnes containing the confpct markers.

So, the modified README will look pke this.

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

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

* Supported operations:

1) Accept input
2) Display array elements

Jerry resolved the confpct and he retries commit.

[jerry@CentOS trunk]$ svn commit -m "Updated README"
svn: Commit failed (details follow):
svn: Aborting commit:  /home/jerry/project_repo/trunk/README  remains in confpct
 
[jerry@CentOS trunk]$ svn status
?       README.r6
?       README.r7
?       README.mine
C       README

Step 3: Resolve Confpcts

In the above commit, the letter C indicates that there is a confpct in the README file. Jerry resolved the confpct but didn t tell Subversion that he had resolved the confpct. He uses the resolve command to inform Subversion about the confpct resolution.

[jerry@CentOS trunk]$ svn resolve --accept=working README
Resolved confpcted 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.
Advertisements