From 9831bc36f7981da230c9dbf3704377b3bf74f50f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 25 Apr 2013 23:44:55 -0400 Subject: per-IA-item content directories --- Limit.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Limit.hs') 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 + - Copyright 2011-2013 Joey Hess - - 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 () -- cgit v1.2.3