2010-11-08 20:40:42 +00:00
|
|
|
{- git-annex repository versioning
|
|
|
|
-
|
2018-10-25 21:23:53 +00:00
|
|
|
- Copyright 2010-2018 Joey Hess <id@joeyh.name>
|
2010-11-08 20:40:42 +00:00
|
|
|
-
|
2018-10-25 21:23:53 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2010-11-08 20:40:42 +00:00
|
|
|
-}
|
|
|
|
|
2013-05-11 20:03:00 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
2011-10-04 04:40:47 +00:00
|
|
|
module Annex.Version where
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2016-01-20 20:36:33 +00:00
|
|
|
import Annex.Common
|
2011-03-28 01:43:25 +00:00
|
|
|
import Config
|
2018-10-25 21:23:53 +00:00
|
|
|
import Types.RepoVersion
|
2013-01-01 17:52:47 +00:00
|
|
|
import qualified Annex
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2018-10-25 22:33:34 +00:00
|
|
|
import qualified Data.Map as M
|
|
|
|
|
2018-10-25 21:23:53 +00:00
|
|
|
defaultVersion :: RepoVersion
|
|
|
|
defaultVersion = RepoVersion 5
|
2011-03-19 18:33:24 +00:00
|
|
|
|
2018-10-25 21:23:53 +00:00
|
|
|
latestVersion :: RepoVersion
|
|
|
|
latestVersion = RepoVersion 7
|
2015-12-15 21:17:13 +00:00
|
|
|
|
2018-10-25 21:23:53 +00:00
|
|
|
supportedVersions :: [RepoVersion]
|
2018-10-25 22:50:44 +00:00
|
|
|
supportedVersions = map RepoVersion [5, 7]
|
2015-12-04 20:14:48 +00:00
|
|
|
|
2018-10-25 21:23:53 +00:00
|
|
|
versionForAdjustedClone :: RepoVersion
|
2018-10-25 22:46:16 +00:00
|
|
|
versionForAdjustedClone = RepoVersion 7
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2018-12-03 16:57:23 +00:00
|
|
|
versionForCrippledFilesystem :: RepoVersion
|
|
|
|
versionForCrippledFilesystem = RepoVersion 7
|
|
|
|
|
2018-10-25 21:23:53 +00:00
|
|
|
upgradableVersions :: [RepoVersion]
|
2013-08-02 16:27:32 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2018-10-25 21:23:53 +00:00
|
|
|
upgradableVersions = map RepoVersion [0..6]
|
2013-05-11 20:03:00 +00:00
|
|
|
#else
|
2018-10-25 21:23:53 +00:00
|
|
|
upgradableVersions = map RepoVersion [2..6]
|
2013-05-11 20:03:00 +00:00
|
|
|
#endif
|
2011-03-19 22:33:39 +00:00
|
|
|
|
2018-10-25 22:33:34 +00:00
|
|
|
autoUpgradeableVersions :: M.Map RepoVersion RepoVersion
|
|
|
|
autoUpgradeableVersions = M.fromList
|
|
|
|
[ (RepoVersion 3, RepoVersion 5)
|
|
|
|
, (RepoVersion 4, RepoVersion 5)
|
|
|
|
, (RepoVersion 6, RepoVersion 7)
|
|
|
|
]
|
2013-11-05 20:42:59 +00:00
|
|
|
|
2012-05-06 00:15:32 +00:00
|
|
|
versionField :: ConfigKey
|
|
|
|
versionField = annexConfig "version"
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2018-10-25 21:23:53 +00:00
|
|
|
getVersion :: Annex (Maybe RepoVersion)
|
2013-01-01 17:52:47 +00:00
|
|
|
getVersion = annexVersion <$> Annex.getGitConfig
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2015-12-04 20:29:27 +00:00
|
|
|
versionSupportsDirectMode :: Annex Bool
|
|
|
|
versionSupportsDirectMode = go <$> getVersion
|
|
|
|
where
|
2018-10-25 21:23:53 +00:00
|
|
|
go (Just v) | v >= RepoVersion 6 = False
|
2015-12-04 20:29:27 +00:00
|
|
|
go _ = True
|
|
|
|
|
2015-12-09 19:18:25 +00:00
|
|
|
versionSupportsUnlockedPointers :: Annex Bool
|
|
|
|
versionSupportsUnlockedPointers = go <$> getVersion
|
|
|
|
where
|
2018-10-25 21:23:53 +00:00
|
|
|
go (Just v) | v >= RepoVersion 6 = True
|
2015-12-09 19:18:25 +00:00
|
|
|
go _ = False
|
|
|
|
|
2016-03-29 16:05:02 +00:00
|
|
|
versionSupportsAdjustedBranch :: Annex Bool
|
|
|
|
versionSupportsAdjustedBranch = versionSupportsUnlockedPointers
|
|
|
|
|
2016-07-19 16:12:19 +00:00
|
|
|
versionUsesKeysDatabase :: Annex Bool
|
|
|
|
versionUsesKeysDatabase = versionSupportsUnlockedPointers
|
|
|
|
|
2018-10-25 21:23:53 +00:00
|
|
|
setVersion :: RepoVersion -> Annex ()
|
|
|
|
setVersion (RepoVersion v) = setConfig versionField (show v)
|
2011-03-19 22:33:39 +00:00
|
|
|
|
2012-10-07 20:04:03 +00:00
|
|
|
removeVersion :: Annex ()
|
|
|
|
removeVersion = unsetConfig versionField
|