--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 , quiet :: Bool
, force :: Bool , force :: Bool
, fast :: Bool , fast :: Bool
, defaultbackend :: Maybe String , forcebackend :: Maybe String
, defaultkey :: Maybe String , defaultkey :: Maybe String
, toremote :: Maybe String , toremote :: Maybe String
, fromremote :: Maybe String , fromremote :: Maybe String
@ -56,7 +56,7 @@ newState gitrepo allbackends = AnnexState
, quiet = False , quiet = False
, force = False , force = False
, fast = False , fast = False
, defaultbackend = Nothing , forcebackend = Nothing
, defaultkey = Nothing , defaultkey = Nothing
, toremote = Nothing , toremote = Nothing
, fromremote = Nothing , fromremote = Nothing

View file

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

View file

@ -28,11 +28,11 @@ commonOptions =
"avoid verbose output" "avoid verbose output"
, Option ['v'] ["verbose"] (NoArg (setquiet False)) , Option ['v'] ["verbose"] (NoArg (setquiet False))
"allow verbose output" "allow verbose output"
, Option ['b'] ["backend"] (ReqArg setdefaultbackend paramName) , Option ['b'] ["backend"] (ReqArg setforcebackend paramName)
"specify default key-value backend to use" "specify key-value backend to use"
] ]
where where
setforce v = Annex.changeState $ \s -> s { Annex.force = v } setforce v = Annex.changeState $ \s -> s { Annex.force = v }
setfast v = Annex.changeState $ \s -> s { Annex.fast = v } setfast v = Annex.changeState $ \s -> s { Annex.fast = v }
setquiet v = Annex.changeState $ \s -> s { Annex.quiet = 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 git-annex (0.20110517) UNRELEASED; urgency=low
* status: New subcommand to show info about an annex, including its size. * 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 -- Joey Hess <joeyh@debian.org> Mon, 16 May 2011 20:27:46 -0400