Differences From:
File
tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
part of check-in
[2cf0462b82]
- Cycle breaker, API change. Routing the core cycle breaking through a callback so that users can choose their own algorithms. Updated passes 6 and 7. Moven changesets selection in pass 7 to separate command.
by
aku on
2007-11-21 04:05:53.
[view]
To:
File
tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
part of check-in
[1e177a4c91]
- Cycle breaker, API extension. Added a hook to process the graph between setup and regular consummation. This will be used by pass 8.
by
aku on
2007-11-21 04:11:59.
[view]
@@ -33,8 +33,13 @@
snit::type ::vc::fossil::import::cvs::cyclebreaker {
# # ## ### ##### ######## #############
## Public API
+ typemethod precmd {cmd} {
+ ::variable myprecmd $cmd
+ return
+ }
+
typemethod savecmd {cmd} {
::variable mysavecmd $cmd
return
}
@@ -146,8 +151,12 @@
$dg arc insert $cset $succ
}
}
+ # Run the user hook to manipulate the graph before
+ # consummation.
+
+ PreHook $dg
return $dg
}
# Instead of searching the whole graph for the degree-0 nodes in
@@ -341,8 +350,19 @@
# # ## ### ##### ######## #############
## Callback invokation ...
+ proc PreHook {graph} {
+ # Give the user of the cycle breaker the opportunity to work
+ # with the graph between setup and consummation.
+
+ ::variable myprecmd
+ if {![llength $myprecmd]} return
+
+ uplevel #0 [linsert $myprecmd end $graph]
+ return
+ }
+
proc ProcessedHook {cset pos} {
# Give the user of the cycle breaker the opportunity to work
# with the changeset before it is removed from the graph.
@@ -367,8 +387,9 @@
return
}
proc ClearHooks {} {
+ ::variable myprecmd {}
::variable mysavecmd {}
::variable mybreakcmd {}
return
}
@@ -379,8 +400,9 @@
# changesets.
typevariable mybottom {} ; # List of the candidate nodes for
# committing.
+ typevariable myprecmd {} ; # Callback, change graph before walk.
typevariable mysavecmd {} ; # Callback, for each processed node.
typevariable mybreakcmd {} ; # Callback, for each found cycle.
typevariable mydotdestination {} ; # Destination directory for the