[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looking for diff4
From: |
Stuart Ballard |
Subject: |
Re: Looking for diff4 |
Date: |
Sat, 22 Feb 2003 11:57:59 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021210 Debian/1.2.1-3 |
Paul Eggert wrote:
Stuart Ballard <address@hidden> writes:
Trunk -- t1 -- t2 ------------ t3
\ \ \
Branch '- b1 -(m1)- b2 -- b3 -(m2)- b4
...
m2, on the other hand, cannot be done adequately with diff3. The reason
is that the 'common ancestor' file has already diverged - on the trunk
it's t2, and on the branch it's b2.
Sorry, I don't get it. From your diagram it appears that t2 is an
ancestor of both t3 and b3. So m2 can computed by invoking "diff3 b3
t2 t3".
Argh, I can't believe how long I thought about this problem without that
basic insight occurring to me!
I think my problem was that I was thinking as if each file could only
have one direct "ancestor" and that b2's ancestor was b1 only. But
you're right, of course, that since b2 is the result of merging t2 and
b1, t2 is just as much of an ancestor and can be used perfectly well
with the diff3 algorithm.
2) Given diff3 a b c, calculate diff b a and diff b c, then combine the
two diffs (resolving conflicts at this point) and apply the resulting
patch to a.
Yes, that's what it does.
Cool :)
"diff3 A B C" could find a longest common subsequence among A, B, and C,
and report everything outside this common subsequence as a difference.
It doesn't do that now; it uses algorithm (2) you mentioned above.
But it _could_ do that, and that would be better than what it does now.
I'm not sure that that would be better in all circumstances; I think
that there's a definite use case for the algorithm that it currently
uses, in merging situations.
etc. Actually, we wouldn't need a "diff4" command, we could just
extend "diff" to accept an arbitrary number of arguments.
Now that I approve of, so long as diff3 in its current form still existed...
PS Oh, and is there a good reason why sdiff seems to be limited to
two-way diffs?
Historical reasons. sdiff is present merely to support the System V
command interface. Most people who want to do merges use other tools
these days, e.g. Emacs.
I really wish there were good standalone interactive "patch" and "diff3"
programs. Not everyone uses emacs[1].
Patch, in particular, seems to live in a nightmare zone of
semi-interactivity. It will prompt you to reverse the patch if it's
already applied, but won't offer you any chance to help it apply a patch
if it can't do it alone, other than throwing a .rej file at you.
On the other hand, you've given me the insight that allows me to proceed
using tools that do already exist - all I need to do is find some
interactive three-way merging tool (and those DO exist, even if not,
sadly, from GNU) and invoke it using t2 as the common ancestor.
Thanks!
Stuart.
[1] Really! It's true! I swear! ;)
--
Stuart Ballard, Programmer
NetReach - Internet Solutions
(215) 283-2300, ext. 126
http://www.netreach.com/