The module src/Darcs/Patch/Depends.hs is central to darcs patch theory in that
we use it with most operations to get the common and uncommon patches between
repositories.
Several bugs have manifested as impossible and bug cases in code in the Depends
module. Inspecting the code it would appear the algorithms are expressed in an
unsafe way, as evidenced by the many uses of unsafeCoerceP.
The function get_common_and_uncommon appears to always add (:<:NilRL) to the
sequences it returns. This then typically requires the caller to remove the
NilRL before processing the output. This results in "impossible" cases in the
calling code. These impossible cases will be triggered if the contract of
get_common_and_uncommon is ever changed. For this reason, we should simplify
the type of get_common_and_uncommon and remove the extra (:<:NilRL) on the ends
of the output.
get_extra is another important function in Depends that deserves to be cleaned up.
Overall, we should consider reorganizing and restructuring the code in this
module so that a) each function has unit tests b) each function has decent
description in haddocks c) re-expressing the algorithms so that the
unsafeCoercePs are no longer needed. This code is very important and so changes
here must be carefully review and tested. Perhaps we could even set code
coverage goals for this module given the importance.
|