summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-19 01:09:17 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-19 01:19:57 -0400
commit51c12a76ef54affaf9428232fde4f2c3e30e7488 (patch)
tree4cb2699e2b410260e383d3bf6da14d502aa0d0dc /Logs
parentb5b5ead4b28fd08100bcac9cb9482263bac3a64e (diff)
remove Read instance for Ref
Removed instance, got it all to build using fromRef. (With a few things that really need to show something using a ref for debugging stubbed out.) Then added back Read instance, and made Logs.View use it for serialization. This changes the view log format.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/FsckResults.hs2
-rw-r--r--Logs/View.hs17
2 files changed, 5 insertions, 14 deletions
diff --git a/Logs/FsckResults.hs b/Logs/FsckResults.hs
index 8e776ec21..3538bdc40 100644
--- a/Logs/FsckResults.hs
+++ b/Logs/FsckResults.hs
@@ -31,7 +31,7 @@ writeFsckResults u fsckresults = do
store s logfile = do
createDirectoryIfMissing True (parentDir logfile)
liftIO $ viaTmp writeFile logfile $ serialize s
- serialize = unlines . map show . S.toList
+ serialize = unlines . map fromRef . S.toList
readFsckResults :: UUID -> Annex FsckResults
readFsckResults u = do
diff --git a/Logs/View.hs b/Logs/View.hs
index cb1e33125..47ce7c4c1 100644
--- a/Logs/View.hs
+++ b/Logs/View.hs
@@ -24,21 +24,12 @@ import Types.MetaData
import qualified Git
import qualified Git.Branch
import qualified Git.Ref
+import Git.Types
import Utility.Tmp
import qualified Data.Set as S
import Data.Char
-showLog :: View -> String
-showLog (View branch components) = show branch ++ " " ++ show components
-
-parseLog :: String -> Maybe View
-parseLog s =
- let (branch, components) = separate (== ' ') s
- in View
- <$> pure (Git.Ref branch)
- <*> readish components
-
setView :: View -> Annex ()
setView v = do
old <- take 99 . filter (/= v) <$> recentViews
@@ -47,7 +38,7 @@ setView v = do
writeViews :: [View] -> Annex ()
writeViews l = do
f <- fromRepo gitAnnexViewLog
- liftIO $ viaTmp writeFile f $ unlines $ map showLog l
+ liftIO $ viaTmp writeFile f $ unlines $ map show l
removeView :: View -> Annex ()
removeView v = writeViews =<< filter (/= v) <$> recentViews
@@ -55,7 +46,7 @@ removeView v = writeViews =<< filter (/= v) <$> recentViews
recentViews :: Annex [View]
recentViews = do
f <- fromRepo gitAnnexViewLog
- liftIO $ mapMaybe parseLog . lines <$> catchDefaultIO [] (readFile f)
+ liftIO $ mapMaybe readish . lines <$> catchDefaultIO [] (readFile f)
{- Gets the currently checked out view, if there is one. -}
currentView :: Annex (Maybe View)
@@ -97,4 +88,4 @@ branchView view
| otherwise = map (\c -> if isAlphaNum c then c else '_') s
prop_branchView_legal :: View -> Bool
-prop_branchView_legal = Git.Ref.legal False . show . branchView
+prop_branchView_legal = Git.Ref.legal False . fromRef . branchView