Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_file.tcl part of check-in [b679ca3356] - Code cleanup. Removed trailing whitespace across the board. by aku on 2007-11-25 07:54:09. [view]

To:

File tools/cvs2fossil/lib/c2f_file.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]

@@ -21,8 +21,9 @@
 package require struct::set                         ; # Set operations.
 package require vc::fossil::import::cvs::file::rev  ; # CVS per file revisions.
 package require vc::fossil::import::cvs::file::sym  ; # CVS per file symbols.
 package require vc::fossil::import::cvs::state      ; # State storage.
+package require vc::fossil::import::cvs::integrity  ; # State integrity checks.
 package require vc::tools::trouble                  ; # Error reporting.
 package require vc::tools::log                      ; # User feedback
 package require vc::tools::misc                     ; # Text formatting
 
@@ -43,9 +44,9 @@
 	return
     }
 
     method setid {id} {
-	if {$myid ne ""} { trouble internal "File '$mypath' already has an id, '$myid'" }
+	integrity assert {$myid eq ""} {File '$mypath' already has an id, '$myid'}
 	set myid $id
 	return
     }
 
@@ -326,11 +327,9 @@
 	return
     }
 
     method Rev2Branch {revnr} {
-	if {[rev istrunkrevnr $revnr]} {
-	    trouble internal "Expected a branch revision number"
-	}
+        integrity assert {![rev istrunkrevnr $revnr]} {Expected a branch revision number}
 	return $mybranches([rev 2branchnr $revnr])
     }
 
     method AddUnlabeledBranch {branchnr} {
@@ -462,9 +461,9 @@
 	# their root (sic!).
 
 	foreach {revnr rev} [array get myrev] {
 	    if {[$rev hasparent]} continue
-	    if {$myroot ne ""} { trouble internal "Multiple root revisions found" }
+	    integrity assert {$myroot eq ""} {Multiple root revisions found}
 	    set myroot $rev
 	}
 
 	# In the future we also need a list, as branches can become
@@ -700,9 +699,9 @@
 
 	    # Cut out the vendor branch symbol
 
 	    set vendor [$first parentbranch]
-	    if {$vendor eq ""} { trouble internal "First NTDB revision has no branch" }
+	    integrity assert {$vendor ne ""} {First NTDB revision has no branch}
 	    if {[$vendor parent] eq $rev11} {
 		$rev11 removebranch        $vendor
 		$rev11 removechildonbranch $first
 		$vendor cutchild
@@ -955,11 +954,11 @@
 	    # --trunk-only.
 
 	    if {[$root hasdefaultbranchchild]} {
 		set ntdbchild [$root defaultbranchchild]
-		if {[$ntdbchild defaultbranchparent] ne $ntdbchild} {
-		    trouble internal "ntdb - trunk linkage broken"
-		}
+		integrity assert {
+		    [$ntdbchild defaultbranchparent] eq $ntdbchild
+		} {ntdb - trunk linkage broken}
 		$ntdbchild cutdefaultbranchparent
 		if {[$ntdbchild hasparent]} {
 		    lappend myroots [$ntdbchild parent]
 		}
@@ -975,10 +974,10 @@
 	# We can now graft the non-trunk default branch revisions to
 	# trunk. They should already be alone on a CVSBranch-less
 	# branch.
 
-	if {[$root hasparentbranch]} { trouble internal "NTDB root still has its branch symbol" }
-	if {[$root hasbranches]}     { trouble internal "NTDB root still has spawned branches" }
+	integrity assert {![$root hasparentbranch]} {NTDB root still has its branch symbol}
+	integrity assert {![$root hasbranches]}     {NTDB root still has spawned branches}
 
 	set last $root
 	while {[$last haschild]} {set last [$last child]}
 
@@ -1108,8 +1107,9 @@
 	namespace import ::vc::tools::misc::*
 	namespace import ::vc::tools::trouble
 	namespace import ::vc::tools::log
 	namespace import ::vc::fossil::import::cvs::state
+	namespace import ::vc::fossil::import::cvs::integrity
     }
 }
 
 # # ## ### ##### ######## ############# #####################