explicit exports
This commit is contained in:
parent
af82586adf
commit
ebc3fbe9ae
11 changed files with 58 additions and 39 deletions
11
Annex.hs
11
Annex.hs
|
@ -1,7 +1,12 @@
|
||||||
{- git-annex toplevel code
|
{- git-annex toplevel code
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Annex where
|
module Annex (
|
||||||
|
State,
|
||||||
|
startAnnex,
|
||||||
|
annexFile,
|
||||||
|
unannexFile
|
||||||
|
) where
|
||||||
|
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
import System.Directory
|
import System.Directory
|
||||||
|
@ -34,7 +39,7 @@ annexDir repo key = do
|
||||||
- later. -}
|
- later. -}
|
||||||
startAnnex :: IO State
|
startAnnex :: IO State
|
||||||
startAnnex = do
|
startAnnex = do
|
||||||
r <- currentRepo
|
r <- gitRepoCurrent
|
||||||
config <- getConfig r
|
config <- getConfig r
|
||||||
gitPrep r
|
gitPrep r
|
||||||
return State {
|
return State {
|
||||||
|
@ -46,7 +51,7 @@ startAnnex = do
|
||||||
getConfig :: GitRepo -> IO GitConfig
|
getConfig :: GitRepo -> IO GitConfig
|
||||||
getConfig repo = do
|
getConfig repo = do
|
||||||
-- a name can be configured, if none is, use the repository path
|
-- a name can be configured, if none is, use the repository path
|
||||||
name <- gitConfigGet "annex.name" (top repo)
|
name <- gitConfigGet "annex.name" (gitRepoTop repo)
|
||||||
-- default number of copies to keep of file contents is 1
|
-- default number of copies to keep of file contents is 1
|
||||||
numcopies <- gitConfigGet "annex.numcopies" "1"
|
numcopies <- gitConfigGet "annex.numcopies" "1"
|
||||||
backends <- gitConfigGet "annex.backends" ""
|
backends <- gitConfigGet "annex.backends" ""
|
||||||
|
|
29
Backend.hs
29
Backend.hs
|
@ -16,32 +16,19 @@
|
||||||
- to store different files' contents in a given repository.
|
- to store different files' contents in a given repository.
|
||||||
- -}
|
- -}
|
||||||
|
|
||||||
module Backend where
|
module Backend (
|
||||||
|
Key,
|
||||||
|
Backend, -- note only data type is exported, not destructors
|
||||||
|
lookupBackend,
|
||||||
|
storeFile,
|
||||||
|
dropFile
|
||||||
|
) where
|
||||||
|
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import Locations
|
import Locations
|
||||||
import GitRepo
|
import GitRepo
|
||||||
import Utility
|
import Utility
|
||||||
|
import BackendType
|
||||||
-- annexed filenames are mapped into keys
|
|
||||||
type Key = FilePath
|
|
||||||
|
|
||||||
-- this structure represents a key/value backend
|
|
||||||
data Backend = Backend {
|
|
||||||
-- name of this backend
|
|
||||||
name :: String,
|
|
||||||
-- converts a filename to a key
|
|
||||||
getKey :: GitRepo -> FilePath -> IO (Maybe Key),
|
|
||||||
-- stores a file's contents to a key
|
|
||||||
storeFileKey :: GitRepo -> FilePath -> Key -> IO Bool,
|
|
||||||
-- retrieves a key's contents to a file
|
|
||||||
retrieveKeyFile :: Key -> FilePath -> IO Bool,
|
|
||||||
-- removes a key
|
|
||||||
removeKey :: Key -> IO Bool
|
|
||||||
}
|
|
||||||
|
|
||||||
instance Show Backend where
|
|
||||||
show backend = "Backend { name =\"" ++ (name backend) ++ "\" }"
|
|
||||||
|
|
||||||
{- Name of state file that holds the key for an annexed file,
|
{- Name of state file that holds the key for an annexed file,
|
||||||
- using a given backend. -}
|
- using a given backend. -}
|
||||||
|
|
|
@ -5,7 +5,7 @@ module BackendChecksum (backend) where
|
||||||
|
|
||||||
import qualified BackendFile
|
import qualified BackendFile
|
||||||
import Data.Digest.Pure.SHA
|
import Data.Digest.Pure.SHA
|
||||||
import Backend
|
import BackendType
|
||||||
import GitRepo
|
import GitRepo
|
||||||
|
|
||||||
-- based on BackendFile just with a different key type
|
-- based on BackendFile just with a different key type
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
module BackendFile (backend) where
|
module BackendFile (backend) where
|
||||||
|
|
||||||
import Backend
|
import BackendType
|
||||||
import GitRepo
|
import GitRepo
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
{- git-annex backend list
|
{- git-annex backend list
|
||||||
- -}
|
- -}
|
||||||
|
|
||||||
module BackendList where
|
module BackendList (
|
||||||
|
supportedBackends,
|
||||||
|
parseBackendList,
|
||||||
|
lookupBackendName
|
||||||
|
) where
|
||||||
|
|
||||||
import Backend
|
import BackendType
|
||||||
|
|
||||||
-- When adding a new backend, import it here and add it to the list.
|
-- When adding a new backend, import it here and add it to the list.
|
||||||
import qualified BackendFile
|
import qualified BackendFile
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
module BackendUrl (backend) where
|
module BackendUrl (backend) where
|
||||||
|
|
||||||
import Backend
|
import BackendType
|
||||||
import GitRepo
|
import GitRepo
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
- System.Console.CmdArgs.Implicit but it is not yet packaged in Debian.
|
- System.Console.CmdArgs.Implicit but it is not yet packaged in Debian.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module CmdLine where
|
module CmdLine (
|
||||||
|
argvToMode,
|
||||||
|
dispatch
|
||||||
|
) where
|
||||||
|
|
||||||
import System.Console.GetOpt
|
import System.Console.GetOpt
|
||||||
import Annex
|
import Annex
|
||||||
|
|
22
GitRepo.hs
22
GitRepo.hs
|
@ -1,6 +1,15 @@
|
||||||
{- git repository handling -}
|
{- git repository handling -}
|
||||||
|
|
||||||
module GitRepo where
|
module GitRepo (
|
||||||
|
GitRepo,
|
||||||
|
gitRepoCurrent,
|
||||||
|
gitRepoTop,
|
||||||
|
gitDir,
|
||||||
|
gitRelative,
|
||||||
|
gitConfigGet,
|
||||||
|
gitAdd,
|
||||||
|
gitAttributes
|
||||||
|
) where
|
||||||
|
|
||||||
import Directory
|
import Directory
|
||||||
import System.Directory
|
import System.Directory
|
||||||
|
@ -13,7 +22,7 @@ import Utility
|
||||||
|
|
||||||
-- a git repository
|
-- a git repository
|
||||||
data GitRepo = GitRepo {
|
data GitRepo = GitRepo {
|
||||||
top :: FilePath,
|
gitRepoTop :: FilePath,
|
||||||
bare :: Bool
|
bare :: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +32,13 @@ gitRepo dir = do
|
||||||
b <- isBareRepo dir
|
b <- isBareRepo dir
|
||||||
|
|
||||||
return GitRepo {
|
return GitRepo {
|
||||||
top = dir,
|
gitRepoTop = dir,
|
||||||
bare = b
|
bare = b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{- Short name used in here for top of repo. -}
|
||||||
|
top = gitRepoTop
|
||||||
|
|
||||||
{- Path to a repository's gitattributes file. -}
|
{- Path to a repository's gitattributes file. -}
|
||||||
gitAttributes :: GitRepo -> IO String
|
gitAttributes :: GitRepo -> IO String
|
||||||
gitAttributes repo = do
|
gitAttributes repo = do
|
||||||
|
@ -73,8 +85,8 @@ gitConfigGet name defaultValue =
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
{- Finds the current git repository, which may be in a parent directory. -}
|
{- Finds the current git repository, which may be in a parent directory. -}
|
||||||
currentRepo :: IO GitRepo
|
gitRepoCurrent :: IO GitRepo
|
||||||
currentRepo = do
|
gitRepoCurrent = do
|
||||||
cwd <- getCurrentDirectory
|
cwd <- getCurrentDirectory
|
||||||
top <- seekUp cwd isRepoTop
|
top <- seekUp cwd isRepoTop
|
||||||
case top of
|
case top of
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
- so the lines may be in arbitrary order, but it will never conflict.
|
- so the lines may be in arbitrary order, but it will never conflict.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module LocationLog where
|
module LocationLog (
|
||||||
|
) where
|
||||||
|
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import Data.Time
|
import Data.Time
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
{- git-annex file locations
|
{- git-annex file locations
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Locations where
|
module Locations (
|
||||||
|
gitStateDir,
|
||||||
|
stateLoc
|
||||||
|
) where
|
||||||
|
|
||||||
import GitRepo
|
import GitRepo
|
||||||
|
|
||||||
|
@ -9,4 +12,4 @@ import GitRepo
|
||||||
- directory, in the git repository. -}
|
- directory, in the git repository. -}
|
||||||
stateLoc = ".git-annex"
|
stateLoc = ".git-annex"
|
||||||
gitStateDir :: GitRepo -> FilePath
|
gitStateDir :: GitRepo -> FilePath
|
||||||
gitStateDir repo = (top repo) ++ "/" ++ stateLoc ++ "/"
|
gitStateDir repo = (gitRepoTop repo) ++ "/" ++ stateLoc ++ "/"
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
{- git-annex utility functions
|
{- git-annex utility functions
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Utility where
|
module Utility (
|
||||||
|
withFileLocked,
|
||||||
|
hGetContentsStrict,
|
||||||
|
parentDir
|
||||||
|
) where
|
||||||
|
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Posix.IO
|
import System.Posix.IO
|
||||||
|
|
Loading…
Add table
Reference in a new issue