Fossil SCM

Added comments to the sql commands in the integrity checks.

aku 2008-01-27 20:38 trunk
Commit 727f370c2927c0788f0adc64f16d67258b237c34
--- tools/cvs2fossil/lib/c2f_integrity.tcl
+++ tools/cvs2fossil/lib/c2f_integrity.tcl
@@ -78,38 +78,38 @@
7878
CheckRev \
7979
{Revisions and their LODs have to be in the same project} \
8080
{disagrees with its LOD about owning project} {
8181
SELECT F.name, R.rev
8282
FROM revision R, file F, symbol S
83
- WHERE R.fid = F.fid
84
- AND R.lod = S.sid
85
- AND F.pid != S.pid
83
+ WHERE R.fid = F.fid -- get file of rev
84
+ AND R.lod = S.sid -- get symbol of its lod
85
+ AND F.pid != S.pid -- disagreement about the owning project
8686
;
8787
}
8888
# Find all revisions which disgree with their meta data about
8989
# the project they are owned by.
9090
CheckRev \
9191
{Revisions and their meta data have to be in the same project} \
9292
{disagrees with its meta data about owning project} {
9393
SELECT F.name, R.rev
9494
FROM revision R, file F, meta M
95
- WHERE R.fid = F.fid
96
- AND R.mid = M.mid
97
- AND F.pid != M.pid
95
+ WHERE R.fid = F.fid -- get file of rev
96
+ AND R.mid = M.mid -- get meta of rev
97
+ AND F.pid != M.pid -- disagreement about owning project
9898
;
9999
}
100100
# Find all revisions with a primary child which disagrees
101101
# about the file they belong to.
102102
CheckRev \
103103
{Revisions and their primary children have to be in the same file} \
104104
{disagrees with its primary child about the owning file} {
105105
SELECT F.name, R.rev
106106
FROM revision R, revision C, file F
107
- WHERE R.fid = F.fid
108
- AND R.child IS NOT NULL
109
- AND R.child = C.rid
110
- AND C.fid != R.fid
107
+ WHERE R.fid = F.fid -- get file of rev
108
+ AND R.child IS NOT NULL -- get all with primary children
109
+ AND R.child = C.rid -- get primary child
110
+ AND C.fid != R.fid -- wrongly in different file
111111
;
112112
}
113113
114114
# Find all revisions with a branch parent symbol whose parent
115115
# disagrees about the file they belong to.
@@ -116,170 +116,170 @@
116116
CheckRev \
117117
{Revisions and their branch children have to be in the same file} \
118118
{at the beginning of its branch and its parent disagree about the owning file} {
119119
SELECT F.name, R.rev
120120
FROM revision R, revision P, file F
121
- WHERE R.fid = F.fid
122
- AND R.bparent IS NOT NULL
123
- AND R.parent = P.rid
124
- AND R.fid != P.fid
121
+ WHERE R.fid = F.fid -- get file of rev
122
+ AND R.bparent IS NOT NULL -- get first-of-branch revisions
123
+ AND R.parent = P.rid -- get out-of-branch parent
124
+ AND R.fid != P.fid -- wrongly in different file
125125
;
126126
}
127127
# Find all revisions with a non-NTDB child which disagrees
128128
# about the file they belong to.
129129
CheckRev \
130130
{Revisions and their non-NTDB children have to be in the same file} \
131131
{disagrees with its non-NTDB child about the owning file} {
132132
SELECT F.name, R.rev
133133
FROM revision R, revision C, file F
134
- WHERE R.fid = F.fid
135
- AND R.dbchild IS NOT NULL
136
- AND R.dbchild = C.rid
137
- AND C.fid != R.fid
134
+ WHERE R.fid = F.fid -- get file of rev
135
+ AND R.dbchild IS NOT NULL -- get last NTDB revisions
136
+ AND R.dbchild = C.rid -- get their child
137
+ AND C.fid != R.fid -- wrongly in different file
138138
;
139139
}
140140
# Find all revisions which have a primary child, but the child
141141
# does not have them as parent.
142142
CheckRev \
143143
{Revisions have to be parents of their primary children} \
144144
{is not the parent of its primary child} {
145145
SELECT F.name, R.rev
146146
FROM revision R, revision C, file F
147
- WHERE R.fid = F.fid
148
- AND R.child IS NOT NULL
149
- AND R.child = C.rid
150
- AND C.parent != R.rid
147
+ WHERE R.fid = F.fid -- get file of rev
148
+ AND R.child IS NOT NULL -- get all with primary children
149
+ AND R.child = C.rid -- get primary child
150
+ AND C.parent != R.rid -- child's parent wrongly not us
151151
;
152152
}
153153
# Find all revisions which have a primrary child, but the
154154
# child has a branch parent symbol making them brach starters.
155155
CheckRev \
156156
{Primary children of revisions must not start branches} \
157157
{is parent of a primary child which is the beginning of a branch} {
158158
SELECT F.name, R.rev
159159
FROM revision R, revision C, file F
160
- WHERE R.fid = F.fid
161
- AND R.child IS NOT NULL
162
- AND R.child = C.rid
163
- AND C.bparent IS NOT NULL
160
+ WHERE R.fid = F.fid -- get file of rev
161
+ AND R.child IS NOT NULL -- get all with primary children
162
+ AND R.child = C.rid -- get primary child
163
+ AND C.bparent IS NOT NULL -- but indicates to be on branch
164164
;
165165
}
166166
# Find all revisions without branch parent symbol which have a
167167
# parent, but the parent does not have them as primary child.
168168
CheckRev \
169169
{Revisions have to be primary children of their parents, if any} \
170170
{is not the child of its parent} {
171171
SELECT F.name, R.rev
172172
FROM revision R, revision P, file F
173
- WHERE R.fid = F.fid
174
- AND R.bparent IS NULL
175
- AND R.parent IS NOT NULL
176
- AND R.parent = P.rid
177
- AND P.child != R.rid
173
+ WHERE R.fid = F.fid -- get file of revision
174
+ AND R.bparent IS NULL -- exclude all first-on-branch revisions
175
+ AND R.parent IS NOT NULL -- which are not root of their line
176
+ AND R.parent = P.rid -- get in-lod parent
177
+ AND P.child != R.rid -- but does not have rev as primary child
178178
;
179179
}
180180
# Find all revisions with a branch parent symbol which do not
181181
# have a parent.
182182
CheckRev \
183183
{Branch starting revisions have to have a parent, if not detached} \
184184
{at the beginning of its branch has no parent, but its branch has} {
185185
SELECT F.name, R.rev
186186
FROM revision R, file F, branch B
187
- WHERE R.fid = F.fid
188
- AND R.bparent IS NOT NULL
189
- AND R.parent IS NULL
190
- AND B.sid = R.bparent
191
- AND B.fid = R.fid
192
- AND B.root IS NOT NULL
187
+ WHERE R.fid = F.fid -- get file of revision
188
+ AND R.bparent IS NOT NULL -- limit to first-on-branch revisions
189
+ AND R.parent IS NULL -- which are detached
190
+ AND B.sid = R.bparent -- get branch governing the rev
191
+ AND B.fid = R.fid -- in the revision's file
192
+ AND B.root IS NOT NULL -- but says that branch is attached
193193
;
194194
}
195195
# Find all revisions with a branch parent symbol whose parent
196196
# has them as primary child.
197197
CheckRev \
198198
{Branch starting revisions must not be primary children of their parents} \
199199
{at the beginning of its branch is the primary child of its parent} {
200200
SELECT F.name, R.rev
201201
FROM revision R, revision P, file F
202
- WHERE R.fid = F.fid
203
- AND R.bparent IS NOT NULL
204
- AND R.parent IS NOT NULL
205
- AND R.parent = P.rid
206
- AND P.child = R.rid
202
+ WHERE R.fid = F.fid -- get file of revision
203
+ AND R.bparent IS NOT NULL -- limit to first-on-branch revisions
204
+ AND R.parent IS NOT NULL -- which are attached
205
+ AND R.parent = P.rid -- get out-of-branch parent
206
+ AND P.child = R.rid -- wrongly has rev as primary child
207207
;
208208
}
209209
# Find all revisions with a non-NTDB child which are not on
210210
# the NTDB.
211211
CheckRev \
212212
{NTDB to trunk transition has to begin on NTDB} \
213213
{has a non-NTDB child, yet is not on the NTDB} {
214214
SELECT F.name, R.rev
215215
FROM revision R, file F
216
- WHERE R.fid = F.fid
217
- AND R.dbchild IS NOT NULL
218
- AND NOT R.isdefault
216
+ WHERE R.fid = F.fid -- get file of revision
217
+ AND R.dbchild IS NOT NULL -- limit to last NTDB revision
218
+ AND NOT R.isdefault -- but signals not-NTDB
219219
;
220220
}
221221
# Find all revisions with a NTDB parent which are on the NTDB.
222222
CheckRev \
223223
{NTDB to trunk transition has to end on non-NTDB} \
224224
{has a NTDB parent, yet is on the NTDB} {
225225
SELECT F.name, R.rev
226226
FROM revision R, file F
227
- WHERE R.fid = F.fid
228
- AND R.dbparent IS NOT NULL
229
- AND R.isdefault
227
+ WHERE R.fid = F.fid -- get file of revision
228
+ AND R.dbparent IS NOT NULL -- limit to roots of non-NTDB
229
+ AND R.isdefault -- but signals to be NTDB
230230
;
231231
}
232232
# Find all revisions with a child which disagrees about the
233233
# line of development they belong to.
234234
CheckRev \
235235
{Revisions and their primary children have to be in the same LOD} \
236236
{and its primary child disagree about their LOD} {
237237
SELECT F.name, R.rev
238238
FROM revision R, revision C, file F
239
- WHERE R.fid = F.fid
240
- AND R.child IS NOT NULL
241
- AND R.child = C.rid
242
- AND C.lod != R.lod
239
+ WHERE R.fid = F.fid -- get file of revision
240
+ AND R.child IS NOT NULL -- revision has a primary child
241
+ AND R.child = C.rid -- get that child
242
+ AND C.lod != R.lod -- child wrongly disagrees with lod
243243
;
244244
}
245245
# Find all revisions with a non-NTDB child which agrees about
246246
# the line of development they belong to.
247247
CheckRev \
248248
{NTDB and trunk revisions have to be in different LODs} \
249249
{on NTDB and its non-NTDB child wrongly agree about their LOD} {
250250
SELECT F.name, R.rev
251251
FROM revision R, revision C, file F
252
- WHERE R.fid = F.fid
253
- AND R.dbchild IS NOT NULL
254
- AND R.dbchild = C.rid
255
- AND C.lod = R.lod
252
+ WHERE R.fid = F.fid -- get file of revision
253
+ AND R.dbchild IS NOT NULL -- limit to last NTDB revision
254
+ AND R.dbchild = C.rid -- get non-NTDB child
255
+ AND C.lod = R.lod -- child wrongly has same lod
256256
;
257257
}
258258
# Find all revisions with a branch parent symbol which is not
259259
# their LOD.
260260
CheckRev \
261261
{Branch starting revisions have to have their LOD as branch parent symbol} \
262262
{at the beginning of its branch does not have the branch symbol as its LOD} {
263263
SELECT F.name, R.rev
264264
FROM revision R, file F
265
- WHERE R.fid = F.fid
266
- AND R.bparent IS NOT NULL
267
- AND R.lod != R.bparent
265
+ WHERE R.fid = F.fid -- get file of revision
266
+ AND R.bparent IS NOT NULL -- limit to branch-first revisions
267
+ AND R.lod != R.bparent -- out-of-branch parent wrongly is not the lod
268268
;
269269
}
270270
# Find all revisions with a branch parent symbol whose parent
271271
# is in the same line of development.
272272
CheckRev \
273273
{Revisions and their branch children have to be in different LODs} \
274274
{at the beginning of its branch and its parent wrongly agree about their LOD} {
275275
SELECT F.name, R.rev
276276
FROM revision R, revision P, file F
277
- WHERE R.fid = F.fid
278
- AND R.bparent IS NOT NULL
279
- AND R.parent = P.rid
280
- AND R.lod = P.lod
277
+ WHERE R.fid = F.fid -- get file of revision
278
+ AND R.bparent IS NOT NULL -- limit to branch-first revisions
279
+ AND R.parent = P.rid -- get out-of-branch parent of revision
280
+ AND R.lod = P.lod -- rev and parent wrongly agree on lod
281281
;
282282
}
283283
return
284284
}
285285
@@ -295,13 +295,13 @@
295295
CheckRev \
296296
{Revisions and their meta data have to be in the same LOD} \
297297
{disagrees with its meta data about owning LOD} {
298298
SELECT F.name, R.rev
299299
FROM revision R, meta M, file F
300
- WHERE R.mid = M.mid
301
- AND R.lod != M.bid
302
- AND R.fid = F.fid
300
+ WHERE R.mid = M.mid -- get meta data of revision
301
+ AND R.lod != M.bid -- rev wrongly disagrees with meta about lod
302
+ AND R.fid = F.fid -- get file of revision
303303
;
304304
}
305305
return
306306
}
307307
@@ -348,18 +348,20 @@
348348
-- select those with more than one user, and get their
349349
-- associated file (name) for display.
350350
351351
SELECT F.name, R.rev
352352
FROM revision R, file F,
353
- (SELECT CI.iid AS rid, count(CI.cid) AS count
353
+ (SELECT CI.iid AS rid, -- revision item
354
+ count(CI.cid) AS count -- number of csets using item
354355
FROM csitem CI, changeset C
355
- WHERE C.type = 0
356
- AND C.cid = CI.cid
357
- GROUP BY CI.iid) AS U
358
- WHERE U.count > 1
359
- AND R.rid = U.rid
360
- AND R.fid = F.fid
356
+ WHERE C.type = 0 -- limit to revision csets
357
+ AND C.cid = CI.cid -- get item in changeset
358
+ GROUP BY CI.iid -- aggregate by item, count csets/item
359
+ ) AS U
360
+ WHERE U.count > 1 -- limit to item with multiple users
361
+ AND R.rid = U.rid -- get revision of item
362
+ AND R.fid = F.fid -- get file of revision
361363
}
362364
# All revisions have to refer to the same meta information as
363365
# their changeset.
364366
CheckRevCS \
365367
{All revisions have to agree with their changeset about the used meta information} \
@@ -386,16 +388,21 @@
386388
{All revisions in a changeset have to belong to the same LOD} \
387389
{: Its revisions disagree about the LOD they belong to} {
388390
SELECT T.name, C.cid
389391
FROM changeset C, cstype T
390392
WHERE C.cid IN (SELECT U.cid
391
- FROM (SELECT DISTINCT CI.cid AS cid, R.lod AS lod
393
+ FROM (SELECT DISTINCT -- unique cset/lod pairs
394
+ CI.cid AS cid, -- revision cset
395
+ R.lod AS lod -- lod of item in cset
392396
FROM csitem CI, changeset C, revision R
393
- WHERE CI.iid = R.rid
394
- AND C.cid = CI.cid
395
- AND C.type = 0) AS U
396
- GROUP BY U.cid HAVING COUNT(U.lod) > 1)
397
+ WHERE CI.iid = R.rid -- get rev of item in cset
398
+ AND C.cid = CI.cid -- get changeset of item
399
+ AND C.type = 0 -- limit to rev csets
400
+ ) AS U
401
+ GROUP BY U.cid -- aggregate by cset, count lods/cset
402
+ HAVING COUNT(U.lod) > 1 -- find csets with multiple lods
403
+ )
397404
AND T.tid = C.type
398405
}
399406
# All revisions have to agree on the project their changeset
400407
# belongs to. In other words, all revisions in a changeset
401408
# have to refer to the same project.
@@ -409,18 +416,23 @@
409416
{All revisions in a changeset have to belong to the same project} \
410417
{: Its revisions disagree about the project they belong to} {
411418
SELECT T.name, C.cid
412419
FROM changeset C, cstype T
413420
WHERE C.cid IN (SELECT U.cid
414
- FROM (SELECT DISTINCT CI.cid AS cid, F.pid AS pid
421
+ FROM (SELECT DISTINCT -- unique cset/proj pairs
422
+ CI.cid AS cid, -- rev cset
423
+ F.pid AS pid -- project of item in cset
415424
FROM csitem CI, changeset C, revision R, file F
416
- WHERE CI.iid = R.rid
417
- AND C.cid = CI.cid
418
- AND C.type = 0
419
- AND F.fid = R.fid) AS U
420
- GROUP BY U.cid HAVING COUNT(U.pid) > 1)
421
- AND T.tid = C.type
425
+ WHERE CI.iid = R.rid -- get rev of item in cset
426
+ AND C.cid = CI.cid -- get changeset of item
427
+ AND C.type = 0 -- limit to rev changesets
428
+ AND F.fid = R.fid -- get file of revision
429
+ ) AS U
430
+ GROUP BY U.cid -- aggregate by csets, count proj/cset
431
+ HAVING COUNT(U.pid) > 1 -- find csets with multiple projects
432
+ )
433
+ AND T.tid = C.type -- get readable changeset type
422434
}
423435
# All revisions in a single changeset have to belong to
424436
# different files. Conversely: No two revisions of a single
425437
# file are allowed to be in the same changeset.
426438
#
@@ -434,26 +446,34 @@
434446
{All revisions in a changeset have to belong to different files} \
435447
{: Its revisions share files} {
436448
SELECT T.name, C.cid
437449
FROM changeset C, cstype T
438450
WHERE C.cid IN (SELECT VV.cid
439
- FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount
440
- FROM (SELECT DISTINCT CI.cid AS cid, R.fid AS fid
451
+ FROM (SELECT U.cid AS cid, -- rev changeset
452
+ COUNT (U.fid) AS fcount -- number of files by items
453
+ FROM (SELECT DISTINCT -- unique cset/file pairs
454
+ CI.cid AS cid, -- rev changeset
455
+ R.fid AS fid -- file of item in changeset
441456
FROM csitem CI, changeset C, revision R
442
- WHERE CI.iid = R.rid
443
- AND C.cid = CI.cid
444
- AND C.type = 0
457
+ WHERE CI.iid = R.rid -- get rev of item in changeset
458
+ AND C.cid = CI.cid -- get changeset of item
459
+ AND C.type = 0 -- limit to rev csets
445460
) AS U
446
- GROUP BY U.cid) AS UU,
447
- (SELECT V.cid AS cid, COUNT (V.iid) AS rcount
461
+ GROUP BY U.cid -- aggregate by csets, count files/cset
462
+ ) AS UU,
463
+ (SELECT V.cid AS cid, -- rev changeset
464
+ COUNT (V.iid) AS rcount -- number of items
448465
FROM csitem V, changeset X
449
- WHERE X.cid = V.cid
450
- AND X.type = 0
451
- GROUP BY V.cid) AS VV
452
- WHERE VV.cid = UU.cid
453
- AND UU.fcount < VV.rcount)
454
- AND T.tid = C.type
466
+ WHERE X.cid = V.cid -- get changeset of item
467
+ AND X.type = 0 -- limit to rev csets
468
+ GROUP BY V.cid -- aggregate by csets, count items/cset
469
+ ) AS VV
470
+ WHERE VV.cid = UU.cid -- sync #items/cset with #files/cset
471
+ AND UU.fcount < VV.rcount -- less files than items
472
+ -- => items belong to the same file.
473
+ )
474
+ AND T.tid = C.type -- get readable changeset type
455475
}
456476
return
457477
}
458478
459479
proc TagChangesets {} {
@@ -498,19 +518,21 @@
498518
-- user, and get their associated file (name) for
499519
-- display.
500520
501521
SELECT P.name, S.name
502522
FROM tag T, project P, symbol S,
503
- (SELECT CI.iid AS iid, count(CI.cid) AS count
523
+ (SELECT CI.iid AS iid, -- item
524
+ count(CI.cid) AS count -- number of csets using item
504525
FROM csitem CI, changeset C
505
- WHERE C.type = 1
506
- AND C.cid = CI.cid
507
- GROUP BY CI.iid) AS U
508
- WHERE U.count > 1
509
- AND T.tid = U.iid
510
- AND S.sid = T.sid -- get symbol of tag
511
- AND P.pid = S.pid -- get project of symbol
526
+ WHERE C.type = 1 -- limit to tag csets
527
+ AND C.cid = CI.cid -- get items of cset
528
+ GROUP BY CI.iid -- aggregate by item, count csets/item
529
+ ) AS U
530
+ WHERE U.count > 1 -- find tag item used multiple times
531
+ AND T.tid = U.iid -- get tag of item
532
+ AND S.sid = T.sid -- get symbol of tag
533
+ AND P.pid = S.pid -- get project of symbol
512534
}
513535
if 0 {
514536
# This check is disabled for the moment. Apparently tags
515537
# can cross lines of development, at least if the involved
516538
# LODs are the trunk, and the NTDB. That makes sense, as
@@ -556,18 +578,23 @@
556578
{All tags in a changeset have to belong to the same project} \
557579
{: Its tags disagree about the project they belong to} {
558580
SELECT T.name, C.cid
559581
FROM changeset C, cstype T
560582
WHERE C.cid IN (SELECT U.cid
561
- FROM (SELECT DISTINCT CI.cid AS cid, F.pid AS pid
583
+ FROM (SELECT DISTINCT -- unique cset/proj pairs
584
+ CI.cid AS cid, -- tag cset
585
+ F.pid AS pid -- project of item in cset
562586
FROM csitem CI, changeset C, tag T, file F
563
- WHERE CI.iid = T.tid
564
- AND C.cid = CI.cid
565
- AND C.type = 1
566
- AND F.fid = T.fid) AS U
567
- GROUP BY U.cid HAVING COUNT(U.pid) > 1)
568
- AND T.tid = C.type
587
+ WHERE CI.iid = T.tid -- get tag of item in cset
588
+ AND C.cid = CI.cid -- get changeset of item
589
+ AND C.type = 1 -- limit to tag changesets
590
+ AND F.fid = T.fid -- get file of tag
591
+ ) AS U
592
+ GROUP BY U.cid -- aggregate by csets, count proj/cset
593
+ HAVING COUNT(U.pid) > 1 -- find csets with multiple projects
594
+ )
595
+ AND T.tid = C.type -- get readable changeset type
569596
}
570597
# All tags in a single changeset have to belong to different
571598
# files. Conversely: No two tags of a single file are allowed
572599
# to be in the same changeset.
573600
#
@@ -580,26 +607,34 @@
580607
{All tags in a changeset have to belong to different files} \
581608
{: Its tags share files} {
582609
SELECT T.name, C.cid
583610
FROM changeset C, cstype T
584611
WHERE C.cid IN (SELECT VV.cid
585
- FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount
586
- FROM (SELECT DISTINCT CI.cid AS cid, T.fid AS fid
612
+ FROM (SELECT U.cid AS cid, -- changeset
613
+ COUNT (U.fid) AS fcount -- number of files by items
614
+ FROM (SELECT DISTINCT -- unique cset/file pairs
615
+ CI.cid AS cid, -- tag changeset
616
+ T.fid AS fid -- file of item in changeset
587617
FROM csitem CI, changeset C, tag T
588
- WHERE CI.iid = T.tid
589
- AND C.cid = CI.cid
590
- AND C.type = 1
618
+ WHERE CI.iid = T.tid -- get tag of item in changeset
619
+ AND C.cid = CI.cid -- get changeset of item
620
+ AND C.type = 1 -- limit to tag changesets
591621
) AS U
592
- GROUP BY U.cid) AS UU,
593
- (SELECT V.cid AS cid, COUNT (V.iid) AS rcount
622
+ GROUP BY U.cid -- aggregate by csets, count files/cset
623
+ ) AS UU,
624
+ (SELECT V.cid AS cid, -- changeset
625
+ COUNT (V.iid) AS rcount -- number of items in cset
594626
FROM csitem V, changeset X
595
- WHERE X.cid = V.cid
596
- AND X.type = 1
597
- GROUP BY V.cid) AS VV
598
- WHERE VV.cid = UU.cid
599
- AND UU.fcount < VV.rcount)
600
- AND T.tid = C.type
627
+ WHERE X.cid = V.cid -- get changeset of item
628
+ AND X.type = 1 -- limit to tag changesets
629
+ GROUP BY V.cid -- aggregate by csets, count items/cset
630
+ ) AS VV
631
+ WHERE VV.cid = UU.cid -- sync #items/cset with #files/cset
632
+ AND UU.fcount < VV.rcount -- less files than items
633
+ -- => items belong to the same file.
634
+ )
635
+ AND T.tid = C.type -- get readable changeset type
601636
}
602637
return
603638
}
604639
605640
proc BranchChangesets {} {
@@ -628,11 +663,12 @@
628663
FROM branch
629664
EXCEPT -- subtract
630665
SELECT CI.iid -- branches used
631666
FROM csitem CI, changeset C
632667
WHERE C.cid = CI.cid -- by any branch
633
- AND C.type = 2) -- changeset
668
+ AND C.type = 2 -- changeset
669
+ )
634670
AND S.sid = B.sid -- get symbol of branch
635671
AND P.pid = S.pid -- get project of symbol
636672
}
637673
# Find all branches which are used by more than one changeset.
638674
CheckRev \
@@ -645,19 +681,21 @@
645681
-- than one user, and get their associated file (name)
646682
-- for display.
647683
648684
SELECT P.name, S.name
649685
FROM branch B, project P, symbol S,
650
- (SELECT CI.iid AS iid, count(CI.cid) AS count
686
+ (SELECT CI.iid AS iid, -- item
687
+ count(CI.cid) AS count -- number of csets for item
651688
FROM csitem CI, changeset C
652
- WHERE C.type = 2
653
- AND C.cid = CI.cid
654
- GROUP BY CI.iid ) AS U
655
- WHERE U.count > 1
656
- AND B.bid = U.iid
657
- AND S.sid = B.sid -- get symbol of branch
658
- AND P.pid = S.pid -- get project of symbol
689
+ WHERE C.type = 2 -- limit to branch changesets,
690
+ AND C.cid = CI.cid -- get the items they contain,
691
+ GROUP BY CI.iid -- aggregate by items, count csets/item (x)
692
+ ) AS U
693
+ WHERE U.count > 1 -- find items used multiple times
694
+ AND B.bid = U.iid -- get the users (branch changesets)
695
+ AND S.sid = B.sid -- get symbol of branch
696
+ AND P.pid = S.pid -- get project of symbol
659697
}
660698
if 0 {
661699
# This check has been disabled. When the converter was run
662700
# on the Tcl CVS several branches tripped this
663701
# constraint. One of them was a free-floating branch, and
@@ -719,18 +757,23 @@
719757
{All branches in a changeset have to belong to the same project} \
720758
{: Its branches disagree about the project they belong to} {
721759
SELECT T.name, C.cid
722760
FROM changeset C, cstype T
723761
WHERE C.cid IN (SELECT U.cid
724
- FROM (SELECT DISTINCT CI.cid AS cid, F.pid AS pid
762
+ FROM (SELECT DISTINCT -- Unique cset/proj pairs
763
+ CI.cid AS cid, -- Branch cset
764
+ F.pid AS pid -- Project of item in cset
725765
FROM csitem CI, changeset C, branch B, file F
726
- WHERE CI.iid = B.bid
727
- AND C.cid = CI.cid
728
- AND C.type = 2
729
- AND F.fid = B.fid) AS U
730
- GROUP BY U.cid HAVING COUNT(U.pid) > 1)
731
- AND T.tid = C.type
766
+ WHERE CI.iid = B.bid -- get branch of item in cset
767
+ AND C.cid = CI.cid -- get changeset of item
768
+ AND C.type = 2 -- limit to branch changesets
769
+ AND F.fid = B.fid -- get file of branch
770
+ ) AS U
771
+ GROUP BY U.cid -- aggregate by csets, count proj/cset
772
+ HAVING COUNT(U.pid) > 1 -- find cset with multiple projects
773
+ )
774
+ AND T.tid = C.type -- get readable changeset type
732775
}
733776
# All branches in a single changeset have to belong to
734777
# different files. Conversely: No two branches of a single
735778
# file are allowed to be in the same changeset.
736779
#
@@ -744,26 +787,34 @@
744787
{All branches in a changeset have to belong to different files} \
745788
{: Its branches share files} {
746789
SELECT T.name, C.cid
747790
FROM changeset C, cstype T
748791
WHERE C.cid IN (SELECT VV.cid
749
- FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount
750
- FROM (SELECT DISTINCT CI.cid AS cid, B.fid AS fid
792
+ FROM (SELECT U.cid AS cid, -- changeset
793
+ COUNT (U.fid) AS fcount -- number of files by items
794
+ FROM (SELECT DISTINCT -- unique cset/file pairs
795
+ CI.cid AS cid, -- Branch changeset
796
+ B.fid AS fid -- File of item in changeset
751797
FROM csitem CI, changeset C, branch B
752
- WHERE CI.iid = B.bid
753
- AND C.cid = CI.cid
754
- AND C.type = 2
798
+ WHERE CI.iid = B.bid -- get tag of item in changeset
799
+ AND C.cid = CI.cid -- get changeset of item
800
+ AND C.type = 2 -- limit to branch changesets
755801
) AS U
756
- GROUP BY U.cid) AS UU,
757
- (SELECT V.cid AS cid, COUNT (V.iid) AS rcount
802
+ GROUP BY U.cid -- aggregate by csets, count files/cset
803
+ ) AS UU,
804
+ (SELECT V.cid AS cid, -- changeset
805
+ COUNT (V.iid) AS rcount -- number of items in cset
758806
FROM csitem V, changeset X
759
- WHERE X.cid = V.cid
760
- AND X.type = 2
761
- GROUP BY V.cid) AS VV
762
- WHERE VV.cid = UU.cid
763
- AND UU.fcount < VV.rcount)
764
- AND T.tid = C.type
807
+ WHERE X.cid = V.cid -- get changeset of item
808
+ AND X.type = 2 -- limit to branch changesets
809
+ GROUP BY V.cid -- aggregate by csets, count items/cset
810
+ ) AS VV
811
+ WHERE VV.cid = UU.cid -- sync #items/cset with #files/cset
812
+ AND UU.fcount < VV.rcount -- less files than items
813
+ -- => items belong to the same file.
814
+ )
815
+ AND T.tid = C.type -- get readable changeset type
765816
}
766817
return
767818
}
768819
769820
proc ___UnusedChangesetChecks___ {} {
@@ -788,11 +839,11 @@
788839
{All revisions used by tag symbol changesets have to have the changeset's tag attached to them} \
789840
{does not have the tag of its symbol changeset @ attached to it} {
790841
SELECT CT.name, C.cid, F.name, R.rev
791842
FROM changeset C, cstype CT, revision R, file F, csitem CI, tag T
792843
WHERE C.type = 1 -- symbol changesets only
793
- AND C.src = T.sid -- tag only, linked by symbol id
844
+ AND C.src = T.sid -- tag only, linked by symbol id
794845
AND C.cid = CI.cid -- changeset --> its revisions
795846
AND R.rid = CI.iid -- look at the revisions
796847
-- and look for the tag among the attached ones.
797848
AND T.sid NOT IN (SELECT TB.sid
798849
FROM tag TB
799850
--- tools/cvs2fossil/lib/c2f_integrity.tcl
+++ tools/cvs2fossil/lib/c2f_integrity.tcl
@@ -78,38 +78,38 @@
78 CheckRev \
79 {Revisions and their LODs have to be in the same project} \
80 {disagrees with its LOD about owning project} {
81 SELECT F.name, R.rev
82 FROM revision R, file F, symbol S
83 WHERE R.fid = F.fid
84 AND R.lod = S.sid
85 AND F.pid != S.pid
86 ;
87 }
88 # Find all revisions which disgree with their meta data about
89 # the project they are owned by.
90 CheckRev \
91 {Revisions and their meta data have to be in the same project} \
92 {disagrees with its meta data about owning project} {
93 SELECT F.name, R.rev
94 FROM revision R, file F, meta M
95 WHERE R.fid = F.fid
96 AND R.mid = M.mid
97 AND F.pid != M.pid
98 ;
99 }
100 # Find all revisions with a primary child which disagrees
101 # about the file they belong to.
102 CheckRev \
103 {Revisions and their primary children have to be in the same file} \
104 {disagrees with its primary child about the owning file} {
105 SELECT F.name, R.rev
106 FROM revision R, revision C, file F
107 WHERE R.fid = F.fid
108 AND R.child IS NOT NULL
109 AND R.child = C.rid
110 AND C.fid != R.fid
111 ;
112 }
113
114 # Find all revisions with a branch parent symbol whose parent
115 # disagrees about the file they belong to.
@@ -116,170 +116,170 @@
116 CheckRev \
117 {Revisions and their branch children have to be in the same file} \
118 {at the beginning of its branch and its parent disagree about the owning file} {
119 SELECT F.name, R.rev
120 FROM revision R, revision P, file F
121 WHERE R.fid = F.fid
122 AND R.bparent IS NOT NULL
123 AND R.parent = P.rid
124 AND R.fid != P.fid
125 ;
126 }
127 # Find all revisions with a non-NTDB child which disagrees
128 # about the file they belong to.
129 CheckRev \
130 {Revisions and their non-NTDB children have to be in the same file} \
131 {disagrees with its non-NTDB child about the owning file} {
132 SELECT F.name, R.rev
133 FROM revision R, revision C, file F
134 WHERE R.fid = F.fid
135 AND R.dbchild IS NOT NULL
136 AND R.dbchild = C.rid
137 AND C.fid != R.fid
138 ;
139 }
140 # Find all revisions which have a primary child, but the child
141 # does not have them as parent.
142 CheckRev \
143 {Revisions have to be parents of their primary children} \
144 {is not the parent of its primary child} {
145 SELECT F.name, R.rev
146 FROM revision R, revision C, file F
147 WHERE R.fid = F.fid
148 AND R.child IS NOT NULL
149 AND R.child = C.rid
150 AND C.parent != R.rid
151 ;
152 }
153 # Find all revisions which have a primrary child, but the
154 # child has a branch parent symbol making them brach starters.
155 CheckRev \
156 {Primary children of revisions must not start branches} \
157 {is parent of a primary child which is the beginning of a branch} {
158 SELECT F.name, R.rev
159 FROM revision R, revision C, file F
160 WHERE R.fid = F.fid
161 AND R.child IS NOT NULL
162 AND R.child = C.rid
163 AND C.bparent IS NOT NULL
164 ;
165 }
166 # Find all revisions without branch parent symbol which have a
167 # parent, but the parent does not have them as primary child.
168 CheckRev \
169 {Revisions have to be primary children of their parents, if any} \
170 {is not the child of its parent} {
171 SELECT F.name, R.rev
172 FROM revision R, revision P, file F
173 WHERE R.fid = F.fid
174 AND R.bparent IS NULL
175 AND R.parent IS NOT NULL
176 AND R.parent = P.rid
177 AND P.child != R.rid
178 ;
179 }
180 # Find all revisions with a branch parent symbol which do not
181 # have a parent.
182 CheckRev \
183 {Branch starting revisions have to have a parent, if not detached} \
184 {at the beginning of its branch has no parent, but its branch has} {
185 SELECT F.name, R.rev
186 FROM revision R, file F, branch B
187 WHERE R.fid = F.fid
188 AND R.bparent IS NOT NULL
189 AND R.parent IS NULL
190 AND B.sid = R.bparent
191 AND B.fid = R.fid
192 AND B.root IS NOT NULL
193 ;
194 }
195 # Find all revisions with a branch parent symbol whose parent
196 # has them as primary child.
197 CheckRev \
198 {Branch starting revisions must not be primary children of their parents} \
199 {at the beginning of its branch is the primary child of its parent} {
200 SELECT F.name, R.rev
201 FROM revision R, revision P, file F
202 WHERE R.fid = F.fid
203 AND R.bparent IS NOT NULL
204 AND R.parent IS NOT NULL
205 AND R.parent = P.rid
206 AND P.child = R.rid
207 ;
208 }
209 # Find all revisions with a non-NTDB child which are not on
210 # the NTDB.
211 CheckRev \
212 {NTDB to trunk transition has to begin on NTDB} \
213 {has a non-NTDB child, yet is not on the NTDB} {
214 SELECT F.name, R.rev
215 FROM revision R, file F
216 WHERE R.fid = F.fid
217 AND R.dbchild IS NOT NULL
218 AND NOT R.isdefault
219 ;
220 }
221 # Find all revisions with a NTDB parent which are on the NTDB.
222 CheckRev \
223 {NTDB to trunk transition has to end on non-NTDB} \
224 {has a NTDB parent, yet is on the NTDB} {
225 SELECT F.name, R.rev
226 FROM revision R, file F
227 WHERE R.fid = F.fid
228 AND R.dbparent IS NOT NULL
229 AND R.isdefault
230 ;
231 }
232 # Find all revisions with a child which disagrees about the
233 # line of development they belong to.
234 CheckRev \
235 {Revisions and their primary children have to be in the same LOD} \
236 {and its primary child disagree about their LOD} {
237 SELECT F.name, R.rev
238 FROM revision R, revision C, file F
239 WHERE R.fid = F.fid
240 AND R.child IS NOT NULL
241 AND R.child = C.rid
242 AND C.lod != R.lod
243 ;
244 }
245 # Find all revisions with a non-NTDB child which agrees about
246 # the line of development they belong to.
247 CheckRev \
248 {NTDB and trunk revisions have to be in different LODs} \
249 {on NTDB and its non-NTDB child wrongly agree about their LOD} {
250 SELECT F.name, R.rev
251 FROM revision R, revision C, file F
252 WHERE R.fid = F.fid
253 AND R.dbchild IS NOT NULL
254 AND R.dbchild = C.rid
255 AND C.lod = R.lod
256 ;
257 }
258 # Find all revisions with a branch parent symbol which is not
259 # their LOD.
260 CheckRev \
261 {Branch starting revisions have to have their LOD as branch parent symbol} \
262 {at the beginning of its branch does not have the branch symbol as its LOD} {
263 SELECT F.name, R.rev
264 FROM revision R, file F
265 WHERE R.fid = F.fid
266 AND R.bparent IS NOT NULL
267 AND R.lod != R.bparent
268 ;
269 }
270 # Find all revisions with a branch parent symbol whose parent
271 # is in the same line of development.
272 CheckRev \
273 {Revisions and their branch children have to be in different LODs} \
274 {at the beginning of its branch and its parent wrongly agree about their LOD} {
275 SELECT F.name, R.rev
276 FROM revision R, revision P, file F
277 WHERE R.fid = F.fid
278 AND R.bparent IS NOT NULL
279 AND R.parent = P.rid
280 AND R.lod = P.lod
281 ;
282 }
283 return
284 }
285
@@ -295,13 +295,13 @@
295 CheckRev \
296 {Revisions and their meta data have to be in the same LOD} \
297 {disagrees with its meta data about owning LOD} {
298 SELECT F.name, R.rev
299 FROM revision R, meta M, file F
300 WHERE R.mid = M.mid
301 AND R.lod != M.bid
302 AND R.fid = F.fid
303 ;
304 }
305 return
306 }
307
@@ -348,18 +348,20 @@
348 -- select those with more than one user, and get their
349 -- associated file (name) for display.
350
351 SELECT F.name, R.rev
352 FROM revision R, file F,
353 (SELECT CI.iid AS rid, count(CI.cid) AS count
 
354 FROM csitem CI, changeset C
355 WHERE C.type = 0
356 AND C.cid = CI.cid
357 GROUP BY CI.iid) AS U
358 WHERE U.count > 1
359 AND R.rid = U.rid
360 AND R.fid = F.fid
 
361 }
362 # All revisions have to refer to the same meta information as
363 # their changeset.
364 CheckRevCS \
365 {All revisions have to agree with their changeset about the used meta information} \
@@ -386,16 +388,21 @@
386 {All revisions in a changeset have to belong to the same LOD} \
387 {: Its revisions disagree about the LOD they belong to} {
388 SELECT T.name, C.cid
389 FROM changeset C, cstype T
390 WHERE C.cid IN (SELECT U.cid
391 FROM (SELECT DISTINCT CI.cid AS cid, R.lod AS lod
 
 
392 FROM csitem CI, changeset C, revision R
393 WHERE CI.iid = R.rid
394 AND C.cid = CI.cid
395 AND C.type = 0) AS U
396 GROUP BY U.cid HAVING COUNT(U.lod) > 1)
 
 
 
397 AND T.tid = C.type
398 }
399 # All revisions have to agree on the project their changeset
400 # belongs to. In other words, all revisions in a changeset
401 # have to refer to the same project.
@@ -409,18 +416,23 @@
409 {All revisions in a changeset have to belong to the same project} \
410 {: Its revisions disagree about the project they belong to} {
411 SELECT T.name, C.cid
412 FROM changeset C, cstype T
413 WHERE C.cid IN (SELECT U.cid
414 FROM (SELECT DISTINCT CI.cid AS cid, F.pid AS pid
 
 
415 FROM csitem CI, changeset C, revision R, file F
416 WHERE CI.iid = R.rid
417 AND C.cid = CI.cid
418 AND C.type = 0
419 AND F.fid = R.fid) AS U
420 GROUP BY U.cid HAVING COUNT(U.pid) > 1)
421 AND T.tid = C.type
 
 
 
422 }
423 # All revisions in a single changeset have to belong to
424 # different files. Conversely: No two revisions of a single
425 # file are allowed to be in the same changeset.
426 #
@@ -434,26 +446,34 @@
434 {All revisions in a changeset have to belong to different files} \
435 {: Its revisions share files} {
436 SELECT T.name, C.cid
437 FROM changeset C, cstype T
438 WHERE C.cid IN (SELECT VV.cid
439 FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount
440 FROM (SELECT DISTINCT CI.cid AS cid, R.fid AS fid
 
 
 
441 FROM csitem CI, changeset C, revision R
442 WHERE CI.iid = R.rid
443 AND C.cid = CI.cid
444 AND C.type = 0
445 ) AS U
446 GROUP BY U.cid) AS UU,
447 (SELECT V.cid AS cid, COUNT (V.iid) AS rcount
 
 
448 FROM csitem V, changeset X
449 WHERE X.cid = V.cid
450 AND X.type = 0
451 GROUP BY V.cid) AS VV
452 WHERE VV.cid = UU.cid
453 AND UU.fcount < VV.rcount)
454 AND T.tid = C.type
 
 
 
455 }
456 return
457 }
458
459 proc TagChangesets {} {
@@ -498,19 +518,21 @@
498 -- user, and get their associated file (name) for
499 -- display.
500
501 SELECT P.name, S.name
502 FROM tag T, project P, symbol S,
503 (SELECT CI.iid AS iid, count(CI.cid) AS count
 
504 FROM csitem CI, changeset C
505 WHERE C.type = 1
506 AND C.cid = CI.cid
507 GROUP BY CI.iid) AS U
508 WHERE U.count > 1
509 AND T.tid = U.iid
510 AND S.sid = T.sid -- get symbol of tag
511 AND P.pid = S.pid -- get project of symbol
 
512 }
513 if 0 {
514 # This check is disabled for the moment. Apparently tags
515 # can cross lines of development, at least if the involved
516 # LODs are the trunk, and the NTDB. That makes sense, as
@@ -556,18 +578,23 @@
556 {All tags in a changeset have to belong to the same project} \
557 {: Its tags disagree about the project they belong to} {
558 SELECT T.name, C.cid
559 FROM changeset C, cstype T
560 WHERE C.cid IN (SELECT U.cid
561 FROM (SELECT DISTINCT CI.cid AS cid, F.pid AS pid
 
 
562 FROM csitem CI, changeset C, tag T, file F
563 WHERE CI.iid = T.tid
564 AND C.cid = CI.cid
565 AND C.type = 1
566 AND F.fid = T.fid) AS U
567 GROUP BY U.cid HAVING COUNT(U.pid) > 1)
568 AND T.tid = C.type
 
 
 
569 }
570 # All tags in a single changeset have to belong to different
571 # files. Conversely: No two tags of a single file are allowed
572 # to be in the same changeset.
573 #
@@ -580,26 +607,34 @@
580 {All tags in a changeset have to belong to different files} \
581 {: Its tags share files} {
582 SELECT T.name, C.cid
583 FROM changeset C, cstype T
584 WHERE C.cid IN (SELECT VV.cid
585 FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount
586 FROM (SELECT DISTINCT CI.cid AS cid, T.fid AS fid
 
 
 
587 FROM csitem CI, changeset C, tag T
588 WHERE CI.iid = T.tid
589 AND C.cid = CI.cid
590 AND C.type = 1
591 ) AS U
592 GROUP BY U.cid) AS UU,
593 (SELECT V.cid AS cid, COUNT (V.iid) AS rcount
 
 
594 FROM csitem V, changeset X
595 WHERE X.cid = V.cid
596 AND X.type = 1
597 GROUP BY V.cid) AS VV
598 WHERE VV.cid = UU.cid
599 AND UU.fcount < VV.rcount)
600 AND T.tid = C.type
 
 
 
601 }
602 return
603 }
604
605 proc BranchChangesets {} {
@@ -628,11 +663,12 @@
628 FROM branch
629 EXCEPT -- subtract
630 SELECT CI.iid -- branches used
631 FROM csitem CI, changeset C
632 WHERE C.cid = CI.cid -- by any branch
633 AND C.type = 2) -- changeset
 
