groupwanted: New command to set the groupwanted preferred content expression.
This commit is contained in:
parent
69a9c98e71
commit
febb1c2082
6 changed files with 83 additions and 5 deletions
|
@ -68,6 +68,7 @@ import qualified Command.Semitrust
|
|||
import qualified Command.Dead
|
||||
import qualified Command.Group
|
||||
import qualified Command.Wanted
|
||||
import qualified Command.GroupWanted
|
||||
import qualified Command.Schedule
|
||||
import qualified Command.Ungroup
|
||||
import qualified Command.Vicfg
|
||||
|
@ -142,6 +143,7 @@ cmds = concat
|
|||
, Command.Dead.cmd
|
||||
, Command.Group.cmd
|
||||
, Command.Wanted.cmd
|
||||
, Command.GroupWanted.cmd
|
||||
, Command.Schedule.cmd
|
||||
, Command.Ungroup.cmd
|
||||
, Command.Vicfg.cmd
|
||||
|
|
45
Command/GroupWanted.hs
Normal file
45
Command/GroupWanted.hs
Normal file
|
@ -0,0 +1,45 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2015 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Command.GroupWanted where
|
||||
|
||||
import Common.Annex
|
||||
import qualified Annex
|
||||
import Command
|
||||
import Logs.PreferredContent
|
||||
import Types.Messages
|
||||
import Types.Group
|
||||
|
||||
import qualified Data.Map as M
|
||||
|
||||
cmd :: [Command]
|
||||
cmd = [command "groupwanted" (paramPair paramGroup (paramOptional paramExpression)) seek
|
||||
SectionSetup "get or set groupwanted expression"]
|
||||
|
||||
seek :: CommandSeek
|
||||
seek = withWords start
|
||||
|
||||
start :: [String] -> CommandStart
|
||||
start (g:[]) = next $ performGet g
|
||||
start (g:expr:[]) = do
|
||||
showStart "groupwanted" g
|
||||
next $ performSet g expr
|
||||
start _ = error "Specify a group."
|
||||
|
||||
performGet :: Group -> CommandPerform
|
||||
performGet g = do
|
||||
Annex.setOutput QuietOutput
|
||||
m <- groupPreferredContentMapRaw
|
||||
liftIO $ putStrLn $ fromMaybe "" $ M.lookup g m
|
||||
next $ return True
|
||||
|
||||
performSet :: Group -> String -> CommandPerform
|
||||
performSet g expr = case checkPreferredContentExpression expr of
|
||||
Just e -> error $ "Parse error: " ++ e
|
||||
Nothing -> do
|
||||
groupPreferredContentSet g expr
|
||||
next $ return True
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -4,6 +4,8 @@ git-annex (5.20150206) UNRELEASED; urgency=medium
|
|||
from boto, rather than from glacier-cli, and refuse to use it,
|
||||
since the boto program fails to fail when passed
|
||||
parameters it does not understand.
|
||||
* groupwanted: New command to set the groupwanted preferred content
|
||||
expression.
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Fri, 06 Feb 2015 13:57:08 -0400
|
||||
|
||||
|
|
|
@ -504,6 +504,21 @@ subdirectories).
|
|||
Without an expression, displays the current preferred content setting
|
||||
of the repository.
|
||||
|
||||
* `groupwanted groupname [expression]`
|
||||
|
||||
Sets or displays the groupwanted expression. This will be used by
|
||||
repositories that are in the group, and that have their preferred
|
||||
content expression set to "groupwanted".
|
||||
|
||||
For example, to configure a group named redundantarchive, and
|
||||
make repositories in the group want to contain 3 copies of every file:
|
||||
|
||||
git annex groupwanted redundantarchive "not (copies=redundantarchive:3)"
|
||||
for repo in foo bar baz; do
|
||||
git annex group $repo redundantarchive
|
||||
git annex wanted $repo groupwanted
|
||||
done
|
||||
|
||||
* `schedule repository [expression]`
|
||||
|
||||
When run with an expression, configures scheduled jobs to run at a
|
||||
|
@ -1375,7 +1390,9 @@ no equivilant to `--in`.
|
|||
|
||||
When a repository is in one of the standard predefined groups, like "backup"
|
||||
and "client", setting its preferred content to "standard" will use a
|
||||
built-in preferred content expression developed for that group.
|
||||
built-in preferred content expression developed for that group. Or,
|
||||
setting its preferred content to "groupwanted" will make it use whatever
|
||||
groupwanted expression you set for the group.
|
||||
|
||||
# SCHEDULED JOBS
|
||||
|
||||
|
|
|
@ -125,8 +125,8 @@ But, you can do more complicated things, for example:
|
|||
|
||||
The "groupwanted" keyword can be used to refer to a preferred content
|
||||
expression that is associated with a group. This is like the "standard"
|
||||
keyword, but you can set up groupwanted preferred content expressions
|
||||
using `git annex vicfg`.
|
||||
keyword, but you can configure the preferred content expressions
|
||||
using `git annex groupwanted`.
|
||||
|
||||
Note that when writing a groupwanted preferred content expression,
|
||||
you can use all of the keywords listed above, including "standard".
|
||||
|
@ -134,7 +134,8 @@ you can use all of the keywords listed above, including "standard".
|
|||
|
||||
For example, to make a variant of the standard client preferred content
|
||||
expression that does not want files in the "out" directory, you
|
||||
could set `groupwanted client = standard and exclude=out/*`.
|
||||
could run: `git annex groupwanted client "standard and exclude=out/*"`
|
||||
|
||||
Then repositories that are in the client group and have their preferred
|
||||
content expression set to "groupwanted" will use that, while
|
||||
other client repositories that have their preferred content expression
|
||||
|
@ -144,6 +145,17 @@ Or, you could make a new group, with your own custom preferred content
|
|||
expression tuned for your needs, and every repository you put in this
|
||||
group and make its preferred content be "groupwanted" will use it.
|
||||
|
||||
For example, the archive group only wants to archive 1 copy of each file,
|
||||
spread amoung every repository in the group.
|
||||
Here's how to configure a group named redundantarchive, that instead
|
||||
wants to contain 3 copies of each file:
|
||||
|
||||
git annex groupwanted redundantarchive "not (copies=redundantarchive:3)"
|
||||
for repo in foo bar baz; do
|
||||
git annex group $repo redundantarchive
|
||||
git annex wanted $repo groupwanted
|
||||
done
|
||||
|
||||
### difference: metadata matching
|
||||
|
||||
This:
|
||||
|
|
|
@ -72,7 +72,7 @@ All content is wanted, unless it's already been archived somewhere else.
|
|||
`(not (copies=archive:1 or copies=smallarchive:1)) or approxlackingcopies=1`
|
||||
|
||||
Note that if you want to archive multiple copies (not a bad idea!),
|
||||
you can set `groupwanted archive` to a version of
|
||||
you can set `git-annex groupwanted archive` to a version of
|
||||
the above preferred content expression with a larger number of copies
|
||||
than 1. Then make the archive repositories have a preferred
|
||||
content expression of "groupwanted" in order to use your modified
|
||||
|
|
Loading…
Add table
Reference in a new issue