summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-15 17:08:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-15 17:08:55 -0400
commitb3bd559c7c814fc26c2887a535837ff4fb4c7c51 (patch)
treeed19959410b91060550b799b2e91578db12e3680 /Annex
parent0897e17b533593418890a1e57939520c5a242d06 (diff)
finish wiring up groupwanted
Diffstat (limited to 'Annex')
-rw-r--r--Annex/FileMatcher.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/Annex/FileMatcher.hs b/Annex/FileMatcher.hs
index 524ae3c7e..ae1bbb77b 100644
--- a/Annex/FileMatcher.hs
+++ b/Annex/FileMatcher.hs
@@ -56,23 +56,24 @@ parsedToMatcher parsed = case partitionEithers parsed of
([], vs) -> Right $ generate vs
(es, _) -> Left $ unwords $ map ("Parse failure: " ++) es
-exprParser :: FileMatcher -> GroupMap -> M.Map UUID RemoteConfig -> Maybe UUID -> String -> [Either String (Token MatchFiles)]
-exprParser matchstandard groupmap configmap mu expr =
+exprParser :: FileMatcher -> FileMatcher -> GroupMap -> M.Map UUID RemoteConfig -> Maybe UUID -> String -> [Either String (Token MatchFiles)]
+exprParser matchstandard matchgroupwanted groupmap configmap mu expr =
map parse $ tokenizeMatcher expr
where
parse = parseToken
matchstandard
+ matchgroupwanted
(limitPresent mu)
(limitInDir preferreddir)
groupmap
preferreddir = fromMaybe "public" $
M.lookup "preferreddir" =<< (`M.lookup` configmap) =<< mu
-parseToken :: FileMatcher -> MkLimit -> MkLimit -> GroupMap -> String -> Either String (Token MatchFiles)
-parseToken matchstandard checkpresent checkpreferreddir groupmap t
+parseToken :: FileMatcher -> FileMatcher -> MkLimit -> MkLimit -> GroupMap -> String -> Either String (Token MatchFiles)
+parseToken matchstandard matchgroupwanted checkpresent checkpreferreddir groupmap t
| t `elem` tokens = Right $ token t
- | t == "standard" = Right $ Operation $ \notpresent mi ->
- matchMrun matchstandard $ \a -> a notpresent mi
+ | t == "standard" = call matchstandard
+ | t == "groupwanted" = call matchgroupwanted
| t == "present" = use checkpresent
| t == "inpreferreddir" = use checkpreferreddir
| t == "unused" = Right $ Operation limitUnused
@@ -92,6 +93,8 @@ parseToken matchstandard checkpresent checkpreferreddir groupmap t
where
(k, v) = separate (== '=') t
use a = Operation <$> a v
+ call sub = Right $ Operation $ \notpresent mi ->
+ matchMrun sub $ \a -> a notpresent mi
{- This is really dumb tokenization; there's no support for quoted values.
- Open and close parens are always treated as standalone tokens;
@@ -112,5 +115,5 @@ largeFilesMatcher = go =<< annexLargeFiles <$> Annex.getGitConfig
rc <- readRemoteLog
u <- getUUID
either badexpr return $
- parsedToMatcher $ exprParser matchAll gm rc (Just u) expr
+ parsedToMatcher $ exprParser matchAll matchAll gm rc (Just u) expr
badexpr e = error $ "bad annex.largefiles configuration: " ++ e