simplification now that all logs use Builder
This commit is contained in:
parent
2fef43dd71
commit
232b1a08f3
3 changed files with 13 additions and 7 deletions
|
@ -34,6 +34,7 @@ import qualified Data.Set as S
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Function
|
import Data.Function
|
||||||
import Data.Char
|
import Data.Char
|
||||||
|
import Data.ByteString.Builder
|
||||||
import Control.Concurrent (threadDelay)
|
import Control.Concurrent (threadDelay)
|
||||||
|
|
||||||
import Annex.Common
|
import Annex.Common
|
||||||
|
@ -586,7 +587,8 @@ performTransitionsLocked jl ts neednewlocalbranch transitionedrefs = do
|
||||||
-- File is deleted; can't run any other
|
-- File is deleted; can't run any other
|
||||||
-- transitions on it.
|
-- transitions on it.
|
||||||
return ()
|
return ()
|
||||||
ChangeFile content' -> do
|
ChangeFile builder -> do
|
||||||
|
let content' = toLazyByteString builder
|
||||||
sha <- hashBlob content'
|
sha <- hashBlob content'
|
||||||
Annex.Queue.addUpdateIndex $ Git.UpdateIndex.pureStreamer $
|
Annex.Queue.addUpdateIndex $ Git.UpdateIndex.pureStreamer $
|
||||||
Git.UpdateIndex.updateIndexLine sha TreeFile (asTopFilePath file)
|
Git.UpdateIndex.updateIndexLine sha TreeFile (asTopFilePath file)
|
||||||
|
|
|
@ -27,7 +27,7 @@ import qualified Data.ByteString.Lazy as L
|
||||||
import Data.ByteString.Builder
|
import Data.ByteString.Builder
|
||||||
|
|
||||||
data FileTransition
|
data FileTransition
|
||||||
= ChangeFile L.ByteString
|
= ChangeFile Builder
|
||||||
| RemoveFile
|
| RemoveFile
|
||||||
| PreserveFile
|
| PreserveFile
|
||||||
|
|
||||||
|
@ -44,25 +44,25 @@ dropDead f content trustmap = case getLogVariety f of
|
||||||
-- because git remotes may still exist, and they need
|
-- because git remotes may still exist, and they need
|
||||||
-- to still know it's dead.
|
-- to still know it's dead.
|
||||||
| f == trustLog -> PreserveFile
|
| f == trustLog -> PreserveFile
|
||||||
| otherwise -> ChangeFile $ toLazyByteString $
|
| otherwise -> ChangeFile $
|
||||||
UUIDBased.buildLog (byteString . encodeBS) $
|
UUIDBased.buildLog (byteString . encodeBS) $
|
||||||
dropDeadFromMapLog trustmap id $ UUIDBased.parseLog Just (decodeBL content)
|
dropDeadFromMapLog trustmap id $ UUIDBased.parseLog Just (decodeBL content)
|
||||||
Just NewUUIDBasedLog -> ChangeFile $ toLazyByteString $
|
Just NewUUIDBasedLog -> ChangeFile $
|
||||||
UUIDBased.buildLogNew (byteString . encodeBS) $
|
UUIDBased.buildLogNew (byteString . encodeBS) $
|
||||||
dropDeadFromMapLog trustmap id $
|
dropDeadFromMapLog trustmap id $
|
||||||
UUIDBased.parseLogNew Just (decodeBL content)
|
UUIDBased.parseLogNew Just (decodeBL content)
|
||||||
Just (ChunkLog _) -> ChangeFile $ toLazyByteString $
|
Just (ChunkLog _) -> ChangeFile $
|
||||||
Chunk.buildLog $ dropDeadFromMapLog trustmap fst $ Chunk.parseLog (decodeBL content)
|
Chunk.buildLog $ dropDeadFromMapLog trustmap fst $ Chunk.parseLog (decodeBL content)
|
||||||
Just (PresenceLog _) ->
|
Just (PresenceLog _) ->
|
||||||
let newlog = Presence.compactLog $ dropDeadFromPresenceLog trustmap $ Presence.parseLog content
|
let newlog = Presence.compactLog $ dropDeadFromPresenceLog trustmap $ Presence.parseLog content
|
||||||
in if null newlog
|
in if null newlog
|
||||||
then RemoveFile
|
then RemoveFile
|
||||||
else ChangeFile $ toLazyByteString $ Presence.buildLog newlog
|
else ChangeFile $ Presence.buildLog newlog
|
||||||
Just RemoteMetaDataLog ->
|
Just RemoteMetaDataLog ->
|
||||||
let newlog = dropDeadFromRemoteMetaDataLog trustmap $ MetaData.simplifyLog $ MetaData.parseLog content
|
let newlog = dropDeadFromRemoteMetaDataLog trustmap $ MetaData.simplifyLog $ MetaData.parseLog content
|
||||||
in if S.null newlog
|
in if S.null newlog
|
||||||
then RemoveFile
|
then RemoveFile
|
||||||
else ChangeFile $ toLazyByteString $ MetaData.buildLog newlog
|
else ChangeFile $ MetaData.buildLog newlog
|
||||||
Just OtherLog -> PreserveFile
|
Just OtherLog -> PreserveFile
|
||||||
Nothing -> PreserveFile
|
Nothing -> PreserveFile
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import Utility.Tmp
|
||||||
|
|
||||||
import qualified Data.ByteString as S
|
import qualified Data.ByteString as S
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
|
import Data.ByteString.Builder
|
||||||
|
|
||||||
type HashObjectHandle = CoProcess.CoProcessHandle
|
type HashObjectHandle = CoProcess.CoProcessHandle
|
||||||
|
|
||||||
|
@ -49,6 +50,9 @@ instance HashableBlob L.ByteString where
|
||||||
instance HashableBlob S.ByteString where
|
instance HashableBlob S.ByteString where
|
||||||
hashableBlobToHandle = S.hPut
|
hashableBlobToHandle = S.hPut
|
||||||
|
|
||||||
|
instance HashableBlob Builder where
|
||||||
|
hashableBlobToHandle = hPutBuilder
|
||||||
|
|
||||||
{- Injects a blob into git. Unfortunately, the current git-hash-object
|
{- Injects a blob into git. Unfortunately, the current git-hash-object
|
||||||
- interface does not allow batch hashing without using temp files. -}
|
- interface does not allow batch hashing without using temp files. -}
|
||||||
hashBlob :: HashableBlob b => HashObjectHandle -> b -> IO Sha
|
hashBlob :: HashableBlob b => HashObjectHandle -> b -> IO Sha
|
||||||
|
|
Loading…
Add table
Reference in a new issue