diff options
-rw-r--r-- | Command/InitRemote.hs | 14 | ||||
-rw-r--r-- | Logs/Trust.hs | 1 | ||||
-rw-r--r-- | debian/changelog | 2 |
3 files changed, 13 insertions, 4 deletions
diff --git a/Command/InitRemote.hs b/Command/InitRemote.hs index 5d48e9715..948b6ef63 100644 --- a/Command/InitRemote.hs +++ b/Command/InitRemote.hs @@ -16,6 +16,9 @@ import qualified Logs.Remote import qualified Types.Remote as R import Annex.UUID import Logs.UUID +import Logs.Trust + +import Data.Ord def :: [Command] def = [command "initremote" @@ -57,15 +60,18 @@ cleanup u name c = do {- Look up existing remote's UUID and config by name, or generate a new one -} findByName :: String -> Annex (UUID, R.RemoteConfig) findByName name = do - m <- Logs.Remote.readRemoteLog - maybe generate return $ findByName' name m + t <- trustMap + matches <- sortBy (comparing $ \(u, _c) -> M.lookup u t ) + . findByName' name + <$> Logs.Remote.readRemoteLog + maybe generate return $ headMaybe matches where generate = do uuid <- liftIO genUUID return (uuid, M.insert nameKey name M.empty) -findByName' :: String -> M.Map UUID R.RemoteConfig -> Maybe (UUID, R.RemoteConfig) -findByName' n = headMaybe . filter (matching . snd) . M.toList +findByName' :: String -> M.Map UUID R.RemoteConfig -> [(UUID, R.RemoteConfig)] +findByName' n = filter (matching . snd) . M.toList where matching c = case M.lookup nameKey c of Nothing -> False diff --git a/Logs/Trust.hs b/Logs/Trust.hs index 89a5404f7..eb6e42ad7 100644 --- a/Logs/Trust.hs +++ b/Logs/Trust.hs @@ -9,6 +9,7 @@ module Logs.Trust ( trustLog, TrustLevel(..), trustGet, + trustMap, trustSet, trustPartition, trustExclude, diff --git a/debian/changelog b/debian/changelog index 1caab32ca..1e6411e5b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,8 @@ git-annex (4.20130418) UNRELEASED; urgency=low performing bulk adds of a large number of files (tens to hundreds of thousands). * assistant: Sanitize XMPP presence information logged for debugging. + * initremote: If two existing remotes have the same name, + prefer the one with a higher trust level. -- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400 |