AAU It Services

Conflicts

Conflicts

Working on a large project with others can be difficult to coordinate. When each user is working on a set of files for some task, sooner or later users will try to commit the same file in two different versions. This is called a conflict.

This guide will demonstrate the basic steps you can take to resolve a conflict once it has happened. We deal with three solution strategies:

Theirs - choosing to accept all incoming changes and discarding all your own changes to a conflicting file.
Mine - the opposite of theirs, discarding all changes done by other users to a file since you last updated it from the server.
Manual/merge - the most time consuming, but by far also most effective strategy. You must manually go through the different versions of conflicting files and assemble a new file from the changes to commit. This is easier than it sounds, although it does require some work.

Below we will show a typical conflict and how it is resolved. In the image below we see that a users is attempting to commit to the SVN server while not having the latest update of the repository. To resolve this, run SVN update before trying to commit again.

However, the update procedure may detect a conflict in one or more files. This is reported as shown below.

You can start resolving the conflicts immediately. Right-click a conflicted item as shown. You will be shown an array of solutions to resolve the conflict. You can choose to quickly resolve by using either your copy or the new copy in its entirety, Resolve conflict using 'mine' and Resolve conflict using 'theirs', respectively. You can also simply ignore the conflict by using Mark as resolved. This is highly discouraged, however, as it will inevitably result in garbage-filled files in your repository. We recommend you solve the conflict by hand. Click on Edit conflicts to continue.

The conflicts editor, as shown below, may seem frightening at first but it is quite simple to understand. The upper left marked area shows what the file the server has is containing and the upper right what your local file contains. In the bottom we see the merged output.

A quick explanation of the lines follows.

The top line in both frames has a line through it, showing that both version agree on its contents.

The second line, however, is marked red. The two versions have different content on this line, and you must consider how to resolve the conflict.

Right-clicking on a red line in either top frame of the window brings up the menu as shown below. Four options are available:

Use this text block - this will insert the selected red line in the Merged output below ignoring the value of the other side
Use this whole file - this will use either theirs or mine entirely ignoring that changes made to the other file. Be careful when using this.
Use text block  from 'mine' before 'theirs' - this will insert first the line from the local file and afterwards the line from the server file.
Use text block  from 'theirs' before 'mine' - this will do the opposite of the above option.

Usually it is the best idea to go through each red line and determining which of the files is the one to be used and the use the first option. This will usually ensure that the most recent changes to both files are put in to the combined file.

Once you have resolved the conflict to satisfaction, and no red lines are left in the Merged output, you can press the Resolve Conflict button as marked below. This will tell Subversion that you have handled the conflicting versions. At this point, we recommend that you do an SVN update followed by a commit to ensure that the resolution is distributed to other collaborators as fast as possible.