Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_integrity.tcl part of check-in [8c6488ded2] - Continued work on the integrity checks for changesets. Moved callers out of transactions. Two checks are already tripping on bad changesets made by InitCSets (pass 5). by aku on 2007-11-27 04:26:56. [view]

To:

File tools/cvs2fossil/lib/c2f_integrity.tcl part of check-in [47d52d1efd] - Added convenience method for assertions and used it in place of the existing if/trouble internal constructions. Changed API of 'log write' so that we can defer substituation of the message to when the write actually happen, and converted all places which would be hit by double-substitution. The remaining 'log write' calls will be converted incrementally. by aku on 2007-11-28 05:39:49. [view]

@@ -28,8 +28,15 @@
 snit::type ::vc::fossil::import::cvs::integrity {
     # # ## ### ##### ######## #############
     ## Public API
 
+    typemethod assert {expression failmessage} {
+	set ok [uplevel 1 [list ::expr $expression]]
+	if {$ok} return
+	trouble internal [uplevel 1 [list ::subst $failmessage]]
+	return
+    }
+
     typemethod strict {} {
 	log write 4 integrity {Check database consistency}
 
 	set n 0
@@ -516,9 +523,9 @@
 	foreach {fname revnr} [state run $sql] {
 	    set ok 0
 	    trouble fatal "$fname <$revnr> $label"
 	}
-	log write 5 integrity "\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header"
+	log write 5 integrity {\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header}
 	return
     }
 
     proc CheckCS {header label sql} {
@@ -527,9 +534,9 @@
 	foreach {ctype cid} [state run $sql] {
 	    set ok 0
 	    trouble fatal "<$ctype $cid> $label"
 	}
-	log write 5 integrity "\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header"
+	log write 5 integrity {\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header}
 	return
     }
 
     proc CheckInCS {header label sql} {
@@ -539,9 +546,9 @@
 	    set ok 0
 	    set b "<$cstype $csid>"
 	    trouble fatal "$fname <$revnr> [string map [list @ $b] $label]"
 	}
-	log write 5 integrity "\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header"
+	log write 5 integrity {\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header}
 	return
     }
 
     # # ## ### ##### ######## #############