diff options
-rw-r--r-- | Annex.hs | 2 | ||||
-rw-r--r-- | CmdLine/GitAnnex/Options.hs | 3 | ||||
-rw-r--r-- | CmdLine/Option.hs | 3 | ||||
-rw-r--r-- | CmdLine/Seek.hs | 5 | ||||
-rw-r--r-- | Command.hs | 6 | ||||
-rw-r--r-- | Command/Copy.hs | 22 | ||||
-rw-r--r-- | Command/Drop.hs | 40 | ||||
-rw-r--r-- | Command/Fsck.hs | 2 | ||||
-rw-r--r-- | Command/Get.hs | 15 | ||||
-rw-r--r-- | Command/MetaData.hs | 2 | ||||
-rw-r--r-- | Command/Mirror.hs | 16 | ||||
-rw-r--r-- | Command/Move.hs | 6 | ||||
-rw-r--r-- | Command/Whereis.hs | 2 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rw-r--r-- | doc/git-annex-copy.mdwn | 6 | ||||
-rw-r--r-- | doc/git-annex-drop.mdwn | 6 | ||||
-rw-r--r-- | doc/git-annex-get.mdwn | 6 | ||||
-rw-r--r-- | doc/git-annex-preferred-content.mdwn | 4 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 6 |
19 files changed, 86 insertions, 69 deletions
@@ -100,7 +100,6 @@ data AnnexState = AnnexState , output :: MessageState , force :: Bool , fast :: Bool - , auto :: Bool , daemon :: Bool , branchstate :: BranchState , repoqueue :: Maybe Git.Queue.Queue @@ -146,7 +145,6 @@ newState c r = AnnexState , output = defaultMessageState , force = False , fast = False - , auto = False , daemon = False , branchstate = startBranchState , repoqueue = Nothing diff --git a/CmdLine/GitAnnex/Options.hs b/CmdLine/GitAnnex/Options.hs index add29d8da..be1c74ede 100644 --- a/CmdLine/GitAnnex/Options.hs +++ b/CmdLine/GitAnnex/Options.hs @@ -142,3 +142,6 @@ timeLimitOption :: Option timeLimitOption = Option ['T'] ["time-limit"] (ReqArg Limit.addTimeLimit paramTime) "stop after the specified amount of time" + +autoOption :: Option +autoOption = flagOption ['a'] "auto" "automatic mode" diff --git a/CmdLine/Option.hs b/CmdLine/Option.hs index 2d4e67fa3..0cda34ba1 100644 --- a/CmdLine/Option.hs +++ b/CmdLine/Option.hs @@ -30,8 +30,6 @@ commonOptions = "allow actions that may lose annexed data" , Option ['F'] ["fast"] (NoArg (setfast True)) "avoid slow operations" - , Option ['a'] ["auto"] (NoArg (setauto True)) - "automatic mode" , Option ['q'] ["quiet"] (NoArg (Annex.setOutput QuietOutput)) "avoid verbose output" , Option ['v'] ["verbose"] (NoArg (Annex.setOutput NormalOutput)) @@ -50,7 +48,6 @@ commonOptions = where setforce v = Annex.changeState $ \s -> s { Annex.force = v } setfast v = Annex.changeState $ \s -> s { Annex.fast = v } - setauto v = Annex.changeState $ \s -> s { Annex.auto = v } setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v } setdebug = Annex.changeGitConfig $ \c -> c { annexDebug = True } unsetdebug = Annex.changeGitConfig $ \c -> c { annexDebug = False } diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index 7bfea45d0..b5726f53e 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -173,13 +173,12 @@ withNothing _ _ = error "This command takes no parameters." - - Otherwise, fall back to a regular CommandSeek action on - whatever params were passed. -} -withKeyOptions :: (Key -> CommandStart) -> CommandSeek -> CommandSeek -withKeyOptions keyop fallbackop params = do +withKeyOptions :: Bool -> (Key -> CommandStart) -> CommandSeek -> CommandSeek +withKeyOptions auto keyop fallbackop params = do bare <- fromRepo Git.repoIsLocalBare allkeys <- Annex.getFlag "all" unused <- Annex.getFlag "unused" specifickey <- Annex.getField "key" - auto <- Annex.getState Annex.auto when (auto && bare) $ error "Cannot use --auto in a bare repository" case (allkeys, unused, null params, specifickey) of diff --git a/Command.hs b/Command.hs index fd12991a4..35034a494 100644 --- a/Command.hs +++ b/Command.hs @@ -17,13 +17,11 @@ module Command ( whenAnnexed, ifAnnexed, isBareRepo, - checkAuto, module ReExported ) where import Common.Annex import qualified Backend -import qualified Annex import qualified Git import Types.Command as ReExported import Types.Option as ReExported @@ -79,7 +77,3 @@ ifAnnexed file yes no = maybe no yes =<< Backend.lookupFile file isBareRepo :: Annex Bool isBareRepo = fromRepo Git.repoIsLocalBare - -checkAuto :: Annex Bool -> Annex Bool -checkAuto checker = ifM (Annex.getState Annex.auto) - ( checker , return True ) diff --git a/Command/Copy.hs b/Command/Copy.hs index e5b093c61..1b9b2aac8 100644 --- a/Command/Copy.hs +++ b/Command/Copy.hs @@ -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) diff --git a/Command/Drop.hs b/Command/Drop.hs index 35c2f5cf4..63b9ccb7f 100644 --- a/Command/Drop.hs +++ b/Command/Drop.hs @@ -27,7 +27,7 @@ cmd = [withOptions (dropOptions) $ command "drop" paramPaths seek SectionCommon "indicate content of files not currently wanted"] dropOptions :: [Option] -dropOptions = dropFromOption : annexedMatchingOptions +dropOptions = dropFromOption : annexedMatchingOptions ++ [autoOption] dropFromOption :: Option dropFromOption = fieldOption ['f'] "from" paramRemote "drop content from a remote" @@ -35,11 +35,12 @@ dropFromOption = fieldOption ['f'] "from" paramRemote "drop content from a remot seek :: CommandSeek seek ps = do from <- getOptionField dropFromOption Remote.byNameWithUUID - withFilesInGit (whenAnnexed $ start from) ps + auto <- getOptionFlag autoOption + withFilesInGit (whenAnnexed $ start auto from) ps -start :: Maybe Remote -> FilePath -> Key -> CommandStart -start from file key = checkDropAuto from file key $ \numcopies -> - stopUnless (checkAuto $ wantDrop False (Remote.uuid <$> from) (Just key) (Just file)) $ +start :: Bool -> Maybe Remote -> FilePath -> Key -> CommandStart +start auto from file key = checkDropAuto auto from file key $ \numcopies -> + stopUnless want $ case from of Nothing -> startLocal (Just file) numcopies key Nothing Just remote -> do @@ -47,6 +48,10 @@ start from file key = checkDropAuto from file key $ \numcopies -> if Remote.uuid remote == u then startLocal (Just file) numcopies key Nothing else startRemote (Just file) numcopies key remote + where + want + | auto = wantDrop False (Remote.uuid <$> from) (Just key) (Just file) + | otherwise = return True startLocal :: AssociatedFile -> NumCopies -> Key -> Maybe Remote -> CommandStart startLocal afile numcopies key knownpresentremote = stopUnless (inAnnex key) $ do @@ -182,17 +187,16 @@ requiredContent = do {- In auto mode, only runs the action if there are enough - copies on other semitrusted repositories. -} -checkDropAuto :: Maybe Remote -> FilePath -> Key -> (NumCopies -> CommandStart) -> CommandStart -checkDropAuto mremote file key a = do - numcopies <- getFileNumCopies file - Annex.getState Annex.auto >>= auto numcopies +checkDropAuto :: Bool -> Maybe Remote -> FilePath -> Key -> (NumCopies -> CommandStart) -> CommandStart +checkDropAuto auto mremote file key a = go =<< getFileNumCopies file where - auto numcopies False = a numcopies - auto numcopies True = do - locs <- Remote.keyLocations key - uuid <- getUUID - let remoteuuid = fromMaybe uuid $ Remote.uuid <$> mremote - locs' <- trustExclude UnTrusted $ filter (/= remoteuuid) locs - if NumCopies (length locs') >= numcopies - then a numcopies - else stop + go numcopies + | auto = do + locs <- Remote.keyLocations key + uuid <- getUUID + let remoteuuid = fromMaybe uuid $ Remote.uuid <$> mremote + locs' <- trustExclude UnTrusted $ filter (/= remoteuuid) locs + if NumCopies (length locs') >= numcopies + then a numcopies + else stop + | otherwise = a numcopies diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 2d6029ec9..7b8fbddf1 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -69,7 +69,7 @@ seek ps = do from <- getOptionField fsckFromOption Remote.byNameWithUUID u <- maybe getUUID (pure . Remote.uuid) from i <- getIncremental u - withKeyOptions + withKeyOptions False (\k -> startKey i k =<< getNumCopies) (withFilesInGit $ whenAnnexed $ start from i) ps diff --git a/Command/Get.hs b/Command/Get.hs index 85960fc1a..922aee06a 100644 --- a/Command/Get.hs +++ b/Command/Get.hs @@ -21,20 +21,23 @@ cmd = [withOptions getOptions $ command "get" paramPaths seek SectionCommon "make content of annexed files available"] getOptions :: [Option] -getOptions = fromOption : annexedMatchingOptions ++ keyOptions +getOptions = fromOption : annexedMatchingOptions ++ keyOptions ++ [autoOption] seek :: CommandSeek seek ps = do from <- getOptionField fromOption Remote.byNameWithUUID - withKeyOptions + auto <- getOptionFlag autoOption + withKeyOptions auto (startKeys from) - (withFilesInGit $ whenAnnexed $ start from) + (withFilesInGit $ whenAnnexed $ start auto from) ps -start :: Maybe Remote -> FilePath -> Key -> CommandStart -start from file key = start' expensivecheck from key (Just file) +start :: Bool -> Maybe Remote -> FilePath -> Key -> CommandStart +start auto from file key = start' expensivecheck from key (Just file) where - expensivecheck = checkAuto (numCopiesCheck file key (<) <||> wantGet False (Just key) (Just file)) + expensivecheck + | auto = numCopiesCheck file key (<) <||> wantGet False (Just key) (Just file) + | otherwise = return True startKeys :: Maybe Remote -> Key -> CommandStart startKeys from key = start' (return True) from key Nothing diff --git a/Command/MetaData.hs b/Command/MetaData.hs index 08f205359..10093ab08 100644 --- a/Command/MetaData.hs +++ b/Command/MetaData.hs @@ -61,7 +61,7 @@ seek ps = do let seeker = if null modmeta then withFilesInGit else withFilesInGitNonRecursive - withKeyOptions + withKeyOptions False (startKeys now getfield modmeta) (seeker $ whenAnnexed $ start now getfield modmeta) ps diff --git a/Command/Mirror.hs b/Command/Mirror.hs index 7d3a7ef67..a04efb89b 100644 --- a/Command/Mirror.hs +++ b/Command/Mirror.hs @@ -14,19 +14,20 @@ import qualified Command.Drop import qualified Command.Get import qualified Remote import Annex.Content -import qualified Annex import Config.NumCopies cmd :: [Command] -cmd = [withOptions (fromToOptions ++ annexedMatchingOptions ++ keyOptions) $ - command "mirror" paramPaths seek - SectionCommon "mirror content of files to/from another repository"] +cmd = [withOptions mirrorOptions $ command "mirror" paramPaths seek + SectionCommon "mirror content of files to/from another repository"] + +mirrorOptions :: [Option] +mirrorOptions = fromToOptions ++ annexedMatchingOptions ++ keyOptions seek :: CommandSeek seek ps = do to <- getOptionField toOption Remote.byNameWithUUID from <- getOptionField fromOption Remote.byNameWithUUID - withKeyOptions + withKeyOptions False (startKey to from Nothing) (withFilesInGit $ whenAnnexed $ start to from) ps @@ -35,16 +36,13 @@ start :: Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart start to from file = startKey to from (Just file) startKey :: Maybe Remote -> Maybe Remote -> Maybe FilePath -> Key -> CommandStart -startKey to from afile key = do - noAuto +startKey to from afile key = case (from, to) of (Nothing, Nothing) -> error "specify either --from or --to" (Nothing, Just r) -> mirrorto r (Just r, Nothing) -> mirrorfrom r _ -> error "only one of --from or --to can be specified" where - noAuto = whenM (Annex.getState Annex.auto) $ - error "--auto is not supported for mirror" mirrorto r = ifM (inAnnex key) ( Command.Move.toStart r False afile key , do diff --git a/Command/Move.hs b/Command/Move.hs index 5317cefdd..bdc8018ba 100644 --- a/Command/Move.hs +++ b/Command/Move.hs @@ -28,7 +28,7 @@ seek :: CommandSeek seek ps = do to <- getOptionField toOption Remote.byNameWithUUID from <- getOptionField fromOption Remote.byNameWithUUID - withKeyOptions + withKeyOptions False (startKey to from True) (withFilesInGit $ whenAnnexed $ start to from True) ps @@ -41,15 +41,11 @@ startKey to from move = start' to from move Nothing start' :: Maybe Remote -> Maybe Remote -> Bool -> AssociatedFile -> Key -> CommandStart start' to from move afile key = do - noAuto case (from, to) of (Nothing, Nothing) -> error "specify either --from or --to" (Nothing, Just dest) -> toStart dest move afile key (Just src, Nothing) -> fromStart src move afile key _ -> error "only one of --from or --to can be specified" - where - noAuto = when move $ whenM (Annex.getState Annex.auto) $ error - "--auto is not supported for move" showMoveAction :: Bool -> Key -> AssociatedFile -> Annex () showMoveAction move = showStart' (if move then "move" else "copy") diff --git a/Command/Whereis.hs b/Command/Whereis.hs index 5f31998c5..cfcc8f224 100644 --- a/Command/Whereis.hs +++ b/Command/Whereis.hs @@ -23,7 +23,7 @@ cmd = [noCommit $ withOptions (jsonOption : annexedMatchingOptions ++ keyOptions seek :: CommandSeek seek ps = do m <- remoteMap id - withKeyOptions + withKeyOptions False (startKeys m) (withFilesInGit $ whenAnnexed $ start m) ps diff --git a/debian/changelog b/debian/changelog index 18d7b22b6..7add96dac 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ git-annex (5.20150318) UNRELEASED; urgency=medium destination backend. Useful in rare cases. * Man pages for individual commands now available, and can be opened using "git annex help <command>" + * --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.) -- Joey Hess <id@joeyh.name> Thu, 19 Mar 2015 17:05:32 -0400 diff --git a/doc/git-annex-copy.mdwn b/doc/git-annex-copy.mdwn index 7de0fbc25..e61cd1281 100644 --- a/doc/git-annex-copy.mdwn +++ b/doc/git-annex-copy.mdwn @@ -22,6 +22,12 @@ Copies the content of files from or to another remote. Use this option to copy the content of files from the local repository to the specified remote. +* `--auto` + + Rather than copying all files, only copy files that don't yet have + the desired number of copies, or that are preferred content of the + destination repository. See [[git-annex-preferred-content]](1) + * `--fast` Avoid contacting the remote to check if it has every file when copying diff --git a/doc/git-annex-drop.mdwn b/doc/git-annex-drop.mdwn index 41daf3858..3fd13467c 100644 --- a/doc/git-annex-drop.mdwn +++ b/doc/git-annex-drop.mdwn @@ -22,6 +22,12 @@ safe to do so. this option can specifiy a remote from which the files' contents should be removed. +* `--auto` + + Rather than trying to drop all specified files, drop only files that + are not preferred content of the repository. + See [[git-annex-preferred-content]](1) + * `--force` Use this option with care! It bypasses safety checks, and forces diff --git a/doc/git-annex-get.mdwn b/doc/git-annex-get.mdwn index cb5b73956..a72c79912 100644 --- a/doc/git-annex-get.mdwn +++ b/doc/git-annex-get.mdwn @@ -14,6 +14,12 @@ or transferring them from some kind of key-value store. # OPTIONS +* `--auto` + + Rather than getting all files, get only files that don't yet have + the desired number of copies, or that are preferred content of the + repository. See [[git-annex-preferred-content]](1) + * `--from=remote` Normally git-annex will choose which remotes to get the content diff --git a/doc/git-annex-preferred-content.mdwn b/doc/git-annex-preferred-content.mdwn index 6d5321ca2..9ea19ce09 100644 --- a/doc/git-annex-preferred-content.mdwn +++ b/doc/git-annex-preferred-content.mdwn @@ -36,6 +36,10 @@ when a repository in the group has its preferred content set to [[git-annex]](1) +[[git-annex-vicfg]](1) + +[[git-annex-wanted]](1) + # AUTHOR Joey Hess <id@joeyh.name> diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index a7d6c341b..316d33537 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -653,12 +653,6 @@ may not be explicitly listed on their individual man pages. Enable less expensive, but also less thorough versions of some commands. What is avoided depends on the command. -* `--auto` - - Enable automatic mode. Commands that get, drop, or move file contents - will only do so when needed to help satisfy the setting of numcopies, - and preferred content configuration. - * `--quiet` Avoid the default verbose display of what is done; only show errors |