aboutsummaryrefslogtreecommitdiff
path: root/Limit.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-04-25 23:44:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-04-25 23:44:55 -0400
commit9831bc36f7981da230c9dbf3704377b3bf74f50f (patch)
tree021e13e365a1ad56e4b621a571f52e111b8b45b3 /Limit.hs
parent62a272b330550a5db4836fd8104ca4b6a2032e39 (diff)
per-IA-item content directories
Diffstat (limited to 'Limit.hs')
-rw-r--r--Limit.hs11
1 files changed, 8 insertions, 3 deletions
diff --git a/Limit.hs b/Limit.hs
index 9ce9d591e..679ebc199 100644
--- a/Limit.hs
+++ b/Limit.hs
@@ -1,6 +1,6 @@
{- user-specified limits on files to act on
-
- - Copyright 2011,2012 Joey Hess <joey@kitenet.net>
+ - Copyright 2011-2013 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -88,9 +88,9 @@ limitExclude glob = Right $ const $ return . not . matchglob glob
- once. Also, we use regex-TDFA because it's less buggy in its support
- of non-unicode characters. -}
matchglob :: String -> Annex.FileInfo -> Bool
-matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
+matchglob glob fi =
case cregex of
- Right r -> case execute r f of
+ Right r -> case execute r (Annex.matchFile fi) of
Right (Just _) -> True
_ -> False
Left _ -> error $ "failed to compile regex: " ++ regex
@@ -138,6 +138,11 @@ limitPresent u _ = Right $ const $ check $ \key -> do
handle _ Nothing = return False
handle a (Just (key, _)) = a key
+{- Limit to content that is in a directory, anywhere in the repository tree -}
+limitInDir :: FilePath -> MkLimit
+limitInDir dir = const $ Right $ const $ \fi -> return $
+ any (== dir) $ splitPath $ takeDirectory $ Annex.matchFile fi
+
{- Adds a limit to skip files not believed to have the specified number
- of copies. -}
addCopies :: String -> Annex ()