whereis: Show untrusted locations separately and do not include in location count.

This commit is contained in:
Joey Hess 2011-09-06 16:59:53 -04:00
parent b7bcd942c5
commit 6f98fd5391
2 changed files with 25 additions and 9 deletions

View file

@ -7,11 +7,15 @@
module Command.Whereis where module Command.Whereis where
import Control.Monad
import Data.List
import LocationLog import LocationLog
import Command import Command
import Messages import Messages
import Remote import Remote
import Types import Types
import Trust
command :: [Command] command :: [Command]
command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek
@ -27,16 +31,21 @@ start file = isAnnexed file $ \(key, _) -> do
perform :: Key -> CommandPerform perform :: Key -> CommandPerform
perform key = do perform key = do
uuids <- keyLocations key locations <- keyLocations key
let num = length uuids untrusted <- trustGet UnTrusted
let untrustedlocations = intersect untrusted locations
let safelocations = filter (`notElem` untrusted) locations
let num = length safelocations
showNote $ show num ++ " " ++ copiesplural num showNote $ show num ++ " " ++ copiesplural num
if null uuids pp <- prettyPrintUUIDs "whereis" safelocations
then stop unless (null safelocations) $
else do
pp <- prettyPrintUUIDs "whereis" uuids
showLongNote pp showLongNote pp
showOutput pp' <- prettyPrintUUIDs "untrusted" untrustedlocations
next $ return True unless (null untrustedlocations) $
showLongNote $ untrustedheader ++ pp'
unless (null locations) showOutput
if null safelocations then stop else next $ return True
where where
copiesplural 1 = "copy" copiesplural 1 = "copy"
copiesplural _ = "copies" copiesplural _ = "copies"
untrustedheader = "The following untrusted locations may also have copies:\n"

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
git-annex (3.20110907) UNRELEASED; urgency=low
* whereis: Show untrusted locations separately and do not include in
location count.
-- Joey Hess <joeyh@debian.org> Tue, 06 Sep 2011 16:59:15 -0400
git-annex (3.20110906) unstable; urgency=low git-annex (3.20110906) unstable; urgency=low
* Improve display of newlines around error and warning messages. * Improve display of newlines around error and warning messages.