summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-18 13:22:48 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-18 13:22:48 -0400
commitc50a5fbeb4f90041f16cc84bf6b39577655d42b6 (patch)
treebf8e72086c6dc5ba947c76a6eb178ba38475bd7f
parent1326bb863516b5e7efbfd9fba2754a3fe7289315 (diff)
status: Include all special remotes in the list of repositories.
Special remotes do not always have a description listed in uuid.log, and such ones were not listed before.
-rw-r--r--Command/Status.hs2
-rw-r--r--Logs/Trust.hs28
-rw-r--r--Logs/UUID.hs6
-rw-r--r--Remote.hs6
-rw-r--r--debian/changelog1
5 files changed, 24 insertions, 19 deletions
diff --git a/Command/Status.hs b/Command/Status.hs
index 47b500b90..7448615cd 100644
--- a/Command/Status.hs
+++ b/Command/Status.hs
@@ -102,7 +102,7 @@ supported_remote_types = stat "supported remote types" $
remote_list :: TrustLevel -> String -> Stat
remote_list level desc = stat n $ lift $ do
- us <- uuidList
+ us <- M.keys <$> (M.union <$> uuidMap <*> remoteMap)
rs <- fst <$> trustPartition level us
s <- prettyPrintUUIDs n rs
return $ if null s then "0" else show (length rs) ++ "\n" ++ init s
diff --git a/Logs/Trust.hs b/Logs/Trust.hs
index 072ea41d6..e447fbebc 100644
--- a/Logs/Trust.hs
+++ b/Logs/Trust.hs
@@ -20,20 +20,30 @@ import Types.TrustLevel
import qualified Annex.Branch
import qualified Annex
import Logs.UUIDBased
-import Logs.UUID
{- Filename of trust.log. -}
trustLog :: FilePath
trustLog = "trust.log"
-{- Returns a list of UUIDs at the specified trust level. -}
+{- Returns a list of UUIDs that the trustLog indicates have the
+ - specified trust level.
+ - Note that the list can be incomplete for SemiTrusted, since that's
+ - the default. -}
trustGet :: TrustLevel -> Annex [UUID]
-trustGet SemiTrusted = do -- special case; trustMap does not contain all these
- others <- M.keys . M.filter (/= SemiTrusted) <$> trustMap
- alluuids <- uuidList
- return $ alluuids \\ others
trustGet level = M.keys . M.filter (== level) <$> trustMap
+{- Partitions a list of UUIDs to those matching a TrustLevel and not. -}
+trustPartition :: TrustLevel -> [UUID] -> Annex ([UUID], [UUID])
+trustPartition level ls
+ | level == SemiTrusted = do
+ t <- trustGet Trusted
+ u <- trustGet UnTrusted
+ let uncandidates = t ++ u
+ return $ partition (`notElem` uncandidates) ls
+ | otherwise = do
+ candidates <- trustGet level
+ return $ partition (`elem` candidates) ls
+
{- Read the trustLog into a map, overriding with any
- values from forcetrust. The map is cached for speed. -}
trustMap :: Annex TrustMap
@@ -72,9 +82,3 @@ trustSet uuid@(UUID _) level = do
showLog showTrust . changeLog ts uuid level . parseLog parseTrust
Annex.changeState $ \s -> s { Annex.trustmap = Nothing }
trustSet NoUUID _ = error "unknown UUID; cannot modify trust level"
-
-{- Partitions a list of UUIDs to those matching a TrustLevel and not. -}
-trustPartition :: TrustLevel -> [UUID] -> Annex ([UUID], [UUID])
-trustPartition level ls = do
- candidates <- trustGet level
- return $ partition (`elem` candidates) ls
diff --git a/Logs/UUID.hs b/Logs/UUID.hs
index 17b0330c1..20f43d15c 100644
--- a/Logs/UUID.hs
+++ b/Logs/UUID.hs
@@ -16,8 +16,7 @@
module Logs.UUID (
describeUUID,
recordUUID,
- uuidMap,
- uuidList
+ uuidMap
) where
import qualified Data.Map as M
@@ -88,6 +87,3 @@ uuidMap = do
return $ M.insertWith' preferold u "" m
where
preferold = flip const
-
-uuidList :: Annex [UUID]
-uuidList = M.keys <$> uuidMap
diff --git a/Remote.hs b/Remote.hs
index 7c0362d2a..b1be60ec4 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -16,6 +16,7 @@ module Remote (
hasKeyCheap,
remoteTypes,
+ remoteMap,
byName,
prettyPrintUUIDs,
remotesWithUUID,
@@ -83,6 +84,10 @@ genList = do
u <- getRepoUUID r
generate t r u (M.lookup u m)
+{- Map of UUIDs of Remotes and their names. -}
+remoteMap :: Annex (M.Map UUID String)
+remoteMap = M.fromList . map (\r -> (uuid r, name r)) <$> genList
+
{- Looks up a remote by name. (Or by UUID.) Only finds currently configured
- git remotes. -}
byName :: String -> Annex (Remote Annex)
@@ -139,7 +144,6 @@ prettyPrintUUIDs desc uuids = do
| d == n = d
| null d = n
| otherwise = n ++ " (" ++ d ++ ")"
- remoteMap = M.fromList . map (\r -> (uuid r, name r)) <$> genList
findlog m u = M.findWithDefault "" u m
prettify m hereu u
| not (null d) = fromUUID u ++ " -- " ++ d
diff --git a/debian/changelog b/debian/changelog
index 52d08f303..12bbba11d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ git-annex (3.20111112) UNRELEASED; urgency=low
in constant space.
* status: Now displays trusted, untrusted, and semitrusted repositories
separately.
+ * status: Include all special remotes in the list of repositories.
* status: Fix --json mode (only the repository lists are currently
displayed)
* status: --fast is back