gratuitous rename
This commit is contained in:
parent
0382d26cdb
commit
f3dcc8489d
11 changed files with 33 additions and 35 deletions
30
Annex.hs
30
Annex.hs
|
@ -17,17 +17,17 @@ import Control.Monad.State
|
||||||
|
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
import Types
|
import Types
|
||||||
import qualified BackendTypes as Backend
|
import qualified TypeInternals as Internals
|
||||||
|
|
||||||
{- Create and returns an Annex state object for the specified git repo.
|
{- Create and returns an Annex state object for the specified git repo.
|
||||||
-}
|
-}
|
||||||
new :: Git.Repo -> [Backend] -> IO AnnexState
|
new :: Git.Repo -> [Backend] -> IO AnnexState
|
||||||
new gitrepo allbackends = do
|
new gitrepo allbackends = do
|
||||||
let s = Backend.AnnexState {
|
let s = Internals.AnnexState {
|
||||||
Backend.repo = gitrepo,
|
Internals.repo = gitrepo,
|
||||||
Backend.backends = [],
|
Internals.backends = [],
|
||||||
Backend.supportedBackends = allbackends,
|
Internals.supportedBackends = allbackends,
|
||||||
Backend.flags = []
|
Internals.flags = []
|
||||||
}
|
}
|
||||||
(_,s') <- Annex.run s (prep gitrepo)
|
(_,s') <- Annex.run s (prep gitrepo)
|
||||||
return s'
|
return s'
|
||||||
|
@ -44,34 +44,34 @@ run state action = runStateT (action) state
|
||||||
gitRepo :: Annex Git.Repo
|
gitRepo :: Annex Git.Repo
|
||||||
gitRepo = do
|
gitRepo = do
|
||||||
state <- get
|
state <- get
|
||||||
return (Backend.repo state)
|
return (Internals.repo state)
|
||||||
gitRepoChange :: Git.Repo -> Annex ()
|
gitRepoChange :: Git.Repo -> Annex ()
|
||||||
gitRepoChange r = do
|
gitRepoChange r = do
|
||||||
state <- get
|
state <- get
|
||||||
put state { Backend.repo = r }
|
put state { Internals.repo = r }
|
||||||
return ()
|
return ()
|
||||||
backends :: Annex [Backend]
|
backends :: Annex [Backend]
|
||||||
backends = do
|
backends = do
|
||||||
state <- get
|
state <- get
|
||||||
return (Backend.backends state)
|
return (Internals.backends state)
|
||||||
backendsChange :: [Backend] -> Annex ()
|
backendsChange :: [Backend] -> Annex ()
|
||||||
backendsChange b = do
|
backendsChange b = do
|
||||||
state <- get
|
state <- get
|
||||||
put state { Backend.backends = b }
|
put state { Internals.backends = b }
|
||||||
return ()
|
return ()
|
||||||
supportedBackends :: Annex [Backend]
|
supportedBackends :: Annex [Backend]
|
||||||
supportedBackends = do
|
supportedBackends = do
|
||||||
state <- get
|
state <- get
|
||||||
return (Backend.supportedBackends state)
|
return (Internals.supportedBackends state)
|
||||||
flagIsSet :: Flag -> Annex Bool
|
flagIsSet :: Flag -> Annex Bool
|
||||||
flagIsSet flag = do
|
flagIsSet flag = do
|
||||||
state <- get
|
state <- get
|
||||||
return $ elem flag $ Backend.flags state
|
return $ elem flag $ Internals.flags state
|
||||||
flagChange :: Flag -> Bool -> Annex ()
|
flagChange :: Flag -> Bool -> Annex ()
|
||||||
flagChange flag set = do
|
flagChange flag set = do
|
||||||
state <- get
|
state <- get
|
||||||
let f = filter (/= flag) $ Backend.flags state
|
let f = filter (/= flag) $ Internals.flags state
|
||||||
if (set)
|
if (set)
|
||||||
then put state { Backend.flags = (flag:f) }
|
then put state { Internals.flags = (flag:f) }
|
||||||
else put state { Backend.flags = f }
|
else put state { Internals.flags = f }
|
||||||
return ()
|
return ()
|
||||||
|
|
14
Backend.hs
14
Backend.hs
|
@ -33,7 +33,7 @@ import qualified GitRepo as Git
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Utility
|
import Utility
|
||||||
import Types
|
import Types
|
||||||
import qualified BackendTypes as B
|
import qualified TypeInternals as Internals
|
||||||
|
|
||||||
{- List of backends in the order to try them when storing a new key. -}
|
{- List of backends in the order to try them when storing a new key. -}
|
||||||
backendList :: Annex [Backend]
|
backendList :: Annex [Backend]
|
||||||
|
@ -59,7 +59,7 @@ lookupBackendName all s =
|
||||||
if ((length matches) /= 1)
|
if ((length matches) /= 1)
|
||||||
then error $ "unknown backend " ++ s
|
then error $ "unknown backend " ++ s
|
||||||
else matches !! 0
|
else matches !! 0
|
||||||
where matches = filter (\b -> s == B.name b) all
|
where matches = filter (\b -> s == Internals.name b) all
|
||||||
|
|
||||||
{- Attempts to store a file in one of the backends. -}
|
{- Attempts to store a file in one of the backends. -}
|
||||||
storeFileKey :: FilePath -> Annex (Maybe (Key, Backend))
|
storeFileKey :: FilePath -> Annex (Maybe (Key, Backend))
|
||||||
|
@ -70,11 +70,11 @@ storeFileKey file = do
|
||||||
storeFileKey' b file relfile
|
storeFileKey' b file relfile
|
||||||
storeFileKey' [] _ _ = return Nothing
|
storeFileKey' [] _ _ = return Nothing
|
||||||
storeFileKey' (b:bs) file relfile = do
|
storeFileKey' (b:bs) file relfile = do
|
||||||
try <- (B.getKey b) relfile
|
try <- (Internals.getKey b) relfile
|
||||||
case (try) of
|
case (try) of
|
||||||
Nothing -> nextbackend
|
Nothing -> nextbackend
|
||||||
Just key -> do
|
Just key -> do
|
||||||
stored <- (B.storeFileKey b) file key
|
stored <- (Internals.storeFileKey b) file key
|
||||||
if (not stored)
|
if (not stored)
|
||||||
then nextbackend
|
then nextbackend
|
||||||
else do
|
else do
|
||||||
|
@ -85,17 +85,17 @@ storeFileKey' (b:bs) file relfile = do
|
||||||
{- Attempts to retrieve an key from one of the backends, saving it to
|
{- Attempts to retrieve an key from one of the backends, saving it to
|
||||||
- a specified location. -}
|
- a specified location. -}
|
||||||
retrieveKeyFile :: Backend -> Key -> FilePath -> Annex Bool
|
retrieveKeyFile :: Backend -> Key -> FilePath -> Annex Bool
|
||||||
retrieveKeyFile backend key dest = (B.retrieveKeyFile backend) key dest
|
retrieveKeyFile backend key dest = (Internals.retrieveKeyFile backend) key dest
|
||||||
|
|
||||||
{- Removes a key from a backend. -}
|
{- Removes a key from a backend. -}
|
||||||
removeKey :: Backend -> Key -> Annex Bool
|
removeKey :: Backend -> Key -> Annex Bool
|
||||||
removeKey backend key = (B.removeKey backend) key
|
removeKey backend key = (Internals.removeKey backend) key
|
||||||
|
|
||||||
{- Checks if a backend has its key. -}
|
{- Checks if a backend has its key. -}
|
||||||
hasKey :: Key -> Annex Bool
|
hasKey :: Key -> Annex Bool
|
||||||
hasKey key = do
|
hasKey key = do
|
||||||
all <- Annex.supportedBackends
|
all <- Annex.supportedBackends
|
||||||
(B.hasKey (lookupBackendName all $ backendName key)) key
|
(Internals.hasKey (lookupBackendName all $ backendName key)) key
|
||||||
|
|
||||||
{- Looks up the key and backend corresponding to an annexed file,
|
{- Looks up the key and backend corresponding to an annexed file,
|
||||||
- by examining what the file symlinks to. -}
|
- by examining what the file symlinks to. -}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import System.Cmd
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
|
|
||||||
import BackendTypes
|
import TypeInternals
|
||||||
import LocationLog
|
import LocationLog
|
||||||
import Locations
|
import Locations
|
||||||
import qualified Remotes
|
import qualified Remotes
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Backend.SHA1 (backend) where
|
||||||
import Data.Digest.Pure.SHA
|
import Data.Digest.Pure.SHA
|
||||||
|
|
||||||
import qualified Backend.File
|
import qualified Backend.File
|
||||||
import BackendTypes
|
import TypeInternals
|
||||||
|
|
||||||
backend = Backend.File.backend {
|
backend = Backend.File.backend {
|
||||||
name = "SHA1",
|
name = "SHA1",
|
||||||
|
|
|
@ -8,7 +8,7 @@ import Data.String.Utils
|
||||||
import System.Cmd
|
import System.Cmd
|
||||||
import System.Exit
|
import System.Exit
|
||||||
|
|
||||||
import BackendTypes
|
import TypeInternals
|
||||||
import Core
|
import Core
|
||||||
|
|
||||||
backend = Backend {
|
backend = Backend {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import System.Posix.Files
|
||||||
import qualified Data.ByteString.Lazy.Char8 as B
|
import qualified Data.ByteString.Lazy.Char8 as B
|
||||||
|
|
||||||
import qualified Backend.File
|
import qualified Backend.File
|
||||||
import BackendTypes
|
import TypeInternals
|
||||||
import Utility
|
import Utility
|
||||||
|
|
||||||
backend = Backend.File.backend {
|
backend = Backend.File.backend {
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
module BackendList (allBackends) where
|
module BackendList (allBackends) where
|
||||||
|
|
||||||
import BackendTypes
|
|
||||||
|
|
||||||
-- 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 Backend.WORM
|
import qualified Backend.WORM
|
||||||
import qualified Backend.SHA1
|
import qualified Backend.SHA1
|
||||||
|
|
|
@ -21,7 +21,7 @@ import LocationLog
|
||||||
import Types
|
import Types
|
||||||
import Core
|
import Core
|
||||||
import qualified Remotes
|
import qualified Remotes
|
||||||
import qualified BackendTypes
|
import qualified TypeInternals
|
||||||
|
|
||||||
data CmdWants = FilesInGit | FilesNotInGit | RepoName | SingleString
|
data CmdWants = FilesInGit | FilesNotInGit | RepoName | SingleString
|
||||||
data Command = Command {
|
data Command = Command {
|
||||||
|
@ -87,7 +87,7 @@ parseCmd argv state = do
|
||||||
[] -> error usage
|
[] -> error usage
|
||||||
[Command _ action want _] -> do
|
[Command _ action want _] -> do
|
||||||
f <- findWanted want (drop 1 params)
|
f <- findWanted want (drop 1 params)
|
||||||
(BackendTypes.repo state)
|
(TypeInternals.repo state)
|
||||||
return (flags, map action $ filter notstate f)
|
return (flags, map action $ filter notstate f)
|
||||||
where
|
where
|
||||||
-- never include files from the state directory
|
-- never include files from the state directory
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Locations (
|
||||||
import Data.String.Utils
|
import Data.String.Utils
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
import qualified BackendTypes as Backend
|
import qualified TypeInternals as Internals
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
|
|
||||||
{- Long-term, cross-repo state is stored in files inside the .git-annex
|
{- Long-term, cross-repo state is stored in files inside the .git-annex
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
{- git-annex backend data types
|
{- git-annex internal data types
|
||||||
-
|
-
|
||||||
- Mostly only backend implementations should need to import this.
|
- Most things should not need this, using Types and/or Annex instead.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module BackendTypes where
|
module TypeInternals where
|
||||||
|
|
||||||
import Control.Monad.State (StateT)
|
import Control.Monad.State (StateT)
|
||||||
import Data.String.Utils
|
import Data.String.Utils
|
2
Types.hs
2
Types.hs
|
@ -10,4 +10,4 @@ module Types (
|
||||||
Flag(..),
|
Flag(..),
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import BackendTypes
|
import TypeInternals
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue