[darcs-users] darcs patch: cut hardly-used type synonym. (and 2 more)

Eric Kow kowey at darcs.net
Wed May 13 03:10:21 UTC 2009


On Wed, May 13, 2009 at 12:54:57 +1000, Trent W.Buck wrote:
> Three more tweaks from David's branch.
> They apply cleanly.  They pass functional tests (on Debian).
> The need review from a subject matter expert.
> 
> Wed Dec 10 03:59:23 EST 2008  David Roundy <droundy at darcs.net>
>   * cut hardly-used type synonym.
> 
> Thu Dec 11 02:41:26 EST 2008  David Roundy <droundy at darcs.net>
>   * fix error output (which leaked userError).

I've applied these two, as they seem to be fine.
 
> Mon Mar 30 09:39:58 EST 2009  David Roundy <droundy at darcs.net>
>   * clean up types in win32/System/Posix.hs

Salvatore, could you look at this last one?

Thanks!

cut hardly-used type synonym.
-----------------------------
> David Roundy <droundy at darcs.net>**20081209165923
>  Ignore-this: db41f41d614520e1adfc86d0444b25e1
> ] hunk ./src/Printer.lhs 156
>  
>  -- | The State associated with a doc. Contains a set of printers for each
>  -- hanlde, and the current prefix of the document.
> -data St = St { printers :: !Printers', current_prefix :: !DocumentInternals }
> +data St = St { printers :: !Printers',
> +               current_prefix :: !([Printable] -> [Printable]) }
>  type Printers = Handle -> Printers'
>  
>  -- | A set of printers to print different types of text to a handle.
> hunk ./src/Printer.lhs 167
>                             userchunkP :: !Printer,
>                             defP :: !Printer,
>                             lineColorT :: !(Color -> Doc -> Doc),
> -                           lineColorS :: !DocumentInternals
> +                           lineColorS :: !([Printable] -> [Printable])
>                            }
>  type Printer = Printable -> St -> Document
>  
> hunk ./src/Printer.lhs 173
>  data Color = Blue | Red | Green | Cyan | Magenta
>  
> --- | 'DocumentInternals' represents a 'Printable' by the function
> --- which concatenates another 'Printable' to its right.
> -type DocumentInternals = [Printable] -> [Printable]
> -
> --- | 'Document' is a wrapper around 'DocumentInternals' which allows
> +-- | 'Document' is a wrapper around '[Printable] -> [Printable]' which allows
>  -- for empty Documents. The simplest 'Documents' are built from 'String's
>  -- using 'text'.
> hunk ./src/Printer.lhs 176
> -data Document = Document DocumentInternals
> +data Document = Document ([Printable] -> [Printable])
>                | Empty
>  
>  -- | renders a 'Doc' into a 'String' with control codes for the

