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

Re: "svn diff" and "svn merge" sittin' in a tree

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2002-02-15 16:05:17 CET

Karl Fogel <kfogel@newton.ch.collab.net> writes:

> Philip Martin <philip@codematters.co.uk> writes:
> > Greg Hudson <ghudson@MIT.EDU> writes:
> > > I hate to pull the emergency break this late in the design, but after
> > > the recent discussion on using diff3 in "svn update", I think we're
> > > wasting our time designing an "svn merge" which simply takes the diffs
> > > from "svn diff" and applies them to the working copy. It will work, but
> > > it will never be as satisfying as CVS is.
> > >
> > > What we really want to do is take the same plaintexts as "svn diff" uses
> > > to make its diffs, and do a three-way-merge with them and the working
> > > copy.
> >
> > Absolutely, a three-way diff is required. That in itself is not a
> > problem, changing the "diff" callback to take three files instead of
> > two is quite simple.
>
> Okay, I confess to being completely confused here.
>
> Every so often, someone says "we can't just apply diffs to the working
> copy to do merge, we have to do a 3-way diff."
>
> I don't understand how the proposed 3-way diff helps us, or, if it
> does help us, how exactly it differs from what we've been discussing
> for "svn merge" all along.

A picture is worth a thousand words, but you need the right
picture :-)

Here is the common ancestor

$ cat file2
line 1
line 2
line 3
line 4
line 5

Here is what I want to merge from (the branch perhaps)

$ cat file3
line 1
line 2 change A
line 3
line 4 change B
line 5

Here is what I want to merge to (the trunk perhaps)

$ cat file1
change C
line 1
line 2 change A
line 3
line 4
line 5
line 6

Here is basic diff + patch

$ diff -u file2 file3 | patch file1
patching file `file1'
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file1.rej

Here is a 3-way merge, 3-way diff, whatever you want to call it

$ merge -p file1 file2 file3
change C
line 1
line 2 change A
line 3
line 4 change B
line 5
line 6

A simple diff + patch can be used, but merge results in fewer
conflicts. The merge algorithm may not work in all cases (I would
like to work on a better one myself) but the important bit is to have
all three files available as that enables the possibility of a more
intelligent algorithm. Who knows, perhaps we can select the merge
algorithm based on file type, there is no reason why merge has to be
limited to a line by line comparison. A specialised merge could parse
the file and do something very sophisticated.

-- 
Philip
-- 
Philip
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:08 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.