Replace "in=" with "present" in preferred content expressions

in= was problimatic in two ways. First, it referred to a remote by name,
but preferred content expressions can be evaluated elsewhere, where that
remote doesn't exist, or a different remote has the same name. This name
lookup code could error out at runtime. Secondly, in= seemed pretty useless.
in=here did not cause content to be gotten, but it did let present content
be dropped.

present is more useful, although "not present" is unstable and should be
avoided.
This commit is contained in:
Joey Hess 2012-10-19 16:09:21 -04:00
parent 3417c55189
commit 40aab719df
4 changed files with 73 additions and 14 deletions

View file

@ -113,6 +113,20 @@ limitIn name = Right $ \notpresent -> check $
then return False
else inAnnex key
{- Limit to content that is currently present on a uuid. -}
limitPresent :: Maybe UUID -> MkLimit
limitPresent u name = Right $ const $ check $ \key -> do
hereu <- getUUID
if u == Just hereu || u == Nothing
then inAnnex key
else do
us <- Remote.keyLocations key
return $ maybe False (`elem` us) u
where
check a = lookupFile >=> handle a
handle _ Nothing = return False
handle a (Just (key, _)) = a key
{- Adds a limit to skip files not believed to have the specified number
- of copies. -}
addCopies :: String -> Annex ()