|
1
|
## -*- tcl -*- |
|
2
|
# # ## ### ##### ######## ############# ##################### |
|
3
|
## Copyright (c) 2007-2008 Andreas Kupries. |
|
4
|
# |
|
5
|
# This software is licensed as described in the file LICENSE, which |
|
6
|
# you should have received as part of this distribution. |
|
7
|
# |
|
8
|
# This software consists of voluntary contributions made by many |
|
9
|
# individuals. For exact contribution history, see the revision |
|
10
|
# history and logs, available at http://fossil-scm.hwaci.com/fossil |
|
11
|
# # ## ### ##### ######## ############# ##################### |
|
12
|
|
|
13
|
## Pass II. This pass parses the collected rcs archives and extracts |
|
14
|
## all the information they contain (revisions, and symbols). |
|
15
|
|
|
16
|
# # ## ### ##### ######## ############# ##################### |
|
17
|
## Requirements |
|
18
|
|
|
19
|
package require Tcl 8.4 ; # Required runtime. |
|
20
|
package require snit ; # OO system. |
|
21
|
package require vc::tools::trouble ; # Error reporting. |
|
22
|
package require vc::tools::log ; # User feedback. |
|
23
|
package require vc::fossil::import::cvs::pass ; # Pass management. |
|
24
|
package require vc::fossil::import::cvs::repository ; # Repository management. |
|
25
|
package require vc::fossil::import::cvs::state ; # State storage. |
|
26
|
package require vc::fossil::import::cvs::integrity ; # State integrity checks. |
|
27
|
package require vc::fossil::import::cvs::project::sym ; # Project level symbols. |
|
28
|
package require vc::fossil::import::cvs::file::rev ; # File level revisions. |
|
29
|
package require vc::rcs::parser ; # Rcs archive data extraction. |
|
30
|
|
|
31
|
# # ## ### ##### ######## ############# ##################### |
|
32
|
## Register the pass with the management |
|
33
|
|
|
34
|
vc::fossil::import::cvs::pass define \ |
|
35
|
CollectRev \ |
|
36
|
{Collect revisions and symbols} \ |
|
37
|
::vc::fossil::import::cvs::pass::collrev |
|
38
|
|
|
39
|
# # ## ### ##### ######## ############# ##################### |
|
40
|
## |
|
41
|
|
|
42
|
snit::type ::vc::fossil::import::cvs::pass::collrev { |
|
43
|
# # ## ### ##### ######## ############# |
|
44
|
## Public API |
|
45
|
|
|
46
|
typemethod setup {} { |
|
47
|
# Define names and structure of the persistent state of this |
|
48
|
# pass. |
|
49
|
|
|
50
|
state use project |
|
51
|
state use file |
|
52
|
|
|
53
|
# We deal with per project and per file data, the first |
|
54
|
# collated from the second. |
|
55
|
|
|
56
|
# Per file we have general information, ..., and then |
|
57
|
# revisions and symbols. The latter can be further separated |
|
58
|
# into tags and branches. At project level the per-file |
|
59
|
# symbols information is merged. |
|
60
|
|
|
61
|
# File level ... |
|
62
|
# Revisions, Branches, Tags |
|
63
|
# |
|
64
|
# Pseudo class hierarchy |
|
65
|
# Tag <- Symbol <- Event |
|
66
|
# Branch <- Symbol <- Event |
|
67
|
# Revision <- Event |
|
68
|
|
|
69
|
state extend revision { |
|
70
|
-- Revisions. Identified by a global numeric id each |
|
71
|
-- belongs to a single file, identified by its id. It |
|
72
|
-- further has a dotted revision number (DTN). |
|
73
|
-- |
|
74
|
-- Constraint: The dotted revision number is unique within |
|
75
|
-- the file. See end of definition. |
|
76
|
|
|
77
|
rid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
|
78
|
fid INTEGER NOT NULL REFERENCES file, -- File owning revision. |
|
79
|
rev TEXT NOT NULL, -- Dotted Rev Number. |
|
80
|
|
|
81
|
-- All revisions belong to a line-of-development, |
|
82
|
-- identified by a symbol (project level). During data |
|
83
|
-- collection it was a file-level branch symbol. |
|
84
|
-- |
|
85
|
-- Constraint: All the LOD symbols are in the same project |
|
86
|
-- as the file itself. This cannot be |
|
87
|
-- expressed in CREATE TABLE syntax. |
|
88
|
|
|
89
|
lod INTEGER NOT NULL REFERENCES symbol, -- Line of development |
|
90
|
|
|
91
|
-- The revisions in a file are organized in a forest of |
|
92
|
-- trees, with the main lines defined through the parent / |
|
93
|
-- child references. A revision without a parent is the |
|
94
|
-- root of a tree, and a revision without a child is a |
|
95
|
-- leaf. |
|
96
|
|
|
97
|
-- Constraints: All revisions coupled through parent/child |
|
98
|
-- refer to the same LOD symbol. The parent |
|
99
|
-- of a child of X is X. The child of a |
|
100
|
-- parent of X is X. |
|
101
|
|
|
102
|
parent INTEGER REFERENCES revision, |
|
103
|
child INTEGER REFERENCES revision, |
|
104
|
|
|
105
|
-- The representation of a branch in a tree is the |
|
106
|
-- exception to the three constraints above. |
|
107
|
|
|
108
|
-- The beginning of a branch is represented by a non-NULL |
|
109
|
-- bparent of a revision. This revision B is the first on |
|
110
|
-- the branch. Its parent P is the revision the branch is |
|
111
|
-- rooted in, and it is not the child of P. B and P refer |
|
112
|
-- to different LOD symbols. The bparent of B is also its |
|
113
|
-- LOD, and the LOD of its children. |
|
114
|
|
|
115
|
bparent INTEGER REFERENCES symbol, |
|
116
|
|
|
117
|
-- Lastly we keep information is about non-trunk default |
|
118
|
-- branches (NTDB) in the revisions. |
|
119
|
|
|
120
|
-- All revisions on the NTDB have 'isdefault' TRUE, |
|
121
|
-- everyone else FALSE. The last revision X on the NTDB |
|
122
|
-- which is still considered to be on the trunk as well |
|
123
|
-- has a non-NULL 'dbchild' which refers to the root of |
|
124
|
-- the trunk. The root also has a non-NULL dbparent |
|
125
|
-- refering to X. |
|
126
|
|
|
127
|
isdefault INTEGER NOT NULL, |
|
128
|
dbparent INTEGER REFERENCES revision, |
|
129
|
dbchild INTEGER REFERENCES revision, |
|
130
|
|
|
131
|
-- The main payload of the revision are the date/time it |
|
132
|
-- was entered, its state, operation (= type/class), text |
|
133
|
-- content, and meta data (author, log message, branch, |
|
134
|
-- project). The last is encoded as single id, see table |
|
135
|
-- 'meta'. The date/time is given in seconds since the |
|
136
|
-- epoch, for easy comparison. |
|
137
|
|
|
138
|
op INTEGER NOT NULL REFERENCES optype, |
|
139
|
date INTEGER NOT NULL, |
|
140
|
state TEXT NOT NULL, |
|
141
|
mid INTEGER NOT NULL REFERENCES meta, |
|
142
|
|
|
143
|
UNIQUE (fid, rev) -- The DTN is unique within the revision's file. |
|
144
|
} |
|
145
|
|
|
146
|
# Blobs contain the information needed to extract revisions |
|
147
|
# from rcs archive files. As such each revision has an |
|
148
|
# associated blob. However we can have blobs without |
|
149
|
# revisions. This happens if a logically irrelevant revision |
|
150
|
# is removed. We may however still need its blob to correctly |
|
151
|
# expand other revisions, both its contents and for the |
|
152
|
# ordering. |
|
153
|
|
|
154
|
state extend blob { |
|
155
|
bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
|
156
|
rid INTEGER REFERENCES revision, |
|
157
|
fid INTEGER NOT NULL REFERENCES file, -- File owning blob. |
|
158
|
|
|
159
|
-- The text content is an (offset,length) pair into the |
|
160
|
-- rcs archive. For deltas we additionally refer to the |
|
161
|
-- parent blob the delta is made against. |
|
162
|
|
|
163
|
coff INTEGER NOT NULL, |
|
164
|
clen INTEGER NOT NULL, |
|
165
|
pid INTEGER REFERENCES blob, |
|
166
|
|
|
167
|
UNIQUE (rid) |
|
168
|
} { fid } |
|
169
|
# Index on owning file to collect all blobs of a file when the |
|
170
|
# time for its expansion comes. |
|
171
|
|
|
172
|
state extend optype { |
|
173
|
oid INTEGER NOT NULL PRIMARY KEY, |
|
174
|
name TEXT NOT NULL, |
|
175
|
UNIQUE(name) |
|
176
|
} |
|
177
|
state run { |
|
178
|
INSERT INTO optype VALUES (-1,'delete'); -- The opcode names are the |
|
179
|
INSERT INTO optype VALUES ( 0,'nothing'); -- fixed pieces, see myopstate |
|
180
|
INSERT INTO optype VALUES ( 1,'add'); -- in file::rev. myopcode is |
|
181
|
INSERT INTO optype VALUES ( 2,'change'); -- loaded from this. |
|
182
|
} |
|
183
|
|
|
184
|
state extend revisionbranchchildren { |
|
185
|
-- The non-primary children of a revision, as reachable |
|
186
|
-- through a branch symbol, are listed here. This is |
|
187
|
-- needed by pass 5 to break internal dependencies in a |
|
188
|
-- changeset. |
|
189
|
|
|
190
|
rid INTEGER NOT NULL REFERENCES revision, |
|
191
|
brid INTEGER NOT NULL REFERENCES revision, |
|
192
|
UNIQUE(rid,brid) |
|
193
|
} |
|
194
|
|
|
195
|
state extend tag { |
|
196
|
tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
|
197
|
fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
|
198
|
lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
|
199
|
sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag |
|
200
|
|
|
201
|
rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged. |
|
202
|
} { rev sid } |
|
203
|
# Indices on: rev (revision successors) |
|
204
|
# sid (tag predecessors, branch successors/predecessors) |
|
205
|
|
|
206
|
state extend branch { |
|
207
|
bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
|
208
|
fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
|
209
|
lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
|
210
|
sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch |
|
211
|
|
|
212
|
root INTEGER REFERENCES revision, -- Revision the branch sprouts from |
|
213
|
first INTEGER REFERENCES revision, -- First revision committed to the branch |
|
214
|
bra TEXT NOT NULL, -- branch number |
|
215
|
pos INTEGER NOT NULL -- creation order in root. |
|
216
|
|
|
217
|
-- A branch can exist without root. It happens when the |
|
218
|
-- only revision on trunk is the unnecessary dead one the |
|
219
|
-- branch was sprouted from and it has commits. The branch |
|
220
|
-- will exist to be the LOD of its revisions, nothing to |
|
221
|
-- sprout from, the dead revision was removed, hence no |
|
222
|
-- root. |
|
223
|
} { root first sid } |
|
224
|
# Indices on: root (revision successors) |
|
225
|
# first (revision predecessors) |
|
226
|
# sid (tag predecessors, branch successors/predecessors) |
|
227
|
|
|
228
|
# Project level ... |
|
229
|
# pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk |
|
230
|
# |
|
231
|
# pTrunk <- pLineOfDevelopment |
|
232
|
# pBranch <- pSymbol, pLineOfDevelopment |
|
233
|
# pTag <- pSymbol, pLineOfDevelopment |
|
234
|
|
|
235
|
state extend symbol { |
|
236
|
sid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
|
237
|
pid INTEGER NOT NULL REFERENCES project, -- Project the symbol belongs to |
|
238
|
name TEXT NOT NULL, |
|
239
|
type INTEGER NOT NULL REFERENCES symtype, -- enum { excluded = 0, tag, branch, undefined } |
|
240
|
|
|
241
|
tag_count INTEGER NOT NULL, -- How often the symbol is used as tag. |
|
242
|
branch_count INTEGER NOT NULL, -- How often the symbol is used as branch |
|
243
|
commit_count INTEGER NOT NULL, -- How often a file was committed on the symbol |
|
244
|
|
|
245
|
UNIQUE (pid, name) -- Symbols are unique within the project |
|
246
|
} |
|
247
|
|
|
248
|
state extend blocker { |
|
249
|
-- For each symbol we save which other symbols are |
|
250
|
-- blocking its removal (if the user asks for it). |
|
251
|
|
|
252
|
sid INTEGER NOT NULL REFERENCES symbol, -- |
|
253
|
bid INTEGER NOT NULL REFERENCES symbol, -- Sprouted from sid, blocks it. |
|
254
|
UNIQUE (sid, bid) |
|
255
|
} |
|
256
|
|
|
257
|
state extend parent { |
|
258
|
-- For each symbol we save which other symbols can act as |
|
259
|
-- a possible parent in some file, and how often. |
|
260
|
|
|
261
|
sid INTEGER NOT NULL REFERENCES symbol, -- |
|
262
|
pid INTEGER NOT NULL REFERENCES symbol, -- Possible parent of sid |
|
263
|
n INTEGER NOT NULL, -- How often pid can act as parent. |
|
264
|
UNIQUE (sid, pid) |
|
265
|
} |
|
266
|
|
|
267
|
state extend symtype { |
|
268
|
tid INTEGER NOT NULL PRIMARY KEY, |
|
269
|
name TEXT NOT NULL, |
|
270
|
plural TEXT NOT NULL, |
|
271
|
UNIQUE (name) |
|
272
|
UNIQUE (plural) |
|
273
|
} |
|
274
|
state run { |
|
275
|
INSERT INTO symtype VALUES (0,'excluded', 'excluded'); -- The ids are the fixed |
|
276
|
INSERT INTO symtype VALUES (1,'tag', 'tags'); -- pieces, see project::sym, |
|
277
|
INSERT INTO symtype VALUES (2,'branch', 'branches'); -- getsymtypes and associated |
|
278
|
INSERT INTO symtype VALUES (3,'undefined','undefined'); -- typevariables. |
|
279
|
} |
|
280
|
|
|
281
|
state extend meta { |
|
282
|
-- Meta data of revisions. See revision.mid for the |
|
283
|
-- reference. Many revisions can share meta data. This is |
|
284
|
-- actually one of the criterions used to sort revisions |
|
285
|
-- into changesets. |
|
286
|
|
|
287
|
mid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
|
288
|
|
|
289
|
-- Meta data belongs to a specific project, stronger, to a |
|
290
|
-- branch in that project. It further has a log message, |
|
291
|
-- and its author. This is unique with the project and |
|
292
|
-- branch. |
|
293
|
|
|
294
|
pid INTEGER NOT NULL REFERENCES project, -- |
|
295
|
bid INTEGER NOT NULL REFERENCES symbol, -- |
|
296
|
aid INTEGER NOT NULL REFERENCES author, -- |
|
297
|
cid INTEGER NOT NULL REFERENCES cmessage, -- |
|
298
|
|
|
299
|
UNIQUE (pid, bid, aid, cid) |
|
300
|
|
|
301
|
-- Constraints: The project of the meta data of a revision |
|
302
|
-- X is the same as the project of X itself. |
|
303
|
-- |
|
304
|
-- ............ The branch of the meta data of a revision |
|
305
|
-- X is the same as the line of development |
|
306
|
-- of X itself. |
|
307
|
} |
|
308
|
|
|
309
|
# Authors and commit messages are fully global, i.e. per |
|
310
|
# repository. |
|
311
|
|
|
312
|
state extend author { |
|
313
|
aid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, -- Pool of the unique |
|
314
|
name TEXT NOT NULL UNIQUE -- author names. |
|
315
|
} |
|
316
|
|
|
317
|
state extend cmessage { |
|
318
|
cid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, -- Pool of the unique |
|
319
|
text TEXT NOT NULL UNIQUE -- log messages |
|
320
|
} |
|
321
|
|
|
322
|
project::sym getsymtypes |
|
323
|
file::rev getopcodes |
|
324
|
return |
|
325
|
} |
|
326
|
|
|
327
|
typemethod load {} { |
|
328
|
state use symbol |
|
329
|
state use symtype |
|
330
|
state use optype |
|
331
|
|
|
332
|
project::sym getsymtypes |
|
333
|
file::rev getopcodes |
|
334
|
repository loadsymbols |
|
335
|
return |
|
336
|
} |
|
337
|
|
|
338
|
typemethod run {} { |
|
339
|
# Pass manager interface. Executed to perform the |
|
340
|
# functionality of the pass. |
|
341
|
|
|
342
|
set rbase [repository base?] |
|
343
|
foreach project [repository projects] { |
|
344
|
set base [::file join $rbase [$project base]] |
|
345
|
log write 1 collrev "Processing $base" |
|
346
|
|
|
347
|
foreach file [$project files] { |
|
348
|
set path [$file path] |
|
349
|
log write 2 collrev "Parsing $path" |
|
350
|
if {[catch { |
|
351
|
parser process [::file join $base $path] $file |
|
352
|
} msg]} { |
|
353
|
global errorCode |
|
354
|
if {$errorCode eq "vc::rcs::parser"} { |
|
355
|
trouble fatal "$path is not a valid RCS archive ($msg)" |
|
356
|
} else { |
|
357
|
global errorInfo |
|
358
|
trouble internal $errorInfo |
|
359
|
} |
|
360
|
} else { |
|
361
|
# We persist the core of the data collected about |
|
362
|
# each file immediately after it has been parsed |
|
363
|
# and wrangled into shape, and then drop it from |
|
364
|
# memory. This is done to keep the amount of |
|
365
|
# required memory within sensible limits. Without |
|
366
|
# doing it this way we would easily gobble up 1G |
|
367
|
# of RAM or more with all the objects (revisions |
|
368
|
# and file-level symbols). |
|
369
|
|
|
370
|
$file persist |
|
371
|
} |
|
372
|
|
|
373
|
$file drop |
|
374
|
} |
|
375
|
|
|
376
|
$project purgeghostsymbols |
|
377
|
} |
|
378
|
|
|
379
|
repository persistrev |
|
380
|
repository printrevstatistics |
|
381
|
integrity strict |
|
382
|
|
|
383
|
log write 1 collrev "Scan completed" |
|
384
|
return |
|
385
|
} |
|
386
|
|
|
387
|
typemethod discard {} { |
|
388
|
# Pass manager interface. Executed for all passes after the |
|
389
|
# run passes, to remove all data of this pass from the state, |
|
390
|
# as being out of date. |
|
391
|
|
|
392
|
state discard revision |
|
393
|
state discard tag |
|
394
|
state discard branch |
|
395
|
state discard symbol |
|
396
|
state discard blocker |
|
397
|
state discard parent |
|
398
|
state discard symtype |
|
399
|
state discard meta |
|
400
|
state discard author |
|
401
|
state discard cmessage |
|
402
|
return |
|
403
|
} |
|
404
|
|
|
405
|
# TODO: Move this code to the integrity module |
|
406
|
proc Paranoia {} { |
|
407
|
# This code performs a number of paranoid checks of the |
|
408
|
# database, searching for inconsistent cross-references. |
|
409
|
log write 4 collrev {Check database consistency} |
|
410
|
|
|
411
|
set n 0 ; # Counter for the checks (we print an id before the |
|
412
|
# main label). |
|
413
|
|
|
414
|
# Find all revisions which disagree with their line of |
|
415
|
# development about the project they are owned by. |
|
416
|
Check \ |
|
417
|
{Revisions and their LODs have to be in the same project} \ |
|
418
|
{disagrees with its LOD about owning project} { |
|
419
|
SELECT F.name, R.rev |
|
420
|
FROM revision R, file F, symbol S |
|
421
|
WHERE R.fid = F.fid -- Get file of revision |
|
422
|
AND R.lod = S.sid -- Get symbol for revision's LOD |
|
423
|
AND F.pid != S.pid -- but symbol is for a different project |
|
424
|
; |
|
425
|
} |
|
426
|
# Find all revisions which disgree with their meta data about |
|
427
|
# the project they are owned by. |
|
428
|
Check \ |
|
429
|
{Revisions and their meta data have to be in the same project} \ |
|
430
|
{disagrees with its meta data about owning project} { |
|
431
|
SELECT F.name, R.rev |
|
432
|
FROM revision R, file F, meta M |
|
433
|
WHERE R.fid = F.fid -- Get file of revision |
|
434
|
AND R.mid = M.mid -- Get meta data of revision |
|
435
|
AND F.pid != M.pid -- but is for a different project |
|
436
|
; |
|
437
|
} |
|
438
|
# Find all revisions which disgree with their meta data about |
|
439
|
# the branch/line of development they belong to. |
|
440
|
Check \ |
|
441
|
{Revisions and their meta data have to be in the same LOD} \ |
|
442
|
{disagrees with its meta data about owning LOD} { |
|
443
|
SELECT F.name, R.rev |
|
444
|
FROM revision R, meta M, file F |
|
445
|
WHERE R.mid = M.mid -- Get meta data of revision |
|
446
|
AND R.lod != M.bid -- but is for a different LOD |
|
447
|
AND R.fid = F.fid -- Get file of revision |
|
448
|
; |
|
449
|
} |
|
450
|
# Find all revisions with a primary child which disagrees |
|
451
|
# about the file they belong to. |
|
452
|
Check \ |
|
453
|
{Revisions and their primary children have to be in the same file} \ |
|
454
|
{disagrees with its primary child about the owning file} { |
|
455
|
SELECT F.name, R.rev |
|
456
|
FROM revision R, revision C, file F |
|
457
|
WHERE R.fid = F.fid -- Get file of revision |
|
458
|
AND R.child IS NOT NULL -- Restrict to non-leaf revisions |
|
459
|
AND R.child = C.rid -- Get child (has to exist) |
|
460
|
AND C.fid != R.fid -- Whic wrongly is in a different file |
|
461
|
; |
|
462
|
} |
|
463
|
|
|
464
|
# Find all revisions with a branch parent symbol whose parent |
|
465
|
# disagrees about the file they belong to. |
|
466
|
Check \ |
|
467
|
{Revisions and their branch children have to be in the same file} \ |
|
468
|
{at the beginning of its branch and its parent disagree about the owning file} { |
|
469
|
SELECT F.name, R.rev |
|
470
|
FROM revision R, revision P, file F |
|
471
|
WHERE R.fid = F.fid -- Get file of revision |
|
472
|
AND R.bparent IS NOT NULL -- Restrict to first on branch |
|
473
|
AND R.parent = P.rid -- Get out-of-branch parent |
|
474
|
AND R.fid != P.fid -- Which wrongly is in a different file |
|
475
|
; |
|
476
|
} |
|
477
|
# Find all revisions with a non-NTDB child which disagrees |
|
478
|
# about the file they belong to. |
|
479
|
Check \ |
|
480
|
{Revisions and their non-NTDB children have to be in the same file} \ |
|
481
|
{disagrees with its non-NTDB child about the owning file} { |
|
482
|
SELECT F.name, R.rev |
|
483
|
FROM revision R, revision C, file F |
|
484
|
WHERE R.fid = F.fid -- Get file of revision |
|
485
|
AND R.dbchild IS NOT NULL -- Restrict to semi-last NTDB revision |
|
486
|
AND R.dbchild = C.rid -- Got to associated trunk revision |
|
487
|
AND C.fid != R.fid -- Which wrongly is in a different file |
|
488
|
; |
|
489
|
} |
|
490
|
# Find all revisions which have a primary child, but the child |
|
491
|
# does not have them as parent. |
|
492
|
Check \ |
|
493
|
{Revisions have to be parents of their primary children} \ |
|
494
|
{is not the parent of its primary child} { |
|
495
|
SELECT F.name, R.rev |
|
496
|
FROM revision R, revision C, file F |
|
497
|
WHERE R.fid = F.fid -- Get file of revision |
|
498
|
AND R.child IS NOT NULL -- Restrict to non-leaves |
|
499
|
AND R.child = C.rid -- Get the child (has to exist) |
|
500
|
AND C.parent != R.rid -- Which does not have us as its parent. |
|
501
|
; |
|
502
|
} |
|
503
|
# Find all revisions which have a primrary child, but the |
|
504
|
# child has a branch parent symbol making them brach starters. |
|
505
|
Check \ |
|
506
|
{Primary children of revisions must not start branches} \ |
|
507
|
{is parent of a primary child which is the beginning of a branch} { |
|
508
|
SELECT F.name, R.rev |
|
509
|
FROM revision R, revision C, file F |
|
510
|
WHERE R.fid = F.fid -- Get file of revision |
|
511
|
AND R.child IS NOT NULL -- Restrict to non-leaves |
|
512
|
AND R.child = C.rid -- Get the child (has to exist) |
|
513
|
AND C.bparent IS NOT NULL -- wrongly claiming to be first on branch |
|
514
|
; |
|
515
|
} |
|
516
|
# Find all revisions without branch parent symbol which have a |
|
517
|
# parent, but the parent does not have them as primary child. |
|
518
|
Check \ |
|
519
|
{Revisions have to be primary children of their parents, if any} \ |
|
520
|
{is not the child of its parent} { |
|
521
|
SELECT F.name, R.rev |
|
522
|
FROM revision R, revision P, file F |
|
523
|
WHERE R.fid = F.fid |
|
524
|
AND R.bparent IS NULL -- Get file of revision |
|
525
|
AND R.parent IS NOT NULL -- Restrict to everything not first on a branch |
|
526
|
AND R.parent = P.rid -- Get the parent (has to exist) |
|
527
|
AND P.child != R.rid -- Which do not have us as their child |
|
528
|
; |
|
529
|
} |
|
530
|
# Find all revisions with a branch parent symbol which do not |
|
531
|
# have a parent. |
|
532
|
Check \ |
|
533
|
{Branch starting revisions have to have a parent} \ |
|
534
|
{at the beginning of its branch has no parent} { |
|
535
|
SELECT F.name, R.rev |
|
536
|
FROM revision R, file F |
|
537
|
WHERE R.fid = F.fid -- Get file of revision |
|
538
|
AND R.bparent IS NOT NULL -- Restrict to first on a branch |
|
539
|
AND R.parent IS NULL -- But there is no out-of-branch parent |
|
540
|
; |
|
541
|
} |
|
542
|
# Find all revisions with a branch parent symbol whose parent |
|
543
|
# has them as primary child. |
|
544
|
Check \ |
|
545
|
{Branch starting revisions must not be primary children of their parents} \ |
|
546
|
{at the beginning of its branch is the primary child of its parent} { |
|
547
|
SELECT F.name, R.rev |
|
548
|
FROM revision R, revision P, file F |
|
549
|
WHERE R.fid = F.fid -- Get file of revision |
|
550
|
AND R.bparent IS NOT NULL -- Restrict to first on a branch |
|
551
|
AND R.parent IS NOT NULL -- Which are not detached |
|
552
|
AND R.parent = P.rid -- Get their non-branch parent |
|
553
|
AND P.child = R.rid -- which improperly has them as primary child |
|
554
|
; |
|
555
|
} |
|
556
|
# Find all revisions with a non-NTDB child which are not on |
|
557
|
# the NTDB. |
|
558
|
Check \ |
|
559
|
{NTDB to trunk transition has to begin on NTDB} \ |
|
560
|
{has a non-NTDB child, yet is not on the NTDB} { |
|
561
|
SELECT F.name, R.rev |
|
562
|
FROM revision R, file F |
|
563
|
WHERE R.fid = F.fid -- Get file of revision |
|
564
|
AND R.dbchild IS NOT NULL -- Restrict to semi-last NTDB revision |
|
565
|
AND NOT R.isdefault -- Improperly claiming to not be on NTDB |
|
566
|
; |
|
567
|
} |
|
568
|
# Find all revisions with a NTDB parent which are on the NTDB. |
|
569
|
Check \ |
|
570
|
{NTDB to trunk transition has to end on non-NTDB} \ |
|
571
|
{has a NTDB parent, yet is on the NTDB} { |
|
572
|
SELECT F.name, R.rev |
|
573
|
FROM revision R, file F |
|
574
|
WHERE R.fid = F.fid -- Get file of revision |
|
575
|
AND R.dbparent IS NOT NULL -- Restrict to trunk roots with NTDB around |
|
576
|
AND R.isdefault -- But root improperly claims to be on NTDB |
|
577
|
; |
|
578
|
} |
|
579
|
# Find all revisions with a child which disagrees about the |
|
580
|
# line of development they belong to. |
|
581
|
Check \ |
|
582
|
{Revisions and their primary children have to be in the same LOD} \ |
|
583
|
{and its primary child disagree about their LOD} { |
|
584
|
SELECT F.name, R.rev |
|
585
|
FROM revision R, revision C, file F |
|
586
|
WHERE R.fid = F.fid -- Get file of revision |
|
587
|
AND R.child IS NOT NULL -- Restrict to non-leaves |
|
588
|
AND R.child = C.rid -- Get child (has to exist) |
|
589
|
AND C.lod != R.lod -- which improperly uses a different LOD |
|
590
|
; |
|
591
|
} |
|
592
|
# Find all revisions with a non-NTDB child which agrees about |
|
593
|
# the line of development they belong to. |
|
594
|
Check \ |
|
595
|
{NTDB and trunk revisions have to be in different LODs} \ |
|
596
|
{on NTDB and its non-NTDB child wrongly agree about their LOD} { |
|
597
|
SELECT F.name, R.rev |
|
598
|
FROM revision R, revision C, file F |
|
599
|
WHERE R.fid = F.fid -- Get file of revision |
|
600
|
AND R.dbchild IS NOT NULL -- Restrict to semi-last NTDB revision |
|
601
|
AND R.dbchild = C.rid -- Get associated trunk root revision |
|
602
|
AND C.lod = R.lod -- Improperly uses the same LOD |
|
603
|
; |
|
604
|
} |
|
605
|
# Find all revisions with a branch parent symbol which is not |
|
606
|
# their LOD. |
|
607
|
Check \ |
|
608
|
{Branch starting revisions have to have their LOD as branch parent symbol} \ |
|
609
|
{at the beginning of its branch does not have the branch symbol as its LOD} { |
|
610
|
SELECT F.name, R.rev |
|
611
|
FROM revision R, file F |
|
612
|
WHERE R.fid = F.fid -- Get file of revision |
|
613
|
AND R.bparent IS NOT NULL -- Restrict to revisions first on a branch |
|
614
|
AND R.lod != R.bparent -- and their branch is not their LOD |
|
615
|
; |
|
616
|
} |
|
617
|
# Find all revisions with a branch parent symbol whose parent |
|
618
|
# is in the same line of development. |
|
619
|
Check \ |
|
620
|
{Revisions and their branch children have to be in different LODs} \ |
|
621
|
{at the beginning of its branch and its parent wrongly agree about their LOD} { |
|
622
|
SELECT F.name, R.rev |
|
623
|
FROM revision R, revision P, file F |
|
624
|
WHERE R.fid = F.fid -- Get file of revision |
|
625
|
AND R.bparent IS NOT NULL -- Restrict to revisions first on a branch |
|
626
|
AND R.parent = P.rid -- Get their non-branch parent |
|
627
|
AND R.lod = P.lod -- Which improperly uses the same LOD |
|
628
|
; |
|
629
|
} |
|
630
|
return |
|
631
|
} |
|
632
|
|
|
633
|
proc Check {header label sql} { |
|
634
|
upvar 1 n n |
|
635
|
set ok 1 |
|
636
|
foreach {fname revnr} [state run $sql] { |
|
637
|
set ok 0 |
|
638
|
trouble fatal "$fname <$revnr> $label" |
|
639
|
} |
|
640
|
log write 5 collrev "\[[format %02d [incr n]]\] [expr {$ok ? "Ok " : "Failed"}] ... $header" |
|
641
|
return |
|
642
|
} |
|
643
|
|
|
644
|
# # ## ### ##### ######## ############# |
|
645
|
## Internal methods |
|
646
|
|
|
647
|
# # ## ### ##### ######## ############# |
|
648
|
## Configuration |
|
649
|
|
|
650
|
pragma -hasinstances no ; # singleton |
|
651
|
pragma -hastypeinfo no ; # no introspection |
|
652
|
pragma -hastypedestroy no ; # immortal |
|
653
|
|
|
654
|
# # ## ### ##### ######## ############# |
|
655
|
} |
|
656
|
|
|
657
|
namespace eval ::vc::fossil::import::cvs::pass { |
|
658
|
namespace export collrev |
|
659
|
namespace eval collrev { |
|
660
|
namespace import ::vc::rcs::parser |
|
661
|
namespace import ::vc::fossil::import::cvs::repository |
|
662
|
namespace import ::vc::fossil::import::cvs::state |
|
663
|
namespace import ::vc::fossil::import::cvs::integrity |
|
664
|
namespace eval project { |
|
665
|
namespace import ::vc::fossil::import::cvs::project::sym |
|
666
|
} |
|
667
|
namespace eval file { |
|
668
|
namespace import ::vc::fossil::import::cvs::file::rev |
|
669
|
} |
|
670
|
namespace import ::vc::tools::trouble |
|
671
|
namespace import ::vc::tools::log |
|
672
|
log register collrev |
|
673
|
} |
|
674
|
} |
|
675
|
|
|
676
|
# # ## ### ##### ######## ############# ##################### |
|
677
|
## Ready |
|
678
|
|
|
679
|
package provide vc::fossil::import::cvs::pass::collrev 1.0 |
|
680
|
return |
|
681
|
|