Fossil SCM

New command 'state foreachrow' for incremental result processing, using less memory. Converted a number of places in pass InitCSet to this command, and marked a number of othre places for possible future use.

aku 2008-02-24 04:43 trunk
Commit 6559f3231e6964c3beed30174498639c6670a557
--- tools/cvs2fossil/lib/c2f_pinitcsets.tcl
+++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl
@@ -195,19 +195,22 @@
195195
# on the csets. Doing it like this, late creation, means
196196
# less such calls. None, but the creation itself.
197197
198198
log write 14 initcsets meta_begin
199199
mem::mark
200
- foreach {mid rid pid} [state run {
201
- SELECT M.mid, R.rid, M.pid
202
- FROM revision R, meta M -- R ==> M, using PK index of M.
200
+ state foreachrow {
201
+ SELECT M.mid AS xmid,
202
+ R.rid AS xrid,
203
+ M.pid AS xpid
204
+ FROM revision R,
205
+ meta M -- R ==> M, using PK index of M.
203206
WHERE R.mid = M.mid
204207
ORDER BY M.mid, R.date
205
- }] {
208
+ } {
206209
log write 14 initcsets meta_next
207210
208
- if {$lastmeta != $mid} {
211
+ if {$lastmeta != $xmid} {
209212
if {[llength $revisions]} {
210213
incr n
211214
set p [repository projectof $lastproject]
212215
log write 14 initcsets meta_cset_begin
213216
mem::mark
@@ -218,14 +221,14 @@
218221
$cset destroy
219222
foreach cset $spawned { $cset persist ; $cset destroy }
220223
mem::mark
221224
set revisions {}
222225
}
223
- set lastmeta $mid
224
- set lastproject $pid
226
+ set lastmeta $xmid
227
+ set lastproject $xpid
225228
}
226
- lappend revisions $rid
229
+ lappend revisions $xrid
227230
}
228231
229232
if {[llength $revisions]} {
230233
incr n
231234
set p [repository projectof $lastproject]
@@ -266,29 +269,32 @@
266269
267270
set lastsymbol {}
268271
set lastproject {}
269272
set tags {}
270273
271
- foreach {sid tid pid} [state run {
272
- SELECT S.sid, T.tid, S.pid
273
- FROM tag T, symbol S -- T ==> R/S, using PK indices of R, S.
274
+ state foreachrow {
275
+ SELECT S.sid AS xsid,
276
+ T.tid AS xtid,
277
+ S.pid AS xpid
278
+ FROM tag T,
279
+ symbol S -- T ==> R/S, using PK indices of R, S.
274280
WHERE T.sid = S.sid
275281
ORDER BY S.sid, T.tid
276
- }] {
277
- if {$lastsymbol != $sid} {
282
+ } {
283
+ if {$lastsymbol != $xsid} {
278284
if {[llength $tags]} {
279285
incr n
280286
set p [repository projectof $lastproject]
281287
set cset [project::rev %AUTO% $p sym::tag $lastsymbol $tags]
282288
set tags {}
283289
$cset persist
284290
$cset destroy
285291
}
286
- set lastsymbol $sid
287
- set lastproject $pid
292
+ set lastsymbol $xsid
293
+ set lastproject $xpid
288294
}
289
- lappend tags $tid
295
+ lappend tags $xtid
290296
}
291297
292298
if {[llength $tags]} {
293299
incr n
294300
set p [repository projectof $lastproject]
@@ -299,29 +305,32 @@
299305
300306
set lastsymbol {}
301307
set lasproject {}
302308
set branches {}
303309
304
- foreach {sid bid pid} [state run {
305
- SELECT S.sid, B.bid, S.pid
306
- FROM branch B, symbol S -- B ==> R/S, using PK indices of R, S.
310
+ state foreachrow {
311
+ SELECT S.sid AS xsid,
312
+ B.bid AS xbid,
313
+ S.pid AS xpid
314
+ FROM branch B,
315
+ symbol S -- B ==> R/S, using PK indices of R, S.
307316
WHERE B.sid = S.sid
308317
ORDER BY S.sid, B.bid
309
- }] {
310
- if {$lastsymbol != $sid} {
318
+ } {
319
+ if {$lastsymbol != $xsid} {
311320
if {[llength $branches]} {
312321
incr n
313322
set p [repository projectof $lastproject]
314323
set cset [project::rev %AUTO% $p sym::branch $lastsymbol $branches]
315324
set branches {}
316325
$cset persist
317326
$cset destroy
318327
}
319
- set lastsymbol $sid
320
- set lastproject $pid
328
+ set lastsymbol $xsid
329
+ set lastproject $xpid
321330
}
322
- lappend branches $bid
331
+ lappend branches $xbid
323332
}
324333
325334
if {[llength $branches]} {
326335
incr n
327336
set p [repository projectof $lastproject]
328337
--- tools/cvs2fossil/lib/c2f_pinitcsets.tcl
+++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl
@@ -195,19 +195,22 @@
195 # on the csets. Doing it like this, late creation, means
196 # less such calls. None, but the creation itself.
197
198 log write 14 initcsets meta_begin
199 mem::mark
200 foreach {mid rid pid} [state run {
201 SELECT M.mid, R.rid, M.pid
202 FROM revision R, meta M -- R ==> M, using PK index of M.
 
 
 
203 WHERE R.mid = M.mid
204 ORDER BY M.mid, R.date
205 }] {
206 log write 14 initcsets meta_next
207
208 if {$lastmeta != $mid} {
209 if {[llength $revisions]} {
210 incr n
211 set p [repository projectof $lastproject]
212 log write 14 initcsets meta_cset_begin
213 mem::mark
@@ -218,14 +221,14 @@
218 $cset destroy
219 foreach cset $spawned { $cset persist ; $cset destroy }
220 mem::mark
221 set revisions {}
222 }
223 set lastmeta $mid
224 set lastproject $pid
225 }
226 lappend revisions $rid
227 }
228
229 if {[llength $revisions]} {
230 incr n
231 set p [repository projectof $lastproject]
@@ -266,29 +269,32 @@
266
267 set lastsymbol {}
268 set lastproject {}
269 set tags {}
270
271 foreach {sid tid pid} [state run {
272 SELECT S.sid, T.tid, S.pid
273 FROM tag T, symbol S -- T ==> R/S, using PK indices of R, S.
 
 
 
274 WHERE T.sid = S.sid
275 ORDER BY S.sid, T.tid
276 }] {
277 if {$lastsymbol != $sid} {
278 if {[llength $tags]} {
279 incr n
280 set p [repository projectof $lastproject]
281 set cset [project::rev %AUTO% $p sym::tag $lastsymbol $tags]
282 set tags {}
283 $cset persist
284 $cset destroy
285 }
286 set lastsymbol $sid
287 set lastproject $pid
288 }
289 lappend tags $tid
290 }
291
292 if {[llength $tags]} {
293 incr n
294 set p [repository projectof $lastproject]
@@ -299,29 +305,32 @@
299
300 set lastsymbol {}
301 set lasproject {}
302 set branches {}
303
304 foreach {sid bid pid} [state run {
305 SELECT S.sid, B.bid, S.pid
306 FROM branch B, symbol S -- B ==> R/S, using PK indices of R, S.
 
 
 
307 WHERE B.sid = S.sid
308 ORDER BY S.sid, B.bid
309 }] {
310 if {$lastsymbol != $sid} {
311 if {[llength $branches]} {
312 incr n
313 set p [repository projectof $lastproject]
314 set cset [project::rev %AUTO% $p sym::branch $lastsymbol $branches]
315 set branches {}
316 $cset persist
317 $cset destroy
318 }
319 set lastsymbol $sid
320 set lastproject $pid
321 }
322 lappend branches $bid
323 }
324
325 if {[llength $branches]} {
326 incr n
327 set p [repository projectof $lastproject]
328
--- tools/cvs2fossil/lib/c2f_pinitcsets.tcl
+++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl
@@ -195,19 +195,22 @@
195 # on the csets. Doing it like this, late creation, means
196 # less such calls. None, but the creation itself.
197
198 log write 14 initcsets meta_begin
199 mem::mark
200 state foreachrow {
201 SELECT M.mid AS xmid,
202 R.rid AS xrid,
203 M.pid AS xpid
204 FROM revision R,
205 meta M -- R ==> M, using PK index of M.
206 WHERE R.mid = M.mid
207 ORDER BY M.mid, R.date
208 } {
209 log write 14 initcsets meta_next
210
211 if {$lastmeta != $xmid} {
212 if {[llength $revisions]} {
213 incr n
214 set p [repository projectof $lastproject]
215 log write 14 initcsets meta_cset_begin
216 mem::mark
@@ -218,14 +221,14 @@
221 $cset destroy
222 foreach cset $spawned { $cset persist ; $cset destroy }
223 mem::mark
224 set revisions {}
225 }
226 set lastmeta $xmid
227 set lastproject $xpid
228 }
229 lappend revisions $xrid
230 }
231
232 if {[llength $revisions]} {
233 incr n
234 set p [repository projectof $lastproject]
@@ -266,29 +269,32 @@
269
270 set lastsymbol {}
271 set lastproject {}
272 set tags {}
273
274 state foreachrow {
275 SELECT S.sid AS xsid,
276 T.tid AS xtid,
277 S.pid AS xpid
278 FROM tag T,
279 symbol S -- T ==> R/S, using PK indices of R, S.
280 WHERE T.sid = S.sid
281 ORDER BY S.sid, T.tid
282 } {
283 if {$lastsymbol != $xsid} {
284 if {[llength $tags]} {
285 incr n
286 set p [repository projectof $lastproject]
287 set cset [project::rev %AUTO% $p sym::tag $lastsymbol $tags]
288 set tags {}
289 $cset persist
290 $cset destroy
291 }
292 set lastsymbol $xsid
293 set lastproject $xpid
294 }
295 lappend tags $xtid
296 }
297
298 if {[llength $tags]} {
299 incr n
300 set p [repository projectof $lastproject]
@@ -299,29 +305,32 @@
305
306 set lastsymbol {}
307 set lasproject {}
308 set branches {}
309
310 state foreachrow {
311 SELECT S.sid AS xsid,
312 B.bid AS xbid,
313 S.pid AS xpid
314 FROM branch B,
315 symbol S -- B ==> R/S, using PK indices of R, S.
316 WHERE B.sid = S.sid
317 ORDER BY S.sid, B.bid
318 } {
319 if {$lastsymbol != $xsid} {
320 if {[llength $branches]} {
321 incr n
322 set p [repository projectof $lastproject]
323 set cset [project::rev %AUTO% $p sym::branch $lastsymbol $branches]
324 set branches {}
325 $cset persist
326 $cset destroy
327 }
328 set lastsymbol $xsid
329 set lastproject $xpid
330 }
331 lappend branches $xbid
332 }
333
334 if {[llength $branches]} {
335 incr n
336 set p [repository projectof $lastproject]
337
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -116,10 +116,12 @@
116116
# new data.
117117
state run {
118118
DELETE FROM cssuccessor WHERE cid = $myid;
119119
}
120120
set loop 0
121
+ # TODO: Check other uses of cs_sucessors.
122
+ # TODO: Consider merging cs_sucessor's SELECT with the INSERT here.
121123
foreach nid [$mytypeobj cs_successors $myitems] {
122124
state run {
123125
INSERT INTO cssuccessor (cid, nid)
124126
VALUES ($myid,$nid)
125127
}
@@ -323,10 +325,11 @@
323325
}
324326
325327
proc Getrevisioninfo {revisions} {
326328
set theset ('[join $revisions {','}]')
327329
set revisions {}
330
+ #foreachrow
328331
foreach {frid path fname revnr rop} [state run [subst -nocommands -nobackslashes {
329332
SELECT U.uuid, F.visible, F.name, R.rev, R.op
330333
FROM revision R, revuuid U, file F
331334
WHERE R.rid IN $theset -- All specified revisions
332335
AND U.rid = R.rid -- get fossil uuid of revision
@@ -581,10 +584,11 @@
581584
# the order given to them by the sort passes. Both the
582585
# filtering by project and sorting make use of 'project::rev
583586
# rev' impossible.
584587
585588
set res {}
589
+ #foreachrow
586590
foreach {cid cdate} [state run {
587591
SELECT C.cid, T.date
588592
FROM changeset C, cstimestamp T
589593
WHERE C.type = 0 -- limit to revision changesets
590594
AND C.pid = $projectid -- limit to changesets in project
@@ -595,27 +599,30 @@
595599
}
596600
return $res
597601
}
598602
599603
typemethod getcstypes {} {
600
- foreach {tid name} [state run {
604
+ state foreachrow {
601605
SELECT tid, name FROM cstype;
602
- }] { set mycstype($name) $tid }
606
+ } { set mycstype($name) $tid }
603607
return
604608
}
605609
606610
typemethod load {repository} {
607611
set n 0
608612
log write 2 csets {Loading the changesets}
609
- foreach {id pid cstype srcid} [state run {
610
- SELECT C.cid, C.pid, CS.name, C.src
613
+ state foreachrow {
614
+ SELECT C.cid AS id,
615
+ C.pid AS xpid,
616
+ CS.name AS cstype,
617
+ C.src AS srcid
611618
FROM changeset C, cstype CS
612619
WHERE C.type = CS.tid
613620
ORDER BY C.cid
614
- }] {
621
+ } {
615622
log progress 2 csets $n {}
616
- set r [$type %AUTO% [$repository projectof $pid] $cstype $srcid [state run {
623
+ set r [$type %AUTO% [$repository projectof $xpid] $cstype $srcid [state run {
617624
SELECT C.iid
618625
FROM csitem C
619626
WHERE C.cid = $id
620627
ORDER BY C.pos
621628
}] $id]
@@ -892,10 +899,11 @@
892899
893900
array set delta {}
894901
array set stamp {}
895902
896903
set theset ('[join $revisions {','}]')
904
+ #foreachrow
897905
foreach {rid time} [state run [subst -nocommands -nobackslashes {
898906
SELECT R.rid, R.date
899907
FROM revision R
900908
WHERE R.rid IN $theset
901909
}]] {
@@ -1162,39 +1170,39 @@
11621170
# revisions we start from. Sensible as we are looking for
11631171
# changeset internal dependencies.
11641172
11651173
array set dep {}
11661174
1167
- foreach {rid child} [state run [subst -nocommands -nobackslashes {
1175
+ state foreachrow [subst -nocommands -nobackslashes {
11681176
-- (1) Primary child
1169
- SELECT R.rid, R.child
1177
+ SELECT R.rid AS xrid, R.child AS xchild
11701178
FROM revision R
11711179
WHERE R.rid IN $theset -- Restrict to revisions of interest
11721180
AND R.child IS NOT NULL -- Has primary child
11731181
AND R.child IN $theset -- Which is also of interest
11741182
UNION
11751183
-- (2) Secondary (branch) children
1176
- SELECT R.rid, B.brid
1184
+ SELECT R.rid AS xrid, B.brid AS xchild
11771185
FROM revision R, revisionbranchchildren B
11781186
WHERE R.rid IN $theset -- Restrict to revisions of interest
11791187
AND R.rid = B.rid -- Select subset of branch children
11801188
AND B.brid IN $theset -- Which is also of interest
11811189
UNION
11821190
-- (4) Child of trunk root successor of last NTDB on trunk.
1183
- SELECT R.rid, RA.child
1191
+ SELECT R.rid AS xrid, RA.child AS xchild
11841192
FROM revision R, revision RA
11851193
WHERE R.rid IN $theset -- Restrict to revisions of interest
11861194
AND R.isdefault -- Restrict to NTDB
11871195
AND R.dbchild IS NOT NULL -- and last NTDB belonging to trunk
11881196
AND RA.rid = R.dbchild -- Go directly to trunk root
11891197
AND RA.child IS NOT NULL -- Has primary child.
11901198
AND RA.child IN $theset -- Which is also of interest
1191
- }]] {
1199
+ }] {
11921200
# Consider moving this to the integrity module.
1193
- integrity assert {$rid != $child} {Revision $rid depends on itself.}
1194
- lappend dependencies($rid) $child
1195
- set dep($rid,$child) .
1201
+ integrity assert {$xrid != $xchild} {Revision $xrid depends on itself.}
1202
+ lappend dependencies($xrid) $xchild
1203
+ set dep($xrid,$xchild) .
11961204
}
11971205
11981206
# The sql statements above looks only for direct dependencies
11991207
# between revision in the changeset. However due to the
12001208
# vagaries of meta data it is possible for two revisions of
@@ -1220,15 +1228,15 @@
12201228
log write 14 csets {internal [array size dep]}
12211229
log write 14 csets {collected [array size dependencies]}
12221230
log write 14 csets pseudo-internalsuccessors
12231231
12241232
array set fids {}
1225
- foreach {rid fid} [state run [subst -nocommands -nobackslashes {
1226
- SELECT R.rid, R.fid
1233
+ state foreachrow [subst -nocommands -nobackslashes {
1234
+ SELECT R.rid AS xrid, R.fid AS xfid
12271235
FROM revision R
12281236
WHERE R.rid IN $theset
1229
- }]] { lappend fids($fid) $rid }
1237
+ }] { lappend fids($xfid) $xrid }
12301238
12311239
set groups {}
12321240
foreach {fid rids} [array get fids] {
12331241
if {[llength $rids] < 2} continue
12341242
foreach a $rids {
@@ -1318,10 +1326,11 @@
13181326
# '1.2' revision) is a successor, if it exists.
13191327
13201328
# Note that the branches spawned from the revisions, and the
13211329
# tags associated with them are successors as well.
13221330
1331
+ #foreachrow
13231332
foreach {rid child} [state run [subst -nocommands -nobackslashes {
13241333
-- (1) Primary child
13251334
SELECT R.rid, R.child
13261335
FROM revision R
13271336
WHERE R.rid IN $theset -- Restrict to revisions of interest
@@ -1344,18 +1353,20 @@
13441353
}]] {
13451354
# Consider moving this to the integrity module.
13461355
integrity assert {$rid != $child} {Revision $rid depends on itself.}
13471356
lappend dependencies([list rev $rid]) [list rev $child]
13481357
}
1358
+ #foreachrow
13491359
foreach {rid child} [state run [subst -nocommands -nobackslashes {
13501360
SELECT R.rid, T.tid
13511361
FROM revision R, tag T
13521362
WHERE R.rid IN $theset -- Restrict to revisions of interest
13531363
AND T.rev = R.rid -- Select tags attached to them
13541364
}]] {
13551365
lappend dependencies([list rev $rid]) [list sym::tag $child]
13561366
}
1367
+ #foreachrow
13571368
foreach {rid child} [state run [subst -nocommands -nobackslashes {
13581369
SELECT R.rid, B.bid
13591370
FROM revision R, branch B
13601371
WHERE R.rid IN $theset -- Restrict to revisions of interest
13611372
AND B.root = R.rid -- Select branches attached to them
@@ -1570,27 +1581,30 @@
15701581
# The first revision committed on a branch, and all branches
15711582
# and tags which have it as their prefered parent are the
15721583
# successors of a branch.
15731584
15741585
set theset ('[join $branches {','}]')
1586
+ #foreachrow
15751587
foreach {bid child} [state run [subst -nocommands -nobackslashes {
15761588
SELECT B.bid, R.rid
15771589
FROM branch B, revision R
15781590
WHERE B.bid IN $theset -- Restrict to branches of interest
15791591
AND B.first = R.rid -- Get first revision on the branch
15801592
}]] {
15811593
lappend dependencies([list sym::branch $bid]) [list rev $child]
15821594
}
1595
+ #foreachrow
15831596
foreach {bid child} [state run [subst -nocommands -nobackslashes {
15841597
SELECT B.bid, BX.bid
15851598
FROM branch B, preferedparent P, branch BX
15861599
WHERE B.bid IN $theset -- Restrict to branches of interest
15871600
AND B.sid = P.pid -- Get subordinate branches via the
15881601
AND BX.sid = P.sid -- prefered parents of their symbols
15891602
}]] {
15901603
lappend dependencies([list sym::branch $bid]) [list sym::branch $child]
15911604
}
1605
+ #foreachrow
15921606
foreach {bid child} [state run [subst -nocommands -nobackslashes {
15931607
SELECT B.bid, T.tid
15941608
FROM branch B, preferedparent P, tag T
15951609
WHERE B.bid IN $theset -- Restrict to branches of interest
15961610
AND B.sid = P.pid -- Get subordinate tags via the
15971611
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -116,10 +116,12 @@
116 # new data.
117 state run {
118 DELETE FROM cssuccessor WHERE cid = $myid;
119 }
120 set loop 0
 
 
121 foreach nid [$mytypeobj cs_successors $myitems] {
122 state run {
123 INSERT INTO cssuccessor (cid, nid)
124 VALUES ($myid,$nid)
125 }
@@ -323,10 +325,11 @@
323 }
324
325 proc Getrevisioninfo {revisions} {
326 set theset ('[join $revisions {','}]')
327 set revisions {}
 
328 foreach {frid path fname revnr rop} [state run [subst -nocommands -nobackslashes {
329 SELECT U.uuid, F.visible, F.name, R.rev, R.op
330 FROM revision R, revuuid U, file F
331 WHERE R.rid IN $theset -- All specified revisions
332 AND U.rid = R.rid -- get fossil uuid of revision
@@ -581,10 +584,11 @@
581 # the order given to them by the sort passes. Both the
582 # filtering by project and sorting make use of 'project::rev
583 # rev' impossible.
584
585 set res {}
 
586 foreach {cid cdate} [state run {
587 SELECT C.cid, T.date
588 FROM changeset C, cstimestamp T
589 WHERE C.type = 0 -- limit to revision changesets
590 AND C.pid = $projectid -- limit to changesets in project
@@ -595,27 +599,30 @@
595 }
596 return $res
597 }
598
599 typemethod getcstypes {} {
600 foreach {tid name} [state run {
601 SELECT tid, name FROM cstype;
602 }] { set mycstype($name) $tid }
603 return
604 }
605
606 typemethod load {repository} {
607 set n 0
608 log write 2 csets {Loading the changesets}
609 foreach {id pid cstype srcid} [state run {
610 SELECT C.cid, C.pid, CS.name, C.src
 
 
 
611 FROM changeset C, cstype CS
612 WHERE C.type = CS.tid
613 ORDER BY C.cid
614 }] {
615 log progress 2 csets $n {}
616 set r [$type %AUTO% [$repository projectof $pid] $cstype $srcid [state run {
617 SELECT C.iid
618 FROM csitem C
619 WHERE C.cid = $id
620 ORDER BY C.pos
621 }] $id]
@@ -892,10 +899,11 @@
892
893 array set delta {}
894 array set stamp {}
895
896 set theset ('[join $revisions {','}]')
 
897 foreach {rid time} [state run [subst -nocommands -nobackslashes {
898 SELECT R.rid, R.date
899 FROM revision R
900 WHERE R.rid IN $theset
901 }]] {
@@ -1162,39 +1170,39 @@
1162 # revisions we start from. Sensible as we are looking for
1163 # changeset internal dependencies.
1164
1165 array set dep {}
1166
1167 foreach {rid child} [state run [subst -nocommands -nobackslashes {
1168 -- (1) Primary child
1169 SELECT R.rid, R.child
1170 FROM revision R
1171 WHERE R.rid IN $theset -- Restrict to revisions of interest
1172 AND R.child IS NOT NULL -- Has primary child
1173 AND R.child IN $theset -- Which is also of interest
1174 UNION
1175 -- (2) Secondary (branch) children
1176 SELECT R.rid, B.brid
1177 FROM revision R, revisionbranchchildren B
1178 WHERE R.rid IN $theset -- Restrict to revisions of interest
1179 AND R.rid = B.rid -- Select subset of branch children
1180 AND B.brid IN $theset -- Which is also of interest
1181 UNION
1182 -- (4) Child of trunk root successor of last NTDB on trunk.
1183 SELECT R.rid, RA.child
1184 FROM revision R, revision RA
1185 WHERE R.rid IN $theset -- Restrict to revisions of interest
1186 AND R.isdefault -- Restrict to NTDB
1187 AND R.dbchild IS NOT NULL -- and last NTDB belonging to trunk
1188 AND RA.rid = R.dbchild -- Go directly to trunk root
1189 AND RA.child IS NOT NULL -- Has primary child.
1190 AND RA.child IN $theset -- Which is also of interest
1191 }]] {
1192 # Consider moving this to the integrity module.
1193 integrity assert {$rid != $child} {Revision $rid depends on itself.}
1194 lappend dependencies($rid) $child
1195 set dep($rid,$child) .
1196 }
1197
1198 # The sql statements above looks only for direct dependencies
1199 # between revision in the changeset. However due to the
1200 # vagaries of meta data it is possible for two revisions of
@@ -1220,15 +1228,15 @@
1220 log write 14 csets {internal [array size dep]}
1221 log write 14 csets {collected [array size dependencies]}
1222 log write 14 csets pseudo-internalsuccessors
1223
1224 array set fids {}
1225 foreach {rid fid} [state run [subst -nocommands -nobackslashes {
1226 SELECT R.rid, R.fid
1227 FROM revision R
1228 WHERE R.rid IN $theset
1229 }]] { lappend fids($fid) $rid }
1230
1231 set groups {}
1232 foreach {fid rids} [array get fids] {
1233 if {[llength $rids] < 2} continue
1234 foreach a $rids {
@@ -1318,10 +1326,11 @@
1318 # '1.2' revision) is a successor, if it exists.
1319
1320 # Note that the branches spawned from the revisions, and the
1321 # tags associated with them are successors as well.
1322
 
1323 foreach {rid child} [state run [subst -nocommands -nobackslashes {
1324 -- (1) Primary child
1325 SELECT R.rid, R.child
1326 FROM revision R
1327 WHERE R.rid IN $theset -- Restrict to revisions of interest
@@ -1344,18 +1353,20 @@
1344 }]] {
1345 # Consider moving this to the integrity module.
1346 integrity assert {$rid != $child} {Revision $rid depends on itself.}
1347 lappend dependencies([list rev $rid]) [list rev $child]
1348 }
 
1349 foreach {rid child} [state run [subst -nocommands -nobackslashes {
1350 SELECT R.rid, T.tid
1351 FROM revision R, tag T
1352 WHERE R.rid IN $theset -- Restrict to revisions of interest
1353 AND T.rev = R.rid -- Select tags attached to them
1354 }]] {
1355 lappend dependencies([list rev $rid]) [list sym::tag $child]
1356 }
 
1357 foreach {rid child} [state run [subst -nocommands -nobackslashes {
1358 SELECT R.rid, B.bid
1359 FROM revision R, branch B
1360 WHERE R.rid IN $theset -- Restrict to revisions of interest
1361 AND B.root = R.rid -- Select branches attached to them
@@ -1570,27 +1581,30 @@
1570 # The first revision committed on a branch, and all branches
1571 # and tags which have it as their prefered parent are the
1572 # successors of a branch.
1573
1574 set theset ('[join $branches {','}]')
 
1575 foreach {bid child} [state run [subst -nocommands -nobackslashes {
1576 SELECT B.bid, R.rid
1577 FROM branch B, revision R
1578 WHERE B.bid IN $theset -- Restrict to branches of interest
1579 AND B.first = R.rid -- Get first revision on the branch
1580 }]] {
1581 lappend dependencies([list sym::branch $bid]) [list rev $child]
1582 }
 
1583 foreach {bid child} [state run [subst -nocommands -nobackslashes {
1584 SELECT B.bid, BX.bid
1585 FROM branch B, preferedparent P, branch BX
1586 WHERE B.bid IN $theset -- Restrict to branches of interest
1587 AND B.sid = P.pid -- Get subordinate branches via the
1588 AND BX.sid = P.sid -- prefered parents of their symbols
1589 }]] {
1590 lappend dependencies([list sym::branch $bid]) [list sym::branch $child]
1591 }
 
1592 foreach {bid child} [state run [subst -nocommands -nobackslashes {
1593 SELECT B.bid, T.tid
1594 FROM branch B, preferedparent P, tag T
1595 WHERE B.bid IN $theset -- Restrict to branches of interest
1596 AND B.sid = P.pid -- Get subordinate tags via the
1597
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -116,10 +116,12 @@
116 # new data.
117 state run {
118 DELETE FROM cssuccessor WHERE cid = $myid;
119 }
120 set loop 0
121 # TODO: Check other uses of cs_sucessors.
122 # TODO: Consider merging cs_sucessor's SELECT with the INSERT here.
123 foreach nid [$mytypeobj cs_successors $myitems] {
124 state run {
125 INSERT INTO cssuccessor (cid, nid)
126 VALUES ($myid,$nid)
127 }
@@ -323,10 +325,11 @@
325 }
326
327 proc Getrevisioninfo {revisions} {
328 set theset ('[join $revisions {','}]')
329 set revisions {}
330 #foreachrow
331 foreach {frid path fname revnr rop} [state run [subst -nocommands -nobackslashes {
332 SELECT U.uuid, F.visible, F.name, R.rev, R.op
333 FROM revision R, revuuid U, file F
334 WHERE R.rid IN $theset -- All specified revisions
335 AND U.rid = R.rid -- get fossil uuid of revision
@@ -581,10 +584,11 @@
584 # the order given to them by the sort passes. Both the
585 # filtering by project and sorting make use of 'project::rev
586 # rev' impossible.
587
588 set res {}
589 #foreachrow
590 foreach {cid cdate} [state run {
591 SELECT C.cid, T.date
592 FROM changeset C, cstimestamp T
593 WHERE C.type = 0 -- limit to revision changesets
594 AND C.pid = $projectid -- limit to changesets in project
@@ -595,27 +599,30 @@
599 }
600 return $res
601 }
602
603 typemethod getcstypes {} {
604 state foreachrow {
605 SELECT tid, name FROM cstype;
606 } { set mycstype($name) $tid }
607 return
608 }
609
610 typemethod load {repository} {
611 set n 0
612 log write 2 csets {Loading the changesets}
613 state foreachrow {
614 SELECT C.cid AS id,
615 C.pid AS xpid,
616 CS.name AS cstype,
617 C.src AS srcid
618 FROM changeset C, cstype CS
619 WHERE C.type = CS.tid
620 ORDER BY C.cid
621 } {
622 log progress 2 csets $n {}
623 set r [$type %AUTO% [$repository projectof $xpid] $cstype $srcid [state run {
624 SELECT C.iid
625 FROM csitem C
626 WHERE C.cid = $id
627 ORDER BY C.pos
628 }] $id]
@@ -892,10 +899,11 @@
899
900 array set delta {}
901 array set stamp {}
902
903 set theset ('[join $revisions {','}]')
904 #foreachrow
905 foreach {rid time} [state run [subst -nocommands -nobackslashes {
906 SELECT R.rid, R.date
907 FROM revision R
908 WHERE R.rid IN $theset
909 }]] {
@@ -1162,39 +1170,39 @@
1170 # revisions we start from. Sensible as we are looking for
1171 # changeset internal dependencies.
1172
1173 array set dep {}
1174
1175 state foreachrow [subst -nocommands -nobackslashes {
1176 -- (1) Primary child
1177 SELECT R.rid AS xrid, R.child AS xchild
1178 FROM revision R
1179 WHERE R.rid IN $theset -- Restrict to revisions of interest
1180 AND R.child IS NOT NULL -- Has primary child
1181 AND R.child IN $theset -- Which is also of interest
1182 UNION
1183 -- (2) Secondary (branch) children
1184 SELECT R.rid AS xrid, B.brid AS xchild
1185 FROM revision R, revisionbranchchildren B
1186 WHERE R.rid IN $theset -- Restrict to revisions of interest
1187 AND R.rid = B.rid -- Select subset of branch children
1188 AND B.brid IN $theset -- Which is also of interest
1189 UNION
1190 -- (4) Child of trunk root successor of last NTDB on trunk.
1191 SELECT R.rid AS xrid, RA.child AS xchild
1192 FROM revision R, revision RA
1193 WHERE R.rid IN $theset -- Restrict to revisions of interest
1194 AND R.isdefault -- Restrict to NTDB
1195 AND R.dbchild IS NOT NULL -- and last NTDB belonging to trunk
1196 AND RA.rid = R.dbchild -- Go directly to trunk root
1197 AND RA.child IS NOT NULL -- Has primary child.
1198 AND RA.child IN $theset -- Which is also of interest
1199 }] {
1200 # Consider moving this to the integrity module.
1201 integrity assert {$xrid != $xchild} {Revision $xrid depends on itself.}
1202 lappend dependencies($xrid) $xchild
1203 set dep($xrid,$xchild) .
1204 }
1205
1206 # The sql statements above looks only for direct dependencies
1207 # between revision in the changeset. However due to the
1208 # vagaries of meta data it is possible for two revisions of
@@ -1220,15 +1228,15 @@
1228 log write 14 csets {internal [array size dep]}
1229 log write 14 csets {collected [array size dependencies]}
1230 log write 14 csets pseudo-internalsuccessors
1231
1232 array set fids {}
1233 state foreachrow [subst -nocommands -nobackslashes {
1234 SELECT R.rid AS xrid, R.fid AS xfid
1235 FROM revision R
1236 WHERE R.rid IN $theset
1237 }] { lappend fids($xfid) $xrid }
1238
1239 set groups {}
1240 foreach {fid rids} [array get fids] {
1241 if {[llength $rids] < 2} continue
1242 foreach a $rids {
@@ -1318,10 +1326,11 @@
1326 # '1.2' revision) is a successor, if it exists.
1327
1328 # Note that the branches spawned from the revisions, and the
1329 # tags associated with them are successors as well.
1330
1331 #foreachrow
1332 foreach {rid child} [state run [subst -nocommands -nobackslashes {
1333 -- (1) Primary child
1334 SELECT R.rid, R.child
1335 FROM revision R
1336 WHERE R.rid IN $theset -- Restrict to revisions of interest
@@ -1344,18 +1353,20 @@
1353 }]] {
1354 # Consider moving this to the integrity module.
1355 integrity assert {$rid != $child} {Revision $rid depends on itself.}
1356 lappend dependencies([list rev $rid]) [list rev $child]
1357 }
1358 #foreachrow
1359 foreach {rid child} [state run [subst -nocommands -nobackslashes {
1360 SELECT R.rid, T.tid
1361 FROM revision R, tag T
1362 WHERE R.rid IN $theset -- Restrict to revisions of interest
1363 AND T.rev = R.rid -- Select tags attached to them
1364 }]] {
1365 lappend dependencies([list rev $rid]) [list sym::tag $child]
1366 }
1367 #foreachrow
1368 foreach {rid child} [state run [subst -nocommands -nobackslashes {
1369 SELECT R.rid, B.bid
1370 FROM revision R, branch B
1371 WHERE R.rid IN $theset -- Restrict to revisions of interest
1372 AND B.root = R.rid -- Select branches attached to them
@@ -1570,27 +1581,30 @@
1581 # The first revision committed on a branch, and all branches
1582 # and tags which have it as their prefered parent are the
1583 # successors of a branch.
1584
1585 set theset ('[join $branches {','}]')
1586 #foreachrow
1587 foreach {bid child} [state run [subst -nocommands -nobackslashes {
1588 SELECT B.bid, R.rid
1589 FROM branch B, revision R
1590 WHERE B.bid IN $theset -- Restrict to branches of interest
1591 AND B.first = R.rid -- Get first revision on the branch
1592 }]] {
1593 lappend dependencies([list sym::branch $bid]) [list rev $child]
1594 }
1595 #foreachrow
1596 foreach {bid child} [state run [subst -nocommands -nobackslashes {
1597 SELECT B.bid, BX.bid
1598 FROM branch B, preferedparent P, branch BX
1599 WHERE B.bid IN $theset -- Restrict to branches of interest
1600 AND B.sid = P.pid -- Get subordinate branches via the
1601 AND BX.sid = P.sid -- prefered parents of their symbols
1602 }]] {
1603 lappend dependencies([list sym::branch $bid]) [list sym::branch $child]
1604 }
1605 #foreachrow
1606 foreach {bid child} [state run [subst -nocommands -nobackslashes {
1607 SELECT B.bid, T.tid
1608 FROM branch B, preferedparent P, tag T
1609 WHERE B.bid IN $theset -- Restrict to branches of interest
1610 AND B.sid = P.pid -- Get subordinate tags via the
1611
--- tools/cvs2fossil/lib/c2f_state.tcl
+++ tools/cvs2fossil/lib/c2f_state.tcl
@@ -158,10 +158,16 @@
158158
159159
typemethod run {args} {
160160
Save $args
161161
return [uplevel 1 [linsert $args 0 $mystate eval]]
162162
}
163
+
164
+ typemethod foreachrow {sql script} {
165
+ Save $sql
166
+ uplevel 1 [list $mystate eval $sql $script]
167
+ return
168
+ }
163169
164170
typemethod one {args} {
165171
Save $args
166172
return [uplevel 1 [linsert $args 0 $mystate onecolumn]]
167173
}
168174
--- tools/cvs2fossil/lib/c2f_state.tcl
+++ tools/cvs2fossil/lib/c2f_state.tcl
@@ -158,10 +158,16 @@
158
159 typemethod run {args} {
160 Save $args
161 return [uplevel 1 [linsert $args 0 $mystate eval]]
162 }
 
 
 
 
 
 
163
164 typemethod one {args} {
165 Save $args
166 return [uplevel 1 [linsert $args 0 $mystate onecolumn]]
167 }
168
--- tools/cvs2fossil/lib/c2f_state.tcl
+++ tools/cvs2fossil/lib/c2f_state.tcl
@@ -158,10 +158,16 @@
158
159 typemethod run {args} {
160 Save $args
161 return [uplevel 1 [linsert $args 0 $mystate eval]]
162 }
163
164 typemethod foreachrow {sql script} {
165 Save $sql
166 uplevel 1 [list $mystate eval $sql $script]
167 return
168 }
169
170 typemethod one {args} {
171 Save $args
172 return [uplevel 1 [linsert $args 0 $mystate onecolumn]]
173 }
174

Keyboard Shortcuts

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