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.

aku 2007-11-23 05:43 trunk
Commit 5f5620fbd25ccc50fac7757fc38abfcb072270a5
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -63,10 +63,15 @@
6363
set dg [Setup $changesets 0]
6464
Mark $dg
6565
$dg destroy
6666
return
6767
}
68
+
69
+ typemethod mark {graph suffix {subgraph {}}} {
70
+ Mark $graph $suffix $subgraph
71
+ return
72
+ }
6873
6974
# # ## ### ##### ######## #############
7075
7176
typemethod run {label changesetcmd} {
7277
::variable myat 0
@@ -93,11 +98,11 @@
9398
log write 3 cyclebreaker {Now sorting the changesets, breaking cycles}
9499
95100
InitializeCandidates $dg
96101
while {1} {
97102
while {[WithoutPredecessor $dg n]} {
98
- ProcessedHook $n $myat
103
+ ProcessedHook $dg $n $myat
99104
$dg node delete $n
100105
incr myat
101106
ShowPendingNodes
102107
}
103108
@@ -149,10 +154,11 @@
149154
150155
foreach cset $changesets {
151156
$dg node insert $cset
152157
$dg node set $cset timerange [$cset timerange]
153158
$dg node set $cset label [ID $cset]
159
+ $dg node set $cset __id__ [$cset id]
154160
}
155161
156162
# 2. Find for all relevant changeset their revisions and their
157163
# dependencies. Map the latter back to changesets and
158164
# construct the corresponding arcs.
@@ -329,18 +335,18 @@
329335
#8.5: return [expr {$b in [$dg nodes -out $a]}]
330336
if {[lsearch -exact [$dg nodes -out $a] $b] < 0} { return 0 }
331337
return 1
332338
}
333339
334
- proc Mark {dg {suffix {}}} {
340
+ proc Mark {dg {suffix {}} {subgraph {}}} {
335341
::variable mydotdestination
336342
if {$mydotdestination eq ""} return
337343
::variable mydotprefix
338344
::variable mydotid
339345
set fname $mydotdestination/${mydotprefix}${mydotid}${suffix}.dot
340346
file mkdir [file dirname $fname]
341
- dot write $dg $mydotprefix$suffix $fname
347
+ dot write $dg $mydotprefix$suffix $fname $subgraph
342348
incr mydotid
343349
344350
log write 5 cyclebreaker ".dot export $fname"
345351
return
346352
}
@@ -397,18 +403,18 @@
397403
uplevel #0 [linsert $myprecmd end $graph]
398404
Mark $graph -pre-done
399405
return
400406
}
401407
402
- proc ProcessedHook {cset pos} {
408
+ proc ProcessedHook {dg cset pos} {
403409
# Give the user of the cycle breaker the opportunity to work
404410
# with the changeset before it is removed from the graph.
405411
406412
::variable mysavecmd
407413
if {![llength $mysavecmd]} return
408414
409
- uplevel #0 [linsert $mysavecmd end $pos $cset]
415
+ uplevel #0 [linsert $mysavecmd end $dg $pos $cset]
410416
return
411417
}
412418
413419
proc BreakCycleHook {graph} {
414420
# Call out to the chosen algorithm for cycle breaking. Finding
415421
--- 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

Keyboard Shortcuts

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