Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

SVN resolves conflicts


May 25, 2021 SVN


Table of contents


SVN resolves conflicts

Tom decided to add a README file to his project, so he created it and added a TODO list to it. When the addition is complete, the file is stored in 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 checked out the code at the end of revision 6, and he started working immediately. A few hours later, Tom updated the README file and submitted the place where he modified it. The modified README will look like 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.

The repository is now in modified version 7, and Jerry's working copy has expired. Jerry also updates the README file and tries to commit his changes.

Jerry's README file will look like this:

[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

Step 1: View conflicts

Subversion has detected that README files have changed since the last update. Therefore, Jerry must update his working copy.

[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 prompts that there is a conflict in the README file, and Subversion does not know how to resolve the issue. Jerry then selects the df option to check for conflicts.

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

Step 2: Postpone the conflict

Jerry then resolves the conflict with a story (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

After opening the README file with the document editor, Jerry realized that Subversion already contained Tom's code and his code and was wrapped up by conflicting labels.

[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 wanted Tom's changes to be consistent with his, so he decided to remove the row that contained the conflicting identity.

So, the changed README will look like this.

[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 resolved the conflict and tried to commit again.

[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

Step 3: Resolve the conflict

In the submission above, the letter C indicates that there is a conflict in the README file. lved the conflict but did not tell Subversion that the conflict had been resolved. He used the resolve command to notify Subversion of the resolution of the conflict.

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