convert from readFileStrict
More of these still to convert, but need to be careful of newline translation.
This commit is contained in:
parent
c5fe457e01
commit
60d0dc9c76
3 changed files with 15 additions and 12 deletions
|
@ -70,6 +70,7 @@ import Logs.View (is_branchView)
|
||||||
import Logs.AdjustedBranchUpdate
|
import Logs.AdjustedBranchUpdate
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import qualified Utility.RawFilePath as R
|
import qualified Utility.RawFilePath as R
|
||||||
|
import qualified Utility.FileIO as F
|
||||||
|
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
@ -268,7 +269,7 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
|
||||||
-- origbranch.
|
-- origbranch.
|
||||||
_ <- propigateAdjustedCommits' True origbranch adj commitlck
|
_ <- propigateAdjustedCommits' True origbranch adj commitlck
|
||||||
|
|
||||||
origheadfile <- inRepo $ readFileStrict . fromRawFilePath . Git.Ref.headFile
|
origheadfile <- inRepo $ F.readFile' . toOsPath . Git.Ref.headFile
|
||||||
origheadsha <- inRepo (Git.Ref.sha currbranch)
|
origheadsha <- inRepo (Git.Ref.sha currbranch)
|
||||||
|
|
||||||
b <- adjustBranch adj origbranch
|
b <- adjustBranch adj origbranch
|
||||||
|
@ -280,8 +281,8 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
|
||||||
newheadfile <- case origheadsha of
|
newheadfile <- case origheadsha of
|
||||||
Just s -> do
|
Just s -> do
|
||||||
inRepo $ \r -> do
|
inRepo $ \r -> do
|
||||||
let newheadfile = fromRef s
|
let newheadfile = fromRef' s
|
||||||
writeFile (fromRawFilePath (Git.Ref.headFile r)) newheadfile
|
F.writeFile' (toOsPath (Git.Ref.headFile r)) newheadfile
|
||||||
return (Just newheadfile)
|
return (Just newheadfile)
|
||||||
_ -> return Nothing
|
_ -> return Nothing
|
||||||
|
|
||||||
|
@ -295,9 +296,9 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
|
||||||
unless ok $ case newheadfile of
|
unless ok $ case newheadfile of
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just v -> preventCommits $ \_commitlck -> inRepo $ \r -> do
|
Just v -> preventCommits $ \_commitlck -> inRepo $ \r -> do
|
||||||
v' <- readFileStrict (fromRawFilePath (Git.Ref.headFile r))
|
v' <- F.readFile' (toOsPath (Git.Ref.headFile r))
|
||||||
when (v == v') $
|
when (v == v') $
|
||||||
writeFile (fromRawFilePath (Git.Ref.headFile r)) origheadfile
|
F.writeFile' (toOsPath (Git.Ref.headFile r)) origheadfile
|
||||||
|
|
||||||
return ok
|
return ok
|
||||||
| otherwise = preventCommits $ \commitlck -> do
|
| otherwise = preventCommits $ \commitlck -> do
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{- Package version determination. -}
|
{- Package version determination. -}
|
||||||
|
|
||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase, OverloadedStrings #-}
|
||||||
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
{-# OPTIONS_GHC -fno-warn-tabs #-}
|
||||||
|
|
||||||
module Build.Version where
|
module Build.Version where
|
||||||
|
@ -14,7 +14,9 @@ import Prelude
|
||||||
|
|
||||||
import Utility.Monad
|
import Utility.Monad
|
||||||
import Utility.Exception
|
import Utility.Exception
|
||||||
import Utility.Misc
|
import Utility.OsPath
|
||||||
|
import Utility.FileSystemEncoding
|
||||||
|
import qualified Utility.FileIO as F
|
||||||
|
|
||||||
type Version = String
|
type Version = String
|
||||||
|
|
||||||
|
@ -56,11 +58,11 @@ getChangelogVersion = do
|
||||||
middle = drop 1 . init
|
middle = drop 1 . init
|
||||||
|
|
||||||
writeVersion :: Version -> IO ()
|
writeVersion :: Version -> IO ()
|
||||||
writeVersion ver = catchMaybeIO (readFileStrict f) >>= \case
|
writeVersion ver = catchMaybeIO (F.readFile' f) >>= \case
|
||||||
Just s | s == body -> return ()
|
Just s | s == body -> return ()
|
||||||
_ -> writeFile f body
|
_ -> F.writeFile' f body
|
||||||
where
|
where
|
||||||
body = unlines $ concat
|
body = encodeBS $ unlines $ concat
|
||||||
[ header
|
[ header
|
||||||
, ["packageversion :: String"]
|
, ["packageversion :: String"]
|
||||||
, ["packageversion = \"" ++ ver ++ "\""]
|
, ["packageversion = \"" ++ ver ++ "\""]
|
||||||
|
@ -71,4 +73,4 @@ writeVersion ver = catchMaybeIO (readFileStrict f) >>= \case
|
||||||
, ""
|
, ""
|
||||||
]
|
]
|
||||||
footer = []
|
footer = []
|
||||||
f = "Build/Version"
|
f = toOsPath "Build/Version"
|
||||||
|
|
|
@ -204,7 +204,7 @@ writeLog1 file ls = viaTmp F.writeFile
|
||||||
|
|
||||||
readLog1 :: FilePath -> IO [LogLine]
|
readLog1 :: FilePath -> IO [LogLine]
|
||||||
readLog1 file = catchDefaultIO [] $
|
readLog1 file = catchDefaultIO [] $
|
||||||
parseLog . encodeBL <$> readFileStrict file
|
parseLog <$> F.readFile (toOsPath (toRawFilePath file))
|
||||||
|
|
||||||
lookupKey1 :: FilePath -> Annex (Maybe (Key, Backend))
|
lookupKey1 :: FilePath -> Annex (Maybe (Key, Backend))
|
||||||
lookupKey1 file = do
|
lookupKey1 file = do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue