diff options
author | Joey Hess <joey@kitenet.net> | 2011-09-18 20:14:18 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-09-18 20:14:18 -0400 |
commit | 1fc3ee24232059ae05ab18ed10bf151f86847ac1 (patch) | |
tree | 7cbfe5536143e09752e97da43d619b948fdeacc3 /Limit.hs | |
parent | dd463a3100f21d72c35ca1af5b0f63f6296cf322 (diff) |
add --in limit
Diffstat (limited to 'Limit.hs')
-rw-r--r-- | Limit.hs | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -14,6 +14,9 @@ import Data.Maybe import Annex import qualified Utility.Matcher +import qualified Remote +import qualified Backend +import LocationLog type Limit = Utility.Matcher.Token (FilePath -> Annex Bool) @@ -51,9 +54,22 @@ token :: String -> Annex () token = add . Utility.Matcher.Token {- Add a limit to skip files that do not match the glob. -} -exclude :: String -> Annex () -exclude glob = addlimit $ return . notExcluded +addExclude :: String -> Annex () +addExclude glob = addlimit $ return . notExcluded where notExcluded f = isNothing $ match cregex f [] cregex = compile regex [] regex = '^':wildToRegex glob + +{- Adds a limit to skip files not believed to be present + - on a specfied remote. -} +addIn :: String -> Annex () +addIn name = do + u <- Remote.nameToUUID name + addlimit $ check u + where + check u f = Backend.lookupFile f >>= handle u + handle _ Nothing = return False + handle u (Just (key, _)) = do + us <- keyLocations key + return $ u `elem` us |