Fossil SCM
Cycle breaker, API extension. Added a hook to process the graph between setup and regular consummation. This will be used by pass 8.
Commit
1e177a4c916004be7d6736f8211ae4cbf87b7ac6
Parent
2cf0462b82ba2ec…
1 file changed
+22
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | ||
| @@ -31,10 +31,15 @@ | ||
| 31 | 31 | ## |
| 32 | 32 | |
| 33 | 33 | snit::type ::vc::fossil::import::cvs::cyclebreaker { |
| 34 | 34 | # # ## ### ##### ######## ############# |
| 35 | 35 | ## Public API |
| 36 | + | |
| 37 | + typemethod precmd {cmd} { | |
| 38 | + ::variable myprecmd $cmd | |
| 39 | + return | |
| 40 | + } | |
| 36 | 41 | |
| 37 | 42 | typemethod savecmd {cmd} { |
| 38 | 43 | ::variable mysavecmd $cmd |
| 39 | 44 | return |
| 40 | 45 | } |
| @@ -145,10 +150,14 @@ | ||
| 145 | 150 | if {![$dg node exists $succ]} continue |
| 146 | 151 | $dg arc insert $cset $succ |
| 147 | 152 | } |
| 148 | 153 | } |
| 149 | 154 | |
| 155 | + # Run the user hook to manipulate the graph before | |
| 156 | + # consummation. | |
| 157 | + | |
| 158 | + PreHook $dg | |
| 150 | 159 | return $dg |
| 151 | 160 | } |
| 152 | 161 | |
| 153 | 162 | # Instead of searching the whole graph for the degree-0 nodes in |
| 154 | 163 | # each iteration we compute the list once to start, and then only |
| @@ -339,10 +348,21 @@ | ||
| 339 | 348 | return |
| 340 | 349 | } |
| 341 | 350 | |
| 342 | 351 | # # ## ### ##### ######## ############# |
| 343 | 352 | ## Callback invokation ... |
| 353 | + | |
| 354 | + proc PreHook {graph} { | |
| 355 | + # Give the user of the cycle breaker the opportunity to work | |
| 356 | + # with the graph between setup and consummation. | |
| 357 | + | |
| 358 | + ::variable myprecmd | |
| 359 | + if {![llength $myprecmd]} return | |
| 360 | + | |
| 361 | + uplevel #0 [linsert $myprecmd end $graph] | |
| 362 | + return | |
| 363 | + } | |
| 344 | 364 | |
| 345 | 365 | proc ProcessedHook {cset pos} { |
| 346 | 366 | # Give the user of the cycle breaker the opportunity to work |
| 347 | 367 | # with the changeset before it is removed from the graph. |
| 348 | 368 | |
| @@ -366,10 +386,11 @@ | ||
| 366 | 386 | uplevel #0 [linsert $mybreakcmd end $graph] |
| 367 | 387 | return |
| 368 | 388 | } |
| 369 | 389 | |
| 370 | 390 | proc ClearHooks {} { |
| 391 | + ::variable myprecmd {} | |
| 371 | 392 | ::variable mysavecmd {} |
| 372 | 393 | ::variable mybreakcmd {} |
| 373 | 394 | return |
| 374 | 395 | } |
| 375 | 396 | |
| @@ -378,10 +399,11 @@ | ||
| 378 | 399 | typevariable myat 0 ; # Counter for commit ids for the |
| 379 | 400 | # changesets. |
| 380 | 401 | typevariable mybottom {} ; # List of the candidate nodes for |
| 381 | 402 | # committing. |
| 382 | 403 | |
| 404 | + typevariable myprecmd {} ; # Callback, change graph before walk. | |
| 383 | 405 | typevariable mysavecmd {} ; # Callback, for each processed node. |
| 384 | 406 | typevariable mybreakcmd {} ; # Callback, for each found cycle. |
| 385 | 407 | |
| 386 | 408 | typevariable mydotdestination {} ; # Destination directory for the |
| 387 | 409 | # generated .dot files. |
| 388 | 410 |
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| @@ -31,10 +31,15 @@ | |
| 31 | ## |
| 32 | |
| 33 | snit::type ::vc::fossil::import::cvs::cyclebreaker { |
| 34 | # # ## ### ##### ######## ############# |
| 35 | ## Public API |
| 36 | |
| 37 | typemethod savecmd {cmd} { |
| 38 | ::variable mysavecmd $cmd |
| 39 | return |
| 40 | } |
| @@ -145,10 +150,14 @@ | |
| 145 | if {![$dg node exists $succ]} continue |
| 146 | $dg arc insert $cset $succ |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | return $dg |
| 151 | } |
| 152 | |
| 153 | # Instead of searching the whole graph for the degree-0 nodes in |
| 154 | # each iteration we compute the list once to start, and then only |
| @@ -339,10 +348,21 @@ | |
| 339 | return |
| 340 | } |
| 341 | |
| 342 | # # ## ### ##### ######## ############# |
| 343 | ## Callback invokation ... |
| 344 | |
| 345 | proc ProcessedHook {cset pos} { |
| 346 | # Give the user of the cycle breaker the opportunity to work |
| 347 | # with the changeset before it is removed from the graph. |
| 348 | |
| @@ -366,10 +386,11 @@ | |
| 366 | uplevel #0 [linsert $mybreakcmd end $graph] |
| 367 | return |
| 368 | } |
| 369 | |
| 370 | proc ClearHooks {} { |
| 371 | ::variable mysavecmd {} |
| 372 | ::variable mybreakcmd {} |
| 373 | return |
| 374 | } |
| 375 | |
| @@ -378,10 +399,11 @@ | |
| 378 | typevariable myat 0 ; # Counter for commit ids for the |
| 379 | # changesets. |
| 380 | typevariable mybottom {} ; # List of the candidate nodes for |
| 381 | # committing. |
| 382 | |
| 383 | typevariable mysavecmd {} ; # Callback, for each processed node. |
| 384 | typevariable mybreakcmd {} ; # Callback, for each found cycle. |
| 385 | |
| 386 | typevariable mydotdestination {} ; # Destination directory for the |
| 387 | # generated .dot files. |
| 388 |
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| @@ -31,10 +31,15 @@ | |
| 31 | ## |
| 32 | |
| 33 | snit::type ::vc::fossil::import::cvs::cyclebreaker { |
| 34 | # # ## ### ##### ######## ############# |
| 35 | ## Public API |
| 36 | |
| 37 | typemethod precmd {cmd} { |
| 38 | ::variable myprecmd $cmd |
| 39 | return |
| 40 | } |
| 41 | |
| 42 | typemethod savecmd {cmd} { |
| 43 | ::variable mysavecmd $cmd |
| 44 | return |
| 45 | } |
| @@ -145,10 +150,14 @@ | |
| 150 | if {![$dg node exists $succ]} continue |
| 151 | $dg arc insert $cset $succ |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | # Run the user hook to manipulate the graph before |
| 156 | # consummation. |
| 157 | |
| 158 | PreHook $dg |
| 159 | return $dg |
| 160 | } |
| 161 | |
| 162 | # Instead of searching the whole graph for the degree-0 nodes in |
| 163 | # each iteration we compute the list once to start, and then only |
| @@ -339,10 +348,21 @@ | |
| 348 | return |
| 349 | } |
| 350 | |
| 351 | # # ## ### ##### ######## ############# |
| 352 | ## Callback invokation ... |
| 353 | |
| 354 | proc PreHook {graph} { |
| 355 | # Give the user of the cycle breaker the opportunity to work |
| 356 | # with the graph between setup and consummation. |
| 357 | |
| 358 | ::variable myprecmd |
| 359 | if {![llength $myprecmd]} return |
| 360 | |
| 361 | uplevel #0 [linsert $myprecmd end $graph] |
| 362 | return |
| 363 | } |
| 364 | |
| 365 | proc ProcessedHook {cset pos} { |
| 366 | # Give the user of the cycle breaker the opportunity to work |
| 367 | # with the changeset before it is removed from the graph. |
| 368 | |
| @@ -366,10 +386,11 @@ | |
| 386 | uplevel #0 [linsert $mybreakcmd end $graph] |
| 387 | return |
| 388 | } |
| 389 | |
| 390 | proc ClearHooks {} { |
| 391 | ::variable myprecmd {} |
| 392 | ::variable mysavecmd {} |
| 393 | ::variable mybreakcmd {} |
| 394 | return |
| 395 | } |
| 396 | |
| @@ -378,10 +399,11 @@ | |
| 399 | typevariable myat 0 ; # Counter for commit ids for the |
| 400 | # changesets. |
| 401 | typevariable mybottom {} ; # List of the candidate nodes for |
| 402 | # committing. |
| 403 | |
| 404 | typevariable myprecmd {} ; # Callback, change graph before walk. |
| 405 | typevariable mysavecmd {} ; # Callback, for each processed node. |
| 406 | typevariable mybreakcmd {} ; # Callback, for each found cycle. |
| 407 | |
| 408 | typevariable mydotdestination {} ; # Destination directory for the |
| 409 | # generated .dot files. |
| 410 |