summaryrefslogtreecommitdiff
path: root/Logs/PreferredContent.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-10 15:15:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-10 15:15:56 -0400
commit2d1e48b3547b4df855d7166e7cee9fd3c00b8ec5 (patch)
tree2a63a72311e68040983ff08cea942a406ae3f1b0 /Logs/PreferredContent.hs
parenta5c3a2fbf523a22fbfcc7b7d419a56b88e6d8d12 (diff)
refactor
Diffstat (limited to 'Logs/PreferredContent.hs')
-rw-r--r--Logs/PreferredContent.hs21
1 files changed, 7 insertions, 14 deletions
diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs
index 37a1d79e0..8fdfef1fd 100644
--- a/Logs/PreferredContent.hs
+++ b/Logs/PreferredContent.hs
@@ -17,7 +17,6 @@ import qualified Data.Map as M
import qualified Data.Set as S
import Data.Either
import Data.Time.Clock.POSIX
-import Data.Monoid
import Common.Annex
import qualified Annex.Branch
@@ -26,6 +25,7 @@ import Logs.UUIDBased
import Limit
import qualified Utility.Matcher
import Annex.UUID
+import Annex.Groups
import Git.FilePath
import Types.Group
import Logs.Group
@@ -85,25 +85,18 @@ makeMatcher groupmap u s
where
tokens = map (parseToken groupmap) (tokenizeMatcher s)
-matchAll :: Utility.Matcher.Matcher MatchFiles
-matchAll = Utility.Matcher.generate []
-
{- Standard matchers are pre-defined for some groups. If none is defined,
- or a repository is in multiple groups with standard matchers, match all. -}
standardMatcher :: GroupMap -> UUID -> Utility.Matcher.Matcher MatchFiles
-standardMatcher groupmap u =
+standardMatcher groupmap u =
maybe matchAll findmatcher $ u `M.lookup` groupsByUUID groupmap
where
- findmatcher s = case catMaybes $ map standard $ S.toList s of
- [m] -> makeMatcher groupmap u m
+ findmatcher s = case catMaybes $ map toStandardGroup $ S.toList s of
+ [g] -> makeMatcher groupmap u $ preferredContent g
_ -> matchAll
- {- See doc/preferred_content.mdwn for explanations
- - of these expressions. -}
- standard "client" = Just "exclude=*/archive/*"
- standard "transfer" = Just "not inallgroup=client and " <> standard "client"
- standard "archive" = Just "not copies=archive:1"
- -- backup preferrs all content
- standard _ = Nothing
+
+matchAll :: Utility.Matcher.Matcher MatchFiles
+matchAll = Utility.Matcher.generate []
{- Checks if an expression can be parsed, if not returns Just error -}
checkPreferredContentExpression :: String -> Maybe String