forget: Preserve currently exported trees

Avoiding problems with exporttree remotes in some unusual circumstances.

This commit was sponsored by Brett Eisenberg on Patreon.
This commit is contained in:
Joey Hess 2021-04-13 15:00:23 -04:00
parent 0bcf155e11
commit 8e7dc958d2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
7 changed files with 36 additions and 8 deletions

View file

@ -71,6 +71,7 @@ import Logs.Transitions
import Logs.File
import Logs.Trust.Pure
import Logs.Remote.Pure
import Logs.Export.Pure
import Logs.Difference.Pure
import qualified Annex.Queue
import Annex.Branch.Transitions
@ -610,6 +611,7 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
else do
ref <- getBranch
commitIndex jl ref message (nub $ fullname:transitionedrefs)
regraftexports
where
message
| neednewlocalbranch && null transitionedrefs = "new branch for transition " ++ tdesc
@ -638,6 +640,7 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
content <- getStaged f
apply changers' f content
liftIO $ void cleanup
apply [] _ _ = return ()
apply (changer:rest) file content = case changer file content of
PreserveFile -> apply rest file content
@ -656,6 +659,15 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
Git.UpdateIndex.updateIndexLine sha TreeFile (asTopFilePath file)
apply rest file content'
-- Trees mentioned in export.log were grafted into the old
-- git-annex branch to make sure they remain available. Re-graft
-- the trees into the new branch.
regraftexports = do
l <- exportedTreeishes . M.elems . parseExportLogMap
<$> getStaged exportLog
forM_ l $ \t ->
rememberTreeishLocked t (asTopFilePath exportTreeGraftPoint) jl
checkBranchDifferences :: Git.Ref -> Annex ()
checkBranchDifferences ref = do
theirdiffs <- allDifferences . parseDifferencesLog
@ -708,7 +720,9 @@ getMergedRefs' = do
- collected, and will always be available as long as the git-annex branch
- is available. -}
rememberTreeish :: Git.Ref -> TopFilePath -> Annex ()
rememberTreeish treeish graftpoint = lockJournal $ \jl -> do
rememberTreeish treeish graftpoint = lockJournal $ rememberTreeishLocked treeish graftpoint
rememberTreeishLocked :: Git.Ref -> TopFilePath -> JournalLocked -> Annex ()
rememberTreeishLocked treeish graftpoint jl = do
branchref <- getBranch
updateIndex jl branchref
origtree <- fromMaybe (giveup "unable to determine git-annex branch tree") <$>

View file

@ -45,7 +45,7 @@ getTransitionCalculator ForgetDeadRemotes = Just dropDead
-- Removes data about all dead repos.
--
-- The trust log is not changed, because other, unmerged clones
-- may contain other data about the dead repos. So we need to rememebr
-- may contain other data about the dead repos. So we need to remember
-- which are dead to later remove that.
--
-- When the remote log contains a sameas-uuid pointing to a dead uuid,