0000: 23 23 20 2d 2a 2d 20 74 63 6c 20 2d 2a 2d 0a 23 ## -*- tcl -*-.#
0010: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 # ## ### #####
0020: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 ######## #######
0030: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
0040: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 ############.##
0050: 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 32 30 Copyright (c) 20
0060: 30 37 20 41 6e 64 72 65 61 73 20 4b 75 70 72 69 07 Andreas Kupri
0070: 65 73 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 es..#.# This sof
0080: 74 77 61 72 65 20 69 73 20 6c 69 63 65 6e 73 65 tware is license
0090: 64 20 61 73 20 64 65 73 63 72 69 62 65 64 20 69 d as described i
00a0: 6e 20 74 68 65 20 66 69 6c 65 20 4c 49 43 45 4e n the file LICEN
00b0: 53 45 2c 20 77 68 69 63 68 0a 23 20 79 6f 75 20 SE, which.# you
00c0: 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65 should have rece
00d0: 69 76 65 64 20 61 73 20 70 61 72 74 20 6f 66 20 ived as part of
00e0: 74 68 69 73 20 64 69 73 74 72 69 62 75 74 69 6f this distributio
00f0: 6e 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 74 n..#.# This soft
0100: 77 61 72 65 20 63 6f 6e 73 69 73 74 73 20 6f 66 ware consists of
0110: 20 76 6f 6c 75 6e 74 61 72 79 20 63 6f 6e 74 72 voluntary contr
0120: 69 62 75 74 69 6f 6e 73 20 6d 61 64 65 20 62 79 ibutions made by
0130: 20 6d 61 6e 79 0a 23 20 69 6e 64 69 76 69 64 75 many.# individu
0140: 61 6c 73 2e 20 20 46 6f 72 20 65 78 61 63 74 20 als. For exact
0150: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 20 68 69 73 contribution his
0160: 74 6f 72 79 2c 20 73 65 65 20 74 68 65 20 72 65 tory, see the re
0170: 76 69 73 69 6f 6e 0a 23 20 68 69 73 74 6f 72 79 vision.# history
0180: 20 61 6e 64 20 6c 6f 67 73 2c 20 61 76 61 69 6c and logs, avail
0190: 61 62 6c 65 20 61 74 20 68 74 74 70 3a 2f 2f 66 able at http://f
01a0: 6f 73 73 69 6c 2d 73 63 6d 2e 68 77 61 63 69 2e ossil-scm.hwaci.
01b0: 63 6f 6d 2f 66 6f 73 73 69 6c 0a 23 20 23 20 23 com/fossil.# # #
01c0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
01d0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
01e0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
01f0: 23 23 23 23 23 23 23 23 0a 0a 23 23 20 54 68 69 ########..## Thi
0200: 73 20 70 61 63 6b 61 67 65 20 68 6f 6c 64 73 20 s package holds
0210: 61 20 6e 75 6d 62 65 72 20 6f 66 20 69 6e 74 65 a number of inte
0220: 67 72 69 74 79 20 63 68 65 63 6b 73 20 64 6f 6e grity checks don
0230: 65 20 6f 6e 20 74 68 65 0a 23 23 20 70 65 72 73 e on the.## pers
0240: 69 73 74 65 6e 74 20 73 74 61 74 65 2e 20 54 68 istent state. Th
0250: 69 73 20 69 73 20 75 73 65 64 20 62 79 20 74 68 is is used by th
0260: 65 20 70 61 73 73 65 73 20 49 49 20 61 6e 64 20 e passes II and
0270: 49 56 2e 0a 0a 23 20 23 20 23 23 20 23 23 23 20 IV...# # ## ###
0280: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 ##### ######## #
0290: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 ############ ###
02a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
02b0: 23 23 0a 23 23 20 52 65 71 75 69 72 65 6d 65 6e ##.## Requiremen
02c0: 74 73 0a 0a 70 61 63 6b 61 67 65 20 72 65 71 75 ts..package requ
02d0: 69 72 65 20 54 63 6c 20 38 2e 34 20 20 20 20 20 ire Tcl 8.4
02e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
02f0: 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 52 65 ; # Re
0300: 71 75 69 72 65 64 20 72 75 6e 74 69 6d 65 2e 0a quired runtime..
0310: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 package require
0320: 73 6e 69 74 20 20 20 20 20 20 20 20 20 20 20 20 snit
0330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0340: 20 20 20 20 20 20 3b 20 23 20 4f 4f 20 73 79 73 ; # OO sys
0350: 74 65 6d 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 tem..package req
0360: 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a uire vc::tools::
0370: 74 72 6f 75 62 6c 65 20 20 20 20 20 20 20 20 20 trouble
0380: 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 45 ; # E
0390: 72 72 6f 72 20 72 65 70 6f 72 74 69 6e 67 2e 0a rror reporting..
03a0: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 package require
03b0: 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 20 20 vc::tools::log
03c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
03d0: 20 20 20 20 20 20 3b 20 23 20 55 73 65 72 20 66 ; # User f
03e0: 65 65 64 62 61 63 6b 2e 0a 70 61 63 6b 61 67 65 eedback..package
03f0: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 require vc::fos
0400: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 sil::import::cvs
0410: 3a 3a 73 74 61 74 65 20 20 20 20 20 20 20 20 3b ::state ;
0420: 20 23 20 53 74 61 74 65 20 73 74 6f 72 61 67 65 # State storage
0430: 2e 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 ...# # ## ### ##
0440: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 ### ######## ###
0450: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 ########## #####
0460: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0470: 0a 23 23 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 .##..snit::type
0480: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d ::vc::fossil::im
0490: 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 port::cvs::integ
04a0: 72 69 74 79 20 7b 0a 20 20 20 20 23 20 23 20 23 rity {. # # #
04b0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
04c0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
04d0: 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69 63 ##. ## Public
04e0: 20 41 50 49 0a 0a 20 20 20 20 74 79 70 65 6d 65 API.. typeme
04f0: 74 68 6f 64 20 61 73 73 65 72 74 20 7b 65 78 70 thod assert {exp
0500: 72 65 73 73 69 6f 6e 20 66 61 69 6c 6d 65 73 73 ression failmess
0510: 61 67 65 7d 20 7b 0a 09 73 65 74 20 6f 6b 20 5b age} {..set ok [
0520: 75 70 6c 65 76 65 6c 20 31 20 5b 6c 69 73 74 20 uplevel 1 [list
0530: 3a 3a 65 78 70 72 20 24 65 78 70 72 65 73 73 69 ::expr $expressi
0540: 6f 6e 5d 5d 0a 09 69 66 20 7b 24 6f 6b 7d 20 72 on]]..if {$ok} r
0550: 65 74 75 72 6e 0a 09 74 72 6f 75 62 6c 65 20 69 eturn..trouble i
0560: 6e 74 65 72 6e 61 6c 20 5b 75 70 6c 65 76 65 6c nternal [uplevel
0570: 20 31 20 5b 6c 69 73 74 20 3a 3a 73 75 62 73 74 1 [list ::subst
0580: 20 24 66 61 69 6c 6d 65 73 73 61 67 65 5d 5d 0a $failmessage]].
0590: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 .return. }..
05a0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 74 typemethod st
05b0: 72 69 63 74 20 7b 7d 20 7b 0a 09 6c 6f 67 20 77 rict {} {..log w
05c0: 72 69 74 65 20 34 20 69 6e 74 65 67 72 69 74 79 rite 4 integrity
05d0: 20 7b 43 68 65 63 6b 20 64 61 74 61 62 61 73 65 {Check database
05e0: 20 63 6f 6e 73 69 73 74 65 6e 63 79 7d 0a 0a 09 consistency}...
05f0: 73 65 74 20 6e 20 30 0a 09 41 6c 6c 42 75 74 4d set n 0..AllButM
0600: 65 74 61 0a 09 4d 65 74 61 0a 09 72 65 74 75 72 eta..Meta..retur
0610: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 n. }.. typ
0620: 65 6d 65 74 68 6f 64 20 6d 65 74 61 72 65 6c 61 emethod metarela
0630: 78 65 64 20 7b 7d 20 7b 0a 09 6c 6f 67 20 77 72 xed {} {..log wr
0640: 69 74 65 20 34 20 69 6e 74 65 67 72 69 74 79 20 ite 4 integrity
0650: 7b 43 68 65 63 6b 20 64 61 74 61 62 61 73 65 20 {Check database
0660: 63 6f 6e 73 69 73 74 65 6e 63 79 7d 0a 0a 09 73 consistency}...s
0670: 65 74 20 6e 20 30 0a 09 41 6c 6c 42 75 74 4d 65 et n 0..AllButMe
0680: 74 61 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d ta..return. }
0690: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 .. typemethod
06a0: 20 63 68 61 6e 67 65 73 65 74 73 20 7b 7d 20 7b changesets {} {
06b0: 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 69 6e ..log write 4 in
06c0: 74 65 67 72 69 74 79 20 7b 43 68 65 63 6b 20 64 tegrity {Check d
06d0: 61 74 61 62 61 73 65 20 63 6f 6e 73 69 73 74 65 atabase consiste
06e0: 6e 63 79 7d 0a 0a 09 73 65 74 20 6e 20 30 0a 09 ncy}...set n 0..
06f0: 52 65 76 69 73 69 6f 6e 43 68 61 6e 67 65 73 65 RevisionChangese
0700: 74 73 0a 09 54 61 67 43 68 61 6e 67 65 73 65 74 ts..TagChangeset
0710: 73 0a 09 42 72 61 6e 63 68 43 68 61 6e 67 65 73 s..BranchChanges
0720: 65 74 73 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 ets..return.
0730: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 }.. # # ## ##
0740: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 # ##### ########
0750: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 #############.
0760: 20 20 20 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d ## Internal m
0770: 65 74 68 6f 64 73 0a 0a 20 20 20 20 70 72 6f 63 ethods.. proc
0780: 20 41 6c 6c 42 75 74 4d 65 74 61 20 7b 7d 20 7b AllButMeta {} {
0790: 0a 09 23 20 54 68 69 73 20 63 6f 64 65 20 70 65 ..# This code pe
07a0: 72 66 6f 72 6d 73 20 61 20 6e 75 6d 62 65 72 20 rforms a number
07b0: 6f 66 20 70 61 72 61 6e 6f 69 64 20 63 68 65 63 of paranoid chec
07c0: 6b 73 20 6f 66 20 74 68 65 0a 09 23 20 64 61 74 ks of the..# dat
07d0: 61 62 61 73 65 2c 20 73 65 61 72 63 68 69 6e 67 abase, searching
07e0: 20 66 6f 72 20 69 6e 63 6f 6e 73 69 73 74 65 6e for inconsisten
07f0: 74 20 63 72 6f 73 73 2d 72 65 66 65 72 65 6e 63 t cross-referenc
0800: 65 73 2e 0a 0a 09 75 70 76 61 72 20 31 20 6e 20 es....upvar 1 n
0810: 6e 20 3b 20 23 20 43 6f 75 6e 74 65 72 20 66 6f n ; # Counter fo
0820: 72 20 74 68 65 20 63 68 65 63 6b 73 20 28 77 65 r the checks (we
0830: 20 70 72 69 6e 74 20 61 6e 20 69 64 20 62 65 66 print an id bef
0840: 6f 72 65 0a 09 09 20 20 20 20 20 20 23 20 74 68 ore... # th
0850: 65 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a 0a e main label)...
0860: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 .# Find all revi
0870: 73 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73 61 sions which disa
0880: 67 72 65 65 20 77 69 74 68 20 74 68 65 69 72 20 gree with their
0890: 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c line of..# devel
08a0: 6f 70 6d 65 6e 74 20 61 62 6f 75 74 20 74 68 65 opment about the
08b0: 20 70 72 6f 6a 65 63 74 20 74 68 65 79 20 61 72 project they ar
08c0: 65 20 6f 77 6e 65 64 20 62 79 2e 0a 09 43 68 65 e owned by...Che
08d0: 63 6b 52 65 76 20 5c 0a 09 20 20 20 20 7b 52 65 ckRev \.. {Re
08e0: 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 visions and thei
08f0: 72 20 4c 4f 44 73 20 68 61 76 65 20 74 6f 20 62 r LODs have to b
0900: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70 72 e in the same pr
0910: 6f 6a 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b 64 oject} \.. {d
0920: 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74 isagrees with it
0930: 73 20 4c 4f 44 20 61 62 6f 75 74 20 6f 77 6e 69 s LOD about owni
0940: 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 ng project} {...
0950: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 SELECT F.name, R
0960: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 .rev...FROM revi
0970: 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 sion R, file F,
0980: 73 79 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52 45 symbol S...WHERE
0990: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 R.fid = F.fid..
09a0: 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20 3d 20 53 .AND R.lod = S
09b0: 2e 73 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70 .sid...AND F.p
09c0: 69 64 20 21 3d 20 53 2e 70 69 64 0a 09 09 3b 0a id != S.pid...;.
09d0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 . }..# Find a
09e0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 ll revisions whi
09f0: 63 68 20 64 69 73 67 72 65 65 20 77 69 74 68 20 ch disgree with
0a00: 74 68 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 their meta data
0a10: 61 62 6f 75 74 0a 09 23 20 74 68 65 20 70 72 6f about..# the pro
0a20: 6a 65 63 74 20 74 68 65 79 20 61 72 65 20 6f 77 ject they are ow
0a30: 6e 65 64 20 62 79 2e 0a 09 43 68 65 63 6b 52 65 ned by...CheckRe
0a40: 76 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 v \.. {Revisi
0a50: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 6d 65 ons and their me
0a60: 74 61 20 64 61 74 61 20 68 61 76 65 20 74 6f 20 ta data have to
0a70: 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70 be in the same p
0a80: 72 6f 6a 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b roject} \.. {
0a90: 64 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69 disagrees with i
0aa0: 74 73 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f ts meta data abo
0ab0: 75 74 20 6f 77 6e 69 6e 67 20 70 72 6f 6a 65 63 ut owning projec
0ac0: 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e t} {...SELECT F.
0ad0: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 name, R.rev...FR
0ae0: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 OM revision R, f
0af0: 69 6c 65 20 46 2c 20 6d 65 74 61 20 4d 0a 09 09 ile F, meta M...
0b00: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e WHERE R.fid = F.
0b10: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 6d 69 fid...AND R.mi
0b20: 64 20 3d 20 4d 2e 6d 69 64 0a 09 09 41 4e 44 20 d = M.mid...AND
0b30: 20 20 46 2e 70 69 64 20 21 3d 20 4d 2e 70 69 64 F.pid != M.pid
0b40: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 ...;.. }..# F
0b50: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e ind all revision
0b60: 73 20 77 69 74 68 20 61 20 70 72 69 6d 61 72 79 s with a primary
0b70: 20 63 68 69 6c 64 20 77 68 69 63 68 20 64 69 73 child which dis
0b80: 61 67 72 65 65 73 0a 09 23 20 61 62 6f 75 74 20 agrees..# about
0b90: 74 68 65 20 66 69 6c 65 20 74 68 65 79 20 62 65 the file they be
0ba0: 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 52 long to...CheckR
0bb0: 65 76 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 ev \.. {Revis
0bc0: 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 70 ions and their p
0bd0: 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20 rimary children
0be0: 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68 have to be in th
0bf0: 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a 09 e same file} \..
0c00: 20 20 20 20 7b 64 69 73 61 67 72 65 65 73 20 77 {disagrees w
0c10: 69 74 68 20 69 74 73 20 70 72 69 6d 61 72 79 20 ith its primary
0c20: 63 68 69 6c 64 20 61 62 6f 75 74 20 74 68 65 20 child about the
0c30: 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 owning file} {..
0c40: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 .SELECT F.name,
0c50: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 R.rev...FROM rev
0c60: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f ision R, revisio
0c70: 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 n C, file F...WH
0c80: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 ERE R.fid = F.fi
0c90: 64 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c d...AND R.chil
0ca0: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 d IS NOT NULL...
0cb0: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 3d 20 AND R.child =
0cc0: 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e C.rid...AND C.
0cd0: 66 69 64 20 21 3d 20 52 2e 66 69 64 0a 09 09 3b fid != R.fid...;
0ce0: 0a 09 20 20 20 20 7d 0a 0a 09 23 20 46 69 6e 64 .. }...# Find
0cf0: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 all revisions w
0d00: 69 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72 ith a branch par
0d10: 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f 73 65 ent symbol whose
0d20: 20 70 61 72 65 6e 74 0a 09 23 20 64 69 73 61 67 parent..# disag
0d30: 72 65 65 73 20 61 62 6f 75 74 20 74 68 65 20 66 rees about the f
0d40: 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 ile they belong
0d50: 74 6f 2e 0a 09 43 68 65 63 6b 52 65 76 20 5c 0a to...CheckRev \.
0d60: 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 . {Revisions
0d70: 61 6e 64 20 74 68 65 69 72 20 62 72 61 6e 63 68 and their branch
0d80: 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 children have t
0d90: 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 o be in the same
0da0: 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 61 file} \.. {a
0db0: 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 t the beginning
0dc0: 6f 66 20 69 74 73 20 62 72 61 6e 63 68 20 61 6e of its branch an
0dd0: 64 20 69 74 73 20 70 61 72 65 6e 74 20 64 69 73 d its parent dis
0de0: 61 67 72 65 65 20 61 62 6f 75 74 20 74 68 65 20 agree about the
0df0: 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 owning file} {..
0e00: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 .SELECT F.name,
0e10: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 R.rev...FROM rev
0e20: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f ision R, revisio
0e30: 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 n P, file F...WH
0e40: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 ERE R.fid = F.fi
0e50: 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 d...AND R.bpar
0e60: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a ent IS NOT NULL.
0e70: 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 ..AND R.parent
0e80: 20 3d 20 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 = P.rid...AND
0e90: 20 52 2e 66 69 64 20 21 3d 20 50 2e 66 69 64 0a R.fid != P.fid.
0ea0: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 ..;.. }..# Fi
0eb0: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 nd all revisions
0ec0: 20 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 with a non-NTDB
0ed0: 20 63 68 69 6c 64 20 77 68 69 63 68 20 64 69 73 child which dis
0ee0: 61 67 72 65 65 73 0a 09 23 20 61 62 6f 75 74 20 agrees..# about
0ef0: 74 68 65 20 66 69 6c 65 20 74 68 65 79 20 62 65 the file they be
0f00: 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 52 long to...CheckR
0f10: 65 76 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 ev \.. {Revis
0f20: 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 6e ions and their n
0f30: 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 72 65 6e on-NTDB children
0f40: 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 have to be in t
0f50: 68 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a he same file} \.
0f60: 09 20 20 20 20 7b 64 69 73 61 67 72 65 65 73 20 . {disagrees
0f70: 77 69 74 68 20 69 74 73 20 6e 6f 6e 2d 4e 54 44 with its non-NTD
0f80: 42 20 63 68 69 6c 64 20 61 62 6f 75 74 20 74 68 B child about th
0f90: 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b e owning file} {
0fa0: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 ...SELECT F.name
0fb0: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 , R.rev...FROM r
0fc0: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 evision R, revis
0fd0: 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 ion C, file F...
0fe0: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e WHERE R.fid = F.
0ff0: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 fid...AND R.db
1000: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c child IS NOT NUL
1010: 4c 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 63 68 L...AND R.dbch
1020: 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e ild = C.rid...AN
1030: 44 20 20 20 43 2e 66 69 64 20 21 3d 20 52 2e 66 D C.fid != R.f
1040: 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 id...;.. }..#
1050: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 Find all revisi
1060: 6f 6e 73 20 77 68 69 63 68 20 68 61 76 65 20 61 ons which have a
1070: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2c 20 primary child,
1080: 62 75 74 20 74 68 65 20 63 68 69 6c 64 0a 09 23 but the child..#
1090: 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 does not have t
10a0: 68 65 6d 20 61 73 20 70 61 72 65 6e 74 2e 0a 09 hem as parent...
10b0: 43 68 65 63 6b 52 65 76 20 5c 0a 09 20 20 20 20 CheckRev \..
10c0: 7b 52 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 {Revisions have
10d0: 74 6f 20 62 65 20 70 61 72 65 6e 74 73 20 6f 66 to be parents of
10e0: 20 74 68 65 69 72 20 70 72 69 6d 61 72 79 20 63 their primary c
10f0: 68 69 6c 64 72 65 6e 7d 20 5c 0a 09 20 20 20 20 hildren} \..
1100: 7b 69 73 20 6e 6f 74 20 74 68 65 20 70 61 72 65 {is not the pare
1110: 6e 74 20 6f 66 20 69 74 73 20 70 72 69 6d 61 72 nt of its primar
1120: 79 20 63 68 69 6c 64 7d 20 7b 0a 09 09 53 45 4c y child} {...SEL
1130: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 ECT F.name, R.re
1140: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f v...FROM revisio
1150: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c n R, revision C,
1160: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 file F...WHERE
1170: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 R.fid = F.fid...
1180: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49 53 AND R.child IS
1190: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 NOT NULL...AND
11a0: 20 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 R.child = C.ri
11b0: 64 0a 09 09 41 4e 44 20 20 20 43 2e 70 61 72 65 d...AND C.pare
11c0: 6e 74 20 21 3d 20 52 2e 72 69 64 0a 09 09 3b 0a nt != R.rid...;.
11d0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 . }..# Find a
11e0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 ll revisions whi
11f0: 63 68 20 68 61 76 65 20 61 20 70 72 69 6d 72 61 ch have a primra
1200: 72 79 20 63 68 69 6c 64 2c 20 62 75 74 20 74 68 ry child, but th
1210: 65 0a 09 23 20 63 68 69 6c 64 20 68 61 73 20 61 e..# child has a
1220: 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 branch parent s
1230: 79 6d 62 6f 6c 20 6d 61 6b 69 6e 67 20 74 68 65 ymbol making the
1240: 6d 20 62 72 61 63 68 20 73 74 61 72 74 65 72 73 m brach starters
1250: 2e 0a 09 43 68 65 63 6b 52 65 76 20 5c 0a 09 20 ...CheckRev \..
1260: 20 20 20 7b 50 72 69 6d 61 72 79 20 63 68 69 6c {Primary chil
1270: 64 72 65 6e 20 6f 66 20 72 65 76 69 73 69 6f 6e dren of revision
1280: 73 20 6d 75 73 74 20 6e 6f 74 20 73 74 61 72 74 s must not start
1290: 20 62 72 61 6e 63 68 65 73 7d 20 5c 0a 09 20 20 branches} \..
12a0: 20 20 7b 69 73 20 70 61 72 65 6e 74 20 6f 66 20 {is parent of
12b0: 61 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 a primary child
12c0: 77 68 69 63 68 20 69 73 20 74 68 65 20 62 65 67 which is the beg
12d0: 69 6e 6e 69 6e 67 20 6f 66 20 61 20 62 72 61 6e inning of a bran
12e0: 63 68 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 ch} {...SELECT F
12f0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 .name, R.rev...F
1300: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 ROM revision R,
1310: 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 revision C, file
1320: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 F...WHERE R.fid
1330: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 = F.fid...AND
1340: 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 R.child IS NOT
1350: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 63 NULL...AND R.c
1360: 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 hild = C.rid...A
1370: 4e 44 20 20 20 43 2e 62 70 61 72 65 6e 74 20 49 ND C.bparent I
1380: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 3b 0a 09 S NOT NULL...;..
1390: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c }..# Find al
13a0: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 l revisions with
13b0: 6f 75 74 20 62 72 61 6e 63 68 20 70 61 72 65 6e out branch paren
13c0: 74 20 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 68 t symbol which h
13d0: 61 76 65 20 61 0a 09 23 20 70 61 72 65 6e 74 2c ave a..# parent,
13e0: 20 62 75 74 20 74 68 65 20 70 61 72 65 6e 74 20 but the parent
13f0: 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 68 does not have th
1400: 65 6d 20 61 73 20 70 72 69 6d 61 72 79 20 63 68 em as primary ch
1410: 69 6c 64 2e 0a 09 43 68 65 63 6b 52 65 76 20 5c ild...CheckRev \
1420: 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 .. {Revisions
1430: 20 68 61 76 65 20 74 6f 20 62 65 20 70 72 69 6d have to be prim
1440: 61 72 79 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 ary children of
1450: 74 68 65 69 72 20 70 61 72 65 6e 74 73 2c 20 69 their parents, i
1460: 66 20 61 6e 79 7d 20 5c 0a 09 20 20 20 20 7b 69 f any} \.. {i
1470: 73 20 6e 6f 74 20 74 68 65 20 63 68 69 6c 64 20 s not the child
1480: 6f 66 20 69 74 73 20 70 61 72 65 6e 74 7d 20 7b of its parent} {
1490: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 ...SELECT F.name
14a0: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 , R.rev...FROM r
14b0: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 evision R, revis
14c0: 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 ion P, file F...
14d0: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e WHERE R.fid = F.
14e0: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 fid...AND R.bp
14f0: 61 72 65 6e 74 20 49 53 20 4e 55 4c 4c 0a 09 09 arent IS NULL...
1500: 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 49 AND R.parent I
1510: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 S NOT NULL...AND
1520: 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e R.parent = P.
1530: 72 69 64 0a 09 09 41 4e 44 20 20 20 50 2e 63 68 rid...AND P.ch
1540: 69 6c 64 20 21 3d 20 52 2e 72 69 64 0a 09 09 3b ild != R.rid...;
1550: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 .. }..# Find
1560: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 all revisions wi
1570: 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72 65 th a branch pare
1580: 6e 74 20 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 nt symbol which
1590: 64 6f 20 6e 6f 74 0a 09 23 20 68 61 76 65 20 61 do not..# have a
15a0: 20 70 61 72 65 6e 74 2e 0a 09 43 68 65 63 6b 52 parent...CheckR
15b0: 65 76 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63 ev \.. {Branc
15c0: 68 20 73 74 61 72 74 69 6e 67 20 72 65 76 69 73 h starting revis
15d0: 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 68 61 76 ions have to hav
15e0: 65 20 61 20 70 61 72 65 6e 74 7d 20 5c 0a 09 20 e a parent} \..
15f0: 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e {at the begin
1600: 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e ning of its bran
1610: 63 68 20 68 61 73 20 6e 6f 20 70 61 72 65 6e 74 ch has no parent
1620: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e } {...SELECT F.n
1630: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f ame, R.rev...FRO
1640: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 M revision R, fi
1650: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 le F...WHERE R.f
1660: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 id = F.fid...AND
1670: 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20 R.bparent IS
1680: 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 NOT NULL...AND
1690: 20 52 2e 70 61 72 65 6e 74 20 49 53 20 4e 55 4c R.parent IS NUL
16a0: 4c 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 L...;.. }..#
16b0: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f Find all revisio
16c0: 6e 73 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 ns with a branch
16d0: 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 parent symbol w
16e0: 68 6f 73 65 20 70 61 72 65 6e 74 0a 09 23 20 68 hose parent..# h
16f0: 61 73 20 74 68 65 6d 20 61 73 20 70 72 69 6d 61 as them as prima
1700: 72 79 20 63 68 69 6c 64 2e 0a 09 43 68 65 63 6b ry child...Check
1710: 52 65 76 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e Rev \.. {Bran
1720: 63 68 20 73 74 61 72 74 69 6e 67 20 72 65 76 69 ch starting revi
1730: 73 69 6f 6e 73 20 6d 75 73 74 20 6e 6f 74 20 62 sions must not b
1740: 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72 e primary childr
1750: 65 6e 20 6f 66 20 74 68 65 69 72 20 70 61 72 65 en of their pare
1760: 6e 74 73 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 nts} \.. {at
1770: 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 the beginning of
1780: 20 69 74 73 20 62 72 61 6e 63 68 20 69 73 20 74 its branch is t
1790: 68 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 he primary child
17a0: 20 6f 66 20 69 74 73 20 70 61 72 65 6e 74 7d 20 of its parent}
17b0: 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d {...SELECT F.nam
17c0: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 e, R.rev...FROM
17d0: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 revision R, revi
17e0: 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 sion P, file F..
17f0: 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 .WHERE R.fid = F
1800: 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 .fid...AND R.b
1810: 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 parent IS NOT NU
1820: 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72 LL...AND R.par
1830: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a ent IS NOT NULL.
1840: 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 ..AND R.parent
1850: 20 3d 20 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 = P.rid...AND
1860: 20 50 2e 63 68 69 6c 64 20 3d 20 52 2e 72 69 64 P.child = R.rid
1870: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 ...;.. }..# F
1880: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e ind all revision
1890: 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 s with a non-NTD
18a0: 42 20 63 68 69 6c 64 20 77 68 69 63 68 20 61 72 B child which ar
18b0: 65 20 6e 6f 74 20 6f 6e 0a 09 23 20 74 68 65 20 e not on..# the
18c0: 4e 54 44 42 2e 0a 09 43 68 65 63 6b 52 65 76 20 NTDB...CheckRev
18d0: 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 74 6f 20 \.. {NTDB to
18e0: 74 72 75 6e 6b 20 74 72 61 6e 73 69 74 69 6f 6e trunk transition
18f0: 20 68 61 73 20 74 6f 20 62 65 67 69 6e 20 6f 6e has to begin on
1900: 20 4e 54 44 42 7d 20 5c 0a 09 20 20 20 20 7b 68 NTDB} \.. {h
1910: 61 73 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 as a non-NTDB ch
1920: 69 6c 64 2c 20 79 65 74 20 69 73 20 6e 6f 74 20 ild, yet is not
1930: 6f 6e 20 74 68 65 20 4e 54 44 42 7d 20 7b 0a 09 on the NTDB} {..
1940: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 .SELECT F.name,
1950: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 R.rev...FROM rev
1960: 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a ision R, file F.
1970: 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 ..WHERE R.fid =
1980: 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e F.fid...AND R.
1990: 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e dbchild IS NOT N
19a0: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 4e 4f 54 20 ULL...AND NOT
19b0: 52 2e 69 73 64 65 66 61 75 6c 74 0a 09 09 3b 0a R.isdefault...;.
19c0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 . }..# Find a
19d0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 ll revisions wit
19e0: 68 20 61 20 4e 54 44 42 20 70 61 72 65 6e 74 20 h a NTDB parent
19f0: 77 68 69 63 68 20 61 72 65 20 6f 6e 20 74 68 65 which are on the
1a00: 20 4e 54 44 42 2e 0a 09 43 68 65 63 6b 52 65 76 NTDB...CheckRev
1a10: 20 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 74 6f \.. {NTDB to
1a20: 20 74 72 75 6e 6b 20 74 72 61 6e 73 69 74 69 6f trunk transitio
1a30: 6e 20 68 61 73 20 74 6f 20 65 6e 64 20 6f 6e 20 n has to end on
1a40: 6e 6f 6e 2d 4e 54 44 42 7d 20 5c 0a 09 20 20 20 non-NTDB} \..
1a50: 20 7b 68 61 73 20 61 20 4e 54 44 42 20 70 61 72 {has a NTDB par
1a60: 65 6e 74 2c 20 79 65 74 20 69 73 20 6f 6e 20 74 ent, yet is on t
1a70: 68 65 20 4e 54 44 42 7d 20 7b 0a 09 09 53 45 4c he NTDB} {...SEL
1a80: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 ECT F.name, R.re
1a90: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f v...FROM revisio
1aa0: 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 n R, file F...WH
1ab0: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 ERE R.fid = F.fi
1ac0: 64 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 70 61 d...AND R.dbpa
1ad0: 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c rent IS NOT NULL
1ae0: 0a 09 09 41 4e 44 20 20 20 52 2e 69 73 64 65 66 ...AND R.isdef
1af0: 61 75 6c 74 0a 09 09 3b 0a 09 20 20 20 20 7d 0a ault...;.. }.
1b00: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 .# Find all revi
1b10: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 63 68 69 sions with a chi
1b20: 6c 64 20 77 68 69 63 68 20 64 69 73 61 67 72 65 ld which disagre
1b30: 65 73 20 61 62 6f 75 74 20 74 68 65 0a 09 23 20 es about the..#
1b40: 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d line of developm
1b50: 65 6e 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 ent they belong
1b60: 74 6f 2e 0a 09 43 68 65 63 6b 52 65 76 20 5c 0a to...CheckRev \.
1b70: 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 . {Revisions
1b80: 61 6e 64 20 74 68 65 69 72 20 70 72 69 6d 61 72 and their primar
1b90: 79 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20 y children have
1ba0: 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d to be in the sam
1bb0: 65 20 4c 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 61 e LOD} \.. {a
1bc0: 6e 64 20 69 74 73 20 70 72 69 6d 61 72 79 20 63 nd its primary c
1bd0: 68 69 6c 64 20 64 69 73 61 67 72 65 65 20 61 62 hild disagree ab
1be0: 6f 75 74 20 74 68 65 69 72 20 4c 4f 44 7d 20 7b out their LOD} {
1bf0: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 ...SELECT F.name
1c00: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 , R.rev...FROM r
1c10: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 evision R, revis
1c20: 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 ion C, file F...
1c30: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e WHERE R.fid = F.
1c40: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 fid...AND R.ch
1c50: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a ild IS NOT NULL.
1c60: 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 ..AND R.child
1c70: 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 = C.rid...AND
1c80: 43 2e 6c 6f 64 20 21 3d 20 52 2e 6c 6f 64 0a 09 C.lod != R.lod..
1c90: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e .;.. }..# Fin
1ca0: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 d all revisions
1cb0: 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 with a non-NTDB
1cc0: 63 68 69 6c 64 20 77 68 69 63 68 20 61 67 72 65 child which agre
1cd0: 65 73 20 61 62 6f 75 74 0a 09 23 20 74 68 65 20 es about..# the
1ce0: 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d line of developm
1cf0: 65 6e 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 ent they belong
1d00: 74 6f 2e 0a 09 43 68 65 63 6b 52 65 76 20 5c 0a to...CheckRev \.
1d10: 09 20 20 20 20 7b 4e 54 44 42 20 61 6e 64 20 74 . {NTDB and t
1d20: 72 75 6e 6b 20 72 65 76 69 73 69 6f 6e 73 20 68 runk revisions h
1d30: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 64 69 66 ave to be in dif
1d40: 66 65 72 65 6e 74 20 4c 4f 44 73 7d 20 5c 0a 09 ferent LODs} \..
1d50: 20 20 20 20 7b 6f 6e 20 4e 54 44 42 20 61 6e 64 {on NTDB and
1d60: 20 69 74 73 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 its non-NTDB ch
1d70: 69 6c 64 20 77 72 6f 6e 67 6c 79 20 61 67 72 65 ild wrongly agre
1d80: 65 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c 4f e about their LO
1d90: 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e D} {...SELECT F.
1da0: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 name, R.rev...FR
1db0: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 OM revision R, r
1dc0: 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 evision C, file
1dd0: 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 F...WHERE R.fid
1de0: 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 = F.fid...AND
1df0: 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 R.dbchild IS NOT
1e00: 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e NULL...AND R.
1e10: 64 62 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a dbchild = C.rid.
1e20: 09 09 41 4e 44 20 20 20 43 2e 6c 6f 64 20 3d 20 ..AND C.lod =
1e30: 52 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20 20 20 7d R.lod...;.. }
1e40: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 ..# Find all rev
1e50: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62 72 isions with a br
1e60: 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 anch parent symb
1e70: 6f 6c 20 77 68 69 63 68 20 69 73 20 6e 6f 74 0a ol which is not.
1e80: 09 23 20 74 68 65 69 72 20 4c 4f 44 2e 0a 09 43 .# their LOD...C
1e90: 68 65 63 6b 52 65 76 20 5c 0a 09 20 20 20 20 7b heckRev \.. {
1ea0: 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67 20 Branch starting
1eb0: 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 revisions have t
1ec0: 6f 20 68 61 76 65 20 74 68 65 69 72 20 4c 4f 44 o have their LOD
1ed0: 20 61 73 20 62 72 61 6e 63 68 20 70 61 72 65 6e as branch paren
1ee0: 74 20 73 79 6d 62 6f 6c 7d 20 5c 0a 09 20 20 20 t symbol} \..
1ef0: 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 {at the beginni
1f00: 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68 ng of its branch
1f10: 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 does not have t
1f20: 68 65 20 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c he branch symbol
1f30: 20 61 73 20 69 74 73 20 4c 4f 44 7d 20 7b 0a 09 as its LOD} {..
1f40: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 .SELECT F.name,
1f50: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 R.rev...FROM rev
1f60: 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a ision R, file F.
1f70: 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 ..WHERE R.fid =
1f80: 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e F.fid...AND R.
1f90: 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e bparent IS NOT N
1fa0: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 6c 6f ULL...AND R.lo
1fb0: 64 20 21 3d 20 52 2e 62 70 61 72 65 6e 74 0a 09 d != R.bparent..
1fc0: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e .;.. }..# Fin
1fd0: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 d all revisions
1fe0: 77 69 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 with a branch pa
1ff0: 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f 73 rent symbol whos
2000: 65 20 70 61 72 65 6e 74 0a 09 23 20 69 73 20 69 e parent..# is i
2010: 6e 20 74 68 65 20 73 61 6d 65 20 6c 69 6e 65 20 n the same line
2020: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 2e 0a of development..
2030: 09 43 68 65 63 6b 52 65 76 20 5c 0a 09 20 20 20 .CheckRev \..
2040: 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 {Revisions and
2050: 74 68 65 69 72 20 62 72 61 6e 63 68 20 63 68 69 their branch chi
2060: 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65 ldren have to be
2070: 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20 4c 4f in different LO
2080: 44 73 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 Ds} \.. {at t
2090: 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 he beginning of
20a0: 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64 20 69 its branch and i
20b0: 74 73 20 70 61 72 65 6e 74 20 77 72 6f 6e 67 6c ts parent wrongl
20c0: 79 20 61 67 72 65 65 20 61 62 6f 75 74 20 74 68 y agree about th
20d0: 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c eir LOD} {...SEL
20e0: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 ECT F.name, R.re
20f0: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f v...FROM revisio
2100: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 50 2c n R, revision P,
2110: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 file F...WHERE
2120: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 R.fid = F.fid...
2130: 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e 74 20 AND R.bparent
2140: 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e IS NOT NULL...AN
2150: 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 D R.parent = P
2160: 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 6c .rid...AND R.l
2170: 6f 64 20 3d 20 50 2e 6c 6f 64 0a 09 09 3b 0a 09 od = P.lod...;..
2180: 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 }..return.
2190: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 4d 65 }.. proc Me
21a0: 74 61 20 7b 7d 20 7b 0a 09 23 20 54 68 69 73 20 ta {} {..# This
21b0: 63 6f 64 65 20 70 65 72 66 6f 72 6d 73 20 61 20 code performs a
21c0: 6e 75 6d 62 65 72 20 6f 66 20 70 61 72 61 6e 6f number of parano
21d0: 69 64 20 63 68 65 63 6b 73 20 6f 66 20 74 68 65 id checks of the
21e0: 0a 09 23 20 64 61 74 61 62 61 73 65 2c 20 73 65 ..# database, se
21f0: 61 72 63 68 69 6e 67 20 66 6f 72 20 69 6e 63 6f arching for inco
2200: 6e 73 69 73 74 65 6e 74 20 63 72 6f 73 73 2d 72 nsistent cross-r
2210: 65 66 65 72 65 6e 63 65 73 2e 0a 0a 09 75 70 76 eferences....upv
2220: 61 72 20 31 20 6e 20 6e 20 3b 20 23 20 43 6f 75 ar 1 n n ; # Cou
2230: 6e 74 65 72 20 66 6f 72 20 74 68 65 20 63 68 65 nter for the che
2240: 63 6b 73 20 28 77 65 20 70 72 69 6e 74 20 61 6e cks (we print an
2250: 20 69 64 20 62 65 66 6f 72 65 0a 09 09 20 20 20 id before...
2260: 20 20 20 23 20 74 68 65 20 6d 61 69 6e 20 6c 61 # the main la
2270: 62 65 6c 29 2e 0a 0a 09 23 20 46 69 6e 64 20 61 bel)....# Find a
2280: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 ll revisions whi
2290: 63 68 20 64 69 73 67 72 65 65 20 77 69 74 68 20 ch disgree with
22a0: 74 68 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 their meta data
22b0: 61 62 6f 75 74 0a 09 23 20 74 68 65 20 62 72 61 about..# the bra
22c0: 6e 63 68 2f 6c 69 6e 65 20 6f 66 20 64 65 76 65 nch/line of deve
22d0: 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20 62 65 6c lopment they bel
22e0: 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 52 65 ong to...CheckRe
22f0: 76 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 v \.. {Revisi
2300: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 6d 65 ons and their me
2310: 74 61 20 64 61 74 61 20 68 61 76 65 20 74 6f 20 ta data have to
2320: 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c be in the same L
2330: 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 OD} \.. {disa
2340: 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6d grees with its m
2350: 65 74 61 20 64 61 74 61 20 61 62 6f 75 74 20 6f eta data about o
2360: 77 6e 69 6e 67 20 4c 4f 44 7d 20 7b 0a 09 09 53 wning LOD} {...S
2370: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e ELECT F.name, R.
2380: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 rev...FROM revis
2390: 69 6f 6e 20 52 2c 20 6d 65 74 61 20 4d 2c 20 66 ion R, meta M, f
23a0: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e ile F...WHERE R.
23b0: 6d 69 64 20 3d 20 4d 2e 6d 69 64 0a 09 09 41 4e mid = M.mid...AN
23c0: 44 20 20 20 52 2e 6c 6f 64 20 21 3d 20 4d 2e 62 D R.lod != M.b
23d0: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 66 69 64 id...AND R.fid
23e0: 20 3d 20 46 2e 66 69 64 0a 09 09 3b 0a 09 20 20 = F.fid...;..
23f0: 20 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 }..return.
2400: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 52 65 76 69 }.. proc Revi
2410: 73 69 6f 6e 43 68 61 6e 67 65 73 65 74 73 20 7b sionChangesets {
2420: 7d 20 7b 0a 09 23 20 54 68 69 73 20 63 6f 64 65 } {..# This code
2430: 20 70 65 72 66 6f 72 6d 73 20 61 20 6e 75 6d 62 performs a numb
2440: 65 72 20 6f 66 20 70 61 72 61 6e 6f 69 64 20 63 er of paranoid c
2450: 68 65 63 6b 73 20 6f 66 20 74 68 65 0a 09 23 20 hecks of the..#
2460: 64 61 74 61 62 61 73 65 2c 20 73 65 61 72 63 68 database, search
2470: 69 6e 67 20 66 6f 72 20 69 6e 63 6f 6e 73 69 73 ing for inconsis
2480: 74 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2f 72 tent changeset/r
2490: 65 76 69 73 69 6f 6e 0a 09 23 20 69 6e 66 6f 72 evision..# infor
24a0: 6d 61 74 69 6f 6e 2e 0a 0a 09 75 70 76 61 72 20 mation....upvar
24b0: 31 20 6e 20 6e 20 3b 20 23 20 43 6f 75 6e 74 65 1 n n ; # Counte
24c0: 72 20 66 6f 72 20 74 68 65 20 63 68 65 63 6b 73 r for the checks
24d0: 20 28 77 65 20 70 72 69 6e 74 20 61 6e 20 69 64 (we print an id
24e0: 20 62 65 66 6f 72 65 0a 09 09 20 20 20 20 20 20 before...
24f0: 23 20 74 68 65 20 6d 61 69 6e 20 6c 61 62 65 6c # the main label
2500: 29 2e 0a 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 )....# Find all
2510: 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 revisions which
2520: 61 72 65 20 6e 6f 74 20 75 73 65 64 20 62 79 20 are not used by
2530: 61 74 20 6c 65 61 73 74 20 6f 6e 65 0a 09 23 20 at least one..#
2540: 63 68 61 6e 67 65 73 65 74 2e 0a 09 43 68 65 63 changeset...Chec
2550: 6b 52 65 76 20 5c 0a 09 20 20 20 20 7b 41 6c 6c kRev \.. {All
2560: 20 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 revisions have
2570: 74 6f 20 62 65 20 75 73 65 64 20 62 79 20 6c 65 to be used by le
2580: 61 73 74 20 6f 6e 65 20 63 68 61 6e 67 65 73 65 ast one changese
2590: 74 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20 6e 6f t} \.. {is no
25a0: 74 20 75 73 65 64 20 62 79 20 61 20 63 68 61 6e t used by a chan
25b0: 67 65 73 65 74 7d 20 7b 0a 09 09 2d 2d 20 55 6e geset} {...-- Un
25c0: 75 73 65 64 20 72 65 76 69 73 69 6f 6e 73 20 3d used revisions =
25d0: 20 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73 0a 09 All revisions..
25e0: 09 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 .--
25f0: 20 20 20 20 20 2d 20 72 65 76 69 73 69 6f 6e 73 - revisions
2600: 20 75 73 65 64 20 62 79 20 72 65 76 69 73 69 6f used by revisio
2610: 6e 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 09 09 n changesets....
2620: 2d 2d 0a 09 09 2d 2d 20 42 6f 74 68 20 73 65 74 --...-- Both set
2630: 73 20 63 61 6e 20 62 65 20 63 6f 6d 70 75 74 65 s can be compute
2640: 64 20 65 61 73 69 6c 79 2c 20 61 6e 64 20 73 75 d easily, and su
2650: 62 74 72 61 63 74 65 64 0a 20 20 20 20 20 20 20 btracted.
2660: 20 20 20 20 20 20 20 20 20 2d 2d 20 66 72 6f 6d -- from
2670: 20 65 61 63 68 20 6f 74 68 65 72 2e 20 54 68 65 each other. The
2680: 6e 20 77 65 20 63 61 6e 20 67 65 74 20 74 68 65 n we can get the
2690: 20 61 73 73 6f 63 69 61 74 65 64 0a 20 20 20 20 associated.
26a0: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 66 -- f
26b0: 69 6c 65 20 28 6e 61 6d 65 29 20 66 6f 72 20 64 ile (name) for d
26c0: 69 73 70 6c 61 79 2e 0a 0a 09 09 53 45 4c 45 43 isplay.....SELEC
26d0: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a T F.name, R.rev.
26e0: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 ..FROM revision
26f0: 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 R, file F...WHER
2700: 45 20 52 2e 72 69 64 20 49 4e 20 28 53 45 4c 45 E R.rid IN (SELE
2710: 43 54 20 72 69 64 0a 09 09 09 09 46 52 4f 4d 20 CT rid.....FROM
2720: 72 65 76 69 73 69 6f 6e 20 20 20 20 20 20 20 20 revision
2730: 20 20 20 20 20 20 20 20 2d 2d 20 41 6c 6c 20 72 -- All r
2740: 65 76 69 73 69 6f 6e 73 0a 09 09 09 09 45 58 43 evisions.....EXC
2750: 45 50 54 20 20 20 20 20 20 20 20 20 20 20 20 20 EPT
2760: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 73 75 62 -- sub
2770: 74 72 61 63 74 0a 09 09 09 09 53 45 4c 45 43 54 tract.....SELECT
2780: 20 43 52 2e 72 69 64 0a 09 09 09 09 46 52 4f 4d CR.rid.....FROM
2790: 20 63 73 72 65 76 69 73 69 6f 6e 20 43 52 2c 20 csrevision CR,
27a0: 63 68 61 6e 67 65 73 65 74 20 43 20 20 2d 2d 20 changeset C --
27b0: 72 65 76 69 73 69 6f 6e 73 20 75 73 65 64 0a 09 revisions used..
27c0: 09 09 09 57 48 45 52 45 20 43 2e 63 69 64 20 3d ...WHERE C.cid =
27d0: 20 43 52 2e 63 69 64 20 20 20 20 20 20 20 20 20 CR.cid
27e0: 2d 2d 20 62 79 20 61 6e 79 20 72 65 76 69 73 69 -- by any revisi
27f0: 6f 6e 0a 09 09 09 09 41 4e 44 20 43 2e 74 79 70 on.....AND C.typ
2800: 65 20 3d 20 30 29 20 20 20 20 20 20 20 20 20 20 e = 0)
2810: 20 20 20 20 2d 2d 20 63 68 61 6e 67 65 73 65 74 -- changeset
2820: 0a 09 09 41 4e 44 20 20 20 52 2e 66 69 64 20 3d ...AND R.fid =
2830: 20 46 2e 66 69 64 20 20 20 20 20 20 20 20 20 20 F.fid
2840: 20 20 20 20 2d 2d 20 67 65 74 20 66 69 6c 65 20 -- get file
2850: 6f 66 20 75 6e 75 73 65 64 20 72 65 76 69 73 69 of unused revisi
2860: 6f 6e 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e on.. }..# Fin
2870: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 d all revisions
2880: 77 68 69 63 68 20 61 72 65 20 75 73 65 64 20 62 which are used b
2890: 79 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 0a y more than one.
28a0: 09 23 20 63 68 61 6e 67 65 73 65 74 2e 0a 09 43 .# changeset...C
28b0: 68 65 63 6b 52 65 76 20 5c 0a 09 20 20 20 20 7b heckRev \.. {
28c0: 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 68 61 All revisions ha
28d0: 76 65 20 74 6f 20 62 65 20 75 73 65 64 20 62 79 ve to be used by
28e0: 20 61 74 20 6d 6f 73 74 20 6f 6e 65 20 63 68 61 at most one cha
28f0: 6e 67 65 73 65 74 7d 20 5c 0a 09 20 20 20 20 7b ngeset} \.. {
2900: 69 73 20 75 73 65 64 20 62 79 20 6d 75 6c 74 69 is used by multi
2910: 70 6c 65 20 63 68 61 6e 67 65 73 65 74 73 7d 20 ple changesets}
2920: 7b 0a 09 09 2d 2d 20 50 72 69 6e 63 69 70 6c 65 {...-- Principle
2930: 20 6f 66 20 6f 70 65 72 61 74 69 6f 6e 3a 20 47 of operation: G
2940: 65 74 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 2f et all revision/
2950: 63 68 61 6e 67 65 73 65 74 0a 20 20 20 20 20 20 changeset.
2960: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 70 61 69 -- pai
2970: 72 73 20 66 6f 72 20 61 6c 6c 20 72 65 76 69 73 rs for all revis
2980: 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 2c 20 ion changesets,
2990: 67 72 6f 75 70 20 62 79 0a 20 20 20 20 20 20 20 group by.
29a0: 20 20 20 20 20 20 20 20 20 2d 2d 20 72 65 76 69 -- revi
29b0: 73 69 6f 6e 20 74 6f 20 61 67 67 72 65 67 61 74 sion to aggregat
29c0: 65 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2c e the changeset,
29d0: 20 63 6f 75 6e 74 69 6e 67 0a 20 20 20 20 20 20 counting.
29e0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 74 68 65 -- the
29f0: 6d 2e 20 46 72 6f 6d 20 74 68 65 20 72 65 73 75 m. From the resu
2a00: 6c 74 69 6e 67 20 72 65 76 69 73 69 6f 6e 2f 63 lting revision/c
2a10: 6f 75 6e 74 20 74 61 62 6c 65 0a 20 20 20 20 20 ount table.
2a20: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 73 65 -- se
2a30: 6c 65 63 74 20 74 68 6f 73 65 20 77 69 74 68 20 lect those with
2a40: 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20 75 73 more than one us
2a50: 65 72 2c 20 61 6e 64 20 67 65 74 20 74 68 65 69 er, and get thei
2a60: 72 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 r.
2a70: 20 20 2d 2d 20 61 73 73 6f 63 69 61 74 65 64 20 -- associated
2a80: 66 69 6c 65 20 28 6e 61 6d 65 29 20 66 6f 72 20 file (name) for
2a90: 64 69 73 70 6c 61 79 2e 0a 0a 09 09 53 45 4c 45 display.....SELE
2aa0: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 CT F.name, R.rev
2ab0: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e ...FROM revision
2ac0: 20 52 2c 20 66 69 6c 65 20 46 2c 0a 09 09 20 20 R, file F,...
2ad0: 20 20 20 28 53 45 4c 45 43 54 20 43 52 2e 72 69 (SELECT CR.ri
2ae0: 64 20 41 53 20 72 69 64 2c 20 63 6f 75 6e 74 28 d AS rid, count(
2af0: 43 52 2e 63 69 64 29 20 41 53 20 63 6f 75 6e 74 CR.cid) AS count
2b00: 0a 09 09 20 20 20 20 20 20 46 52 4f 4d 20 63 73 ... FROM cs
2b10: 72 65 76 69 73 69 6f 6e 20 43 52 2c 20 63 68 61 revision CR, cha
2b20: 6e 67 65 73 65 74 20 43 0a 09 09 20 20 20 20 20 ngeset C...
2b30: 20 57 48 45 52 45 20 43 2e 74 79 70 65 20 3d 20 WHERE C.type =
2b40: 30 0a 09 09 20 20 20 20 20 20 41 4e 44 20 20 20 0... AND
2b50: 43 2e 63 69 64 20 3d 20 43 52 2e 63 69 64 0a 09 C.cid = CR.cid..
2b60: 09 20 20 20 20 20 20 47 52 4f 55 50 20 42 59 20 . GROUP BY
2b70: 43 52 2e 72 69 64 29 20 41 53 20 55 0a 09 09 57 CR.rid) AS U...W
2b80: 48 45 52 45 20 55 2e 63 6f 75 6e 74 20 3e 20 31 HERE U.count > 1
2b90: 0a 09 09 41 4e 44 20 52 2e 72 69 64 20 3d 20 55 ...AND R.rid = U
2ba0: 2e 72 69 64 0a 09 09 41 4e 44 20 52 2e 66 69 64 .rid...AND R.fid
2bb0: 20 3d 20 46 2e 66 69 64 0a 09 20 20 20 20 7d 0a = F.fid.. }.
2bc0: 09 23 20 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73 .# All revisions
2bd0: 20 68 61 76 65 20 74 6f 20 72 65 66 65 72 20 74 have to refer t
2be0: 6f 20 74 68 65 20 73 61 6d 65 20 6d 65 74 61 20 o the same meta
2bf0: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 73 0a 09 information as..
2c00: 23 20 74 68 65 69 72 20 63 68 61 6e 67 65 73 65 # their changese
2c10: 74 2e 0a 09 43 68 65 63 6b 52 65 76 43 53 20 5c t...CheckRevCS \
2c20: 0a 09 20 20 20 20 7b 41 6c 6c 20 72 65 76 69 73 .. {All revis
2c30: 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 61 67 72 ions have to agr
2c40: 65 65 20 77 69 74 68 20 74 68 65 69 72 20 63 68 ee with their ch
2c50: 61 6e 67 65 73 65 74 20 61 62 6f 75 74 20 74 68 angeset about th
2c60: 65 20 75 73 65 64 20 6d 65 74 61 20 69 6e 66 6f e used meta info
2c70: 72 6d 61 74 69 6f 6e 7d 20 5c 0a 09 20 20 20 20 rmation} \..
2c80: 7b 64 69 73 61 67 72 65 65 73 20 77 69 74 68 20 {disagrees with
2c90: 69 74 73 20 63 68 61 6e 67 65 73 65 74 20 40 20 its changeset @
2ca0: 61 62 6f 75 74 20 74 68 65 20 6d 65 74 61 20 69 about the meta i
2cb0: 6e 66 6f 72 6d 61 74 69 6f 6e 7d 20 7b 0a 09 09 nformation} {...
2cc0: 53 45 4c 45 43 54 20 43 54 2e 6e 61 6d 65 2c 20 SELECT CT.name,
2cd0: 43 2e 63 69 64 2c 20 46 2e 6e 61 6d 65 2c 20 52 C.cid, F.name, R
2ce0: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 63 68 61 6e .rev...FROM chan
2cf0: 67 65 73 65 74 20 43 2c 20 63 73 74 79 70 65 20 geset C, cstype
2d00: 43 54 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 CT, revision R,
2d10: 66 69 6c 65 20 46 2c 20 63 73 72 65 76 69 73 69 file F, csrevisi
2d20: 6f 6e 20 43 52 0a 09 09 57 48 45 52 45 20 43 2e on CR...WHERE C.
2d30: 74 79 70 65 20 3d 20 30 20 20 20 20 20 20 20 2d type = 0 -
2d40: 2d 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 - revision chang
2d50: 65 73 65 74 73 20 6f 6e 6c 79 0a 09 09 41 4e 44 esets only...AND
2d60: 20 20 20 43 2e 63 69 64 20 20 3d 20 43 52 2e 63 C.cid = CR.c
2d70: 69 64 20 20 2d 2d 20 63 68 61 6e 67 65 73 65 74 id -- changeset
2d80: 20 2d 2d 3e 20 69 74 73 20 72 65 76 69 73 69 6f --> its revisio
2d90: 6e 73 0a 09 09 41 4e 44 20 20 20 52 2e 72 69 64 ns...AND R.rid
2da0: 20 20 3d 20 43 52 2e 72 69 64 20 20 2d 2d 20 6c = CR.rid -- l
2db0: 6f 6f 6b 20 61 74 20 74 68 65 6d 0a 09 09 41 4e ook at them...AN
2dc0: 44 20 20 20 52 2e 6d 69 64 20 21 3d 20 43 2e 73 D R.mid != C.s
2dd0: 72 63 20 20 20 2d 2d 20 4f 6e 6c 79 20 74 68 6f rc -- Only tho
2de0: 73 65 20 77 68 69 63 68 20 64 69 73 61 67 72 65 se which disagre
2df0: 65 20 77 69 74 68 20 63 68 61 6e 67 65 73 65 74 e with changeset
2e00: 20 61 62 6f 75 74 20 74 68 65 20 6d 65 74 61 0a about the meta.
2e10: 09 09 41 4e 44 20 20 20 52 2e 66 69 64 20 3d 20 ..AND R.fid =
2e20: 46 2e 66 69 64 20 20 20 20 2d 2d 20 67 65 74 20 F.fid -- get
2e30: 66 69 6c 65 20 6f 66 20 74 68 65 20 72 65 76 69 file of the revi
2e40: 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 43 54 2e sion...AND CT.
2e50: 74 69 64 20 3d 20 43 2e 74 79 70 65 20 20 2d 2d tid = C.type --
2e60: 20 67 65 74 20 63 68 61 6e 67 65 73 65 74 20 74 get changeset t
2e70: 79 70 65 2c 20 66 6f 72 20 6c 61 62 65 6c 69 6e ype, for labelin
2e80: 67 0a 09 20 20 20 20 7d 0a 09 23 20 41 6c 6c 20 g.. }..# All
2e90: 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 revisions have t
2ea0: 6f 20 61 67 72 65 65 20 6f 6e 20 74 68 65 20 4c o agree on the L
2eb0: 4f 44 20 74 68 65 69 72 20 63 68 61 6e 67 65 73 OD their changes
2ec0: 65 74 0a 09 23 20 62 65 6c 6f 6e 67 73 20 74 6f et..# belongs to
2ed0: 2e 20 49 6e 20 6f 74 68 65 72 20 77 6f 72 64 73 . In other words
2ee0: 2c 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 , all revisions
2ef0: 69 6e 20 61 20 63 68 61 6e 67 65 73 65 74 0a 09 in a changeset..
2f00: 23 20 68 61 76 65 20 74 6f 20 72 65 66 65 72 20 # have to refer
2f10: 74 6f 20 74 68 65 20 73 61 6d 65 20 6c 69 6e 65 to the same line
2f20: 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 2e of development.
2f30: 0a 09 23 0a 09 23 20 49 6e 73 74 65 61 64 20 6f ..#..# Instead o
2f40: 66 20 6c 6f 6f 6b 69 6e 67 20 61 74 20 61 6c 6c f looking at all
2f50: 20 70 61 69 72 73 20 6f 66 20 72 65 76 69 73 69 pairs of revisi
2f60: 6f 6e 73 20 69 6e 20 61 6c 6c 0a 09 23 20 63 68 ons in all..# ch
2f70: 61 6e 67 65 73 65 74 73 20 77 65 20 67 65 6e 65 angesets we gene
2f80: 72 61 74 65 20 74 68 65 20 64 69 73 74 69 6e 63 rate the distinc
2f90: 74 20 73 65 74 20 6f 66 20 61 6c 6c 20 4c 4f 44 t set of all LOD
2fa0: 73 0a 09 23 20 72 65 66 65 72 65 6e 63 65 64 20 s..# referenced
2fb0: 62 79 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 by the revisions
2fc0: 20 6f 66 20 61 20 63 68 61 6e 67 65 73 65 74 2c of a changeset,
2fd0: 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 6f 73 65 0a look for those.
2fe0: 09 23 20 77 69 74 68 20 63 61 72 64 69 6e 61 6c .# with cardinal
2ff0: 69 74 79 20 3e 20 31 2c 20 61 6e 64 20 67 65 74 ity > 1, and get
3000: 20 74 68 65 20 69 64 65 6e 74 69 66 79 69 6e 67 the identifying
3010: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 0a 09 23 20 information..#
3020: 66 6f 72 20 74 68 65 20 63 68 61 6e 67 65 73 65 for the changese
3030: 74 73 20 66 6f 75 6e 64 20 74 68 75 73 6c 79 2e ts found thusly.
3040: 0a 09 43 68 65 63 6b 43 53 20 5c 0a 09 20 20 20 ..CheckCS \..
3050: 20 7b 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 {All revisions
3060: 69 6e 20 61 20 63 68 61 6e 67 65 73 65 74 20 68 in a changeset h
3070: 61 76 65 20 74 6f 20 62 65 6c 6f 6e 67 20 74 6f ave to belong to
3080: 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 7d 20 5c the same LOD} \
3090: 0a 09 20 20 20 20 7b 3a 20 49 74 73 20 72 65 76 .. {: Its rev
30a0: 69 73 69 6f 6e 73 20 64 69 73 61 67 72 65 65 20 isions disagree
30b0: 61 62 6f 75 74 20 74 68 65 20 4c 4f 44 20 74 68 about the LOD th
30c0: 65 79 20 62 65 6c 6f 6e 67 20 74 6f 7d 20 7b 0a ey belong to} {.
30d0: 09 09 53 45 4c 45 43 54 20 54 2e 6e 61 6d 65 2c ..SELECT T.name,
30e0: 20 43 2e 63 69 64 0a 09 09 46 52 4f 4d 20 20 20 C.cid...FROM
30f0: 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 74 changeset C, cst
3100: 79 70 65 20 54 0a 09 09 57 48 45 52 45 20 20 43 ype T...WHERE C
3110: 2e 63 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20 .cid IN (SELECT
3120: 55 2e 63 69 64 0a 09 09 09 09 20 46 52 4f 4d 20 U.cid..... FROM
3130: 28 53 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54 (SELECT DISTINCT
3140: 20 43 52 2e 63 69 64 20 41 53 20 63 69 64 2c 20 CR.cid AS cid,
3150: 52 2e 6c 6f 64 20 41 53 20 6c 6f 64 0a 09 09 09 R.lod AS lod....
3160: 09 20 20 20 20 20 20 20 46 52 4f 4d 20 20 20 63 . FROM c
3170: 73 72 65 76 69 73 69 6f 6e 20 43 52 2c 20 63 68 srevision CR, ch
3180: 61 6e 67 65 73 65 74 20 43 2c 20 72 65 76 69 73 angeset C, revis
3190: 69 6f 6e 20 52 0a 09 09 09 09 20 20 20 20 20 20 ion R.....
31a0: 20 57 48 45 52 45 20 20 43 52 2e 72 69 64 20 3d WHERE CR.rid =
31b0: 20 52 2e 72 69 64 0a 09 09 09 09 20 20 20 20 20 R.rid.....
31c0: 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d AND C.cid =
31d0: 20 43 52 2e 63 69 64 0a 09 09 09 09 20 20 20 20 CR.cid.....
31e0: 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 AND C.type
31f0: 20 3d 20 30 29 20 41 53 20 55 0a 09 09 09 09 20 = 0) AS U.....
3200: 47 52 4f 55 50 20 42 59 20 55 2e 63 69 64 20 48 GROUP BY U.cid H
3210: 41 56 49 4e 47 20 43 4f 55 4e 54 28 55 2e 6c 6f AVING COUNT(U.lo
3220: 64 29 20 3e 20 31 29 0a 09 09 41 4e 44 20 20 20 d) > 1)...AND
3230: 20 54 2e 74 69 64 20 3d 20 43 2e 74 79 70 65 0a T.tid = C.type.
3240: 09 20 20 20 20 7d 0a 09 23 20 41 6c 6c 20 72 65 . }..# All re
3250: 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 visions have to
3260: 61 67 72 65 65 20 6f 6e 20 74 68 65 20 70 72 6f agree on the pro
3270: 6a 65 63 74 20 74 68 65 69 72 20 63 68 61 6e 67 ject their chang
3280: 65 73 65 74 0a 09 23 20 62 65 6c 6f 6e 67 73 20 eset..# belongs
3290: 74 6f 2e 20 49 6e 20 6f 74 68 65 72 20 77 6f 72 to. In other wor
32a0: 64 73 2c 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e ds, all revision
32b0: 73 20 69 6e 20 61 20 63 68 61 6e 67 65 73 65 74 s in a changeset
32c0: 0a 09 23 20 68 61 76 65 20 74 6f 20 72 65 66 65 ..# have to refe
32d0: 72 20 74 6f 20 74 68 65 20 73 61 6d 65 20 70 72 r to the same pr
32e0: 6f 6a 65 63 74 2e 0a 09 23 0a 09 23 20 49 6e 73 oject...#..# Ins
32f0: 74 65 61 64 20 6f 66 20 6c 6f 6f 6b 69 6e 67 20 tead of looking
3300: 61 74 20 61 6c 6c 20 70 61 69 72 73 20 6f 66 20 at all pairs of
3310: 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 61 6c 6c revisions in all
3320: 0a 09 23 20 63 68 61 6e 67 65 73 65 74 73 20 77 ..# changesets w
3330: 65 20 67 65 6e 65 72 61 74 65 20 74 68 65 20 64 e generate the d
3340: 69 73 74 69 6e 63 74 20 73 65 74 20 6f 66 20 61 istinct set of a
3350: 6c 6c 20 70 72 6f 6a 65 63 74 73 0a 09 23 20 72 ll projects..# r
3360: 65 66 65 72 65 6e 63 65 64 20 62 79 20 74 68 65 eferenced by the
3370: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 61 20 revisions of a
3380: 63 68 61 6e 67 65 73 65 74 2c 20 6c 6f 6f 6b 20 changeset, look
3390: 66 6f 72 20 74 68 6f 73 65 0a 09 23 20 77 69 74 for those..# wit
33a0: 68 20 63 61 72 64 69 6e 61 6c 69 74 79 20 3e 20 h cardinality >
33b0: 31 2c 20 61 6e 64 20 67 65 74 20 74 68 65 20 69 1, and get the i
33c0: 64 65 6e 74 69 66 79 69 6e 67 20 69 6e 66 6f 72 dentifying infor
33d0: 6d 61 74 69 6f 6e 0a 09 23 20 66 6f 72 20 74 68 mation..# for th
33e0: 65 20 63 68 61 6e 67 65 73 65 74 73 20 66 6f 75 e changesets fou
33f0: 6e 64 20 74 68 75 73 6c 79 2e 0a 09 43 68 65 63 nd thusly...Chec
3400: 6b 43 53 20 5c 0a 09 20 20 20 20 7b 41 6c 6c 20 kCS \.. {All
3410: 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 61 20 63 revisions in a c
3420: 68 61 6e 67 65 73 65 74 20 68 61 76 65 20 74 6f hangeset have to
3430: 20 62 65 6c 6f 6e 67 20 74 6f 20 74 68 65 20 73 belong to the s
3440: 61 6d 65 20 70 72 6f 6a 65 63 74 7d 20 5c 0a 09 ame project} \..
3450: 20 20 20 20 7b 3a 20 49 74 73 20 72 65 76 69 73 {: Its revis
3460: 69 6f 6e 73 20 64 69 73 61 67 72 65 65 20 61 62 ions disagree ab
3470: 6f 75 74 20 74 68 65 20 70 72 6f 6a 65 63 74 20 out the project
3480: 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 7d 20 they belong to}
3490: 7b 0a 09 09 53 45 4c 45 43 54 20 54 2e 6e 61 6d {...SELECT T.nam
34a0: 65 2c 20 43 2e 63 69 64 0a 09 09 46 52 4f 4d 20 e, C.cid...FROM
34b0: 20 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 changeset C, c
34c0: 73 74 79 70 65 20 54 0a 09 09 57 48 45 52 45 20 stype T...WHERE
34d0: 20 43 2e 63 69 64 20 49 4e 20 28 53 45 4c 45 43 C.cid IN (SELEC
34e0: 54 20 55 2e 63 69 64 0a 09 09 09 09 20 46 52 4f T U.cid..... FRO
34f0: 4d 20 28 53 45 4c 45 43 54 20 44 49 53 54 49 4e M (SELECT DISTIN
3500: 43 54 20 43 52 2e 63 69 64 20 41 53 20 63 69 64 CT CR.cid AS cid
3510: 2c 20 46 2e 70 69 64 20 41 53 20 70 69 64 0a 09 , F.pid AS pid..
3520: 09 09 09 20 20 20 20 20 20 20 46 52 4f 4d 20 20 ... FROM
3530: 20 63 73 72 65 76 69 73 69 6f 6e 20 43 52 2c 20 csrevision CR,
3540: 63 68 61 6e 67 65 73 65 74 20 43 2c 20 72 65 76 changeset C, rev
3550: 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a ision R, file F.
3560: 09 09 09 09 20 20 20 20 20 20 20 57 48 45 52 45 .... WHERE
3570: 20 20 43 52 2e 72 69 64 20 3d 20 52 2e 72 69 64 CR.rid = R.rid
3580: 0a 09 09 09 09 20 20 20 20 20 20 20 41 4e 44 20 ..... AND
3590: 20 20 20 43 2e 63 69 64 20 3d 20 43 52 2e 63 69 C.cid = CR.ci
35a0: 64 0a 09 09 09 09 20 20 20 20 20 20 20 41 4e 44 d..... AND
35b0: 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30 0a 09 C.type = 0..
35c0: 09 09 09 20 20 20 20 20 20 20 41 4e 44 20 20 20 ... AND
35d0: 20 46 2e 66 69 64 20 20 3d 20 52 2e 66 69 64 29 F.fid = R.fid)
35e0: 20 41 53 20 55 0a 09 09 09 09 20 47 52 4f 55 50 AS U..... GROUP
35f0: 20 42 59 20 55 2e 63 69 64 20 48 41 56 49 4e 47 BY U.cid HAVING
3600: 20 43 4f 55 4e 54 28 55 2e 70 69 64 29 20 3e 20 COUNT(U.pid) >
3610: 31 29 0a 09 09 41 4e 44 20 20 20 20 54 2e 74 69 1)...AND T.ti
3620: 64 20 3d 20 43 2e 74 79 70 65 0a 09 20 20 20 20 d = C.type..
3630: 7d 0a 09 23 20 41 6c 6c 20 72 65 76 69 73 69 6f }..# All revisio
3640: 6e 73 20 69 6e 20 61 20 73 69 6e 67 6c 65 20 63 ns in a single c
3650: 68 61 6e 67 65 73 65 74 20 68 61 76 65 20 74 6f hangeset have to
3660: 20 62 65 6c 6f 6e 67 20 74 6f 0a 09 23 20 64 69 belong to..# di
3670: 66 66 65 72 65 6e 74 20 66 69 6c 65 73 2e 20 43 fferent files. C
3680: 6f 6e 76 65 72 73 65 6c 79 3a 20 4e 6f 20 74 77 onversely: No tw
3690: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 61 o revisions of a
36a0: 20 73 69 6e 67 6c 65 0a 09 23 20 66 69 6c 65 20 single..# file
36b0: 61 72 65 20 61 6c 6c 6f 77 65 64 20 74 6f 20 62 are allowed to b
36c0: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 63 68 e in the same ch
36d0: 61 6e 67 65 73 65 74 2e 0a 09 23 0a 09 23 20 49 angeset...#..# I
36e0: 6e 73 74 65 61 64 20 6f 66 20 6c 6f 6f 6b 69 6e nstead of lookin
36f0: 67 20 61 74 20 61 6c 6c 20 70 61 69 72 73 20 6f g at all pairs o
3700: 66 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 61 f revisions in a
3710: 6c 6c 0a 09 23 20 63 68 61 6e 67 65 73 65 74 73 ll..# changesets
3720: 20 77 65 20 67 65 6e 65 72 61 74 65 20 74 68 65 we generate the
3730: 20 64 69 73 74 69 6e 63 74 20 73 65 74 20 6f 66 distinct set of
3740: 20 61 6c 6c 20 66 69 6c 65 73 0a 09 23 20 72 65 all files..# re
3750: 66 65 72 65 6e 63 65 64 20 62 79 20 74 68 65 20 ferenced by the
3760: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 61 20 63 revisions of a c
3770: 68 61 6e 67 65 73 65 74 2c 20 61 6e 64 20 6c 6f hangeset, and lo
3780: 6f 6b 20 66 6f 72 0a 09 23 20 74 68 6f 73 65 20 ok for..# those
3790: 77 69 74 68 20 63 61 72 64 69 6e 61 6c 69 74 79 with cardinality
37a0: 20 3c 20 74 68 65 20 63 61 72 64 69 6e 61 6c 69 < the cardinali
37b0: 74 79 20 6f 66 20 74 68 65 20 73 65 74 20 6f 66 ty of the set of
37c0: 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 2c 20 61 ..# revisions, a
37d0: 6e 64 20 67 65 74 20 74 68 65 20 69 64 65 6e 74 nd get the ident
37e0: 69 66 79 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 ifying informati
37f0: 6f 6e 20 66 6f 72 20 74 68 65 0a 09 23 20 63 68 on for the..# ch
3800: 61 6e 67 65 73 65 74 73 20 66 6f 75 6e 64 20 74 angesets found t
3810: 68 75 73 6c 79 2e 0a 09 43 68 65 63 6b 43 53 20 husly...CheckCS
3820: 5c 0a 09 20 20 20 20 7b 41 6c 6c 20 72 65 76 69 \.. {All revi
3830: 73 69 6f 6e 73 20 69 6e 20 61 20 63 68 61 6e 67 sions in a chang
3840: 65 73 65 74 20 68 61 76 65 20 74 6f 20 62 65 6c eset have to bel
3850: 6f 6e 67 20 74 6f 20 64 69 66 66 65 72 65 6e 74 ong to different
3860: 20 66 69 6c 65 73 7d 20 5c 0a 09 20 20 20 20 7b files} \.. {
3870: 3a 20 49 74 73 20 72 65 76 69 73 69 6f 6e 73 20 : Its revisions
3880: 73 68 61 72 65 20 66 69 6c 65 73 7d 20 7b 0a 09 share files} {..
3890: 09 53 45 4c 45 43 54 20 54 2e 6e 61 6d 65 2c 20 .SELECT T.name,
38a0: 43 2e 63 69 64 0a 09 09 46 52 4f 4d 20 20 20 63 C.cid...FROM c
38b0: 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 74 79 hangeset C, csty
38c0: 70 65 20 54 0a 09 09 57 48 45 52 45 20 20 43 2e pe T...WHERE C.
38d0: 63 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20 56 cid IN (SELECT V
38e0: 56 2e 63 69 64 0a 09 09 09 09 20 46 52 4f 4d 20 V.cid..... FROM
38f0: 28 53 45 4c 45 43 54 20 55 2e 63 69 64 20 61 73 (SELECT U.cid as
3900: 20 63 69 64 2c 20 43 4f 55 4e 54 20 28 55 2e 66 cid, COUNT (U.f
3910: 69 64 29 20 41 53 20 66 63 6f 75 6e 74 0a 09 09 id) AS fcount...
3920: 09 09 20 20 20 20 20 20 20 46 52 4f 4d 20 28 53 .. FROM (S
3930: 45 4c 45 43 54 20 44 49 53 54 49 4e 43 54 20 43 ELECT DISTINCT C
3940: 52 2e 63 69 64 20 41 53 20 63 69 64 2c 20 52 2e R.cid AS cid, R.
3950: 66 69 64 20 41 53 20 66 69 64 0a 09 09 09 09 09 fid AS fid......
3960: 20 20 20 20 20 46 52 4f 4d 20 20 20 63 73 72 65 FROM csre
3970: 76 69 73 69 6f 6e 20 43 52 2c 20 63 68 61 6e 67 vision CR, chang
3980: 65 73 65 74 20 43 2c 20 72 65 76 69 73 69 6f 6e eset C, revision
3990: 20 52 0a 09 09 09 09 09 20 20 20 20 20 57 48 45 R...... WHE
39a0: 52 45 20 20 43 52 2e 72 69 64 20 3d 20 52 2e 72 RE CR.rid = R.r
39b0: 69 64 0a 09 09 09 09 09 20 20 20 20 20 41 4e 44 id...... AND
39c0: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 52 2e 63 C.cid = CR.c
39d0: 69 64 0a 09 09 09 09 09 20 20 20 20 20 41 4e 44 id...... AND
39e0: 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30 0a 09 C.type = 0..
39f0: 09 09 09 09 20 20 20 20 20 29 20 41 53 20 55 0a .... ) AS U.
3a00: 09 09 09 09 20 20 20 20 20 20 20 47 52 4f 55 50 .... GROUP
3a10: 20 42 59 20 55 2e 63 69 64 29 20 41 53 20 55 55 BY U.cid) AS UU
3a20: 2c 0a 09 09 09 09 20 20 20 20 20 20 28 53 45 4c ,..... (SEL
3a30: 45 43 54 20 56 2e 63 69 64 20 41 53 20 63 69 64 ECT V.cid AS cid
3a40: 2c 20 43 4f 55 4e 54 20 28 56 2e 72 69 64 29 20 , COUNT (V.rid)
3a50: 41 53 20 72 63 6f 75 6e 74 0a 09 09 09 09 20 20 AS rcount.....
3a60: 20 20 20 20 20 46 52 4f 4d 20 20 20 63 73 72 65 FROM csre
3a70: 76 69 73 69 6f 6e 20 56 2c 20 63 68 61 6e 67 65 vision V, change
3a80: 73 65 74 20 58 0a 09 09 09 09 20 20 20 20 20 20 set X.....
3a90: 20 57 48 45 52 45 20 20 58 2e 63 69 64 20 3d 20 WHERE X.cid =
3aa0: 56 2e 63 69 64 0a 09 09 09 09 20 20 20 20 20 20 V.cid.....
3ab0: 20 41 4e 44 20 20 20 20 58 2e 74 79 70 65 20 3d AND X.type =
3ac0: 20 30 0a 09 09 09 09 20 20 20 20 20 20 20 47 52 0..... GR
3ad0: 4f 55 50 20 42 59 20 56 2e 63 69 64 29 20 41 53 OUP BY V.cid) AS
3ae0: 20 56 56 0a 09 09 09 09 20 57 48 45 52 45 20 56 VV..... WHERE V
3af0: 56 2e 63 69 64 20 3d 20 55 55 2e 63 69 64 0a 09 V.cid = UU.cid..
3b00: 09 09 09 20 41 4e 44 20 20 20 55 55 2e 66 63 6f ... AND UU.fco
3b10: 75 6e 74 20 3c 20 56 56 2e 72 63 6f 75 6e 74 29 unt < VV.rcount)
3b20: 0a 09 09 41 4e 44 20 20 20 20 54 2e 74 69 64 20 ...AND T.tid
3b30: 3d 20 43 2e 74 79 70 65 0a 09 20 20 20 20 7d 0a = C.type.. }.
3b40: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 .return. }..
3b50: 20 20 20 70 72 6f 63 20 54 61 67 43 68 61 6e 67 proc TagChang
3b60: 65 73 65 74 73 20 7b 7d 20 7b 0a 09 23 20 54 68 esets {} {..# Th
3b70: 69 73 20 63 6f 64 65 20 70 65 72 66 6f 72 6d 73 is code performs
3b80: 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 70 61 72 a number of par
3b90: 61 6e 6f 69 64 20 63 68 65 63 6b 73 20 6f 66 20 anoid checks of
3ba0: 74 68 65 0a 09 23 20 64 61 74 61 62 61 73 65 2c the..# database,
3bb0: 20 73 65 61 72 63 68 69 6e 67 20 66 6f 72 20 69 searching for i
3bc0: 6e 63 6f 6e 73 69 73 74 65 6e 74 20 63 68 61 6e nconsistent chan
3bd0: 67 65 73 65 74 2f 72 65 76 69 73 69 6f 6e 0a 09 geset/revision..
3be0: 23 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e 0a 0a # information...
3bf0: 09 75 70 76 61 72 20 31 20 6e 20 6e 20 3b 20 23 .upvar 1 n n ; #
3c00: 20 43 6f 75 6e 74 65 72 20 66 6f 72 20 74 68 65 Counter for the
3c10: 20 63 68 65 63 6b 73 20 28 77 65 20 70 72 69 6e checks (we prin
3c20: 74 20 61 6e 20 69 64 20 62 65 66 6f 72 65 0a 09 t an id before..
3c30: 09 20 20 20 20 20 20 23 20 74 68 65 20 6d 61 69 . # the mai
3c40: 6e 20 6c 61 62 65 6c 29 2e 0a 20 20 20 20 7d 0a n label).. }.
3c50: 0a 20 20 20 20 70 72 6f 63 20 42 72 61 6e 63 68 . proc Branch
3c60: 43 68 61 6e 67 65 73 65 74 73 20 7b 7d 20 7b 0a Changesets {} {.
3c70: 09 23 20 54 68 69 73 20 63 6f 64 65 20 70 65 72 .# This code per
3c80: 66 6f 72 6d 73 20 61 20 6e 75 6d 62 65 72 20 6f forms a number o
3c90: 66 20 70 61 72 61 6e 6f 69 64 20 63 68 65 63 6b f paranoid check
3ca0: 73 20 6f 66 20 74 68 65 0a 09 23 20 64 61 74 61 s of the..# data
3cb0: 62 61 73 65 2c 20 73 65 61 72 63 68 69 6e 67 20 base, searching
3cc0: 66 6f 72 20 69 6e 63 6f 6e 73 69 73 74 65 6e 74 for inconsistent
3cd0: 20 63 68 61 6e 67 65 73 65 74 2f 72 65 76 69 73 changeset/revis
3ce0: 69 6f 6e 0a 09 23 20 69 6e 66 6f 72 6d 61 74 69 ion..# informati
3cf0: 6f 6e 2e 0a 0a 09 75 70 76 61 72 20 31 20 6e 20 on....upvar 1 n
3d00: 6e 20 3b 20 23 20 43 6f 75 6e 74 65 72 20 66 6f n ; # Counter fo
3d10: 72 20 74 68 65 20 63 68 65 63 6b 73 20 28 77 65 r the checks (we
3d20: 20 70 72 69 6e 74 20 61 6e 20 69 64 20 62 65 66 print an id bef
3d30: 6f 72 65 0a 09 09 20 20 20 20 20 20 23 20 74 68 ore... # th
3d40: 65 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a 20 e main label)..
3d50: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 5f }.. proc _
3d60: 5f 5f 55 6e 75 73 65 64 43 68 61 6e 67 65 73 65 __UnusedChangese
3d70: 74 43 68 65 63 6b 73 5f 5f 5f 20 7b 7d 20 7b 0a tChecks___ {} {.
3d80: 09 23 20 54 68 69 73 20 63 6f 64 65 20 70 65 72 .# This code per
3d90: 66 6f 72 6d 73 20 61 20 6e 75 6d 62 65 72 20 6f forms a number o
3da0: 66 20 70 61 72 61 6e 6f 69 64 20 63 68 65 63 6b f paranoid check
3db0: 73 20 6f 66 20 74 68 65 0a 09 23 20 64 61 74 61 s of the..# data
3dc0: 62 61 73 65 2c 20 73 65 61 72 63 68 69 6e 67 20 base, searching
3dd0: 66 6f 72 20 69 6e 63 6f 6e 73 69 73 74 65 6e 74 for inconsistent
3de0: 20 63 68 61 6e 67 65 73 65 74 2f 72 65 76 69 73 changeset/revis
3df0: 69 6f 6e 0a 09 23 20 69 6e 66 6f 72 6d 61 74 69 ion..# informati
3e00: 6f 6e 2e 0a 0a 09 72 65 74 75 72 6e 20 3b 20 23 on....return ; #
3e10: 20 44 69 73 61 62 6c 65 64 20 66 6f 72 20 6e 6f Disabled for no
3e20: 77 2c 20 62 6f 74 74 6c 65 6e 65 63 6b 73 20 2e w, bottlenecks .
3e30: 2e 2e 0a 0a 09 75 70 76 61 72 20 31 20 6e 20 6e .....upvar 1 n n
3e40: 20 3b 20 23 20 43 6f 75 6e 74 65 72 20 66 6f 72 ; # Counter for
3e50: 20 74 68 65 20 63 68 65 63 6b 73 20 28 77 65 20 the checks (we
3e60: 70 72 69 6e 74 20 61 6e 20 69 64 20 62 65 66 6f print an id befo
3e70: 72 65 0a 09 09 20 20 20 20 20 20 23 20 74 68 65 re... # the
3e80: 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a 0a 09 main label)....
3e90: 23 20 54 68 65 20 6e 65 78 74 20 74 77 6f 20 63 # The next two c
3ea0: 68 65 63 6b 73 20 61 72 65 20 42 4f 54 54 4c 45 hecks are BOTTLE
3eb0: 4e 45 43 4b 53 2e 20 49 6e 20 65 73 73 65 6e 63 NECKS. In essenc
3ec0: 65 20 77 65 20 61 72 65 0a 09 23 20 63 68 65 63 e we are..# chec
3ed0: 6b 69 6e 67 20 65 61 63 68 20 73 79 6d 62 6f 6c king each symbol
3ee0: 20 63 68 61 6e 67 65 73 65 74 20 6f 6e 65 20 62 changeset one b
3ef0: 79 20 6f 6e 65 2e 0a 0a 09 23 20 54 4f 44 4f 3a y one....# TODO:
3f00: 20 54 72 79 20 74 6f 20 72 65 70 68 72 61 73 65 Try to rephrase
3f10: 20 74 68 65 20 63 68 65 63 6b 73 20 74 6f 20 6d the checks to m
3f20: 61 6b 65 20 6d 6f 72 65 20 75 73 65 20 6f 66 0a ake more use of.
3f30: 09 23 20 69 6e 64 69 63 65 73 2c 20 73 65 74 20 .# indices, set
3f40: 61 6e 64 20 73 74 72 65 61 6d 20 6f 70 65 72 61 and stream opera
3f50: 74 69 6f 6e 73 2e 0a 0a 09 23 20 41 6c 6c 20 72 tions....# All r
3f60: 65 76 69 73 69 6f 6e 73 20 75 73 65 64 20 62 79 evisions used by
3f70: 20 74 61 67 20 73 79 6d 62 6f 6c 20 63 68 61 6e tag symbol chan
3f80: 67 65 73 65 74 73 20 68 61 76 65 20 74 6f 20 68 gesets have to h
3f90: 61 76 65 20 74 68 65 0a 09 23 20 63 68 61 6e 67 ave the..# chang
3fa0: 65 73 65 74 27 73 20 74 61 67 20 61 73 73 6f 63 eset's tag assoc
3fb0: 69 61 74 65 64 20 77 69 74 68 20 74 68 65 6d 2e iated with them.
3fc0: 0a 09 43 68 65 63 6b 52 65 76 43 53 20 5c 0a 09 ..CheckRevCS \..
3fd0: 20 20 20 20 7b 41 6c 6c 20 72 65 76 69 73 69 6f {All revisio
3fe0: 6e 73 20 75 73 65 64 20 62 79 20 74 61 67 20 73 ns used by tag s
3ff0: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 ymbol changesets
4000: 20 68 61 76 65 20 74 6f 20 68 61 76 65 20 74 68 have to have th
4010: 65 20 63 68 61 6e 67 65 73 65 74 27 73 20 74 61 e changeset's ta
4020: 67 20 61 74 74 61 63 68 65 64 20 74 6f 20 74 68 g attached to th
4030: 65 6d 7d 20 5c 0a 09 20 20 20 20 7b 64 6f 65 73 em} \.. {does
4040: 20 6e 6f 74 20 68 61 76 65 20 74 68 65 20 74 61 not have the ta
4050: 67 20 6f 66 20 69 74 73 20 73 79 6d 62 6f 6c 20 g of its symbol
4060: 63 68 61 6e 67 65 73 65 74 20 40 20 61 74 74 61 changeset @ atta
4070: 63 68 65 64 20 74 6f 20 69 74 7d 20 7b 0a 09 09 ched to it} {...
4080: 53 45 4c 45 43 54 20 43 54 2e 6e 61 6d 65 2c 20 SELECT CT.name,
4090: 43 2e 63 69 64 2c 20 46 2e 6e 61 6d 65 2c 20 52 C.cid, F.name, R
40a0: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20 20 63 68 .rev...FROM ch
40b0: 61 6e 67 65 73 65 74 20 43 2c 20 63 73 74 79 70 angeset C, cstyp
40c0: 65 20 43 54 2c 20 72 65 76 69 73 69 6f 6e 20 52 e CT, revision R
40d0: 2c 20 66 69 6c 65 20 46 2c 20 63 73 72 65 76 69 , file F, csrevi
40e0: 73 69 6f 6e 20 43 52 2c 20 74 61 67 20 54 0a 09 sion CR, tag T..
40f0: 09 57 48 45 52 45 20 20 43 2e 74 79 70 65 20 3d .WHERE C.type =
4100: 20 31 20 20 20 20 20 20 20 2d 2d 20 73 79 6d 62 1 -- symb
4110: 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 20 6f 6e ol changesets on
4120: 6c 79 0a 09 09 41 4e 44 20 20 20 20 43 2e 73 72 ly...AND C.sr
4130: 63 20 20 3d 20 54 2e 73 69 64 20 20 20 2d 2d 20 c = T.sid --
4140: 74 61 67 20 6f 6e 6c 79 2c 20 6c 69 6e 6b 65 64 tag only, linked
4150: 20 62 79 20 73 79 6d 62 6f 6c 20 69 64 20 0a 09 by symbol id ..
4160: 09 41 4e 44 20 20 20 20 43 2e 63 69 64 20 20 3d .AND C.cid =
4170: 20 43 52 2e 63 69 64 20 20 2d 2d 20 63 68 61 6e CR.cid -- chan
4180: 67 65 73 65 74 20 2d 2d 3e 20 69 74 73 20 72 65 geset --> its re
4190: 76 69 73 69 6f 6e 73 0a 09 09 41 4e 44 20 20 20 visions...AND
41a0: 20 52 2e 72 69 64 20 20 3d 20 43 52 2e 72 69 64 R.rid = CR.rid
41b0: 20 20 2d 2d 20 6c 6f 6f 6b 20 61 74 20 74 68 65 -- look at the
41c0: 20 72 65 76 69 73 69 6f 6e 73 0a 09 09 2d 2d 20 revisions...--
41d0: 61 6e 64 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 and look for the
41e0: 20 74 61 67 20 61 6d 6f 6e 67 20 74 68 65 20 61 tag among the a
41f0: 74 74 61 63 68 65 64 20 6f 6e 65 73 2e 0a 09 09 ttached ones....
4200: 41 4e 44 20 20 20 20 54 2e 73 69 64 20 4e 4f 54 AND T.sid NOT
4210: 20 49 4e 20 28 53 45 4c 45 43 54 20 54 42 2e 73 IN (SELECT TB.s
4220: 69 64 0a 09 09 09 09 20 20 20 20 20 46 52 4f 4d id..... FROM
4230: 20 20 20 74 61 67 20 54 42 0a 09 09 09 09 20 20 tag TB.....
4240: 20 20 20 57 48 45 52 45 20 20 54 42 2e 72 65 76 WHERE TB.rev
4250: 20 3d 20 52 2e 72 69 64 29 0a 09 09 41 4e 44 20 = R.rid)...AND
4260: 20 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 R.fid = F.fid
4270: 20 20 20 20 2d 2d 20 67 65 74 20 66 69 6c 65 20 -- get file
4280: 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 of revision..
4290: 20 7d 0a 0a 09 23 20 41 6c 6c 20 72 65 76 69 73 }...# All revis
42a0: 69 6f 6e 73 20 75 73 65 64 20 62 79 20 62 72 61 ions used by bra
42b0: 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 nch symbol chang
42c0: 65 73 65 74 73 20 68 61 76 65 20 74 6f 20 68 61 esets have to ha
42d0: 76 65 0a 09 23 20 74 68 65 20 63 68 61 6e 67 65 ve..# the change
42e0: 73 65 74 27 73 20 62 72 61 6e 63 68 20 61 73 73 set's branch ass
42f0: 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 65 ociated with the
4300: 6d 2e 0a 0a 09 43 68 65 63 6b 52 65 76 43 53 20 m....CheckRevCS
4310: 5c 0a 09 20 20 20 20 7b 41 6c 6c 20 72 65 76 69 \.. {All revi
4320: 73 69 6f 6e 73 20 75 73 65 64 20 62 79 20 62 72 sions used by br
4330: 61 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68 61 6e anch symbol chan
4340: 67 65 73 65 74 73 20 68 61 76 65 20 74 6f 20 68 gesets have to h
4350: 61 76 65 20 74 68 65 20 63 68 61 6e 67 65 73 65 ave the changese
4360: 74 27 73 20 62 72 61 6e 63 68 20 61 74 74 61 63 t's branch attac
4370: 68 65 64 20 74 6f 20 74 68 65 6d 7d 20 5c 0a 09 hed to them} \..
4380: 20 20 20 20 7b 64 6f 65 73 20 6e 6f 74 20 68 61 {does not ha
4390: 76 65 20 74 68 65 20 62 72 61 6e 63 68 20 6f 66 ve the branch of
43a0: 20 69 74 73 20 73 79 6d 62 6f 6c 20 63 68 61 6e its symbol chan
43b0: 67 65 73 65 74 20 40 20 61 74 74 61 63 68 65 64 geset @ attached
43c0: 20 74 6f 20 69 74 7d 20 7b 0a 09 09 53 45 4c 45 to it} {...SELE
43d0: 43 54 20 43 54 2e 6e 61 6d 65 2c 20 43 2e 63 69 CT CT.name, C.ci
43e0: 64 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 d, F.name, R.rev
43f0: 2c 20 43 2e 63 69 64 0a 09 09 46 52 4f 4d 20 20 , C.cid...FROM
4400: 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 changeset C, cs
4410: 74 79 70 65 20 43 54 2c 20 72 65 76 69 73 69 6f type CT, revisio
4420: 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 63 73 72 n R, file F, csr
4430: 65 76 69 73 69 6f 6e 20 43 52 2c 20 62 72 61 6e evision CR, bran
4440: 63 68 20 42 0a 09 09 57 48 45 52 45 20 20 43 2e ch B...WHERE C.
4450: 74 79 70 65 20 3d 20 31 20 20 20 20 20 20 20 2d type = 1 -
4460: 2d 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 - symbol changes
4470: 65 74 73 20 6f 6e 6c 79 0a 09 09 41 4e 44 20 20 ets only...AND
4480: 20 20 43 2e 73 72 63 20 20 3d 20 42 2e 73 69 64 C.src = B.sid
4490: 20 20 20 2d 2d 20 62 72 61 6e 63 68 65 73 20 6f -- branches o
44a0: 6e 6c 79 0a 09 09 41 4e 44 20 20 20 20 43 2e 63 nly...AND C.c
44b0: 69 64 20 20 3d 20 43 52 2e 63 69 64 20 20 2d 2d id = CR.cid --
44c0: 20 63 68 61 6e 67 65 73 65 74 20 2d 2d 3e 20 69 changeset --> i
44d0: 74 73 20 72 65 76 69 73 69 6f 6e 73 0a 09 09 41 ts revisions...A
44e0: 4e 44 20 20 20 20 52 2e 72 69 64 20 20 3d 20 43 ND R.rid = C
44f0: 52 2e 72 69 64 20 20 2d 2d 20 6c 6f 6f 6b 20 61 R.rid -- look a
4500: 74 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 0a t the revisions.
4510: 09 09 2d 2d 20 61 6e 64 20 6c 6f 6f 6b 20 66 6f ..-- and look fo
4520: 72 20 74 68 65 20 62 72 61 6e 63 68 20 61 6d 6f r the branch amo
4530: 6e 67 20 74 68 65 20 61 74 74 61 63 68 65 64 20 ng the attached
4540: 6f 6e 65 73 2e 0a 09 09 41 4e 44 20 20 20 20 42 ones....AND B
4550: 2e 73 69 64 20 4e 4f 54 20 49 4e 20 28 53 45 4c .sid NOT IN (SEL
4560: 45 43 54 20 42 42 2e 73 69 64 0a 09 09 09 09 20 ECT BB.sid.....
4570: 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 FROM branc
4580: 68 20 42 42 0a 09 09 09 09 20 20 20 20 20 57 48 h BB..... WH
4590: 45 52 45 20 20 42 42 2e 72 6f 6f 74 20 3d 20 52 ERE BB.root = R
45a0: 2e 72 69 64 29 0a 09 09 41 4e 44 20 20 20 20 52 .rid)...AND R
45b0: 2e 66 69 64 20 3d 20 46 2e 66 69 64 20 20 20 20 .fid = F.fid
45c0: 2d 2d 20 67 65 74 20 66 69 6c 65 20 6f 66 20 72 -- get file of r
45d0: 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 7d 0a 0a evision.. }..
45e0: 09 23 20 54 4f 44 4f 0a 09 23 20 54 68 65 20 73 .# TODO..# The s
45f0: 74 61 74 65 20 68 61 73 20 74 6f 20 63 6f 6e 74 tate has to cont
4600: 61 69 6e 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 ain at least one
4610: 20 74 61 67 20 73 79 6d 62 6f 6c 20 63 68 61 6e tag symbol chan
4620: 67 65 73 65 74 0a 09 23 20 66 6f 72 20 61 6c 6c geset..# for all
4630: 20 6b 6e 6f 77 6e 20 74 61 67 73 2e 0a 0a 09 23 known tags....#
4640: 20 54 4f 44 4f 0a 09 23 20 54 68 65 20 73 74 61 TODO..# The sta
4650: 74 65 20 68 61 73 20 74 6f 20 63 6f 6e 74 61 69 te has to contai
4660: 6e 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 62 n at least one b
4670: 72 61 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68 61 ranch symbol cha
4680: 6e 67 65 73 65 74 0a 09 23 20 66 6f 72 20 61 6c ngeset..# for al
4690: 6c 20 6b 6e 6f 77 6e 20 62 72 61 6e 63 68 65 73 l known branches
46a0: 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a ...return. }.
46b0: 0a 0a 20 20 20 20 70 72 6f 63 20 43 68 65 63 6b .. proc Check
46c0: 52 65 76 20 7b 68 65 61 64 65 72 20 6c 61 62 65 Rev {header labe
46d0: 6c 20 73 71 6c 7d 20 7b 0a 09 75 70 76 61 72 20 l sql} {..upvar
46e0: 31 20 6e 20 6e 0a 09 73 65 74 20 6f 6b 20 31 0a 1 n n..set ok 1.
46f0: 09 66 6f 72 65 61 63 68 20 7b 66 6e 61 6d 65 20 .foreach {fname
4700: 72 65 76 6e 72 7d 20 5b 73 74 61 74 65 20 72 75 revnr} [state ru
4710: 6e 20 24 73 71 6c 5d 20 7b 0a 09 20 20 20 20 73 n $sql] {.. s
4720: 65 74 20 6f 6b 20 30 0a 09 20 20 20 20 74 72 6f et ok 0.. tro
4730: 75 62 6c 65 20 66 61 74 61 6c 20 22 24 7b 72 65 uble fatal "${re
4740: 76 6e 72 7d 3a 3a 24 66 6e 61 6d 65 20 24 6c 61 vnr}::$fname $la
4750: 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 bel"..}..log wri
4760: 74 65 20 35 20 69 6e 74 65 67 72 69 74 79 20 7b te 5 integrity {
4770: 5c 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 5b \[[format %02d [
4780: 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 incr n]]\] [expr
4790: 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 {$ok ? "Ok "
47a0: 20 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e : "Failed"}] ..
47b0: 2e 20 24 68 65 61 64 65 72 7d 0a 09 72 65 74 75 . $header}..retu
47c0: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 rn. }.. pr
47d0: 6f 63 20 43 68 65 63 6b 54 61 67 20 7b 68 65 61 oc CheckTag {hea
47e0: 64 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20 7b der label sql} {
47f0: 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09 73 ..upvar 1 n n..s
4800: 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63 68 et ok 1..foreach
4810: 20 7b 70 6e 61 6d 65 20 73 6e 61 6d 65 7d 20 5b {pname sname} [
4820: 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d 20 state run $sql]
4830: 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30 0a {.. set ok 0.
4840: 09 20 20 20 20 74 72 6f 75 62 6c 65 20 66 61 74 . trouble fat
4850: 61 6c 20 22 3c 24 70 6e 61 6d 65 20 74 61 67 20 al "<$pname tag
4860: 27 24 73 6e 61 6d 65 27 3e 20 24 6c 61 62 65 6c '$sname'> $label
4870: 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 "..}..log write
4880: 35 20 69 6e 74 65 67 72 69 74 79 20 7b 5c 5b 5b 5 integrity {\[[
4890: 66 6f 72 6d 61 74 20 25 30 32 64 20 5b 69 6e 63 format %02d [inc
48a0: 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20 7b 24 r n]]\] [expr {$
48b0: 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 20 3a 20 ok ? "Ok " :
48c0: 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e 20 24 "Failed"}] ... $
48d0: 68 65 61 64 65 72 7d 0a 09 72 65 74 75 72 6e 0a header}..return.
48e0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
48f0: 43 68 65 63 6b 42 72 61 6e 63 68 20 7b 68 65 61 CheckBranch {hea
4900: 64 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20 7b der label sql} {
4910: 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09 73 ..upvar 1 n n..s
4920: 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63 68 et ok 1..foreach
4930: 20 7b 70 6e 61 6d 65 20 73 6e 61 6d 65 7d 20 5b {pname sname} [
4940: 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d 20 state run $sql]
4950: 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30 0a {.. set ok 0.
4960: 09 20 20 20 20 74 72 6f 75 62 6c 65 20 66 61 74 . trouble fat
4970: 61 6c 20 22 3c 24 70 6e 61 6d 65 20 62 72 61 6e al "<$pname bran
4980: 63 68 20 27 24 73 6e 61 6d 65 27 3e 20 24 6c 61 ch '$sname'> $la
4990: 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 bel"..}..log wri
49a0: 74 65 20 35 20 69 6e 74 65 67 72 69 74 79 20 7b te 5 integrity {
49b0: 5c 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 5b \[[format %02d [
49c0: 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 incr n]]\] [expr
49d0: 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 {$ok ? "Ok "
49e0: 20 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e : "Failed"}] ..
49f0: 2e 20 24 68 65 61 64 65 72 7d 0a 09 72 65 74 75 . $header}..retu
4a00: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 rn. }.. pr
4a10: 6f 63 20 43 68 65 63 6b 43 53 20 7b 68 65 61 64 oc CheckCS {head
4a20: 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20 7b 0a er label sql} {.
4a30: 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09 73 65 .upvar 1 n n..se
4a40: 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63 68 20 t ok 1..foreach
4a50: 7b 63 74 79 70 65 20 63 69 64 7d 20 5b 73 74 61 {ctype cid} [sta
4a60: 74 65 20 72 75 6e 20 24 73 71 6c 5d 20 7b 0a 09 te run $sql] {..
4a70: 20 20 20 20 73 65 74 20 6f 6b 20 30 0a 09 20 20 set ok 0..
4a80: 20 20 74 72 6f 75 62 6c 65 20 66 61 74 61 6c 20 trouble fatal
4a90: 22 3c 24 63 74 79 70 65 20 24 63 69 64 3e 20 24 "<$ctype $cid> $
4aa0: 6c 61 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 label"..}..log w
4ab0: 72 69 74 65 20 35 20 69 6e 74 65 67 72 69 74 79 rite 5 integrity
4ac0: 20 7b 5c 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64 {\[[format %02d
4ad0: 20 5b 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 [incr n]]\] [ex
4ae0: 70 72 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 pr {$ok ? "Ok
4af0: 20 22 20 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20 " : "Failed"}]
4b00: 2e 2e 2e 20 24 68 65 61 64 65 72 7d 0a 09 72 65 ... $header}..re
4b10: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
4b20: 70 72 6f 63 20 43 68 65 63 6b 52 65 76 43 53 20 proc CheckRevCS
4b30: 7b 68 65 61 64 65 72 20 6c 61 62 65 6c 20 73 71 {header label sq
4b40: 6c 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 6e 20 l} {..upvar 1 n
4b50: 6e 0a 09 73 65 74 20 6f 6b 20 31 0a 09 66 6f 72 n..set ok 1..for
4b60: 65 61 63 68 20 7b 63 73 74 79 70 65 20 63 73 69 each {cstype csi
4b70: 64 20 66 6e 61 6d 65 20 72 65 76 6e 72 7d 20 5b d fname revnr} [
4b80: 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d 20 state run $sql]
4b90: 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30 0a {.. set ok 0.
4ba0: 09 20 20 20 20 73 65 74 20 62 20 22 3c 24 63 73 . set b "<$cs
4bb0: 74 79 70 65 20 24 63 73 69 64 3e 22 0a 09 20 20 type $csid>"..
4bc0: 20 20 74 72 6f 75 62 6c 65 20 66 61 74 61 6c 20 trouble fatal
4bd0: 22 24 66 6e 61 6d 65 20 3c 24 72 65 76 6e 72 3e "$fname <$revnr>
4be0: 20 5b 73 74 72 69 6e 67 20 6d 61 70 20 5b 6c 69 [string map [li
4bf0: 73 74 20 40 20 24 62 5d 20 24 6c 61 62 65 6c 5d st @ $b] $label]
4c00: 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 "..}..log write
4c10: 35 20 69 6e 74 65 67 72 69 74 79 20 7b 5c 5b 5b 5 integrity {\[[
4c20: 66 6f 72 6d 61 74 20 25 30 32 64 20 5b 69 6e 63 format %02d [inc
4c30: 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20 7b 24 r n]]\] [expr {$
4c40: 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 20 3a 20 ok ? "Ok " :
4c50: 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e 20 24 "Failed"}] ... $
4c60: 68 65 61 64 65 72 7d 0a 09 72 65 74 75 72 6e 0a header}..return.
4c70: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 }.. # # #
4c80: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
4c90: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
4ca0: 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 ##. ## Config
4cb0: 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 uration.. pra
4cc0: 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 65 gma -hasinstance
4cd0: 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c s no ; # singl
4ce0: 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 eton. pragma
4cf0: 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20 -hastypeinfo
4d00: 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73 no ; # no intros
4d10: 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 pection. prag
4d20: 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73 74 72 ma -hastypedestr
4d30: 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 oy no ; # immort
4d40: 61 6c 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 al.. # # ## #
4d50: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 ## ##### #######
4d60: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a # #############.
4d70: 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61 }..namespace eva
4d80: 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a l ::vc::fossil::
4d90: 69 6d 70 6f 72 74 3a 3a 63 76 73 20 7b 0a 20 20 import::cvs {.
4da0: 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 70 6f namespace expo
4db0: 72 74 20 69 6e 74 65 67 72 69 74 79 0a 20 20 20 rt integrity.
4dc0: 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 namespace eval
4dd0: 69 6e 74 65 67 72 69 74 79 20 7b 0a 09 6e 61 6d integrity {..nam
4de0: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a espace import ::
4df0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f vc::fossil::impo
4e00: 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 rt::cvs::state..
4e10: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 namespace import
4e20: 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 ::vc::tools::tr
4e30: 6f 75 62 6c 65 0a 09 6e 61 6d 65 73 70 61 63 65 ouble..namespace
4e40: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f import ::vc::to
4e50: 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65 ols::log..log re
4e60: 67 69 73 74 65 72 20 69 6e 74 65 67 72 69 74 79 gister integrity
4e70: 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 . }.}..# # ##
4e80: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
4e90: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
4ea0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 # ##############
4eb0: 23 23 23 23 23 23 23 0a 23 23 20 52 65 61 64 79 #######.## Ready
4ec0: 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 69 64 ..package provid
4ed0: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d e vc::fossil::im
4ee0: 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 port::cvs::integ
4ef0: 72 69 74 79 20 31 2e 30 0a 72 65 74 75 72 6e 0a rity 1.0.return.