Differences between svn merge left, right & working files after conflicts
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?
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 (5
→8
) doesn't touch those lines, all is still good.
If delta (5
→8
) 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 branchB@6
-
file.merge-left
--- state of file in branchA@5
-
file.merge-right
--- state of file in branchA@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. left
→right
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.
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
- '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.