v7 for all repositories

* Default to v7 for new repositories.
* Automatically upgrade v5 repositories to v7.
This commit is contained in:
Joey Hess 2019-08-30 13:54:57 -04:00
parent 1558e03014
commit 3f0eef4baa
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
29 changed files with 127 additions and 482 deletions

View file

@ -26,7 +26,6 @@ module Annex.AdjustedBranch (
propigateAdjustedCommits,
AdjustedClone(..),
checkAdjustedClone,
isSupported,
checkVersionSupported,
isGitVersionSupported,
) where
@ -50,7 +49,6 @@ import Git.Index
import Git.FilePath
import qualified Git.LockFile
import qualified Git.Version
import Annex.Version
import Annex.CatFile
import Annex.Link
import Annex.AutoMerge
@ -572,7 +570,7 @@ diffTreeToTreeItem dti = TreeItem
(Git.DiffTree.dstmode dti)
(Git.DiffTree.dstsha dti)
data AdjustedClone = InAdjustedClone | NotInAdjustedClone | NeedUpgradeForAdjustedClone
data AdjustedClone = InAdjustedClone | NotInAdjustedClone
{- Cloning a repository that has an adjusted branch checked out will
- result in the clone having the same adjusted branch checked out -- but
@ -611,18 +609,10 @@ checkAdjustedClone = ifM isBareRepo
case aps of
Just [p] -> setBasisBranch basis p
_ -> giveup $ "Unable to clean up from clone of adjusted branch; perhaps you should check out " ++ Git.Ref.describe origbranch
ifM versionSupportsUnlockedPointers
( return InAdjustedClone
, return NeedUpgradeForAdjustedClone
)
isSupported :: Annex Bool
isSupported = versionSupportsAdjustedBranch <&&> liftIO isGitVersionSupported
return InAdjustedClone
checkVersionSupported :: Annex ()
checkVersionSupported = do
unlessM versionSupportsAdjustedBranch $
giveup "Adjusted branches are only supported in v6 or newer repositories."
checkVersionSupported =
unlessM (liftIO isGitVersionSupported) $
giveup "Your version of git is too old; upgrade it to 2.2.0 or newer to use adjusted branches."

View file

@ -31,7 +31,6 @@ import Annex.Perms
import Annex.Link
import Annex.MetaData
import Annex.CurrentBranch
import Annex.Version
import Logs.Location
import qualified Annex
import qualified Annex.Queue
@ -308,11 +307,9 @@ forceParams = ifM (Annex.getState Annex.force)
-}
addUnlocked :: Annex Bool
addUnlocked =
(versionSupportsUnlockedPointers <&&>
((not . coreSymlinks <$> Annex.getGitConfig) <||>
(annexAddUnlocked <$> Annex.getGitConfig) <||>
(maybe False isadjustedunlocked . snd <$> getCurrentBranch)
)
((not . coreSymlinks <$> Annex.getGitConfig) <||>
(annexAddUnlocked <$> Annex.getGitConfig) <||>
(maybe False isadjustedunlocked . snd <$> getCurrentBranch)
)
where
isadjustedunlocked (LinkAdjustment UnlockAdjustment) = True

View file

@ -100,26 +100,20 @@ initialize' :: Maybe RepoVersion -> Annex ()
initialize' mversion = checkCanInitialize $ do
checkLockSupport
checkFifoSupport
checkCrippledFileSystem mversion
checkCrippledFileSystem
unlessM isBareRepo $ do
hookWrite preCommitHook
hookWrite postReceiveHook
setDifferences
unlessM (isJust <$> getVersion) $
ifM (crippledFileSystem <&&> (not <$> isBareRepo))
( setVersion (fromMaybe versionForCrippledFilesystem mversion)
, setVersion (fromMaybe defaultVersion mversion)
)
whenM versionSupportsUnlockedPointers $ do
configureSmudgeFilter
showSideAction "scanning for unlocked files"
scanUnlockedFiles True
unlessM isBareRepo $ do
hookWrite postCheckoutHook
hookWrite postMergeHook
setVersion (fromMaybe defaultVersion mversion)
configureSmudgeFilter
showSideAction "scanning for unlocked files"
scanUnlockedFiles True
unlessM isBareRepo $ do
hookWrite postCheckoutHook
hookWrite postMergeHook
AdjustedBranch.checkAdjustedClone >>= \case
AdjustedBranch.NeedUpgradeForAdjustedClone ->
void $ upgrade True versionForAdjustedClone
AdjustedBranch.InAdjustedClone -> return ()
AdjustedBranch.NotInAdjustedClone ->
ifM (crippledFileSystem <&&> (not <$> isBareRepo))
@ -147,12 +141,12 @@ uninitialize = do
- Checks repository version and handles upgrades too.
-}
ensureInitialized :: Annex ()
ensureInitialized = do
getVersion >>= maybe needsinit checkUpgrade
whenM isDirect $
unlessM (catchBoolIO $ upgrade True versionForAdjustedBranch) $ do
g <- Annex.gitRepo
giveup $ "Upgrading direct mode repository " ++ Git.repoDescribe g ++ " failed, and direct mode is no longer supported."
ensureInitialized = ifM isDirect
( unlessM (catchBoolIO $ upgrade True defaultVersion) $ do
g <- Annex.gitRepo
giveup $ "Upgrading direct mode repository " ++ Git.repoDescribe g ++ " failed, and direct mode is no longer supported."
, getVersion >>= maybe needsinit checkUpgrade
)
where
needsinit = ifM Annex.Branch.hasSibling
( initialize Nothing Nothing
@ -204,15 +198,9 @@ probeCrippledFileSystem' tmp = do
)
#endif
checkCrippledFileSystem :: Maybe RepoVersion -> Annex ()
checkCrippledFileSystem mversion = whenM probeCrippledFileSystem $ do
checkCrippledFileSystem :: Annex ()
checkCrippledFileSystem = whenM probeCrippledFileSystem $ do
warning "Detected a crippled filesystem."
unlessM isBareRepo $ case mversion of
Just ver | ver < versionForCrippledFilesystem ->
giveup $ "Cannot use repo version " ++ show (fromRepoVersion ver) ++ " in a crippled filesystem."
_ -> noop
setCrippledFileSystem True
{- Normally git disables core.symlinks itself when the

View file

@ -9,7 +9,6 @@ module Annex.UpdateInstead where
import qualified Annex
import Annex.Common
import Annex.Version
import Annex.AdjustedBranch
import Git.Branch
import Git.ConfigTypes
@ -21,5 +20,4 @@ needUpdateInsteadEmulation = updateinsteadset <&&> isadjusted
where
updateinsteadset = (== UpdateInstead) . receiveDenyCurrentBranch
<$> Annex.getGitConfig
isadjusted = versionSupportsUnlockedPointers
<&&> (maybe False (isJust . getAdjustment) <$> inRepo Git.Branch.current)
isadjusted = (maybe False (isJust . getAdjustment) <$> inRepo Git.Branch.current)

View file

@ -17,22 +17,13 @@ import qualified Annex
import qualified Data.Map as M
defaultVersion :: RepoVersion
defaultVersion = RepoVersion 5
defaultVersion = RepoVersion 7
latestVersion :: RepoVersion
latestVersion = RepoVersion 7
supportedVersions :: [RepoVersion]
supportedVersions = map RepoVersion [5, 7]
versionForAdjustedClone :: RepoVersion
versionForAdjustedClone = RepoVersion 7
versionForAdjustedBranch :: RepoVersion
versionForAdjustedBranch = RepoVersion 7
versionForCrippledFilesystem :: RepoVersion
versionForCrippledFilesystem = RepoVersion 7
supportedVersions = map RepoVersion [7]
upgradableVersions :: [RepoVersion]
#ifndef mingw32_HOST_OS
@ -54,18 +45,6 @@ versionField = annexConfig "version"
getVersion :: Annex (Maybe RepoVersion)
getVersion = annexVersion <$> Annex.getGitConfig
versionSupportsUnlockedPointers :: Annex Bool
versionSupportsUnlockedPointers = go <$> getVersion
where
go (Just v) | v >= RepoVersion 6 = True
go _ = False
versionSupportsAdjustedBranch :: Annex Bool
versionSupportsAdjustedBranch = versionSupportsUnlockedPointers
versionUsesKeysDatabase :: Annex Bool
versionUsesKeysDatabase = versionSupportsUnlockedPointers
setVersion :: RepoVersion -> Annex ()
setVersion (RepoVersion v) = setConfig versionField (show v)

View file

@ -10,7 +10,6 @@ module Annex.WorkTree where
import Annex.Common
import Annex.Link
import Annex.CatFile
import Annex.Version
import Annex.Content
import Annex.ReplaceFile
import Annex.CurrentBranch
@ -54,10 +53,7 @@ lookupFileNotHidden = lookupFile' catkeyfile
lookupFile' :: (FilePath -> Annex (Maybe Key)) -> FilePath -> Annex (Maybe Key)
lookupFile' catkeyfile file = isAnnexLink file >>= \case
Just key -> return (Just key)
Nothing -> ifM versionSupportsUnlockedPointers
( catkeyfile file
, return Nothing
)
Nothing -> catkeyfile file
{- Modifies an action to only act on files that are already annexed,
- and passes the key on to it. -}