summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Limit.hs23
-rw-r--r--debian/changelog2
-rw-r--r--doc/git-annex.mdwn6
3 files changed, 21 insertions, 10 deletions
diff --git a/Limit.hs b/Limit.hs
index babd1c00c..6f83c0e38 100644
--- a/Limit.hs
+++ b/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 ()
diff --git a/debian/changelog b/debian/changelog
index 57da10688..41a350690 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 50de5e389..5a0f0569b 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -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