From 51c12a76ef54affaf9428232fde4f2c3e30e7488 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Feb 2014 01:09:17 -0400 Subject: 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. --- Logs/FsckResults.hs | 2 +- Logs/View.hs | 17 ++++------------- 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'Logs') 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 -- cgit v1.2.3