Add --numcopies option.
This commit is contained in:
parent
12e0e95916
commit
3d567aa64f
6 changed files with 32 additions and 8 deletions
2
Annex.hs
2
Annex.hs
|
@ -39,6 +39,7 @@ data AnnexState = AnnexState
|
|||
, force :: Bool
|
||||
, fast :: Bool
|
||||
, forcebackend :: Maybe String
|
||||
, forcenumcopies :: Maybe Int
|
||||
, defaultkey :: Maybe String
|
||||
, toremote :: Maybe String
|
||||
, fromremote :: Maybe String
|
||||
|
@ -57,6 +58,7 @@ newState gitrepo allbackends = AnnexState
|
|||
, force = False
|
||||
, fast = False
|
||||
, forcebackend = Nothing
|
||||
, forcenumcopies = Nothing
|
||||
, defaultkey = Nothing
|
||||
, toremote = Nothing
|
||||
, fromremote = Nothing
|
||||
|
|
|
@ -152,12 +152,16 @@ showTriedRemotes remotes =
|
|||
showLongNote $ "Unable to access these remotes: " ++
|
||||
(join ", " $ map Remote.name remotes)
|
||||
|
||||
{- If a value is specified, it is used; otherwise the default is looked up
|
||||
- in git config. forcenumcopies overrides everything. -}
|
||||
getNumCopies :: Maybe Int -> Annex Int
|
||||
getNumCopies (Just n) = return n
|
||||
getNumCopies Nothing = do
|
||||
g <- Annex.gitRepo
|
||||
return $ read $ Git.configGet g config "1"
|
||||
getNumCopies v =
|
||||
Annex.getState Annex.forcenumcopies >>= maybe (use v) (return . id)
|
||||
where
|
||||
use (Just n) = return n
|
||||
use Nothing = do
|
||||
g <- Annex.gitRepo
|
||||
return $ read $ Git.configGet g config "1"
|
||||
config = "annex.numcopies"
|
||||
|
||||
{- Ideally, all keys have file size metadata. Old keys may not. -}
|
||||
|
|
12
GitAnnex.hs
12
GitAnnex.hs
|
@ -13,6 +13,7 @@ import qualified GitRepo as Git
|
|||
import CmdLine
|
||||
import Command
|
||||
import Options
|
||||
import Utility
|
||||
import qualified Annex
|
||||
|
||||
import qualified Command.Add
|
||||
|
@ -82,20 +83,23 @@ cmds = concat
|
|||
|
||||
options :: [Option]
|
||||
options = commonOptions ++
|
||||
[ Option ['k'] ["key"] (ReqArg setkey paramKey)
|
||||
"specify a key to use"
|
||||
, Option ['t'] ["to"] (ReqArg setto paramRemote)
|
||||
[ Option ['t'] ["to"] (ReqArg setto paramRemote)
|
||||
"specify to where to transfer content"
|
||||
, Option ['f'] ["from"] (ReqArg setfrom paramRemote)
|
||||
"specify from where to transfer content"
|
||||
, Option ['x'] ["exclude"] (ReqArg addexclude paramGlob)
|
||||
"skip files matching the glob pattern"
|
||||
, Option ['N'] ["numcopies"] (ReqArg setnumcopies paramNumber)
|
||||
"override default number of copies"
|
||||
, Option ['k'] ["key"] (ReqArg setkey paramKey)
|
||||
"specify a key to use"
|
||||
]
|
||||
where
|
||||
setkey v = Annex.changeState $ \s -> s { Annex.defaultkey = Just v }
|
||||
setto v = Annex.changeState $ \s -> s { Annex.toremote = Just v }
|
||||
setfrom v = Annex.changeState $ \s -> s { Annex.fromremote = Just v }
|
||||
addexclude v = Annex.changeState $ \s -> s { Annex.exclude = v:(Annex.exclude s) }
|
||||
setnumcopies v = Annex.changeState $ \s -> s {Annex.forcenumcopies = readMaybe v }
|
||||
setkey v = Annex.changeState $ \s -> s { Annex.defaultkey = Just v }
|
||||
|
||||
header :: String
|
||||
header = "Usage: git-annex command [option ..]"
|
||||
|
|
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -1,3 +1,9 @@
|
|||
git-annex (0.20110602) UNRELEASED; urgency=low
|
||||
|
||||
* Add --numcopies option.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Wed, 01 Jun 2011 16:26:48 -0400
|
||||
|
||||
git-annex (0.20110601) unstable; urgency=low
|
||||
|
||||
* Minor bugfixes and error message improvements.
|
||||
|
|
|
@ -5,6 +5,9 @@ Here are a few I've been considering:
|
|||
---
|
||||
|
||||
* --numcopies would be a useful command line switch.
|
||||
> Update: Added. Also allows for things like `git annex drop
|
||||
> --numcopies=2` when in a repo that normally needs 3 copies, if you need
|
||||
> to urgently free up space.
|
||||
* A way to make `drop` and other commands temporarily trust a given remote, or possibly all remotes.
|
||||
|
||||
Combined, this would allow `git annex drop --numcopies=2 --trust=repoa --trust=repob` to remove files that have been replicated out to the other 2 repositories, which could be offline. (Slightly unsafe, but in this case the files are podcasts so not really.)
|
||||
|
|
|
@ -354,6 +354,11 @@ Many git-annex commands will stage changes for later `git commit` by you.
|
|||
|
||||
This option can be specified multiple times.
|
||||
|
||||
* --numcopies=n
|
||||
|
||||
Overrides the `annex.numcopies` setting, forcing git-annex to ensure the
|
||||
specified number of copies exist.
|
||||
|
||||
* --backend=name
|
||||
|
||||
Specifies which key-value backend to use. This can be used when
|
||||
|
|
Loading…
Add table
Reference in a new issue