[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:32:33 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.
> 
> The performance of darcs whatsnew seems to improve by 2..3 %, however,
> the measurements were done with only one repository.
> 
> Any comments on use of Haskell and programming style are greatly appreciated...

Looks reasonable to me.  The style looks generally fine, although I saw one
place where you included unnecessary parentheses around a variable.

If you're interested in improving the diff code even more, I think it'd be
worth trying to implement the "patience diff" algorithm from bazaar, which
is most likely simpler, and probably produces nicer diffs.

Applied, and thanks!

David

> Wed May 21 14:36:55 EEST 2008  Pekka Pessi <pekka.pessi at nokia.com>
>   * getChanges with better shifting of first and last hunk with shiftBoundaries
> 
>   The one-line context left with old dropStart and dropEnd is not always
>   enough. As a consequence first and last hunk in the file got treated
>   inconsistently by shiftBoundaries.
> 
>   The refactored code converts lists into PArrays already by getChanges,
>   dropStart and dropEnd advance bounds within PArray.
> 
>   getChanges' handles PArrays, and refactored code introduces minor
>   optimizations to hash handling (collisions within one file are not
>   propagated to diffArr).


More information about the darcs-users mailing list