better filtering out of special remotes

This commit is contained in:
Joey Hess 2011-12-31 03:27:37 -04:00
parent 6cd4c7efcd
commit 8a33573caf
9 changed files with 23 additions and 12 deletions

View file

@ -17,10 +17,10 @@ import qualified Annex
import qualified Annex.Branch import qualified Annex.Branch
import qualified Git.Command import qualified Git.Command
import qualified Git.Branch import qualified Git.Branch
import qualified Git.Config
import qualified Git.Ref import qualified Git.Ref
import qualified Git import qualified Git
import qualified Types.Remote import qualified Types.Remote
import qualified Remote.Git
import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.ByteString.Lazy.Char8 as L
import qualified Data.Map as M import qualified Data.Map as M
@ -61,9 +61,8 @@ syncRemotes rs = do
| null rs = available | null rs = available
| otherwise = listed | otherwise = listed
listed = mapM Remote.byName rs listed = mapM Remote.byName rs
available = filterM hasurl =<< Remote.enabledRemoteList available = filter nonspecial <$> Remote.enabledRemoteList
hasurl r = not . null <$> geturl r nonspecial r = Types.Remote.remotetype r == Remote.Git.remote
geturl r = fromRepo $ Git.Config.get ("remote." ++ Remote.name r ++ ".url") ""
fastest = fromMaybe [] . headMaybe . fastest = fromMaybe [] . headMaybe .
map snd . sort . M.toList . costmap map snd . sort . M.toList . costmap
costmap = M.fromListWith (++) . map costpair costmap = M.fromListWith (++) . map costpair

View file

@ -54,7 +54,8 @@ gen r u c = do
hasKey = checkPresent r bupr', hasKey = checkPresent r bupr',
hasKeyCheap = bupLocal buprepo, hasKeyCheap = bupLocal buprepo,
config = c, config = c,
repo = r repo = r,
remotetype = remote
} }
bupSetup :: UUID -> RemoteConfig -> Annex RemoteConfig bupSetup :: UUID -> RemoteConfig -> Annex RemoteConfig

View file

@ -45,7 +45,8 @@ gen r u c = do
hasKey = checkPresent dir, hasKey = checkPresent dir,
hasKeyCheap = True, hasKeyCheap = True,
config = Nothing, config = Nothing,
repo = r repo = r,
remotetype = remote
} }
directorySetup :: UUID -> RemoteConfig -> Annex RemoteConfig directorySetup :: UUID -> RemoteConfig -> Annex RemoteConfig

View file

@ -79,7 +79,8 @@ gen r u _ = do
hasKey = inAnnex r', hasKey = inAnnex r',
hasKeyCheap = cheap, hasKeyCheap = cheap,
config = Nothing, config = Nothing,
repo = r' repo = r',
remotetype = remote
} }
{- Tries to read the config for a specified remote, updates state, and {- Tries to read the config for a specified remote, updates state, and

View file

@ -45,7 +45,8 @@ gen r u c = do
hasKey = checkPresent r hooktype, hasKey = checkPresent r hooktype,
hasKeyCheap = False, hasKeyCheap = False,
config = Nothing, config = Nothing,
repo = r repo = r,
remotetype = remote
} }
hookSetup :: UUID -> RemoteConfig -> Annex RemoteConfig hookSetup :: UUID -> RemoteConfig -> Annex RemoteConfig

View file

@ -52,7 +52,8 @@ gen r u c = do
hasKey = checkPresent r o, hasKey = checkPresent r o,
hasKeyCheap = False, hasKeyCheap = False,
config = Nothing, config = Nothing,
repo = r repo = r,
remotetype = remote
} }
genRsyncOpts :: Git.Repo -> Annex RsyncOpts genRsyncOpts :: Git.Repo -> Annex RsyncOpts

View file

@ -57,7 +57,8 @@ gen' r u c cst =
hasKey = checkPresent this, hasKey = checkPresent this,
hasKeyCheap = False, hasKeyCheap = False,
config = c, config = c,
repo = r repo = r,
remotetype = remote
} }
s3Setup :: UUID -> RemoteConfig -> Annex RemoteConfig s3Setup :: UUID -> RemoteConfig -> Annex RemoteConfig

View file

@ -43,7 +43,8 @@ gen r _ _ =
hasKey = checkKey, hasKey = checkKey,
hasKeyCheap = False, hasKeyCheap = False,
config = Nothing, config = Nothing,
repo = r repo = r,
remotetype = remote
} }
downloadKey :: Key -> FilePath -> Annex Bool downloadKey :: Key -> FilePath -> Annex Bool

View file

@ -30,6 +30,9 @@ data RemoteType a = RemoteType {
setup :: UUID -> RemoteConfig -> a RemoteConfig setup :: UUID -> RemoteConfig -> a RemoteConfig
} }
instance Eq (RemoteType a) where
x == y = typename x == typename y
{- An individual remote. -} {- An individual remote. -}
data Remote a = Remote { data Remote a = Remote {
-- each Remote has a unique uuid -- each Remote has a unique uuid
@ -53,7 +56,9 @@ data Remote a = Remote {
-- a Remote can have a persistent configuration store -- a Remote can have a persistent configuration store
config :: Maybe RemoteConfig, config :: Maybe RemoteConfig,
-- git configuration for the remote -- git configuration for the remote
repo :: Git.Repo repo :: Git.Repo,
-- the type of the remote
remotetype :: RemoteType a
} }
instance Show (Remote a) where instance Show (Remote a) where