Added annex.autoupgraderepository configuration
Can be set to false to prevent any automatic repository upgrades. Also, removed direct mode specific upgrade code in Annex.Init, and made needsUpgrade always include the name/path of the repo, so if there's a problem it's clear what repo has the problem. And, made needsUpgrade catch any exceptions that might occur during the upgrade, so it can display a more useful error message than just the exception.
This commit is contained in:
parent
b421004d75
commit
f845195354
7 changed files with 53 additions and 23 deletions
|
@ -141,12 +141,7 @@ uninitialize = do
|
|||
- Checks repository version and handles upgrades too.
|
||||
-}
|
||||
ensureInitialized :: Annex ()
|
||||
ensureInitialized = ifM isDirect
|
||||
( unlessM (catchBoolIO $ upgrade True defaultVersion) $ do
|
||||
g <- Annex.gitRepo
|
||||
giveup $ "Upgrading direct mode repository " ++ Git.repoDescribe g ++ " failed, and direct mode is no longer supported."
|
||||
, getVersion >>= maybe needsinit checkUpgrade
|
||||
)
|
||||
ensureInitialized = getVersion >>= maybe needsinit checkUpgrade
|
||||
where
|
||||
needsinit = ifM Annex.Branch.hasSibling
|
||||
( initialize Nothing Nothing
|
||||
|
|
|
@ -4,6 +4,8 @@ git-annex (7.20190826) UNRELEASED; urgency=medium
|
|||
* Automatically upgrade v5 repositories to v7.
|
||||
* Automatically convert direct mode repositories to v7 with adjusted
|
||||
unlocked branches and set annex.thin.
|
||||
* Added annex.autoupgraderepository configuration that can be set to false
|
||||
to prevent any automatic repository upgrades.
|
||||
* Refuse to upgrade direct mode repositories when git is older than 2.22,
|
||||
which fixed a memory leak that could cause an OOM during the upgrade.
|
||||
* assistant: When creating a new repository, no longer use direct
|
||||
|
|
|
@ -13,9 +13,13 @@ import Annex.Version
|
|||
import Annex.Init
|
||||
|
||||
cmd :: Command
|
||||
cmd = dontCheck repoExists $ -- because an old version may not seem to exist
|
||||
noDaemonRunning $ -- avoid upgrading repo out from under daemon
|
||||
command "upgrade" SectionMaintenance "upgrade repository layout"
|
||||
cmd = dontCheck repoExists $
|
||||
-- ^ because an old version may not seem to exist
|
||||
-- and also, this avoids automatic silent upgrades before
|
||||
-- this command can start up.
|
||||
noDaemonRunning $
|
||||
-- ^ avoid upgrading repo out from under daemon
|
||||
command "upgrade" SectionMaintenance "upgrade repository"
|
||||
paramNothing (withParams seek)
|
||||
|
||||
seek :: CmdParams -> CommandSeek
|
||||
|
|
|
@ -103,6 +103,7 @@ data GitConfig = GitConfig
|
|||
, annexMaxExtensionLength :: Maybe Int
|
||||
, annexJobs :: Concurrency
|
||||
, annexCacheCreds :: Bool
|
||||
, annexAutoUpgradeRepository :: Bool
|
||||
, coreSymlinks :: Bool
|
||||
, coreSharedRepository :: SharedRepository
|
||||
, receiveDenyCurrentBranch :: DenyCurrentBranch
|
||||
|
@ -182,6 +183,7 @@ extractGitConfig r = GitConfig
|
|||
, annexJobs = fromMaybe NonConcurrent $
|
||||
parseConcurrency =<< getmaybe (annex "jobs")
|
||||
, annexCacheCreds = getbool (annex "cachecreds") True
|
||||
, annexAutoUpgradeRepository = getbool (annex "autoupgraderepository") True
|
||||
, coreSymlinks = getbool "core.symlinks" True
|
||||
, coreSharedRepository = getSharedRepository r
|
||||
, receiveDenyCurrentBranch = getDenyCurrentBranch r
|
||||
|
|
26
Upgrade.hs
26
Upgrade.hs
|
@ -1,6 +1,6 @@
|
|||
{- git-annex upgrade support
|
||||
-
|
||||
- Copyright 2010, 2013 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2019 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -10,6 +10,8 @@
|
|||
module Upgrade where
|
||||
|
||||
import Annex.Common
|
||||
import qualified Annex
|
||||
import qualified Git
|
||||
import Annex.Version
|
||||
import Types.RepoVersion
|
||||
#ifndef mingw32_HOST_OS
|
||||
|
@ -36,14 +38,23 @@ needsUpgrade v
|
|||
err "Upgrade this repository: git-annex upgrade"
|
||||
| otherwise ->
|
||||
err "Upgrade git-annex."
|
||||
Just newv -> ifM (upgrade True newv)
|
||||
( ok
|
||||
, err "Automatic upgrade failed!"
|
||||
Just newv -> ifM (annexAutoUpgradeRepository <$> Annex.getGitConfig)
|
||||
( tryNonAsync (upgrade True newv) >>= \case
|
||||
Right True -> ok
|
||||
Right False -> "Automatic upgrade failed!"
|
||||
Left err -> "Automatic upgrade exception! " ++ show err
|
||||
, err "Automatic upgrade is disabled by annex.autoupgraderepository configuration. To upgrade this repository: git-annex upgrade"
|
||||
)
|
||||
where
|
||||
err msg = return $ Just $ "Repository version " ++
|
||||
show (fromRepoVersion v) ++
|
||||
" is not supported. " ++ msg
|
||||
err msg = do
|
||||
g <- Annex.gitRepo
|
||||
p <- liftIO $ absPath $ Git.repoPath g
|
||||
return $ Just $ unwords
|
||||
[ "Repository", p
|
||||
, "is at unsupported version"
|
||||
, show (fromRepoVersion v) ++ "."
|
||||
, msg
|
||||
]
|
||||
ok = return Nothing
|
||||
|
||||
upgrade :: Bool -> RepoVersion -> Annex Bool
|
||||
|
@ -74,3 +85,4 @@ upgrade automatic destversion = do
|
|||
up (RepoVersion 5) = Upgrade.V5.upgrade automatic
|
||||
up (RepoVersion 6) = Upgrade.V6.upgrade automatic
|
||||
up _ = return True
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# NAME
|
||||
|
||||
git-annex upgrade - upgrade repository layout
|
||||
git-annex upgrade - upgrade repository
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
|
@ -8,13 +8,16 @@ git annex upgrade
|
|||
|
||||
# DESCRIPTION
|
||||
|
||||
Upgrades the repository to current layout.
|
||||
Upgrades the repository.
|
||||
|
||||
Each git-annex repository has an annex.version in its git configuration,
|
||||
that indicates the repository version. If git-annex changes to a new
|
||||
layout, you must upgrade the repository before git-annex can be used in it.
|
||||
that indicates the repository version. When an old repository version
|
||||
becomes deprecated, git-annex will automatically upgrade it
|
||||
(unless annex.autoupgraderepository is set to false). To manually upgrade,
|
||||
you can use this command.
|
||||
|
||||
To see version information, run `git annex version`.
|
||||
Sometimes there's a newer repository version that is not the default yet,
|
||||
and then you can use this command to upgrade to it.
|
||||
|
||||
Currently, git-annex supports upgrades all the way back to version 0, which
|
||||
was only used by its author. It's expected that git-annex will always
|
||||
|
|
|
@ -383,7 +383,7 @@ subdirectories).
|
|||
|
||||
* `upgrade`
|
||||
|
||||
Upgrades the repository to current layout.
|
||||
Upgrades the repository.
|
||||
|
||||
See [[git-annex-upgrade]](1) for details.
|
||||
|
||||
|
@ -1066,7 +1066,19 @@ Like other git commands, git-annex is configured via `.git/config`.
|
|||
|
||||
* `annex.version`
|
||||
|
||||
Automatically maintained, and used to automate upgrades between versions.
|
||||
The current version of the git-annex repository. This is
|
||||
maintained by git-annex and should never be manually changed.
|
||||
|
||||
* `annex.autoupgraderepository`
|
||||
|
||||
When an old git-annex repository version has become deprecated,
|
||||
git-annex will normally automatically upgrade the repository to
|
||||
the new version.
|
||||
|
||||
If this is set to false, git-annex won't automatically upgrade the
|
||||
repository. Instead it will exit with an error message. You can run
|
||||
`git annex upgrade` yourself when you are ready to upgrade the
|
||||
repository.
|
||||
|
||||
* `annex.crippledfilesystem`
|
||||
|
||||
|
|
Loading…
Reference in a new issue