unused command updates for branches

Now that branches are more likely, unused needs to more explicitly warn
that it does not look in them.
This commit is contained in:
Joey Hess 2011-06-23 12:23:25 -04:00
parent 1b21dd99c5
commit 89fd7b34ce
2 changed files with 15 additions and 11 deletions

View file

@ -54,7 +54,9 @@ checkUnused = do
where where
list file msg l c = do list file msg l c = do
let unusedlist = number c l let unusedlist = number c l
when (not $ null l) $ showLongNote $ msg unusedlist when (not $ null l) $ do
showLongNote $ msg unusedlist
showLongNote $ "\n"
writeUnusedFile file unusedlist writeUnusedFile file unusedlist
return $ c + length l return $ c + length l
@ -108,16 +110,18 @@ staleBadMsg t = unlines $
unusedMsg :: [(Int, Key)] -> String unusedMsg :: [(Int, Key)] -> String
unusedMsg u = unusedMsg' u unusedMsg u = unusedMsg' u
["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 current branch:"]
[dropMsg Nothing] [dropMsg Nothing,
"Please be cautious -- are you sure that another branch, or another",
"repository does not still use this data?"]
remoteUnusedMsg :: Remote.Remote Annex -> [(Int, Key)] -> String remoteUnusedMsg :: Remote.Remote Annex -> [(Int, Key)] -> String
remoteUnusedMsg r u = unusedMsg' u remoteUnusedMsg r u = unusedMsg' u
["Some annexed data on " ++ name ++ ["Some annexed data on " ++ name ++
" is not used by any files in this repository."] " is not used by any files in the current branch:"]
[dropMsg $ Just r, [dropMsg $ Just r,
"Please be cautious -- are you sure that the remote repository", "Please be cautious -- Are you sure that the remote repository",
"does not use this data?"] "does not use this data? Or that it's not used by another branch?"]
where where
name = Remote.name r name = Remote.name r
@ -132,7 +136,7 @@ dropMsg :: Maybe (Remote.Remote Annex) -> String
dropMsg Nothing = dropMsg' "" dropMsg Nothing = dropMsg' ""
dropMsg (Just r) = dropMsg' $ " --from " ++ Remote.name r dropMsg (Just r) = dropMsg' $ " --from " ++ Remote.name r
dropMsg' :: String -> String dropMsg' :: String -> String
dropMsg' s = "(To remove unwanted data: git-annex dropunused" ++ s ++ " NUMBER)\n" dropMsg' s = "\nTo remove unwanted data: git-annex dropunused" ++ s ++ " NUMBER\n"
{- Finds keys whose content is present, but that do not seem to be used {- Finds keys whose content is present, but that do not seem to be used
- by any files in the git repo, or that are only present as bad or tmp - by any files in the git repo, or that are only present as bad or tmp

View file

@ -155,13 +155,13 @@ Many git-annex commands will stage changes for later `git commit` by you.
* unused * unused
Checks the annex for data that does not correspond to any files currently Checks the annex for data that does not correspond to any files present
in the respository, and prints a numbered list of the data. in the currently checked out branch, and prints a numbered list of the data.
To only show unused temp and bad files, specify --fast To only show unused temp and bad files, specify --fast
To check data on a remote that does not correspond to any files currently To check data on a remote that does not correspond to any files present
in the local repository, specify --from. on the locally checked out branch, specify --from.
* dropunused [number ...] * dropunused [number ...]