Hex Artifact Content
Not logged in

Artifact 531ee2ff11b159d84be1ca08a4afb69a438fd43c:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [79c227a9c0] - Bugfix. Handle free-floating branches (their root revision was removed as unnecessary). by aku on 2007-12-01 18:36:26.

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 72 65 61 64 69 6e 67 20 70 72  state reading pr
0840: 6f 6a 65 63 74 0a 09 73 74 61 74 65 20 72 65 61  oject..state rea
0850: 64 69 6e 67 20 66 69 6c 65 0a 0a 09 23 20 57 65  ding file...# We
0860: 20 64 65 61 6c 20 77 69 74 68 20 70 65 72 20 70   deal with per p
0870: 72 6f 6a 65 63 74 20 61 6e 64 20 70 65 72 20 66  roject and per f
0880: 69 6c 65 20 64 61 74 61 2c 20 74 68 65 20 66 69  ile data, the fi
0890: 72 73 74 0a 09 23 20 63 6f 6c 6c 61 74 65 64 20  rst..# collated 
08a0: 66 72 6f 6d 20 74 68 65 20 73 65 63 6f 6e 64 2e  from the second.
08b0: 0a 0a 09 23 20 50 65 72 20 66 69 6c 65 20 77 65  ...# Per file we
08c0: 20 68 61 76 65 20 67 65 6e 65 72 61 6c 20 69 6e   have general in
08d0: 66 6f 72 6d 61 74 69 6f 6e 2c 20 2e 2e 2e 2c 20  formation, ..., 
08e0: 61 6e 64 20 74 68 65 6e 0a 09 23 20 72 65 76 69  and then..# revi
08f0: 73 69 6f 6e 73 20 61 6e 64 20 73 79 6d 62 6f 6c  sions and symbol
0900: 73 2e 20 54 68 65 20 6c 61 74 74 65 72 20 63 61  s. The latter ca
0910: 6e 20 62 65 20 66 75 72 74 68 65 72 20 73 65 70  n be further sep
0920: 61 72 61 74 65 64 0a 09 23 20 69 6e 74 6f 20 74  arated..# into t
0930: 61 67 73 20 61 6e 64 20 62 72 61 6e 63 68 65 73  ags and branches
0940: 2e 20 41 74 20 70 72 6f 6a 65 63 74 20 6c 65 76  . At project lev
0950: 65 6c 20 74 68 65 20 70 65 72 2d 66 69 6c 65 0a  el the per-file.
0960: 09 23 20 73 79 6d 62 6f 6c 73 20 69 6e 66 6f 72  .# symbols infor
0970: 6d 61 74 69 6f 6e 20 69 73 20 6d 65 72 67 65 64  mation is merged
0980: 2e 0a 0a 09 23 20 46 69 6c 65 20 6c 65 76 65 6c  ....# File level
0990: 20 2e 2e 2e 0a 09 23 09 52 65 76 69 73 69 6f 6e   .....#.Revision
09a0: 73 2c 20 42 72 61 6e 63 68 65 73 2c 20 54 61 67  s, Branches, Tag
09b0: 73 0a 09 23 0a 09 23 20 50 73 65 75 64 6f 20 63  s..#..# Pseudo c
09c0: 6c 61 73 73 20 68 69 65 72 61 72 63 68 79 0a 09  lass hierarchy..
09d0: 23 09 54 61 67 20 20 20 20 20 20 3c 2d 20 53 79  #.Tag      <- Sy
09e0: 6d 62 6f 6c 20 3c 2d 20 45 76 65 6e 74 0a 09 23  mbol <- Event..#
09f0: 09 42 72 61 6e 63 68 20 20 20 3c 2d 20 53 79 6d  .Branch   <- Sym
0a00: 62 6f 6c 20 3c 2d 20 45 76 65 6e 74 0a 09 23 09  bol <- Event..#.
0a10: 52 65 76 69 73 69 6f 6e 20 20 20 20 20 20 20 20  Revision        
0a20: 20 20 20 3c 2d 20 45 76 65 6e 74 0a 0a 09 73 74     <- Event...st
0a30: 61 74 65 20 77 72 69 74 69 6e 67 20 72 65 76 69  ate writing revi
0a40: 73 69 6f 6e 20 7b 0a 09 20 20 20 20 2d 2d 20 52  sion {..    -- R
0a50: 65 76 69 73 69 6f 6e 73 2e 20 49 64 65 6e 74 69  evisions. Identi
0a60: 66 69 65 64 20 62 79 20 61 20 67 6c 6f 62 61 6c  fied by a global
0a70: 20 6e 75 6d 65 72 69 63 20 69 64 20 65 61 63 68   numeric id each
0a80: 0a 09 20 20 20 20 2d 2d 20 62 65 6c 6f 6e 67 73  ..    -- belongs
0a90: 20 74 6f 20 61 20 73 69 6e 67 6c 65 20 66 69 6c   to a single fil
0aa0: 65 2c 20 69 64 65 6e 74 69 66 69 65 64 20 62 79  e, identified by
0ab0: 20 69 74 73 20 69 64 2e 20 49 74 0a 09 20 20 20   its id. It..   
0ac0: 20 2d 2d 20 66 75 72 74 68 65 72 20 68 61 73 20   -- further has 
0ad0: 61 20 64 6f 74 74 65 64 20 72 65 76 69 73 69 6f  a dotted revisio
0ae0: 6e 20 6e 75 6d 62 65 72 20 28 44 54 4e 29 2e 0a  n number (DTN)..
0af0: 09 20 20 20 20 2d 2d 0a 09 20 20 20 20 2d 2d 20  .    --..    -- 
0b00: 43 6f 6e 73 74 72 61 69 6e 74 3a 20 54 68 65 20  Constraint: The 
0b10: 64 6f 74 74 65 64 20 72 65 76 69 73 69 6f 6e 20  dotted revision 
0b20: 6e 75 6d 62 65 72 20 69 73 20 75 6e 69 71 75 65  number is unique
0b30: 20 77 69 74 68 69 6e 0a 20 20 20 20 20 20 20 20   within.        
0b40: 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20      --          
0b50: 20 20 20 74 68 65 20 66 69 6c 65 2e 20 53 65 65     the file. See
0b60: 20 65 6e 64 20 6f 66 20 64 65 66 69 6e 69 74 69   end of definiti
0b70: 6f 6e 2e 0a 0a 09 20 20 20 20 72 69 64 20 20 49  on....    rid  I
0b80: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
0b90: 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41 55    PRIMARY KEY AU
0ba0: 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20  TOINCREMENT,..  
0bb0: 20 20 66 69 64 20 20 49 4e 54 45 47 45 52 20 20    fid  INTEGER  
0bc0: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
0bd0: 4e 43 45 53 20 66 69 6c 65 2c 20 20 20 2d 2d 20  NCES file,   -- 
0be0: 46 69 6c 65 20 6f 77 6e 69 6e 67 20 72 65 76 69  File owning revi
0bf0: 73 69 6f 6e 2e 0a 09 20 20 20 20 72 65 76 20 20  sion...    rev  
0c00: 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c  TEXT     NOT NUL
0c10: 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20  L,              
0c20: 20 20 20 20 20 20 2d 2d 20 44 6f 74 74 65 64 20        -- Dotted 
0c30: 52 65 76 20 4e 75 6d 62 65 72 2e 0a 0a 09 20 20  Rev Number....  
0c40: 20 20 2d 2d 20 41 6c 6c 20 72 65 76 69 73 69 6f    -- All revisio
0c50: 6e 73 20 62 65 6c 6f 6e 67 20 74 6f 20 61 20 6c  ns belong to a l
0c60: 69 6e 65 2d 6f 66 2d 64 65 76 65 6c 6f 70 6d 65  ine-of-developme
0c70: 6e 74 2c 0a 09 20 20 20 20 2d 2d 20 69 64 65 6e  nt,..    -- iden
0c80: 74 69 66 69 65 64 20 62 79 20 61 20 73 79 6d 62  tified by a symb
0c90: 6f 6c 20 28 70 72 6f 6a 65 63 74 20 6c 65 76 65  ol (project leve
0ca0: 6c 29 2e 20 44 75 72 69 6e 67 20 64 61 74 61 0a  l). During data.
0cb0: 09 20 20 20 20 2d 2d 20 63 6f 6c 6c 65 63 74 69  .    -- collecti
0cc0: 6f 6e 20 69 74 20 77 61 73 20 61 20 66 69 6c 65  on it was a file
0cd0: 2d 6c 65 76 65 6c 20 62 72 61 6e 63 68 20 73 79  -level branch sy
0ce0: 6d 62 6f 6c 2e 0a 09 20 20 20 20 2d 2d 0a 09 20  mbol...    --.. 
0cf0: 20 20 20 2d 2d 20 43 6f 6e 73 74 72 61 69 6e 74     -- Constraint
0d00: 3a 20 41 6c 6c 20 74 68 65 20 4c 4f 44 20 73 79  : All the LOD sy
0d10: 6d 62 6f 6c 73 20 61 72 65 20 69 6e 20 74 68 65  mbols are in the
0d20: 20 73 61 6d 65 20 70 72 6f 6a 65 63 74 0a 09 20   same project.. 
0d30: 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20     --           
0d40: 20 20 61 73 20 74 68 65 20 66 69 6c 65 20 69 74    as the file it
0d50: 73 65 6c 66 2e 20 54 68 69 73 20 63 61 6e 6e 6f  self. This canno
0d60: 74 20 62 65 0a 09 20 20 20 20 2d 2d 20 20 20 20  t be..    --    
0d70: 20 20 20 20 20 20 20 20 20 65 78 70 72 65 73 73           express
0d80: 65 64 20 69 6e 20 43 52 45 41 54 45 20 54 41 42  ed in CREATE TAB
0d90: 4c 45 20 73 79 6e 74 61 78 2e 0a 0a 09 20 20 20  LE syntax....   
0da0: 20 6c 6f 64 20 20 49 4e 54 45 47 45 52 20 20 4e   lod  INTEGER  N
0db0: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
0dc0: 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20 4c  CES symbol, -- L
0dd0: 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65  ine of developme
0de0: 6e 74 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65 20  nt...    -- The 
0df0: 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 61 20 66  revisions in a f
0e00: 69 6c 65 20 61 72 65 20 6f 72 67 61 6e 69 7a 65  ile are organize
0e10: 64 20 69 6e 20 61 20 66 6f 72 65 73 74 20 6f 66  d in a forest of
0e20: 0a 09 20 20 20 20 2d 2d 20 74 72 65 65 73 2c 20  ..    -- trees, 
0e30: 77 69 74 68 20 74 68 65 20 6d 61 69 6e 20 6c 69  with the main li
0e40: 6e 65 73 20 64 65 66 69 6e 65 64 20 74 68 72 6f  nes defined thro
0e50: 75 67 68 20 74 68 65 20 70 61 72 65 6e 74 20 2f  ugh the parent /
0e60: 0a 09 20 20 20 20 2d 2d 20 63 68 69 6c 64 20 72  ..    -- child r
0e70: 65 66 65 72 65 6e 63 65 73 2e 20 41 20 72 65 76  eferences. A rev
0e80: 69 73 69 6f 6e 20 77 69 74 68 6f 75 74 20 61 20  ision without a 
0e90: 70 61 72 65 6e 74 20 69 73 20 74 68 65 0a 09 20  parent is the.. 
0ea0: 20 20 20 2d 2d 20 72 6f 6f 74 20 6f 66 20 61 20     -- root of a 
0eb0: 74 72 65 65 2c 20 61 6e 64 20 61 20 72 65 76 69  tree, and a revi
0ec0: 73 69 6f 6e 20 77 69 74 68 6f 75 74 20 61 20 63  sion without a c
0ed0: 68 69 6c 64 20 69 73 20 61 0a 09 20 20 20 20 2d  hild is a..    -
0ee0: 2d 20 6c 65 61 66 2e 0a 0a 09 20 20 20 20 2d 2d  - leaf....    --
0ef0: 20 43 6f 6e 73 74 72 61 69 6e 74 73 3a 20 41 6c   Constraints: Al
0f00: 6c 20 72 65 76 69 73 69 6f 6e 73 20 63 6f 75 70  l revisions coup
0f10: 6c 65 64 20 74 68 72 6f 75 67 68 20 70 61 72 65  led through pare
0f20: 6e 74 2f 63 68 69 6c 64 0a 09 20 20 20 20 2d 2d  nt/child..    --
0f30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65                re
0f40: 66 65 72 20 74 6f 20 74 68 65 20 73 61 6d 65 20  fer to the same 
0f50: 4c 4f 44 20 73 79 6d 62 6f 6c 2e 20 54 68 65 20  LOD symbol. The 
0f60: 70 61 72 65 6e 74 0a 09 20 20 20 20 2d 2d 20 20  parent..    --  
0f70: 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 20 61              of a
0f80: 20 63 68 69 6c 64 20 6f 66 20 58 20 69 73 20 58   child of X is X
0f90: 2e 20 54 68 65 20 63 68 69 6c 64 20 6f 66 20 61  . The child of a
0fa0: 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20  ..    --        
0fb0: 20 20 20 20 20 20 70 61 72 65 6e 74 20 6f 66 20        parent of 
0fc0: 58 20 69 73 20 58 2e 0a 0a 09 20 20 20 20 70 61  X is X....    pa
0fd0: 72 65 6e 74 20 20 49 4e 54 45 47 45 52 20 20 20  rent  INTEGER   
0fe0: 20 20 20 20 20 20 20 20 20 52 45 46 45 52 45 4e           REFEREN
0ff0: 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20  CES revision,.. 
1000: 20 20 20 63 68 69 6c 64 20 20 20 49 4e 54 45 47     child   INTEG
1010: 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52 45  ER            RE
1020: 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f  FERENCES revisio
1030: 6e 2c 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65 20  n,...    -- The 
1040: 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 20 6f  representation o
1050: 66 20 61 20 62 72 61 6e 63 68 20 69 6e 20 61 20  f a branch in a 
1060: 74 72 65 65 20 69 73 20 74 68 65 0a 09 20 20 20  tree is the..   
1070: 20 2d 2d 20 65 78 63 65 70 74 69 6f 6e 20 74 6f   -- exception to
1080: 20 74 68 65 20 74 68 72 65 65 20 63 6f 6e 73 74   the three const
1090: 72 61 69 6e 74 73 20 61 62 6f 76 65 2e 0a 0a 09  raints above....
10a0: 20 20 20 20 2d 2d 20 54 68 65 20 62 65 67 69 6e      -- The begin
10b0: 6e 69 6e 67 20 6f 66 20 61 20 62 72 61 6e 63 68  ning of a branch
10c0: 20 69 73 20 72 65 70 72 65 73 65 6e 74 65 64 20   is represented 
10d0: 62 79 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 0a 09 20  by a non-NULL.. 
10e0: 20 20 20 2d 2d 20 62 70 61 72 65 6e 74 20 6f 66     -- bparent of
10f0: 20 61 20 72 65 76 69 73 69 6f 6e 2e 20 54 68 69   a revision. Thi
1100: 73 20 72 65 76 69 73 69 6f 6e 20 42 20 69 73 20  s revision B is 
1110: 74 68 65 20 66 69 72 73 74 20 6f 6e 0a 09 20 20  the first on..  
1120: 20 20 2d 2d 20 74 68 65 20 62 72 61 6e 63 68 2e    -- the branch.
1130: 20 49 74 73 20 70 61 72 65 6e 74 20 50 20 69 73   Its parent P is
1140: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 74 68   the revision th
1150: 65 20 62 72 61 6e 63 68 20 69 73 0a 09 20 20 20  e branch is..   
1160: 20 2d 2d 20 72 6f 6f 74 65 64 20 69 6e 2c 20 61   -- rooted in, a
1170: 6e 64 20 69 74 20 69 73 20 6e 6f 74 20 74 68 65  nd it is not the
1180: 20 63 68 69 6c 64 20 6f 66 20 50 2e 20 42 20 61   child of P. B a
1190: 6e 64 20 50 20 72 65 66 65 72 0a 09 20 20 20 20  nd P refer..    
11a0: 2d 2d 20 74 6f 20 64 69 66 66 65 72 65 6e 74 20  -- to different 
11b0: 4c 4f 44 20 73 79 6d 62 6f 6c 73 2e 20 54 68 65  LOD symbols. The
11c0: 20 62 70 61 72 65 6e 74 20 6f 66 20 42 20 69 73   bparent of B is
11d0: 20 61 6c 73 6f 20 69 74 73 0a 09 20 20 20 20 2d   also its..    -
11e0: 2d 20 4c 4f 44 2c 20 61 6e 64 20 74 68 65 20 4c  - LOD, and the L
11f0: 4f 44 20 6f 66 20 69 74 73 20 63 68 69 6c 64 72  OD of its childr
1200: 65 6e 2e 0a 0a 09 20 20 20 20 62 70 61 72 65 6e  en....    bparen
1210: 74 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20  t INTEGER       
1220: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
1230: 73 79 6d 62 6f 6c 2c 0a 0a 09 20 20 20 20 2d 2d  symbol,...    --
1240: 20 4c 61 73 74 6c 79 20 77 65 20 6b 65 65 70 20   Lastly we keep 
1250: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 61  information is a
1260: 62 6f 75 74 20 6e 6f 6e 2d 74 72 75 6e 6b 20 64  bout non-trunk d
1270: 65 66 61 75 6c 74 0a 09 20 20 20 20 2d 2d 20 62  efault..    -- b
1280: 72 61 6e 63 68 65 73 20 28 4e 54 44 42 29 20 69  ranches (NTDB) i
1290: 6e 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 2e  n the revisions.
12a0: 0a 0a 09 20 20 20 20 2d 2d 20 41 6c 6c 20 72 65  ...    -- All re
12b0: 76 69 73 69 6f 6e 73 20 6f 6e 20 74 68 65 20 4e  visions on the N
12c0: 54 44 42 20 68 61 76 65 20 27 69 73 64 65 66 61  TDB have 'isdefa
12d0: 75 6c 74 27 20 54 52 55 45 2c 0a 09 20 20 20 20  ult' TRUE,..    
12e0: 2d 2d 20 65 76 65 72 79 6f 6e 65 20 65 6c 73 65  -- everyone else
12f0: 20 46 41 4c 53 45 2e 20 54 68 65 20 6c 61 73 74   FALSE. The last
1300: 20 72 65 76 69 73 69 6f 6e 20 58 20 6f 6e 20 74   revision X on t
1310: 68 65 20 4e 54 44 42 0a 09 20 20 20 20 2d 2d 20  he NTDB..    -- 
1320: 77 68 69 63 68 20 69 73 20 73 74 69 6c 6c 20 63  which is still c
1330: 6f 6e 73 69 64 65 72 65 64 20 74 6f 20 62 65 20  onsidered to be 
1340: 6f 6e 20 74 68 65 20 74 72 75 6e 6b 20 61 73 20  on the trunk as 
1350: 77 65 6c 6c 0a 09 20 20 20 20 2d 2d 20 68 61 73  well..    -- has
1360: 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 20 27 64 62 63   a non-NULL 'dbc
1370: 68 69 6c 64 27 20 77 68 69 63 68 20 72 65 66 65  hild' which refe
1380: 72 73 20 74 6f 20 74 68 65 20 72 6f 6f 74 20 6f  rs to the root o
1390: 66 0a 09 20 20 20 20 2d 2d 20 74 68 65 20 74 72  f..    -- the tr
13a0: 75 6e 6b 2e 20 54 68 65 20 72 6f 6f 74 20 61 6c  unk. The root al
13b0: 73 6f 20 68 61 73 20 61 20 6e 6f 6e 2d 4e 55 4c  so has a non-NUL
13c0: 4c 20 64 62 70 61 72 65 6e 74 0a 09 20 20 20 20  L dbparent..    
13d0: 2d 2d 20 72 65 66 65 72 69 6e 67 20 74 6f 20 58  -- refering to X
13e0: 2e 0a 0a 09 20 20 20 20 69 73 64 65 66 61 75 6c  ....    isdefaul
13f0: 74 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e  t INTEGER  NOT N
1400: 55 4c 4c 2c 0a 09 20 20 20 20 64 62 70 61 72 65  ULL,..    dbpare
1410: 6e 74 20 20 49 4e 54 45 47 45 52 20 20 20 20 20  nt  INTEGER     
1420: 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45         REFERENCE
1430: 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20 20  S revision,..   
1440: 20 64 62 63 68 69 6c 64 20 20 20 49 4e 54 45 47   dbchild   INTEG
1450: 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52 45  ER            RE
1460: 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f  FERENCES revisio
1470: 6e 2c 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65 20  n,...    -- The 
1480: 6d 61 69 6e 20 70 61 79 6c 6f 61 64 20 6f 66 20  main payload of 
1490: 74 68 65 20 72 65 76 69 73 69 6f 6e 20 61 72 65  the revision are
14a0: 20 74 68 65 20 64 61 74 65 2f 74 69 6d 65 20 69   the date/time i
14b0: 74 0a 09 20 20 20 20 2d 2d 20 77 61 73 20 65 6e  t..    -- was en
14c0: 74 65 72 65 64 2c 20 69 74 73 20 73 74 61 74 65  tered, its state
14d0: 2c 20 6f 70 65 72 61 74 69 6f 6e 20 28 3d 20 74  , operation (= t
14e0: 79 70 65 2f 63 6c 61 73 73 29 2c 20 74 65 78 74  ype/class), text
14f0: 0a 09 20 20 20 20 2d 2d 20 63 6f 6e 74 65 6e 74  ..    -- content
1500: 2c 20 61 6e 64 20 6d 65 74 61 20 64 61 74 61 20  , and meta data 
1510: 28 61 75 74 68 6f 72 2c 20 6c 6f 67 20 6d 65 73  (author, log mes
1520: 73 61 67 65 2c 20 62 72 61 6e 63 68 2c 0a 09 20  sage, branch,.. 
1530: 20 20 20 2d 2d 20 70 72 6f 6a 65 63 74 29 2e 20     -- project). 
1540: 54 68 65 20 6c 61 73 74 20 69 73 20 65 6e 63 6f  The last is enco
1550: 64 65 64 20 61 73 20 73 69 6e 67 6c 65 20 69 64  ded as single id
1560: 2c 20 73 65 65 20 74 61 62 6c 65 0a 09 20 20 20  , see table..   
1570: 20 2d 2d 20 27 6d 65 74 61 27 2e 20 54 68 65 20   -- 'meta'. The 
1580: 64 61 74 65 2f 74 69 6d 65 20 69 73 20 67 69 76  date/time is giv
1590: 65 6e 20 69 6e 20 73 65 63 6f 6e 64 73 20 73 69  en in seconds si
15a0: 6e 63 65 20 74 68 65 0a 09 20 20 20 20 2d 2d 20  nce the..    -- 
15b0: 65 70 6f 63 68 2c 20 66 6f 72 20 65 61 73 79 20  epoch, for easy 
15c0: 63 6f 6d 70 61 72 69 73 6f 6e 2e 20 54 68 65 20  comparison. The 
15d0: 74 65 78 74 20 63 6f 6e 74 65 6e 74 20 69 73 20  text content is 
15e0: 61 6e 0a 09 20 20 20 20 2d 2d 20 28 6f 66 66 73  an..    -- (offs
15f0: 65 74 2c 6c 65 6e 67 74 68 29 20 70 61 69 72 20  et,length) pair 
1600: 69 6e 74 6f 20 74 68 65 20 72 63 73 20 61 72 63  into the rcs arc
1610: 68 69 76 65 2e 0a 0a 09 20 20 20 20 6f 70 20 20  hive....    op  
1620: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
1630: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
1640: 6f 70 74 79 70 65 2c 0a 09 20 20 20 20 64 61 74  optype,..    dat
1650: 65 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  e  INTEGER  NOT 
1660: 4e 55 4c 4c 2c 0a 09 20 20 20 20 73 74 61 74 65  NULL,..    state
1670: 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55   TEXT     NOT NU
1680: 4c 4c 2c 0a 09 20 20 20 20 6d 69 64 20 20 20 49  LL,..    mid   I
1690: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
16a0: 20 20 52 45 46 45 52 45 4e 43 45 53 20 6d 65 74    REFERENCES met
16b0: 61 2c 0a 09 20 20 20 20 63 6f 66 66 20 20 49 4e  a,..    coff  IN
16c0: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c  TEGER  NOT NULL,
16d0: 0a 09 20 20 20 20 63 6c 65 6e 20 20 49 4e 54 45  ..    clen  INTE
16e0: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 0a  GER  NOT NULL,..
16f0: 09 20 20 20 20 55 4e 49 51 55 45 20 28 66 69 64  .    UNIQUE (fid
1700: 2c 20 72 65 76 29 20 2d 2d 20 54 68 65 20 44 54  , rev) -- The DT
1710: 4e 20 69 73 20 75 6e 69 71 75 65 20 77 69 74 68  N is unique with
1720: 69 6e 20 74 68 65 20 72 65 76 69 73 69 6f 6e 27  in the revision'
1730: 73 20 66 69 6c 65 2e 0a 09 7d 0a 0a 09 73 74 61  s file...}...sta
1740: 74 65 20 77 72 69 74 69 6e 67 20 6f 70 74 79 70  te writing optyp
1750: 65 20 7b 0a 09 20 20 20 20 6f 69 64 20 20 20 49  e {..    oid   I
1760: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1770: 20 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 0a 09    PRIMARY KEY,..
1780: 20 20 20 20 6e 61 6d 65 20 20 54 45 58 54 20 20      name  TEXT  
1790: 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20     NOT NULL,..  
17a0: 20 20 55 4e 49 51 55 45 28 6e 61 6d 65 29 0a 09    UNIQUE(name)..
17b0: 7d 0a 09 73 74 61 74 65 20 72 75 6e 20 7b 0a 09  }..state run {..
17c0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
17d0: 6f 70 74 79 70 65 20 56 41 4c 55 45 53 20 28 2d  optype VALUES (-
17e0: 31 2c 27 64 65 6c 65 74 65 27 29 3b 20 20 2d 2d  1,'delete');  --
17f0: 20 54 68 65 20 6f 70 63 6f 64 65 20 6e 61 6d 65   The opcode name
1800: 73 20 61 72 65 20 74 68 65 0a 09 20 20 20 20 49  s are the..    I
1810: 4e 53 45 52 54 20 49 4e 54 4f 20 6f 70 74 79 70  NSERT INTO optyp
1820: 65 20 56 41 4c 55 45 53 20 28 20 30 2c 27 6e 6f  e VALUES ( 0,'no
1830: 74 68 69 6e 67 27 29 3b 20 2d 2d 20 66 69 78 65  thing'); -- fixe
1840: 64 20 70 69 65 63 65 73 2c 20 73 65 65 20 6d 79  d pieces, see my
1850: 6f 70 73 74 61 74 65 0a 09 20 20 20 20 49 4e 53  opstate..    INS
1860: 45 52 54 20 49 4e 54 4f 20 6f 70 74 79 70 65 20  ERT INTO optype 
1870: 56 41 4c 55 45 53 20 28 20 31 2c 27 61 64 64 27  VALUES ( 1,'add'
1880: 29 3b 20 20 20 20 20 2d 2d 20 69 6e 20 66 69 6c  );     -- in fil
1890: 65 3a 3a 72 65 76 2e 20 6d 79 6f 70 63 6f 64 65  e::rev. myopcode
18a0: 20 69 73 0a 09 20 20 20 20 49 4e 53 45 52 54 20   is..    INSERT 
18b0: 49 4e 54 4f 20 6f 70 74 79 70 65 20 56 41 4c 55  INTO optype VALU
18c0: 45 53 20 28 20 32 2c 27 63 68 61 6e 67 65 27 29  ES ( 2,'change')
18d0: 3b 20 20 2d 2d 20 6c 6f 61 64 65 64 20 66 72 6f  ;  -- loaded fro
18e0: 6d 20 74 68 69 73 2e 0a 09 7d 0a 0a 09 73 74 61  m this...}...sta
18f0: 74 65 20 77 72 69 74 69 6e 67 20 72 65 76 69 73  te writing revis
1900: 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65  ionbranchchildre
1910: 6e 20 7b 0a 09 20 20 20 20 2d 2d 20 54 68 65 20  n {..    -- The 
1920: 6e 6f 6e 2d 70 72 69 6d 61 72 79 20 63 68 69 6c  non-primary chil
1930: 64 72 65 6e 20 6f 66 20 61 20 72 65 76 69 73 69  dren of a revisi
1940: 6f 6e 2c 20 61 73 20 72 65 61 63 68 61 62 6c 65  on, as reachable
1950: 0a 09 20 20 20 20 2d 2d 20 74 68 72 6f 75 67 68  ..    -- through
1960: 20 61 20 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c   a branch symbol
1970: 2c 20 61 72 65 20 6c 69 73 74 65 64 20 68 65 72  , are listed her
1980: 65 2e 20 54 68 69 73 20 69 73 0a 09 20 20 20 20  e. This is..    
1990: 2d 2d 20 6e 65 65 64 65 64 20 62 79 20 70 61 73  -- needed by pas
19a0: 73 20 35 20 74 6f 20 62 72 65 61 6b 20 69 6e 74  s 5 to break int
19b0: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
19c0: 65 73 20 69 6e 20 61 0a 09 20 20 20 20 2d 2d 20  es in a..    -- 
19d0: 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 20 20 20  changeset....   
19e0: 20 72 69 64 20 20 20 49 4e 54 45 47 45 52 20 20   rid   INTEGER  
19f0: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
1a00: 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09  NCES revision,..
1a10: 20 20 20 20 62 72 69 64 20 20 49 4e 54 45 47 45      brid  INTEGE
1a20: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1a30: 45 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e  ERENCES revision
1a40: 2c 0a 09 20 20 20 20 55 4e 49 51 55 45 28 72 69  ,..    UNIQUE(ri
1a50: 64 2c 62 72 69 64 29 0a 09 7d 0a 0a 09 73 74 61  d,brid)..}...sta
1a60: 74 65 20 77 72 69 74 69 6e 67 20 74 61 67 20 7b  te writing tag {
1a70: 0a 09 20 20 20 20 74 69 64 20 20 49 4e 54 45 47  ..    tid  INTEG
1a80: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52  ER  NOT NULL  PR
1a90: 49 4d 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e  IMARY KEY AUTOIN
1aa0: 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 66 69  CREMENT,..    fi
1ab0: 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  d  INTEGER  NOT 
1ac0: 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53  NULL  REFERENCES
1ad0: 20 66 69 6c 65 2c 20 20 20 20 20 2d 2d 20 46 69   file,     -- Fi
1ae0: 6c 65 20 74 68 65 20 69 74 65 6d 20 62 65 6c 6f  le the item belo
1af0: 6e 67 73 20 74 6f 0a 09 20 20 20 20 6c 6f 64 20  ngs to..    lod 
1b00: 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20   INTEGER        
1b10: 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20 73      REFERENCES s
1b20: 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20 4c 69 6e 65  ymbol,   -- Line
1b30: 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20   of development 
1b40: 28 4e 55 4c 4c 20 3d 3e 20 54 72 75 6e 6b 29 0a  (NULL => Trunk).
1b50: 09 20 20 20 20 73 69 64 20 20 49 4e 54 45 47 45  .    sid  INTEGE
1b60: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1b70: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
1b80: 20 20 2d 2d 20 53 79 6d 62 6f 6c 20 63 61 70 74    -- Symbol capt
1b90: 75 72 69 6e 67 20 74 68 65 20 74 61 67 0a 0a 09  uring the tag...
1ba0: 20 20 20 20 72 65 76 20 20 49 4e 54 45 47 45 52      rev  INTEGER
1bb0: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
1bc0: 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 20  RENCES revision 
1bd0: 20 2d 2d 20 54 68 65 20 72 65 76 69 73 69 6f 6e   -- The revision
1be0: 20 62 65 69 6e 67 20 74 61 67 67 65 64 2e 0a 09   being tagged...
1bf0: 7d 0a 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e  }...state writin
1c00: 67 20 62 72 61 6e 63 68 20 7b 0a 09 20 20 20 20  g branch {..    
1c10: 62 69 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e  bid   INTEGER  N
1c20: 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59  OT NULL  PRIMARY
1c30: 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45   KEY AUTOINCREME
1c40: 4e 54 2c 0a 09 20 20 20 20 66 69 64 20 20 20 49  NT,..    fid   I
1c50: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1c60: 20 20 52 45 46 45 52 45 4e 43 45 53 20 66 69 6c    REFERENCES fil
1c70: 65 2c 20 20 20 20 20 2d 2d 20 46 69 6c 65 20 74  e,     -- File t
1c80: 68 65 20 69 74 65 6d 20 62 65 6c 6f 6e 67 73 20  he item belongs 
1c90: 74 6f 0a 09 20 20 20 20 6c 6f 64 20 20 20 49 4e  to..    lod   IN
1ca0: 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20  TEGER           
1cb0: 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62   REFERENCES symb
1cc0: 6f 6c 2c 20 20 20 2d 2d 20 4c 69 6e 65 20 6f 66  ol,   -- Line of
1cd0: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 28 4e 55   development (NU
1ce0: 4c 4c 20 3d 3e 20 54 72 75 6e 6b 29 0a 09 20 20  LL => Trunk)..  
1cf0: 20 20 73 69 64 20 20 20 49 4e 54 45 47 45 52 20    sid   INTEGER 
1d00: 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52   NOT NULL  REFER
1d10: 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 20 20  ENCES symbol,   
1d20: 2d 2d 20 53 79 6d 62 6f 6c 20 63 61 70 74 75 72  -- Symbol captur
1d30: 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68 0a 0a  ing the branch..
1d40: 09 20 20 20 20 72 6f 6f 74 20 20 49 4e 54 45 47  .    root  INTEG
1d50: 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52 45  ER            RE
1d60: 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f  FERENCES revisio
1d70: 6e 2c 20 2d 2d 20 52 65 76 69 73 69 6f 6e 20 74  n, -- Revision t
1d80: 68 65 20 62 72 61 6e 63 68 20 73 70 72 6f 75 74  he branch sprout
1d90: 73 20 66 72 6f 6d 0a 09 20 20 20 20 66 69 72 73  s from..    firs
1da0: 74 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20  t INTEGER       
1db0: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
1dc0: 72 65 76 69 73 69 6f 6e 2c 20 2d 2d 20 46 69 72  revision, -- Fir
1dd0: 73 74 20 72 65 76 69 73 69 6f 6e 20 63 6f 6d 6d  st revision comm
1de0: 69 74 74 65 64 20 74 6f 20 74 68 65 20 62 72 61  itted to the bra
1df0: 6e 63 68 0a 09 20 20 20 20 62 72 61 20 20 20 54  nch..    bra   T
1e00: 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c  EXT     NOT NULL
1e10: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,               
1e20: 20 20 20 20 20 20 20 2d 2d 20 62 72 61 6e 63 68         -- branch
1e30: 20 6e 75 6d 62 65 72 0a 09 20 20 20 20 70 6f 73   number..    pos
1e40: 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20     INTEGER  NOT 
1e50: 4e 55 4c 4c 20 20 20 20 20 20 20 20 20 20 20 20  NULL            
1e60: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 63 72             -- cr
1e70: 65 61 74 69 6f 6e 20 6f 72 64 65 72 20 69 6e 20  eation order in 
1e80: 72 6f 6f 74 2e 0a 0a 09 20 20 20 20 2d 2d 20 41  root....    -- A
1e90: 20 62 72 61 6e 63 68 20 63 61 6e 20 65 78 69 73   branch can exis
1ea0: 74 20 77 69 74 68 6f 75 74 20 72 6f 6f 74 2e 20  t without root. 
1eb0: 49 74 20 68 61 70 70 65 6e 73 20 77 68 65 6e 20  It happens when 
1ec0: 74 68 65 0a 20 20 20 20 20 20 20 20 20 20 20 20  the.            
1ed0: 2d 2d 20 6f 6e 6c 79 20 72 65 76 69 73 69 6f 6e  -- only revision
1ee0: 20 6f 6e 20 74 72 75 6e 6b 20 69 73 20 74 68 65   on trunk is the
1ef0: 20 75 6e 6e 65 63 65 73 73 61 72 79 20 64 65 61   unnecessary dea
1f00: 64 20 6f 6e 65 20 74 68 65 0a 20 20 20 20 20 20  d one the.      
1f10: 20 20 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 20        -- branch 
1f20: 77 61 73 20 73 70 72 6f 75 74 65 64 20 66 72 6f  was sprouted fro
1f30: 6d 20 61 6e 64 20 69 74 20 68 61 73 20 63 6f 6d  m and it has com
1f40: 6d 69 74 73 2e 20 54 68 65 20 62 72 61 6e 63 68  mits. The branch
1f50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20  .            -- 
1f60: 77 69 6c 6c 20 65 78 69 73 74 20 74 6f 20 62 65  will exist to be
1f70: 20 74 68 65 20 4c 4f 44 20 6f 66 20 69 74 73 20   the LOD of its 
1f80: 72 65 76 69 73 69 6f 6e 73 2c 20 6e 6f 74 68 69  revisions, nothi
1f90: 6e 67 20 74 6f 0a 20 20 20 20 20 20 20 20 20 20  ng to.          
1fa0: 20 20 2d 2d 20 73 70 72 6f 75 74 20 66 72 6f 6d    -- sprout from
1fb0: 2c 20 74 68 65 20 64 65 61 64 20 72 65 76 69 73  , the dead revis
1fc0: 69 6f 6e 20 77 61 73 20 72 65 6d 6f 76 65 64 2c  ion was removed,
1fd0: 20 68 65 6e 63 65 20 6e 6f 0a 20 20 20 20 20 20   hence no.      
1fe0: 20 20 20 20 20 20 2d 2d 20 72 6f 6f 74 2e 0a 09        -- root...
1ff0: 7d 0a 0a 09 23 20 50 72 6f 6a 65 63 74 20 6c 65  }...# Project le
2000: 76 65 6c 20 2e 2e 2e 0a 09 23 09 70 4c 69 6e 65  vel .....#.pLine
2010: 4f 66 44 65 76 65 6c 6f 70 6d 65 6e 74 2c 20 70  OfDevelopment, p
2020: 53 79 6d 62 6f 6c 2c 20 70 42 72 61 6e 63 68 2c  Symbol, pBranch,
2030: 20 70 54 61 67 2c 20 70 54 72 75 6e 6b 0a 09 23   pTag, pTrunk..#
2040: 0a 09 23 09 70 54 72 75 6e 6b 20 20 3c 2d 20 70  ..#.pTrunk  <- p
2050: 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d 65 6e  LineOfDevelopmen
2060: 74 0a 09 23 09 70 42 72 61 6e 63 68 20 3c 2d 20  t..#.pBranch <- 
2070: 70 53 79 6d 62 6f 6c 2c 20 70 4c 69 6e 65 4f 66  pSymbol, pLineOf
2080: 44 65 76 65 6c 6f 70 6d 65 6e 74 0a 09 23 09 70  Development..#.p
2090: 54 61 67 20 20 20 20 3c 2d 20 70 53 79 6d 62 6f  Tag    <- pSymbo
20a0: 6c 2c 20 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f  l, pLineOfDevelo
20b0: 70 6d 65 6e 74 0a 0a 09 73 74 61 74 65 20 77 72  pment...state wr
20c0: 69 74 69 6e 67 20 73 79 6d 62 6f 6c 20 7b 0a 09  iting symbol {..
20d0: 20 20 20 20 73 69 64 20 20 49 4e 54 45 47 45 52      sid  INTEGER
20e0: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d    NOT NULL  PRIM
20f0: 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43 52  ARY KEY AUTOINCR
2100: 45 4d 45 4e 54 2c 0a 09 20 20 20 20 70 69 64 20  EMENT,..    pid 
2110: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
2120: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 70  LL  REFERENCES p
2130: 72 6f 6a 65 63 74 2c 20 20 2d 2d 20 50 72 6f 6a  roject,  -- Proj
2140: 65 63 74 20 74 68 65 20 73 79 6d 62 6f 6c 20 62  ect the symbol b
2150: 65 6c 6f 6e 67 73 20 74 6f 0a 09 20 20 20 20 6e  elongs to..    n
2160: 61 6d 65 20 54 45 58 54 20 20 20 20 20 4e 4f 54  ame TEXT     NOT
2170: 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 74 79 70 65   NULL,..    type
2180: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
2190: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73  LL  REFERENCES s
21a0: 79 6d 74 79 70 65 2c 20 20 2d 2d 20 65 6e 75 6d  ymtype,  -- enum
21b0: 20 7b 20 65 78 63 6c 75 64 65 64 20 3d 20 30 2c   { excluded = 0,
21c0: 20 74 61 67 2c 20 62 72 61 6e 63 68 2c 20 75 6e   tag, branch, un
21d0: 64 65 66 69 6e 65 64 20 7d 0a 0a 09 20 20 20 20  defined }...    
21e0: 74 61 67 5f 63 6f 75 6e 74 20 20 20 20 49 4e 54  tag_count    INT
21f0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20  EGER  NOT NULL, 
2200: 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 74 68 65  -- How often the
2210: 20 73 79 6d 62 6f 6c 20 69 73 20 75 73 65 64 20   symbol is used 
2220: 61 73 20 74 61 67 2e 0a 09 20 20 20 20 62 72 61  as tag...    bra
2230: 6e 63 68 5f 63 6f 75 6e 74 20 49 4e 54 45 47 45  nch_count INTEGE
2240: 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 2d 2d 20  R  NOT NULL, -- 
2250: 48 6f 77 20 6f 66 74 65 6e 20 74 68 65 20 73 79  How often the sy
2260: 6d 62 6f 6c 20 69 73 20 75 73 65 64 20 61 73 20  mbol is used as 
2270: 62 72 61 6e 63 68 0a 09 20 20 20 20 63 6f 6d 6d  branch..    comm
2280: 69 74 5f 63 6f 75 6e 74 20 49 4e 54 45 47 45 52  it_count INTEGER
2290: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 2d 2d 20 48    NOT NULL, -- H
22a0: 6f 77 20 6f 66 74 65 6e 20 61 20 66 69 6c 65 20  ow often a file 
22b0: 77 61 73 20 63 6f 6d 6d 69 74 74 65 64 20 6f 6e  was committed on
22c0: 20 74 68 65 20 73 79 6d 62 6f 6c 0a 0a 09 20 20   the symbol...  
22d0: 20 20 55 4e 49 51 55 45 20 28 70 69 64 2c 20 6e    UNIQUE (pid, n
22e0: 61 6d 65 29 20 2d 2d 20 53 79 6d 62 6f 6c 73 20  ame) -- Symbols 
22f0: 61 72 65 20 75 6e 69 71 75 65 20 77 69 74 68 69  are unique withi
2300: 6e 20 74 68 65 20 70 72 6f 6a 65 63 74 0a 09 7d  n the project..}
2310: 0a 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e 67  ...state writing
2320: 20 62 6c 6f 63 6b 65 72 20 7b 0a 09 20 20 20 20   blocker {..    
2330: 2d 2d 20 46 6f 72 20 65 61 63 68 20 73 79 6d 62  -- For each symb
2340: 6f 6c 20 77 65 20 73 61 76 65 20 77 68 69 63 68  ol we save which
2350: 20 6f 74 68 65 72 20 73 79 6d 62 6f 6c 73 20 61   other symbols a
2360: 72 65 0a 09 20 20 20 20 2d 2d 20 62 6c 6f 63 6b  re..    -- block
2370: 69 6e 67 20 69 74 73 20 72 65 6d 6f 76 61 6c 20  ing its removal 
2380: 28 69 66 20 74 68 65 20 75 73 65 72 20 61 73 6b  (if the user ask
2390: 73 20 66 6f 72 20 69 74 29 2e 0a 0a 09 20 20 20  s for it)....   
23a0: 20 73 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f   sid INTEGER  NO
23b0: 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43  T NULL  REFERENC
23c0: 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 0a 09 20  ES symbol, --.. 
23d0: 20 20 20 62 69 64 20 49 4e 54 45 47 45 52 20 20     bid INTEGER  
23e0: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
23f0: 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20  NCES symbol, -- 
2400: 53 70 72 6f 75 74 65 64 20 66 72 6f 6d 20 73 69  Sprouted from si
2410: 64 2c 20 62 6c 6f 63 6b 73 20 69 74 2e 0a 09 20  d, blocks it... 
2420: 20 20 20 55 4e 49 51 55 45 20 28 73 69 64 2c 20     UNIQUE (sid, 
2430: 62 69 64 29 0a 09 7d 0a 0a 09 73 74 61 74 65 20  bid)..}...state 
2440: 77 72 69 74 69 6e 67 20 70 61 72 65 6e 74 20 7b  writing parent {
2450: 0a 09 20 20 20 20 2d 2d 20 46 6f 72 20 65 61 63  ..    -- For eac
2460: 68 20 73 79 6d 62 6f 6c 20 77 65 20 73 61 76 65  h symbol we save
2470: 20 77 68 69 63 68 20 6f 74 68 65 72 20 73 79 6d   which other sym
2480: 62 6f 6c 73 20 63 61 6e 20 61 63 74 20 61 73 0a  bols can act as.
2490: 09 20 20 20 20 2d 2d 20 61 20 70 6f 73 73 69 62  .    -- a possib
24a0: 6c 65 20 70 61 72 65 6e 74 20 69 6e 20 73 6f 6d  le parent in som
24b0: 65 20 66 69 6c 65 2c 20 61 6e 64 20 68 6f 77 20  e file, and how 
24c0: 6f 66 74 65 6e 2e 0a 0a 09 20 20 20 20 73 69 64  often....    sid
24d0: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
24e0: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73  LL  REFERENCES s
24f0: 79 6d 62 6f 6c 2c 20 2d 2d 0a 09 20 20 20 20 70  ymbol, --..    p
2500: 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  id INTEGER  NOT 
2510: 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53  NULL  REFERENCES
2520: 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20 50 6f 73 73   symbol, -- Poss
2530: 69 62 6c 65 20 70 61 72 65 6e 74 20 6f 66 20 73  ible parent of s
2540: 69 64 0a 09 20 20 20 20 6e 20 20 20 49 4e 54 45  id..    n   INTE
2550: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 20  GER  NOT NULL,  
2560: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2570: 20 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 70    -- How often p
2580: 69 64 20 63 61 6e 20 61 63 74 20 61 73 20 70 61  id can act as pa
2590: 72 65 6e 74 2e 0a 09 20 20 20 20 55 4e 49 51 55  rent...    UNIQU
25a0: 45 20 28 73 69 64 2c 20 70 69 64 29 0a 09 7d 0a  E (sid, pid)..}.
25b0: 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e 67 20  ..state writing 
25c0: 73 79 6d 74 79 70 65 20 7b 0a 09 20 20 20 20 74  symtype {..    t
25d0: 69 64 20 20 20 20 49 4e 54 45 47 45 52 20 20 4e  id    INTEGER  N
25e0: 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59  OT NULL  PRIMARY
25f0: 20 4b 45 59 2c 0a 09 20 20 20 20 6e 61 6d 65 20   KEY,..    name 
2600: 20 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e    TEXT     NOT N
2610: 55 4c 4c 2c 0a 09 20 20 20 20 70 6c 75 72 61 6c  ULL,..    plural
2620: 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55   TEXT     NOT NU
2630: 4c 4c 2c 0a 09 20 20 20 20 55 4e 49 51 55 45 20  LL,..    UNIQUE 
2640: 28 6e 61 6d 65 29 0a 09 20 20 20 20 55 4e 49 51  (name)..    UNIQ
2650: 55 45 20 28 70 6c 75 72 61 6c 29 0a 09 7d 0a 09  UE (plural)..}..
2660: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20  state run {..   
2670: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 73 79 6d   INSERT INTO sym
2680: 74 79 70 65 20 56 41 4c 55 45 53 20 28 30 2c 27  type VALUES (0,'
2690: 65 78 63 6c 75 64 65 64 27 2c 20 27 65 78 63 6c  excluded', 'excl
26a0: 75 64 65 64 27 29 3b 0a 09 20 20 20 20 49 4e 53  uded');..    INS
26b0: 45 52 54 20 49 4e 54 4f 20 73 79 6d 74 79 70 65  ERT INTO symtype
26c0: 20 56 41 4c 55 45 53 20 28 31 2c 27 74 61 67 27   VALUES (1,'tag'
26d0: 2c 20 20 20 20 20 20 27 74 61 67 73 27 29 3b 0a  ,      'tags');.
26e0: 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
26f0: 20 73 79 6d 74 79 70 65 20 56 41 4c 55 45 53 20   symtype VALUES 
2700: 28 32 2c 27 62 72 61 6e 63 68 27 2c 20 20 20 27  (2,'branch',   '
2710: 62 72 61 6e 63 68 65 73 27 29 3b 0a 09 20 20 20  branches');..   
2720: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 73 79 6d   INSERT INTO sym
2730: 74 79 70 65 20 56 41 4c 55 45 53 20 28 33 2c 27  type VALUES (3,'
2740: 75 6e 64 65 66 69 6e 65 64 27 2c 27 75 6e 64 65  undefined','unde
2750: 66 69 6e 65 64 27 29 3b 0a 09 7d 0a 0a 09 73 74  fined');..}...st
2760: 61 74 65 20 77 72 69 74 69 6e 67 20 6d 65 74 61  ate writing meta
2770: 20 7b 0a 09 20 20 20 20 2d 2d 20 4d 65 74 61 20   {..    -- Meta 
2780: 64 61 74 61 20 6f 66 20 72 65 76 69 73 69 6f 6e  data of revision
2790: 73 2e 20 53 65 65 20 72 65 76 69 73 69 6f 6e 2e  s. See revision.
27a0: 6d 69 64 20 66 6f 72 20 74 68 65 0a 09 20 20 20  mid for the..   
27b0: 20 2d 2d 20 72 65 66 65 72 65 6e 63 65 2e 20 4d   -- reference. M
27c0: 61 6e 79 20 72 65 76 69 73 69 6f 6e 73 20 63 61  any revisions ca
27d0: 6e 20 73 68 61 72 65 20 6d 65 74 61 20 64 61 74  n share meta dat
27e0: 61 2e 20 54 68 69 73 20 69 73 0a 09 20 20 20 20  a. This is..    
27f0: 2d 2d 20 61 63 74 75 61 6c 6c 79 20 6f 6e 65 20  -- actually one 
2800: 6f 66 20 74 68 65 20 63 72 69 74 65 72 69 6f 6e  of the criterion
2810: 73 20 75 73 65 64 20 74 6f 20 73 6f 72 74 20 72  s used to sort r
2820: 65 76 69 73 69 6f 6e 73 0a 09 20 20 20 20 2d 2d  evisions..    --
2830: 20 69 6e 74 6f 20 63 68 61 6e 67 65 73 65 74 73   into changesets
2840: 2e 0a 0a 09 20 20 20 20 6d 69 64 20 49 4e 54 45  ....    mid INTE
2850: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50  GER  NOT NULL  P
2860: 52 49 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f  RIMARY KEY  AUTO
2870: 49 4e 43 52 45 4d 45 4e 54 2c 0a 0a 09 20 20 20  INCREMENT,...   
2880: 20 2d 2d 20 4d 65 74 61 20 64 61 74 61 20 62 65   -- Meta data be
2890: 6c 6f 6e 67 73 20 74 6f 20 61 20 73 70 65 63 69  longs to a speci
28a0: 66 69 63 20 70 72 6f 6a 65 63 74 2c 20 73 74 72  fic project, str
28b0: 6f 6e 67 65 72 2c 20 74 6f 20 61 0a 09 20 20 20  onger, to a..   
28c0: 20 2d 2d 20 62 72 61 6e 63 68 20 69 6e 20 74 68   -- branch in th
28d0: 61 74 20 70 72 6f 6a 65 63 74 2e 20 49 74 20 66  at project. It f
28e0: 75 72 74 68 65 72 20 68 61 73 20 61 20 6c 6f 67  urther has a log
28f0: 20 6d 65 73 73 61 67 65 2c 0a 09 20 20 20 20 2d   message,..    -
2900: 2d 20 61 6e 64 20 69 74 73 20 61 75 74 68 6f 72  - and its author
2910: 2e 20 54 68 69 73 20 69 73 20 75 6e 69 71 75 65  . This is unique
2920: 20 77 69 74 68 20 74 68 65 20 70 72 6f 6a 65 63   with the projec
2930: 74 20 61 6e 64 0a 09 20 20 20 20 2d 2d 20 62 72  t and..    -- br
2940: 61 6e 63 68 2e 0a 0a 09 20 20 20 20 70 69 64 20  anch....    pid 
2950: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
2960: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 70 72  L  REFERENCES pr
2970: 6f 6a 65 63 74 2c 20 20 2d 2d 0a 09 20 20 20 20  oject,  --..    
2980: 62 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  bid INTEGER  NOT
2990: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
29a0: 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 0a 09  S symbol,   --..
29b0: 20 20 20 20 61 69 64 20 49 4e 54 45 47 45 52 20      aid INTEGER 
29c0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52   NOT NULL  REFER
29d0: 45 4e 43 45 53 20 61 75 74 68 6f 72 2c 20 20 20  ENCES author,   
29e0: 2d 2d 0a 09 20 20 20 20 63 69 64 20 49 4e 54 45  --..    cid INTE
29f0: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52  GER  NOT NULL  R
2a00: 45 46 45 52 45 4e 43 45 53 20 63 6d 65 73 73 61  EFERENCES cmessa
2a10: 67 65 2c 20 2d 2d 0a 0a 09 20 20 20 20 55 4e 49  ge, --...    UNI
2a20: 51 55 45 20 28 70 69 64 2c 20 62 69 64 2c 20 61  QUE (pid, bid, a
2a30: 69 64 2c 20 63 69 64 29 0a 0a 09 20 20 20 20 2d  id, cid)...    -
2a40: 2d 20 43 6f 6e 73 74 72 61 69 6e 74 73 3a 20 54  - Constraints: T
2a50: 68 65 20 70 72 6f 6a 65 63 74 20 6f 66 20 74 68  he project of th
2a60: 65 20 6d 65 74 61 20 64 61 74 61 20 6f 66 20 61  e meta data of a
2a70: 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 2d   revision..    -
2a80: 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 58  -              X
2a90: 20 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 20   is the same as 
2aa0: 74 68 65 20 70 72 6f 6a 65 63 74 20 6f 66 20 58  the project of X
2ab0: 20 69 74 73 65 6c 66 2e 0a 09 20 20 20 20 2d 2d   itself...    --
2ac0: 0a 09 20 20 20 20 2d 2d 20 2e 2e 2e 2e 2e 2e 2e  ..    -- .......
2ad0: 2e 2e 2e 2e 2e 20 54 68 65 20 62 72 61 6e 63 68  ..... The branch
2ae0: 20 6f 66 20 74 68 65 20 6d 65 74 61 20 64 61 74   of the meta dat
2af0: 61 20 6f 66 20 61 20 72 65 76 69 73 69 6f 6e 0a  a of a revision.
2b00: 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20  .    --         
2b10: 20 20 20 20 20 58 20 69 73 20 74 68 65 20 73 61       X is the sa
2b20: 6d 65 20 61 73 20 74 68 65 20 6c 69 6e 65 20 6f  me as the line o
2b30: 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 0a 09 20  f development.. 
2b40: 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20     --           
2b50: 20 20 20 6f 66 20 58 20 69 74 73 65 6c 66 2e 0a     of X itself..
2b60: 09 7d 0a 0a 09 23 20 41 75 74 68 6f 72 73 20 61  .}...# Authors a
2b70: 6e 64 20 63 6f 6d 6d 69 74 20 6d 65 73 73 61 67  nd commit messag
2b80: 65 73 20 61 72 65 20 66 75 6c 6c 79 20 67 6c 6f  es are fully glo
2b90: 62 61 6c 2c 20 69 2e 65 2e 20 70 65 72 0a 09 23  bal, i.e. per..#
2ba0: 20 72 65 70 6f 73 69 74 6f 72 79 2e 0a 0a 09 73   repository....s
2bb0: 74 61 74 65 20 77 72 69 74 69 6e 67 20 61 75 74  tate writing aut
2bc0: 68 6f 72 20 7b 0a 09 20 20 20 20 61 69 64 20 20  hor {..    aid  
2bd0: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
2be0: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20  L  PRIMARY KEY  
2bf0: 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09  AUTOINCREMENT,..
2c00: 20 20 20 20 6e 61 6d 65 20 54 45 58 54 20 20 20      name TEXT   
2c10: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 55 4e 49 51    NOT NULL  UNIQ
2c20: 55 45 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77 72  UE..}...state wr
2c30: 69 74 69 6e 67 20 63 6d 65 73 73 61 67 65 20 7b  iting cmessage {
2c40: 0a 09 20 20 20 20 63 69 64 20 20 49 4e 54 45 47  ..    cid  INTEG
2c50: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52  ER  NOT NULL  PR
2c60: 49 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f 49  IMARY KEY  AUTOI
2c70: 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 74  NCREMENT,..    t
2c80: 65 78 74 20 54 45 58 54 20 20 20 20 20 4e 4f 54  ext TEXT     NOT
2c90: 20 4e 55 4c 4c 20 20 55 4e 49 51 55 45 0a 09 7d   NULL  UNIQUE..}
2ca0: 0a 0a 09 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20  ...project::sym 
2cb0: 67 65 74 73 79 6d 74 79 70 65 73 0a 09 66 69 6c  getsymtypes..fil
2cc0: 65 3a 3a 72 65 76 20 20 20 20 67 65 74 6f 70 63  e::rev    getopc
2cd0: 6f 64 65 73 0a 09 72 65 74 75 72 6e 0a 20 20 20  odes..return.   
2ce0: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68   }..    typemeth
2cf0: 6f 64 20 6c 6f 61 64 20 7b 7d 20 7b 0a 09 73 74  od load {} {..st
2d00: 61 74 65 20 72 65 61 64 69 6e 67 20 73 79 6d 62  ate reading symb
2d10: 6f 6c 0a 09 73 74 61 74 65 20 72 65 61 64 69 6e  ol..state readin
2d20: 67 20 73 79 6d 74 79 70 65 0a 09 73 74 61 74 65  g symtype..state
2d30: 20 72 65 61 64 69 6e 67 20 6f 70 74 79 70 65 0a   reading optype.
2d40: 0a 09 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 67  ..project::sym g
2d50: 65 74 73 79 6d 74 79 70 65 73 0a 09 66 69 6c 65  etsymtypes..file
2d60: 3a 3a 72 65 76 20 20 20 20 67 65 74 6f 70 63 6f  ::rev    getopco
2d70: 64 65 73 0a 09 72 65 70 6f 73 69 74 6f 72 79 20  des..repository 
2d80: 20 20 6c 6f 61 64 73 79 6d 62 6f 6c 73 0a 09 72    loadsymbols..r
2d90: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
2da0: 20 74 79 70 65 6d 65 74 68 6f 64 20 72 75 6e 20   typemethod run 
2db0: 7b 7d 20 7b 0a 09 23 20 50 61 73 73 20 6d 61 6e  {} {..# Pass man
2dc0: 61 67 65 72 20 69 6e 74 65 72 66 61 63 65 2e 20  ager interface. 
2dd0: 45 78 65 63 75 74 65 64 20 74 6f 20 70 65 72 66  Executed to perf
2de0: 6f 72 6d 20 74 68 65 0a 09 23 20 66 75 6e 63 74  orm the..# funct
2df0: 69 6f 6e 61 6c 69 74 79 20 6f 66 20 74 68 65 20  ionality of the 
2e00: 70 61 73 73 2e 0a 0a 09 73 65 74 20 72 62 61 73  pass....set rbas
2e10: 65 20 5b 72 65 70 6f 73 69 74 6f 72 79 20 62 61  e [repository ba
2e20: 73 65 3f 5d 0a 09 66 6f 72 65 61 63 68 20 70 72  se?]..foreach pr
2e30: 6f 6a 65 63 74 20 5b 72 65 70 6f 73 69 74 6f 72  oject [repositor
2e40: 79 20 70 72 6f 6a 65 63 74 73 5d 20 7b 0a 09 20  y projects] {.. 
2e50: 20 20 20 73 65 74 20 62 61 73 65 20 5b 66 69 6c     set base [fil
2e60: 65 20 6a 6f 69 6e 20 24 72 62 61 73 65 20 5b 24  e join $rbase [$
2e70: 70 72 6f 6a 65 63 74 20 62 61 73 65 5d 5d 0a 09  project base]]..
2e80: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 31 20      log write 1 
2e90: 63 6f 6c 6c 72 65 76 20 22 50 72 6f 63 65 73 73  collrev "Process
2ea0: 69 6e 67 20 24 62 61 73 65 22 0a 0a 09 20 20 20  ing $base"...   
2eb0: 20 66 6f 72 65 61 63 68 20 66 69 6c 65 20 5b 24   foreach file [$
2ec0: 70 72 6f 6a 65 63 74 20 66 69 6c 65 73 5d 20 7b  project files] {
2ed0: 0a 09 09 73 65 74 20 70 61 74 68 20 5b 24 66 69  ...set path [$fi
2ee0: 6c 65 20 70 61 74 68 5d 0a 09 09 6c 6f 67 20 77  le path]...log w
2ef0: 72 69 74 65 20 32 20 63 6f 6c 6c 72 65 76 20 22  rite 2 collrev "
2f00: 50 61 72 73 69 6e 67 20 24 70 61 74 68 22 0a 09  Parsing $path"..
2f10: 09 69 66 20 7b 5b 63 61 74 63 68 20 7b 0a 09 09  .if {[catch {...
2f20: 20 20 20 20 70 61 72 73 65 72 20 70 72 6f 63 65      parser proce
2f30: 73 73 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 24 62  ss [file join $b
2f40: 61 73 65 20 24 70 61 74 68 5d 20 24 66 69 6c 65  ase $path] $file
2f50: 0a 09 09 7d 20 6d 73 67 5d 7d 20 7b 0a 09 09 20  ...} msg]} {... 
2f60: 20 20 20 67 6c 6f 62 61 6c 20 65 72 72 6f 72 43     global errorC
2f70: 6f 64 65 0a 09 09 20 20 20 20 69 66 20 7b 24 65  ode...    if {$e
2f80: 72 72 6f 72 43 6f 64 65 20 65 71 20 22 76 63 3a  rrorCode eq "vc:
2f90: 3a 72 63 73 3a 3a 70 61 72 73 65 72 22 7d 20 7b  :rcs::parser"} {
2fa0: 0a 09 09 09 74 72 6f 75 62 6c 65 20 66 61 74 61  ....trouble fata
2fb0: 6c 20 22 24 70 61 74 68 20 69 73 20 6e 6f 74 20  l "$path is not 
2fc0: 61 20 76 61 6c 69 64 20 52 43 53 20 61 72 63 68  a valid RCS arch
2fd0: 69 76 65 20 28 24 6d 73 67 29 22 0a 09 09 20 20  ive ($msg)"...  
2fe0: 20 20 7d 20 65 6c 73 65 20 7b 0a 09 09 09 67 6c    } else {....gl
2ff0: 6f 62 61 6c 20 65 72 72 6f 72 49 6e 66 6f 0a 09  obal errorInfo..
3000: 09 09 74 72 6f 75 62 6c 65 20 69 6e 74 65 72 6e  ..trouble intern
3010: 61 6c 20 24 65 72 72 6f 72 49 6e 66 6f 0a 09 09  al $errorInfo...
3020: 20 20 20 20 7d 0a 09 09 7d 20 65 6c 73 65 20 7b      }...} else {
3030: 0a 09 09 20 20 20 20 23 20 57 65 20 70 65 72 73  ...    # We pers
3040: 69 73 74 20 74 68 65 20 63 6f 72 65 20 6f 66 20  ist the core of 
3050: 74 68 65 20 64 61 74 61 20 63 6f 6c 6c 65 63 74  the data collect
3060: 65 64 20 61 62 6f 75 74 0a 09 09 20 20 20 20 23  ed about...    #
3070: 20 65 61 63 68 20 66 69 6c 65 20 69 6d 6d 65 64   each file immed
3080: 69 61 74 65 6c 79 20 61 66 74 65 72 20 69 74 20  iately after it 
3090: 68 61 73 20 62 65 65 6e 20 70 61 72 73 65 64 0a  has been parsed.
30a0: 09 09 20 20 20 20 23 20 61 6e 64 20 77 72 61 6e  ..    # and wran
30b0: 67 6c 65 64 20 69 6e 74 6f 20 73 68 61 70 65 2c  gled into shape,
30c0: 20 61 6e 64 20 74 68 65 6e 20 64 72 6f 70 20 69   and then drop i
30d0: 74 20 66 72 6f 6d 0a 09 09 20 20 20 20 23 20 6d  t from...    # m
30e0: 65 6d 6f 72 79 2e 20 54 68 69 73 20 69 73 20 64  emory. This is d
30f0: 6f 6e 65 20 74 6f 20 6b 65 65 70 20 74 68 65 20  one to keep the 
3100: 61 6d 6f 75 6e 74 20 6f 66 0a 09 09 20 20 20 20  amount of...    
3110: 23 20 72 65 71 75 69 72 65 64 20 6d 65 6d 6f 72  # required memor
3120: 79 20 77 69 74 68 69 6e 20 73 65 6e 73 69 62 6c  y within sensibl
3130: 65 20 6c 69 6d 69 74 73 2e 20 57 69 74 68 6f 75  e limits. Withou
3140: 74 0a 09 09 20 20 20 20 23 20 64 6f 69 6e 67 20  t...    # doing 
3150: 69 74 20 74 68 69 73 20 77 61 79 20 77 65 20 77  it this way we w
3160: 6f 75 6c 64 20 65 61 73 69 6c 79 20 67 6f 62 62  ould easily gobb
3170: 6c 65 20 75 70 20 31 47 0a 09 09 20 20 20 20 23  le up 1G...    #
3180: 20 6f 66 20 52 41 4d 20 6f 72 20 6d 6f 72 65 20   of RAM or more 
3190: 77 69 74 68 20 61 6c 6c 20 74 68 65 20 6f 62 6a  with all the obj
31a0: 65 63 74 73 20 28 72 65 76 69 73 69 6f 6e 73 0a  ects (revisions.
31b0: 09 09 20 20 20 20 23 20 61 6e 64 20 66 69 6c 65  ..    # and file
31c0: 2d 6c 65 76 65 6c 20 73 79 6d 62 6f 6c 73 29 2e  -level symbols).
31d0: 0a 0a 09 09 20 20 20 20 24 66 69 6c 65 20 70 65  ....    $file pe
31e0: 72 73 69 73 74 0a 09 09 7d 0a 0a 09 09 24 66 69  rsist...}....$fi
31f0: 6c 65 20 64 72 6f 70 0a 09 20 20 20 20 7d 0a 0a  le drop..    }..
3200: 09 20 20 20 20 24 70 72 6f 6a 65 63 74 20 70 75  .    $project pu
3210: 72 67 65 67 68 6f 73 74 73 79 6d 62 6f 6c 73 0a  rgeghostsymbols.
3220: 09 7d 0a 0a 09 72 65 70 6f 73 69 74 6f 72 79 20  .}...repository 
3230: 70 65 72 73 69 73 74 72 65 76 0a 09 72 65 70 6f  persistrev..repo
3240: 73 69 74 6f 72 79 20 70 72 69 6e 74 72 65 76 73  sitory printrevs
3250: 74 61 74 69 73 74 69 63 73 0a 09 69 6e 74 65 67  tatistics..integ
3260: 72 69 74 79 20 20 73 74 72 69 63 74 0a 0a 09 6c  rity  strict...l
3270: 6f 67 20 77 72 69 74 65 20 31 20 63 6f 6c 6c 72  og write 1 collr
3280: 65 76 20 22 53 63 61 6e 20 63 6f 6d 70 6c 65 74  ev "Scan complet
3290: 65 64 22 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ed"..return.    
32a0: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
32b0: 64 20 64 69 73 63 61 72 64 20 7b 7d 20 7b 0a 09  d discard {} {..
32c0: 23 20 50 61 73 73 20 6d 61 6e 61 67 65 72 20 69  # Pass manager i
32d0: 6e 74 65 72 66 61 63 65 2e 20 45 78 65 63 75 74  nterface. Execut
32e0: 65 64 20 66 6f 72 20 61 6c 6c 20 70 61 73 73 65  ed for all passe
32f0: 73 20 61 66 74 65 72 20 74 68 65 0a 09 23 20 72  s after the..# r
3300: 75 6e 20 70 61 73 73 65 73 2c 20 74 6f 20 72 65  un passes, to re
3310: 6d 6f 76 65 20 61 6c 6c 20 64 61 74 61 20 6f 66  move all data of
3320: 20 74 68 69 73 20 70 61 73 73 20 66 72 6f 6d 20   this pass from 
3330: 74 68 65 20 73 74 61 74 65 2c 0a 09 23 20 61 73  the state,..# as
3340: 20 62 65 69 6e 67 20 6f 75 74 20 6f 66 20 64 61   being out of da
3350: 74 65 2e 0a 0a 09 73 74 61 74 65 20 64 69 73 63  te....state disc
3360: 61 72 64 20 72 65 76 69 73 69 6f 6e 0a 09 73 74  ard revision..st
3370: 61 74 65 20 64 69 73 63 61 72 64 20 74 61 67 0a  ate discard tag.
3380: 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20 62  .state discard b
3390: 72 61 6e 63 68 0a 09 73 74 61 74 65 20 64 69 73  ranch..state dis
33a0: 63 61 72 64 20 73 79 6d 62 6f 6c 0a 09 73 74 61  card symbol..sta
33b0: 74 65 20 64 69 73 63 61 72 64 20 62 6c 6f 63 6b  te discard block
33c0: 65 72 0a 09 73 74 61 74 65 20 64 69 73 63 61 72  er..state discar
33d0: 64 20 70 61 72 65 6e 74 0a 09 73 74 61 74 65 20  d parent..state 
33e0: 64 69 73 63 61 72 64 20 73 79 6d 74 79 70 65 0a  discard symtype.
33f0: 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20 6d  .state discard m
3400: 65 74 61 0a 09 73 74 61 74 65 20 64 69 73 63 61  eta..state disca
3410: 72 64 20 61 75 74 68 6f 72 0a 09 73 74 61 74 65  rd author..state
3420: 20 64 69 73 63 61 72 64 20 63 6d 65 73 73 61 67   discard cmessag
3430: 65 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  e..return.    }.
3440: 0a 20 20 20 20 70 72 6f 63 20 50 61 72 61 6e 6f  .    proc Parano
3450: 69 61 20 7b 7d 20 7b 0a 09 23 20 54 68 69 73 20  ia {} {..# This 
3460: 63 6f 64 65 20 70 65 72 66 6f 72 6d 73 20 61 20  code performs a 
3470: 6e 75 6d 62 65 72 20 6f 66 20 70 61 72 61 6e 6f  number of parano
3480: 69 64 20 63 68 65 63 6b 73 20 6f 66 20 74 68 65  id checks of the
3490: 0a 09 23 20 64 61 74 61 62 61 73 65 2c 20 73 65  ..# database, se
34a0: 61 72 63 68 69 6e 67 20 66 6f 72 20 69 6e 63 6f  arching for inco
34b0: 6e 73 69 73 74 65 6e 74 20 63 72 6f 73 73 2d 72  nsistent cross-r
34c0: 65 66 65 72 65 6e 63 65 73 2e 0a 09 6c 6f 67 20  eferences...log 
34d0: 77 72 69 74 65 20 34 20 63 6f 6c 6c 72 65 76 20  write 4 collrev 
34e0: 7b 43 68 65 63 6b 20 64 61 74 61 62 61 73 65 20  {Check database 
34f0: 63 6f 6e 73 69 73 74 65 6e 63 79 7d 0a 0a 09 73  consistency}...s
3500: 65 74 20 6e 20 30 20 3b 20 23 20 43 6f 75 6e 74  et n 0 ; # Count
3510: 65 72 20 66 6f 72 20 74 68 65 20 63 68 65 63 6b  er for the check
3520: 73 20 28 77 65 20 70 72 69 6e 74 20 61 6e 20 69  s (we print an i
3530: 64 20 62 65 66 6f 72 65 20 74 68 65 0a 09 09 20  d before the... 
3540: 20 23 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a   # main label)..
3550: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
3560: 69 73 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73  isions which dis
3570: 61 67 72 65 65 20 77 69 74 68 20 74 68 65 69 72  agree with their
3580: 20 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65   line of..# deve
3590: 6c 6f 70 6d 65 6e 74 20 61 62 6f 75 74 20 74 68  lopment about th
35a0: 65 20 70 72 6f 6a 65 63 74 20 74 68 65 79 20 61  e project they a
35b0: 72 65 20 6f 77 6e 65 64 20 62 79 2e 0a 09 43 68  re owned by...Ch
35c0: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69  eck \..    {Revi
35d0: 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20  sions and their 
35e0: 4c 4f 44 73 20 68 61 76 65 20 74 6f 20 62 65 20  LODs have to be 
35f0: 69 6e 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a  in the same proj
3600: 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73  ect} \..    {dis
3610: 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20  agrees with its 
3620: 4c 4f 44 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67  LOD about owning
3630: 20 70 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 53 45   project} {...SE
3640: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
3650: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69  ev...FROM revisi
3660: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 73 79  on R, file F, sy
3670: 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52 45 20 52  mbol S...WHERE R
3680: 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41  .fid = F.fid...A
3690: 4e 44 20 20 20 52 2e 6c 6f 64 20 3d 20 53 2e 73  ND   R.lod = S.s
36a0: 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70 69 64  id...AND   F.pid
36b0: 20 21 3d 20 53 2e 70 69 64 0a 09 09 3b 0a 09 20   != S.pid...;.. 
36c0: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
36d0: 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68   revisions which
36e0: 20 64 69 73 67 72 65 65 20 77 69 74 68 20 74 68   disgree with th
36f0: 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 61 62  eir meta data ab
3700: 6f 75 74 0a 09 23 20 74 68 65 20 70 72 6f 6a 65  out..# the proje
3710: 63 74 20 74 68 65 79 20 61 72 65 20 6f 77 6e 65  ct they are owne
3720: 64 20 62 79 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  d by...Check \..
3730: 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61      {Revisions a
3740: 6e 64 20 74 68 65 69 72 20 6d 65 74 61 20 64 61  nd their meta da
3750: 74 61 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e  ta have to be in
3760: 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a 65 63   the same projec
3770: 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67  t} \..    {disag
3780: 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6d 65  rees with its me
3790: 74 61 20 64 61 74 61 20 61 62 6f 75 74 20 6f 77  ta data about ow
37a0: 6e 69 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b 0a  ning project} {.
37b0: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
37c0: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
37d0: 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46  vision R, file F
37e0: 2c 20 6d 65 74 61 20 4d 0a 09 09 57 48 45 52 45  , meta M...WHERE
37f0: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09   R.fid = F.fid..
3800: 09 41 4e 44 20 20 20 52 2e 6d 69 64 20 3d 20 4d  .AND   R.mid = M
3810: 2e 6d 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70  .mid...AND   F.p
3820: 69 64 20 21 3d 20 4d 2e 70 69 64 0a 09 09 3b 0a  id != M.pid...;.
3830: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
3840: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69  ll revisions whi
3850: 63 68 20 64 69 73 67 72 65 65 20 77 69 74 68 20  ch disgree with 
3860: 74 68 65 69 72 20 6d 65 74 61 20 64 61 74 61 20  their meta data 
3870: 61 62 6f 75 74 0a 09 23 20 74 68 65 20 62 72 61  about..# the bra
3880: 6e 63 68 2f 6c 69 6e 65 20 6f 66 20 64 65 76 65  nch/line of deve
3890: 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20 62 65 6c  lopment they bel
38a0: 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c  ong to...Check \
38b0: 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73  ..    {Revisions
38c0: 20 61 6e 64 20 74 68 65 69 72 20 6d 65 74 61 20   and their meta 
38d0: 64 61 74 61 20 68 61 76 65 20 74 6f 20 62 65 20  data have to be 
38e0: 69 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 7d  in the same LOD}
38f0: 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65   \..    {disagre
3900: 65 73 20 77 69 74 68 20 69 74 73 20 6d 65 74 61  es with its meta
3910: 20 64 61 74 61 20 61 62 6f 75 74 20 6f 77 6e 69   data about owni
3920: 6e 67 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c 45  ng LOD} {...SELE
3930: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
3940: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
3950: 20 52 2c 20 6d 65 74 61 20 4d 2c 20 66 69 6c 65   R, meta M, file
3960: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 6d 69 64   F...WHERE R.mid
3970: 20 3d 20 4d 2e 6d 69 64 0a 09 09 41 4e 44 20 20   = M.mid...AND  
3980: 20 52 2e 6c 6f 64 20 21 3d 20 4d 2e 62 69 64 0a   R.lod != M.bid.
3990: 09 09 41 4e 44 20 20 20 52 2e 66 69 64 20 3d 20  ..AND   R.fid = 
39a0: 46 2e 66 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d  F.fid...;..    }
39b0: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
39c0: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 70 72  isions with a pr
39d0: 69 6d 61 72 79 20 63 68 69 6c 64 20 77 68 69 63  imary child whic
39e0: 68 20 64 69 73 61 67 72 65 65 73 0a 09 23 20 61  h disagrees..# a
39f0: 62 6f 75 74 20 74 68 65 20 66 69 6c 65 20 74 68  bout the file th
3a00: 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43  ey belong to...C
3a10: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76  heck \..    {Rev
3a20: 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72  isions and their
3a30: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65   primary childre
3a40: 6e 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20  n have to be in 
3a50: 74 68 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c  the same file} \
3a60: 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65 65 73  ..    {disagrees
3a70: 20 77 69 74 68 20 69 74 73 20 70 72 69 6d 61 72   with its primar
3a80: 79 20 63 68 69 6c 64 20 61 62 6f 75 74 20 74 68  y child about th
3a90: 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b  e owning file} {
3aa0: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65  ...SELECT F.name
3ab0: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72  , R.rev...FROM r
3ac0: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73  evision R, revis
3ad0: 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09  ion C, file F...
3ae0: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e  WHERE R.fid = F.
3af0: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 63 68  fid...AND   R.ch
3b00: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a  ild IS NOT NULL.
3b10: 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20  ..AND   R.child 
3b20: 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20  = C.rid...AND   
3b30: 43 2e 66 69 64 20 21 3d 20 52 2e 66 69 64 0a 09  C.fid != R.fid..
3b40: 09 3b 0a 09 20 20 20 20 7d 0a 0a 09 23 20 46 69  .;..    }...# Fi
3b50: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
3b60: 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 20 70   with a branch p
3b70: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f  arent symbol who
3b80: 73 65 20 70 61 72 65 6e 74 0a 09 23 20 64 69 73  se parent..# dis
3b90: 61 67 72 65 65 73 20 61 62 6f 75 74 20 74 68 65  agrees about the
3ba0: 20 66 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e   file they belon
3bb0: 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  g to...Check \..
3bc0: 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61      {Revisions a
3bd0: 6e 64 20 74 68 65 69 72 20 62 72 61 6e 63 68 20  nd their branch 
3be0: 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f  children have to
3bf0: 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20   be in the same 
3c00: 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 61 74  file} \..    {at
3c10: 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f   the beginning o
3c20: 66 20 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64  f its branch and
3c30: 20 69 74 73 20 70 61 72 65 6e 74 20 64 69 73 61   its parent disa
3c40: 67 72 65 65 20 61 62 6f 75 74 20 74 68 65 20 6f  gree about the o
3c50: 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09  wning file} {...
3c60: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52  SELECT F.name, R
3c70: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69  .rev...FROM revi
3c80: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
3c90: 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   P, file F...WHE
3ca0: 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  RE R.fid = F.fid
3cb0: 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65  ...AND   R.bpare
3cc0: 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09  nt IS NOT NULL..
3cd0: 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20  .AND   R.parent 
3ce0: 3d 20 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 20  = P.rid...AND   
3cf0: 52 2e 66 69 64 20 21 3d 20 50 2e 66 69 64 0a 09  R.fid != P.fid..
3d00: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
3d10: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
3d20: 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20  with a non-NTDB 
3d30: 63 68 69 6c 64 20 77 68 69 63 68 20 64 69 73 61  child which disa
3d40: 67 72 65 65 73 0a 09 23 20 61 62 6f 75 74 20 74  grees..# about t
3d50: 68 65 20 66 69 6c 65 20 74 68 65 79 20 62 65 6c  he file they bel
3d60: 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c  ong to...Check \
3d70: 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73  ..    {Revisions
3d80: 20 61 6e 64 20 74 68 65 69 72 20 6e 6f 6e 2d 4e   and their non-N
3d90: 54 44 42 20 63 68 69 6c 64 72 65 6e 20 68 61 76  TDB children hav
3da0: 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73  e to be in the s
3db0: 61 6d 65 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20  ame file} \..   
3dc0: 20 7b 64 69 73 61 67 72 65 65 73 20 77 69 74 68   {disagrees with
3dd0: 20 69 74 73 20 6e 6f 6e 2d 4e 54 44 42 20 63 68   its non-NTDB ch
3de0: 69 6c 64 20 61 62 6f 75 74 20 74 68 65 20 6f 77  ild about the ow
3df0: 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09 53  ning file} {...S
3e00: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
3e10: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
3e20: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
3e30: 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  C, file F...WHER
3e40: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
3e50: 09 09 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c  ..AND   R.dbchil
3e60: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  d IS NOT NULL...
3e70: 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20  AND   R.dbchild 
3e80: 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20  = C.rid...AND   
3e90: 43 2e 66 69 64 20 21 3d 20 52 2e 66 69 64 0a 09  C.fid != R.fid..
3ea0: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
3eb0: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
3ec0: 77 68 69 63 68 20 68 61 76 65 20 61 20 70 72 69  which have a pri
3ed0: 6d 61 72 79 20 63 68 69 6c 64 2c 20 62 75 74 20  mary child, but 
3ee0: 74 68 65 20 63 68 69 6c 64 0a 09 23 20 64 6f 65  the child..# doe
3ef0: 73 20 6e 6f 74 20 68 61 76 65 20 74 68 65 6d 20  s not have them 
3f00: 61 73 20 70 61 72 65 6e 74 2e 0a 09 43 68 65 63  as parent...Chec
3f10: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
3f20: 6f 6e 73 20 68 61 76 65 20 74 6f 20 62 65 20 70  ons have to be p
3f30: 61 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20  arents of their 
3f40: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e  primary children
3f50: 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20 6e 6f 74  } \..    {is not
3f60: 20 74 68 65 20 70 61 72 65 6e 74 20 6f 66 20 69   the parent of i
3f70: 74 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  ts primary child
3f80: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
3f90: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
3fa0: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65  M revision R, re
3fb0: 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46  vision C, file F
3fc0: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
3fd0: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
3fe0: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  .child IS NOT NU
3ff0: 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69  LL...AND   R.chi
4000: 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44  ld = C.rid...AND
4010: 20 20 20 43 2e 70 61 72 65 6e 74 20 21 3d 20 52     C.parent != R
4020: 2e 72 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  .rid...;..    }.
4030: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
4040: 73 69 6f 6e 73 20 77 68 69 63 68 20 68 61 76 65  sions which have
4050: 20 61 20 70 72 69 6d 72 61 72 79 20 63 68 69 6c   a primrary chil
4060: 64 2c 20 62 75 74 20 74 68 65 0a 09 23 20 63 68  d, but the..# ch
4070: 69 6c 64 20 68 61 73 20 61 20 62 72 61 6e 63 68  ild has a branch
4080: 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 6d   parent symbol m
4090: 61 6b 69 6e 67 20 74 68 65 6d 20 62 72 61 63 68  aking them brach
40a0: 20 73 74 61 72 74 65 72 73 2e 0a 09 43 68 65 63   starters...Chec
40b0: 6b 20 5c 0a 09 20 20 20 20 7b 50 72 69 6d 61 72  k \..    {Primar
40c0: 79 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 72 65  y children of re
40d0: 76 69 73 69 6f 6e 73 20 6d 75 73 74 20 6e 6f 74  visions must not
40e0: 20 73 74 61 72 74 20 62 72 61 6e 63 68 65 73 7d   start branches}
40f0: 20 5c 0a 09 20 20 20 20 7b 69 73 20 70 61 72 65   \..    {is pare
4100: 6e 74 20 6f 66 20 61 20 70 72 69 6d 61 72 79 20  nt of a primary 
4110: 63 68 69 6c 64 20 77 68 69 63 68 20 69 73 20 74  child which is t
4120: 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20  he beginning of 
4130: 61 20 62 72 61 6e 63 68 7d 20 7b 0a 09 09 53 45  a branch} {...SE
4140: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
4150: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69  ev...FROM revisi
4160: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43  on R, revision C
4170: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45  , file F...WHERE
4180: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09   R.fid = F.fid..
4190: 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49  .AND   R.child I
41a0: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44  S NOT NULL...AND
41b0: 20 20 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72     R.child = C.r
41c0: 69 64 0a 09 09 41 4e 44 20 20 20 43 2e 62 70 61  id...AND   C.bpa
41d0: 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  rent IS NOT NULL
41e0: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46  ...;..    }..# F
41f0: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  ind all revision
4200: 73 20 77 69 74 68 6f 75 74 20 62 72 61 6e 63 68  s without branch
4210: 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77   parent symbol w
4220: 68 69 63 68 20 68 61 76 65 20 61 0a 09 23 20 70  hich have a..# p
4230: 61 72 65 6e 74 2c 20 62 75 74 20 74 68 65 20 70  arent, but the p
4240: 61 72 65 6e 74 20 64 6f 65 73 20 6e 6f 74 20 68  arent does not h
4250: 61 76 65 20 74 68 65 6d 20 61 73 20 70 72 69 6d  ave them as prim
4260: 61 72 79 20 63 68 69 6c 64 2e 0a 09 43 68 65 63  ary child...Chec
4270: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
4280: 6f 6e 73 20 68 61 76 65 20 74 6f 20 62 65 20 70  ons have to be p
4290: 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20  rimary children 
42a0: 6f 66 20 74 68 65 69 72 20 70 61 72 65 6e 74 73  of their parents
42b0: 2c 20 69 66 20 61 6e 79 7d 20 5c 0a 09 20 20 20  , if any} \..   
42c0: 20 7b 69 73 20 6e 6f 74 20 74 68 65 20 63 68 69   {is not the chi
42d0: 6c 64 20 6f 66 20 69 74 73 20 70 61 72 65 6e 74  ld of its parent
42e0: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
42f0: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
4300: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65  M revision R, re
4310: 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46  vision P, file F
4320: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
4330: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
4340: 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 55 4c 4c  .bparent IS NULL
4350: 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e  ...AND   R.paren
4360: 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  t IS NOT NULL...
4370: 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d  AND   R.parent =
4380: 20 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 50   P.rid...AND   P
4390: 2e 63 68 69 6c 64 20 21 3d 20 52 2e 72 69 64 0a  .child != R.rid.
43a0: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69  ..;..    }..# Fi
43b0: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
43c0: 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 20 70   with a branch p
43d0: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 69  arent symbol whi
43e0: 63 68 20 64 6f 20 6e 6f 74 0a 09 23 20 68 61 76  ch do not..# hav
43f0: 65 20 61 20 70 61 72 65 6e 74 2e 0a 09 43 68 65  e a parent...Che
4400: 63 6b 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63  ck \..    {Branc
4410: 68 20 73 74 61 72 74 69 6e 67 20 72 65 76 69 73  h starting revis
4420: 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 68 61 76  ions have to hav
4430: 65 20 61 20 70 61 72 65 6e 74 7d 20 5c 0a 09 20  e a parent} \.. 
4440: 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e     {at the begin
4450: 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e  ning of its bran
4460: 63 68 20 68 61 73 20 6e 6f 20 70 61 72 65 6e 74  ch has no parent
4470: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
4480: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
4490: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69  M revision R, fi
44a0: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66  le F...WHERE R.f
44b0: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
44c0: 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20     R.bparent IS 
44d0: 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20  NOT NULL...AND  
44e0: 20 52 2e 70 61 72 65 6e 74 20 49 53 20 4e 55 4c   R.parent IS NUL
44f0: 4c 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20  L...;..    }..# 
4500: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f  Find all revisio
4510: 6e 73 20 77 69 74 68 20 61 20 62 72 61 6e 63 68  ns with a branch
4520: 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77   parent symbol w
4530: 68 6f 73 65 20 70 61 72 65 6e 74 0a 09 23 20 68  hose parent..# h
4540: 61 73 20 74 68 65 6d 20 61 73 20 70 72 69 6d 61  as them as prima
4550: 72 79 20 63 68 69 6c 64 2e 0a 09 43 68 65 63 6b  ry child...Check
4560: 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63 68 20   \..    {Branch 
4570: 73 74 61 72 74 69 6e 67 20 72 65 76 69 73 69 6f  starting revisio
4580: 6e 73 20 6d 75 73 74 20 6e 6f 74 20 62 65 20 70  ns must not be p
4590: 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20  rimary children 
45a0: 6f 66 20 74 68 65 69 72 20 70 61 72 65 6e 74 73  of their parents
45b0: 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65  } \..    {at the
45c0: 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74   beginning of it
45d0: 73 20 62 72 61 6e 63 68 20 69 73 20 74 68 65 20  s branch is the 
45e0: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 6f 66  primary child of
45f0: 20 69 74 73 20 70 61 72 65 6e 74 7d 20 7b 0a 09   its parent} {..
4600: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20  .SELECT F.name, 
4610: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76  R.rev...FROM rev
4620: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
4630: 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n P, file F...WH
4640: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
4650: 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72  d...AND   R.bpar
4660: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a  ent IS NOT NULL.
4670: 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74  ..AND   R.parent
4680: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41   IS NOT NULL...A
4690: 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20  ND   R.parent = 
46a0: 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 50 2e  P.rid...AND   P.
46b0: 63 68 69 6c 64 20 3d 20 52 2e 72 69 64 0a 09 09  child = R.rid...
46c0: 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64  ;..    }..# Find
46d0: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
46e0: 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63  ith a non-NTDB c
46f0: 68 69 6c 64 20 77 68 69 63 68 20 61 72 65 20 6e  hild which are n
4700: 6f 74 20 6f 6e 0a 09 23 20 74 68 65 20 4e 54 44  ot on..# the NTD
4710: 42 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20  B...Check \..   
4720: 20 7b 4e 54 44 42 20 74 6f 20 74 72 75 6e 6b 20   {NTDB to trunk 
4730: 74 72 61 6e 73 69 74 69 6f 6e 20 68 61 73 20 74  transition has t
4740: 6f 20 62 65 67 69 6e 20 6f 6e 20 4e 54 44 42 7d  o begin on NTDB}
4750: 20 5c 0a 09 20 20 20 20 7b 68 61 73 20 61 20 6e   \..    {has a n
4760: 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 2c 20 79  on-NTDB child, y
4770: 65 74 20 69 73 20 6e 6f 74 20 6f 6e 20 74 68 65  et is not on the
4780: 20 4e 54 44 42 7d 20 7b 0a 09 09 53 45 4c 45 43   NTDB} {...SELEC
4790: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
47a0: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
47b0: 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  R, file F...WHER
47c0: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
47d0: 09 09 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c  ..AND   R.dbchil
47e0: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  d IS NOT NULL...
47f0: 41 4e 44 20 20 20 4e 4f 54 20 52 2e 69 73 64 65  AND   NOT R.isde
4800: 66 61 75 6c 74 0a 09 09 3b 0a 09 20 20 20 20 7d  fault...;..    }
4810: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
4820: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 4e 54  isions with a NT
4830: 44 42 20 70 61 72 65 6e 74 20 77 68 69 63 68 20  DB parent which 
4840: 61 72 65 20 6f 6e 20 74 68 65 20 4e 54 44 42 2e  are on the NTDB.
4850: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b  ..Check \..    {
4860: 4e 54 44 42 20 74 6f 20 74 72 75 6e 6b 20 74 72  NTDB to trunk tr
4870: 61 6e 73 69 74 69 6f 6e 20 68 61 73 20 74 6f 20  ansition has to 
4880: 65 6e 64 20 6f 6e 20 6e 6f 6e 2d 4e 54 44 42 7d  end on non-NTDB}
4890: 20 5c 0a 09 20 20 20 20 7b 68 61 73 20 61 20 4e   \..    {has a N
48a0: 54 44 42 20 70 61 72 65 6e 74 2c 20 79 65 74 20  TDB parent, yet 
48b0: 69 73 20 6f 6e 20 74 68 65 20 4e 54 44 42 7d 20  is on the NTDB} 
48c0: 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d  {...SELECT F.nam
48d0: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20  e, R.rev...FROM 
48e0: 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65  revision R, file
48f0: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   F...WHERE R.fid
4900: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
4910: 20 52 2e 64 62 70 61 72 65 6e 74 20 49 53 20 4e   R.dbparent IS N
4920: 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20  OT NULL...AND   
4930: 52 2e 69 73 64 65 66 61 75 6c 74 0a 09 09 3b 0a  R.isdefault...;.
4940: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
4950: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74  ll revisions wit
4960: 68 20 61 20 63 68 69 6c 64 20 77 68 69 63 68 20  h a child which 
4970: 64 69 73 61 67 72 65 65 73 20 61 62 6f 75 74 20  disagrees about 
4980: 74 68 65 0a 09 23 20 6c 69 6e 65 20 6f 66 20 64  the..# line of d
4990: 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20  evelopment they 
49a0: 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63  belong to...Chec
49b0: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
49c0: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 70 72  ons and their pr
49d0: 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20 68  imary children h
49e0: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65  ave to be in the
49f0: 20 73 61 6d 65 20 4c 4f 44 7d 20 5c 0a 09 20 20   same LOD} \..  
4a00: 20 20 7b 61 6e 64 20 69 74 73 20 70 72 69 6d 61    {and its prima
4a10: 72 79 20 63 68 69 6c 64 20 64 69 73 61 67 72 65  ry child disagre
4a20: 65 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c 4f  e about their LO
4a30: 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  D} {...SELECT F.
4a40: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
4a50: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72  OM revision R, r
4a60: 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20  evision C, file 
4a70: 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20  F...WHERE R.fid 
4a80: 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20  = F.fid...AND   
4a90: 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e  R.child IS NOT N
4aa0: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 63 68  ULL...AND   R.ch
4ab0: 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e  ild = C.rid...AN
4ac0: 44 20 20 20 43 2e 6c 6f 64 20 21 3d 20 52 2e 6c  D   C.lod != R.l
4ad0: 6f 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23  od...;..    }..#
4ae0: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69   Find all revisi
4af0: 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d 4e  ons with a non-N
4b00: 54 44 42 20 63 68 69 6c 64 20 77 68 69 63 68 20  TDB child which 
4b10: 61 67 72 65 65 73 20 61 62 6f 75 74 0a 09 23 20  agrees about..# 
4b20: 74 68 65 20 6c 69 6e 65 20 6f 66 20 64 65 76 65  the line of deve
4b30: 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20 62 65 6c  lopment they bel
4b40: 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c  ong to...Check \
4b50: 0a 09 20 20 20 20 7b 4e 54 44 42 20 61 6e 64 20  ..    {NTDB and 
4b60: 74 72 75 6e 6b 20 72 65 76 69 73 69 6f 6e 73 20  trunk revisions 
4b70: 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 64 69  have to be in di
4b80: 66 66 65 72 65 6e 74 20 4c 4f 44 73 7d 20 5c 0a  fferent LODs} \.
4b90: 09 20 20 20 20 7b 6f 6e 20 4e 54 44 42 20 61 6e  .    {on NTDB an
4ba0: 64 20 69 74 73 20 6e 6f 6e 2d 4e 54 44 42 20 63  d its non-NTDB c
4bb0: 68 69 6c 64 20 77 72 6f 6e 67 6c 79 20 61 67 72  hild wrongly agr
4bc0: 65 65 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c  ee about their L
4bd0: 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  OD} {...SELECT F
4be0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
4bf0: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  ROM revision R, 
4c00: 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65  revision C, file
4c10: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   F...WHERE R.fid
4c20: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
4c30: 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f   R.dbchild IS NO
4c40: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
4c50: 2e 64 62 63 68 69 6c 64 20 3d 20 43 2e 72 69 64  .dbchild = C.rid
4c60: 0a 09 09 41 4e 44 20 20 20 43 2e 6c 6f 64 20 3d  ...AND   C.lod =
4c70: 20 52 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20 20 20   R.lod...;..    
4c80: 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  }..# Find all re
4c90: 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62  visions with a b
4ca0: 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d  ranch parent sym
4cb0: 62 6f 6c 20 77 68 69 63 68 20 69 73 20 6e 6f 74  bol which is not
4cc0: 0a 09 23 20 74 68 65 69 72 20 4c 4f 44 2e 0a 09  ..# their LOD...
4cd0: 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 42 72  Check \..    {Br
4ce0: 61 6e 63 68 20 73 74 61 72 74 69 6e 67 20 72 65  anch starting re
4cf0: 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20  visions have to 
4d00: 68 61 76 65 20 74 68 65 69 72 20 4c 4f 44 20 61  have their LOD a
4d10: 73 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20  s branch parent 
4d20: 73 79 6d 62 6f 6c 7d 20 5c 0a 09 20 20 20 20 7b  symbol} \..    {
4d30: 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67  at the beginning
4d40: 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68 20 64   of its branch d
4d50: 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 68 65  oes not have the
4d60: 20 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 20 61   branch symbol a
4d70: 73 20 69 74 73 20 4c 4f 44 7d 20 7b 0a 09 09 53  s its LOD} {...S
4d80: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
4d90: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
4da0: 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09  ion R, file F...
4db0: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e  WHERE R.fid = F.
4dc0: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70  fid...AND   R.bp
4dd0: 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c  arent IS NOT NUL
4de0: 4c 0a 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20  L...AND   R.lod 
4df0: 21 3d 20 52 2e 62 70 61 72 65 6e 74 0a 09 09 3b  != R.bparent...;
4e00: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
4e10: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
4e20: 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72 65  th a branch pare
4e30: 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f 73 65 20  nt symbol whose 
4e40: 70 61 72 65 6e 74 0a 09 23 20 69 73 20 69 6e 20  parent..# is in 
4e50: 74 68 65 20 73 61 6d 65 20 6c 69 6e 65 20 6f 66  the same line of
4e60: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 2e 0a 09 43   development...C
4e70: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76  heck \..    {Rev
4e80: 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72  isions and their
4e90: 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e   branch children
4ea0: 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 64   have to be in d
4eb0: 69 66 66 65 72 65 6e 74 20 4c 4f 44 73 7d 20 5c  ifferent LODs} \
4ec0: 0a 09 20 20 20 20 7b 61 74 20 74 68 65 20 62 65  ..    {at the be
4ed0: 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62  ginning of its b
4ee0: 72 61 6e 63 68 20 61 6e 64 20 69 74 73 20 70 61  ranch and its pa
4ef0: 72 65 6e 74 20 77 72 6f 6e 67 6c 79 20 61 67 72  rent wrongly agr
4f00: 65 65 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c  ee about their L
4f10: 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  OD} {...SELECT F
4f20: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
4f30: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  ROM revision R, 
4f40: 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65  revision P, file
4f50: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   F...WHERE R.fid
4f60: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
4f70: 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f   R.bparent IS NO
4f80: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
4f90: 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a  .parent = P.rid.
4fa0: 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20 3d 20  ..AND   R.lod = 
4fb0: 50 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20 20 20 7d  P.lod...;..    }
4fc0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
4fd0: 20 20 20 20 70 72 6f 63 20 43 68 65 63 6b 20 7b      proc Check {
4fe0: 68 65 61 64 65 72 20 6c 61 62 65 6c 20 73 71 6c  header label sql
4ff0: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 6e 20 6e  } {..upvar 1 n n
5000: 0a 09 73 65 74 20 6f 6b 20 31 0a 09 66 6f 72 65  ..set ok 1..fore
5010: 61 63 68 20 7b 66 6e 61 6d 65 20 72 65 76 6e 72  ach {fname revnr
5020: 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 24 73 71  } [state run $sq
5030: 6c 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 6f 6b  l] {..    set ok
5040: 20 30 0a 09 20 20 20 20 74 72 6f 75 62 6c 65 20   0..    trouble 
5050: 66 61 74 61 6c 20 22 24 66 6e 61 6d 65 20 3c 24  fatal "$fname <$
5060: 72 65 76 6e 72 3e 20 24 6c 61 62 65 6c 22 0a 09  revnr> $label"..
5070: 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 35 20 63  }..log write 5 c
5080: 6f 6c 6c 72 65 76 20 22 5c 5b 5b 66 6f 72 6d 61  ollrev "\[[forma
5090: 74 20 25 30 32 64 20 5b 69 6e 63 72 20 6e 5d 5d  t %02d [incr n]]
50a0: 5c 5d 20 5b 65 78 70 72 20 7b 24 6f 6b 20 3f 20  \] [expr {$ok ? 
50b0: 22 4f 6b 20 20 20 20 22 20 3a 20 22 46 61 69 6c  "Ok    " : "Fail
50c0: 65 64 22 7d 5d 20 2e 2e 2e 20 24 68 65 61 64 65  ed"}] ... $heade
50d0: 72 22 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  r"..return.    }
50e0: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
50f0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
5100: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20  #############.  
5110: 20 20 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d 65    ## Internal me
5120: 74 68 6f 64 73 0a 0a 20 20 20 20 23 20 23 20 23  thods..    # # #
5130: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
5140: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
5150: 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67  ##.    ## Config
5160: 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61  uration..    pra
5170: 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 65  gma -hasinstance
5180: 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c  s   no ; # singl
5190: 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20  eton.    pragma 
51a0: 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20  -hastypeinfo    
51b0: 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73  no ; # no intros
51c0: 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67  pection.    prag
51d0: 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73 74 72  ma -hastypedestr
51e0: 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74  oy no ; # immort
51f0: 61 6c 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23  al..    # # ## #
5200: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
5210: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  # #############.
5220: 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61  }..namespace eva
5230: 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  l ::vc::fossil::
5240: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73  import::cvs::pas
5250: 73 20 7b 0a 20 20 20 20 6e 61 6d 65 73 70 61 63  s {.    namespac
5260: 65 20 65 78 70 6f 72 74 20 63 6f 6c 6c 72 65 76  e export collrev
5270: 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65  .    namespace e
5280: 76 61 6c 20 63 6f 6c 6c 72 65 76 20 7b 0a 09 6e  val collrev {..n
5290: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
52a0: 3a 3a 76 63 3a 3a 72 63 73 3a 3a 70 61 72 73 65  ::vc::rcs::parse
52b0: 72 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70  r..namespace imp
52c0: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
52d0: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 72  ::import::cvs::r
52e0: 65 70 6f 73 69 74 6f 72 79 0a 09 6e 61 6d 65 73  epository..names
52f0: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
5300: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
5310: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61  ::cvs::state..na
5320: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
5330: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
5340: 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72  ort::cvs::integr
5350: 69 74 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 65  ity..namespace e
5360: 76 61 6c 20 70 72 6f 6a 65 63 74 20 7b 0a 09 20  val project {.. 
5370: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70     namespace imp
5380: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
5390: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70  ::import::cvs::p
53a0: 72 6f 6a 65 63 74 3a 3a 73 79 6d 0a 09 7d 0a 09  roject::sym..}..
53b0: 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 66  namespace eval f
53c0: 69 6c 65 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73  ile {..    names
53d0: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
53e0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
53f0: 3a 3a 63 76 73 3a 3a 66 69 6c 65 3a 3a 72 65 76  ::cvs::file::rev
5400: 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ..}..namespace i
5410: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c  mport ::vc::tool
5420: 73 3a 3a 74 72 6f 75 62 6c 65 0a 09 6e 61 6d 65  s::trouble..name
5430: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
5440: 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c  c::tools::log..l
5450: 6f 67 20 72 65 67 69 73 74 65 72 20 63 6f 6c 6c  og register coll
5460: 72 65 76 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23  rev.    }.}..# #
5470: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
5480: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
5490: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
54a0: 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65  ##########.## Re
54b0: 61 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f  ady..package pro
54c0: 76 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a  vide vc::fossil:
54d0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61  :import::cvs::pa
54e0: 73 73 3a 3a 63 6f 6c 6c 72 65 76 20 31 2e 30 0a  ss::collrev 1.0.
54f0: 72 65 74 75 72 6e 0a                             return.