summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-14 02:52:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-14 02:52:17 -0400
commit0b55bd05de7b83a474ea58e9d45676934667f4bd (patch)
tree1e2373381a650d0c2c5c1bc6c5cffa58cf922989
parent4c1d8b9689043c18214b1da7d5c145fb0859443d (diff)
more namespace cleanup
-rw-r--r--AbstractTypes.hs32
-rw-r--r--Backend.hs3
-rw-r--r--BackendChecksum.hs2
-rw-r--r--BackendFile.hs2
-rw-r--r--BackendList.hs2
-rw-r--r--BackendTypes.hs (renamed from Types.hs)37
-rw-r--r--BackendUrl.hs2
-rw-r--r--Locations.hs8
8 files changed, 49 insertions, 39 deletions
diff --git a/AbstractTypes.hs b/AbstractTypes.hs
index 510a37f0c..935d1de2f 100644
--- a/AbstractTypes.hs
+++ b/AbstractTypes.hs
@@ -14,4 +14,34 @@ module AbstractTypes (
Backend
) where
-import Types
+import Control.Monad.State
+import qualified GitRepo as Git
+import BackendTypes
+
+-- constructor
+makeAnnexState :: Git.Repo -> AnnexState
+makeAnnexState g = AnnexState { repo = g, backends = [] }
+
+-- performs an action in the Annex monad
+runAnnexState state action = runStateT (action) state
+
+-- Annex monad state accessors
+gitAnnex :: Annex Git.Repo
+gitAnnex = do
+ state <- get
+ return (repo state)
+gitAnnexChange :: Git.Repo -> Annex ()
+gitAnnexChange r = do
+ state <- get
+ put state { repo = r }
+ return ()
+backendsAnnex :: Annex [Backend]
+backendsAnnex = do
+ state <- get
+ return (backends state)
+backendsAnnexChange :: [Backend] -> Annex ()
+backendsAnnexChange b = do
+ state <- get
+ put state { backends = b }
+ return ()
+
diff --git a/Backend.hs b/Backend.hs
index 1bd4efc1e..251e436c7 100644
--- a/Backend.hs
+++ b/Backend.hs
@@ -30,7 +30,8 @@ import BackendList
import Locations
import qualified GitRepo as Git
import Utility
-import Types
+import AbstractTypes
+import BackendTypes
{- Attempts to store a file in one of the backends. -}
storeFile :: FilePath -> Annex (Maybe (Key, Backend))
diff --git a/BackendChecksum.hs b/BackendChecksum.hs
index c6e68ffed..50ef2ae6f 100644
--- a/BackendChecksum.hs
+++ b/BackendChecksum.hs
@@ -5,7 +5,7 @@ module BackendChecksum (backend) where
import qualified BackendFile
import Data.Digest.Pure.SHA
-import Types
+import BackendTypes
-- based on BackendFile just with a different key type
backend = BackendFile.backend {
diff --git a/BackendFile.hs b/BackendFile.hs
index a0396f51d..284daca88 100644
--- a/BackendFile.hs
+++ b/BackendFile.hs
@@ -7,7 +7,7 @@ import Control.Monad.State
import System.IO
import System.Cmd
import Control.Exception
-import Types
+import BackendTypes
import LocationLog
import Locations
import qualified Remotes
diff --git a/BackendList.hs b/BackendList.hs
index 104444dc2..91a2fa7fc 100644
--- a/BackendList.hs
+++ b/BackendList.hs
@@ -7,7 +7,7 @@ module BackendList (
lookupBackendName
) where
-import Types
+import BackendTypes
-- When adding a new backend, import it here and add it to the list.
import qualified BackendFile
diff --git a/Types.hs b/BackendTypes.hs
index c9d33affd..2ef65f469 100644
--- a/Types.hs
+++ b/BackendTypes.hs
@@ -1,12 +1,16 @@
-{- git-annex core data types -}
+{- git-annex backend data types
+ -
+ - Mostly only backend implementations should need to import this.
+ -}
-module Types where
+module BackendTypes where
import Control.Monad.State
import Data.String.Utils
import qualified GitRepo as Git
--- git-annex's runtime state
+-- git-annex's runtime state type doesn't really belong here,
+-- but it uses Backend, so has to be here to avoid a depends loop.
data AnnexState = AnnexState {
repo :: Git.Repo,
backends :: [Backend]
@@ -15,33 +19,6 @@ data AnnexState = AnnexState {
-- git-annex's monad
type Annex = StateT AnnexState IO
--- constructor
-makeAnnexState :: Git.Repo -> AnnexState
-makeAnnexState g = AnnexState { repo = g, backends = [] }
-
--- performs an action in the Annex monad
-runAnnexState state action = runStateT (action) state
-
--- Annex monad state accessors
-gitAnnex :: Annex Git.Repo
-gitAnnex = do
- state <- get
- return (repo state)
-gitAnnexChange :: Git.Repo -> Annex ()
-gitAnnexChange r = do
- state <- get
- put state { repo = r }
- return ()
-backendsAnnex :: Annex [Backend]
-backendsAnnex = do
- state <- get
- return (backends state)
-backendsAnnexChange :: [Backend] -> Annex ()
-backendsAnnexChange b = do
- state <- get
- put state { backends = b }
- return ()
-
-- annexed filenames are mapped into keys
data Key = Key String deriving (Eq)
diff --git a/BackendUrl.hs b/BackendUrl.hs
index 43b0bc75a..fc0a8ae58 100644
--- a/BackendUrl.hs
+++ b/BackendUrl.hs
@@ -6,7 +6,7 @@ module BackendUrl (backend) where
import Control.Monad.State
import System.Cmd
import IO
-import Types
+import BackendTypes
backend = Backend {
name = "url",
diff --git a/Locations.hs b/Locations.hs
index 5d701681c..8c1915b02 100644
--- a/Locations.hs
+++ b/Locations.hs
@@ -11,7 +11,8 @@ module Locations (
) where
import Data.String.Utils
-import Types
+import AbstractTypes
+import qualified BackendTypes as Backend
import qualified GitRepo as Git
{- Long-term, cross-repo state is stored in files inside the .git-annex
@@ -32,7 +33,7 @@ annexLocation r backend key =
{- Annexed file's location relative to the gitWorkTree -}
annexLocationRelative :: Git.Repo -> Backend -> Key -> FilePath
annexLocationRelative r backend key =
- Git.dir r ++ "/annex/" ++ (name backend) ++ "/" ++ (keyFile key)
+ Git.dir r ++ "/annex/" ++ (Backend.name backend) ++ "/" ++ (keyFile key)
{- Converts a key into a filename fragment.
-
@@ -50,4 +51,5 @@ keyFile key = replace "/" "%" $ replace "%" "&s" $ replace "&" "&a" $ show key
{- Reverses keyFile, converting a filename fragment (ie, the basename of
- the symlink target) into a key. -}
fileKey :: FilePath -> Key
-fileKey file = Key $ replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file
+fileKey file = Backend.Key $
+ replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file