[darcs-users] darcs patch: code cleanup (and 1 more)

Eric Kow kowey at darcs.net
Fri Oct 24 13:38:38 UTC 2008


On Fri, Oct 24, 2008 at 15:33:37 +0200, Christian Kellermann wrote:
> ask already discussed I have split up the patch into two parts. A
> refactoring one and the new feature implementation.

No further requests from me...

code cleanup
------------
> -       in do
> -       tentativelyAddPatch repository opts $ n2pia $ adddeps mypatch deps
> -       finalizeRepositoryChanges repository
> -       when (CheckPoint `elem` opts) $ write_recorded_checkpoint repository myinfo
> -       putStrLn $ "Finished tagging patch '"++name++"'"
> +    tentativelyAddPatch repository opts $ n2pia $ adddeps mypatch deps
> +    finalizeRepositoryChanges repository
> +    when (CheckPoint `elem` opts) $ write_recorded_checkpoint repository myinfo
> +    putStrLn $ "Finished tagging patch '"++name++"'"

Just killing a now redundant inner do block

resolve issue628: reuse the long comment code from Darcs.record
---------------------------------------------------------------
> +  where  get_name_log :: [DarcsFlag] -> [String] -> IO (String, [String])
> +         get_name_log o a = do let o2 = if null a then o else (add_patch_name o (unwords a))
> +                               (name, comment, _) <- get_log o2 Nothing (world_readable_temp "darcs-tag") NilFL
> +                               return ("TAG " ++ name, comment)

This also slightly refactors the tag code, which is nice.

> -get_patchname :: [DarcsFlag] -> IO String
> -get_patchname (PatchName n:_) = return $ "TAG "++n
> -get_patchname (_:flags) = get_patchname flags
> -get_patchname [] = do
> -    n <- askUser "What is the version name? "
> -    if n == "" then get_patchname []
> -               else return $ "TAG "++n

Note that the one drawback is that we now replace the next "What is the
version name? " with "What is the patch name? ".  I think  that's a
small matter though, and we should consider just taking this patch and
letting somebody fix it later.

-- 
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: 189 bytes
Desc: Digital signature
Url : http://lists.osuosl.org/pipermail/darcs-users/attachments/20081024/2dda5727/attachment.pgp 


More information about the darcs-users mailing list