summaryrefslogtreecommitdiff
path: root/Command/Unused.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-05-28 22:20:22 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-05-28 22:20:22 -0400
commit25b13673f0574ad2cc7baa055d08c13da134821a (patch)
tree6efdb6be57b087fcb0962671ec48b1f18ce5ef6a /Command/Unused.hs
parentfdead6b9bb0883dd982e72e955fc58dee844f2ca (diff)
improve unused command's output
Display the name of the remote being checked, with "." for the current remote, echoing the way describe takes that to change its description.
Diffstat (limited to 'Command/Unused.hs')
-rw-r--r--Command/Unused.hs27
1 files changed, 15 insertions, 12 deletions
diff --git a/Command/Unused.hs b/Command/Unused.hs
index 1482f057e..7e5549c09 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -36,21 +36,22 @@ seek = [withNothing start]
{- Finds unused content in the annex. -}
start :: CommandStartNothing
start = notBareRepo $ do
- showStart "unused" ""
- next perform
-
-perform :: CommandPerform
-perform = do
- maybe checkUnused checkRemoteUnused =<< Annex.getState Annex.fromremote
- next $ return True
+ from <- Annex.getState Annex.fromremote
+ case from of
+ Nothing -> pass "." checkUnused
+ Just n -> pass n $ checkRemoteUnused n
+ where
+ pass n a = do
+ showStart "unused" n
+ next a
-checkUnused :: Annex ()
+checkUnused :: CommandPerform
checkUnused = do
(unused, stalebad, staletmp) <- unusedKeys
n <- list "" unusedMsg unused 0
n' <- list "bad" staleBadMsg stalebad n
_ <- list "tmp" staleTmpMsg staletmp n'
- return ()
+ next $ return True
where
list file msg l c = do
let unusedlist = number c l
@@ -58,13 +59,15 @@ checkUnused = do
writeUnusedFile file unusedlist
return $ length l
-checkRemoteUnused :: String -> Annex ()
-checkRemoteUnused name = checkRemoteUnused' =<< Remote.byName name
+checkRemoteUnused :: String -> CommandPerform
+checkRemoteUnused name = do
+ checkRemoteUnused' =<< Remote.byName name
+ next $ return True
checkRemoteUnused' :: Remote.Remote Annex -> Annex ()
checkRemoteUnused' r = do
+ showNote $ "checking for unused data..."
g <- Annex.gitRepo
- showNote $ "checking for unused data on " ++ Remote.name r ++ "..."
referenced <- getKeysReferenced
logged <- liftIO $ loggedKeys g
remotehas <- filterM isthere logged