Fossil SCM

Added lots of checks looking for inconsistent references between the various objects, mainly revisions.

aku 2007-10-26 05:29 trunk
Commit 2434ad3bfe860659e3b41ca21a91d26a64f20a33
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -165,17 +165,10 @@
165165
root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from
166166
first INTEGER REFERENCES revision, -- First revision committed to the branch
167167
bra TEXT NOT NULL -- branch number
168168
}
169169
170
- # It is in principle possible to collapse the four tables
171
- # above (from item to barnch) into a single table, with
172
- # similar columns merged, and unused columns allowing NULL,
173
- # the use determined by the type. We may do that if the
174
- # performance is not good enough, but for now clarity of
175
- # structure over efficiency.
176
-
177170
# Project level ...
178171
# pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
179172
#
180173
# pTrunk <- pLineOfDevelopment
181174
# pBranch <- pSymbol, pLineOfDevelopment
@@ -296,10 +289,11 @@
296289
297290
repository printrevstatistics
298291
repository persistrev
299292
300293
log write 1 collrev "Scan completed"
294
+ Paranoia
301295
return
302296
}
303297
304298
typemethod discard {} {
305299
# Pass manager interface. Executed for all passes after the
@@ -315,10 +309,244 @@
315309
state discard meta
316310
state discard author
317311
state discard cmessage
318312
return
319313
}
314
+
315
+ proc Paranoia {} {
316
+ # This code performs a number of paranoid checks of the
317
+ # database for inconsistent cross-references.
318
+ log write 4 collrev {Check database consistency}
319
+
320
+ #
321
+ # +-> Symbol ------------------+
322
+ # | ^ | [1]
323
+ # | | V
324
+ # | Revision --> File --> Project
325
+ # | [3] | ^
326
+ # | V | [2]
327
+ # +--- Meta -------------------+
328
+ #
329
+
330
+ set n 0
331
+
332
+ # Find all revisions which disagree with their line of
333
+ # development about the project they are owned by.
334
+ Check \
335
+ {Revisions and their LODs have to be in the same project} \
336
+ {disagrees with its LOD about owning project} {
337
+ SELECT F.name, R.rev
338
+ FROM revision R, file F, symbol S
339
+ WHERE R.fid = F.fid
340
+ AND R.lod = S.sid
341
+ AND F.pid != S.pid
342
+ ;
343
+ }
344
+ # Find all revisions which disgree with their meta data about
345
+ # the project they are owned by.
346
+ Check \
347
+ {Revisions and their meta data have to be in the same project} \
348
+ {disagrees with its meta data about owning project} {
349
+ SELECT F.name, R.rev
350
+ FROM revision R, file F, meta M
351
+ WHERE R.fid = F.fid
352
+ AND R.mid = M.mid
353
+ AND F.pid != M.pid
354
+ ;
355
+ }
356
+ # Find all revisions which disgree with their meta data about
357
+ # the branch/line of development they belong to.
358
+ Check \
359
+ {Revisions and their meta data have to be in the same LOD} \
360
+ {disagrees with its meta data about owning LOD} {
361
+ SELECT F.name, R.rev
362
+ FROM revision R, meta M, file F
363
+ WHERE R.mid = M.mid
364
+ AND R.lod != M.bid
365
+ AND R.fid = F.fid
366
+ ;
367
+ }
368
+ # Find all revisions with a child which disagrees about the
369
+ # file they belong to.
370
+ Check \
371
+ {Revisions and their children have to be in the same file} \
372
+ {disagrees with its child about the owning file} {
373
+ SELECT F.name, R.rev
374
+ FROM revision R, revision C, file F
375
+ WHERE R.fid = F.fid
376
+ AND R.child IS NOT NULL
377
+ AND R.child = C.rid
378
+ AND C.fid != R.fid
379
+ ;
380
+ }
381
+ # Find all revisions with a non-NTDB child which disagrees
382
+ # about the file they belong to.
383
+ Check \
384
+ {Revisions and their non-NTDB children have to be in the same file} \
385
+ {disagrees with its non-NTDB child about the owning file} {
386
+ SELECT F.name, R.rev
387
+ FROM revision R, revision C, file F
388
+ WHERE R.fid = F.fid
389
+ AND R.dbchild IS NOT NULL
390
+ AND R.dbchild = C.rid
391
+ AND C.fid != R.fid
392
+ ;
393
+ }
394
+ # Find all revisions which have a child, but the child does
395
+ # not have them as parent.
396
+ Check \
397
+ {Revisions have to be parents of their children} \
398
+ {is not the parent of its child} {
399
+ SELECT F.name, R.rev
400
+ FROM revision R, revision C, file F
401
+ WHERE R.fid = F.fid
402
+ AND R.child IS NOT NULL
403
+ AND R.child = C.rid
404
+ AND C.parent != R.rid
405
+ ;
406
+ }
407
+ # Find all revisions which have a child, but the child has a
408
+ # branch parent.
409
+ Check \
410
+ {Revision's children must not be branch starters} \
411
+ {is parent of a child which is the beginning of a branch} {
412
+ SELECT F.name, R.rev
413
+ FROM revision R, revision C, file F
414
+ WHERE R.fid = F.fid
415
+ AND R.child IS NOT NULL
416
+ AND R.child = C.rid
417
+ AND C.bparent IS NOT NULL
418
+ ;
419
+ }
420
+ # Find all revisions without branch parent which have a
421
+ # parent, but the parent does not have them as child.
422
+ Check \
423
+ {Revisions have to be children of their parents} \
424
+ {is not the child of its parent} {
425
+ SELECT F.name, R.rev
426
+ FROM revision R, revision P, file F
427
+ WHERE R.fid = F.fid
428
+ AND R.bparent IS NULL
429
+ AND R.parent IS NOT NULL
430
+ AND R.parent = P.rid
431
+ AND P.child != R.rid
432
+ ;
433
+ }
434
+ # Find all revisions with a branch parent which do not have a
435
+ # parent.
436
+ Check \
437
+ {Branch starting revisions have to have a parent} \
438
+ {at the beginning of its branch has no parent} {
439
+ SELECT F.name, R.rev
440
+ FROM revision R, file F
441
+ WHERE R.fid = F.fid
442
+ AND R.bparent IS NOT NULL
443
+ AND R.parent IS NULL
444
+ ;
445
+ }
446
+ # Find all revisions with a branch parent whose parent has
447
+ # them as child.
448
+ Check \
449
+ {Branch starting revisions must not be children of their parents} \
450
+ {at the beginning of its branch is the child of its parent} {
451
+ SELECT F.name, R.rev
452
+ FROM revision R, revision P, file F
453
+ WHERE R.fid = F.fid
454
+ AND R.bparent IS NOT NULL
455
+ AND R.parent IS NOT NULL
456
+ AND R.parent = P.child
457
+ ;
458
+ }
459
+ # Find all revisions with a non-NTDB child which are not on
460
+ # the NTDB.
461
+ Check \
462
+ {NTDB to trunk transition has to begin on NTDB} \
463
+ {has a non-NTDB child, yet is not on the NTDB} {
464
+ SELECT F.name, R.rev
465
+ FROM revision R, file F
466
+ WHERE R.fid = F.fid
467
+ AND R.dbchild IS NOT NULL
468
+ AND NOT R.isdefault
469
+ ;
470
+ }
471
+ # Find all revisions with a NTDB parent which are on the NTDB.
472
+ Check \
473
+ {NTDB to trunk transition has to end on non-NTDB} \
474
+ {has a NTDB parent, yet is on the NTDB} {
475
+ SELECT F.name, R.rev
476
+ FROM revision R, file F
477
+ WHERE R.fid = F.fid
478
+ AND R.dbparent IS NOT NULL
479
+ AND R.isdefault
480
+ ;
481
+ }
482
+ # Find all revisions with a child which disagrees about the
483
+ # line of development they belong to.
484
+ Check \
485
+ {Revisions and their children have to be in the same LOD} \
486
+ {and its child disagree about their LOD} {
487
+
488
+ SELECT F.name, R.rev
489
+ FROM revision R, revision C, file F
490
+ WHERE R.fid = F.fid
491
+ AND R.child IS NOT NULL
492
+ AND R.child = C.rid
493
+ AND C.lod != R.lod
494
+ ;
495
+ }
496
+ # Find all revisions with a non-NTDB child which agrees about
497
+ # the line of development they belong to.
498
+ Check \
499
+ {NTDB and trunk revisions have to be in different LODs} \
500
+ {on NTDB and its non-NTDB child wrongly agree about their LOD} {
501
+
502
+ SELECT F.name, R.rev
503
+ FROM revision R, revision C, file F
504
+ WHERE R.fid = F.fid
505
+ AND R.dbchild IS NOT NULL
506
+ AND R.dbchild = C.rid
507
+ AND C.lod = R.lod
508
+ ;
509
+ }
510
+ # Find all revisions with a branch parent which is not their
511
+ # line of development.
512
+ Check \
513
+ {Branch starting revisions have to have their LOD as branch parent} \
514
+ {at the beginning of its branch does not have the branch as its LOD} {
515
+ SELECT F.name, R.rev
516
+ FROM revision R, file F
517
+ WHERE R.fid = F.fid
518
+ AND R.bparent IS NOT NULL
519
+ AND R.lod != R.bparent
520
+ ;
521
+ }
522
+ # Find all revisions with a branch parent whose parent is in
523
+ # the same line of development.
524
+ Check \
525
+ {Revisions and their branch children have to be in different LODs} \
526
+ {at the beginning of its branch and its parent wrongly agree about their LOD} {
527
+ SELECT F.name, R.rev
528
+ FROM revision R, revision P, file F
529
+ WHERE R.fid = F.fid
530
+ AND R.bparent IS NOT NULL
531
+ AND R.parent = P.rid
532
+ AND R.lod = P.lod
533
+ ;
534
+ }
535
+ return
536
+ }
537
+
538
+ proc Check {header label sql} {
539
+ upvar 1 n n
540
+ set ok 1
541
+ foreach {fname revnr} [state run $sql] {
542
+ set ok 0
543
+ trouble fatal "$fname <$revnr> $label"
544
+ }
545
+ log write 5 collrev "\[[format %02d [incr n]]\] [expr {$ok ? "Ok " : "Failed"}] ... $header"
546
+ return
547
+ }
320548
321549
# # ## ### ##### ######## #############
322550
## Internal methods
323551
324552
# # ## ### ##### ######## #############
325553
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -165,17 +165,10 @@
165 root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from
166 first INTEGER REFERENCES revision, -- First revision committed to the branch
167 bra TEXT NOT NULL -- branch number
168 }
169
170 # It is in principle possible to collapse the four tables
171 # above (from item to barnch) into a single table, with
172 # similar columns merged, and unused columns allowing NULL,
173 # the use determined by the type. We may do that if the
174 # performance is not good enough, but for now clarity of
175 # structure over efficiency.
176
177 # Project level ...
178 # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
179 #
180 # pTrunk <- pLineOfDevelopment
181 # pBranch <- pSymbol, pLineOfDevelopment
@@ -296,10 +289,11 @@
296
297 repository printrevstatistics
298 repository persistrev
299
300 log write 1 collrev "Scan completed"
 
