--auto is no longer a global option; only get, drop, and copy accept it.

Not a behavior change unless you were passing it to a command that ignored it.
This commit is contained in:
Joey Hess 2015-03-25 17:06:14 -04:00
parent 59e0df02ec
commit cd6b62f35e
19 changed files with 86 additions and 69 deletions

View file

@ -15,26 +15,32 @@ import Annex.Wanted
import Config.NumCopies
cmd :: [Command]
cmd = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek
cmd = [withOptions copyOptions $ command "copy" paramPaths seek
SectionCommon "copy content of files to/from another repository"]
copyOptions :: [Option]
copyOptions = Command.Move.moveOptions ++ [autoOption]
seek :: CommandSeek
seek ps = do
to <- getOptionField toOption Remote.byNameWithUUID
from <- getOptionField fromOption Remote.byNameWithUUID
withKeyOptions
auto <- getOptionFlag autoOption
withKeyOptions auto
(Command.Move.startKey to from False)
(withFilesInGit $ whenAnnexed $ start to from)
(withFilesInGit $ whenAnnexed $ start auto to from)
ps
{- A copy is just a move that does not delete the source file.
- However, --auto mode avoids unnecessary copies, and avoids getting or
- However, auto mode avoids unnecessary copies, and avoids getting or
- sending non-preferred content. -}
start :: Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart
start to from file key = stopUnless shouldCopy $
start :: Bool -> Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart
start auto to from file key = stopUnless shouldCopy $
Command.Move.start to from False file key
where
shouldCopy = checkAuto (check <||> numCopiesCheck file key (<))
check = case to of
shouldCopy
| auto = want <||> numCopiesCheck file key (<)
| otherwise = return True
want = case to of
Nothing -> wantGet False (Just key) (Just file)
Just r -> wantSend False (Just key) (Just file) (Remote.uuid r)