Fossil SCM

API change cycle breaker. The save callback command is now specified through a separate configuration command. Moved callback invokation to helper command. Updated pass 6. Moved changeset selection to helper command.

aku 2007-11-21 03:46 trunk
Commit d58423cdc4a7801f94f0e5fbe07c4a16df39599e
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -30,10 +30,15 @@
3030
##
3131
3232
snit::type ::vc::fossil::import::cvs::cyclebreaker {
3333
# # ## ### ##### ######## #############
3434
## Public API
35
+
36
+ typemethod savecmd {cmd} {
37
+ ::variable mysavecmd $cmd
38
+ return
39
+ }
3540
3641
typemethod dotsto {path} {
3742
::variable mydotdestination $path
3843
return
3944
}
@@ -46,12 +51,11 @@
4651
Mark $dg
4752
$dg destroy
4853
return
4954
}
5055
51
- typemethod run {label changesets {savecmd {}}} {
52
- ::variable mysave $savecmd
56
+ typemethod run {label changesets} {
5357
::variable myat 0
5458
::variable mydotprefix $label
5559
::variable mydotid 0
5660
5761
# We create a graph of the revision changesets, using the file
@@ -83,10 +87,12 @@
8387
}
8488
8589
dg destroy
8690
8791
log write 3 cyclebreaker Done.
92
+
93
+ ClearHooks
8894
return
8995
}
9096
9197
# # ## ### ##### ######## #############
9298
## Internal methods
@@ -171,21 +177,13 @@
171177
return 1
172178
}
173179
174180
proc SaveAndRemove {dg n} {
175181
::variable myat
176
- ::variable mysave
177
-
178
- # Give the user of the cycle breaker the opportunity to work
179
- # with the changeset before it is removed from the graph.
180
-
181
- if {[llength $mysave]} {
182
- uplevel #0 [linsert $mysave end $myat $n]
183
- }
184
-
185
- incr myat
182
+ ProcessedHook $n $myat
186183
$dg node delete $n
184
+ incr myat
187185
return
188186
}
189187
190188
proc FindCycle {dg} {
191189
# This procedure is run if and only the graph is not empty and
@@ -327,17 +325,44 @@
327325
328326
log write 5 cyclebreaker ".dot export $fname"
329327
return
330328
}
331329
332
- typevariable myat 0 ; # Counter for commit ids for the changesets.
333
- typevariable mybottom {} ; # List of candidate nodes for committing.
334
- typevariable mysave {} ; # The command to call for each processed node
330
+ # # ## ### ##### ######## #############
331
+ ## Callback invokation ...
332
+
333
+ proc ProcessedHook {cset pos} {
334
+ # Give the user of the cycle breaker the opportunity to work
335
+ # with the changeset before it is removed from the graph.
336
+
337
+ ::variable mysavecmd
338
+ if {![llength $mysavecmd]} return
339
+
340
+ uplevel #0 [linsert $mysavecmd end $pos $cset]
341
+ return
342
+ }
343
+
344
+ proc ClearHooks {} {
345
+ ::variable mysavecmd {}
346
+ return
347
+ }
348
+
349
+ # # ## ### ##### ######## #############
350
+
351
+ typevariable myat 0 ; # Counter for commit ids for the
352
+ # changesets.
353
+ typevariable mybottom {} ; # List of the candidate nodes for
354
+ # committing.
355
+
356
+ typevariable mysavecmd {} ; # Callback, for each processed node.
335357
336
- typevariable mydotdestination {} ; # Destination directory for .dot files.
337
- typevariable mydotprefix {} ; # Prefix for dot files when exporting the graphs.
338
- typevariable mydotid 0 ; # Counter for dot file name generation.
358
+ typevariable mydotdestination {} ; # Destination directory for the
359
+ # generated .dot files.
360
+ typevariable mydotprefix {} ; # Prefix for dot files when
361
+ # exporting the graphs.
362
+ typevariable mydotid 0 ; # Counter for dot file name
363
+ # generation.
339364
340365
# # ## ### ##### ######## #############
341366
## Configuration
342367
343368
pragma -hasinstances no ; # singleton
344369
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -30,10 +30,15 @@
30 ##
31
32 snit::type ::vc::fossil::import::cvs::cyclebreaker {
33 # # ## ### ##### ######## #############
34 ## Public API
 
 
 
 
 
35
36 typemethod dotsto {path} {
37 ::variable mydotdestination $path
38 return
39 }
@@ -46,12 +51,11 @@
46 Mark $dg
47 $dg destroy
48 return
49 }
50
51 typemethod run {label changesets {savecmd {}}} {
52 ::variable mysave $savecmd
53 ::variable myat 0
54 ::variable mydotprefix $label
55 ::variable mydotid 0
56
57 # We create a graph of the revision changesets, using the file
@@ -83,10 +87,12 @@
83 }
84
85 dg destroy
86
87 log write 3 cyclebreaker Done.
 
 
88 return
89 }
90
91 # # ## ### ##### ######## #############
92 ## Internal methods
@@ -171,21 +177,13 @@
171 return 1
172 }
173
174 proc SaveAndRemove {dg n} {
175 ::variable myat
176 ::variable mysave
177
178 # Give the user of the cycle breaker the opportunity to work
179 # with the changeset before it is removed from the graph.
180
181 if {[llength $mysave]} {
182 uplevel #0 [linsert $mysave end $myat $n]
183 }
184
185 incr myat
186 $dg node delete $n
 
187 return
188 }
189
190 proc FindCycle {dg} {
191 # This procedure is run if and only the graph is not empty and
@@ -327,17 +325,44 @@
327
328 log write 5 cyclebreaker ".dot export $fname"
329 return
330 }
331
332 typevariable myat 0 ; # Counter for commit ids for the changesets.
333 typevariable mybottom {} ; # List of candidate nodes for committing.
334 typevariable mysave {} ; # The command to call for each processed node
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
336 typevariable mydotdestination {} ; # Destination directory for .dot files.
337 typevariable mydotprefix {} ; # Prefix for dot files when exporting the graphs.
338 typevariable mydotid 0 ; # Counter for dot file name generation.
 
 
 
