Patience Diff Advantages

Mar 30, 2010 11:10

There's no coherent explanation of what the advantages of Patience Diff are, so I'll explain now. First, a quick overview of how Patience Diff works -
  1. Match the first lines of both if they're identical, then match the second, third, etc. until a pair doesn't match.
  2. Match the last lines of both if they're identical, then match the next to last, ( Read more... )

Leave a comment

Comments 10

elsmi March 30 2010, 21:55:17 UTC
Your overview here says "longest common substring"; the post by alfodenzo says "longest common subsequence". If this is intended as the canonical explanation you should perhaps clarify which is meant just to be sure :-).

Reply

bramcohen March 30 2010, 22:36:27 UTC
Fixed that, thanks. It's supposed to be subsequence. It's kinda confusing because both words are used for diff, and they both have the same acronym.

Reply

elsmi March 31 2010, 04:16:39 UTC
I know.

Reply


(The comment has been removed)

bramcohen March 30 2010, 23:56:10 UTC
Straight LCS-based diff just does an LCS and it's done. Patience diff pulls out just the lines which occur exactly once on both sides, does an LCS on those, and extends out from there. This has the advantage of ignoring potentially misleading lines, and also is a much simpler algorithm due to the lack of duplicate lines.

Reply


Stand alone utility? jsyjr April 8 2010, 02:47:09 UTC
Is there a stand alone utility available? Something not embedded within a DVCS?

Reply

Re: Stand alone utility? bramcohen April 8 2010, 02:51:18 UTC
I believe the diff code in bazaar, which uses patience diff (the extended one with recursive application, which I'm basically saying is unnecessary here) can be run as a standalone diff utility.

Reply

Re: Stand alone utility? jsyjr April 8 2010, 10:46:00 UTC
If you are suggesting that I can say

$ bzr diff path1 path2

that does not work. I get

bzr: ERROR: Not a branch: "path1".

Reply


axxyaan June 22 2011, 13:52:57 UTC
I think you would do better to eliminate step 1 and step 2. Because they can make patience diff interpret the diff as the latter in your example here.

Suppose a new function is added, your functhreehalves here. Now what happens when you start comparing lines from the bottom up in your old and new file. You will start by finding the common function func2 in both files. But then you will find that the blank line and the end of func1 in the old file will match the blank line and the end of functhreehalves in the new file. So the result will be a diff in your pet peeve version.

Reply


ironcream August 16 2011, 17:37:24 UTC
Thank you! :)
Very nice idea and really cool diff output.

Reply


Leave a comment

Up