Hex Artifact Content
Not logged in

Artifact 5bb47f2e683e7118cdd1199256b85a82a80c6e66:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [e288af3995] - Fluff: Renamed state methods use/reading/writing to usedb/use/extend for clarity. Updated all callers. Extended state module with code to dump the SQL statements it receives to a file for analysis. Extended the 'use' declarations of several passes. by aku on 2007-12-02 23:47:45.

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 50 61 73  ########..## Pas
0200: 73 20 49 49 2e 20 54 68 69 73 20 70 61 73 73 20  s II. This pass 
0210: 70 61 72 73 65 73 20 74 68 65 20 63 6f 6c 6c 65  parses the colle
0220: 63 74 65 64 20 72 63 73 20 61 72 63 68 69 76 65  cted rcs archive
0230: 73 20 61 6e 64 20 65 78 74 72 61 63 74 73 0a 23  s and extracts.#
0240: 23 20 61 6c 6c 20 74 68 65 20 69 6e 66 6f 72 6d  # all the inform
0250: 61 74 69 6f 6e 20 74 68 65 79 20 63 6f 6e 74 61  ation they conta
0260: 69 6e 20 28 72 65 76 69 73 69 6f 6e 73 2c 20 61  in (revisions, a
0270: 6e 64 20 73 79 6d 62 6f 6c 73 29 2e 0a 0a 23 20  nd symbols)...# 
0280: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
0290: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
02a0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
02b0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52  ###########.## R
02c0: 65 71 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61 63  equirements..pac
02d0: 6b 61 67 65 20 72 65 71 75 69 72 65 20 54 63 6c  kage require Tcl
02e0: 20 38 2e 34 20 20 20 20 20 20 20 20 20 20 20 20   8.4            
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0300: 20 20 20 3b 20 23 20 52 65 71 75 69 72 65 64 20     ; # Required 
0310: 72 75 6e 74 69 6d 65 2e 0a 70 61 63 6b 61 67 65  runtime..package
0320: 20 72 65 71 75 69 72 65 20 73 6e 69 74 20 20 20   require 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 20 20 20 20 20 20 20 20 20 3b                 ;
0350: 20 23 20 4f 4f 20 73 79 73 74 65 6d 2e 0a 70 61   # OO system..pa
0360: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
0370: 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65  ::tools::trouble
0380: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0390: 20 20 20 20 3b 20 23 20 45 72 72 6f 72 20 72 65      ; # Error re
03a0: 70 6f 72 74 69 6e 67 2e 0a 70 61 63 6b 61 67 65  porting..package
03b0: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f   require vc::too
03c0: 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20 20 20 20  ls::log         
03d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b                 ;
03e0: 20 23 20 55 73 65 72 20 66 65 65 64 62 61 63 6b   # User feedback
03f0: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72  ..package requir
0400: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  e vc::fossil::im
0410: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20  port::cvs::pass 
0420: 20 20 20 20 20 20 20 20 3b 20 23 20 50 61 73 73          ; # Pass
0430: 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70 61 63   management..pac
0440: 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a  kage require vc:
0450: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
0460: 3a 63 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72 79  :cvs::repository
0470: 20 20 20 3b 20 23 20 52 65 70 6f 73 69 74 6f 72     ; # Repositor
0480: 79 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70 61  y management..pa
0490: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
04a0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
04b0: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 20 20 20 20  ::cvs::state    
04c0: 20 20 20 20 3b 20 23 20 53 74 61 74 65 20 73 74      ; # State st
04d0: 6f 72 61 67 65 2e 0a 70 61 63 6b 61 67 65 20 72  orage..package r
04e0: 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69  equire vc::fossi
04f0: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
0500: 69 6e 74 65 67 72 69 74 79 20 20 20 20 3b 20 23  integrity    ; #
0510: 20 53 74 61 74 65 20 69 6e 74 65 67 72 69 74 79   State integrity
0520: 20 63 68 65 63 6b 73 2e 0a 70 61 63 6b 61 67 65   checks..package
0530: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73   require vc::fos
0540: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
0550: 3a 3a 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 3b  ::project::sym ;
0560: 20 23 20 50 72 6f 6a 65 63 74 20 6c 65 76 65 6c   # Project level
0570: 20 73 79 6d 62 6f 6c 73 2e 0a 70 61 63 6b 61 67   symbols..packag
0580: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f  e require vc::fo
0590: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
05a0: 73 3a 3a 66 69 6c 65 3a 3a 72 65 76 20 20 20 20  s::file::rev    
05b0: 3b 20 23 20 46 69 6c 65 20 6c 65 76 65 6c 20 72  ; # File level r
05c0: 65 76 69 73 69 6f 6e 73 2e 0a 70 61 63 6b 61 67  evisions..packag
05d0: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 72 63  e require vc::rc
05e0: 73 3a 3a 70 61 72 73 65 72 20 20 20 20 20 20 20  s::parser       
05f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0600: 3b 20 23 20 52 63 73 20 61 72 63 68 69 76 65 20  ; # Rcs archive 
0610: 64 61 74 61 20 65 78 74 72 61 63 74 69 6f 6e 2e  data extraction.
0620: 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
0630: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
0640: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23  ######### ######
0650: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
0660: 23 23 20 52 65 67 69 73 74 65 72 20 74 68 65 20  ## Register the 
0670: 70 61 73 73 20 77 69 74 68 20 74 68 65 20 6d 61  pass with the ma
0680: 6e 61 67 65 6d 65 6e 74 0a 0a 76 63 3a 3a 66 6f  nagement..vc::fo
0690: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
06a0: 73 3a 3a 70 61 73 73 20 64 65 66 69 6e 65 20 5c  s::pass define \
06b0: 0a 20 20 20 20 43 6f 6c 6c 65 63 74 52 65 76 20  .    CollectRev 
06c0: 5c 0a 20 20 20 20 7b 43 6f 6c 6c 65 63 74 20 72  \.    {Collect r
06d0: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 73 79 6d  evisions and sym
06e0: 62 6f 6c 73 7d 20 5c 0a 20 20 20 20 3a 3a 76 63  bols} \.    ::vc
06f0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
0700: 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c  ::cvs::pass::col
0710: 6c 72 65 76 0a 0a 23 20 23 20 23 23 20 23 23 23  lrev..# # ## ###
0720: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
0730: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23  ############# ##
0740: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0750: 23 23 23 0a 23 23 0a 0a 73 6e 69 74 3a 3a 74 79  ###.##..snit::ty
0760: 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  pe ::vc::fossil:
0770: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61  :import::cvs::pa
0780: 73 73 3a 3a 63 6f 6c 6c 72 65 76 20 7b 0a 20 20  ss::collrev {.  
0790: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
07a0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
07b0: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
07c0: 20 50 75 62 6c 69 63 20 41 50 49 0a 0a 20 20 20   Public API..   
07d0: 20 74 79 70 65 6d 65 74 68 6f 64 20 73 65 74 75   typemethod setu
07e0: 70 20 7b 7d 20 7b 0a 09 23 20 44 65 66 69 6e 65  p {} {..# Define
07f0: 20 6e 61 6d 65 73 20 61 6e 64 20 73 74 72 75 63   names and struc
0800: 74 75 72 65 20 6f 66 20 74 68 65 20 70 65 72 73  ture of the pers
0810: 69 73 74 65 6e 74 20 73 74 61 74 65 20 6f 66 20  istent state of 
0820: 74 68 69 73 0a 09 23 20 70 61 73 73 2e 0a 0a 09  this..# pass....
0830: 73 74 61 74 65 20 75 73 65 20 70 72 6f 6a 65 63  state use projec
0840: 74 0a 09 73 74 61 74 65 20 75 73 65 20 66 69 6c  t..state use fil
0850: 65 0a 0a 09 23 20 57 65 20 64 65 61 6c 20 77 69  e...# We deal wi
0860: 74 68 20 70 65 72 20 70 72 6f 6a 65 63 74 20 61  th per project a
0870: 6e 64 20 70 65 72 20 66 69 6c 65 20 64 61 74 61  nd per file data
0880: 2c 20 74 68 65 20 66 69 72 73 74 0a 09 23 20 63  , the first..# c
0890: 6f 6c 6c 61 74 65 64 20 66 72 6f 6d 20 74 68 65  ollated from the
08a0: 20 73 65 63 6f 6e 64 2e 0a 0a 09 23 20 50 65 72   second....# Per
08b0: 20 66 69 6c 65 20 77 65 20 68 61 76 65 20 67 65   file we have ge
08c0: 6e 65 72 61 6c 20 69 6e 66 6f 72 6d 61 74 69 6f  neral informatio
08d0: 6e 2c 20 2e 2e 2e 2c 20 61 6e 64 20 74 68 65 6e  n, ..., and then
08e0: 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 20 61 6e  ..# revisions an
08f0: 64 20 73 79 6d 62 6f 6c 73 2e 20 54 68 65 20 6c  d symbols. The l
0900: 61 74 74 65 72 20 63 61 6e 20 62 65 20 66 75 72  atter can be fur
0910: 74 68 65 72 20 73 65 70 61 72 61 74 65 64 0a 09  ther separated..
0920: 23 20 69 6e 74 6f 20 74 61 67 73 20 61 6e 64 20  # into tags and 
0930: 62 72 61 6e 63 68 65 73 2e 20 41 74 20 70 72 6f  branches. At pro
0940: 6a 65 63 74 20 6c 65 76 65 6c 20 74 68 65 20 70  ject level the p
0950: 65 72 2d 66 69 6c 65 0a 09 23 20 73 79 6d 62 6f  er-file..# symbo
0960: 6c 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 69  ls information i
0970: 73 20 6d 65 72 67 65 64 2e 0a 0a 09 23 20 46 69  s merged....# Fi
0980: 6c 65 20 6c 65 76 65 6c 20 2e 2e 2e 0a 09 23 09  le level .....#.
0990: 52 65 76 69 73 69 6f 6e 73 2c 20 42 72 61 6e 63  Revisions, Branc
09a0: 68 65 73 2c 20 54 61 67 73 0a 09 23 0a 09 23 20  hes, Tags..#..# 
09b0: 50 73 65 75 64 6f 20 63 6c 61 73 73 20 68 69 65  Pseudo class hie
09c0: 72 61 72 63 68 79 0a 09 23 09 54 61 67 20 20 20  rarchy..#.Tag   
09d0: 20 20 20 3c 2d 20 53 79 6d 62 6f 6c 20 3c 2d 20     <- Symbol <- 
09e0: 45 76 65 6e 74 0a 09 23 09 42 72 61 6e 63 68 20  Event..#.Branch 
09f0: 20 20 3c 2d 20 53 79 6d 62 6f 6c 20 3c 2d 20 45    <- Symbol <- E
0a00: 76 65 6e 74 0a 09 23 09 52 65 76 69 73 69 6f 6e  vent..#.Revision
0a10: 20 20 20 20 20 20 20 20 20 20 20 3c 2d 20 45 76             <- Ev
0a20: 65 6e 74 0a 0a 09 73 74 61 74 65 20 65 78 74 65  ent...state exte
0a30: 6e 64 20 72 65 76 69 73 69 6f 6e 20 7b 0a 09 20  nd revision {.. 
0a40: 20 20 20 2d 2d 20 52 65 76 69 73 69 6f 6e 73 2e     -- Revisions.
0a50: 20 49 64 65 6e 74 69 66 69 65 64 20 62 79 20 61   Identified by a
0a60: 20 67 6c 6f 62 61 6c 20 6e 75 6d 65 72 69 63 20   global numeric 
0a70: 69 64 20 65 61 63 68 0a 09 20 20 20 20 2d 2d 20  id each..    -- 
0a80: 62 65 6c 6f 6e 67 73 20 74 6f 20 61 20 73 69 6e  belongs to a sin
0a90: 67 6c 65 20 66 69 6c 65 2c 20 69 64 65 6e 74 69  gle file, identi
0aa0: 66 69 65 64 20 62 79 20 69 74 73 20 69 64 2e 20  fied by its id. 
0ab0: 49 74 0a 09 20 20 20 20 2d 2d 20 66 75 72 74 68  It..    -- furth
0ac0: 65 72 20 68 61 73 20 61 20 64 6f 74 74 65 64 20  er has a dotted 
0ad0: 72 65 76 69 73 69 6f 6e 20 6e 75 6d 62 65 72 20  revision number 
0ae0: 28 44 54 4e 29 2e 0a 09 20 20 20 20 2d 2d 0a 09  (DTN)...    --..
0af0: 20 20 20 20 2d 2d 20 43 6f 6e 73 74 72 61 69 6e      -- Constrain
0b00: 74 3a 20 54 68 65 20 64 6f 74 74 65 64 20 72 65  t: The dotted re
0b10: 76 69 73 69 6f 6e 20 6e 75 6d 62 65 72 20 69 73  vision number is
0b20: 20 75 6e 69 71 75 65 20 77 69 74 68 69 6e 0a 20   unique within. 
0b30: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 20 20             --   
0b40: 20 20 20 20 20 20 20 20 20 20 74 68 65 20 66 69            the fi
0b50: 6c 65 2e 20 53 65 65 20 65 6e 64 20 6f 66 20 64  le. See end of d
0b60: 65 66 69 6e 69 74 69 6f 6e 2e 0a 0a 09 20 20 20  efinition....   
0b70: 20 72 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e   rid  INTEGER  N
0b80: 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59  OT NULL  PRIMARY
0b90: 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45   KEY AUTOINCREME
0ba0: 4e 54 2c 0a 09 20 20 20 20 66 69 64 20 20 49 4e  NT,..    fid  IN
0bb0: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
0bc0: 20 52 45 46 45 52 45 4e 43 45 53 20 66 69 6c 65   REFERENCES file
0bd0: 2c 20 20 20 2d 2d 20 46 69 6c 65 20 6f 77 6e 69  ,   -- File owni
0be0: 6e 67 20 72 65 76 69 73 69 6f 6e 2e 0a 09 20 20  ng revision...  
0bf0: 20 20 72 65 76 20 20 54 45 58 54 20 20 20 20 20    rev  TEXT     
0c00: 4e 4f 54 20 4e 55 4c 4c 2c 20 20 20 20 20 20 20  NOT NULL,       
0c10: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20               -- 
0c20: 44 6f 74 74 65 64 20 52 65 76 20 4e 75 6d 62 65  Dotted Rev Numbe
0c30: 72 2e 0a 0a 09 20 20 20 20 2d 2d 20 41 6c 6c 20  r....    -- All 
0c40: 72 65 76 69 73 69 6f 6e 73 20 62 65 6c 6f 6e 67  revisions belong
0c50: 20 74 6f 20 61 20 6c 69 6e 65 2d 6f 66 2d 64 65   to a line-of-de
0c60: 76 65 6c 6f 70 6d 65 6e 74 2c 0a 09 20 20 20 20  velopment,..    
0c70: 2d 2d 20 69 64 65 6e 74 69 66 69 65 64 20 62 79  -- identified by
0c80: 20 61 20 73 79 6d 62 6f 6c 20 28 70 72 6f 6a 65   a symbol (proje
0c90: 63 74 20 6c 65 76 65 6c 29 2e 20 44 75 72 69 6e  ct level). Durin
0ca0: 67 20 64 61 74 61 0a 09 20 20 20 20 2d 2d 20 63  g data..    -- c
0cb0: 6f 6c 6c 65 63 74 69 6f 6e 20 69 74 20 77 61 73  ollection it was
0cc0: 20 61 20 66 69 6c 65 2d 6c 65 76 65 6c 20 62 72   a file-level br
0cd0: 61 6e 63 68 20 73 79 6d 62 6f 6c 2e 0a 09 20 20  anch symbol...  
0ce0: 20 20 2d 2d 0a 09 20 20 20 20 2d 2d 20 43 6f 6e    --..    -- Con
0cf0: 73 74 72 61 69 6e 74 3a 20 41 6c 6c 20 74 68 65  straint: All the
0d00: 20 4c 4f 44 20 73 79 6d 62 6f 6c 73 20 61 72 65   LOD symbols are
0d10: 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70 72 6f   in the same pro
0d20: 6a 65 63 74 0a 09 20 20 20 20 2d 2d 20 20 20 20  ject..    --    
0d30: 20 20 20 20 20 20 20 20 20 61 73 20 74 68 65 20           as the 
0d40: 66 69 6c 65 20 69 74 73 65 6c 66 2e 20 54 68 69  file itself. Thi
0d50: 73 20 63 61 6e 6e 6f 74 20 62 65 0a 09 20 20 20  s cannot be..   
0d60: 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20   --             
0d70: 65 78 70 72 65 73 73 65 64 20 69 6e 20 43 52 45  expressed in CRE
0d80: 41 54 45 20 54 41 42 4c 45 20 73 79 6e 74 61 78  ATE TABLE syntax
0d90: 2e 0a 0a 09 20 20 20 20 6c 6f 64 20 20 49 4e 54  ....    lod  INT
0da0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
0db0: 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f  REFERENCES symbo
0dc0: 6c 2c 20 2d 2d 20 4c 69 6e 65 20 6f 66 20 64 65  l, -- Line of de
0dd0: 76 65 6c 6f 70 6d 65 6e 74 0a 0a 09 20 20 20 20  velopment...    
0de0: 2d 2d 20 54 68 65 20 72 65 76 69 73 69 6f 6e 73  -- The revisions
0df0: 20 69 6e 20 61 20 66 69 6c 65 20 61 72 65 20 6f   in a file are o
0e00: 72 67 61 6e 69 7a 65 64 20 69 6e 20 61 20 66 6f  rganized in a fo
0e10: 72 65 73 74 20 6f 66 0a 09 20 20 20 20 2d 2d 20  rest of..    -- 
0e20: 74 72 65 65 73 2c 20 77 69 74 68 20 74 68 65 20  trees, with the 
0e30: 6d 61 69 6e 20 6c 69 6e 65 73 20 64 65 66 69 6e  main lines defin
0e40: 65 64 20 74 68 72 6f 75 67 68 20 74 68 65 20 70  ed through the p
0e50: 61 72 65 6e 74 20 2f 0a 09 20 20 20 20 2d 2d 20  arent /..    -- 
0e60: 63 68 69 6c 64 20 72 65 66 65 72 65 6e 63 65 73  child references
0e70: 2e 20 41 20 72 65 76 69 73 69 6f 6e 20 77 69 74  . A revision wit
0e80: 68 6f 75 74 20 61 20 70 61 72 65 6e 74 20 69 73  hout a parent is
0e90: 20 74 68 65 0a 09 20 20 20 20 2d 2d 20 72 6f 6f   the..    -- roo
0ea0: 74 20 6f 66 20 61 20 74 72 65 65 2c 20 61 6e 64  t of a tree, and
0eb0: 20 61 20 72 65 76 69 73 69 6f 6e 20 77 69 74 68   a revision with
0ec0: 6f 75 74 20 61 20 63 68 69 6c 64 20 69 73 20 61  out a child is a
0ed0: 0a 09 20 20 20 20 2d 2d 20 6c 65 61 66 2e 0a 0a  ..    -- leaf...
0ee0: 09 20 20 20 20 2d 2d 20 43 6f 6e 73 74 72 61 69  .    -- Constrai
0ef0: 6e 74 73 3a 20 41 6c 6c 20 72 65 76 69 73 69 6f  nts: All revisio
0f00: 6e 73 20 63 6f 75 70 6c 65 64 20 74 68 72 6f 75  ns coupled throu
0f10: 67 68 20 70 61 72 65 6e 74 2f 63 68 69 6c 64 0a  gh parent/child.
0f20: 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20  .    --         
0f30: 20 20 20 20 20 72 65 66 65 72 20 74 6f 20 74 68       refer to th
0f40: 65 20 73 61 6d 65 20 4c 4f 44 20 73 79 6d 62 6f  e same LOD symbo
0f50: 6c 2e 20 54 68 65 20 70 61 72 65 6e 74 0a 09 20  l. The parent.. 
0f60: 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20     --           
0f70: 20 20 20 6f 66 20 61 20 63 68 69 6c 64 20 6f 66     of a child of
0f80: 20 58 20 69 73 20 58 2e 20 54 68 65 20 63 68 69   X is X. The chi
0f90: 6c 64 20 6f 66 20 61 0a 09 20 20 20 20 2d 2d 20  ld of a..    -- 
0fa0: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 61 72               par
0fb0: 65 6e 74 20 6f 66 20 58 20 69 73 20 58 2e 0a 0a  ent of X is X...
0fc0: 09 20 20 20 20 70 61 72 65 6e 74 20 20 49 4e 54  .    parent  INT
0fd0: 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20 20  EGER            
0fe0: 52 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73  REFERENCES revis
0ff0: 69 6f 6e 2c 0a 09 20 20 20 20 63 68 69 6c 64 20  ion,..    child 
1000: 20 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20    INTEGER       
1010: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
1020: 72 65 76 69 73 69 6f 6e 2c 0a 0a 09 20 20 20 20  revision,...    
1030: 2d 2d 20 54 68 65 20 72 65 70 72 65 73 65 6e 74  -- The represent
1040: 61 74 69 6f 6e 20 6f 66 20 61 20 62 72 61 6e 63  ation of a branc
1050: 68 20 69 6e 20 61 20 74 72 65 65 20 69 73 20 74  h in a tree is t
1060: 68 65 0a 09 20 20 20 20 2d 2d 20 65 78 63 65 70  he..    -- excep
1070: 74 69 6f 6e 20 74 6f 20 74 68 65 20 74 68 72 65  tion to the thre
1080: 65 20 63 6f 6e 73 74 72 61 69 6e 74 73 20 61 62  e constraints ab
1090: 6f 76 65 2e 0a 0a 09 20 20 20 20 2d 2d 20 54 68  ove....    -- Th
10a0: 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 61  e beginning of a
10b0: 20 62 72 61 6e 63 68 20 69 73 20 72 65 70 72 65   branch is repre
10c0: 73 65 6e 74 65 64 20 62 79 20 61 20 6e 6f 6e 2d  sented by a non-
10d0: 4e 55 4c 4c 0a 09 20 20 20 20 2d 2d 20 62 70 61  NULL..    -- bpa
10e0: 72 65 6e 74 20 6f 66 20 61 20 72 65 76 69 73 69  rent of a revisi
10f0: 6f 6e 2e 20 54 68 69 73 20 72 65 76 69 73 69 6f  on. This revisio
1100: 6e 20 42 20 69 73 20 74 68 65 20 66 69 72 73 74  n B is the first
1110: 20 6f 6e 0a 09 20 20 20 20 2d 2d 20 74 68 65 20   on..    -- the 
1120: 62 72 61 6e 63 68 2e 20 49 74 73 20 70 61 72 65  branch. Its pare
1130: 6e 74 20 50 20 69 73 20 74 68 65 20 72 65 76 69  nt P is the revi
1140: 73 69 6f 6e 20 74 68 65 20 62 72 61 6e 63 68 20  sion the branch 
1150: 69 73 0a 09 20 20 20 20 2d 2d 20 72 6f 6f 74 65  is..    -- roote
1160: 64 20 69 6e 2c 20 61 6e 64 20 69 74 20 69 73 20  d in, and it is 
1170: 6e 6f 74 20 74 68 65 20 63 68 69 6c 64 20 6f 66  not the child of
1180: 20 50 2e 20 42 20 61 6e 64 20 50 20 72 65 66 65   P. B and P refe
1190: 72 0a 09 20 20 20 20 2d 2d 20 74 6f 20 64 69 66  r..    -- to dif
11a0: 66 65 72 65 6e 74 20 4c 4f 44 20 73 79 6d 62 6f  ferent LOD symbo
11b0: 6c 73 2e 20 54 68 65 20 62 70 61 72 65 6e 74 20  ls. The bparent 
11c0: 6f 66 20 42 20 69 73 20 61 6c 73 6f 20 69 74 73  of B is also its
11d0: 0a 09 20 20 20 20 2d 2d 20 4c 4f 44 2c 20 61 6e  ..    -- LOD, an
11e0: 64 20 74 68 65 20 4c 4f 44 20 6f 66 20 69 74 73  d the LOD of its
11f0: 20 63 68 69 6c 64 72 65 6e 2e 0a 0a 09 20 20 20   children....   
1200: 20 62 70 61 72 65 6e 74 20 49 4e 54 45 47 45 52   bparent INTEGER
1210: 20 20 20 20 20 20 20 20 20 20 20 20 52 45 46 45              REFE
1220: 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 0a 0a  RENCES symbol,..
1230: 09 20 20 20 20 2d 2d 20 4c 61 73 74 6c 79 20 77  .    -- Lastly w
1240: 65 20 6b 65 65 70 20 69 6e 66 6f 72 6d 61 74 69  e keep informati
1250: 6f 6e 20 69 73 20 61 62 6f 75 74 20 6e 6f 6e 2d  on is about non-
1260: 74 72 75 6e 6b 20 64 65 66 61 75 6c 74 0a 09 20  trunk default.. 
1270: 20 20 20 2d 2d 20 62 72 61 6e 63 68 65 73 20 28     -- branches (
1280: 4e 54 44 42 29 20 69 6e 20 74 68 65 20 72 65 76  NTDB) in the rev
1290: 69 73 69 6f 6e 73 2e 0a 0a 09 20 20 20 20 2d 2d  isions....    --
12a0: 20 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 6f   All revisions o
12b0: 6e 20 74 68 65 20 4e 54 44 42 20 68 61 76 65 20  n the NTDB have 
12c0: 27 69 73 64 65 66 61 75 6c 74 27 20 54 52 55 45  'isdefault' TRUE
12d0: 2c 0a 09 20 20 20 20 2d 2d 20 65 76 65 72 79 6f  ,..    -- everyo
12e0: 6e 65 20 65 6c 73 65 20 46 41 4c 53 45 2e 20 54  ne else FALSE. T
12f0: 68 65 20 6c 61 73 74 20 72 65 76 69 73 69 6f 6e  he last revision
1300: 20 58 20 6f 6e 20 74 68 65 20 4e 54 44 42 0a 09   X on the NTDB..
1310: 20 20 20 20 2d 2d 20 77 68 69 63 68 20 69 73 20      -- which is 
1320: 73 74 69 6c 6c 20 63 6f 6e 73 69 64 65 72 65 64  still considered
1330: 20 74 6f 20 62 65 20 6f 6e 20 74 68 65 20 74 72   to be on the tr
1340: 75 6e 6b 20 61 73 20 77 65 6c 6c 0a 09 20 20 20  unk as well..   
1350: 20 2d 2d 20 68 61 73 20 61 20 6e 6f 6e 2d 4e 55   -- has a non-NU
1360: 4c 4c 20 27 64 62 63 68 69 6c 64 27 20 77 68 69  LL 'dbchild' whi
1370: 63 68 20 72 65 66 65 72 73 20 74 6f 20 74 68 65  ch refers to the
1380: 20 72 6f 6f 74 20 6f 66 0a 09 20 20 20 20 2d 2d   root of..    --
1390: 20 74 68 65 20 74 72 75 6e 6b 2e 20 54 68 65 20   the trunk. The 
13a0: 72 6f 6f 74 20 61 6c 73 6f 20 68 61 73 20 61 20  root also has a 
13b0: 6e 6f 6e 2d 4e 55 4c 4c 20 64 62 70 61 72 65 6e  non-NULL dbparen
13c0: 74 0a 09 20 20 20 20 2d 2d 20 72 65 66 65 72 69  t..    -- referi
13d0: 6e 67 20 74 6f 20 58 2e 0a 0a 09 20 20 20 20 69  ng to X....    i
13e0: 73 64 65 66 61 75 6c 74 20 49 4e 54 45 47 45 52  sdefault INTEGER
13f0: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20    NOT NULL,..   
1400: 20 64 62 70 61 72 65 6e 74 20 20 49 4e 54 45 47   dbparent  INTEG
1410: 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52 45  ER            RE
1420: 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f  FERENCES revisio
1430: 6e 2c 0a 09 20 20 20 20 64 62 63 68 69 6c 64 20  n,..    dbchild 
1440: 20 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20    INTEGER       
1450: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
1460: 72 65 76 69 73 69 6f 6e 2c 0a 0a 09 20 20 20 20  revision,...    
1470: 2d 2d 20 54 68 65 20 6d 61 69 6e 20 70 61 79 6c  -- The main payl
1480: 6f 61 64 20 6f 66 20 74 68 65 20 72 65 76 69 73  oad of the revis
1490: 69 6f 6e 20 61 72 65 20 74 68 65 20 64 61 74 65  ion are the date
14a0: 2f 74 69 6d 65 20 69 74 0a 09 20 20 20 20 2d 2d  /time it..    --
14b0: 20 77 61 73 20 65 6e 74 65 72 65 64 2c 20 69 74   was entered, it
14c0: 73 20 73 74 61 74 65 2c 20 6f 70 65 72 61 74 69  s state, operati
14d0: 6f 6e 20 28 3d 20 74 79 70 65 2f 63 6c 61 73 73  on (= type/class
14e0: 29 2c 20 74 65 78 74 0a 09 20 20 20 20 2d 2d 20  ), text..    -- 
14f0: 63 6f 6e 74 65 6e 74 2c 20 61 6e 64 20 6d 65 74  content, and met
1500: 61 20 64 61 74 61 20 28 61 75 74 68 6f 72 2c 20  a data (author, 
1510: 6c 6f 67 20 6d 65 73 73 61 67 65 2c 20 62 72 61  log message, bra
1520: 6e 63 68 2c 0a 09 20 20 20 20 2d 2d 20 70 72 6f  nch,..    -- pro
1530: 6a 65 63 74 29 2e 20 54 68 65 20 6c 61 73 74 20  ject). The last 
1540: 69 73 20 65 6e 63 6f 64 65 64 20 61 73 20 73 69  is encoded as si
1550: 6e 67 6c 65 20 69 64 2c 20 73 65 65 20 74 61 62  ngle id, see tab
1560: 6c 65 0a 09 20 20 20 20 2d 2d 20 27 6d 65 74 61  le..    -- 'meta
1570: 27 2e 20 54 68 65 20 64 61 74 65 2f 74 69 6d 65  '. The date/time
1580: 20 69 73 20 67 69 76 65 6e 20 69 6e 20 73 65 63   is given in sec
1590: 6f 6e 64 73 20 73 69 6e 63 65 20 74 68 65 0a 09  onds since the..
15a0: 20 20 20 20 2d 2d 20 65 70 6f 63 68 2c 20 66 6f      -- epoch, fo
15b0: 72 20 65 61 73 79 20 63 6f 6d 70 61 72 69 73 6f  r easy compariso
15c0: 6e 2e 20 54 68 65 20 74 65 78 74 20 63 6f 6e 74  n. The text cont
15d0: 65 6e 74 20 69 73 20 61 6e 0a 09 20 20 20 20 2d  ent is an..    -
15e0: 2d 20 28 6f 66 66 73 65 74 2c 6c 65 6e 67 74 68  - (offset,length
15f0: 29 20 70 61 69 72 20 69 6e 74 6f 20 74 68 65 20  ) pair into the 
1600: 72 63 73 20 61 72 63 68 69 76 65 2e 0a 0a 09 20  rcs archive.... 
1610: 20 20 20 6f 70 20 20 20 20 49 4e 54 45 47 45 52     op    INTEGER
1620: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
1630: 52 45 4e 43 45 53 20 6f 70 74 79 70 65 2c 0a 09  RENCES optype,..
1640: 20 20 20 20 64 61 74 65 20 20 49 4e 54 45 47 45      date  INTEGE
1650: 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20  R  NOT NULL,..  
1660: 20 20 73 74 61 74 65 20 54 45 58 54 20 20 20 20    state TEXT    
1670: 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20   NOT NULL,..    
1680: 6d 69 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e  mid   INTEGER  N
1690: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
16a0: 43 45 53 20 6d 65 74 61 2c 0a 09 20 20 20 20 63  CES meta,..    c
16b0: 6f 66 66 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  off  INTEGER  NO
16c0: 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 63 6c 65  T NULL,..    cle
16d0: 6e 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  n  INTEGER  NOT 
16e0: 4e 55 4c 4c 2c 0a 0a 09 20 20 20 20 55 4e 49 51  NULL,...    UNIQ
16f0: 55 45 20 28 66 69 64 2c 20 72 65 76 29 20 2d 2d  UE (fid, rev) --
1700: 20 54 68 65 20 44 54 4e 20 69 73 20 75 6e 69 71   The DTN is uniq
1710: 75 65 20 77 69 74 68 69 6e 20 74 68 65 20 72 65  ue within the re
1720: 76 69 73 69 6f 6e 27 73 20 66 69 6c 65 2e 0a 09  vision's file...
1730: 7d 0a 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64  }...state extend
1740: 20 6f 70 74 79 70 65 20 7b 0a 09 20 20 20 20 6f   optype {..    o
1750: 69 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  id   INTEGER  NO
1760: 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20  T NULL  PRIMARY 
1770: 4b 45 59 2c 0a 09 20 20 20 20 6e 61 6d 65 20 20  KEY,..    name  
1780: 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c  TEXT     NOT NUL
1790: 4c 2c 0a 09 20 20 20 20 55 4e 49 51 55 45 28 6e  L,..    UNIQUE(n
17a0: 61 6d 65 29 0a 09 7d 0a 09 73 74 61 74 65 20 72  ame)..}..state r
17b0: 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45 52 54  un {..    INSERT
17c0: 20 49 4e 54 4f 20 6f 70 74 79 70 65 20 56 41 4c   INTO optype VAL
17d0: 55 45 53 20 28 2d 31 2c 27 64 65 6c 65 74 65 27  UES (-1,'delete'
17e0: 29 3b 20 20 2d 2d 20 54 68 65 20 6f 70 63 6f 64  );  -- The opcod
17f0: 65 20 6e 61 6d 65 73 20 61 72 65 20 74 68 65 0a  e names are the.
1800: 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
1810: 20 6f 70 74 79 70 65 20 56 41 4c 55 45 53 20 28   optype VALUES (
1820: 20 30 2c 27 6e 6f 74 68 69 6e 67 27 29 3b 20 2d   0,'nothing'); -
1830: 2d 20 66 69 78 65 64 20 70 69 65 63 65 73 2c 20  - fixed pieces, 
1840: 73 65 65 20 6d 79 6f 70 73 74 61 74 65 0a 09 20  see myopstate.. 
1850: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 6f     INSERT INTO o
1860: 70 74 79 70 65 20 56 41 4c 55 45 53 20 28 20 31  ptype VALUES ( 1
1870: 2c 27 61 64 64 27 29 3b 20 20 20 20 20 2d 2d 20  ,'add');     -- 
1880: 69 6e 20 66 69 6c 65 3a 3a 72 65 76 2e 20 6d 79  in file::rev. my
1890: 6f 70 63 6f 64 65 20 69 73 0a 09 20 20 20 20 49  opcode is..    I
18a0: 4e 53 45 52 54 20 49 4e 54 4f 20 6f 70 74 79 70  NSERT INTO optyp
18b0: 65 20 56 41 4c 55 45 53 20 28 20 32 2c 27 63 68  e VALUES ( 2,'ch
18c0: 61 6e 67 65 27 29 3b 20 20 2d 2d 20 6c 6f 61 64  ange');  -- load
18d0: 65 64 20 66 72 6f 6d 20 74 68 69 73 2e 0a 09 7d  ed from this...}
18e0: 0a 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64 20  ...state extend 
18f0: 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68  revisionbranchch
1900: 69 6c 64 72 65 6e 20 7b 0a 09 20 20 20 20 2d 2d  ildren {..    --
1910: 20 54 68 65 20 6e 6f 6e 2d 70 72 69 6d 61 72 79   The non-primary
1920: 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 61 20 72   children of a r
1930: 65 76 69 73 69 6f 6e 2c 20 61 73 20 72 65 61 63  evision, as reac
1940: 68 61 62 6c 65 0a 09 20 20 20 20 2d 2d 20 74 68  hable..    -- th
1950: 72 6f 75 67 68 20 61 20 62 72 61 6e 63 68 20 73  rough a branch s
1960: 79 6d 62 6f 6c 2c 20 61 72 65 20 6c 69 73 74 65  ymbol, are liste
1970: 64 20 68 65 72 65 2e 20 54 68 69 73 20 69 73 0a  d here. This is.
1980: 09 20 20 20 20 2d 2d 20 6e 65 65 64 65 64 20 62  .    -- needed b
1990: 79 20 70 61 73 73 20 35 20 74 6f 20 62 72 65 61  y pass 5 to brea
19a0: 6b 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e  k internal depen
19b0: 64 65 6e 63 69 65 73 20 69 6e 20 61 0a 09 20 20  dencies in a..  
19c0: 20 20 2d 2d 20 63 68 61 6e 67 65 73 65 74 2e 0a    -- changeset..
19d0: 0a 09 20 20 20 20 72 69 64 20 20 20 49 4e 54 45  ..    rid   INTE
19e0: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52  GER  NOT NULL  R
19f0: 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69  EFERENCES revisi
1a00: 6f 6e 2c 0a 09 20 20 20 20 62 72 69 64 20 20 49  on,..    brid  I
1a10: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1a20: 20 20 52 45 46 45 52 45 4e 43 45 53 20 72 65 76    REFERENCES rev
1a30: 69 73 69 6f 6e 2c 0a 09 20 20 20 20 55 4e 49 51  ision,..    UNIQ
1a40: 55 45 28 72 69 64 2c 62 72 69 64 29 0a 09 7d 0a  UE(rid,brid)..}.
1a50: 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64 20 74  ..state extend t
1a60: 61 67 20 7b 0a 09 20 20 20 20 74 69 64 20 20 49  ag {..    tid  I
1a70: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1a80: 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41 55    PRIMARY KEY AU
1a90: 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20  TOINCREMENT,..  
1aa0: 20 20 66 69 64 20 20 49 4e 54 45 47 45 52 20 20    fid  INTEGER  
1ab0: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
1ac0: 4e 43 45 53 20 66 69 6c 65 2c 20 20 20 20 20 2d  NCES file,     -
1ad0: 2d 20 46 69 6c 65 20 74 68 65 20 69 74 65 6d 20  - File the item 
1ae0: 62 65 6c 6f 6e 67 73 20 74 6f 0a 09 20 20 20 20  belongs to..    
1af0: 6c 6f 64 20 20 49 4e 54 45 47 45 52 20 20 20 20  lod  INTEGER    
1b00: 20 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43          REFERENC
1b10: 45 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20  ES symbol,   -- 
1b20: 4c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d  Line of developm
1b30: 65 6e 74 20 28 4e 55 4c 4c 20 3d 3e 20 54 72 75  ent (NULL => Tru
1b40: 6e 6b 29 0a 09 20 20 20 20 73 69 64 20 20 49 4e  nk)..    sid  IN
1b50: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
1b60: 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62   REFERENCES symb
1b70: 6f 6c 2c 20 20 20 2d 2d 20 53 79 6d 62 6f 6c 20  ol,   -- Symbol 
1b80: 63 61 70 74 75 72 69 6e 67 20 74 68 65 20 74 61  capturing the ta
1b90: 67 0a 0a 09 20 20 20 20 72 65 76 20 20 49 4e 54  g...    rev  INT
1ba0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
1bb0: 52 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73  REFERENCES revis
1bc0: 69 6f 6e 20 20 2d 2d 20 54 68 65 20 72 65 76 69  ion  -- The revi
1bd0: 73 69 6f 6e 20 62 65 69 6e 67 20 74 61 67 67 65  sion being tagge
1be0: 64 2e 0a 09 7d 20 7b 20 72 65 76 20 73 69 64 20  d...} { rev sid 
1bf0: 7d 0a 09 23 20 49 6e 64 69 63 65 73 20 6f 6e 3a  }..# Indices on:
1c00: 20 72 65 76 20 28 72 65 76 69 73 69 6f 6e 20 73   rev (revision s
1c10: 75 63 63 65 73 73 6f 72 73 29 0a 09 23 20 20 20  uccessors)..#   
1c20: 20 20 20 20 20 20 20 20 20 20 73 69 64 20 28 74            sid (t
1c30: 61 67 20 70 72 65 64 65 63 65 73 73 6f 72 73 2c  ag predecessors,
1c40: 20 62 72 61 6e 63 68 20 73 75 63 63 65 73 73 6f   branch successo
1c50: 72 73 2f 70 72 65 64 65 63 65 73 73 6f 72 73 29  rs/predecessors)
1c60: 0a 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64 20  ...state extend 
1c70: 62 72 61 6e 63 68 20 7b 0a 09 20 20 20 20 62 69  branch {..    bi
1c80: 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  d   INTEGER  NOT
1c90: 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b   NULL  PRIMARY K
1ca0: 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54  EY AUTOINCREMENT
1cb0: 2c 0a 09 20 20 20 20 66 69 64 20 20 20 49 4e 54  ,..    fid   INT
1cc0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
1cd0: 52 45 46 45 52 45 4e 43 45 53 20 66 69 6c 65 2c  REFERENCES file,
1ce0: 20 20 20 20 20 2d 2d 20 46 69 6c 65 20 74 68 65       -- File the
1cf0: 20 69 74 65 6d 20 62 65 6c 6f 6e 67 73 20 74 6f   item belongs to
1d00: 0a 09 20 20 20 20 6c 6f 64 20 20 20 49 4e 54 45  ..    lod   INTE
1d10: 47 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52  GER            R
1d20: 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c  EFERENCES symbol
1d30: 2c 20 20 20 2d 2d 20 4c 69 6e 65 20 6f 66 20 64  ,   -- Line of d
1d40: 65 76 65 6c 6f 70 6d 65 6e 74 20 28 4e 55 4c 4c  evelopment (NULL
1d50: 20 3d 3e 20 54 72 75 6e 6b 29 0a 09 20 20 20 20   => Trunk)..    
1d60: 73 69 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e  sid   INTEGER  N
1d70: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
1d80: 43 45 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d  CES symbol,   --
1d90: 20 53 79 6d 62 6f 6c 20 63 61 70 74 75 72 69 6e   Symbol capturin
1da0: 67 20 74 68 65 20 62 72 61 6e 63 68 0a 0a 09 20  g the branch... 
1db0: 20 20 20 72 6f 6f 74 20 20 49 4e 54 45 47 45 52     root  INTEGER
1dc0: 20 20 20 20 20 20 20 20 20 20 20 20 52 45 46 45              REFE
1dd0: 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c  RENCES revision,
1de0: 20 2d 2d 20 52 65 76 69 73 69 6f 6e 20 74 68 65   -- Revision the
1df0: 20 62 72 61 6e 63 68 20 73 70 72 6f 75 74 73 20   branch sprouts 
1e00: 66 72 6f 6d 0a 09 20 20 20 20 66 69 72 73 74 20  from..    first 
1e10: 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 20  INTEGER         
1e20: 20 20 20 52 45 46 45 52 45 4e 43 45 53 20 72 65     REFERENCES re
1e30: 76 69 73 69 6f 6e 2c 20 2d 2d 20 46 69 72 73 74  vision, -- First
1e40: 20 72 65 76 69 73 69 6f 6e 20 63 6f 6d 6d 69 74   revision commit
1e50: 74 65 64 20 74 6f 20 74 68 65 20 62 72 61 6e 63  ted to the branc
1e60: 68 0a 09 20 20 20 20 62 72 61 20 20 20 54 45 58  h..    bra   TEX
1e70: 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20  T     NOT NULL, 
1e80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1e90: 20 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 20 6e       -- branch n
1ea0: 75 6d 62 65 72 0a 09 20 20 20 20 70 6f 73 20 20  umber..    pos  
1eb0: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1ec0: 4c 4c 20 20 20 20 20 20 20 20 20 20 20 20 20 20  LL              
1ed0: 20 20 20 20 20 20 20 20 20 2d 2d 20 63 72 65 61           -- crea
1ee0: 74 69 6f 6e 20 6f 72 64 65 72 20 69 6e 20 72 6f  tion order in ro
1ef0: 6f 74 2e 0a 0a 09 20 20 20 20 2d 2d 20 41 20 62  ot....    -- A b
1f00: 72 61 6e 63 68 20 63 61 6e 20 65 78 69 73 74 20  ranch can exist 
1f10: 77 69 74 68 6f 75 74 20 72 6f 6f 74 2e 20 49 74  without root. It
1f20: 20 68 61 70 70 65 6e 73 20 77 68 65 6e 20 74 68   happens when th
1f30: 65 0a 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d  e.            --
1f40: 20 6f 6e 6c 79 20 72 65 76 69 73 69 6f 6e 20 6f   only revision o
1f50: 6e 20 74 72 75 6e 6b 20 69 73 20 74 68 65 20 75  n trunk is the u
1f60: 6e 6e 65 63 65 73 73 61 72 79 20 64 65 61 64 20  nnecessary dead 
1f70: 6f 6e 65 20 74 68 65 0a 20 20 20 20 20 20 20 20  one the.        
1f80: 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 20 77 61      -- branch wa
1f90: 73 20 73 70 72 6f 75 74 65 64 20 66 72 6f 6d 20  s sprouted from 
1fa0: 61 6e 64 20 69 74 20 68 61 73 20 63 6f 6d 6d 69  and it has commi
1fb0: 74 73 2e 20 54 68 65 20 62 72 61 6e 63 68 0a 20  ts. The branch. 
1fc0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 77 69             -- wi
1fd0: 6c 6c 20 65 78 69 73 74 20 74 6f 20 62 65 20 74  ll exist to be t
1fe0: 68 65 20 4c 4f 44 20 6f 66 20 69 74 73 20 72 65  he LOD of its re
1ff0: 76 69 73 69 6f 6e 73 2c 20 6e 6f 74 68 69 6e 67  visions, nothing
2000: 20 74 6f 0a 20 20 20 20 20 20 20 20 20 20 20 20   to.            
2010: 2d 2d 20 73 70 72 6f 75 74 20 66 72 6f 6d 2c 20  -- sprout from, 
2020: 74 68 65 20 64 65 61 64 20 72 65 76 69 73 69 6f  the dead revisio
2030: 6e 20 77 61 73 20 72 65 6d 6f 76 65 64 2c 20 68  n was removed, h
2040: 65 6e 63 65 20 6e 6f 0a 20 20 20 20 20 20 20 20  ence no.        
2050: 20 20 20 20 2d 2d 20 72 6f 6f 74 2e 0a 09 7d 20      -- root...} 
2060: 7b 20 72 6f 6f 74 20 66 69 72 73 74 20 73 69 64  { root first sid
2070: 20 7d 0a 09 23 20 49 6e 64 69 63 65 73 20 6f 6e   }..# Indices on
2080: 3a 20 72 6f 6f 74 20 20 28 72 65 76 69 73 69 6f  : root  (revisio
2090: 6e 20 73 75 63 63 65 73 73 6f 72 73 29 0a 09 23  n successors)..#
20a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 66 69 72               fir
20b0: 73 74 20 28 72 65 76 69 73 69 6f 6e 20 70 72 65  st (revision pre
20c0: 64 65 63 65 73 73 6f 72 73 29 0a 09 23 20 20 20  decessors)..#   
20d0: 20 20 20 20 20 20 20 20 20 20 73 69 64 20 20 20            sid   
20e0: 28 74 61 67 20 70 72 65 64 65 63 65 73 73 6f 72  (tag predecessor
20f0: 73 2c 20 62 72 61 6e 63 68 20 73 75 63 63 65 73  s, branch succes
2100: 73 6f 72 73 2f 70 72 65 64 65 63 65 73 73 6f 72  sors/predecessor
2110: 73 29 0a 0a 09 23 20 50 72 6f 6a 65 63 74 20 6c  s)...# Project l
2120: 65 76 65 6c 20 2e 2e 2e 0a 09 23 09 70 4c 69 6e  evel .....#.pLin
2130: 65 4f 66 44 65 76 65 6c 6f 70 6d 65 6e 74 2c 20  eOfDevelopment, 
2140: 70 53 79 6d 62 6f 6c 2c 20 70 42 72 61 6e 63 68  pSymbol, pBranch
2150: 2c 20 70 54 61 67 2c 20 70 54 72 75 6e 6b 0a 09  , pTag, pTrunk..
2160: 23 0a 09 23 09 70 54 72 75 6e 6b 20 20 3c 2d 20  #..#.pTrunk  <- 
2170: 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d 65  pLineOfDevelopme
2180: 6e 74 0a 09 23 09 70 42 72 61 6e 63 68 20 3c 2d  nt..#.pBranch <-
2190: 20 70 53 79 6d 62 6f 6c 2c 20 70 4c 69 6e 65 4f   pSymbol, pLineO
21a0: 66 44 65 76 65 6c 6f 70 6d 65 6e 74 0a 09 23 09  fDevelopment..#.
21b0: 70 54 61 67 20 20 20 20 3c 2d 20 70 53 79 6d 62  pTag    <- pSymb
21c0: 6f 6c 2c 20 70 4c 69 6e 65 4f 66 44 65 76 65 6c  ol, pLineOfDevel
21d0: 6f 70 6d 65 6e 74 0a 0a 09 73 74 61 74 65 20 65  opment...state e
21e0: 78 74 65 6e 64 20 73 79 6d 62 6f 6c 20 7b 0a 09  xtend symbol {..
21f0: 20 20 20 20 73 69 64 20 20 49 4e 54 45 47 45 52      sid  INTEGER
2200: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d    NOT NULL  PRIM
2210: 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43 52  ARY KEY AUTOINCR
2220: 45 4d 45 4e 54 2c 0a 09 20 20 20 20 70 69 64 20  EMENT,..    pid 
2230: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
2240: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 70  LL  REFERENCES p
2250: 72 6f 6a 65 63 74 2c 20 20 2d 2d 20 50 72 6f 6a  roject,  -- Proj
2260: 65 63 74 20 74 68 65 20 73 79 6d 62 6f 6c 20 62  ect the symbol b
2270: 65 6c 6f 6e 67 73 20 74 6f 0a 09 20 20 20 20 6e  elongs to..    n
2280: 61 6d 65 20 54 45 58 54 20 20 20 20 20 4e 4f 54  ame TEXT     NOT
2290: 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 74 79 70 65   NULL,..    type
22a0: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
22b0: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73  LL  REFERENCES s
22c0: 79 6d 74 79 70 65 2c 20 20 2d 2d 20 65 6e 75 6d  ymtype,  -- enum
22d0: 20 7b 20 65 78 63 6c 75 64 65 64 20 3d 20 30 2c   { excluded = 0,
22e0: 20 74 61 67 2c 20 62 72 61 6e 63 68 2c 20 75 6e   tag, branch, un
22f0: 64 65 66 69 6e 65 64 20 7d 0a 0a 09 20 20 20 20  defined }...    
2300: 74 61 67 5f 63 6f 75 6e 74 20 20 20 20 49 4e 54  tag_count    INT
2310: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20  EGER  NOT NULL, 
2320: 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 74 68 65  -- How often the
2330: 20 73 79 6d 62 6f 6c 20 69 73 20 75 73 65 64 20   symbol is used 
2340: 61 73 20 74 61 67 2e 0a 09 20 20 20 20 62 72 61  as tag...    bra
2350: 6e 63 68 5f 63 6f 75 6e 74 20 49 4e 54 45 47 45  nch_count INTEGE
2360: 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 2d 2d 20  R  NOT NULL, -- 
2370: 48 6f 77 20 6f 66 74 65 6e 20 74 68 65 20 73 79  How often the sy
2380: 6d 62 6f 6c 20 69 73 20 75 73 65 64 20 61 73 20  mbol is used as 
2390: 62 72 61 6e 63 68 0a 09 20 20 20 20 63 6f 6d 6d  branch..    comm
23a0: 69 74 5f 63 6f 75 6e 74 20 49 4e 54 45 47 45 52  it_count INTEGER
23b0: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 2d 2d 20 48    NOT NULL, -- H
23c0: 6f 77 20 6f 66 74 65 6e 20 61 20 66 69 6c 65 20  ow often a file 
23d0: 77 61 73 20 63 6f 6d 6d 69 74 74 65 64 20 6f 6e  was committed on
23e0: 20 74 68 65 20 73 79 6d 62 6f 6c 0a 0a 09 20 20   the symbol...  
23f0: 20 20 55 4e 49 51 55 45 20 28 70 69 64 2c 20 6e    UNIQUE (pid, n
2400: 61 6d 65 29 20 2d 2d 20 53 79 6d 62 6f 6c 73 20  ame) -- Symbols 
2410: 61 72 65 20 75 6e 69 71 75 65 20 77 69 74 68 69  are unique withi
2420: 6e 20 74 68 65 20 70 72 6f 6a 65 63 74 0a 09 7d  n the project..}
2430: 0a 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64 20  ...state extend 
2440: 62 6c 6f 63 6b 65 72 20 7b 0a 09 20 20 20 20 2d  blocker {..    -
2450: 2d 20 46 6f 72 20 65 61 63 68 20 73 79 6d 62 6f  - For each symbo
2460: 6c 20 77 65 20 73 61 76 65 20 77 68 69 63 68 20  l we save which 
2470: 6f 74 68 65 72 20 73 79 6d 62 6f 6c 73 20 61 72  other symbols ar
2480: 65 0a 09 20 20 20 20 2d 2d 20 62 6c 6f 63 6b 69  e..    -- blocki
2490: 6e 67 20 69 74 73 20 72 65 6d 6f 76 61 6c 20 28  ng its removal (
24a0: 69 66 20 74 68 65 20 75 73 65 72 20 61 73 6b 73  if the user asks
24b0: 20 66 6f 72 20 69 74 29 2e 0a 0a 09 20 20 20 20   for it)....    
24c0: 73 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  sid INTEGER  NOT
24d0: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
24e0: 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 0a 09 20 20  S symbol, --..  
24f0: 20 20 62 69 64 20 49 4e 54 45 47 45 52 20 20 4e    bid INTEGER  N
2500: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
2510: 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20 53  CES symbol, -- S
2520: 70 72 6f 75 74 65 64 20 66 72 6f 6d 20 73 69 64  prouted from sid
2530: 2c 20 62 6c 6f 63 6b 73 20 69 74 2e 0a 09 20 20  , blocks it...  
2540: 20 20 55 4e 49 51 55 45 20 28 73 69 64 2c 20 62    UNIQUE (sid, b
2550: 69 64 29 0a 09 7d 0a 0a 09 73 74 61 74 65 20 65  id)..}...state e
2560: 78 74 65 6e 64 20 70 61 72 65 6e 74 20 7b 0a 09  xtend parent {..
2570: 20 20 20 20 2d 2d 20 46 6f 72 20 65 61 63 68 20      -- For each 
2580: 73 79 6d 62 6f 6c 20 77 65 20 73 61 76 65 20 77  symbol we save w
2590: 68 69 63 68 20 6f 74 68 65 72 20 73 79 6d 62 6f  hich other symbo
25a0: 6c 73 20 63 61 6e 20 61 63 74 20 61 73 0a 09 20  ls can act as.. 
25b0: 20 20 20 2d 2d 20 61 20 70 6f 73 73 69 62 6c 65     -- a possible
25c0: 20 70 61 72 65 6e 74 20 69 6e 20 73 6f 6d 65 20   parent in some 
25d0: 66 69 6c 65 2c 20 61 6e 64 20 68 6f 77 20 6f 66  file, and how of
25e0: 74 65 6e 2e 0a 0a 09 20 20 20 20 73 69 64 20 49  ten....    sid I
25f0: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
2600: 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d    REFERENCES sym
2610: 62 6f 6c 2c 20 2d 2d 0a 09 20 20 20 20 70 69 64  bol, --..    pid
2620: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
2630: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73  LL  REFERENCES s
2640: 79 6d 62 6f 6c 2c 20 2d 2d 20 50 6f 73 73 69 62  ymbol, -- Possib
2650: 6c 65 20 70 61 72 65 6e 74 20 6f 66 20 73 69 64  le parent of sid
2660: 0a 09 20 20 20 20 6e 20 20 20 49 4e 54 45 47 45  ..    n   INTEGE
2670: 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 20 20 20  R  NOT NULL,    
2680: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2690: 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 70 69 64  -- How often pid
26a0: 20 63 61 6e 20 61 63 74 20 61 73 20 70 61 72 65   can act as pare
26b0: 6e 74 2e 0a 09 20 20 20 20 55 4e 49 51 55 45 20  nt...    UNIQUE 
26c0: 28 73 69 64 2c 20 70 69 64 29 0a 09 7d 0a 0a 09  (sid, pid)..}...
26d0: 73 74 61 74 65 20 65 78 74 65 6e 64 20 73 79 6d  state extend sym
26e0: 74 79 70 65 20 7b 0a 09 20 20 20 20 74 69 64 20  type {..    tid 
26f0: 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20     INTEGER  NOT 
2700: 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b 45  NULL  PRIMARY KE
2710: 59 2c 0a 09 20 20 20 20 6e 61 6d 65 20 20 20 54  Y,..    name   T
2720: 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c  EXT     NOT NULL
2730: 2c 0a 09 20 20 20 20 70 6c 75 72 61 6c 20 54 45  ,..    plural TE
2740: 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c  XT     NOT NULL,
2750: 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 6e 61  ..    UNIQUE (na
2760: 6d 65 29 0a 09 20 20 20 20 55 4e 49 51 55 45 20  me)..    UNIQUE 
2770: 28 70 6c 75 72 61 6c 29 0a 09 7d 0a 09 73 74 61  (plural)..}..sta
2780: 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e  te run {..    IN
2790: 53 45 52 54 20 49 4e 54 4f 20 73 79 6d 74 79 70  SERT INTO symtyp
27a0: 65 20 56 41 4c 55 45 53 20 28 30 2c 27 65 78 63  e VALUES (0,'exc
27b0: 6c 75 64 65 64 27 2c 20 27 65 78 63 6c 75 64 65  luded', 'exclude
27c0: 64 27 29 3b 0a 09 20 20 20 20 49 4e 53 45 52 54  d');..    INSERT
27d0: 20 49 4e 54 4f 20 73 79 6d 74 79 70 65 20 56 41   INTO symtype VA
27e0: 4c 55 45 53 20 28 31 2c 27 74 61 67 27 2c 20 20  LUES (1,'tag',  
27f0: 20 20 20 20 27 74 61 67 73 27 29 3b 0a 09 20 20      'tags');..  
2800: 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 73 79    INSERT INTO sy
2810: 6d 74 79 70 65 20 56 41 4c 55 45 53 20 28 32 2c  mtype VALUES (2,
2820: 27 62 72 61 6e 63 68 27 2c 20 20 20 27 62 72 61  'branch',   'bra
2830: 6e 63 68 65 73 27 29 3b 0a 09 20 20 20 20 49 4e  nches');..    IN
2840: 53 45 52 54 20 49 4e 54 4f 20 73 79 6d 74 79 70  SERT INTO symtyp
2850: 65 20 56 41 4c 55 45 53 20 28 33 2c 27 75 6e 64  e VALUES (3,'und
2860: 65 66 69 6e 65 64 27 2c 27 75 6e 64 65 66 69 6e  efined','undefin
2870: 65 64 27 29 3b 0a 09 7d 0a 0a 09 73 74 61 74 65  ed');..}...state
2880: 20 65 78 74 65 6e 64 20 6d 65 74 61 20 7b 0a 09   extend meta {..
2890: 20 20 20 20 2d 2d 20 4d 65 74 61 20 64 61 74 61      -- Meta data
28a0: 20 6f 66 20 72 65 76 69 73 69 6f 6e 73 2e 20 53   of revisions. S
28b0: 65 65 20 72 65 76 69 73 69 6f 6e 2e 6d 69 64 20  ee revision.mid 
28c0: 66 6f 72 20 74 68 65 0a 09 20 20 20 20 2d 2d 20  for the..    -- 
28d0: 72 65 66 65 72 65 6e 63 65 2e 20 4d 61 6e 79 20  reference. Many 
28e0: 72 65 76 69 73 69 6f 6e 73 20 63 61 6e 20 73 68  revisions can sh
28f0: 61 72 65 20 6d 65 74 61 20 64 61 74 61 2e 20 54  are meta data. T
2900: 68 69 73 20 69 73 0a 09 20 20 20 20 2d 2d 20 61  his is..    -- a
2910: 63 74 75 61 6c 6c 79 20 6f 6e 65 20 6f 66 20 74  ctually one of t
2920: 68 65 20 63 72 69 74 65 72 69 6f 6e 73 20 75 73  he criterions us
2930: 65 64 20 74 6f 20 73 6f 72 74 20 72 65 76 69 73  ed to sort revis
2940: 69 6f 6e 73 0a 09 20 20 20 20 2d 2d 20 69 6e 74  ions..    -- int
2950: 6f 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09  o changesets....
2960: 20 20 20 20 6d 69 64 20 49 4e 54 45 47 45 52 20      mid INTEGER 
2970: 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41   NOT NULL  PRIMA
2980: 52 59 20 4b 45 59 20 20 41 55 54 4f 49 4e 43 52  RY KEY  AUTOINCR
2990: 45 4d 45 4e 54 2c 0a 0a 09 20 20 20 20 2d 2d 20  EMENT,...    -- 
29a0: 4d 65 74 61 20 64 61 74 61 20 62 65 6c 6f 6e 67  Meta data belong
29b0: 73 20 74 6f 20 61 20 73 70 65 63 69 66 69 63 20  s to a specific 
29c0: 70 72 6f 6a 65 63 74 2c 20 73 74 72 6f 6e 67 65  project, stronge
29d0: 72 2c 20 74 6f 20 61 0a 09 20 20 20 20 2d 2d 20  r, to a..    -- 
29e0: 62 72 61 6e 63 68 20 69 6e 20 74 68 61 74 20 70  branch in that p
29f0: 72 6f 6a 65 63 74 2e 20 49 74 20 66 75 72 74 68  roject. It furth
2a00: 65 72 20 68 61 73 20 61 20 6c 6f 67 20 6d 65 73  er has a log mes
2a10: 73 61 67 65 2c 0a 09 20 20 20 20 2d 2d 20 61 6e  sage,..    -- an
2a20: 64 20 69 74 73 20 61 75 74 68 6f 72 2e 20 54 68  d its author. Th
2a30: 69 73 20 69 73 20 75 6e 69 71 75 65 20 77 69 74  is is unique wit
2a40: 68 20 74 68 65 20 70 72 6f 6a 65 63 74 20 61 6e  h the project an
2a50: 64 0a 09 20 20 20 20 2d 2d 20 62 72 61 6e 63 68  d..    -- branch
2a60: 2e 0a 0a 09 20 20 20 20 70 69 64 20 49 4e 54 45  ....    pid INTE
2a70: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52  GER  NOT NULL  R
2a80: 45 46 45 52 45 4e 43 45 53 20 70 72 6f 6a 65 63  EFERENCES projec
2a90: 74 2c 20 20 2d 2d 0a 09 20 20 20 20 62 69 64 20  t,  --..    bid 
2aa0: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
2ab0: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79  L  REFERENCES sy
2ac0: 6d 62 6f 6c 2c 20 20 20 2d 2d 0a 09 20 20 20 20  mbol,   --..    
2ad0: 61 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  aid INTEGER  NOT
2ae0: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
2af0: 53 20 61 75 74 68 6f 72 2c 20 20 20 2d 2d 0a 09  S author,   --..
2b00: 20 20 20 20 63 69 64 20 49 4e 54 45 47 45 52 20      cid INTEGER 
2b10: 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52   NOT NULL  REFER
2b20: 45 4e 43 45 53 20 63 6d 65 73 73 61 67 65 2c 20  ENCES cmessage, 
2b30: 2d 2d 0a 0a 09 20 20 20 20 55 4e 49 51 55 45 20  --...    UNIQUE 
2b40: 28 70 69 64 2c 20 62 69 64 2c 20 61 69 64 2c 20  (pid, bid, aid, 
2b50: 63 69 64 29 0a 0a 09 20 20 20 20 2d 2d 20 43 6f  cid)...    -- Co
2b60: 6e 73 74 72 61 69 6e 74 73 3a 20 54 68 65 20 70  nstraints: The p
2b70: 72 6f 6a 65 63 74 20 6f 66 20 74 68 65 20 6d 65  roject of the me
2b80: 74 61 20 64 61 74 61 20 6f 66 20 61 20 72 65 76  ta data of a rev
2b90: 69 73 69 6f 6e 0a 09 20 20 20 20 2d 2d 20 20 20  ision..    --   
2ba0: 20 20 20 20 20 20 20 20 20 20 20 58 20 69 73 20             X is 
2bb0: 74 68 65 20 73 61 6d 65 20 61 73 20 74 68 65 20  the same as the 
2bc0: 70 72 6f 6a 65 63 74 20 6f 66 20 58 20 69 74 73  project of X its
2bd0: 65 6c 66 2e 0a 09 20 20 20 20 2d 2d 0a 09 20 20  elf...    --..  
2be0: 20 20 2d 2d 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e    -- ...........
2bf0: 2e 20 54 68 65 20 62 72 61 6e 63 68 20 6f 66 20  . The branch of 
2c00: 74 68 65 20 6d 65 74 61 20 64 61 74 61 20 6f 66  the meta data of
2c10: 20 61 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 20   a revision..   
2c20: 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20   --             
2c30: 20 58 20 69 73 20 74 68 65 20 73 61 6d 65 20 61   X is the same a
2c40: 73 20 74 68 65 20 6c 69 6e 65 20 6f 66 20 64 65  s the line of de
2c50: 76 65 6c 6f 70 6d 65 6e 74 0a 09 20 20 20 20 2d  velopment..    -
2c60: 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f  -              o
2c70: 66 20 58 20 69 74 73 65 6c 66 2e 0a 09 7d 0a 0a  f X itself...}..
2c80: 09 23 20 41 75 74 68 6f 72 73 20 61 6e 64 20 63  .# Authors and c
2c90: 6f 6d 6d 69 74 20 6d 65 73 73 61 67 65 73 20 61  ommit messages a
2ca0: 72 65 20 66 75 6c 6c 79 20 67 6c 6f 62 61 6c 2c  re fully global,
2cb0: 20 69 2e 65 2e 20 70 65 72 0a 09 23 20 72 65 70   i.e. per..# rep
2cc0: 6f 73 69 74 6f 72 79 2e 0a 0a 09 73 74 61 74 65  ository....state
2cd0: 20 65 78 74 65 6e 64 20 61 75 74 68 6f 72 20 7b   extend author {
2ce0: 0a 09 20 20 20 20 61 69 64 20 20 49 4e 54 45 47  ..    aid  INTEG
2cf0: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52  ER  NOT NULL  PR
2d00: 49 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f 49  IMARY KEY  AUTOI
2d10: 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 6e  NCREMENT,..    n
2d20: 61 6d 65 20 54 45 58 54 20 20 20 20 20 4e 4f 54  ame TEXT     NOT
2d30: 20 4e 55 4c 4c 20 20 55 4e 49 51 55 45 0a 09 7d   NULL  UNIQUE..}
2d40: 0a 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64 20  ...state extend 
2d50: 63 6d 65 73 73 61 67 65 20 7b 0a 09 20 20 20 20  cmessage {..    
2d60: 63 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  cid  INTEGER  NO
2d70: 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20  T NULL  PRIMARY 
2d80: 4b 45 59 20 20 41 55 54 4f 49 4e 43 52 45 4d 45  KEY  AUTOINCREME
2d90: 4e 54 2c 0a 09 20 20 20 20 74 65 78 74 20 54 45  NT,..    text TE
2da0: 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 20  XT     NOT NULL 
2db0: 20 55 4e 49 51 55 45 0a 09 7d 0a 0a 09 70 72 6f   UNIQUE..}...pro
2dc0: 6a 65 63 74 3a 3a 73 79 6d 20 67 65 74 73 79 6d  ject::sym getsym
2dd0: 74 79 70 65 73 0a 09 66 69 6c 65 3a 3a 72 65 76  types..file::rev
2de0: 20 20 20 20 67 65 74 6f 70 63 6f 64 65 73 0a 09      getopcodes..
2df0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
2e00: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61    typemethod loa
2e10: 64 20 7b 7d 20 7b 0a 09 73 74 61 74 65 20 75 73  d {} {..state us
2e20: 65 20 73 79 6d 62 6f 6c 0a 09 73 74 61 74 65 20  e symbol..state 
2e30: 75 73 65 20 73 79 6d 74 79 70 65 0a 09 73 74 61  use symtype..sta
2e40: 74 65 20 75 73 65 20 6f 70 74 79 70 65 0a 0a 09  te use optype...
2e50: 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 67 65 74  project::sym get
2e60: 73 79 6d 74 79 70 65 73 0a 09 66 69 6c 65 3a 3a  symtypes..file::
2e70: 72 65 76 20 20 20 20 67 65 74 6f 70 63 6f 64 65  rev    getopcode
2e80: 73 0a 09 72 65 70 6f 73 69 74 6f 72 79 20 20 20  s..repository   
2e90: 6c 6f 61 64 73 79 6d 62 6f 6c 73 0a 09 72 65 74  loadsymbols..ret
2ea0: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74  urn.    }..    t
2eb0: 79 70 65 6d 65 74 68 6f 64 20 72 75 6e 20 7b 7d  ypemethod run {}
2ec0: 20 7b 0a 09 23 20 50 61 73 73 20 6d 61 6e 61 67   {..# Pass manag
2ed0: 65 72 20 69 6e 74 65 72 66 61 63 65 2e 20 45 78  er interface. Ex
2ee0: 65 63 75 74 65 64 20 74 6f 20 70 65 72 66 6f 72  ecuted to perfor
2ef0: 6d 20 74 68 65 0a 09 23 20 66 75 6e 63 74 69 6f  m the..# functio
2f00: 6e 61 6c 69 74 79 20 6f 66 20 74 68 65 20 70 61  nality of the pa
2f10: 73 73 2e 0a 0a 09 73 65 74 20 72 62 61 73 65 20  ss....set rbase 
2f20: 5b 72 65 70 6f 73 69 74 6f 72 79 20 62 61 73 65  [repository base
2f30: 3f 5d 0a 09 66 6f 72 65 61 63 68 20 70 72 6f 6a  ?]..foreach proj
2f40: 65 63 74 20 5b 72 65 70 6f 73 69 74 6f 72 79 20  ect [repository 
2f50: 70 72 6f 6a 65 63 74 73 5d 20 7b 0a 09 20 20 20  projects] {..   
2f60: 20 73 65 74 20 62 61 73 65 20 5b 66 69 6c 65 20   set base [file 
2f70: 6a 6f 69 6e 20 24 72 62 61 73 65 20 5b 24 70 72  join $rbase [$pr
2f80: 6f 6a 65 63 74 20 62 61 73 65 5d 5d 0a 09 20 20  oject base]]..  
2f90: 20 20 6c 6f 67 20 77 72 69 74 65 20 31 20 63 6f    log write 1 co
2fa0: 6c 6c 72 65 76 20 22 50 72 6f 63 65 73 73 69 6e  llrev "Processin
2fb0: 67 20 24 62 61 73 65 22 0a 0a 09 20 20 20 20 66  g $base"...    f
2fc0: 6f 72 65 61 63 68 20 66 69 6c 65 20 5b 24 70 72  oreach file [$pr
2fd0: 6f 6a 65 63 74 20 66 69 6c 65 73 5d 20 7b 0a 09  oject files] {..
2fe0: 09 73 65 74 20 70 61 74 68 20 5b 24 66 69 6c 65  .set path [$file
2ff0: 20 70 61 74 68 5d 0a 09 09 6c 6f 67 20 77 72 69   path]...log wri
3000: 74 65 20 32 20 63 6f 6c 6c 72 65 76 20 22 50 61  te 2 collrev "Pa
3010: 72 73 69 6e 67 20 24 70 61 74 68 22 0a 09 09 69  rsing $path"...i
3020: 66 20 7b 5b 63 61 74 63 68 20 7b 0a 09 09 20 20  f {[catch {...  
3030: 20 20 70 61 72 73 65 72 20 70 72 6f 63 65 73 73    parser process
3040: 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 24 62 61 73   [file join $bas
3050: 65 20 24 70 61 74 68 5d 20 24 66 69 6c 65 0a 09  e $path] $file..
3060: 09 7d 20 6d 73 67 5d 7d 20 7b 0a 09 09 20 20 20  .} msg]} {...   
3070: 20 67 6c 6f 62 61 6c 20 65 72 72 6f 72 43 6f 64   global errorCod
3080: 65 0a 09 09 20 20 20 20 69 66 20 7b 24 65 72 72  e...    if {$err
3090: 6f 72 43 6f 64 65 20 65 71 20 22 76 63 3a 3a 72  orCode eq "vc::r
30a0: 63 73 3a 3a 70 61 72 73 65 72 22 7d 20 7b 0a 09  cs::parser"} {..
30b0: 09 09 74 72 6f 75 62 6c 65 20 66 61 74 61 6c 20  ..trouble fatal 
30c0: 22 24 70 61 74 68 20 69 73 20 6e 6f 74 20 61 20  "$path is not a 
30d0: 76 61 6c 69 64 20 52 43 53 20 61 72 63 68 69 76  valid RCS archiv
30e0: 65 20 28 24 6d 73 67 29 22 0a 09 09 20 20 20 20  e ($msg)"...    
30f0: 7d 20 65 6c 73 65 20 7b 0a 09 09 09 67 6c 6f 62  } else {....glob
3100: 61 6c 20 65 72 72 6f 72 49 6e 66 6f 0a 09 09 09  al errorInfo....
3110: 74 72 6f 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c  trouble internal
3120: 20 24 65 72 72 6f 72 49 6e 66 6f 0a 09 09 20 20   $errorInfo...  
3130: 20 20 7d 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09    }...} else {..
3140: 09 20 20 20 20 23 20 57 65 20 70 65 72 73 69 73  .    # We persis
3150: 74 20 74 68 65 20 63 6f 72 65 20 6f 66 20 74 68  t the core of th
3160: 65 20 64 61 74 61 20 63 6f 6c 6c 65 63 74 65 64  e data collected
3170: 20 61 62 6f 75 74 0a 09 09 20 20 20 20 23 20 65   about...    # e
3180: 61 63 68 20 66 69 6c 65 20 69 6d 6d 65 64 69 61  ach file immedia
3190: 74 65 6c 79 20 61 66 74 65 72 20 69 74 20 68 61  tely after it ha
31a0: 73 20 62 65 65 6e 20 70 61 72 73 65 64 0a 09 09  s been parsed...
31b0: 20 20 20 20 23 20 61 6e 64 20 77 72 61 6e 67 6c      # and wrangl
31c0: 65 64 20 69 6e 74 6f 20 73 68 61 70 65 2c 20 61  ed into shape, a
31d0: 6e 64 20 74 68 65 6e 20 64 72 6f 70 20 69 74 20  nd then drop it 
31e0: 66 72 6f 6d 0a 09 09 20 20 20 20 23 20 6d 65 6d  from...    # mem
31f0: 6f 72 79 2e 20 54 68 69 73 20 69 73 20 64 6f 6e  ory. This is don
3200: 65 20 74 6f 20 6b 65 65 70 20 74 68 65 20 61 6d  e to keep the am
3210: 6f 75 6e 74 20 6f 66 0a 09 09 20 20 20 20 23 20  ount of...    # 
3220: 72 65 71 75 69 72 65 64 20 6d 65 6d 6f 72 79 20  required memory 
3230: 77 69 74 68 69 6e 20 73 65 6e 73 69 62 6c 65 20  within sensible 
3240: 6c 69 6d 69 74 73 2e 20 57 69 74 68 6f 75 74 0a  limits. Without.
3250: 09 09 20 20 20 20 23 20 64 6f 69 6e 67 20 69 74  ..    # doing it
3260: 20 74 68 69 73 20 77 61 79 20 77 65 20 77 6f 75   this way we wou
3270: 6c 64 20 65 61 73 69 6c 79 20 67 6f 62 62 6c 65  ld easily gobble
3280: 20 75 70 20 31 47 0a 09 09 20 20 20 20 23 20 6f   up 1G...    # o
3290: 66 20 52 41 4d 20 6f 72 20 6d 6f 72 65 20 77 69  f RAM or more wi
32a0: 74 68 20 61 6c 6c 20 74 68 65 20 6f 62 6a 65 63  th all the objec
32b0: 74 73 20 28 72 65 76 69 73 69 6f 6e 73 0a 09 09  ts (revisions...
32c0: 20 20 20 20 23 20 61 6e 64 20 66 69 6c 65 2d 6c      # and file-l
32d0: 65 76 65 6c 20 73 79 6d 62 6f 6c 73 29 2e 0a 0a  evel symbols)...
32e0: 09 09 20 20 20 20 24 66 69 6c 65 20 70 65 72 73  ..    $file pers
32f0: 69 73 74 0a 09 09 7d 0a 0a 09 09 24 66 69 6c 65  ist...}....$file
3300: 20 64 72 6f 70 0a 09 20 20 20 20 7d 0a 0a 09 20   drop..    }... 
3310: 20 20 20 24 70 72 6f 6a 65 63 74 20 70 75 72 67     $project purg
3320: 65 67 68 6f 73 74 73 79 6d 62 6f 6c 73 0a 09 7d  eghostsymbols..}
3330: 0a 0a 09 72 65 70 6f 73 69 74 6f 72 79 20 70 65  ...repository pe
3340: 72 73 69 73 74 72 65 76 0a 09 72 65 70 6f 73 69  rsistrev..reposi
3350: 74 6f 72 79 20 70 72 69 6e 74 72 65 76 73 74 61  tory printrevsta
3360: 74 69 73 74 69 63 73 0a 09 69 6e 74 65 67 72 69  tistics..integri
3370: 74 79 20 20 73 74 72 69 63 74 0a 0a 09 6c 6f 67  ty  strict...log
3380: 20 77 72 69 74 65 20 31 20 63 6f 6c 6c 72 65 76   write 1 collrev
3390: 20 22 53 63 61 6e 20 63 6f 6d 70 6c 65 74 65 64   "Scan completed
33a0: 22 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  "..return.    }.
33b0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
33c0: 64 69 73 63 61 72 64 20 7b 7d 20 7b 0a 09 23 20  discard {} {..# 
33d0: 50 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e 74  Pass manager int
33e0: 65 72 66 61 63 65 2e 20 45 78 65 63 75 74 65 64  erface. Executed
33f0: 20 66 6f 72 20 61 6c 6c 20 70 61 73 73 65 73 20   for all passes 
3400: 61 66 74 65 72 20 74 68 65 0a 09 23 20 72 75 6e  after the..# run
3410: 20 70 61 73 73 65 73 2c 20 74 6f 20 72 65 6d 6f   passes, to remo
3420: 76 65 20 61 6c 6c 20 64 61 74 61 20 6f 66 20 74  ve all data of t
3430: 68 69 73 20 70 61 73 73 20 66 72 6f 6d 20 74 68  his pass from th
3440: 65 20 73 74 61 74 65 2c 0a 09 23 20 61 73 20 62  e state,..# as b
3450: 65 69 6e 67 20 6f 75 74 20 6f 66 20 64 61 74 65  eing out of date
3460: 2e 0a 0a 09 73 74 61 74 65 20 64 69 73 63 61 72  ....state discar
3470: 64 20 72 65 76 69 73 69 6f 6e 0a 09 73 74 61 74  d revision..stat
3480: 65 20 64 69 73 63 61 72 64 20 74 61 67 0a 09 73  e discard tag..s
3490: 74 61 74 65 20 64 69 73 63 61 72 64 20 62 72 61  tate discard bra
34a0: 6e 63 68 0a 09 73 74 61 74 65 20 64 69 73 63 61  nch..state disca
34b0: 72 64 20 73 79 6d 62 6f 6c 0a 09 73 74 61 74 65  rd symbol..state
34c0: 20 64 69 73 63 61 72 64 20 62 6c 6f 63 6b 65 72   discard blocker
34d0: 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20  ..state discard 
34e0: 70 61 72 65 6e 74 0a 09 73 74 61 74 65 20 64 69  parent..state di
34f0: 73 63 61 72 64 20 73 79 6d 74 79 70 65 0a 09 73  scard symtype..s
3500: 74 61 74 65 20 64 69 73 63 61 72 64 20 6d 65 74  tate discard met
3510: 61 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64  a..state discard
3520: 20 61 75 74 68 6f 72 0a 09 73 74 61 74 65 20 64   author..state d
3530: 69 73 63 61 72 64 20 63 6d 65 73 73 61 67 65 0a  iscard cmessage.
3540: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
3550: 20 20 20 70 72 6f 63 20 50 61 72 61 6e 6f 69 61     proc Paranoia
3560: 20 7b 7d 20 7b 0a 09 23 20 54 68 69 73 20 63 6f   {} {..# This co
3570: 64 65 20 70 65 72 66 6f 72 6d 73 20 61 20 6e 75  de performs a nu
3580: 6d 62 65 72 20 6f 66 20 70 61 72 61 6e 6f 69 64  mber of paranoid
3590: 20 63 68 65 63 6b 73 20 6f 66 20 74 68 65 0a 09   checks of the..
35a0: 23 20 64 61 74 61 62 61 73 65 2c 20 73 65 61 72  # database, sear
35b0: 63 68 69 6e 67 20 66 6f 72 20 69 6e 63 6f 6e 73  ching for incons
35c0: 69 73 74 65 6e 74 20 63 72 6f 73 73 2d 72 65 66  istent cross-ref
35d0: 65 72 65 6e 63 65 73 2e 0a 09 6c 6f 67 20 77 72  erences...log wr
35e0: 69 74 65 20 34 20 63 6f 6c 6c 72 65 76 20 7b 43  ite 4 collrev {C
35f0: 68 65 63 6b 20 64 61 74 61 62 61 73 65 20 63 6f  heck database co
3600: 6e 73 69 73 74 65 6e 63 79 7d 0a 0a 09 73 65 74  nsistency}...set
3610: 20 6e 20 30 20 3b 20 23 20 43 6f 75 6e 74 65 72   n 0 ; # Counter
3620: 20 66 6f 72 20 74 68 65 20 63 68 65 63 6b 73 20   for the checks 
3630: 28 77 65 20 70 72 69 6e 74 20 61 6e 20 69 64 20  (we print an id 
3640: 62 65 66 6f 72 65 20 74 68 65 0a 09 09 20 20 23  before the...  #
3650: 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a 0a 09   main label)....
3660: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
3670: 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73 61 67  ions which disag
3680: 72 65 65 20 77 69 74 68 20 74 68 65 69 72 20 6c  ree with their l
3690: 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c 6f  ine of..# develo
36a0: 70 6d 65 6e 74 20 61 62 6f 75 74 20 74 68 65 20  pment about the 
36b0: 70 72 6f 6a 65 63 74 20 74 68 65 79 20 61 72 65  project they are
36c0: 20 6f 77 6e 65 64 20 62 79 2e 0a 09 43 68 65 63   owned by...Chec
36d0: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
36e0: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 4c 4f  ons and their LO
36f0: 44 73 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e  Ds have to be in
3700: 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a 65 63   the same projec
3710: 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67  t} \..    {disag
3720: 72 65 65 73 20 77 69 74 68 20 69 74 73 20 4c 4f  rees with its LO
3730: 44 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67 20 70  D about owning p
3740: 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 53 45 4c 45  roject} {...SELE
3750: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
3760: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
3770: 20 52 2c 20 66 69 6c 65 20 46 2c 20 73 79 6d 62   R, file F, symb
3780: 6f 6c 20 53 0a 09 09 57 48 45 52 45 20 52 2e 66  ol S...WHERE R.f
3790: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
37a0: 20 20 20 52 2e 6c 6f 64 20 3d 20 53 2e 73 69 64     R.lod = S.sid
37b0: 0a 09 09 41 4e 44 20 20 20 46 2e 70 69 64 20 21  ...AND   F.pid !
37c0: 3d 20 53 2e 70 69 64 0a 09 09 3b 0a 09 20 20 20  = S.pid...;..   
37d0: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72   }..# Find all r
37e0: 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 64  evisions which d
37f0: 69 73 67 72 65 65 20 77 69 74 68 20 74 68 65 69  isgree with thei
3800: 72 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f 75  r meta data abou
3810: 74 0a 09 23 20 74 68 65 20 70 72 6f 6a 65 63 74  t..# the project
3820: 20 74 68 65 79 20 61 72 65 20 6f 77 6e 65 64 20   they are owned 
3830: 62 79 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20  by...Check \..  
3840: 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64    {Revisions and
3850: 20 74 68 65 69 72 20 6d 65 74 61 20 64 61 74 61   their meta data
3860: 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74   have to be in t
3870: 68 65 20 73 61 6d 65 20 70 72 6f 6a 65 63 74 7d  he same project}
3880: 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65   \..    {disagre
3890: 65 73 20 77 69 74 68 20 69 74 73 20 6d 65 74 61  es with its meta
38a0: 20 64 61 74 61 20 61 62 6f 75 74 20 6f 77 6e 69   data about owni
38b0: 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b 0a 09 09  ng project} {...
38c0: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52  SELECT F.name, R
38d0: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69  .rev...FROM revi
38e0: 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20  sion R, file F, 
38f0: 6d 65 74 61 20 4d 0a 09 09 57 48 45 52 45 20 52  meta M...WHERE R
3900: 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41  .fid = F.fid...A
3910: 4e 44 20 20 20 52 2e 6d 69 64 20 3d 20 4d 2e 6d  ND   R.mid = M.m
3920: 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70 69 64  id...AND   F.pid
3930: 20 21 3d 20 4d 2e 70 69 64 0a 09 09 3b 0a 09 20   != M.pid...;.. 
3940: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
3950: 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68   revisions which
3960: 20 64 69 73 67 72 65 65 20 77 69 74 68 20 74 68   disgree with th
3970: 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 61 62  eir meta data ab
3980: 6f 75 74 0a 09 23 20 74 68 65 20 62 72 61 6e 63  out..# the branc
3990: 68 2f 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f  h/line of develo
39a0: 70 6d 65 6e 74 20 74 68 65 79 20 62 65 6c 6f 6e  pment they belon
39b0: 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  g to...Check \..
39c0: 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61      {Revisions a
39d0: 6e 64 20 74 68 65 69 72 20 6d 65 74 61 20 64 61  nd their meta da
39e0: 74 61 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e  ta have to be in
39f0: 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 7d 20 5c   the same LOD} \
3a00: 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65 65 73  ..    {disagrees
3a10: 20 77 69 74 68 20 69 74 73 20 6d 65 74 61 20 64   with its meta d
3a20: 61 74 61 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67  ata about owning
3a30: 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54   LOD} {...SELECT
3a40: 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09   F.name, R.rev..
3a50: 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52  .FROM revision R
3a60: 2c 20 6d 65 74 61 20 4d 2c 20 66 69 6c 65 20 46  , meta M, file F
3a70: 0a 09 09 57 48 45 52 45 20 52 2e 6d 69 64 20 3d  ...WHERE R.mid =
3a80: 20 4d 2e 6d 69 64 0a 09 09 41 4e 44 20 20 20 52   M.mid...AND   R
3a90: 2e 6c 6f 64 20 21 3d 20 4d 2e 62 69 64 0a 09 09  .lod != M.bid...
3aa0: 41 4e 44 20 20 20 52 2e 66 69 64 20 3d 20 46 2e  AND   R.fid = F.
3ab0: 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  fid...;..    }..
3ac0: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
3ad0: 69 6f 6e 73 20 77 69 74 68 20 61 20 70 72 69 6d  ions with a prim
3ae0: 61 72 79 20 63 68 69 6c 64 20 77 68 69 63 68 20  ary child which 
3af0: 64 69 73 61 67 72 65 65 73 0a 09 23 20 61 62 6f  disagrees..# abo
3b00: 75 74 20 74 68 65 20 66 69 6c 65 20 74 68 65 79  ut the file they
3b10: 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65   belong to...Che
3b20: 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73  ck \..    {Revis
3b30: 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 70  ions and their p
3b40: 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20  rimary children 
3b50: 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68  have to be in th
3b60: 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a 09  e same file} \..
3b70: 20 20 20 20 7b 64 69 73 61 67 72 65 65 73 20 77      {disagrees w
3b80: 69 74 68 20 69 74 73 20 70 72 69 6d 61 72 79 20  ith its primary 
3b90: 63 68 69 6c 64 20 61 62 6f 75 74 20 74 68 65 20  child about the 
3ba0: 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09  owning file} {..
3bb0: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20  .SELECT F.name, 
3bc0: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76  R.rev...FROM rev
3bd0: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
3be0: 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n C, file F...WH
3bf0: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
3c00: 64 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c  d...AND   R.chil
3c10: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  d IS NOT NULL...
3c20: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 3d 20  AND   R.child = 
3c30: 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e  C.rid...AND   C.
3c40: 66 69 64 20 21 3d 20 52 2e 66 69 64 0a 09 09 3b  fid != R.fid...;
3c50: 0a 09 20 20 20 20 7d 0a 0a 09 23 20 46 69 6e 64  ..    }...# Find
3c60: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
3c70: 69 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72  ith a branch par
3c80: 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f 73 65  ent symbol whose
3c90: 20 70 61 72 65 6e 74 0a 09 23 20 64 69 73 61 67   parent..# disag
3ca0: 72 65 65 73 20 61 62 6f 75 74 20 74 68 65 20 66  rees about the f
3cb0: 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e 67 20  ile they belong 
3cc0: 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20  to...Check \..  
3cd0: 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64    {Revisions and
3ce0: 20 74 68 65 69 72 20 62 72 61 6e 63 68 20 63 68   their branch ch
3cf0: 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62  ildren have to b
3d00: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 66 69  e in the same fi
3d10: 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74  le} \..    {at t
3d20: 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20  he beginning of 
3d30: 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64 20 69  its branch and i
3d40: 74 73 20 70 61 72 65 6e 74 20 64 69 73 61 67 72  ts parent disagr
3d50: 65 65 20 61 62 6f 75 74 20 74 68 65 20 6f 77 6e  ee about the own
3d60: 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09 53 45  ing file} {...SE
3d70: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
3d80: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69  ev...FROM revisi
3d90: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 50  on R, revision P
3da0: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45  , file F...WHERE
3db0: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09   R.fid = F.fid..
3dc0: 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e 74  .AND   R.bparent
3dd0: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41   IS NOT NULL...A
3de0: 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20  ND   R.parent = 
3df0: 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 52 2e  P.rid...AND   R.
3e00: 66 69 64 20 21 3d 20 50 2e 66 69 64 0a 09 09 3b  fid != P.fid...;
3e10: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
3e20: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
3e30: 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68  th a non-NTDB ch
3e40: 69 6c 64 20 77 68 69 63 68 20 64 69 73 61 67 72  ild which disagr
3e50: 65 65 73 0a 09 23 20 61 62 6f 75 74 20 74 68 65  ees..# about the
3e60: 20 66 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e   file they belon
3e70: 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  g to...Check \..
3e80: 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61      {Revisions a
3e90: 6e 64 20 74 68 65 69 72 20 6e 6f 6e 2d 4e 54 44  nd their non-NTD
3ea0: 42 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20  B children have 
3eb0: 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d  to be in the sam
3ec0: 65 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b  e file} \..    {
3ed0: 64 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69  disagrees with i
3ee0: 74 73 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c  ts non-NTDB chil
3ef0: 64 20 61 62 6f 75 74 20 74 68 65 20 6f 77 6e 69  d about the owni
3f00: 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09 53 45 4c  ng file} {...SEL
3f10: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
3f20: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f  v...FROM revisio
3f30: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c  n R, revision C,
3f40: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
3f50: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
3f60: 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20  AND   R.dbchild 
3f70: 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e  IS NOT NULL...AN
3f80: 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20 3d 20  D   R.dbchild = 
3f90: 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e  C.rid...AND   C.
3fa0: 66 69 64 20 21 3d 20 52 2e 66 69 64 0a 09 09 3b  fid != R.fid...;
3fb0: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
3fc0: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68  all revisions wh
3fd0: 69 63 68 20 68 61 76 65 20 61 20 70 72 69 6d 61  ich have a prima
3fe0: 72 79 20 63 68 69 6c 64 2c 20 62 75 74 20 74 68  ry child, but th
3ff0: 65 20 63 68 69 6c 64 0a 09 23 20 64 6f 65 73 20  e child..# does 
4000: 6e 6f 74 20 68 61 76 65 20 74 68 65 6d 20 61 73  not have them as
4010: 20 70 61 72 65 6e 74 2e 0a 09 43 68 65 63 6b 20   parent...Check 
4020: 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e  \..    {Revision
4030: 73 20 68 61 76 65 20 74 6f 20 62 65 20 70 61 72  s have to be par
4040: 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20 70 72  ents of their pr
4050: 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 7d 20  imary children} 
4060: 5c 0a 09 20 20 20 20 7b 69 73 20 6e 6f 74 20 74  \..    {is not t
4070: 68 65 20 70 61 72 65 6e 74 20 6f 66 20 69 74 73  he parent of its
4080: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 7d 20   primary child} 
4090: 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d  {...SELECT F.nam
40a0: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20  e, R.rev...FROM 
40b0: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69  revision R, revi
40c0: 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09  sion C, file F..
40d0: 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46  .WHERE R.fid = F
40e0: 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 63  .fid...AND   R.c
40f0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
4100: 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64  ...AND   R.child
4110: 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20 20   = C.rid...AND  
4120: 20 43 2e 70 61 72 65 6e 74 20 21 3d 20 52 2e 72   C.parent != R.r
4130: 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23  id...;..    }..#
4140: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69   Find all revisi
4150: 6f 6e 73 20 77 68 69 63 68 20 68 61 76 65 20 61  ons which have a
4160: 20 70 72 69 6d 72 61 72 79 20 63 68 69 6c 64 2c   primrary child,
4170: 20 62 75 74 20 74 68 65 0a 09 23 20 63 68 69 6c   but the..# chil
4180: 64 20 68 61 73 20 61 20 62 72 61 6e 63 68 20 70  d has a branch p
4190: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 6d 61 6b  arent symbol mak
41a0: 69 6e 67 20 74 68 65 6d 20 62 72 61 63 68 20 73  ing them brach s
41b0: 74 61 72 74 65 72 73 2e 0a 09 43 68 65 63 6b 20  tarters...Check 
41c0: 5c 0a 09 20 20 20 20 7b 50 72 69 6d 61 72 79 20  \..    {Primary 
41d0: 63 68 69 6c 64 72 65 6e 20 6f 66 20 72 65 76 69  children of revi
41e0: 73 69 6f 6e 73 20 6d 75 73 74 20 6e 6f 74 20 73  sions must not s
41f0: 74 61 72 74 20 62 72 61 6e 63 68 65 73 7d 20 5c  tart branches} \
4200: 0a 09 20 20 20 20 7b 69 73 20 70 61 72 65 6e 74  ..    {is parent
4210: 20 6f 66 20 61 20 70 72 69 6d 61 72 79 20 63 68   of a primary ch
4220: 69 6c 64 20 77 68 69 63 68 20 69 73 20 74 68 65  ild which is the
4230: 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 61 20   beginning of a 
4240: 62 72 61 6e 63 68 7d 20 7b 0a 09 09 53 45 4c 45  branch} {...SELE
4250: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
4260: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
4270: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20   R, revision C, 
4280: 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52  file F...WHERE R
4290: 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41  .fid = F.fid...A
42a0: 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20  ND   R.child IS 
42b0: 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20  NOT NULL...AND  
42c0: 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64   R.child = C.rid
42d0: 0a 09 09 41 4e 44 20 20 20 43 2e 62 70 61 72 65  ...AND   C.bpare
42e0: 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09  nt IS NOT NULL..
42f0: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
4300: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
4310: 77 69 74 68 6f 75 74 20 62 72 61 6e 63 68 20 70  without branch p
4320: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 69  arent symbol whi
4330: 63 68 20 68 61 76 65 20 61 0a 09 23 20 70 61 72  ch have a..# par
4340: 65 6e 74 2c 20 62 75 74 20 74 68 65 20 70 61 72  ent, but the par
4350: 65 6e 74 20 64 6f 65 73 20 6e 6f 74 20 68 61 76  ent does not hav
4360: 65 20 74 68 65 6d 20 61 73 20 70 72 69 6d 61 72  e them as primar
4370: 79 20 63 68 69 6c 64 2e 0a 09 43 68 65 63 6b 20  y child...Check 
4380: 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e  \..    {Revision
4390: 73 20 68 61 76 65 20 74 6f 20 62 65 20 70 72 69  s have to be pri
43a0: 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20 6f 66  mary children of
43b0: 20 74 68 65 69 72 20 70 61 72 65 6e 74 73 2c 20   their parents, 
43c0: 69 66 20 61 6e 79 7d 20 5c 0a 09 20 20 20 20 7b  if any} \..    {
43d0: 69 73 20 6e 6f 74 20 74 68 65 20 63 68 69 6c 64  is not the child
43e0: 20 6f 66 20 69 74 73 20 70 61 72 65 6e 74 7d 20   of its parent} 
43f0: 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d  {...SELECT F.nam
4400: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20  e, R.rev...FROM 
4410: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69  revision R, revi
4420: 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09  sion P, file F..
4430: 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46  .WHERE R.fid = F
4440: 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62  .fid...AND   R.b
4450: 70 61 72 65 6e 74 20 49 53 20 4e 55 4c 4c 0a 09  parent IS NULL..
4460: 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20  .AND   R.parent 
4470: 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e  IS NOT NULL...AN
4480: 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50  D   R.parent = P
4490: 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 50 2e 63  .rid...AND   P.c
44a0: 68 69 6c 64 20 21 3d 20 52 2e 72 69 64 0a 09 09  hild != R.rid...
44b0: 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64  ;..    }..# Find
44c0: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
44d0: 69 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72  ith a branch par
44e0: 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 69 63 68  ent symbol which
44f0: 20 64 6f 20 6e 6f 74 0a 09 23 20 68 61 76 65 20   do not..# have 
4500: 61 20 70 61 72 65 6e 74 2e 0a 09 43 68 65 63 6b  a parent...Check
4510: 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63 68 20   \..    {Branch 
4520: 73 74 61 72 74 69 6e 67 20 72 65 76 69 73 69 6f  starting revisio
4530: 6e 73 20 68 61 76 65 20 74 6f 20 68 61 76 65 20  ns have to have 
4540: 61 20 70 61 72 65 6e 74 7d 20 5c 0a 09 20 20 20  a parent} \..   
4550: 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69   {at the beginni
4560: 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68  ng of its branch
4570: 20 68 61 73 20 6e 6f 20 70 61 72 65 6e 74 7d 20   has no parent} 
4580: 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d  {...SELECT F.nam
4590: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20  e, R.rev...FROM 
45a0: 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65  revision R, file
45b0: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   F...WHERE R.fid
45c0: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
45d0: 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f   R.bparent IS NO
45e0: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
45f0: 2e 70 61 72 65 6e 74 20 49 53 20 4e 55 4c 4c 0a  .parent IS NULL.
4600: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69  ..;..    }..# Fi
4610: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
4620: 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 20 70   with a branch p
4630: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f  arent symbol who
4640: 73 65 20 70 61 72 65 6e 74 0a 09 23 20 68 61 73  se parent..# has
4650: 20 74 68 65 6d 20 61 73 20 70 72 69 6d 61 72 79   them as primary
4660: 20 63 68 69 6c 64 2e 0a 09 43 68 65 63 6b 20 5c   child...Check \
4670: 0a 09 20 20 20 20 7b 42 72 61 6e 63 68 20 73 74  ..    {Branch st
4680: 61 72 74 69 6e 67 20 72 65 76 69 73 69 6f 6e 73  arting revisions
4690: 20 6d 75 73 74 20 6e 6f 74 20 62 65 20 70 72 69   must not be pri
46a0: 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20 6f 66  mary children of
46b0: 20 74 68 65 69 72 20 70 61 72 65 6e 74 73 7d 20   their parents} 
46c0: 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65 20 62  \..    {at the b
46d0: 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20  eginning of its 
46e0: 62 72 61 6e 63 68 20 69 73 20 74 68 65 20 70 72  branch is the pr
46f0: 69 6d 61 72 79 20 63 68 69 6c 64 20 6f 66 20 69  imary child of i
4700: 74 73 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53  ts parent} {...S
4710: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
4720: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
4730: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
4740: 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  P, file F...WHER
4750: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
4760: 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e  ..AND   R.bparen
4770: 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  t IS NOT NULL...
4780: 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 49  AND   R.parent I
4790: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44  S NOT NULL...AND
47a0: 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e     R.parent = P.
47b0: 72 69 64 0a 09 09 41 4e 44 20 20 20 50 2e 63 68  rid...AND   P.ch
47c0: 69 6c 64 20 3d 20 52 2e 72 69 64 0a 09 09 3b 0a  ild = R.rid...;.
47d0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
47e0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74  ll revisions wit
47f0: 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69  h a non-NTDB chi
4800: 6c 64 20 77 68 69 63 68 20 61 72 65 20 6e 6f 74  ld which are not
4810: 20 6f 6e 0a 09 23 20 74 68 65 20 4e 54 44 42 2e   on..# the NTDB.
4820: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b  ..Check \..    {
4830: 4e 54 44 42 20 74 6f 20 74 72 75 6e 6b 20 74 72  NTDB to trunk tr
4840: 61 6e 73 69 74 69 6f 6e 20 68 61 73 20 74 6f 20  ansition has to 
4850: 62 65 67 69 6e 20 6f 6e 20 4e 54 44 42 7d 20 5c  begin on NTDB} \
4860: 0a 09 20 20 20 20 7b 68 61 73 20 61 20 6e 6f 6e  ..    {has a non
4870: 2d 4e 54 44 42 20 63 68 69 6c 64 2c 20 79 65 74  -NTDB child, yet
4880: 20 69 73 20 6e 6f 74 20 6f 6e 20 74 68 65 20 4e   is not on the N
4890: 54 44 42 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20  TDB} {...SELECT 
48a0: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
48b0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
48c0: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
48d0: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
48e0: 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20  AND   R.dbchild 
48f0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e  IS NOT NULL...AN
4900: 44 20 20 20 4e 4f 54 20 52 2e 69 73 64 65 66 61  D   NOT R.isdefa
4910: 75 6c 74 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  ult...;..    }..
4920: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
4930: 69 6f 6e 73 20 77 69 74 68 20 61 20 4e 54 44 42  ions with a NTDB
4940: 20 70 61 72 65 6e 74 20 77 68 69 63 68 20 61 72   parent which ar
4950: 65 20 6f 6e 20 74 68 65 20 4e 54 44 42 2e 0a 09  e on the NTDB...
4960: 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 4e 54  Check \..    {NT
4970: 44 42 20 74 6f 20 74 72 75 6e 6b 20 74 72 61 6e  DB to trunk tran
4980: 73 69 74 69 6f 6e 20 68 61 73 20 74 6f 20 65 6e  sition has to en
4990: 64 20 6f 6e 20 6e 6f 6e 2d 4e 54 44 42 7d 20 5c  d on non-NTDB} \
49a0: 0a 09 20 20 20 20 7b 68 61 73 20 61 20 4e 54 44  ..    {has a NTD
49b0: 42 20 70 61 72 65 6e 74 2c 20 79 65 74 20 69 73  B parent, yet is
49c0: 20 6f 6e 20 74 68 65 20 4e 54 44 42 7d 20 7b 0a   on the NTDB} {.
49d0: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
49e0: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
49f0: 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46  vision R, file F
4a00: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
4a10: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
4a20: 2e 64 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54  .dbparent IS NOT
4a30: 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e   NULL...AND   R.
4a40: 69 73 64 65 66 61 75 6c 74 0a 09 09 3b 0a 09 20  isdefault...;.. 
4a50: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
4a60: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
4a70: 61 20 63 68 69 6c 64 20 77 68 69 63 68 20 64 69  a child which di
4a80: 73 61 67 72 65 65 73 20 61 62 6f 75 74 20 74 68  sagrees about th
4a90: 65 0a 09 23 20 6c 69 6e 65 20 6f 66 20 64 65 76  e..# line of dev
4aa0: 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20 62 65  elopment they be
4ab0: 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20  long to...Check 
4ac0: 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e  \..    {Revision
4ad0: 73 20 61 6e 64 20 74 68 65 69 72 20 70 72 69 6d  s and their prim
4ae0: 61 72 79 20 63 68 69 6c 64 72 65 6e 20 68 61 76  ary children hav
4af0: 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73  e to be in the s
4b00: 61 6d 65 20 4c 4f 44 7d 20 5c 0a 09 20 20 20 20  ame LOD} \..    
4b10: 7b 61 6e 64 20 69 74 73 20 70 72 69 6d 61 72 79  {and its primary
4b20: 20 63 68 69 6c 64 20 64 69 73 61 67 72 65 65 20   child disagree 
4b30: 61 62 6f 75 74 20 74 68 65 69 72 20 4c 4f 44 7d  about their LOD}
4b40: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
4b50: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
4b60: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76   revision R, rev
4b70: 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a  ision C, file F.
4b80: 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20  ..WHERE R.fid = 
4b90: 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e  F.fid...AND   R.
4ba0: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
4bb0: 4c 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c  L...AND   R.chil
4bc0: 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20  d = C.rid...AND 
4bd0: 20 20 43 2e 6c 6f 64 20 21 3d 20 52 2e 6c 6f 64    C.lod != R.lod
4be0: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46  ...;..    }..# F
4bf0: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  ind all revision
4c00: 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44  s with a non-NTD
4c10: 42 20 63 68 69 6c 64 20 77 68 69 63 68 20 61 67  B child which ag
4c20: 72 65 65 73 20 61 62 6f 75 74 0a 09 23 20 74 68  rees about..# th
4c30: 65 20 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f  e line of develo
4c40: 70 6d 65 6e 74 20 74 68 65 79 20 62 65 6c 6f 6e  pment they belon
4c50: 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  g to...Check \..
4c60: 20 20 20 20 7b 4e 54 44 42 20 61 6e 64 20 74 72      {NTDB and tr
4c70: 75 6e 6b 20 72 65 76 69 73 69 6f 6e 73 20 68 61  unk revisions ha
4c80: 76 65 20 74 6f 20 62 65 20 69 6e 20 64 69 66 66  ve to be in diff
4c90: 65 72 65 6e 74 20 4c 4f 44 73 7d 20 5c 0a 09 20  erent LODs} \.. 
4ca0: 20 20 20 7b 6f 6e 20 4e 54 44 42 20 61 6e 64 20     {on NTDB and 
4cb0: 69 74 73 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69  its non-NTDB chi
4cc0: 6c 64 20 77 72 6f 6e 67 6c 79 20 61 67 72 65 65  ld wrongly agree
4cd0: 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c 4f 44   about their LOD
4ce0: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
4cf0: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
4d00: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65  M revision R, re
4d10: 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46  vision C, file F
4d20: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
4d30: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
4d40: 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20  .dbchild IS NOT 
4d50: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 64  NULL...AND   R.d
4d60: 62 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09  bchild = C.rid..
4d70: 09 41 4e 44 20 20 20 43 2e 6c 6f 64 20 3d 20 52  .AND   C.lod = R
4d80: 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  .lod...;..    }.
4d90: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
4da0: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62 72 61  sions with a bra
4db0: 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f  nch parent symbo
4dc0: 6c 20 77 68 69 63 68 20 69 73 20 6e 6f 74 0a 09  l which is not..
4dd0: 23 20 74 68 65 69 72 20 4c 4f 44 2e 0a 09 43 68  # their LOD...Ch
4de0: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e  eck \..    {Bran
4df0: 63 68 20 73 74 61 72 74 69 6e 67 20 72 65 76 69  ch starting revi
4e00: 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 68 61  sions have to ha
4e10: 76 65 20 74 68 65 69 72 20 4c 4f 44 20 61 73 20  ve their LOD as 
4e20: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79  branch parent sy
4e30: 6d 62 6f 6c 7d 20 5c 0a 09 20 20 20 20 7b 61 74  mbol} \..    {at
4e40: 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f   the beginning o
4e50: 66 20 69 74 73 20 62 72 61 6e 63 68 20 64 6f 65  f its branch doe
4e60: 73 20 6e 6f 74 20 68 61 76 65 20 74 68 65 20 62  s not have the b
4e70: 72 61 6e 63 68 20 73 79 6d 62 6f 6c 20 61 73 20  ranch symbol as 
4e80: 69 74 73 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c  its LOD} {...SEL
4e90: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
4ea0: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f  v...FROM revisio
4eb0: 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n R, file F...WH
4ec0: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
4ed0: 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72  d...AND   R.bpar
4ee0: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a  ent IS NOT NULL.
4ef0: 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20 21 3d  ..AND   R.lod !=
4f00: 20 52 2e 62 70 61 72 65 6e 74 0a 09 09 3b 0a 09   R.bparent...;..
4f10: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
4f20: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68  l revisions with
4f30: 20 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74   a branch parent
4f40: 20 73 79 6d 62 6f 6c 20 77 68 6f 73 65 20 70 61   symbol whose pa
4f50: 72 65 6e 74 0a 09 23 20 69 73 20 69 6e 20 74 68  rent..# is in th
4f60: 65 20 73 61 6d 65 20 6c 69 6e 65 20 6f 66 20 64  e same line of d
4f70: 65 76 65 6c 6f 70 6d 65 6e 74 2e 0a 09 43 68 65  evelopment...Che
4f80: 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73  ck \..    {Revis
4f90: 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 62  ions and their b
4fa0: 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 20 68  ranch children h
4fb0: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 64 69 66  ave to be in dif
4fc0: 66 65 72 65 6e 74 20 4c 4f 44 73 7d 20 5c 0a 09  ferent LODs} \..
4fd0: 20 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69      {at the begi
4fe0: 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61  nning of its bra
4ff0: 6e 63 68 20 61 6e 64 20 69 74 73 20 70 61 72 65  nch and its pare
5000: 6e 74 20 77 72 6f 6e 67 6c 79 20 61 67 72 65 65  nt wrongly agree
5010: 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c 4f 44   about their LOD
5020: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
5030: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
5040: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65  M revision R, re
5050: 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46  vision P, file F
5060: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
5070: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
5080: 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20  .bparent IS NOT 
5090: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70  NULL...AND   R.p
50a0: 61 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a 09 09  arent = P.rid...
50b0: 41 4e 44 20 20 20 52 2e 6c 6f 64 20 3d 20 50 2e  AND   R.lod = P.
50c0: 6c 6f 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  lod...;..    }..
50d0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
50e0: 20 20 70 72 6f 63 20 43 68 65 63 6b 20 7b 68 65    proc Check {he
50f0: 61 64 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20  ader label sql} 
5100: 7b 0a 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09  {..upvar 1 n n..
5110: 73 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63  set ok 1..foreac
5120: 68 20 7b 66 6e 61 6d 65 20 72 65 76 6e 72 7d 20  h {fname revnr} 
5130: 5b 73 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d  [state run $sql]
5140: 20 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30   {..    set ok 0
5150: 0a 09 20 20 20 20 74 72 6f 75 62 6c 65 20 66 61  ..    trouble fa
5160: 74 61 6c 20 22 24 66 6e 61 6d 65 20 3c 24 72 65  tal "$fname <$re
5170: 76 6e 72 3e 20 24 6c 61 62 65 6c 22 0a 09 7d 0a  vnr> $label"..}.
5180: 09 6c 6f 67 20 77 72 69 74 65 20 35 20 63 6f 6c  .log write 5 col
5190: 6c 72 65 76 20 22 5c 5b 5b 66 6f 72 6d 61 74 20  lrev "\[[format 
51a0: 25 30 32 64 20 5b 69 6e 63 72 20 6e 5d 5d 5c 5d  %02d [incr n]]\]
51b0: 20 5b 65 78 70 72 20 7b 24 6f 6b 20 3f 20 22 4f   [expr {$ok ? "O
51c0: 6b 20 20 20 20 22 20 3a 20 22 46 61 69 6c 65 64  k    " : "Failed
51d0: 22 7d 5d 20 2e 2e 2e 20 24 68 65 61 64 65 72 22  "}] ... $header"
51e0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
51f0: 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23      # # ## ### #
5200: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
5210: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20  ###########.    
5220: 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68  ## Internal meth
5230: 6f 64 73 0a 0a 20 20 20 20 23 20 23 20 23 23 20  ods..    # # ## 
5240: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
5250: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
5260: 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72  .    ## Configur
5270: 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d  ation..    pragm
5280: 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 65 73 20  a -hasinstances 
5290: 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74    no ; # singlet
52a0: 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68  on.    pragma -h
52b0: 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f  astypeinfo    no
52c0: 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65   ; # no introspe
52d0: 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61  ction.    pragma
52e0: 20 2d 68 61 73 74 79 70 65 64 65 73 74 72 6f 79   -hastypedestroy
52f0: 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c   no ; # immortal
5300: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
5310: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
5320: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 7d 0a  #############.}.
5330: 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
5340: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
5350: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20  port::cvs::pass 
5360: 7b 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20  {.    namespace 
5370: 65 78 70 6f 72 74 20 63 6f 6c 6c 72 65 76 0a 20  export collrev. 
5380: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61     namespace eva
5390: 6c 20 63 6f 6c 6c 72 65 76 20 7b 0a 09 6e 61 6d  l collrev {..nam
53a0: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
53b0: 76 63 3a 3a 72 63 73 3a 3a 70 61 72 73 65 72 0a  vc::rcs::parser.
53c0: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
53d0: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
53e0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70  import::cvs::rep
53f0: 6f 73 69 74 6f 72 79 0a 09 6e 61 6d 65 73 70 61  ository..namespa
5400: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
5410: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
5420: 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65  cvs::state..name
5430: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
5440: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
5450: 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74  t::cvs::integrit
5460: 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61  y..namespace eva
5470: 6c 20 70 72 6f 6a 65 63 74 20 7b 0a 09 20 20 20  l project {..   
5480: 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72   namespace impor
5490: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
54a0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f  import::cvs::pro
54b0: 6a 65 63 74 3a 3a 73 79 6d 0a 09 7d 0a 09 6e 61  ject::sym..}..na
54c0: 6d 65 73 70 61 63 65 20 65 76 61 6c 20 66 69 6c  mespace eval fil
54d0: 65 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70 61  e {..    namespa
54e0: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
54f0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
5500: 63 76 73 3a 3a 66 69 6c 65 3a 3a 72 65 76 0a 09  cvs::file::rev..
5510: 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70  }..namespace imp
5520: 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a  ort ::vc::tools:
5530: 3a 74 72 6f 75 62 6c 65 0a 09 6e 61 6d 65 73 70  :trouble..namesp
5540: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
5550: 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67  :tools::log..log
5560: 20 72 65 67 69 73 74 65 72 20 63 6f 6c 6c 72 65   register collre
5570: 76 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23  v.    }.}..# # #
5580: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
5590: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
55a0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
55b0: 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 61 64  ########.## Read
55c0: 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 69  y..package provi
55d0: 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69  de vc::fossil::i
55e0: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73  mport::cvs::pass
55f0: 3a 3a 63 6f 6c 6c 72 65 76 20 31 2e 30 0a 72 65  ::collrev 1.0.re
5600: 74 75 72 6e 0a                                   turn.