301 return
302 }
303
304 typemethod discard {} {
305 # Pass manager interface. Executed for all passes after the
@@ -315,10 +309,244 @@
315 state discard meta
316 state discard author
317 state discard cmessage
318 return
319 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
321 # # ## ### ##### ######## #############
322 ## Internal methods
323
324 # # ## ### ##### ######## #############
325
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -165,17 +165,10 @@
165 root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from
166 first INTEGER REFERENCES revision, -- First revision committed to the branch
167 bra TEXT NOT NULL -- branch number
168 }
169
 
 
 
 
 
 
 
170 # Project level ...
171 # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
172 #
173 # pTrunk <- pLineOfDevelopment
174 # pBranch <- pSymbol, pLineOfDevelopment
@@ -296,10 +289,11 @@
289
290 repository printrevstatistics
291 repository persistrev
292
293 log write 1 collrev "Scan completed"
294 Paranoia
295 return
296 }
297
298 typemethod discard {} {
299 # Pass manager interface. Executed for all passes after the
@@ -315,10 +309,244 @@
309 state discard meta
310 state discard author
311 state discard cmessage
312 return
313 }
314
315 proc Paranoia {} {
316 # This code performs a number of paranoid checks of the
317 # database for inconsistent cross-references.
318 log write 4 collrev {Check database consistency}
319
320 #
321 # +-> Symbol ------------------+
322 # | ^ | [1]
323 # | | V
324 # | Revision --> File --> Project
325 # | [3] | ^
326 # | V | [2]
327 # +--- Meta -------------------+
328 #
329
330 set n 0
331
332 # Find all revisions which disagree with their line of
333 # development about the project they are owned by.
334 Check \
335 {Revisions and their LODs have to be in the same project} \
336 {disagrees with its LOD about owning project} {
337 SELECT F.name, R.rev
338 FROM revision R, file F, symbol S
339 WHERE R.fid = F.fid
340 AND R.lod = S.sid
341 AND F.pid != S.pid
342 ;
343 }
344 # Find all revisions which disgree with their meta data about
345 # the project they are owned by.
346 Check \
347 {Revisions and their meta data have to be in the same project} \
348 {disagrees with its meta data about owning project} {
349 SELECT F.name, R.rev
350 FROM revision R, file F, meta M
351 WHERE R.fid = F.fid
352 AND R.mid = M.mid
353 AND F.pid != M.pid
354 ;
355 }
356 # Find all revisions which disgree with their meta data about
357 # the branch/line of development they belong to.
358 Check \
359 {Revisions and their meta data have to be in the same LOD} \
360 {disagrees with its meta data about owning LOD} {
361 SELECT F.name, R.rev
362 FROM revision R, meta M, file F
363 WHERE R.mid = M.mid
364 AND R.lod != M.bid
365 AND R.fid = F.fid
366 ;
367 }
368 # Find all revisions with a child which disagrees about the
369 # file they belong to.
370 Check \
371 {Revisions and their children have to be in the same file} \
372 {disagrees with its child about the owning file} {
373 SELECT F.name, R.rev
374 FROM revision R, revision C, file F
375 WHERE R.fid = F.fid
376 AND R.child IS NOT NULL
377 AND R.child = C.rid
378 AND C.fid != R.fid
379 ;
380 }
381 # Find all revisions with a non-NTDB child which disagrees
382 # about the file they belong to.
383 Check \
384 {Revisions and their non-NTDB children have to be in the same file} \
385 {disagrees with its non-NTDB child about the owning file} {
386 SELECT F.name, R.rev
387 FROM revision R, revision C, file F
388 WHERE R.fid = F.fid
389 AND R.dbchild IS NOT NULL
390 AND R.dbchild = C.rid
391 AND C.fid != R.fid
392 ;
393 }
394 # Find all revisions which have a child, but the child does
395 # not have them as parent.
396 Check \
397 {Revisions have to be parents of their children} \
398 {is not the parent of its child} {
399 SELECT F.name, R.rev
400 FROM revision R, revision C, file F
401 WHERE R.fid = F.fid
402 AND R.child IS NOT NULL
403 AND R.child = C.rid
404 AND C.parent != R.rid
405 ;
406 }
407 # Find all revisions which have a child, but the child has a
408 # branch parent.
409 Check \
410 {Revision's children must not be branch starters} \
411 {is parent of a child which is the beginning of a branch} {
412 SELECT F.name, R.rev
413 FROM revision R, revision C, file F
414 WHERE R.fid = F.fid
415 AND R.child IS NOT NULL
416 AND R.child = C.rid
417 AND C.bparent IS NOT NULL
418 ;
419 }
420 # Find all revisions without branch parent which have a
421 # parent, but the parent does not have them as child.
422 Check \
423 {Revisions have to be children of their parents} \
424 {is not the child of its parent} {
425 SELECT F.name, R.rev
426 FROM revision R, revision P, file F
427 WHERE R.fid = F.fid
428 AND R.bparent IS NULL
429 AND R.parent IS NOT NULL
430 AND R.parent = P.rid
431 AND P.child != R.rid
432 ;
433 }
434 # Find all revisions with a branch parent which do not have a
435 # parent.
436 Check \
437 {Branch starting revisions have to have a parent} \
438 {at the beginning of its branch has no parent} {
439 SELECT F.name, R.rev
440 FROM revision R, file F
441 WHERE R.fid = F.fid
442 AND R.bparent IS NOT NULL
443 AND R.parent IS NULL
444 ;
445 }
446 # Find all revisions with a branch parent whose parent has
447 # them as child.
448 Check \
449 {Branch starting revisions must not be children of their parents} \
450 {at the beginning of its branch is the child of its parent} {
451 SELECT F.name, R.rev
452 FROM revision R, revision P, file F
453 WHERE R.fid = F.fid
454 AND R.bparent IS NOT NULL
455 AND R.parent IS NOT NULL
456 AND R.parent = P.child
457 ;
458 }
459 # Find all revisions with a non-NTDB child which are not on
460 # the NTDB.
461 Check \
462 {NTDB to trunk transition has to begin on NTDB} \
463 {has a non-NTDB child, yet is not on the NTDB} {
464 SELECT F.name, R.rev
465 FROM revision R, file F
466 WHERE R.fid = F.fid
467 AND R.dbchild IS NOT NULL
468 AND NOT R.isdefault
469 ;
470 }
471 # Find all revisions with a NTDB parent which are on the NTDB.
472 Check \
473 {NTDB to trunk transition has to end on non-NTDB} \
474 {has a NTDB parent, yet is on the NTDB} {
475 SELECT F.name, R.rev
476 FROM revision R, file F
477 WHERE R.fid = F.fid
478 AND R.dbparent IS NOT NULL
479 AND R.isdefault
480 ;
481 }
482 # Find all revisions with a child which disagrees about the
483 # line of development they belong to.
484 Check \
485 {Revisions and their children have to be in the same LOD} \
486 {and its child disagree about their LOD} {
487
488 SELECT F.name, R.rev
489 FROM revision R, revision C, file F
490 WHERE R.fid = F.fid
491 AND R.child IS NOT NULL
492 AND R.child = C.rid
493 AND C.lod != R.lod
494 ;
495 }
496 # Find all revisions with a non-NTDB child which agrees about
497 # the line of development they belong to.
498 Check \
499 {NTDB and trunk revisions have to be in different LODs} \
500 {on NTDB and its non-NTDB child wrongly agree about their LOD} {
501
502 SELECT F.name, R.rev
503 FROM revision R, revision C, file F
504 WHERE R.fid = F.fid
505 AND R.dbchild IS NOT NULL
506 AND R.dbchild = C.rid
507 AND C.lod = R.lod
508 ;
509 }
510 # Find all revisions with a branch parent which is not their
511 # line of development.
512 Check \
513 {Branch starting revisions have to have their LOD as branch parent} \
514 {at the beginning of its branch does not have the branch as its LOD} {
515 SELECT F.name, R.rev
516 FROM revision R, file F
517 WHERE R.fid = F.fid
518 AND R.bparent IS NOT NULL
519 AND R.lod != R.bparent
520 ;
521 }
522 # Find all revisions with a branch parent whose parent is in
523 # the same line of development.
524 Check \
525 {Revisions and their branch children have to be in different LODs} \
526 {at the beginning of its branch and its parent wrongly agree about their LOD} {
527 SELECT F.name, R.rev
528 FROM revision R, revision P, file F
529 WHERE R.fid = F.fid
530 AND R.bparent IS NOT NULL
531 AND R.parent = P.rid
532 AND R.lod = P.lod
533 ;
534 }
535 return
536 }
537
538 proc Check {header label sql} {
539 upvar 1 n n
540 set ok 1
541 foreach {fname revnr} [state run $sql] {
542 set ok 0
543 trouble fatal "$fname <$revnr> $label"
544 }
545 log write 5 collrev "\[[format %02d [incr n]]\] [expr {$ok ? "Ok " : "Failed"}] ... $header"
546 return
547 }
548
549 # # ## ### ##### ######## #############
550 ## Internal methods
551
552 # # ## ### ##### ######## #############
553

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button