Storage.Hashed.Darcs

hashed-storage-0.5.10: Hashed file storage support code.

Safe Haskell | None

Storage.Hashed.Darcs

Description

A few darcs-specific utility functions. These are used for reading and writing darcs and darcs-compatible hashed trees.

Synopsis

- darcsDecodeWhite :: String -> FilePath
- darcsEncodeWhite :: FilePath -> String
- darcsEncodeWhiteBS :: ByteString -> ByteString
- decodeDarcsHash :: ByteString -> Hash
- decodeDarcsSize :: ByteString -> Maybe Int
- darcsLocation :: FilePath -> (Maybe Int, Hash) -> FileSegment
- darcsFormatDir :: Tree m -> Maybe ByteString
- darcsParseDir :: ByteString -> [(ItemType, Name, Maybe Int, Hash)]
- darcsTreeHash :: Tree m -> Hash
- darcsUpdateDirHashes :: Tree m -> Tree m
- darcsUpdateHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)
- darcsHash :: (Monad m, Functor m) => TreeItem m -> m Hash
- darcshash :: Monad m => t -> m Hash
- darcsAddMissingHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)
- readDarcsHashedDir :: FilePath -> (Maybe Int, Hash) -> IO [(ItemType, Name, Maybe Int, Hash)]
- readDarcsHashed' :: Bool -> FilePath -> (Maybe Int, Hash) -> IO (Tree IO)
- readDarcsHashed :: FilePath -> (Maybe Int, Hash) -> IO (Tree IO)
- readDarcsHashedNosize :: FilePath -> Hash -> IO (Tree IO)
- writeDarcsHashed :: Tree IO -> FilePath -> IO Hash
- fsCreateHashedFile :: FilePath -> ByteString -> TreeIO ()
- hashedTreeIO :: TreeIO a -> Tree IO -> FilePath -> IO (a, Tree IO)
- readPackedDarcsPristine :: OS -> Hash -> IO (Tree IO)
- writePackedDarcsPristine :: Tree IO -> OS -> IO (OS, Hash)
- storePackedDarcsPristine :: Tree IO -> OS -> IO (OS, Hash)
- darcsPristineRefs :: FileSegment -> IO [Hash]
- darcsCheckExpand :: Tree IO -> IO (Either [(FilePath, Hash, Maybe Hash)] (Tree IO))

# Documentation

darcsDecodeWhite :: String -> FilePath

`darcsDecodeWhite` interprets the Darcs-specific "encoded" filenames produced by `darcsEncodeWhite`

     darcsDecodeWhite "hello\32\there" == "hello there"
     darcsDecodeWhite "hello\92\there" == "hello\there"
     darcsDecodeWhite "hello\there"    == error "malformed filename"

darcsEncodeWhite :: FilePath -> String

`darcsEncodeWhite` translates whitespace in filenames to a darcs-specific format (backslash followed by numerical representation according to `ord`). Note that backslashes are also escaped since they are used in the encoding.

     darcsEncodeWhite "hello there" == "hello\32\there"
     darcsEncodeWhite "hello\there" == "hello\92\there"

darcsEncodeWhiteBS :: ByteString -> ByteString

decodeDarcsHash :: ByteString -> Hash

decodeDarcsSize :: ByteString -> Maybe Int

darcsLocation :: FilePath -> (Maybe Int, Hash) -> FileSegment

darcsFormatDir :: Tree m -> Maybe ByteString

darcsParseDir :: ByteString -> [(ItemType, Name, Maybe Int, Hash)]

darcsTreeHash :: Tree m -> Hash

Compute a darcs-compatible hash value for a tree-like structure.

darcsUpdateDirHashes :: Tree m -> Tree m

darcsUpdateHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)

darcsHash :: (Monad m, Functor m) => TreeItem m -> m Hash

darcshash :: Monad m => t -> m Hash

darcsAddMissingHashes :: (Monad m, Functor m) => Tree m -> m (Tree m)

readDarcsHashedDir :: FilePath -> (Maybe Int, Hash) -> IO [(ItemType, Name, Maybe Int, Hash)]

Read and parse a darcs-style hashed directory listing from a given `dir` and with a given `hash`.

readDarcsHashed' :: Bool -> FilePath -> (Maybe Int, Hash) -> IO (Tree IO)

Read in a darcs-style hashed tree. This is mainly useful for reading "pristine.hashed". You need to provide the root hash you are interested in (found in _darcs/hashed_inventory).

readDarcsHashed :: FilePath -> (Maybe Int, Hash) -> IO (Tree IO)

readDarcsHashedNosize :: FilePath -> Hash -> IO (Tree IO)

writeDarcsHashed :: Tree IO -> FilePath -> IO Hash

Write a Tree into a darcs-style hashed directory.

fsCreateHashedFile :: FilePath -> ByteString -> TreeIO ()

Create a hashed file from a `FilePath` and content. In case the file exists it is kept untouched and is assumed to have the right content. XXX Corrupt files should be probably renamed out of the way automatically or something (probably when they are being read though).

hashedTreeIO

Arguments

:: TreeIO a | action
-> Tree IO | initial
-> FilePath | directory
-> IO (a, Tree IO) |

Run a `TreeIO` `action` in a hashed setting. The `initial` tree is assumed to be fully available from the `directory`, and any changes will be written out to same. Please note that actual filesystem files are never removed.

readPackedDarcsPristine :: OS -> Hash -> IO (Tree IO)

Read a Tree in the darcs hashed format from an object storage. This is basically the same as readDarcsHashed from Storage.Hashed, but uses an object storage instead of traditional darcs filesystem layout. Requires the tree root hash as a starting point.

writePackedDarcsPristine :: Tree IO -> OS -> IO (OS, Hash)

Write a Tree into an object storage, using the darcs-style directory formatting (and therefore darcs-style hashes). Gives back the object storage and the root hash of the stored Tree. NB. The function expects that the Tree comes equipped with darcs-style hashes already!

storePackedDarcsPristine :: Tree IO -> OS -> IO (OS, Hash)

darcsPristineRefs :: FileSegment -> IO [Hash]

darcsCheckExpand :: Tree IO -> IO (Either [(FilePath, Hash, Maybe Hash)] (Tree IO))