fix error output (which leaked userError).
------------------------------------------
> David Roundy <droundy at darcs.net>**20081210154126
>  Ignore-this: 3c5be44fa8b52d5f583dd8a664e330be
> ] hunk ./src/Darcs/Commands/Get.lhs 64
>  import Darcs.SignalHandler ( catchInterrupt )
>  import Darcs.Commands.Init ( initialize )
>  import Darcs.Match ( have_patchset_match, get_one_patchset )
> -import Darcs.Utils ( catchall, formatPath, withCurrentDirectory )
> +import Darcs.Utils ( catchall, formatPath, withCurrentDirectory, prettyError )
>  import Progress ( debugMessage )
>  import Printer ( text, vcat, errorDoc, ($$), Doc, putDocLn, )
>  import Darcs.Lock ( writeBinFile )
> hunk ./src/Darcs/Commands/Get.lhs 332
>                                      get_patches_beyond_tag pi_ch local_patches
>                     in do write_checkpoint_patch p_ch
>                           apply opts p_ch `catch`
> -                             \e -> fail ("Bad checkpoint!\n" ++ show e)
> +                             \e -> fail ("Bad checkpoint!!!\n" ++ prettyError e)
>                           apply_patches opts needed_patches
>            else apply_patches opts $ reverseRL $ concatRL local_patches
>    debugMessage "Writing the pristine"
> hunk ./src/Darcs/Repository.hs 108
>  import Darcs.Repository.Pristine ( createPristine, flagsToPristine )
>  import Darcs.Patch.Depends ( get_patches_beyond_tag )
>  import Darcs.SlurpDirectory ( empty_slurpy )
> -import Darcs.Utils ( withCurrentDirectory, catchall, promptYorn )
> +import Darcs.Utils ( withCurrentDirectory, catchall, promptYorn, prettyError )
>  import Darcs.External ( copyFileOrUrl, Cachable(..) )
>  import Progress ( debugMessage, tediousSize,
>                          beginTedious, endTedious, progress )
> hunk ./src/Darcs/Repository.hs 212
>             FlippedSeal ps <- return $ get_patches_beyond_tag pi_ch local_patches
>             let needed_patches = reverseRL $ concatRL ps
>             apply opts ch `catch`
> -                             \e -> fail ("Bad checkpoint!\n" ++ show e)
> +                             \e -> fail ("Bad checkpoint!\n" ++ prettyError e)
>             apply_patches opts needed_patches
>             debugMessage "Writing the pristine"
>             pristineFromWorking torepository
> hunk ./src/Darcs/Utils.hs 6
>  {-# LANGUAGE CPP, ForeignFunctionInterface #-}
>  
>  module Darcs.Utils ( catchall, ortryrunning, nubsort, breakCommand,
> -                     clarify_errors, prettyException,
> +                     clarify_errors, prettyException, prettyError,
>                      putStrLnError, putDocLnError,
>                      withCurrentDirectory,
>                      withUMask, askUser, stripCr,
> hunk ./src/Darcs/Utils.hs 100
>  prettyException (IOException e) | isUserError e = ioeGetErrorString e
>  prettyException e = show e
>  
> +prettyError :: IOError -> String
> +prettyError e | isUserError e = ioeGetErrorString e
> +              | otherwise = show e
> +
>  ortryrunning :: IO ExitCode -> IO ExitCode -> IO ExitCode
>  a `ortryrunning` b = do ret <- try a
>                          case ret of

clean up types in win32/System/Posix.hs
---------------------------------------
> David Roundy <droundy at darcs.net>**20090329223958
>  Ignore-this: 80fb3dcbc0bb296d7b7337905bcf12564f8e79f4
> ] hunk ./src/win32/System/Posix.hs 6
>  
>  module System.Posix where
>  
> -import Foreign.Ptr ( Ptr, castPtr, plusPtr )
> -import Foreign.Storable ( peek, poke, sizeOf )
> +import Foreign.Ptr ( Ptr )
> +import Foreign.Storable ( peek )
>  import Foreign.C.Types ( CInt, CUInt, CULong, CTime )
>  import Foreign.C.String ( CString, withCString )
> hunk ./src/win32/System/Posix.hs 10
> -import Foreign.Marshal.Alloc ( allocaBytes )
> +import Foreign.Marshal.Array ( withArray )
> +import Foreign.Marshal.Alloc ( alloca )
>  
>  import System.Posix.Types ( EpochTime )
>  import System.IO ( Handle )
> hunk ./src/win32/System/Posix.hs 16
>  
> -
> -foreign import ccall "sys/utime.h _utime" c_utime :: CString -> Ptr a -> IO CInt
> +foreign import ccall "sys/utime.h _utime" c_utime :: CString -> Ptr CTime -> IO CInt
>  
>  setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
>  setFileTimes path atime mtime = path `withCString` \s -> do
> hunk ./src/win32/System/Posix.hs 20
> -  allocaBytes 8 $ \p -> do
> -    poke (castPtr p :: Ptr CTime) (atime)
> -    poke (castPtr (plusPtr p 4) :: Ptr CTime) (mtime)
> -    c_utime s p
> -    return ()
> +  withArray [atime,mtime] $ \p -> do c_utime s p
> +                                     return ()
>  
>  
>  foreign import ccall "time" c_ctime :: Ptr CTime -> IO CInt
> hunk ./src/win32/System/Posix.hs 28
>  
>  epochTime :: IO EpochTime
>  epochTime = do
> -    allocaBytes (sizeOf (undefined :: CTime)) $ \p -> do
> -      c_ctime p
> -      t <- peek p :: IO CTime
> -      return t
> +  alloca $ \p -> do c_ctime p
> +                    t <- peek p :: IO CTime
> +                    return t
>  
>  foreign import stdcall "winbase.h SleepEx" c_SleepEx :: CULong -> CUInt -> IO CInt
>  
> 

-- 
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: 194 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090512/10ee603d/attachment.pgp>


More information about the darcs-users mailing list