Overview
SHA1 Hash: | 2cf0462b82ba2ecec92877f810562af2b7a8284d |
---|---|
Date: | 2007-11-21 04:05:53 |
User: | aku |
Comment: | 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. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified tools/cvs2fossil/lib/c2f_cyclebreaker.tcl from [9c7c517526] to [af14f4e127].
@@ -20,10 +20,11 @@ package require snit ; # OO system. package require struct::graph ; # Graph handling. package require struct::list ; # Higher order list operations. package require vc::tools::dot ; # User feedback. DOT export. package require vc::tools::log ; # User feedback. +package require vc::tools::trouble ; # Error reporting. package require vc::tools::misc ; # Text formatting. package require vc::fossil::import::cvs::project::rev ; # Project level changesets package require vc::fossil::import::cvs::project::revlink ; # Cycle links. # # ## ### ##### ######## ############# ##################### @@ -36,10 +37,17 @@ typemethod savecmd {cmd} { ::variable mysavecmd $cmd return } + typemethod breakcmd {cmd} { + ::variable mybreakcmd $cmd + return + } + + # # ## ### ##### ######## ############# + typemethod dotsto {path} { ::variable mydotdestination $path return } @@ -50,10 +58,12 @@ set dg [Setup $changesets 0] Mark $dg $dg destroy return } + + # # ## ### ##### ######## ############# typemethod run {label changesets} { ::variable myat 0 ::variable mydotprefix $label ::variable mydotid 0 @@ -77,22 +87,32 @@ log write 3 cyclebreaker {Now sorting the changesets, breaking cycles} InitializeCandidates $dg while {1} { while {[WithoutPredecessor $dg n]} { - SaveAndRemove $dg $n + ProcessedHook $n $myat + $dg node delete $n + incr myat } + if {![llength [dg nodes]]} break - BreakCycle $dg [FindCycle $dg] + + BreakCycleHook $dg InitializeCandidates $dg } dg destroy log write 3 cyclebreaker Done. - ClearHooks + return + } + + # # ## ### ##### ######## ############# + + typemethod break {graph} { + BreakCycle $graph [FindCycle $graph] return } # # ## ### ##### ######## ############# ## Internal methods @@ -173,18 +193,10 @@ # We do not delete the node immediately, to allow the Save # procedure to save the dependencies as well (encoded in the # arcs). return 1 - } - - proc SaveAndRemove {dg n} { - ::variable myat - ProcessedHook $n $myat - $dg node delete $n - incr myat - return } proc FindCycle {dg} { # This procedure is run if and only the graph is not empty and # all nodes have predecessors. This means that each node is @@ -339,12 +351,27 @@ uplevel #0 [linsert $mysavecmd end $pos $cset] return } + proc BreakCycleHook {graph} { + # Call out to the chosen algorithm for cycle breaking. Finding + # a cycle if no breaker was chosen is an error. + + ::variable mybreakcmd + if {![llength $mybreakcmd]} { + trouble fatal "Found a cycle, expecting none." + exit 1 + } + + uplevel #0 [linsert $mybreakcmd end $graph] + return + } + proc ClearHooks {} { - ::variable mysavecmd {} + ::variable mysavecmd {} + ::variable mybreakcmd {} return } # # ## ### ##### ######## ############# @@ -352,10 +379,11 @@ # changesets. typevariable mybottom {} ; # List of the candidate nodes for # committing. typevariable mysavecmd {} ; # Callback, for each processed node. + typevariable mybreakcmd {} ; # Callback, for each found cycle. typevariable mydotdestination {} ; # Destination directory for the # generated .dot files. typevariable mydotprefix {} ; # Prefix for dot files when # exporting the graphs. @@ -379,10 +407,11 @@ namespace import ::vc::fossil::import::cvs::project::rev namespace import ::vc::fossil::import::cvs::project::revlink } namespace import ::vc::tools::misc::* namespace import ::vc::tools::log + namespace import ::vc::tools::trouble namespace import ::vc::tools::dot log register cyclebreaker } }
Modified tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl from [d4b18e168b] to [1228cf6726].
@@ -75,11 +75,12 @@ # functionality of the pass. set changesets [Changesets] cyclebreaker dot break-rev-start $changesets - cyclebreaker savecmd [myproc SaveOrder] + cyclebreaker savecmd [myproc SaveOrder] + cyclebreaker breakcmd {::vc::fossil::import::cvs::cyclebreaker break} state transaction { cyclebreaker run break-rev $changesets }
Modified tools/cvs2fossil/lib/c2f_pbreakscycle.tcl from [e94461c91b] to [3177172d52].
@@ -60,19 +60,20 @@ typemethod run {} { # Pass manager interface. Executed to perform the # functionality of the pass. - set changesets [struct::list filter [project::rev all] [myproc IsBySymbol]] + set changesets [Changesets] cyclebreaker dot break-sym-start $changesets + + cyclebreaker breakcmd {::vc::fossil::import::cvs::cyclebreaker break} state transaction { cyclebreaker run break-sym $changesets } - set changesets [struct::list filter [project::rev all] [myproc IsBySymbol]] - cyclebreaker dot break-sym-done $changesets + cyclebreaker dot break-sym-done [Changesets] repository printcsetstatistics return } @@ -83,10 +84,14 @@ return } # # ## ### ##### ######## ############# ## Internal methods + + proc Changesets {} { + return [struct::list filter [project::rev all] [myproc IsBySymbol]] + } proc IsBySymbol {cset} { $cset bysymbol } # # ## ### ##### ######## ############# ## Configuration