From 826d5887b2c31c9dca1415997d7704d9442077b0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 11 Nov 2011 13:42:31 -0400 Subject: [PATCH] Automatically fix up badly formatted uuid.log entries produced by 3.20111105, whenever the uuid.log is changed (ie, by init or describe). --- Logs/UUID.hs | 31 ++++++++++++++++++++++++++++++- Logs/UUIDBased.hs | 1 + debian/changelog | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Logs/UUID.hs b/Logs/UUID.hs index da611d7bf5..20f43d15ca 100644 --- a/Logs/UUID.hs +++ b/Logs/UUID.hs @@ -36,7 +36,36 @@ describeUUID :: UUID -> String -> Annex () describeUUID uuid desc = do ts <- liftIO getPOSIXTime Annex.Branch.change logfile $ - showLog id . changeLog ts uuid desc . parseLog Just + showLog id . changeLog ts uuid desc . fixBadUUID . parseLog Just + +{- Temporarily here to fix badly formatted uuid logs generated by + - versions 3.20111105 and 3.20111025. + - + - Those logs contain entries with the UUID and description flipped. + - Due to parsing, if the description is multiword, only the first + - will be taken to be the UUID. So, if the UUID of an entry does + - not look like a UUID, and the last word of the description does, + - flip them back. + -} +fixBadUUID :: Log String -> Log String +fixBadUUID = M.fromList . map fixup . M.toList + where + fixup (k, v) + | isbad = (fixeduuid, LogEntry (Date $ newertime v) fixedvalue) + | otherwise = (k, v) + where + kuuid = fromUUID k + isbad = (not $ isuuid kuuid) && isuuid lastword + ws = words $ value v + lastword = last ws + fixeduuid = toUUID lastword + fixedvalue = unwords $ kuuid:(take (length ws - 1) ws) + -- For the fixed line to take precidence, it should be + -- slightly newer, but only slightly. + newertime (LogEntry (Date d) _) = d + minimumPOSIXTimeSlice + newertime (LogEntry (Unknown) _) = minimumPOSIXTimeSlice + minimumPOSIXTimeSlice = 0.000001 + isuuid s = length s == 36 && length (split "-" s) == 5 {- Records the uuid in the log, if it's not already there. -} recordUUID :: UUID -> Annex () diff --git a/Logs/UUIDBased.hs b/Logs/UUIDBased.hs index 42908ab1d3..04b12887d7 100644 --- a/Logs/UUIDBased.hs +++ b/Logs/UUIDBased.hs @@ -15,6 +15,7 @@ module Logs.UUIDBased ( Log, LogEntry(..), + TimeStamp(..), parseLog, showLog, changeLog, diff --git a/debian/changelog b/debian/changelog index 72110785bb..e1d08ecdb8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ git-annex (3.20111108) UNRELEASED; urgency=low * Avoid cyclic drop problems. * Optimized copy --from and get --from to avoid checking the location log for files that are already present. + * Automatically fix up badly formatted uuid.log entries produced by + 3.20111105, whenever the uuid.log is changed (ie, by init or describe). -- Joey Hess Mon, 07 Nov 2011 18:08:42 -0400