summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-28 14:50:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-28 14:50:17 -0400
commit50c6c7406ba4c310e3567dc7d812330ef79098d2 (patch)
tree925449e6e9382646834b75968e4d3b0b2014dd06
parenta86cd4bc8215f01ffe2ba06c63be56656d8ae7cf (diff)
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"
-rw-r--r--Annex/Wanted.hs2
-rw-r--r--Command/Drop.hs2
-rw-r--r--GitAnnex/Options.hs17
-rw-r--r--Limit/Wanted.hs21
-rw-r--r--Types/Limit.hs3
-rw-r--r--debian/changelog3
-rw-r--r--doc/git-annex.mdwn12
-rw-r--r--doc/preferred_content.mdwn10
-rw-r--r--doc/todo/whishlist:_git_annex_drop_--dry-run.mdwn2
9 files changed, 63 insertions, 9 deletions
diff --git a/Annex/Wanted.hs b/Annex/Wanted.hs
index b90a1af31..04dcc1c1c 100644
--- a/Annex/Wanted.hs
+++ b/Annex/Wanted.hs
@@ -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>
-
diff --git a/Command/Drop.hs b/Command/Drop.hs
index b3f7d7574..5d642ed3a 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -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
diff --git a/GitAnnex/Options.hs b/GitAnnex/Options.hs
index 596cc138f..6359f83a0 100644
--- a/GitAnnex/Options.hs
+++ b/GitAnnex/Options.hs
@@ -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)
diff --git a/Limit/Wanted.hs b/Limit/Wanted.hs
new file mode 100644
index 000000000..ed4529dea
--- /dev/null
+++ b/Limit/Wanted.hs
@@ -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)
diff --git a/Types/Limit.hs b/Types/Limit.hs
index 9d981242d..4436f6953 100644
--- a/Types/Limit.hs
+++ b/Types/Limit.hs
@@ -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
diff --git a/debian/changelog b/debian/changelog
index 3c7435c9b..e35bb9127 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 693ce57ee..8d27bd7a7 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -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
diff --git a/doc/preferred_content.mdwn b/doc/preferred_content.mdwn
index 0f284c4c1..6a5364f67 100644
--- a/doc/preferred_content.mdwn
+++ b/doc/preferred_content.mdwn
@@ -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
diff --git a/doc/todo/whishlist:_git_annex_drop_--dry-run.mdwn b/doc/todo/whishlist:_git_annex_drop_--dry-run.mdwn
index 0c67d1629..6bbfd7a4d 100644
--- a/doc/todo/whishlist:_git_annex_drop_--dry-run.mdwn
+++ b/doc/todo/whishlist:_git_annex_drop_--dry-run.mdwn
@@ -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]]