update
This commit is contained in:
parent
64b5167b0f
commit
8ab54401b6
4 changed files with 19 additions and 10 deletions
|
@ -40,10 +40,7 @@ dummyRemove url = return False
|
||||||
copyKeyFile :: Key -> FilePath -> Annex (Bool)
|
copyKeyFile :: Key -> FilePath -> Annex (Bool)
|
||||||
copyKeyFile key file = do
|
copyKeyFile key file = do
|
||||||
remotes <- remotesWithKey key
|
remotes <- remotesWithKey key
|
||||||
if (0 == length remotes)
|
trycopy remotes remotes
|
||||||
then error $ "no known remotes have: " ++ (keyFile key) ++ "\n" ++
|
|
||||||
"(Perhaps you need to git remote add a repository?)"
|
|
||||||
else trycopy remotes remotes
|
|
||||||
where
|
where
|
||||||
trycopy full [] = error $ "unable to get: " ++ (keyFile key) ++ "\n" ++
|
trycopy full [] = error $ "unable to get: " ++ (keyFile key) ++ "\n" ++
|
||||||
"To get that file, need access to one of these remotes: " ++
|
"To get that file, need access to one of these remotes: " ++
|
||||||
|
|
12
Remotes.hs
12
Remotes.hs
|
@ -8,10 +8,11 @@ module Remotes (
|
||||||
|
|
||||||
import Control.Monad.State (liftIO)
|
import Control.Monad.State (liftIO)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
import Data.String.Utils
|
||||||
import Types
|
import Types
|
||||||
import GitRepo
|
import GitRepo
|
||||||
import LocationLog
|
import LocationLog
|
||||||
import Data.String.Utils
|
import Locations
|
||||||
import UUID
|
import UUID
|
||||||
import List
|
import List
|
||||||
|
|
||||||
|
@ -24,8 +25,13 @@ remotesWithKey :: Key -> Annex [GitRepo]
|
||||||
remotesWithKey key = do
|
remotesWithKey key = do
|
||||||
g <- gitAnnex
|
g <- gitAnnex
|
||||||
uuids <- liftIO $ keyLocations g key
|
uuids <- liftIO $ keyLocations g key
|
||||||
remotes <- remotesByCost
|
allremotes <- remotesByCost
|
||||||
reposByUUID remotes uuids
|
remotes <- reposByUUID allremotes uuids
|
||||||
|
if (0 == length remotes)
|
||||||
|
then error $ "no configured git remotes have: " ++ (keyFile key) ++ "\n" ++
|
||||||
|
"It has been seen before in these repositories:\n" ++
|
||||||
|
prettyPrintUUIDs uuids
|
||||||
|
else return remotes
|
||||||
|
|
||||||
{- Cost Ordered list of remotes. -}
|
{- Cost Ordered list of remotes. -}
|
||||||
remotesByCost :: Annex [GitRepo]
|
remotesByCost :: Annex [GitRepo]
|
||||||
|
|
2
TODO
2
TODO
|
@ -1,8 +1,6 @@
|
||||||
* bug when annexing files while in a subdir of a git repo
|
* bug when annexing files while in a subdir of a git repo
|
||||||
* bug when specifying absolute path to files when annexing
|
* bug when specifying absolute path to files when annexing
|
||||||
|
|
||||||
* state monad
|
|
||||||
|
|
||||||
* query remotes for their annex.uuid settings and cache
|
* query remotes for their annex.uuid settings and cache
|
||||||
|
|
||||||
* --push/--pull/--want/--drop
|
* --push/--pull/--want/--drop
|
||||||
|
|
10
UUID.hs
10
UUID.hs
|
@ -10,7 +10,8 @@ module UUID (
|
||||||
getUUID,
|
getUUID,
|
||||||
prepUUID,
|
prepUUID,
|
||||||
genUUID,
|
genUUID,
|
||||||
reposByUUID
|
reposByUUID,
|
||||||
|
prettyPrintUUIDs
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.State
|
import Control.Monad.State
|
||||||
|
@ -71,3 +72,10 @@ reposByUUID repos uuids = do
|
||||||
match r = do
|
match r = do
|
||||||
u <- getUUID r
|
u <- getUUID r
|
||||||
return $ isJust $ elemIndex u uuids
|
return $ isJust $ elemIndex u uuids
|
||||||
|
|
||||||
|
{- Pretty-prints a list of UUIDs
|
||||||
|
- TODO: use lookup file to really show pretty names. -}
|
||||||
|
prettyPrintUUIDs :: [UUID] -> String
|
||||||
|
prettyPrintUUIDs uuids =
|
||||||
|
unwords $ map (\u -> "\tUUID "++u++"\n") uuids
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue