Resolving conflicts

Posted in Subversion , 07.09.2008 19:09

Resolving conflicts (aus: http://gcc.gnu.org/wiki/SvnBasic) In SVN, the conflict status is sort of 'sticky': after a conflict is detected, SVN remembers that the file is in conflict status. Let's see an example:

$ svn up 
U  gcc/global.c 
C  gcc/reload.c 
U  gcc/simplify-rtx.c 
Updated to revision 5624 
$ ls -l gcc/reload.* 
gcc/reload.c 
gcc/reload.c.mine 
gcc/reload.c.r5623 
gcc/reload.c.r5624  

After detecting a conflict, SVN adds the usual conflict markers to the original file gcc/reload.c , and also prepares three additional files to help in the merge process: * gcc/reload.c.mine the locally modified version before the update * gcc/reload.c.r5623 the previous version (the version against which the local changes were made) * gcc/reload.c.r5624 the new version (the version we were trying to update to)

Resolving the changes can be done by manually editing the file containing the conflict markers (as usually done), or by copying one of the three pure versions over it. After that, it is necessary to inform SVN about the fact the conflict was resolved:

$ svn status gcc/reload.c C  reload.c 
$ cp gcc/reload.c.r5624 gcc/reload.c     # revert local changes 
$ svn resolved gcc/reload.c 
Resolved conflicted state of 'gcc/reload.c' 
$ svn status 
gcc/reload.c M  
gcc/reload.c 
$ ls -l gcc/reload.
* gcc/reload.c  

SVN cleans up the additional files created to help the conflict resolution leaving a clean tree, and the file is ready to be committed.