{-# LANGUAGE Rank2Types, TypeSynonymInstances, DeriveDataTypeable #-}{- |
Module : Data.FileStore.Types
Copyright : Copyright (C) 2009 John MacFarlane
License : BSD 3
Maintainer : John MacFarlane <jgm@berkeley.edu>
Stability : alpha
Portability : GHC 6.10 required
Type definitions for "Data.FileStore".
-}moduleData.FileStore.Types(RevisionId,Resource(..),Author(..),Change(..),Description,Revision(..),Contents(..),TimeRange(..),MergeInfo(..),FileStoreError(..),SearchMatch(..),SearchQuery(..),defaultSearchQuery,DateTime,FileStore(..))whereimportData.ByteString.Lazy(ByteString)importData.TypeableimportData.ByteString.Lazy.UTF8(toString,fromString)importData.DateTime(DateTime)importControl.Exception(Exception)importPreludehiding(catch)importSystem.FilePath(FilePath)typeRevisionId=StringdataResource=FSFileFilePath|FSDirectoryFilePathderiving(Show,Read,Eq,Typeable,Ord)dataAuthor=Author{authorName::String,authorEmail::String}deriving(Show,Read,Eq,Typeable)dataChange=AddedFilePath|DeletedFilePath|ModifiedFilePathderiving(Show,Read,Eq,Typeable)typeDescription=StringdataRevision=Revision{revId::RevisionId,revDateTime::DateTime,revAuthor::Author,revDescription::Description,revChanges::[Change]}deriving(Show,Read,Eq,Typeable)classContentsawherefromByteString::ByteString->atoByteString::a->ByteStringinstanceContentsByteStringwheretoByteString=idfromByteString=idinstanceContentsStringwheretoByteString=fromStringfromByteString=toStringdataTimeRange=TimeRange{timeFrom::MaybeDateTime-- ^ @Nothing@ means no lower bound,timeTo::MaybeDateTime-- ^ @Nothing@ means no upper bound}deriving(Show,Read,Eq,Typeable)dataMergeInfo=MergeInfo{mergeRevision::Revision-- ^ The revision w/ which changes were merged,mergeConflicts::Bool-- ^ @True@ if there were merge conflicts,mergeText::String-- ^ The merged text, w/ conflict markers}deriving(Show,Read,Eq,Typeable)dataFileStoreError=RepositoryExists-- ^ Tried to initialize a repo that exists|ResourceExists-- ^ Tried to create a resource that exists|NotFound-- ^ Requested resource was not found|IllegalResourceName-- ^ The specified resource name is illegal|Unchanged-- ^ The resource was not modified,-- because the contents were unchanged|UnsupportedOperation|NoMaxCount-- ^ The darcs version used does not support-- --max-count|UnknownErrorStringderiving(Read,Eq,Typeable)instanceShowFileStoreErrorwhereshowRepositoryExists="RepositoryExists"showResourceExists="ResourceExists"showNotFound="NotFound"showIllegalResourceName="IllegalResourceName"showUnchanged="Unchanged"showUnsupportedOperation="UnsupportedOperation"showNoMaxCount="NoMaxCount:\n"++"filestore was compiled with the maxcount flag, but your version of\n"++"darcs does not support the --max-count option. You should either\n"++"upgrade to darcs >= 2.3.0 (recommended) or compile filestore without\n"++"the maxcount flag (cabal install filestore -f-maxcount)."show(UnknownErrors)="UnknownError: "++sinstanceExceptionFileStoreErrordataSearchQuery=SearchQuery{queryPatterns::[String]-- ^ Patterns to match,queryWholeWords::Bool-- ^ Match patterns only with whole words?,queryMatchAll::Bool-- ^ Return matches only from files in which-- all patterns match?,queryIgnoreCase::Bool-- ^ Make matches case-insensitive?}deriving(Show,Read,Eq,Typeable)defaultSearchQuery::SearchQuerydefaultSearchQuery=SearchQuery{queryPatterns=[],queryWholeWords=True,queryMatchAll=True,queryIgnoreCase=True}dataSearchMatch=SearchMatch{matchResourceName::FilePath,matchLineNumber::Integer,matchLine::String}deriving(Show,Read,Eq,Typeable)-- | A versioning filestore, which can be implemented using the-- file system, a database, or revision-control software.dataFileStore=FileStore{-- | Initialize a new filestore.initialize::IO()-- | Save contents in the filestore.,save::Contentsa=>FilePath-- Resource to save.->Author-- Author of change.->Description-- Description of change.->a-- New contents of resource.->IO()-- | Retrieve the contents of the named resource.,retrieve::Contentsa=>FilePath-- Resource to retrieve.->MaybeRevisionId-- @Just@ a particular revision ID,-- or @Nothing@ for latest->IOa-- | Delete a named resource, providing author and log message.,delete::FilePath-- Resource to delete.->Author-- Author of change.->Description-- Description of change.->IO()-- | Rename a resource, providing author and log message.,rename::FilePath-- Resource original name.->FilePath-- Resource new name.->Author-- Author of change.->Description-- Description of change.->IO()-- | Get history for a list of named resources in a (possibly openended)-- time range. If the list is empty, history for all resources will-- be returned.,history::[FilePath]-- List of resources to get history for-- or @[]@ for all.->TimeRange-- Time range in which to get history.->IO[Revision]-- | Return the revision ID of the latest change for a resource.-- Raises 'NotFound' if the resource is not found.,latest::FilePath-- Resource to get revision ID for.->IORevisionId-- | Return information about a revision, given the ID.-- Raises 'NotFound' if there is no such revision.,revision::RevisionId-- Revision ID to get information for.->IORevision-- | Return a list of resources in the filestore.,index::IO[FilePath]-- | Return a list of resources in a directory of the filestore.,directory::FilePath-- Directory to list (empty for root)->IO[Resource]-- | @True@ if the revision IDs match, in the sense that the-- can be treated as specifying the same revision.,idsMatch::RevisionId->RevisionId->Bool-- | Search the filestore for patterns.,search::SearchQuery->IO[SearchMatch]}