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



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



darcsDecodeWhite :: String -> FilePathSource

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 -> StringSource

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"

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

darcsTreeHash :: Tree m -> HashSource

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

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

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

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

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).

writeDarcsHashed :: Tree IO -> FilePath -> IO HashSource

Write a Tree into a darcs-style hashed directory.

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

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).



:: TreeIO a


-> Tree IO


-> FilePath


-> 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)Source

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)Source

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!

darcsPristineRefs :: FileSegment -> IO [Hash]Source