add --want-get and --want-drop options

New --want-get and --want-drop options which can be used to test preferred
content settings. For example, "git annex find --in . --want-drop"
This commit is contained in:
Joey Hess 2013-10-28 14:50:17 -04:00
parent afddbfd7e9
commit 230bfa9688
9 changed files with 63 additions and 9 deletions

View file

@ -1,4 +1,4 @@
{- git-annex control over whether content is wanted
{- git-annex checking whether content is wanted
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-

View file

@ -139,7 +139,7 @@ notEnoughCopies key need have skip bad = do
unsafe = showNote "unsafe"
hint = showLongNote "(Use --force to override this check, or adjust annex.numcopies.)"
{- In auto mode, only runs the action if there are enough copies
{- In auto mode, only runs the action if there are enough
- copies on other semitrusted repositories.
-
- Passes any numcopies attribute of the file on to the action as an

View file

@ -16,6 +16,7 @@ import Types.TrustLevel
import qualified Annex
import qualified Remote
import qualified Limit
import qualified Limit.Wanted
import qualified Option
options :: [Option]
@ -33,19 +34,23 @@ options = Option.common ++
, Option ['x'] ["exclude"] (ReqArg Limit.addExclude paramGlob)
"skip files matching the glob pattern"
, Option ['I'] ["include"] (ReqArg Limit.addInclude paramGlob)
"don't skip files matching the glob pattern"
"limit to files matching the glob pattern"
, Option ['i'] ["in"] (ReqArg Limit.addIn paramRemote)
"skip files not present in a remote"
"match files present in a remote"
, Option ['C'] ["copies"] (ReqArg Limit.addCopies paramNumber)
"skip files with fewer copies"
, Option ['B'] ["inbackend"] (ReqArg Limit.addInBackend paramName)
"skip files not using a key-value backend"
"match files using a key-value backend"
, Option [] ["inallgroup"] (ReqArg Limit.addInAllGroup paramGroup)
"skip files not present in all remotes in a group"
"match files present in all remotes in a group"
, Option [] ["largerthan"] (ReqArg Limit.addLargerThan paramSize)
"skip files larger than a size"
"match files larger than a size"
, Option [] ["smallerthan"] (ReqArg Limit.addSmallerThan paramSize)
"skip files smaller than a size"
"match files smaller than a size"
, Option [] ["want-get"] (NoArg Limit.Wanted.addWantGet)
"match files preferred content wants to get"
, Option [] ["want-drop"] (NoArg Limit.Wanted.addWantDrop)
"match files preferred-content wants to drop"
, Option ['T'] ["time-limit"] (ReqArg Limit.addTimeLimit paramTime)
"stop after the specified amount of time"
, Option [] ["user-agent"] (ReqArg setuseragent paramName)

21
Limit/Wanted.hs Normal file
View file

@ -0,0 +1,21 @@
{- git-annex limits by wanted status
-
- Copyright 2012 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
module Limit.Wanted where
import Common.Annex
import Annex.Wanted
import Limit
import Types.FileMatcher
addWantGet :: Annex ()
addWantGet = addLimit $ Right $ const $
\fileinfo -> wantGet False (Just $ matchFile fileinfo)
addWantDrop :: Annex ()
addWantDrop = addLimit $ Right $ const $
\fileinfo -> wantDrop False Nothing (Just $ matchFile fileinfo)

View file

@ -14,6 +14,7 @@ import Types.FileMatcher
import qualified Data.Set as S
type MatchFiles = AssumeNotPresent -> FileInfo -> Annex Bool
type MkLimit = String -> Either String MatchFiles
type AssumeNotPresent = S.Set UUID
type MatchFiles = AssumeNotPresent -> FileInfo -> Annex Bool

3
debian/changelog vendored
View file

@ -1,6 +1,9 @@
git-annex (4.20131025) UNRELEASED; urgency=low
* The "git annex content" command is renamed to "git annex wanted".
* New --want-get and --want-drop options which can be used to
test preferred content settings.
For example, "git annex find --in . --want-drop"
* assistant: When autostarted, wait 5 seconds before running the startup
scan, to avoid contending with the user's desktop login process.
* webapp: When setting up a bare shared repository, enable non-fast-forward

View file

@ -947,6 +947,18 @@ file contents are present at either of two repositories.
The size can be specified with any commonly used units, for example,
"0.5 gb" or "100 KiloBytes"
* `--want-get`
Matches files that the preferred content settings for the repository
make it want to get. Note that this will match even files that are
already present, unless limited with eg, `--not --in .`
* `--want-drop`
Matches files that the preferred content settings for the repository
make it want to drop. Note that this will match even files that have
already been dropped, unless limited with eg, `--in .`
* `--not`
Inverts the next file matching option. For example, to only act on

View file

@ -84,6 +84,16 @@ The name of the directory can be configured using
(If no directory name is configured, it uses "public" by default.)
## testing preferred content settings
To check at the command line which files are matched by preferred content
settings, you can use the --want-get and --want-drop options.
For example, "git annex find --want-get --not --in ." will find all the
files that "git annex get --auto" will want to get, and "git annex find
--want-drop --in ." will find all the files that "git annex drop --auto"
will want to drop.
## standard expressions
git-annex comes with some standard preferred content expressions, that can

View file

@ -1,3 +1,5 @@
It'd be useful to be able to see what `git annex drop` would do *before* asking it to drop any files.
For example, I just set up my preferred contents expressions, and I don't know if I got them right. Before dropping anything from this repo, it'd be nice to check what would happen. I know git annex drop will only drop files that are above their minimum numcopies, but I'd still like to avoid heavyweight copying in case I got my preferred contents expressions wrong.
> [[done]]; added --want-get and --want-drop. --[[Joey]]