avoid redundant adjusted branch update in sync
sync still does update it if the config would otherwise not, since it already did.
This commit is contained in:
parent
805af01562
commit
631c8d3e5b
2 changed files with 22 additions and 16 deletions
|
@ -21,8 +21,8 @@ module Annex.AdjustedBranch (
|
||||||
fromAdjustedBranch,
|
fromAdjustedBranch,
|
||||||
getAdjustment,
|
getAdjustment,
|
||||||
enterAdjustedBranch,
|
enterAdjustedBranch,
|
||||||
updateAdjustedBranch,
|
|
||||||
adjustedBranchRefresh,
|
adjustedBranchRefresh,
|
||||||
|
adjustedBranchRefreshFull,
|
||||||
adjustBranch,
|
adjustBranch,
|
||||||
adjustTree,
|
adjustTree,
|
||||||
adjustToCrippledFileSystem,
|
adjustToCrippledFileSystem,
|
||||||
|
@ -296,7 +296,7 @@ adjustedBranchRefresh _af a = do
|
||||||
ifM (checkcounter n)
|
ifM (checkcounter n)
|
||||||
( update adj origbranch
|
( update adj origbranch
|
||||||
, Annex.addCleanup AdjustedBranchUpdate $
|
, Annex.addCleanup AdjustedBranchUpdate $
|
||||||
update adj origbranch
|
adjustedBranchRefreshFull adj origbranch
|
||||||
)
|
)
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
|
||||||
|
@ -309,20 +309,26 @@ adjustedBranchRefresh _af a = do
|
||||||
!c' = if enough then 0 else c
|
!c' = if enough then 0 else c
|
||||||
!s' = s { Annex.adjustedbranchrefreshcounter = c' }
|
!s' = s { Annex.adjustedbranchrefreshcounter = c' }
|
||||||
in pure (s', enough)
|
in pure (s', enough)
|
||||||
|
|
||||||
-- TODO This is very slow when run a lot of times.
|
|
||||||
-- Incrementally adjust only the AssociatedFile.
|
|
||||||
-- However, this should be run once at shutdown then,
|
|
||||||
-- because other files than the provided AssociatedFile
|
|
||||||
-- can need to be updated in some edge cases.
|
|
||||||
update adj origbranch = do
|
update adj origbranch = do
|
||||||
-- Flush the queue, to make any pending changes be written
|
-- Flush the queue, to make any pending changes be written
|
||||||
-- out to disk. But mostly so any pointer files
|
-- out to disk. But mostly so any pointer files
|
||||||
-- restagePointerFile was called on get updated so git
|
-- restagePointerFile was called on get updated so git
|
||||||
-- checkout won't fall over.
|
-- checkout won't fall over.
|
||||||
Annex.Queue.flush
|
Annex.Queue.flush
|
||||||
let adjbranch = originalToAdjusted origbranch adj
|
-- This is slow, it would be better to incrementally
|
||||||
void $ updateAdjustedBranch adj adjbranch origbranch
|
-- adjust the AssociatedFile, and only call this once
|
||||||
|
-- at shutdown to handle cases where not all
|
||||||
|
-- AssociatedFiles are known.
|
||||||
|
adjustedBranchRefreshFull adj origbranch
|
||||||
|
|
||||||
|
{- Slow, but more dependable version of adjustedBranchRefresh that
|
||||||
|
- does not rely on all AssociatedFiles being known. -}
|
||||||
|
adjustedBranchRefreshFull :: Adjustment -> OrigBranch -> Annex ()
|
||||||
|
adjustedBranchRefreshFull adj origbranch = do
|
||||||
|
let adjbranch = originalToAdjusted origbranch adj
|
||||||
|
unlessM (updateAdjustedBranch adj adjbranch origbranch) $
|
||||||
|
warning $ unwords [ "Updating adjusted branch failed." ]
|
||||||
|
|
||||||
adjustToCrippledFileSystem :: Annex ()
|
adjustToCrippledFileSystem :: Annex ()
|
||||||
adjustToCrippledFileSystem = do
|
adjustToCrippledFileSystem = do
|
||||||
|
|
|
@ -407,17 +407,17 @@ updateBranches (Nothing, _) = noop
|
||||||
updateBranches (Just branch, madj) = do
|
updateBranches (Just branch, madj) = do
|
||||||
-- When in an adjusted branch, propigate any changes made to it
|
-- When in an adjusted branch, propigate any changes made to it
|
||||||
-- back to the original branch. The adjusted branch may also need
|
-- back to the original branch. The adjusted branch may also need
|
||||||
-- to be updated, if the adjustment is not stable.
|
-- to be updated, if the adjustment is not stable, and the usual
|
||||||
|
-- configuration does not update it.
|
||||||
case madj of
|
case madj of
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just adj -> do
|
Just adj -> do
|
||||||
let origbranch = branch
|
let origbranch = branch
|
||||||
propigateAdjustedCommits origbranch adj
|
propigateAdjustedCommits origbranch adj
|
||||||
unless (adjustmentIsStable adj) $ do
|
unless (adjustmentIsStable adj) $
|
||||||
showSideAction "updating adjusted branch"
|
annexAdjustedBranchRefresh <$> Annex.getGitConfig >>= \case
|
||||||
let adjbranch = originalToAdjusted origbranch adj
|
0 -> adjustedBranchRefreshFull adj origbranch
|
||||||
unlessM (updateAdjustedBranch adj adjbranch origbranch) $
|
_ -> return ()
|
||||||
warning $ unwords [ "Updating adjusted branch failed." ]
|
|
||||||
|
|
||||||
-- Update the sync branch to match the new state of the branch
|
-- Update the sync branch to match the new state of the branch
|
||||||
inRepo $ updateBranch (syncBranch branch) branch
|
inRepo $ updateBranch (syncBranch branch) branch
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue