[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: merge disagrees with diff

From: Flemming Frandsen <dren.dk_at_gmail.com>
Date: Fri, 28 Oct 2011 14:32:39 +0200

On Fri, Oct 28, 2011 at 2:00 PM, Andreas Krey <a.krey_at_gmx.de> wrote:
> That only looks like that because of the way merging is described in the
> book.

Aaah! RTFM, is it?

> In essence, svn sees only two different (and conflicting) changes to
> a block of lines, and leaves it to you to deal with that. (Likewise
> do git and CVS.)
>
> This looks pretty much like your situation.

My god man! you're right!

I've managed to write a very minimal test case which demonstrates the problem:

#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw($Bin);

system("svnadmin create repo") and die;
system("svn", 'co', "file://$Bin/repo", "checkout") and die;

open A, ">checkout/a" or die "Failed to create a: $!";
for my $i (1..10) {
        print A "$i\n";
}
close A;

open B, ">checkout/b" or die "Failed to create b: $!";
for my $i (1..10) {
        print B "$i\n";
        print B "$i and a half\n" if $i == 5;
}
close B;

system("svn", "add", "checkout/a", "checkout/b") and die;
system("svn", "ci", "checkout", "-m", "Added some files to test on") and die;

open B, ">checkout/b" or die "Failed to create b: $!";
for my $i (1..10) {
        print B "$i\n";
        print B "$i and a quarter\n" if $i == 5;
        print B "$i and a half\n" if $i == 5;
}
close B;

system("svn", "ci", "checkout", "-m", "Added an extra line") and die;

system("svn", "diff", "-c", '2', "file://$Bin/repo") and die;

system("svn", "merge", '--non-interactive', "-c", '2',
"file://$Bin/repo/b", "checkout/a") and die;

The change to b that I merge is:
Index: b
===================================================================
--- b (revision 1)
+++ b (revision 2)
@@ -3,6 +3,7 @@
 3
 4
 5
+5 and a quarter
 5 and a half
 6
 7

The conflict in a ends up being:
1
2
3
4
5
<<<<<<< .working
=======
5 and a quarter
5 and a half
>>>>>>> .merge-right.r2
6
7
8
9
10

I'm comforted that this only happens when there is a conflict, but
it's still terribly confusing for people and I wonder if trying to
apply the diff (as reported by svn diff) would lead to a less
confusing conflict as you would only have to deal with the actual
change you wanted to merge rather than the entire

Thank you all for your time.

-- 
Flemming Frandsen - YAPH - http://osaa.dk - http://dren.dk/
Received on 2011-10-28 14:33:10 CEST

This is an archived mail posted to the Subversion Users mailing list.