Fossil SCM

Reworked the in-memory databases of changesets. Objects now hold items, not only revisions. Tags, and branches are new possibilities. Lists of ids go to the type-dependent retrieval command. List of tagged items (type/id pairs) come back, and are in the API. The 1:n map revisions to changesets is now an 1:1-map tagged items to changeset.

aku 2007-11-29 07:24 trunk
Commit 0fcfbf78284063c4832621645afa080b30185887
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -49,11 +49,15 @@
4949
5050
# Keep track of the generated changesets and of the inverse
5151
# mapping from revisions to them.
5252
lappend mychangesets $self
5353
set myidmap($myid) $self
54
- foreach r $revisions { lappend myrevmap($r) $self }
54
+ foreach r $revisions {
55
+ set key [list $cstype $id]
56
+ set myrevmap($key) $self
57
+ lappend mytitems $key
58
+ }
5559
return
5660
}
5761
5862
method str {} {
5963
set str "<"
@@ -68,11 +72,11 @@
6872
append str "$mytype ${myid}${detail}>"
6973
return $str
7074
}
7175
7276
method id {} { return $myid }
73
- method revisions {} { return $myrevisions }
77
+ method revisions {} { return $mytitems }
7478
method data {} { return [list $myproject $mytype $mysrcid] }
7579
7680
delegate method bysymbol to mytypeobj
7781
delegate method byrevision to mytypeobj
7882
delegate method isbranch to mytypeobj
@@ -79,11 +83,11 @@
7983
delegate method istag to mytypeobj
8084
8185
method setpos {p} { set mypos $p ; return }
8286
method pos {} { return $mypos }
8387
84
- # result = dict (revision -> list (changeset))
88
+ # result = dict (item -> list (changeset))
8589
method successormap {} {
8690
# NOTE / FUTURE: Possible bottleneck.
8791
array set tmp {}
8892
foreach {rev children} [$self nextmap] {
8993
foreach child $children {
@@ -95,10 +99,11 @@
9599
set tmp($rev) [lsort -unique $tmp($rev)]
96100
}
97101
return [array get tmp]
98102
}
99103
104
+ # result = list (changeset)
100105
method successors {} {
101106
# NOTE / FUTURE: Possible bottleneck.
102107
set csets {}
103108
foreach {_ children} [$self nextmap] {
104109
foreach child $children {
@@ -109,11 +114,11 @@
109114
}
110115
}
111116
return [lsort -unique $csets]
112117
}
113118
114
- # result = dict (revision -> list (changeset))
119
+ # result = dict (item -> list (changeset))
115120
method predecessormap {} {
116121
# NOTE / FUTURE: Possible bottleneck.
117122
array set tmp {}
118123
foreach {rev children} [$self premap] {
119124
foreach child $children {
@@ -125,19 +130,19 @@
125130
set tmp($rev) [lsort -unique $tmp($rev)]
126131
}
127132
return [array get tmp]
128133
}
129134
130
- # revision -> list (revision)
135
+ # item -> list (item)
131136
method nextmap {} {
132137
if {[llength $mynextmap]} { return $mynextmap }
133138
$mytypeobj successors tmp $myrevisions
134139
set mynextmap [array get tmp]
135140
return $mynextmap
136141
}
137142
138
- # revision -> list (revision)
143
+ # item -> list (item)
139144
method premap {} {
140145
if {[llength $mypremap]} { return $mypremap }
141146
$mytypeobj predecessors tmp $myrevisions
142147
set mypremap [array get tmp]
143148
return $mypremap
@@ -244,11 +249,14 @@
244249
# (*) We clear out the associated part of the myrevmap
245250
# in-memory index in preparation for new data. A simple unset
246251
# is enough, we have no symbol changesets at this time, and
247252
# thus never more than one reference in the list.
248253
249
- foreach r $myrevisions { unset myrevmap($r) }
254
+ foreach r $myrevisions {
255
+ set key [list $mytype $r]
256
+ unset myrevmap($key)
257
+ }
250258
251259
# Create changesets for the fragments, reusing the current one
252260
# for the first fragment. We sort them in order to allow
253261
# checking for gaps and nice messages.
254262
@@ -282,11 +290,14 @@
282290
# information, see (*) above. Persistence does not matter
283291
# here, none of the changesets has been saved to the
284292
# persistent state yet.
285293
286294
set myrevisions [lrange $myrevisions 0 $firste]
287
- foreach r $myrevisions { lappend myrevmap($r) $self }
295
+ foreach r $myrevisions {
296
+ set key [list $mytype $r]
297
+ set myrevmap($key) $self
298
+ }
288299
289300
return 1
290301
}
291302
292303
method persist {} {
@@ -319,16 +330,12 @@
319330
DELETE FROM changeset WHERE cid = $myid;
320331
DELETE FROM csrevision WHERE cid = $myid;
321332
}
322333
}
323334
foreach r $myrevisions {
324
- if {[llength $myrevmap($r)] == 1} {
325
- unset myrevmap($r)
326
- } else {
327
- set pos [lsearch -exact $myrevmap($r) $self]
328
- set myrevmap($r) [lreplace $myrevmap($r) $pos $pos]
329
- }
335
+ set key [list $mytype $r]
336
+ unset myrevmap($key)
330337
}
331338
set pos [lsearch -exact $mychangesets $self]
332339
set mychangesets [lreplace $mychangesets $pos $pos]
333340
return
334341
}
@@ -336,10 +343,14 @@
336343
typemethod split {cset args} {
337344
# As part of the creation of the new changesets specified in
338345
# ARGS as sets of revisions, all subsets of CSET's revision
339346
# set, CSET will be dropped from all databases, in and out of
340347
# 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.
341352
342353
struct::list assign [$cset data] project cstype cssrc
343354
344355
$cset drop
345356
$cset destroy
@@ -347,11 +358,12 @@
347358
set newcsets {}
348359
foreach fragmentrevisions $args {
349360
integrity assert {
350361
[llength $fragmentrevisions]
351362
} {Attempted to create an empty changeset, i.e. without revisions}
352
- lappend newcsets [$type %AUTO% $project $cstype $cssrc $fragmentrevisions]
363
+ lappend newcsets [$type %AUTO% $project $cstype $cssrc \
364
+ [Untag $fragmentrevisions $cstype]]
353365
}
354366
355367
foreach c $newcsets { $c persist }
356368
return $newcsets
357369
}
@@ -359,10 +371,20 @@
359371
typemethod strlist {changesets} {
360372
return [join [struct::list map $changesets [myproc ID]]]
361373
}
362374
363375
proc ID {cset} { $cset str }
376
+
377
+ proc Untag {taggeditems cstype} {
378
+ return [struct::list map $taggeditems [myproc Untag1 $cstype]]
379
+ }
380
+
381
+ proc Untag1 {cstype theitem} {
382
+ struct::list assign $theitem t i
383
+ integrity assert {$cstype eq $t} {Item $i's type is '$t', expected '$cstype'}
384
+ return $i
385
+ }
364386
365387
# # ## ### ##### ######## #############
366388
## State
367389
368390
variable myid {} ; # Id of the cset for the persistent
@@ -379,20 +401,22 @@
379401
variable mytypeobj {} ; # Reference to the container for the
380402
# type dependent code. Derived from
381403
# mytype.
382404
variable mysrcid {} ; # Id of the metadata or symbol the cset
383405
# is based on.
384
- variable myrevisions {} ; # List of the file level revisions in
385
- # the cset.
386
- variable mypremap {} ; # Dictionary mapping from the revisions
387
- # to their predecessors. Cache to avoid
388
- # loading this from the state more than
389
- # once.
390
- variable mynextmap {} ; # Dictionary mapping from the revisions
391
- # to their successors. Cache to avoid
392
- # loading this from the state more than
393
- # once.
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)
415
+ # to their successors (also tagged). A
416
+ # cache to avoid loading this from the
417
+ # state more than once.
394418
variable mypos {} ; # Commit position of the changeset, if
395419
# known.
396420
397421
# # ## ### ##### ######## #############
398422
## Internal methods
@@ -630,18 +654,14 @@
630654
}
631655
632656
# # ## ### ##### ######## #############
633657
634658
typevariable mychangesets {} ; # List of all known changesets.
635
- typevariable myrevmap -array {} ; # Map from revisions to the list
636
- # of changesets containing
637
- # it. NOTE: While only one
638
- # revision changeset can contain
639
- # the revision, there can
640
- # however also be one or more
641
- # additional symbol changesets
642
- # which use it, hence a list.
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.
643663
typevariable myidmap -array {} ; # Map from changeset id to changeset.
644664
645665
typemethod all {} { return $mychangesets }
646666
typemethod of {id} { return $myidmap($id) }
647667
typemethod ofrev {id} { return $myrevmap($id) }
648668
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -49,11 +49,15 @@
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 { lappend myrevmap($r) $self }
 
 
 
 
55 return
56 }
57
58 method str {} {
59 set str "<"
@@ -68,11 +72,11 @@
68 append str "$mytype ${myid}${detail}>"
69 return $str
70 }
71
72 method id {} { return $myid }
73 method revisions {} { return $myrevisions }
74 method data {} { return [list $myproject $mytype $mysrcid] }
75
76 delegate method bysymbol to mytypeobj
77 delegate method byrevision to mytypeobj
78 delegate method isbranch to mytypeobj
@@ -79,11 +83,11 @@
79 delegate method istag to mytypeobj
80
81 method setpos {p} { set mypos $p ; return }
82 method pos {} { return $mypos }
83
84 # result = dict (revision -> list (changeset))
85 method successormap {} {
86 # NOTE / FUTURE: Possible bottleneck.
87 array set tmp {}
88 foreach {rev children} [$self nextmap] {
89 foreach child $children {
@@ -95,10 +99,11 @@
95 set tmp($rev) [lsort -unique $tmp($rev)]
96 }
97 return [array get tmp]
98 }
99
 
100 method successors {} {
101 # NOTE / FUTURE: Possible bottleneck.
102 set csets {}
103 foreach {_ children} [$self nextmap] {
104 foreach child $children {
@@ -109,11 +114,11 @@
109 }
110 }
111 return [lsort -unique $csets]
112 }
113
114 # result = dict (revision -> list (changeset))
115 method predecessormap {} {
116 # NOTE / FUTURE: Possible bottleneck.
117 array set tmp {}
118 foreach {rev children} [$self premap] {
119 foreach child $children {
@@ -125,19 +130,19 @@
125 set tmp($rev) [lsort -unique $tmp($rev)]
126 }
127 return [array get tmp]
128 }
129
130 # revision -> list (revision)
131 method nextmap {} {
132 if {[llength $mynextmap]} { return $mynextmap }
133 $mytypeobj successors tmp $myrevisions
134 set mynextmap [array get tmp]
135 return $mynextmap
136 }
137
138 # revision -> list (revision)
139 method premap {} {
140 if {[llength $mypremap]} { return $mypremap }
141 $mytypeobj predecessors tmp $myrevisions
142 set mypremap [array get tmp]
143 return $mypremap
@@ -244,11 +249,14 @@
244 # (*) We clear out the associated part of the myrevmap
245 # in-memory index in preparation for new data. A simple unset
246 # is enough, we have no symbol changesets at this time, and
247 # thus never more than one reference in the list.
248
249 foreach r $myrevisions { unset myrevmap($r) }
 
 
 
250
251 # Create changesets for the fragments, reusing the current one
252 # for the first fragment. We sort them in order to allow
253 # checking for gaps and nice messages.
254
@@ -282,11 +290,14 @@
282 # information, see (*) above. Persistence does not matter
283 # here, none of the changesets has been saved to the
284 # persistent state yet.
285
286 set myrevisions [lrange $myrevisions 0 $firste]
287 foreach r $myrevisions { lappend myrevmap($r) $self }
 
 
 
288
289 return 1
290 }
291
292 method persist {} {
@@ -319,16 +330,12 @@
319 DELETE FROM changeset WHERE cid = $myid;
320 DELETE FROM csrevision WHERE cid = $myid;
321 }
322 }
323 foreach r $myrevisions {
324 if {[llength $myrevmap($r)] == 1} {
325 unset myrevmap($r)
326 } else {
327 set pos [lsearch -exact $myrevmap($r) $self]
328 set myrevmap($r) [lreplace $myrevmap($r) $pos $pos]
329 }
330 }
331 set pos [lsearch -exact $mychangesets $self]
332 set mychangesets [lreplace $mychangesets $pos $pos]
333 return
334 }
@@ -336,10 +343,14 @@
336 typemethod split {cset args} {
337 # As part of the creation of the new changesets specified in
338 # ARGS as sets of revisions, all subsets of CSET's revision
339 # set, CSET will be dropped from all databases, in and out of
340 # memory, and then destroyed.
 
 
 
 
341
342 struct::list assign [$cset data] project cstype cssrc
343
344 $cset drop
345 $cset destroy
@@ -347,11 +358,12 @@
347 set newcsets {}
348 foreach fragmentrevisions $args {
349 integrity assert {
350 [llength $fragmentrevisions]
351 } {Attempted to create an empty changeset, i.e. without revisions}
352 lappend newcsets [$type %AUTO% $project $cstype $cssrc $fragmentrevisions]
 
353 }
354
355 foreach c $newcsets { $c persist }
356 return $newcsets
357 }
@@ -359,10 +371,20 @@
359 typemethod strlist {changesets} {
360 return [join [struct::list map $changesets [myproc ID]]]
361 }
362
363 proc ID {cset} { $cset str }
 
 
 
 
 
 
 
 
 
 
364
365 # # ## ### ##### ######## #############
366 ## State
367
368 variable myid {} ; # Id of the cset for the persistent
@@ -379,20 +401,22 @@
379 variable mytypeobj {} ; # Reference to the container for the
380 # type dependent code. Derived from
381 # mytype.
382 variable mysrcid {} ; # Id of the metadata or symbol the cset
383 # is based on.
384 variable myrevisions {} ; # List of the file level revisions in
385 # the cset.
386 variable mypremap {} ; # Dictionary mapping from the revisions
387 # to their predecessors. Cache to avoid
388 # loading this from the state more than
389 # once.
390 variable mynextmap {} ; # Dictionary mapping from the revisions
391 # to their successors. Cache to avoid
392 # loading this from the state more than
393 # once.
 
 
394 variable mypos {} ; # Commit position of the changeset, if
395 # known.
396
397 # # ## ### ##### ######## #############
398 ## Internal methods
@@ -630,18 +654,14 @@
630 }
631
632 # # ## ### ##### ######## #############
633
634 typevariable mychangesets {} ; # List of all known changesets.
635 typevariable myrevmap -array {} ; # Map from revisions to the list
636 # of changesets containing
637 # it. NOTE: While only one
638 # revision changeset can contain
639 # the revision, there can
640 # however also be one or more
641 # additional symbol changesets
642 # which use it, hence a list.
643 typevariable myidmap -array {} ; # Map from changeset id to changeset.
644
645 typemethod all {} { return $mychangesets }
646 typemethod of {id} { return $myidmap($id) }
647 typemethod ofrev {id} { return $myrevmap($id) }
648
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -49,11 +49,15 @@
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
62 method str {} {
63 set str "<"
@@ -68,11 +72,11 @@
72 append str "$mytype ${myid}${detail}>"
73 return $str
74 }
75
76 method id {} { return $myid }
77 method revisions {} { return $mytitems }
78 method data {} { return [list $myproject $mytype $mysrcid] }
79
80 delegate method bysymbol to mytypeobj
81 delegate method byrevision to mytypeobj
82 delegate method isbranch to mytypeobj
@@ -79,11 +83,11 @@
83 delegate method istag to mytypeobj
84
85 method setpos {p} { set mypos $p ; return }
86 method pos {} { return $mypos }
87
88 # result = dict (item -> list (changeset))
89 method successormap {} {
90 # NOTE / FUTURE: Possible bottleneck.
91 array set tmp {}
92 foreach {rev children} [$self nextmap] {
93 foreach child $children {
@@ -95,10 +99,11 @@
99 set tmp($rev) [lsort -unique $tmp($rev)]
100 }
101 return [array get tmp]
102 }
103
104 # result = list (changeset)
105 method successors {} {
106 # NOTE / FUTURE: Possible bottleneck.
107 set csets {}
108 foreach {_ children} [$self nextmap] {
109 foreach child $children {
@@ -109,11 +114,11 @@
114 }
115 }
116 return [lsort -unique $csets]
117 }
118
119 # result = dict (item -> list (changeset))
120 method predecessormap {} {
121 # NOTE / FUTURE: Possible bottleneck.
122 array set tmp {}
123 foreach {rev children} [$self premap] {
124 foreach child $children {
@@ -125,19 +130,19 @@
130 set tmp($rev) [lsort -unique $tmp($rev)]
131 }
132 return [array get tmp]
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
@@ -244,11 +249,14 @@
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.
262
@@ -282,11 +290,14 @@
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
303 method persist {} {
@@ -319,16 +330,12 @@
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 }
@@ -336,10 +343,14 @@
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
353 struct::list assign [$cset data] project cstype cssrc
354
355 $cset drop
356 $cset destroy
@@ -347,11 +358,12 @@
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 }
@@ -359,10 +371,20 @@
371 typemethod strlist {changesets} {
372 return [join [struct::list map $changesets [myproc ID]]]
373 }
374
375 proc ID {cset} { $cset str }
376
377 proc Untag {taggeditems cstype} {
378 return [struct::list map $taggeditems [myproc Untag1 $cstype]]
379 }
380
381 proc Untag1 {cstype theitem} {
382 struct::list assign $theitem t i
383 integrity assert {$cstype eq $t} {Item $i's type is '$t', expected '$cstype'}
384 return $i
385 }
386
387 # # ## ### ##### ######## #############
388 ## State
389
390 variable myid {} ; # Id of the cset for the persistent
@@ -379,20 +401,22 @@
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)
415 # to their successors (also tagged). A
416 # cache to avoid loading this from the
417 # state more than once.
418 variable mypos {} ; # Commit position of the changeset, if
419 # known.
420
421 # # ## ### ##### ######## #############
422 ## Internal methods
@@ -630,18 +654,14 @@
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

Keyboard Shortcuts

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