Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_cyclebreaker.tcl part of check-in [54e9b0a143] - Tweaks of the log output, and reworked internals to expose not only breaking of cycles, but of paths as well. by aku on 2007-11-25 02:51:50. [view]

To:

File tools/cvs2fossil/lib/c2f_cyclebreaker.tcl part of check-in [97b4405ecf] - Extended cycle breaker with debug facility allowing the user to watch the neighbourhood of specific changesets during the traversal. Extended label information, highlighting of the nodes of interest. Tweaked log output a bit. by aku on 2007-11-25 07:35:30. [view]

@@ -55,8 +55,13 @@
 	::variable mydotdestination $path
 	return
     }
 
+    typemethod watch {id} {
+	::variable mywatchids
+	lappend mywatchids $id
+    }
+
     typemethod dot {label changesets} {
 	::variable mydotprefix $label
 	::variable mydotid     0
 
@@ -99,8 +104,9 @@
 
 	InitializeCandidates $dg
 	while {1} {
 	    while {[WithoutPredecessor $dg n]} {
+		MarkWatch $dg
 		ProcessedHook $dg $n $myat
 		$dg node delete $n
 		incr myat
 		ShowPendingNodes
@@ -109,8 +115,9 @@
 	    if {![llength [dg nodes]]} break
 
 	    BreakCycleHook       $dg
 	    InitializeCandidates $dg
+	    MarkWatch            $dg
 	}
 
 	$dg destroy
 
@@ -161,27 +168,31 @@
     ## Internal methods
 
     proc Setup {changesets {log 1}} {
 	if {$log} {
-	    log write 3 cyclebreaker "Create changeset graph, [nsp [llength $changesets] node]"
+	    log write 3 cyclebreaker "Creating graph of changesets"
 	}
 
 	set dg [struct::graph dg]
 
 	foreach cset $changesets {
+	    set tr [$cset timerange]
 	    $dg node insert $cset
-	    $dg node set    $cset timerange [$cset timerange]
-	    $dg node set    $cset label     [$cset str]
+	    $dg node set    $cset timerange $tr
+	    $dg node set    $cset label     "[$cset str]\\n[join [struct::list map $tr {::clock format}] "\\n"]"
 	    $dg node set    $cset __id__    [$cset id]
+	    $dg node set    $cset shape     [expr {[$cset bysymbol]
+						   ? "ellipse"
+						   : "box"}]
+	}
+
+	if {$log} {
+	    log write 3 cyclebreaker "Has [nsp [llength $changesets] changeset]"
 	}
 
 	# 2. Find for all relevant changeset their revisions and their
 	#    dependencies. Map the latter back to changesets and
 	#    construct the corresponding arcs.
-
-	if {$log} {
-	    log write 3 cyclebreaker {Setting up node dependencies}
-	}
 
 	foreach cset $changesets {
 	    foreach succ [$cset successors] {
 		# Changesets may have dependencies outside of the
@@ -211,13 +222,19 @@
 		}
 	    }
 	}
 
+	if {$log} {
+	    log write 3 cyclebreaker "Has [nsp [llength [$dg arcs]] dependency dependencies]"
+	}
+
 	# Run the user hook to manipulate the graph before
 	# consummation.
 
 	if {$log} { Mark $dg -start }
-	PreHook $dg
+	MarkWatch $dg
+	PreHook   $dg
+	MarkWatch $dg
 
 	# This kills the application if loops (see above) were found.
 	trouble abort?
 	return  $dg
@@ -396,12 +413,16 @@
 
         $dg node delete $n
 
 	foreach cset $replacements {
+	    set tr [$cset timerange]
 	    $dg node insert $cset
-	    $dg node set    $cset timerange [$cset timerange]
-	    $dg node set    $cset label     [$cset str]
+	    $dg node set    $cset timerange $tr
+	    $dg node set    $cset label     "[$cset str]\\n[join [struct::list map $tr {::clock format}] "\\n"]"
 	    $dg node set    $cset __id__    [$cset id]
+	    $dg node set    $cset shape     [expr {[$cset bysymbol]
+						   ? "ellipse"
+						   : "box"}]
 	}
 
 	foreach cset $replacements {
 	    foreach succ [$cset successors] {
@@ -477,8 +498,33 @@
     }
 
     # # ## ### ##### ######## #############
 
+    proc MarkWatch {graph} {
+	::variable mywatchids
+	set watched [Watched $graph $mywatchids]
+	if {![llength $watched]} return
+	set neighbours [eval [linsert $watched 0 $graph nodes -adj]]
+	#foreach n $neighbours { log write 6 cyclebreaker "Neighbor [$n id] => $n" }
+	Mark $graph watched [concat $watched $neighbours]
+	return
+    }
+
+    proc Watched {graph watchids} {
+	set res {}
+	foreach id $watchids {
+	    set nl [$graph nodes -key __id__ -value $id]
+	    if {![llength $nl]} continue
+	    lappend res $nl
+	    #log write 6 breakrcycle "Watching $id => $nl"
+	    $graph node set $nl fontcolor red
+	}
+	return $res
+    }
+
+    # # ## ### ##### ######## #############
+
+
     typevariable myat      0 ; # Counter for commit ids for the
 			       # changesets.
     typevariable mybottom {} ; # List of the candidate nodes for
 			       # committing.
@@ -492,8 +538,10 @@
     typevariable mydotprefix      {} ; # Prefix for dot files when
 				       # exporting the graphs.
     typevariable mydotid           0 ; # Counter for dot file name
 				       # generation.
+    typevariable mywatchids       {} ; # Changesets to watch the
+				       # neighbourhood of.
 
     # # ## ### ##### ######## #############
     ## Configuration