diff --git a/RemoteLog.hs b/RemoteLog.hs index 149104fbac..d49635b930 100644 --- a/RemoteLog.hs +++ b/RemoteLog.hs @@ -6,7 +6,6 @@ -} module RemoteLog ( - remoteLog, readRemoteLog, configSet, keyValToConfig, @@ -16,12 +15,14 @@ module RemoteLog ( ) where import qualified Data.Map as M +import Data.Time.Clock.POSIX import Data.Char import Common.Annex import qualified Annex.Branch import Types.Remote import UUID +import UUIDLog {- Filename of remote.log. -} remoteLog :: FilePath @@ -29,27 +30,20 @@ remoteLog = "remote.log" {- Adds or updates a remote's config in the log. -} configSet :: UUID -> RemoteConfig -> Annex () -configSet u c = Annex.Branch.change remoteLog $ - serialize . M.insert u c . remoteLogParse - where - serialize = unlines . sort . map toline . M.toList - toline (u', c') = u' ++ " " ++ unwords (configToKeyVal c') +configSet u c = do + ts <- liftIO $ getPOSIXTime + Annex.Branch.change remoteLog $ + showLog showConfig . changeLog ts u c . parseLog parseConfig {- Map of remotes by uuid containing key/value config maps. -} readRemoteLog :: Annex (M.Map UUID RemoteConfig) -readRemoteLog = remoteLogParse <$> Annex.Branch.get remoteLog +readRemoteLog = (simpleMap . parseLog parseConfig) <$> Annex.Branch.get remoteLog -remoteLogParse :: String -> M.Map UUID RemoteConfig -remoteLogParse s = - M.fromList $ mapMaybe parseline $ filter (not . null) $ lines s - where - parseline l - | length w > 2 = Just (u, c) - | otherwise = Nothing - where - w = words l - u = head w - c = keyValToConfig $ tail w +parseConfig :: String -> Maybe RemoteConfig +parseConfig = Just . keyValToConfig . words + +showConfig :: RemoteConfig -> String +showConfig = unwords . configToKeyVal {- Given Strings like "key=value", generates a RemoteConfig. -} keyValToConfig :: [String] -> RemoteConfig diff --git a/debian/changelog b/debian/changelog index e5f74bec5b..31455c9f0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,7 +12,7 @@ git-annex (3.20110929) UNRELEASED; urgency=low has been merged. * Note that older versions of git-annex will display the timestamp as part of the repository description, which is ugly but otherwise harmless. - * Add timestamps to trust.log. + * Add timestamps to trust.log and remote.log too. -- Joey Hess Thu, 29 Sep 2011 18:58:53 -0400 diff --git a/doc/bugs/uuid.log_trust.log_and_remote.log_merge_wackiness.mdwn b/doc/bugs/uuid.log_trust.log_and_remote.log_merge_wackiness.mdwn index f300d8708c..a84d8cb568 100644 --- a/doc/bugs/uuid.log_trust.log_and_remote.log_merge_wackiness.mdwn +++ b/doc/bugs/uuid.log_trust.log_and_remote.log_merge_wackiness.mdwn @@ -28,6 +28,9 @@ would keep working, ignoring the timestamp. - remote.log: "uuid key=value ... timestamp" is on the edge but does work (old git-annex will include the timestamp in the key/value map it builds, but that should not break anything really) + > update: converted! --[[Joey]] Appending "timestamp=xxxxx" would be good for clarity, and make it easier to parse the timestamp out from lines that have it. + +> [[done]] --[[Joey]] diff --git a/doc/internals.mdwn b/doc/internals.mdwn index 4881588ca6..5559d122b9 100644 --- a/doc/internals.mdwn +++ b/doc/internals.mdwn @@ -54,7 +54,7 @@ Amazon S3. The file format is one line per remote, starting with the uuid of the remote, followed by a space, and then a series of key=value pairs, -each separated by whitespace. +each separated by whitespace, and finally a timestamp. ## `trust.log` @@ -62,13 +62,15 @@ Records the [[trust]] information for repositories. Does not exist unless [[trust]] values are configured. The file format is one line per repository, with the uuid followed by a -space, and then either 1 (trusted), 0 (untrusted), or ? (semi-trusted). -Repositories not listed are semi-trusted. +space, and then either 1 (trusted), 0 (untrusted), or ? (semi-trusted), +and finally a timestamp. Example: - e605dca6-446a-11e0-8b2a-002170d25c55 1 - 26339d22-446b-11e0-9101-002170d25c55 ? + e605dca6-446a-11e0-8b2a-002170d25c55 1 timestamp=1317929189.157237s + 26339d22-446b-11e0-9101-002170d25c55 ? timestamp=1317929330.769997s + +Repositories not listed are semi-trusted. ## `aaa/bbb/*.log`