Overview
SHA1 Hash: | 54e9b0a1439023bd37ee40edc6f6ccb1b5b23213 |
---|---|
Date: | 2007-11-25 02:51:50 |
User: | aku |
Comment: | Tweaks of the log output, and reworked internals to expose not only breaking of cycles, but of paths as well. |
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 [ddec7fb99c] to [20cdcc5766].
@@ -93,11 +93,11 @@ # the nodes which have no predecessors, in order from # oldest to youngest, saving and removing dependencies. If # we find no nodes without predecessors we have a cycle, # and work on breaking it. - log write 3 cyclebreaker {Now sorting the changesets, breaking cycles} + log write 3 cyclebreaker {Traverse changesets} InitializeCandidates $dg while {1} { while {[WithoutPredecessor $dg n]} { ProcessedHook $dg $n $myat @@ -129,12 +129,28 @@ return } # # ## ### ##### ######## ############# + typemethod break-segment {graph} { + BreakSegment $graph $path "segment ([project::rev strlist $path])" + return + } + typemethod break {graph} { - BreakCycle $graph [FindCycle $graph] + set cycle [FindCycle $graph] + set label "cycle ([project::rev strlist $cycle])" + + # NOTE: cvs2svn uses the sequence "end-1, cycle, 0" to create + # the path from the cycle. The only effect I can see is + # that this causes the link-triples to be generated in a + # sightly different order, i.e. one link rotated to the + # right. This should have no effect on the search for + # the best of all. + + lappend cycle [lindex $cycle 0] [lindex $cycle 1] + BreakSegment $graph $cycle $label return } typemethod replace {graph n replacements} { Replace $graph $n $replacements @@ -144,12 +160,11 @@ # # ## ### ##### ######## ############# ## Internal methods proc Setup {changesets {log 1}} { if {$log} { - log write 3 cyclebreaker "Creating changeset graph, filling with nodes" - log write 3 cyclebreaker "Adding [nsp [llength $changesets] node]" + log write 3 cyclebreaker "Create changeset graph, [nsp [llength $changesets] node]" } set dg [struct::graph dg] foreach cset $changesets { @@ -298,27 +313,23 @@ } return [struct::list reverse [lrange $path $seen($start) end]] } - proc BreakCycle {dg cycle} { - # The cycle we have gotten is broken by breaking apart one or - # more of the changesets in the cycle. This causes us to - # create one or more changesets which are to be committed, - # added to the graph, etc. pp. - - # NOTE/TODO. Move this map operation to project::rev, as typemethod. - set cprint [project::rev strlist $cycle] - - lappend cycle [lindex $cycle 0] [lindex $cycle 1] + proc BreakSegment {dg path label} { + # The path, usually a cycle, we have gotten is broken by + # breaking apart one or more of the changesets in the + # cycle. This causes us to create one or more changesets which + # are to be committed, added to the graph, etc. pp. + set bestlink {} set bestnode {} foreach \ - prev [lrange $cycle 0 end-2] \ - cset [lrange $cycle 1 end-1] \ - next [lrange $cycle 2 end] { + prev [lrange $path 0 end-2] \ + cset [lrange $path 1 end-1] \ + next [lrange $path 2 end] { # Each triple PREV -> CSET -> NEXT of changesets, a # 'link' in the cycle, is analysed and the best # location where to at least weaken the cycle is # chosen for further processing. @@ -334,11 +345,11 @@ } else { $link destroy } } - log write 5 cyclebreaker "Breaking cycle ($cprint) by splitting changeset [$bestnode str]" + log write 5 cyclebreaker "Breaking $label by splitting changeset [$bestnode str]" set ID [$bestnode id] Mark $dg -${ID}-before set newcsets [$bestlink break] $bestlink destroy