[darcs-users] [patch20] simplify Darcs.Commands.Record.ask_about... (and 6 more)

Eric Kow kowey at darcs.net
Sat Oct 31 22:57:52 UTC 2009


Apologies for the delay!  This review is under way.

> Wed Oct 14 13:50:45 BST 2009  Florent Becker <florent.becker at ens-lyon.org>
>   * Remove useless import of Verbose in Darcs.Commands.Unrecord
>
> Wed Oct 14 14:50:55 BST 2009  Florent Becker <florent.becker at ens-lyon.org>
>   * Refactor Darcs.Commands.Rollback
> 
> Thu Oct 15 13:36:19 BST 2009  Florent Becker <florent.becker at ens-lyon.org>
>   * Refactor Darcs.Commands.AmendRecord

Have pushed these three.  The general approach is to break up large
chunks of code into more manageable top level functions.  No more lambda
abuse.  Seems sensible enough.

> Thu Oct  8 16:04:29 BST 2009  Florent Becker <florent.becker at ens-lyon.org>
>   * Refactor Darcs.Commands.Apply

This conflicts, but I think I can fix it myself.

> Thu Sep 24 15:13:35 BST 2009  Florent Becker <florent.becker at ens-lyon.org>
>   * simplify Darcs.Commands.Record.ask_about_depends

> Thu Oct 15 09:28:18 BST 2009  Florent Becker <florent.becker at ens-lyon.org>
>   * Refactor Darcs.Commands.Push
> 
> Thu Oct 15 14:07:43 BST 2009  Florent Becker <florent.becker at ens-lyon.org>
>   * Refactor Darcs.Commands.Send

Will look at these tomorrow.

Refactor Darcs.Commands.AmendRecord
-----------------------------------
> hunk ./src/Darcs/Commands/AmendRecord.lhs 131
> -          NilFL | not edit_metadata -> putStrLn "No changes!"
> -          _ -> do
> -              date <- getDate opts

If I understand correctly, we can do this getDate at anytime since we're
not using --pipe

> -              with_selected_changes_to_files' "add" (filter (==All) opts) (Just primSplitter)
> -                (map toFilePath files) ch $ \ (chs:>_) ->
> -                  if (nullFL chs && not edit_metadata)
> +          NilFL | not (has_edit_metadata opts) -> putStrLn "No changes!"
> +          _ ->
> +               with_selected_changes_to_files' "add" (filter (==All) opts) (Just primSplitter)
> +                (map toFilePath files) ch $ addChangesToPatch opts repository oldp

This seems like a nice refactor.

Florent has unpacked our big amend-record function into some distinct
more manageable phases:

  with_selected_changes_to_files
  `- addChangesToPatch
     `- updatePatchHeader
        `- warnIfHijacking (in case you're amending someone else's patch)

Really just rearranging some whitespace and promoting things to top
level functions

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20091031/72670444/attachment.pgp>


More information about the darcs-users mailing list