summaryrefslogtreecommitdiff
path: root/Upgrade.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-14 17:04:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-14 17:04:58 -0400
commit521ef9dfebd6a9418a5dce7d1686dbf353ddd0a0 (patch)
treeafe6bb5d52e21a049f04020ae448afb81adc02a7 /Upgrade.hs
parentf4b4f327b69189d24663a7db6407c1f7a6e48fdd (diff)
parent5c6f6e4d0abb9b4856908a500611044b3b7a48e6 (diff)
Merge branch 'master' into tasty-tests
Conflicts: Test.hs
Diffstat (limited to 'Upgrade.hs')
-rw-r--r--Upgrade.hs17
1 files changed, 15 insertions, 2 deletions
diff --git a/Upgrade.hs b/Upgrade.hs
index f0166bf8e..59cca3fe4 100644
--- a/Upgrade.hs
+++ b/Upgrade.hs
@@ -16,9 +16,21 @@ import qualified Upgrade.V0
import qualified Upgrade.V1
#endif
import qualified Upgrade.V2
+import qualified Upgrade.V4
-upgrade :: Annex Bool
-upgrade = go =<< getVersion
+checkUpgrade :: Version -> Annex ()
+checkUpgrade v
+ | v `elem` supportedVersions = noop
+ | v `elem` autoUpgradeableVersions = unlessM (upgrade True) $
+ err "Automatic upgrade failed!"
+ | v `elem` upgradableVersions = err "Upgrade this repository: git-annex upgrade"
+ | otherwise = err "Upgrade git-annex."
+ where
+ err msg = error $ "Repository version " ++ v ++
+ " is not supported. " ++ msg
+
+upgrade :: Bool -> Annex Bool
+upgrade automatic = go =<< getVersion
where
#ifndef mingw32_HOST_OS
go (Just "0") = Upgrade.V0.upgrade
@@ -28,4 +40,5 @@ upgrade = go =<< getVersion
go (Just "1") = error "upgrade from v1 on Windows not supported"
#endif
go (Just "2") = Upgrade.V2.upgrade
+ go (Just "4") = Upgrade.V4.upgrade automatic
go _ = return True