Auto-upgrade v3 indirect repos to v5 with no changes. This also fixes a problem when a direct mode repo was somehow set to v3 rather than v4, and so the automatic direct mode upgrade to v5 was not done.
This commit is contained in:
parent
7f6685c16e
commit
b1d7474c1d
9 changed files with 18 additions and 29 deletions
|
@ -15,24 +15,18 @@ import qualified Annex
|
|||
|
||||
type Version = String
|
||||
|
||||
defaultVersion :: Version
|
||||
defaultVersion = "3"
|
||||
|
||||
directModeVersion :: Version
|
||||
directModeVersion = "5"
|
||||
|
||||
supportedVersions :: [Version]
|
||||
supportedVersions = [defaultVersion, directModeVersion]
|
||||
supportedVersion :: Version
|
||||
supportedVersion = "5"
|
||||
|
||||
upgradableVersions :: [Version]
|
||||
#ifndef mingw32_HOST_OS
|
||||
upgradableVersions = ["0", "1", "2", "4"]
|
||||
#else
|
||||
upgradableVersions = ["2", "4"]
|
||||
upgradableVersions = ["2", "3", "4"]
|
||||
#endif
|
||||
|
||||
autoUpgradeableVersions :: [Version]
|
||||
autoUpgradeableVersions = ["4"]
|
||||
autoUpgradeableVersions = ["3", "4"]
|
||||
|
||||
versionField :: ConfigKey
|
||||
versionField = annexConfig "version"
|
||||
|
|
|
@ -16,7 +16,6 @@ import qualified Git.Command
|
|||
import qualified Git.LsFiles
|
||||
import Config
|
||||
import Annex.Direct
|
||||
import Annex.Version
|
||||
import Annex.Exception
|
||||
|
||||
def :: [Command]
|
||||
|
@ -69,5 +68,4 @@ cleanup :: CommandCleanup
|
|||
cleanup = do
|
||||
showStart "direct" ""
|
||||
setDirect True
|
||||
setVersion directModeVersion
|
||||
return True
|
||||
|
|
|
@ -22,7 +22,6 @@ import Annex.Direct
|
|||
import Annex.Content
|
||||
import Annex.Content.Direct
|
||||
import Annex.CatFile
|
||||
import Annex.Version
|
||||
import Annex.Exception
|
||||
import Init
|
||||
import qualified Command.Add
|
||||
|
@ -107,7 +106,6 @@ perform = do
|
|||
|
||||
cleanup :: CommandCleanup
|
||||
cleanup = do
|
||||
setVersion defaultVersion
|
||||
showStart "indirect" ""
|
||||
showEndOk
|
||||
return True
|
||||
|
|
|
@ -30,9 +30,7 @@ start = do
|
|||
liftIO $ do
|
||||
showPackageVersion
|
||||
info "local repository version" $ fromMaybe "unknown" v
|
||||
info "default repository version" defaultVersion
|
||||
info "supported repository versions" $
|
||||
unwords supportedVersions
|
||||
info "supported repository version" supportedVersion
|
||||
info "upgrade supported from repository versions" $
|
||||
unwords upgradableVersions
|
||||
stop
|
||||
|
|
3
Init.hs
3
Init.hs
|
@ -65,13 +65,12 @@ initialize mdescription = do
|
|||
checkCrippledFileSystem
|
||||
unlessM isBare $
|
||||
hookWrite preCommitHook
|
||||
setVersion supportedVersion
|
||||
ifM (crippledFileSystem <&&> not <$> isBare)
|
||||
( do
|
||||
enableDirectMode
|
||||
setDirect True
|
||||
setVersion directModeVersion
|
||||
, do
|
||||
setVersion defaultVersion
|
||||
-- Handle case where this repo was cloned from a
|
||||
-- direct mode repo.
|
||||
unlessM isBare
|
||||
|
|
10
Upgrade.hs
10
Upgrade.hs
|
@ -11,12 +11,12 @@ module Upgrade where
|
|||
|
||||
import Common.Annex
|
||||
import Annex.Version
|
||||
import Config
|
||||
#ifndef mingw32_HOST_OS
|
||||
import qualified Upgrade.V0
|
||||
import qualified Upgrade.V1
|
||||
#endif
|
||||
import qualified Upgrade.V2
|
||||
import qualified Upgrade.V3
|
||||
import qualified Upgrade.V4
|
||||
|
||||
checkUpgrade :: Version -> Annex ()
|
||||
|
@ -24,7 +24,7 @@ checkUpgrade = maybe noop error <=< needsUpgrade
|
|||
|
||||
needsUpgrade :: Version -> Annex (Maybe String)
|
||||
needsUpgrade v
|
||||
| v `elem` supportedVersions = ok
|
||||
| v == supportedVersion = ok
|
||||
| v `elem` autoUpgradeableVersions = ifM (upgrade True)
|
||||
( ok
|
||||
, err "Automatic upgrade failed!"
|
||||
|
@ -40,10 +40,7 @@ upgrade :: Bool -> Annex Bool
|
|||
upgrade automatic = do
|
||||
upgraded <- go =<< getVersion
|
||||
when upgraded $
|
||||
ifM isDirect
|
||||
( setVersion directModeVersion
|
||||
, setVersion defaultVersion
|
||||
)
|
||||
setVersion supportedVersion
|
||||
return upgraded
|
||||
where
|
||||
#ifndef mingw32_HOST_OS
|
||||
|
@ -54,5 +51,6 @@ upgrade automatic = do
|
|||
go (Just "1") = error "upgrade from v1 on Windows not supported"
|
||||
#endif
|
||||
go (Just "2") = Upgrade.V2.upgrade
|
||||
go (Just "3") = Upgrade.V3.upgrade automatic
|
||||
go (Just "4") = Upgrade.V4.upgrade automatic
|
||||
go _ = return True
|
||||
|
|
|
@ -53,14 +53,14 @@ upgrade = do
|
|||
ifM (fromRepo Git.repoIsLocalBare)
|
||||
( do
|
||||
moveContent
|
||||
setVersion defaultVersion
|
||||
setVersion supportedVersion
|
||||
, do
|
||||
moveContent
|
||||
updateSymlinks
|
||||
moveLocationLogs
|
||||
|
||||
Annex.Queue.flush
|
||||
setVersion defaultVersion
|
||||
setVersion supportedVersion
|
||||
)
|
||||
|
||||
Upgrade.V2.upgrade
|
||||
|
|
|
@ -11,7 +11,7 @@ import Common.Annex
|
|||
import Config
|
||||
import Annex.Direct
|
||||
|
||||
{- Direct mode only upgrade. -}
|
||||
{- Direct mode only upgrade. v4 to v5 indirect update is a no-op -}
|
||||
upgrade :: Bool -> Annex Bool
|
||||
upgrade automatic = ifM isDirect
|
||||
( do
|
||||
|
@ -19,5 +19,5 @@ upgrade automatic = ifM isDirect
|
|||
showAction "v4 to v5"
|
||||
setDirect True
|
||||
return True
|
||||
, return False
|
||||
, return True
|
||||
)
|
||||
|
|
4
debian/changelog
vendored
4
debian/changelog
vendored
|
@ -10,6 +10,10 @@ git-annex (5.20131222) UNRELEASED; urgency=medium
|
|||
* Added new external special remote interface.
|
||||
* addurl, importfeed: Sanitize | and some other symbols and special
|
||||
characters.
|
||||
* Auto-upgrade v3 indirect repos to v5 with no changes.
|
||||
This also fixes a problem when a direct mode repo was somehow set to v3
|
||||
rather than v4, and so the automatic direct mode upgrade to v5 was not
|
||||
done.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Tue, 24 Dec 2013 13:54:32 -0400
|
||||
|
||||
|
|
Loading…
Reference in a new issue