65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
-
|
src INTEGER NOT NULL -- REFERENCES meta|symbol (type dependent)
}
state writing cstype {
tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
UNIQUE (name)
}
# Note: Keep the labels used here in sync with the names for
# singleton helper classes for 'project::rev'. They are
# the valid type names for changesets and also hardwired
# in some code.
state run {
INSERT INTO cstype VALUES (0,'rev');
INSERT INTO cstype VALUES (1,'sym::tag');
INSERT INTO cstype VALUES (1,'sym');
INSERT INTO cstype VALUES (2,'sym::branch');
}
# Map from changesets to the (file level) revisions they
# contain. The pos'ition provides an order of the revisions
# within a changeset. They are unique within the changeset.
# The revisions are in principle unique, if we were looking
# only at revision changesets. However a revision can appear
# in both revision and symbol changesets, and in multiple
# symbol changesets as well. So we can only say that it is
# unique within the changeset.
# Map from changesets to the (file level) revisions, tags, or
# branches they contain. The pos'ition provides an order of
# the items within a changeset. They are unique within the
# changeset. The items are in principle unique, if we were
# looking only at relevant changesets. However as they come
# from disparate sources the same id may have different
# meaning, be in different changesets and so is formally not
# unique. So we can only say that it is unique within the
# changeset. The integrity module has stronger checks.
#
# TODO: Check if integrity checks are possible.
state writing csrevision {
cid INTEGER NOT NULL REFERENCES changeset,
pos INTEGER NOT NULL,
rid INTEGER NOT NULL REFERENCES revision,
rid INTEGER NOT NULL, -- REFERENCES revision|tag|branch
UNIQUE (cid, pos),
UNIQUE (cid, rid)
}
project::rev getcstypes
return
}
typemethod load {} {
# Pass manager interface. Executed to load data computed by
# this pass into memory when this pass is skipped instead of
# executed.
state reading changeset
state reading csrevision
state reading cstype
# Need the types first, the constructor in the loop below uses
# them to assert the correctness of type names.
project::rev getcstypes
foreach {id pid cstype srcid} [state run {
SELECT C.cid, C.pid, CS.name, C.src
FROM changeset C, cstype CS
WHERE C.type = CS.tid
ORDER BY C.cid
}] {
set r [project::rev %AUTO% [repository projectof $pid] $cstype $srcid [state run {
SELECT C.rid
FROM csrevision C
WHERE C.cid = $id
ORDER BY C.pos
}] $id]
}
project::rev getcstypes
project::rev loadcounter
return
}
typemethod run {} {
# Pass manager interface. Executed to perform the
# functionality of the pass.
|
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
-
-
-
-
+
+
+
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
set n 0
# First process the tags, then the branches. We know that
# their ids do not overlap with each other.
set lastsymbol {}
set lastlod {}
set lastproject {}
set revisions {}
foreach {sid rid lod pid} [state run {
SELECT S.sid, R.rid, R.lod, S.pid
FROM tag T, revision R, symbol S -- T ==> R/S, using PK indices of R, S.
foreach {sid rid pid} [state run {
SELECT S.sid, T.tid, S.pid
FROM tag T, symbol S -- T ==> R/S, using PK indices of R, S.
WHERE T.rev = R.rid
AND T.sid = S.sid
ORDER BY S.sid, R.lod, R.date
WHERE T.sid = S.sid
ORDER BY S.sid, T.tid
}] {
if {($lastlod != $lod) || ($lastsymbol != $sid)} {
if {$lastsymbol != $sid} {
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
project::rev %AUTO% $p sym $lastsymbol $revisions
project::rev %AUTO% $p sym::tag $lastsymbol $revisions
set revisions {}
}
set lastsymbol $sid
set lastproject $pid
}
lappend revisions $rid
}
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
project::rev %AUTO% $p sym::tag $lastsymbol $revisions
}
set lastlod $lod
set lastsymbol {}
set lasproject {}
set revisions {}
foreach {sid rid pid} [state run {
SELECT S.sid, B.bid, S.pid
FROM branch B, symbol S -- B ==> R/S, using PK indices of R, S.
WHERE B.sid = S.sid
ORDER BY S.sid, B.bid
}] {
if {$lastsymbol != $sid} {
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
project::rev %AUTO% $p sym::branch $lastsymbol $revisions
set revisions {}
}
set lastsymbol $sid
set lastproject $pid
}
lappend revisions $rid
}
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
project::rev %AUTO% $p sym $lastsymbol $revisions
project::rev %AUTO% $p sym::branch $lastsymbol $revisions
}
set lastsymbol {}
set lastlod {}
set lasproject {}
set revisions {}
foreach {sid rid lod pid} [state run {
SELECT S.sid, R.rid, R.lod, S.pid
FROM branch B, revision R, symbol S -- B ==> R/S, using PK indices of R, S.
WHERE B.root = R.rid
AND B.sid = S.sid
ORDER BY S.sid, R.lod, R.date
}] {
if {($lastlod != $lod) || ($lastsymbol != $sid)} {
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
project::rev %AUTO% $p sym $lastsymbol $revisions
set revisions {}
}
set lastsymbol $sid
set lastlod $lod
set lastproject $pid
}
lappend revisions $rid
}
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
project::rev %AUTO% $p sym $lastsymbol $revisions
}
log write 4 initcsets "Created [nsp $n {symbol changeset}]"
return
}
proc BreakInternalDependencies {} {
|