2010-11-08 20:40:42 +00:00
|
|
|
{- git-annex repository versioning
|
|
|
|
-
|
2013-02-26 19:13:10 +00:00
|
|
|
- Copyright 2010,2013 Joey Hess <joey@kitenet.net>
|
2010-11-08 20:40:42 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
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
|
|
|
|
2011-10-05 20:02:51 +00:00
|
|
|
import Common.Annex
|
2011-03-28 01:43:25 +00:00
|
|
|
import Config
|
2013-01-01 17:52:47 +00:00
|
|
|
import qualified Annex
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2011-03-19 18:33:24 +00:00
|
|
|
type Version = String
|
|
|
|
|
|
|
|
defaultVersion :: Version
|
2011-06-21 18:34:08 +00:00
|
|
|
defaultVersion = "3"
|
2011-03-19 18:33:24 +00:00
|
|
|
|
2013-02-26 19:13:10 +00:00
|
|
|
directModeVersion :: Version
|
|
|
|
directModeVersion = "4"
|
|
|
|
|
2011-03-19 18:33:24 +00:00
|
|
|
supportedVersions :: [Version]
|
2013-02-26 19:13:10 +00:00
|
|
|
supportedVersions = [defaultVersion, directModeVersion]
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2011-03-19 22:33:39 +00:00
|
|
|
upgradableVersions :: [Version]
|
2013-05-11 20:03:00 +00:00
|
|
|
#ifndef __WINDOWS__
|
2011-06-21 18:34:08 +00:00
|
|
|
upgradableVersions = ["0", "1", "2"]
|
2013-05-11 20:03:00 +00:00
|
|
|
#else
|
|
|
|
upgradableVersions = ["2"]
|
|
|
|
#endif
|
2011-03-19 22:33:39 +00:00
|
|
|
|
2012-05-06 00:15:32 +00:00
|
|
|
versionField :: ConfigKey
|
|
|
|
versionField = annexConfig "version"
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2011-06-22 22:07:45 +00:00
|
|
|
getVersion :: Annex (Maybe Version)
|
2013-01-01 17:52:47 +00:00
|
|
|
getVersion = annexVersion <$> Annex.getGitConfig
|
2010-11-08 20:40:42 +00:00
|
|
|
|
2013-02-26 19:13:10 +00:00
|
|
|
setVersion :: Version -> Annex ()
|
|
|
|
setVersion = setConfig versionField
|
2011-03-19 22:33:39 +00:00
|
|
|
|
2012-10-07 20:04:03 +00:00
|
|
|
removeVersion :: Annex ()
|
|
|
|
removeVersion = unsetConfig versionField
|
|
|
|
|
2011-08-17 22:38:26 +00:00
|
|
|
checkVersion :: Version -> Annex ()
|
|
|
|
checkVersion v
|
2012-04-22 03:32:33 +00:00
|
|
|
| v `elem` supportedVersions = noop
|
2011-08-17 22:38:26 +00:00
|
|
|
| v `elem` upgradableVersions = err "Upgrade this repository: git-annex upgrade"
|
|
|
|
| otherwise = err "Upgrade git-annex."
|
2012-12-13 04:24:19 +00:00
|
|
|
where
|
|
|
|
err msg = error $ "Repository version " ++ v ++
|
|
|
|
" is not supported. " ++ msg
|