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 20 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 .## ..snit::type
0480: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 ::vc::fossil::i
0490: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 mport::cvs::inte
04a0: 67 72 69 74 79 20 7b 0a 20 20 20 20 23 20 23 20 grity {. # #
04b0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
04c0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
04d0: 23 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69 ###. ## Publi
04e0: 63 20 41 50 49 0a 0a 20 20 20 20 74 79 70 65 6d c API.. typem
04f0: 65 74 68 6f 64 20 73 74 72 69 63 74 20 7b 7d 20 ethod strict {}
0500: 7b 0a 09 73 65 74 20 6e 20 30 0a 09 41 6c 6c 42 {..set n 0..AllB
0510: 75 74 4d 65 74 61 0a 09 4d 65 74 61 0a 09 72 65 utMeta..Meta..re
0520: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
0530: 74 79 70 65 6d 65 74 68 6f 64 20 6d 65 74 61 72 typemethod metar
0540: 65 6c 61 78 65 64 20 7b 7d 20 7b 0a 09 73 65 74 elaxed {} {..set
0550: 20 6e 20 30 0a 09 41 6c 6c 42 75 74 4d 65 74 61 n 0..AllButMeta
0560: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a ..return. }..
0570: 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 # # ## ### #
0580: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 #### ######## ##
0590: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 ###########.
05a0: 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68 ## Internal meth
05b0: 6f 64 73 0a 0a 20 20 20 20 70 72 6f 63 20 41 6c ods.. proc Al
05c0: 6c 42 75 74 4d 65 74 61 20 7b 7d 20 7b 0a 09 23 lButMeta {} {..#
05d0: 20 54 68 69 73 20 63 6f 64 65 20 70 65 72 66 6f This code perfo
05e0: 72 6d 73 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 rms a number of
05f0: 70 61 72 61 6e 6f 69 64 20 63 68 65 63 6b 73 20 paranoid checks
0600: 6f 66 20 74 68 65 0a 09 23 20 64 61 74 61 62 61 of the..# databa
0610: 73 65 2c 20 73 65 61 72 63 68 69 6e 67 20 66 6f se, searching fo
0620: 72 20 69 6e 63 6f 6e 73 69 73 74 65 6e 74 20 63 r inconsistent c
0630: 72 6f 73 73 2d 72 65 66 65 72 65 6e 63 65 73 2e ross-references.
0640: 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 69 6e ..log write 4 in
0650: 74 65 67 72 69 74 79 20 7b 43 68 65 63 6b 20 64 tegrity {Check d
0660: 61 74 61 62 61 73 65 20 63 6f 6e 73 69 73 74 65 atabase consiste
0670: 6e 63 79 7d 0a 0a 09 75 70 76 61 72 20 31 20 6e ncy}...upvar 1 n
0680: 20 6e 20 3b 20 23 20 43 6f 75 6e 74 65 72 20 66 n ; # Counter f
0690: 6f 72 20 74 68 65 20 63 68 65 63 6b 73 20 28 77 or the checks (w
06a0: 65 20 70 72 69 6e 74 20 61 6e 20 69 64 20 62 65 e print an id be
06b0: 66 6f 72 65 0a 09 09 20 20 20 20 20 20 23 20 74 fore... # t
06c0: 68 65 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a he main label)..
06d0: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 ..# Find all rev
06e0: 69 73 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73 isions which dis
06f0: 61 67 72 65 65 20 77 69 74 68 20 74 68 65 69 72 agree with their
0700: 20 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 line of..# deve
0710: 6c 6f 70 6d 65 6e 74 20 61 62 6f 75 74 20 74 68 lopment about th
0720: 65 20 70 72 6f 6a 65 63 74 20 74 68 65 79 20 61 e project they a
0730: 72 65 20 6f 77 6e 65 64 20 62 79 2e 0a 09 43 68 re owned by...Ch
0740: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 eck \.. {Revi
0750: 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 sions and their
0760: 4c 4f 44 73 20 68 61 76 65 20 74 6f 20 62 65 20 LODs have to be
0770: 69 6e 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a in the same proj
0780: 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 ect} \.. {dis
0790: 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 agrees with its
07a0: 4c 4f 44 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67 LOD about owning
07b0: 20 70 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 53 45 project} {...SE
07c0: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 LECT F.name, R.r
07d0: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 ev...FROM revisi
07e0: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 73 79 on R, file F, sy
07f0: 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52 45 20 52 mbol S...WHERE R
0800: 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 .fid = F.fid...A
0810: 4e 44 20 20 20 52 2e 6c 6f 64 20 3d 20 53 2e 73 ND R.lod = S.s
0820: 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70 69 64 id...AND F.pid
0830: 20 21 3d 20 53 2e 70 69 64 0a 09 09 3b 0a 09 20 != S.pid...;..
0840: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c }..# Find all
0850: 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68 revisions which
0860: 20 64 69 73 67 72 65 65 20 77 69 74 68 20 74 68 disgree with th
0870: 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 61 62 eir meta data ab
0880: 6f 75 74 0a 09 23 20 74 68 65 20 70 72 6f 6a 65 out..# the proje
0890: 63 74 20 74 68 65 79 20 61 72 65 20 6f 77 6e 65 ct they are owne
08a0: 64 20 62 79 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 d by...Check \..
08b0: 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 {Revisions a
08c0: 6e 64 20 74 68 65 69 72 20 6d 65 74 61 20 64 61 nd their meta da
08d0: 74 61 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e ta have to be in
08e0: 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a 65 63 the same projec
08f0: 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67 t} \.. {disag
0900: 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6d 65 rees with its me
0910: 74 61 20 64 61 74 61 20 61 62 6f 75 74 20 6f 77 ta data about ow
0920: 6e 69 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b 0a ning project} {.
0930: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c ..SELECT F.name,
0940: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 R.rev...FROM re
0950: 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 vision R, file F
0960: 2c 20 6d 65 74 61 20 4d 0a 09 09 57 48 45 52 45 , meta M...WHERE
0970: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 R.fid = F.fid..
0980: 09 41 4e 44 20 20 20 52 2e 6d 69 64 20 3d 20 4d .AND R.mid = M
0990: 2e 6d 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70 .mid...AND F.p
09a0: 69 64 20 21 3d 20 4d 2e 70 69 64 0a 09 09 3b 0a id != M.pid...;.
09b0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 . }..# Find a
09c0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 ll revisions wit
09d0: 68 20 61 20 70 72 69 6d 61 72 79 20 63 68 69 6c h a primary chil
09e0: 64 20 77 68 69 63 68 20 64 69 73 61 67 72 65 65 d which disagree
09f0: 73 0a 09 23 20 61 62 6f 75 74 20 74 68 65 20 66 s..# about the f
0a00: 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 ile they belong
0a10: 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 to...Check \..
0a20: 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 {Revisions and
0a30: 20 74 68 65 69 72 20 70 72 69 6d 61 72 79 20 63 their primary c
0a40: 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 hildren have to
0a50: 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 66 be in the same f
0a60: 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 ile} \.. {dis
0a70: 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 agrees with its
0a80: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 61 62 primary child ab
0a90: 6f 75 74 20 74 68 65 20 6f 77 6e 69 6e 67 20 66 out the owning f
0aa0: 69 6c 65 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 ile} {...SELECT
0ab0: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 F.name, R.rev...
0ac0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c FROM revision R,
0ad0: 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c revision C, fil
0ae0: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 e F...WHERE R.fi
0af0: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 d = F.fid...AND
0b00: 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 R.child IS NOT
0b10: 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e NULL...AND R.
0b20: 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 child = C.rid...
0b30: 41 4e 44 20 20 20 43 2e 66 69 64 20 21 3d 20 52 AND C.fid != R
0b40: 2e 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a .fid...;.. }.
0b50: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 ..# Find all rev
0b60: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62 72 isions with a br
0b70: 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 anch parent symb
0b80: 6f 6c 20 77 68 6f 73 65 20 70 61 72 65 6e 74 0a ol whose parent.
0b90: 09 23 20 64 69 73 61 67 72 65 65 73 20 61 62 6f .# disagrees abo
0ba0: 75 74 20 74 68 65 20 66 69 6c 65 20 74 68 65 79 ut the file they
0bb0: 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 belong to...Che
0bc0: 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 ck \.. {Revis
0bd0: 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 62 ions and their b
0be0: 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 20 68 ranch children h
0bf0: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65 ave to be in the
0c00: 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a 09 20 same file} \..
0c10: 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e {at the begin
0c20: 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e ning of its bran
0c30: 63 68 20 61 6e 64 20 69 74 73 20 70 61 72 65 6e ch and its paren
0c40: 74 20 64 69 73 61 67 72 65 65 20 61 62 6f 75 74 t disagree about
0c50: 20 74 68 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65 the owning file
0c60: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e } {...SELECT F.n
0c70: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f ame, R.rev...FRO
0c80: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 M revision R, re
0c90: 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46 vision P, file F
0ca0: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d ...WHERE R.fid =
0cb0: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 F.fid...AND R
0cc0: 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 .bparent IS NOT
0cd0: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 NULL...AND R.p
0ce0: 61 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a 09 09 arent = P.rid...
0cf0: 41 4e 44 20 20 20 52 2e 66 69 64 20 21 3d 20 50 AND R.fid != P
0d00: 2e 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a .fid...;.. }.
0d10: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 .# Find all revi
0d20: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e sions with a non
0d30: 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69 63 -NTDB child whic
0d40: 68 20 64 69 73 61 67 72 65 65 73 0a 09 23 20 61 h disagrees..# a
0d50: 62 6f 75 74 20 74 68 65 20 66 69 6c 65 20 74 68 bout the file th
0d60: 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 ey belong to...C
0d70: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 heck \.. {Rev
0d80: 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 isions and their
0d90: 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 72 non-NTDB childr
0da0: 65 6e 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e en have to be in
0db0: 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 the same file}
0dc0: 5c 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65 65 \.. {disagree
0dd0: 73 20 77 69 74 68 20 69 74 73 20 6e 6f 6e 2d 4e s with its non-N
0de0: 54 44 42 20 63 68 69 6c 64 20 61 62 6f 75 74 20 TDB child about
0df0: 74 68 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65 7d the owning file}
0e00: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 {...SELECT F.na
0e10: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d me, R.rev...FROM
0e20: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 revision R, rev
0e30: 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a ision C, file F.
0e40: 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 ..WHERE R.fid =
0e50: 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e F.fid...AND R.
0e60: 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e dbchild IS NOT N
0e70: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 ULL...AND R.db
0e80: 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 child = C.rid...
0e90: 41 4e 44 20 20 20 43 2e 66 69 64 20 21 3d 20 52 AND C.fid != R
0ea0: 2e 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a .fid...;.. }.
0eb0: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 .# Find all revi
0ec0: 73 69 6f 6e 73 20 77 68 69 63 68 20 68 61 76 65 sions which have
0ed0: 20 61 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 a primary child
0ee0: 2c 20 62 75 74 20 74 68 65 20 63 68 69 6c 64 0a , but the child.
0ef0: 09 23 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 .# does not have
0f00: 20 74 68 65 6d 20 61 73 20 70 61 72 65 6e 74 2e them as parent.
0f10: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b ..Check \.. {
0f20: 52 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 Revisions have t
0f30: 6f 20 62 65 20 70 61 72 65 6e 74 73 20 6f 66 20 o be parents of
0f40: 74 68 65 69 72 20 70 72 69 6d 61 72 79 20 63 68 their primary ch
0f50: 69 6c 64 72 65 6e 7d 20 5c 0a 09 20 20 20 20 7b ildren} \.. {
0f60: 69 73 20 6e 6f 74 20 74 68 65 20 70 61 72 65 6e is not the paren
0f70: 74 20 6f 66 20 69 74 73 20 70 72 69 6d 61 72 79 t of its primary
0f80: 20 63 68 69 6c 64 7d 20 7b 0a 09 09 53 45 4c 45 child} {...SELE
0f90: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 CT F.name, R.rev
0fa0: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e ...FROM revision
0fb0: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 R, revision C,
0fc0: 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 file F...WHERE R
0fd0: 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 .fid = F.fid...A
0fe0: 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 ND R.child IS
0ff0: 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 NOT NULL...AND
1000: 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 R.child = C.rid
1010: 0a 09 09 41 4e 44 20 20 20 43 2e 70 61 72 65 6e ...AND C.paren
1020: 74 20 21 3d 20 52 2e 72 69 64 0a 09 09 3b 0a 09 t != R.rid...;..
1030: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c }..# Find al
1040: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 l revisions whic
1050: 68 20 68 61 76 65 20 61 20 70 72 69 6d 72 61 72 h have a primrar
1060: 79 20 63 68 69 6c 64 2c 20 62 75 74 20 74 68 65 y child, but the
1070: 0a 09 23 20 63 68 69 6c 64 20 68 61 73 20 61 20 ..# child has a
1080: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 branch parent sy
1090: 6d 62 6f 6c 20 6d 61 6b 69 6e 67 20 74 68 65 6d mbol making them
10a0: 20 62 72 61 63 68 20 73 74 61 72 74 65 72 73 2e brach starters.
10b0: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b ..Check \.. {
10c0: 50 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e Primary children
10d0: 20 6f 66 20 72 65 76 69 73 69 6f 6e 73 20 6d 75 of revisions mu
10e0: 73 74 20 6e 6f 74 20 73 74 61 72 74 20 62 72 61 st not start bra
10f0: 6e 63 68 65 73 7d 20 5c 0a 09 20 20 20 20 7b 69 nches} \.. {i
1100: 73 20 70 61 72 65 6e 74 20 6f 66 20 61 20 70 72 s parent of a pr
1110: 69 6d 61 72 79 20 63 68 69 6c 64 20 77 68 69 63 imary child whic
1120: 68 20 69 73 20 74 68 65 20 62 65 67 69 6e 6e 69 h is the beginni
1130: 6e 67 20 6f 66 20 61 20 62 72 61 6e 63 68 7d 20 ng of a branch}
1140: 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d {...SELECT F.nam
1150: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 e, R.rev...FROM
1160: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 revision R, revi
1170: 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 sion C, file F..
1180: 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 .WHERE R.fid = F
1190: 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 63 .fid...AND R.c
11a0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c hild IS NOT NULL
11b0: 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 ...AND R.child
11c0: 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 = C.rid...AND
11d0: 20 43 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f C.bparent IS NO
11e0: 54 20 4e 55 4c 4c 0a 09 09 3b 0a 09 20 20 20 20 T NULL...;..
11f0: 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 }..# Find all re
1200: 76 69 73 69 6f 6e 73 20 77 69 74 68 6f 75 74 20 visions without
1210: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 branch parent sy
1220: 6d 62 6f 6c 20 77 68 69 63 68 20 68 61 76 65 20 mbol which have
1230: 61 0a 09 23 20 70 61 72 65 6e 74 2c 20 62 75 74 a..# parent, but
1240: 20 74 68 65 20 70 61 72 65 6e 74 20 64 6f 65 73 the parent does
1250: 20 6e 6f 74 20 68 61 76 65 20 74 68 65 6d 20 61 not have them a
1260: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e s primary child.
1270: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b ..Check \.. {
1280: 52 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 Revisions have t
1290: 6f 20 62 65 20 70 72 69 6d 61 72 79 20 63 68 69 o be primary chi
12a0: 6c 64 72 65 6e 20 6f 66 20 74 68 65 69 72 20 70 ldren of their p
12b0: 61 72 65 6e 74 73 2c 20 69 66 20 61 6e 79 7d 20 arents, if any}
12c0: 5c 0a 09 20 20 20 20 7b 69 73 20 6e 6f 74 20 74 \.. {is not t
12d0: 68 65 20 63 68 69 6c 64 20 6f 66 20 69 74 73 20 he child of its
12e0: 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45 4c 45 parent} {...SELE
12f0: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 CT F.name, R.rev
1300: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e ...FROM revision
1310: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 50 2c 20 R, revision P,
1320: 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 file F...WHERE R
1330: 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 .fid = F.fid...A
1340: 4e 44 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 ND R.bparent I
1350: 53 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 S NULL...AND R
1360: 2e 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e .parent IS NOT N
1370: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 ULL...AND R.pa
1380: 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a 09 09 41 rent = P.rid...A
1390: 4e 44 20 20 20 50 2e 63 68 69 6c 64 20 21 3d 20 ND P.child !=
13a0: 52 2e 72 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d R.rid...;.. }
13b0: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 ..# Find all rev
13c0: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62 72 isions with a br
13d0: 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 anch parent symb
13e0: 6f 6c 20 77 68 69 63 68 20 64 6f 20 6e 6f 74 0a ol which do not.
13f0: 09 23 20 68 61 76 65 20 61 20 70 61 72 65 6e 74 .# have a parent
1400: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 ...Check \..
1410: 7b 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67 {Branch starting
1420: 20 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 revisions have
1430: 74 6f 20 68 61 76 65 20 61 20 70 61 72 65 6e 74 to have a parent
1440: 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65 } \.. {at the
1450: 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 beginning of it
1460: 73 20 62 72 61 6e 63 68 20 68 61 73 20 6e 6f 20 s branch has no
1470: 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45 4c 45 parent} {...SELE
1480: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 CT F.name, R.rev
1490: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e ...FROM revision
14a0: 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 R, file F...WHE
14b0: 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 RE R.fid = F.fid
14c0: 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65 ...AND R.bpare
14d0: 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 nt IS NOT NULL..
14e0: 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 .AND R.parent
14f0: 49 53 20 4e 55 4c 4c 0a 09 09 3b 0a 09 20 20 20 IS NULL...;..
1500: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 }..# Find all r
1510: 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 evisions with a
1520: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 branch parent sy
1530: 6d 62 6f 6c 20 77 68 6f 73 65 20 70 61 72 65 6e mbol whose paren
1540: 74 0a 09 23 20 68 61 73 20 74 68 65 6d 20 61 73 t..# has them as
1550: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a primary child..
1560: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 42 .Check \.. {B
1570: 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67 20 72 ranch starting r
1580: 65 76 69 73 69 6f 6e 73 20 6d 75 73 74 20 6e 6f evisions must no
1590: 74 20 62 65 20 70 72 69 6d 61 72 79 20 63 68 69 t be primary chi
15a0: 6c 64 72 65 6e 20 6f 66 20 74 68 65 69 72 20 70 ldren of their p
15b0: 61 72 65 6e 74 73 7d 20 5c 0a 09 20 20 20 20 7b arents} \.. {
15c0: 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 at the beginning
15d0: 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68 20 69 of its branch i
15e0: 73 20 74 68 65 20 70 72 69 6d 61 72 79 20 63 68 s the primary ch
15f0: 69 6c 64 20 6f 66 20 69 74 73 20 70 61 72 65 6e ild of its paren
1600: 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e t} {...SELECT F.
1610: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 name, R.rev...FR
1620: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 OM revision R, r
1630: 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20 evision P, file
1640: 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 F...WHERE R.fid
1650: 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 = F.fid...AND
1660: 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 R.bparent IS NOT
1670: 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e NULL...AND R.
1680: 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 parent IS NOT NU
1690: 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72 LL...AND R.par
16a0: 65 6e 74 20 3d 20 50 2e 72 69 64 0a 09 09 41 4e ent = P.rid...AN
16b0: 44 20 20 20 50 2e 63 68 69 6c 64 20 3d 20 52 2e D P.child = R.
16c0: 72 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 rid...;.. }..
16d0: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 # Find all revis
16e0: 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d ions with a non-
16f0: 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69 63 68 NTDB child which
1700: 20 61 72 65 20 6e 6f 74 20 6f 6e 0a 09 23 20 74 are not on..# t
1710: 68 65 20 4e 54 44 42 2e 0a 09 43 68 65 63 6b 20 he NTDB...Check
1720: 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 74 6f 20 \.. {NTDB to
1730: 74 72 75 6e 6b 20 74 72 61 6e 73 69 74 69 6f 6e trunk transition
1740: 20 68 61 73 20 74 6f 20 62 65 67 69 6e 20 6f 6e has to begin on
1750: 20 4e 54 44 42 7d 20 5c 0a 09 20 20 20 20 7b 68 NTDB} \.. {h
1760: 61 73 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 as a non-NTDB ch
1770: 69 6c 64 2c 20 79 65 74 20 69 73 20 6e 6f 74 20 ild, yet is not
1780: 6f 6e 20 74 68 65 20 4e 54 44 42 7d 20 7b 0a 09 on the NTDB} {..
1790: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 .SELECT F.name,
17a0: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 R.rev...FROM rev
17b0: 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a ision R, file F.
17c0: 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 ..WHERE R.fid =
17d0: 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e F.fid...AND R.
17e0: 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e dbchild IS NOT N
17f0: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 4e 4f 54 20 ULL...AND NOT
1800: 52 2e 69 73 64 65 66 61 75 6c 74 0a 09 09 3b 0a R.isdefault...;.
1810: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 . }..# Find a
1820: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 ll revisions wit
1830: 68 20 61 20 4e 54 44 42 20 70 61 72 65 6e 74 20 h a NTDB parent
1840: 77 68 69 63 68 20 61 72 65 20 6f 6e 20 74 68 65 which are on the
1850: 20 4e 54 44 42 2e 0a 09 43 68 65 63 6b 20 5c 0a NTDB...Check \.
1860: 09 20 20 20 20 7b 4e 54 44 42 20 74 6f 20 74 72 . {NTDB to tr
1870: 75 6e 6b 20 74 72 61 6e 73 69 74 69 6f 6e 20 68 unk transition h
1880: 61 73 20 74 6f 20 65 6e 64 20 6f 6e 20 6e 6f 6e as to end on non
1890: 2d 4e 54 44 42 7d 20 5c 0a 09 20 20 20 20 7b 68 -NTDB} \.. {h
18a0: 61 73 20 61 20 4e 54 44 42 20 70 61 72 65 6e 74 as a NTDB parent
18b0: 2c 20 79 65 74 20 69 73 20 6f 6e 20 74 68 65 20 , yet is on the
18c0: 4e 54 44 42 7d 20 7b 0a 09 09 53 45 4c 45 43 54 NTDB} {...SELECT
18d0: 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 F.name, R.rev..
18e0: 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 .FROM revision R
18f0: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 , file F...WHERE
1900: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 R.fid = F.fid..
1910: 09 41 4e 44 20 20 20 52 2e 64 62 70 61 72 65 6e .AND R.dbparen
1920: 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 t IS NOT NULL...
1930: 41 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75 6c AND R.isdefaul
1940: 74 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 t...;.. }..#
1950: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f Find all revisio
1960: 6e 73 20 77 69 74 68 20 61 20 63 68 69 6c 64 20 ns with a child
1970: 77 68 69 63 68 20 64 69 73 61 67 72 65 65 73 20 which disagrees
1980: 61 62 6f 75 74 20 74 68 65 0a 09 23 20 6c 69 6e about the..# lin
1990: 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 e of development
19a0: 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e they belong to.
19b0: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b ..Check \.. {
19c0: 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 Revisions and th
19d0: 65 69 72 20 70 72 69 6d 61 72 79 20 63 68 69 6c eir primary chil
19e0: 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65 20 dren have to be
19f0: 69 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 7d in the same LOD}
1a00: 20 5c 0a 09 20 20 20 20 7b 61 6e 64 20 69 74 73 \.. {and its
1a10: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 64 primary child d
1a20: 69 73 61 67 72 65 65 20 61 62 6f 75 74 20 74 68 isagree about th
1a30: 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c eir LOD} {...SEL
1a40: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 ECT F.name, R.re
1a50: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f v...FROM revisio
1a60: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c n R, revision C,
1a70: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 file F...WHERE
1a80: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 R.fid = F.fid...
1a90: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49 53 AND R.child IS
1aa0: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 NOT NULL...AND
1ab0: 20 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 R.child = C.ri
1ac0: 64 0a 09 09 41 4e 44 20 20 20 43 2e 6c 6f 64 20 d...AND C.lod
1ad0: 21 3d 20 52 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20 != R.lod...;..
1ae0: 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 }..# Find all
1af0: 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 revisions with a
1b00: 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20 non-NTDB child
1b10: 77 68 69 63 68 20 61 67 72 65 65 73 20 61 62 6f which agrees abo
1b20: 75 74 0a 09 23 20 74 68 65 20 6c 69 6e 65 20 6f ut..# the line o
1b30: 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 f development th
1b40: 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 ey belong to...C
1b50: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 4e 54 44 heck \.. {NTD
1b60: 42 20 61 6e 64 20 74 72 75 6e 6b 20 72 65 76 69 B and trunk revi
1b70: 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 62 65 sions have to be
1b80: 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20 4c 4f in different LO
1b90: 44 73 7d 20 5c 0a 09 20 20 20 20 7b 6f 6e 20 4e Ds} \.. {on N
1ba0: 54 44 42 20 61 6e 64 20 69 74 73 20 6e 6f 6e 2d TDB and its non-
1bb0: 4e 54 44 42 20 63 68 69 6c 64 20 77 72 6f 6e 67 NTDB child wrong
1bc0: 6c 79 20 61 67 72 65 65 20 61 62 6f 75 74 20 74 ly agree about t
1bd0: 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 heir LOD} {...SE
1be0: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 LECT F.name, R.r
1bf0: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 ev...FROM revisi
1c00: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 on R, revision C
1c10: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 , file F...WHERE
1c20: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 R.fid = F.fid..
1c30: 09 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 .AND R.dbchild
1c40: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 IS NOT NULL...A
1c50: 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20 3d ND R.dbchild =
1c60: 20 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 C.rid...AND C
1c70: 2e 6c 6f 64 20 3d 20 52 2e 6c 6f 64 0a 09 09 3b .lod = R.lod...;
1c80: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 .. }..# Find
1c90: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 all revisions wi
1ca0: 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72 65 th a branch pare
1cb0: 6e 74 20 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 nt symbol which
1cc0: 69 73 20 6e 6f 74 0a 09 23 20 74 68 65 69 72 20 is not..# their
1cd0: 4c 4f 44 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 LOD...Check \..
1ce0: 20 20 20 7b 42 72 61 6e 63 68 20 73 74 61 72 74 {Branch start
1cf0: 69 6e 67 20 72 65 76 69 73 69 6f 6e 73 20 68 61 ing revisions ha
1d00: 76 65 20 74 6f 20 68 61 76 65 20 74 68 65 69 72 ve to have their
1d10: 20 4c 4f 44 20 61 73 20 62 72 61 6e 63 68 20 70 LOD as branch p
1d20: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 7d 20 5c 0a arent symbol} \.
1d30: 09 20 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 . {at the beg
1d40: 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 inning of its br
1d50: 61 6e 63 68 20 64 6f 65 73 20 6e 6f 74 20 68 61 anch does not ha
1d60: 76 65 20 74 68 65 20 62 72 61 6e 63 68 20 73 79 ve the branch sy
1d70: 6d 62 6f 6c 20 61 73 20 69 74 73 20 4c 4f 44 7d mbol as its LOD}
1d80: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 {...SELECT F.na
1d90: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d me, R.rev...FROM
1da0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c revision R, fil
1db0: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 e F...WHERE R.fi
1dc0: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 d = F.fid...AND
1dd0: 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e R.bparent IS N
1de0: 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 OT NULL...AND
1df0: 52 2e 6c 6f 64 20 21 3d 20 52 2e 62 70 61 72 65 R.lod != R.bpare
1e00: 6e 74 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 nt...;.. }..#
1e10: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 Find all revisi
1e20: 6f 6e 73 20 77 69 74 68 20 61 20 62 72 61 6e 63 ons with a branc
1e30: 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 h parent symbol
1e40: 77 68 6f 73 65 20 70 61 72 65 6e 74 0a 09 23 20 whose parent..#
1e50: 69 73 20 69 6e 20 74 68 65 20 73 61 6d 65 20 6c is in the same l
1e60: 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 ine of developme
1e70: 6e 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 nt...Check \..
1e80: 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 {Revisions and
1e90: 20 74 68 65 69 72 20 62 72 61 6e 63 68 20 63 68 their branch ch
1ea0: 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62 ildren have to b
1eb0: 65 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20 4c e in different L
1ec0: 4f 44 73 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 ODs} \.. {at
1ed0: 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 the beginning of
1ee0: 20 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64 20 its branch and
1ef0: 69 74 73 20 70 61 72 65 6e 74 20 77 72 6f 6e 67 its parent wrong
1f00: 6c 79 20 61 67 72 65 65 20 61 62 6f 75 74 20 74 ly agree about t
1f10: 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 heir LOD} {...SE
1f20: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 LECT F.name, R.r
1f30: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 ev...FROM revisi
1f40: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 50 on R, revision P
1f50: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 , file F...WHERE
1f60: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 R.fid = F.fid..
1f70: 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e 74 .AND R.bparent
1f80: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 IS NOT NULL...A
1f90: 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 ND R.parent =
1fa0: 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 52 2e P.rid...AND R.
1fb0: 6c 6f 64 20 3d 20 50 2e 6c 6f 64 0a 09 09 3b 0a lod = P.lod...;.
1fc0: 09 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a 20 . }..return.
1fd0: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 4d }.. proc M
1fe0: 65 74 61 20 7b 7d 20 7b 0a 09 23 20 54 68 69 73 eta {} {..# This
1ff0: 20 63 6f 64 65 20 70 65 72 66 6f 72 6d 73 20 61 code performs a
2000: 20 6e 75 6d 62 65 72 20 6f 66 20 70 61 72 61 6e number of paran
2010: 6f 69 64 20 63 68 65 63 6b 73 20 6f 66 20 74 68 oid checks of th
2020: 65 0a 09 23 20 64 61 74 61 62 61 73 65 2c 20 73 e..# database, s
2030: 65 61 72 63 68 69 6e 67 20 66 6f 72 20 69 6e 63 earching for inc
2040: 6f 6e 73 69 73 74 65 6e 74 20 63 72 6f 73 73 2d onsistent cross-
2050: 72 65 66 65 72 65 6e 63 65 73 2e 0a 09 6c 6f 67 references...log
2060: 20 77 72 69 74 65 20 34 20 69 6e 74 65 67 72 69 write 4 integri
2070: 74 79 20 7b 43 68 65 63 6b 20 64 61 74 61 62 61 ty {Check databa
2080: 73 65 20 63 6f 6e 73 69 73 74 65 6e 63 79 7d 0a se consistency}.
2090: 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 20 3b 20 ..upvar 1 n n ;
20a0: 23 20 43 6f 75 6e 74 65 72 20 66 6f 72 20 74 68 # Counter for th
20b0: 65 20 63 68 65 63 6b 73 20 28 77 65 20 70 72 69 e checks (we pri
20c0: 6e 74 20 61 6e 20 69 64 20 62 65 66 6f 72 65 0a nt an id before.
20d0: 09 09 20 20 20 20 20 20 23 20 74 68 65 20 6d 61 .. # the ma
20e0: 69 6e 20 6c 61 62 65 6c 29 2e 0a 0a 09 23 20 46 in label)....# F
20f0: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e ind all revision
2100: 73 20 77 68 69 63 68 20 64 69 73 67 72 65 65 20 s which disgree
2110: 77 69 74 68 20 74 68 65 69 72 20 6d 65 74 61 20 with their meta
2120: 64 61 74 61 20 61 62 6f 75 74 0a 09 23 20 74 68 data about..# th
2130: 65 20 62 72 61 6e 63 68 2f 6c 69 6e 65 20 6f 66 e branch/line of
2140: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 development the
2150: 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 y belong to...Ch
2160: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 eck \.. {Revi
2170: 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 sions and their
2180: 6d 65 74 61 20 64 61 74 61 20 68 61 76 65 20 74 meta data have t
2190: 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 o be in the same
21a0: 20 4c 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 64 69 LOD} \.. {di
21b0: 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73 sagrees with its
21c0: 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f 75 74 meta data about
21d0: 20 6f 77 6e 69 6e 67 20 4c 4f 44 7d 20 7b 0a 09 owning LOD} {..
21e0: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 .SELECT F.name,
21f0: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 R.rev...FROM rev
2200: 69 73 69 6f 6e 20 52 2c 20 6d 65 74 61 20 4d 2c ision R, meta M,
2210: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 file F...WHERE
2220: 52 2e 6d 69 64 20 3d 20 4d 2e 6d 69 64 0a 09 09 R.mid = M.mid...
2230: 41 4e 44 20 20 20 52 2e 6c 6f 64 20 21 3d 20 4d AND R.lod != M
2240: 2e 62 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 66 .bid...AND R.f
2250: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 3b 0a 09 id = F.fid...;..
2260: 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 }..return.
2270: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 43 68 }.. proc Ch
2280: 65 63 6b 20 7b 68 65 61 64 65 72 20 6c 61 62 65 eck {header labe
2290: 6c 20 73 71 6c 7d 20 7b 0a 09 75 70 76 61 72 20 l sql} {..upvar
22a0: 31 20 6e 20 6e 0a 09 73 65 74 20 6f 6b 20 31 0a 1 n n..set ok 1.
22b0: 09 66 6f 72 65 61 63 68 20 7b 66 6e 61 6d 65 20 .foreach {fname
22c0: 72 65 76 6e 72 7d 20 5b 73 74 61 74 65 20 72 75 revnr} [state ru
22d0: 6e 20 24 73 71 6c 5d 20 7b 0a 09 20 20 20 20 73 n $sql] {.. s
22e0: 65 74 20 6f 6b 20 30 0a 09 20 20 20 20 74 72 6f et ok 0.. tro
22f0: 75 62 6c 65 20 66 61 74 61 6c 20 22 24 66 6e 61 uble fatal "$fna
2300: 6d 65 20 3c 24 72 65 76 6e 72 3e 20 24 6c 61 62 me <$revnr> $lab
2310: 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 74 el"..}..log writ
2320: 65 20 35 20 69 6e 74 65 67 72 69 74 79 20 22 5c e 5 integrity "\
2330: 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 5b 69 [[format %02d [i
2340: 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20 ncr n]]\] [expr
2350: 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 20 {$ok ? "Ok "
2360: 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e : "Failed"}] ...
2370: 20 24 68 65 61 64 65 72 22 0a 09 72 65 74 75 72 $header"..retur
2380: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 n. }.. # #
2390: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 ## ### ##### ##
23a0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
23b0: 23 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 ####. ## Conf
23c0: 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 iguration.. p
23d0: 72 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e ragma -hasinstan
23e0: 63 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e ces no ; # sin
23f0: 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d gleton. pragm
2400: 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 a -hastypeinfo
2410: 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 no ; # no intr
2420: 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 ospection. pr
2430: 61 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73 agma -hastypedes
2440: 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f troy no ; # immo
2450: 72 74 61 6c 0a 0a 20 20 20 20 23 20 23 20 23 23 rtal.. # # ##
2460: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
2470: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
2480: 23 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 #.}..namespace e
2490: 76 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c val ::vc::fossil
24a0: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 20 7b 0a ::import::cvs {.
24b0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 namespace ex
24c0: 70 6f 72 74 20 69 6e 74 65 67 72 69 74 79 0a 20 port integrity.
24d0: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 namespace eva
24e0: 6c 20 69 6e 74 65 67 72 69 74 79 20 7b 0a 09 6e l integrity {..n
24f0: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 amespace import
2500: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d ::vc::fossil::im
2510: 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 port::cvs::state
2520: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f ..namespace impo
2530: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a rt ::vc::tools::
2540: 74 72 6f 75 62 6c 65 0a 09 6e 61 6d 65 73 70 61 trouble..namespa
2550: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a ce import ::vc::
2560: 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 tools::log..log
2570: 72 65 67 69 73 74 65 72 20 69 6e 74 65 67 72 69 register integri
2580: 74 79 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 ty. }.}..# #
2590: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
25a0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
25b0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
25c0: 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 61 #########.## Rea
25d0: 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 dy..package prov
25e0: 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a ide vc::fossil::
25f0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 import::cvs::int
2600: 65 67 72 69 74 79 20 31 2e 30 0a 72 65 74 75 72 egrity 1.0.retur
2610: 6e 0a n.