use a zipper
This commit is contained in:
parent
a3a9f87047
commit
47646d44b7
1 changed files with 12 additions and 11 deletions
|
@ -33,29 +33,30 @@ seek = [withFilesInGit $ whenAnnexed $ start]
|
||||||
start :: FilePath -> (Key, Backend) -> CommandStart
|
start :: FilePath -> (Key, Backend) -> CommandStart
|
||||||
start file (key, _) = do
|
start file (key, _) = do
|
||||||
showStart file ""
|
showStart file ""
|
||||||
liftIO $ putStrLn ""
|
|
||||||
showLog =<< readLog key
|
showLog =<< readLog key
|
||||||
stop
|
stop
|
||||||
|
|
||||||
showLog :: [(POSIXTime, Git.Ref)] -> Annex ()
|
showLog :: [(POSIXTime, Git.Ref)] -> Annex ()
|
||||||
showLog v = go Nothing v =<< (liftIO getCurrentTimeZone)
|
showLog ps = do
|
||||||
|
zone <- liftIO getCurrentTimeZone
|
||||||
|
sets <- mapM getset ps
|
||||||
|
liftIO $ putStrLn ""
|
||||||
|
mapM_ (diff zone) $ zip sets (drop 1 sets ++ genesis)
|
||||||
where
|
where
|
||||||
go new [] zone = diff S.empty new zone
|
genesis = [(0, S.empty)]
|
||||||
go new ((ts, ref):ls) zone = do
|
getset (ts, ref) = do
|
||||||
cur <- S.fromList <$> get ref
|
s <- S.fromList <$> get ref
|
||||||
diff cur new zone
|
return (ts, s)
|
||||||
go (Just (ts, cur)) ls zone
|
|
||||||
get ref = map toUUID . Logs.Presence.getLog . L.unpack <$>
|
get ref = map toUUID . Logs.Presence.getLog . L.unpack <$>
|
||||||
catObject ref
|
catObject ref
|
||||||
diff _ Nothing _ = return ()
|
diff zone ((ts, new), (_, old)) = do
|
||||||
diff cur (Just (ts, new)) zone = do
|
|
||||||
let time = show $ utcToLocalTime zone $
|
let time = show $ utcToLocalTime zone $
|
||||||
posixSecondsToUTCTime ts
|
posixSecondsToUTCTime ts
|
||||||
output time True added
|
output time True added
|
||||||
output time False removed
|
output time False removed
|
||||||
where
|
where
|
||||||
added = S.difference new cur
|
added = S.difference new old
|
||||||
removed = S.difference cur new
|
removed = S.difference old new
|
||||||
output time present s = do
|
output time present s = do
|
||||||
rs <- map (dropWhile isSpace) . lines <$>
|
rs <- map (dropWhile isSpace) . lines <$>
|
||||||
Remote.prettyPrintUUIDs "log" (S.toList s)
|
Remote.prettyPrintUUIDs "log" (S.toList s)
|
||||||
|
|
Loading…
Reference in a new issue