Use git-annex init --version=6 to get v6 for now
authorJoey Hess <joeyh@joeyh.name>
Tue, 15 Dec 2015 21:17:13 +0000 (17:17 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 15 Dec 2015 21:17:13 +0000 (17:17 -0400)
Not ready to make it default because of the direct mode upgrade needing to
all happen at once.

Annex/Init.hs
Annex/MakeRepo.hs
Annex/Version.hs
Command/ConfigList.hs
Command/Init.hs
Command/Reinit.hs
Upgrade.hs
Upgrade/V1.hs
debian/changelog
doc/git-annex-init.mdwn

index 997312c31e50112d371faec55fed10d3107268eb..99bb03e929710c9fa420b328ade3cc37d0ac134a 100644 (file)
@@ -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"
                        )
 
index 73443c43d91e21191c80bb4db33dc1df3b9df56d..adf49ed2c4c5400dd127a6cad3b5817464b8b58a 100644 (file)
@@ -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
index 4c2a990fa8dd649d4a5ef9718083fe34a7a87ca6..b54fb68e075932f6934294e3824988b8bb830813 100644 (file)
@@ -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
index 46c909107b5de26f89a536e1ee4bed4baf880bba..997016e8e3e8d1bad3be967f3b1d8584c8137a7f 100644 (file)
@@ -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
                        )
index d969669f81a5e2eac5edbfd6ffa9a6a2ac9d2793..94d8168a67911eb771cbce24186e1d4ee6a35279 100644 (file)
@@ -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
index 1be692871d00d048e47f8568f8b91014ac0c7be5..e2c00a3d29f42a502339ed4bbc0eefd270118014 100644 (file)
@@ -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
index 1f4a8d8dec3f1c0b1f8985f14a178d7f33a1beaa..f9dfb72589ec316b45f8f8b0390ac49f5b0c76e4 100644 (file)
@@ -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
index bcf7e0b6de0f50033805b1aff292a4d48d4e4696..507af9e3b3fde7626d1fc6d16d86e0e8a2209fe7 100644 (file)
@@ -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
index 21d875d1d89bed8eb348858405c6a49ac72d33b7..838b2d39cc9486d1d510ffb976b8be7e2592d56f 100644 (file)
@@ -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 <id@joeyh.name>  Tue, 08 Dec 2015 11:14:03 -0400
 
index 1457051057d09be05b116cf39994fc910418116b..29522181dc9c15993b15c5d2f2fef2e4bf837514 100644 (file)
@@ -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)