Fossil SCM

Tweaks of the log output, and reworked internals to expose not only breaking of cycles, but of paths as well.

aku 2007-11-25 02:51 trunk
Commit 54e9b0a1439023bd37ee40edc6f6ccb1b5b23213
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -93,11 +93,11 @@
9393
# the nodes which have no predecessors, in order from
9494
# oldest to youngest, saving and removing dependencies. If
9595
# we find no nodes without predecessors we have a cycle,
9696
# and work on breaking it.
9797
98
- log write 3 cyclebreaker {Now sorting the changesets, breaking cycles}
98
+ log write 3 cyclebreaker {Traverse changesets}
9999
100100
InitializeCandidates $dg
101101
while {1} {
102102
while {[WithoutPredecessor $dg n]} {
103103
ProcessedHook $dg $n $myat
@@ -128,13 +128,29 @@
128128
$dg destroy
129129
return
130130
}
131131
132132
# # ## ### ##### ######## #############
133
+
134
+ typemethod break-segment {graph} {
135
+ BreakSegment $graph $path "segment ([project::rev strlist $path])"
136
+ return
137
+ }
133138
134139
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
136152
return
137153
}
138154
139155
typemethod replace {graph n replacements} {
140156
Replace $graph $n $replacements
@@ -144,12 +160,11 @@
144160
# # ## ### ##### ######## #############
145161
## Internal methods
146162
147163
proc Setup {changesets {log 1}} {
148164
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]"
151166
}
152167
153168
set dg [struct::graph dg]
154169
155170
foreach cset $changesets {
@@ -298,27 +313,23 @@
298313
}
299314
300315
return [struct::list reverse [lrange $path $seen($start) end]]
301316
}
302317
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
+
313324
set bestlink {}
314325
set bestnode {}
315326
316327
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] {
320331
321332
# Each triple PREV -> CSET -> NEXT of changesets, a
322333
# 'link' in the cycle, is analysed and the best
323334
# location where to at least weaken the cycle is
324335
# chosen for further processing.
@@ -334,11 +345,11 @@
334345
} else {
335346
$link destroy
336347
}
337348
}
338349
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]"
340351
set ID [$bestnode id]
341352
Mark $dg -${ID}-before
342353
343354
set newcsets [$bestlink break]
344355
$bestlink destroy
345356
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button