2010-11-08 16:40:42 -04:00
|
|
|
{- git-annex repository versioning
|
|
|
|
-
|
2022-01-11 16:36:07 -04:00
|
|
|
- Copyright 2010-2022 Joey Hess <id@joeyh.name>
|
2010-11-08 16:40:42 -04:00
|
|
|
-
|
2018-10-25 17:23:53 -04:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2010-11-08 16:40:42 -04:00
|
|
|
-}
|
|
|
|
|
2013-05-11 15:03:00 -05:00
|
|
|
{-# LANGUAGE CPP #-}
|
2019-11-27 16:54:11 -04:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2013-05-11 15:03:00 -05:00
|
|
|
|
2011-10-04 00:40:47 -04:00
|
|
|
module Annex.Version where
|
2010-11-08 16:40:42 -04:00
|
|
|
|
2016-01-20 16:36:33 -04:00
|
|
|
import Annex.Common
|
2011-03-27 21:43:25 -04:00
|
|
|
import Config
|
2019-12-02 10:57:09 -04:00
|
|
|
import Git.Types
|
2018-10-25 17:23:53 -04:00
|
|
|
import Types.RepoVersion
|
2013-01-01 13:52:47 -04:00
|
|
|
import qualified Annex
|
2010-11-08 16:40:42 -04:00
|
|
|
|
2018-10-25 18:33:34 -04:00
|
|
|
import qualified Data.Map as M
|
|
|
|
|
2018-10-25 17:23:53 -04:00
|
|
|
defaultVersion :: RepoVersion
|
2022-07-25 16:09:11 -04:00
|
|
|
defaultVersion = RepoVersion 10
|
2011-03-19 14:33:24 -04:00
|
|
|
|
2018-10-25 17:23:53 -04:00
|
|
|
latestVersion :: RepoVersion
|
2022-01-19 13:06:31 -04:00
|
|
|
latestVersion = RepoVersion 10
|
2015-12-15 17:17:13 -04:00
|
|
|
|
2018-10-25 17:23:53 -04:00
|
|
|
supportedVersions :: [RepoVersion]
|
2022-01-20 11:56:05 -04:00
|
|
|
supportedVersions = map RepoVersion [8, 9, 10]
|
2018-12-03 12:57:23 -04:00
|
|
|
|
2022-01-19 12:14:50 -04:00
|
|
|
upgradeableVersions :: [RepoVersion]
|
2013-08-02 12:27:32 -04:00
|
|
|
#ifndef mingw32_HOST_OS
|
2022-01-19 13:06:31 -04:00
|
|
|
upgradeableVersions = map RepoVersion [0..10]
|
2013-05-11 15:03:00 -05:00
|
|
|
#else
|
2022-01-19 13:06:31 -04:00
|
|
|
upgradeableVersions = map RepoVersion [2..10]
|
2013-05-11 15:03:00 -05:00
|
|
|
#endif
|
2011-03-19 18:33:39 -04:00
|
|
|
|
2018-10-25 18:33:34 -04:00
|
|
|
autoUpgradeableVersions :: M.Map RepoVersion RepoVersion
|
|
|
|
autoUpgradeableVersions = M.fromList
|
2022-01-25 13:52:42 -04:00
|
|
|
[ (RepoVersion 3, defaultVersion)
|
|
|
|
, (RepoVersion 4, defaultVersion)
|
|
|
|
, (RepoVersion 5, defaultVersion)
|
|
|
|
, (RepoVersion 6, defaultVersion)
|
|
|
|
, (RepoVersion 7, defaultVersion)
|
|
|
|
, (RepoVersion 8, defaultVersion)
|
2022-07-25 16:09:11 -04:00
|
|
|
, (RepoVersion 9, defaultVersion)
|
2018-10-25 18:33:34 -04:00
|
|
|
]
|
2013-11-05 16:42:59 -04:00
|
|
|
|
2012-05-05 20:15:32 -04:00
|
|
|
versionField :: ConfigKey
|
|
|
|
versionField = annexConfig "version"
|
2010-11-08 16:40:42 -04:00
|
|
|
|
2018-10-25 17:23:53 -04:00
|
|
|
getVersion :: Annex (Maybe RepoVersion)
|
2013-01-01 13:52:47 -04:00
|
|
|
getVersion = annexVersion <$> Annex.getGitConfig
|
2010-11-08 16:40:42 -04:00
|
|
|
|
2018-10-25 17:23:53 -04:00
|
|
|
setVersion :: RepoVersion -> Annex ()
|
|
|
|
setVersion (RepoVersion v) = setConfig versionField (show v)
|
2011-03-19 18:33:39 -04:00
|
|
|
|
2012-10-07 16:04:03 -04:00
|
|
|
removeVersion :: Annex ()
|
|
|
|
removeVersion = unsetConfig versionField
|
2022-01-11 16:36:07 -04:00
|
|
|
|
enable filter.annex.process in v9
This has tradeoffs, but is generally a win, and users who it causes git add to
slow down unacceptably for can just disable it again.
It needed to happen in an upgrade, since there are git-annex versions
that do not support it, and using such an old version with a v8
repository with filter.annex.process set will cause bad behavior.
By enabling it in v9, it's guaranteed that any git-annex version that
can use the repository does support it. Although, this is not a perfect
protection against problems, since an old git-annex version, if it's
used with a v9 repository, will cause git add to try to run
git-annex filter-process, which will fail. But at least, the user is
unlikely to have an old git-annex in path if they are using a v9
repository, since it won't work in that repository.
Sponsored-by: Dartmouth College's Datalad project
2022-01-21 13:11:18 -04:00
|
|
|
versionSupportsFilterProcess :: Maybe RepoVersion -> Bool
|
|
|
|
versionSupportsFilterProcess (Just v)
|
|
|
|
| v >= RepoVersion 9 = True
|
|
|
|
versionSupportsFilterProcess _ = False
|
|
|
|
|
2022-01-11 16:36:07 -04:00
|
|
|
versionNeedsWritableContentFiles :: Maybe RepoVersion -> Bool
|
|
|
|
versionNeedsWritableContentFiles (Just v)
|
2022-01-19 13:06:31 -04:00
|
|
|
| v >= RepoVersion 10 = False
|
2022-01-11 16:36:07 -04:00
|
|
|
versionNeedsWritableContentFiles _ = True
|