* Support "onlyingroup=" in preferred content expressions.
* Support --onlyingroup= matching option.
Sponsored-by: Jack Hill on Patreon
, ValueToken "inbackend" (usev limitInBackend)
, ValueToken "metadata" (usev limitMetaData)
, ValueToken "inallgroup" (usev $ limitInAllGroup $ getGroupMap pcd)
+ , ValueToken "onlyingroup" (usev $ limitOnlyInGroup $ getGroupMap pcd)
] ++ commonKeyedTokens
preferredContentTokens :: PreferredContentData -> [ParseToken (MatchFiles Annex)]
access.
* directory, gcrypt: Remove empty hash directories when dropping content.
* dropunused: Support --jobs
+ * Support "onlyingroup=" in preferred content expressions.
+ * Support --onlyingroup= matching option.
-- Joey Hess <id@joeyh.name> Mon, 26 Jun 2023 13:10:40 -0400
)
, annexOption (setAnnexState . Limit.addInAllGroup) $ strOption
( long "inallgroup" <> metavar paramGroup
- <> help "match files present in all remotes in a group"
+ <> help "match files present in all repositories in a group"
+ <> hidden
+ )
+ , annexOption (setAnnexState . Limit.addOnlyInGroup) $ strOption
+ ( long "onlyingroup" <> metavar paramGroup
+ <> help "match files that are only present in repositories in the group"
<> hidden
)
, annexOption (setAnnexState . Limit.addMetaData) $ strOption
present <- S.fromList <$> Remote.keyLocations key
return $ S.null $ want `S.difference` present
+{- Skip files that are only present in repositories that are not in the
+ - group. -}
+addOnlyInGroup :: String -> Annex ()
+addOnlyInGroup groupname = addLimit $ limitOnlyInGroup groupMap groupname
+
+limitOnlyInGroup :: Annex GroupMap -> MkLimit Annex
+limitOnlyInGroup getgroupmap groupname = Right $ MatchFiles
+ { matchAction = \notpresent mi -> do
+ m <- getgroupmap
+ let want = fromMaybe S.empty $ M.lookup (toGroup groupname) $ uuidsByGroup m
+ if S.null want
+ then return False
+ else checkKey (check notpresent want) mi
+ , matchNeedsFileName = False
+ , matchNeedsFileContent = False
+ , matchNeedsKey = True
+ , matchNeedsLocationLog = True
+ , matchDesc = "inallgroup" =? groupname
+ }
+ where
+ check notpresent want key = do
+ locs <- S.fromList <$> Remote.keyLocations key
+ let present = locs `S.difference` notpresent
+ return $ not $ S.null $ present `S.intersection` want
+
{- Adds a limit to skip files not using a specified key-value backend. -}
addInBackend :: String -> Annex ()
addInBackend = addLimit . limitInBackend
Matches only when git-annex believes content is present in
all repositories in the specified group.
+* `--onlyingroup=groupname`
+
+ Matches only when git-annex believes content is present in at least one
+ repository that is in the specified group, and is not present in any
+ repositories that are not in the specified group.
+
* `--smallerthan=size`
* `--largerthan=size`
Matches only files that git-annex believes are present in all repositories
in the specified group.
+* `onlyingroup=groupname`
+
+ Matches files that git-annex believes are present in at least one
+ repository that is in the specified group, and are not present in any
+ repositories that are not in the specified group.
+
* `smallerthan=size` / `largerthan=size`
Matches only files whose content is smaller than, or larger than the
--- /dev/null
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2023-07-31T18:41:03Z"
+ content="""
+ Matches files that git-annex believes are present in at least one
+ repository that is in the specified group, and are not present in any
+ repositories that are not in the specified group.
+
+That's a pretty simple description and it allows matching when a repository
+is in the specified group but is also in some other groups.
+
+So that makes me happy with onlyingroup and I implemented it.
+"""]]
Cheers,
Yann
+
+> [[done]] --[[Joey]]