[darcs-users] DARCS changes XSLT stylesheet

David Roundy droundy at abridgegame.org
Thu Nov 20 12:53:50 UTC 2003

On Wed, Nov 19, 2003 at 10:24:34AM -0500, Sean E. Russell wrote:
> You are right -- granularity is nice to have, which is basically what
> you're talking about.  You also don't like the format; you want to see
> the diffs in-line, as it were.
> There isn't a solution for turning diffs into the kind of in-line display
> that you'd like to have, primarily because diff only notices line-level
> changes; a diff doesn't have enough information to mark up
> character-level changes.  You'd need a more granular diffing algorithm.

Actually, it's not hard to implement a character-based diff.  It'd probably
be too slow for running on large files, but once you've gotten a line-based
diff, for each hunk you could run a character-based one.  The hard part of
a diff is the LCS code, which I've already done.

The darcs diff code is in the unexpected location of canonizeHunk in
Patch.lhs, which uses lcs from Lcs.lhs, which does all the hard work.  You
can play with it using ghci if you comment out the two lines containing
FastPackedString (these are to specialize it for the case I actually use,
for speed).

For example:

*Lcs> lcs "hello my silly world" "hello you silly silly world"
"hello y silly world"

Once you have the LCS, it's quite easy to create the "diff".
David Roundy

More information about the darcs-users mailing list