--copies=N can be used to make git-annex only operate on files with the specified number of copies.
(And --not --copies=N for the inverse.)
This commit is contained in:
parent
1fc3ee2423
commit
9da23dff78
4 changed files with 24 additions and 0 deletions
|
@ -112,6 +112,8 @@ options = commonOptions ++
|
||||||
"skip files matching the glob pattern"
|
"skip files matching the glob pattern"
|
||||||
, Option ['i'] ["in"] (ReqArg (Limit.addIn) paramRemote)
|
, Option ['i'] ["in"] (ReqArg (Limit.addIn) paramRemote)
|
||||||
"skip files not present in a remote"
|
"skip files not present in a remote"
|
||||||
|
, Option ['C'] ["copies"] (ReqArg (Limit.addCopies) paramNumber)
|
||||||
|
"skip files with fewer copies"
|
||||||
] ++ matcherOptions
|
] ++ matcherOptions
|
||||||
where
|
where
|
||||||
setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v }
|
setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v }
|
||||||
|
|
15
Limit.hs
15
Limit.hs
|
@ -17,6 +17,7 @@ import qualified Utility.Matcher
|
||||||
import qualified Remote
|
import qualified Remote
|
||||||
import qualified Backend
|
import qualified Backend
|
||||||
import LocationLog
|
import LocationLog
|
||||||
|
import Utility
|
||||||
|
|
||||||
type Limit = Utility.Matcher.Token (FilePath -> Annex Bool)
|
type Limit = Utility.Matcher.Token (FilePath -> Annex Bool)
|
||||||
|
|
||||||
|
@ -73,3 +74,17 @@ addIn name = do
|
||||||
handle u (Just (key, _)) = do
|
handle u (Just (key, _)) = do
|
||||||
us <- keyLocations key
|
us <- keyLocations key
|
||||||
return $ u `elem` us
|
return $ u `elem` us
|
||||||
|
|
||||||
|
{- Adds a limit to skip files not believed to have the specified number
|
||||||
|
- of copies. -}
|
||||||
|
addCopies :: String -> Annex ()
|
||||||
|
addCopies num = do
|
||||||
|
case readMaybe num :: Maybe Int of
|
||||||
|
Nothing -> error "bad number for --copies"
|
||||||
|
Just n -> addlimit $ check n
|
||||||
|
where
|
||||||
|
check n f = Backend.lookupFile f >>= handle n
|
||||||
|
handle _ Nothing = return False
|
||||||
|
handle n (Just (key, _)) = do
|
||||||
|
us <- keyLocations key
|
||||||
|
return $ length us >= n
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -5,6 +5,8 @@ git-annex (3.20110916) UNRELEASED; urgency=low
|
||||||
* Arbitrarily complex expressions can be built to limit the files git-annex
|
* Arbitrarily complex expressions can be built to limit the files git-annex
|
||||||
operates on, by combining the options --not --and --or -( and -)
|
operates on, by combining the options --not --and --or -( and -)
|
||||||
Example: git annex get --exclude '*.mp3' --and --not -( --in usbdrive --or --in archive -)
|
Example: git annex get --exclude '*.mp3' --and --not -( --in usbdrive --or --in archive -)
|
||||||
|
* --copies=N can be used to make git-annex only operate on files with
|
||||||
|
the specified number of copies. (And --not --copies=N for the inverse.)
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sun, 18 Sep 2011 18:25:51 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 18 Sep 2011 18:25:51 -0400
|
||||||
|
|
||||||
|
|
|
@ -434,6 +434,11 @@ file contents are present at either of two repositories.
|
||||||
The repository should be specified using the name of a configured remote,
|
The repository should be specified using the name of a configured remote,
|
||||||
or the UUID or description of a repository.
|
or the UUID or description of a repository.
|
||||||
|
|
||||||
|
* --copies=number
|
||||||
|
|
||||||
|
Matches only files that git-annex believes to have the specified number
|
||||||
|
of copies.
|
||||||
|
|
||||||
* --not
|
* --not
|
||||||
|
|
||||||
Inverts the next file matching option. For example, to only act on
|
Inverts the next file matching option. For example, to only act on
|
||||||
|
|
Loading…
Reference in a new issue