A way to match files in repositories in a group
--copies=group:number can now be used to match files that are present in a specified number of repositories in a group.
This commit is contained in:
parent
5bd5bc094a
commit
eeaa8dada8
3 changed files with 21 additions and 10 deletions
23
Limit.hs
23
Limit.hs
|
@ -10,6 +10,7 @@ module Limit where
|
|||
import Text.Regex.PCRE.Light.Char8
|
||||
import System.Path.WildMatch
|
||||
import Data.Time.Clock.POSIX
|
||||
import qualified Data.Set as S
|
||||
|
||||
import Common.Annex
|
||||
import qualified Annex
|
||||
|
@ -18,6 +19,7 @@ import qualified Remote
|
|||
import qualified Backend
|
||||
import Annex.Content
|
||||
import Logs.Trust
|
||||
import Logs.Group
|
||||
import Utility.HumanTime
|
||||
|
||||
type Limit = Utility.Matcher.Token (FilePath -> Annex Bool)
|
||||
|
@ -86,21 +88,22 @@ addIn name = addLimit $ check $ if name == "." then inAnnex else inremote
|
|||
{- Adds a limit to skip files not believed to have the specified number
|
||||
- of copies. -}
|
||||
addCopies :: String -> Annex ()
|
||||
addCopies trust_num = addLimit . check $ readnum num
|
||||
addCopies want = addLimit . check $ readnum num
|
||||
where
|
||||
(num, mayCheckTrust) = case split ":" trust_num of
|
||||
[trust, num'] -> (num', checkTrust (readtrust trust))
|
||||
[num'] -> (num', const (return True))
|
||||
_ -> bad
|
||||
readnum = maybe bad id . readish
|
||||
readtrust = maybe bad id . readTrust
|
||||
(num, good) = case split ":" want of
|
||||
[v, n] -> case readTrust v of
|
||||
Just trust -> (n, checktrust trust)
|
||||
Nothing -> (n, checkgroup v)
|
||||
[n] -> (n, const $ return True)
|
||||
_ -> error "bad value for --copies"
|
||||
readnum = maybe (error "bad number for --copies") id . readish
|
||||
check n = Backend.lookupFile >=> handle n
|
||||
handle _ Nothing = return False
|
||||
handle n (Just (key, _)) = do
|
||||
us <- filterM mayCheckTrust =<< Remote.keyLocations key
|
||||
us <- filterM good =<< Remote.keyLocations key
|
||||
return $ length us >= n
|
||||
checkTrust t u = (== t) <$> lookupTrust u
|
||||
bad = error "bad number or trust:number for --copies"
|
||||
checktrust t u = (== t) <$> lookupTrust u
|
||||
checkgroup g u = S.member g <$> lookupGroups u
|
||||
|
||||
{- Adds a limit to skip files not using a specified key-value backend. -}
|
||||
addInBackend :: String -> Annex ()
|
||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -1,6 +1,8 @@
|
|||
git-annex (3.20121002) UNRELEASED; urgency=low
|
||||
|
||||
* group, ungroup: New commands to indicate groups of repositories.
|
||||
* --copies=group:number can now be used to match files that are present
|
||||
in a specified number of repositories in a group.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Mon, 01 Oct 2012 15:09:49 -0400
|
||||
|
||||
|
|
|
@ -625,6 +625,12 @@ file contents are present at either of two repositories.
|
|||
copies, on remotes with the specified trust level. For example,
|
||||
"--copies=trusted:2"
|
||||
|
||||
* --copies=groupname:number
|
||||
|
||||
Matches only files that git-annex believes have the specified number of
|
||||
copies, on remotes in the specified group. For example,
|
||||
"--copies=archival:2"
|
||||
|
||||
* --inbackend=name
|
||||
|
||||
Matches only files whose content is stored using the specified key-value
|
||||
|
|
Loading…
Reference in a new issue