SVN - Resolver conflictos

Tom decide agregar un archivo README para su proyecto. Entonces crea el archivo README y agrega la lista TODO en ese. Después de agregar esto, el repositorio de archivos está en la revisión 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 revisa el último código que está en la revisión 6. E inmediatamente comienza a trabajar. Después de unas horas, Tom actualiza el archivo README y confirma sus cambios. El archivo README modificado se verá así.

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

Ahora, el repositorio está en la revisión 7 y la copia de trabajo de Jerry está desactualizada. Jerry también actualiza el archivo README e intenta confirmar sus cambios.

El archivo README de Jerry se ve así.

[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

Paso 1: Ver conflictos

Subversion ha detectado que el archivo README ha cambiado desde la última actualización. Entonces, Jerry tiene que actualizar su copia de trabajo.

[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 se queja de que hay un conflicto con el archivo README y Subversion no sabe cómo resolverlo. Así Jerry elige el df opción de revisar el conflicto.

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

Paso 2: posponga los conflictos

A continuación, Jerry elige las opciones de posponer (p) , para poder resolver el conflicto.

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

Después de abrir el README en el editor de texto, se da cuenta de que Subversion ha incluido tanto el código de Tom como su código con marcadores de conflicto.

[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 quiere los cambios de Tom además de los suyos, por lo que simplemente elimina las líneas que contienen los marcadores de conflicto.

Por tanto, el archivo README modificado se verá así.

[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 resolvió el conflicto y vuelve a intentar cometer.

[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

Paso 3: resuelva los conflictos

En el compromiso anterior, la letra Cindica que hay un conflicto en el archivo README. Jerry resolvió el conflicto pero no le dijo a Subversion que lo había resuelto. Utiliza el comando resolve para informar a Subversion sobre la resolución del conflicto.

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