@@ -117,8 +117,10 @@
state run {
DELETE FROM cssuccessor WHERE cid = $myid;
}
set loop 0
+ # TODO: Check other uses of cs_sucessors.
+ # TODO: Consider merging cs_sucessor's SELECT with the INSERT here.
foreach nid [$mytypeobj cs_successors $myitems] {
state run {
INSERT INTO cssuccessor (cid, nid)
VALUES ($myid,$nid)
@@ -324,8 +326,9 @@
proc Getrevisioninfo {revisions} {
set theset ('[join $revisions {','}]')
set revisions {}
+ #foreachrow
foreach {frid path fname revnr rop} [state run [subst -nocommands -nobackslashes {
SELECT U.uuid, F.visible, F.name, R.rev, R.op
FROM revision R, revuuid U, file F
WHERE R.rid IN $theset -- All specified revisions
@@ -582,8 +585,9 @@
# filtering by project and sorting make use of 'project::rev
# rev' impossible.
set res {}
+ #foreachrow
foreach {cid cdate} [state run {
SELECT C.cid, T.date
FROM changeset C, cstimestamp T
WHERE C.type = 0 -- limit to revision changesets
@@ -596,25 +600,28 @@
return $res
}
typemethod getcstypes {} {
- foreach {tid name} [state run {
+ state foreachrow {
SELECT tid, name FROM cstype;
- }] { set mycstype($name) $tid }
+ } { set mycstype($name) $tid }
return
}
typemethod load {repository} {
set n 0
log write 2 csets {Loading the changesets}
- foreach {id pid cstype srcid} [state run {
- SELECT C.cid, C.pid, CS.name, C.src
+ state foreachrow {
+ SELECT C.cid AS id,
+ C.pid AS xpid,
+ CS.name AS cstype,
+ C.src AS srcid
FROM changeset C, cstype CS
WHERE C.type = CS.tid
ORDER BY C.cid
- }] {
+ } {
log progress 2 csets $n {}
- set r [$type %AUTO% [$repository projectof $pid] $cstype $srcid [state run {
+ set r [$type %AUTO% [$repository projectof $xpid] $cstype $srcid [state run {
SELECT C.iid
FROM csitem C
WHERE C.cid = $id
ORDER BY C.pos
@@ -893,8 +900,9 @@
array set delta {}
array set stamp {}
set theset ('[join $revisions {','}]')
+ #foreachrow
foreach {rid time} [state run [subst -nocommands -nobackslashes {
SELECT R.rid, R.date
FROM revision R
WHERE R.rid IN $theset
@@ -1163,37 +1171,37 @@
# changeset internal dependencies.
array set dep {}
- foreach {rid child} [state run [subst -nocommands -nobackslashes {
+ state foreachrow [subst -nocommands -nobackslashes {
-- (1) Primary child
- SELECT R.rid, R.child
+ SELECT R.rid AS xrid, R.child AS xchild
FROM revision R
WHERE R.rid IN $theset -- Restrict to revisions of interest
AND R.child IS NOT NULL -- Has primary child
AND R.child IN $theset -- Which is also of interest
UNION
-- (2) Secondary (branch) children
- SELECT R.rid, B.brid
+ SELECT R.rid AS xrid, B.brid AS xchild
FROM revision R, revisionbranchchildren B
WHERE R.rid IN $theset -- Restrict to revisions of interest
AND R.rid = B.rid -- Select subset of branch children
AND B.brid IN $theset -- Which is also of interest
UNION
-- (4) Child of trunk root successor of last NTDB on trunk.
- SELECT R.rid, RA.child
+ SELECT R.rid AS xrid, RA.child AS xchild
FROM revision R, revision RA
WHERE R.rid IN $theset -- Restrict to revisions of interest
AND R.isdefault -- Restrict to NTDB
AND R.dbchild IS NOT NULL -- and last NTDB belonging to trunk
AND RA.rid = R.dbchild -- Go directly to trunk root
AND RA.child IS NOT NULL -- Has primary child.
AND RA.child IN $theset -- Which is also of interest
- }]] {
+ }] {
# Consider moving this to the integrity module.
- integrity assert {$rid != $child} {Revision $rid depends on itself.}
- lappend dependencies($rid) $child
- set dep($rid,$child) .
+ integrity assert {$xrid != $xchild} {Revision $xrid depends on itself.}
+ lappend dependencies($xrid) $xchild
+ set dep($xrid,$xchild) .
}
# The sql statements above looks only for direct dependencies
# between revision in the changeset. However due to the
@@ -1221,13 +1229,13 @@
log write 14 csets {collected [array size dependencies]}
log write 14 csets pseudo-internalsuccessors
array set fids {}
- foreach {rid fid} [state run [subst -nocommands -nobackslashes {
- SELECT R.rid, R.fid
+ state foreachrow [subst -nocommands -nobackslashes {
+ SELECT R.rid AS xrid, R.fid AS xfid
FROM revision R
WHERE R.rid IN $theset
- }]] { lappend fids($fid) $rid }
+ }] { lappend fids($xfid) $xrid }
set groups {}
foreach {fid rids} [array get fids] {
if {[llength $rids] < 2} continue
@@ -1319,8 +1327,9 @@
# Note that the branches spawned from the revisions, and the
# tags associated with them are successors as well.
+ #foreachrow
foreach {rid child} [state run [subst -nocommands -nobackslashes {
-- (1) Primary child
SELECT R.rid, R.child
FROM revision R
@@ -1345,8 +1354,9 @@
# Consider moving this to the integrity module.
integrity assert {$rid != $child} {Revision $rid depends on itself.}
lappend dependencies([list rev $rid]) [list rev $child]
}
+ #foreachrow
foreach {rid child} [state run [subst -nocommands -nobackslashes {
SELECT R.rid, T.tid
FROM revision R, tag T
WHERE R.rid IN $theset -- Restrict to revisions of interest
@@ -1353,8 +1363,9 @@
AND T.rev = R.rid -- Select tags attached to them
}]] {
lappend dependencies([list rev $rid]) [list sym::tag $child]
}
+ #foreachrow
foreach {rid child} [state run [subst -nocommands -nobackslashes {
SELECT R.rid, B.bid
FROM revision R, branch B
WHERE R.rid IN $theset -- Restrict to revisions of interest
@@ -1571,8 +1582,9 @@
# and tags which have it as their prefered parent are the
# successors of a branch.
set theset ('[join $branches {','}]')
+ #foreachrow
foreach {bid child} [state run [subst -nocommands -nobackslashes {
SELECT B.bid, R.rid
FROM branch B, revision R
WHERE B.bid IN $theset -- Restrict to branches of interest
@@ -1579,8 +1591,9 @@
AND B.first = R.rid -- Get first revision on the branch
}]] {
lappend dependencies([list sym::branch $bid]) [list rev $child]
}
+ #foreachrow
foreach {bid child} [state run [subst -nocommands -nobackslashes {
SELECT B.bid, BX.bid
FROM branch B, preferedparent P, branch BX
WHERE B.bid IN $theset -- Restrict to branches of interest
@@ -1588,8 +1601,9 @@
AND BX.sid = P.sid -- prefered parents of their symbols
}]] {
lappend dependencies([list sym::branch $bid]) [list sym::branch $child]
}
+ #foreachrow
foreach {bid child} [state run [subst -nocommands -nobackslashes {
SELECT B.bid, T.tid
FROM branch B, preferedparent P, tag T
WHERE B.bid IN $theset -- Restrict to branches of interest