[darcs-devel] When are conflicts regarded as "resolved"?

Ganesh Sittampalam ganesh at earth.li
Fri Aug 11 19:23:33 UTC 2017


On 11/08/2017 19:02, Ganesh Sittampalam wrote:
> On 11/08/2017 19:48, Benjamin Franksen wrote:

>> I just tested that if I resolve only one of two conflicts in the same
>> file and record (only) that change, darcs sees that there are still
>> conflicts remaining. I understand that this is because darcs looks at
>> the sequence of /primitive/ patches. That still leaves the question:
>> when does a (primitive) change count as a conflict resolution? Or
>> perhaps the better question is: how does darcs determine whether a file
>> is conflicted or not? I tried to find this in the code but I failed
>> miserably.
> 
> From memory, I think a primitive patch resolves a conflict if it depends
> on all of the conflicting primitive patches. But I could be misremembering.

OK, I think the code is the definition of 'resolveConflicts' in the
'Conflict (RL p)' instance in Darcs/Patch/Conflict.hs:

    resolveConflicts x = rcs x NilFL
        where rcs :: RL p wX wY -> FL p wY wW
                  -> [[Sealed (FL (PrimOf p) wW)]]
              rcs NilRL _ = []
              rcs (ps:<:p) passedby | (_:_) <- resolveConflicts p =
                  case commuteNoConflictsFL (p:>passedby) of
                    Just (_:> p')
                       -> resolveConflicts p' ++ rcs ps (p:>:passedby)
                    Nothing -> rcs ps (p:>:passedby)
              rcs (ps:<:p) passedby
                  = seq passedby $ rcs ps (p:>:passedby)

(I've reformatted the code for the email)

When looking for conflicts in a list of patches, we go through the whole
list looking for individual patches that are in conflict. But then we
try to commute them past all the patches we've already seen. If we fail,
i.e. there's something that depends on the conflict, then we forget
about the conflict - this is the Nothing case of the
'commuteNoConflictsFL' call.

So precisely, a conflicting (primitive) patch is resolved if another
(primitive) patch depends on the conflict.

[I'm writing this on a plane, so apologies if it crosses with something
you've already sent]

Ganesh


More information about the darcs-devel mailing list