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 0a 09 23 20 46 69 n label)....# Fi
3c50: 6e 64 20 61 6c 6c 20 74 61 67 73 20 77 68 69 63 nd all tags whic
3c60: 68 20 61 72 65 20 6e 6f 74 20 75 73 65 64 20 62 h are not used b
3c70: 79 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 63 y at least one c
3c80: 68 61 6e 67 65 73 65 74 2e 0a 09 43 68 65 63 6b hangeset...Check
3c90: 54 61 67 20 5c 0a 09 20 20 20 20 7b 41 6c 6c 20 Tag \.. {All
3ca0: 74 61 67 73 20 68 61 76 65 20 74 6f 20 62 65 20 tags have to be
3cb0: 75 73 65 64 20 62 79 20 6c 65 61 73 74 20 6f 6e used by least on
3cc0: 65 20 63 68 61 6e 67 65 73 65 74 7d 20 5c 0a 09 e changeset} \..
3cd0: 20 20 20 20 7b 69 73 20 6e 6f 74 20 75 73 65 64 {is not used
3ce0: 20 62 79 20 61 20 63 68 61 6e 67 65 73 65 74 7d by a changeset}
3cf0: 20 7b 0a 09 09 2d 2d 20 55 6e 75 73 65 64 20 74 {...-- Unused t
3d00: 61 67 73 20 3d 20 41 6c 6c 20 74 61 67 73 0a 09 ags = All tags..
3d10: 09 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 .--
3d20: 2d 20 72 65 76 69 73 69 6f 6e 73 20 75 73 65 64 - revisions used
3d30: 20 62 79 20 74 61 67 20 63 68 61 6e 67 65 73 65 by tag changese
3d40: 74 73 2e 0a 09 09 2d 2d 0a 09 09 2d 2d 20 42 6f ts....--...-- Bo
3d50: 74 68 20 73 65 74 73 20 63 61 6e 20 62 65 20 63 th sets can be c
3d60: 6f 6d 70 75 74 65 64 20 65 61 73 69 6c 79 2c 20 omputed easily,
3d70: 61 6e 64 20 73 75 62 74 72 61 63 74 65 64 0a 20 and subtracted.
3d80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
3d90: 2d 20 66 72 6f 6d 20 65 61 63 68 20 6f 74 68 65 - from each othe
3da0: 72 2e 20 54 68 65 6e 20 77 65 20 63 61 6e 20 67 r. Then we can g
3db0: 65 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65 et the associate
3dc0: 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 d.
3dd0: 20 20 2d 2d 20 66 69 6c 65 20 28 6e 61 6d 65 29 -- file (name)
3de0: 20 66 6f 72 20 64 69 73 70 6c 61 79 2e 0a 0a 09 for display....
3df0: 09 53 45 4c 45 43 54 20 50 2e 6e 61 6d 65 2c 20 .SELECT P.name,
3e00: 53 2e 6e 61 6d 65 0a 09 09 46 52 4f 4d 20 70 72 S.name...FROM pr
3e10: 6f 6a 65 63 74 20 50 2c 20 74 61 67 20 54 2c 20 oject P, tag T,
3e20: 73 79 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52 45 symbol S...WHERE
3e30: 20 54 2e 74 69 64 20 49 4e 20 28 53 45 4c 45 43 T.tid IN (SELEC
3e40: 54 20 74 69 64 20 20 20 20 20 20 20 20 20 20 20 T tid
3e50: 20 20 20 20 20 20 20 20 20 2d 2d 20 41 6c 6c 20 -- All
3e60: 74 61 67 73 0a 09 09 09 09 46 52 4f 4d 20 20 20 tags.....FROM
3e70: 74 61 67 0a 09 09 09 09 45 58 43 45 50 54 20 20 tag.....EXCEPT
3e80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3e90: 20 20 20 20 20 20 2d 2d 20 73 75 62 74 72 61 63 -- subtrac
3ea0: 74 0a 09 09 09 09 53 45 4c 45 43 54 20 43 52 2e t.....SELECT CR.
3eb0: 72 69 64 20 20 20 20 20 20 20 20 20 20 20 20 20 rid
3ec0: 20 20 20 20 2d 2d 20 74 61 67 73 20 75 73 65 64 -- tags used
3ed0: 0a 09 09 09 09 46 52 4f 4d 20 20 20 63 73 72 65 .....FROM csre
3ee0: 76 69 73 69 6f 6e 20 43 52 2c 20 63 68 61 6e 67 vision CR, chang
3ef0: 65 73 65 74 20 43 0a 09 09 09 09 57 48 45 52 45 eset C.....WHERE
3f00: 20 20 43 2e 63 69 64 20 3d 20 43 52 2e 63 69 64 C.cid = CR.cid
3f10: 20 20 20 20 20 20 20 20 20 2d 2d 20 62 79 20 61 -- by a
3f20: 6e 79 20 74 61 67 0a 09 09 09 09 41 4e 44 20 20 ny tag.....AND
3f30: 20 20 43 2e 74 79 70 65 20 3d 20 31 29 20 20 20 C.type = 1)
3f40: 20 20 20 20 20 20 20 20 20 2d 2d 20 63 68 61 6e -- chan
3f50: 67 65 73 65 74 0a 09 09 41 4e 44 20 20 20 53 2e geset...AND S.
3f60: 73 69 64 20 3d 20 54 2e 73 69 64 20 20 20 20 20 sid = T.sid
3f70: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 67 65 74 -- get
3f80: 20 73 79 6d 62 6f 6c 20 6f 66 20 74 61 67 0a 09 symbol of tag..
3f90: 09 41 4e 44 20 20 20 50 2e 70 69 64 20 3d 20 53 .AND P.pid = S
3fa0: 2e 70 69 64 20 20 20 20 20 20 20 20 20 20 20 20 .pid
3fb0: 20 20 20 2d 2d 20 67 65 74 20 70 72 6f 6a 65 63 -- get projec
3fc0: 74 20 6f 66 20 73 79 6d 62 6f 6c 0a 09 20 20 20 t of symbol..
3fd0: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 74 }..# Find all t
3fe0: 61 67 73 20 77 68 69 63 68 20 61 72 65 20 75 73 ags which are us
3ff0: 65 64 20 62 79 20 6d 6f 72 65 20 74 68 61 6e 20 ed by more than
4000: 6f 6e 65 20 63 68 61 6e 67 65 73 65 74 2e 0a 09 one changeset...
4010: 43 68 65 63 6b 52 65 76 20 5c 0a 09 20 20 20 20 CheckRev \..
4020: 7b 41 6c 6c 20 74 61 67 73 20 68 61 76 65 20 74 {All tags have t
4030: 6f 20 62 65 20 75 73 65 64 20 62 79 20 61 74 20 o be used by at
4040: 6d 6f 73 74 20 6f 6e 65 20 63 68 61 6e 67 65 73 most one changes
4050: 65 74 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20 75 et} \.. {is u
4060: 73 65 64 20 62 79 20 6d 75 6c 74 69 70 6c 65 20 sed by multiple
4070: 63 68 61 6e 67 65 73 65 74 73 7d 20 7b 0a 09 09 changesets} {...
4080: 2d 2d 20 50 72 69 6e 63 69 70 6c 65 20 6f 66 20 -- Principle of
4090: 6f 70 65 72 61 74 69 6f 6e 3a 20 47 65 74 20 61 operation: Get a
40a0: 6c 6c 20 74 61 67 2f 63 68 61 6e 67 65 73 65 74 ll tag/changeset
40b0: 20 70 61 69 72 73 0a 20 20 20 20 20 20 20 20 20 pairs.
40c0: 20 20 20 20 20 20 20 2d 2d 20 66 6f 72 20 61 6c -- for al
40d0: 6c 20 74 61 67 20 63 68 61 6e 67 65 73 65 74 73 l tag changesets
40e0: 2c 20 67 72 6f 75 70 20 62 79 20 74 61 67 20 74 , group by tag t
40f0: 6f 20 61 67 67 72 65 67 61 74 65 0a 20 20 20 20 o aggregate.
4100: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 74 -- t
4110: 68 65 20 63 68 61 6e 67 65 73 65 74 2c 20 63 6f he changeset, co
4120: 75 6e 74 69 6e 67 20 74 68 65 6d 2e 20 46 72 6f unting them. Fro
4130: 6d 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 0a m the resulting.
4140: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4150: 2d 2d 20 74 61 67 2f 63 6f 75 6e 74 20 74 61 62 -- tag/count tab
4160: 6c 65 20 73 65 6c 65 63 74 20 74 68 6f 73 65 20 le select those
4170: 77 69 74 68 20 6d 6f 72 65 20 74 68 61 6e 20 6f with more than o
4180: 6e 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ne.
4190: 20 20 20 2d 2d 20 75 73 65 72 2c 20 61 6e 64 20 -- user, and
41a0: 67 65 74 20 74 68 65 69 72 20 61 73 73 6f 63 69 get their associ
41b0: 61 74 65 64 20 66 69 6c 65 20 28 6e 61 6d 65 29 ated file (name)
41c0: 20 66 6f 72 0a 20 20 20 20 20 20 20 20 20 20 20 for.
41d0: 20 20 20 20 20 2d 2d 20 64 69 73 70 6c 61 79 2e -- display.
41e0: 0a 0a 09 09 53 45 4c 45 43 54 20 50 2e 6e 61 6d ....SELECT P.nam
41f0: 65 2c 20 53 2e 6e 61 6d 65 0a 09 09 46 52 4f 4d e, S.name...FROM
4200: 20 74 61 67 20 54 2c 20 70 72 6f 6a 65 63 74 20 tag T, project
4210: 50 2c 20 73 79 6d 62 6f 6c 20 53 2c 0a 09 09 20 P, symbol S,...
4220: 20 20 20 20 28 53 45 4c 45 43 54 20 43 52 2e 72 (SELECT CR.r
4230: 69 64 20 41 53 20 72 69 64 2c 20 63 6f 75 6e 74 id AS rid, count
4240: 28 43 52 2e 63 69 64 29 20 41 53 20 63 6f 75 6e (CR.cid) AS coun
4250: 74 0a 09 09 20 20 20 20 20 20 46 52 4f 4d 20 63 t... FROM c
4260: 73 72 65 76 69 73 69 6f 6e 20 43 52 2c 20 63 68 srevision CR, ch
4270: 61 6e 67 65 73 65 74 20 43 0a 09 09 20 20 20 20 angeset C...
4280: 20 20 57 48 45 52 45 20 43 2e 74 79 70 65 20 3d WHERE C.type =
4290: 20 31 0a 09 09 20 20 20 20 20 20 41 4e 44 20 20 1... AND
42a0: 20 43 2e 63 69 64 20 3d 20 43 52 2e 63 69 64 0a C.cid = CR.cid.
42b0: 09 09 20 20 20 20 20 20 47 52 4f 55 50 20 42 59 .. GROUP BY
42c0: 20 43 52 2e 72 69 64 29 20 41 53 20 55 0a 09 09 CR.rid) AS U...
42d0: 57 48 45 52 45 20 55 2e 63 6f 75 6e 74 20 3e 20 WHERE U.count >
42e0: 31 0a 09 09 41 4e 44 20 20 20 54 2e 74 69 64 20 1...AND T.tid
42f0: 3d 20 55 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 = U.rid...AND
4300: 53 2e 73 69 64 20 3d 20 54 2e 73 69 64 20 20 20 S.sid = T.sid
4310: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 67 -- g
4320: 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 74 61 67 et symbol of tag
4330: 0a 09 09 41 4e 44 20 20 20 50 2e 70 69 64 20 3d ...AND P.pid =
4340: 20 53 2e 70 69 64 20 20 20 20 20 20 20 20 20 20 S.pid
4350: 20 20 20 20 20 2d 2d 20 67 65 74 20 70 72 6f 6a -- get proj
4360: 65 63 74 20 6f 66 20 73 79 6d 62 6f 6c 0a 09 20 ect of symbol..
4370: 20 20 20 7d 0a 09 69 66 20 30 20 7b 0a 09 20 20 }..if 0 {..
4380: 20 20 23 20 54 68 69 73 20 63 68 65 63 6b 20 69 # This check i
4390: 73 20 64 69 73 61 62 6c 65 64 20 66 6f 72 20 74 s disabled for t
43a0: 68 65 20 6d 6f 6d 65 6e 74 2e 20 41 70 70 61 72 he moment. Appar
43b0: 65 6e 74 6c 79 20 74 61 67 73 0a 09 20 20 20 20 ently tags..
43c0: 23 20 63 61 6e 20 63 72 6f 73 73 20 6c 69 6e 65 # can cross line
43d0: 73 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 s of development
43e0: 2c 20 61 74 20 6c 65 61 73 74 20 69 66 20 74 68 , at least if th
43f0: 65 20 69 6e 76 6f 6c 76 65 64 0a 09 20 20 20 20 e involved..
4400: 23 20 4c 4f 44 73 20 61 72 65 20 74 68 65 20 74 # LODs are the t
4410: 72 75 6e 6b 2c 20 61 6e 64 20 74 68 65 20 4e 54 runk, and the NT
4420: 44 42 2e 20 54 68 61 74 20 6d 61 6b 65 73 20 73 DB. That makes s
4430: 65 6e 73 65 2c 20 61 73 0a 09 20 20 20 20 23 20 ense, as.. #
4440: 74 68 65 20 4e 54 44 42 20 72 65 76 69 73 69 6f the NTDB revisio
4450: 6e 73 20 61 72 65 20 69 6e 69 74 69 61 6c 6c 79 ns are initially
4460: 20 6c 6f 67 69 63 61 6c 6c 79 20 61 20 70 61 72 logically a par
4470: 74 20 6f 66 20 74 68 65 0a 09 20 20 20 20 23 20 t of the.. #
4480: 74 72 75 6e 6b 2e 20 54 68 65 20 73 74 61 6e 64 trunk. The stand
4490: 61 72 64 20 63 68 65 63 6b 20 62 65 6c 6f 77 20 ard check below
44a0: 68 6f 77 65 76 65 72 20 64 6f 65 73 20 6e 6f 74 however does not
44b0: 20 63 61 70 74 75 72 65 0a 09 20 20 20 20 23 20 capture.. #
44c0: 74 68 69 73 2e 20 57 68 65 6e 20 49 20 6d 61 6e this. When I man
44d0: 61 67 65 20 74 6f 20 72 65 70 68 72 61 73 65 20 age to rephrase
44e0: 69 74 20 74 6f 20 61 63 63 65 70 74 20 74 68 69 it to accept thi
44f0: 73 20 74 79 70 65 0a 09 20 20 20 20 23 20 6f 66 s type.. # of
4500: 20 63 72 6f 73 73 2d 6f 76 65 72 20 69 74 20 77 cross-over it w
4510: 69 6c 6c 20 62 65 20 72 65 2d 61 63 74 69 76 61 ill be re-activa
4520: 74 65 64 2e 0a 0a 09 20 20 20 20 23 20 41 6c 6c ted.... # All
4530: 20 74 61 67 73 20 68 61 76 65 20 74 6f 20 61 67 tags have to ag
4540: 72 65 65 20 6f 6e 20 74 68 65 20 4c 4f 44 20 74 ree on the LOD t
4550: 68 65 69 72 20 63 68 61 6e 67 65 73 65 74 0a 09 heir changeset..
4560: 20 20 20 20 23 20 62 65 6c 6f 6e 67 73 20 74 6f # belongs to
4570: 2e 20 49 6e 20 6f 74 68 65 72 20 77 6f 72 64 73 . In other words
4580: 2c 20 61 6c 6c 20 74 61 67 73 20 69 6e 20 61 20 , all tags in a
4590: 63 68 61 6e 67 65 73 65 74 20 68 61 76 65 0a 09 changeset have..
45a0: 20 20 20 20 23 20 74 6f 20 72 65 66 65 72 20 74 # to refer t
45b0: 6f 20 74 68 65 20 73 61 6d 65 20 6c 69 6e 65 20 o the same line
45c0: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 2e 0a of development..
45d0: 09 20 20 20 20 23 0a 09 20 20 20 20 23 20 49 6e . #.. # In
45e0: 73 74 65 61 64 20 6f 66 20 6c 6f 6f 6b 69 6e 67 stead of looking
45f0: 20 61 74 20 61 6c 6c 20 70 61 69 72 73 20 6f 66 at all pairs of
4600: 20 74 61 67 73 20 69 6e 20 61 6c 6c 0a 09 20 20 tags in all..
4610: 20 20 23 20 63 68 61 6e 67 65 73 65 74 73 20 77 # changesets w
4620: 65 20 67 65 6e 65 72 61 74 65 20 74 68 65 20 64 e generate the d
4630: 69 73 74 69 6e 63 74 20 73 65 74 20 6f 66 20 61 istinct set of a
4640: 6c 6c 20 4c 4f 44 73 0a 09 20 20 20 20 23 20 72 ll LODs.. # r
4650: 65 66 65 72 65 6e 63 65 64 20 62 79 20 74 68 65 eferenced by the
4660: 20 74 61 67 73 20 6f 66 20 61 20 63 68 61 6e 67 tags of a chang
4670: 65 73 65 74 2c 20 6c 6f 6f 6b 20 66 6f 72 20 74 eset, look for t
4680: 68 6f 73 65 0a 09 20 20 20 20 23 20 77 69 74 68 hose.. # with
4690: 20 63 61 72 64 69 6e 61 6c 69 74 79 20 3e 20 31 cardinality > 1
46a0: 2c 20 61 6e 64 20 67 65 74 20 74 68 65 20 69 64 , and get the id
46b0: 65 6e 74 69 66 79 69 6e 67 0a 09 20 20 20 20 23 entifying.. #
46c0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 66 6f 72 information for
46d0: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 73 20 the changesets
46e0: 66 6f 75 6e 64 20 74 68 75 73 6c 79 2e 0a 09 20 found thusly...
46f0: 20 20 20 43 68 65 63 6b 43 53 20 5c 0a 09 09 7b CheckCS \...{
4700: 41 6c 6c 20 74 61 67 73 20 69 6e 20 61 20 63 68 All tags in a ch
4710: 61 6e 67 65 73 65 74 20 68 61 76 65 20 74 6f 20 angeset have to
4720: 62 65 6c 6f 6e 67 20 74 6f 20 74 68 65 20 73 61 belong to the sa
4730: 6d 65 20 4c 4f 44 7d 20 5c 0a 09 09 7b 3a 20 49 me LOD} \...{: I
4740: 74 73 20 74 61 67 73 20 64 69 73 61 67 72 65 65 ts tags disagree
4750: 20 61 62 6f 75 74 20 74 68 65 20 4c 4f 44 20 74 about the LOD t
4760: 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 7d 20 7b hey belong to} {
4770: 0a 09 09 20 20 20 20 53 45 4c 45 43 54 20 54 2e ... SELECT T.
4780: 6e 61 6d 65 2c 20 43 2e 63 69 64 0a 09 09 20 20 name, C.cid...
4790: 20 20 46 52 4f 4d 20 20 20 63 68 61 6e 67 65 73 FROM changes
47a0: 65 74 20 43 2c 20 63 73 74 79 70 65 20 54 0a 09 et C, cstype T..
47b0: 09 20 20 20 20 57 48 45 52 45 20 20 43 2e 63 69 . WHERE C.ci
47c0: 64 20 49 4e 20 28 53 45 4c 45 43 54 20 55 2e 63 d IN (SELECT U.c
47d0: 69 64 0a 09 09 09 09 20 20 20 20 20 46 52 4f 4d id..... FROM
47e0: 20 28 53 45 4c 45 43 54 20 44 49 53 54 49 4e 43 (SELECT DISTINC
47f0: 54 20 43 52 2e 63 69 64 20 41 53 20 63 69 64 2c T CR.cid AS cid,
4800: 20 54 2e 6c 6f 64 20 41 53 20 6c 6f 64 0a 09 09 T.lod AS lod...
4810: 09 09 09 20 20 20 46 52 4f 4d 20 20 20 63 73 72 ... FROM csr
4820: 65 76 69 73 69 6f 6e 20 43 52 2c 20 63 68 61 6e evision CR, chan
4830: 67 65 73 65 74 20 43 2c 20 74 61 67 20 54 0a 09 geset C, tag T..
4840: 09 09 09 09 20 20 20 57 48 45 52 45 20 20 43 52 .... WHERE CR
4850: 2e 72 69 64 20 3d 20 54 2e 74 69 64 0a 09 09 09 .rid = T.tid....
4860: 09 09 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 .. AND C.ci
4870: 64 20 3d 20 43 52 2e 63 69 64 0a 09 09 09 09 09 d = CR.cid......
4880: 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 AND C.type
4890: 20 3d 20 31 29 20 41 53 20 55 0a 09 09 09 09 20 = 1) AS U.....
48a0: 20 20 20 20 47 52 4f 55 50 20 42 59 20 55 2e 63 GROUP BY U.c
48b0: 69 64 20 48 41 56 49 4e 47 20 43 4f 55 4e 54 28 id HAVING COUNT(
48c0: 55 2e 6c 6f 64 29 20 3e 20 31 29 0a 09 09 20 20 U.lod) > 1)...
48d0: 20 20 41 4e 44 20 20 20 20 54 2e 74 69 64 20 3d AND T.tid =
48e0: 20 43 2e 74 79 70 65 0a 09 09 7d 0a 09 7d 0a 09 C.type...}..}..
48f0: 23 20 41 6c 6c 20 74 61 67 73 20 68 61 76 65 20 # All tags have
4900: 74 6f 20 61 67 72 65 65 20 6f 6e 20 74 68 65 20 to agree on the
4910: 70 72 6f 6a 65 63 74 20 74 68 65 69 72 20 63 68 project their ch
4920: 61 6e 67 65 73 65 74 0a 09 23 20 62 65 6c 6f 6e angeset..# belon
4930: 67 73 20 74 6f 2e 20 49 6e 20 6f 74 68 65 72 20 gs to. In other
4940: 77 6f 72 64 73 2c 20 61 6c 6c 20 74 61 67 73 20 words, all tags
4950: 69 6e 20 61 20 63 68 61 6e 67 65 73 65 74 20 68 in a changeset h
4960: 61 76 65 20 74 6f 0a 09 23 20 72 65 66 65 72 20 ave to..# refer
4970: 74 6f 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a to the same proj
4980: 65 63 74 2e 0a 09 23 0a 09 23 20 49 6e 73 74 65 ect...#..# Inste
4990: 61 64 20 6f 66 20 6c 6f 6f 6b 69 6e 67 20 61 74 ad of looking at
49a0: 20 61 6c 6c 20 70 61 69 72 73 20 6f 66 20 74 61 all pairs of ta
49b0: 67 73 20 69 6e 20 61 6c 6c 20 63 68 61 6e 67 65 gs in all change
49c0: 73 65 74 73 20 77 65 0a 09 23 20 67 65 6e 65 72 sets we..# gener
49d0: 61 74 65 20 74 68 65 20 64 69 73 74 69 6e 63 74 ate the distinct
49e0: 20 73 65 74 20 6f 66 20 61 6c 6c 20 70 72 6f 6a set of all proj
49f0: 65 63 74 73 20 72 65 66 65 72 65 6e 63 65 64 20 ects referenced
4a00: 62 79 20 74 68 65 0a 09 23 20 74 61 67 73 20 6f by the..# tags o
4a10: 66 20 61 20 63 68 61 6e 67 65 73 65 74 2c 20 6c f a changeset, l
4a20: 6f 6f 6b 20 66 6f 72 20 74 68 6f 73 65 20 77 69 ook for those wi
4a30: 74 68 20 63 61 72 64 69 6e 61 6c 69 74 79 20 3e th cardinality >
4a40: 20 31 2c 0a 09 23 20 61 6e 64 20 67 65 74 20 74 1,..# and get t
4a50: 68 65 20 69 64 65 6e 74 69 66 79 69 6e 67 20 69 he identifying i
4a60: 6e 66 6f 72 6d 61 74 69 6f 6e 20 66 6f 72 20 74 nformation for t
4a70: 68 65 20 63 68 61 6e 67 65 73 65 74 73 20 66 6f he changesets fo
4a80: 75 6e 64 0a 09 23 20 74 68 75 73 6c 79 2e 0a 09 und..# thusly...
4a90: 43 68 65 63 6b 43 53 20 5c 0a 09 20 20 20 20 7b CheckCS \.. {
4aa0: 41 6c 6c 20 74 61 67 73 20 69 6e 20 61 20 63 68 All tags in a ch
4ab0: 61 6e 67 65 73 65 74 20 68 61 76 65 20 74 6f 20 angeset have to
4ac0: 62 65 6c 6f 6e 67 20 74 6f 20 74 68 65 20 73 61 belong to the sa
4ad0: 6d 65 20 70 72 6f 6a 65 63 74 7d 20 5c 0a 09 20 me project} \..
4ae0: 20 20 20 7b 3a 20 49 74 73 20 74 61 67 73 20 64 {: Its tags d
4af0: 69 73 61 67 72 65 65 20 61 62 6f 75 74 20 74 68 isagree about th
4b00: 65 20 70 72 6f 6a 65 63 74 20 74 68 65 79 20 62 e project they b
4b10: 65 6c 6f 6e 67 20 74 6f 7d 20 7b 0a 09 09 53 45 elong to} {...SE
4b20: 4c 45 43 54 20 54 2e 6e 61 6d 65 2c 20 43 2e 63 LECT T.name, C.c
4b30: 69 64 0a 09 09 46 52 4f 4d 20 20 20 63 68 61 6e id...FROM chan
4b40: 67 65 73 65 74 20 43 2c 20 63 73 74 79 70 65 20 geset C, cstype
4b50: 54 0a 09 09 57 48 45 52 45 20 20 43 2e 63 69 64 T...WHERE C.cid
4b60: 20 49 4e 20 28 53 45 4c 45 43 54 20 55 2e 63 69 IN (SELECT U.ci
4b70: 64 0a 09 09 09 09 20 46 52 4f 4d 20 28 53 45 4c d..... FROM (SEL
4b80: 45 43 54 20 44 49 53 54 49 4e 43 54 20 43 52 2e ECT DISTINCT CR.
4b90: 63 69 64 20 41 53 20 63 69 64 2c 20 46 2e 70 69 cid AS cid, F.pi
4ba0: 64 20 41 53 20 70 69 64 0a 09 09 09 09 20 20 20 d AS pid.....
4bb0: 20 20 20 20 46 52 4f 4d 20 20 20 63 73 72 65 76 FROM csrev
4bc0: 69 73 69 6f 6e 20 43 52 2c 20 63 68 61 6e 67 65 ision CR, change
4bd0: 73 65 74 20 43 2c 20 74 61 67 20 54 2c 20 66 69 set C, tag T, fi
4be0: 6c 65 20 46 0a 09 09 09 09 20 20 20 20 20 20 20 le F.....
4bf0: 57 48 45 52 45 20 20 43 52 2e 72 69 64 20 3d 20 WHERE CR.rid =
4c00: 54 2e 74 69 64 0a 09 09 09 09 20 20 20 20 20 20 T.tid.....
4c10: 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 AND C.cid =
4c20: 43 52 2e 63 69 64 0a 09 09 09 09 20 20 20 20 20 CR.cid.....
4c30: 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 AND C.type
4c40: 3d 20 31 0a 09 09 09 09 20 20 20 20 20 20 20 41 = 1..... A
4c50: 4e 44 20 20 20 20 46 2e 66 69 64 20 20 3d 20 54 ND F.fid = T
4c60: 2e 66 69 64 29 20 41 53 20 55 0a 09 09 09 09 20 .fid) AS U.....
4c70: 47 52 4f 55 50 20 42 59 20 55 2e 63 69 64 20 48 GROUP BY U.cid H
4c80: 41 56 49 4e 47 20 43 4f 55 4e 54 28 55 2e 70 69 AVING COUNT(U.pi
4c90: 64 29 20 3e 20 31 29 0a 09 09 41 4e 44 20 20 20 d) > 1)...AND
4ca0: 20 54 2e 74 69 64 20 3d 20 43 2e 74 79 70 65 0a T.tid = C.type.
4cb0: 09 20 20 20 20 7d 0a 09 23 20 41 6c 6c 20 74 61 . }..# All ta
4cc0: 67 73 20 69 6e 20 61 20 73 69 6e 67 6c 65 20 63 gs in a single c
4cd0: 68 61 6e 67 65 73 65 74 20 68 61 76 65 20 74 6f hangeset have to
4ce0: 20 62 65 6c 6f 6e 67 20 74 6f 20 64 69 66 66 65 belong to diffe
4cf0: 72 65 6e 74 0a 09 23 20 66 69 6c 65 73 2e 20 43 rent..# files. C
4d00: 6f 6e 76 65 72 73 65 6c 79 3a 20 4e 6f 20 74 77 onversely: No tw
4d10: 6f 20 74 61 67 73 20 6f 66 20 61 20 73 69 6e 67 o tags of a sing
4d20: 6c 65 20 66 69 6c 65 20 61 72 65 20 61 6c 6c 6f le file are allo
4d30: 77 65 64 0a 09 23 20 74 6f 20 62 65 20 69 6e 20 wed..# to be in
4d40: 74 68 65 20 73 61 6d 65 20 63 68 61 6e 67 65 73 the same changes
4d50: 65 74 2e 0a 09 23 0a 09 23 20 49 6e 73 74 65 61 et...#..# Instea
4d60: 64 20 6f 66 20 6c 6f 6f 6b 69 6e 67 20 61 74 20 d of looking at
4d70: 61 6c 6c 20 70 61 69 72 73 20 6f 66 20 74 61 67 all pairs of tag
4d80: 73 20 69 6e 20 61 6c 6c 20 63 68 61 6e 67 65 73 s in all changes
4d90: 65 74 73 20 77 65 0a 09 23 20 67 65 6e 65 72 61 ets we..# genera
4da0: 74 65 20 74 68 65 20 64 69 73 74 69 6e 63 74 20 te the distinct
4db0: 73 65 74 20 6f 66 20 61 6c 6c 20 66 69 6c 65 73 set of all files
4dc0: 20 72 65 66 65 72 65 6e 63 65 64 20 62 79 20 74 referenced by t
4dd0: 68 65 0a 09 23 20 74 61 67 73 20 6f 66 20 61 20 he..# tags of a
4de0: 63 68 61 6e 67 65 73 65 74 2c 20 61 6e 64 20 6c changeset, and l
4df0: 6f 6f 6b 20 66 6f 72 20 74 68 6f 73 65 20 77 69 ook for those wi
4e00: 74 68 20 63 61 72 64 69 6e 61 6c 69 74 79 20 3c th cardinality <
4e10: 0a 09 23 20 74 68 65 20 63 61 72 64 69 6e 61 6c ..# the cardinal
4e20: 69 74 79 20 6f 66 20 74 68 65 20 73 65 74 20 6f ity of the set o
4e30: 66 20 74 61 67 73 2c 20 61 6e 64 20 67 65 74 20 f tags, and get
4e40: 74 68 65 20 69 64 65 6e 74 69 66 79 69 6e 67 0a the identifying.
4e50: 09 23 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 66 .# information f
4e60: 6f 72 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 or the changeset
4e70: 73 20 66 6f 75 6e 64 20 74 68 75 73 6c 79 2e 0a s found thusly..
4e80: 09 43 68 65 63 6b 43 53 20 5c 0a 09 20 20 20 20 .CheckCS \..
4e90: 7b 41 6c 6c 20 74 61 67 73 20 69 6e 20 61 20 63 {All tags in a c
4ea0: 68 61 6e 67 65 73 65 74 20 68 61 76 65 20 74 6f hangeset have to
4eb0: 20 62 65 6c 6f 6e 67 20 74 6f 20 64 69 66 66 65 belong to diffe
4ec0: 72 65 6e 74 20 66 69 6c 65 73 7d 20 5c 0a 09 20 rent files} \..
4ed0: 20 20 20 7b 3a 20 49 74 73 20 74 61 67 73 20 73 {: Its tags s
4ee0: 68 61 72 65 20 66 69 6c 65 73 7d 20 7b 0a 09 09 hare files} {...
4ef0: 53 45 4c 45 43 54 20 54 2e 6e 61 6d 65 2c 20 43 SELECT T.name, C
4f00: 2e 63 69 64 0a 09 09 46 52 4f 4d 20 20 20 63 68 .cid...FROM ch
4f10: 61 6e 67 65 73 65 74 20 43 2c 20 63 73 74 79 70 angeset C, cstyp
4f20: 65 20 54 0a 09 09 57 48 45 52 45 20 20 43 2e 63 e T...WHERE C.c
4f30: 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20 56 56 id IN (SELECT VV
4f40: 2e 63 69 64 0a 09 09 09 09 20 46 52 4f 4d 20 28 .cid..... FROM (
4f50: 53 45 4c 45 43 54 20 55 2e 63 69 64 20 61 73 20 SELECT U.cid as
4f60: 63 69 64 2c 20 43 4f 55 4e 54 20 28 55 2e 66 69 cid, COUNT (U.fi
4f70: 64 29 20 41 53 20 66 63 6f 75 6e 74 0a 09 09 09 d) AS fcount....
4f80: 09 20 20 20 20 20 20 20 46 52 4f 4d 20 28 53 45 . FROM (SE
4f90: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 20 43 52 LECT DISTINCT CR
4fa0: 2e 63 69 64 20 41 53 20 63 69 64 2c 20 54 2e 66 .cid AS cid, T.f
4fb0: 69 64 20 41 53 20 66 69 64 0a 09 09 09 09 09 20 id AS fid......
4fc0: 20 20 20 20 46 52 4f 4d 20 20 20 63 73 72 65 76 FROM csrev
4fd0: 69 73 69 6f 6e 20 43 52 2c 20 63 68 61 6e 67 65 ision CR, change
4fe0: 73 65 74 20 43 2c 20 74 61 67 20 54 0a 09 09 09 set C, tag T....
4ff0: 09 09 20 20 20 20 20 57 48 45 52 45 20 20 43 52 .. WHERE CR
5000: 2e 72 69 64 20 3d 20 54 2e 74 69 64 0a 09 09 09 .rid = T.tid....
5010: 09 09 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e .. AND C.
5020: 63 69 64 20 3d 20 43 52 2e 63 69 64 0a 09 09 09 cid = CR.cid....
5030: 09 09 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e .. AND C.
5040: 74 79 70 65 20 3d 20 31 0a 09 09 09 09 09 20 20 type = 1......
5050: 20 20 20 29 20 41 53 20 55 0a 09 09 09 09 20 20 ) AS U.....
5060: 20 20 20 20 20 47 52 4f 55 50 20 42 59 20 55 2e GROUP BY U.
5070: 63 69 64 29 20 41 53 20 55 55 2c 0a 09 09 09 09 cid) AS UU,.....
5080: 20 20 20 20 20 20 28 53 45 4c 45 43 54 20 56 2e (SELECT V.
5090: 63 69 64 20 41 53 20 63 69 64 2c 20 43 4f 55 4e cid AS cid, COUN
50a0: 54 20 28 56 2e 72 69 64 29 20 41 53 20 72 63 6f T (V.rid) AS rco
50b0: 75 6e 74 0a 09 09 09 09 20 20 20 20 20 20 20 46 unt..... F
50c0: 52 4f 4d 20 20 20 63 73 72 65 76 69 73 69 6f 6e ROM csrevision
50d0: 20 56 2c 20 63 68 61 6e 67 65 73 65 74 20 58 0a V, changeset X.
50e0: 09 09 09 09 20 20 20 20 20 20 20 57 48 45 52 45 .... WHERE
50f0: 20 20 58 2e 63 69 64 20 3d 20 56 2e 63 69 64 0a X.cid = V.cid.
5100: 09 09 09 09 20 20 20 20 20 20 20 41 4e 44 20 20 .... AND
5110: 20 20 58 2e 74 79 70 65 20 3d 20 31 0a 09 09 09 X.type = 1....
5120: 09 20 20 20 20 20 20 20 47 52 4f 55 50 20 42 59 . GROUP BY
5130: 20 56 2e 63 69 64 29 20 41 53 20 56 56 0a 09 09 V.cid) AS VV...
5140: 09 09 20 57 48 45 52 45 20 56 56 2e 63 69 64 20 .. WHERE VV.cid
5150: 3d 20 55 55 2e 63 69 64 0a 09 09 09 09 20 41 4e = UU.cid..... AN
5160: 44 20 20 20 55 55 2e 66 63 6f 75 6e 74 20 3c 20 D UU.fcount <
5170: 56 56 2e 72 63 6f 75 6e 74 29 0a 09 09 41 4e 44 VV.rcount)...AND
5180: 20 20 20 20 54 2e 74 69 64 20 3d 20 43 2e 74 79 T.tid = C.ty
5190: 70 65 0a 09 20 20 20 20 7d 0a 09 72 65 74 75 72 pe.. }..retur
51a0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f n. }.. pro
51b0: 63 20 42 72 61 6e 63 68 43 68 61 6e 67 65 73 65 c BranchChangese
51c0: 74 73 20 7b 7d 20 7b 0a 09 23 20 54 68 69 73 20 ts {} {..# This
51d0: 63 6f 64 65 20 70 65 72 66 6f 72 6d 73 20 61 20 code performs a
51e0: 6e 75 6d 62 65 72 20 6f 66 20 70 61 72 61 6e 6f number of parano
51f0: 69 64 20 63 68 65 63 6b 73 20 6f 66 20 74 68 65 id checks of the
5200: 0a 09 23 20 64 61 74 61 62 61 73 65 2c 20 73 65 ..# database, se
5210: 61 72 63 68 69 6e 67 20 66 6f 72 20 69 6e 63 6f arching for inco
5220: 6e 73 69 73 74 65 6e 74 20 63 68 61 6e 67 65 73 nsistent changes
5230: 65 74 2f 72 65 76 69 73 69 6f 6e 0a 09 23 20 69 et/revision..# i
5240: 6e 66 6f 72 6d 61 74 69 6f 6e 2e 0a 0a 09 75 70 nformation....up
5250: 76 61 72 20 31 20 6e 20 6e 20 3b 20 23 20 43 6f var 1 n n ; # Co
5260: 75 6e 74 65 72 20 66 6f 72 20 74 68 65 20 63 68 unter for the ch
5270: 65 63 6b 73 20 28 77 65 20 70 72 69 6e 74 20 61 ecks (we print a
5280: 6e 20 69 64 20 62 65 66 6f 72 65 0a 09 09 20 20 n id before...
5290: 20 20 20 20 23 20 74 68 65 20 6d 61 69 6e 20 6c # the main l
52a0: 61 62 65 6c 29 2e 0a 0a 09 23 20 46 69 6e 64 20 abel)....# Find
52b0: 61 6c 6c 20 62 72 61 6e 63 68 65 73 20 77 68 69 all branches whi
52c0: 63 68 20 61 72 65 20 6e 6f 74 20 75 73 65 64 20 ch are not used
52d0: 62 79 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 0a by at least one.
52e0: 09 23 20 63 68 61 6e 67 65 73 65 74 2e 0a 09 43 .# changeset...C
52f0: 68 65 63 6b 42 72 61 6e 63 68 20 5c 0a 09 20 20 heckBranch \..
5300: 20 20 7b 41 6c 6c 20 62 72 61 6e 63 68 65 73 20 {All branches
5310: 68 61 76 65 20 74 6f 20 62 65 20 75 73 65 64 20 have to be used
5320: 62 79 20 6c 65 61 73 74 20 6f 6e 65 20 63 68 61 by least one cha
5330: 6e 67 65 73 65 74 7d 20 5c 0a 09 20 20 20 20 7b ngeset} \.. {
5340: 69 73 20 6e 6f 74 20 75 73 65 64 20 62 79 20 61 is not used by a
5350: 20 63 68 61 6e 67 65 73 65 74 7d 20 7b 0a 09 09 changeset} {...
5360: 2d 2d 20 55 6e 75 73 65 64 20 62 72 61 6e 63 68 -- Unused branch
5370: 65 73 20 3d 20 41 6c 6c 20 62 72 61 6e 63 68 65 es = All branche
5380: 73 0a 09 09 2d 2d 20 20 20 20 20 20 20 20 20 20 s...--
5390: 20 20 20 20 20 20 20 2d 20 62 72 61 6e 63 68 65 - branche
53a0: 73 20 75 73 65 64 20 62 79 20 62 72 61 6e 63 68 s used by branch
53b0: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 09 09 2d changesets....-
53c0: 2d 0a 09 09 2d 2d 20 42 6f 74 68 20 73 65 74 73 -...-- Both sets
53d0: 20 63 61 6e 20 62 65 20 63 6f 6d 70 75 74 65 64 can be computed
53e0: 20 65 61 73 69 6c 79 2c 20 61 6e 64 20 73 75 62 easily, and sub
53f0: 74 72 61 63 74 65 64 0a 20 20 20 20 20 20 20 20 tracted.
5400: 20 20 20 20 20 20 20 20 2d 2d 20 66 72 6f 6d 20 -- from
5410: 65 61 63 68 20 6f 74 68 65 72 2e 20 54 68 65 6e each other. Then
5420: 20 77 65 20 63 61 6e 20 67 65 74 20 74 68 65 20 we can get the
5430: 61 73 73 6f 63 69 61 74 65 64 0a 20 20 20 20 20 associated.
5440: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 66 69 -- fi
5450: 6c 65 20 28 6e 61 6d 65 29 20 66 6f 72 20 64 69 le (name) for di
5460: 73 70 6c 61 79 2e 0a 0a 09 09 53 45 4c 45 43 54 splay.....SELECT
5470: 20 50 2e 6e 61 6d 65 2c 20 53 2e 6e 61 6d 65 0a P.name, S.name.
5480: 09 09 46 52 4f 4d 20 70 72 6f 6a 65 63 74 20 50 ..FROM project P
5490: 2c 20 62 72 61 6e 63 68 20 42 2c 20 73 79 6d 62 , branch B, symb
54a0: 6f 6c 20 53 0a 09 09 57 48 45 52 45 20 42 2e 62 ol S...WHERE B.b
54b0: 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20 62 69 id IN (SELECT bi
54c0: 64 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 d
54d0: 20 20 20 20 20 2d 2d 20 41 6c 6c 20 62 72 61 6e -- All bran
54e0: 63 68 65 73 0a 09 09 09 09 46 52 4f 4d 20 20 20 ches.....FROM
54f0: 62 72 61 6e 63 68 0a 09 09 09 09 45 58 43 45 50 branch.....EXCEP
5500: 54 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 T
5510: 20 20 20 20 20 20 20 20 20 2d 2d 20 73 75 62 74 -- subt
5520: 72 61 63 74 0a 09 09 09 09 53 45 4c 45 43 54 20 ract.....SELECT
5530: 43 52 2e 72 69 64 20 20 20 20 20 20 20 20 20 20 CR.rid
5540: 20 20 20 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 -- branch
5550: 65 73 20 75 73 65 64 0a 09 09 09 09 46 52 4f 4d es used.....FROM
5560: 20 20 20 63 73 72 65 76 69 73 69 6f 6e 20 43 52 csrevision CR
5570: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 09 , changeset C...
5580: 09 09 57 48 45 52 45 20 20 43 2e 63 69 64 20 3d ..WHERE C.cid =
5590: 20 43 52 2e 63 69 64 20 20 20 20 20 20 20 20 20 CR.cid
55a0: 2d 2d 20 62 79 20 61 6e 79 20 62 72 61 6e 63 68 -- by any branch
55b0: 0a 09 09 09 09 41 4e 44 20 20 20 20 43 2e 74 79 .....AND C.ty
55c0: 70 65 20 3d 20 32 29 20 20 20 20 20 20 20 20 20 pe = 2)
55d0: 20 20 20 2d 2d 20 63 68 61 6e 67 65 73 65 74 0a -- changeset.
55e0: 09 09 41 4e 44 20 20 20 53 2e 73 69 64 20 3d 20 ..AND S.sid =
55f0: 42 2e 73 69 64 20 20 20 20 20 20 20 20 20 20 20 B.sid
5600: 20 20 20 20 2d 2d 20 67 65 74 20 73 79 6d 62 6f -- get symbo
5610: 6c 20 6f 66 20 62 72 61 6e 63 68 0a 09 09 41 4e l of branch...AN
5620: 44 20 20 20 50 2e 70 69 64 20 3d 20 53 2e 70 69 D P.pid = S.pi
5630: 64 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 d
5640: 2d 2d 20 67 65 74 20 70 72 6f 6a 65 63 74 20 6f -- get project o
5650: 66 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20 7d 0a f symbol.. }.
5660: 09 23 20 46 69 6e 64 20 61 6c 6c 20 62 72 61 6e .# Find all bran
5670: 63 68 65 73 20 77 68 69 63 68 20 61 72 65 20 75 ches which are u
5680: 73 65 64 20 62 79 20 6d 6f 72 65 20 74 68 61 6e sed by more than
5690: 20 6f 6e 65 20 63 68 61 6e 67 65 73 65 74 2e 0a one changeset..
56a0: 09 43 68 65 63 6b 52 65 76 20 5c 0a 09 20 20 20 .CheckRev \..
56b0: 20 7b 41 6c 6c 20 62 72 61 6e 63 68 65 73 20 68 {All branches h
56c0: 61 76 65 20 74 6f 20 62 65 20 75 73 65 64 20 62 ave to be used b
56d0: 79 20 61 74 20 6d 6f 73 74 20 6f 6e 65 20 63 68 y at most one ch
56e0: 61 6e 67 65 73 65 74 7d 20 5c 0a 09 20 20 20 20 angeset} \..
56f0: 7b 69 73 20 75 73 65 64 20 62 79 20 6d 75 6c 74 {is used by mult
5700: 69 70 6c 65 20 63 68 61 6e 67 65 73 65 74 73 7d iple changesets}
5710: 20 7b 0a 09 09 2d 2d 20 50 72 69 6e 63 69 70 6c {...-- Principl
5720: 65 20 6f 66 20 6f 70 65 72 61 74 69 6f 6e 3a 20 e of operation:
5730: 47 65 74 20 61 6c 6c 20 62 72 61 6e 63 68 2f 63 Get all branch/c
5740: 68 61 6e 67 65 73 65 74 0a 20 20 20 20 20 20 20 hangeset.
5750: 20 20 20 20 20 20 20 20 20 2d 2d 20 70 61 69 72 -- pair
5760: 73 20 66 6f 72 20 61 6c 6c 20 62 72 61 6e 63 68 s for all branch
5770: 20 63 68 61 6e 67 65 73 65 74 73 2c 20 67 72 6f changesets, gro
5780: 75 70 20 62 79 20 74 61 67 20 74 6f 0a 20 20 20 up by tag to.
5790: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 --
57a0: 61 67 67 72 65 67 61 74 65 20 74 68 65 20 63 68 aggregate the ch
57b0: 61 6e 67 65 73 65 74 2c 20 63 6f 75 6e 74 69 6e angeset, countin
57c0: 67 20 74 68 65 6d 2e 20 46 72 6f 6d 20 74 68 65 g them. From the
57d0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
57e0: 20 2d 2d 20 72 65 73 75 6c 74 69 6e 67 20 62 72 -- resulting br
57f0: 61 6e 63 68 2f 63 6f 75 6e 74 20 74 61 62 6c 65 anch/count table
5800: 20 73 65 6c 65 63 74 20 74 68 6f 73 65 20 77 69 select those wi
5810: 74 68 20 6d 6f 72 65 0a 20 20 20 20 20 20 20 20 th more.
5820: 20 20 20 20 20 20 20 20 2d 2d 20 74 68 61 6e 20 -- than
5830: 6f 6e 65 20 75 73 65 72 2c 20 61 6e 64 20 67 65 one user, and ge
5840: 74 20 74 68 65 69 72 20 61 73 73 6f 63 69 61 74 t their associat
5850: 65 64 20 66 69 6c 65 20 28 6e 61 6d 65 29 0a 20 ed file (name).
5860: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d -
5870: 2d 20 66 6f 72 20 64 69 73 70 6c 61 79 2e 0a 0a - for display...
5880: 09 09 53 45 4c 45 43 54 20 50 2e 6e 61 6d 65 2c ..SELECT P.name,
5890: 20 53 2e 6e 61 6d 65 0a 09 09 46 52 4f 4d 20 62 S.name...FROM b
58a0: 72 61 6e 63 68 20 42 2c 20 70 72 6f 6a 65 63 74 ranch B, project
58b0: 20 50 2c 20 73 79 6d 62 6f 6c 20 53 2c 0a 09 09 P, symbol S,...
58c0: 20 20 20 20 20 28 53 45 4c 45 43 54 20 43 52 2e (SELECT CR.
58d0: 72 69 64 20 41 53 20 72 69 64 2c 20 63 6f 75 6e rid AS rid, coun
58e0: 74 28 43 52 2e 63 69 64 29 20 41 53 20 63 6f 75 t(CR.cid) AS cou
58f0: 6e 74 0a 09 09 20 20 20 20 20 20 46 52 4f 4d 20 nt... FROM
5900: 63 73 72 65 76 69 73 69 6f 6e 20 43 52 2c 20 63 csrevision CR, c
5910: 68 61 6e 67 65 73 65 74 20 43 0a 09 09 20 20 20 hangeset C...
5920: 20 20 20 57 48 45 52 45 20 43 2e 74 79 70 65 20 WHERE C.type
5930: 3d 20 32 0a 09 09 20 20 20 20 20 20 41 4e 44 20 = 2... AND
5940: 20 20 43 2e 63 69 64 20 3d 20 43 52 2e 63 69 64 C.cid = CR.cid
5950: 0a 09 09 20 20 20 20 20 20 47 52 4f 55 50 20 42 ... GROUP B
5960: 59 20 43 52 2e 72 69 64 20 29 20 41 53 20 55 0a Y CR.rid ) AS U.
5970: 09 09 57 48 45 52 45 20 55 2e 63 6f 75 6e 74 20 ..WHERE U.count
5980: 3e 20 31 0a 09 09 41 4e 44 20 20 20 42 2e 62 69 > 1...AND B.bi
5990: 64 20 3d 20 55 2e 72 69 64 0a 09 09 41 4e 44 20 d = U.rid...AND
59a0: 20 20 53 2e 73 69 64 20 3d 20 42 2e 73 69 64 20 S.sid = B.sid
59b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d --
59c0: 20 67 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 62 get symbol of b
59d0: 72 61 6e 63 68 0a 09 09 41 4e 44 20 20 20 50 2e ranch...AND P.
59e0: 70 69 64 20 3d 20 53 2e 70 69 64 20 20 20 20 20 pid = S.pid
59f0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 67 65 74 -- get
5a00: 20 70 72 6f 6a 65 63 74 20 6f 66 20 73 79 6d 62 project of symb
5a10: 6f 6c 0a 09 20 20 20 20 7d 0a 09 23 20 41 6c 6c ol.. }..# All
5a20: 20 62 72 61 6e 63 68 65 73 20 68 61 76 65 20 74 branches have t
5a30: 6f 20 61 67 72 65 65 20 6f 6e 20 74 68 65 20 4c o agree on the L
5a40: 4f 44 20 74 68 65 69 72 20 63 68 61 6e 67 65 73 OD their changes
5a50: 65 74 0a 09 23 20 62 65 6c 6f 6e 67 73 20 74 6f et..# belongs to
5a60: 2e 20 49 6e 20 6f 74 68 65 72 20 77 6f 72 64 73 . In other words
5a70: 2c 20 61 6c 6c 20 62 72 61 6e 63 68 65 73 20 69 , all branches i
5a80: 6e 20 61 20 63 68 61 6e 67 65 73 65 74 20 68 61 n a changeset ha
5a90: 76 65 0a 09 23 20 74 6f 20 72 65 66 65 72 20 74 ve..# to refer t
5aa0: 6f 20 74 68 65 20 73 61 6d 65 20 6c 69 6e 65 20 o the same line
5ab0: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 2e 0a of development..
5ac0: 09 23 0a 09 23 20 49 6e 73 74 65 61 64 20 6f 66 .#..# Instead of
5ad0: 20 6c 6f 6f 6b 69 6e 67 20 61 74 20 61 6c 6c 20 looking at all
5ae0: 70 61 69 72 73 20 6f 66 20 62 72 61 6e 63 68 65 pairs of branche
5af0: 73 20 69 6e 20 61 6c 6c 0a 09 23 20 63 68 61 6e s in all..# chan
5b00: 67 65 73 65 74 73 20 77 65 20 67 65 6e 65 72 61 gesets we genera
5b10: 74 65 20 74 68 65 20 64 69 73 74 69 6e 63 74 20 te the distinct
5b20: 73 65 74 20 6f 66 20 61 6c 6c 20 4c 4f 44 73 0a set of all LODs.
5b30: 09 23 20 72 65 66 65 72 65 6e 63 65 64 20 62 79 .# referenced by
5b40: 20 74 68 65 20 62 72 61 6e 63 68 65 73 20 6f 66 the branches of
5b50: 20 61 20 63 68 61 6e 67 65 73 65 74 2c 20 6c 6f a changeset, lo
5b60: 6f 6b 20 66 6f 72 20 74 68 6f 73 65 0a 09 23 20 ok for those..#
5b70: 77 69 74 68 20 63 61 72 64 69 6e 61 6c 69 74 79 with cardinality
5b80: 20 3e 20 31 2c 20 61 6e 64 20 67 65 74 20 74 68 > 1, and get th
5b90: 65 20 69 64 65 6e 74 69 66 79 69 6e 67 20 69 6e e identifying in
5ba0: 66 6f 72 6d 61 74 69 6f 6e 0a 09 23 20 66 6f 72 formation..# for
5bb0: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 73 20 the changesets
5bc0: 66 6f 75 6e 64 20 74 68 75 73 6c 79 2e 0a 09 43 found thusly...C
5bd0: 68 65 63 6b 43 53 20 5c 0a 09 20 20 20 20 7b 41 heckCS \.. {A
5be0: 6c 6c 20 62 72 61 6e 63 68 65 73 20 69 6e 20 61 ll branches in a
5bf0: 20 63 68 61 6e 67 65 73 65 74 20 68 61 76 65 20 changeset have
5c00: 74 6f 20 62 65 6c 6f 6e 67 20 74 6f 20 74 68 65 to belong to the
5c10: 20 73 61 6d 65 20 4c 4f 44 7d 20 5c 0a 09 20 20 same LOD} \..
5c20: 20 20 7b 3a 20 49 74 73 20 62 72 61 6e 63 68 65 {: Its branche
5c30: 73 20 64 69 73 61 67 72 65 65 20 61 62 6f 75 74 s disagree about
5c40: 20 74 68 65 20 4c 4f 44 20 74 68 65 79 20 62 65 the LOD they be
5c50: 6c 6f 6e 67 20 74 6f 7d 20 7b 0a 09 09 53 45 4c long to} {...SEL
5c60: 45 43 54 20 54 2e 6e 61 6d 65 2c 20 43 2e 63 69 ECT T.name, C.ci
5c70: 64 0a 09 09 46 52 4f 4d 20 20 20 63 68 61 6e 67 d...FROM chang
5c80: 65 73 65 74 20 43 2c 20 63 73 74 79 70 65 20 54 eset C, cstype T
5c90: 0a 09 09 57 48 45 52 45 20 20 43 2e 63 69 64 20 ...WHERE C.cid
5ca0: 49 4e 20 28 53 45 4c 45 43 54 20 55 2e 63 69 64 IN (SELECT U.cid
5cb0: 0a 09 09 09 09 20 46 52 4f 4d 20 28 53 45 4c 45 ..... FROM (SELE
5cc0: 43 54 20 44 49 53 54 49 4e 43 54 20 43 52 2e 63 CT DISTINCT CR.c
5cd0: 69 64 20 41 53 20 63 69 64 2c 20 42 2e 6c 6f 64 id AS cid, B.lod
5ce0: 20 41 53 20 6c 6f 64 0a 09 09 09 09 20 20 20 20 AS lod.....
5cf0: 20 20 20 46 52 4f 4d 20 20 20 63 73 72 65 76 69 FROM csrevi
5d00: 73 69 6f 6e 20 43 52 2c 20 63 68 61 6e 67 65 73 sion CR, changes
5d10: 65 74 20 43 2c 20 62 72 61 6e 63 68 20 42 0a 09 et C, branch B..
5d20: 09 09 09 20 20 20 20 20 20 20 57 48 45 52 45 20 ... WHERE
5d30: 20 43 52 2e 72 69 64 20 3d 20 42 2e 62 69 64 0a CR.rid = B.bid.
5d40: 09 09 09 09 20 20 20 20 20 20 20 41 4e 44 20 20 .... AND
5d50: 20 20 43 2e 63 69 64 20 3d 20 43 52 2e 63 69 64 C.cid = CR.cid
5d60: 0a 09 09 09 09 20 20 20 20 20 20 20 41 4e 44 20 ..... AND
5d70: 20 20 20 43 2e 74 79 70 65 20 3d 20 32 29 20 41 C.type = 2) A
5d80: 53 20 55 0a 09 09 09 09 20 47 52 4f 55 50 20 42 S U..... GROUP B
5d90: 59 20 55 2e 63 69 64 20 48 41 56 49 4e 47 20 43 Y U.cid HAVING C
5da0: 4f 55 4e 54 28 55 2e 6c 6f 64 29 20 3e 20 31 29 OUNT(U.lod) > 1)
5db0: 0a 09 09 41 4e 44 20 20 20 20 54 2e 74 69 64 20 ...AND T.tid
5dc0: 3d 20 43 2e 74 79 70 65 0a 09 20 20 20 20 7d 0a = C.type.. }.
5dd0: 09 23 20 41 6c 6c 20 62 72 61 6e 63 68 65 73 20 .# All branches
5de0: 68 61 76 65 20 74 6f 20 61 67 72 65 65 20 6f 6e have to agree on
5df0: 20 74 68 65 20 70 72 6f 6a 65 63 74 20 74 68 65 the project the
5e00: 69 72 20 63 68 61 6e 67 65 73 65 74 0a 09 23 20 ir changeset..#
5e10: 62 65 6c 6f 6e 67 73 20 74 6f 2e 20 49 6e 20 6f belongs to. In o
5e20: 74 68 65 72 20 77 6f 72 64 73 2c 20 61 6c 6c 20 ther words, all
5e30: 62 72 61 6e 63 68 65 73 20 69 6e 20 61 20 63 68 branches in a ch
5e40: 61 6e 67 65 73 65 74 20 68 61 76 65 0a 09 23 20 angeset have..#
5e50: 74 6f 20 72 65 66 65 72 20 74 6f 20 74 68 65 20 to refer to the
5e60: 73 61 6d 65 20 70 72 6f 6a 65 63 74 2e 0a 09 23 same project...#
5e70: 0a 09 23 20 49 6e 73 74 65 61 64 20 6f 66 20 6c ..# Instead of l
5e80: 6f 6f 6b 69 6e 67 20 61 74 20 61 6c 6c 20 70 61 ooking at all pa
5e90: 69 72 73 20 6f 66 20 62 72 61 6e 63 68 65 73 20 irs of branches
5ea0: 69 6e 20 61 6c 6c 0a 09 23 20 63 68 61 6e 67 65 in all..# change
5eb0: 73 65 74 73 20 77 65 20 67 65 6e 65 72 61 74 65 sets we generate
5ec0: 20 74 68 65 20 64 69 73 74 69 6e 63 74 20 73 65 the distinct se
5ed0: 74 20 6f 66 20 61 6c 6c 20 70 72 6f 6a 65 63 74 t of all project
5ee0: 73 0a 09 23 20 72 65 66 65 72 65 6e 63 65 64 20 s..# referenced
5ef0: 62 79 20 74 68 65 20 62 72 61 6e 63 68 65 73 20 by the branches
5f00: 6f 66 20 61 20 63 68 61 6e 67 65 73 65 74 2c 20 of a changeset,
5f10: 6c 6f 6f 6b 20 66 6f 72 20 74 68 6f 73 65 0a 09 look for those..
5f20: 23 20 77 69 74 68 20 63 61 72 64 69 6e 61 6c 69 # with cardinali
5f30: 74 79 20 3e 20 31 2c 20 61 6e 64 20 67 65 74 20 ty > 1, and get
5f40: 74 68 65 20 69 64 65 6e 74 69 66 79 69 6e 67 20 the identifying
5f50: 69 6e 66 6f 72 6d 61 74 69 6f 6e 0a 09 23 20 66 information..# f
5f60: 6f 72 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 or the changeset
5f70: 73 20 66 6f 75 6e 64 20 74 68 75 73 6c 79 2e 0a s found thusly..
5f80: 09 43 68 65 63 6b 43 53 20 5c 0a 09 20 20 20 20 .CheckCS \..
5f90: 7b 41 6c 6c 20 62 72 61 6e 63 68 65 73 20 69 6e {All branches in
5fa0: 20 61 20 63 68 61 6e 67 65 73 65 74 20 68 61 76 a changeset hav
5fb0: 65 20 74 6f 20 62 65 6c 6f 6e 67 20 74 6f 20 74 e to belong to t
5fc0: 68 65 20 73 61 6d 65 20 70 72 6f 6a 65 63 74 7d he same project}
5fd0: 20 5c 0a 09 20 20 20 20 7b 3a 20 49 74 73 20 62 \.. {: Its b
5fe0: 72 61 6e 63 68 65 73 20 64 69 73 61 67 72 65 65 ranches disagree
5ff0: 20 61 62 6f 75 74 20 74 68 65 20 70 72 6f 6a 65 about the proje
6000: 63 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 ct they belong t
6010: 6f 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 54 2e o} {...SELECT T.
6020: 6e 61 6d 65 2c 20 43 2e 63 69 64 0a 09 09 46 52 name, C.cid...FR
6030: 4f 4d 20 20 20 63 68 61 6e 67 65 73 65 74 20 43 OM changeset C
6040: 2c 20 63 73 74 79 70 65 20 54 0a 09 09 57 48 45 , cstype T...WHE
6050: 52 45 20 20 43 2e 63 69 64 20 49 4e 20 28 53 45 RE C.cid IN (SE
6060: 4c 45 43 54 20 55 2e 63 69 64 0a 09 09 09 09 20 LECT U.cid.....
6070: 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 44 49 53 FROM (SELECT DIS
6080: 54 49 4e 43 54 20 43 52 2e 63 69 64 20 41 53 20 TINCT CR.cid AS
6090: 63 69 64 2c 20 46 2e 70 69 64 20 41 53 20 70 69 cid, F.pid AS pi
60a0: 64 0a 09 09 09 09 20 20 20 20 20 20 20 46 52 4f d..... FRO
60b0: 4d 20 20 20 63 73 72 65 76 69 73 69 6f 6e 20 43 M csrevision C
60c0: 52 2c 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 R, changeset C,
60d0: 62 72 61 6e 63 68 20 42 2c 20 66 69 6c 65 20 46 branch B, file F
60e0: 0a 09 09 09 09 20 20 20 20 20 20 20 57 48 45 52 ..... WHER
60f0: 45 20 20 43 52 2e 72 69 64 20 3d 20 42 2e 62 69 E CR.rid = B.bi
6100: 64 0a 09 09 09 09 20 20 20 20 20 20 20 41 4e 44 d..... AND
6110: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 52 2e 63 C.cid = CR.c
6120: 69 64 0a 09 09 09 09 20 20 20 20 20 20 20 41 4e id..... AN
6130: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 32 0a D C.type = 2.
6140: 09 09 09 09 20 20 20 20 20 20 20 41 4e 44 20 20 .... AND
6150: 20 20 46 2e 66 69 64 20 20 3d 20 42 2e 66 69 64 F.fid = B.fid
6160: 29 20 41 53 20 55 0a 09 09 09 09 20 47 52 4f 55 ) AS U..... GROU
6170: 50 20 42 59 20 55 2e 63 69 64 20 48 41 56 49 4e P BY U.cid HAVIN
6180: 47 20 43 4f 55 4e 54 28 55 2e 70 69 64 29 20 3e G COUNT(U.pid) >
6190: 20 31 29 0a 09 09 41 4e 44 20 20 20 20 54 2e 74 1)...AND T.t
61a0: 69 64 20 3d 20 43 2e 74 79 70 65 0a 09 20 20 20 id = C.type..
61b0: 20 7d 0a 09 23 20 41 6c 6c 20 62 72 61 6e 63 68 }..# All branch
61c0: 65 73 20 69 6e 20 61 20 73 69 6e 67 6c 65 20 63 es in a single c
61d0: 68 61 6e 67 65 73 65 74 20 68 61 76 65 20 74 6f hangeset have to
61e0: 20 62 65 6c 6f 6e 67 20 74 6f 0a 09 23 20 64 69 belong to..# di
61f0: 66 66 65 72 65 6e 74 20 66 69 6c 65 73 2e 20 43 fferent files. C
6200: 6f 6e 76 65 72 73 65 6c 79 3a 20 4e 6f 20 74 77 onversely: No tw
6210: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 61 20 o branches of a
6220: 73 69 6e 67 6c 65 0a 09 23 20 66 69 6c 65 20 61 single..# file a
6230: 72 65 20 61 6c 6c 6f 77 65 64 20 74 6f 20 62 65 re allowed to be
6240: 20 69 6e 20 74 68 65 20 73 61 6d 65 20 63 68 61 in the same cha
6250: 6e 67 65 73 65 74 2e 0a 09 23 0a 09 23 20 49 6e ngeset...#..# In
6260: 73 74 65 61 64 20 6f 66 20 6c 6f 6f 6b 69 6e 67 stead of looking
6270: 20 61 74 20 61 6c 6c 20 70 61 69 72 73 20 6f 66 at all pairs of
6280: 20 62 72 61 6e 63 68 65 73 20 69 6e 20 61 6c 6c branches in all
6290: 0a 09 23 20 63 68 61 6e 67 65 73 65 74 73 20 77 ..# changesets w
62a0: 65 20 67 65 6e 65 72 61 74 65 20 74 68 65 20 64 e generate the d
62b0: 69 73 74 69 6e 63 74 20 73 65 74 20 6f 66 20 61 istinct set of a
62c0: 6c 6c 20 66 69 6c 65 73 0a 09 23 20 72 65 66 65 ll files..# refe
62d0: 72 65 6e 63 65 64 20 62 79 20 74 68 65 20 62 72 renced by the br
62e0: 61 6e 63 68 65 73 20 6f 66 20 61 20 63 68 61 6e anches of a chan
62f0: 67 65 73 65 74 2c 20 61 6e 64 20 6c 6f 6f 6b 20 geset, and look
6300: 66 6f 72 0a 09 23 20 74 68 6f 73 65 20 77 69 74 for..# those wit
6310: 68 20 63 61 72 64 69 6e 61 6c 69 74 79 20 3c 20 h cardinality <
6320: 74 68 65 20 63 61 72 64 69 6e 61 6c 69 74 79 20 the cardinality
6330: 6f 66 20 74 68 65 20 73 65 74 20 6f 66 0a 09 23 of the set of..#
6340: 20 62 72 61 6e 63 68 65 73 2c 20 61 6e 64 20 67 branches, and g
6350: 65 74 20 74 68 65 20 69 64 65 6e 74 69 66 79 69 et the identifyi
6360: 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 66 ng information f
6370: 6f 72 20 74 68 65 0a 09 23 20 63 68 61 6e 67 65 or the..# change
6380: 73 65 74 73 20 66 6f 75 6e 64 20 74 68 75 73 6c sets found thusl
6390: 79 2e 0a 09 43 68 65 63 6b 43 53 20 5c 0a 09 20 y...CheckCS \..
63a0: 20 20 20 7b 41 6c 6c 20 62 72 61 6e 63 68 65 73 {All branches
63b0: 20 69 6e 20 61 20 63 68 61 6e 67 65 73 65 74 20 in a changeset
63c0: 68 61 76 65 20 74 6f 20 62 65 6c 6f 6e 67 20 74 have to belong t
63d0: 6f 20 64 69 66 66 65 72 65 6e 74 20 66 69 6c 65 o different file
63e0: 73 7d 20 5c 0a 09 20 20 20 20 7b 3a 20 49 74 73 s} \.. {: Its
63f0: 20 62 72 61 6e 63 68 65 73 20 73 68 61 72 65 20 branches share
6400: 66 69 6c 65 73 7d 20 7b 0a 09 09 53 45 4c 45 43 files} {...SELEC
6410: 54 20 54 2e 6e 61 6d 65 2c 20 43 2e 63 69 64 0a T T.name, C.cid.
6420: 09 09 46 52 4f 4d 20 20 20 63 68 61 6e 67 65 73 ..FROM changes
6430: 65 74 20 43 2c 20 63 73 74 79 70 65 20 54 0a 09 et C, cstype T..
6440: 09 57 48 45 52 45 20 20 43 2e 63 69 64 20 49 4e .WHERE C.cid IN
6450: 20 28 53 45 4c 45 43 54 20 56 56 2e 63 69 64 0a (SELECT VV.cid.
6460: 09 09 09 09 20 46 52 4f 4d 20 28 53 45 4c 45 43 .... FROM (SELEC
6470: 54 20 55 2e 63 69 64 20 61 73 20 63 69 64 2c 20 T U.cid as cid,
6480: 43 4f 55 4e 54 20 28 55 2e 66 69 64 29 20 41 53 COUNT (U.fid) AS
6490: 20 66 63 6f 75 6e 74 0a 09 09 09 09 20 20 20 20 fcount.....
64a0: 20 20 20 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 FROM (SELECT
64b0: 44 49 53 54 49 4e 43 54 20 43 52 2e 63 69 64 20 DISTINCT CR.cid
64c0: 41 53 20 63 69 64 2c 20 42 2e 66 69 64 20 41 53 AS cid, B.fid AS
64d0: 20 66 69 64 0a 09 09 09 09 09 20 20 20 20 20 46 fid...... F
64e0: 52 4f 4d 20 20 20 63 73 72 65 76 69 73 69 6f 6e ROM csrevision
64f0: 20 43 52 2c 20 63 68 61 6e 67 65 73 65 74 20 43 CR, changeset C
6500: 2c 20 62 72 61 6e 63 68 20 42 0a 09 09 09 09 09 , branch B......
6510: 20 20 20 20 20 57 48 45 52 45 20 20 43 52 2e 72 WHERE CR.r
6520: 69 64 20 3d 20 42 2e 62 69 64 0a 09 09 09 09 09 id = B.bid......
6530: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 AND C.ci
6540: 64 20 3d 20 43 52 2e 63 69 64 0a 09 09 09 09 09 d = CR.cid......
6550: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 AND C.ty
6560: 70 65 20 3d 20 32 0a 09 09 09 09 09 20 20 20 20 pe = 2......
6570: 20 29 20 41 53 20 55 0a 09 09 09 09 20 20 20 20 ) AS U.....
6580: 20 20 20 47 52 4f 55 50 20 42 59 20 55 2e 63 69 GROUP BY U.ci
6590: 64 29 20 41 53 20 55 55 2c 0a 09 09 09 09 20 20 d) AS UU,.....
65a0: 20 20 20 20 28 53 45 4c 45 43 54 20 56 2e 63 69 (SELECT V.ci
65b0: 64 20 41 53 20 63 69 64 2c 20 43 4f 55 4e 54 20 d AS cid, COUNT
65c0: 28 56 2e 72 69 64 29 20 41 53 20 72 63 6f 75 6e (V.rid) AS rcoun
65d0: 74 0a 09 09 09 09 20 20 20 20 20 20 20 46 52 4f t..... FRO
65e0: 4d 20 20 20 63 73 72 65 76 69 73 69 6f 6e 20 56 M csrevision V
65f0: 2c 20 63 68 61 6e 67 65 73 65 74 20 58 0a 09 09 , changeset X...
6600: 09 09 20 20 20 20 20 20 20 57 48 45 52 45 20 20 .. WHERE
6610: 58 2e 63 69 64 20 3d 20 56 2e 63 69 64 0a 09 09 X.cid = V.cid...
6620: 09 09 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 .. AND
6630: 58 2e 74 79 70 65 20 3d 20 32 0a 09 09 09 09 20 X.type = 2.....
6640: 20 20 20 20 20 20 47 52 4f 55 50 20 42 59 20 56 GROUP BY V
6650: 2e 63 69 64 29 20 41 53 20 56 56 0a 09 09 09 09 .cid) AS VV.....
6660: 20 57 48 45 52 45 20 56 56 2e 63 69 64 20 3d 20 WHERE VV.cid =
6670: 55 55 2e 63 69 64 0a 09 09 09 09 20 41 4e 44 20 UU.cid..... AND
6680: 20 20 55 55 2e 66 63 6f 75 6e 74 20 3c 20 56 56 UU.fcount < VV
6690: 2e 72 63 6f 75 6e 74 29 0a 09 09 41 4e 44 20 20 .rcount)...AND
66a0: 20 20 54 2e 74 69 64 20 3d 20 43 2e 74 79 70 65 T.tid = C.type
66b0: 0a 09 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a .. }..return.
66c0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
66d0: 5f 5f 5f 55 6e 75 73 65 64 43 68 61 6e 67 65 73 ___UnusedChanges
66e0: 65 74 43 68 65 63 6b 73 5f 5f 5f 20 7b 7d 20 7b etChecks___ {} {
66f0: 0a 09 23 20 54 68 69 73 20 63 6f 64 65 20 70 65 ..# This code pe
6700: 72 66 6f 72 6d 73 20 61 20 6e 75 6d 62 65 72 20 rforms a number
6710: 6f 66 20 70 61 72 61 6e 6f 69 64 20 63 68 65 63 of paranoid chec
6720: 6b 73 20 6f 66 20 74 68 65 0a 09 23 20 64 61 74 ks of the..# dat
6730: 61 62 61 73 65 2c 20 73 65 61 72 63 68 69 6e 67 abase, searching
6740: 20 66 6f 72 20 69 6e 63 6f 6e 73 69 73 74 65 6e for inconsisten
6750: 74 20 63 68 61 6e 67 65 73 65 74 2f 72 65 76 69 t changeset/revi
6760: 73 69 6f 6e 0a 09 23 20 69 6e 66 6f 72 6d 61 74 sion..# informat
6770: 69 6f 6e 2e 0a 0a 09 72 65 74 75 72 6e 20 3b 20 ion....return ;
6780: 23 20 44 69 73 61 62 6c 65 64 20 66 6f 72 20 6e # Disabled for n
6790: 6f 77 2c 20 62 6f 74 74 6c 65 6e 65 63 6b 73 20 ow, bottlenecks
67a0: 2e 2e 2e 0a 0a 09 75 70 76 61 72 20 31 20 6e 20 ......upvar 1 n
67b0: 6e 20 3b 20 23 20 43 6f 75 6e 74 65 72 20 66 6f n ; # Counter fo
67c0: 72 20 74 68 65 20 63 68 65 63 6b 73 20 28 77 65 r the checks (we
67d0: 20 70 72 69 6e 74 20 61 6e 20 69 64 20 62 65 66 print an id bef
67e0: 6f 72 65 0a 09 09 20 20 20 20 20 20 23 20 74 68 ore... # th
67f0: 65 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a 0a e main label)...
6800: 09 23 20 54 68 65 20 6e 65 78 74 20 74 77 6f 20 .# The next two
6810: 63 68 65 63 6b 73 20 61 72 65 20 42 4f 54 54 4c checks are BOTTL
6820: 45 4e 45 43 4b 53 2e 20 49 6e 20 65 73 73 65 6e ENECKS. In essen
6830: 63 65 20 77 65 20 61 72 65 0a 09 23 20 63 68 65 ce we are..# che
6840: 63 6b 69 6e 67 20 65 61 63 68 20 73 79 6d 62 6f cking each symbo
6850: 6c 20 63 68 61 6e 67 65 73 65 74 20 6f 6e 65 20 l changeset one
6860: 62 79 20 6f 6e 65 2e 0a 0a 09 23 20 54 4f 44 4f by one....# TODO
6870: 3a 20 54 72 79 20 74 6f 20 72 65 70 68 72 61 73 : Try to rephras
6880: 65 20 74 68 65 20 63 68 65 63 6b 73 20 74 6f 20 e the checks to
6890: 6d 61 6b 65 20 6d 6f 72 65 20 75 73 65 20 6f 66 make more use of
68a0: 0a 09 23 20 69 6e 64 69 63 65 73 2c 20 73 65 74 ..# indices, set
68b0: 20 61 6e 64 20 73 74 72 65 61 6d 20 6f 70 65 72 and stream oper
68c0: 61 74 69 6f 6e 73 2e 0a 0a 09 23 20 41 6c 6c 20 ations....# All
68d0: 72 65 76 69 73 69 6f 6e 73 20 75 73 65 64 20 62 revisions used b
68e0: 79 20 74 61 67 20 73 79 6d 62 6f 6c 20 63 68 61 y tag symbol cha
68f0: 6e 67 65 73 65 74 73 20 68 61 76 65 20 74 6f 20 ngesets have to
6900: 68 61 76 65 20 74 68 65 0a 09 23 20 63 68 61 6e have the..# chan
6910: 67 65 73 65 74 27 73 20 74 61 67 20 61 73 73 6f geset's tag asso
6920: 63 69 61 74 65 64 20 77 69 74 68 20 74 68 65 6d ciated with them
6930: 2e 0a 09 43 68 65 63 6b 52 65 76 43 53 20 5c 0a ...CheckRevCS \.
6940: 09 20 20 20 20 7b 41 6c 6c 20 72 65 76 69 73 69 . {All revisi
6950: 6f 6e 73 20 75 73 65 64 20 62 79 20 74 61 67 20 ons used by tag
6960: 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 symbol changeset
6970: 73 20 68 61 76 65 20 74 6f 20 68 61 76 65 20 74 s have to have t
6980: 68 65 20 63 68 61 6e 67 65 73 65 74 27 73 20 74 he changeset's t
6990: 61 67 20 61 74 74 61 63 68 65 64 20 74 6f 20 74 ag attached to t
69a0: 68 65 6d 7d 20 5c 0a 09 20 20 20 20 7b 64 6f 65 hem} \.. {doe
69b0: 73 20 6e 6f 74 20 68 61 76 65 20 74 68 65 20 74 s not have the t
69c0: 61 67 20 6f 66 20 69 74 73 20 73 79 6d 62 6f 6c ag of its symbol
69d0: 20 63 68 61 6e 67 65 73 65 74 20 40 20 61 74 74 changeset @ att
69e0: 61 63 68 65 64 20 74 6f 20 69 74 7d 20 7b 0a 09 ached to it} {..
69f0: 09 53 45 4c 45 43 54 20 43 54 2e 6e 61 6d 65 2c .SELECT CT.name,
6a00: 20 43 2e 63 69 64 2c 20 46 2e 6e 61 6d 65 2c 20 C.cid, F.name,
6a10: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20 20 63 R.rev...FROM c
6a20: 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 74 79 hangeset C, csty
6a30: 70 65 20 43 54 2c 20 72 65 76 69 73 69 6f 6e 20 pe CT, revision
6a40: 52 2c 20 66 69 6c 65 20 46 2c 20 63 73 72 65 76 R, file F, csrev
6a50: 69 73 69 6f 6e 20 43 52 2c 20 74 61 67 20 54 0a ision CR, tag T.
6a60: 09 09 57 48 45 52 45 20 20 43 2e 74 79 70 65 20 ..WHERE C.type
6a70: 3d 20 31 20 20 20 20 20 20 20 2d 2d 20 73 79 6d = 1 -- sym
6a80: 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 20 6f bol changesets o
6a90: 6e 6c 79 0a 09 09 41 4e 44 20 20 20 20 43 2e 73 nly...AND C.s
6aa0: 72 63 20 20 3d 20 54 2e 73 69 64 20 20 20 2d 2d rc = T.sid --
6ab0: 20 74 61 67 20 6f 6e 6c 79 2c 20 6c 69 6e 6b 65 tag only, linke
6ac0: 64 20 62 79 20 73 79 6d 62 6f 6c 20 69 64 20 0a d by symbol id .
6ad0: 09 09 41 4e 44 20 20 20 20 43 2e 63 69 64 20 20 ..AND C.cid
6ae0: 3d 20 43 52 2e 63 69 64 20 20 2d 2d 20 63 68 61 = CR.cid -- cha
6af0: 6e 67 65 73 65 74 20 2d 2d 3e 20 69 74 73 20 72 ngeset --> its r
6b00: 65 76 69 73 69 6f 6e 73 0a 09 09 41 4e 44 20 20 evisions...AND
6b10: 20 20 52 2e 72 69 64 20 20 3d 20 43 52 2e 72 69 R.rid = CR.ri
6b20: 64 20 20 2d 2d 20 6c 6f 6f 6b 20 61 74 20 74 68 d -- look at th
6b30: 65 20 72 65 76 69 73 69 6f 6e 73 0a 09 09 2d 2d e revisions...--
6b40: 20 61 6e 64 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 and look for th
6b50: 65 20 74 61 67 20 61 6d 6f 6e 67 20 74 68 65 20 e tag among the
6b60: 61 74 74 61 63 68 65 64 20 6f 6e 65 73 2e 0a 09 attached ones...
6b70: 09 41 4e 44 20 20 20 20 54 2e 73 69 64 20 4e 4f .AND T.sid NO
6b80: 54 20 49 4e 20 28 53 45 4c 45 43 54 20 54 42 2e T IN (SELECT TB.
6b90: 73 69 64 0a 09 09 09 09 20 20 20 20 20 46 52 4f sid..... FRO
6ba0: 4d 20 20 20 74 61 67 20 54 42 0a 09 09 09 09 20 M tag TB.....
6bb0: 20 20 20 20 57 48 45 52 45 20 20 54 42 2e 72 65 WHERE TB.re
6bc0: 76 20 3d 20 52 2e 72 69 64 29 0a 09 09 41 4e 44 v = R.rid)...AND
6bd0: 20 20 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 R.fid = F.fi
6be0: 64 20 20 20 20 2d 2d 20 67 65 74 20 66 69 6c 65 d -- get file
6bf0: 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 of revision..
6c00: 20 20 7d 0a 0a 09 23 20 41 6c 6c 20 72 65 76 69 }...# All revi
6c10: 73 69 6f 6e 73 20 75 73 65 64 20 62 79 20 62 72 sions used by br
6c20: 61 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68 61 6e anch symbol chan
6c30: 67 65 73 65 74 73 20 68 61 76 65 20 74 6f 20 68 gesets have to h
6c40: 61 76 65 0a 09 23 20 74 68 65 20 63 68 61 6e 67 ave..# the chang
6c50: 65 73 65 74 27 73 20 62 72 61 6e 63 68 20 61 73 eset's branch as
6c60: 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 sociated with th
6c70: 65 6d 2e 0a 0a 09 43 68 65 63 6b 52 65 76 43 53 em....CheckRevCS
6c80: 20 5c 0a 09 20 20 20 20 7b 41 6c 6c 20 72 65 76 \.. {All rev
6c90: 69 73 69 6f 6e 73 20 75 73 65 64 20 62 79 20 62 isions used by b
6ca0: 72 61 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68 61 ranch symbol cha
6cb0: 6e 67 65 73 65 74 73 20 68 61 76 65 20 74 6f 20 ngesets have to
6cc0: 68 61 76 65 20 74 68 65 20 63 68 61 6e 67 65 73 have the changes
6cd0: 65 74 27 73 20 62 72 61 6e 63 68 20 61 74 74 61 et's branch atta
6ce0: 63 68 65 64 20 74 6f 20 74 68 65 6d 7d 20 5c 0a ched to them} \.
6cf0: 09 20 20 20 20 7b 64 6f 65 73 20 6e 6f 74 20 68 . {does not h
6d00: 61 76 65 20 74 68 65 20 62 72 61 6e 63 68 20 6f ave the branch o
6d10: 66 20 69 74 73 20 73 79 6d 62 6f 6c 20 63 68 61 f its symbol cha
6d20: 6e 67 65 73 65 74 20 40 20 61 74 74 61 63 68 65 ngeset @ attache
6d30: 64 20 74 6f 20 69 74 7d 20 7b 0a 09 09 53 45 4c d to it} {...SEL
6d40: 45 43 54 20 43 54 2e 6e 61 6d 65 2c 20 43 2e 63 ECT CT.name, C.c
6d50: 69 64 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 id, F.name, R.re
6d60: 76 2c 20 43 2e 63 69 64 0a 09 09 46 52 4f 4d 20 v, C.cid...FROM
6d70: 20 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 changeset C, c
6d80: 73 74 79 70 65 20 43 54 2c 20 72 65 76 69 73 69 stype CT, revisi
6d90: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 63 73 on R, file F, cs
6da0: 72 65 76 69 73 69 6f 6e 20 43 52 2c 20 62 72 61 revision CR, bra
6db0: 6e 63 68 20 42 0a 09 09 57 48 45 52 45 20 20 43 nch B...WHERE C
6dc0: 2e 74 79 70 65 20 3d 20 31 20 20 20 20 20 20 20 .type = 1
6dd0: 2d 2d 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 -- symbol change
6de0: 73 65 74 73 20 6f 6e 6c 79 0a 09 09 41 4e 44 20 sets only...AND
6df0: 20 20 20 43 2e 73 72 63 20 20 3d 20 42 2e 73 69 C.src = B.si
6e00: 64 20 20 20 2d 2d 20 62 72 61 6e 63 68 65 73 20 d -- branches
6e10: 6f 6e 6c 79 0a 09 09 41 4e 44 20 20 20 20 43 2e only...AND C.
6e20: 63 69 64 20 20 3d 20 43 52 2e 63 69 64 20 20 2d cid = CR.cid -
6e30: 2d 20 63 68 61 6e 67 65 73 65 74 20 2d 2d 3e 20 - changeset -->
6e40: 69 74 73 20 72 65 76 69 73 69 6f 6e 73 0a 09 09 its revisions...
6e50: 41 4e 44 20 20 20 20 52 2e 72 69 64 20 20 3d 20 AND R.rid =
6e60: 43 52 2e 72 69 64 20 20 2d 2d 20 6c 6f 6f 6b 20 CR.rid -- look
6e70: 61 74 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 at the revisions
6e80: 0a 09 09 2d 2d 20 61 6e 64 20 6c 6f 6f 6b 20 66 ...-- and look f
6e90: 6f 72 20 74 68 65 20 62 72 61 6e 63 68 20 61 6d or the branch am
6ea0: 6f 6e 67 20 74 68 65 20 61 74 74 61 63 68 65 64 ong the attached
6eb0: 20 6f 6e 65 73 2e 0a 09 09 41 4e 44 20 20 20 20 ones....AND
6ec0: 42 2e 73 69 64 20 4e 4f 54 20 49 4e 20 28 53 45 B.sid NOT IN (SE
6ed0: 4c 45 43 54 20 42 42 2e 73 69 64 0a 09 09 09 09 LECT BB.sid.....
6ee0: 20 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e FROM bran
6ef0: 63 68 20 42 42 0a 09 09 09 09 20 20 20 20 20 57 ch BB..... W
6f00: 48 45 52 45 20 20 42 42 2e 72 6f 6f 74 20 3d 20 HERE BB.root =
6f10: 52 2e 72 69 64 29 0a 09 09 41 4e 44 20 20 20 20 R.rid)...AND
6f20: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 20 20 20 R.fid = F.fid
6f30: 20 2d 2d 20 67 65 74 20 66 69 6c 65 20 6f 66 20 -- get file of
6f40: 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 7d 0a revision.. }.
6f50: 0a 09 23 20 54 4f 44 4f 0a 09 23 20 54 68 65 20 ..# TODO..# The
6f60: 73 74 61 74 65 20 68 61 73 20 74 6f 20 63 6f 6e state has to con
6f70: 74 61 69 6e 20 61 74 20 6c 65 61 73 74 20 6f 6e tain at least on
6f80: 65 20 74 61 67 20 73 79 6d 62 6f 6c 20 63 68 61 e tag symbol cha
6f90: 6e 67 65 73 65 74 0a 09 23 20 66 6f 72 20 61 6c ngeset..# for al
6fa0: 6c 20 6b 6e 6f 77 6e 20 74 61 67 73 2e 0a 0a 09 l known tags....
6fb0: 23 20 54 4f 44 4f 0a 09 23 20 54 68 65 20 73 74 # TODO..# The st
6fc0: 61 74 65 20 68 61 73 20 74 6f 20 63 6f 6e 74 61 ate has to conta
6fd0: 69 6e 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 in at least one
6fe0: 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68 branch symbol ch
6ff0: 61 6e 67 65 73 65 74 0a 09 23 20 66 6f 72 20 61 angeset..# for a
7000: 6c 6c 20 6b 6e 6f 77 6e 20 62 72 61 6e 63 68 65 ll known branche
7010: 73 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d s...return. }
7020: 0a 0a 0a 20 20 20 20 70 72 6f 63 20 43 68 65 63 ... proc Chec
7030: 6b 52 65 76 20 7b 68 65 61 64 65 72 20 6c 61 62 kRev {header lab
7040: 65 6c 20 73 71 6c 7d 20 7b 0a 09 75 70 76 61 72 el sql} {..upvar
7050: 20 31 20 6e 20 6e 0a 09 73 65 74 20 6f 6b 20 31 1 n n..set ok 1
7060: 0a 09 66 6f 72 65 61 63 68 20 7b 66 6e 61 6d 65 ..foreach {fname
7070: 20 72 65 76 6e 72 7d 20 5b 73 74 61 74 65 20 72 revnr} [state r
7080: 75 6e 20 24 73 71 6c 5d 20 7b 0a 09 20 20 20 20 un $sql] {..
7090: 73 65 74 20 6f 6b 20 30 0a 09 20 20 20 20 74 72 set ok 0.. tr
70a0: 6f 75 62 6c 65 20 66 61 74 61 6c 20 22 24 7b 72 ouble fatal "${r
70b0: 65 76 6e 72 7d 3a 3a 24 66 6e 61 6d 65 20 24 6c evnr}::$fname $l
70c0: 61 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 abel"..}..log wr
70d0: 69 74 65 20 35 20 69 6e 74 65 67 72 69 74 79 20 ite 5 integrity
70e0: 7b 5c 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 {\[[format %02d
70f0: 5b 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 [incr n]]\] [exp
7100: 72 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 r {$ok ? "Ok
7110: 22 20 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e " : "Failed"}] .
7120: 2e 2e 20 24 68 65 61 64 65 72 7d 0a 09 72 65 74 .. $header}..ret
7130: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 urn. }.. p
7140: 72 6f 63 20 43 68 65 63 6b 54 61 67 20 7b 68 65 roc CheckTag {he
7150: 61 64 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20 ader label sql}
7160: 7b 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09 {..upvar 1 n n..
7170: 73 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63 set ok 1..foreac
7180: 68 20 7b 70 6e 61 6d 65 20 73 6e 61 6d 65 7d 20 h {pname sname}
7190: 5b 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d [state run $sql]
71a0: 20 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30 {.. set ok 0
71b0: 0a 09 20 20 20 20 74 72 6f 75 62 6c 65 20 66 61 .. trouble fa
71c0: 74 61 6c 20 22 3c 24 70 6e 61 6d 65 20 74 61 67 tal "<$pname tag
71d0: 20 27 24 73 6e 61 6d 65 27 3e 20 24 6c 61 62 65 '$sname'> $labe
71e0: 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 74 65 l"..}..log write
71f0: 20 35 20 69 6e 74 65 67 72 69 74 79 20 7b 5c 5b 5 integrity {\[
7200: 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 5b 69 6e [format %02d [in
7210: 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20 7b cr n]]\] [expr {
7220: 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 20 3a $ok ? "Ok " :
7230: 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e 20 "Failed"}] ...
7240: 24 68 65 61 64 65 72 7d 0a 09 72 65 74 75 72 6e $header}..return
7250: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 . }.. proc
7260: 20 43 68 65 63 6b 42 72 61 6e 63 68 20 7b 68 65 CheckBranch {he
7270: 61 64 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20 ader label sql}
7280: 7b 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09 {..upvar 1 n n..
7290: 73 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63 set ok 1..foreac
72a0: 68 20 7b 70 6e 61 6d 65 20 73 6e 61 6d 65 7d 20 h {pname sname}
72b0: 5b 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d [state run $sql]
72c0: 20 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30 {.. set ok 0
72d0: 0a 09 20 20 20 20 74 72 6f 75 62 6c 65 20 66 61 .. trouble fa
72e0: 74 61 6c 20 22 3c 24 70 6e 61 6d 65 20 62 72 61 tal "<$pname bra
72f0: 6e 63 68 20 27 24 73 6e 61 6d 65 27 3e 20 24 6c nch '$sname'> $l
7300: 61 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 abel"..}..log wr
7310: 69 74 65 20 35 20 69 6e 74 65 67 72 69 74 79 20 ite 5 integrity
7320: 7b 5c 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 {\[[format %02d
7330: 5b 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 [incr n]]\] [exp
7340: 72 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 r {$ok ? "Ok
7350: 22 20 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e " : "Failed"}] .
7360: 2e 2e 20 24 68 65 61 64 65 72 7d 0a 09 72 65 74 .. $header}..ret
7370: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 urn. }.. p
7380: 72 6f 63 20 43 68 65 63 6b 43 53 20 7b 68 65 61 roc CheckCS {hea
7390: 64 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20 7b der label sql} {
73a0: 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09 73 ..upvar 1 n n..s
73b0: 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63 68 et ok 1..foreach
73c0: 20 7b 63 74 79 70 65 20 63 69 64 7d 20 5b 73 74 {ctype cid} [st
73d0: 61 74 65 20 72 75 6e 20 24 73 71 6c 5d 20 7b 0a ate run $sql] {.
73e0: 09 20 20 20 20 73 65 74 20 6f 6b 20 30 0a 09 20 . set ok 0..
73f0: 20 20 20 74 72 6f 75 62 6c 65 20 66 61 74 61 6c trouble fatal
7400: 20 22 3c 24 63 74 79 70 65 20 24 63 69 64 3e 20 "<$ctype $cid>
7410: 24 6c 61 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 $label"..}..log
7420: 77 72 69 74 65 20 35 20 69 6e 74 65 67 72 69 74 write 5 integrit
7430: 79 20 7b 5c 5b 5b 66 6f 72 6d 61 74 20 25 30 32 y {\[[format %02
7440: 64 20 5b 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 d [incr n]]\] [e
7450: 78 70 72 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 xpr {$ok ? "Ok
7460: 20 20 22 20 3a 20 22 46 61 69 6c 65 64 22 7d 5d " : "Failed"}]
7470: 20 2e 2e 2e 20 24 68 65 61 64 65 72 7d 0a 09 72 ... $header}..r
7480: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
7490: 20 70 72 6f 63 20 43 68 65 63 6b 52 65 76 43 53 proc CheckRevCS
74a0: 20 7b 68 65 61 64 65 72 20 6c 61 62 65 6c 20 73 {header label s
74b0: 71 6c 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 6e ql} {..upvar 1 n
74c0: 20 6e 0a 09 73 65 74 20 6f 6b 20 31 0a 09 66 6f n..set ok 1..fo
74d0: 72 65 61 63 68 20 7b 63 73 74 79 70 65 20 63 73 reach {cstype cs
74e0: 69 64 20 66 6e 61 6d 65 20 72 65 76 6e 72 7d 20 id fname revnr}
74f0: 5b 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d [state run $sql]
7500: 20 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30 {.. set ok 0
7510: 0a 09 20 20 20 20 73 65 74 20 62 20 22 3c 24 63 .. set b "<$c
7520: 73 74 79 70 65 20 24 63 73 69 64 3e 22 0a 09 20 stype $csid>"..
7530: 20 20 20 74 72 6f 75 62 6c 65 20 66 61 74 61 6c trouble fatal
7540: 20 22 24 66 6e 61 6d 65 20 3c 24 72 65 76 6e 72 "$fname <$revnr
7550: 3e 20 5b 73 74 72 69 6e 67 20 6d 61 70 20 5b 6c > [string map [l
7560: 69 73 74 20 40 20 24 62 5d 20 24 6c 61 62 65 6c ist @ $b] $label
7570: 5d 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 74 65 ]"..}..log write
7580: 20 35 20 69 6e 74 65 67 72 69 74 79 20 7b 5c 5b 5 integrity {\[
7590: 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 5b 69 6e [format %02d [in
75a0: 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20 7b cr n]]\] [expr {
75b0: 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 20 3a $ok ? "Ok " :
75c0: 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e 20 "Failed"}] ...
75d0: 24 68 65 61 64 65 72 7d 0a 09 72 65 74 75 72 6e $header}..return
75e0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 . }.. # #
75f0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
7600: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
7610: 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 ###. ## Confi
7620: 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 guration.. pr
7630: 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 agma -hasinstanc
7640: 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 es no ; # sing
7650: 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 leton. pragma
7660: 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20 -hastypeinfo
7670: 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f no ; # no intro
7680: 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 spection. pra
7690: 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73 74 gma -hastypedest
76a0: 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 roy no ; # immor
76b0: 74 61 6c 0a 0a 20 20 20 20 23 20 23 20 23 23 20 tal.. # # ##
76c0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 ### ##### ######
76d0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
76e0: 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 .}..namespace ev
76f0: 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a al ::vc::fossil:
7700: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 20 7b 0a 20 :import::cvs {.
7710: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 70 namespace exp
7720: 6f 72 74 20 69 6e 74 65 67 72 69 74 79 0a 20 20 ort integrity.
7730: 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c namespace eval
7740: 20 69 6e 74 65 67 72 69 74 79 20 7b 0a 09 6e 61 integrity {..na
7750: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a mespace import :
7760: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 :vc::fossil::imp
7770: 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a ort::cvs::state.
7780: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 .namespace impor
7790: 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 t ::vc::tools::t
77a0: 72 6f 75 62 6c 65 0a 09 6e 61 6d 65 73 70 61 63 rouble..namespac
77b0: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 e import ::vc::t
77c0: 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72 ools::log..log r
77d0: 65 67 69 73 74 65 72 20 69 6e 74 65 67 72 69 74 egister integrit
77e0: 79 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 y. }.}..# # #
77f0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
7800: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
7810: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
7820: 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 61 64 ########.## Read
7830: 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 69 y..package provi
7840: 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 de vc::fossil::i
7850: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 mport::cvs::inte
7860: 67 72 69 74 79 20 31 2e 30 0a 72 65 74 75 72 6e grity 1.0.return
7870: 0a .