Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get SVN to take a specific resolution for all binary conflicts without prompting me for each one?

When running an svn up I regularly encounter this prompt:

Conflict discovered in 'lib/somelibrary.so'.
Select: (p) postpone,
        (mf) mine-full, (tf) theirs-full,
        (s) show all options:

Hitting s reveals the options mc and tc, mine-conflict and theirs-conflict, which supposedly allow me to take either my version or their version for all conflicts and not just somelibrary.so.

However, those options don't work. I get this message:

Invalid option; cannot choose based on conflicts in a binary file.

Edwin's answer makes it clear that I've misunderstood how mc and tc work, but I still want to be able to take the same resolution for every file that conflicts. Is there a way to make svn use mf or tf for every conflict without prompting me again after the first time?

like image 830
Matthew Read Avatar asked Jan 27 '12 20:01

Matthew Read


2 Answers

To automatically resolve conflicts on svn update, svn switch, svn merge, use the --accept flag.

From the SVN Book - svn options:

--accept ACTION
Specifies an action for automatic conflict resolution. Possible actions are postpone, base, mine-full, theirs-full, edit, and launch.

Meaning of each action can be seen in the svn resolve specification:

You can pass the following arguments to the --accept command depending on your desired resolution:

base Choose the file that was the BASE revision before you updated your working copy. That is, the file that you checked out before you made your latest edits.

working Assuming that you've manually handled the conflict resolution, choose the version of the file as it currently stands in your working copy.

mine-full Resolve all conflicted files with copies of the files as they stood immediately before you ran svn update.

theirs-full Resolve all conflicted files with copies of the files that were fetched from the server when you ran svn update.

mine-conflict Resolve all conflicted files by preferring local modifications over the changes fetched from the server in conflicting regions of each file's content.

theirs-conflict Resolve all conflicted files by preferring the changes fetched from the server over local modifications in conflicting regions of each file's content.

Also check out the Resolve Any Conflict section.

Finally, an example. To automatically resolve all the conflicts as mine-full on update, execute:

$ svn up --resolve mine-full
like image 166
Paker Avatar answered Oct 18 '22 22:10

Paker


mc and tc are merging options, where one only considers the lines in conflict, and then does a merge of those lines from either your sources (mc) or the "other" sources (tc).

Binary files are generally not structured in such a way that they contain lines, as as such, conflict resolution algorithms that are based on replacing one's line of text with another's line of text won't work properly for a binary file. The developers who wrote SVN know this, and so when dealing with a binary file, the options that only make sense with text files won't be accepted.

You can use mf and tf, which are slightly different. Instead of replacing just the conflicting areas of a file, they replace the entire file with (mf) "my" copy of the full file, or (tf) "their" copy of the full file).

If you want SVN to "shutup and accept the mc / tc file options", svn edit the mime-type and set it to text. Good luck if that's not a text file, odds are you will get a file that isn't within the specifications of either starting binary file (merging continuous sections of two jpeg files, for example, will not yield a valid jpeg file).

like image 20
Edwin Buck Avatar answered Oct 18 '22 21:10

Edwin Buck