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. -} {- Finds unused content in the annex. -}
start :: CommandStartNothing start :: CommandStartNothing
start = notBareRepo $ do start = notBareRepo $ do
showStart "unused" "" from <- Annex.getState Annex.fromremote
next perform case from of
Nothing -> pass "." checkUnused
Just n -> pass n $ checkRemoteUnused n
where
pass n a = do
showStart "unused" n
next a
perform :: CommandPerform checkUnused :: CommandPerform
perform = do
maybe checkUnused checkRemoteUnused =<< Annex.getState Annex.fromremote
next $ return True
checkUnused :: Annex ()
checkUnused = do checkUnused = do
(unused, stalebad, staletmp) <- unusedKeys (unused, stalebad, staletmp) <- unusedKeys
n <- list "" unusedMsg unused 0 n <- list "" unusedMsg unused 0
n' <- list "bad" staleBadMsg stalebad n n' <- list "bad" staleBadMsg stalebad n
_ <- list "tmp" staleTmpMsg staletmp n' _ <- list "tmp" staleTmpMsg staletmp n'
return () next $ return True
where where
list file msg l c = do list file msg l c = do
let unusedlist = number c l let unusedlist = number c l
@ -58,13 +59,15 @@ checkUnused = do
writeUnusedFile file unusedlist writeUnusedFile file unusedlist
return $ length l return $ length l
checkRemoteUnused :: String -> Annex () checkRemoteUnused :: String -> CommandPerform
checkRemoteUnused name = checkRemoteUnused' =<< Remote.byName name checkRemoteUnused name = do
checkRemoteUnused' =<< Remote.byName name
next $ return True
checkRemoteUnused' :: Remote.Remote Annex -> Annex () checkRemoteUnused' :: Remote.Remote Annex -> Annex ()
checkRemoteUnused' r = do checkRemoteUnused' r = do
showNote $ "checking for unused data..."
g <- Annex.gitRepo g <- Annex.gitRepo
showNote $ "checking for unused data on " ++ Remote.name r ++ "..."
referenced <- getKeysReferenced referenced <- getKeysReferenced
logged <- liftIO $ loggedKeys g logged <- liftIO $ loggedKeys g
remotehas <- filterM isthere logged 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: on special remotes, instead use `git annex unused --from`. Example:
$ git annex unused --from mys3 $ 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. Some annexed data on mys3 is not used by any files in this repository.
NUMBER KEY NUMBER KEY
1 WORM-s3-m1301674316--foo 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. setting is satisfied for all files.
# git annex fsck # git annex fsck
unused (checking for unused data...) ok fsck some_file (checksum...) ok
fsck my_cool_big_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. eliminate it to save space.
# git annex unused # 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. Some annexed data is no longer used by any files in the repository.
NUMBER KEY NUMBER KEY
1 WORM-s3-m1289672605--file 1 WORM-s3-m1289672605--file