From 42710158e49f8460ac50b6a77d317b2f6cda4b57 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 15 Dec 2015 17:17:13 -0400 Subject: Use git-annex init --version=6 to get v6 for now Not ready to make it default because of the direct mode upgrade needing to all happen at once. --- Annex/Init.hs | 18 ++++++++++-------- Annex/MakeRepo.hs | 2 +- Annex/Version.hs | 9 ++++++--- Command/ConfigList.hs | 2 +- Command/Init.hs | 43 +++++++++++++++++++++++++++++++------------ Command/Reinit.hs | 2 +- Upgrade.hs | 2 +- Upgrade/V1.hs | 4 ++-- debian/changelog | 4 +++- doc/git-annex-init.mdwn | 7 +++++++ 10 files changed, 63 insertions(+), 30 deletions(-) diff --git a/Annex/Init.hs b/Annex/Init.hs index 997312c31..99bb03e92 100644 --- a/Annex/Init.hs +++ b/Annex/Init.hs @@ -57,8 +57,8 @@ genDescription Nothing = do return $ concat [hostname, ":", reldir] #endif -initialize :: Maybe String -> Annex () -initialize mdescription = do +initialize :: Maybe String -> Maybe Version -> Annex () +initialize mdescription mversion = do {- Has to come before any commits are made as the shared - clone heuristic expects no local objects. -} sharedclone <- checkSharedClone @@ -68,7 +68,7 @@ initialize mdescription = do ensureCommit $ Annex.Branch.create prepUUID - initialize' + initialize' mversion initSharedClone sharedclone @@ -77,16 +77,18 @@ initialize mdescription = do -- Everything except for uuid setup, shared clone setup, and initial -- description. -initialize' :: Annex () -initialize' = do +initialize' :: Maybe Version -> Annex () +initialize' mversion = do checkLockSupport checkFifoSupport checkCrippledFileSystem unlessM isBare $ hookWrite preCommitHook setDifferences - setVersion currentVersion - configureSmudgeFilter + unlessM (isJust <$> getVersion) $ + setVersion (fromMaybe defaultVersion mversion) + whenM versionSupportsUnlockedPointers + configureSmudgeFilter ifM (crippledFileSystem <&&> not <$> isBare) ( do enableDirectMode @@ -115,7 +117,7 @@ ensureInitialized :: Annex () ensureInitialized = getVersion >>= maybe needsinit checkUpgrade where needsinit = ifM Annex.Branch.hasSibling - ( initialize Nothing + ( initialize Nothing Nothing , error "First run: git-annex init" ) diff --git a/Annex/MakeRepo.hs b/Annex/MakeRepo.hs index 73443c43d..adf49ed2c 100644 --- a/Annex/MakeRepo.hs +++ b/Annex/MakeRepo.hs @@ -75,7 +75,7 @@ initRepo False _ dir desc mgroup = inDir dir $ do initRepo' :: Maybe String -> Maybe StandardGroup -> Annex () initRepo' desc mgroup = unlessM isInitialized $ do - initialize desc + initialize desc Nothing u <- getUUID maybe noop (defaultStandardGroup u) mgroup {- Ensure branch gets committed right away so it is diff --git a/Annex/Version.hs b/Annex/Version.hs index 4c2a990fa..b54fb68e0 100644 --- a/Annex/Version.hs +++ b/Annex/Version.hs @@ -15,11 +15,14 @@ import qualified Annex type Version = String -currentVersion :: Version -currentVersion = "6" +defaultVersion :: Version +defaultVersion = "5" + +latestVersion :: Version +latestVersion = "6" supportedVersions :: [Version] -supportedVersions = ["5", currentVersion] +supportedVersions = ["5", "6"] upgradableVersions :: [Version] #ifndef mingw32_HOST_OS diff --git a/Command/ConfigList.hs b/Command/ConfigList.hs index 46c909107..997016e8e 100644 --- a/Command/ConfigList.hs +++ b/Command/ConfigList.hs @@ -46,7 +46,7 @@ findOrGenUUID = do else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit)) ( do liftIO checkNotReadOnly - initialize Nothing + initialize Nothing Nothing getUUID , return NoUUID ) diff --git a/Command/Init.hs b/Command/Init.hs index d969669f8..94d8168a6 100644 --- a/Command/Init.hs +++ b/Command/Init.hs @@ -10,25 +10,44 @@ module Command.Init where import Common.Annex import Command import Annex.Init +import Annex.Version import qualified Annex.SpecialRemote cmd :: Command cmd = dontCheck repoExists $ command "init" SectionSetup "initialize git-annex" - paramDesc (withParams seek) + paramDesc (seek <$$> optParser) -seek :: CmdParams -> CommandSeek -seek = withWords start +data InitOptions = InitOptions + { initDesc :: String + , initVersion :: Maybe Version + } -start :: [String] -> CommandStart -start ws = do - showStart "init" description - next $ perform description - where - description = unwords ws +optParser :: CmdParamsDesc -> Parser InitOptions +optParser desc = InitOptions + <$> (unwords <$> cmdParams desc) + <*> optional (option (str >>= parseVersion) + ( long "version" <> metavar paramValue + <> help "Override default annex.version" + )) -perform :: String -> CommandPerform -perform description = do - initialize $ if null description then Nothing else Just description +parseVersion :: Monad m => String -> m Version +parseVersion v + | v `elem` supportedVersions = return v + | otherwise = fail $ v ++ " is not a currently supported repository version" + +seek :: InitOptions -> CommandSeek +seek = commandAction . start + +start :: InitOptions -> CommandStart +start os = do + showStart "init" (initDesc os) + next $ perform os + +perform :: InitOptions -> CommandPerform +perform os = do + initialize + (if null (initDesc os) then Nothing else Just (initDesc os)) + (initVersion os) Annex.SpecialRemote.autoEnable next $ return True diff --git a/Command/Reinit.hs b/Command/Reinit.hs index 1be692871..e2c00a3d2 100644 --- a/Command/Reinit.hs +++ b/Command/Reinit.hs @@ -38,6 +38,6 @@ perform s = do then return $ toUUID s else Remote.nameToUUID s storeUUID u - initialize' + initialize' Nothing Annex.SpecialRemote.autoEnable next $ return True diff --git a/Upgrade.hs b/Upgrade.hs index 1f4a8d8de..f9dfb7258 100644 --- a/Upgrade.hs +++ b/Upgrade.hs @@ -41,7 +41,7 @@ upgrade :: Bool -> Annex Bool upgrade automatic = do upgraded <- go =<< getVersion when upgraded $ - setVersion currentVersion + setVersion latestVersion return upgraded where #ifndef mingw32_HOST_OS diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs index bcf7e0b6d..507af9e3b 100644 --- a/Upgrade/V1.hs +++ b/Upgrade/V1.hs @@ -54,14 +54,14 @@ upgrade = do ifM (fromRepo Git.repoIsLocalBare) ( do moveContent - setVersion currentVersion + setVersion latestVersion , do moveContent updateSymlinks moveLocationLogs Annex.Queue.flush - setVersion currentVersion + setVersion latestVersion ) Upgrade.V2.upgrade diff --git a/debian/changelog b/debian/changelog index 21d875d1d..838b2d39c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ git-annex (6.20151225) unstable; urgency=medium - * annex.version increased to 6, but version 5 is also still supported. + * Added v6 repository mode, but v5 is still the default for now. * The upgrade to version 6 is not done fully automatically, because upgrading a direct mode repository to version 6 will prevent old versions of git-annex from working in other clones of that repository. @@ -12,6 +12,8 @@ git-annex (6.20151225) unstable; urgency=medium * unlock, lock: In v6 mode, unlocking a file changes it from a symlink to a pointer file, and this change can be committed to the git repository. * add: In v6 mode, adds modified files to the annex. + * init: --version parameter added to control which supported repository + version to use. -- Joey Hess Tue, 08 Dec 2015 11:14:03 -0400 diff --git a/doc/git-annex-init.mdwn b/doc/git-annex-init.mdwn index 145705105..29522181d 100644 --- a/doc/git-annex-init.mdwn +++ b/doc/git-annex-init.mdwn @@ -24,6 +24,13 @@ mark it as dead (see [[git-annex-dead]](1)). This command is entirely safe, although usually pointless, to run inside an already initialized git-annex repository. +# OPTIONS + +* `--version=N` + + Force the repository to be initialized using a different annex.version + than the current default. + # SEE ALSO [[git-annex]](1) -- cgit v1.2.3