634 AND S.sid = B.sid -- get symbol of branch
635 AND P.pid = S.pid -- get project of symbol
636 }
637 # Find all branches which are used by more than one changeset.
638 CheckRev \
@@ -645,19 +681,21 @@
645 -- than one user, and get their associated file (name)
646 -- for display.
647
648 SELECT P.name, S.name
649 FROM branch B, project P, symbol S,
650 (SELECT CI.iid AS iid, count(CI.cid) AS count
 
651 FROM csitem CI, changeset C
652 WHERE C.type = 2
653 AND C.cid = CI.cid
654 GROUP BY CI.iid ) AS U
655 WHERE U.count > 1
656 AND B.bid = U.iid
657 AND S.sid = B.sid -- get symbol of branch
658 AND P.pid = S.pid -- get project of symbol
 
659 }
660 if 0 {
661 # This check has been disabled. When the converter was run
662 # on the Tcl CVS several branches tripped this
663 # constraint. One of them was a free-floating branch, and
@@ -719,18 +757,23 @@
719 {All branches in a changeset have to belong to the same project} \
720 {: Its branches disagree about the project they belong to} {
721 SELECT T.name, C.cid
722 FROM changeset C, cstype T
723 WHERE C.cid IN (SELECT U.cid
724 FROM (SELECT DISTINCT CI.cid AS cid, F.pid AS pid
 
 
725 FROM csitem CI, changeset C, branch B, file F
726 WHERE CI.iid = B.bid
727 AND C.cid = CI.cid
728 AND C.type = 2
729 AND F.fid = B.fid) AS U
730 GROUP BY U.cid HAVING COUNT(U.pid) > 1)
731 AND T.tid = C.type
 
 
 
732 }
733 # All branches in a single changeset have to belong to
734 # different files. Conversely: No two branches of a single
735 # file are allowed to be in the same changeset.
736 #
@@ -744,26 +787,34 @@
744 {All branches in a changeset have to belong to different files} \
745 {: Its branches share files} {
746 SELECT T.name, C.cid
747 FROM changeset C, cstype T
748 WHERE C.cid IN (SELECT VV.cid
749 FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount
750 FROM (SELECT DISTINCT CI.cid AS cid, B.fid AS fid
 
 
 
751 FROM csitem CI, changeset C, branch B
752 WHERE CI.iid = B.bid
753 AND C.cid = CI.cid
754 AND C.type = 2
755 ) AS U
756 GROUP BY U.cid) AS UU,
757 (SELECT V.cid AS cid, COUNT (V.iid) AS rcount
 
 
758 FROM csitem V, changeset X
759 WHERE X.cid = V.cid
760 AND X.type = 2
761 GROUP BY V.cid) AS VV
762 WHERE VV.cid = UU.cid
763 AND UU.fcount < VV.rcount)
764 AND T.tid = C.type
 
 
 
765 }
766 return
767 }
768
769 proc ___UnusedChangesetChecks___ {} {
@@ -788,11 +839,11 @@
788 {All revisions used by tag symbol changesets have to have the changeset's tag attached to them} \
789 {does not have the tag of its symbol changeset @ attached to it} {
790 SELECT CT.name, C.cid, F.name, R.rev
791 FROM changeset C, cstype CT, revision R, file F, csitem CI, tag T
792 WHERE C.type = 1 -- symbol changesets only
793 AND C.src = T.sid -- tag only, linked by symbol id
794 AND C.cid = CI.cid -- changeset --> its revisions
795 AND R.rid = CI.iid -- look at the revisions
796 -- and look for the tag among the attached ones.
797 AND T.sid NOT IN (SELECT TB.sid
798 FROM tag TB
799
--- tools/cvs2fossil/lib/c2f_integrity.tcl
+++ tools/cvs2fossil/lib/c2f_integrity.tcl
@@ -78,38 +78,38 @@
78 CheckRev \
79 {Revisions and their LODs have to be in the same project} \
80 {disagrees with its LOD about owning project} {
81 SELECT F.name, R.rev
82 FROM revision R, file F, symbol S
83 WHERE R.fid = F.fid -- get file of rev
84 AND R.lod = S.sid -- get symbol of its lod
85 AND F.pid != S.pid -- disagreement about the owning project
86 ;
87 }
88 # Find all revisions which disgree with their meta data about
89 # the project they are owned by.
90 CheckRev \
91 {Revisions and their meta data have to be in the same project} \
92 {disagrees with its meta data about owning project} {
93 SELECT F.name, R.rev
94 FROM revision R, file F, meta M
95 WHERE R.fid = F.fid -- get file of rev
96 AND R.mid = M.mid -- get meta of rev
97 AND F.pid != M.pid -- disagreement about owning project
98 ;
99 }
100 # Find all revisions with a primary child which disagrees
101 # about the file they belong to.
102 CheckRev \
103 {Revisions and their primary children have to be in the same file} \
104 {disagrees with its primary child about the owning file} {
105 SELECT F.name, R.rev
106 FROM revision R, revision C, file F
107 WHERE R.fid = F.fid -- get file of rev
108 AND R.child IS NOT NULL -- get all with primary children
109 AND R.child = C.rid -- get primary child
110 AND C.fid != R.fid -- wrongly in different file
111 ;
112 }
113
114 # Find all revisions with a branch parent symbol whose parent
115 # disagrees about the file they belong to.
@@ -116,170 +116,170 @@
116 CheckRev \
117 {Revisions and their branch children have to be in the same file} \
118 {at the beginning of its branch and its parent disagree about the owning file} {
119 SELECT F.name, R.rev
120 FROM revision R, revision P, file F
121 WHERE R.fid = F.fid -- get file of rev
122 AND R.bparent IS NOT NULL -- get first-of-branch revisions
123 AND R.parent = P.rid -- get out-of-branch parent
124 AND R.fid != P.fid -- wrongly in different file
125 ;
126 }
127 # Find all revisions with a non-NTDB child which disagrees
128 # about the file they belong to.
129 CheckRev \
130 {Revisions and their non-NTDB children have to be in the same file} \
131 {disagrees with its non-NTDB child about the owning file} {
132 SELECT F.name, R.rev
133 FROM revision R, revision C, file F
134 WHERE R.fid = F.fid -- get file of rev
135 AND R.dbchild IS NOT NULL -- get last NTDB revisions
136 AND R.dbchild = C.rid -- get their child
137 AND C.fid != R.fid -- wrongly in different file
138 ;
139 }
140 # Find all revisions which have a primary child, but the child
141 # does not have them as parent.
142 CheckRev \
143 {Revisions have to be parents of their primary children} \
144 {is not the parent of its primary child} {
145 SELECT F.name, R.rev
146 FROM revision R, revision C, file F
147 WHERE R.fid = F.fid -- get file of rev
148 AND R.child IS NOT NULL -- get all with primary children
149 AND R.child = C.rid -- get primary child
150 AND C.parent != R.rid -- child's parent wrongly not us
151 ;
152 }
153 # Find all revisions which have a primrary child, but the
154 # child has a branch parent symbol making them brach starters.
155 CheckRev \
156 {Primary children of revisions must not start branches} \
157 {is parent of a primary child which is the beginning of a branch} {
158 SELECT F.name, R.rev
159 FROM revision R, revision C, file F
160 WHERE R.fid = F.fid -- get file of rev
161 AND R.child IS NOT NULL -- get all with primary children
162 AND R.child = C.rid -- get primary child
163 AND C.bparent IS NOT NULL -- but indicates to be on branch
164 ;
165 }
166 # Find all revisions without branch parent symbol which have a
167 # parent, but the parent does not have them as primary child.
168 CheckRev \
169 {Revisions have to be primary children of their parents, if any} \
170 {is not the child of its parent} {
171 SELECT F.name, R.rev
172 FROM revision R, revision P, file F
173 WHERE R.fid = F.fid -- get file of revision
174 AND R.bparent IS NULL -- exclude all first-on-branch revisions
175 AND R.parent IS NOT NULL -- which are not root of their line
176 AND R.parent = P.rid -- get in-lod parent
177 AND P.child != R.rid -- but does not have rev as primary child
178 ;
179 }
180 # Find all revisions with a branch parent symbol which do not
181 # have a parent.
182 CheckRev \
183 {Branch starting revisions have to have a parent, if not detached} \
184 {at the beginning of its branch has no parent, but its branch has} {
185 SELECT F.name, R.rev
186 FROM revision R, file F, branch B
187 WHERE R.fid = F.fid -- get file of revision
188 AND R.bparent IS NOT NULL -- limit to first-on-branch revisions
189 AND R.parent IS NULL -- which are detached
190 AND B.sid = R.bparent -- get branch governing the rev
191 AND B.fid = R.fid -- in the revision's file
192 AND B.root IS NOT NULL -- but says that branch is attached
193 ;
194 }
195 # Find all revisions with a branch parent symbol whose parent
196 # has them as primary child.
197 CheckRev \
198 {Branch starting revisions must not be primary children of their parents} \
199 {at the beginning of its branch is the primary child of its parent} {
200 SELECT F.name, R.rev
201 FROM revision R, revision P, file F
202 WHERE R.fid = F.fid -- get file of revision
203 AND R.bparent IS NOT NULL -- limit to first-on-branch revisions
204 AND R.parent IS NOT NULL -- which are attached
205 AND R.parent = P.rid -- get out-of-branch parent
206 AND P.child = R.rid -- wrongly has rev as primary child
207 ;
208 }
209 # Find all revisions with a non-NTDB child which are not on
210 # the NTDB.
211 CheckRev \
212 {NTDB to trunk transition has to begin on NTDB} \
213 {has a non-NTDB child, yet is not on the NTDB} {
214 SELECT F.name, R.rev
215 FROM revision R, file F
216 WHERE R.fid = F.fid -- get file of revision
217 AND R.dbchild IS NOT NULL -- limit to last NTDB revision
218 AND NOT R.isdefault -- but signals not-NTDB
219 ;
220 }
221 # Find all revisions with a NTDB parent which are on the NTDB.
222 CheckRev \
223 {NTDB to trunk transition has to end on non-NTDB} \
224 {has a NTDB parent, yet is on the NTDB} {
225 SELECT F.name, R.rev
226 FROM revision R, file F
227 WHERE R.fid = F.fid -- get file of revision
228 AND R.dbparent IS NOT NULL -- limit to roots of non-NTDB
229 AND R.isdefault -- but signals to be NTDB
230 ;
231 }
232 # Find all revisions with a child which disagrees about the
233 # line of development they belong to.
234 CheckRev \
235 {Revisions and their primary children have to be in the same LOD} \
236 {and its primary child disagree about their LOD} {
237 SELECT F.name, R.rev
238 FROM revision R, revision C, file F
239 WHERE R.fid = F.fid -- get file of revision
240 AND R.child IS NOT NULL -- revision has a primary child
241 AND R.child = C.rid -- get that child
242 AND C.lod != R.lod -- child wrongly disagrees with lod
243 ;
244 }
245 # Find all revisions with a non-NTDB child which agrees about
246 # the line of development they belong to.
247 CheckRev \
248 {NTDB and trunk revisions have to be in different LODs} \
249 {on NTDB and its non-NTDB child wrongly agree about their LOD} {
250 SELECT F.name, R.rev
251 FROM revision R, revision C, file F
252 WHERE R.fid = F.fid -- get file of revision
253 AND R.dbchild IS NOT NULL -- limit to last NTDB revision
254 AND R.dbchild = C.rid -- get non-NTDB child
255 AND C.lod = R.lod -- child wrongly has same lod
256 ;
257 }
258 # Find all revisions with a branch parent symbol which is not
259 # their LOD.
260 CheckRev \
261 {Branch starting revisions have to have their LOD as branch parent symbol} \
262 {at the beginning of its branch does not have the branch symbol as its LOD} {
263 SELECT F.name, R.rev
264 FROM revision R, file F
265 WHERE R.fid = F.fid -- get file of revision
266 AND R.bparent IS NOT NULL -- limit to branch-first revisions
267 AND R.lod != R.bparent -- out-of-branch parent wrongly is not the lod
268 ;
269 }
270 # Find all revisions with a branch parent symbol whose parent
271 # is in the same line of development.
272 CheckRev \
273 {Revisions and their branch children have to be in different LODs} \
274 {at the beginning of its branch and its parent wrongly agree about their LOD} {
275 SELECT F.name, R.rev
276 FROM revision R, revision P, file F
277 WHERE R.fid = F.fid -- get file of revision
278 AND R.bparent IS NOT NULL -- limit to branch-first revisions
279 AND R.parent = P.rid -- get out-of-branch parent of revision
280 AND R.lod = P.lod -- rev and parent wrongly agree on lod
281 ;
282 }
283 return
284 }
285
@@ -295,13 +295,13 @@
295 CheckRev \
296 {Revisions and their meta data have to be in the same LOD} \
297 {disagrees with its meta data about owning LOD} {
298 SELECT F.name, R.rev
299 FROM revision R, meta M, file F
300 WHERE R.mid = M.mid -- get meta data of revision
301 AND R.lod != M.bid -- rev wrongly disagrees with meta about lod
302 AND R.fid = F.fid -- get file of revision
303 ;
304 }
305 return
306 }
307
@@ -348,18 +348,20 @@
348 -- select those with more than one user, and get their
349 -- associated file (name) for display.
350
351 SELECT F.name, R.rev
352 FROM revision R, file F,
353 (SELECT CI.iid AS rid, -- revision item
354 count(CI.cid) AS count -- number of csets using item
355 FROM csitem CI, changeset C
356 WHERE C.type = 0 -- limit to revision csets
357 AND C.cid = CI.cid -- get item in changeset
358 GROUP BY CI.iid -- aggregate by item, count csets/item
359 ) AS U
360 WHERE U.count > 1 -- limit to item with multiple users
361 AND R.rid = U.rid -- get revision of item
362 AND R.fid = F.fid -- get file of revision
363 }
364 # All revisions have to refer to the same meta information as
365 # their changeset.
366 CheckRevCS \
367 {All revisions have to agree with their changeset about the used meta information} \
@@ -386,16 +388,21 @@
388 {All revisions in a changeset have to belong to the same LOD} \
389 {: Its revisions disagree about the LOD they belong to} {
390 SELECT T.name, C.cid
391 FROM changeset C, cstype T
392 WHERE C.cid IN (SELECT U.cid
393 FROM (SELECT DISTINCT -- unique cset/lod pairs
394 CI.cid AS cid, -- revision cset
395 R.lod AS lod -- lod of item in cset
396 FROM csitem CI, changeset C, revision R
397 WHERE CI.iid = R.rid -- get rev of item in cset
398 AND C.cid = CI.cid -- get changeset of item
399 AND C.type = 0 -- limit to rev csets
400 ) AS U
401 GROUP BY U.cid -- aggregate by cset, count lods/cset
402 HAVING COUNT(U.lod) > 1 -- find csets with multiple lods
403 )
404 AND T.tid = C.type
405 }
406 # All revisions have to agree on the project their changeset
407 # belongs to. In other words, all revisions in a changeset
408 # have to refer to the same project.
@@ -409,18 +416,23 @@
416 {All revisions in a changeset have to belong to the same project} \
417 {: Its revisions disagree about the project they belong to} {
418 SELECT T.name, C.cid
419 FROM changeset C, cstype T
420 WHERE C.cid IN (SELECT U.cid
421 FROM (SELECT DISTINCT -- unique cset/proj pairs
422 CI.cid AS cid, -- rev cset
423 F.pid AS pid -- project of item in cset
424 FROM csitem CI, changeset C, revision R, file F
425 WHERE CI.iid = R.rid -- get rev of item in cset
426 AND C.cid = CI.cid -- get changeset of item
427 AND C.type = 0 -- limit to rev changesets
428 AND F.fid = R.fid -- get file of revision
429 ) AS U
430 GROUP BY U.cid -- aggregate by csets, count proj/cset
431 HAVING COUNT(U.pid) > 1 -- find csets with multiple projects
432 )
433 AND T.tid = C.type -- get readable changeset type
434 }
435 # All revisions in a single changeset have to belong to
436 # different files. Conversely: No two revisions of a single
437 # file are allowed to be in the same changeset.
438 #
@@ -434,26 +446,34 @@
446 {All revisions in a changeset have to belong to different files} \
447 {: Its revisions share files} {
448 SELECT T.name, C.cid
449 FROM changeset C, cstype T
450 WHERE C.cid IN (SELECT VV.cid
451 FROM (SELECT U.cid AS cid, -- rev changeset
452 COUNT (U.fid) AS fcount -- number of files by items
453 FROM (SELECT DISTINCT -- unique cset/file pairs
454 CI.cid AS cid, -- rev changeset
455 R.fid AS fid -- file of item in changeset
456 FROM csitem CI, changeset C, revision R
457 WHERE CI.iid = R.rid -- get rev of item in changeset
458 AND C.cid = CI.cid -- get changeset of item
459 AND C.type = 0 -- limit to rev csets
460 ) AS U
461 GROUP BY U.cid -- aggregate by csets, count files/cset
462 ) AS UU,
463 (SELECT V.cid AS cid, -- rev changeset
464 COUNT (V.iid) AS rcount -- number of items
465 FROM csitem V, changeset X
466 WHERE X.cid = V.cid -- get changeset of item
467 AND X.type = 0 -- limit to rev csets
468 GROUP BY V.cid -- aggregate by csets, count items/cset
469 ) AS VV
470 WHERE VV.cid = UU.cid -- sync #items/cset with #files/cset
471 AND UU.fcount < VV.rcount -- less files than items
472 -- => items belong to the same file.
473 )
474 AND T.tid = C.type -- get readable changeset type
475 }
476 return
477 }
478
479 proc TagChangesets {} {
@@ -498,19 +518,21 @@
518 -- user, and get their associated file (name) for
519 -- display.
520
521 SELECT P.name, S.name
522 FROM tag T, project P, symbol S,
523 (SELECT CI.iid AS iid, -- item
524 count(CI.cid) AS count -- number of csets using item
525 FROM csitem CI, changeset C
526 WHERE C.type = 1 -- limit to tag csets
527 AND C.cid = CI.cid -- get items of cset
528 GROUP BY CI.iid -- aggregate by item, count csets/item
529 ) AS U
530 WHERE U.count > 1 -- find tag item used multiple times
531 AND T.tid = U.iid -- get tag of item
532 AND S.sid = T.sid -- get symbol of tag
533 AND P.pid = S.pid -- get project of symbol
534 }
535 if 0 {
536 # This check is disabled for the moment. Apparently tags
537 # can cross lines of development, at least if the involved
538 # LODs are the trunk, and the NTDB. That makes sense, as
@@ -556,18 +578,23 @@
578 {All tags in a changeset have to belong to the same project} \
579 {: Its tags disagree about the project they belong to} {
580 SELECT T.name, C.cid
581 FROM changeset C, cstype T
582 WHERE C.cid IN (SELECT U.cid
583 FROM (SELECT DISTINCT -- unique cset/proj pairs
584 CI.cid AS cid, -- tag cset
585 F.pid AS pid -- project of item in cset
586 FROM csitem CI, changeset C, tag T, file F
587 WHERE CI.iid = T.tid -- get tag of item in cset
588 AND C.cid = CI.cid -- get changeset of item
589 AND C.type = 1 -- limit to tag changesets
590 AND F.fid = T.fid -- get file of tag
591 ) AS U
592 GROUP BY U.cid -- aggregate by csets, count proj/cset
593 HAVING COUNT(U.pid) > 1 -- find csets with multiple projects
594 )
595 AND T.tid = C.type -- get readable changeset type
596 }
597 # All tags in a single changeset have to belong to different
598 # files. Conversely: No two tags of a single file are allowed
599 # to be in the same changeset.
600 #
@@ -580,26 +607,34 @@
607 {All tags in a changeset have to belong to different files} \
608 {: Its tags share files} {
609 SELECT T.name, C.cid
610 FROM changeset C, cstype T
611 WHERE C.cid IN (SELECT VV.cid
612 FROM (SELECT U.cid AS cid, -- changeset
613 COUNT (U.fid) AS fcount -- number of files by items
614 FROM (SELECT DISTINCT -- unique cset/file pairs
615 CI.cid AS cid, -- tag changeset
616 T.fid AS fid -- file of item in changeset
617 FROM csitem CI, changeset C, tag T
618 WHERE CI.iid = T.tid -- get tag of item in changeset
619 AND C.cid = CI.cid -- get changeset of item
620 AND C.type = 1 -- limit to tag changesets
621 ) AS U
622 GROUP BY U.cid -- aggregate by csets, count files/cset
623 ) AS UU,
624 (SELECT V.cid AS cid, -- changeset
625 COUNT (V.iid) AS rcount -- number of items in cset
626 FROM csitem V, changeset X
627 WHERE X.cid = V.cid -- get changeset of item
628 AND X.type = 1 -- limit to tag changesets
629 GROUP BY V.cid -- aggregate by csets, count items/cset
630 ) AS VV
631 WHERE VV.cid = UU.cid -- sync #items/cset with #files/cset
632 AND UU.fcount < VV.rcount -- less files than items
633 -- => items belong to the same file.
634 )
635 AND T.tid = C.type -- get readable changeset type
636 }
637 return
638 }
639
640 proc BranchChangesets {} {
@@ -628,11 +663,12 @@
663 FROM branch
664 EXCEPT -- subtract
665 SELECT CI.iid -- branches used
666 FROM csitem CI, changeset C
667 WHERE C.cid = CI.cid -- by any branch
668 AND C.type = 2 -- changeset
669 )
670 AND S.sid = B.sid -- get symbol of branch
671 AND P.pid = S.pid -- get project of symbol
672 }
673 # Find all branches which are used by more than one changeset.
674 CheckRev \
@@ -645,19 +681,21 @@
681 -- than one user, and get their associated file (name)
682 -- for display.
683
684 SELECT P.name, S.name
685 FROM branch B, project P, symbol S,
686 (SELECT CI.iid AS iid, -- item
687 count(CI.cid) AS count -- number of csets for item
688 FROM csitem CI, changeset C
689 WHERE C.type = 2 -- limit to branch changesets,
690 AND C.cid = CI.cid -- get the items they contain,
691 GROUP BY CI.iid -- aggregate by items, count csets/item (x)
692 ) AS U
693 WHERE U.count > 1 -- find items used multiple times
694 AND B.bid = U.iid -- get the users (branch changesets)
695 AND S.sid = B.sid -- get symbol of branch
696 AND P.pid = S.pid -- get project of symbol
697 }
698 if 0 {
699 # This check has been disabled. When the converter was run
700 # on the Tcl CVS several branches tripped this
701 # constraint. One of them was a free-floating branch, and
@@ -719,18 +757,23 @@
757 {All branches in a changeset have to belong to the same project} \
758 {: Its branches disagree about the project they belong to} {
759 SELECT T.name, C.cid
760 FROM changeset C, cstype T
761 WHERE C.cid IN (SELECT U.cid
762 FROM (SELECT DISTINCT -- Unique cset/proj pairs
763 CI.cid AS cid, -- Branch cset
764 F.pid AS pid -- Project of item in cset
765 FROM csitem CI, changeset C, branch B, file F
766 WHERE CI.iid = B.bid -- get branch of item in cset
767 AND C.cid = CI.cid -- get changeset of item
768 AND C.type = 2 -- limit to branch changesets
769 AND F.fid = B.fid -- get file of branch
770 ) AS U
771 GROUP BY U.cid -- aggregate by csets, count proj/cset
772 HAVING COUNT(U.pid) > 1 -- find cset with multiple projects
773 )
774 AND T.tid = C.type -- get readable changeset type
775 }
776 # All branches in a single changeset have to belong to
777 # different files. Conversely: No two branches of a single
778 # file are allowed to be in the same changeset.
779 #
@@ -744,26 +787,34 @@
787 {All branches in a changeset have to belong to different files} \
788 {: Its branches share files} {
789 SELECT T.name, C.cid
790 FROM changeset C, cstype T
791 WHERE C.cid IN (SELECT VV.cid
792 FROM (SELECT U.cid AS cid, -- changeset
793 COUNT (U.fid) AS fcount -- number of files by items
794 FROM (SELECT DISTINCT -- unique cset/file pairs
795 CI.cid AS cid, -- Branch changeset
796 B.fid AS fid -- File of item in changeset
797 FROM csitem CI, changeset C, branch B
798 WHERE CI.iid = B.bid -- get tag of item in changeset
799 AND C.cid = CI.cid -- get changeset of item
800 AND C.type = 2 -- limit to branch changesets
801 ) AS U
802 GROUP BY U.cid -- aggregate by csets, count files/cset
803 ) AS UU,
804 (SELECT V.cid AS cid, -- changeset
805 COUNT (V.iid) AS rcount -- number of items in cset
806 FROM csitem V, changeset X
807 WHERE X.cid = V.cid -- get changeset of item
808 AND X.type = 2 -- limit to branch changesets
809 GROUP BY V.cid -- aggregate by csets, count items/cset
810 ) AS VV
811 WHERE VV.cid = UU.cid -- sync #items/cset with #files/cset
812 AND UU.fcount < VV.rcount -- less files than items
813 -- => items belong to the same file.
814 )
815 AND T.tid = C.type -- get readable changeset type
816 }
817 return
818 }
819
820 proc ___UnusedChangesetChecks___ {} {
@@ -788,11 +839,11 @@
839 {All revisions used by tag symbol changesets have to have the changeset's tag attached to them} \
840 {does not have the tag of its symbol changeset @ attached to it} {
841 SELECT CT.name, C.cid, F.name, R.rev
842 FROM changeset C, cstype CT, revision R, file F, csitem CI, tag T
843 WHERE C.type = 1 -- symbol changesets only
844 AND C.src = T.sid -- tag only, linked by symbol id
845 AND C.cid = CI.cid -- changeset --> its revisions
846 AND R.rid = CI.iid -- look at the revisions
847 -- and look for the tag among the attached ones.
848 AND T.sid NOT IN (SELECT TB.sid
849 FROM tag TB
850

Keyboard Shortcuts

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