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.
This commit is contained in:
Joey Hess 2011-05-28 22:20:22 -04:00
parent fdead6b9bb
commit 25b13673f0
4 changed files with 18 additions and 15 deletions

View file

@ -36,21 +36,22 @@ seek = [withNothing start]
{- Finds unused content in the annex. -}
start :: CommandStartNothing
start = notBareRepo $ do
showStart "unused" ""
next perform
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
perform :: CommandPerform
perform = do
maybe checkUnused checkRemoteUnused =<< Annex.getState Annex.fromremote
next $ return True
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

View file

@ -21,7 +21,7 @@ repository is found by running `git annex unused`. To detect unused content
on special remotes, instead use `git annex unused --from`. Example:
$ git annex unused --from mys3
unused (checking for unused data on mys3...)
unused mys3 (checking for unused data...)
Some annexed data on mys3 is not used by any files in this repository.
NUMBER KEY
1 WORM-s3-m1301674316--foo

View file

@ -5,7 +5,7 @@ the checksums of your files are good. Fsck also checks that the annex.numcopies
setting is satisfied for all files.
# git annex fsck
unused (checking for unused data...) ok
fsck some_file (checksum...) ok
fsck my_cool_big_file (checksum...) ok
...

View file

@ -9,7 +9,7 @@ preserving it. So from time to time, you may want to check for such data and
eliminate it to save space.
# git annex unused
unused (checking for unused data...)
unused . (checking for unused data...)
Some annexed data is no longer used by any files in the repository.
NUMBER KEY
1 WORM-s3-m1289672605--file