aboutsummaryrefslogtreecommitdiff
path: root/Logs/PreferredContent.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-08 13:16:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-08 13:16:53 -0400
commit45d50d8c27207fa09e5d3331683e1510df3f3bdd (patch)
tree4bc41f75b77aebd09f7343d9d5bca355d57f4536 /Logs/PreferredContent.hs
parent7057ce97cce7622051815cf8dd6c8ddd5ac0f62c (diff)
wired preferred content up to get, copy, and drop --auto
Diffstat (limited to 'Logs/PreferredContent.hs')
-rw-r--r--Logs/PreferredContent.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/Logs/PreferredContent.hs b/Logs/PreferredContent.hs
index 77e4f2705..8d812ec4d 100644
--- a/Logs/PreferredContent.hs
+++ b/Logs/PreferredContent.hs
@@ -7,6 +7,7 @@
module Logs.PreferredContent (
preferredContentSet,
+ isPreferredContent,
preferredContentMap,
preferredContentMapRaw,
checkPreferredContentExpression,
@@ -20,8 +21,10 @@ import Common.Annex
import qualified Annex.Branch
import qualified Annex
import Logs.UUIDBased
-import Limit (MatchFiles, limitInclude, limitExclude, limitIn, limitCopies, limitInBackend)
+import Limit (MatchFiles, AssumeNotPresent, limitInclude, limitExclude, limitIn, limitCopies, limitInBackend)
import qualified Utility.Matcher
+import Annex.UUID
+import Git.FilePath
{- Filename of preferred-content.log. -}
preferredContentLog :: FilePath
@@ -36,6 +39,18 @@ preferredContentSet uuid@(UUID _) val = do
Annex.changeState $ \s -> s { Annex.groupmap = Nothing }
preferredContentSet NoUUID _ = error "unknown UUID; cannot modify"
+{- Checks if a file is preferred content for the specified repository
+ - (or the current repository if none is specified). -}
+isPreferredContent :: Maybe UUID -> AssumeNotPresent -> TopFilePath -> Annex Bool
+isPreferredContent mu notpresent file = do
+ u <- maybe getUUID return mu
+ m <- preferredContentMap
+ case M.lookup u m of
+ Nothing -> return True
+ Just matcher ->
+ Utility.Matcher.matchM2 matcher notpresent $
+ getTopFilePath file
+
{- Read the preferredContentLog into a map. The map is cached for speed. -}
preferredContentMap :: Annex Annex.PreferredContentMap
preferredContentMap = do