[darcs-devel] [patch2055] resolve issue2649: cleanup display of patches

Ben Franksen bugs at darcs.net
Thu Jul 30 10:07:56 UTC 2020


Ben Franksen <ben.franksen at online.de> added the comment:

>>   * resolve issue2649: cleanup display of patches
> 
>> Logically, 'description' should default
>> -- to 'mempty' while 'content' should default to 'displayPatch'. We define them
>> -- the other way around so that 'Darcs.UI.PrintPatch.showFriendly' gives
>> -- reasonable results for all patch types.
> 
> Is it effectively a future TODO to refactor this further, or is it
> fundamental? (The answer might be a useful comment either way)

I find it quite hard to decide this, which is why I haven't elaborated
this point.

On the one hand, yes, the defaults are unintuitive, if we regard them
out of context. On the other hand, in the context of how they are used
for showFriendly and the other functions in Darcs.UI.PrintPatch, the
default definitions are the only ones that make sense.

I can't think of a possible refactor that "fixes" this, but I don't want
to completely rule out the possibility either.

>> showWithSummary :: ShowPatch p => p wX wY -> Doc
>> showWithSummary p = description p $$ prefix "    " (summary p)
> 
> Given the above defaults, doesn't that mean that showWithSummary might
> print out the whole patch followed by a summary of it?

A good point. Yes, it means exactly that. I have actually thought about
this case and could not find a principle fault with it.

We don't encounter this case in practice, though. The only place where
we call that function directly is in setEnvDarcsPatches which works only
with PatchInfAnd. showFriendly/printFriendly may hit this case but again
the only call site outside of Darcs.UI.Selectpatches is in
Darcs.UI.Commands.Util and Dracs.UI.Commands.Log where it gets passed a
PatchInfoAnd. That leaves interactive selection in
Darcs.UI.Selectpatches when used for prim patches. But none of the
commands that may involve interactive selection of prim patches accept
the --summary option; except whatsnew and that implements its own
interactive procedure (and that calls neither showFriendly nor
printFriendly).

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/patch2055>
__________________________________


More information about the darcs-devel mailing list