[darcs-users] amend-record = unrecord+record?

Ganesh Sittampalam ganesh at earth.li
Thu Jul 30 21:33:04 UTC 2009


Hi,

Should amend-record be the same as unrecord/record (of the same changes)?

I suspect that most people would expect it to be so, and indeed we have 
previously fixed bugs where it was not the case, e.g. 
http://bugs.darcs.net/issue1272

However, there turn out to be very small examples where it is not the 
case, and in fact with the current way amend-record works it's actually 
impossible.

The reason is that amend-record uses a local coalescing operation on 
patches that is ignorant of repo state, whereas unrecord/record re-diffs 
actual repo states. In the following test case:

state    1    2    3
contents g => a => g
               g    g

If we go from state 1 to state 2 to state 3, we record insertion of "a" at 
line 1 followed by change of "a" -> "g" at line 1. At no stage is line 2 
involved, so there only possible local coalescing gives us insertion of 
"g" at line 1.

But if we diff states 1 and 3 directly, the diff algorithm picks insertion 
of "g" at line 2. There's no prospect of tweaking the diff algorithm: if 
we change state 2 to ["g", "a"] instead, then coalescing gives us 
insertion of "g" at line 2 by the same reasoning.

I have more complicated examples (but only very slightly more complicated) 
where the amend-recorded diff is larger than the freshly recorded diff, 
for similar reasons; a line which is not touched in the sequence of 
patches still tweaks the diff.

So the question is whether this matters or not. My feeling is that it 
does, for the reasons that Simon Marlow mentioned in the aforementioned 
bug, and particularly where the amend-recorded diff is larger than the 
freshly recorded one.

To fix this, I think we would need to make amend-record more aware of file 
contents, perhaps by making the code path very similar to what 
unrecord/record would do, or perhaps a bit more subtly by augmenting the 
existing coalescing code.

This question also has implications for the hunk editing feature that Rob 
Hoelz has been working on for a while, which I've also been looking at a 
bit recently, so I'm mostly in favour of having a better coalesce 
operation, if feasible.

Cheers,

Ganesh


More information about the darcs-users mailing list