From 9f87133bf5b67ed425df87f4c42f18a8e823a527 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 26 Oct 2018 11:44:05 -0400 Subject: [PATCH] snap --version= to auto-upgrade This makes --version=6 still work, despite v6 not being in supportedVersions. Which is useful for scripts that use it. I didn't document it on the man page, because it's indistinguishable from an automatic upgrade after initting as v6. --- CHANGELOG | 2 ++ Command/Init.hs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index e77c25f74a..ff25b44456 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -42,6 +42,8 @@ git-annex (7.20181025) UNRELEASED; urgency=medium get confused about whether a locked file's content was present. * Fix concurrency bug that occurred on the first download from an exporttree remote. + * init --version=6 will still work, but the repository is auto-upgraded + immediately to v7. -- Joey Hess Sat, 13 Oct 2018 00:52:02 -0400 diff --git a/Command/Init.hs b/Command/Init.hs index f0aed4dc04..8e239b5351 100644 --- a/Command/Init.hs +++ b/Command/Init.hs @@ -12,6 +12,8 @@ import Annex.Init import Annex.Version import Types.RepoVersion import qualified Annex.SpecialRemote + +import qualified Data.Map as M cmd :: Command cmd = dontCheck repoExists $ @@ -36,7 +38,9 @@ parseRepoVersion s = case RepoVersion <$> readish s of Nothing -> fail $ "version parse error" Just v | v `elem` supportedVersions -> return v - | otherwise -> fail $ s ++ " is not a currently supported repository version" + | otherwise -> case M.lookup v autoUpgradeableVersions of + Just v' -> return v' + Nothing -> fail $ s ++ " is not a currently supported repository version" seek :: InitOptions -> CommandSeek seek = commandAction . start