Add --all option, and support it for fsck
This commit is contained in:
parent
1fbba745d5
commit
def7cb706f
5 changed files with 56 additions and 25 deletions
|
@ -33,6 +33,7 @@ import qualified Option
|
||||||
import Types.Key
|
import Types.Key
|
||||||
import Utility.HumanTime
|
import Utility.HumanTime
|
||||||
import Git.FilePath
|
import Git.FilePath
|
||||||
|
import GitAnnex.Options
|
||||||
|
|
||||||
#ifndef __WINDOWS__
|
#ifndef __WINDOWS__
|
||||||
import System.Posix.Process (getProcessID)
|
import System.Posix.Process (getProcessID)
|
||||||
|
@ -45,7 +46,7 @@ import System.Posix.Types (EpochTime)
|
||||||
import System.Locale
|
import System.Locale
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
def = [withOptions options $ command "fsck" paramPaths seek
|
def = [withOptions fsckOptions $ command "fsck" paramPaths seek
|
||||||
SectionMaintenance "check for problems"]
|
SectionMaintenance "check for problems"]
|
||||||
|
|
||||||
fromOption :: Option
|
fromOption :: Option
|
||||||
|
@ -61,9 +62,10 @@ incrementalScheduleOption :: Option
|
||||||
incrementalScheduleOption = Option.field [] "incremental-schedule" paramTime
|
incrementalScheduleOption = Option.field [] "incremental-schedule" paramTime
|
||||||
"schedule incremental fscking"
|
"schedule incremental fscking"
|
||||||
|
|
||||||
options :: [Option]
|
fsckOptions :: [Option]
|
||||||
options =
|
fsckOptions =
|
||||||
[ fromOption
|
[ allOption
|
||||||
|
, fromOption
|
||||||
, startIncrementalOption
|
, startIncrementalOption
|
||||||
, moreIncrementalOption
|
, moreIncrementalOption
|
||||||
, incrementalScheduleOption
|
, incrementalScheduleOption
|
||||||
|
@ -72,8 +74,9 @@ options =
|
||||||
seek :: [CommandSeek]
|
seek :: [CommandSeek]
|
||||||
seek =
|
seek =
|
||||||
[ withField fromOption Remote.byNameWithUUID $ \from ->
|
[ withField fromOption Remote.byNameWithUUID $ \from ->
|
||||||
withIncremental $ \i -> withFilesInGit $ whenAnnexed $ start from i
|
withIncremental $ \i ->
|
||||||
, withIncremental $ \i -> withBarePresentKeys $ startBare i
|
withAll (startAll i) $
|
||||||
|
withFilesInGit $ whenAnnexed $ start from i
|
||||||
]
|
]
|
||||||
|
|
||||||
withIncremental :: (Incremental -> CommandSeek) -> CommandSeek
|
withIncremental :: (Incremental -> CommandSeek) -> CommandSeek
|
||||||
|
@ -170,26 +173,15 @@ performRemote key file backend numcopies remote =
|
||||||
)
|
)
|
||||||
dummymeter _ = noop
|
dummymeter _ = noop
|
||||||
|
|
||||||
{- To fsck a bare repository, fsck each key in the location log. -}
|
startAll :: Incremental -> Key -> CommandStart
|
||||||
withBarePresentKeys :: (Key -> CommandStart) -> CommandSeek
|
startAll inc key = case Backend.maybeLookupBackendName (Types.Key.keyBackendName key) of
|
||||||
withBarePresentKeys a params = isBareRepo >>= go
|
|
||||||
where
|
|
||||||
go False = return []
|
|
||||||
go True = do
|
|
||||||
unless (null params) $
|
|
||||||
error "fsck should be run without parameters in a bare repository"
|
|
||||||
map a <$> loggedKeys
|
|
||||||
|
|
||||||
startBare :: Incremental -> Key -> CommandStart
|
|
||||||
startBare inc key = case Backend.maybeLookupBackendName (Types.Key.keyBackendName key) of
|
|
||||||
Nothing -> stop
|
Nothing -> stop
|
||||||
Just backend -> runFsck inc (key2file key) key $ performBare key backend
|
Just backend -> runFsck inc (key2file key) key $ performAll key backend
|
||||||
|
|
||||||
{- Note that numcopies cannot be checked in a bare repository, because
|
{- Note that numcopies cannot be checked in --all mode, since we do not
|
||||||
- getting the numcopies value requires a working copy with .gitattributes
|
- have associated filenames to look up in the .gitattributes file. -}
|
||||||
- files. -}
|
performAll :: Key -> Backend -> Annex Bool
|
||||||
performBare :: Key -> Backend -> Annex Bool
|
performAll key backend = check
|
||||||
performBare key backend = check
|
|
||||||
[ verifyLocationLog key (key2file key)
|
[ verifyLocationLog key (key2file key)
|
||||||
, checkKeySize key
|
, checkKeySize key
|
||||||
, checkBackend backend key Nothing
|
, checkBackend backend key Nothing
|
||||||
|
|
|
@ -58,3 +58,7 @@ options = Option.common ++
|
||||||
setgitconfig v = Annex.changeGitRepo =<< inRepo (Git.Config.store v)
|
setgitconfig v = Annex.changeGitRepo =<< inRepo (Git.Config.store v)
|
||||||
|
|
||||||
trustArg t = ReqArg (Remote.forceTrust t) paramRemote
|
trustArg t = ReqArg (Remote.forceTrust t) paramRemote
|
||||||
|
|
||||||
|
allOption :: Option
|
||||||
|
allOption = Option ['A'] ["all"] (NoArg (Annex.setFlag "all"))
|
||||||
|
"operate on all versions of all files"
|
||||||
|
|
20
Seek.hs
20
Seek.hs
|
@ -4,7 +4,7 @@
|
||||||
- the values a user passes to a command, and prepare actions operating
|
- the values a user passes to a command, and prepare actions operating
|
||||||
- on them.
|
- on them.
|
||||||
-
|
-
|
||||||
- Copyright 2010-2012 Joey Hess <joey@kitenet.net>
|
- Copyright 2010-2013 Joey Hess <joey@kitenet.net>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -24,6 +24,7 @@ import qualified Git.LsFiles as LsFiles
|
||||||
import qualified Limit
|
import qualified Limit
|
||||||
import qualified Option
|
import qualified Option
|
||||||
import Config
|
import Config
|
||||||
|
import Logs.Location
|
||||||
|
|
||||||
seekHelper :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> [FilePath] -> Annex [FilePath]
|
seekHelper :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> [FilePath] -> Annex [FilePath]
|
||||||
seekHelper a params = do
|
seekHelper a params = do
|
||||||
|
@ -121,6 +122,23 @@ withNothing :: CommandStart -> CommandSeek
|
||||||
withNothing a [] = return [a]
|
withNothing a [] = return [a]
|
||||||
withNothing _ _ = error "This command takes no parameters."
|
withNothing _ _ = error "This command takes no parameters."
|
||||||
|
|
||||||
|
{- If --all is specified, runs an action on all logged keys.
|
||||||
|
- Otherwise, fall back to a regular CommandSeek action on
|
||||||
|
- whatever params were passed. -}
|
||||||
|
withAll :: (Key -> CommandStart) -> CommandSeek -> CommandSeek
|
||||||
|
withAll allop fallbackop params = go =<< (Annex.getFlag "all" <||> isbare)
|
||||||
|
where
|
||||||
|
go False = fallbackop params
|
||||||
|
go True = do
|
||||||
|
whenM (Annex.getState Annex.auto) $
|
||||||
|
ifM isbare
|
||||||
|
( error "Cannot use --auto in a bare repository."
|
||||||
|
, error "Cannot use --auto with --all."
|
||||||
|
)
|
||||||
|
unless (null params) $
|
||||||
|
error "Cannot mix --all with file names."
|
||||||
|
map allop <$> loggedKeys
|
||||||
|
isbare = fromRepo Git.repoIsLocalBare
|
||||||
|
|
||||||
prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart]
|
prepFiltered :: (FilePath -> CommandStart) -> Annex [FilePath] -> Annex [CommandStart]
|
||||||
prepFiltered a fs = do
|
prepFiltered a fs = do
|
||||||
|
|
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -1,5 +1,10 @@
|
||||||
git-annex (4.20130628) UNRELEASED; urgency=low
|
git-annex (4.20130628) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
* --all: New switch that makes git-annex operate on all data stored
|
||||||
|
in the git annex, including old versions of files. Supported by
|
||||||
|
fsck, get, drop, move, copy, migrate.
|
||||||
|
* get, drop, move, copy, migrate: Can now be run in a bare repository,
|
||||||
|
like fsck already could. --all is enabled automatically in this case.
|
||||||
* webapp: Fix ssh setup with nonstandard port, broken in last release.
|
* webapp: Fix ssh setup with nonstandard port, broken in last release.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Tue, 02 Jul 2013 15:40:55 -0400
|
-- Joey Hess <joeyh@debian.org> Tue, 02 Jul 2013 15:40:55 -0400
|
||||||
|
|
|
@ -602,6 +602,18 @@ subdirectories).
|
||||||
will only do so when needed to help satisfy the setting of annex.numcopies,
|
will only do so when needed to help satisfy the setting of annex.numcopies,
|
||||||
and preferred content configuration.
|
and preferred content configuration.
|
||||||
|
|
||||||
|
* --all
|
||||||
|
|
||||||
|
Operate on all data that has been stored in the git annex,
|
||||||
|
including old versions of files. This is the default behavior when
|
||||||
|
running git-annex in a bare repository; in a non-bare repository the
|
||||||
|
normal behavior is to only operate on specified files in the working
|
||||||
|
tree.
|
||||||
|
|
||||||
|
Note that using --all makes .gitattributes annex.numcopies settings
|
||||||
|
not be honored. Other numcopies settings are still taken into account.
|
||||||
|
--all cannot be combined with --auto.
|
||||||
|
|
||||||
* --quiet
|
* --quiet
|
||||||
|
|
||||||
Avoid the default verbose display of what is done; only show errors
|
Avoid the default verbose display of what is done; only show errors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue