Fossil SCM
Modified cycle breaker API. Hook for processed nodes now takes the graph as new first argument. Extended API, exposed method for dumping the current state of the graph, including ability to dump a sub graph.
Commit
5f5620fbd25ccc50fac7757fc38abfcb072270a5
Parent
86f3319041f2b26…
1 file changed
+11
-5
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | ||
| @@ -63,10 +63,15 @@ | ||
| 63 | 63 | set dg [Setup $changesets 0] |
| 64 | 64 | Mark $dg |
| 65 | 65 | $dg destroy |
| 66 | 66 | return |
| 67 | 67 | } |
| 68 | + | |
| 69 | + typemethod mark {graph suffix {subgraph {}}} { | |
| 70 | + Mark $graph $suffix $subgraph | |
| 71 | + return | |
| 72 | + } | |
| 68 | 73 | |
| 69 | 74 | # # ## ### ##### ######## ############# |
| 70 | 75 | |
| 71 | 76 | typemethod run {label changesetcmd} { |
| 72 | 77 | ::variable myat 0 |
| @@ -93,11 +98,11 @@ | ||
| 93 | 98 | log write 3 cyclebreaker {Now sorting the changesets, breaking cycles} |
| 94 | 99 | |
| 95 | 100 | InitializeCandidates $dg |
| 96 | 101 | while {1} { |
| 97 | 102 | while {[WithoutPredecessor $dg n]} { |
| 98 | - ProcessedHook $n $myat | |
| 103 | + ProcessedHook $dg $n $myat | |
| 99 | 104 | $dg node delete $n |
| 100 | 105 | incr myat |
| 101 | 106 | ShowPendingNodes |
| 102 | 107 | } |
| 103 | 108 | |
| @@ -149,10 +154,11 @@ | ||
| 149 | 154 | |
| 150 | 155 | foreach cset $changesets { |
| 151 | 156 | $dg node insert $cset |
| 152 | 157 | $dg node set $cset timerange [$cset timerange] |
| 153 | 158 | $dg node set $cset label [ID $cset] |
| 159 | + $dg node set $cset __id__ [$cset id] | |
| 154 | 160 | } |
| 155 | 161 | |
| 156 | 162 | # 2. Find for all relevant changeset their revisions and their |
| 157 | 163 | # dependencies. Map the latter back to changesets and |
| 158 | 164 | # construct the corresponding arcs. |
| @@ -329,18 +335,18 @@ | ||
| 329 | 335 | #8.5: return [expr {$b in [$dg nodes -out $a]}] |
| 330 | 336 | if {[lsearch -exact [$dg nodes -out $a] $b] < 0} { return 0 } |
| 331 | 337 | return 1 |
| 332 | 338 | } |
| 333 | 339 | |
| 334 | - proc Mark {dg {suffix {}}} { | |
| 340 | + proc Mark {dg {suffix {}} {subgraph {}}} { | |
| 335 | 341 | ::variable mydotdestination |
| 336 | 342 | if {$mydotdestination eq ""} return |
| 337 | 343 | ::variable mydotprefix |
| 338 | 344 | ::variable mydotid |
| 339 | 345 | set fname $mydotdestination/${mydotprefix}${mydotid}${suffix}.dot |
| 340 | 346 | file mkdir [file dirname $fname] |
| 341 | - dot write $dg $mydotprefix$suffix $fname | |
| 347 | + dot write $dg $mydotprefix$suffix $fname $subgraph | |
| 342 | 348 | incr mydotid |
| 343 | 349 | |
| 344 | 350 | log write 5 cyclebreaker ".dot export $fname" |
| 345 | 351 | return |
| 346 | 352 | } |
| @@ -397,18 +403,18 @@ | ||
| 397 | 403 | uplevel #0 [linsert $myprecmd end $graph] |
| 398 | 404 | Mark $graph -pre-done |
| 399 | 405 | return |
| 400 | 406 | } |
| 401 | 407 | |
| 402 | - proc ProcessedHook {cset pos} { | |
| 408 | + proc ProcessedHook {dg cset pos} { | |
| 403 | 409 | # Give the user of the cycle breaker the opportunity to work |
| 404 | 410 | # with the changeset before it is removed from the graph. |
| 405 | 411 | |
| 406 | 412 | ::variable mysavecmd |
| 407 | 413 | if {![llength $mysavecmd]} return |
| 408 | 414 | |
| 409 | - uplevel #0 [linsert $mysavecmd end $pos $cset] | |
| 415 | + uplevel #0 [linsert $mysavecmd end $dg $pos $cset] | |
| 410 | 416 | return |
| 411 | 417 | } |
| 412 | 418 | |
| 413 | 419 | proc BreakCycleHook {graph} { |
| 414 | 420 | # Call out to the chosen algorithm for cycle breaking. Finding |
| 415 | 421 |
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| @@ -63,10 +63,15 @@ | |
| 63 | set dg [Setup $changesets 0] |
| 64 | Mark $dg |
| 65 | $dg destroy |
| 66 | return |
| 67 | } |
| 68 | |
| 69 | # # ## ### ##### ######## ############# |
| 70 | |
| 71 | typemethod run {label changesetcmd} { |
| 72 | ::variable myat 0 |
| @@ -93,11 +98,11 @@ | |
| 93 | log write 3 cyclebreaker {Now sorting the changesets, breaking cycles} |
| 94 | |
| 95 | InitializeCandidates $dg |
| 96 | while {1} { |
| 97 | while {[WithoutPredecessor $dg n]} { |
| 98 | ProcessedHook $n $myat |
| 99 | $dg node delete $n |
| 100 | incr myat |
| 101 | ShowPendingNodes |
| 102 | } |
| 103 | |
| @@ -149,10 +154,11 @@ | |
| 149 | |
| 150 | foreach cset $changesets { |
| 151 | $dg node insert $cset |
| 152 | $dg node set $cset timerange [$cset timerange] |
| 153 | $dg node set $cset label [ID $cset] |
| 154 | } |
| 155 | |
| 156 | # 2. Find for all relevant changeset their revisions and their |
| 157 | # dependencies. Map the latter back to changesets and |
| 158 | # construct the corresponding arcs. |
| @@ -329,18 +335,18 @@ | |
| 329 | #8.5: return [expr {$b in [$dg nodes -out $a]}] |
| 330 | if {[lsearch -exact [$dg nodes -out $a] $b] < 0} { return 0 } |
| 331 | return 1 |
| 332 | } |
| 333 | |
| 334 | proc Mark {dg {suffix {}}} { |
| 335 | ::variable mydotdestination |
| 336 | if {$mydotdestination eq ""} return |
| 337 | ::variable mydotprefix |
| 338 | ::variable mydotid |
| 339 | set fname $mydotdestination/${mydotprefix}${mydotid}${suffix}.dot |
| 340 | file mkdir [file dirname $fname] |
| 341 | dot write $dg $mydotprefix$suffix $fname |
| 342 | incr mydotid |
| 343 | |
| 344 | log write 5 cyclebreaker ".dot export $fname" |
| 345 | return |
| 346 | } |
| @@ -397,18 +403,18 @@ | |
| 397 | uplevel #0 [linsert $myprecmd end $graph] |
| 398 | Mark $graph -pre-done |
| 399 | return |
| 400 | } |
| 401 | |
| 402 | proc ProcessedHook {cset pos} { |
| 403 | # Give the user of the cycle breaker the opportunity to work |
| 404 | # with the changeset before it is removed from the graph. |
| 405 | |
| 406 | ::variable mysavecmd |
| 407 | if {![llength $mysavecmd]} return |
| 408 | |
| 409 | uplevel #0 [linsert $mysavecmd end $pos $cset] |
| 410 | return |
| 411 | } |
| 412 | |
| 413 | proc BreakCycleHook {graph} { |
| 414 | # Call out to the chosen algorithm for cycle breaking. Finding |
| 415 |
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| @@ -63,10 +63,15 @@ | |
| 63 | set dg [Setup $changesets 0] |
| 64 | Mark $dg |
| 65 | $dg destroy |
| 66 | return |
| 67 | } |
| 68 | |
| 69 | typemethod mark {graph suffix {subgraph {}}} { |
| 70 | Mark $graph $suffix $subgraph |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | # # ## ### ##### ######## ############# |
| 75 | |
| 76 | typemethod run {label changesetcmd} { |
| 77 | ::variable myat 0 |
| @@ -93,11 +98,11 @@ | |
| 98 | log write 3 cyclebreaker {Now sorting the changesets, breaking cycles} |
| 99 | |
| 100 | InitializeCandidates $dg |
| 101 | while {1} { |
| 102 | while {[WithoutPredecessor $dg n]} { |
| 103 | ProcessedHook $dg $n $myat |
| 104 | $dg node delete $n |
| 105 | incr myat |
| 106 | ShowPendingNodes |
| 107 | } |
| 108 | |
| @@ -149,10 +154,11 @@ | |
| 154 | |
| 155 | foreach cset $changesets { |
| 156 | $dg node insert $cset |
| 157 | $dg node set $cset timerange [$cset timerange] |
| 158 | $dg node set $cset label [ID $cset] |
| 159 | $dg node set $cset __id__ [$cset id] |
| 160 | } |
| 161 | |
| 162 | # 2. Find for all relevant changeset their revisions and their |
| 163 | # dependencies. Map the latter back to changesets and |
| 164 | # construct the corresponding arcs. |
| @@ -329,18 +335,18 @@ | |
| 335 | #8.5: return [expr {$b in [$dg nodes -out $a]}] |
| 336 | if {[lsearch -exact [$dg nodes -out $a] $b] < 0} { return 0 } |
| 337 | return 1 |
| 338 | } |
| 339 | |
| 340 | proc Mark {dg {suffix {}} {subgraph {}}} { |
| 341 | ::variable mydotdestination |
| 342 | if {$mydotdestination eq ""} return |
| 343 | ::variable mydotprefix |
| 344 | ::variable mydotid |
| 345 | set fname $mydotdestination/${mydotprefix}${mydotid}${suffix}.dot |
| 346 | file mkdir [file dirname $fname] |
| 347 | dot write $dg $mydotprefix$suffix $fname $subgraph |
| 348 | incr mydotid |
| 349 | |
| 350 | log write 5 cyclebreaker ".dot export $fname" |
| 351 | return |
| 352 | } |
| @@ -397,18 +403,18 @@ | |
| 403 | uplevel #0 [linsert $myprecmd end $graph] |
| 404 | Mark $graph -pre-done |
| 405 | return |
| 406 | } |
| 407 | |
| 408 | proc ProcessedHook {dg cset pos} { |
| 409 | # Give the user of the cycle breaker the opportunity to work |
| 410 | # with the changeset before it is removed from the graph. |
| 411 | |
| 412 | ::variable mysavecmd |
| 413 | if {![llength $mysavecmd]} return |
| 414 | |
| 415 | uplevel #0 [linsert $mysavecmd end $dg $pos $cset] |
| 416 | return |
| 417 | } |
| 418 | |
| 419 | proc BreakCycleHook {graph} { |
| 420 | # Call out to the chosen algorithm for cycle breaking. Finding |
| 421 |