Fossil SCM
Tweaks of the log output, and reworked internals to expose not only breaking of cycles, but of paths as well.
Commit
54e9b0a1439023bd37ee40edc6f6ccb1b5b23213
Parent
87cf60902113c75…
1 file changed
+29
-18
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | ||
| @@ -93,11 +93,11 @@ | ||
| 93 | 93 | # the nodes which have no predecessors, in order from |
| 94 | 94 | # oldest to youngest, saving and removing dependencies. If |
| 95 | 95 | # we find no nodes without predecessors we have a cycle, |
| 96 | 96 | # and work on breaking it. |
| 97 | 97 | |
| 98 | - log write 3 cyclebreaker {Now sorting the changesets, breaking cycles} | |
| 98 | + log write 3 cyclebreaker {Traverse changesets} | |
| 99 | 99 | |
| 100 | 100 | InitializeCandidates $dg |
| 101 | 101 | while {1} { |
| 102 | 102 | while {[WithoutPredecessor $dg n]} { |
| 103 | 103 | ProcessedHook $dg $n $myat |
| @@ -128,13 +128,29 @@ | ||
| 128 | 128 | $dg destroy |
| 129 | 129 | return |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | # # ## ### ##### ######## ############# |
| 133 | + | |
| 134 | + typemethod break-segment {graph} { | |
| 135 | + BreakSegment $graph $path "segment ([project::rev strlist $path])" | |
| 136 | + return | |
| 137 | + } | |
| 133 | 138 | |
| 134 | 139 | typemethod break {graph} { |
| 135 | - BreakCycle $graph [FindCycle $graph] | |
| 140 | + set cycle [FindCycle $graph] | |
| 141 | + set label "cycle ([project::rev strlist $cycle])" | |
| 142 | + | |
| 143 | + # NOTE: cvs2svn uses the sequence "end-1, cycle, 0" to create | |
| 144 | + # the path from the cycle. The only effect I can see is | |
| 145 | + # that this causes the link-triples to be generated in a | |
| 146 | + # sightly different order, i.e. one link rotated to the | |
| 147 | + # right. This should have no effect on the search for | |
| 148 | + # the best of all. | |
| 149 | + | |
| 150 | + lappend cycle [lindex $cycle 0] [lindex $cycle 1] | |
| 151 | + BreakSegment $graph $cycle $label | |
| 136 | 152 | return |
| 137 | 153 | } |
| 138 | 154 | |
| 139 | 155 | typemethod replace {graph n replacements} { |
| 140 | 156 | Replace $graph $n $replacements |
| @@ -144,12 +160,11 @@ | ||
| 144 | 160 | # # ## ### ##### ######## ############# |
| 145 | 161 | ## Internal methods |
| 146 | 162 | |
| 147 | 163 | proc Setup {changesets {log 1}} { |
| 148 | 164 | if {$log} { |
| 149 | - log write 3 cyclebreaker "Creating changeset graph, filling with nodes" | |
| 150 | - log write 3 cyclebreaker "Adding [nsp [llength $changesets] node]" | |
| 165 | + log write 3 cyclebreaker "Create changeset graph, [nsp [llength $changesets] node]" | |
| 151 | 166 | } |
| 152 | 167 | |
| 153 | 168 | set dg [struct::graph dg] |
| 154 | 169 | |
| 155 | 170 | foreach cset $changesets { |
| @@ -298,27 +313,23 @@ | ||
| 298 | 313 | } |
| 299 | 314 | |
| 300 | 315 | return [struct::list reverse [lrange $path $seen($start) end]] |
| 301 | 316 | } |
| 302 | 317 | |
| 303 | - proc BreakCycle {dg cycle} { | |
| 304 | - # The cycle we have gotten is broken by breaking apart one or | |
| 305 | - # more of the changesets in the cycle. This causes us to | |
| 306 | - # create one or more changesets which are to be committed, | |
| 307 | - # added to the graph, etc. pp. | |
| 308 | - | |
| 309 | - # NOTE/TODO. Move this map operation to project::rev, as typemethod. | |
| 310 | - set cprint [project::rev strlist $cycle] | |
| 311 | - | |
| 312 | - lappend cycle [lindex $cycle 0] [lindex $cycle 1] | |
| 318 | + proc BreakSegment {dg path label} { | |
| 319 | + # The path, usually a cycle, we have gotten is broken by | |
| 320 | + # breaking apart one or more of the changesets in the | |
| 321 | + # cycle. This causes us to create one or more changesets which | |
| 322 | + # are to be committed, added to the graph, etc. pp. | |
| 323 | + | |
| 313 | 324 | set bestlink {} |
| 314 | 325 | set bestnode {} |
| 315 | 326 | |
| 316 | 327 | foreach \ |
| 317 | - prev [lrange $cycle 0 end-2] \ | |
| 318 | - cset [lrange $cycle 1 end-1] \ | |
| 319 | - next [lrange $cycle 2 end] { | |
| 328 | + prev [lrange $path 0 end-2] \ | |
| 329 | + cset [lrange $path 1 end-1] \ | |
| 330 | + next [lrange $path 2 end] { | |
| 320 | 331 | |
| 321 | 332 | # Each triple PREV -> CSET -> NEXT of changesets, a |
| 322 | 333 | # 'link' in the cycle, is analysed and the best |
| 323 | 334 | # location where to at least weaken the cycle is |
| 324 | 335 | # chosen for further processing. |
| @@ -334,11 +345,11 @@ | ||
| 334 | 345 | } else { |
| 335 | 346 | $link destroy |
| 336 | 347 | } |
| 337 | 348 | } |
| 338 | 349 | |
| 339 | - log write 5 cyclebreaker "Breaking cycle ($cprint) by splitting changeset [$bestnode str]" | |
| 350 | + log write 5 cyclebreaker "Breaking $label by splitting changeset [$bestnode str]" | |
| 340 | 351 | set ID [$bestnode id] |
| 341 | 352 | Mark $dg -${ID}-before |
| 342 | 353 | |
| 343 | 354 | set newcsets [$bestlink break] |
| 344 | 355 | $bestlink destroy |
| 345 | 356 |
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| @@ -93,11 +93,11 @@ | |
| 93 | # the nodes which have no predecessors, in order from |
| 94 | # oldest to youngest, saving and removing dependencies. If |
| 95 | # we find no nodes without predecessors we have a cycle, |
| 96 | # and work on breaking it. |
| 97 | |
| 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 |
| @@ -128,13 +128,29 @@ | |
| 128 | $dg destroy |
| 129 | return |
| 130 | } |
| 131 | |
| 132 | # # ## ### ##### ######## ############# |
| 133 | |
| 134 | typemethod break {graph} { |
| 135 | BreakCycle $graph [FindCycle $graph] |
| 136 | return |
| 137 | } |
| 138 | |
| 139 | typemethod replace {graph n replacements} { |
| 140 | Replace $graph $n $replacements |
| @@ -144,12 +160,11 @@ | |
| 144 | # # ## ### ##### ######## ############# |
| 145 | ## Internal methods |
| 146 | |
| 147 | proc Setup {changesets {log 1}} { |
| 148 | if {$log} { |
| 149 | log write 3 cyclebreaker "Creating changeset graph, filling with nodes" |
| 150 | log write 3 cyclebreaker "Adding [nsp [llength $changesets] node]" |
| 151 | } |
| 152 | |
| 153 | set dg [struct::graph dg] |
| 154 | |
| 155 | foreach cset $changesets { |
| @@ -298,27 +313,23 @@ | |
| 298 | } |
| 299 | |
| 300 | return [struct::list reverse [lrange $path $seen($start) end]] |
| 301 | } |
| 302 | |
| 303 | proc BreakCycle {dg cycle} { |
| 304 | # The cycle we have gotten is broken by breaking apart one or |
| 305 | # more of the changesets in the cycle. This causes us to |
| 306 | # create one or more changesets which are to be committed, |
| 307 | # added to the graph, etc. pp. |
| 308 | |
| 309 | # NOTE/TODO. Move this map operation to project::rev, as typemethod. |
| 310 | set cprint [project::rev strlist $cycle] |
| 311 | |
| 312 | lappend cycle [lindex $cycle 0] [lindex $cycle 1] |
| 313 | set bestlink {} |
| 314 | set bestnode {} |
| 315 | |
| 316 | foreach \ |
| 317 | prev [lrange $cycle 0 end-2] \ |
| 318 | cset [lrange $cycle 1 end-1] \ |
| 319 | next [lrange $cycle 2 end] { |
| 320 | |
| 321 | # Each triple PREV -> CSET -> NEXT of changesets, a |
| 322 | # 'link' in the cycle, is analysed and the best |
| 323 | # location where to at least weaken the cycle is |
| 324 | # chosen for further processing. |
| @@ -334,11 +345,11 @@ | |
| 334 | } else { |
| 335 | $link destroy |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | log write 5 cyclebreaker "Breaking cycle ($cprint) by splitting changeset [$bestnode str]" |
| 340 | set ID [$bestnode id] |
| 341 | Mark $dg -${ID}-before |
| 342 | |
| 343 | set newcsets [$bestlink break] |
| 344 | $bestlink destroy |
| 345 |
| --- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| +++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl | |
| @@ -93,11 +93,11 @@ | |
| 93 | # the nodes which have no predecessors, in order from |
| 94 | # oldest to youngest, saving and removing dependencies. If |
| 95 | # we find no nodes without predecessors we have a cycle, |
| 96 | # and work on breaking it. |
| 97 | |
| 98 | log write 3 cyclebreaker {Traverse changesets} |
| 99 | |
| 100 | InitializeCandidates $dg |
| 101 | while {1} { |
| 102 | while {[WithoutPredecessor $dg n]} { |
| 103 | ProcessedHook $dg $n $myat |
| @@ -128,13 +128,29 @@ | |
| 128 | $dg destroy |
| 129 | return |
| 130 | } |
| 131 | |
| 132 | # # ## ### ##### ######## ############# |
| 133 | |
| 134 | typemethod break-segment {graph} { |
| 135 | BreakSegment $graph $path "segment ([project::rev strlist $path])" |
| 136 | return |
| 137 | } |
| 138 | |
| 139 | typemethod break {graph} { |
| 140 | set cycle [FindCycle $graph] |
| 141 | set label "cycle ([project::rev strlist $cycle])" |
| 142 | |
| 143 | # NOTE: cvs2svn uses the sequence "end-1, cycle, 0" to create |
| 144 | # the path from the cycle. The only effect I can see is |
| 145 | # that this causes the link-triples to be generated in a |
| 146 | # sightly different order, i.e. one link rotated to the |
| 147 | # right. This should have no effect on the search for |
| 148 | # the best of all. |
| 149 | |
| 150 | lappend cycle [lindex $cycle 0] [lindex $cycle 1] |
| 151 | BreakSegment $graph $cycle $label |
| 152 | return |
| 153 | } |
| 154 | |
| 155 | typemethod replace {graph n replacements} { |
| 156 | Replace $graph $n $replacements |
| @@ -144,12 +160,11 @@ | |
| 160 | # # ## ### ##### ######## ############# |
| 161 | ## Internal methods |
| 162 | |
| 163 | proc Setup {changesets {log 1}} { |
| 164 | if {$log} { |
| 165 | log write 3 cyclebreaker "Create changeset graph, [nsp [llength $changesets] node]" |
| 166 | } |
| 167 | |
| 168 | set dg [struct::graph dg] |
| 169 | |
| 170 | foreach cset $changesets { |
| @@ -298,27 +313,23 @@ | |
| 313 | } |
| 314 | |
| 315 | return [struct::list reverse [lrange $path $seen($start) end]] |
| 316 | } |
| 317 | |
| 318 | proc BreakSegment {dg path label} { |
| 319 | # The path, usually a cycle, we have gotten is broken by |
| 320 | # breaking apart one or more of the changesets in the |
| 321 | # cycle. This causes us to create one or more changesets which |
| 322 | # are to be committed, added to the graph, etc. pp. |
| 323 | |
| 324 | set bestlink {} |
| 325 | set bestnode {} |
| 326 | |
| 327 | foreach \ |
| 328 | prev [lrange $path 0 end-2] \ |
| 329 | cset [lrange $path 1 end-1] \ |
| 330 | next [lrange $path 2 end] { |
| 331 | |
| 332 | # Each triple PREV -> CSET -> NEXT of changesets, a |
| 333 | # 'link' in the cycle, is analysed and the best |
| 334 | # location where to at least weaken the cycle is |
| 335 | # chosen for further processing. |
| @@ -334,11 +345,11 @@ | |
| 345 | } else { |
| 346 | $link destroy |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | log write 5 cyclebreaker "Breaking $label by splitting changeset [$bestnode str]" |
| 351 | set ID [$bestnode id] |
| 352 | Mark $dg -${ID}-before |
| 353 | |
| 354 | set newcsets [$bestlink break] |
| 355 | $bestlink destroy |
| 356 |