summaryrefslogtreecommitdiff
path: root/Upgrade.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-05 16:42:59 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-05 17:05:03 -0400
commit4f6c8222072ace33e3acedddd31637089ae474b6 (patch)
tree720d851820dd6ccc51e5393f2dc87818141ec2ed /Upgrade.hs
parentda9eea5dc0e86b4abb14064346eddc5689d94333 (diff)
v5 for direct mode, with automatic upgrade
This includes storing the current state of the HEAD ref, which git annex sync is going to need, but does not make sync use it.
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