Hex Artifact Content
Not logged in

Artifact 69cecd83d4ab313fa351d80c0c11eb91d92fe47e:

File tools/cvs2fossil/lib/c2f_integrity.tcl part of check-in [bf83201c7f] - Outline for more integrity checks, focusing on the changesets. by aku on 2007-11-27 02:37:51.

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 73 74 72 69 63 74 20 7b 7d 20 7b  thod strict {} {
0500: 0a 09 73 65 74 20 6e 20 30 0a 09 41 6c 6c 42 75  ..set n 0..AllBu
0510: 74 4d 65 74 61 0a 09 4d 65 74 61 0a 09 72 65 74  tMeta..Meta..ret
0520: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74  urn.    }..    t
0530: 79 70 65 6d 65 74 68 6f 64 20 6d 65 74 61 72 65  ypemethod metare
0540: 6c 61 78 65 64 20 7b 7d 20 7b 0a 09 73 65 74 20  laxed {} {..set 
0550: 6e 20 30 0a 09 41 6c 6c 42 75 74 4d 65 74 61 0a  n 0..AllButMeta.
0560: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
0570: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63 68     typemethod ch
0580: 61 6e 67 65 73 65 74 73 20 7b 7d 20 7b 0a 09 73  angesets {} {..s
0590: 65 74 20 6e 20 30 0a 09 52 65 76 69 73 69 6f 6e  et n 0..Revision
05a0: 43 53 65 74 4c 69 6e 6b 61 67 65 0a 09 52 65 76  CSetLinkage..Rev
05b0: 69 73 69 6f 6e 43 68 61 6e 67 65 73 65 74 73 0a  isionChangesets.
05c0: 09 53 79 6d 62 6f 6c 43 68 61 6e 67 65 73 65 74  .SymbolChangeset
05d0: 73 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  s..return.    }.
05e0: 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20  .    # # ## ### 
05f0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
0600: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20  ############.   
0610: 20 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74   ## Internal met
0620: 68 6f 64 73 0a 0a 20 20 20 20 70 72 6f 63 20 41  hods..    proc A
0630: 6c 6c 42 75 74 4d 65 74 61 20 7b 7d 20 7b 0a 09  llButMeta {} {..
0640: 23 20 54 68 69 73 20 63 6f 64 65 20 70 65 72 66  # This code perf
0650: 6f 72 6d 73 20 61 20 6e 75 6d 62 65 72 20 6f 66  orms a number of
0660: 20 70 61 72 61 6e 6f 69 64 20 63 68 65 63 6b 73   paranoid checks
0670: 20 6f 66 20 74 68 65 0a 09 23 20 64 61 74 61 62   of the..# datab
0680: 61 73 65 2c 20 73 65 61 72 63 68 69 6e 67 20 66  ase, searching f
0690: 6f 72 20 69 6e 63 6f 6e 73 69 73 74 65 6e 74 20  or inconsistent 
06a0: 63 72 6f 73 73 2d 72 65 66 65 72 65 6e 63 65 73  cross-references
06b0: 2e 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 69  ...log write 4 i
06c0: 6e 74 65 67 72 69 74 79 20 7b 43 68 65 63 6b 20  ntegrity {Check 
06d0: 64 61 74 61 62 61 73 65 20 63 6f 6e 73 69 73 74  database consist
06e0: 65 6e 63 79 7d 0a 0a 09 75 70 76 61 72 20 31 20  ency}...upvar 1 
06f0: 6e 20 6e 20 3b 20 23 20 43 6f 75 6e 74 65 72 20  n n ; # Counter 
0700: 66 6f 72 20 74 68 65 20 63 68 65 63 6b 73 20 28  for the checks (
0710: 77 65 20 70 72 69 6e 74 20 61 6e 20 69 64 20 62  we print an id b
0720: 65 66 6f 72 65 0a 09 09 20 20 20 20 20 20 23 20  efore...      # 
0730: 74 68 65 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e  the main label).
0740: 0a 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  ...# Find all re
0750: 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 64 69  visions which di
0760: 73 61 67 72 65 65 20 77 69 74 68 20 74 68 65 69  sagree with thei
0770: 72 20 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76  r line of..# dev
0780: 65 6c 6f 70 6d 65 6e 74 20 61 62 6f 75 74 20 74  elopment about t
0790: 68 65 20 70 72 6f 6a 65 63 74 20 74 68 65 79 20  he project they 
07a0: 61 72 65 20 6f 77 6e 65 64 20 62 79 2e 0a 09 43  are owned by...C
07b0: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76  heck \..    {Rev
07c0: 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72  isions and their
07d0: 20 4c 4f 44 73 20 68 61 76 65 20 74 6f 20 62 65   LODs have to be
07e0: 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70 72 6f   in the same pro
07f0: 6a 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69  ject} \..    {di
0800: 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73  sagrees with its
0810: 20 4c 4f 44 20 61 62 6f 75 74 20 6f 77 6e 69 6e   LOD about ownin
0820: 67 20 70 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 53  g project} {...S
0830: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
0840: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
0850: 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 73  ion R, file F, s
0860: 79 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52 45 20  ymbol S...WHERE 
0870: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
0880: 41 4e 44 20 20 20 52 2e 6c 6f 64 20 3d 20 53 2e  AND   R.lod = S.
0890: 73 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70 69  sid...AND   F.pi
08a0: 64 20 21 3d 20 53 2e 70 69 64 0a 09 09 3b 0a 09  d != S.pid...;..
08b0: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
08c0: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63  l revisions whic
08d0: 68 20 64 69 73 67 72 65 65 20 77 69 74 68 20 74  h disgree with t
08e0: 68 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 61  heir meta data a
08f0: 62 6f 75 74 0a 09 23 20 74 68 65 20 70 72 6f 6a  bout..# the proj
0900: 65 63 74 20 74 68 65 79 20 61 72 65 20 6f 77 6e  ect they are own
0910: 65 64 20 62 79 2e 0a 09 43 68 65 63 6b 20 5c 0a  ed by...Check \.
0920: 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20  .    {Revisions 
0930: 61 6e 64 20 74 68 65 69 72 20 6d 65 74 61 20 64  and their meta d
0940: 61 74 61 20 68 61 76 65 20 74 6f 20 62 65 20 69  ata have to be i
0950: 6e 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a 65  n the same proje
0960: 63 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61  ct} \..    {disa
0970: 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6d  grees with its m
0980: 65 74 61 20 64 61 74 61 20 61 62 6f 75 74 20 6f  eta data about o
0990: 77 6e 69 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b  wning project} {
09a0: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65  ...SELECT F.name
09b0: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72  , R.rev...FROM r
09c0: 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20  evision R, file 
09d0: 46 2c 20 6d 65 74 61 20 4d 0a 09 09 57 48 45 52  F, meta M...WHER
09e0: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
09f0: 09 09 41 4e 44 20 20 20 52 2e 6d 69 64 20 3d 20  ..AND   R.mid = 
0a00: 4d 2e 6d 69 64 0a 09 09 41 4e 44 20 20 20 46 2e  M.mid...AND   F.
0a10: 70 69 64 20 21 3d 20 4d 2e 70 69 64 0a 09 09 3b  pid != M.pid...;
0a20: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
0a30: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
0a40: 74 68 20 61 20 70 72 69 6d 61 72 79 20 63 68 69  th a primary chi
0a50: 6c 64 20 77 68 69 63 68 20 64 69 73 61 67 72 65  ld which disagre
0a60: 65 73 0a 09 23 20 61 62 6f 75 74 20 74 68 65 20  es..# about the 
0a70: 66 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e 67  file they belong
0a80: 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20   to...Check \.. 
0a90: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e     {Revisions an
0aa0: 64 20 74 68 65 69 72 20 70 72 69 6d 61 72 79 20  d their primary 
0ab0: 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f  children have to
0ac0: 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20   be in the same 
0ad0: 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 64 69  file} \..    {di
0ae0: 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73  sagrees with its
0af0: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 61   primary child a
0b00: 62 6f 75 74 20 74 68 65 20 6f 77 6e 69 6e 67 20  bout the owning 
0b10: 66 69 6c 65 7d 20 7b 0a 09 09 53 45 4c 45 43 54  file} {...SELECT
0b20: 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09   F.name, R.rev..
0b30: 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52  .FROM revision R
0b40: 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69  , revision C, fi
0b50: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66  le F...WHERE R.f
0b60: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
0b70: 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f     R.child IS NO
0b80: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
0b90: 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09  .child = C.rid..
0ba0: 09 41 4e 44 20 20 20 43 2e 66 69 64 20 21 3d 20  .AND   C.fid != 
0bb0: 52 2e 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d  R.fid...;..    }
0bc0: 0a 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  ...# Find all re
0bd0: 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62  visions with a b
0be0: 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d  ranch parent sym
0bf0: 62 6f 6c 20 77 68 6f 73 65 20 70 61 72 65 6e 74  bol whose parent
0c00: 0a 09 23 20 64 69 73 61 67 72 65 65 73 20 61 62  ..# disagrees ab
0c10: 6f 75 74 20 74 68 65 20 66 69 6c 65 20 74 68 65  out the file the
0c20: 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68  y belong to...Ch
0c30: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69  eck \..    {Revi
0c40: 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20  sions and their 
0c50: 62 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 20  branch children 
0c60: 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68  have to be in th
0c70: 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a 09  e same file} \..
0c80: 20 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69      {at the begi
0c90: 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61  nning of its bra
0ca0: 6e 63 68 20 61 6e 64 20 69 74 73 20 70 61 72 65  nch and its pare
0cb0: 6e 74 20 64 69 73 61 67 72 65 65 20 61 62 6f 75  nt disagree abou
0cc0: 74 20 74 68 65 20 6f 77 6e 69 6e 67 20 66 69 6c  t the owning fil
0cd0: 65 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  e} {...SELECT F.
0ce0: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
0cf0: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72  OM revision R, r
0d00: 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20  evision P, file 
0d10: 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20  F...WHERE R.fid 
0d20: 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20  = F.fid...AND   
0d30: 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54  R.bparent IS NOT
0d40: 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e   NULL...AND   R.
0d50: 70 61 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a 09  parent = P.rid..
0d60: 09 41 4e 44 20 20 20 52 2e 66 69 64 20 21 3d 20  .AND   R.fid != 
0d70: 50 2e 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d  P.fid...;..    }
0d80: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
0d90: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f  isions with a no
0da0: 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69  n-NTDB child whi
0db0: 63 68 20 64 69 73 61 67 72 65 65 73 0a 09 23 20  ch disagrees..# 
0dc0: 61 62 6f 75 74 20 74 68 65 20 66 69 6c 65 20 74  about the file t
0dd0: 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09  hey belong to...
0de0: 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65  Check \..    {Re
0df0: 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69  visions and thei
0e00: 72 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64  r non-NTDB child
0e10: 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65 20 69  ren have to be i
0e20: 6e 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 7d  n the same file}
0e30: 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65   \..    {disagre
0e40: 65 73 20 77 69 74 68 20 69 74 73 20 6e 6f 6e 2d  es with its non-
0e50: 4e 54 44 42 20 63 68 69 6c 64 20 61 62 6f 75 74  NTDB child about
0e60: 20 74 68 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65   the owning file
0e70: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
0e80: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
0e90: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65  M revision R, re
0ea0: 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46  vision C, file F
0eb0: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
0ec0: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
0ed0: 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20  .dbchild IS NOT 
0ee0: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 64  NULL...AND   R.d
0ef0: 62 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09  bchild = C.rid..
0f00: 09 41 4e 44 20 20 20 43 2e 66 69 64 20 21 3d 20  .AND   C.fid != 
0f10: 52 2e 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d  R.fid...;..    }
0f20: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
0f30: 69 73 69 6f 6e 73 20 77 68 69 63 68 20 68 61 76  isions which hav
0f40: 65 20 61 20 70 72 69 6d 61 72 79 20 63 68 69 6c  e a primary chil
0f50: 64 2c 20 62 75 74 20 74 68 65 20 63 68 69 6c 64  d, but the child
0f60: 0a 09 23 20 64 6f 65 73 20 6e 6f 74 20 68 61 76  ..# does not hav
0f70: 65 20 74 68 65 6d 20 61 73 20 70 61 72 65 6e 74  e them as parent
0f80: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
0f90: 7b 52 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20  {Revisions have 
0fa0: 74 6f 20 62 65 20 70 61 72 65 6e 74 73 20 6f 66  to be parents of
0fb0: 20 74 68 65 69 72 20 70 72 69 6d 61 72 79 20 63   their primary c
0fc0: 68 69 6c 64 72 65 6e 7d 20 5c 0a 09 20 20 20 20  hildren} \..    
0fd0: 7b 69 73 20 6e 6f 74 20 74 68 65 20 70 61 72 65  {is not the pare
0fe0: 6e 74 20 6f 66 20 69 74 73 20 70 72 69 6d 61 72  nt of its primar
0ff0: 79 20 63 68 69 6c 64 7d 20 7b 0a 09 09 53 45 4c  y child} {...SEL
1000: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
1010: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f  v...FROM revisio
1020: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c  n R, revision C,
1030: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
1040: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
1050: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49 53  AND   R.child IS
1060: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20   NOT NULL...AND 
1070: 20 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69    R.child = C.ri
1080: 64 0a 09 09 41 4e 44 20 20 20 43 2e 70 61 72 65  d...AND   C.pare
1090: 6e 74 20 21 3d 20 52 2e 72 69 64 0a 09 09 3b 0a  nt != R.rid...;.
10a0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
10b0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69  ll revisions whi
10c0: 63 68 20 68 61 76 65 20 61 20 70 72 69 6d 72 61  ch have a primra
10d0: 72 79 20 63 68 69 6c 64 2c 20 62 75 74 20 74 68  ry child, but th
10e0: 65 0a 09 23 20 63 68 69 6c 64 20 68 61 73 20 61  e..# child has a
10f0: 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73   branch parent s
1100: 79 6d 62 6f 6c 20 6d 61 6b 69 6e 67 20 74 68 65  ymbol making the
1110: 6d 20 62 72 61 63 68 20 73 74 61 72 74 65 72 73  m brach starters
1120: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
1130: 7b 50 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65  {Primary childre
1140: 6e 20 6f 66 20 72 65 76 69 73 69 6f 6e 73 20 6d  n of revisions m
1150: 75 73 74 20 6e 6f 74 20 73 74 61 72 74 20 62 72  ust not start br
1160: 61 6e 63 68 65 73 7d 20 5c 0a 09 20 20 20 20 7b  anches} \..    {
1170: 69 73 20 70 61 72 65 6e 74 20 6f 66 20 61 20 70  is parent of a p
1180: 72 69 6d 61 72 79 20 63 68 69 6c 64 20 77 68 69  rimary child whi
1190: 63 68 20 69 73 20 74 68 65 20 62 65 67 69 6e 6e  ch is the beginn
11a0: 69 6e 67 20 6f 66 20 61 20 62 72 61 6e 63 68 7d  ing of a branch}
11b0: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
11c0: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
11d0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76   revision R, rev
11e0: 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a  ision C, file F.
11f0: 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20  ..WHERE R.fid = 
1200: 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e  F.fid...AND   R.
1210: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
1220: 4c 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c  L...AND   R.chil
1230: 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20  d = C.rid...AND 
1240: 20 20 43 2e 62 70 61 72 65 6e 74 20 49 53 20 4e    C.bparent IS N
1250: 4f 54 20 4e 55 4c 4c 0a 09 09 3b 0a 09 20 20 20  OT NULL...;..   
1260: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72   }..# Find all r
1270: 65 76 69 73 69 6f 6e 73 20 77 69 74 68 6f 75 74  evisions without
1280: 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73   branch parent s
1290: 79 6d 62 6f 6c 20 77 68 69 63 68 20 68 61 76 65  ymbol which have
12a0: 20 61 0a 09 23 20 70 61 72 65 6e 74 2c 20 62 75   a..# parent, bu
12b0: 74 20 74 68 65 20 70 61 72 65 6e 74 20 64 6f 65  t the parent doe
12c0: 73 20 6e 6f 74 20 68 61 76 65 20 74 68 65 6d 20  s not have them 
12d0: 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  as primary child
12e0: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
12f0: 7b 52 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20  {Revisions have 
1300: 74 6f 20 62 65 20 70 72 69 6d 61 72 79 20 63 68  to be primary ch
1310: 69 6c 64 72 65 6e 20 6f 66 20 74 68 65 69 72 20  ildren of their 
1320: 70 61 72 65 6e 74 73 2c 20 69 66 20 61 6e 79 7d  parents, if any}
1330: 20 5c 0a 09 20 20 20 20 7b 69 73 20 6e 6f 74 20   \..    {is not 
1340: 74 68 65 20 63 68 69 6c 64 20 6f 66 20 69 74 73  the child of its
1350: 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45 4c   parent} {...SEL
1360: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
1370: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f  v...FROM revisio
1380: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 50 2c  n R, revision P,
1390: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
13a0: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
13b0: 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e 74 20  AND   R.bparent 
13c0: 49 53 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20  IS NULL...AND   
13d0: 52 2e 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20  R.parent IS NOT 
13e0: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70  NULL...AND   R.p
13f0: 61 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a 09 09  arent = P.rid...
1400: 41 4e 44 20 20 20 50 2e 63 68 69 6c 64 20 21 3d  AND   P.child !=
1410: 20 52 2e 72 69 64 0a 09 09 3b 0a 09 20 20 20 20   R.rid...;..    
1420: 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  }..# Find all re
1430: 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62  visions with a b
1440: 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d  ranch parent sym
1450: 62 6f 6c 20 77 68 69 63 68 20 64 6f 20 6e 6f 74  bol which do not
1460: 0a 09 23 20 68 61 76 65 20 61 20 70 61 72 65 6e  ..# have a paren
1470: 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20  t...Check \..   
1480: 20 7b 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e   {Branch startin
1490: 67 20 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65  g revisions have
14a0: 20 74 6f 20 68 61 76 65 20 61 20 70 61 72 65 6e   to have a paren
14b0: 74 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68  t} \..    {at th
14c0: 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69  e beginning of i
14d0: 74 73 20 62 72 61 6e 63 68 20 68 61 73 20 6e 6f  ts branch has no
14e0: 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45 4c   parent} {...SEL
14f0: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
1500: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f  v...FROM revisio
1510: 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n R, file F...WH
1520: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
1530: 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72  d...AND   R.bpar
1540: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a  ent IS NOT NULL.
1550: 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74  ..AND   R.parent
1560: 20 49 53 20 4e 55 4c 4c 0a 09 09 3b 0a 09 20 20   IS NULL...;..  
1570: 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20    }..# Find all 
1580: 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61  revisions with a
1590: 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73   branch parent s
15a0: 79 6d 62 6f 6c 20 77 68 6f 73 65 20 70 61 72 65  ymbol whose pare
15b0: 6e 74 0a 09 23 20 68 61 73 20 74 68 65 6d 20 61  nt..# has them a
15c0: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e  s primary child.
15d0: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b  ..Check \..    {
15e0: 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67 20  Branch starting 
15f0: 72 65 76 69 73 69 6f 6e 73 20 6d 75 73 74 20 6e  revisions must n
1600: 6f 74 20 62 65 20 70 72 69 6d 61 72 79 20 63 68  ot be primary ch
1610: 69 6c 64 72 65 6e 20 6f 66 20 74 68 65 69 72 20  ildren of their 
1620: 70 61 72 65 6e 74 73 7d 20 5c 0a 09 20 20 20 20  parents} \..    
1630: 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e  {at the beginnin
1640: 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68 20  g of its branch 
1650: 69 73 20 74 68 65 20 70 72 69 6d 61 72 79 20 63  is the primary c
1660: 68 69 6c 64 20 6f 66 20 69 74 73 20 70 61 72 65  hild of its pare
1670: 6e 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  nt} {...SELECT F
1680: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
1690: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  ROM revision R, 
16a0: 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65  revision P, file
16b0: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   F...WHERE R.fid
16c0: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
16d0: 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f   R.bparent IS NO
16e0: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
16f0: 2e 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e  .parent IS NOT N
1700: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61  ULL...AND   R.pa
1710: 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a 09 09 41  rent = P.rid...A
1720: 4e 44 20 20 20 50 2e 63 68 69 6c 64 20 3d 20 52  ND   P.child = R
1730: 2e 72 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  .rid...;..    }.
1740: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
1750: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e  sions with a non
1760: 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69 63  -NTDB child whic
1770: 68 20 61 72 65 20 6e 6f 74 20 6f 6e 0a 09 23 20  h are not on..# 
1780: 74 68 65 20 4e 54 44 42 2e 0a 09 43 68 65 63 6b  the NTDB...Check
1790: 20 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 74 6f   \..    {NTDB to
17a0: 20 74 72 75 6e 6b 20 74 72 61 6e 73 69 74 69 6f   trunk transitio
17b0: 6e 20 68 61 73 20 74 6f 20 62 65 67 69 6e 20 6f  n has to begin o
17c0: 6e 20 4e 54 44 42 7d 20 5c 0a 09 20 20 20 20 7b  n NTDB} \..    {
17d0: 68 61 73 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63  has a non-NTDB c
17e0: 68 69 6c 64 2c 20 79 65 74 20 69 73 20 6e 6f 74  hild, yet is not
17f0: 20 6f 6e 20 74 68 65 20 4e 54 44 42 7d 20 7b 0a   on the NTDB} {.
1800: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
1810: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
1820: 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46  vision R, file F
1830: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
1840: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
1850: 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20  .dbchild IS NOT 
1860: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 4e 4f 54  NULL...AND   NOT
1870: 20 52 2e 69 73 64 65 66 61 75 6c 74 0a 09 09 3b   R.isdefault...;
1880: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
1890: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
18a0: 74 68 20 61 20 4e 54 44 42 20 70 61 72 65 6e 74  th a NTDB parent
18b0: 20 77 68 69 63 68 20 61 72 65 20 6f 6e 20 74 68   which are on th
18c0: 65 20 4e 54 44 42 2e 0a 09 43 68 65 63 6b 20 5c  e NTDB...Check \
18d0: 0a 09 20 20 20 20 7b 4e 54 44 42 20 74 6f 20 74  ..    {NTDB to t
18e0: 72 75 6e 6b 20 74 72 61 6e 73 69 74 69 6f 6e 20  runk transition 
18f0: 68 61 73 20 74 6f 20 65 6e 64 20 6f 6e 20 6e 6f  has to end on no
1900: 6e 2d 4e 54 44 42 7d 20 5c 0a 09 20 20 20 20 7b  n-NTDB} \..    {
1910: 68 61 73 20 61 20 4e 54 44 42 20 70 61 72 65 6e  has a NTDB paren
1920: 74 2c 20 79 65 74 20 69 73 20 6f 6e 20 74 68 65  t, yet is on the
1930: 20 4e 54 44 42 7d 20 7b 0a 09 09 53 45 4c 45 43   NTDB} {...SELEC
1940: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
1950: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
1960: 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  R, file F...WHER
1970: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
1980: 09 09 41 4e 44 20 20 20 52 2e 64 62 70 61 72 65  ..AND   R.dbpare
1990: 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09  nt IS NOT NULL..
19a0: 09 41 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75  .AND   R.isdefau
19b0: 6c 74 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23  lt...;..    }..#
19c0: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69   Find all revisi
19d0: 6f 6e 73 20 77 69 74 68 20 61 20 63 68 69 6c 64  ons with a child
19e0: 20 77 68 69 63 68 20 64 69 73 61 67 72 65 65 73   which disagrees
19f0: 20 61 62 6f 75 74 20 74 68 65 0a 09 23 20 6c 69   about the..# li
1a00: 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e  ne of developmen
1a10: 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f  t they belong to
1a20: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
1a30: 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74  {Revisions and t
1a40: 68 65 69 72 20 70 72 69 6d 61 72 79 20 63 68 69  heir primary chi
1a50: 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65  ldren have to be
1a60: 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f 44   in the same LOD
1a70: 7d 20 5c 0a 09 20 20 20 20 7b 61 6e 64 20 69 74  } \..    {and it
1a80: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20  s primary child 
1a90: 64 69 73 61 67 72 65 65 20 61 62 6f 75 74 20 74  disagree about t
1aa0: 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45  heir LOD} {...SE
1ab0: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
1ac0: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69  ev...FROM revisi
1ad0: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43  on R, revision C
1ae0: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45  , file F...WHERE
1af0: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09   R.fid = F.fid..
1b00: 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49  .AND   R.child I
1b10: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44  S NOT NULL...AND
1b20: 20 20 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72     R.child = C.r
1b30: 69 64 0a 09 09 41 4e 44 20 20 20 43 2e 6c 6f 64  id...AND   C.lod
1b40: 20 21 3d 20 52 2e 6c 6f 64 0a 09 09 3b 0a 09 20   != R.lod...;.. 
1b50: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
1b60: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
1b70: 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64  a non-NTDB child
1b80: 20 77 68 69 63 68 20 61 67 72 65 65 73 20 61 62   which agrees ab
1b90: 6f 75 74 0a 09 23 20 74 68 65 20 6c 69 6e 65 20  out..# the line 
1ba0: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74  of development t
1bb0: 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09  hey belong to...
1bc0: 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 4e 54  Check \..    {NT
1bd0: 44 42 20 61 6e 64 20 74 72 75 6e 6b 20 72 65 76  DB and trunk rev
1be0: 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 62  isions have to b
1bf0: 65 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20 4c  e in different L
1c00: 4f 44 73 7d 20 5c 0a 09 20 20 20 20 7b 6f 6e 20  ODs} \..    {on 
1c10: 4e 54 44 42 20 61 6e 64 20 69 74 73 20 6e 6f 6e  NTDB and its non
1c20: 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 72 6f 6e  -NTDB child wron
1c30: 67 6c 79 20 61 67 72 65 65 20 61 62 6f 75 74 20  gly agree about 
1c40: 74 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53  their LOD} {...S
1c50: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
1c60: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
1c70: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
1c80: 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  C, file F...WHER
1c90: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
1ca0: 09 09 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c  ..AND   R.dbchil
1cb0: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  d IS NOT NULL...
1cc0: 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20  AND   R.dbchild 
1cd0: 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20  = C.rid...AND   
1ce0: 43 2e 6c 6f 64 20 3d 20 52 2e 6c 6f 64 0a 09 09  C.lod = R.lod...
1cf0: 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64  ;..    }..# Find
1d00: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
1d10: 69 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72  ith a branch par
1d20: 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 69 63 68  ent symbol which
1d30: 20 69 73 20 6e 6f 74 0a 09 23 20 74 68 65 69 72   is not..# their
1d40: 20 4c 4f 44 2e 0a 09 43 68 65 63 6b 20 5c 0a 09   LOD...Check \..
1d50: 20 20 20 20 7b 42 72 61 6e 63 68 20 73 74 61 72      {Branch star
1d60: 74 69 6e 67 20 72 65 76 69 73 69 6f 6e 73 20 68  ting revisions h
1d70: 61 76 65 20 74 6f 20 68 61 76 65 20 74 68 65 69  ave to have thei
1d80: 72 20 4c 4f 44 20 61 73 20 62 72 61 6e 63 68 20  r LOD as branch 
1d90: 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 7d 20 5c  parent symbol} \
1da0: 0a 09 20 20 20 20 7b 61 74 20 74 68 65 20 62 65  ..    {at the be
1db0: 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62  ginning of its b
1dc0: 72 61 6e 63 68 20 64 6f 65 73 20 6e 6f 74 20 68  ranch does not h
1dd0: 61 76 65 20 74 68 65 20 62 72 61 6e 63 68 20 73  ave the branch s
1de0: 79 6d 62 6f 6c 20 61 73 20 69 74 73 20 4c 4f 44  ymbol as its LOD
1df0: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
1e00: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
1e10: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69  M revision R, fi
1e20: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66  le F...WHERE R.f
1e30: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
1e40: 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20     R.bparent IS 
1e50: 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20  NOT NULL...AND  
1e60: 20 52 2e 6c 6f 64 20 21 3d 20 52 2e 62 70 61 72   R.lod != R.bpar
1e70: 65 6e 74 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  ent...;..    }..
1e80: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
1e90: 69 6f 6e 73 20 77 69 74 68 20 61 20 62 72 61 6e  ions with a bran
1ea0: 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c  ch parent symbol
1eb0: 20 77 68 6f 73 65 20 70 61 72 65 6e 74 0a 09 23   whose parent..#
1ec0: 20 69 73 20 69 6e 20 74 68 65 20 73 61 6d 65 20   is in the same 
1ed0: 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d  line of developm
1ee0: 65 6e 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  ent...Check \.. 
1ef0: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e     {Revisions an
1f00: 64 20 74 68 65 69 72 20 62 72 61 6e 63 68 20 63  d their branch c
1f10: 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20  hildren have to 
1f20: 62 65 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20  be in different 
1f30: 4c 4f 44 73 7d 20 5c 0a 09 20 20 20 20 7b 61 74  LODs} \..    {at
1f40: 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f   the beginning o
1f50: 66 20 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64  f its branch and
1f60: 20 69 74 73 20 70 61 72 65 6e 74 20 77 72 6f 6e   its parent wron
1f70: 67 6c 79 20 61 67 72 65 65 20 61 62 6f 75 74 20  gly agree about 
1f80: 74 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53  their LOD} {...S
1f90: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
1fa0: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
1fb0: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
1fc0: 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  P, file F...WHER
1fd0: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
1fe0: 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e  ..AND   R.bparen
1ff0: 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  t IS NOT NULL...
2000: 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d  AND   R.parent =
2010: 20 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 52   P.rid...AND   R
2020: 2e 6c 6f 64 20 3d 20 50 2e 6c 6f 64 0a 09 09 3b  .lod = P.lod...;
2030: 0a 09 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a  ..    }..return.
2040: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20      }..    proc 
2050: 4d 65 74 61 20 7b 7d 20 7b 0a 09 23 20 54 68 69  Meta {} {..# Thi
2060: 73 20 63 6f 64 65 20 70 65 72 66 6f 72 6d 73 20  s code performs 
2070: 61 20 6e 75 6d 62 65 72 20 6f 66 20 70 61 72 61  a number of para
2080: 6e 6f 69 64 20 63 68 65 63 6b 73 20 6f 66 20 74  noid checks of t
2090: 68 65 0a 09 23 20 64 61 74 61 62 61 73 65 2c 20  he..# database, 
20a0: 73 65 61 72 63 68 69 6e 67 20 66 6f 72 20 69 6e  searching for in
20b0: 63 6f 6e 73 69 73 74 65 6e 74 20 63 72 6f 73 73  consistent cross
20c0: 2d 72 65 66 65 72 65 6e 63 65 73 2e 0a 09 6c 6f  -references...lo
20d0: 67 20 77 72 69 74 65 20 34 20 69 6e 74 65 67 72  g write 4 integr
20e0: 69 74 79 20 7b 43 68 65 63 6b 20 64 61 74 61 62  ity {Check datab
20f0: 61 73 65 20 63 6f 6e 73 69 73 74 65 6e 63 79 7d  ase consistency}
2100: 0a 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 20 3b  ...upvar 1 n n ;
2110: 20 23 20 43 6f 75 6e 74 65 72 20 66 6f 72 20 74   # Counter for t
2120: 68 65 20 63 68 65 63 6b 73 20 28 77 65 20 70 72  he checks (we pr
2130: 69 6e 74 20 61 6e 20 69 64 20 62 65 66 6f 72 65  int an id before
2140: 0a 09 09 20 20 20 20 20 20 23 20 74 68 65 20 6d  ...      # the m
2150: 61 69 6e 20 6c 61 62 65 6c 29 2e 0a 0a 09 23 20  ain label)....# 
2160: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f  Find all revisio
2170: 6e 73 20 77 68 69 63 68 20 64 69 73 67 72 65 65  ns which disgree
2180: 20 77 69 74 68 20 74 68 65 69 72 20 6d 65 74 61   with their meta
2190: 20 64 61 74 61 20 61 62 6f 75 74 0a 09 23 20 74   data about..# t
21a0: 68 65 20 62 72 61 6e 63 68 2f 6c 69 6e 65 20 6f  he branch/line o
21b0: 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68  f development th
21c0: 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43  ey belong to...C
21d0: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76  heck \..    {Rev
21e0: 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72  isions and their
21f0: 20 6d 65 74 61 20 64 61 74 61 20 68 61 76 65 20   meta data have 
2200: 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d  to be in the sam
2210: 65 20 4c 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 64  e LOD} \..    {d
2220: 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74  isagrees with it
2230: 73 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f 75  s meta data abou
2240: 74 20 6f 77 6e 69 6e 67 20 4c 4f 44 7d 20 7b 0a  t owning LOD} {.
2250: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
2260: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
2270: 76 69 73 69 6f 6e 20 52 2c 20 6d 65 74 61 20 4d  vision R, meta M
2280: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45  , file F...WHERE
2290: 20 52 2e 6d 69 64 20 3d 20 4d 2e 6d 69 64 0a 09   R.mid = M.mid..
22a0: 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20 21 3d 20  .AND   R.lod != 
22b0: 4d 2e 62 69 64 0a 09 09 41 4e 44 20 20 20 52 2e  M.bid...AND   R.
22c0: 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 3b 0a  fid = F.fid...;.
22d0: 09 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a 20  .    }..return. 
22e0: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 52     }..    proc R
22f0: 65 76 69 73 69 6f 6e 43 53 65 74 4c 69 6e 6b 61  evisionCSetLinka
2300: 67 65 20 7b 7d 20 7b 0a 20 20 20 20 7d 0a 0a 20  ge {} {.    }.. 
2310: 20 20 20 70 72 6f 63 20 52 65 76 69 73 69 6f 6e     proc Revision
2320: 43 68 61 6e 67 65 73 65 74 73 20 7b 7d 20 7b 0a  Changesets {} {.
2330: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20      }..    proc 
2340: 53 79 6d 62 6f 6c 43 68 61 6e 67 65 73 65 74 73  SymbolChangesets
2350: 20 7b 7d 20 7b 0a 20 20 20 20 7d 0a 0a 0a 20 20   {} {.    }...  
2360: 20 20 70 72 6f 63 20 43 68 65 63 6b 20 7b 68 65    proc Check {he
2370: 61 64 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20  ader label sql} 
2380: 7b 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09  {..upvar 1 n n..
2390: 73 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63  set ok 1..foreac
23a0: 68 20 7b 66 6e 61 6d 65 20 72 65 76 6e 72 7d 20  h {fname revnr} 
23b0: 5b 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d  [state run $sql]
23c0: 20 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30   {..    set ok 0
23d0: 0a 09 20 20 20 20 74 72 6f 75 62 6c 65 20 66 61  ..    trouble fa
23e0: 74 61 6c 20 22 24 66 6e 61 6d 65 20 3c 24 72 65  tal "$fname <$re
23f0: 76 6e 72 3e 20 24 6c 61 62 65 6c 22 0a 09 7d 0a  vnr> $label"..}.
2400: 09 6c 6f 67 20 77 72 69 74 65 20 35 20 69 6e 74  .log write 5 int
2410: 65 67 72 69 74 79 20 22 5c 5b 5b 66 6f 72 6d 61  egrity "\[[forma
2420: 74 20 25 30 32 64 20 5b 69 6e 63 72 20 6e 5d 5d  t %02d [incr n]]
2430: 5c 5d 20 5b 65 78 70 72 20 7b 24 6f 6b 20 3f 20  \] [expr {$ok ? 
2440: 22 4f 6b 20 20 20 20 22 20 3a 20 22 46 61 69 6c  "Ok    " : "Fail
2450: 65 64 22 7d 5d 20 2e 2e 2e 20 24 68 65 61 64 65  ed"}] ... $heade
2460: 72 22 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  r"..return.    }
2470: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
2480: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
2490: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20  #############.  
24a0: 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74 69    ## Configurati
24b0: 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20 2d  on..    pragma -
24c0: 68 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20 6e  hasinstances   n
24d0: 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e 0a  o ; # singleton.
24e0: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74      pragma -hast
24f0: 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b 20  ypeinfo    no ; 
2500: 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74 69  # no introspecti
2510: 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68  on.    pragma -h
2520: 61 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e 6f  astypedestroy no
2530: 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 0a 20   ; # immortal.. 
2540: 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23     # # ## ### ##
2550: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
2560: 23 23 23 23 23 23 23 23 23 23 0a 7d 0a 0a 6e 61  ##########.}..na
2570: 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a 76  mespace eval ::v
2580: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
2590: 74 3a 3a 63 76 73 20 7b 0a 20 20 20 20 6e 61 6d  t::cvs {.    nam
25a0: 65 73 70 61 63 65 20 65 78 70 6f 72 74 20 69 6e  espace export in
25b0: 74 65 67 72 69 74 79 0a 20 20 20 20 6e 61 6d 65  tegrity.    name
25c0: 73 70 61 63 65 20 65 76 61 6c 20 69 6e 74 65 67  space eval integ
25d0: 72 69 74 79 20 7b 0a 09 6e 61 6d 65 73 70 61 63  rity {..namespac
25e0: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
25f0: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
2600: 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65 73  vs::state..names
2610: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
2620: 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65  ::tools::trouble
2630: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
2640: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  rt ::vc::tools::
2650: 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65  log..log registe
2660: 72 20 69 6e 74 65 67 72 69 74 79 0a 20 20 20 20  r integrity.    
2670: 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20  }.}..# # ## ### 
2680: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
2690: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23  ############ ###
26a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
26b0: 23 23 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 63  ##.## Ready..pac
26c0: 6b 61 67 65 20 70 72 6f 76 69 64 65 20 76 63 3a  kage provide vc:
26d0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
26e0: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 20  :cvs::integrity 
26f0: 31 2e 30 0a 72 65 74 75 72 6e 0a                 1.0.return.