Fossil SCM

Brought the variable names into alignment with the semantics, now again naming what is stored in them.

aku 2007-11-29 07:36 trunk
Commit deab4d035be04cb3c33888d610944d7176cd415b
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -29,11 +29,11 @@
2929
3030
snit::type ::vc::fossil::import::cvs::project::rev {
3131
# # ## ### ##### ######## #############
3232
## Public API
3333
34
- constructor {project cstype srcid revisions {theid {}}} {
34
+ constructor {project cstype srcid items {theid {}}} {
3535
if {$theid ne ""} {
3636
set myid $theid
3737
} else {
3838
set myid [incr mycounter]
3939
}
@@ -42,20 +42,20 @@
4242
4343
set myproject $project
4444
set mytype $cstype
4545
set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype}
4646
set mysrcid $srcid
47
- set myrevisions $revisions
47
+ set myitems $items
4848
set mypos {} ; # Commit location is not known yet.
4949
5050
# Keep track of the generated changesets and of the inverse
51
- # mapping from revisions to them.
51
+ # mapping from items to them.
5252
lappend mychangesets $self
5353
set myidmap($myid) $self
54
- foreach r $revisions {
55
- set key [list $cstype $id]
56
- set myrevmap($key) $self
54
+ foreach iid $items {
55
+ set key [list $cstype $iid]
56
+ set myitemmap($key) $self
5757
lappend mytitems $key
5858
}
5959
return
6060
}
6161
@@ -89,12 +89,12 @@
8989
method successormap {} {
9090
# NOTE / FUTURE: Possible bottleneck.
9191
array set tmp {}
9292
foreach {rev children} [$self nextmap] {
9393
foreach child $children {
94
- # 8.5 lappend tmp($rev) {*}$myrevmap($child)
95
- foreach cset $myrevmap($child) {
94
+ # 8.5 lappend tmp($rev) {*}$myitemmap($child)
95
+ foreach cset $myitemmap($child) {
9696
lappend tmp($rev) $cset
9797
}
9898
}
9999
set tmp($rev) [lsort -unique $tmp($rev)]
100100
}
@@ -105,12 +105,12 @@
105105
method successors {} {
106106
# NOTE / FUTURE: Possible bottleneck.
107107
set csets {}
108108
foreach {_ children} [$self nextmap] {
109109
foreach child $children {
110
- # 8.5 lappend csets {*}$myrevmap($child)
111
- foreach cset $myrevmap($child) {
110
+ # 8.5 lappend csets {*}$myitemmap($child)
111
+ foreach cset $myitemmap($child) {
112112
lappend csets $cset
113113
}
114114
}
115115
}
116116
return [lsort -unique $csets]
@@ -120,12 +120,12 @@
120120
method predecessormap {} {
121121
# NOTE / FUTURE: Possible bottleneck.
122122
array set tmp {}
123123
foreach {rev children} [$self premap] {
124124
foreach child $children {
125
- # 8.5 lappend tmp($rev) {*}$myrevmap($child)
126
- foreach cset $myrevmap($child) {
125
+ # 8.5 lappend tmp($rev) {*}$myitemmap($child)
126
+ foreach cset $myitemmap($child) {
127127
lappend tmp($rev) $cset
128128
}
129129
}
130130
set tmp($rev) [lsort -unique $tmp($rev)]
131131
}
@@ -133,19 +133,19 @@
133133
}
134134
135135
# item -> list (item)
136136
method nextmap {} {
137137
if {[llength $mynextmap]} { return $mynextmap }
138
- $mytypeobj successors tmp $myrevisions
138
+ $mytypeobj successors tmp $myitems
139139
set mynextmap [array get tmp]
140140
return $mynextmap
141141
}
142142
143143
# item -> list (item)
144144
method premap {} {
145145
if {[llength $mypremap]} { return $mypremap }
146
- $mytypeobj predecessors tmp $myrevisions
146
+ $mytypeobj predecessors tmp $myitems
147147
set mypremap [array get tmp]
148148
return $mypremap
149149
}
150150
151151
method breakinternaldependencies {} {
@@ -169,11 +169,11 @@
169169
170170
# Array of dependencies (parent -> child). This is pulled from
171171
# the state, and limited to successors within the changeset.
172172
173173
array set dependencies {}
174
- $mytypeobj internalsuccessors dependencies $myrevisions
174
+ $mytypeobj internalsuccessors dependencies $myitems
175175
if {![array size dependencies]} {return 0} ; # Nothing to break.
176176
177177
log write 5 csets ...[$self str].......................................................
178178
179179
# We have internal dependencies to break. We now iterate over
@@ -189,11 +189,11 @@
189189
# CROSS position in list -> number of dependencies crossing it
190190
# DEPC dependency -> positions it crosses
191191
# List: RANGE Of the positions itself.
192192
# A dependency is a single-element map parent -> child
193193
194
- InitializeBreakState $myrevisions
194
+ InitializeBreakState $myitems
195195
196196
set fragments {}
197197
set pending [list $range]
198198
set at 0
199199
array set breaks {}
@@ -222,11 +222,11 @@
222222
set breaks($best) $cross($best)
223223
224224
log write 6 csets "Best break @ $best, cutting [nsp $cross($best) dependency dependencies]"
225225
226226
# Note: The value of best is an abolute location in
227
- # myrevisions. Use the start of current to make it an
227
+ # myitems. Use the start of current to make it an
228228
# index absolute to current.
229229
230230
set brel [expr {$best - [lindex $current 0]}]
231231
set bnext $brel ; incr bnext
232232
set fragbefore [lrange $current 0 $brel]
@@ -244,18 +244,18 @@
244244
incr at
245245
}
246246
247247
log write 6 csets ". . .. ... ..... ........ ............."
248248
249
- # (*) We clear out the associated part of the myrevmap
249
+ # (*) We clear out the associated part of the myitemmap
250250
# in-memory index in preparation for new data. A simple unset
251251
# is enough, we have no symbol changesets at this time, and
252252
# thus never more than one reference in the list.
253253
254
- foreach r $myrevisions {
255
- set key [list $mytype $r]
256
- unset myrevmap($key)
254
+ foreach iid $myitems {
255
+ set key [list $mytype $iid]
256
+ unset myitemmap($key)
257257
}
258258
259259
# Create changesets for the fragments, reusing the current one
260260
# for the first fragment. We sort them in order to allow
261261
# checking for gaps and nice messages.
@@ -271,32 +271,31 @@
271271
set laste $firste
272272
foreach fragment [lrange $fragments 1 end] {
273273
Border $fragment s e
274274
integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap}
275275
276
- set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myrevisions $s $e]]
276
+ set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myitems $s $e]]
277277
278278
log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)"
279279
280280
set laste $e
281281
}
282282
283283
integrity assert {
284
- $laste == ([llength $myrevisions]-1)
284
+ $laste == ([llength $myitems]-1)
285285
} {Bad fragment end @ $laste, gap, or beyond end of the range}
286286
287287
# Put the first fragment into the current changeset, and
288
- # update the in-memory index. We can simply (re)add the
289
- # revisions because we cleared the previously existing
290
- # information, see (*) above. Persistence does not matter
291
- # here, none of the changesets has been saved to the
292
- # persistent state yet.
293
-
294
- set myrevisions [lrange $myrevisions 0 $firste]
295
- foreach r $myrevisions {
296
- set key [list $mytype $r]
297
- set myrevmap($key) $self
288
+ # update the in-memory index. We can simply (re)add the items
289
+ # because we cleared the previously existing information, see
290
+ # (*) above. Persistence does not matter here, none of the
291
+ # changesets has been saved to the persistent state yet.
292
+
293
+ set myitems [lrange $myitems 0 $firste]
294
+ foreach iid $myitems {
295
+ set key [list $mytype $iid]
296
+ set myitemmap($key) $self
298297
}
299298
300299
return 1
301300
}
302301
@@ -309,44 +308,44 @@
309308
state run {
310309
INSERT INTO changeset (cid, pid, type, src)
311310
VALUES ($myid, $pid, $tid, $mysrcid);
312311
}
313312
314
- foreach rid $myrevisions {
313
+ foreach iid $myitems {
315314
state run {
316315
INSERT INTO csrevision (cid, pos, rid)
317
- VALUES ($myid, $pos, $rid);
316
+ VALUES ($myid, $pos, $iid);
318317
}
319318
incr pos
320319
}
321320
}
322321
return
323322
}
324323
325
- method timerange {} { return [$mytypeobj timerange $myrevisions] }
324
+ method timerange {} { return [$mytypeobj timerange $myitems] }
326325
327326
method drop {} {
328327
state transaction {
329328
state run {
330329
DELETE FROM changeset WHERE cid = $myid;
331330
DELETE FROM csrevision WHERE cid = $myid;
332331
}
333332
}
334
- foreach r $myrevisions {
335
- set key [list $mytype $r]
336
- unset myrevmap($key)
333
+ foreach iid $myitems {
334
+ set key [list $mytype $iid]
335
+ unset myitemmap($key)
337336
}
338337
set pos [lsearch -exact $mychangesets $self]
339338
set mychangesets [lreplace $mychangesets $pos $pos]
340339
return
341340
}
342341
343342
typemethod split {cset args} {
344343
# As part of the creation of the new changesets specified in
345
- # ARGS as sets of revisions, all subsets of CSET's revision
346
- # set, CSET will be dropped from all databases, in and out of
347
- # memory, and then destroyed.
344
+ # ARGS as sets of items, all subsets of CSET's item set, CSET
345
+ # will be dropped from all databases, in and out of memory,
346
+ # and then destroyed.
348347
#
349348
# Note: The item lists found in args are tagged items. They
350349
# have to have the same type as the changeset, being subsets
351350
# of its items. This is checked in Untag1.
352351
@@ -354,16 +353,16 @@
354353
355354
$cset drop
356355
$cset destroy
357356
358357
set newcsets {}
359
- foreach fragmentrevisions $args {
358
+ foreach fragmentitems $args {
360359
integrity assert {
361
- [llength $fragmentrevisions]
362
- } {Attempted to create an empty changeset, i.e. without revisions}
360
+ [llength $fragmentitems]
361
+ } {Attempted to create an empty changeset, i.e. without items}
363362
lappend newcsets [$type %AUTO% $project $cstype $cssrc \
364
- [Untag $fragmentrevisions $cstype]]
363
+ [Untag $fragmentitems $cstype]]
365364
}
366365
367366
foreach c $newcsets { $c persist }
368367
return $newcsets
369368
}
@@ -401,14 +400,14 @@
401400
variable mytypeobj {} ; # Reference to the container for the
402401
# type dependent code. Derived from
403402
# mytype.
404403
variable mysrcid {} ; # Id of the metadata or symbol the cset
405404
# is based on.
406
- variable myrevisions {} ; # List of the file level revisions,
405
+ variable myitems {} ; # List of the file level revisions,
407406
# tags, or branches in the cset, as
408407
# ids. Not tagged.
409
- variable mytitems {} ; # As myrevisions, the tagged form.
408
+ variable mytitems {} ; # As myitems, the tagged form.
410409
variable mypremap {} ; # Dictionary mapping from the items (tagged now)
411410
# to their predecessors, also tagged. A
412411
# cache to avoid loading this from the
413412
# state more than once.
414413
variable mynextmap {} ; # Dictionary mapping from the items (tagged)
@@ -653,20 +652,22 @@
653652
return
654653
}
655654
656655
# # ## ### ##### ######## #############
657656
658
- typevariable mychangesets {} ; # List of all known changesets.
659
- typevariable myrevmap -array {} ; # Map from items (tagged) to the
660
- # list of changesets containing
661
- # it. Each item can be used by
662
- # only one changeset.
663
- typevariable myidmap -array {} ; # Map from changeset id to changeset.
664
-
665
- typemethod all {} { return $mychangesets }
666
- typemethod of {id} { return $myidmap($id) }
667
- typemethod ofrev {id} { return $myrevmap($id) }
657
+ typevariable mychangesets {} ; # List of all known changesets.
658
+ typevariable myitemmap -array {} ; # Map from items (tagged) to
659
+ # the list of changesets
660
+ # containing it. Each item can
661
+ # be used by only one
662
+ # changeset.
663
+ typevariable myidmap -array {} ; # Map from changeset id to
664
+ # changeset.
665
+
666
+ typemethod all {} { return $mychangesets }
667
+ typemethod of {cid} { return $myidmap($cid) }
668
+ typemethod ofrev {iid} { return $myitemmap($iid) }
668669
669670
# # ## ### ##### ######## #############
670671
## Configuration
671672
672673
pragma -hastypeinfo no ; # no type introspection
673674
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -29,11 +29,11 @@
29
30 snit::type ::vc::fossil::import::cvs::project::rev {
31 # # ## ### ##### ######## #############
32 ## Public API
33
34 constructor {project cstype srcid revisions {theid {}}} {
35 if {$theid ne ""} {
36 set myid $theid
37 } else {
38 set myid [incr mycounter]
39 }
@@ -42,20 +42,20 @@
42
43 set myproject $project
44 set mytype $cstype
45 set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype}
46 set mysrcid $srcid
47 set myrevisions $revisions
48 set mypos {} ; # Commit location is not known yet.
49
50 # Keep track of the generated changesets and of the inverse
51 # mapping from revisions to them.
52 lappend mychangesets $self
53 set myidmap($myid) $self
54 foreach r $revisions {
55 set key [list $cstype $id]
56 set myrevmap($key) $self
57 lappend mytitems $key
58 }
59 return
60 }
61
@@ -89,12 +89,12 @@
89 method successormap {} {
90 # NOTE / FUTURE: Possible bottleneck.
91 array set tmp {}
92 foreach {rev children} [$self nextmap] {
93 foreach child $children {
94 # 8.5 lappend tmp($rev) {*}$myrevmap($child)
95 foreach cset $myrevmap($child) {
96 lappend tmp($rev) $cset
97 }
98 }
99 set tmp($rev) [lsort -unique $tmp($rev)]
100 }
@@ -105,12 +105,12 @@
105 method successors {} {
106 # NOTE / FUTURE: Possible bottleneck.
107 set csets {}
108 foreach {_ children} [$self nextmap] {
109 foreach child $children {
110 # 8.5 lappend csets {*}$myrevmap($child)
111 foreach cset $myrevmap($child) {
112 lappend csets $cset
113 }
114 }
115 }
116 return [lsort -unique $csets]
@@ -120,12 +120,12 @@
120 method predecessormap {} {
121 # NOTE / FUTURE: Possible bottleneck.
122 array set tmp {}
123 foreach {rev children} [$self premap] {
124 foreach child $children {
125 # 8.5 lappend tmp($rev) {*}$myrevmap($child)
126 foreach cset $myrevmap($child) {
127 lappend tmp($rev) $cset
128 }
129 }
130 set tmp($rev) [lsort -unique $tmp($rev)]
131 }
@@ -133,19 +133,19 @@
133 }
134
135 # item -> list (item)
136 method nextmap {} {
137 if {[llength $mynextmap]} { return $mynextmap }
138 $mytypeobj successors tmp $myrevisions
139 set mynextmap [array get tmp]
140 return $mynextmap
141 }
142
143 # item -> list (item)
144 method premap {} {
145 if {[llength $mypremap]} { return $mypremap }
146 $mytypeobj predecessors tmp $myrevisions
147 set mypremap [array get tmp]
148 return $mypremap
149 }
150
151 method breakinternaldependencies {} {
@@ -169,11 +169,11 @@
169
170 # Array of dependencies (parent -> child). This is pulled from
171 # the state, and limited to successors within the changeset.
172
173 array set dependencies {}
174 $mytypeobj internalsuccessors dependencies $myrevisions
175 if {![array size dependencies]} {return 0} ; # Nothing to break.
176
177 log write 5 csets ...[$self str].......................................................
178
179 # We have internal dependencies to break. We now iterate over
@@ -189,11 +189,11 @@
189 # CROSS position in list -> number of dependencies crossing it
190 # DEPC dependency -> positions it crosses
191 # List: RANGE Of the positions itself.
192 # A dependency is a single-element map parent -> child
193
194 InitializeBreakState $myrevisions
195
196 set fragments {}
197 set pending [list $range]
198 set at 0
199 array set breaks {}
@@ -222,11 +222,11 @@
222 set breaks($best) $cross($best)
223
224 log write 6 csets "Best break @ $best, cutting [nsp $cross($best) dependency dependencies]"
225
226 # Note: The value of best is an abolute location in
227 # myrevisions. Use the start of current to make it an
228 # index absolute to current.
229
230 set brel [expr {$best - [lindex $current 0]}]
231 set bnext $brel ; incr bnext
232 set fragbefore [lrange $current 0 $brel]
@@ -244,18 +244,18 @@
244 incr at
245 }
246
247 log write 6 csets ". . .. ... ..... ........ ............."
248
249 # (*) We clear out the associated part of the myrevmap
250 # in-memory index in preparation for new data. A simple unset
251 # is enough, we have no symbol changesets at this time, and
252 # thus never more than one reference in the list.
253
254 foreach r $myrevisions {
255 set key [list $mytype $r]
256 unset myrevmap($key)
257 }
258
259 # Create changesets for the fragments, reusing the current one
260 # for the first fragment. We sort them in order to allow
261 # checking for gaps and nice messages.
@@ -271,32 +271,31 @@
271 set laste $firste
272 foreach fragment [lrange $fragments 1 end] {
273 Border $fragment s e
274 integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap}
275
276 set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myrevisions $s $e]]
277
278 log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)"
279
280 set laste $e
281 }
282
283 integrity assert {
284 $laste == ([llength $myrevisions]-1)
285 } {Bad fragment end @ $laste, gap, or beyond end of the range}
286
287 # Put the first fragment into the current changeset, and
288 # update the in-memory index. We can simply (re)add the
289 # revisions because we cleared the previously existing
290 # information, see (*) above. Persistence does not matter
291 # here, none of the changesets has been saved to the
292 # persistent state yet.
293
294 set myrevisions [lrange $myrevisions 0 $firste]
295 foreach r $myrevisions {
296 set key [list $mytype $r]
297 set myrevmap($key) $self
298 }
299
300 return 1
301 }
302
@@ -309,44 +308,44 @@
309 state run {
310 INSERT INTO changeset (cid, pid, type, src)
311 VALUES ($myid, $pid, $tid, $mysrcid);
312 }
313
314 foreach rid $myrevisions {
315 state run {
316 INSERT INTO csrevision (cid, pos, rid)
317 VALUES ($myid, $pos, $rid);
318 }
319 incr pos
320 }
321 }
322 return
323 }
324
325 method timerange {} { return [$mytypeobj timerange $myrevisions] }
326
327 method drop {} {
328 state transaction {
329 state run {
330 DELETE FROM changeset WHERE cid = $myid;
331 DELETE FROM csrevision WHERE cid = $myid;
332 }
333 }
334 foreach r $myrevisions {
335 set key [list $mytype $r]
336 unset myrevmap($key)
337 }
338 set pos [lsearch -exact $mychangesets $self]
339 set mychangesets [lreplace $mychangesets $pos $pos]
340 return
341 }
342
343 typemethod split {cset args} {
344 # As part of the creation of the new changesets specified in
345 # ARGS as sets of revisions, all subsets of CSET's revision
346 # set, CSET will be dropped from all databases, in and out of
347 # memory, and then destroyed.
348 #
349 # Note: The item lists found in args are tagged items. They
350 # have to have the same type as the changeset, being subsets
351 # of its items. This is checked in Untag1.
352
@@ -354,16 +353,16 @@
354
355 $cset drop
356 $cset destroy
357
358 set newcsets {}
359 foreach fragmentrevisions $args {
360 integrity assert {
361 [llength $fragmentrevisions]
362 } {Attempted to create an empty changeset, i.e. without revisions}
363 lappend newcsets [$type %AUTO% $project $cstype $cssrc \
364 [Untag $fragmentrevisions $cstype]]
365 }
366
367 foreach c $newcsets { $c persist }
368 return $newcsets
369 }
@@ -401,14 +400,14 @@
401 variable mytypeobj {} ; # Reference to the container for the
402 # type dependent code. Derived from
403 # mytype.
404 variable mysrcid {} ; # Id of the metadata or symbol the cset
405 # is based on.
406 variable myrevisions {} ; # List of the file level revisions,
407 # tags, or branches in the cset, as
408 # ids. Not tagged.
409 variable mytitems {} ; # As myrevisions, the tagged form.
410 variable mypremap {} ; # Dictionary mapping from the items (tagged now)
411 # to their predecessors, also tagged. A
412 # cache to avoid loading this from the
413 # state more than once.
414 variable mynextmap {} ; # Dictionary mapping from the items (tagged)
@@ -653,20 +652,22 @@
653 return
654 }
655
656 # # ## ### ##### ######## #############
657
658 typevariable mychangesets {} ; # List of all known changesets.
659 typevariable myrevmap -array {} ; # Map from items (tagged) to the
660 # list of changesets containing
661 # it. Each item can be used by
662 # only one changeset.
663 typevariable myidmap -array {} ; # Map from changeset id to changeset.
664
665 typemethod all {} { return $mychangesets }
666 typemethod of {id} { return $myidmap($id) }
667 typemethod ofrev {id} { return $myrevmap($id) }
 
 
668
669 # # ## ### ##### ######## #############
670 ## Configuration
671
672 pragma -hastypeinfo no ; # no type introspection
673
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -29,11 +29,11 @@
29
30 snit::type ::vc::fossil::import::cvs::project::rev {
31 # # ## ### ##### ######## #############
32 ## Public API
33
34 constructor {project cstype srcid items {theid {}}} {
35 if {$theid ne ""} {
36 set myid $theid
37 } else {
38 set myid [incr mycounter]
39 }
@@ -42,20 +42,20 @@
42
43 set myproject $project
44 set mytype $cstype
45 set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype}
46 set mysrcid $srcid
47 set myitems $items
48 set mypos {} ; # Commit location is not known yet.
49
50 # Keep track of the generated changesets and of the inverse
51 # mapping from items to them.
52 lappend mychangesets $self
53 set myidmap($myid) $self
54 foreach iid $items {
55 set key [list $cstype $iid]
56 set myitemmap($key) $self
57 lappend mytitems $key
58 }
59 return
60 }
61
@@ -89,12 +89,12 @@
89 method successormap {} {
90 # NOTE / FUTURE: Possible bottleneck.
91 array set tmp {}
92 foreach {rev children} [$self nextmap] {
93 foreach child $children {
94 # 8.5 lappend tmp($rev) {*}$myitemmap($child)
95 foreach cset $myitemmap($child) {
96 lappend tmp($rev) $cset
97 }
98 }
99 set tmp($rev) [lsort -unique $tmp($rev)]
100 }
@@ -105,12 +105,12 @@
105 method successors {} {
106 # NOTE / FUTURE: Possible bottleneck.
107 set csets {}
108 foreach {_ children} [$self nextmap] {
109 foreach child $children {
110 # 8.5 lappend csets {*}$myitemmap($child)
111 foreach cset $myitemmap($child) {
112 lappend csets $cset
113 }
114 }
115 }
116 return [lsort -unique $csets]
@@ -120,12 +120,12 @@
120 method predecessormap {} {
121 # NOTE / FUTURE: Possible bottleneck.
122 array set tmp {}
123 foreach {rev children} [$self premap] {
124 foreach child $children {
125 # 8.5 lappend tmp($rev) {*}$myitemmap($child)
126 foreach cset $myitemmap($child) {
127 lappend tmp($rev) $cset
128 }
129 }
130 set tmp($rev) [lsort -unique $tmp($rev)]
131 }
@@ -133,19 +133,19 @@
133 }
134
135 # item -> list (item)
136 method nextmap {} {
137 if {[llength $mynextmap]} { return $mynextmap }
138 $mytypeobj successors tmp $myitems
139 set mynextmap [array get tmp]
140 return $mynextmap
141 }
142
143 # item -> list (item)
144 method premap {} {
145 if {[llength $mypremap]} { return $mypremap }
146 $mytypeobj predecessors tmp $myitems
147 set mypremap [array get tmp]
148 return $mypremap
149 }
150
151 method breakinternaldependencies {} {
@@ -169,11 +169,11 @@
169
170 # Array of dependencies (parent -> child). This is pulled from
171 # the state, and limited to successors within the changeset.
172
173 array set dependencies {}
174 $mytypeobj internalsuccessors dependencies $myitems
175 if {![array size dependencies]} {return 0} ; # Nothing to break.
176
177 log write 5 csets ...[$self str].......................................................
178
179 # We have internal dependencies to break. We now iterate over
@@ -189,11 +189,11 @@
189 # CROSS position in list -> number of dependencies crossing it
190 # DEPC dependency -> positions it crosses
191 # List: RANGE Of the positions itself.
192 # A dependency is a single-element map parent -> child
193
194 InitializeBreakState $myitems
195
196 set fragments {}
197 set pending [list $range]
198 set at 0
199 array set breaks {}
@@ -222,11 +222,11 @@
222 set breaks($best) $cross($best)
223
224 log write 6 csets "Best break @ $best, cutting [nsp $cross($best) dependency dependencies]"
225
226 # Note: The value of best is an abolute location in
227 # myitems. Use the start of current to make it an
228 # index absolute to current.
229
230 set brel [expr {$best - [lindex $current 0]}]
231 set bnext $brel ; incr bnext
232 set fragbefore [lrange $current 0 $brel]
@@ -244,18 +244,18 @@
244 incr at
245 }
246
247 log write 6 csets ". . .. ... ..... ........ ............."
248
249 # (*) We clear out the associated part of the myitemmap
250 # in-memory index in preparation for new data. A simple unset
251 # is enough, we have no symbol changesets at this time, and
252 # thus never more than one reference in the list.
253
254 foreach iid $myitems {
255 set key [list $mytype $iid]
256 unset myitemmap($key)
257 }
258
259 # Create changesets for the fragments, reusing the current one
260 # for the first fragment. We sort them in order to allow
261 # checking for gaps and nice messages.
@@ -271,32 +271,31 @@
271 set laste $firste
272 foreach fragment [lrange $fragments 1 end] {
273 Border $fragment s e
274 integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap}
275
276 set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myitems $s $e]]
277
278 log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)"
279
280 set laste $e
281 }
282
283 integrity assert {
284 $laste == ([llength $myitems]-1)
285 } {Bad fragment end @ $laste, gap, or beyond end of the range}
286
287 # Put the first fragment into the current changeset, and
288 # update the in-memory index. We can simply (re)add the items
289 # because we cleared the previously existing information, see
290 # (*) above. Persistence does not matter here, none of the
291 # changesets has been saved to the persistent state yet.
292
293 set myitems [lrange $myitems 0 $firste]
294 foreach iid $myitems {
295 set key [list $mytype $iid]
296 set myitemmap($key) $self
 
297 }
298
299 return 1
300 }
301
@@ -309,44 +308,44 @@
308 state run {
309 INSERT INTO changeset (cid, pid, type, src)
310 VALUES ($myid, $pid, $tid, $mysrcid);
311 }
312
313 foreach iid $myitems {
314 state run {
315 INSERT INTO csrevision (cid, pos, rid)
316 VALUES ($myid, $pos, $iid);
317 }
318 incr pos
319 }
320 }
321 return
322 }
323
324 method timerange {} { return [$mytypeobj timerange $myitems] }
325
326 method drop {} {
327 state transaction {
328 state run {
329 DELETE FROM changeset WHERE cid = $myid;
330 DELETE FROM csrevision WHERE cid = $myid;
331 }
332 }
333 foreach iid $myitems {
334 set key [list $mytype $iid]
335 unset myitemmap($key)
336 }
337 set pos [lsearch -exact $mychangesets $self]
338 set mychangesets [lreplace $mychangesets $pos $pos]
339 return
340 }
341
342 typemethod split {cset args} {
343 # As part of the creation of the new changesets specified in
344 # ARGS as sets of items, all subsets of CSET's item set, CSET
345 # will be dropped from all databases, in and out of memory,
346 # and then destroyed.
347 #
348 # Note: The item lists found in args are tagged items. They
349 # have to have the same type as the changeset, being subsets
350 # of its items. This is checked in Untag1.
351
@@ -354,16 +353,16 @@
353
354 $cset drop
355 $cset destroy
356
357 set newcsets {}
358 foreach fragmentitems $args {
359 integrity assert {
360 [llength $fragmentitems]
361 } {Attempted to create an empty changeset, i.e. without items}
362 lappend newcsets [$type %AUTO% $project $cstype $cssrc \
363 [Untag $fragmentitems $cstype]]
364 }
365
366 foreach c $newcsets { $c persist }
367 return $newcsets
368 }
@@ -401,14 +400,14 @@
400 variable mytypeobj {} ; # Reference to the container for the
401 # type dependent code. Derived from
402 # mytype.
403 variable mysrcid {} ; # Id of the metadata or symbol the cset
404 # is based on.
405 variable myitems {} ; # List of the file level revisions,
406 # tags, or branches in the cset, as
407 # ids. Not tagged.
408 variable mytitems {} ; # As myitems, the tagged form.
409 variable mypremap {} ; # Dictionary mapping from the items (tagged now)
410 # to their predecessors, also tagged. A
411 # cache to avoid loading this from the
412 # state more than once.
413 variable mynextmap {} ; # Dictionary mapping from the items (tagged)
@@ -653,20 +652,22 @@
652 return
653 }
654
655 # # ## ### ##### ######## #############
656
657 typevariable mychangesets {} ; # List of all known changesets.
658 typevariable myitemmap -array {} ; # Map from items (tagged) to
659 # the list of changesets
660 # containing it. Each item can
661 # be used by only one
662 # changeset.
663 typevariable myidmap -array {} ; # Map from changeset id to
664 # changeset.
665
666 typemethod all {} { return $mychangesets }
667 typemethod of {cid} { return $myidmap($cid) }
668 typemethod ofrev {iid} { return $myitemmap($iid) }
669
670 # # ## ### ##### ######## #############
671 ## Configuration
672
673 pragma -hastypeinfo no ; # no type introspection
674

Keyboard Shortcuts

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