Differences between svn merge left, right & working files after conflicts

Svn

Svn Problem Overview


When performing a 'svn merge' from my development team's trunk into a branch, we occasionally experience merge conflicts that produce files with suffix names: *.merge-right.r5004, *.merge-left.r4521 and *.working. I've searched throughout Subversions's documentation but their explanation hasn't been much use. I've gathered the following:

  • *.merge-right.r5004 = trunk version
  • *.merge-left.r4521 = ?
  • *.working = branch version

I can't seem to figure out what merge-left.r4521 is. And if the answer is that its simply an older version of the file from branch, then why 4521?

Svn Solutions


Solution 1 - Svn

Let's say there are two branches, and last (HEAD) revision in branch A is 9, while it is 6 in branch B.

When cd B; svn merge -r 5:8 ^/braches/A is ran, svn will try to apply delta between 5 and 8 from branch A on top of branch B.

(In other words, change sets 7 and 8 will be applied to B)

common
ancestor      left     right
(1)━━┱───(3)──(5)──(7)──(8)──(9)  # branch A
     ┃         └┄┄┄┄┬┄┄┄┄┘
     ┃              ↓
     ┗━(2)━━(4)━━(6)              # branch B
               working

If the delta applies cleanly, it's all good.

Let's say some lines were modified in change set 3, and same source lines were modified differently in change set 4.

If delta (58) doesn't touch those lines, all is still good.

If delta (58) also modified what 3 and 4 did, changes cannot be merged automatically, and svn leaves a file in conflict state:

  • file --- file with (working, left, right) delimited
  • file.working --- state of file in branch B@6
  • file.merge-left --- state of file in branch A@5
  • file.merge-right --- state of file in branch A@8

If you edit such a file manually, you have a few choices --- keep working (your version), keep right (their version; the other branch version) or merge the changes manually.

Left is not useful in itself, there's no point to keep left (their old version) in the file.

It is, however, useful for tools. leftright is the change set.

When you see, for example:

<<<<<<< .working

    life_universe_and_everything = 13

||||||| .merge-left.r5

    life_universe_and_everything = "13"

=======

    life_universe_and_everything = "42"

>>>>>>> .merge-right.r8

In branch A, "13" (str) was changed to "42".

Branch B had 13 (int).

Perhaps you want 42 (int) when you reconcile this conflict manually.

Solution 2 - Svn

file.merge-left.r4521 is the latest change of this file in the left branch (i.e. the origin) before the right branch (the destination) were created.

In other words, merge-left.r4521 it's the first version of the file to be merged

with merge-right.r5004 (the latest version of the destination branch)

For example, say you want to merge branches Left and Right as below:

Left   1   2   f.3   4   f.5   6    7    f.9    11 

Right                                  8    f.10    f.12   13


Right is created in 8 ( is a copy of 7 )

file 'f' has been modified in 3, 5, 9, 10, 12

The merge of file 'f' will occur between 7 and 13 because

7 is the latest version of file f in Left before Right was created

13 is the latest version of Right

Solution 3 - Svn

  • 'file.py.merge-left.rxxx` shows the merging result taking the left side of the conflict
  • 'file.py.merge-right.ryyy` shows the merging result taking the right side of the conflict
  • 'file.py.working` shows your unchanged working copy
  • 'file.py` shows SVNs attempts to merge both

This question is similar to stackoverflow.com/questions/1673658/svnmerge-workflow but this one is more specific about the content of the conflict files.

Solution 4 - Svn

It seems that the "left" file is the last version where the file was the same in the trunk and the branch (for your question, but it would be between the source and dest in general).

If you've never merged changes from the trunk into your branch then this would be the version of the trunk when a branch (copy) was performed. Otherwise, it's the last version of the trunk that was merged and committed to this branch.

The left and right are what is used to create the diff that will be applied (as a patch) to the working file.

Solution 5 - Svn

You performed 3-side merge diring conflict-resolving (when merging 2 different files). It this operation 3 sources used

  • "your" file (from WC or source-location, depending on parameters)
  • "their" file (file with with changes must be merged)
  • "base" file (common ancestor of files 1-2)

r*** extension just added to the same filename in order to have 3 files on merge

After successful merging and marking conflict as resolved temp-files must disappear automagically, if my memory served me well

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiond mView Question on Stackoverflow
Solution 1 - SvnDima TisnekView Answer on Stackoverflow
Solution 2 - SvnejaenvView Answer on Stackoverflow
Solution 3 - SvnTickonView Answer on Stackoverflow
Solution 4 - SvnJasonView Answer on Stackoverflow
Solution 5 - SvnLazy BadgerView Answer on Stackoverflow