[darcs-users] darcs patch: getChanges with better shifting of first and last hunk with shiftBoundaries

David Roundy droundy at darcs.net
Wed May 21 13:38:47 UTC 2008


On Wed, May 21, 2008 at 03:14:46PM +0300, Pekka Pessi wrote:
> Hello,
> 
> The diff optimization with shiftBoundaries used by darcs whatsnew and
> darcs record does not work properly with last (and first) hunk. The
> culprit is in dropStart and dropEnd, which keep only one line of
> context to perform the optimizations. Beside aesthetics the practical
> consequence is that darcsum loses track of hunks that get moved after
> hunks before or after them are recorded.
> 
> The attached patch refactors the code so that the complete files gets
> passed to shiftBoundaries. There is also a minor optimization handling
> hash conflicts within one file only.

Oh, and another interesting (related) idea would be to specialize the code
for doing a character-based diff rather than a line-based diff.  This would
require a bit of tedious work, but should be simpler in many ways (e.g. no
need to hash the single bytes).

getByteChanges :: PackedString -> PackedString
           -> [(Int,PackedString,PackedString)]

In principle this could share a lot of code with getChanges, but in
practice the optimal code will be quite different between the two, since
there are unlikely to be any unique characters.  And also because there's
no reason to hash the bytes.

David


More information about the darcs-users mailing list