filestore-0.6.3.4: Interface for versioning file stores.

Copyright | Copyright (C) 2009 John MacFarlane Gwern Branwen Sebastiaan Visser
License | BSD 3
Maintainer | John MacFarlane <jgm@berkeley.edu>
Stability | alpha
Portability | GHC 6.10 required
Safe Haskell | Safe
Language | Haskell98

Data.FileStore.Generic

Description

Generic utility functions for working with filestores.

Synopsis

- modify :: Contents a => FileStore -> FilePath -> RevisionId -> Author -> Description -> a -> IO (Either MergeInfo ())
- create :: Contents a => FileStore -> FilePath -> Author -> Description -> a -> IO ()
- data Diff a
  - = First a
  - | Second a
  - | Both a a
- diff :: FileStore -> FilePath -> Maybe RevisionId -> Maybe RevisionId -> IO [Diff [String]]
- searchRevisions :: FileStore -> Bool -> FilePath -> Description -> IO [Revision]
- smartRetrieve :: Contents a => FileStore -> Bool -> FilePath -> Maybe String -> IO a
- richDirectory :: FileStore -> FilePath -> IO [(Resource, Either String Revision)]

# Documentation

modify Source #

Arguments

:: Contents a |
=> FileStore |
-> FilePath | Resource to create.
-> RevisionId | ID of previous revision that is being modified.
-> Author | Author of change.
-> Description | Description of change.
-> a | Contents of resource.
-> IO (Either MergeInfo ()) |

Modify a named resource in the filestore. Like save, except that a revision ID must be specified. If the resource has been modified since the specified revision, `Left` merge information is returned. Otherwise, `Right` the new contents are saved.

create Source #

Arguments

:: Contents a |
=> FileStore |
-> FilePath | Resource to create.
-> Author | Author of change.
-> Description | Description of change.
-> a | Contents of resource.
-> IO () |

Like save, but first verify that the resource name is new. If not, throws a `ResourceExists` error.

data Diff a Source #

A value is either from the `First` list, the `Second` or from `Both`. `Both` contains both the left and right values, in case you are using a form of equality that doesn't check all data (for example, if you are using a newtype to only perform equality on side of a tuple).

Constructors

First a |
Second a |
Both a a |

Instances

Eq a => Eq (Diff a) |
Instance details Defined in Data.Algorithm.Diff Methods (==) :: Diff a -> Diff a -> Bool Source # (/=) :: Diff a -> Diff a -> Bool Source #
Show a => Show (Diff a) |
Instance details Defined in Data.Algorithm.Diff Methods showsPrec :: Int -> Diff a -> ShowS Source # show :: Diff a -> String Source # showList :: [Diff a] -> ShowS Source #

diff Source #

Arguments

:: FileStore |
-> FilePath | Resource name to get diff for.
-> Maybe RevisionId | `Just` old revision ID, or `Nothing` for empty.
-> Maybe RevisionId | `Just` oew revision ID, or `Nothing` for latest.
-> IO [Diff [String]] |

Return a unified diff of two revisions of a named resource. Format of the diff is a list `[(Diff, [String])]`, where `DI` is `F` (in first document only), `S` (in second only), or `B` (in both), and the list is a list of lines (without newlines at the end).

searchRevisions Source #

Arguments

:: FileStore |
-> Bool | When true the description must match exactly, when false partial hits are allowed.
-> FilePath | The resource to search history for.
-> Description | Revision description to search for.
-> IO [Revision] |

Return a list of all revisions that are saved with the given description or with a part of this description.

smartRetrieve Source #

Arguments

:: Contents a |
=> FileStore |
-> Bool | `True` for exact description match, `False` for partial match.
-> FilePath | Resource name to retrieve.
-> Maybe String | `Just` revision ID or description, or `Nothing` for empty.
-> IO a |

Try to retrieve a resource from the repository by name and possibly a revision identifier. When retrieving a resource by revision identifier fails this function will try to fetch the latest revision for which the description matches the given string.

richDirectory :: FileStore -> FilePath -> IO [(Resource, Either String Revision)] Source #

Like `directory`, but returns information about the latest revision.