Hex Artifact Content
Not logged in

Artifact 643897c97a0558c46ffa98837c3d9f097d0269a6:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [66235f2430] - Updated the copyright information of all files touched in the new year. by aku on 2008-02-06 05:04:12. Also file tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [6b78df3861] - Merge in changes from Andreas's branch. by drh on 2008-02-08 21:52:21.

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 2d 32 30 30 38 20 41 6e 64 72 65 61 73 20  07-2008 Andreas 
0070: 4b 75 70 72 69 65 73 2e 0a 23 0a 23 20 54 68 69  Kupries..#.# Thi
0080: 73 20 73 6f 66 74 77 61 72 65 20 69 73 20 6c 69  s software is li
0090: 63 65 6e 73 65 64 20 61 73 20 64 65 73 63 72 69  censed as descri
00a0: 62 65 64 20 69 6e 20 74 68 65 20 66 69 6c 65 20  bed in the file 
00b0: 4c 49 43 45 4e 53 45 2c 20 77 68 69 63 68 0a 23  LICENSE, which.#
00c0: 20 79 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65   you should have
00d0: 20 72 65 63 65 69 76 65 64 20 61 73 20 70 61 72   received as par
00e0: 74 20 6f 66 20 74 68 69 73 20 64 69 73 74 72 69  t of this distri
00f0: 62 75 74 69 6f 6e 2e 0a 23 0a 23 20 54 68 69 73  bution..#.# This
0100: 20 73 6f 66 74 77 61 72 65 20 63 6f 6e 73 69 73   software consis
0110: 74 73 20 6f 66 20 76 6f 6c 75 6e 74 61 72 79 20  ts of voluntary 
0120: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 73 20 6d 61  contributions ma
0130: 64 65 20 62 79 20 6d 61 6e 79 0a 23 20 69 6e 64  de by many.# ind
0140: 69 76 69 64 75 61 6c 73 2e 20 20 46 6f 72 20 65  ividuals.  For e
0150: 78 61 63 74 20 63 6f 6e 74 72 69 62 75 74 69 6f  xact contributio
0160: 6e 20 68 69 73 74 6f 72 79 2c 20 73 65 65 20 74  n history, see t
0170: 68 65 20 72 65 76 69 73 69 6f 6e 0a 23 20 68 69  he revision.# hi
0180: 73 74 6f 72 79 20 61 6e 64 20 6c 6f 67 73 2c 20  story and logs, 
0190: 61 76 61 69 6c 61 62 6c 65 20 61 74 20 68 74 74  available at htt
01a0: 70 3a 2f 2f 66 6f 73 73 69 6c 2d 73 63 6d 2e 68  p://fossil-scm.h
01b0: 77 61 63 69 2e 63 6f 6d 2f 66 6f 73 73 69 6c 0a  waci.com/fossil.
01c0: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
01d0: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
01e0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
01f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a 23  #############..#
0200: 23 20 50 61 73 73 20 49 49 2e 20 54 68 69 73 20  # Pass II. This 
0210: 70 61 73 73 20 70 61 72 73 65 73 20 74 68 65 20  pass parses the 
0220: 63 6f 6c 6c 65 63 74 65 64 20 72 63 73 20 61 72  collected rcs ar
0230: 63 68 69 76 65 73 20 61 6e 64 20 65 78 74 72 61  chives and extra
0240: 63 74 73 0a 23 23 20 61 6c 6c 20 74 68 65 20 69  cts.## all the i
0250: 6e 66 6f 72 6d 61 74 69 6f 6e 20 74 68 65 79 20  nformation they 
0260: 63 6f 6e 74 61 69 6e 20 28 72 65 76 69 73 69 6f  contain (revisio
0270: 6e 73 2c 20 61 6e 64 20 73 79 6d 62 6f 6c 73 29  ns, and symbols)
0280: 2e 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23  ...# # ## ### ##
0290: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
02a0: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23  ########## #####
02b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
02c0: 0a 23 23 20 52 65 71 75 69 72 65 6d 65 6e 74 73  .## Requirements
02d0: 0a 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72  ..package requir
02e0: 65 20 54 63 6c 20 38 2e 34 20 20 20 20 20 20 20  e Tcl 8.4       
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0300: 20 20 20 20 20 20 20 20 3b 20 23 20 52 65 71 75          ; # Requ
0310: 69 72 65 64 20 72 75 6e 74 69 6d 65 2e 0a 70 61  ired runtime..pa
0320: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 73 6e  ckage require sn
0330: 69 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20  it              
0340: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0350: 20 20 20 20 3b 20 23 20 4f 4f 20 73 79 73 74 65      ; # OO syste
0360: 6d 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69  m..package requi
0370: 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72  re vc::tools::tr
0380: 6f 75 62 6c 65 20 20 20 20 20 20 20 20 20 20 20  ouble           
0390: 20 20 20 20 20 20 20 20 20 3b 20 23 20 45 72 72           ; # Err
03a0: 6f 72 20 72 65 70 6f 72 74 69 6e 67 2e 0a 70 61  or reporting..pa
03b0: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
03c0: 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 20 20 20 20  ::tools::log    
03d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03e0: 20 20 20 20 3b 20 23 20 55 73 65 72 20 66 65 65      ; # User fee
03f0: 64 62 61 63 6b 2e 0a 70 61 63 6b 61 67 65 20 72  dback..package r
0400: 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69  equire vc::fossi
0410: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
0420: 70 61 73 73 20 20 20 20 20 20 20 20 20 3b 20 23  pass         ; #
0430: 20 50 61 73 73 20 6d 61 6e 61 67 65 6d 65 6e 74   Pass management
0440: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72  ..package requir
0450: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  e vc::fossil::im
0460: 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70 6f 73  port::cvs::repos
0470: 69 74 6f 72 79 20 20 20 3b 20 23 20 52 65 70 6f  itory   ; # Repo
0480: 73 69 74 6f 72 79 20 6d 61 6e 61 67 65 6d 65 6e  sitory managemen
0490: 74 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69  t..package requi
04a0: 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69  re vc::fossil::i
04b0: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74  mport::cvs::stat
04c0: 65 20 20 20 20 20 20 20 20 3b 20 23 20 53 74 61  e        ; # Sta
04d0: 74 65 20 73 74 6f 72 61 67 65 2e 0a 70 61 63 6b  te storage..pack
04e0: 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a  age require vc::
04f0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
0500: 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 20 20  cvs::integrity  
0510: 20 20 3b 20 23 20 53 74 61 74 65 20 69 6e 74 65    ; # State inte
0520: 67 72 69 74 79 20 63 68 65 63 6b 73 2e 0a 70 61  grity checks..pa
0530: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
0540: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
0550: 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a  ::cvs::project::
0560: 73 79 6d 20 3b 20 23 20 50 72 6f 6a 65 63 74 20  sym ; # Project 
0570: 6c 65 76 65 6c 20 73 79 6d 62 6f 6c 73 2e 0a 70  level symbols..p
0580: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76  ackage require v
0590: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
05a0: 74 3a 3a 63 76 73 3a 3a 66 69 6c 65 3a 3a 72 65  t::cvs::file::re
05b0: 76 20 20 20 20 3b 20 23 20 46 69 6c 65 20 6c 65  v    ; # File le
05c0: 76 65 6c 20 72 65 76 69 73 69 6f 6e 73 2e 0a 70  vel revisions..p
05d0: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76  ackage require v
05e0: 63 3a 3a 72 63 73 3a 3a 70 61 72 73 65 72 20 20  c::rcs::parser  
05f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0600: 20 20 20 20 20 3b 20 23 20 52 63 73 20 61 72 63       ; # Rcs arc
0610: 68 69 76 65 20 64 61 74 61 20 65 78 74 72 61 63  hive data extrac
0620: 74 69 6f 6e 2e 0a 0a 23 20 23 20 23 23 20 23 23  tion...# # ## ##
0630: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
0640: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23   ############# #
0650: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0660: 23 23 23 23 0a 23 23 20 52 65 67 69 73 74 65 72  ####.## Register
0670: 20 74 68 65 20 70 61 73 73 20 77 69 74 68 20 74   the pass with t
0680: 68 65 20 6d 61 6e 61 67 65 6d 65 6e 74 0a 0a 76  he management..v
0690: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
06a0: 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20 64 65 66  t::cvs::pass def
06b0: 69 6e 65 20 5c 0a 20 20 20 20 43 6f 6c 6c 65 63  ine \.    Collec
06c0: 74 52 65 76 20 5c 0a 20 20 20 20 7b 43 6f 6c 6c  tRev \.    {Coll
06d0: 65 63 74 20 72 65 76 69 73 69 6f 6e 73 20 61 6e  ect revisions an
06e0: 64 20 73 79 6d 62 6f 6c 73 7d 20 5c 0a 20 20 20  d symbols} \.   
06f0: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
0700: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73  mport::cvs::pass
0710: 3a 3a 63 6f 6c 6c 72 65 76 0a 0a 23 20 23 20 23  ::collrev..# # #
0720: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
0730: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
0740: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
0750: 23 23 23 23 23 23 23 23 0a 23 23 0a 0a 73 6e 69  ########.##..sni
0760: 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f  t::type ::vc::fo
0770: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
0780: 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c 6c 72 65 76  s::pass::collrev
0790: 20 7b 0a 20 20 20 20 23 20 23 20 23 23 20 23 23   {.    # # ## ##
07a0: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
07b0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
07c0: 20 20 20 23 23 20 50 75 62 6c 69 63 20 41 50 49     ## Public API
07d0: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
07e0: 20 73 65 74 75 70 20 7b 7d 20 7b 0a 09 23 20 44   setup {} {..# D
07f0: 65 66 69 6e 65 20 6e 61 6d 65 73 20 61 6e 64 20  efine names and 
0800: 73 74 72 75 63 74 75 72 65 20 6f 66 20 74 68 65  structure of the
0810: 20 70 65 72 73 69 73 74 65 6e 74 20 73 74 61 74   persistent stat
0820: 65 20 6f 66 20 74 68 69 73 0a 09 23 20 70 61 73  e of this..# pas
0830: 73 2e 0a 0a 09 73 74 61 74 65 20 75 73 65 20 70  s....state use p
0840: 72 6f 6a 65 63 74 0a 09 73 74 61 74 65 20 75 73  roject..state us
0850: 65 20 66 69 6c 65 0a 0a 09 23 20 57 65 20 64 65  e file...# We de
0860: 61 6c 20 77 69 74 68 20 70 65 72 20 70 72 6f 6a  al with per proj
0870: 65 63 74 20 61 6e 64 20 70 65 72 20 66 69 6c 65  ect and per file
0880: 20 64 61 74 61 2c 20 74 68 65 20 66 69 72 73 74   data, the first
0890: 0a 09 23 20 63 6f 6c 6c 61 74 65 64 20 66 72 6f  ..# collated fro
08a0: 6d 20 74 68 65 20 73 65 63 6f 6e 64 2e 0a 0a 09  m the second....
08b0: 23 20 50 65 72 20 66 69 6c 65 20 77 65 20 68 61  # Per file we ha
08c0: 76 65 20 67 65 6e 65 72 61 6c 20 69 6e 66 6f 72  ve general infor
08d0: 6d 61 74 69 6f 6e 2c 20 2e 2e 2e 2c 20 61 6e 64  mation, ..., and
08e0: 20 74 68 65 6e 0a 09 23 20 72 65 76 69 73 69 6f   then..# revisio
08f0: 6e 73 20 61 6e 64 20 73 79 6d 62 6f 6c 73 2e 20  ns and symbols. 
0900: 54 68 65 20 6c 61 74 74 65 72 20 63 61 6e 20 62  The latter can b
0910: 65 20 66 75 72 74 68 65 72 20 73 65 70 61 72 61  e further separa
0920: 74 65 64 0a 09 23 20 69 6e 74 6f 20 74 61 67 73  ted..# into tags
0930: 20 61 6e 64 20 62 72 61 6e 63 68 65 73 2e 20 41   and branches. A
0940: 74 20 70 72 6f 6a 65 63 74 20 6c 65 76 65 6c 20  t project level 
0950: 74 68 65 20 70 65 72 2d 66 69 6c 65 0a 09 23 20  the per-file..# 
0960: 73 79 6d 62 6f 6c 73 20 69 6e 66 6f 72 6d 61 74  symbols informat
0970: 69 6f 6e 20 69 73 20 6d 65 72 67 65 64 2e 0a 0a  ion is merged...
0980: 09 23 20 46 69 6c 65 20 6c 65 76 65 6c 20 2e 2e  .# File level ..
0990: 2e 0a 09 23 09 52 65 76 69 73 69 6f 6e 73 2c 20  ...#.Revisions, 
09a0: 42 72 61 6e 63 68 65 73 2c 20 54 61 67 73 0a 09  Branches, Tags..
09b0: 23 0a 09 23 20 50 73 65 75 64 6f 20 63 6c 61 73  #..# Pseudo clas
09c0: 73 20 68 69 65 72 61 72 63 68 79 0a 09 23 09 54  s hierarchy..#.T
09d0: 61 67 20 20 20 20 20 20 3c 2d 20 53 79 6d 62 6f  ag      <- Symbo
09e0: 6c 20 3c 2d 20 45 76 65 6e 74 0a 09 23 09 42 72  l <- Event..#.Br
09f0: 61 6e 63 68 20 20 20 3c 2d 20 53 79 6d 62 6f 6c  anch   <- Symbol
0a00: 20 3c 2d 20 45 76 65 6e 74 0a 09 23 09 52 65 76   <- Event..#.Rev
0a10: 69 73 69 6f 6e 20 20 20 20 20 20 20 20 20 20 20  ision           
0a20: 3c 2d 20 45 76 65 6e 74 0a 0a 09 73 74 61 74 65  <- Event...state
0a30: 20 65 78 74 65 6e 64 20 72 65 76 69 73 69 6f 6e   extend revision
0a40: 20 7b 0a 09 20 20 20 20 2d 2d 20 52 65 76 69 73   {..    -- Revis
0a50: 69 6f 6e 73 2e 20 49 64 65 6e 74 69 66 69 65 64  ions. Identified
0a60: 20 62 79 20 61 20 67 6c 6f 62 61 6c 20 6e 75 6d   by a global num
0a70: 65 72 69 63 20 69 64 20 65 61 63 68 0a 09 20 20  eric id each..  
0a80: 20 20 2d 2d 20 62 65 6c 6f 6e 67 73 20 74 6f 20    -- belongs to 
0a90: 61 20 73 69 6e 67 6c 65 20 66 69 6c 65 2c 20 69  a single file, i
0aa0: 64 65 6e 74 69 66 69 65 64 20 62 79 20 69 74 73  dentified by its
0ab0: 20 69 64 2e 20 49 74 0a 09 20 20 20 20 2d 2d 20   id. It..    -- 
0ac0: 66 75 72 74 68 65 72 20 68 61 73 20 61 20 64 6f  further has a do
0ad0: 74 74 65 64 20 72 65 76 69 73 69 6f 6e 20 6e 75  tted revision nu
0ae0: 6d 62 65 72 20 28 44 54 4e 29 2e 0a 09 20 20 20  mber (DTN)...   
0af0: 20 2d 2d 0a 09 20 20 20 20 2d 2d 20 43 6f 6e 73   --..    -- Cons
0b00: 74 72 61 69 6e 74 3a 20 54 68 65 20 64 6f 74 74  traint: The dott
0b10: 65 64 20 72 65 76 69 73 69 6f 6e 20 6e 75 6d 62  ed revision numb
0b20: 65 72 20 69 73 20 75 6e 69 71 75 65 20 77 69 74  er is unique wit
0b30: 68 69 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20  hin.            
0b40: 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 74  --             t
0b50: 68 65 20 66 69 6c 65 2e 20 53 65 65 20 65 6e 64  he file. See end
0b60: 20 6f 66 20 64 65 66 69 6e 69 74 69 6f 6e 2e 0a   of definition..
0b70: 0a 09 20 20 20 20 72 69 64 20 20 49 4e 54 45 47  ..    rid  INTEG
0b80: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52  ER  NOT NULL  PR
0b90: 49 4d 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e  IMARY KEY AUTOIN
0ba0: 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 66 69  CREMENT,..    fi
0bb0: 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  d  INTEGER  NOT 
0bc0: 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53  NULL  REFERENCES
0bd0: 20 66 69 6c 65 2c 20 20 20 2d 2d 20 46 69 6c 65   file,   -- File
0be0: 20 6f 77 6e 69 6e 67 20 72 65 76 69 73 69 6f 6e   owning revision
0bf0: 2e 0a 09 20 20 20 20 72 65 76 20 20 54 45 58 54  ...    rev  TEXT
0c00: 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 20       NOT NULL,  
0c10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0c20: 20 20 2d 2d 20 44 6f 74 74 65 64 20 52 65 76 20    -- Dotted Rev 
0c30: 4e 75 6d 62 65 72 2e 0a 0a 09 20 20 20 20 2d 2d  Number....    --
0c40: 20 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 62   All revisions b
0c50: 65 6c 6f 6e 67 20 74 6f 20 61 20 6c 69 6e 65 2d  elong to a line-
0c60: 6f 66 2d 64 65 76 65 6c 6f 70 6d 65 6e 74 2c 0a  of-development,.
0c70: 09 20 20 20 20 2d 2d 20 69 64 65 6e 74 69 66 69  .    -- identifi
0c80: 65 64 20 62 79 20 61 20 73 79 6d 62 6f 6c 20 28  ed by a symbol (
0c90: 70 72 6f 6a 65 63 74 20 6c 65 76 65 6c 29 2e 20  project level). 
0ca0: 44 75 72 69 6e 67 20 64 61 74 61 0a 09 20 20 20  During data..   
0cb0: 20 2d 2d 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 69   -- collection i
0cc0: 74 20 77 61 73 20 61 20 66 69 6c 65 2d 6c 65 76  t was a file-lev
0cd0: 65 6c 20 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c  el branch symbol
0ce0: 2e 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 20 2d  ...    --..    -
0cf0: 2d 20 43 6f 6e 73 74 72 61 69 6e 74 3a 20 41 6c  - Constraint: Al
0d00: 6c 20 74 68 65 20 4c 4f 44 20 73 79 6d 62 6f 6c  l the LOD symbol
0d10: 73 20 61 72 65 20 69 6e 20 74 68 65 20 73 61 6d  s are in the sam
0d20: 65 20 70 72 6f 6a 65 63 74 0a 09 20 20 20 20 2d  e project..    -
0d30: 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 61 73  -             as
0d40: 20 74 68 65 20 66 69 6c 65 20 69 74 73 65 6c 66   the file itself
0d50: 2e 20 54 68 69 73 20 63 61 6e 6e 6f 74 20 62 65  . This cannot be
0d60: 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20  ..    --        
0d70: 20 20 20 20 20 65 78 70 72 65 73 73 65 64 20 69       expressed i
0d80: 6e 20 43 52 45 41 54 45 20 54 41 42 4c 45 20 73  n CREATE TABLE s
0d90: 79 6e 74 61 78 2e 0a 0a 09 20 20 20 20 6c 6f 64  yntax....    lod
0da0: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
0db0: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
0dc0: 73 79 6d 62 6f 6c 2c 20 2d 2d 20 4c 69 6e 65 20  symbol, -- Line 
0dd0: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 0a 0a  of development..
0de0: 09 20 20 20 20 2d 2d 20 54 68 65 20 72 65 76 69  .    -- The revi
0df0: 73 69 6f 6e 73 20 69 6e 20 61 20 66 69 6c 65 20  sions in a file 
0e00: 61 72 65 20 6f 72 67 61 6e 69 7a 65 64 20 69 6e  are organized in
0e10: 20 61 20 66 6f 72 65 73 74 20 6f 66 0a 09 20 20   a forest of..  
0e20: 20 20 2d 2d 20 74 72 65 65 73 2c 20 77 69 74 68    -- trees, with
0e30: 20 74 68 65 20 6d 61 69 6e 20 6c 69 6e 65 73 20   the main lines 
0e40: 64 65 66 69 6e 65 64 20 74 68 72 6f 75 67 68 20  defined through 
0e50: 74 68 65 20 70 61 72 65 6e 74 20 2f 0a 09 20 20  the parent /..  
0e60: 20 20 2d 2d 20 63 68 69 6c 64 20 72 65 66 65 72    -- child refer
0e70: 65 6e 63 65 73 2e 20 41 20 72 65 76 69 73 69 6f  ences. A revisio
0e80: 6e 20 77 69 74 68 6f 75 74 20 61 20 70 61 72 65  n without a pare
0e90: 6e 74 20 69 73 20 74 68 65 0a 09 20 20 20 20 2d  nt is the..    -
0ea0: 2d 20 72 6f 6f 74 20 6f 66 20 61 20 74 72 65 65  - root of a tree
0eb0: 2c 20 61 6e 64 20 61 20 72 65 76 69 73 69 6f 6e  , and a revision
0ec0: 20 77 69 74 68 6f 75 74 20 61 20 63 68 69 6c 64   without a child
0ed0: 20 69 73 20 61 0a 09 20 20 20 20 2d 2d 20 6c 65   is a..    -- le
0ee0: 61 66 2e 0a 0a 09 20 20 20 20 2d 2d 20 43 6f 6e  af....    -- Con
0ef0: 73 74 72 61 69 6e 74 73 3a 20 41 6c 6c 20 72 65  straints: All re
0f00: 76 69 73 69 6f 6e 73 20 63 6f 75 70 6c 65 64 20  visions coupled 
0f10: 74 68 72 6f 75 67 68 20 70 61 72 65 6e 74 2f 63  through parent/c
0f20: 68 69 6c 64 0a 09 20 20 20 20 2d 2d 20 20 20 20  hild..    --    
0f30: 20 20 20 20 20 20 20 20 20 20 72 65 66 65 72 20            refer 
0f40: 74 6f 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 20  to the same LOD 
0f50: 73 79 6d 62 6f 6c 2e 20 54 68 65 20 70 61 72 65  symbol. The pare
0f60: 6e 74 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20  nt..    --      
0f70: 20 20 20 20 20 20 20 20 6f 66 20 61 20 63 68 69          of a chi
0f80: 6c 64 20 6f 66 20 58 20 69 73 20 58 2e 20 54 68  ld of X is X. Th
0f90: 65 20 63 68 69 6c 64 20 6f 66 20 61 0a 09 20 20  e child of a..  
0fa0: 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20    --            
0fb0: 20 20 70 61 72 65 6e 74 20 6f 66 20 58 20 69 73    parent of X is
0fc0: 20 58 2e 0a 0a 09 20 20 20 20 70 61 72 65 6e 74   X....    parent
0fd0: 20 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20    INTEGER       
0fe0: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
0ff0: 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20 20 20 63  revision,..    c
1000: 68 69 6c 64 20 20 20 49 4e 54 45 47 45 52 20 20  hild   INTEGER  
1010: 20 20 20 20 20 20 20 20 20 20 52 45 46 45 52 45            REFERE
1020: 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a 0a  NCES revision,..
1030: 09 20 20 20 20 2d 2d 20 54 68 65 20 72 65 70 72  .    -- The repr
1040: 65 73 65 6e 74 61 74 69 6f 6e 20 6f 66 20 61 20  esentation of a 
1050: 62 72 61 6e 63 68 20 69 6e 20 61 20 74 72 65 65  branch in a tree
1060: 20 69 73 20 74 68 65 0a 09 20 20 20 20 2d 2d 20   is the..    -- 
1070: 65 78 63 65 70 74 69 6f 6e 20 74 6f 20 74 68 65  exception to the
1080: 20 74 68 72 65 65 20 63 6f 6e 73 74 72 61 69 6e   three constrain
1090: 74 73 20 61 62 6f 76 65 2e 0a 0a 09 20 20 20 20  ts above....    
10a0: 2d 2d 20 54 68 65 20 62 65 67 69 6e 6e 69 6e 67  -- The beginning
10b0: 20 6f 66 20 61 20 62 72 61 6e 63 68 20 69 73 20   of a branch is 
10c0: 72 65 70 72 65 73 65 6e 74 65 64 20 62 79 20 61  represented by a
10d0: 20 6e 6f 6e 2d 4e 55 4c 4c 0a 09 20 20 20 20 2d   non-NULL..    -
10e0: 2d 20 62 70 61 72 65 6e 74 20 6f 66 20 61 20 72  - bparent of a r
10f0: 65 76 69 73 69 6f 6e 2e 20 54 68 69 73 20 72 65  evision. This re
1100: 76 69 73 69 6f 6e 20 42 20 69 73 20 74 68 65 20  vision B is the 
1110: 66 69 72 73 74 20 6f 6e 0a 09 20 20 20 20 2d 2d  first on..    --
1120: 20 74 68 65 20 62 72 61 6e 63 68 2e 20 49 74 73   the branch. Its
1130: 20 70 61 72 65 6e 74 20 50 20 69 73 20 74 68 65   parent P is the
1140: 20 72 65 76 69 73 69 6f 6e 20 74 68 65 20 62 72   revision the br
1150: 61 6e 63 68 20 69 73 0a 09 20 20 20 20 2d 2d 20  anch is..    -- 
1160: 72 6f 6f 74 65 64 20 69 6e 2c 20 61 6e 64 20 69  rooted in, and i
1170: 74 20 69 73 20 6e 6f 74 20 74 68 65 20 63 68 69  t is not the chi
1180: 6c 64 20 6f 66 20 50 2e 20 42 20 61 6e 64 20 50  ld of P. B and P
1190: 20 72 65 66 65 72 0a 09 20 20 20 20 2d 2d 20 74   refer..    -- t
11a0: 6f 20 64 69 66 66 65 72 65 6e 74 20 4c 4f 44 20  o different LOD 
11b0: 73 79 6d 62 6f 6c 73 2e 20 54 68 65 20 62 70 61  symbols. The bpa
11c0: 72 65 6e 74 20 6f 66 20 42 20 69 73 20 61 6c 73  rent of B is als
11d0: 6f 20 69 74 73 0a 09 20 20 20 20 2d 2d 20 4c 4f  o its..    -- LO
11e0: 44 2c 20 61 6e 64 20 74 68 65 20 4c 4f 44 20 6f  D, and the LOD o
11f0: 66 20 69 74 73 20 63 68 69 6c 64 72 65 6e 2e 0a  f its children..
1200: 0a 09 20 20 20 20 62 70 61 72 65 6e 74 20 49 4e  ..    bparent IN
1210: 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20  TEGER           
1220: 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62   REFERENCES symb
1230: 6f 6c 2c 0a 0a 09 20 20 20 20 2d 2d 20 4c 61 73  ol,...    -- Las
1240: 74 6c 79 20 77 65 20 6b 65 65 70 20 69 6e 66 6f  tly we keep info
1250: 72 6d 61 74 69 6f 6e 20 69 73 20 61 62 6f 75 74  rmation is about
1260: 20 6e 6f 6e 2d 74 72 75 6e 6b 20 64 65 66 61 75   non-trunk defau
1270: 6c 74 0a 09 20 20 20 20 2d 2d 20 62 72 61 6e 63  lt..    -- branc
1280: 68 65 73 20 28 4e 54 44 42 29 20 69 6e 20 74 68  hes (NTDB) in th
1290: 65 20 72 65 76 69 73 69 6f 6e 73 2e 0a 0a 09 20  e revisions.... 
12a0: 20 20 20 2d 2d 20 41 6c 6c 20 72 65 76 69 73 69     -- All revisi
12b0: 6f 6e 73 20 6f 6e 20 74 68 65 20 4e 54 44 42 20  ons on the NTDB 
12c0: 68 61 76 65 20 27 69 73 64 65 66 61 75 6c 74 27  have 'isdefault'
12d0: 20 54 52 55 45 2c 0a 09 20 20 20 20 2d 2d 20 65   TRUE,..    -- e
12e0: 76 65 72 79 6f 6e 65 20 65 6c 73 65 20 46 41 4c  veryone else FAL
12f0: 53 45 2e 20 54 68 65 20 6c 61 73 74 20 72 65 76  SE. The last rev
1300: 69 73 69 6f 6e 20 58 20 6f 6e 20 74 68 65 20 4e  ision X on the N
1310: 54 44 42 0a 09 20 20 20 20 2d 2d 20 77 68 69 63  TDB..    -- whic
1320: 68 20 69 73 20 73 74 69 6c 6c 20 63 6f 6e 73 69  h is still consi
1330: 64 65 72 65 64 20 74 6f 20 62 65 20 6f 6e 20 74  dered to be on t
1340: 68 65 20 74 72 75 6e 6b 20 61 73 20 77 65 6c 6c  he trunk as well
1350: 0a 09 20 20 20 20 2d 2d 20 68 61 73 20 61 20 6e  ..    -- has a n
1360: 6f 6e 2d 4e 55 4c 4c 20 27 64 62 63 68 69 6c 64  on-NULL 'dbchild
1370: 27 20 77 68 69 63 68 20 72 65 66 65 72 73 20 74  ' which refers t
1380: 6f 20 74 68 65 20 72 6f 6f 74 20 6f 66 0a 09 20  o the root of.. 
1390: 20 20 20 2d 2d 20 74 68 65 20 74 72 75 6e 6b 2e     -- the trunk.
13a0: 20 54 68 65 20 72 6f 6f 74 20 61 6c 73 6f 20 68   The root also h
13b0: 61 73 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 20 64 62  as a non-NULL db
13c0: 70 61 72 65 6e 74 0a 09 20 20 20 20 2d 2d 20 72  parent..    -- r
13d0: 65 66 65 72 69 6e 67 20 74 6f 20 58 2e 0a 0a 09  efering to X....
13e0: 20 20 20 20 69 73 64 65 66 61 75 6c 74 20 49 4e      isdefault IN
13f0: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c  TEGER  NOT NULL,
1400: 0a 09 20 20 20 20 64 62 70 61 72 65 6e 74 20 20  ..    dbparent  
1410: 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 20  INTEGER         
1420: 20 20 20 52 45 46 45 52 45 4e 43 45 53 20 72 65     REFERENCES re
1430: 76 69 73 69 6f 6e 2c 0a 09 20 20 20 20 64 62 63  vision,..    dbc
1440: 68 69 6c 64 20 20 20 49 4e 54 45 47 45 52 20 20  hild   INTEGER  
1450: 20 20 20 20 20 20 20 20 20 20 52 45 46 45 52 45            REFERE
1460: 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a 0a  NCES revision,..
1470: 09 20 20 20 20 2d 2d 20 54 68 65 20 6d 61 69 6e  .    -- The main
1480: 20 70 61 79 6c 6f 61 64 20 6f 66 20 74 68 65 20   payload of the 
1490: 72 65 76 69 73 69 6f 6e 20 61 72 65 20 74 68 65  revision are the
14a0: 20 64 61 74 65 2f 74 69 6d 65 20 69 74 0a 09 20   date/time it.. 
14b0: 20 20 20 2d 2d 20 77 61 73 20 65 6e 74 65 72 65     -- was entere
14c0: 64 2c 20 69 74 73 20 73 74 61 74 65 2c 20 6f 70  d, its state, op
14d0: 65 72 61 74 69 6f 6e 20 28 3d 20 74 79 70 65 2f  eration (= type/
14e0: 63 6c 61 73 73 29 2c 20 74 65 78 74 0a 09 20 20  class), text..  
14f0: 20 20 2d 2d 20 63 6f 6e 74 65 6e 74 2c 20 61 6e    -- content, an
1500: 64 20 6d 65 74 61 20 64 61 74 61 20 28 61 75 74  d meta data (aut
1510: 68 6f 72 2c 20 6c 6f 67 20 6d 65 73 73 61 67 65  hor, log message
1520: 2c 20 62 72 61 6e 63 68 2c 0a 09 20 20 20 20 2d  , branch,..    -
1530: 2d 20 70 72 6f 6a 65 63 74 29 2e 20 54 68 65 20  - project). The 
1540: 6c 61 73 74 20 69 73 20 65 6e 63 6f 64 65 64 20  last is encoded 
1550: 61 73 20 73 69 6e 67 6c 65 20 69 64 2c 20 73 65  as single id, se
1560: 65 20 74 61 62 6c 65 0a 09 20 20 20 20 2d 2d 20  e table..    -- 
1570: 27 6d 65 74 61 27 2e 20 54 68 65 20 64 61 74 65  'meta'. The date
1580: 2f 74 69 6d 65 20 69 73 20 67 69 76 65 6e 20 69  /time is given i
1590: 6e 20 73 65 63 6f 6e 64 73 20 73 69 6e 63 65 20  n seconds since 
15a0: 74 68 65 0a 09 20 20 20 20 2d 2d 20 65 70 6f 63  the..    -- epoc
15b0: 68 2c 20 66 6f 72 20 65 61 73 79 20 63 6f 6d 70  h, for easy comp
15c0: 61 72 69 73 6f 6e 2e 0a 0a 09 20 20 20 20 6f 70  arison....    op
15d0: 20 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54      INTEGER  NOT
15e0: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
15f0: 53 20 6f 70 74 79 70 65 2c 0a 09 20 20 20 20 64  S optype,..    d
1600: 61 74 65 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  ate  INTEGER  NO
1610: 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 73 74 61  T NULL,..    sta
1620: 74 65 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20  te TEXT     NOT 
1630: 4e 55 4c 4c 2c 0a 09 20 20 20 20 6d 69 64 20 20  NULL,..    mid  
1640: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1650: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 6d  LL  REFERENCES m
1660: 65 74 61 2c 0a 0a 09 20 20 20 20 55 4e 49 51 55  eta,...    UNIQU
1670: 45 20 28 66 69 64 2c 20 72 65 76 29 20 2d 2d 20  E (fid, rev) -- 
1680: 54 68 65 20 44 54 4e 20 69 73 20 75 6e 69 71 75  The DTN is uniqu
1690: 65 20 77 69 74 68 69 6e 20 74 68 65 20 72 65 76  e within the rev
16a0: 69 73 69 6f 6e 27 73 20 66 69 6c 65 2e 0a 09 7d  ision's file...}
16b0: 0a 0a 09 23 20 42 6c 6f 62 73 20 63 6f 6e 74 61  ...# Blobs conta
16c0: 69 6e 20 74 68 65 20 69 6e 66 6f 72 6d 61 74 69  in the informati
16d0: 6f 6e 20 6e 65 65 64 65 64 20 74 6f 20 65 78 74  on needed to ext
16e0: 72 61 63 74 20 72 65 76 69 73 69 6f 6e 73 0a 09  ract revisions..
16f0: 23 20 66 72 6f 6d 20 72 63 73 20 61 72 63 68 69  # from rcs archi
1700: 76 65 20 66 69 6c 65 73 2e 20 41 73 20 73 75 63  ve files. As suc
1710: 68 20 65 61 63 68 20 72 65 76 69 73 69 6f 6e 20  h each revision 
1720: 68 61 73 20 61 6e 0a 09 23 20 61 73 73 6f 63 69  has an..# associ
1730: 61 74 65 64 20 62 6c 6f 62 2e 20 48 6f 77 65 76  ated blob. Howev
1740: 65 72 20 77 65 20 63 61 6e 20 68 61 76 65 20 62  er we can have b
1750: 6c 6f 62 73 20 77 69 74 68 6f 75 74 0a 09 23 20  lobs without..# 
1760: 72 65 76 69 73 69 6f 6e 73 2e 20 54 68 69 73 20  revisions. This 
1770: 68 61 70 70 65 6e 73 20 69 66 20 61 20 6c 6f 67  happens if a log
1780: 69 63 61 6c 6c 79 20 69 72 72 65 6c 65 76 61 6e  ically irrelevan
1790: 74 20 72 65 76 69 73 69 6f 6e 0a 09 23 20 69 73  t revision..# is
17a0: 20 72 65 6d 6f 76 65 64 2e 20 57 65 20 6d 61 79   removed. We may
17b0: 20 68 6f 77 65 76 65 72 20 73 74 69 6c 6c 20 6e   however still n
17c0: 65 65 64 20 69 74 73 20 62 6c 6f 62 20 74 6f 20  eed its blob to 
17d0: 63 6f 72 72 65 63 74 6c 79 0a 09 23 20 65 78 70  correctly..# exp
17e0: 61 6e 64 20 6f 74 68 65 72 20 72 65 76 69 73 69  and other revisi
17f0: 6f 6e 73 2c 20 62 6f 74 68 20 69 74 73 20 63 6f  ons, both its co
1800: 6e 74 65 6e 74 73 20 61 6e 64 20 66 6f 72 20 74  ntents and for t
1810: 68 65 0a 09 23 20 6f 72 64 65 72 69 6e 67 2e 0a  he..# ordering..
1820: 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64 20 62  ..state extend b
1830: 6c 6f 62 20 7b 0a 09 20 20 20 20 62 69 64 20 20  lob {..    bid  
1840: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1850: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41  L  PRIMARY KEY A
1860: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20  UTOINCREMENT,.. 
1870: 20 20 20 72 69 64 20 20 49 4e 54 45 47 45 52 20     rid  INTEGER 
1880: 20 20 20 20 20 20 20 20 20 20 20 52 45 46 45 52             REFER
1890: 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a  ENCES revision,.
18a0: 09 20 20 20 20 66 69 64 20 20 49 4e 54 45 47 45  .    fid  INTEGE
18b0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
18c0: 45 52 45 4e 43 45 53 20 66 69 6c 65 2c 20 20 20  ERENCES file,   
18d0: 2d 2d 20 46 69 6c 65 20 6f 77 6e 69 6e 67 20 62  -- File owning b
18e0: 6c 6f 62 2e 0a 0a 09 20 20 20 20 2d 2d 20 54 68  lob....    -- Th
18f0: 65 20 74 65 78 74 20 63 6f 6e 74 65 6e 74 20 69  e text content i
1900: 73 20 61 6e 20 28 6f 66 66 73 65 74 2c 6c 65 6e  s an (offset,len
1910: 67 74 68 29 20 70 61 69 72 20 69 6e 74 6f 20 74  gth) pair into t
1920: 68 65 0a 09 20 20 20 20 2d 2d 20 72 63 73 20 61  he..    -- rcs a
1930: 72 63 68 69 76 65 2e 20 46 6f 72 20 64 65 6c 74  rchive. For delt
1940: 61 73 20 77 65 20 61 64 64 69 74 69 6f 6e 61 6c  as we additional
1950: 6c 79 20 72 65 66 65 72 20 74 6f 20 74 68 65 0a  ly refer to the.
1960: 09 20 20 20 20 2d 2d 20 70 61 72 65 6e 74 20 62  .    -- parent b
1970: 6c 6f 62 20 74 68 65 20 64 65 6c 74 61 20 69 73  lob the delta is
1980: 20 6d 61 64 65 20 61 67 61 69 6e 73 74 2e 0a 0a   made against...
1990: 09 20 20 20 20 63 6f 66 66 20 49 4e 54 45 47 45  .    coff INTEGE
19a0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20  R  NOT NULL,..  
19b0: 20 20 63 6c 65 6e 20 49 4e 54 45 47 45 52 20 20    clen INTEGER  
19c0: 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 70  NOT NULL,..    p
19d0: 69 64 20 20 49 4e 54 45 47 45 52 20 20 20 20 20  id  INTEGER     
19e0: 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45         REFERENCE
19f0: 53 20 62 6c 6f 62 2c 0a 0a 09 20 20 20 20 55 4e  S blob,...    UN
1a00: 49 51 55 45 20 28 72 69 64 29 0a 09 7d 20 7b 20  IQUE (rid)..} { 
1a10: 66 69 64 20 7d 0a 09 23 20 49 6e 64 65 78 20 6f  fid }..# Index o
1a20: 6e 20 6f 77 6e 69 6e 67 20 66 69 6c 65 20 74 6f  n owning file to
1a30: 20 63 6f 6c 6c 65 63 74 20 61 6c 6c 20 62 6c 6f   collect all blo
1a40: 62 73 20 6f 66 20 61 20 66 69 6c 65 20 77 68 65  bs of a file whe
1a50: 6e 20 74 68 65 0a 09 23 20 74 69 6d 65 20 66 6f  n the..# time fo
1a60: 72 20 69 74 73 20 65 78 70 61 6e 73 69 6f 6e 20  r its expansion 
1a70: 63 6f 6d 65 73 2e 0a 0a 09 73 74 61 74 65 20 65  comes....state e
1a80: 78 74 65 6e 64 20 6f 70 74 79 70 65 20 7b 0a 09  xtend optype {..
1a90: 20 20 20 20 6f 69 64 20 20 20 49 4e 54 45 47 45      oid   INTEGE
1aa0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49  R  NOT NULL  PRI
1ab0: 4d 41 52 59 20 4b 45 59 2c 0a 09 20 20 20 20 6e  MARY KEY,..    n
1ac0: 61 6d 65 20 20 54 45 58 54 20 20 20 20 20 4e 4f  ame  TEXT     NO
1ad0: 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 55 4e 49  T NULL,..    UNI
1ae0: 51 55 45 28 6e 61 6d 65 29 0a 09 7d 0a 09 73 74  QUE(name)..}..st
1af0: 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 49  ate run {..    I
1b00: 4e 53 45 52 54 20 49 4e 54 4f 20 6f 70 74 79 70  NSERT INTO optyp
1b10: 65 20 56 41 4c 55 45 53 20 28 2d 31 2c 27 64 65  e VALUES (-1,'de
1b20: 6c 65 74 65 27 29 3b 20 20 2d 2d 20 54 68 65 20  lete');  -- The 
1b30: 6f 70 63 6f 64 65 20 6e 61 6d 65 73 20 61 72 65  opcode names are
1b40: 20 74 68 65 0a 09 20 20 20 20 49 4e 53 45 52 54   the..    INSERT
1b50: 20 49 4e 54 4f 20 6f 70 74 79 70 65 20 56 41 4c   INTO optype VAL
1b60: 55 45 53 20 28 20 30 2c 27 6e 6f 74 68 69 6e 67  UES ( 0,'nothing
1b70: 27 29 3b 20 2d 2d 20 66 69 78 65 64 20 70 69 65  '); -- fixed pie
1b80: 63 65 73 2c 20 73 65 65 20 6d 79 6f 70 73 74 61  ces, see myopsta
1b90: 74 65 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49  te..    INSERT I
1ba0: 4e 54 4f 20 6f 70 74 79 70 65 20 56 41 4c 55 45  NTO optype VALUE
1bb0: 53 20 28 20 31 2c 27 61 64 64 27 29 3b 20 20 20  S ( 1,'add');   
1bc0: 20 20 2d 2d 20 69 6e 20 66 69 6c 65 3a 3a 72 65    -- in file::re
1bd0: 76 2e 20 6d 79 6f 70 63 6f 64 65 20 69 73 0a 09  v. myopcode is..
1be0: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
1bf0: 6f 70 74 79 70 65 20 56 41 4c 55 45 53 20 28 20  optype VALUES ( 
1c00: 32 2c 27 63 68 61 6e 67 65 27 29 3b 20 20 2d 2d  2,'change');  --
1c10: 20 6c 6f 61 64 65 64 20 66 72 6f 6d 20 74 68 69   loaded from thi
1c20: 73 2e 0a 09 7d 0a 0a 09 73 74 61 74 65 20 65 78  s...}...state ex
1c30: 74 65 6e 64 20 72 65 76 69 73 69 6f 6e 62 72 61  tend revisionbra
1c40: 6e 63 68 63 68 69 6c 64 72 65 6e 20 7b 0a 09 20  nchchildren {.. 
1c50: 20 20 20 2d 2d 20 54 68 65 20 6e 6f 6e 2d 70 72     -- The non-pr
1c60: 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20 6f  imary children o
1c70: 66 20 61 20 72 65 76 69 73 69 6f 6e 2c 20 61 73  f a revision, as
1c80: 20 72 65 61 63 68 61 62 6c 65 0a 09 20 20 20 20   reachable..    
1c90: 2d 2d 20 74 68 72 6f 75 67 68 20 61 20 62 72 61  -- through a bra
1ca0: 6e 63 68 20 73 79 6d 62 6f 6c 2c 20 61 72 65 20  nch symbol, are 
1cb0: 6c 69 73 74 65 64 20 68 65 72 65 2e 20 54 68 69  listed here. Thi
1cc0: 73 20 69 73 0a 09 20 20 20 20 2d 2d 20 6e 65 65  s is..    -- nee
1cd0: 64 65 64 20 62 79 20 70 61 73 73 20 35 20 74 6f  ded by pass 5 to
1ce0: 20 62 72 65 61 6b 20 69 6e 74 65 72 6e 61 6c 20   break internal 
1cf0: 64 65 70 65 6e 64 65 6e 63 69 65 73 20 69 6e 20  dependencies in 
1d00: 61 0a 09 20 20 20 20 2d 2d 20 63 68 61 6e 67 65  a..    -- change
1d10: 73 65 74 2e 0a 0a 09 20 20 20 20 72 69 64 20 20  set....    rid  
1d20: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1d30: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 72  LL  REFERENCES r
1d40: 65 76 69 73 69 6f 6e 2c 0a 09 20 20 20 20 62 72  evision,..    br
1d50: 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  id  INTEGER  NOT
1d60: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
1d70: 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20 20  S revision,..   
1d80: 20 55 4e 49 51 55 45 28 72 69 64 2c 62 72 69 64   UNIQUE(rid,brid
1d90: 29 0a 09 7d 0a 0a 09 73 74 61 74 65 20 65 78 74  )..}...state ext
1da0: 65 6e 64 20 74 61 67 20 7b 0a 09 20 20 20 20 74  end tag {..    t
1db0: 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  id  INTEGER  NOT
1dc0: 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b   NULL  PRIMARY K
1dd0: 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54  EY AUTOINCREMENT
1de0: 2c 0a 09 20 20 20 20 66 69 64 20 20 49 4e 54 45  ,..    fid  INTE
1df0: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52  GER  NOT NULL  R
1e00: 45 46 45 52 45 4e 43 45 53 20 66 69 6c 65 2c 20  EFERENCES file, 
1e10: 20 20 20 20 2d 2d 20 46 69 6c 65 20 74 68 65 20      -- File the 
1e20: 69 74 65 6d 20 62 65 6c 6f 6e 67 73 20 74 6f 0a  item belongs to.
1e30: 09 20 20 20 20 6c 6f 64 20 20 49 4e 54 45 47 45  .    lod  INTEGE
1e40: 52 20 20 20 20 20 20 20 20 20 20 20 20 52 45 46  R            REF
1e50: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
1e60: 20 20 2d 2d 20 4c 69 6e 65 20 6f 66 20 64 65 76    -- Line of dev
1e70: 65 6c 6f 70 6d 65 6e 74 20 28 4e 55 4c 4c 20 3d  elopment (NULL =
1e80: 3e 20 54 72 75 6e 6b 29 0a 09 20 20 20 20 73 69  > Trunk)..    si
1e90: 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  d  INTEGER  NOT 
1ea0: 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53  NULL  REFERENCES
1eb0: 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20 53 79   symbol,   -- Sy
1ec0: 6d 62 6f 6c 20 63 61 70 74 75 72 69 6e 67 20 74  mbol capturing t
1ed0: 68 65 20 74 61 67 0a 0a 09 20 20 20 20 72 65 76  he tag...    rev
1ee0: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
1ef0: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
1f00: 72 65 76 69 73 69 6f 6e 20 20 2d 2d 20 54 68 65  revision  -- The
1f10: 20 72 65 76 69 73 69 6f 6e 20 62 65 69 6e 67 20   revision being 
1f20: 74 61 67 67 65 64 2e 0a 09 7d 20 7b 20 72 65 76  tagged...} { rev
1f30: 20 73 69 64 20 7d 0a 09 23 20 49 6e 64 69 63 65   sid }..# Indice
1f40: 73 20 6f 6e 3a 20 72 65 76 20 28 72 65 76 69 73  s on: rev (revis
1f50: 69 6f 6e 20 73 75 63 63 65 73 73 6f 72 73 29 0a  ion successors).
1f60: 09 23 20 20 20 20 20 20 20 20 20 20 20 20 20 73  .#             s
1f70: 69 64 20 28 74 61 67 20 70 72 65 64 65 63 65 73  id (tag predeces
1f80: 73 6f 72 73 2c 20 62 72 61 6e 63 68 20 73 75 63  sors, branch suc
1f90: 63 65 73 73 6f 72 73 2f 70 72 65 64 65 63 65 73  cessors/predeces
1fa0: 73 6f 72 73 29 0a 0a 09 73 74 61 74 65 20 65 78  sors)...state ex
1fb0: 74 65 6e 64 20 62 72 61 6e 63 68 20 7b 0a 09 20  tend branch {.. 
1fc0: 20 20 20 62 69 64 20 20 20 49 4e 54 45 47 45 52     bid   INTEGER
1fd0: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d    NOT NULL  PRIM
1fe0: 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43 52  ARY KEY AUTOINCR
1ff0: 45 4d 45 4e 54 2c 0a 09 20 20 20 20 66 69 64 20  EMENT,..    fid 
2000: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
2010: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
2020: 66 69 6c 65 2c 20 20 20 20 20 2d 2d 20 46 69 6c  file,     -- Fil
2030: 65 20 74 68 65 20 69 74 65 6d 20 62 65 6c 6f 6e  e the item belon
2040: 67 73 20 74 6f 0a 09 20 20 20 20 6c 6f 64 20 20  gs to..    lod  
2050: 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20   INTEGER        
2060: 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20 73      REFERENCES s
2070: 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20 4c 69 6e 65  ymbol,   -- Line
2080: 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20   of development 
2090: 28 4e 55 4c 4c 20 3d 3e 20 54 72 75 6e 6b 29 0a  (NULL => Trunk).
20a0: 09 20 20 20 20 73 69 64 20 20 20 49 4e 54 45 47  .    sid   INTEG
20b0: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45  ER  NOT NULL  RE
20c0: 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c  FERENCES symbol,
20d0: 20 20 20 2d 2d 20 53 79 6d 62 6f 6c 20 63 61 70     -- Symbol cap
20e0: 74 75 72 69 6e 67 20 74 68 65 20 62 72 61 6e 63  turing the branc
20f0: 68 0a 0a 09 20 20 20 20 72 6f 6f 74 20 20 49 4e  h...    root  IN
2100: 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20  TEGER           
2110: 20 52 45 46 45 52 45 4e 43 45 53 20 72 65 76 69   REFERENCES revi
2120: 73 69 6f 6e 2c 20 2d 2d 20 52 65 76 69 73 69 6f  sion, -- Revisio
2130: 6e 20 74 68 65 20 62 72 61 6e 63 68 20 73 70 72  n the branch spr
2140: 6f 75 74 73 20 66 72 6f 6d 0a 09 20 20 20 20 66  outs from..    f
2150: 69 72 73 74 20 49 4e 54 45 47 45 52 20 20 20 20  irst INTEGER    
2160: 20 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43          REFERENC
2170: 45 53 20 72 65 76 69 73 69 6f 6e 2c 20 2d 2d 20  ES revision, -- 
2180: 46 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 63  First revision c
2190: 6f 6d 6d 69 74 74 65 64 20 74 6f 20 74 68 65 20  ommitted to the 
21a0: 62 72 61 6e 63 68 0a 09 20 20 20 20 62 72 61 20  branch..    bra 
21b0: 20 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e    TEXT     NOT N
21c0: 55 4c 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20  ULL,            
21d0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 62 72 61            -- bra
21e0: 6e 63 68 20 6e 75 6d 62 65 72 0a 09 20 20 20 20  nch number..    
21f0: 70 6f 73 20 20 20 49 4e 54 45 47 45 52 20 20 4e  pos   INTEGER  N
2200: 4f 54 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20  OT NULL         
2210: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d                --
2220: 20 63 72 65 61 74 69 6f 6e 20 6f 72 64 65 72 20   creation order 
2230: 69 6e 20 72 6f 6f 74 2e 0a 0a 09 20 20 20 20 2d  in root....    -
2240: 2d 20 41 20 62 72 61 6e 63 68 20 63 61 6e 20 65  - A branch can e
2250: 78 69 73 74 20 77 69 74 68 6f 75 74 20 72 6f 6f  xist without roo
2260: 74 2e 20 49 74 20 68 61 70 70 65 6e 73 20 77 68  t. It happens wh
2270: 65 6e 20 74 68 65 0a 20 20 20 20 20 20 20 20 20  en the.         
2280: 20 20 20 2d 2d 20 6f 6e 6c 79 20 72 65 76 69 73     -- only revis
2290: 69 6f 6e 20 6f 6e 20 74 72 75 6e 6b 20 69 73 20  ion on trunk is 
22a0: 74 68 65 20 75 6e 6e 65 63 65 73 73 61 72 79 20  the unnecessary 
22b0: 64 65 61 64 20 6f 6e 65 20 74 68 65 0a 20 20 20  dead one the.   
22c0: 20 20 20 20 20 20 20 20 20 2d 2d 20 62 72 61 6e           -- bran
22d0: 63 68 20 77 61 73 20 73 70 72 6f 75 74 65 64 20  ch was sprouted 
22e0: 66 72 6f 6d 20 61 6e 64 20 69 74 20 68 61 73 20  from and it has 
22f0: 63 6f 6d 6d 69 74 73 2e 20 54 68 65 20 62 72 61  commits. The bra
2300: 6e 63 68 0a 20 20 20 20 20 20 20 20 20 20 20 20  nch.            
2310: 2d 2d 20 77 69 6c 6c 20 65 78 69 73 74 20 74 6f  -- will exist to
2320: 20 62 65 20 74 68 65 20 4c 4f 44 20 6f 66 20 69   be the LOD of i
2330: 74 73 20 72 65 76 69 73 69 6f 6e 73 2c 20 6e 6f  ts revisions, no
2340: 74 68 69 6e 67 20 74 6f 0a 20 20 20 20 20 20 20  thing to.       
2350: 20 20 20 20 20 2d 2d 20 73 70 72 6f 75 74 20 66       -- sprout f
2360: 72 6f 6d 2c 20 74 68 65 20 64 65 61 64 20 72 65  rom, the dead re
2370: 76 69 73 69 6f 6e 20 77 61 73 20 72 65 6d 6f 76  vision was remov
2380: 65 64 2c 20 68 65 6e 63 65 20 6e 6f 0a 20 20 20  ed, hence no.   
2390: 20 20 20 20 20 20 20 20 20 2d 2d 20 72 6f 6f 74           -- root
23a0: 2e 0a 09 7d 20 7b 20 72 6f 6f 74 20 66 69 72 73  ...} { root firs
23b0: 74 20 73 69 64 20 7d 0a 09 23 20 49 6e 64 69 63  t sid }..# Indic
23c0: 65 73 20 6f 6e 3a 20 72 6f 6f 74 20 20 28 72 65  es on: root  (re
23d0: 76 69 73 69 6f 6e 20 73 75 63 63 65 73 73 6f 72  vision successor
23e0: 73 29 0a 09 23 20 20 20 20 20 20 20 20 20 20 20  s)..#           
23f0: 20 20 66 69 72 73 74 20 28 72 65 76 69 73 69 6f    first (revisio
2400: 6e 20 70 72 65 64 65 63 65 73 73 6f 72 73 29 0a  n predecessors).
2410: 09 23 20 20 20 20 20 20 20 20 20 20 20 20 20 73  .#             s
2420: 69 64 20 20 20 28 74 61 67 20 70 72 65 64 65 63  id   (tag predec
2430: 65 73 73 6f 72 73 2c 20 62 72 61 6e 63 68 20 73  essors, branch s
2440: 75 63 63 65 73 73 6f 72 73 2f 70 72 65 64 65 63  uccessors/predec
2450: 65 73 73 6f 72 73 29 0a 0a 09 23 20 50 72 6f 6a  essors)...# Proj
2460: 65 63 74 20 6c 65 76 65 6c 20 2e 2e 2e 0a 09 23  ect level .....#
2470: 09 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d  .pLineOfDevelopm
2480: 65 6e 74 2c 20 70 53 79 6d 62 6f 6c 2c 20 70 42  ent, pSymbol, pB
2490: 72 61 6e 63 68 2c 20 70 54 61 67 2c 20 70 54 72  ranch, pTag, pTr
24a0: 75 6e 6b 0a 09 23 0a 09 23 09 70 54 72 75 6e 6b  unk..#..#.pTrunk
24b0: 20 20 3c 2d 20 70 4c 69 6e 65 4f 66 44 65 76 65    <- pLineOfDeve
24c0: 6c 6f 70 6d 65 6e 74 0a 09 23 09 70 42 72 61 6e  lopment..#.pBran
24d0: 63 68 20 3c 2d 20 70 53 79 6d 62 6f 6c 2c 20 70  ch <- pSymbol, p
24e0: 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d 65 6e  LineOfDevelopmen
24f0: 74 0a 09 23 09 70 54 61 67 20 20 20 20 3c 2d 20  t..#.pTag    <- 
2500: 70 53 79 6d 62 6f 6c 2c 20 70 4c 69 6e 65 4f 66  pSymbol, pLineOf
2510: 44 65 76 65 6c 6f 70 6d 65 6e 74 0a 0a 09 73 74  Development...st
2520: 61 74 65 20 65 78 74 65 6e 64 20 73 79 6d 62 6f  ate extend symbo
2530: 6c 20 7b 0a 09 20 20 20 20 73 69 64 20 20 49 4e  l {..    sid  IN
2540: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
2550: 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41 55 54   PRIMARY KEY AUT
2560: 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20  OINCREMENT,..   
2570: 20 70 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e   pid  INTEGER  N
2580: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
2590: 43 45 53 20 70 72 6f 6a 65 63 74 2c 20 20 2d 2d  CES project,  --
25a0: 20 50 72 6f 6a 65 63 74 20 74 68 65 20 73 79 6d   Project the sym
25b0: 62 6f 6c 20 62 65 6c 6f 6e 67 73 20 74 6f 0a 09  bol belongs to..
25c0: 20 20 20 20 6e 61 6d 65 20 54 45 58 54 20 20 20      name TEXT   
25d0: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20    NOT NULL,..   
25e0: 20 74 79 70 65 20 49 4e 54 45 47 45 52 20 20 4e   type INTEGER  N
25f0: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
2600: 43 45 53 20 73 79 6d 74 79 70 65 2c 20 20 2d 2d  CES symtype,  --
2610: 20 65 6e 75 6d 20 7b 20 65 78 63 6c 75 64 65 64   enum { excluded
2620: 20 3d 20 30 2c 20 74 61 67 2c 20 62 72 61 6e 63   = 0, tag, branc
2630: 68 2c 20 75 6e 64 65 66 69 6e 65 64 20 7d 0a 0a  h, undefined }..
2640: 09 20 20 20 20 74 61 67 5f 63 6f 75 6e 74 20 20  .    tag_count  
2650: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
2660: 55 4c 4c 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65  ULL, -- How ofte
2670: 6e 20 74 68 65 20 73 79 6d 62 6f 6c 20 69 73 20  n the symbol is 
2680: 75 73 65 64 20 61 73 20 74 61 67 2e 0a 09 20 20  used as tag...  
2690: 20 20 62 72 61 6e 63 68 5f 63 6f 75 6e 74 20 49    branch_count I
26a0: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
26b0: 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 74  , -- How often t
26c0: 68 65 20 73 79 6d 62 6f 6c 20 69 73 20 75 73 65  he symbol is use
26d0: 64 20 61 73 20 62 72 61 6e 63 68 0a 09 20 20 20  d as branch..   
26e0: 20 63 6f 6d 6d 69 74 5f 63 6f 75 6e 74 20 49 4e   commit_count IN
26f0: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c  TEGER  NOT NULL,
2700: 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 61 20   -- How often a 
2710: 66 69 6c 65 20 77 61 73 20 63 6f 6d 6d 69 74 74  file was committ
2720: 65 64 20 6f 6e 20 74 68 65 20 73 79 6d 62 6f 6c  ed on the symbol
2730: 0a 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 70  ...    UNIQUE (p
2740: 69 64 2c 20 6e 61 6d 65 29 20 2d 2d 20 53 79 6d  id, name) -- Sym
2750: 62 6f 6c 73 20 61 72 65 20 75 6e 69 71 75 65 20  bols are unique 
2760: 77 69 74 68 69 6e 20 74 68 65 20 70 72 6f 6a 65  within the proje
2770: 63 74 0a 09 7d 0a 0a 09 73 74 61 74 65 20 65 78  ct..}...state ex
2780: 74 65 6e 64 20 62 6c 6f 63 6b 65 72 20 7b 0a 09  tend blocker {..
2790: 20 20 20 20 2d 2d 20 46 6f 72 20 65 61 63 68 20      -- For each 
27a0: 73 79 6d 62 6f 6c 20 77 65 20 73 61 76 65 20 77  symbol we save w
27b0: 68 69 63 68 20 6f 74 68 65 72 20 73 79 6d 62 6f  hich other symbo
27c0: 6c 73 20 61 72 65 0a 09 20 20 20 20 2d 2d 20 62  ls are..    -- b
27d0: 6c 6f 63 6b 69 6e 67 20 69 74 73 20 72 65 6d 6f  locking its remo
27e0: 76 61 6c 20 28 69 66 20 74 68 65 20 75 73 65 72  val (if the user
27f0: 20 61 73 6b 73 20 66 6f 72 20 69 74 29 2e 0a 0a   asks for it)...
2800: 09 20 20 20 20 73 69 64 20 49 4e 54 45 47 45 52  .    sid INTEGER
2810: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
2820: 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d  RENCES symbol, -
2830: 2d 0a 09 20 20 20 20 62 69 64 20 49 4e 54 45 47  -..    bid INTEG
2840: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45  ER  NOT NULL  RE
2850: 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c  FERENCES symbol,
2860: 20 2d 2d 20 53 70 72 6f 75 74 65 64 20 66 72 6f   -- Sprouted fro
2870: 6d 20 73 69 64 2c 20 62 6c 6f 63 6b 73 20 69 74  m sid, blocks it
2880: 2e 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 73  ...    UNIQUE (s
2890: 69 64 2c 20 62 69 64 29 0a 09 7d 0a 0a 09 73 74  id, bid)..}...st
28a0: 61 74 65 20 65 78 74 65 6e 64 20 70 61 72 65 6e  ate extend paren
28b0: 74 20 7b 0a 09 20 20 20 20 2d 2d 20 46 6f 72 20  t {..    -- For 
28c0: 65 61 63 68 20 73 79 6d 62 6f 6c 20 77 65 20 73  each symbol we s
28d0: 61 76 65 20 77 68 69 63 68 20 6f 74 68 65 72 20  ave which other 
28e0: 73 79 6d 62 6f 6c 73 20 63 61 6e 20 61 63 74 20  symbols can act 
28f0: 61 73 0a 09 20 20 20 20 2d 2d 20 61 20 70 6f 73  as..    -- a pos
2900: 73 69 62 6c 65 20 70 61 72 65 6e 74 20 69 6e 20  sible parent in 
2910: 73 6f 6d 65 20 66 69 6c 65 2c 20 61 6e 64 20 68  some file, and h
2920: 6f 77 20 6f 66 74 65 6e 2e 0a 0a 09 20 20 20 20  ow often....    
2930: 73 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  sid INTEGER  NOT
2940: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
2950: 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 0a 09 20 20  S symbol, --..  
2960: 20 20 70 69 64 20 49 4e 54 45 47 45 52 20 20 4e    pid INTEGER  N
2970: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
2980: 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20 50  CES symbol, -- P
2990: 6f 73 73 69 62 6c 65 20 70 61 72 65 6e 74 20 6f  ossible parent o
29a0: 66 20 73 69 64 0a 09 20 20 20 20 6e 20 20 20 49  f sid..    n   I
29b0: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
29c0: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,               
29d0: 20 20 20 20 20 2d 2d 20 48 6f 77 20 6f 66 74 65       -- How ofte
29e0: 6e 20 70 69 64 20 63 61 6e 20 61 63 74 20 61 73  n pid can act as
29f0: 20 70 61 72 65 6e 74 2e 0a 09 20 20 20 20 55 4e   parent...    UN
2a00: 49 51 55 45 20 28 73 69 64 2c 20 70 69 64 29 0a  IQUE (sid, pid).
2a10: 09 7d 0a 0a 09 73 74 61 74 65 20 65 78 74 65 6e  .}...state exten
2a20: 64 20 73 79 6d 74 79 70 65 20 7b 0a 09 20 20 20  d symtype {..   
2a30: 20 74 69 64 20 20 20 20 49 4e 54 45 47 45 52 20   tid    INTEGER 
2a40: 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41   NOT NULL  PRIMA
2a50: 52 59 20 4b 45 59 2c 0a 09 20 20 20 20 6e 61 6d  RY KEY,..    nam
2a60: 65 20 20 20 54 45 58 54 20 20 20 20 20 4e 4f 54  e   TEXT     NOT
2a70: 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 70 6c 75 72   NULL,..    plur
2a80: 61 6c 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20  al TEXT     NOT 
2a90: 4e 55 4c 4c 2c 0a 09 20 20 20 20 55 4e 49 51 55  NULL,..    UNIQU
2aa0: 45 20 28 6e 61 6d 65 29 0a 09 20 20 20 20 55 4e  E (name)..    UN
2ab0: 49 51 55 45 20 28 70 6c 75 72 61 6c 29 0a 09 7d  IQUE (plural)..}
2ac0: 0a 09 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20  ..state run {.. 
2ad0: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 73     INSERT INTO s
2ae0: 79 6d 74 79 70 65 20 56 41 4c 55 45 53 20 28 30  ymtype VALUES (0
2af0: 2c 27 65 78 63 6c 75 64 65 64 27 2c 20 27 65 78  ,'excluded', 'ex
2b00: 63 6c 75 64 65 64 27 29 3b 20 20 2d 2d 20 54 68  cluded');  -- Th
2b10: 65 20 69 64 73 20 61 72 65 20 74 68 65 20 66 69  e ids are the fi
2b20: 78 65 64 0a 09 20 20 20 20 49 4e 53 45 52 54 20  xed..    INSERT 
2b30: 49 4e 54 4f 20 73 79 6d 74 79 70 65 20 56 41 4c  INTO symtype VAL
2b40: 55 45 53 20 28 31 2c 27 74 61 67 27 2c 20 20 20  UES (1,'tag',   
2b50: 20 20 20 27 74 61 67 73 27 29 3b 20 20 20 20 20     'tags');     
2b60: 20 2d 2d 20 70 69 65 63 65 73 2c 20 73 65 65 20   -- pieces, see 
2b70: 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 2c 0a 09 20  project::sym,.. 
2b80: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 73     INSERT INTO s
2b90: 79 6d 74 79 70 65 20 56 41 4c 55 45 53 20 28 32  ymtype VALUES (2
2ba0: 2c 27 62 72 61 6e 63 68 27 2c 20 20 20 27 62 72  ,'branch',   'br
2bb0: 61 6e 63 68 65 73 27 29 3b 20 20 2d 2d 20 67 65  anches');  -- ge
2bc0: 74 73 79 6d 74 79 70 65 73 20 61 6e 64 20 61 73  tsymtypes and as
2bd0: 73 6f 63 69 61 74 65 64 0a 09 20 20 20 20 49 4e  sociated..    IN
2be0: 53 45 52 54 20 49 4e 54 4f 20 73 79 6d 74 79 70  SERT INTO symtyp
2bf0: 65 20 56 41 4c 55 45 53 20 28 33 2c 27 75 6e 64  e VALUES (3,'und
2c00: 65 66 69 6e 65 64 27 2c 27 75 6e 64 65 66 69 6e  efined','undefin
2c10: 65 64 27 29 3b 20 2d 2d 20 74 79 70 65 76 61 72  ed'); -- typevar
2c20: 69 61 62 6c 65 73 2e 0a 09 7d 0a 0a 09 73 74 61  iables...}...sta
2c30: 74 65 20 65 78 74 65 6e 64 20 6d 65 74 61 20 7b  te extend meta {
2c40: 0a 09 20 20 20 20 2d 2d 20 4d 65 74 61 20 64 61  ..    -- Meta da
2c50: 74 61 20 6f 66 20 72 65 76 69 73 69 6f 6e 73 2e  ta of revisions.
2c60: 20 53 65 65 20 72 65 76 69 73 69 6f 6e 2e 6d 69   See revision.mi
2c70: 64 20 66 6f 72 20 74 68 65 0a 09 20 20 20 20 2d  d for the..    -
2c80: 2d 20 72 65 66 65 72 65 6e 63 65 2e 20 4d 61 6e  - reference. Man
2c90: 79 20 72 65 76 69 73 69 6f 6e 73 20 63 61 6e 20  y revisions can 
2ca0: 73 68 61 72 65 20 6d 65 74 61 20 64 61 74 61 2e  share meta data.
2cb0: 20 54 68 69 73 20 69 73 0a 09 20 20 20 20 2d 2d   This is..    --
2cc0: 20 61 63 74 75 61 6c 6c 79 20 6f 6e 65 20 6f 66   actually one of
2cd0: 20 74 68 65 20 63 72 69 74 65 72 69 6f 6e 73 20   the criterions 
2ce0: 75 73 65 64 20 74 6f 20 73 6f 72 74 20 72 65 76  used to sort rev
2cf0: 69 73 69 6f 6e 73 0a 09 20 20 20 20 2d 2d 20 69  isions..    -- i
2d00: 6e 74 6f 20 63 68 61 6e 67 65 73 65 74 73 2e 0a  nto changesets..
2d10: 0a 09 20 20 20 20 6d 69 64 20 49 4e 54 45 47 45  ..    mid INTEGE
2d20: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49  R  NOT NULL  PRI
2d30: 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f 49 4e  MARY KEY  AUTOIN
2d40: 43 52 45 4d 45 4e 54 2c 0a 0a 09 20 20 20 20 2d  CREMENT,...    -
2d50: 2d 20 4d 65 74 61 20 64 61 74 61 20 62 65 6c 6f  - Meta data belo
2d60: 6e 67 73 20 74 6f 20 61 20 73 70 65 63 69 66 69  ngs to a specifi
2d70: 63 20 70 72 6f 6a 65 63 74 2c 20 73 74 72 6f 6e  c project, stron
2d80: 67 65 72 2c 20 74 6f 20 61 0a 09 20 20 20 20 2d  ger, to a..    -
2d90: 2d 20 62 72 61 6e 63 68 20 69 6e 20 74 68 61 74  - branch in that
2da0: 20 70 72 6f 6a 65 63 74 2e 20 49 74 20 66 75 72   project. It fur
2db0: 74 68 65 72 20 68 61 73 20 61 20 6c 6f 67 20 6d  ther has a log m
2dc0: 65 73 73 61 67 65 2c 0a 09 20 20 20 20 2d 2d 20  essage,..    -- 
2dd0: 61 6e 64 20 69 74 73 20 61 75 74 68 6f 72 2e 20  and its author. 
2de0: 54 68 69 73 20 69 73 20 75 6e 69 71 75 65 20 77  This is unique w
2df0: 69 74 68 20 74 68 65 20 70 72 6f 6a 65 63 74 20  ith the project 
2e00: 61 6e 64 0a 09 20 20 20 20 2d 2d 20 62 72 61 6e  and..    -- bran
2e10: 63 68 2e 0a 0a 09 20 20 20 20 70 69 64 20 49 4e  ch....    pid IN
2e20: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
2e30: 20 52 45 46 45 52 45 4e 43 45 53 20 70 72 6f 6a   REFERENCES proj
2e40: 65 63 74 2c 20 20 2d 2d 0a 09 20 20 20 20 62 69  ect,  --..    bi
2e50: 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e  d INTEGER  NOT N
2e60: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
2e70: 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 0a 09 20 20  symbol,   --..  
2e80: 20 20 61 69 64 20 49 4e 54 45 47 45 52 20 20 4e    aid INTEGER  N
2e90: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
2ea0: 43 45 53 20 61 75 74 68 6f 72 2c 20 20 20 2d 2d  CES author,   --
2eb0: 0a 09 20 20 20 20 63 69 64 20 49 4e 54 45 47 45  ..    cid INTEGE
2ec0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
2ed0: 45 52 45 4e 43 45 53 20 63 6d 65 73 73 61 67 65  ERENCES cmessage
2ee0: 2c 20 2d 2d 0a 0a 09 20 20 20 20 55 4e 49 51 55  , --...    UNIQU
2ef0: 45 20 28 70 69 64 2c 20 62 69 64 2c 20 61 69 64  E (pid, bid, aid
2f00: 2c 20 63 69 64 29 0a 0a 09 20 20 20 20 2d 2d 20  , cid)...    -- 
2f10: 43 6f 6e 73 74 72 61 69 6e 74 73 3a 20 54 68 65  Constraints: The
2f20: 20 70 72 6f 6a 65 63 74 20 6f 66 20 74 68 65 20   project of the 
2f30: 6d 65 74 61 20 64 61 74 61 20 6f 66 20 61 20 72  meta data of a r
2f40: 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 2d 2d 20  evision..    -- 
2f50: 20 20 20 20 20 20 20 20 20 20 20 20 20 58 20 69               X i
2f60: 73 20 74 68 65 20 73 61 6d 65 20 61 73 20 74 68  s the same as th
2f70: 65 20 70 72 6f 6a 65 63 74 20 6f 66 20 58 20 69  e project of X i
2f80: 74 73 65 6c 66 2e 0a 09 20 20 20 20 2d 2d 0a 09  tself...    --..
2f90: 20 20 20 20 2d 2d 20 2e 2e 2e 2e 2e 2e 2e 2e 2e      -- .........
2fa0: 2e 2e 2e 20 54 68 65 20 62 72 61 6e 63 68 20 6f  ... The branch o
2fb0: 66 20 74 68 65 20 6d 65 74 61 20 64 61 74 61 20  f the meta data 
2fc0: 6f 66 20 61 20 72 65 76 69 73 69 6f 6e 0a 09 20  of a revision.. 
2fd0: 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20     --           
2fe0: 20 20 20 58 20 69 73 20 74 68 65 20 73 61 6d 65     X is the same
2ff0: 20 61 73 20 74 68 65 20 6c 69 6e 65 20 6f 66 20   as the line of 
3000: 64 65 76 65 6c 6f 70 6d 65 6e 74 0a 09 20 20 20  development..   
3010: 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20   --             
3020: 20 6f 66 20 58 20 69 74 73 65 6c 66 2e 0a 09 7d   of X itself...}
3030: 0a 0a 09 23 20 41 75 74 68 6f 72 73 20 61 6e 64  ...# Authors and
3040: 20 63 6f 6d 6d 69 74 20 6d 65 73 73 61 67 65 73   commit messages
3050: 20 61 72 65 20 66 75 6c 6c 79 20 67 6c 6f 62 61   are fully globa
3060: 6c 2c 20 69 2e 65 2e 20 70 65 72 0a 09 23 20 72  l, i.e. per..# r
3070: 65 70 6f 73 69 74 6f 72 79 2e 0a 0a 09 73 74 61  epository....sta
3080: 74 65 20 65 78 74 65 6e 64 20 61 75 74 68 6f 72  te extend author
3090: 20 7b 0a 09 20 20 20 20 61 69 64 20 20 49 4e 54   {..    aid  INT
30a0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
30b0: 50 52 49 4d 41 52 59 20 4b 45 59 20 20 41 55 54  PRIMARY KEY  AUT
30c0: 4f 49 4e 43 52 45 4d 45 4e 54 2c 20 2d 2d 20 50  OINCREMENT, -- P
30d0: 6f 6f 6c 20 6f 66 20 74 68 65 20 75 6e 69 71 75  ool of the uniqu
30e0: 65 0a 09 20 20 20 20 6e 61 6d 65 20 54 45 58 54  e..    name TEXT
30f0: 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 55       NOT NULL  U
3100: 4e 49 51 55 45 20 20 20 20 20 20 20 20 20 20 20  NIQUE           
3110: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 61 75             -- au
3120: 74 68 6f 72 20 6e 61 6d 65 73 2e 0a 09 7d 0a 0a  thor names...}..
3130: 09 73 74 61 74 65 20 65 78 74 65 6e 64 20 63 6d  .state extend cm
3140: 65 73 73 61 67 65 20 7b 0a 09 20 20 20 20 63 69  essage {..    ci
3150: 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  d  INTEGER  NOT 
3160: 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b 45  NULL  PRIMARY KE
3170: 59 20 20 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54  Y  AUTOINCREMENT
3180: 2c 20 2d 2d 20 50 6f 6f 6c 20 6f 66 20 74 68 65  , -- Pool of the
3190: 20 75 6e 69 71 75 65 0a 09 20 20 20 20 74 65 78   unique..    tex
31a0: 74 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e  t TEXT     NOT N
31b0: 55 4c 4c 20 20 55 4e 49 51 55 45 20 20 20 20 20  ULL  UNIQUE     
31c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
31d0: 20 2d 2d 20 6c 6f 67 20 6d 65 73 73 61 67 65 73   -- log messages
31e0: 0a 09 7d 0a 0a 09 70 72 6f 6a 65 63 74 3a 3a 73  ..}...project::s
31f0: 79 6d 20 67 65 74 73 79 6d 74 79 70 65 73 0a 09  ym getsymtypes..
3200: 66 69 6c 65 3a 3a 72 65 76 20 20 20 20 67 65 74  file::rev    get
3210: 6f 70 63 6f 64 65 73 0a 09 72 65 74 75 72 6e 0a  opcodes..return.
3220: 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d      }..    typem
3230: 65 74 68 6f 64 20 6c 6f 61 64 20 7b 7d 20 7b 0a  ethod load {} {.
3240: 09 73 74 61 74 65 20 75 73 65 20 73 79 6d 62 6f  .state use symbo
3250: 6c 0a 09 73 74 61 74 65 20 75 73 65 20 73 79 6d  l..state use sym
3260: 74 79 70 65 0a 09 73 74 61 74 65 20 75 73 65 20  type..state use 
3270: 6f 70 74 79 70 65 0a 0a 09 70 72 6f 6a 65 63 74  optype...project
3280: 3a 3a 73 79 6d 20 67 65 74 73 79 6d 74 79 70 65  ::sym getsymtype
3290: 73 0a 09 66 69 6c 65 3a 3a 72 65 76 20 20 20 20  s..file::rev    
32a0: 67 65 74 6f 70 63 6f 64 65 73 0a 09 72 65 70 6f  getopcodes..repo
32b0: 73 69 74 6f 72 79 20 20 20 6c 6f 61 64 73 79 6d  sitory   loadsym
32c0: 62 6f 6c 73 0a 09 72 65 74 75 72 6e 0a 20 20 20  bols..return.   
32d0: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68   }..    typemeth
32e0: 6f 64 20 72 75 6e 20 7b 7d 20 7b 0a 09 23 20 50  od run {} {..# P
32f0: 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65  ass manager inte
3300: 72 66 61 63 65 2e 20 45 78 65 63 75 74 65 64 20  rface. Executed 
3310: 74 6f 20 70 65 72 66 6f 72 6d 20 74 68 65 0a 09  to perform the..
3320: 23 20 66 75 6e 63 74 69 6f 6e 61 6c 69 74 79 20  # functionality 
3330: 6f 66 20 74 68 65 20 70 61 73 73 2e 0a 0a 09 73  of the pass....s
3340: 65 74 20 72 62 61 73 65 20 5b 72 65 70 6f 73 69  et rbase [reposi
3350: 74 6f 72 79 20 62 61 73 65 3f 5d 0a 09 66 6f 72  tory base?]..for
3360: 65 61 63 68 20 70 72 6f 6a 65 63 74 20 5b 72 65  each project [re
3370: 70 6f 73 69 74 6f 72 79 20 70 72 6f 6a 65 63 74  pository project
3380: 73 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 62 61  s] {..    set ba
3390: 73 65 20 5b 3a 3a 66 69 6c 65 20 6a 6f 69 6e 20  se [::file join 
33a0: 24 72 62 61 73 65 20 5b 24 70 72 6f 6a 65 63 74  $rbase [$project
33b0: 20 62 61 73 65 5d 5d 0a 09 20 20 20 20 6c 6f 67   base]]..    log
33c0: 20 77 72 69 74 65 20 31 20 63 6f 6c 6c 72 65 76   write 1 collrev
33d0: 20 22 50 72 6f 63 65 73 73 69 6e 67 20 24 62 61   "Processing $ba
33e0: 73 65 22 0a 0a 09 20 20 20 20 66 6f 72 65 61 63  se"...    foreac
33f0: 68 20 66 69 6c 65 20 5b 24 70 72 6f 6a 65 63 74  h file [$project
3400: 20 66 69 6c 65 73 5d 20 7b 0a 09 09 73 65 74 20   files] {...set 
3410: 70 61 74 68 20 5b 24 66 69 6c 65 20 70 61 74 68  path [$file path
3420: 5d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 32 20  ]...log write 2 
3430: 63 6f 6c 6c 72 65 76 20 22 50 61 72 73 69 6e 67  collrev "Parsing
3440: 20 24 70 61 74 68 22 0a 09 09 69 66 20 7b 5b 63   $path"...if {[c
3450: 61 74 63 68 20 7b 0a 09 09 20 20 20 20 70 61 72  atch {...    par
3460: 73 65 72 20 70 72 6f 63 65 73 73 20 5b 3a 3a 66  ser process [::f
3470: 69 6c 65 20 6a 6f 69 6e 20 24 62 61 73 65 20 24  ile join $base $
3480: 70 61 74 68 5d 20 24 66 69 6c 65 0a 09 09 7d 20  path] $file...} 
3490: 6d 73 67 5d 7d 20 7b 0a 09 09 20 20 20 20 67 6c  msg]} {...    gl
34a0: 6f 62 61 6c 20 65 72 72 6f 72 43 6f 64 65 0a 09  obal errorCode..
34b0: 09 20 20 20 20 69 66 20 7b 24 65 72 72 6f 72 43  .    if {$errorC
34c0: 6f 64 65 20 65 71 20 22 76 63 3a 3a 72 63 73 3a  ode eq "vc::rcs:
34d0: 3a 70 61 72 73 65 72 22 7d 20 7b 0a 09 09 09 74  :parser"} {....t
34e0: 72 6f 75 62 6c 65 20 66 61 74 61 6c 20 22 24 70  rouble fatal "$p
34f0: 61 74 68 20 69 73 20 6e 6f 74 20 61 20 76 61 6c  ath is not a val
3500: 69 64 20 52 43 53 20 61 72 63 68 69 76 65 20 28  id RCS archive (
3510: 24 6d 73 67 29 22 0a 09 09 20 20 20 20 7d 20 65  $msg)"...    } e
3520: 6c 73 65 20 7b 0a 09 09 09 67 6c 6f 62 61 6c 20  lse {....global 
3530: 65 72 72 6f 72 49 6e 66 6f 0a 09 09 09 74 72 6f  errorInfo....tro
3540: 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 24 65  uble internal $e
3550: 72 72 6f 72 49 6e 66 6f 0a 09 09 20 20 20 20 7d  rrorInfo...    }
3560: 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20  ...} else {...  
3570: 20 20 23 20 57 65 20 70 65 72 73 69 73 74 20 74    # We persist t
3580: 68 65 20 63 6f 72 65 20 6f 66 20 74 68 65 20 64  he core of the d
3590: 61 74 61 20 63 6f 6c 6c 65 63 74 65 64 20 61 62  ata collected ab
35a0: 6f 75 74 0a 09 09 20 20 20 20 23 20 65 61 63 68  out...    # each
35b0: 20 66 69 6c 65 20 69 6d 6d 65 64 69 61 74 65 6c   file immediatel
35c0: 79 20 61 66 74 65 72 20 69 74 20 68 61 73 20 62  y after it has b
35d0: 65 65 6e 20 70 61 72 73 65 64 0a 09 09 20 20 20  een parsed...   
35e0: 20 23 20 61 6e 64 20 77 72 61 6e 67 6c 65 64 20   # and wrangled 
35f0: 69 6e 74 6f 20 73 68 61 70 65 2c 20 61 6e 64 20  into shape, and 
3600: 74 68 65 6e 20 64 72 6f 70 20 69 74 20 66 72 6f  then drop it fro
3610: 6d 0a 09 09 20 20 20 20 23 20 6d 65 6d 6f 72 79  m...    # memory
3620: 2e 20 54 68 69 73 20 69 73 20 64 6f 6e 65 20 74  . This is done t
3630: 6f 20 6b 65 65 70 20 74 68 65 20 61 6d 6f 75 6e  o keep the amoun
3640: 74 20 6f 66 0a 09 09 20 20 20 20 23 20 72 65 71  t of...    # req
3650: 75 69 72 65 64 20 6d 65 6d 6f 72 79 20 77 69 74  uired memory wit
3660: 68 69 6e 20 73 65 6e 73 69 62 6c 65 20 6c 69 6d  hin sensible lim
3670: 69 74 73 2e 20 57 69 74 68 6f 75 74 0a 09 09 20  its. Without... 
3680: 20 20 20 23 20 64 6f 69 6e 67 20 69 74 20 74 68     # doing it th
3690: 69 73 20 77 61 79 20 77 65 20 77 6f 75 6c 64 20  is way we would 
36a0: 65 61 73 69 6c 79 20 67 6f 62 62 6c 65 20 75 70  easily gobble up
36b0: 20 31 47 0a 09 09 20 20 20 20 23 20 6f 66 20 52   1G...    # of R
36c0: 41 4d 20 6f 72 20 6d 6f 72 65 20 77 69 74 68 20  AM or more with 
36d0: 61 6c 6c 20 74 68 65 20 6f 62 6a 65 63 74 73 20  all the objects 
36e0: 28 72 65 76 69 73 69 6f 6e 73 0a 09 09 20 20 20  (revisions...   
36f0: 20 23 20 61 6e 64 20 66 69 6c 65 2d 6c 65 76 65   # and file-leve
3700: 6c 20 73 79 6d 62 6f 6c 73 29 2e 0a 0a 09 09 20  l symbols)..... 
3710: 20 20 20 24 66 69 6c 65 20 70 65 72 73 69 73 74     $file persist
3720: 0a 09 09 7d 0a 0a 09 09 24 66 69 6c 65 20 64 72  ...}....$file dr
3730: 6f 70 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20  op..    }...    
3740: 24 70 72 6f 6a 65 63 74 20 70 75 72 67 65 67 68  $project purgegh
3750: 6f 73 74 73 79 6d 62 6f 6c 73 0a 09 7d 0a 0a 09  ostsymbols..}...
3760: 72 65 70 6f 73 69 74 6f 72 79 20 70 65 72 73 69  repository persi
3770: 73 74 72 65 76 0a 09 72 65 70 6f 73 69 74 6f 72  strev..repositor
3780: 79 20 70 72 69 6e 74 72 65 76 73 74 61 74 69 73  y printrevstatis
3790: 74 69 63 73 0a 09 69 6e 74 65 67 72 69 74 79 20  tics..integrity 
37a0: 20 73 74 72 69 63 74 0a 0a 09 6c 6f 67 20 77 72   strict...log wr
37b0: 69 74 65 20 31 20 63 6f 6c 6c 72 65 76 20 22 53  ite 1 collrev "S
37c0: 63 61 6e 20 63 6f 6d 70 6c 65 74 65 64 22 0a 09  can completed"..
37d0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
37e0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 64 69 73    typemethod dis
37f0: 63 61 72 64 20 7b 7d 20 7b 0a 09 23 20 50 61 73  card {} {..# Pas
3800: 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65 72 66  s manager interf
3810: 61 63 65 2e 20 45 78 65 63 75 74 65 64 20 66 6f  ace. Executed fo
3820: 72 20 61 6c 6c 20 70 61 73 73 65 73 20 61 66 74  r all passes aft
3830: 65 72 20 74 68 65 0a 09 23 20 72 75 6e 20 70 61  er the..# run pa
3840: 73 73 65 73 2c 20 74 6f 20 72 65 6d 6f 76 65 20  sses, to remove 
3850: 61 6c 6c 20 64 61 74 61 20 6f 66 20 74 68 69 73  all data of this
3860: 20 70 61 73 73 20 66 72 6f 6d 20 74 68 65 20 73   pass from the s
3870: 74 61 74 65 2c 0a 09 23 20 61 73 20 62 65 69 6e  tate,..# as bein
3880: 67 20 6f 75 74 20 6f 66 20 64 61 74 65 2e 0a 0a  g out of date...
3890: 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20 72  .state discard r
38a0: 65 76 69 73 69 6f 6e 0a 09 73 74 61 74 65 20 64  evision..state d
38b0: 69 73 63 61 72 64 20 74 61 67 0a 09 73 74 61 74  iscard tag..stat
38c0: 65 20 64 69 73 63 61 72 64 20 62 72 61 6e 63 68  e discard branch
38d0: 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20  ..state discard 
38e0: 73 79 6d 62 6f 6c 0a 09 73 74 61 74 65 20 64 69  symbol..state di
38f0: 73 63 61 72 64 20 62 6c 6f 63 6b 65 72 0a 09 73  scard blocker..s
3900: 74 61 74 65 20 64 69 73 63 61 72 64 20 70 61 72  tate discard par
3910: 65 6e 74 0a 09 73 74 61 74 65 20 64 69 73 63 61  ent..state disca
3920: 72 64 20 73 79 6d 74 79 70 65 0a 09 73 74 61 74  rd symtype..stat
3930: 65 20 64 69 73 63 61 72 64 20 6d 65 74 61 0a 09  e discard meta..
3940: 73 74 61 74 65 20 64 69 73 63 61 72 64 20 61 75  state discard au
3950: 74 68 6f 72 0a 09 73 74 61 74 65 20 64 69 73 63  thor..state disc
3960: 61 72 64 20 63 6d 65 73 73 61 67 65 0a 09 72 65  ard cmessage..re
3970: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
3980: 23 20 54 4f 44 4f 3a 20 4d 6f 76 65 20 74 68 69  # TODO: Move thi
3990: 73 20 63 6f 64 65 20 74 6f 20 74 68 65 20 69 6e  s code to the in
39a0: 74 65 67 72 69 74 79 20 6d 6f 64 75 6c 65 0a 20  tegrity module. 
39b0: 20 20 20 70 72 6f 63 20 50 61 72 61 6e 6f 69 61     proc Paranoia
39c0: 20 7b 7d 20 7b 0a 09 23 20 54 68 69 73 20 63 6f   {} {..# This co
39d0: 64 65 20 70 65 72 66 6f 72 6d 73 20 61 20 6e 75  de performs a nu
39e0: 6d 62 65 72 20 6f 66 20 70 61 72 61 6e 6f 69 64  mber of paranoid
39f0: 20 63 68 65 63 6b 73 20 6f 66 20 74 68 65 0a 09   checks of the..
3a00: 23 20 64 61 74 61 62 61 73 65 2c 20 73 65 61 72  # database, sear
3a10: 63 68 69 6e 67 20 66 6f 72 20 69 6e 63 6f 6e 73  ching for incons
3a20: 69 73 74 65 6e 74 20 63 72 6f 73 73 2d 72 65 66  istent cross-ref
3a30: 65 72 65 6e 63 65 73 2e 0a 09 6c 6f 67 20 77 72  erences...log wr
3a40: 69 74 65 20 34 20 63 6f 6c 6c 72 65 76 20 7b 43  ite 4 collrev {C
3a50: 68 65 63 6b 20 64 61 74 61 62 61 73 65 20 63 6f  heck database co
3a60: 6e 73 69 73 74 65 6e 63 79 7d 0a 0a 09 73 65 74  nsistency}...set
3a70: 20 6e 20 30 20 3b 20 23 20 43 6f 75 6e 74 65 72   n 0 ; # Counter
3a80: 20 66 6f 72 20 74 68 65 20 63 68 65 63 6b 73 20   for the checks 
3a90: 28 77 65 20 70 72 69 6e 74 20 61 6e 20 69 64 20  (we print an id 
3aa0: 62 65 66 6f 72 65 20 74 68 65 0a 09 09 20 20 23  before the...  #
3ab0: 20 6d 61 69 6e 20 6c 61 62 65 6c 29 2e 0a 0a 09   main label)....
3ac0: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
3ad0: 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73 61 67  ions which disag
3ae0: 72 65 65 20 77 69 74 68 20 74 68 65 69 72 20 6c  ree with their l
3af0: 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c 6f  ine of..# develo
3b00: 70 6d 65 6e 74 20 61 62 6f 75 74 20 74 68 65 20  pment about the 
3b10: 70 72 6f 6a 65 63 74 20 74 68 65 79 20 61 72 65  project they are
3b20: 20 6f 77 6e 65 64 20 62 79 2e 0a 09 43 68 65 63   owned by...Chec
3b30: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
3b40: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 4c 4f  ons and their LO
3b50: 44 73 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e  Ds have to be in
3b60: 20 74 68 65 20 73 61 6d 65 20 70 72 6f 6a 65 63   the same projec
3b70: 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67  t} \..    {disag
3b80: 72 65 65 73 20 77 69 74 68 20 69 74 73 20 4c 4f  rees with its LO
3b90: 44 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67 20 70  D about owning p
3ba0: 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 53 45 4c 45  roject} {...SELE
3bb0: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
3bc0: 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69 73 69  ...FROM   revisi
3bd0: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 73 79  on R, file F, sy
3be0: 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52 45 20 20  mbol S...WHERE  
3bf0: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 20 20 20  R.fid = F.fid   
3c00: 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 72  -- Get file of r
3c10: 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20  evision...AND   
3c20: 20 52 2e 6c 6f 64 20 3d 20 53 2e 73 69 64 20 20   R.lod = S.sid  
3c30: 20 2d 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 66   -- Get symbol f
3c40: 6f 72 20 72 65 76 69 73 69 6f 6e 27 73 20 4c 4f  or revision's LO
3c50: 44 0a 09 09 41 4e 44 20 20 20 20 46 2e 70 69 64  D...AND    F.pid
3c60: 20 21 3d 20 53 2e 70 69 64 20 20 2d 2d 20 62 75   != S.pid  -- bu
3c70: 74 20 73 79 6d 62 6f 6c 20 69 73 20 66 6f 72 20  t symbol is for 
3c80: 61 20 64 69 66 66 65 72 65 6e 74 20 70 72 6f 6a  a different proj
3c90: 65 63 74 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  ect...;..    }..
3ca0: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
3cb0: 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73 67 72  ions which disgr
3cc0: 65 65 20 77 69 74 68 20 74 68 65 69 72 20 6d 65  ee with their me
3cd0: 74 61 20 64 61 74 61 20 61 62 6f 75 74 0a 09 23  ta data about..#
3ce0: 20 74 68 65 20 70 72 6f 6a 65 63 74 20 74 68 65   the project the
3cf0: 79 20 61 72 65 20 6f 77 6e 65 64 20 62 79 2e 0a  y are owned by..
3d00: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52  .Check \..    {R
3d10: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65  evisions and the
3d20: 69 72 20 6d 65 74 61 20 64 61 74 61 20 68 61 76  ir meta data hav
3d30: 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73  e to be in the s
3d40: 61 6d 65 20 70 72 6f 6a 65 63 74 7d 20 5c 0a 09  ame project} \..
3d50: 20 20 20 20 7b 64 69 73 61 67 72 65 65 73 20 77      {disagrees w
3d60: 69 74 68 20 69 74 73 20 6d 65 74 61 20 64 61 74  ith its meta dat
3d70: 61 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67 20 70  a about owning p
3d80: 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 53 45 4c 45  roject} {...SELE
3d90: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
3da0: 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69 73 69  ...FROM   revisi
3db0: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 6d 65  on R, file F, me
3dc0: 74 61 20 4d 0a 09 09 57 48 45 52 45 20 20 52 2e  ta M...WHERE  R.
3dd0: 66 69 64 20 3d 20 46 2e 66 69 64 20 20 20 2d 2d  fid = F.fid   --
3de0: 20 47 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76   Get file of rev
3df0: 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52  ision...AND    R
3e00: 2e 6d 69 64 20 3d 20 4d 2e 6d 69 64 20 20 20 2d  .mid = M.mid   -
3e10: 2d 20 47 65 74 20 6d 65 74 61 20 64 61 74 61 20  - Get meta data 
3e20: 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e  of revision...AN
3e30: 44 20 20 20 20 46 2e 70 69 64 20 21 3d 20 4d 2e  D    F.pid != M.
3e40: 70 69 64 20 20 2d 2d 20 62 75 74 20 69 73 20 66  pid  -- but is f
3e50: 6f 72 20 61 20 64 69 66 66 65 72 65 6e 74 20 70  or a different p
3e60: 72 6f 6a 65 63 74 0a 09 09 3b 0a 09 20 20 20 20  roject...;..    
3e70: 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  }..# Find all re
3e80: 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 64 69  visions which di
3e90: 73 67 72 65 65 20 77 69 74 68 20 74 68 65 69 72  sgree with their
3ea0: 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f 75 74   meta data about
3eb0: 0a 09 23 20 74 68 65 20 62 72 61 6e 63 68 2f 6c  ..# the branch/l
3ec0: 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65  ine of developme
3ed0: 6e 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74  nt they belong t
3ee0: 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20  o...Check \..   
3ef0: 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20   {Revisions and 
3f00: 74 68 65 69 72 20 6d 65 74 61 20 64 61 74 61 20  their meta data 
3f10: 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68  have to be in th
3f20: 65 20 73 61 6d 65 20 4c 4f 44 7d 20 5c 0a 09 20  e same LOD} \.. 
3f30: 20 20 20 7b 64 69 73 61 67 72 65 65 73 20 77 69     {disagrees wi
3f40: 74 68 20 69 74 73 20 6d 65 74 61 20 64 61 74 61  th its meta data
3f50: 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67 20 4c 4f   about owning LO
3f60: 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  D} {...SELECT F.
3f70: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
3f80: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
3f90: 20 6d 65 74 61 20 4d 2c 20 66 69 6c 65 20 46 0a   meta M, file F.
3fa0: 09 09 57 48 45 52 45 20 20 52 2e 6d 69 64 20 3d  ..WHERE  R.mid =
3fb0: 20 4d 2e 6d 69 64 20 20 20 2d 2d 20 47 65 74 20   M.mid   -- Get 
3fc0: 6d 65 74 61 20 64 61 74 61 20 6f 66 20 72 65 76  meta data of rev
3fd0: 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52  ision...AND    R
3fe0: 2e 6c 6f 64 20 21 3d 20 4d 2e 62 69 64 20 20 2d  .lod != M.bid  -
3ff0: 2d 20 62 75 74 20 69 73 20 66 6f 72 20 61 20 64  - but is for a d
4000: 69 66 66 65 72 65 6e 74 20 4c 4f 44 0a 09 09 41  ifferent LOD...A
4010: 4e 44 20 20 20 20 52 2e 66 69 64 20 3d 20 46 2e  ND    R.fid = F.
4020: 66 69 64 20 20 20 2d 2d 20 47 65 74 20 66 69 6c  fid   -- Get fil
4030: 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 09  e of revision...
4040: 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64  ;..    }..# Find
4050: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
4060: 69 74 68 20 61 20 70 72 69 6d 61 72 79 20 63 68  ith a primary ch
4070: 69 6c 64 20 77 68 69 63 68 20 64 69 73 61 67 72  ild which disagr
4080: 65 65 73 0a 09 23 20 61 62 6f 75 74 20 74 68 65  ees..# about the
4090: 20 66 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e   file they belon
40a0: 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  g to...Check \..
40b0: 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61      {Revisions a
40c0: 6e 64 20 74 68 65 69 72 20 70 72 69 6d 61 72 79  nd their primary
40d0: 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74   children have t
40e0: 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65  o be in the same
40f0: 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 64   file} \..    {d
4100: 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74  isagrees with it
4110: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20  s primary child 
4120: 61 62 6f 75 74 20 74 68 65 20 6f 77 6e 69 6e 67  about the owning
4130: 20 66 69 6c 65 7d 20 7b 0a 09 09 53 45 4c 45 43   file} {...SELEC
4140: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
4150: 09 09 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f  ..FROM   revisio
4160: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c  n R, revision C,
4170: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
4180: 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 20 20   R.fid = F.fid  
4190: 20 20 20 20 20 20 2d 2d 20 47 65 74 20 66 69 6c        -- Get fil
41a0: 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 09  e of revision...
41b0: 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49  AND    R.child I
41c0: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52  S NOT NULL  -- R
41d0: 65 73 74 72 69 63 74 20 74 6f 20 6e 6f 6e 2d 6c  estrict to non-l
41e0: 65 61 66 20 72 65 76 69 73 69 6f 6e 73 0a 09 09  eaf revisions...
41f0: 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 3d  AND    R.child =
4200: 20 43 2e 72 69 64 20 20 20 20 20 20 2d 2d 20 47   C.rid      -- G
4210: 65 74 20 63 68 69 6c 64 20 28 68 61 73 20 74 6f  et child (has to
4220: 20 65 78 69 73 74 29 0a 09 09 41 4e 44 20 20 20   exist)...AND   
4230: 20 43 2e 66 69 64 20 21 3d 20 52 2e 66 69 64 20   C.fid != R.fid 
4240: 20 20 20 20 20 20 2d 2d 20 57 68 69 63 20 77 72        -- Whic wr
4250: 6f 6e 67 6c 79 20 69 73 20 69 6e 20 61 20 64 69  ongly is in a di
4260: 66 66 65 72 65 6e 74 20 66 69 6c 65 0a 09 09 3b  fferent file...;
4270: 0a 09 20 20 20 20 7d 0a 0a 09 23 20 46 69 6e 64  ..    }...# Find
4280: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
4290: 69 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72  ith a branch par
42a0: 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f 73 65  ent symbol whose
42b0: 20 70 61 72 65 6e 74 0a 09 23 20 64 69 73 61 67   parent..# disag
42c0: 72 65 65 73 20 61 62 6f 75 74 20 74 68 65 20 66  rees about the f
42d0: 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e 67 20  ile they belong 
42e0: 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20  to...Check \..  
42f0: 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64    {Revisions and
4300: 20 74 68 65 69 72 20 62 72 61 6e 63 68 20 63 68   their branch ch
4310: 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62  ildren have to b
4320: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 66 69  e in the same fi
4330: 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74  le} \..    {at t
4340: 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20  he beginning of 
4350: 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64 20 69  its branch and i
4360: 74 73 20 70 61 72 65 6e 74 20 64 69 73 61 67 72  ts parent disagr
4370: 65 65 20 61 62 6f 75 74 20 74 68 65 20 6f 77 6e  ee about the own
4380: 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09 53 45  ing file} {...SE
4390: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
43a0: 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69  ev...FROM   revi
43b0: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
43c0: 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   P, file F...WHE
43d0: 52 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  RE  R.fid = F.fi
43e0: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65  d          -- Ge
43f0: 74 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69  t file of revisi
4400: 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 62 70  on...AND    R.bp
4410: 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c  arent IS NOT NUL
4420: 4c 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74  L  -- Restrict t
4430: 6f 20 66 69 72 73 74 20 6f 6e 20 62 72 61 6e 63  o first on branc
4440: 68 0a 09 09 41 4e 44 20 20 20 20 52 2e 70 61 72  h...AND    R.par
4450: 65 6e 74 20 3d 20 50 2e 72 69 64 20 20 20 20 20  ent = P.rid     
4460: 20 20 2d 2d 20 47 65 74 20 6f 75 74 2d 6f 66 2d    -- Get out-of-
4470: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 0a 09 09  branch parent...
4480: 41 4e 44 20 20 20 20 52 2e 66 69 64 20 21 3d 20  AND    R.fid != 
4490: 50 2e 66 69 64 20 20 20 20 20 20 20 20 20 2d 2d  P.fid         --
44a0: 20 57 68 69 63 68 20 77 72 6f 6e 67 6c 79 20 69   Which wrongly i
44b0: 73 20 69 6e 20 61 20 64 69 66 66 65 72 65 6e 74  s in a different
44c0: 20 66 69 6c 65 0a 09 09 3b 0a 09 20 20 20 20 7d   file...;..    }
44d0: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
44e0: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f  isions with a no
44f0: 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69  n-NTDB child whi
4500: 63 68 20 64 69 73 61 67 72 65 65 73 0a 09 23 20  ch disagrees..# 
4510: 61 62 6f 75 74 20 74 68 65 20 66 69 6c 65 20 74  about the file t
4520: 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09  hey belong to...
4530: 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65  Check \..    {Re
4540: 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69  visions and thei
4550: 72 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64  r non-NTDB child
4560: 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65 20 69  ren have to be i
4570: 6e 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 7d  n the same file}
4580: 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65   \..    {disagre
4590: 65 73 20 77 69 74 68 20 69 74 73 20 6e 6f 6e 2d  es with its non-
45a0: 4e 54 44 42 20 63 68 69 6c 64 20 61 62 6f 75 74  NTDB child about
45b0: 20 74 68 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65   the owning file
45c0: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
45d0: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
45e0: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
45f0: 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65  revision C, file
4600: 20 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66 69   F...WHERE  R.fi
4610: 64 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20 20  d = F.fid       
4620: 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f     -- Get file o
4630: 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44  f revision...AND
4640: 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53      R.dbchild IS
4650: 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65   NOT NULL  -- Re
4660: 73 74 72 69 63 74 20 74 6f 20 73 65 6d 69 2d 6c  strict to semi-l
4670: 61 73 74 20 4e 54 44 42 20 72 65 76 69 73 69 6f  ast NTDB revisio
4680: 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 64 62 63  n...AND    R.dbc
4690: 68 69 6c 64 20 3d 20 43 2e 72 69 64 20 20 20 20  hild = C.rid    
46a0: 20 20 2d 2d 20 47 6f 74 20 74 6f 20 61 73 73 6f    -- Got to asso
46b0: 63 69 61 74 65 64 20 74 72 75 6e 6b 20 72 65 76  ciated trunk rev
46c0: 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 43  ision...AND    C
46d0: 2e 66 69 64 20 21 3d 20 52 2e 66 69 64 20 20 20  .fid != R.fid   
46e0: 20 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20 77        -- Which w
46f0: 72 6f 6e 67 6c 79 20 69 73 20 69 6e 20 61 20 64  rongly is in a d
4700: 69 66 66 65 72 65 6e 74 20 66 69 6c 65 0a 09 09  ifferent file...
4710: 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64  ;..    }..# Find
4720: 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77   all revisions w
4730: 68 69 63 68 20 68 61 76 65 20 61 20 70 72 69 6d  hich have a prim
4740: 61 72 79 20 63 68 69 6c 64 2c 20 62 75 74 20 74  ary child, but t
4750: 68 65 20 63 68 69 6c 64 0a 09 23 20 64 6f 65 73  he child..# does
4760: 20 6e 6f 74 20 68 61 76 65 20 74 68 65 6d 20 61   not have them a
4770: 73 20 70 61 72 65 6e 74 2e 0a 09 43 68 65 63 6b  s parent...Check
4780: 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f   \..    {Revisio
4790: 6e 73 20 68 61 76 65 20 74 6f 20 62 65 20 70 61  ns have to be pa
47a0: 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20 70  rents of their p
47b0: 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 7d  rimary children}
47c0: 20 5c 0a 09 20 20 20 20 7b 69 73 20 6e 6f 74 20   \..    {is not 
47d0: 74 68 65 20 70 61 72 65 6e 74 20 6f 66 20 69 74  the parent of it
47e0: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 7d  s primary child}
47f0: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
4800: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
4810: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72     revision R, r
4820: 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20  evision C, file 
4830: 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66 69 64  F...WHERE  R.fid
4840: 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20 20 20   = F.fid        
4850: 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 72  -- Get file of r
4860: 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20  evision...AND   
4870: 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20   R.child IS NOT 
4880: 4e 55 4c 4c 20 20 2d 2d 20 52 65 73 74 72 69 63  NULL  -- Restric
4890: 74 20 74 6f 20 6e 6f 6e 2d 6c 65 61 76 65 73 0a  t to non-leaves.
48a0: 09 09 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64  ..AND    R.child
48b0: 20 3d 20 43 2e 72 69 64 20 20 20 20 20 20 2d 2d   = C.rid      --
48c0: 20 47 65 74 20 74 68 65 20 63 68 69 6c 64 20 28   Get the child (
48d0: 68 61 73 20 74 6f 20 65 78 69 73 74 29 0a 09 09  has to exist)...
48e0: 41 4e 44 20 20 20 20 43 2e 70 61 72 65 6e 74 20  AND    C.parent 
48f0: 21 3d 20 52 2e 72 69 64 20 20 20 20 2d 2d 20 57  != R.rid    -- W
4900: 68 69 63 68 20 64 6f 65 73 20 6e 6f 74 20 68 61  hich does not ha
4910: 76 65 20 75 73 20 61 73 20 69 74 73 20 70 61 72  ve us as its par
4920: 65 6e 74 2e 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  ent....;..    }.
4930: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
4940: 73 69 6f 6e 73 20 77 68 69 63 68 20 68 61 76 65  sions which have
4950: 20 61 20 70 72 69 6d 72 61 72 79 20 63 68 69 6c   a primrary chil
4960: 64 2c 20 62 75 74 20 74 68 65 0a 09 23 20 63 68  d, but the..# ch
4970: 69 6c 64 20 68 61 73 20 61 20 62 72 61 6e 63 68  ild has a branch
4980: 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 6d   parent symbol m
4990: 61 6b 69 6e 67 20 74 68 65 6d 20 62 72 61 63 68  aking them brach
49a0: 20 73 74 61 72 74 65 72 73 2e 0a 09 43 68 65 63   starters...Chec
49b0: 6b 20 5c 0a 09 20 20 20 20 7b 50 72 69 6d 61 72  k \..    {Primar
49c0: 79 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 72 65  y children of re
49d0: 76 69 73 69 6f 6e 73 20 6d 75 73 74 20 6e 6f 74  visions must not
49e0: 20 73 74 61 72 74 20 62 72 61 6e 63 68 65 73 7d   start branches}
49f0: 20 5c 0a 09 20 20 20 20 7b 69 73 20 70 61 72 65   \..    {is pare
4a00: 6e 74 20 6f 66 20 61 20 70 72 69 6d 61 72 79 20  nt of a primary 
4a10: 63 68 69 6c 64 20 77 68 69 63 68 20 69 73 20 74  child which is t
4a20: 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20  he beginning of 
4a30: 61 20 62 72 61 6e 63 68 7d 20 7b 0a 09 09 53 45  a branch} {...SE
4a40: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
4a50: 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65 76 69  ev...FROM   revi
4a60: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
4a70: 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   C, file F...WHE
4a80: 52 45 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  RE  R.fid = F.fi
4a90: 64 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47  d           -- G
4aa0: 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73  et file of revis
4ab0: 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 63  ion...AND    R.c
4ac0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
4ad0: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
4ae0: 20 74 6f 20 6e 6f 6e 2d 6c 65 61 76 65 73 0a 09   to non-leaves..
4af0: 09 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20  .AND    R.child 
4b00: 3d 20 43 2e 72 69 64 20 20 20 20 20 20 20 20 20  = C.rid         
4b10: 2d 2d 20 47 65 74 20 74 68 65 20 63 68 69 6c 64  -- Get the child
4b20: 20 28 68 61 73 20 74 6f 20 65 78 69 73 74 29 0a   (has to exist).
4b30: 09 09 41 4e 44 20 20 20 20 43 2e 62 70 61 72 65  ..AND    C.bpare
4b40: 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20  nt IS NOT NULL  
4b50: 20 2d 2d 20 77 72 6f 6e 67 6c 79 20 63 6c 61 69   -- wrongly clai
4b60: 6d 69 6e 67 20 74 6f 20 62 65 20 66 69 72 73 74  ming to be first
4b70: 20 6f 6e 20 62 72 61 6e 63 68 0a 09 09 3b 0a 09   on branch...;..
4b80: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
4b90: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68  l revisions with
4ba0: 6f 75 74 20 62 72 61 6e 63 68 20 70 61 72 65 6e  out branch paren
4bb0: 74 20 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 68  t symbol which h
4bc0: 61 76 65 20 61 0a 09 23 20 70 61 72 65 6e 74 2c  ave a..# parent,
4bd0: 20 62 75 74 20 74 68 65 20 70 61 72 65 6e 74 20   but the parent 
4be0: 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 68  does not have th
4bf0: 65 6d 20 61 73 20 70 72 69 6d 61 72 79 20 63 68  em as primary ch
4c00: 69 6c 64 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  ild...Check \.. 
4c10: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 68 61     {Revisions ha
4c20: 76 65 20 74 6f 20 62 65 20 70 72 69 6d 61 72 79  ve to be primary
4c30: 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 74 68 65   children of the
4c40: 69 72 20 70 61 72 65 6e 74 73 2c 20 69 66 20 61  ir parents, if a
4c50: 6e 79 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20 6e  ny} \..    {is n
4c60: 6f 74 20 74 68 65 20 63 68 69 6c 64 20 6f 66 20  ot the child of 
4c70: 69 74 73 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09  its parent} {...
4c80: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52  SELECT F.name, R
4c90: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20 20 72 65  .rev...FROM   re
4ca0: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69  vision R, revisi
4cb0: 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57  on P, file F...W
4cc0: 48 45 52 45 20 20 52 2e 66 69 64 20 3d 20 46 2e  HERE  R.fid = F.
4cd0: 66 69 64 0a 09 09 41 4e 44 20 20 20 20 52 2e 62  fid...AND    R.b
4ce0: 70 61 72 65 6e 74 20 49 53 20 4e 55 4c 4c 20 20  parent IS NULL  
4cf0: 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f     -- Get file o
4d00: 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44  f revision...AND
4d10: 20 20 20 20 52 2e 70 61 72 65 6e 74 20 49 53 20      R.parent IS 
4d20: 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65 73  NOT NULL  -- Res
4d30: 74 72 69 63 74 20 74 6f 20 65 76 65 72 79 74 68  trict to everyth
4d40: 69 6e 67 20 6e 6f 74 20 66 69 72 73 74 20 6f 6e  ing not first on
4d50: 20 61 20 62 72 61 6e 63 68 0a 09 09 41 4e 44 20   a branch...AND 
4d60: 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e     R.parent = P.
4d70: 72 69 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20  rid      -- Get 
4d80: 74 68 65 20 70 61 72 65 6e 74 20 28 68 61 73 20  the parent (has 
4d90: 74 6f 20 65 78 69 73 74 29 0a 09 09 41 4e 44 20  to exist)...AND 
4da0: 20 20 20 50 2e 63 68 69 6c 64 20 21 3d 20 52 2e     P.child != R.
4db0: 72 69 64 20 20 20 20 20 20 2d 2d 20 57 68 69 63  rid      -- Whic
4dc0: 68 20 64 6f 20 6e 6f 74 20 68 61 76 65 20 75 73  h do not have us
4dd0: 20 61 73 20 74 68 65 69 72 20 63 68 69 6c 64 0a   as their child.
4de0: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69  ..;..    }..# Fi
4df0: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
4e00: 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 20 70   with a branch p
4e10: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 69  arent symbol whi
4e20: 63 68 20 64 6f 20 6e 6f 74 0a 09 23 20 68 61 76  ch do not..# hav
4e30: 65 20 61 20 70 61 72 65 6e 74 2e 0a 09 43 68 65  e a parent...Che
4e40: 63 6b 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63  ck \..    {Branc
4e50: 68 20 73 74 61 72 74 69 6e 67 20 72 65 76 69 73  h starting revis
4e60: 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 68 61 76  ions have to hav
4e70: 65 20 61 20 70 61 72 65 6e 74 7d 20 5c 0a 09 20  e a parent} \.. 
4e80: 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e     {at the begin
4e90: 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e  ning of its bran
4ea0: 63 68 20 68 61 73 20 6e 6f 20 70 61 72 65 6e 74  ch has no parent
4eb0: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
4ec0: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
4ed0: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
4ee0: 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 20  file F...WHERE  
4ef0: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 20 20 20  R.fid = F.fid   
4f00: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 66 69         -- Get fi
4f10: 6c 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09  le of revision..
4f20: 09 41 4e 44 20 20 20 20 52 2e 62 70 61 72 65 6e  .AND    R.bparen
4f30: 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d  t IS NOT NULL  -
4f40: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 66 69  - Restrict to fi
4f50: 72 73 74 20 6f 6e 20 61 20 62 72 61 6e 63 68 0a  rst on a branch.
4f60: 09 09 41 4e 44 20 20 20 20 52 2e 70 61 72 65 6e  ..AND    R.paren
4f70: 74 20 49 53 20 4e 55 4c 4c 20 20 20 20 20 20 20  t IS NULL       
4f80: 2d 2d 20 42 75 74 20 74 68 65 72 65 20 69 73 20  -- But there is 
4f90: 6e 6f 20 6f 75 74 2d 6f 66 2d 62 72 61 6e 63 68  no out-of-branch
4fa0: 20 70 61 72 65 6e 74 0a 09 09 3b 0a 09 20 20 20   parent...;..   
4fb0: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72   }..# Find all r
4fc0: 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20  evisions with a 
4fd0: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79  branch parent sy
4fe0: 6d 62 6f 6c 20 77 68 6f 73 65 20 70 61 72 65 6e  mbol whose paren
4ff0: 74 0a 09 23 20 68 61 73 20 74 68 65 6d 20 61 73  t..# has them as
5000: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a   primary child..
5010: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 42  .Check \..    {B
5020: 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67 20 72  ranch starting r
5030: 65 76 69 73 69 6f 6e 73 20 6d 75 73 74 20 6e 6f  evisions must no
5040: 74 20 62 65 20 70 72 69 6d 61 72 79 20 63 68 69  t be primary chi
5050: 6c 64 72 65 6e 20 6f 66 20 74 68 65 69 72 20 70  ldren of their p
5060: 61 72 65 6e 74 73 7d 20 5c 0a 09 20 20 20 20 7b  arents} \..    {
5070: 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67  at the beginning
5080: 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68 20 69   of its branch i
5090: 73 20 74 68 65 20 70 72 69 6d 61 72 79 20 63 68  s the primary ch
50a0: 69 6c 64 20 6f 66 20 69 74 73 20 70 61 72 65 6e  ild of its paren
50b0: 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  t} {...SELECT F.
50c0: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
50d0: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
50e0: 20 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c   revision P, fil
50f0: 65 20 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66  e F...WHERE  R.f
5100: 69 64 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20  id = F.fid      
5110: 20 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20      -- Get file 
5120: 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e  of revision...AN
5130: 44 20 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49  D    R.bparent I
5140: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52  S NOT NULL  -- R
5150: 65 73 74 72 69 63 74 20 74 6f 20 66 69 72 73 74  estrict to first
5160: 20 6f 6e 20 61 20 62 72 61 6e 63 68 0a 09 09 41   on a branch...A
5170: 4e 44 20 20 20 20 52 2e 70 61 72 65 6e 74 20 49  ND    R.parent I
5180: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20  S NOT NULL   -- 
5190: 57 68 69 63 68 20 61 72 65 20 6e 6f 74 20 64 65  Which are not de
51a0: 74 61 63 68 65 64 0a 09 09 41 4e 44 20 20 20 20  tached...AND    
51b0: 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72 69 64  R.parent = P.rid
51c0: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 74 68         -- Get th
51d0: 65 69 72 20 6e 6f 6e 2d 62 72 61 6e 63 68 20 70  eir non-branch p
51e0: 61 72 65 6e 74 0a 09 09 41 4e 44 20 20 20 20 50  arent...AND    P
51f0: 2e 63 68 69 6c 64 20 3d 20 52 2e 72 69 64 20 20  .child = R.rid  
5200: 20 20 20 20 20 20 2d 2d 20 77 68 69 63 68 20 69        -- which i
5210: 6d 70 72 6f 70 65 72 6c 79 20 68 61 73 20 74 68  mproperly has th
5220: 65 6d 20 61 73 20 70 72 69 6d 61 72 79 20 63 68  em as primary ch
5230: 69 6c 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  ild...;..    }..
5240: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
5250: 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d  ions with a non-
5260: 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69 63 68  NTDB child which
5270: 20 61 72 65 20 6e 6f 74 20 6f 6e 0a 09 23 20 74   are not on..# t
5280: 68 65 20 4e 54 44 42 2e 0a 09 43 68 65 63 6b 20  he NTDB...Check 
5290: 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 74 6f 20  \..    {NTDB to 
52a0: 74 72 75 6e 6b 20 74 72 61 6e 73 69 74 69 6f 6e  trunk transition
52b0: 20 68 61 73 20 74 6f 20 62 65 67 69 6e 20 6f 6e   has to begin on
52c0: 20 4e 54 44 42 7d 20 5c 0a 09 20 20 20 20 7b 68   NTDB} \..    {h
52d0: 61 73 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68  as a non-NTDB ch
52e0: 69 6c 64 2c 20 79 65 74 20 69 73 20 6e 6f 74 20  ild, yet is not 
52f0: 6f 6e 20 74 68 65 20 4e 54 44 42 7d 20 7b 0a 09  on the NTDB} {..
5300: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20  .SELECT F.name, 
5310: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20 20 72  R.rev...FROM   r
5320: 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20  evision R, file 
5330: 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66 69 64  F...WHERE  R.fid
5340: 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20 20 20   = F.fid        
5350: 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66    -- Get file of
5360: 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20   revision...AND 
5370: 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20     R.dbchild IS 
5380: 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65 73  NOT NULL  -- Res
5390: 74 72 69 63 74 20 74 6f 20 73 65 6d 69 2d 6c 61  trict to semi-la
53a0: 73 74 20 4e 54 44 42 20 72 65 76 69 73 69 6f 6e  st NTDB revision
53b0: 0a 09 09 41 4e 44 20 20 20 20 4e 4f 54 20 52 2e  ...AND    NOT R.
53c0: 69 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20  isdefault       
53d0: 20 2d 2d 20 49 6d 70 72 6f 70 65 72 6c 79 20 63   -- Improperly c
53e0: 6c 61 69 6d 69 6e 67 20 74 6f 20 6e 6f 74 20 62  laiming to not b
53f0: 65 20 6f 6e 20 4e 54 44 42 0a 09 09 3b 0a 09 20  e on NTDB...;.. 
5400: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
5410: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
5420: 61 20 4e 54 44 42 20 70 61 72 65 6e 74 20 77 68  a NTDB parent wh
5430: 69 63 68 20 61 72 65 20 6f 6e 20 74 68 65 20 4e  ich are on the N
5440: 54 44 42 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  TDB...Check \.. 
5450: 20 20 20 7b 4e 54 44 42 20 74 6f 20 74 72 75 6e     {NTDB to trun
5460: 6b 20 74 72 61 6e 73 69 74 69 6f 6e 20 68 61 73  k transition has
5470: 20 74 6f 20 65 6e 64 20 6f 6e 20 6e 6f 6e 2d 4e   to end on non-N
5480: 54 44 42 7d 20 5c 0a 09 20 20 20 20 7b 68 61 73  TDB} \..    {has
5490: 20 61 20 4e 54 44 42 20 70 61 72 65 6e 74 2c 20   a NTDB parent, 
54a0: 79 65 74 20 69 73 20 6f 6e 20 74 68 65 20 4e 54  yet is on the NT
54b0: 44 42 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  DB} {...SELECT F
54c0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
54d0: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
54e0: 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45  , file F...WHERE
54f0: 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 20    R.fid = F.fid 
5500: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74            -- Get
5510: 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73 69 6f   file of revisio
5520: 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 64 62 70  n...AND    R.dbp
5530: 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c  arent IS NOT NUL
5540: 4c 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74  L  -- Restrict t
5550: 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 73 20 77 69  o trunk roots wi
5560: 74 68 20 4e 54 44 42 20 61 72 6f 75 6e 64 0a 09  th NTDB around..
5570: 09 41 4e 44 20 20 20 20 52 2e 69 73 64 65 66 61  .AND    R.isdefa
5580: 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20  ult             
5590: 2d 2d 20 42 75 74 20 72 6f 6f 74 20 69 6d 70 72  -- But root impr
55a0: 6f 70 65 72 6c 79 20 63 6c 61 69 6d 73 20 74 6f  operly claims to
55b0: 20 62 65 20 6f 6e 20 4e 54 44 42 0a 09 09 3b 0a   be on NTDB...;.
55c0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
55d0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74  ll revisions wit
55e0: 68 20 61 20 63 68 69 6c 64 20 77 68 69 63 68 20  h a child which 
55f0: 64 69 73 61 67 72 65 65 73 20 61 62 6f 75 74 20  disagrees about 
5600: 74 68 65 0a 09 23 20 6c 69 6e 65 20 6f 66 20 64  the..# line of d
5610: 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20  evelopment they 
5620: 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63  belong to...Chec
5630: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
5640: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 70 72  ons and their pr
5650: 69 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20 68  imary children h
5660: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65  ave to be in the
5670: 20 73 61 6d 65 20 4c 4f 44 7d 20 5c 0a 09 20 20   same LOD} \..  
5680: 20 20 7b 61 6e 64 20 69 74 73 20 70 72 69 6d 61    {and its prima
5690: 72 79 20 63 68 69 6c 64 20 64 69 73 61 67 72 65  ry child disagre
56a0: 65 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c 4f  e about their LO
56b0: 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  D} {...SELECT F.
56c0: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
56d0: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
56e0: 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c   revision C, fil
56f0: 65 20 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66  e F...WHERE  R.f
5700: 69 64 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20  id = F.fid      
5710: 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66    -- Get file of
5720: 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20   revision...AND 
5730: 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f     R.child IS NO
5740: 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65 73 74 72  T NULL  -- Restr
5750: 69 63 74 20 74 6f 20 6e 6f 6e 2d 6c 65 61 76 65  ict to non-leave
5760: 73 0a 09 09 41 4e 44 20 20 20 20 52 2e 63 68 69  s...AND    R.chi
5770: 6c 64 20 3d 20 43 2e 72 69 64 20 20 20 20 20 20  ld = C.rid      
5780: 2d 2d 20 47 65 74 20 63 68 69 6c 64 20 28 68 61  -- Get child (ha
5790: 73 20 74 6f 20 65 78 69 73 74 29 0a 09 09 41 4e  s to exist)...AN
57a0: 44 20 20 20 20 43 2e 6c 6f 64 20 21 3d 20 52 2e  D    C.lod != R.
57b0: 6c 6f 64 20 20 20 20 20 20 20 2d 2d 20 77 68 69  lod       -- whi
57c0: 63 68 20 69 6d 70 72 6f 70 65 72 6c 79 20 75 73  ch improperly us
57d0: 65 73 20 61 20 64 69 66 66 65 72 65 6e 74 20 4c  es a different L
57e0: 4f 44 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23  OD...;..    }..#
57f0: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69   Find all revisi
5800: 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d 4e  ons with a non-N
5810: 54 44 42 20 63 68 69 6c 64 20 77 68 69 63 68 20  TDB child which 
5820: 61 67 72 65 65 73 20 61 62 6f 75 74 0a 09 23 20  agrees about..# 
5830: 74 68 65 20 6c 69 6e 65 20 6f 66 20 64 65 76 65  the line of deve
5840: 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20 62 65 6c  lopment they bel
5850: 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c  ong to...Check \
5860: 0a 09 20 20 20 20 7b 4e 54 44 42 20 61 6e 64 20  ..    {NTDB and 
5870: 74 72 75 6e 6b 20 72 65 76 69 73 69 6f 6e 73 20  trunk revisions 
5880: 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 64 69  have to be in di
5890: 66 66 65 72 65 6e 74 20 4c 4f 44 73 7d 20 5c 0a  fferent LODs} \.
58a0: 09 20 20 20 20 7b 6f 6e 20 4e 54 44 42 20 61 6e  .    {on NTDB an
58b0: 64 20 69 74 73 20 6e 6f 6e 2d 4e 54 44 42 20 63  d its non-NTDB c
58c0: 68 69 6c 64 20 77 72 6f 6e 67 6c 79 20 61 67 72  hild wrongly agr
58d0: 65 65 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c  ee about their L
58e0: 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  OD} {...SELECT F
58f0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
5900: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
5910: 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69  , revision C, fi
5920: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 20 52 2e  le F...WHERE  R.
5930: 66 69 64 20 3d 20 46 2e 66 69 64 20 20 20 20 20  fid = F.fid     
5940: 20 20 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65       -- Get file
5950: 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41   of revision...A
5960: 4e 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20  ND    R.dbchild 
5970: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20  IS NOT NULL  -- 
5980: 52 65 73 74 72 69 63 74 20 74 6f 20 73 65 6d 69  Restrict to semi
5990: 2d 6c 61 73 74 20 4e 54 44 42 20 72 65 76 69 73  -last NTDB revis
59a0: 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 52 2e 64  ion...AND    R.d
59b0: 62 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 20 20  bchild = C.rid  
59c0: 20 20 20 20 2d 2d 20 47 65 74 20 61 73 73 6f 63      -- Get assoc
59d0: 69 61 74 65 64 20 74 72 75 6e 6b 20 72 6f 6f 74  iated trunk root
59e0: 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20   revision...AND 
59f0: 20 20 20 43 2e 6c 6f 64 20 3d 20 52 2e 6c 6f 64     C.lod = R.lod
5a00: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 49 6d 70            -- Imp
5a10: 72 6f 70 65 72 6c 79 20 75 73 65 73 20 74 68 65  roperly uses the
5a20: 20 73 61 6d 65 20 4c 4f 44 0a 09 09 3b 0a 09 20   same LOD...;.. 
5a30: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
5a40: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
5a50: 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20  a branch parent 
5a60: 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 69 73 20  symbol which is 
5a70: 6e 6f 74 0a 09 23 20 74 68 65 69 72 20 4c 4f 44  not..# their LOD
5a80: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
5a90: 7b 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67  {Branch starting
5aa0: 20 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20   revisions have 
5ab0: 74 6f 20 68 61 76 65 20 74 68 65 69 72 20 4c 4f  to have their LO
5ac0: 44 20 61 73 20 62 72 61 6e 63 68 20 70 61 72 65  D as branch pare
5ad0: 6e 74 20 73 79 6d 62 6f 6c 7d 20 5c 0a 09 20 20  nt symbol} \..  
5ae0: 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e    {at the beginn
5af0: 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63  ing of its branc
5b00: 68 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20  h does not have 
5b10: 74 68 65 20 62 72 61 6e 63 68 20 73 79 6d 62 6f  the branch symbo
5b20: 6c 20 61 73 20 69 74 73 20 4c 4f 44 7d 20 7b 0a  l as its LOD} {.
5b30: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
5b40: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 20 20   R.rev...FROM   
5b50: 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65  revision R, file
5b60: 20 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66 69   F...WHERE  R.fi
5b70: 64 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20 20  d = F.fid       
5b80: 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f     -- Get file o
5b90: 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44  f revision...AND
5ba0: 20 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53      R.bparent IS
5bb0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65   NOT NULL  -- Re
5bc0: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
5bd0: 6f 6e 73 20 66 69 72 73 74 20 6f 6e 20 61 20 62  ons first on a b
5be0: 72 61 6e 63 68 0a 09 09 41 4e 44 20 20 20 20 52  ranch...AND    R
5bf0: 2e 6c 6f 64 20 21 3d 20 52 2e 62 70 61 72 65 6e  .lod != R.bparen
5c00: 74 20 20 20 20 20 2d 2d 20 61 6e 64 20 74 68 65  t     -- and the
5c10: 69 72 20 62 72 61 6e 63 68 20 69 73 20 6e 6f 74  ir branch is not
5c20: 20 74 68 65 69 72 20 4c 4f 44 0a 09 09 3b 0a 09   their LOD...;..
5c30: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
5c40: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68  l revisions with
5c50: 20 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74   a branch parent
5c60: 20 73 79 6d 62 6f 6c 20 77 68 6f 73 65 20 70 61   symbol whose pa
5c70: 72 65 6e 74 0a 09 23 20 69 73 20 69 6e 20 74 68  rent..# is in th
5c80: 65 20 73 61 6d 65 20 6c 69 6e 65 20 6f 66 20 64  e same line of d
5c90: 65 76 65 6c 6f 70 6d 65 6e 74 2e 0a 09 43 68 65  evelopment...Che
5ca0: 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73  ck \..    {Revis
5cb0: 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 62  ions and their b
5cc0: 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 20 68  ranch children h
5cd0: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 64 69 66  ave to be in dif
5ce0: 66 65 72 65 6e 74 20 4c 4f 44 73 7d 20 5c 0a 09  ferent LODs} \..
5cf0: 20 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69      {at the begi
5d00: 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61  nning of its bra
5d10: 6e 63 68 20 61 6e 64 20 69 74 73 20 70 61 72 65  nch and its pare
5d20: 6e 74 20 77 72 6f 6e 67 6c 79 20 61 67 72 65 65  nt wrongly agree
5d30: 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c 4f 44   about their LOD
5d40: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
5d50: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
5d60: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
5d70: 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65  revision P, file
5d80: 20 46 0a 09 09 57 48 45 52 45 20 20 52 2e 66 69   F...WHERE  R.fi
5d90: 64 20 3d 20 46 2e 66 69 64 20 20 20 20 20 20 20  d = F.fid       
5da0: 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f     -- Get file o
5db0: 66 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44  f revision...AND
5dc0: 20 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53      R.bparent IS
5dd0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 52 65   NOT NULL  -- Re
5de0: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
5df0: 6f 6e 73 20 66 69 72 73 74 20 6f 6e 20 61 20 62  ons first on a b
5e00: 72 61 6e 63 68 0a 09 09 41 4e 44 20 20 20 20 52  ranch...AND    R
5e10: 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72 69 64 20  .parent = P.rid 
5e20: 20 20 20 20 20 20 2d 2d 20 47 65 74 20 74 68 65        -- Get the
5e30: 69 72 20 6e 6f 6e 2d 62 72 61 6e 63 68 20 70 61  ir non-branch pa
5e40: 72 65 6e 74 0a 09 09 41 4e 44 20 20 20 20 52 2e  rent...AND    R.
5e50: 6c 6f 64 20 3d 20 50 2e 6c 6f 64 20 20 20 20 20  lod = P.lod     
5e60: 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20 69 6d       -- Which im
5e70: 70 72 6f 70 65 72 6c 79 20 75 73 65 73 20 74 68  properly uses th
5e80: 65 20 73 61 6d 65 20 4c 4f 44 0a 09 09 3b 0a 09  e same LOD...;..
5e90: 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20      }..return.  
5ea0: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 43 68    }..    proc Ch
5eb0: 65 63 6b 20 7b 68 65 61 64 65 72 20 6c 61 62 65  eck {header labe
5ec0: 6c 20 73 71 6c 7d 20 7b 0a 09 75 70 76 61 72 20  l sql} {..upvar 
5ed0: 31 20 6e 20 6e 0a 09 73 65 74 20 6f 6b 20 31 0a  1 n n..set ok 1.
5ee0: 09 66 6f 72 65 61 63 68 20 7b 66 6e 61 6d 65 20  .foreach {fname 
5ef0: 72 65 76 6e 72 7d 20 5b 73 74 61 74 65 20 72 75  revnr} [state ru
5f00: 6e 20 24 73 71 6c 5d 20 7b 0a 09 20 20 20 20 73  n $sql] {..    s
5f10: 65 74 20 6f 6b 20 30 0a 09 20 20 20 20 74 72 6f  et ok 0..    tro
5f20: 75 62 6c 65 20 66 61 74 61 6c 20 22 24 66 6e 61  uble fatal "$fna
5f30: 6d 65 20 3c 24 72 65 76 6e 72 3e 20 24 6c 61 62  me <$revnr> $lab
5f40: 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 74  el"..}..log writ
5f50: 65 20 35 20 63 6f 6c 6c 72 65 76 20 22 5c 5b 5b  e 5 collrev "\[[
5f60: 66 6f 72 6d 61 74 20 25 30 32 64 20 5b 69 6e 63  format %02d [inc
5f70: 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20 7b 24  r n]]\] [expr {$
5f80: 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 20 3a 20  ok ? "Ok    " : 
5f90: 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e 20 24  "Failed"}] ... $
5fa0: 68 65 61 64 65 72 22 0a 09 72 65 74 75 72 6e 0a  header"..return.
5fb0: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23      }..    # # #
5fc0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
5fd0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
5fe0: 23 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72 6e  ##.    ## Intern
5ff0: 61 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20 20  al methods..    
6000: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
6010: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
6020: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 43  #######.    ## C
6030: 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20  onfiguration..  
6040: 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69 6e 73    pragma -hasins
6050: 74 61 6e 63 65 73 20 20 20 6e 6f 20 3b 20 23 20  tances   no ; # 
6060: 73 69 6e 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72  singleton.    pr
6070: 61 67 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66  agma -hastypeinf
6080: 6f 20 20 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69  o    no ; # no i
6090: 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20  ntrospection.   
60a0: 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65   pragma -hastype
60b0: 64 65 73 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69  destroy no ; # i
60c0: 6d 6d 6f 72 74 61 6c 0a 0a 20 20 20 20 23 20 23  mmortal..    # #
60d0: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
60e0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
60f0: 23 23 23 23 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63  ####.}..namespac
6100: 65 20 65 76 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73  e eval ::vc::fos
6110: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
6120: 3a 3a 70 61 73 73 20 7b 0a 20 20 20 20 6e 61 6d  ::pass {.    nam
6130: 65 73 70 61 63 65 20 65 78 70 6f 72 74 20 63 6f  espace export co
6140: 6c 6c 72 65 76 0a 20 20 20 20 6e 61 6d 65 73 70  llrev.    namesp
6150: 61 63 65 20 65 76 61 6c 20 63 6f 6c 6c 72 65 76  ace eval collrev
6160: 20 7b 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d   {..namespace im
6170: 70 6f 72 74 20 3a 3a 76 63 3a 3a 72 63 73 3a 3a  port ::vc::rcs::
6180: 70 61 72 73 65 72 0a 09 6e 61 6d 65 73 70 61 63  parser..namespac
6190: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
61a0: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
61b0: 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72 79 0a 09  vs::repository..
61c0: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
61d0: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
61e0: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74  mport::cvs::stat
61f0: 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70  e..namespace imp
6200: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
6210: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69  ::import::cvs::i
6220: 6e 74 65 67 72 69 74 79 0a 09 6e 61 6d 65 73 70  ntegrity..namesp
6230: 61 63 65 20 65 76 61 6c 20 70 72 6f 6a 65 63 74  ace eval project
6240: 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63   {..    namespac
6250: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
6260: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
6270: 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 73 79 6d  vs::project::sym
6280: 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65  ..}..namespace e
6290: 76 61 6c 20 66 69 6c 65 20 7b 0a 09 20 20 20 20  val file {..    
62a0: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
62b0: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
62c0: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 66 69 6c 65  mport::cvs::file
62d0: 3a 3a 72 65 76 0a 09 7d 0a 09 6e 61 6d 65 73 70  ::rev..}..namesp
62e0: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
62f0: 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 0a  :tools::trouble.
6300: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
6310: 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c  t ::vc::tools::l
6320: 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65 72  og..log register
6330: 20 63 6f 6c 6c 72 65 76 0a 20 20 20 20 7d 0a 7d   collrev.    }.}
6340: 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
6350: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
6360: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23  ######### ######
6370: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
6380: 23 23 20 52 65 61 64 79 0a 0a 70 61 63 6b 61 67  ## Ready..packag
6390: 65 20 70 72 6f 76 69 64 65 20 76 63 3a 3a 66 6f  e provide vc::fo
63a0: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
63b0: 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c 6c 72 65 76  s::pass::collrev
63c0: 20 31 2e 30 0a 72 65 74 75 72 6e 0a               1.0.return.