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.
This commit is contained in:
Joey Hess 2015-12-15 17:17:13 -04:00
parent b9588fe69e
commit 7d0e79b9e1
Failed to extract signature
10 changed files with 63 additions and 30 deletions

View file

@ -57,8 +57,8 @@ genDescription Nothing = do
return $ concat [hostname, ":", reldir] return $ concat [hostname, ":", reldir]
#endif #endif
initialize :: Maybe String -> Annex () initialize :: Maybe String -> Maybe Version -> Annex ()
initialize mdescription = do initialize mdescription mversion = do
{- Has to come before any commits are made as the shared {- Has to come before any commits are made as the shared
- clone heuristic expects no local objects. -} - clone heuristic expects no local objects. -}
sharedclone <- checkSharedClone sharedclone <- checkSharedClone
@ -68,7 +68,7 @@ initialize mdescription = do
ensureCommit $ Annex.Branch.create ensureCommit $ Annex.Branch.create
prepUUID prepUUID
initialize' initialize' mversion
initSharedClone sharedclone initSharedClone sharedclone
@ -77,16 +77,18 @@ initialize mdescription = do
-- Everything except for uuid setup, shared clone setup, and initial -- Everything except for uuid setup, shared clone setup, and initial
-- description. -- description.
initialize' :: Annex () initialize' :: Maybe Version -> Annex ()
initialize' = do initialize' mversion = do
checkLockSupport checkLockSupport
checkFifoSupport checkFifoSupport
checkCrippledFileSystem checkCrippledFileSystem
unlessM isBare $ unlessM isBare $
hookWrite preCommitHook hookWrite preCommitHook
setDifferences setDifferences
setVersion currentVersion unlessM (isJust <$> getVersion) $
configureSmudgeFilter setVersion (fromMaybe defaultVersion mversion)
whenM versionSupportsUnlockedPointers
configureSmudgeFilter
ifM (crippledFileSystem <&&> not <$> isBare) ifM (crippledFileSystem <&&> not <$> isBare)
( do ( do
enableDirectMode enableDirectMode
@ -115,7 +117,7 @@ ensureInitialized :: Annex ()
ensureInitialized = getVersion >>= maybe needsinit checkUpgrade ensureInitialized = getVersion >>= maybe needsinit checkUpgrade
where where
needsinit = ifM Annex.Branch.hasSibling needsinit = ifM Annex.Branch.hasSibling
( initialize Nothing ( initialize Nothing Nothing
, error "First run: git-annex init" , error "First run: git-annex init"
) )

View file

@ -75,7 +75,7 @@ initRepo False _ dir desc mgroup = inDir dir $ do
initRepo' :: Maybe String -> Maybe StandardGroup -> Annex () initRepo' :: Maybe String -> Maybe StandardGroup -> Annex ()
initRepo' desc mgroup = unlessM isInitialized $ do initRepo' desc mgroup = unlessM isInitialized $ do
initialize desc initialize desc Nothing
u <- getUUID u <- getUUID
maybe noop (defaultStandardGroup u) mgroup maybe noop (defaultStandardGroup u) mgroup
{- Ensure branch gets committed right away so it is {- Ensure branch gets committed right away so it is

View file

@ -15,11 +15,14 @@ import qualified Annex
type Version = String type Version = String
currentVersion :: Version defaultVersion :: Version
currentVersion = "6" defaultVersion = "5"
latestVersion :: Version
latestVersion = "6"
supportedVersions :: [Version] supportedVersions :: [Version]
supportedVersions = ["5", currentVersion] supportedVersions = ["5", "6"]
upgradableVersions :: [Version] upgradableVersions :: [Version]
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS

View file

@ -46,7 +46,7 @@ findOrGenUUID = do
else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit)) else ifM (Annex.Branch.hasSibling <||> (isJust <$> Fields.getField Fields.autoInit))
( do ( do
liftIO checkNotReadOnly liftIO checkNotReadOnly
initialize Nothing initialize Nothing Nothing
getUUID getUUID
, return NoUUID , return NoUUID
) )

View file

@ -10,25 +10,44 @@ module Command.Init where
import Common.Annex import Common.Annex
import Command import Command
import Annex.Init import Annex.Init
import Annex.Version
import qualified Annex.SpecialRemote import qualified Annex.SpecialRemote
cmd :: Command cmd :: Command
cmd = dontCheck repoExists $ cmd = dontCheck repoExists $
command "init" SectionSetup "initialize git-annex" command "init" SectionSetup "initialize git-annex"
paramDesc (withParams seek) paramDesc (seek <$$> optParser)
seek :: CmdParams -> CommandSeek data InitOptions = InitOptions
seek = withWords start { initDesc :: String
, initVersion :: Maybe Version
}
start :: [String] -> CommandStart optParser :: CmdParamsDesc -> Parser InitOptions
start ws = do optParser desc = InitOptions
showStart "init" description <$> (unwords <$> cmdParams desc)
next $ perform description <*> optional (option (str >>= parseVersion)
where ( long "version" <> metavar paramValue
description = unwords ws <> help "Override default annex.version"
))
perform :: String -> CommandPerform parseVersion :: Monad m => String -> m Version
perform description = do parseVersion v
initialize $ if null description then Nothing else Just description | 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 Annex.SpecialRemote.autoEnable
next $ return True next $ return True

View file

@ -38,6 +38,6 @@ perform s = do
then return $ toUUID s then return $ toUUID s
else Remote.nameToUUID s else Remote.nameToUUID s
storeUUID u storeUUID u
initialize' initialize' Nothing
Annex.SpecialRemote.autoEnable Annex.SpecialRemote.autoEnable
next $ return True next $ return True

View file

@ -41,7 +41,7 @@ upgrade :: Bool -> Annex Bool
upgrade automatic = do upgrade automatic = do
upgraded <- go =<< getVersion upgraded <- go =<< getVersion
when upgraded $ when upgraded $
setVersion currentVersion setVersion latestVersion
return upgraded return upgraded
where where
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS

View file

@ -54,14 +54,14 @@ upgrade = do
ifM (fromRepo Git.repoIsLocalBare) ifM (fromRepo Git.repoIsLocalBare)
( do ( do
moveContent moveContent
setVersion currentVersion setVersion latestVersion
, do , do
moveContent moveContent
updateSymlinks updateSymlinks
moveLocationLogs moveLocationLogs
Annex.Queue.flush Annex.Queue.flush
setVersion currentVersion setVersion latestVersion
) )
Upgrade.V2.upgrade Upgrade.V2.upgrade

4
debian/changelog vendored
View file

@ -1,6 +1,6 @@
git-annex (6.20151225) unstable; urgency=medium 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 * The upgrade to version 6 is not done fully automatically, because
upgrading a direct mode repository to version 6 will prevent old upgrading a direct mode repository to version 6 will prevent old
versions of git-annex from working in other clones of that repository. 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 * 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. pointer file, and this change can be committed to the git repository.
* add: In v6 mode, adds modified files to the annex. * 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 -- Joey Hess <id@joeyh.name> Tue, 08 Dec 2015 11:14:03 -0400

View 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 This command is entirely safe, although usually pointless, to run inside an
already initialized git-annex repository. 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 # SEE ALSO
[[git-annex]](1) [[git-annex]](1)