Check-in [eabaea870a]
Not logged in
Overview

SHA1 Hash:eabaea870afdc22be494d98edac5b2fab37a30df
Date: 2007-11-24 04:15:46
User: aku
Comment:Added a number of assertions and must-not-happens with associated log output. Plus some small tweaks, and notes.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified tools/cvs2fossil/lib/c2f_cyclebreaker.tcl from [675dc7f03b] to [a02d54b2ad].

@@ -171,18 +171,42 @@
 	    foreach succ [$cset successors] {
 		# Changesets may have dependencies outside of the
 		# chosen set. These are ignored
 		if {![$dg node exists $succ]} continue
 		$dg arc insert $cset $succ
+
+		# Check for changesets referencing themselves. Such a
+		# loop shows that the changeset in question has
+		# internal dependencies. Something which is supposed
+		# to be not possible, as pass 5 (InitCsets) takes care
+		# to transform internal into external dependencies by
+		# breaking the relevant changesets apart. So having
+		# one indicates big trouble in pass 5. We report them
+		# and dump internal structures to make it easier to
+		# trace the links causing the problem.
+		if {$succ eq $cset} {
+		    trouble fatal "Self-referencing changeset <[$cset id]>"
+		    log write 2 cyclebreaker "LOOP changeset <[$cset id]> __________________"
+		    array set nmap [$cset nextmap]
+		    foreach r [lsort -dict [array names nmap]] {
+			foreach succrev $nmap($r) {
+			    log write 2 cyclebreaker \
+				"LOOP * rev <$r> --> rev <$succrev> --> cs [join [struct::list map [project::rev ofrev $succrev] [myproc ID]] { }]"
+			}
+		    }
+		}
 	    }
 	}
 
 	# Run the user hook to manipulate the graph before
 	# consummation.
 
 	if {$log} { Mark $dg -start }
 	PreHook $dg
+
+	# This kills the application if loops (see above) were found.
+	trouble abort?
 	return  $dg
     }
 
     # Instead of searching the whole graph for the degree-0 nodes in
     # each iteration we compute the list once to start, and then only
@@ -282,10 +306,11 @@
 	# The cycle we have gotten is broken by breaking apart one or
 	# more of the changesets in the cycle. This causes us to
 	# create one or more changesets which are to be committed,
 	# added to the graph, etc. pp.
 
+	# NOTE/TODO. Move this map operation to project::rev, as typemethod.
 	set cprint [join [struct::list map $cycle [myproc ID]] { }]
 
 	lappend cycle [lindex $cycle 0] [lindex $cycle 1]
 	set bestlink {}
 	set bestnode {}
@@ -373,10 +398,13 @@
 	    foreach succ [$cset successors] {
 		# The new changesets may have dependencies outside of
 		# the chosen set. These are ignored
 		if {![$dg node exists $succ]} continue
 		$dg arc insert $cset $succ
+		if {$succ eq $cset} {
+		    trouble internal "Self-referencing changeset <[$cset id]>"
+		}
 	    }
 	}
 	foreach cset $pre {
 	    foreach succ [$cset successors] {
 		# Note that the arc may already exist in the graph. If

Modified tools/cvs2fossil/lib/c2f_prev.tcl from [6a8631591f] to [3c9d1e003d].

@@ -315,10 +315,13 @@
 	$cset drop
 	$cset destroy
 
 	set newcsets {}
 	foreach fragmentrevisions $args {
+	    if {![llength $fragmentrevisions]} {
+		trouble internal "Attempted to create an empty changeset, i.e. without revisions"
+	    }
 	    lappend newcsets [$type %AUTO% $project $cstype $cssrc $fragmentrevisions]
 	}
 
 	foreach c $newcsets { $c persist }
 	return $newcsets
@@ -428,10 +431,11 @@
 	    if {$rid == $child} {
 		trouble internal "Revision $rid depends on itself."
 	    }
 	    lappend dependencies($rid) $child
 	}
+	return
     }
 
     proc PullPredecessorRevisions {dv revisions} {
 	upvar 1 $dv dependencies
 	set theset ('[join $revisions {','}]')
@@ -453,10 +457,11 @@
 	    if {$rid == $parent} {
 		trouble internal "Revision $rid depends on itself."
 	    }
 	    lappend dependencies($rid) $parent
 	}
+	return
     }
 
     proc InitializeBreakState {revisions} {
 	upvar 1 pos pos cross cross range range depc depc delta delta \
 	    dependencies dependencies