include upgrade code back in

Remaining things that need to be fixed up to get this branch into a
basically mergeable state: remotes, commands, and the assistant
This commit is contained in:
Joey Hess 2019-12-02 12:01:20 -04:00
parent f3047d7186
commit 1100e0d3c9
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 11 additions and 14 deletions

View file

@ -15,7 +15,6 @@ import qualified Git
import Annex.Version import Annex.Version
import Types.RepoVersion import Types.RepoVersion
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
{-
import qualified Upgrade.V0 import qualified Upgrade.V0
import qualified Upgrade.V1 import qualified Upgrade.V1
#endif #endif
@ -24,7 +23,6 @@ import qualified Upgrade.V3
import qualified Upgrade.V4 import qualified Upgrade.V4
import qualified Upgrade.V5 import qualified Upgrade.V5
import qualified Upgrade.V6 import qualified Upgrade.V6
-}
import qualified Data.Map as M import qualified Data.Map as M
@ -74,7 +72,6 @@ upgrade automatic destversion = do
) )
go _ = return True go _ = return True
{-
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
up (RepoVersion 0) = Upgrade.V0.upgrade up (RepoVersion 0) = Upgrade.V0.upgrade
up (RepoVersion 1) = Upgrade.V1.upgrade up (RepoVersion 1) = Upgrade.V1.upgrade
@ -87,6 +84,4 @@ upgrade automatic destversion = do
up (RepoVersion 4) = Upgrade.V4.upgrade automatic up (RepoVersion 4) = Upgrade.V4.upgrade automatic
up (RepoVersion 5) = Upgrade.V5.upgrade automatic up (RepoVersion 5) = Upgrade.V5.upgrade automatic
up (RepoVersion 6) = Upgrade.V6.upgrade automatic up (RepoVersion 6) = Upgrade.V6.upgrade automatic
-}
up _ = return True up _ = return True

View file

@ -84,8 +84,8 @@ updateSymlinks :: Annex ()
updateSymlinks = do updateSymlinks = do
showAction "updating symlinks" showAction "updating symlinks"
top <- fromRepo Git.repoPath top <- fromRepo Git.repoPath
(files, cleanup) <- inRepo $ LsFiles.inRepo [top] (files, cleanup) <- inRepo $ LsFiles.inRepo [toRawFilePath top]
forM_ files fixlink forM_ files (fixlink . fromRawFilePath)
void $ liftIO cleanup void $ liftIO cleanup
where where
fixlink f = do fixlink f = do

View file

@ -50,7 +50,7 @@ upgrade = do
e <- liftIO $ doesDirectoryExist old e <- liftIO $ doesDirectoryExist old
when e $ do when e $ do
config <- Annex.getGitConfig config <- Annex.getGitConfig
mapM_ (\(k, f) -> inject f $ locationLogFile config k) =<< locationLogs mapM_ (\(k, f) -> inject f $ fromRawFilePath $ locationLogFile config k) =<< locationLogs
mapM_ (\f -> inject f f) =<< logFiles old mapM_ (\f -> inject f f) =<< logFiles old
saveState False saveState False
@ -76,13 +76,13 @@ locationLogs = do
where where
tryDirContents d = catchDefaultIO [] $ dirContents d tryDirContents d = catchDefaultIO [] $ dirContents d
islogfile f = maybe Nothing (\k -> Just (k, f)) $ islogfile f = maybe Nothing (\k -> Just (k, f)) $
locationLogFileKey f locationLogFileKey (toRawFilePath f)
inject :: FilePath -> FilePath -> Annex () inject :: FilePath -> FilePath -> Annex ()
inject source dest = do inject source dest = do
old <- fromRepo olddir old <- fromRepo olddir
new <- liftIO (readFile $ old </> source) new <- liftIO (readFile $ old </> source)
Annex.Branch.change dest $ \prev -> Annex.Branch.change (toRawFilePath dest) $ \prev ->
encodeBL $ unlines $ nub $ lines (decodeBL prev) ++ lines new encodeBL $ unlines $ nub $ lines (decodeBL prev) ++ lines new
logFiles :: FilePath -> Annex [FilePath] logFiles :: FilePath -> Annex [FilePath]

View file

@ -5,6 +5,8 @@
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
{-# LANGUAGE OverloadedStrings #-}
module Upgrade.V5 where module Upgrade.V5 where
import Annex.Common import Annex.Common
@ -106,7 +108,7 @@ convertDirect = do
upgradeDirectWorkTree :: Annex () upgradeDirectWorkTree :: Annex ()
upgradeDirectWorkTree = do upgradeDirectWorkTree = do
top <- fromRepo Git.repoPath top <- fromRepo Git.repoPath
(l, clean) <- inRepo $ Git.LsFiles.stagedDetails [top] (l, clean) <- inRepo $ Git.LsFiles.stagedDetails [toRawFilePath top]
forM_ l go forM_ l go
void $ liftIO clean void $ liftIO clean
where where
@ -119,11 +121,11 @@ upgradeDirectWorkTree = do
Just k -> do Just k -> do
stagePointerFile f Nothing =<< hashPointerFile k stagePointerFile f Nothing =<< hashPointerFile k
ifM (isJust <$> getAnnexLinkTarget f) ifM (isJust <$> getAnnexLinkTarget f)
( writepointer f k ( writepointer (fromRawFilePath f) k
, fromdirect f k , fromdirect (fromRawFilePath f) k
) )
Database.Keys.addAssociatedFile k Database.Keys.addAssociatedFile k
=<< inRepo (toTopFilePath f) =<< inRepo (toTopFilePath (fromRawFilePath f))
go _ = noop go _ = noop
fromdirect f k = ifM (Direct.goodContent k f) fromdirect f k = ifM (Direct.goodContent k f)