Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_cyclebreaker.tcl part of check-in [a99d5798f6] - Added missing node attributes in the Replace command. by aku on 2007-11-24 03:59:55. [view]

To:

File tools/cvs2fossil/lib/c2f_cyclebreaker.tcl part of check-in [eabaea870a] - Added a number of assertions and must-not-happens with associated log output. Plus some small tweaks, and notes. by aku on 2007-11-24 04:15:46. [view]

@@ -172,8 +172,29 @@
 		# 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
@@ -180,8 +201,11 @@
 	# 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
@@ -283,8 +307,9 @@
 	# 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 {}
@@ -374,8 +399,11 @@
 		# 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] {