339
340 # # ## ### ##### ######## #############
341 ## Configuration
342
343 pragma -hasinstances no ; # singleton
344
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -30,10 +30,15 @@
30 ##
31
32 snit::type ::vc::fossil::import::cvs::cyclebreaker {
33 # # ## ### ##### ######## #############
34 ## Public API
35
36 typemethod savecmd {cmd} {
37 ::variable mysavecmd $cmd
38 return
39 }
40
41 typemethod dotsto {path} {
42 ::variable mydotdestination $path
43 return
44 }
@@ -46,12 +51,11 @@
51 Mark $dg
52 $dg destroy
53 return
54 }
55
56 typemethod run {label changesets} {
 
57 ::variable myat 0
58 ::variable mydotprefix $label
59 ::variable mydotid 0
60
61 # We create a graph of the revision changesets, using the file
@@ -83,10 +87,12 @@
87 }
88
89 dg destroy
90
91 log write 3 cyclebreaker Done.
92
93 ClearHooks
94 return
95 }
96
97 # # ## ### ##### ######## #############
98 ## Internal methods
@@ -171,21 +177,13 @@
177 return 1
178 }
179
180 proc SaveAndRemove {dg n} {
181 ::variable myat
182 ProcessedHook $n $myat
 
 
 
 
 
 
 
 
 
183 $dg node delete $n
184 incr myat
185 return
186 }
187
188 proc FindCycle {dg} {
189 # This procedure is run if and only the graph is not empty and
@@ -327,17 +325,44 @@
325
326 log write 5 cyclebreaker ".dot export $fname"
327 return
328 }
329
330 # # ## ### ##### ######## #############
331 ## Callback invokation ...
332
333 proc ProcessedHook {cset pos} {
334 # Give the user of the cycle breaker the opportunity to work
335 # with the changeset before it is removed from the graph.
336
337 ::variable mysavecmd
338 if {![llength $mysavecmd]} return
339
340 uplevel #0 [linsert $mysavecmd end $pos $cset]
341 return
342 }
343
344 proc ClearHooks {} {
345 ::variable mysavecmd {}
346 return
347 }
348
349 # # ## ### ##### ######## #############
350
351 typevariable myat 0 ; # Counter for commit ids for the
352 # changesets.
353 typevariable mybottom {} ; # List of the candidate nodes for
354 # committing.
355
356 typevariable mysavecmd {} ; # Callback, for each processed node.
357
358 typevariable mydotdestination {} ; # Destination directory for the
359 # generated .dot files.
360 typevariable mydotprefix {} ; # Prefix for dot files when
361 # exporting the graphs.
362 typevariable mydotid 0 ; # Counter for dot file name
363 # generation.
364
365 # # ## ### ##### ######## #############
366 ## Configuration
367
368 pragma -hasinstances no ; # singleton
369
--- tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl
+++ tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl
@@ -72,19 +72,20 @@
7272
7373
typemethod run {} {
7474
# Pass manager interface. Executed to perform the
7575
# functionality of the pass.
7676
77
- set changesets [struct::list filter [project::rev all] [myproc IsByRevision]]
77
+ set changesets [Changesets]
7878
cyclebreaker dot break-rev-start $changesets
7979
80
+ cyclebreaker savecmd [myproc SaveOrder]
81
+
8082
state transaction {
81
- cyclebreaker run break-rev $changesets [myproc SaveOrder]
83
+ cyclebreaker run break-rev $changesets
8284
}
8385
84
- set changesets [struct::list filter [project::rev all] [myproc IsByRevision]]
85
- cyclebreaker dot break-rev-done $changesets
86
+ cyclebreaker dot break-rev-done [Changesets]
8687
8788
repository printcsetstatistics
8889
return
8990
}
9091
@@ -97,10 +98,14 @@
9798
return
9899
}
99100
100101
# # ## ### ##### ######## #############
101102
## Internal methods
103
+
104
+ proc Changesets {} {
105
+ return [struct::list filter [project::rev all] [myproc IsByRevision]]
106
+ }
102107
103108
proc IsByRevision {cset} { $cset byrevision }
104109
105110
proc SaveOrder {at cset} {
106111
set cid [$cset id]
107112
--- tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl
+++ tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl
@@ -72,19 +72,20 @@
72
73 typemethod run {} {
74 # Pass manager interface. Executed to perform the
75 # functionality of the pass.
76
77 set changesets [struct::list filter [project::rev all] [myproc IsByRevision]]
78 cyclebreaker dot break-rev-start $changesets
79
 
 
80 state transaction {
81 cyclebreaker run break-rev $changesets [myproc SaveOrder]
82 }
83
84 set changesets [struct::list filter [project::rev all] [myproc IsByRevision]]
85 cyclebreaker dot break-rev-done $changesets
86
87 repository printcsetstatistics
88 return
89 }
90
@@ -97,10 +98,14 @@
97 return
98 }
99
100 # # ## ### ##### ######## #############
101 ## Internal methods
 
 
 
 
102
103 proc IsByRevision {cset} { $cset byrevision }
104
105 proc SaveOrder {at cset} {
106 set cid [$cset id]
107
--- tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl
+++ tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl
@@ -72,19 +72,20 @@
72
73 typemethod run {} {
74 # Pass manager interface. Executed to perform the
75 # functionality of the pass.
76
77 set changesets [Changesets]
78 cyclebreaker dot break-rev-start $changesets
79
80 cyclebreaker savecmd [myproc SaveOrder]
81
82 state transaction {
83 cyclebreaker run break-rev $changesets
84 }
85
86 cyclebreaker dot break-rev-done [Changesets]
 
87
88 repository printcsetstatistics
89 return
90 }
91
@@ -97,10 +98,14 @@
98 return
99 }
100
101 # # ## ### ##### ######## #############
102 ## Internal methods
103
104 proc Changesets {} {
105 return [struct::list filter [project::rev all] [myproc IsByRevision]]
106 }
107
108 proc IsByRevision {cset} { $cset byrevision }
109
110 proc SaveOrder {at cset} {
111 set cid [$cset id]
112

Keyboard Shortcuts

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