summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Location.hs16
-rw-r--r--Logs/Presence.hs15
2 files changed, 25 insertions, 6 deletions
diff --git a/Logs/Location.hs b/Logs/Location.hs
index f751c00de..cb1e415fd 100644
--- a/Logs/Location.hs
+++ b/Logs/Location.hs
@@ -8,7 +8,7 @@
- Repositories record their UUID and the date when they --get or --drop
- a value.
-
- - Copyright 2010-2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -18,6 +18,7 @@ module Logs.Location (
logStatus,
logChange,
loggedLocations,
+ loggedLocationsHistorical,
loggedKeys,
loggedKeysFor,
) where
@@ -27,6 +28,7 @@ import qualified Annex.Branch
import Logs
import Logs.Presence
import Annex.UUID
+import Git.Types (RefDate)
{- Log a change in the presence of a key's value in current repository. -}
logStatus :: Key -> LogStatus -> Annex ()
@@ -40,10 +42,16 @@ logChange key (UUID u) s = addLog (locationLogFile key) =<< logNow s u
logChange _ NoUUID _ = noop
{- Returns a list of repository UUIDs that, according to the log, have
- - the value of a key.
- -}
+ - the value of a key. -}
loggedLocations :: Key -> Annex [UUID]
-loggedLocations key = map toUUID <$> (currentLog . locationLogFile) key
+loggedLocations = getLoggedLocations currentLog
+
+{- Gets the location log on a particular date. -}
+loggedLocationsHistorical :: RefDate -> Key -> Annex [UUID]
+loggedLocationsHistorical = getLoggedLocations . historicalLog
+
+getLoggedLocations :: (FilePath -> Annex [String]) -> Key -> Annex [UUID]
+getLoggedLocations getter key = map toUUID <$> (getter . locationLogFile) key
{- Finds all keys that have location log information.
- (There may be duplicate keys in the list.) -}
diff --git a/Logs/Presence.hs b/Logs/Presence.hs
index 516d59618..7545f5afc 100644
--- a/Logs/Presence.hs
+++ b/Logs/Presence.hs
@@ -6,7 +6,7 @@
- A line of the log will look like: "date N INFO"
- Where N=1 when the INFO is present, and 0 otherwise.
-
- - Copyright 2010-2011 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2014 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -16,7 +16,8 @@ module Logs.Presence (
addLog,
readLog,
logNow,
- currentLog
+ currentLog,
+ historicalLog
) where
import Data.Time.Clock.POSIX
@@ -24,6 +25,7 @@ import Data.Time.Clock.POSIX
import Logs.Presence.Pure as X
import Common.Annex
import qualified Annex.Branch
+import Git.Types (RefDate)
addLog :: FilePath -> LogLine -> Annex ()
addLog file line = Annex.Branch.change file $ \s ->
@@ -43,3 +45,12 @@ logNow s i = do
{- Reads a log and returns only the info that is still in effect. -}
currentLog :: FilePath -> Annex [String]
currentLog file = map info . filterPresent <$> readLog file
+
+{- Reads a historical version of a log and returns the info that was in
+ - effect at that time.
+ -
+ - The date is formatted as shown in gitrevisions man page.
+ -}
+historicalLog :: RefDate -> FilePath -> Annex [String]
+historicalLog refdate file = map info . filterPresent . parseLog
+ <$> Annex.Branch.getHistorical refdate file