summaryrefslogtreecommitdiff
path: root/Version.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Version.hs')
-rw-r--r--Version.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/Version.hs b/Version.hs
index d4a58d77a..d061a2eab 100644
--- a/Version.hs
+++ b/Version.hs
@@ -8,6 +8,7 @@
module Version where
import Control.Monad.State (liftIO)
+import Control.Monad (unless)
import System.Directory
import Types
@@ -23,6 +24,9 @@ defaultVersion = "2"
supportedVersions :: [Version]
supportedVersions = [defaultVersion]
+upgradableVersions :: [Version]
+upgradableVersions = ["0", "1"]
+
versionField :: String
versionField = "annex.version"
@@ -51,3 +55,15 @@ getVersion = do
setVersion :: Annex ()
setVersion = Annex.setConfig versionField defaultVersion
+
+checkVersion :: Annex ()
+checkVersion = do
+ v <- getVersion
+ unless (v `elem` supportedVersions) $ do
+ error $ "Repository version " ++ v ++
+ " is not supported. " ++
+ msg v
+ where
+ msg v
+ | v `elem` upgradableVersions = "Upgrade this repository: git-annex upgrade"
+ | otherwise = "Upgrade git-annex."