aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-11 13:42:31 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-11 13:42:31 -0400
commit826d5887b2c31c9dca1415997d7704d9442077b0 (patch)
tree30c08e9eedb8d4b850e073b50c54842e0accfb89
parent637b5feb45013f69f3aacbafeb796de666d3faa3 (diff)
Automatically fix up badly formatted uuid.log entries produced by 3.20111105, whenever the uuid.log is changed (ie, by init or describe).
-rw-r--r--Logs/UUID.hs31
-rw-r--r--Logs/UUIDBased.hs1
-rw-r--r--debian/changelog2
3 files changed, 33 insertions, 1 deletions
diff --git a/Logs/UUID.hs b/Logs/UUID.hs
index da611d7bf..20f43d15c 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 42908ab1d..04b12887d 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 72110785b..e1d08ecdb 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 <joeyh@debian.org> Mon, 07 Nov 2011 18:08:42 -0400