@@ -114,7 +114,7 @@ lookupReport pkgid reportId buildReports = remCvg.Map.lookup reportId . reports
114
114
lookupPackageReports :: PackageId -> BuildReports -> [(BuildReportId , (BuildReport , Maybe BuildLog ))]
115
115
lookupPackageReports pkgid buildReports = case Map. lookup pkgid (reportsIndex buildReports) of
116
116
Nothing -> []
117
- Just rs -> map removeCovg $ Map. toList (reports rs)
117
+ Just rs -> map removeCovg $ Map. toList (reports rs)
118
118
where
119
119
removeCovg (brid,(brpt,blog,_)) = (brid,(brpt,blog))
120
120
@@ -214,9 +214,32 @@ instance ToSElem BuildReportId where
214
214
-- SafeCopy instances
215
215
--
216
216
217
+
218
+ newtype BuildReportId_v0 = BuildReportId_v0 Int
219
+ deriving (Serialize , Enum , Eq , Ord )
220
+
221
+ instance SafeCopy BuildReportId_v0 where
222
+ getCopy = contain get
223
+ putCopy = contain . put
224
+
225
+ instance Migrate BuildReportId where
226
+ type MigrateFrom BuildReportId = BuildReportId_v0
227
+ migrate (BuildReportId_v0 bid) = BuildReportId bid
228
+
217
229
deriveSafeCopy 2 'extension ''BuildReportId
230
+
231
+ newtype BuildLog_v0 = BuildLog_v0 BlobStorage. BlobId_v0
232
+ deriving Serialize
233
+
234
+ instance SafeCopy BuildLog_v0 where
235
+ getCopy = contain get
236
+ putCopy = contain . put
237
+
238
+ instance Migrate BuildLog where
239
+ type MigrateFrom BuildLog = BuildLog_v0
240
+ migrate (BuildLog_v0 bl) = BuildLog (migrate bl)
241
+
218
242
deriveSafeCopy 2 'extension ''BuildLog
219
- deriveSafeCopy 3 'extension ''BuildReports
220
243
221
244
-- note: if the set of report ids is [1, 2, 3], then nextReportId = 4
222
245
-- after calling deleteReport for 3, the set is [1, 2] and nextReportId is still 4.
@@ -233,21 +256,16 @@ instance SafeCopy PkgBuildReports where
233
256
then BuildReportId 1
234
257
else incrementReportId (fst $ Map. findMax rs))
235
258
f
236
- instance MemSize BuildReports where
237
- memSize (BuildReports a) = memSize1 a
238
259
239
260
instance MemSize PkgBuildReports where
240
261
memSize (PkgBuildReports a b c) = memSize3 a b c
241
262
242
- -------------------
243
- -- Old V2 SafeCopy versions
244
- --
263
+
245
264
data PkgBuildReports_v2 = PkgBuildReports_v2 {
246
265
reports_v2 :: ! (Map BuildReportId (BuildReport , Maybe BuildLog )),
247
266
nextReportId_v2 :: ! BuildReportId
248
267
} deriving (Eq , Typeable , Show )
249
268
250
-
251
269
instance SafeCopy PkgBuildReports_v2 where
252
270
version = 2
253
271
kind = extension
@@ -262,6 +280,33 @@ instance SafeCopy PkgBuildReports_v2 where
262
280
instance MemSize PkgBuildReports_v2 where
263
281
memSize (PkgBuildReports_v2 a b) = memSize2 a b
264
282
283
+ data PkgBuildReports_v0 = PkgBuildReports_v0
284
+ ! (Map BuildReportId_v0 (BuildReport_v0 , Maybe BuildLog_v0 ))
285
+ ! BuildReportId_v0
286
+
287
+ instance SafeCopy PkgBuildReports_v0 where
288
+ getCopy = contain get
289
+ putCopy = contain . put
290
+
291
+ instance Serialize PkgBuildReports_v0 where
292
+ put (PkgBuildReports_v0 listing _) = Serialize. put listing
293
+ get = mkReports <$> Serialize. get
294
+ where
295
+ mkReports rs = PkgBuildReports_v0 rs
296
+ (if Map. null rs
297
+ then BuildReportId_v0 1
298
+ else succ (fst $ Map. findMax rs))
299
+
300
+ instance Migrate PkgBuildReports_v2 where
301
+ type MigrateFrom PkgBuildReports_v2 = PkgBuildReports_v0
302
+ migrate (PkgBuildReports_v0 m n) =
303
+ PkgBuildReports_v2 (migrateMap m) (migrate n)
304
+ where
305
+ migrateMap :: Map BuildReportId_v0 (BuildReport_v0 , Maybe BuildLog_v0 )
306
+ -> Map BuildReportId (BuildReport , Maybe BuildLog )
307
+ migrateMap = Map. mapKeys migrate
308
+ . Map. map (\ (br, l) -> (migrate (migrate br),
309
+ fmap migrate l))
265
310
266
311
instance Migrate PkgBuildReports where
267
312
type MigrateFrom PkgBuildReports = PkgBuildReports_v2
@@ -273,47 +318,6 @@ instance Migrate PkgBuildReports where
273
318
migrateMap = Map. mapKeys (\ x-> x)
274
319
. Map. map (\ (br, l) -> (br, l, Nothing ))
275
320
276
- ---
277
-
278
- data BuildReports_v2 = BuildReports_v2 {
279
- reportsIndex_v2 :: ! (Map. Map PackageId PkgBuildReports_v2 )
280
- } deriving (Eq , Typeable , Show )
281
-
282
- deriveSafeCopy 2 'extension ''BuildReports_v2
283
-
284
- instance MemSize BuildReports_v2 where
285
- memSize (BuildReports_v2 a) = memSize1 a
286
-
287
- instance Migrate BuildReports where
288
- type MigrateFrom BuildReports = BuildReports_v2
289
- migrate (BuildReports_v2 m) =
290
- BuildReports (Map. mapKeys (\ x-> x) $ Map. map migrate m)
291
- -------------------
292
- -- Old SafeCopy versions
293
- --
294
-
295
- newtype BuildReportId_v0 = BuildReportId_v0 Int deriving (Serialize , Enum , Eq , Ord )
296
- instance SafeCopy BuildReportId_v0 where
297
- getCopy = contain get
298
- putCopy = contain . put
299
-
300
- instance Migrate BuildReportId where
301
- type MigrateFrom BuildReportId = BuildReportId_v0
302
- migrate (BuildReportId_v0 bid) = BuildReportId bid
303
-
304
- ---
305
-
306
- newtype BuildLog_v0 = BuildLog_v0 BlobStorage. BlobId_v0 deriving Serialize
307
- instance SafeCopy BuildLog_v0 where
308
- getCopy = contain get
309
- putCopy = contain . put
310
-
311
-
312
- instance Migrate BuildLog where
313
- type MigrateFrom BuildLog = BuildLog_v0
314
- migrate (BuildLog_v0 bl) = BuildLog (migrate bl)
315
-
316
- ---
317
321
318
322
data BuildReports_v0 = BuildReports_v0
319
323
! (Map. Map PackageIdentifier_v0 PkgBuildReports_v0 )
@@ -326,37 +330,26 @@ instance Serialize BuildReports_v0 where
326
330
put (BuildReports_v0 index) = Serialize. put index
327
331
get = BuildReports_v0 <$> Serialize. get
328
332
333
+ data BuildReports_v2 = BuildReports_v2
334
+ { reportsIndex_v2 :: ! (Map. Map PackageId PkgBuildReports_v2 )
335
+ } deriving (Eq , Typeable , Show )
336
+
329
337
instance Migrate BuildReports_v2 where
330
338
type MigrateFrom BuildReports_v2 = BuildReports_v0
331
339
migrate (BuildReports_v0 m) =
332
340
BuildReports_v2 (Map. mapKeys migrate $ Map. map migrate m)
333
341
334
- ---
342
+ instance MemSize BuildReports_v2 where
343
+ memSize (BuildReports_v2 a) = memSize1 a
335
344
336
- data PkgBuildReports_v0 = PkgBuildReports_v0
337
- ! (Map BuildReportId_v0 (BuildReport_v0 , Maybe BuildLog_v0 ))
338
- ! BuildReportId_v0
345
+ deriveSafeCopy 2 'extension ''BuildReports_v2
339
346
340
- instance SafeCopy PkgBuildReports_v0 where
341
- getCopy = contain get
342
- putCopy = contain . put
347
+ instance Migrate BuildReports where
348
+ type MigrateFrom BuildReports = BuildReports_v2
349
+ migrate (BuildReports_v2 m) =
350
+ BuildReports (Map. mapKeys id $ Map. map migrate m)
343
351
344
- instance Serialize PkgBuildReports_v0 where
345
- put (PkgBuildReports_v0 listing _) = Serialize. put listing
346
- get = mkReports <$> Serialize. get
347
- where
348
- mkReports rs = PkgBuildReports_v0 rs
349
- (if Map. null rs
350
- then BuildReportId_v0 1
351
- else succ (fst $ Map. findMax rs))
352
+ instance MemSize BuildReports where
353
+ memSize (BuildReports a) = memSize1 a
352
354
353
- instance Migrate PkgBuildReports_v2 where
354
- type MigrateFrom PkgBuildReports_v2 = PkgBuildReports_v0
355
- migrate (PkgBuildReports_v0 m n) =
356
- PkgBuildReports_v2 (migrateMap m) (migrate n)
357
- where
358
- migrateMap :: Map BuildReportId_v0 (BuildReport_v0 , Maybe BuildLog_v0 )
359
- -> Map BuildReportId (BuildReport , Maybe BuildLog )
360
- migrateMap = Map. mapKeys migrate
361
- . Map. map (\ (br, l) -> (migrate (migrate br),
362
- fmap migrate l))
355
+ deriveSafeCopy 3 'extension ''BuildReports
0 commit comments