aboutsummaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-09-18 20:14:18 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-09-18 20:14:18 -0400
commit1fc3ee24232059ae05ab18ed10bf151f86847ac1 (patch)
tree7cbfe5536143e09752e97da43d619b948fdeacc3 /Limit.hs
parentdd463a3100f21d72c35ca1af5b0f63f6296cf322 (diff)
add --in limit
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs20
1 files changed, 18 insertions, 2 deletions
diff --git a/Limit.hs b/Limit.hs
index 91ea3453c..13df5f6c2 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -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