summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-21 18:08:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-21 18:08:56 -0400
commitd71baf07108c4903c444175ca482af1ed4cca1b4 (patch)
tree571818e459afc7722f5fc8c109f5502b8748988f
parentd44bd607d4fd18eadabe3c7693ebcf1c74aae63e (diff)
reorg
-rw-r--r--Annex/Drop.hs2
-rw-r--r--Command/Copy.hs2
-rw-r--r--Command/Drop.hs2
-rw-r--r--Command/DropUnused.hs2
-rw-r--r--Command/Fsck.hs2
-rw-r--r--Command/Get.hs2
-rw-r--r--Command/Info.hs2
-rw-r--r--Command/Mirror.hs2
-rw-r--r--Command/NumCopies.hs2
-rw-r--r--Config/NumCopies.hs80
-rw-r--r--Limit.hs2
-rw-r--r--Logs/NumCopies.hs65
-rw-r--r--Types/GitConfig.hs1
13 files changed, 90 insertions, 76 deletions
diff --git a/Annex/Drop.hs b/Annex/Drop.hs
index 8cab7b065..09ca822a3 100644
--- a/Annex/Drop.hs
+++ b/Annex/Drop.hs
@@ -9,7 +9,7 @@ module Annex.Drop where
import Common.Annex
import Logs.Trust
-import Logs.NumCopies
+import Config.NumCopies
import Types.Remote (uuid)
import qualified Remote
import qualified Command.Drop
diff --git a/Command/Copy.hs b/Command/Copy.hs
index 090bd3a9a..395992ed0 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -13,7 +13,7 @@ import GitAnnex.Options
import qualified Command.Move
import qualified Remote
import Annex.Wanted
-import Logs.NumCopies
+import Config.NumCopies
def :: [Command]
def = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 8f7e1aae9..bf832e8d5 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -14,7 +14,7 @@ import qualified Annex
import Annex.UUID
import Logs.Location
import Logs.Trust
-import Logs.NumCopies
+import Config.NumCopies
import Annex.Content
import qualified Option
import Annex.Wanted
diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs
index 043ddfe00..af90303fb 100644
--- a/Command/DropUnused.hs
+++ b/Command/DropUnused.hs
@@ -15,7 +15,7 @@ import qualified Remote
import qualified Git
import qualified Option
import Command.Unused (withUnusedMaps, UnusedMaps(..), startUnused)
-import Logs.NumCopies
+import Config.NumCopies
def :: [Command]
def = [withOptions [Command.Drop.fromOption] $
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 598025189..892823584 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -25,7 +25,7 @@ import Annex.Perms
import Annex.Link
import Logs.Location
import Logs.Trust
-import Logs.NumCopies
+import Config.NumCopies
import Annex.UUID
import Utility.DataUnits
import Utility.FileMode
diff --git a/Command/Get.hs b/Command/Get.hs
index 74d5068d3..cdb85af94 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -12,7 +12,7 @@ import Command
import qualified Remote
import Annex.Content
import Logs.Transfer
-import Logs.NumCopies
+import Config.NumCopies
import Annex.Wanted
import GitAnnex.Options
import qualified Command.Move
diff --git a/Command/Info.hs b/Command/Info.hs
index c62dc3844..c36ae8eed 100644
--- a/Command/Info.hs
+++ b/Command/Info.hs
@@ -29,7 +29,7 @@ import Annex.Content
import Types.Key
import Logs.UUID
import Logs.Trust
-import Logs.NumCopies
+import Config.NumCopies
import Remote
import Config
import Utility.Percentage
diff --git a/Command/Mirror.hs b/Command/Mirror.hs
index fb06ed2b4..49208065b 100644
--- a/Command/Mirror.hs
+++ b/Command/Mirror.hs
@@ -16,7 +16,7 @@ import qualified Command.Get
import qualified Remote
import Annex.Content
import qualified Annex
-import Logs.NumCopies
+import Config.NumCopies
def :: [Command]
def = [withOptions (fromToOptions ++ keyOptions) $
diff --git a/Command/NumCopies.hs b/Command/NumCopies.hs
index cc322bcbd..b7323ae35 100644
--- a/Command/NumCopies.hs
+++ b/Command/NumCopies.hs
@@ -10,7 +10,7 @@ module Command.NumCopies where
import Common.Annex
import qualified Annex
import Command
-import Logs.NumCopies
+import Config.NumCopies
import Types.Messages
def :: [Command]
diff --git a/Config/NumCopies.hs b/Config/NumCopies.hs
new file mode 100644
index 000000000..26d81b8a4
--- /dev/null
+++ b/Config/NumCopies.hs
@@ -0,0 +1,80 @@
+{- git-annex numcopies configuration
+ -
+ - Copyright 2014 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Config.NumCopies (
+ module Types.NumCopies,
+ module Logs.NumCopies,
+ getFileNumCopies,
+ getGlobalFileNumCopies,
+ getNumCopies,
+ numCopiesCheck,
+ deprecatedNumCopies,
+ defaultNumCopies
+) where
+
+import Common.Annex
+import qualified Annex
+import Types.NumCopies
+import Logs.NumCopies
+import Logs.Trust
+import Annex.CheckAttr
+import qualified Remote
+
+defaultNumCopies :: NumCopies
+defaultNumCopies = NumCopies 1
+
+fromSources :: [Annex (Maybe NumCopies)] -> Annex NumCopies
+fromSources = fromMaybe defaultNumCopies <$$> getM id
+
+{- The git config annex.numcopies is deprecated. -}
+deprecatedNumCopies :: Annex (Maybe NumCopies)
+deprecatedNumCopies = annexNumCopies <$> Annex.getGitConfig
+
+{- Value forced on the command line by --numcopies. -}
+getForcedNumCopies :: Annex (Maybe NumCopies)
+getForcedNumCopies = Annex.getState Annex.forcenumcopies
+
+{- Numcopies value from any of the non-.gitattributes configuration
+ - sources. -}
+getNumCopies :: Annex NumCopies
+getNumCopies = fromSources
+ [ getForcedNumCopies
+ , getGlobalNumCopies
+ , deprecatedNumCopies
+ ]
+
+{- Numcopies value for a file, from any configuration source, including the
+ - deprecated git config. -}
+getFileNumCopies :: FilePath -> Annex NumCopies
+getFileNumCopies f = fromSources
+ [ getForcedNumCopies
+ , getFileNumCopies' f
+ , deprecatedNumCopies
+ ]
+
+{- This is the globally visible numcopies value for a file. So it does
+ - not include local configuration in the git config or command line
+ - options. -}
+getGlobalFileNumCopies :: FilePath -> Annex NumCopies
+getGlobalFileNumCopies f = fromSources
+ [ getFileNumCopies' f
+ ]
+
+getFileNumCopies' :: FilePath -> Annex (Maybe NumCopies)
+getFileNumCopies' file = maybe getGlobalNumCopies (return . Just) =<< getattr
+ where
+ getattr = (NumCopies <$$> readish)
+ <$> checkAttr "annex.numcopies" file
+
+{- Checks if numcopies are satisfied for a file by running a comparison
+ - between the number of (not untrusted) copies that are
+ - belived to exist, and the configured value. -}
+numCopiesCheck :: FilePath -> Key -> (Int -> Int -> v) -> Annex v
+numCopiesCheck file key vs = do
+ NumCopies needed <- getFileNumCopies file
+ have <- trustExclude UnTrusted =<< Remote.keyLocations key
+ return $ length have `vs` needed
diff --git a/Limit.hs b/Limit.hs
index 9d62fecc1..471a0c278 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -23,7 +23,7 @@ import qualified Backend
import Annex.Content
import Annex.UUID
import Logs.Trust
-import Logs.NumCopies
+import Config.NumCopies
import Types.TrustLevel
import Types.Key
import Types.Group
diff --git a/Logs/NumCopies.hs b/Logs/NumCopies.hs
index 8f1a09301..5cce61ce6 100644
--- a/Logs/NumCopies.hs
+++ b/Logs/NumCopies.hs
@@ -8,16 +8,9 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Logs.NumCopies (
- module Types.NumCopies,
setGlobalNumCopies,
getGlobalNumCopies,
globalNumCopiesLoad,
- getFileNumCopies,
- getGlobalFileNumCopies,
- getNumCopies,
- numCopiesCheck,
- deprecatedNumCopies,
- defaultNumCopies
) where
import Common.Annex
@@ -25,9 +18,6 @@ import qualified Annex
import Types.NumCopies
import Logs
import Logs.SingleValue
-import Logs.Trust
-import Annex.CheckAttr
-import qualified Remote
instance SingleValueSerializable NumCopies where
serialize (NumCopies n) = show n
@@ -46,58 +36,3 @@ globalNumCopiesLoad = do
v <- getLog numcopiesLog
Annex.changeState $ \s -> s { Annex.globalnumcopies = v }
return v
-
-defaultNumCopies :: NumCopies
-defaultNumCopies = NumCopies 1
-
-fromSources :: [Annex (Maybe NumCopies)] -> Annex NumCopies
-fromSources = fromMaybe defaultNumCopies <$$> getM id
-
-{- The git config annex.numcopies is deprecated. -}
-deprecatedNumCopies :: Annex (Maybe NumCopies)
-deprecatedNumCopies = annexNumCopies <$> Annex.getGitConfig
-
-{- Value forced on the command line by --numcopies. -}
-getForcedNumCopies :: Annex (Maybe NumCopies)
-getForcedNumCopies = Annex.getState Annex.forcenumcopies
-
-{- Numcopies value from any of the non-.gitattributes configuration
- - sources. -}
-getNumCopies :: Annex NumCopies
-getNumCopies = fromSources
- [ getForcedNumCopies
- , getGlobalNumCopies
- , deprecatedNumCopies
- ]
-
-{- Numcopies value for a file, from any configuration source, including the
- - deprecated git config. -}
-getFileNumCopies :: FilePath -> Annex NumCopies
-getFileNumCopies f = fromSources
- [ getForcedNumCopies
- , getFileNumCopies' f
- , deprecatedNumCopies
- ]
-
-{- This is the globally visible numcopies value for a file. So it does
- - not include local configuration in the git config or command line
- - options. -}
-getGlobalFileNumCopies :: FilePath -> Annex NumCopies
-getGlobalFileNumCopies f = fromSources
- [ getFileNumCopies' f
- ]
-
-getFileNumCopies' :: FilePath -> Annex (Maybe NumCopies)
-getFileNumCopies' file = maybe getGlobalNumCopies (return . Just) =<< getattr
- where
- getattr = (NumCopies <$$> readish)
- <$> checkAttr "annex.numcopies" file
-
-{- Checks if numcopies are satisfied for a file by running a comparison
- - between the number of (not untrusted) copies that are
- - belived to exist, and the configured value. -}
-numCopiesCheck :: FilePath -> Key -> (Int -> Int -> v) -> Annex v
-numCopiesCheck file key vs = do
- NumCopies needed <- getFileNumCopies file
- have <- trustExclude UnTrusted =<< Remote.keyLocations key
- return $ length have `vs` needed
diff --git a/Types/GitConfig.hs b/Types/GitConfig.hs
index af516d27a..e19fdc42f 100644
--- a/Types/GitConfig.hs
+++ b/Types/GitConfig.hs
@@ -79,7 +79,6 @@ extractGitConfig r = GitConfig
, gcryptId = getmaybe "core.gcrypt-id"
}
where
- get k def = fromMaybe def $ getmayberead k
getbool k def = fromMaybe def $ getmaybebool k
getmaybebool k = Git.Config.isTrue =<< getmaybe k
getmayberead k = readish =<< getmaybe k