convert GitRepo to qualified import

This commit is contained in:
Joey Hess 2010-10-14 02:36:41 -04:00
commit 48643b68b3
11 changed files with 173 additions and 189 deletions

View file

@ -10,18 +10,18 @@ import Control.Monad.State (liftIO)
import qualified Data.Map as Map
import Data.String.Utils
import AbstractTypes
import GitRepo
import qualified GitRepo as Git
import LocationLog
import Locations
import UUID
import List
{- Human visible list of remotes. -}
remotesList :: [GitRepo] -> String
remotesList remotes = join " " $ map gitRepoDescribe remotes
remotesList :: [Git.Repo] -> String
remotesList remotes = join " " $ map Git.repoDescribe remotes
{- Cost ordered list of remotes that the LocationLog indicate may have a key. -}
remotesWithKey :: Key -> Annex [GitRepo]
remotesWithKey :: Key -> Annex [Git.Repo]
remotesWithKey key = do
g <- gitAnnex
uuids <- liftIO $ keyLocations g key
@ -34,13 +34,13 @@ remotesWithKey key = do
else return remotes
{- Cost Ordered list of remotes. -}
remotesByCost :: Annex [GitRepo]
remotesByCost :: Annex [Git.Repo]
remotesByCost = do
g <- gitAnnex
reposByCost $ gitRepoRemotes g
reposByCost $ Git.remotes g
{- Orders a list of git repos by cost. -}
reposByCost :: [GitRepo] -> Annex [GitRepo]
reposByCost :: [Git.Repo] -> Annex [Git.Repo]
reposByCost l = do
costpairs <- mapM costpair l
return $ fst $ unzip $ sortBy bycost $ costpairs
@ -55,36 +55,36 @@ reposByCost l = do
- The default cost is 100 for local repositories, and 200 for remote
- repositories; it can also be configured by remote.<name>.annex-cost
-}
repoCost :: GitRepo -> Annex Int
repoCost :: Git.Repo -> Annex Int
repoCost r = do
g <- gitAnnex
if ((length $ config g r) > 0)
then return $ read $ config g r
else if (gitRepoIsLocal r)
else if (Git.repoIsLocal r)
then return 100
else return 200
where
config g r = gitConfig g (configkey r) ""
configkey r = "remote." ++ (gitRepoRemoteName r) ++ ".annex-cost"
config g r = Git.configGet g (configkey r) ""
configkey r = "remote." ++ (Git.repoRemoteName r) ++ ".annex-cost"
{- The git configs for the git repo's remotes is not read on startup
- because reading it may be expensive. This function ensures that it is
- read for a specified remote, and updates state. It returns the
- updated git repo also. -}
remoteEnsureGitConfigRead :: GitRepo -> Annex GitRepo
remoteEnsureGitConfigRead :: Git.Repo -> Annex Git.Repo
remoteEnsureGitConfigRead r = do
if (Map.null $ gitConfigMap r)
if (Map.null $ Git.configMap r)
then do
r' <- liftIO $ gitConfigRead r
r' <- liftIO $ Git.configRead r
g <- gitAnnex
let l = gitRepoRemotes g
let g' = gitRepoRemotesAdd g $ exchange l r'
let l = Git.remotes g
let g' = Git.remotesAdd g $ exchange l r'
gitAnnexChange g'
return r'
else return r
where
exchange [] new = []
exchange (old:ls) new =
if ((gitRepoRemoteName old) == (gitRepoRemoteName new))
if ((Git.repoRemoteName old) == (Git.repoRemoteName new))
then new:(exchange ls new)
else old:(exchange ls new)