Hex Artifact Content
Not logged in

Artifact 8de6139917a2fb718bf461b8bff79aae51beab4c:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [6809145eb1] - More comments on sql statements. by aku on 2008-01-19 06:07:49.

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 20 20 2d 2d 20 54 68 65 20 69 64 73  d');  -- The ids
27d0: 20 61 72 65 20 74 68 65 20 66 69 78 65 64 0a 09   are the fixed..
27e0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
27f0: 73 79 6d 74 79 70 65 20 56 41 4c 55 45 53 20 28  symtype VALUES (
2800: 31 2c 27 74 61 67 27 2c 20 20 20 20 20 20 27 74  1,'tag',      't
2810: 61 67 73 27 29 3b 20 20 20 20 20 20 2d 2d 20 70  ags');      -- p
2820: 69 65 63 65 73 2c 20 73 65 65 20 70 72 6f 6a 65  ieces, see proje
2830: 63 74 3a 3a 73 79 6d 2c 0a 09 20 20 20 20 49 4e  ct::sym,..    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 32 2c 27 62 72 61  e VALUES (2,'bra
2860: 6e 63 68 27 2c 20 20 20 27 62 72 61 6e 63 68 65  nch',   'branche
2870: 73 27 29 3b 20 20 2d 2d 20 67 65 74 73 79 6d 74  s');  -- getsymt
2880: 79 70 65 73 20 61 6e 64 20 61 73 73 6f 63 69 61  ypes and associa
2890: 74 65 64 0a 09 20 20 20 20 49 4e 53 45 52 54 20  ted..    INSERT 
28a0: 49 4e 54 4f 20 73 79 6d 74 79 70 65 20 56 41 4c  INTO symtype VAL
28b0: 55 45 53 20 28 33 2c 27 75 6e 64 65 66 69 6e 65  UES (3,'undefine
28c0: 64 27 2c 27 75 6e 64 65 66 69 6e 65 64 27 29 3b  d','undefined');
28d0: 20 2d 2d 20 74 79 70 65 76 61 72 69 61 62 6c 65   -- typevariable
28e0: 73 2e 0a 09 7d 0a 0a 09 73 74 61 74 65 20 65 78  s...}...state ex
28f0: 74 65 6e 64 20 6d 65 74 61 20 7b 0a 09 20 20 20  tend meta {..   
2900: 20 2d 2d 20 4d 65 74 61 20 64 61 74 61 20 6f 66   -- Meta data of
2910: 20 72 65 76 69 73 69 6f 6e 73 2e 20 53 65 65 20   revisions. See 
2920: 72 65 76 69 73 69 6f 6e 2e 6d 69 64 20 66 6f 72  revision.mid for
2930: 20 74 68 65 0a 09 20 20 20 20 2d 2d 20 72 65 66   the..    -- ref
2940: 65 72 65 6e 63 65 2e 20 4d 61 6e 79 20 72 65 76  erence. Many rev
2950: 69 73 69 6f 6e 73 20 63 61 6e 20 73 68 61 72 65  isions can share
2960: 20 6d 65 74 61 20 64 61 74 61 2e 20 54 68 69 73   meta data. This
2970: 20 69 73 0a 09 20 20 20 20 2d 2d 20 61 63 74 75   is..    -- actu
2980: 61 6c 6c 79 20 6f 6e 65 20 6f 66 20 74 68 65 20  ally one of the 
2990: 63 72 69 74 65 72 69 6f 6e 73 20 75 73 65 64 20  criterions used 
29a0: 74 6f 20 73 6f 72 74 20 72 65 76 69 73 69 6f 6e  to sort revision
29b0: 73 0a 09 20 20 20 20 2d 2d 20 69 6e 74 6f 20 63  s..    -- into c
29c0: 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09 20 20 20  hangesets....   
29d0: 20 6d 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f   mid INTEGER  NO
29e0: 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20  T NULL  PRIMARY 
29f0: 4b 45 59 20 20 41 55 54 4f 49 4e 43 52 45 4d 45  KEY  AUTOINCREME
2a00: 4e 54 2c 0a 0a 09 20 20 20 20 2d 2d 20 4d 65 74  NT,...    -- Met
2a10: 61 20 64 61 74 61 20 62 65 6c 6f 6e 67 73 20 74  a data belongs t
2a20: 6f 20 61 20 73 70 65 63 69 66 69 63 20 70 72 6f  o a specific pro
2a30: 6a 65 63 74 2c 20 73 74 72 6f 6e 67 65 72 2c 20  ject, stronger, 
2a40: 74 6f 20 61 0a 09 20 20 20 20 2d 2d 20 62 72 61  to a..    -- bra
2a50: 6e 63 68 20 69 6e 20 74 68 61 74 20 70 72 6f 6a  nch in that proj
2a60: 65 63 74 2e 20 49 74 20 66 75 72 74 68 65 72 20  ect. It further 
2a70: 68 61 73 20 61 20 6c 6f 67 20 6d 65 73 73 61 67  has a log messag
2a80: 65 2c 0a 09 20 20 20 20 2d 2d 20 61 6e 64 20 69  e,..    -- and i
2a90: 74 73 20 61 75 74 68 6f 72 2e 20 54 68 69 73 20  ts author. This 
2aa0: 69 73 20 75 6e 69 71 75 65 20 77 69 74 68 20 74  is unique with t
2ab0: 68 65 20 70 72 6f 6a 65 63 74 20 61 6e 64 0a 09  he project and..
2ac0: 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 2e 0a 0a      -- branch...
2ad0: 09 20 20 20 20 70 69 64 20 49 4e 54 45 47 45 52  .    pid INTEGER
2ae0: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
2af0: 52 45 4e 43 45 53 20 70 72 6f 6a 65 63 74 2c 20  RENCES project, 
2b00: 20 2d 2d 0a 09 20 20 20 20 62 69 64 20 49 4e 54   --..    bid INT
2b10: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
2b20: 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f  REFERENCES symbo
2b30: 6c 2c 20 20 20 2d 2d 0a 09 20 20 20 20 61 69 64  l,   --..    aid
2b40: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
2b50: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 61  LL  REFERENCES a
2b60: 75 74 68 6f 72 2c 20 20 20 2d 2d 0a 09 20 20 20  uthor,   --..   
2b70: 20 63 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f   cid INTEGER  NO
2b80: 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43  T NULL  REFERENC
2b90: 45 53 20 63 6d 65 73 73 61 67 65 2c 20 2d 2d 0a  ES cmessage, --.
2ba0: 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 70 69  ..    UNIQUE (pi
2bb0: 64 2c 20 62 69 64 2c 20 61 69 64 2c 20 63 69 64  d, bid, aid, cid
2bc0: 29 0a 0a 09 20 20 20 20 2d 2d 20 43 6f 6e 73 74  )...    -- Const
2bd0: 72 61 69 6e 74 73 3a 20 54 68 65 20 70 72 6f 6a  raints: The proj
2be0: 65 63 74 20 6f 66 20 74 68 65 20 6d 65 74 61 20  ect of the meta 
2bf0: 64 61 74 61 20 6f 66 20 61 20 72 65 76 69 73 69  data of a revisi
2c00: 6f 6e 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20  on..    --      
2c10: 20 20 20 20 20 20 20 20 58 20 69 73 20 74 68 65          X is the
2c20: 20 73 61 6d 65 20 61 73 20 74 68 65 20 70 72 6f   same as the pro
2c30: 6a 65 63 74 20 6f 66 20 58 20 69 74 73 65 6c 66  ject of X itself
2c40: 2e 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 20 2d  ...    --..    -
2c50: 2d 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 20 54  - ............ T
2c60: 68 65 20 62 72 61 6e 63 68 20 6f 66 20 74 68 65  he branch of the
2c70: 20 6d 65 74 61 20 64 61 74 61 20 6f 66 20 61 20   meta data of a 
2c80: 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 2d 2d  revision..    --
2c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 58 20                X 
2ca0: 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 20 74  is the same as t
2cb0: 68 65 20 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c  he line of devel
2cc0: 6f 70 6d 65 6e 74 0a 09 20 20 20 20 2d 2d 20 20  opment..    --  
2cd0: 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 20 58              of X
2ce0: 20 69 74 73 65 6c 66 2e 0a 09 7d 0a 0a 09 23 20   itself...}...# 
2cf0: 41 75 74 68 6f 72 73 20 61 6e 64 20 63 6f 6d 6d  Authors and comm
2d00: 69 74 20 6d 65 73 73 61 67 65 73 20 61 72 65 20  it messages are 
2d10: 66 75 6c 6c 79 20 67 6c 6f 62 61 6c 2c 20 69 2e  fully global, i.
2d20: 65 2e 20 70 65 72 0a 09 23 20 72 65 70 6f 73 69  e. per..# reposi
2d30: 74 6f 72 79 2e 0a 0a 09 73 74 61 74 65 20 65 78  tory....state ex
2d40: 74 65 6e 64 20 61 75 74 68 6f 72 20 7b 0a 09 20  tend author {.. 
2d50: 20 20 20 61 69 64 20 20 49 4e 54 45 47 45 52 20     aid  INTEGER 
2d60: 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41   NOT NULL  PRIMA
2d70: 52 59 20 4b 45 59 20 20 41 55 54 4f 49 4e 43 52  RY KEY  AUTOINCR
2d80: 45 4d 45 4e 54 2c 20 2d 2d 20 50 6f 6f 6c 20 6f  EMENT, -- Pool o
2d90: 66 20 74 68 65 20 75 6e 69 71 75 65 0a 09 20 20  f the unique..  
2da0: 20 20 6e 61 6d 65 20 54 45 58 54 20 20 20 20 20    name TEXT     
2db0: 4e 4f 54 20 4e 55 4c 4c 20 20 55 4e 49 51 55 45  NOT NULL  UNIQUE
2dc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2dd0: 20 20 20 20 20 20 2d 2d 20 61 75 74 68 6f 72 20        -- author 
2de0: 6e 61 6d 65 73 2e 0a 09 7d 0a 0a 09 73 74 61 74  names...}...stat
2df0: 65 20 65 78 74 65 6e 64 20 63 6d 65 73 73 61 67  e extend cmessag
2e00: 65 20 7b 0a 09 20 20 20 20 63 69 64 20 20 49 4e  e {..    cid  IN
2e10: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
2e20: 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20 41 55   PRIMARY KEY  AU
2e30: 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 20 2d 2d 20  TOINCREMENT, -- 
2e40: 50 6f 6f 6c 20 6f 66 20 74 68 65 20 75 6e 69 71  Pool of the uniq
2e50: 75 65 0a 09 20 20 20 20 74 65 78 74 20 54 45 58  ue..    text TEX
2e60: 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  T     NOT NULL  
2e70: 55 4e 49 51 55 45 20 20 20 20 20 20 20 20 20 20  UNIQUE          
2e80: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 6c              -- l
2e90: 6f 67 20 6d 65 73 73 61 67 65 73 0a 09 7d 0a 0a  og messages..}..
2ea0: 09 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 67 65  .project::sym ge
2eb0: 74 73 79 6d 74 79 70 65 73 0a 09 66 69 6c 65 3a  tsymtypes..file:
2ec0: 3a 72 65 76 20 20 20 20 67 65 74 6f 70 63 6f 64  :rev    getopcod
2ed0: 65 73 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  es..return.    }
2ee0: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
2ef0: 20 6c 6f 61 64 20 7b 7d 20 7b 0a 09 73 74 61 74   load {} {..stat
2f00: 65 20 75 73 65 20 73 79 6d 62 6f 6c 0a 09 73 74  e use symbol..st
2f10: 61 74 65 20 75 73 65 20 73 79 6d 74 79 70 65 0a  ate use symtype.
2f20: 09 73 74 61 74 65 20 75 73 65 20 6f 70 74 79 70  .state use optyp
2f30: 65 0a 0a 09 70 72 6f 6a 65 63 74 3a 3a 73 79 6d  e...project::sym
2f40: 20 67 65 74 73 79 6d 74 79 70 65 73 0a 09 66 69   getsymtypes..fi
2f50: 6c 65 3a 3a 72 65 76 20 20 20 20 67 65 74 6f 70  le::rev    getop
2f60: 63 6f 64 65 73 0a 09 72 65 70 6f 73 69 74 6f 72  codes..repositor
2f70: 79 20 20 20 6c 6f 61 64 73 79 6d 62 6f 6c 73 0a  y   loadsymbols.
2f80: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
2f90: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 72 75     typemethod ru
2fa0: 6e 20 7b 7d 20 7b 0a 09 23 20 50 61 73 73 20 6d  n {} {..# Pass m
2fb0: 61 6e 61 67 65 72 20 69 6e 74 65 72 66 61 63 65  anager interface
2fc0: 2e 20 45 78 65 63 75 74 65 64 20 74 6f 20 70 65  . Executed to pe
2fd0: 72 66 6f 72 6d 20 74 68 65 0a 09 23 20 66 75 6e  rform the..# fun
2fe0: 63 74 69 6f 6e 61 6c 69 74 79 20 6f 66 20 74 68  ctionality of th
2ff0: 65 20 70 61 73 73 2e 0a 0a 09 73 65 74 20 72 62  e pass....set rb
3000: 61 73 65 20 5b 72 65 70 6f 73 69 74 6f 72 79 20  ase [repository 
3010: 62 61 73 65 3f 5d 0a 09 66 6f 72 65 61 63 68 20  base?]..foreach 
3020: 70 72 6f 6a 65 63 74 20 5b 72 65 70 6f 73 69 74  project [reposit
3030: 6f 72 79 20 70 72 6f 6a 65 63 74 73 5d 20 7b 0a  ory projects] {.
3040: 09 20 20 20 20 73 65 74 20 62 61 73 65 20 5b 66  .    set base [f
3050: 69 6c 65 20 6a 6f 69 6e 20 24 72 62 61 73 65 20  ile join $rbase 
3060: 5b 24 70 72 6f 6a 65 63 74 20 62 61 73 65 5d 5d  [$project base]]
3070: 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20  ..    log write 
3080: 31 20 63 6f 6c 6c 72 65 76 20 22 50 72 6f 63 65  1 collrev "Proce
3090: 73 73 69 6e 67 20 24 62 61 73 65 22 0a 0a 09 20  ssing $base"... 
30a0: 20 20 20 66 6f 72 65 61 63 68 20 66 69 6c 65 20     foreach file 
30b0: 5b 24 70 72 6f 6a 65 63 74 20 66 69 6c 65 73 5d  [$project files]
30c0: 20 7b 0a 09 09 73 65 74 20 70 61 74 68 20 5b 24   {...set path [$
30d0: 66 69 6c 65 20 70 61 74 68 5d 0a 09 09 6c 6f 67  file path]...log
30e0: 20 77 72 69 74 65 20 32 20 63 6f 6c 6c 72 65 76   write 2 collrev
30f0: 20 22 50 61 72 73 69 6e 67 20 24 70 61 74 68 22   "Parsing $path"
3100: 0a 09 09 69 66 20 7b 5b 63 61 74 63 68 20 7b 0a  ...if {[catch {.
3110: 09 09 20 20 20 20 70 61 72 73 65 72 20 70 72 6f  ..    parser pro
3120: 63 65 73 73 20 5b 66 69 6c 65 20 6a 6f 69 6e 20  cess [file join 
3130: 24 62 61 73 65 20 24 70 61 74 68 5d 20 24 66 69  $base $path] $fi
3140: 6c 65 0a 09 09 7d 20 6d 73 67 5d 7d 20 7b 0a 09  le...} msg]} {..
3150: 09 20 20 20 20 67 6c 6f 62 61 6c 20 65 72 72 6f  .    global erro
3160: 72 43 6f 64 65 0a 09 09 20 20 20 20 69 66 20 7b  rCode...    if {
3170: 24 65 72 72 6f 72 43 6f 64 65 20 65 71 20 22 76  $errorCode eq "v
3180: 63 3a 3a 72 63 73 3a 3a 70 61 72 73 65 72 22 7d  c::rcs::parser"}
3190: 20 7b 0a 09 09 09 74 72 6f 75 62 6c 65 20 66 61   {....trouble fa
31a0: 74 61 6c 20 22 24 70 61 74 68 20 69 73 20 6e 6f  tal "$path is no
31b0: 74 20 61 20 76 61 6c 69 64 20 52 43 53 20 61 72  t a valid RCS ar
31c0: 63 68 69 76 65 20 28 24 6d 73 67 29 22 0a 09 09  chive ($msg)"...
31d0: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 09 09 09      } else {....
31e0: 67 6c 6f 62 61 6c 20 65 72 72 6f 72 49 6e 66 6f  global errorInfo
31f0: 0a 09 09 09 74 72 6f 75 62 6c 65 20 69 6e 74 65  ....trouble inte
3200: 72 6e 61 6c 20 24 65 72 72 6f 72 49 6e 66 6f 0a  rnal $errorInfo.
3210: 09 09 20 20 20 20 7d 0a 09 09 7d 20 65 6c 73 65  ..    }...} else
3220: 20 7b 0a 09 09 20 20 20 20 23 20 57 65 20 70 65   {...    # We pe
3230: 72 73 69 73 74 20 74 68 65 20 63 6f 72 65 20 6f  rsist the core o
3240: 66 20 74 68 65 20 64 61 74 61 20 63 6f 6c 6c 65  f the data colle
3250: 63 74 65 64 20 61 62 6f 75 74 0a 09 09 20 20 20  cted about...   
3260: 20 23 20 65 61 63 68 20 66 69 6c 65 20 69 6d 6d   # each file imm
3270: 65 64 69 61 74 65 6c 79 20 61 66 74 65 72 20 69  ediately after i
3280: 74 20 68 61 73 20 62 65 65 6e 20 70 61 72 73 65  t has been parse
3290: 64 0a 09 09 20 20 20 20 23 20 61 6e 64 20 77 72  d...    # and wr
32a0: 61 6e 67 6c 65 64 20 69 6e 74 6f 20 73 68 61 70  angled into shap
32b0: 65 2c 20 61 6e 64 20 74 68 65 6e 20 64 72 6f 70  e, and then drop
32c0: 20 69 74 20 66 72 6f 6d 0a 09 09 20 20 20 20 23   it from...    #
32d0: 20 6d 65 6d 6f 72 79 2e 20 54 68 69 73 20 69 73   memory. This is
32e0: 20 64 6f 6e 65 20 74 6f 20 6b 65 65 70 20 74 68   done to keep th
32f0: 65 20 61 6d 6f 75 6e 74 20 6f 66 0a 09 09 20 20  e amount of...  
3300: 20 20 23 20 72 65 71 75 69 72 65 64 20 6d 65 6d    # required mem
3310: 6f 72 79 20 77 69 74 68 69 6e 20 73 65 6e 73 69  ory within sensi
3320: 62 6c 65 20 6c 69 6d 69 74 73 2e 20 57 69 74 68  ble limits. With
3330: 6f 75 74 0a 09 09 20 20 20 20 23 20 64 6f 69 6e  out...    # doin
3340: 67 20 69 74 20 74 68 69 73 20 77 61 79 20 77 65  g it this way we
3350: 20 77 6f 75 6c 64 20 65 61 73 69 6c 79 20 67 6f   would easily go
3360: 62 62 6c 65 20 75 70 20 31 47 0a 09 09 20 20 20  bble up 1G...   
3370: 20 23 20 6f 66 20 52 41 4d 20 6f 72 20 6d 6f 72   # of RAM or mor
3380: 65 20 77 69 74 68 20 61 6c 6c 20 74 68 65 20 6f  e with all the o
3390: 62 6a 65 63 74 73 20 28 72 65 76 69 73 69 6f 6e  bjects (revision
33a0: 73 0a 09 09 20 20 20 20 23 20 61 6e 64 20 66 69  s...    # and fi
33b0: 6c 65 2d 6c 65 76 65 6c 20 73 79 6d 62 6f 6c 73  le-level symbols
33c0: 29 2e 0a 0a 09 09 20 20 20 20 24 66 69 6c 65 20  ).....    $file 
33d0: 70 65 72 73 69 73 74 0a 09 09 7d 0a 0a 09 09 24  persist...}....$
33e0: 66 69 6c 65 20 64 72 6f 70 0a 09 20 20 20 20 7d  file drop..    }
33f0: 0a 0a 09 20 20 20 20 24 70 72 6f 6a 65 63 74 20  ...    $project 
3400: 70 75 72 67 65 67 68 6f 73 74 73 79 6d 62 6f 6c  purgeghostsymbol
3410: 73 0a 09 7d 0a 0a 09 72 65 70 6f 73 69 74 6f 72  s..}...repositor
3420: 79 20 70 65 72 73 69 73 74 72 65 76 0a 09 72 65  y persistrev..re
3430: 70 6f 73 69 74 6f 72 79 20 70 72 69 6e 74 72 65  pository printre
3440: 76 73 74 61 74 69 73 74 69 63 73 0a 09 69 6e 74  vstatistics..int
3450: 65 67 72 69 74 79 20 20 73 74 72 69 63 74 0a 0a  egrity  strict..
3460: 09 6c 6f 67 20 77 72 69 74 65 20 31 20 63 6f 6c  .log write 1 col
3470: 6c 72 65 76 20 22 53 63 61 6e 20 63 6f 6d 70 6c  lrev "Scan compl
3480: 65 74 65 64 22 0a 09 72 65 74 75 72 6e 0a 20 20  eted"..return.  
3490: 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74    }..    typemet
34a0: 68 6f 64 20 64 69 73 63 61 72 64 20 7b 7d 20 7b  hod discard {} {
34b0: 0a 09 23 20 50 61 73 73 20 6d 61 6e 61 67 65 72  ..# Pass manager
34c0: 20 69 6e 74 65 72 66 61 63 65 2e 20 45 78 65 63   interface. Exec
34d0: 75 74 65 64 20 66 6f 72 20 61 6c 6c 20 70 61 73  uted for all pas
34e0: 73 65 73 20 61 66 74 65 72 20 74 68 65 0a 09 23  ses after the..#
34f0: 20 72 75 6e 20 70 61 73 73 65 73 2c 20 74 6f 20   run passes, to 
3500: 72 65 6d 6f 76 65 20 61 6c 6c 20 64 61 74 61 20  remove all data 
3510: 6f 66 20 74 68 69 73 20 70 61 73 73 20 66 72 6f  of this pass fro
3520: 6d 20 74 68 65 20 73 74 61 74 65 2c 0a 09 23 20  m the state,..# 
3530: 61 73 20 62 65 69 6e 67 20 6f 75 74 20 6f 66 20  as being out of 
3540: 64 61 74 65 2e 0a 0a 09 73 74 61 74 65 20 64 69  date....state di
3550: 73 63 61 72 64 20 72 65 76 69 73 69 6f 6e 0a 09  scard revision..
3560: 73 74 61 74 65 20 64 69 73 63 61 72 64 20 74 61  state discard ta
3570: 67 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64  g..state discard
3580: 20 62 72 61 6e 63 68 0a 09 73 74 61 74 65 20 64   branch..state d
3590: 69 73 63 61 72 64 20 73 79 6d 62 6f 6c 0a 09 73  iscard symbol..s
35a0: 74 61 74 65 20 64 69 73 63 61 72 64 20 62 6c 6f  tate discard blo
35b0: 63 6b 65 72 0a 09 73 74 61 74 65 20 64 69 73 63  cker..state disc
35c0: 61 72 64 20 70 61 72 65 6e 74 0a 09 73 74 61 74  ard parent..stat
35d0: 65 20 64 69 73 63 61 72 64 20 73 79 6d 74 79 70  e discard symtyp
35e0: 65 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64  e..state discard
35f0: 20 6d 65 74 61 0a 09 73 74 61 74 65 20 64 69 73   meta..state dis
3600: 63 61 72 64 20 61 75 74 68 6f 72 0a 09 73 74 61  card author..sta
3610: 74 65 20 64 69 73 63 61 72 64 20 63 6d 65 73 73  te discard cmess
3620: 61 67 65 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  age..return.    
3630: 7d 0a 0a 20 20 20 20 23 20 54 4f 44 4f 3a 20 4d  }..    # TODO: M
3640: 6f 76 65 20 74 68 69 73 20 63 6f 64 65 20 74 6f  ove this code to
3650: 20 74 68 65 20 69 6e 74 65 67 72 69 74 79 20 6d   the integrity m
3660: 6f 64 75 6c 65 0a 20 20 20 20 70 72 6f 63 20 50  odule.    proc P
3670: 61 72 61 6e 6f 69 61 20 7b 7d 20 7b 0a 09 23 20  aranoia {} {..# 
3680: 54 68 69 73 20 63 6f 64 65 20 70 65 72 66 6f 72  This code perfor
3690: 6d 73 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 70  ms a number of p
36a0: 61 72 61 6e 6f 69 64 20 63 68 65 63 6b 73 20 6f  aranoid checks o
36b0: 66 20 74 68 65 0a 09 23 20 64 61 74 61 62 61 73  f the..# databas
36c0: 65 2c 20 73 65 61 72 63 68 69 6e 67 20 66 6f 72  e, searching for
36d0: 20 69 6e 63 6f 6e 73 69 73 74 65 6e 74 20 63 72   inconsistent cr
36e0: 6f 73 73 2d 72 65 66 65 72 65 6e 63 65 73 2e 0a  oss-references..
36f0: 09 6c 6f 67 20 77 72 69 74 65 20 34 20 63 6f 6c  .log write 4 col
3700: 6c 72 65 76 20 7b 43 68 65 63 6b 20 64 61 74 61  lrev {Check data
3710: 62 61 73 65 20 63 6f 6e 73 69 73 74 65 6e 63 79  base consistency
3720: 7d 0a 0a 09 73 65 74 20 6e 20 30 20 3b 20 23 20  }...set n 0 ; # 
3730: 43 6f 75 6e 74 65 72 20 66 6f 72 20 74 68 65 20  Counter for the 
3740: 63 68 65 63 6b 73 20 28 77 65 20 70 72 69 6e 74  checks (we print
3750: 20 61 6e 20 69 64 20 62 65 66 6f 72 65 20 74 68   an id before th
3760: 65 0a 09 09 20 20 23 20 6d 61 69 6e 20 6c 61 62  e...  # main lab
3770: 65 6c 29 2e 0a 0a 09 23 20 46 69 6e 64 20 61 6c  el)....# Find al
3780: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63  l revisions whic
3790: 68 20 64 69 73 61 67 72 65 65 20 77 69 74 68 20  h disagree with 
37a0: 74 68 65 69 72 20 6c 69 6e 65 20 6f 66 0a 09 23  their line of..#
37b0: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 61 62 6f   development abo
37c0: 75 74 20 74 68 65 20 70 72 6f 6a 65 63 74 20 74  ut the project t
37d0: 68 65 79 20 61 72 65 20 6f 77 6e 65 64 20 62 79  hey are owned by
37e0: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
37f0: 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74  {Revisions and t
3800: 68 65 69 72 20 4c 4f 44 73 20 68 61 76 65 20 74  heir LODs have t
3810: 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65  o be in the same
3820: 20 70 72 6f 6a 65 63 74 7d 20 5c 0a 09 20 20 20   project} \..   
3830: 20 7b 64 69 73 61 67 72 65 65 73 20 77 69 74 68   {disagrees with
3840: 20 69 74 73 20 4c 4f 44 20 61 62 6f 75 74 20 6f   its LOD about o
3850: 77 6e 69 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b  wning project} {
3860: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65  ...SELECT F.name
3870: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20  , R.rev...FROM  
3880: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c   revision R, fil
3890: 65 20 46 2c 20 73 79 6d 62 6f 6c 20 53 0a 09 09  e F, symbol S...
38a0: 57 48 45 52 45 20 20 52 2e 66 69 64 20 3d 20 46  WHERE  R.fid = F
38b0: 2e 66 69 64 20 20 20 2d 2d 20 47 65 74 20 66 69  .fid   -- Get fi
38c0: 6c 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09  le of revision..
38d0: 09 41 4e 44 20 20 20 20 52 2e 6c 6f 64 20 3d 20  .AND    R.lod = 
38e0: 53 2e 73 69 64 20 20 20 2d 2d 20 47 65 74 20 73  S.sid   -- Get s
38f0: 79 6d 62 6f 6c 20 66 6f 72 20 72 65 76 69 73 69  ymbol for revisi
3900: 6f 6e 27 73 20 4c 4f 44 0a 09 09 41 4e 44 20 20  on's LOD...AND  
3910: 20 20 46 2e 70 69 64 20 21 3d 20 53 2e 70 69 64    F.pid != S.pid
3920: 20 20 2d 2d 20 62 75 74 20 73 79 6d 62 6f 6c 20    -- but symbol 
3930: 69 73 20 66 6f 72 20 61 20 64 69 66 66 65 72 65  is for a differe
3940: 6e 74 20 70 72 6f 6a 65 63 74 0a 09 09 3b 0a 09  nt project...;..
3950: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
3960: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63  l revisions whic
3970: 68 20 64 69 73 67 72 65 65 20 77 69 74 68 20 74  h disgree with t
3980: 68 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 61  heir meta data a
3990: 62 6f 75 74 0a 09 23 20 74 68 65 20 70 72 6f 6a  bout..# the proj
39a0: 65 63 74 20 74 68 65 79 20 61 72 65 20 6f 77 6e  ect they are own
39b0: 65 64 20 62 79 2e 0a 09 43 68 65 63 6b 20 5c 0a  ed by...Check \.
39c0: 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20  .    {Revisions 
39d0: 61 6e 64 20 74 68 65 69 72 20 6d 65 74 61 20 64  and their meta d
39e0: 61 74 61 20 68 61 76 65 20 74 6f 20 62 65 20 69  ata have to be i
39f0: 6e 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a 65  n the same proje
3a00: 63 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61  ct} \..    {disa
3a10: 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6d  grees with its m
3a20: 65 74 61 20 64 61 74 61 20 61 62 6f 75 74 20 6f  eta data about o
3a30: 77 6e 69 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b  wning project} {
3a40: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65  ...SELECT F.name
3a50: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20  , R.rev...FROM  
3a60: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c   revision R, fil
3a70: 65 20 46 2c 20 6d 65 74 61 20 4d 0a 09 09 57 48  e F, meta M...WH
3a80: 45 52 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66  ERE  R.fid = F.f
3a90: 69 64 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65  id   -- Get file
3aa0: 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41   of revision...A
3ab0: 4e 44 20 20 20 20 52 2e 6d 69 64 20 3d 20 4d 2e  ND    R.mid = M.
3ac0: 6d 69 64 20 20 20 2d 2d 20 47 65 74 20 6d 65 74  mid   -- Get met
3ad0: 61 20 64 61 74 61 20 6f 66 20 72 65 76 69 73 69  a data of revisi
3ae0: 6f 6e 0a 09 09 41 4e 44 20 20 20 20 46 2e 70 69  on...AND    F.pi
3af0: 64 20 21 3d 20 4d 2e 70 69 64 20 20 2d 2d 20 62  d != M.pid  -- b
3b00: 75 74 20 69 73 20 66 6f 72 20 61 20 64 69 66 66  ut is for a diff
3b10: 65 72 65 6e 74 20 70 72 6f 6a 65 63 74 0a 09 09  erent project...
3b20: 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64  ;..    }..# Find
3b30: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
3b40: 68 69 63 68 20 64 69 73 67 72 65 65 20 77 69 74  hich disgree wit
3b50: 68 20 74 68 65 69 72 20 6d 65 74 61 20 64 61 74  h their meta dat
3b60: 61 20 61 62 6f 75 74 0a 09 23 20 74 68 65 20 62  a about..# the b
3b70: 72 61 6e 63 68 2f 6c 69 6e 65 20 6f 66 20 64 65  ranch/line of de
3b80: 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20 62  velopment they b
3b90: 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b  elong to...Check
3ba0: 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f   \..    {Revisio
3bb0: 6e 73 20 61 6e 64 20 74 68 65 69 72 20 6d 65 74  ns and their met
3bc0: 61 20 64 61 74 61 20 68 61 76 65 20 74 6f 20 62  a data have to b
3bd0: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f  e in the same LO
3be0: 44 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67  D} \..    {disag
3bf0: 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6d 65  rees with its me
3c00: 74 61 20 64 61 74 61 20 61 62 6f 75 74 20 6f 77  ta data about ow
3c10: 6e 69 6e 67 20 4c 4f 44 7d 20 7b 0a 09 09 53 45  ning LOD} {...SE
3c20: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
3c30: 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69  ev...FROM   revi
3c40: 73 69 6f 6e 20 52 2c 20 6d 65 74 61 20 4d 2c 20  sion R, meta M, 
3c50: 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 20  file F...WHERE  
3c60: 52 2e 6d 69 64 20 3d 20 4d 2e 6d 69 64 20 20 20  R.mid = M.mid   
3c70: 2d 2d 20 47 65 74 20 6d 65 74 61 20 64 61 74 61  -- Get meta data
3c80: 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41   of revision...A
3c90: 4e 44 20 20 20 20 52 2e 6c 6f 64 20 21 3d 20 4d  ND    R.lod != M
3ca0: 2e 62 69 64 20 20 2d 2d 20 62 75 74 20 69 73 20  .bid  -- but is 
3cb0: 66 6f 72 20 61 20 64 69 66 66 65 72 65 6e 74 20  for a different 
3cc0: 4c 4f 44 0a 09 09 41 4e 44 20 20 20 20 52 2e 66  LOD...AND    R.f
3cd0: 69 64 20 3d 20 46 2e 66 69 64 20 20 20 2d 2d 20  id = F.fid   -- 
3ce0: 47 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76 69  Get file of revi
3cf0: 73 69 6f 6e 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  sion...;..    }.
3d00: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
3d10: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 70 72 69  sions with a pri
3d20: 6d 61 72 79 20 63 68 69 6c 64 20 77 68 69 63 68  mary child which
3d30: 20 64 69 73 61 67 72 65 65 73 0a 09 23 20 61 62   disagrees..# ab
3d40: 6f 75 74 20 74 68 65 20 66 69 6c 65 20 74 68 65  out the file the
3d50: 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68  y belong to...Ch
3d60: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69  eck \..    {Revi
3d70: 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20  sions and their 
3d80: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e  primary children
3d90: 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74   have to be in t
3da0: 68 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a  he same file} \.
3db0: 09 20 20 20 20 7b 64 69 73 61 67 72 65 65 73 20  .    {disagrees 
3dc0: 77 69 74 68 20 69 74 73 20 70 72 69 6d 61 72 79  with its primary
3dd0: 20 63 68 69 6c 64 20 61 62 6f 75 74 20 74 68 65   child about the
3de0: 20 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a   owning file} {.
3df0: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
3e00: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20 20   R.rev...FROM   
3e10: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69  revision R, revi
3e20: 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09  sion C, file F..
3e30: 09 57 48 45 52 45 20 20 52 2e 66 69 64 20 3d 20  .WHERE  R.fid = 
3e40: 46 2e 66 69 64 20 20 20 20 20 20 20 20 2d 2d 20  F.fid        -- 
3e50: 47 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76 69  Get file of revi
3e60: 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e  sion...AND    R.
3e70: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
3e80: 4c 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74  L  -- Restrict t
3e90: 6f 20 6e 6f 6e 2d 6c 65 61 66 20 72 65 76 69 73  o non-leaf revis
3ea0: 69 6f 6e 73 0a 09 09 41 4e 44 20 20 20 20 52 2e  ions...AND    R.
3eb0: 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 20 20 20  child = C.rid   
3ec0: 20 20 20 2d 2d 20 47 65 74 20 63 68 69 6c 64 20     -- Get child 
3ed0: 28 68 61 73 20 74 6f 20 65 78 69 73 74 29 0a 09  (has to exist)..
3ee0: 09 41 4e 44 20 20 20 20 43 2e 66 69 64 20 21 3d  .AND    C.fid !=
3ef0: 20 52 2e 66 69 64 20 20 20 20 20 20 20 2d 2d 20   R.fid       -- 
3f00: 57 68 69 63 20 77 72 6f 6e 67 6c 79 20 69 73 20  Whic wrongly is 
3f10: 69 6e 20 61 20 64 69 66 66 65 72 65 6e 74 20 66  in a different f
3f20: 69 6c 65 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 0a  ile...;..    }..
3f30: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
3f40: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62 72 61  sions with a bra
3f50: 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f  nch parent symbo
3f60: 6c 20 77 68 6f 73 65 20 70 61 72 65 6e 74 0a 09  l whose parent..
3f70: 23 20 64 69 73 61 67 72 65 65 73 20 61 62 6f 75  # disagrees abou
3f80: 74 20 74 68 65 20 66 69 6c 65 20 74 68 65 79 20  t the file they 
3f90: 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63  belong to...Chec
3fa0: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
3fb0: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 62 72  ons and their br
3fc0: 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 20 68 61  anch children ha
3fd0: 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65 20  ve to be in the 
3fe0: 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a 09 20 20  same file} \..  
3ff0: 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e    {at the beginn
4000: 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63  ing of its branc
4010: 68 20 61 6e 64 20 69 74 73 20 70 61 72 65 6e 74  h and its parent
4020: 20 64 69 73 61 67 72 65 65 20 61 62 6f 75 74 20   disagree about 
4030: 74 68 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65 7d  the owning file}
4040: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
4050: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
4060: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72     revision R, r
4070: 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20  evision P, file 
4080: 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66 69 64  F...WHERE  R.fid
4090: 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20 20 20   = F.fid        
40a0: 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66    -- Get file of
40b0: 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20   revision...AND 
40c0: 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20     R.bparent IS 
40d0: 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65 73  NOT NULL  -- Res
40e0: 74 72 69 63 74 20 74 6f 20 66 69 72 73 74 20 6f  trict to first o
40f0: 6e 20 62 72 61 6e 63 68 0a 09 09 41 4e 44 20 20  n branch...AND  
4100: 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72    R.parent = P.r
4110: 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20  id       -- Get 
4120: 6f 75 74 2d 6f 66 2d 62 72 61 6e 63 68 20 70 61  out-of-branch pa
4130: 72 65 6e 74 0a 09 09 41 4e 44 20 20 20 20 52 2e  rent...AND    R.
4140: 66 69 64 20 21 3d 20 50 2e 66 69 64 20 20 20 20  fid != P.fid    
4150: 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20 77 72       -- Which wr
4160: 6f 6e 67 6c 79 20 69 73 20 69 6e 20 61 20 64 69  ongly is in a di
4170: 66 66 65 72 65 6e 74 20 66 69 6c 65 0a 09 09 3b  fferent file...;
4180: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
4190: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
41a0: 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68  th a non-NTDB ch
41b0: 69 6c 64 20 77 68 69 63 68 20 64 69 73 61 67 72  ild which disagr
41c0: 65 65 73 0a 09 23 20 61 62 6f 75 74 20 74 68 65  ees..# about the
41d0: 20 66 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e   file they belon
41e0: 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  g to...Check \..
41f0: 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61      {Revisions a
4200: 6e 64 20 74 68 65 69 72 20 6e 6f 6e 2d 4e 54 44  nd their non-NTD
4210: 42 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20  B children have 
4220: 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d  to be in the sam
4230: 65 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b  e file} \..    {
4240: 64 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69  disagrees with i
4250: 74 73 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c  ts non-NTDB chil
4260: 64 20 61 62 6f 75 74 20 74 68 65 20 6f 77 6e 69  d about the owni
4270: 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09 53 45 4c  ng file} {...SEL
4280: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
4290: 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69 73  v...FROM   revis
42a0: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
42b0: 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  C, file F...WHER
42c0: 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  E  R.fid = F.fid
42d0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74            -- Get
42e0: 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69 6f   file of revisio
42f0: 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 64 62 63  n...AND    R.dbc
4300: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
4310: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
4320: 20 73 65 6d 69 2d 6c 61 73 74 20 4e 54 44 42 20   semi-last NTDB 
4330: 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20  revision...AND  
4340: 20 20 52 2e 64 62 63 68 69 6c 64 20 3d 20 43 2e    R.dbchild = C.
4350: 72 69 64 20 20 20 20 20 20 2d 2d 20 47 6f 74 20  rid      -- Got 
4360: 74 6f 20 61 73 73 6f 63 69 61 74 65 64 20 74 72  to associated tr
4370: 75 6e 6b 20 72 65 76 69 73 69 6f 6e 0a 09 09 41  unk revision...A
4380: 4e 44 20 20 20 20 43 2e 66 69 64 20 21 3d 20 52  ND    C.fid != R
4390: 2e 66 69 64 20 20 20 20 20 20 20 20 20 2d 2d 20  .fid         -- 
43a0: 57 68 69 63 68 20 77 72 6f 6e 67 6c 79 20 69 73  Which wrongly is
43b0: 20 69 6e 20 61 20 64 69 66 66 65 72 65 6e 74 20   in a different 
43c0: 66 69 6c 65 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  file...;..    }.
43d0: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
43e0: 73 69 6f 6e 73 20 77 68 69 63 68 20 68 61 76 65  sions which have
43f0: 20 61 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64   a primary child
4400: 2c 20 62 75 74 20 74 68 65 20 63 68 69 6c 64 0a  , but the child.
4410: 09 23 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65  .# does not have
4420: 20 74 68 65 6d 20 61 73 20 70 61 72 65 6e 74 2e   them as parent.
4430: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b  ..Check \..    {
4440: 52 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74  Revisions have t
4450: 6f 20 62 65 20 70 61 72 65 6e 74 73 20 6f 66 20  o be parents of 
4460: 74 68 65 69 72 20 70 72 69 6d 61 72 79 20 63 68  their primary ch
4470: 69 6c 64 72 65 6e 7d 20 5c 0a 09 20 20 20 20 7b  ildren} \..    {
4480: 69 73 20 6e 6f 74 20 74 68 65 20 70 61 72 65 6e  is not the paren
4490: 74 20 6f 66 20 69 74 73 20 70 72 69 6d 61 72 79  t of its primary
44a0: 20 63 68 69 6c 64 7d 20 7b 0a 09 09 53 45 4c 45   child} {...SELE
44b0: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
44c0: 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69 73 69  ...FROM   revisi
44d0: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43  on R, revision C
44e0: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45  , file F...WHERE
44f0: 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 20    R.fid = F.fid 
4500: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 66 69         -- Get fi
4510: 6c 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09  le of revision..
4520: 09 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20  .AND    R.child 
4530: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20  IS NOT NULL  -- 
4540: 52 65 73 74 72 69 63 74 20 74 6f 20 6e 6f 6e 2d  Restrict to non-
4550: 6c 65 61 76 65 73 0a 09 09 41 4e 44 20 20 20 20  leaves...AND    
4560: 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 20  R.child = C.rid 
4570: 20 20 20 20 20 2d 2d 20 47 65 74 20 74 68 65 20       -- Get the 
4580: 63 68 69 6c 64 20 28 68 61 73 20 74 6f 20 65 78  child (has to ex
4590: 69 73 74 29 0a 09 09 41 4e 44 20 20 20 20 43 2e  ist)...AND    C.
45a0: 70 61 72 65 6e 74 20 21 3d 20 52 2e 72 69 64 20  parent != R.rid 
45b0: 20 20 20 2d 2d 20 57 68 69 63 68 20 64 6f 65 73     -- Which does
45c0: 20 6e 6f 74 20 68 61 76 65 20 75 73 20 61 73 20   not have us as 
45d0: 69 74 73 20 70 61 72 65 6e 74 2e 0a 09 09 3b 0a  its parent....;.
45e0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
45f0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69  ll revisions whi
4600: 63 68 20 68 61 76 65 20 61 20 70 72 69 6d 72 61  ch have a primra
4610: 72 79 20 63 68 69 6c 64 2c 20 62 75 74 20 74 68  ry child, but th
4620: 65 0a 09 23 20 63 68 69 6c 64 20 68 61 73 20 61  e..# child has a
4630: 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73   branch parent s
4640: 79 6d 62 6f 6c 20 6d 61 6b 69 6e 67 20 74 68 65  ymbol making the
4650: 6d 20 62 72 61 63 68 20 73 74 61 72 74 65 72 73  m brach starters
4660: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
4670: 7b 50 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65  {Primary childre
4680: 6e 20 6f 66 20 72 65 76 69 73 69 6f 6e 73 20 6d  n of revisions m
4690: 75 73 74 20 6e 6f 74 20 73 74 61 72 74 20 62 72  ust not start br
46a0: 61 6e 63 68 65 73 7d 20 5c 0a 09 20 20 20 20 7b  anches} \..    {
46b0: 69 73 20 70 61 72 65 6e 74 20 6f 66 20 61 20 70  is parent of a p
46c0: 72 69 6d 61 72 79 20 63 68 69 6c 64 20 77 68 69  rimary child whi
46d0: 63 68 20 69 73 20 74 68 65 20 62 65 67 69 6e 6e  ch is the beginn
46e0: 69 6e 67 20 6f 66 20 61 20 62 72 61 6e 63 68 7d  ing of a branch}
46f0: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
4700: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
4710: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72     revision R, r
4720: 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20  evision C, file 
4730: 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66 69 64  F...WHERE  R.fid
4740: 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20 20 20   = F.fid        
4750: 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f     -- Get file o
4760: 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44  f revision...AND
4770: 20 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e      R.child IS N
4780: 4f 54 20 4e 55 4c 4c 20 20 20 20 20 2d 2d 20 52  OT NULL     -- R
4790: 65 73 74 72 69 63 74 20 74 6f 20 6e 6f 6e 2d 6c  estrict to non-l
47a0: 65 61 76 65 73 0a 09 09 41 4e 44 20 20 20 20 52  eaves...AND    R
47b0: 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 20 20  .child = C.rid  
47c0: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 74 68         -- Get th
47d0: 65 20 63 68 69 6c 64 20 28 68 61 73 20 74 6f 20  e child (has to 
47e0: 65 78 69 73 74 29 0a 09 09 41 4e 44 20 20 20 20  exist)...AND    
47f0: 43 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54  C.bparent IS NOT
4800: 20 4e 55 4c 4c 20 20 20 2d 2d 20 77 72 6f 6e 67   NULL   -- wrong
4810: 6c 79 20 63 6c 61 69 6d 69 6e 67 20 74 6f 20 62  ly claiming to b
4820: 65 20 66 69 72 73 74 20 6f 6e 20 62 72 61 6e 63  e first on branc
4830: 68 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20  h...;..    }..# 
4840: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f  Find all revisio
4850: 6e 73 20 77 69 74 68 6f 75 74 20 62 72 61 6e 63  ns without branc
4860: 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20  h parent symbol 
4870: 77 68 69 63 68 20 68 61 76 65 20 61 0a 09 23 20  which have a..# 
4880: 70 61 72 65 6e 74 2c 20 62 75 74 20 74 68 65 20  parent, but the 
4890: 70 61 72 65 6e 74 20 64 6f 65 73 20 6e 6f 74 20  parent does not 
48a0: 68 61 76 65 20 74 68 65 6d 20 61 73 20 70 72 69  have them as pri
48b0: 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 43 68 65  mary child...Che
48c0: 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73  ck \..    {Revis
48d0: 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 62 65 20  ions have to be 
48e0: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e  primary children
48f0: 20 6f 66 20 74 68 65 69 72 20 70 61 72 65 6e 74   of their parent
4900: 73 2c 20 69 66 20 61 6e 79 7d 20 5c 0a 09 20 20  s, if any} \..  
4910: 20 20 7b 69 73 20 6e 6f 74 20 74 68 65 20 63 68    {is not the ch
4920: 69 6c 64 20 6f 66 20 69 74 73 20 70 61 72 65 6e  ild of its paren
4930: 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  t} {...SELECT F.
4940: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
4950: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
4960: 20 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c   revision P, fil
4970: 65 20 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66  e F...WHERE  R.f
4980: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
4990: 20 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53      R.bparent IS
49a0: 20 4e 55 4c 4c 20 20 20 20 20 2d 2d 20 47 65 74   NULL     -- Get
49b0: 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69 6f   file of revisio
49c0: 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 70 61 72  n...AND    R.par
49d0: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ent IS NOT NULL 
49e0: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
49f0: 65 76 65 72 79 74 68 69 6e 67 20 6e 6f 74 20 66  everything not f
4a00: 69 72 73 74 20 6f 6e 20 61 20 62 72 61 6e 63 68  irst on a branch
4a10: 0a 09 09 41 4e 44 20 20 20 20 52 2e 70 61 72 65  ...AND    R.pare
4a20: 6e 74 20 3d 20 50 2e 72 69 64 20 20 20 20 20 20  nt = P.rid      
4a30: 2d 2d 20 47 65 74 20 74 68 65 20 70 61 72 65 6e  -- Get the paren
4a40: 74 20 28 68 61 73 20 74 6f 20 65 78 69 73 74 29  t (has to exist)
4a50: 0a 09 09 41 4e 44 20 20 20 20 50 2e 63 68 69 6c  ...AND    P.chil
4a60: 64 20 21 3d 20 52 2e 72 69 64 20 20 20 20 20 20  d != R.rid      
4a70: 2d 2d 20 57 68 69 63 68 20 64 6f 20 6e 6f 74 20  -- Which do not 
4a80: 68 61 76 65 20 75 73 20 61 73 20 74 68 65 69 72  have us as their
4a90: 20 63 68 69 6c 64 0a 09 09 3b 0a 09 20 20 20 20   child...;..    
4aa0: 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  }..# Find all re
4ab0: 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62  visions with a b
4ac0: 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d  ranch parent sym
4ad0: 62 6f 6c 20 77 68 69 63 68 20 64 6f 20 6e 6f 74  bol which do not
4ae0: 0a 09 23 20 68 61 76 65 20 61 20 70 61 72 65 6e  ..# have a paren
4af0: 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20  t...Check \..   
4b00: 20 7b 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e   {Branch startin
4b10: 67 20 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65  g revisions have
4b20: 20 74 6f 20 68 61 76 65 20 61 20 70 61 72 65 6e   to have a paren
4b30: 74 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68  t} \..    {at th
4b40: 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69  e beginning of i
4b50: 74 73 20 62 72 61 6e 63 68 20 68 61 73 20 6e 6f  ts branch has no
4b60: 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45 4c   parent} {...SEL
4b70: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
4b80: 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69 73  v...FROM   revis
4b90: 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09  ion R, file F...
4ba0: 57 48 45 52 45 20 20 52 2e 66 69 64 20 3d 20 46  WHERE  R.fid = F
4bb0: 2e 66 69 64 20 20 20 20 20 20 20 20 20 20 2d 2d  .fid          --
4bc0: 20 47 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76   Get file of rev
4bd0: 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52  ision...AND    R
4be0: 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20  .bparent IS NOT 
4bf0: 4e 55 4c 4c 20 20 2d 2d 20 52 65 73 74 72 69 63  NULL  -- Restric
4c00: 74 20 74 6f 20 66 69 72 73 74 20 6f 6e 20 61 20  t to first on a 
4c10: 62 72 61 6e 63 68 0a 09 09 41 4e 44 20 20 20 20  branch...AND    
4c20: 52 2e 70 61 72 65 6e 74 20 49 53 20 4e 55 4c 4c  R.parent IS NULL
4c30: 20 20 20 20 20 20 20 2d 2d 20 42 75 74 20 74 68         -- But th
4c40: 65 72 65 20 69 73 20 6e 6f 20 6f 75 74 2d 6f 66  ere is no out-of
4c50: 2d 62 72 61 6e 63 68 20 70 61 72 65 6e 74 0a 09  -branch parent..
4c60: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
4c70: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
4c80: 77 69 74 68 20 61 20 62 72 61 6e 63 68 20 70 61  with a branch pa
4c90: 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f 73  rent symbol whos
4ca0: 65 20 70 61 72 65 6e 74 0a 09 23 20 68 61 73 20  e parent..# has 
4cb0: 74 68 65 6d 20 61 73 20 70 72 69 6d 61 72 79 20  them as primary 
4cc0: 63 68 69 6c 64 2e 0a 09 43 68 65 63 6b 20 5c 0a  child...Check \.
4cd0: 09 20 20 20 20 7b 42 72 61 6e 63 68 20 73 74 61  .    {Branch sta
4ce0: 72 74 69 6e 67 20 72 65 76 69 73 69 6f 6e 73 20  rting revisions 
4cf0: 6d 75 73 74 20 6e 6f 74 20 62 65 20 70 72 69 6d  must not be prim
4d00: 61 72 79 20 63 68 69 6c 64 72 65 6e 20 6f 66 20  ary children of 
4d10: 74 68 65 69 72 20 70 61 72 65 6e 74 73 7d 20 5c  their parents} \
4d20: 0a 09 20 20 20 20 7b 61 74 20 74 68 65 20 62 65  ..    {at the be
4d30: 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62  ginning of its b
4d40: 72 61 6e 63 68 20 69 73 20 74 68 65 20 70 72 69  ranch is the pri
4d50: 6d 61 72 79 20 63 68 69 6c 64 20 6f 66 20 69 74  mary child of it
4d60: 73 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45  s parent} {...SE
4d70: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
4d80: 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69  ev...FROM   revi
4d90: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
4da0: 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   P, file F...WHE
4db0: 52 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  RE  R.fid = F.fi
4dc0: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65  d          -- Ge
4dd0: 74 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69  t file of revisi
4de0: 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 62 70  on...AND    R.bp
4df0: 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c  arent IS NOT NUL
4e00: 4c 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74  L  -- Restrict t
4e10: 6f 20 66 69 72 73 74 20 6f 6e 20 61 20 62 72 61  o first on a bra
4e20: 6e 63 68 0a 09 09 41 4e 44 20 20 20 20 52 2e 70  nch...AND    R.p
4e30: 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c  arent IS NOT NUL
4e40: 4c 20 20 20 2d 2d 20 57 68 69 63 68 20 61 72 65  L   -- Which are
4e50: 20 6e 6f 74 20 64 65 74 61 63 68 65 64 0a 09 09   not detached...
4e60: 41 4e 44 20 20 20 20 52 2e 70 61 72 65 6e 74 20  AND    R.parent 
4e70: 3d 20 50 2e 72 69 64 20 20 20 20 20 20 20 2d 2d  = P.rid       --
4e80: 20 47 65 74 20 74 68 65 69 72 20 6e 6f 6e 2d 62   Get their non-b
4e90: 72 61 6e 63 68 20 70 61 72 65 6e 74 0a 09 09 41  ranch parent...A
4ea0: 4e 44 20 20 20 20 50 2e 63 68 69 6c 64 20 3d 20  ND    P.child = 
4eb0: 52 2e 72 69 64 20 20 20 20 20 20 20 20 2d 2d 20  R.rid        -- 
4ec0: 77 68 69 63 68 20 69 6d 70 72 6f 70 65 72 6c 79  which improperly
4ed0: 20 68 61 73 20 74 68 65 6d 20 61 73 20 70 72 69   has them as pri
4ee0: 6d 61 72 79 20 63 68 69 6c 64 0a 09 09 3b 0a 09  mary child...;..
4ef0: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
4f00: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68  l revisions with
4f10: 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c   a non-NTDB chil
4f20: 64 20 77 68 69 63 68 20 61 72 65 20 6e 6f 74 20  d which are not 
4f30: 6f 6e 0a 09 23 20 74 68 65 20 4e 54 44 42 2e 0a  on..# the NTDB..
4f40: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 4e  .Check \..    {N
4f50: 54 44 42 20 74 6f 20 74 72 75 6e 6b 20 74 72 61  TDB to trunk tra
4f60: 6e 73 69 74 69 6f 6e 20 68 61 73 20 74 6f 20 62  nsition has to b
4f70: 65 67 69 6e 20 6f 6e 20 4e 54 44 42 7d 20 5c 0a  egin on NTDB} \.
4f80: 09 20 20 20 20 7b 68 61 73 20 61 20 6e 6f 6e 2d  .    {has a non-
4f90: 4e 54 44 42 20 63 68 69 6c 64 2c 20 79 65 74 20  NTDB child, yet 
4fa0: 69 73 20 6e 6f 74 20 6f 6e 20 74 68 65 20 4e 54  is not on the NT
4fb0: 44 42 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  DB} {...SELECT F
4fc0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
4fd0: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
4fe0: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45  , file F...WHERE
4ff0: 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 20    R.fid = F.fid 
5000: 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20           -- Get 
5010: 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69 6f 6e  file of revision
5020: 0a 09 09 41 4e 44 20 20 20 20 52 2e 64 62 63 68  ...AND    R.dbch
5030: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ild IS NOT NULL 
5040: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
5050: 73 65 6d 69 2d 6c 61 73 74 20 4e 54 44 42 20 72  semi-last NTDB r
5060: 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20  evision...AND   
5070: 20 4e 4f 54 20 52 2e 69 73 64 65 66 61 75 6c 74   NOT R.isdefault
5080: 20 20 20 20 20 20 20 20 2d 2d 20 49 6d 70 72 6f          -- Impro
5090: 70 65 72 6c 79 20 63 6c 61 69 6d 69 6e 67 20 74  perly claiming t
50a0: 6f 20 6e 6f 74 20 62 65 20 6f 6e 20 4e 54 44 42  o not be on NTDB
50b0: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46  ...;..    }..# F
50c0: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  ind all revision
50d0: 73 20 77 69 74 68 20 61 20 4e 54 44 42 20 70 61  s with a NTDB pa
50e0: 72 65 6e 74 20 77 68 69 63 68 20 61 72 65 20 6f  rent which are o
50f0: 6e 20 74 68 65 20 4e 54 44 42 2e 0a 09 43 68 65  n the NTDB...Che
5100: 63 6b 20 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20  ck \..    {NTDB 
5110: 74 6f 20 74 72 75 6e 6b 20 74 72 61 6e 73 69 74  to trunk transit
5120: 69 6f 6e 20 68 61 73 20 74 6f 20 65 6e 64 20 6f  ion has to end o
5130: 6e 20 6e 6f 6e 2d 4e 54 44 42 7d 20 5c 0a 09 20  n non-NTDB} \.. 
5140: 20 20 20 7b 68 61 73 20 61 20 4e 54 44 42 20 70     {has a NTDB p
5150: 61 72 65 6e 74 2c 20 79 65 74 20 69 73 20 6f 6e  arent, yet is on
5160: 20 74 68 65 20 4e 54 44 42 7d 20 7b 0a 09 09 53   the NTDB} {...S
5170: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
5180: 72 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76  rev...FROM   rev
5190: 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a  ision R, file F.
51a0: 09 09 57 48 45 52 45 20 20 52 2e 66 69 64 20 3d  ..WHERE  R.fid =
51b0: 20 46 2e 66 69 64 20 20 20 20 20 20 20 20 20 20   F.fid          
51c0: 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20   -- Get file of 
51d0: 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20  revision...AND  
51e0: 20 20 52 2e 64 62 70 61 72 65 6e 74 20 49 53 20    R.dbparent IS 
51f0: 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65 73  NOT NULL  -- Res
5200: 74 72 69 63 74 20 74 6f 20 74 72 75 6e 6b 20 72  trict to trunk r
5210: 6f 6f 74 73 20 77 69 74 68 20 4e 54 44 42 20 61  oots with NTDB a
5220: 72 6f 75 6e 64 0a 09 09 41 4e 44 20 20 20 20 52  round...AND    R
5230: 2e 69 73 64 65 66 61 75 6c 74 20 20 20 20 20 20  .isdefault      
5240: 20 20 20 20 20 20 20 2d 2d 20 42 75 74 20 72 6f         -- But ro
5250: 6f 74 20 69 6d 70 72 6f 70 65 72 6c 79 20 63 6c  ot improperly cl
5260: 61 69 6d 73 20 74 6f 20 62 65 20 6f 6e 20 4e 54  aims to be on NT
5270: 44 42 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23  DB...;..    }..#
5280: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69   Find all revisi
5290: 6f 6e 73 20 77 69 74 68 20 61 20 63 68 69 6c 64  ons with a child
52a0: 20 77 68 69 63 68 20 64 69 73 61 67 72 65 65 73   which disagrees
52b0: 20 61 62 6f 75 74 20 74 68 65 0a 09 23 20 6c 69   about the..# li
52c0: 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e  ne of developmen
52d0: 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f  t they belong to
52e0: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
52f0: 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74  {Revisions and t
5300: 68 65 69 72 20 70 72 69 6d 61 72 79 20 63 68 69  heir primary chi
5310: 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65  ldren have to be
5320: 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f 44   in the same LOD
5330: 7d 20 5c 0a 09 20 20 20 20 7b 61 6e 64 20 69 74  } \..    {and it
5340: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20  s primary child 
5350: 64 69 73 61 67 72 65 65 20 61 62 6f 75 74 20 74  disagree about t
5360: 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45  heir LOD} {...SE
5370: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
5380: 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69  ev...FROM   revi
5390: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
53a0: 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   C, file F...WHE
53b0: 52 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  RE  R.fid = F.fi
53c0: 64 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20  d        -- Get 
53d0: 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69 6f 6e  file of revision
53e0: 0a 09 09 41 4e 44 20 20 20 20 52 2e 63 68 69 6c  ...AND    R.chil
53f0: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d  d IS NOT NULL  -
5400: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 6e 6f  - Restrict to no
5410: 6e 2d 6c 65 61 76 65 73 0a 09 09 41 4e 44 20 20  n-leaves...AND  
5420: 20 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69    R.child = C.ri
5430: 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20 63 68  d      -- Get ch
5440: 69 6c 64 20 28 68 61 73 20 74 6f 20 65 78 69 73  ild (has to exis
5450: 74 29 0a 09 09 41 4e 44 20 20 20 20 43 2e 6c 6f  t)...AND    C.lo
5460: 64 20 21 3d 20 52 2e 6c 6f 64 20 20 20 20 20 20  d != R.lod      
5470: 20 2d 2d 20 77 68 69 63 68 20 69 6d 70 72 6f 70   -- which improp
5480: 65 72 6c 79 20 75 73 65 73 20 61 20 64 69 66 66  erly uses a diff
5490: 65 72 65 6e 74 20 4c 4f 44 0a 09 09 3b 0a 09 20  erent LOD...;.. 
54a0: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
54b0: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
54c0: 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64  a non-NTDB child
54d0: 20 77 68 69 63 68 20 61 67 72 65 65 73 20 61 62   which agrees ab
54e0: 6f 75 74 0a 09 23 20 74 68 65 20 6c 69 6e 65 20  out..# the line 
54f0: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74  of development t
5500: 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09  hey belong to...
5510: 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 4e 54  Check \..    {NT
5520: 44 42 20 61 6e 64 20 74 72 75 6e 6b 20 72 65 76  DB and trunk rev
5530: 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 62  isions have to b
5540: 65 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20 4c  e in different L
5550: 4f 44 73 7d 20 5c 0a 09 20 20 20 20 7b 6f 6e 20  ODs} \..    {on 
5560: 4e 54 44 42 20 61 6e 64 20 69 74 73 20 6e 6f 6e  NTDB and its non
5570: 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 72 6f 6e  -NTDB child wron
5580: 67 6c 79 20 61 67 72 65 65 20 61 62 6f 75 74 20  gly agree about 
5590: 74 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53  their LOD} {...S
55a0: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
55b0: 72 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76  rev...FROM   rev
55c0: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
55d0: 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n C, file F...WH
55e0: 45 52 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66  ERE  R.fid = F.f
55f0: 69 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47  id          -- G
5600: 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73  et file of revis
5610: 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 64  ion...AND    R.d
5620: 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  bchild IS NOT NU
5630: 4c 4c 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20  LL  -- Restrict 
5640: 74 6f 20 73 65 6d 69 2d 6c 61 73 74 20 4e 54 44  to semi-last NTD
5650: 42 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44  B revision...AND
5660: 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 3d 20      R.dbchild = 
5670: 43 2e 72 69 64 20 20 20 20 20 20 2d 2d 20 47 65  C.rid      -- Ge
5680: 74 20 61 73 73 6f 63 69 61 74 65 64 20 74 72 75  t associated tru
5690: 6e 6b 20 72 6f 6f 74 20 72 65 76 69 73 69 6f 6e  nk root revision
56a0: 0a 09 09 41 4e 44 20 20 20 20 43 2e 6c 6f 64 20  ...AND    C.lod 
56b0: 3d 20 52 2e 6c 6f 64 20 20 20 20 20 20 20 20 20  = R.lod         
56c0: 20 2d 2d 20 49 6d 70 72 6f 70 65 72 6c 79 20 75   -- Improperly u
56d0: 73 65 73 20 74 68 65 20 73 61 6d 65 20 4c 4f 44  ses the same LOD
56e0: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46  ...;..    }..# F
56f0: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  ind all revision
5700: 73 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 20  s with a branch 
5710: 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68  parent symbol wh
5720: 69 63 68 20 69 73 20 6e 6f 74 0a 09 23 20 74 68  ich is not..# th
5730: 65 69 72 20 4c 4f 44 2e 0a 09 43 68 65 63 6b 20  eir LOD...Check 
5740: 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63 68 20 73  \..    {Branch s
5750: 74 61 72 74 69 6e 67 20 72 65 76 69 73 69 6f 6e  tarting revision
5760: 73 20 68 61 76 65 20 74 6f 20 68 61 76 65 20 74  s have to have t
5770: 68 65 69 72 20 4c 4f 44 20 61 73 20 62 72 61 6e  heir LOD as bran
5780: 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c  ch parent symbol
5790: 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65  } \..    {at the
57a0: 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74   beginning of it
57b0: 73 20 62 72 61 6e 63 68 20 64 6f 65 73 20 6e 6f  s branch does no
57c0: 74 20 68 61 76 65 20 74 68 65 20 62 72 61 6e 63  t have the branc
57d0: 68 20 73 79 6d 62 6f 6c 20 61 73 20 69 74 73 20  h symbol as its 
57e0: 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20  LOD} {...SELECT 
57f0: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
5800: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
5810: 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  R, file F...WHER
5820: 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  E  R.fid = F.fid
5830: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74            -- Get
5840: 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69 6f   file of revisio
5850: 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 62 70 61  n...AND    R.bpa
5860: 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  rent IS NOT NULL
5870: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
5880: 20 72 65 76 69 73 69 6f 6e 73 20 66 69 72 73 74   revisions first
5890: 20 6f 6e 20 61 20 62 72 61 6e 63 68 0a 09 09 41   on a branch...A
58a0: 4e 44 20 20 20 20 52 2e 6c 6f 64 20 21 3d 20 52  ND    R.lod != R
58b0: 2e 62 70 61 72 65 6e 74 20 20 20 20 20 2d 2d 20  .bparent     -- 
58c0: 61 6e 64 20 74 68 65 69 72 20 62 72 61 6e 63 68  and their branch
58d0: 20 69 73 20 6e 6f 74 20 74 68 65 69 72 20 4c 4f   is not their LO
58e0: 44 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20  D...;..    }..# 
58f0: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f  Find all revisio
5900: 6e 73 20 77 69 74 68 20 61 20 62 72 61 6e 63 68  ns with a branch
5910: 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77   parent symbol w
5920: 68 6f 73 65 20 70 61 72 65 6e 74 0a 09 23 20 69  hose parent..# i
5930: 73 20 69 6e 20 74 68 65 20 73 61 6d 65 20 6c 69  s in the same li
5940: 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e  ne of developmen
5950: 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20  t...Check \..   
5960: 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20   {Revisions and 
5970: 74 68 65 69 72 20 62 72 61 6e 63 68 20 63 68 69  their branch chi
5980: 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65  ldren have to be
5990: 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20 4c 4f   in different LO
59a0: 44 73 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74  Ds} \..    {at t
59b0: 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20  he beginning of 
59c0: 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64 20 69  its branch and i
59d0: 74 73 20 70 61 72 65 6e 74 20 77 72 6f 6e 67 6c  ts parent wrongl
59e0: 79 20 61 67 72 65 65 20 61 62 6f 75 74 20 74 68  y agree about th
59f0: 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c  eir LOD} {...SEL
5a00: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
5a10: 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69 73  v...FROM   revis
5a20: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
5a30: 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  P, file F...WHER
5a40: 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  E  R.fid = F.fid
5a50: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74            -- Get
5a60: 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69 6f   file of revisio
5a70: 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 62 70 61  n...AND    R.bpa
5a80: 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  rent IS NOT NULL
5a90: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
5aa0: 20 72 65 76 69 73 69 6f 6e 73 20 66 69 72 73 74   revisions first
5ab0: 20 6f 6e 20 61 20 62 72 61 6e 63 68 0a 09 09 41   on a branch...A
5ac0: 4e 44 20 20 20 20 52 2e 70 61 72 65 6e 74 20 3d  ND    R.parent =
5ad0: 20 50 2e 72 69 64 20 20 20 20 20 20 20 2d 2d 20   P.rid       -- 
5ae0: 47 65 74 20 74 68 65 69 72 20 6e 6f 6e 2d 62 72  Get their non-br
5af0: 61 6e 63 68 20 70 61 72 65 6e 74 0a 09 09 41 4e  anch parent...AN
5b00: 44 20 20 20 20 52 2e 6c 6f 64 20 3d 20 50 2e 6c  D    R.lod = P.l
5b10: 6f 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 57  od          -- W
5b20: 68 69 63 68 20 69 6d 70 72 6f 70 65 72 6c 79 20  hich improperly 
5b30: 75 73 65 73 20 74 68 65 20 73 61 6d 65 20 4c 4f  uses the same LO
5b40: 44 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 72 65  D...;..    }..re
5b50: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
5b60: 70 72 6f 63 20 43 68 65 63 6b 20 7b 68 65 61 64  proc Check {head
5b70: 65 72 20 6c 61 62 65 6c 20 73 71 6c 7d 20 7b 0a  er label sql} {.
5b80: 09 75 70 76 61 72 20 31 20 6e 20 6e 0a 09 73 65  .upvar 1 n n..se
5b90: 74 20 6f 6b 20 31 0a 09 66 6f 72 65 61 63 68 20  t ok 1..foreach 
5ba0: 7b 66 6e 61 6d 65 20 72 65 76 6e 72 7d 20 5b 73  {fname revnr} [s
5bb0: 74 61 74 65 20 72 75 6e 20 24 73 71 6c 5d 20 7b  tate run $sql] {
5bc0: 0a 09 20 20 20 20 73 65 74 20 6f 6b 20 30 0a 09  ..    set ok 0..
5bd0: 20 20 20 20 74 72 6f 75 62 6c 65 20 66 61 74 61      trouble fata
5be0: 6c 20 22 24 66 6e 61 6d 65 20 3c 24 72 65 76 6e  l "$fname <$revn
5bf0: 72 3e 20 24 6c 61 62 65 6c 22 0a 09 7d 0a 09 6c  r> $label"..}..l
5c00: 6f 67 20 77 72 69 74 65 20 35 20 63 6f 6c 6c 72  og write 5 collr
5c10: 65 76 20 22 5c 5b 5b 66 6f 72 6d 61 74 20 25 30  ev "\[[format %0
5c20: 32 64 20 5b 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b  2d [incr n]]\] [
5c30: 65 78 70 72 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20  expr {$ok ? "Ok 
5c40: 20 20 20 22 20 3a 20 22 46 61 69 6c 65 64 22 7d     " : "Failed"}
5c50: 5d 20 2e 2e 2e 20 24 68 65 61 64 65 72 22 0a 09  ] ... $header"..
5c60: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
5c70: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
5c80: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
5c90: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
5ca0: 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68 6f 64   Internal method
5cb0: 73 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23  s..    # # ## ##
5cc0: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
5cd0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
5ce0: 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74     ## Configurat
5cf0: 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20  ion..    pragma 
5d00: 2d 68 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20  -hasinstances   
5d10: 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e  no ; # singleton
5d20: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73  .    pragma -has
5d30: 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b  typeinfo    no ;
5d40: 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74   # no introspect
5d50: 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d  ion.    pragma -
5d60: 68 61 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e  hastypedestroy n
5d70: 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 0a  o ; # immortal..
5d80: 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23      # # ## ### #
5d90: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
5da0: 23 23 23 23 23 23 23 23 23 23 23 0a 7d 0a 0a 6e  ###########.}..n
5db0: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a  amespace eval ::
5dc0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
5dd0: 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20 7b 0a  rt::cvs::pass {.
5de0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78      namespace ex
5df0: 70 6f 72 74 20 63 6f 6c 6c 72 65 76 0a 20 20 20  port collrev.   
5e00: 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20   namespace eval 
5e10: 63 6f 6c 6c 72 65 76 20 7b 0a 09 6e 61 6d 65 73  collrev {..names
5e20: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
5e30: 3a 3a 72 63 73 3a 3a 70 61 72 73 65 72 0a 09 6e  ::rcs::parser..n
5e40: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
5e50: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
5e60: 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70 6f 73  port::cvs::repos
5e70: 69 74 6f 72 79 0a 09 6e 61 6d 65 73 70 61 63 65  itory..namespace
5e80: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f   import ::vc::fo
5e90: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
5ea0: 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65 73 70  s::state..namesp
5eb0: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
5ec0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
5ed0: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a  :cvs::integrity.
5ee0: 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
5ef0: 70 72 6f 6a 65 63 74 20 7b 0a 09 20 20 20 20 6e  project {..    n
5f00: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
5f10: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
5f20: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65  port::cvs::proje
5f30: 63 74 3a 3a 73 79 6d 0a 09 7d 0a 09 6e 61 6d 65  ct::sym..}..name
5f40: 73 70 61 63 65 20 65 76 61 6c 20 66 69 6c 65 20  space eval file 
5f50: 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65  {..    namespace
5f60: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f   import ::vc::fo
5f70: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
5f80: 73 3a 3a 66 69 6c 65 3a 3a 72 65 76 0a 09 7d 0a  s::file::rev..}.
5f90: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
5fa0: 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74  t ::vc::tools::t
5fb0: 72 6f 75 62 6c 65 0a 09 6e 61 6d 65 73 70 61 63  rouble..namespac
5fc0: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74  e import ::vc::t
5fd0: 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72  ools::log..log r
5fe0: 65 67 69 73 74 65 72 20 63 6f 6c 6c 72 65 76 0a  egister collrev.
5ff0: 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20      }.}..# # ## 
6000: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
6010: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
6020: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23   ###############
6030: 23 23 23 23 23 23 0a 23 23 20 52 65 61 64 79 0a  ######.## Ready.
6040: 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 69 64 65  .package provide
6050: 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70   vc::fossil::imp
6060: 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a  ort::cvs::pass::
6070: 63 6f 6c 6c 72 65 76 20 31 2e 30 0a 72 65 74 75  collrev 1.0.retu
6080: 72 6e 0a                                         rn.