darcs

Patch 2143 option refactors

Title option refactors
Superseder Nosy List bf
Related Issues
Status accepted Assigned To
Milestone

Created on 2020-12-21.18:55:15 by bf, last changed 2021-03-27.23:55:56 by ganesh.

Files
File name Status Uploaded Type Edit Remove
patch-preview.txt bf, 2020-12-21.18:55:14 text/x-darcs-patch
patch-preview.txt bf, 2020-12-21.19:22:38 text/x-darcs-patch
record-command_-clean-up-import-lists.dpatch bf, 2020-12-21.19:22:38 application/x-darcs-patch
rollback_-simplify-by-inlining-undoitnow.dpatch bf, 2020-12-21.18:55:14 application/x-darcs-patch
unnamed bf, 2020-12-21.18:55:14 text/plain
unnamed bf, 2020-12-21.19:22:38 text/plain
See mailing list archives for discussion on individual patches.
Messages
msg22587 (view) Author: bf Date: 2020-12-21.18:55:14
The first patch here is a an accidental dependency but I guess it doesn't
hurt to include it. The main thing are the last two patches. I've finally
bitten the bullet and reverted amend and record back to using [DarcsFlag]
instead of a configuration record. The diffing options refactor is also
something I wanted to do for a long time.

4 patches for repository http://darcs.net/screened:

patch 4330f2b8d149eee4bd6a7883ca4d919570be29ae
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Oct 26 09:10:46 CET 2020
  * rollback: simplify by inlining undoItNow

patch 9c73fa5db0d98b0c081ccc066071d29f46a4d49b
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Nov  9 20:24:20 CET 2020
  * add missing options to some optimize commands

patch 1d3e44c970d405378eea3081a6ca3083468d5fa3
Author: Ben Franksen <ben.franksen@online.de>
Date:   Mon Nov  2 09:49:06 CET 2020
  * unify diffing options
  
  This lets us treat all options that influence how we determine tree
  differences into a single data type, simplifying type signatures and call
  sites. The ScanKnown repo flag is removed, instead we add a third variant to
  LookForAdds.

patch c949ed8364be099ea66f00d1123f44cdb460c157
Author: Ben Franksen <ben.franksen@online.de>
Date:   Tue Nov  3 17:46:44 CET 2020
  * amend and record commands: back to using [DarcsFlag]
  
  Introducing configuration for these commands was done as an experiment and
  my conclusion is that it has failed. Haskell's records are just not flexible
  enough to be useful here.
Attachments
msg22588 (view) Author: bf Date: 2020-12-21.19:22:38
Forgot to include this cleanup patch.

1 patch for repository http://darcs.net/screened:

patch a2139abb3765db0c5c88491dcb7130a643d4ba0e
Author: Ben Franksen <ben.franksen@online.de>
Date:   Tue Nov  3 18:10:36 CET 2020
  * record command: clean up import lists
Attachments
msg22669 (view) Author: ganesh Date: 2021-03-22.17:08:34
(partial review)

>  * rollback: simplify by inlining undoItNow
OK

>   * add missing options to some optimize commands
OK
msg22671 (view) Author: ganesh Date: 2021-03-22.21:01:55
>  * unify diffing options

This looks nice, especially dropping ScanKnown.

In a few places we end up with

>    ^ O.lookforadds
>    ^ O.lookforreplaces
>    ^ O.lookformoves

instead of

>    ^ O.lookfor

Could that helper be kept? Or do the types not work out?

>   * amend and record commands: back to using [DarcsFlag]

Fair enough - shame about the experiment

>  * record command: clean up import lists

OK
msg22674 (view) Author: bf Date: 2021-03-23.18:30:51
>>  * unify diffing options
> 
> This looks nice, especially dropping ScanKnown.
> 
> In a few places we end up with
> 
>>    ^ O.lookforadds
>>    ^ O.lookforreplaces
>>    ^ O.lookformoves
> 
> instead of
> 
>>    ^ O.lookfor
> 
> Could that helper be kept? Or do the types not work out?

The typing is no problem. But amend and record have O.lookforadds (which
is synonym for O.maybelookforadds False), while whatsnew has
O.maybelookforadds False and status has O.maybelookforadds True. So
either O.lookfor gets an argument to indicate the default value for the
lookfor option, or else it cannot be used for the status command.

>>   * amend and record commands: back to using [DarcsFlag]
> 
> Fair enough - shame about the experiment

True, I guess that's why it took me so long to admit defeat ;-)

This problem can only be solved properly with extensible records. For
the time being [DarcsFlag] is our weakly typed emulation of that. The
important point is that it is treated like an abstract data type now. I
guess we could wrap it with a newtype and make it technically abstract
nowadays.
msg22675 (view) Author: bf Date: 2021-03-23.18:46:58
>> Could that helper be kept?

There is a disadvantage to using such a combined option: the code still
uses e.g. O.lookforadds to get at individual option values. This will
become more obscure if the individual options aren't declared explicitly
in the command definition. Overall I think I am in favour of being more
explicit and slighlty more verbose here.
History
Date User Action Args
2020-12-21 18:55:15bfcreate
2020-12-21 19:22:38bfsetfiles: + patch-preview.txt, record-command_-clean-up-import-lists.dpatch, unnamed
messages: + msg22588
2020-12-21 19:23:10bfsetstatus: needs-screening -> needs-review
2021-03-22 17:08:35ganeshsetstatus: needs-review -> review-in-progress
messages: + msg22669
2021-03-22 21:01:56ganeshsetstatus: review-in-progress -> accepted-pending-tests
messages: + msg22671
2021-03-23 18:30:52bfsetmessages: + msg22674
2021-03-23 18:46:58bfsetmessages: + msg22675
2021-03-27 23:55:56ganeshsetstatus: accepted-pending-tests -> accepted