]> dgit.raspbian.org Git - git-annex.git/commitdiff
refactoring
authorJoey Hess <joeyh@joeyh.name>
Tue, 28 Dec 2021 16:15:51 +0000 (12:15 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 28 Dec 2021 16:15:51 +0000 (12:15 -0400)
Annex/Branch.hs
Logs/Transitions.hs

index 8501625898ce8f069465a70d0d20252a58848229..c1f108f3c596549ad9ba5c20abe5ba44649cfb76 100644 (file)
@@ -230,8 +230,7 @@ updateTo' pairs = do
                        else return $ "merging " ++
                                unwords (map Git.Ref.describe branches) ++ 
                                " into " ++ fromRef name
-               localtransitions <- parseTransitionsStrictly "local"
-                       <$> getLocal transitionsLog
+               localtransitions <- getLocalTransitions
                unless (null tomerge) $ do
                        showSideAction merge_desc
                        mapM_ checkBranchDifferences refs
@@ -634,6 +633,11 @@ stageJournal jl commitindex = withIndex $ withOtherTmp $ \tmpdir -> do
                removeWhenExistsWith (R.removeLink) (toRawFilePath jlogf)
        openjlog tmpdir = liftIO $ openTmpFileIn tmpdir "jlog"
 
+getLocalTransitions :: Annex Transitions
+getLocalTransitions = 
+       parseTransitionsStrictly "local"
+               <$> getLocal transitionsLog
+
 {- This is run after the refs have been merged into the index,
  - but before the result is committed to the branch.
  - (Which is why it's passed the contents of the local branches's
@@ -652,7 +656,7 @@ stageJournal jl commitindex = withIndex $ withOtherTmp $ \tmpdir -> do
  -}
 handleTransitions :: JournalLocked -> Transitions -> [Git.Ref] -> Annex Bool
 handleTransitions jl localts refs = do
-       m <- M.fromList <$> mapM getreftransition refs
+       m <- M.fromList <$> mapM getRefTransitions refs
        let remotets = M.elems m
        if all (localts ==) remotets
                then return False
@@ -663,11 +667,6 @@ handleTransitions jl localts refs = do
                        performTransitionsLocked jl allts (localts /= allts) transitionedrefs
                        ignoreRefs untransitionedrefs
                        return True
-  where
-       getreftransition ref = do
-               ts <- parseTransitionsStrictly "remote"
-                       <$> catFile ref transitionsLog
-               return (ref, ts)
 
 {- Performs the specified transitions on the contents of the index file,
  - commits it to the branch, or creates a new branch.
index 07ee94dce95151870b6ca1a66b51eaa56444c78f..ef89e4ac05678c8f4903daf65661a709ae00e4c5 100644 (file)
@@ -7,7 +7,7 @@
  - done that is listed in the remote branch by checking that the local
  - branch contains the same transition, with the same or newer start time.
  -
- - Copyright 2013-2019 Joey Hess <id@joeyh.name>
+ - Copyright 2013-2021 Joey Hess <id@joeyh.name>
  -
  - Licensed under the GNU AGPL version 3 or higher.
  -}
@@ -19,6 +19,9 @@ module Logs.Transitions where
 import Annex.Common
 import Annex.VectorClock
 import Logs.Line
+import qualified Git
+import Git.Types (fromRef)
+import Annex.CatFile
 
 import qualified Data.Set as S
 import Data.Either
@@ -100,3 +103,9 @@ knownTransitionList = nub . rights . map transition . S.elems
 recordTransitions :: (RawFilePath -> (L.ByteString -> Builder) -> Annex ()) -> Transitions -> Annex ()
 recordTransitions changer t = changer transitionsLog $
        buildTransitions . S.union t . parseTransitionsStrictly "local"
+
+getRefTransitions :: Git.Ref -> Annex (Git.Ref, Transitions)
+getRefTransitions ref = do
+       ts <- parseTransitionsStrictly (fromRef ref)
+               <$> catFile ref transitionsLog
+       return (ref, ts)