reuse annex's HashObjectHandle

This commit is contained in:
Joey Hess 2016-03-14 16:29:19 -04:00
parent 2d234de781
commit a2b668a8f6
Failed to extract signature

View file

@ -45,12 +45,12 @@ import qualified Git.Branch
import qualified Git.UnionMerge import qualified Git.UnionMerge
import qualified Git.UpdateIndex import qualified Git.UpdateIndex
import Git.LsTree (lsTreeParams) import Git.LsTree (lsTreeParams)
import Git.HashObject import qualified Git.HashObject
import Annex.HashObject
import Git.Types import Git.Types
import Git.FilePath import Git.FilePath
import Annex.CatFile import Annex.CatFile
import Annex.Perms import Annex.Perms
import Annex.HashObject (hashObjectHandle)
import Logs import Logs
import Logs.Transitions import Logs.Transitions
import Logs.Trust.Pure import Logs.Trust.Pure
@ -425,11 +425,10 @@ stageJournal jl = withIndex $ do
let dir = gitAnnexJournalDir g let dir = gitAnnexJournalDir g
(jlogf, jlogh) <- openjlog (jlogf, jlogh) <- openjlog
liftIO $ fileEncoding jlogh liftIO $ fileEncoding jlogh
withJournalHandle $ \jh -> do h <- hashObjectHandle
h <- hashObjectStart g withJournalHandle $ \jh ->
Git.UpdateIndex.streamUpdateIndex g Git.UpdateIndex.streamUpdateIndex g
[genstream dir h jh jlogh] [genstream dir h jh jlogh]
hashObjectStop h
return $ cleanup dir jlogh jlogf return $ cleanup dir jlogh jlogf
where where
genstream dir h jh jlogh streamer = do genstream dir h jh jlogh streamer = do
@ -439,7 +438,7 @@ stageJournal jl = withIndex $ do
Just file -> do Just file -> do
unless (dirCruft file) $ do unless (dirCruft file) $ do
let path = dir </> file let path = dir </> file
sha <- hashFile h path sha <- Git.HashObject.hashFile h path
hPutStrLn jlogh file hPutStrLn jlogh file
streamer $ Git.UpdateIndex.updateIndexLine streamer $ Git.UpdateIndex.updateIndexLine
sha FileBlob (asTopFilePath $ fileJournal file) sha FileBlob (asTopFilePath $ fileJournal file)
@ -551,13 +550,11 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
run changers = do run changers = do
trustmap <- calcTrustMap <$> getRaw trustLog trustmap <- calcTrustMap <$> getRaw trustLog
fs <- branchFiles fs <- branchFiles
hasher <- inRepo hashObjectStart
forM_ fs $ \f -> do forM_ fs $ \f -> do
content <- getRaw f content <- getRaw f
apply changers hasher f content trustmap apply changers f content trustmap
liftIO $ hashObjectStop hasher apply [] _ _ _ = return ()
apply [] _ _ _ _ = return () apply (changer:rest) file content trustmap =
apply (changer:rest) hasher file content trustmap =
case changer file content trustmap of case changer file content trustmap of
RemoveFile -> do RemoveFile -> do
Annex.Queue.addUpdateIndex Annex.Queue.addUpdateIndex
@ -566,12 +563,12 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
-- transitions on it. -- transitions on it.
return () return ()
ChangeFile content' -> do ChangeFile content' -> do
sha <- liftIO $ hashBlob hasher content' sha <- hashBlob content'
Annex.Queue.addUpdateIndex $ Git.UpdateIndex.pureStreamer $ Annex.Queue.addUpdateIndex $ Git.UpdateIndex.pureStreamer $
Git.UpdateIndex.updateIndexLine sha FileBlob (asTopFilePath file) Git.UpdateIndex.updateIndexLine sha FileBlob (asTopFilePath file)
apply rest hasher file content' trustmap apply rest file content' trustmap
PreserveFile -> PreserveFile ->
apply rest hasher file content trustmap apply rest file content trustmap
checkBranchDifferences :: Git.Ref -> Annex () checkBranchDifferences :: Git.Ref -> Annex ()
checkBranchDifferences ref = do checkBranchDifferences ref = do