[darcs-devel] fixing issue 2270

Sebastian Fischer mail at sebfisch.de
Sun Feb 3 22:03:50 UTC 2013


Hello,

I am working for factis research on implementing extensions and bug
fixes for Darcs. To familiarize myself with the Darcs source code, I
looked into the bug "darcs changes -i --only-to-files reports changes
to all files" (http://bugs.darcs.net/issue2270) and want to discuss
possible ways to fix it.

When showing patches that touch a given list of interesting files,
unrelated changes are printed too if they have been recorded together
with a change to an 'interesting' file. This is because the function
`filterPatchesByNames` in `Darcs.UI.Commands.Changes` collects a list
of type

    [(Sealed2 (PatchInfoAnd p),[FilePath])]

where the first component is a named patch and the second component is
a list of all files that the corresponding named patch touches. Even
files unrelated to the original query are listed in the second
component and the named patch contains primitive patches that touch
such unrelated files.

When using the flag `--interactive`, the function

    viewChanges :: (Patchy p, ShowPatch p, ApplyState p ~ Tree) =>
        [DarcsFlag] -> [Sealed2 p] -> IO ()

in module `Darcs.UI.SelectChanges` is used. A list of first components
of type `Sealed2 (PatchInfoAnd p)` computed by the function
`filterPatchesByNames` is passed as second argument to `viewChanges`.
`viewChanges` prints the info of each passed named patch and (if
asked) also prints all changes.

The easiest way to print only relevant changes seems to be to call
`viewChanges` with a list of relevant primitive patches instead of
with a list of named patches. But, I think, this would mean that the
patch info would no longer be printed and users would be asked to type
'y' once for every primitive patch instead of only once for every
named patch.

An alternative seems to be to modify the named patches such that they
contain only relevant primitive patches. It looks like the list of
primitive patches can be modified by the function `filterOutFLFL` in
module `Darcs.Patch.Witnesses.Ordered`. But, as far as I can tell, it
is not easily possible to rewrap such a list of filtered primitive
patches as a named patch in a generic way (that works for V1 and V2
patches).

I think the cleanest way to ensure that `viewChanges` prints only
relevant changes is to change its type to something like

    viewChanges :: ... => [DarcsFlag] -> [(PatchInfo,[Sealed2 p])] -> IO ()

The pairs in the second argument would contain an info component for
each named patch and a corresponding list of relevant primitive
patches. This type would allow to filter out unrelated primitive
patches without losing the patch info or increasing the number of
questions to users.

Is a change along these lines acceptable or are there better ways to
fix the bug?

Best regards,
Sebastian


More information about the darcs-devel mailing list