Fossil SCM

Extended cycle breaker with debug facility allowing the user to watch the neighbourhood of specific changesets during the traversal. Extended label information, highlighting of the nodes of interest. Tweaked log output a bit.

aku 2007-11-25 07:35 trunk
Commit 97b4405ecf7ef61e838044ffa5ea5a6754a3d20e
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -53,10 +53,15 @@
5353
5454
typemethod dotsto {path} {
5555
::variable mydotdestination $path
5656
return
5757
}
58
+
59
+ typemethod watch {id} {
60
+ ::variable mywatchids
61
+ lappend mywatchids $id
62
+ }
5863
5964
typemethod dot {label changesets} {
6065
::variable mydotprefix $label
6166
::variable mydotid 0
6267
@@ -98,10 +103,11 @@
98103
log write 3 cyclebreaker {Traverse changesets}
99104
100105
InitializeCandidates $dg
101106
while {1} {
102107
while {[WithoutPredecessor $dg n]} {
108
+ MarkWatch $dg
103109
ProcessedHook $dg $n $myat
104110
$dg node delete $n
105111
incr myat
106112
ShowPendingNodes
107113
}
@@ -108,10 +114,11 @@
108114
109115
if {![llength [dg nodes]]} break
110116
111117
BreakCycleHook $dg
112118
InitializeCandidates $dg
119
+ MarkWatch $dg
113120
}
114121
115122
$dg destroy
116123
117124
log write 3 cyclebreaker Done.
@@ -160,30 +167,34 @@
160167
# # ## ### ##### ######## #############
161168
## Internal methods
162169
163170
proc Setup {changesets {log 1}} {
164171
if {$log} {
165
- log write 3 cyclebreaker "Create changeset graph, [nsp [llength $changesets] node]"
172
+ log write 3 cyclebreaker "Creating graph of changesets"
166173
}
167174
168175
set dg [struct::graph dg]
169176
170177
foreach cset $changesets {
178
+ set tr [$cset timerange]
171179
$dg node insert $cset
172
- $dg node set $cset timerange [$cset timerange]
173
- $dg node set $cset label [$cset str]
180
+ $dg node set $cset timerange $tr
181
+ $dg node set $cset label "[$cset str]\\n[join [struct::list map $tr {::clock format}] "\\n"]"
174182
$dg node set $cset __id__ [$cset id]
183
+ $dg node set $cset shape [expr {[$cset bysymbol]
184
+ ? "ellipse"
185
+ : "box"}]
186
+ }
187
+
188
+ if {$log} {
189
+ log write 3 cyclebreaker "Has [nsp [llength $changesets] changeset]"
175190
}
176191
177192
# 2. Find for all relevant changeset their revisions and their
178193
# dependencies. Map the latter back to changesets and
179194
# construct the corresponding arcs.
180195
181
- if {$log} {
182
- log write 3 cyclebreaker {Setting up node dependencies}
183
- }
184
-
185196
foreach cset $changesets {
186197
foreach succ [$cset successors] {
187198
# Changesets may have dependencies outside of the
188199
# chosen set. These are ignored
189200
if {![$dg node exists $succ]} continue
@@ -209,16 +220,22 @@
209220
}
210221
}
211222
}
212223
}
213224
}
225
+
226
+ if {$log} {
227
+ log write 3 cyclebreaker "Has [nsp [llength [$dg arcs]] dependency dependencies]"
228
+ }
214229
215230
# Run the user hook to manipulate the graph before
216231
# consummation.
217232
218233
if {$log} { Mark $dg -start }
219
- PreHook $dg
234
+ MarkWatch $dg
235
+ PreHook $dg
236
+ MarkWatch $dg
220237
221238
# This kills the application if loops (see above) were found.
222239
trouble abort?
223240
return $dg
224241
}
@@ -395,14 +412,18 @@
395412
set pre [$dg nodes -in $n]
396413
397414
$dg node delete $n
398415
399416
foreach cset $replacements {
417
+ set tr [$cset timerange]
400418
$dg node insert $cset
401
- $dg node set $cset timerange [$cset timerange]
402
- $dg node set $cset label [$cset str]
419
+ $dg node set $cset timerange $tr
420
+ $dg node set $cset label "[$cset str]\\n[join [struct::list map $tr {::clock format}] "\\n"]"
403421
$dg node set $cset __id__ [$cset id]
422
+ $dg node set $cset shape [expr {[$cset bysymbol]
423
+ ? "ellipse"
424
+ : "box"}]
404425
}
405426
406427
foreach cset $replacements {
407428
foreach succ [$cset successors] {
408429
# The new changesets may have dependencies outside of
@@ -475,10 +496,35 @@
475496
::variable mybreakcmd {}
476497
return
477498
}
478499
479500
# # ## ### ##### ######## #############
501
+
502
+ proc MarkWatch {graph} {
503
+ ::variable mywatchids
504
+ set watched [Watched $graph $mywatchids]
505
+ if {![llength $watched]} return
506
+ set neighbours [eval [linsert $watched 0 $graph nodes -adj]]
507
+ #foreach n $neighbours { log write 6 cyclebreaker "Neighbor [$n id] => $n" }
508
+ Mark $graph watched [concat $watched $neighbours]
509
+ return
510
+ }
511
+
512
+ proc Watched {graph watchids} {
513
+ set res {}
514
+ foreach id $watchids {
515
+ set nl [$graph nodes -key __id__ -value $id]
516
+ if {![llength $nl]} continue
517
+ lappend res $nl
518
+ #log write 6 breakrcycle "Watching $id => $nl"
519
+ $graph node set $nl fontcolor red
520
+ }
521
+ return $res
522
+ }
523
+
524
+ # # ## ### ##### ######## #############
525
+
480526
481527
typevariable myat 0 ; # Counter for commit ids for the
482528
# changesets.
483529
typevariable mybottom {} ; # List of the candidate nodes for
484530
# committing.
@@ -491,10 +537,12 @@
491537
# generated .dot files.
492538
typevariable mydotprefix {} ; # Prefix for dot files when
493539
# exporting the graphs.
494540
typevariable mydotid 0 ; # Counter for dot file name
495541
# generation.
542
+ typevariable mywatchids {} ; # Changesets to watch the
543
+ # neighbourhood of.
496544
497545
# # ## ### ##### ######## #############
498546
## Configuration
499547
500548
pragma -hasinstances no ; # singleton
501549
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -53,10 +53,15 @@
53
54 typemethod dotsto {path} {
55 ::variable mydotdestination $path
56 return
57 }
 
 
 
 
 
58
59 typemethod dot {label changesets} {
60 ::variable mydotprefix $label
61 ::variable mydotid 0
62
@@ -98,10 +103,11 @@
98 log write 3 cyclebreaker {Traverse changesets}
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,10 +114,11 @@
108
109 if {![llength [dg nodes]]} break
110
111 BreakCycleHook $dg
112 InitializeCandidates $dg
 
113 }
114
115 $dg destroy
116
117 log write 3 cyclebreaker Done.
@@ -160,30 +167,34 @@
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 {
 
171 $dg node insert $cset
172 $dg node set $cset timerange [$cset timerange]
173 $dg node set $cset label [$cset str]
174 $dg node set $cset __id__ [$cset id]
 
 
 
 
 
 
 
175 }
176
177 # 2. Find for all relevant changeset their revisions and their
178 # dependencies. Map the latter back to changesets and
179 # construct the corresponding arcs.
180
181 if {$log} {
182 log write 3 cyclebreaker {Setting up node dependencies}
183 }
184
185 foreach cset $changesets {
186 foreach succ [$cset successors] {
187 # Changesets may have dependencies outside of the
188 # chosen set. These are ignored
189 if {![$dg node exists $succ]} continue
@@ -209,16 +220,22 @@
209 }
210 }
211 }
212 }
213 }
 
 
 
 
214
215 # Run the user hook to manipulate the graph before
216 # consummation.
217
218 if {$log} { Mark $dg -start }
219 PreHook $dg
 
 
220
221 # This kills the application if loops (see above) were found.
222 trouble abort?
223 return $dg
224 }
@@ -395,14 +412,18 @@
395 set pre [$dg nodes -in $n]
396
397 $dg node delete $n
398
399 foreach cset $replacements {
 
400 $dg node insert $cset
401 $dg node set $cset timerange [$cset timerange]
402 $dg node set $cset label [$cset str]
403 $dg node set $cset __id__ [$cset id]
 
 
 
404 }
405
406 foreach cset $replacements {
407 foreach succ [$cset successors] {
408 # The new changesets may have dependencies outside of
@@ -475,10 +496,35 @@
475 ::variable mybreakcmd {}
476 return
477 }
478
479 # # ## ### ##### ######## #############
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
480
481 typevariable myat 0 ; # Counter for commit ids for the
482 # changesets.
483 typevariable mybottom {} ; # List of the candidate nodes for
484 # committing.
@@ -491,10 +537,12 @@
491 # generated .dot files.
492 typevariable mydotprefix {} ; # Prefix for dot files when
493 # exporting the graphs.
494 typevariable mydotid 0 ; # Counter for dot file name
495 # generation.
 
 
496
497 # # ## ### ##### ######## #############
498 ## Configuration
499
500 pragma -hasinstances no ; # singleton
501
--- tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
+++ tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
@@ -53,10 +53,15 @@
53
54 typemethod dotsto {path} {
55 ::variable mydotdestination $path
56 return
57 }
58
59 typemethod watch {id} {
60 ::variable mywatchids
61 lappend mywatchids $id
62 }
63
64 typemethod dot {label changesets} {
65 ::variable mydotprefix $label
66 ::variable mydotid 0
67
@@ -98,10 +103,11 @@
103 log write 3 cyclebreaker {Traverse changesets}
104
105 InitializeCandidates $dg
106 while {1} {
107 while {[WithoutPredecessor $dg n]} {
108 MarkWatch $dg
109 ProcessedHook $dg $n $myat
110 $dg node delete $n
111 incr myat
112 ShowPendingNodes
113 }
@@ -108,10 +114,11 @@
114
115 if {![llength [dg nodes]]} break
116
117 BreakCycleHook $dg
118 InitializeCandidates $dg
119 MarkWatch $dg
120 }
121
122 $dg destroy
123
124 log write 3 cyclebreaker Done.
@@ -160,30 +167,34 @@
167 # # ## ### ##### ######## #############
168 ## Internal methods
169
170 proc Setup {changesets {log 1}} {
171 if {$log} {
172 log write 3 cyclebreaker "Creating graph of changesets"
173 }
174
175 set dg [struct::graph dg]
176
177 foreach cset $changesets {
178 set tr [$cset timerange]
179 $dg node insert $cset
180 $dg node set $cset timerange $tr
181 $dg node set $cset label "[$cset str]\\n[join [struct::list map $tr {::clock format}] "\\n"]"
182 $dg node set $cset __id__ [$cset id]
183 $dg node set $cset shape [expr {[$cset bysymbol]
184 ? "ellipse"
185 : "box"}]
186 }
187
188 if {$log} {
189 log write 3 cyclebreaker "Has [nsp [llength $changesets] changeset]"
190 }
191
192 # 2. Find for all relevant changeset their revisions and their
193 # dependencies. Map the latter back to changesets and
194 # construct the corresponding arcs.
195
 
 
 
 
196 foreach cset $changesets {
197 foreach succ [$cset successors] {
198 # Changesets may have dependencies outside of the
199 # chosen set. These are ignored
200 if {![$dg node exists $succ]} continue
@@ -209,16 +220,22 @@
220 }
221 }
222 }
223 }
224 }
225
226 if {$log} {
227 log write 3 cyclebreaker "Has [nsp [llength [$dg arcs]] dependency dependencies]"
228 }
229
230 # Run the user hook to manipulate the graph before
231 # consummation.
232
233 if {$log} { Mark $dg -start }
234 MarkWatch $dg
235 PreHook $dg
236 MarkWatch $dg
237
238 # This kills the application if loops (see above) were found.
239 trouble abort?
240 return $dg
241 }
@@ -395,14 +412,18 @@
412 set pre [$dg nodes -in $n]
413
414 $dg node delete $n
415
416 foreach cset $replacements {
417 set tr [$cset timerange]
418 $dg node insert $cset
419 $dg node set $cset timerange $tr
420 $dg node set $cset label "[$cset str]\\n[join [struct::list map $tr {::clock format}] "\\n"]"
421 $dg node set $cset __id__ [$cset id]
422 $dg node set $cset shape [expr {[$cset bysymbol]
423 ? "ellipse"
424 : "box"}]
425 }
426
427 foreach cset $replacements {
428 foreach succ [$cset successors] {
429 # The new changesets may have dependencies outside of
@@ -475,10 +496,35 @@
496 ::variable mybreakcmd {}
497 return
498 }
499
500 # # ## ### ##### ######## #############
501
502 proc MarkWatch {graph} {
503 ::variable mywatchids
504 set watched [Watched $graph $mywatchids]
505 if {![llength $watched]} return
506 set neighbours [eval [linsert $watched 0 $graph nodes -adj]]
507 #foreach n $neighbours { log write 6 cyclebreaker "Neighbor [$n id] => $n" }
508 Mark $graph watched [concat $watched $neighbours]
509 return
510 }
511
512 proc Watched {graph watchids} {
513 set res {}
514 foreach id $watchids {
515 set nl [$graph nodes -key __id__ -value $id]
516 if {![llength $nl]} continue
517 lappend res $nl
518 #log write 6 breakrcycle "Watching $id => $nl"
519 $graph node set $nl fontcolor red
520 }
521 return $res
522 }
523
524 # # ## ### ##### ######## #############
525
526
527 typevariable myat 0 ; # Counter for commit ids for the
528 # changesets.
529 typevariable mybottom {} ; # List of the candidate nodes for
530 # committing.
@@ -491,10 +537,12 @@
537 # generated .dot files.
538 typevariable mydotprefix {} ; # Prefix for dot files when
539 # exporting the graphs.
540 typevariable mydotid 0 ; # Counter for dot file name
541 # generation.
542 typevariable mywatchids {} ; # Changesets to watch the
543 # neighbourhood of.
544
545 # # ## ### ##### ######## #############
546 ## Configuration
547
548 pragma -hasinstances no ; # singleton
549
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -79,10 +79,11 @@
7979
--exclude { project::sym exclude [Value arguments] }
8080
--force-tag { project::sym forcetag [Value arguments] }
8181
--force-branch { project::sym forcebranch [Value arguments] }
8282
--batch { log noprogress }
8383
--dots { cyclebreaker dotsto [Value arguments] }
84
+ --watch { cyclebreaker watch [Value arguments] }
8485
default {
8586
Usage $badoption$option\n$gethelp
8687
}
8788
}
8889
}
8990
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -79,10 +79,11 @@
79 --exclude { project::sym exclude [Value arguments] }
80 --force-tag { project::sym forcetag [Value arguments] }
81 --force-branch { project::sym forcebranch [Value arguments] }
82 --batch { log noprogress }
83 --dots { cyclebreaker dotsto [Value arguments] }
 
84 default {
85 Usage $badoption$option\n$gethelp
86 }
87 }
88 }
89
--- tools/cvs2fossil/lib/c2f_option.tcl
+++ tools/cvs2fossil/lib/c2f_option.tcl
@@ -79,10 +79,11 @@
79 --exclude { project::sym exclude [Value arguments] }
80 --force-tag { project::sym forcetag [Value arguments] }
81 --force-branch { project::sym forcebranch [Value arguments] }
82 --batch { log noprogress }
83 --dots { cyclebreaker dotsto [Value arguments] }
84 --watch { cyclebreaker watch [Value arguments] }
85 default {
86 Usage $badoption$option\n$gethelp
87 }
88 }
89 }
90

Keyboard Shortcuts

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