--backend now overrides any backend configured in .gitattributes files.

This commit is contained in:
Joey Hess 2011-05-18 19:34:46 -04:00
parent dd44e53c0c
commit cd83541872
4 changed files with 17 additions and 9 deletions

View file

@ -38,7 +38,7 @@ data AnnexState = AnnexState
, quiet :: Bool
, force :: Bool
, fast :: Bool
, defaultbackend :: Maybe String
, forcebackend :: Maybe String
, defaultkey :: Maybe String
, toremote :: Maybe String
, fromremote :: Maybe String
@ -56,7 +56,7 @@ newState gitrepo allbackends = AnnexState
, quiet = False
, force = False
, fast = False
, defaultbackend = Nothing
, forcebackend = Nothing
, defaultkey = Nothing
, toremote = Nothing
, fromremote = Nothing

View file

@ -33,6 +33,7 @@ module Backend (
) where
import Control.Monad.State (liftIO, when)
import Control.Monad (liftM)
import System.IO.Error (try)
import System.FilePath
import System.Posix.Files
@ -56,7 +57,7 @@ list = do
then return l
else do
s <- getstandard
d <- Annex.getState Annex.defaultbackend
d <- Annex.getState Annex.forcebackend
handle d s
where
parseBackendList l [] = l
@ -161,9 +162,15 @@ lookupFile file = do
chooseBackends :: [FilePath] -> Annex [(FilePath, Maybe (Backend Annex))]
chooseBackends fs = do
g <- Annex.gitRepo
bs <- Annex.getState Annex.supportedBackends
pairs <- liftIO $ Git.checkAttr g "annex.backend" fs
return $ map (\(f,b) -> (f, maybeLookupBackendName bs b)) pairs
forced <- Annex.getState Annex.forcebackend
if forced /= Nothing
then do
l <- list
return $ map (\f -> (f, Just $ head l)) fs
else do
bs <- Annex.getState Annex.supportedBackends
pairs <- liftIO $ Git.checkAttr g "annex.backend" fs
return $ map (\(f,b) -> (f, maybeLookupBackendName bs b)) pairs
{- Returns the backend to use for a key. -}
keyBackend :: Key -> Annex (Backend Annex)

View file

@ -28,11 +28,11 @@ commonOptions =
"avoid verbose output"
, Option ['v'] ["verbose"] (NoArg (setquiet False))
"allow verbose output"
, Option ['b'] ["backend"] (ReqArg setdefaultbackend paramName)
"specify default key-value backend to use"
, Option ['b'] ["backend"] (ReqArg setforcebackend paramName)
"specify key-value backend to use"
]
where
setforce v = Annex.changeState $ \s -> s { Annex.force = v }
setfast v = Annex.changeState $ \s -> s { Annex.fast = v }
setquiet v = Annex.changeState $ \s -> s { Annex.quiet = v }
setdefaultbackend v = Annex.changeState $ \s -> s { Annex.defaultbackend = Just v }
setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v }

1
debian/changelog vendored
View file

@ -1,6 +1,7 @@
git-annex (0.20110517) UNRELEASED; urgency=low
* status: New subcommand to show info about an annex, including its size.
* --backend now overrides any backend configured in .gitattributes files.
-- Joey Hess <joeyh@debian.org> Mon, 16 May 2011 20:27:46 -0400