Hex Artifact Content
Not logged in

Artifact 9385b6cf1b9a5e59ed7eace66e1b6429a31307f6:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [95af789e1f] - Oops. pass 5 is not complete. Missed the breaking of internal dependencies, this is done in this pass already. Extended pass _2_ and file revisions with code to save the branchchildren (possible dependencies), and pass 5 and changesets with the proper algorithm. From cvs2svn, works, do not truly like it, as it throws away and recomputes a lot of state after each split of a cset. Could update and reuse the state to perform all splits in one go. Will try that next, for now we have a working form in the code base. by aku on 2007-11-10 20:40:06.

0000: 23 23 20 2d 2a 2d 20 74 63 6c 20 2d 2a 2d 0a 23  ## -*- tcl -*-.#
0010: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
0020: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0030: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
0040: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
0050: 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 32 30  Copyright (c) 20
0060: 30 37 20 41 6e 64 72 65 61 73 20 4b 75 70 72 69  07 Andreas Kupri
0070: 65 73 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66  es..#.# This sof
0080: 74 77 61 72 65 20 69 73 20 6c 69 63 65 6e 73 65  tware is license
0090: 64 20 61 73 20 64 65 73 63 72 69 62 65 64 20 69  d as described i
00a0: 6e 20 74 68 65 20 66 69 6c 65 20 4c 49 43 45 4e  n the file LICEN
00b0: 53 45 2c 20 77 68 69 63 68 0a 23 20 79 6f 75 20  SE, which.# you 
00c0: 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65  should have rece
00d0: 69 76 65 64 20 61 73 20 70 61 72 74 20 6f 66 20  ived as part of 
00e0: 74 68 69 73 20 64 69 73 74 72 69 62 75 74 69 6f  this distributio
00f0: 6e 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 74  n..#.# This soft
0100: 77 61 72 65 20 63 6f 6e 73 69 73 74 73 20 6f 66  ware consists of
0110: 20 76 6f 6c 75 6e 74 61 72 79 20 63 6f 6e 74 72   voluntary contr
0120: 69 62 75 74 69 6f 6e 73 20 6d 61 64 65 20 62 79  ibutions made by
0130: 20 6d 61 6e 79 0a 23 20 69 6e 64 69 76 69 64 75   many.# individu
0140: 61 6c 73 2e 20 20 46 6f 72 20 65 78 61 63 74 20  als.  For exact 
0150: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 20 68 69 73  contribution his
0160: 74 6f 72 79 2c 20 73 65 65 20 74 68 65 20 72 65  tory, see the re
0170: 76 69 73 69 6f 6e 0a 23 20 68 69 73 74 6f 72 79  vision.# history
0180: 20 61 6e 64 20 6c 6f 67 73 2c 20 61 76 61 69 6c   and logs, avail
0190: 61 62 6c 65 20 61 74 20 68 74 74 70 3a 2f 2f 66  able at http://f
01a0: 6f 73 73 69 6c 2d 73 63 6d 2e 68 77 61 63 69 2e  ossil-scm.hwaci.
01b0: 63 6f 6d 2f 66 6f 73 73 69 6c 0a 23 20 23 20 23  com/fossil.# # #
01c0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
01d0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
01e0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
01f0: 23 23 23 23 23 23 23 23 0a 0a 23 23 20 50 61 73  ########..## Pas
0200: 73 20 49 49 2e 20 54 68 69 73 20 70 61 73 73 20  s II. This pass 
0210: 70 61 72 73 65 73 20 74 68 65 20 63 6f 6c 6c 65  parses the colle
0220: 63 74 65 64 20 72 63 73 20 61 72 63 68 69 76 65  cted rcs archive
0230: 73 20 61 6e 64 20 65 78 74 72 61 63 74 73 0a 23  s and extracts.#
0240: 23 20 61 6c 6c 20 74 68 65 20 69 6e 66 6f 72 6d  # all the inform
0250: 61 74 69 6f 6e 20 74 68 65 79 20 63 6f 6e 74 61  ation they conta
0260: 69 6e 20 28 72 65 76 69 73 69 6f 6e 73 2c 20 61  in (revisions, a
0270: 6e 64 20 73 79 6d 62 6f 6c 73 29 2e 0a 0a 23 20  nd symbols)...# 
0280: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
0290: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
02a0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
02b0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52  ###########.## R
02c0: 65 71 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61 63  equirements..pac
02d0: 6b 61 67 65 20 72 65 71 75 69 72 65 20 54 63 6c  kage require Tcl
02e0: 20 38 2e 34 20 20 20 20 20 20 20 20 20 20 20 20   8.4            
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0300: 20 20 20 3b 20 23 20 52 65 71 75 69 72 65 64 20     ; # Required 
0310: 72 75 6e 74 69 6d 65 2e 0a 70 61 63 6b 61 67 65  runtime..package
0320: 20 72 65 71 75 69 72 65 20 73 6e 69 74 20 20 20   require snit   
0330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0340: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b                 ;
0350: 20 23 20 4f 4f 20 73 79 73 74 65 6d 2e 0a 70 61   # OO system..pa
0360: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
0370: 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65  ::tools::trouble
0380: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0390: 20 20 20 20 3b 20 23 20 45 72 72 6f 72 20 72 65      ; # Error re
03a0: 70 6f 72 74 69 6e 67 2e 0a 70 61 63 6b 61 67 65  porting..package
03b0: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f   require vc::too
03c0: 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20 20 20 20  ls::log         
03d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b                 ;
03e0: 20 23 20 55 73 65 72 20 66 65 65 64 62 61 63 6b   # User feedback
03f0: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72  ..package requir
0400: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  e vc::fossil::im
0410: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20  port::cvs::pass 
0420: 20 20 20 20 20 20 20 20 3b 20 23 20 50 61 73 73          ; # Pass
0430: 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70 61 63   management..pac
0440: 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a  kage require vc:
0450: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
0460: 3a 63 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72 79  :cvs::repository
0470: 20 20 20 3b 20 23 20 52 65 70 6f 73 69 74 6f 72     ; # Repositor
0480: 79 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70 61  y management..pa
0490: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
04a0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
04b0: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 20 20 20 20  ::cvs::state    
04c0: 20 20 20 20 3b 20 23 20 53 74 61 74 65 20 73 74      ; # State st
04d0: 6f 72 61 67 65 2e 0a 70 61 63 6b 61 67 65 20 72  orage..package r
04e0: 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69  equire vc::fossi
04f0: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
0500: 69 6e 74 65 67 72 69 74 79 20 20 20 20 3b 20 23  integrity    ; #
0510: 20 53 74 61 74 65 20 69 6e 74 65 67 72 69 74 79   State integrity
0520: 20 63 68 65 63 6b 73 2e 0a 70 61 63 6b 61 67 65   checks..package
0530: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73   require vc::fos
0540: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
0550: 3a 3a 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 3b  ::project::sym ;
0560: 20 23 20 50 72 6f 6a 65 63 74 20 6c 65 76 65 6c   # Project level
0570: 20 73 79 6d 62 6f 6c 73 2e 0a 70 61 63 6b 61 67   symbols..packag
0580: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f  e require vc::fo
0590: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
05a0: 73 3a 3a 66 69 6c 65 3a 3a 72 65 76 20 20 20 20  s::file::rev    
05b0: 3b 20 23 20 46 69 6c 65 20 6c 65 76 65 6c 20 72  ; # File level r
05c0: 65 76 69 73 69 6f 6e 73 2e 0a 70 61 63 6b 61 67  evisions..packag
05d0: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 72 63  e require vc::rc
05e0: 73 3a 3a 70 61 72 73 65 72 20 20 20 20 20 20 20  s::parser       
05f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0600: 3b 20 23 20 52 63 73 20 61 72 63 68 69 76 65 20  ; # Rcs archive 
0610: 64 61 74 61 20 65 78 74 72 61 63 74 69 6f 6e 2e  data extraction.
0620: 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
0630: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
0640: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23  ######### ######
0650: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
0660: 23 23 20 52 65 67 69 73 74 65 72 20 74 68 65 20  ## Register the 
0670: 70 61 73 73 20 77 69 74 68 20 74 68 65 20 6d 61  pass with the ma
0680: 6e 61 67 65 6d 65 6e 74 0a 0a 76 63 3a 3a 66 6f  nagement..vc::fo
0690: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
06a0: 73 3a 3a 70 61 73 73 20 64 65 66 69 6e 65 20 5c  s::pass define \
06b0: 0a 20 20 20 20 43 6f 6c 6c 65 63 74 52 65 76 20  .    CollectRev 
06c0: 5c 0a 20 20 20 20 7b 43 6f 6c 6c 65 63 74 20 72  \.    {Collect r
06d0: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 73 79 6d  evisions and sym
06e0: 62 6f 6c 73 7d 20 5c 0a 20 20 20 20 3a 3a 76 63  bols} \.    ::vc
06f0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
0700: 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c  ::cvs::pass::col
0710: 6c 72 65 76 0a 0a 23 20 23 20 23 23 20 23 23 23  lrev..# # ## ###
0720: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
0730: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23  ############# ##
0740: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0750: 23 23 23 0a 23 23 20 0a 0a 73 6e 69 74 3a 3a 74  ###.## ..snit::t
0760: 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ype ::vc::fossil
0770: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70  ::import::cvs::p
0780: 61 73 73 3a 3a 63 6f 6c 6c 72 65 76 20 7b 0a 20  ass::collrev {. 
0790: 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23     # # ## ### ##
07a0: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
07b0: 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23  ##########.    #
07c0: 23 20 50 75 62 6c 69 63 20 41 50 49 0a 0a 20 20  # Public API..  
07d0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 65 74    typemethod set
07e0: 75 70 20 7b 7d 20 7b 0a 09 23 20 44 65 66 69 6e  up {} {..# Defin
07f0: 65 20 6e 61 6d 65 73 20 61 6e 64 20 73 74 72 75  e names and stru
0800: 63 74 75 72 65 20 6f 66 20 74 68 65 20 70 65 72  cture of the per
0810: 73 69 73 74 65 6e 74 20 73 74 61 74 65 20 6f 66  sistent state of
0820: 20 74 68 69 73 0a 09 23 20 70 61 73 73 2e 0a 0a   this..# pass...
0830: 09 73 74 61 74 65 20 72 65 61 64 69 6e 67 20 70  .state reading p
0840: 72 6f 6a 65 63 74 0a 09 73 74 61 74 65 20 72 65  roject..state re
0850: 61 64 69 6e 67 20 66 69 6c 65 0a 0a 09 23 20 57  ading file...# W
0860: 65 20 64 65 61 6c 20 77 69 74 68 20 70 65 72 20  e deal with per 
0870: 70 72 6f 6a 65 63 74 20 61 6e 64 20 70 65 72 20  project and per 
0880: 66 69 6c 65 20 64 61 74 61 2c 20 74 68 65 20 66  file data, the f
0890: 69 72 73 74 0a 09 23 20 63 6f 6c 6c 61 74 65 64  irst..# collated
08a0: 20 66 72 6f 6d 20 74 68 65 20 73 65 63 6f 6e 64   from the second
08b0: 2e 0a 0a 09 23 20 50 65 72 20 66 69 6c 65 20 77  ....# Per file w
08c0: 65 20 68 61 76 65 20 67 65 6e 65 72 61 6c 20 69  e have general i
08d0: 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20 2e 2e 2e 2c  nformation, ...,
08e0: 20 61 6e 64 20 74 68 65 6e 0a 09 23 20 72 65 76   and then..# rev
08f0: 69 73 69 6f 6e 73 20 61 6e 64 20 73 79 6d 62 6f  isions and symbo
0900: 6c 73 2e 20 54 68 65 20 6c 61 74 74 65 72 20 63  ls. The latter c
0910: 61 6e 20 62 65 20 66 75 72 74 68 65 72 20 73 65  an be further se
0920: 70 61 72 61 74 65 64 0a 09 23 20 69 6e 74 6f 20  parated..# into 
0930: 74 61 67 73 20 61 6e 64 20 62 72 61 6e 63 68 65  tags and branche
0940: 73 2e 20 41 74 20 70 72 6f 6a 65 63 74 20 6c 65  s. At project le
0950: 76 65 6c 20 74 68 65 20 70 65 72 2d 66 69 6c 65  vel the per-file
0960: 0a 09 23 20 73 79 6d 62 6f 6c 73 20 69 6e 66 6f  ..# symbols info
0970: 72 6d 61 74 69 6f 6e 20 69 73 20 6d 65 72 67 65  rmation is merge
0980: 64 2e 0a 0a 09 23 20 46 69 6c 65 20 6c 65 76 65  d....# File leve
0990: 6c 20 2e 2e 2e 0a 09 23 09 52 65 76 69 73 69 6f  l .....#.Revisio
09a0: 6e 73 2c 20 42 72 61 6e 63 68 65 73 2c 20 54 61  ns, Branches, Ta
09b0: 67 73 0a 09 23 0a 09 23 20 50 73 65 75 64 6f 20  gs..#..# Pseudo 
09c0: 63 6c 61 73 73 20 68 69 65 72 61 72 63 68 79 0a  class hierarchy.
09d0: 09 23 09 54 61 67 20 20 20 20 20 20 3c 2d 20 53  .#.Tag      <- S
09e0: 79 6d 62 6f 6c 20 3c 2d 20 45 76 65 6e 74 0a 09  ymbol <- Event..
09f0: 23 09 42 72 61 6e 63 68 20 20 20 3c 2d 20 53 79  #.Branch   <- Sy
0a00: 6d 62 6f 6c 20 3c 2d 20 45 76 65 6e 74 0a 09 23  mbol <- Event..#
0a10: 09 52 65 76 69 73 69 6f 6e 20 20 20 20 20 20 20  .Revision       
0a20: 20 20 20 20 3c 2d 20 45 76 65 6e 74 0a 0a 09 73      <- Event...s
0a30: 74 61 74 65 20 77 72 69 74 69 6e 67 20 72 65 76  tate writing rev
0a40: 69 73 69 6f 6e 20 7b 0a 09 20 20 20 20 2d 2d 20  ision {..    -- 
0a50: 52 65 76 69 73 69 6f 6e 73 2e 20 49 64 65 6e 74  Revisions. Ident
0a60: 69 66 69 65 64 20 62 79 20 61 20 67 6c 6f 62 61  ified by a globa
0a70: 6c 20 6e 75 6d 65 72 69 63 20 69 64 20 65 61 63  l numeric id eac
0a80: 68 0a 09 20 20 20 20 2d 2d 20 62 65 6c 6f 6e 67  h..    -- belong
0a90: 73 20 74 6f 20 61 20 73 69 6e 67 6c 65 20 66 69  s to a single fi
0aa0: 6c 65 2c 20 69 64 65 6e 74 69 66 69 65 64 20 62  le, identified b
0ab0: 79 20 69 74 73 20 69 64 2e 20 49 74 0a 09 20 20  y its id. It..  
0ac0: 20 20 2d 2d 20 66 75 72 74 68 65 72 20 68 61 73    -- further has
0ad0: 20 61 20 64 6f 74 74 65 64 20 72 65 76 69 73 69   a dotted revisi
0ae0: 6f 6e 20 6e 75 6d 62 65 72 20 28 44 54 4e 29 2e  on number (DTN).
0af0: 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 20 2d 2d  ..    --..    --
0b00: 20 43 6f 6e 73 74 72 61 69 6e 74 3a 20 54 68 65   Constraint: The
0b10: 20 64 6f 74 74 65 64 20 72 65 76 69 73 69 6f 6e   dotted revision
0b20: 20 6e 75 6d 62 65 72 20 69 73 20 75 6e 69 71 75   number is uniqu
0b30: 65 20 77 69 74 68 69 6e 0a 20 20 20 20 20 20 20  e within.       
0b40: 20 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20       --         
0b50: 20 20 20 20 74 68 65 20 66 69 6c 65 2e 20 53 65      the file. Se
0b60: 65 20 65 6e 64 20 6f 66 20 64 65 66 69 6e 69 74  e end of definit
0b70: 69 6f 6e 2e 0a 0a 09 20 20 20 20 72 69 64 20 20  ion....    rid  
0b80: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
0b90: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41  L  PRIMARY KEY A
0ba0: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20  UTOINCREMENT,.. 
0bb0: 20 20 20 66 69 64 20 20 49 4e 54 45 47 45 52 20     fid  INTEGER 
0bc0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52   NOT NULL  REFER
0bd0: 45 4e 43 45 53 20 66 69 6c 65 2c 20 20 20 2d 2d  ENCES file,   --
0be0: 20 46 69 6c 65 20 6f 77 6e 69 6e 67 20 72 65 76   File owning rev
0bf0: 69 73 69 6f 6e 2e 0a 09 20 20 20 20 72 65 76 20  ision...    rev 
0c00: 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55   TEXT     NOT NU
0c10: 4c 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20 20  LL,             
0c20: 20 20 20 20 20 20 20 2d 2d 20 44 6f 74 74 65 64         -- Dotted
0c30: 20 52 65 76 20 4e 75 6d 62 65 72 2e 0a 0a 09 20   Rev Number.... 
0c40: 20 20 20 2d 2d 20 41 6c 6c 20 72 65 76 69 73 69     -- All revisi
0c50: 6f 6e 73 20 62 65 6c 6f 6e 67 20 74 6f 20 61 20  ons belong to a 
0c60: 6c 69 6e 65 2d 6f 66 2d 64 65 76 65 6c 6f 70 6d  line-of-developm
0c70: 65 6e 74 2c 0a 09 20 20 20 20 2d 2d 20 69 64 65  ent,..    -- ide
0c80: 6e 74 69 66 69 65 64 20 62 79 20 61 20 73 79 6d  ntified by a sym
0c90: 62 6f 6c 20 28 70 72 6f 6a 65 63 74 20 6c 65 76  bol (project lev
0ca0: 65 6c 29 2e 20 44 75 72 69 6e 67 20 64 61 74 61  el). During data
0cb0: 0a 09 20 20 20 20 2d 2d 20 63 6f 6c 6c 65 63 74  ..    -- collect
0cc0: 69 6f 6e 20 69 74 20 77 61 73 20 61 20 66 69 6c  ion it was a fil
0cd0: 65 2d 6c 65 76 65 6c 20 62 72 61 6e 63 68 20 73  e-level branch s
0ce0: 79 6d 62 6f 6c 2e 0a 09 20 20 20 20 2d 2d 0a 09  ymbol...    --..
0cf0: 20 20 20 20 2d 2d 20 43 6f 6e 73 74 72 61 69 6e      -- Constrain
0d00: 74 3a 20 41 6c 6c 20 74 68 65 20 4c 4f 44 20 73  t: All the LOD s
0d10: 79 6d 62 6f 6c 73 20 61 72 65 20 69 6e 20 74 68  ymbols are in th
0d20: 65 20 73 61 6d 65 20 70 72 6f 6a 65 63 74 0a 09  e same project..
0d30: 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20      --          
0d40: 20 20 20 61 73 20 74 68 65 20 66 69 6c 65 20 69     as the file i
0d50: 74 73 65 6c 66 2e 20 54 68 69 73 20 63 61 6e 6e  tself. This cann
0d60: 6f 74 20 62 65 0a 09 20 20 20 20 2d 2d 20 20 20  ot be..    --   
0d70: 20 20 20 20 20 20 20 20 20 20 65 78 70 72 65 73            expres
0d80: 73 65 64 20 69 6e 20 43 52 45 41 54 45 20 54 41  sed in CREATE TA
0d90: 42 4c 45 20 73 79 6e 74 61 78 2e 0a 0a 09 20 20  BLE syntax....  
0da0: 20 20 6c 6f 64 20 20 49 4e 54 45 47 45 52 20 20    lod  INTEGER  
0db0: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
0dc0: 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20  NCES symbol, -- 
0dd0: 4c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d  Line of developm
0de0: 65 6e 74 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65  ent...    -- The
0df0: 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 61 20   revisions in a 
0e00: 66 69 6c 65 20 61 72 65 20 6f 72 67 61 6e 69 7a  file are organiz
0e10: 65 64 20 69 6e 20 61 20 66 6f 72 65 73 74 20 6f  ed in a forest o
0e20: 66 0a 09 20 20 20 20 2d 2d 20 74 72 65 65 73 2c  f..    -- trees,
0e30: 20 77 69 74 68 20 74 68 65 20 6d 61 69 6e 20 6c   with the main l
0e40: 69 6e 65 73 20 64 65 66 69 6e 65 64 20 74 68 72  ines defined thr
0e50: 6f 75 67 68 20 74 68 65 20 70 61 72 65 6e 74 20  ough the parent 
0e60: 2f 0a 09 20 20 20 20 2d 2d 20 63 68 69 6c 64 20  /..    -- child 
0e70: 72 65 66 65 72 65 6e 63 65 73 2e 20 41 20 72 65  references. A re
0e80: 76 69 73 69 6f 6e 20 77 69 74 68 6f 75 74 20 61  vision without a
0e90: 20 70 61 72 65 6e 74 20 69 73 20 74 68 65 0a 09   parent is the..
0ea0: 20 20 20 20 2d 2d 20 72 6f 6f 74 20 6f 66 20 61      -- root of a
0eb0: 20 74 72 65 65 2c 20 61 6e 64 20 61 20 72 65 76   tree, and a rev
0ec0: 69 73 69 6f 6e 20 77 69 74 68 6f 75 74 20 61 20  ision without a 
0ed0: 63 68 69 6c 64 20 69 73 20 61 0a 09 20 20 20 20  child is a..    
0ee0: 2d 2d 20 6c 65 61 66 2e 0a 0a 09 20 20 20 20 2d  -- leaf....    -
0ef0: 2d 20 43 6f 6e 73 74 72 61 69 6e 74 73 3a 20 41  - Constraints: A
0f00: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 63 6f 75  ll revisions cou
0f10: 70 6c 65 64 20 74 68 72 6f 75 67 68 20 70 61 72  pled through par
0f20: 65 6e 74 2f 63 68 69 6c 64 0a 09 20 20 20 20 2d  ent/child..    -
0f30: 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72  -              r
0f40: 65 66 65 72 20 74 6f 20 74 68 65 20 73 61 6d 65  efer to the same
0f50: 20 4c 4f 44 20 73 79 6d 62 6f 6c 2e 20 54 68 65   LOD symbol. The
0f60: 20 70 61 72 65 6e 74 0a 09 20 20 20 20 2d 2d 20   parent..    -- 
0f70: 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 20               of 
0f80: 61 20 63 68 69 6c 64 20 6f 66 20 58 20 69 73 20  a child of X is 
0f90: 58 2e 20 54 68 65 20 63 68 69 6c 64 20 6f 66 20  X. The child of 
0fa0: 61 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20  a..    --       
0fb0: 20 20 20 20 20 20 20 70 61 72 65 6e 74 20 6f 66         parent of
0fc0: 20 58 20 69 73 20 58 2e 0a 0a 09 20 20 20 20 70   X is X....    p
0fd0: 61 72 65 6e 74 20 20 49 4e 54 45 47 45 52 20 20  arent  INTEGER  
0fe0: 20 20 20 20 20 20 20 20 20 20 52 45 46 45 52 45            REFERE
0ff0: 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09  NCES revision,..
1000: 20 20 20 20 63 68 69 6c 64 20 20 20 49 4e 54 45      child   INTE
1010: 47 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52  GER            R
1020: 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69  EFERENCES revisi
1030: 6f 6e 2c 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65  on,...    -- The
1040: 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 20   representation 
1050: 6f 66 20 61 20 62 72 61 6e 63 68 20 69 6e 20 61  of a branch in a
1060: 20 74 72 65 65 20 69 73 20 74 68 65 0a 09 20 20   tree is the..  
1070: 20 20 2d 2d 20 65 78 63 65 70 74 69 6f 6e 20 74    -- exception t
1080: 6f 20 74 68 65 20 74 68 72 65 65 20 63 6f 6e 73  o the three cons
1090: 74 72 61 69 6e 74 73 20 61 62 6f 76 65 2e 0a 0a  traints above...
10a0: 09 20 20 20 20 2d 2d 20 54 68 65 20 62 65 67 69  .    -- The begi
10b0: 6e 6e 69 6e 67 20 6f 66 20 61 20 62 72 61 6e 63  nning of a branc
10c0: 68 20 69 73 20 72 65 70 72 65 73 65 6e 74 65 64  h is represented
10d0: 20 62 79 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 0a 09   by a non-NULL..
10e0: 20 20 20 20 2d 2d 20 62 70 61 72 65 6e 74 20 6f      -- bparent o
10f0: 66 20 61 20 72 65 76 69 73 69 6f 6e 2e 20 54 68  f a revision. Th
1100: 69 73 20 72 65 76 69 73 69 6f 6e 20 42 20 69 73  is revision B is
1110: 20 74 68 65 20 66 69 72 73 74 20 6f 6e 0a 09 20   the first on.. 
1120: 20 20 20 2d 2d 20 74 68 65 20 62 72 61 6e 63 68     -- the branch
1130: 2e 20 49 74 73 20 70 61 72 65 6e 74 20 50 20 69  . Its parent P i
1140: 73 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 74  s the revision t
1150: 68 65 20 62 72 61 6e 63 68 20 69 73 0a 09 20 20  he branch is..  
1160: 20 20 2d 2d 20 72 6f 6f 74 65 64 20 69 6e 2c 20    -- rooted in, 
1170: 61 6e 64 20 69 74 20 69 73 20 6e 6f 74 20 74 68  and it is not th
1180: 65 20 63 68 69 6c 64 20 6f 66 20 50 2e 20 42 20  e child of P. B 
1190: 61 6e 64 20 50 20 72 65 66 65 72 0a 09 20 20 20  and P refer..   
11a0: 20 2d 2d 20 74 6f 20 64 69 66 66 65 72 65 6e 74   -- to different
11b0: 20 4c 4f 44 20 73 79 6d 62 6f 6c 73 2e 20 54 68   LOD symbols. Th
11c0: 65 20 62 70 61 72 65 6e 74 20 6f 66 20 42 20 69  e bparent of B i
11d0: 73 20 61 6c 73 6f 20 69 74 73 0a 09 20 20 20 20  s also its..    
11e0: 2d 2d 20 4c 4f 44 2c 20 61 6e 64 20 74 68 65 20  -- LOD, and the 
11f0: 4c 4f 44 20 6f 66 20 69 74 73 20 63 68 69 6c 64  LOD of its child
1200: 72 65 6e 2e 0a 0a 09 20 20 20 20 62 70 61 72 65  ren....    bpare
1210: 6e 74 20 49 4e 54 45 47 45 52 20 20 20 20 20 20  nt INTEGER      
1220: 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53        REFERENCES
1230: 20 73 79 6d 62 6f 6c 2c 0a 0a 09 20 20 20 20 2d   symbol,...    -
1240: 2d 20 4c 61 73 74 6c 79 20 77 65 20 6b 65 65 70  - Lastly we keep
1250: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20   information is 
1260: 61 62 6f 75 74 20 6e 6f 6e 2d 74 72 75 6e 6b 20  about non-trunk 
1270: 64 65 66 61 75 6c 74 0a 09 20 20 20 20 2d 2d 20  default..    -- 
1280: 62 72 61 6e 63 68 65 73 20 28 4e 54 44 42 29 20  branches (NTDB) 
1290: 69 6e 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73  in the revisions
12a0: 2e 0a 0a 09 20 20 20 20 2d 2d 20 41 6c 6c 20 72  ....    -- All r
12b0: 65 76 69 73 69 6f 6e 73 20 6f 6e 20 74 68 65 20  evisions on the 
12c0: 4e 54 44 42 20 68 61 76 65 20 27 69 73 64 65 66  NTDB have 'isdef
12d0: 61 75 6c 74 27 20 54 52 55 45 2c 0a 09 20 20 20  ault' TRUE,..   
12e0: 20 2d 2d 20 65 76 65 72 79 6f 6e 65 20 65 6c 73   -- everyone els
12f0: 65 20 46 41 4c 53 45 2e 20 54 68 65 20 6c 61 73  e FALSE. The las
1300: 74 20 72 65 76 69 73 69 6f 6e 20 58 20 6f 6e 20  t revision X on 
1310: 74 68 65 20 4e 54 44 42 0a 09 20 20 20 20 2d 2d  the NTDB..    --
1320: 20 77 68 69 63 68 20 69 73 20 73 74 69 6c 6c 20   which is still 
1330: 63 6f 6e 73 69 64 65 72 65 64 20 74 6f 20 62 65  considered to be
1340: 20 6f 6e 20 74 68 65 20 74 72 75 6e 6b 20 61 73   on the trunk as
1350: 20 77 65 6c 6c 0a 09 20 20 20 20 2d 2d 20 68 61   well..    -- ha
1360: 73 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 20 27 64 62  s a non-NULL 'db
1370: 63 68 69 6c 64 27 20 77 68 69 63 68 20 72 65 66  child' which ref
1380: 65 72 73 20 74 6f 20 74 68 65 20 72 6f 6f 74 20  ers to the root 
1390: 6f 66 0a 09 20 20 20 20 2d 2d 20 74 68 65 20 74  of..    -- the t
13a0: 72 75 6e 6b 2e 20 54 68 65 20 72 6f 6f 74 20 61  runk. The root a
13b0: 6c 73 6f 20 68 61 73 20 61 20 6e 6f 6e 2d 4e 55  lso has a non-NU
13c0: 4c 4c 20 64 62 70 61 72 65 6e 74 0a 09 20 20 20  LL dbparent..   
13d0: 20 2d 2d 20 72 65 66 65 72 69 6e 67 20 74 6f 20   -- refering to 
13e0: 58 2e 0a 0a 09 20 20 20 20 69 73 64 65 66 61 75  X....    isdefau
13f0: 6c 74 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  lt INTEGER  NOT 
1400: 4e 55 4c 4c 2c 0a 09 20 20 20 20 64 62 70 61 72  NULL,..    dbpar
1410: 65 6e 74 20 20 49 4e 54 45 47 45 52 20 20 20 20  ent  INTEGER    
1420: 20 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43          REFERENC
1430: 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20  ES revision,..  
1440: 20 20 64 62 63 68 69 6c 64 20 20 20 49 4e 54 45    dbchild   INTE
1450: 47 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52  GER            R
1460: 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69  EFERENCES revisi
1470: 6f 6e 2c 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65  on,...    -- The
1480: 20 6d 61 69 6e 20 70 61 79 6c 6f 61 64 20 6f 66   main payload of
1490: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 61 72   the revision ar
14a0: 65 20 74 68 65 20 64 61 74 65 2f 74 69 6d 65 20  e the date/time 
14b0: 69 74 0a 09 20 20 20 20 2d 2d 20 77 61 73 20 65  it..    -- was e
14c0: 6e 74 65 72 65 64 2c 20 69 74 73 20 73 74 61 74  ntered, its stat
14d0: 65 2c 20 6f 70 65 72 61 74 69 6f 6e 20 28 3d 20  e, operation (= 
14e0: 74 79 70 65 2f 63 6c 61 73 73 29 2c 20 74 65 78  type/class), tex
14f0: 74 0a 09 20 20 20 20 2d 2d 20 63 6f 6e 74 65 6e  t..    -- conten
1500: 74 2c 20 61 6e 64 20 6d 65 74 61 20 64 61 74 61  t, and meta data
1510: 20 28 61 75 74 68 6f 72 2c 20 6c 6f 67 20 6d 65   (author, log me
1520: 73 73 61 67 65 2c 20 62 72 61 6e 63 68 2c 0a 09  ssage, branch,..
1530: 20 20 20 20 2d 2d 20 70 72 6f 6a 65 63 74 29 2e      -- project).
1540: 20 54 68 65 20 6c 61 73 74 20 69 73 20 65 6e 63   The last is enc
1550: 6f 64 65 64 20 61 73 20 73 69 6e 67 6c 65 20 69  oded as single i
1560: 64 2c 20 73 65 65 20 74 61 62 6c 65 0a 09 20 20  d, see table..  
1570: 20 20 2d 2d 20 27 6d 65 74 61 27 2e 20 54 68 65    -- 'meta'. The
1580: 20 64 61 74 65 2f 74 69 6d 65 20 69 73 20 67 69   date/time is gi
1590: 76 65 6e 20 69 6e 20 73 65 63 6f 6e 64 73 20 73  ven in seconds s
15a0: 69 6e 63 65 20 74 68 65 0a 09 20 20 20 20 2d 2d  ince the..    --
15b0: 20 65 70 6f 63 68 2c 20 66 6f 72 20 65 61 73 79   epoch, for easy
15c0: 20 63 6f 6d 70 61 72 69 73 6f 6e 2e 20 54 68 65   comparison. The
15d0: 20 74 65 78 74 20 63 6f 6e 74 65 6e 74 20 69 73   text content is
15e0: 20 61 6e 0a 09 20 20 20 20 2d 2d 20 28 6f 66 66   an..    -- (off
15f0: 73 65 74 2c 6c 65 6e 67 74 68 29 20 70 61 69 72  set,length) pair
1600: 20 69 6e 74 6f 20 74 68 65 20 72 63 73 20 61 72   into the rcs ar
1610: 63 68 69 76 65 2e 0a 0a 09 20 20 20 20 6f 70 20  chive....    op 
1620: 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20     INTEGER  NOT 
1630: 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53  NULL  REFERENCES
1640: 20 6f 70 74 79 70 65 2c 0a 09 20 20 20 20 64 61   optype,..    da
1650: 74 65 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  te  INTEGER  NOT
1660: 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 73 74 61 74   NULL,..    stat
1670: 65 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e  e TEXT     NOT N
1680: 55 4c 4c 2c 0a 09 20 20 20 20 6d 69 64 20 20 20  ULL,..    mid   
1690: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
16a0: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 6d 65  L  REFERENCES me
16b0: 74 61 2c 0a 09 20 20 20 20 63 6f 66 66 20 20 49  ta,..    coff  I
16c0: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
16d0: 2c 0a 09 20 20 20 20 63 6c 65 6e 20 20 49 4e 54  ,..    clen  INT
16e0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a  EGER  NOT NULL,.
16f0: 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 66 69  ..    UNIQUE (fi
1700: 64 2c 20 72 65 76 29 20 2d 2d 20 54 68 65 20 44  d, rev) -- The D
1710: 54 4e 20 69 73 20 75 6e 69 71 75 65 20 77 69 74  TN is unique wit
1720: 68 69 6e 20 74 68 65 20 72 65 76 69 73 69 6f 6e  hin the revision
1730: 27 73 20 66 69 6c 65 2e 0a 09 7d 0a 0a 09 73 74  's file...}...st
1740: 61 74 65 20 77 72 69 74 69 6e 67 20 6f 70 74 79  ate writing opty
1750: 70 65 20 7b 0a 09 20 20 20 20 6f 69 64 20 20 20  pe {..    oid   
1760: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1770: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 0a  L  PRIMARY KEY,.
1780: 09 20 20 20 20 6e 61 6d 65 20 20 54 45 58 54 20  .    name  TEXT 
1790: 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20      NOT NULL,.. 
17a0: 20 20 20 55 4e 49 51 55 45 28 6e 61 6d 65 29 0a     UNIQUE(name).
17b0: 09 7d 0a 09 73 74 61 74 65 20 72 75 6e 20 7b 0a  .}..state run {.
17c0: 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
17d0: 20 6f 70 74 79 70 65 20 56 41 4c 55 45 53 20 28   optype VALUES (
17e0: 2d 31 2c 27 64 65 6c 65 74 65 27 29 3b 20 20 2d  -1,'delete');  -
17f0: 2d 20 54 68 65 20 6f 70 63 6f 64 65 20 6e 61 6d  - The opcode nam
1800: 65 73 20 61 72 65 20 74 68 65 0a 09 20 20 20 20  es are the..    
1810: 49 4e 53 45 52 54 20 49 4e 54 4f 20 6f 70 74 79  INSERT INTO opty
1820: 70 65 20 56 41 4c 55 45 53 20 28 20 30 2c 27 6e  pe VALUES ( 0,'n
1830: 6f 74 68 69 6e 67 27 29 3b 20 2d 2d 20 66 69 78  othing'); -- fix
1840: 65 64 20 70 69 65 63 65 73 2c 20 73 65 65 20 6d  ed pieces, see m
1850: 79 6f 70 73 74 61 74 65 0a 09 20 20 20 20 49 4e  yopstate..    IN
1860: 53 45 52 54 20 49 4e 54 4f 20 6f 70 74 79 70 65  SERT INTO optype
1870: 20 56 41 4c 55 45 53 20 28 20 31 2c 27 61 64 64   VALUES ( 1,'add
1880: 27 29 3b 20 20 20 20 20 2d 2d 20 69 6e 20 66 69  ');     -- in fi
1890: 6c 65 3a 3a 72 65 76 2e 20 6d 79 6f 70 63 6f 64  le::rev. myopcod
18a0: 65 20 69 73 0a 09 20 20 20 20 49 4e 53 45 52 54  e is..    INSERT
18b0: 20 49 4e 54 4f 20 6f 70 74 79 70 65 20 56 41 4c   INTO optype VAL
18c0: 55 45 53 20 28 20 32 2c 27 63 68 61 6e 67 65 27  UES ( 2,'change'
18d0: 29 3b 20 20 2d 2d 20 6c 6f 61 64 65 64 20 66 72  );  -- loaded fr
18e0: 6f 6d 20 74 68 69 73 2e 0a 09 7d 0a 0a 09 73 74  om this...}...st
18f0: 61 74 65 20 77 72 69 74 69 6e 67 20 72 65 76 69  ate writing revi
1900: 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72  sionbranchchildr
1910: 65 6e 20 7b 0a 09 20 20 20 20 2d 2d 20 54 68 65  en {..    -- The
1920: 20 6e 6f 6e 2d 70 72 69 6d 61 72 79 20 63 68 69   non-primary chi
1930: 6c 64 72 65 6e 20 6f 66 20 61 20 72 65 76 69 73  ldren of a revis
1940: 69 6f 6e 2c 20 61 73 20 72 65 61 63 68 61 62 6c  ion, as reachabl
1950: 65 0a 09 20 20 20 20 2d 2d 20 74 68 72 6f 75 67  e..    -- throug
1960: 68 20 61 20 62 72 61 6e 63 68 20 73 79 6d 62 6f  h a branch symbo
1970: 6c 2c 20 61 72 65 20 6c 69 73 74 65 64 20 68 65  l, are listed he
1980: 72 65 2e 20 54 68 69 73 20 69 73 0a 09 20 20 20  re. This is..   
1990: 20 2d 2d 20 6e 65 65 64 65 64 20 62 79 20 70 61   -- needed by pa
19a0: 73 73 20 35 20 74 6f 20 62 72 65 61 6b 20 69 6e  ss 5 to break in
19b0: 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63  ternal dependenc
19c0: 69 65 73 20 69 6e 20 61 0a 09 20 20 20 20 2d 2d  ies in a..    --
19d0: 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 20 20   changeset....  
19e0: 20 20 72 69 64 20 20 20 49 4e 54 45 47 45 52 20    rid   INTEGER 
19f0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52   NOT NULL  REFER
1a00: 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a  ENCES revision,.
1a10: 09 20 20 20 20 62 72 69 64 20 20 49 4e 54 45 47  .    brid  INTEG
1a20: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45  ER  NOT NULL  RE
1a30: 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f  FERENCES revisio
1a40: 6e 2c 0a 09 20 20 20 20 55 4e 49 51 55 45 28 72  n,..    UNIQUE(r
1a50: 69 64 2c 62 72 69 64 29 0a 09 7d 0a 0a 09 73 74  id,brid)..}...st
1a60: 61 74 65 20 77 72 69 74 69 6e 67 20 74 61 67 20  ate writing tag 
1a70: 7b 0a 09 20 20 20 20 74 69 64 20 20 49 4e 54 45  {..    tid  INTE
1a80: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50  GER  NOT NULL  P
1a90: 52 49 4d 41 52 59 20 4b 45 59 20 41 55 54 4f 49  RIMARY KEY AUTOI
1aa0: 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 66  NCREMENT,..    f
1ab0: 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  id  INTEGER  NOT
1ac0: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
1ad0: 53 20 66 69 6c 65 2c 20 20 20 20 20 2d 2d 20 46  S file,     -- F
1ae0: 69 6c 65 20 74 68 65 20 69 74 65 6d 20 62 65 6c  ile the item bel
1af0: 6f 6e 67 73 20 74 6f 0a 09 20 20 20 20 6c 6f 64  ongs to..    lod
1b00: 20 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20    INTEGER       
1b10: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
1b20: 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20 4c 69 6e  symbol,   -- Lin
1b30: 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74  e of development
1b40: 20 28 4e 55 4c 4c 20 3d 3e 20 54 72 75 6e 6b 29   (NULL => Trunk)
1b50: 0a 09 20 20 20 20 73 69 64 20 20 49 4e 54 45 47  ..    sid  INTEG
1b60: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45  ER  NOT NULL  RE
1b70: 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c  FERENCES symbol,
1b80: 20 20 20 2d 2d 20 53 79 6d 62 6f 6c 20 63 61 70     -- Symbol cap
1b90: 74 75 72 69 6e 67 20 74 68 65 20 74 61 67 0a 0a  turing the tag..
1ba0: 09 20 20 20 20 72 65 76 20 20 49 4e 54 45 47 45  .    rev  INTEGE
1bb0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1bc0: 45 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e  ERENCES revision
1bd0: 20 20 2d 2d 20 54 68 65 20 72 65 76 69 73 69 6f    -- The revisio
1be0: 6e 20 62 65 69 6e 67 20 74 61 67 67 65 64 2e 0a  n being tagged..
1bf0: 09 7d 0a 0a 09 73 74 61 74 65 20 77 72 69 74 69  .}...state writi
1c00: 6e 67 20 62 72 61 6e 63 68 20 7b 0a 09 20 20 20  ng branch {..   
1c10: 20 62 69 64 20 20 20 49 4e 54 45 47 45 52 20 20   bid   INTEGER  
1c20: 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52  NOT NULL  PRIMAR
1c30: 59 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d  Y KEY AUTOINCREM
1c40: 45 4e 54 2c 0a 09 20 20 20 20 66 69 64 20 20 20  ENT,..    fid   
1c50: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1c60: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 66 69  L  REFERENCES fi
1c70: 6c 65 2c 20 20 20 20 20 2d 2d 20 46 69 6c 65 20  le,     -- File 
1c80: 74 68 65 20 69 74 65 6d 20 62 65 6c 6f 6e 67 73  the item belongs
1c90: 20 74 6f 0a 09 20 20 20 20 6c 6f 64 20 20 20 49   to..    lod   I
1ca0: 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20  NTEGER          
1cb0: 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d    REFERENCES sym
1cc0: 62 6f 6c 2c 20 20 20 2d 2d 20 4c 69 6e 65 20 6f  bol,   -- Line o
1cd0: 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 28 4e  f development (N
1ce0: 55 4c 4c 20 3d 3e 20 54 72 75 6e 6b 29 0a 09 20  ULL => Trunk).. 
1cf0: 20 20 20 73 69 64 20 20 20 49 4e 54 45 47 45 52     sid   INTEGER
1d00: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
1d10: 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 20  RENCES symbol,  
1d20: 20 2d 2d 20 53 79 6d 62 6f 6c 20 63 61 70 74 75   -- Symbol captu
1d30: 72 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68 0a  ring the branch.
1d40: 0a 09 20 20 20 20 72 6f 6f 74 20 20 49 4e 54 45  ..    root  INTE
1d50: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52  GER  NOT NULL  R
1d60: 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69  EFERENCES revisi
1d70: 6f 6e 2c 20 2d 2d 20 52 65 76 69 73 69 6f 6e 20  on, -- Revision 
1d80: 74 68 65 20 62 72 61 6e 63 68 20 73 70 72 6f 75  the branch sprou
1d90: 74 73 20 66 72 6f 6d 0a 09 20 20 20 20 66 69 72  ts from..    fir
1da0: 73 74 20 49 4e 54 45 47 45 52 20 20 20 20 20 20  st INTEGER      
1db0: 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53        REFERENCES
1dc0: 20 72 65 76 69 73 69 6f 6e 2c 20 2d 2d 20 46 69   revision, -- Fi
1dd0: 72 73 74 20 72 65 76 69 73 69 6f 6e 20 63 6f 6d  rst revision com
1de0: 6d 69 74 74 65 64 20 74 6f 20 74 68 65 20 62 72  mitted to the br
1df0: 61 6e 63 68 0a 09 20 20 20 20 62 72 61 20 20 20  anch..    bra   
1e00: 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c  TEXT     NOT NUL
1e10: 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20  L,              
1e20: 20 20 20 20 20 20 20 20 2d 2d 20 62 72 61 6e 63          -- branc
1e30: 68 20 6e 75 6d 62 65 72 0a 09 20 20 20 20 70 6f  h number..    po
1e40: 73 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  s   INTEGER  NOT
1e50: 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20 20 20   NULL           
1e60: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 63              -- c
1e70: 72 65 61 74 69 6f 6e 20 6f 72 64 65 72 20 69 6e  reation order in
1e80: 20 72 6f 6f 74 2e 0a 09 7d 0a 0a 09 23 20 50 72   root...}...# Pr
1e90: 6f 6a 65 63 74 20 6c 65 76 65 6c 20 2e 2e 2e 0a  oject level ....
1ea0: 09 23 09 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f  .#.pLineOfDevelo
1eb0: 70 6d 65 6e 74 2c 20 70 53 79 6d 62 6f 6c 2c 20  pment, pSymbol, 
1ec0: 70 42 72 61 6e 63 68 2c 20 70 54 61 67 2c 20 70  pBranch, pTag, p
1ed0: 54 72 75 6e 6b 0a 09 23 0a 09 23 09 70 54 72 75  Trunk..#..#.pTru
1ee0: 6e 6b 20 20 3c 2d 20 70 4c 69 6e 65 4f 66 44 65  nk  <- pLineOfDe
1ef0: 76 65 6c 6f 70 6d 65 6e 74 0a 09 23 09 70 42 72  velopment..#.pBr
1f00: 61 6e 63 68 20 3c 2d 20 70 53 79 6d 62 6f 6c 2c  anch <- pSymbol,
1f10: 20 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d   pLineOfDevelopm
1f20: 65 6e 74 0a 09 23 09 70 54 61 67 20 20 20 20 3c  ent..#.pTag    <
1f30: 2d 20 70 53 79 6d 62 6f 6c 2c 20 70 4c 69 6e 65  - pSymbol, pLine
1f40: 4f 66 44 65 76 65 6c 6f 70 6d 65 6e 74 0a 0a 09  OfDevelopment...
1f50: 73 74 61 74 65 20 77 72 69 74 69 6e 67 20 73 79  state writing sy
1f60: 6d 62 6f 6c 20 7b 0a 09 20 20 20 20 73 69 64 20  mbol {..    sid 
1f70: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1f80: 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20  LL  PRIMARY KEY 
1f90: 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09  AUTOINCREMENT,..
1fa0: 20 20 20 20 70 69 64 20 20 49 4e 54 45 47 45 52      pid  INTEGER
1fb0: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
1fc0: 52 45 4e 43 45 53 20 70 72 6f 6a 65 63 74 2c 20  RENCES project, 
1fd0: 20 2d 2d 20 50 72 6f 6a 65 63 74 20 74 68 65 20   -- Project the 
1fe0: 73 79 6d 62 6f 6c 20 62 65 6c 6f 6e 67 73 20 74  symbol belongs t
1ff0: 6f 0a 09 20 20 20 20 6e 61 6d 65 20 54 45 58 54  o..    name TEXT
2000: 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09       NOT NULL,..
2010: 20 20 20 20 74 79 70 65 20 49 4e 54 45 47 45 52      type INTEGER
2020: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
2030: 52 45 4e 43 45 53 20 73 79 6d 74 79 70 65 2c 20  RENCES symtype, 
2040: 20 2d 2d 20 65 6e 75 6d 20 7b 20 65 78 63 6c 75   -- enum { exclu
2050: 64 65 64 20 3d 20 30 2c 20 74 61 67 2c 20 62 72  ded = 0, tag, br
2060: 61 6e 63 68 2c 20 75 6e 64 65 66 69 6e 65 64 20  anch, undefined 
2070: 7d 0a 0a 09 20 20 20 20 74 61 67 5f 63 6f 75 6e  }...    tag_coun
2080: 74 20 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  t    INTEGER  NO
2090: 54 20 4e 55 4c 4c 2c 20 2d 2d 20 48 6f 77 20 6f  T NULL, -- How o
20a0: 66 74 65 6e 20 74 68 65 20 73 79 6d 62 6f 6c 20  ften the symbol 
20b0: 69 73 20 75 73 65 64 20 61 73 20 74 61 67 2e 0a  is used as tag..
20c0: 09 20 20 20 20 62 72 61 6e 63 68 5f 63 6f 75 6e  .    branch_coun
20d0: 74 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e  t INTEGER  NOT N
20e0: 55 4c 4c 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65  ULL, -- How ofte
20f0: 6e 20 74 68 65 20 73 79 6d 62 6f 6c 20 69 73 20  n the symbol is 
2100: 75 73 65 64 20 61 73 20 62 72 61 6e 63 68 0a 09  used as branch..
2110: 20 20 20 20 63 6f 6d 6d 69 74 5f 63 6f 75 6e 74      commit_count
2120: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
2130: 4c 4c 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e  LL, -- How often
2140: 20 61 20 66 69 6c 65 20 77 61 73 20 63 6f 6d 6d   a file was comm
2150: 69 74 74 65 64 20 6f 6e 20 74 68 65 20 73 79 6d  itted on the sym
2160: 62 6f 6c 0a 0a 09 20 20 20 20 55 4e 49 51 55 45  bol...    UNIQUE
2170: 20 28 70 69 64 2c 20 6e 61 6d 65 29 20 2d 2d 20   (pid, name) -- 
2180: 53 79 6d 62 6f 6c 73 20 61 72 65 20 75 6e 69 71  Symbols are uniq
2190: 75 65 20 77 69 74 68 69 6e 20 74 68 65 20 70 72  ue within the pr
21a0: 6f 6a 65 63 74 0a 09 7d 0a 0a 09 73 74 61 74 65  oject..}...state
21b0: 20 77 72 69 74 69 6e 67 20 62 6c 6f 63 6b 65 72   writing blocker
21c0: 20 7b 0a 09 20 20 20 20 2d 2d 20 46 6f 72 20 65   {..    -- For e
21d0: 61 63 68 20 73 79 6d 62 6f 6c 20 77 65 20 73 61  ach symbol we sa
21e0: 76 65 20 77 68 69 63 68 20 6f 74 68 65 72 20 73  ve which other s
21f0: 79 6d 62 6f 6c 73 20 61 72 65 0a 09 20 20 20 20  ymbols are..    
2200: 2d 2d 20 62 6c 6f 63 6b 69 6e 67 20 69 74 73 20  -- blocking its 
2210: 72 65 6d 6f 76 61 6c 20 28 69 66 20 74 68 65 20  removal (if the 
2220: 75 73 65 72 20 61 73 6b 73 20 66 6f 72 20 69 74  user asks for it
2230: 29 2e 0a 0a 09 20 20 20 20 73 69 64 20 49 4e 54  )....    sid INT
2240: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
2250: 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f  REFERENCES symbo
2260: 6c 2c 20 2d 2d 20 0a 09 20 20 20 20 62 69 64 20  l, -- ..    bid 
2270: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
2280: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79  L  REFERENCES sy
2290: 6d 62 6f 6c 2c 20 2d 2d 20 53 70 72 6f 75 74 65  mbol, -- Sproute
22a0: 64 20 66 72 6f 6d 20 73 69 64 2c 20 62 6c 6f 63  d from sid, bloc
22b0: 6b 73 20 69 74 2e 0a 09 20 20 20 20 55 4e 49 51  ks it...    UNIQ
22c0: 55 45 20 28 73 69 64 2c 20 62 69 64 29 0a 09 7d  UE (sid, bid)..}
22d0: 0a 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e 67  ...state writing
22e0: 20 70 61 72 65 6e 74 20 7b 0a 09 20 20 20 20 2d   parent {..    -
22f0: 2d 20 46 6f 72 20 65 61 63 68 20 73 79 6d 62 6f  - For each symbo
2300: 6c 20 77 65 20 73 61 76 65 20 77 68 69 63 68 20  l we save which 
2310: 6f 74 68 65 72 20 73 79 6d 62 6f 6c 73 20 63 61  other symbols ca
2320: 6e 20 61 63 74 20 61 73 0a 09 20 20 20 20 2d 2d  n act as..    --
2330: 20 61 20 70 6f 73 73 69 62 6c 65 20 70 61 72 65   a possible pare
2340: 6e 74 20 69 6e 20 73 6f 6d 65 20 66 69 6c 65 2c  nt in some file,
2350: 20 61 6e 64 20 68 6f 77 20 6f 66 74 65 6e 2e 0a   and how often..
2360: 0a 09 20 20 20 20 73 69 64 20 49 4e 54 45 47 45  ..    sid INTEGE
2370: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
2380: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
2390: 2d 2d 20 0a 09 20 20 20 20 70 69 64 20 49 4e 54  -- ..    pid INT
23a0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
23b0: 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f  REFERENCES symbo
23c0: 6c 2c 20 2d 2d 20 50 6f 73 73 69 62 6c 65 20 70  l, -- Possible p
23d0: 61 72 65 6e 74 20 6f 66 20 73 69 64 0a 09 20 20  arent of sid..  
23e0: 20 20 6e 20 20 20 49 4e 54 45 47 45 52 20 20 4e    n   INTEGER  N
23f0: 4f 54 20 4e 55 4c 4c 2c 20 20 20 20 20 20 20 20  OT NULL,        
2400: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 48              -- H
2410: 6f 77 20 6f 66 74 65 6e 20 70 69 64 20 63 61 6e  ow often pid can
2420: 20 61 63 74 20 61 73 20 70 61 72 65 6e 74 2e 0a   act as parent..
2430: 09 20 20 20 20 55 4e 49 51 55 45 20 28 73 69 64  .    UNIQUE (sid
2440: 2c 20 70 69 64 29 0a 09 7d 0a 0a 09 73 74 61 74  , pid)..}...stat
2450: 65 20 77 72 69 74 69 6e 67 20 73 79 6d 74 79 70  e writing symtyp
2460: 65 20 7b 0a 09 20 20 20 20 74 69 64 20 20 20 20  e {..    tid    
2470: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
2480: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 0a  L  PRIMARY KEY,.
2490: 09 20 20 20 20 6e 61 6d 65 20 20 20 54 45 58 54  .    name   TEXT
24a0: 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09       NOT NULL,..
24b0: 20 20 20 20 70 6c 75 72 61 6c 20 54 45 58 54 20      plural TEXT 
24c0: 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20      NOT NULL,.. 
24d0: 20 20 20 55 4e 49 51 55 45 20 28 6e 61 6d 65 29     UNIQUE (name)
24e0: 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 70 6c  ..    UNIQUE (pl
24f0: 75 72 61 6c 29 0a 09 7d 0a 09 73 74 61 74 65 20  ural)..}..state 
2500: 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45 52  run {..    INSER
2510: 54 20 49 4e 54 4f 20 73 79 6d 74 79 70 65 20 56  T INTO symtype V
2520: 41 4c 55 45 53 20 28 30 2c 27 65 78 63 6c 75 64  ALUES (0,'exclud
2530: 65 64 27 2c 20 27 65 78 63 6c 75 64 65 64 27 29  ed', 'excluded')
2540: 3b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e  ;..    INSERT IN
2550: 54 4f 20 73 79 6d 74 79 70 65 20 56 41 4c 55 45  TO symtype VALUE
2560: 53 20 28 31 2c 27 74 61 67 27 2c 20 20 20 20 20  S (1,'tag',     
2570: 20 27 74 61 67 73 27 29 3b 0a 09 20 20 20 20 49   'tags');..    I
2580: 4e 53 45 52 54 20 49 4e 54 4f 20 73 79 6d 74 79  NSERT INTO symty
2590: 70 65 20 56 41 4c 55 45 53 20 28 32 2c 27 62 72  pe VALUES (2,'br
25a0: 61 6e 63 68 27 2c 20 20 20 27 62 72 61 6e 63 68  anch',   'branch
25b0: 65 73 27 29 3b 0a 09 20 20 20 20 49 4e 53 45 52  es');..    INSER
25c0: 54 20 49 4e 54 4f 20 73 79 6d 74 79 70 65 20 56  T INTO symtype V
25d0: 41 4c 55 45 53 20 28 33 2c 27 75 6e 64 65 66 69  ALUES (3,'undefi
25e0: 6e 65 64 27 2c 27 75 6e 64 65 66 69 6e 65 64 27  ned','undefined'
25f0: 29 3b 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77 72  );..}...state wr
2600: 69 74 69 6e 67 20 6d 65 74 61 20 7b 0a 09 20 20  iting meta {..  
2610: 20 20 2d 2d 20 4d 65 74 61 20 64 61 74 61 20 6f    -- Meta data o
2620: 66 20 72 65 76 69 73 69 6f 6e 73 2e 20 53 65 65  f revisions. See
2630: 20 72 65 76 69 73 69 6f 6e 2e 6d 69 64 20 66 6f   revision.mid fo
2640: 72 20 74 68 65 0a 09 20 20 20 20 2d 2d 20 72 65  r the..    -- re
2650: 66 65 72 65 6e 63 65 2e 20 4d 61 6e 79 20 72 65  ference. Many re
2660: 76 69 73 69 6f 6e 73 20 63 61 6e 20 73 68 61 72  visions can shar
2670: 65 20 6d 65 74 61 20 64 61 74 61 2e 20 54 68 69  e meta data. Thi
2680: 73 20 69 73 0a 09 20 20 20 20 2d 2d 20 61 63 74  s is..    -- act
2690: 75 61 6c 6c 79 20 6f 6e 65 20 6f 66 20 74 68 65  ually one of the
26a0: 20 63 72 69 74 65 72 69 6f 6e 73 20 75 73 65 64   criterions used
26b0: 20 74 6f 20 73 6f 72 74 20 72 65 76 69 73 69 6f   to sort revisio
26c0: 6e 73 0a 09 20 20 20 20 2d 2d 20 69 6e 74 6f 20  ns..    -- into 
26d0: 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09 20 20  changesets....  
26e0: 20 20 6d 69 64 20 49 4e 54 45 47 45 52 20 20 4e    mid INTEGER  N
26f0: 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59  OT NULL  PRIMARY
2700: 20 4b 45 59 20 20 41 55 54 4f 49 4e 43 52 45 4d   KEY  AUTOINCREM
2710: 45 4e 54 2c 0a 0a 09 20 20 20 20 2d 2d 20 4d 65  ENT,...    -- Me
2720: 74 61 20 64 61 74 61 20 62 65 6c 6f 6e 67 73 20  ta data belongs 
2730: 74 6f 20 61 20 73 70 65 63 69 66 69 63 20 70 72  to a specific pr
2740: 6f 6a 65 63 74 2c 20 73 74 72 6f 6e 67 65 72 2c  oject, stronger,
2750: 20 74 6f 20 61 0a 09 20 20 20 20 2d 2d 20 62 72   to a..    -- br
2760: 61 6e 63 68 20 69 6e 20 74 68 61 74 20 70 72 6f  anch in that pro
2770: 6a 65 63 74 2e 20 49 74 20 66 75 72 74 68 65 72  ject. It further
2780: 20 68 61 73 20 61 20 6c 6f 67 20 6d 65 73 73 61   has a log messa
2790: 67 65 2c 0a 09 20 20 20 20 2d 2d 20 61 6e 64 20  ge,..    -- and 
27a0: 69 74 73 20 61 75 74 68 6f 72 2e 20 54 68 69 73  its author. This
27b0: 20 69 73 20 75 6e 69 71 75 65 20 77 69 74 68 20   is unique with 
27c0: 74 68 65 20 70 72 6f 6a 65 63 74 20 61 6e 64 0a  the project and.
27d0: 09 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 2e 0a  .    -- branch..
27e0: 0a 09 20 20 20 20 70 69 64 20 49 4e 54 45 47 45  ..    pid INTEGE
27f0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
2800: 45 52 45 4e 43 45 53 20 70 72 6f 6a 65 63 74 2c  ERENCES project,
2810: 20 20 2d 2d 0a 09 20 20 20 20 62 69 64 20 49 4e    --..    bid IN
2820: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
2830: 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62   REFERENCES symb
2840: 6f 6c 2c 20 20 20 2d 2d 0a 09 20 20 20 20 61 69  ol,   --..    ai
2850: 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e  d INTEGER  NOT N
2860: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
2870: 61 75 74 68 6f 72 2c 20 20 20 2d 2d 0a 09 20 20  author,   --..  
2880: 20 20 63 69 64 20 49 4e 54 45 47 45 52 20 20 4e    cid INTEGER  N
2890: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
28a0: 43 45 53 20 63 6d 65 73 73 61 67 65 2c 20 2d 2d  CES cmessage, --
28b0: 0a 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 70  ...    UNIQUE (p
28c0: 69 64 2c 20 62 69 64 2c 20 61 69 64 2c 20 63 69  id, bid, aid, ci
28d0: 64 29 0a 0a 09 20 20 20 20 2d 2d 20 43 6f 6e 73  d)...    -- Cons
28e0: 74 72 61 69 6e 74 73 3a 20 54 68 65 20 70 72 6f  traints: The pro
28f0: 6a 65 63 74 20 6f 66 20 74 68 65 20 6d 65 74 61  ject of the meta
2900: 20 64 61 74 61 20 6f 66 20 61 20 72 65 76 69 73   data of a revis
2910: 69 6f 6e 0a 09 20 20 20 20 2d 2d 20 20 20 20 20  ion..    --     
2920: 20 20 20 20 20 20 20 20 20 58 20 69 73 20 74 68           X is th
2930: 65 20 73 61 6d 65 20 61 73 20 74 68 65 20 70 72  e same as the pr
2940: 6f 6a 65 63 74 20 6f 66 20 58 20 69 74 73 65 6c  oject of X itsel
2950: 66 2e 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 20  f...    --..    
2960: 2d 2d 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 20  -- ............ 
2970: 54 68 65 20 62 72 61 6e 63 68 20 6f 66 20 74 68  The branch of th
2980: 65 20 6d 65 74 61 20 64 61 74 61 20 6f 66 20 61  e meta data of a
2990: 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 2d   revision..    -
29a0: 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 58  -              X
29b0: 20 69 73 20 74 68 65 20 73 61 6d 65 20 61 73 20   is the same as 
29c0: 74 68 65 20 6c 69 6e 65 20 6f 66 20 64 65 76 65  the line of deve
29d0: 6c 6f 70 6d 65 6e 74 0a 09 20 20 20 20 2d 2d 20  lopment..    -- 
29e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 20               of 
29f0: 58 20 69 74 73 65 6c 66 2e 0a 09 7d 0a 0a 09 23  X itself...}...#
2a00: 20 41 75 74 68 6f 72 73 20 61 6e 64 20 63 6f 6d   Authors and com
2a10: 6d 69 74 20 6d 65 73 73 61 67 65 73 20 61 72 65  mit messages are
2a20: 20 66 75 6c 6c 79 20 67 6c 6f 62 61 6c 2c 20 69   fully global, i
2a30: 2e 65 2e 20 70 65 72 0a 09 23 20 72 65 70 6f 73  .e. per..# repos
2a40: 69 74 6f 72 79 2e 0a 0a 09 73 74 61 74 65 20 77  itory....state w
2a50: 72 69 74 69 6e 67 20 61 75 74 68 6f 72 20 7b 0a  riting author {.
2a60: 09 20 20 20 20 61 69 64 20 20 49 4e 54 45 47 45  .    aid  INTEGE
2a70: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49  R  NOT NULL  PRI
2a80: 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f 49 4e  MARY KEY  AUTOIN
2a90: 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 6e 61  CREMENT,..    na
2aa0: 6d 65 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20  me TEXT     NOT 
2ab0: 4e 55 4c 4c 20 20 55 4e 49 51 55 45 0a 09 7d 0a  NULL  UNIQUE..}.
2ac0: 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e 67 20  ..state writing 
2ad0: 63 6d 65 73 73 61 67 65 20 7b 0a 09 20 20 20 20  cmessage {..    
2ae0: 63 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  cid  INTEGER  NO
2af0: 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20  T NULL  PRIMARY 
2b00: 4b 45 59 20 20 41 55 54 4f 49 4e 43 52 45 4d 45  KEY  AUTOINCREME
2b10: 4e 54 2c 0a 09 20 20 20 20 74 65 78 74 20 54 45  NT,..    text TE
2b20: 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 20  XT     NOT NULL 
2b30: 20 55 4e 49 51 55 45 0a 09 7d 0a 0a 09 70 72 6f   UNIQUE..}...pro
2b40: 6a 65 63 74 3a 3a 73 79 6d 20 67 65 74 73 79 6d  ject::sym getsym
2b50: 74 79 70 65 73 0a 09 66 69 6c 65 3a 3a 72 65 76  types..file::rev
2b60: 20 20 20 20 67 65 74 6f 70 63 6f 64 65 73 0a 09      getopcodes..
2b70: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
2b80: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61    typemethod loa
2b90: 64 20 7b 7d 20 7b 0a 09 73 74 61 74 65 20 72 65  d {} {..state re
2ba0: 61 64 69 6e 67 20 73 79 6d 62 6f 6c 0a 09 73 74  ading symbol..st
2bb0: 61 74 65 20 72 65 61 64 69 6e 67 20 73 79 6d 74  ate reading symt
2bc0: 79 70 65 0a 09 73 74 61 74 65 20 72 65 61 64 69  ype..state readi
2bd0: 6e 67 20 6f 70 74 79 70 65 0a 0a 09 70 72 6f 6a  ng optype...proj
2be0: 65 63 74 3a 3a 73 79 6d 20 67 65 74 73 79 6d 74  ect::sym getsymt
2bf0: 79 70 65 73 0a 09 66 69 6c 65 3a 3a 72 65 76 20  ypes..file::rev 
2c00: 20 20 20 67 65 74 6f 70 63 6f 64 65 73 0a 09 72     getopcodes..r
2c10: 65 70 6f 73 69 74 6f 72 79 20 20 20 6c 6f 61 64  epository   load
2c20: 73 79 6d 62 6f 6c 73 0a 09 72 65 74 75 72 6e 0a  symbols..return.
2c30: 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d      }..    typem
2c40: 65 74 68 6f 64 20 72 75 6e 20 7b 7d 20 7b 0a 09  ethod run {} {..
2c50: 23 20 50 61 73 73 20 6d 61 6e 61 67 65 72 20 69  # Pass manager i
2c60: 6e 74 65 72 66 61 63 65 2e 20 45 78 65 63 75 74  nterface. Execut
2c70: 65 64 20 74 6f 20 70 65 72 66 6f 72 6d 20 74 68  ed to perform th
2c80: 65 0a 09 23 20 66 75 6e 63 74 69 6f 6e 61 6c 69  e..# functionali
2c90: 74 79 20 6f 66 20 74 68 65 20 70 61 73 73 2e 0a  ty of the pass..
2ca0: 0a 09 73 65 74 20 72 62 61 73 65 20 5b 72 65 70  ..set rbase [rep
2cb0: 6f 73 69 74 6f 72 79 20 62 61 73 65 3f 5d 0a 09  ository base?]..
2cc0: 66 6f 72 65 61 63 68 20 70 72 6f 6a 65 63 74 20  foreach project 
2cd0: 5b 72 65 70 6f 73 69 74 6f 72 79 20 70 72 6f 6a  [repository proj
2ce0: 65 63 74 73 5d 20 7b 0a 09 20 20 20 20 73 65 74  ects] {..    set
2cf0: 20 62 61 73 65 20 5b 66 69 6c 65 20 6a 6f 69 6e   base [file join
2d00: 20 24 72 62 61 73 65 20 5b 24 70 72 6f 6a 65 63   $rbase [$projec
2d10: 74 20 62 61 73 65 5d 5d 0a 09 20 20 20 20 6c 6f  t base]]..    lo
2d20: 67 20 77 72 69 74 65 20 31 20 63 6f 6c 6c 72 65  g write 1 collre
2d30: 76 20 22 50 72 6f 63 65 73 73 69 6e 67 20 24 62  v "Processing $b
2d40: 61 73 65 22 0a 0a 09 20 20 20 20 66 6f 72 65 61  ase"...    forea
2d50: 63 68 20 66 69 6c 65 20 5b 24 70 72 6f 6a 65 63  ch file [$projec
2d60: 74 20 66 69 6c 65 73 5d 20 7b 0a 09 09 73 65 74  t files] {...set
2d70: 20 70 61 74 68 20 5b 24 66 69 6c 65 20 70 61 74   path [$file pat
2d80: 68 5d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 32  h]...log write 2
2d90: 20 63 6f 6c 6c 72 65 76 20 22 50 61 72 73 69 6e   collrev "Parsin
2da0: 67 20 24 70 61 74 68 22 0a 09 09 69 66 20 7b 5b  g $path"...if {[
2db0: 63 61 74 63 68 20 7b 0a 09 09 20 20 20 20 70 61  catch {...    pa
2dc0: 72 73 65 72 20 70 72 6f 63 65 73 73 20 5b 66 69  rser process [fi
2dd0: 6c 65 20 6a 6f 69 6e 20 24 62 61 73 65 20 24 70  le join $base $p
2de0: 61 74 68 5d 20 24 66 69 6c 65 0a 09 09 7d 20 6d  ath] $file...} m
2df0: 73 67 5d 7d 20 7b 0a 09 09 20 20 20 20 67 6c 6f  sg]} {...    glo
2e00: 62 61 6c 20 65 72 72 6f 72 43 6f 64 65 0a 09 09  bal errorCode...
2e10: 20 20 20 20 69 66 20 7b 24 65 72 72 6f 72 43 6f      if {$errorCo
2e20: 64 65 20 65 71 20 22 76 63 3a 3a 72 63 73 3a 3a  de eq "vc::rcs::
2e30: 70 61 72 73 65 72 22 7d 20 7b 0a 09 09 09 74 72  parser"} {....tr
2e40: 6f 75 62 6c 65 20 66 61 74 61 6c 20 22 24 70 61  ouble fatal "$pa
2e50: 74 68 20 69 73 20 6e 6f 74 20 61 20 76 61 6c 69  th is not a vali
2e60: 64 20 52 43 53 20 61 72 63 68 69 76 65 20 28 24  d RCS archive ($
2e70: 6d 73 67 29 22 0a 09 09 20 20 20 20 7d 20 65 6c  msg)"...    } el
2e80: 73 65 20 7b 0a 09 09 09 67 6c 6f 62 61 6c 20 65  se {....global e
2e90: 72 72 6f 72 49 6e 66 6f 0a 09 09 09 74 72 6f 75  rrorInfo....trou
2ea0: 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 24 65 72  ble internal $er
2eb0: 72 6f 72 49 6e 66 6f 0a 09 09 20 20 20 20 7d 0a  rorInfo...    }.
2ec0: 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20 20  ..} else {...   
2ed0: 20 23 20 57 65 20 70 65 72 73 69 73 74 20 74 68   # We persist th
2ee0: 65 20 63 6f 72 65 20 6f 66 20 74 68 65 20 64 61  e core of the da
2ef0: 74 61 20 63 6f 6c 6c 65 63 74 65 64 20 61 62 6f  ta collected abo
2f00: 75 74 0a 09 09 20 20 20 20 23 20 65 61 63 68 20  ut...    # each 
2f10: 66 69 6c 65 20 69 6d 6d 65 64 69 61 74 65 6c 79  file immediately
2f20: 20 61 66 74 65 72 20 69 74 20 68 61 73 20 62 65   after it has be
2f30: 65 6e 20 70 61 72 73 65 64 0a 09 09 20 20 20 20  en parsed...    
2f40: 23 20 61 6e 64 20 77 72 61 6e 67 6c 65 64 20 69  # and wrangled i
2f50: 6e 74 6f 20 73 68 61 70 65 2c 20 61 6e 64 20 74  nto shape, and t
2f60: 68 65 6e 20 64 72 6f 70 20 69 74 20 66 72 6f 6d  hen drop it from
2f70: 0a 09 09 20 20 20 20 23 20 6d 65 6d 6f 72 79 2e  ...    # memory.
2f80: 20 54 68 69 73 20 69 73 20 64 6f 6e 65 20 74 6f   This is done to
2f90: 20 6b 65 65 70 20 74 68 65 20 61 6d 6f 75 6e 74   keep the amount
2fa0: 20 6f 66 0a 09 09 20 20 20 20 23 20 72 65 71 75   of...    # requ
2fb0: 69 72 65 64 20 6d 65 6d 6f 72 79 20 77 69 74 68  ired memory with
2fc0: 69 6e 20 73 65 6e 73 69 62 6c 65 20 6c 69 6d 69  in sensible limi
2fd0: 74 73 2e 20 57 69 74 68 6f 75 74 0a 09 09 20 20  ts. Without...  
2fe0: 20 20 23 20 64 6f 69 6e 67 20 69 74 20 74 68 69    # doing it thi
2ff0: 73 20 77 61 79 20 77 65 20 77 6f 75 6c 64 20 65  s way we would e
3000: 61 73 69 6c 79 20 67 6f 62 62 6c 65 20 75 70 20  asily gobble up 
3010: 31 47 0a 09 09 20 20 20 20 23 20 6f 66 20 52 41  1G...    # of RA
3020: 4d 20 6f 72 20 6d 6f 72 65 20 77 69 74 68 20 61  M or more with a
3030: 6c 6c 20 74 68 65 20 6f 62 6a 65 63 74 73 20 28  ll the objects (
3040: 72 65 76 69 73 69 6f 6e 73 0a 09 09 20 20 20 20  revisions...    
3050: 23 20 61 6e 64 20 66 69 6c 65 2d 6c 65 76 65 6c  # and file-level
3060: 20 73 79 6d 62 6f 6c 73 29 2e 0a 0a 09 09 20 20   symbols).....  
3070: 20 20 24 66 69 6c 65 20 70 65 72 73 69 73 74 0a    $file persist.
3080: 09 09 7d 0a 0a 09 09 24 66 69 6c 65 20 64 72 6f  ..}....$file dro
3090: 70 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20 24  p..    }...    $
30a0: 70 72 6f 6a 65 63 74 20 70 75 72 67 65 67 68 6f  project purgegho
30b0: 73 74 73 79 6d 62 6f 6c 73 0a 09 7d 0a 0a 09 72  stsymbols..}...r
30c0: 65 70 6f 73 69 74 6f 72 79 20 70 72 69 6e 74 72  epository printr
30d0: 65 76 73 74 61 74 69 73 74 69 63 73 0a 09 72 65  evstatistics..re
30e0: 70 6f 73 69 74 6f 72 79 20 70 65 72 73 69 73 74  pository persist
30f0: 72 65 76 0a 09 69 6e 74 65 67 72 69 74 79 20 20  rev..integrity  
3100: 73 74 72 69 63 74 0a 0a 09 6c 6f 67 20 77 72 69  strict...log wri
3110: 74 65 20 31 20 63 6f 6c 6c 72 65 76 20 22 53 63  te 1 collrev "Sc
3120: 61 6e 20 63 6f 6d 70 6c 65 74 65 64 22 0a 09 72  an completed"..r
3130: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
3140: 20 74 79 70 65 6d 65 74 68 6f 64 20 64 69 73 63   typemethod disc
3150: 61 72 64 20 7b 7d 20 7b 0a 09 23 20 50 61 73 73  ard {} {..# Pass
3160: 20 6d 61 6e 61 67 65 72 20 69 6e 74 65 72 66 61   manager interfa
3170: 63 65 2e 20 45 78 65 63 75 74 65 64 20 66 6f 72  ce. Executed for
3180: 20 61 6c 6c 20 70 61 73 73 65 73 20 61 66 74 65   all passes afte
3190: 72 20 74 68 65 0a 09 23 20 72 75 6e 20 70 61 73  r the..# run pas
31a0: 73 65 73 2c 20 74 6f 20 72 65 6d 6f 76 65 20 61  ses, to remove a
31b0: 6c 6c 20 64 61 74 61 20 6f 66 20 74 68 69 73 20  ll data of this 
31c0: 70 61 73 73 20 66 72 6f 6d 20 74 68 65 20 73 74  pass from the st
31d0: 61 74 65 2c 0a 09 23 20 61 73 20 62 65 69 6e 67  ate,..# as being
31e0: 20 6f 75 74 20 6f 66 20 64 61 74 65 2e 0a 0a 09   out of date....
31f0: 73 74 61 74 65 20 64 69 73 63 61 72 64 20 72 65  state discard re
3200: 76 69 73 69 6f 6e 0a 09 73 74 61 74 65 20 64 69  vision..state di
3210: 73 63 61 72 64 20 74 61 67 0a 09 73 74 61 74 65  scard tag..state
3220: 20 64 69 73 63 61 72 64 20 62 72 61 6e 63 68 0a   discard branch.
3230: 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20 73  .state discard s
3240: 79 6d 62 6f 6c 0a 09 73 74 61 74 65 20 64 69 73  ymbol..state dis
3250: 63 61 72 64 20 62 6c 6f 63 6b 65 72 0a 09 73 74  card blocker..st
3260: 61 74 65 20 64 69 73 63 61 72 64 20 70 61 72 65  ate discard pare
3270: 6e 74 0a 09 73 74 61 74 65 20 64 69 73 63 61 72  nt..state discar
3280: 64 20 73 79 6d 74 79 70 65 0a 09 73 74 61 74 65  d symtype..state
3290: 20 64 69 73 63 61 72 64 20 6d 65 74 61 0a 09 73   discard meta..s
32a0: 74 61 74 65 20 64 69 73 63 61 72 64 20 61 75 74  tate discard aut
32b0: 68 6f 72 0a 09 73 74 61 74 65 20 64 69 73 63 61  hor..state disca
32c0: 72 64 20 63 6d 65 73 73 61 67 65 0a 09 72 65 74  rd cmessage..ret
32d0: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70  urn.    }..    p
32e0: 72 6f 63 20 50 61 72 61 6e 6f 69 61 20 7b 7d 20  roc Paranoia {} 
32f0: 7b 0a 09 23 20 54 68 69 73 20 63 6f 64 65 20 70  {..# This code p
3300: 65 72 66 6f 72 6d 73 20 61 20 6e 75 6d 62 65 72  erforms a number
3310: 20 6f 66 20 70 61 72 61 6e 6f 69 64 20 63 68 65   of paranoid che
3320: 63 6b 73 20 6f 66 20 74 68 65 0a 09 23 20 64 61  cks of the..# da
3330: 74 61 62 61 73 65 2c 20 73 65 61 72 63 68 69 6e  tabase, searchin
3340: 67 20 66 6f 72 20 69 6e 63 6f 6e 73 69 73 74 65  g for inconsiste
3350: 6e 74 20 63 72 6f 73 73 2d 72 65 66 65 72 65 6e  nt cross-referen
3360: 63 65 73 2e 0a 09 6c 6f 67 20 77 72 69 74 65 20  ces...log write 
3370: 34 20 63 6f 6c 6c 72 65 76 20 7b 43 68 65 63 6b  4 collrev {Check
3380: 20 64 61 74 61 62 61 73 65 20 63 6f 6e 73 69 73   database consis
3390: 74 65 6e 63 79 7d 0a 0a 09 73 65 74 20 6e 20 30  tency}...set n 0
33a0: 20 3b 20 23 20 43 6f 75 6e 74 65 72 20 66 6f 72   ; # Counter for
33b0: 20 74 68 65 20 63 68 65 63 6b 73 20 28 77 65 20   the checks (we 
33c0: 70 72 69 6e 74 20 61 6e 20 69 64 20 62 65 66 6f  print an id befo
33d0: 72 65 20 74 68 65 0a 09 09 20 20 23 20 6d 61 69  re the...  # mai
33e0: 6e 20 6c 61 62 65 6c 29 2e 0a 0a 09 23 20 46 69  n label)....# Fi
33f0: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
3400: 20 77 68 69 63 68 20 64 69 73 61 67 72 65 65 20   which disagree 
3410: 77 69 74 68 20 74 68 65 69 72 20 6c 69 6e 65 20  with their line 
3420: 6f 66 0a 09 23 20 64 65 76 65 6c 6f 70 6d 65 6e  of..# developmen
3430: 74 20 61 62 6f 75 74 20 74 68 65 20 70 72 6f 6a  t about the proj
3440: 65 63 74 20 74 68 65 79 20 61 72 65 20 6f 77 6e  ect they are own
3450: 65 64 20 62 79 2e 0a 09 43 68 65 63 6b 20 5c 0a  ed by...Check \.
3460: 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20  .    {Revisions 
3470: 61 6e 64 20 74 68 65 69 72 20 4c 4f 44 73 20 68  and their LODs h
3480: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65  ave to be in the
3490: 20 73 61 6d 65 20 70 72 6f 6a 65 63 74 7d 20 5c   same project} \
34a0: 0a 09 20 20 20 20 7b 64 69 73 61 67 72 65 65 73  ..    {disagrees
34b0: 20 77 69 74 68 20 69 74 73 20 4c 4f 44 20 61 62   with its LOD ab
34c0: 6f 75 74 20 6f 77 6e 69 6e 67 20 70 72 6f 6a 65  out owning proje
34d0: 63 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  ct} {...SELECT F
34e0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
34f0: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  ROM revision R, 
3500: 66 69 6c 65 20 46 2c 20 73 79 6d 62 6f 6c 20 53  file F, symbol S
3510: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
3520: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
3530: 2e 6c 6f 64 20 3d 20 53 2e 73 69 64 0a 09 09 41  .lod = S.sid...A
3540: 4e 44 20 20 20 46 2e 70 69 64 20 21 3d 20 53 2e  ND   F.pid != S.
3550: 70 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  pid...;..    }..
3560: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
3570: 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73 67 72  ions which disgr
3580: 65 65 20 77 69 74 68 20 74 68 65 69 72 20 6d 65  ee with their me
3590: 74 61 20 64 61 74 61 20 61 62 6f 75 74 0a 09 23  ta data about..#
35a0: 20 74 68 65 20 70 72 6f 6a 65 63 74 20 74 68 65   the project the
35b0: 79 20 61 72 65 20 6f 77 6e 65 64 20 62 79 2e 0a  y are owned by..
35c0: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52  .Check \..    {R
35d0: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65  evisions and the
35e0: 69 72 20 6d 65 74 61 20 64 61 74 61 20 68 61 76  ir meta data hav
35f0: 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73  e to be in the s
3600: 61 6d 65 20 70 72 6f 6a 65 63 74 7d 20 5c 0a 09  ame project} \..
3610: 20 20 20 20 7b 64 69 73 61 67 72 65 65 73 20 77      {disagrees w
3620: 69 74 68 20 69 74 73 20 6d 65 74 61 20 64 61 74  ith its meta dat
3630: 61 20 61 62 6f 75 74 20 6f 77 6e 69 6e 67 20 70  a about owning p
3640: 72 6f 6a 65 63 74 7d 20 7b 0a 09 09 53 45 4c 45  roject} {...SELE
3650: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
3660: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
3670: 20 52 2c 20 66 69 6c 65 20 46 2c 20 6d 65 74 61   R, file F, meta
3680: 20 4d 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   M...WHERE R.fid
3690: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
36a0: 20 52 2e 6d 69 64 20 3d 20 4d 2e 6d 69 64 0a 09   R.mid = M.mid..
36b0: 09 41 4e 44 20 20 20 46 2e 70 69 64 20 21 3d 20  .AND   F.pid != 
36c0: 4d 2e 70 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d  M.pid...;..    }
36d0: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
36e0: 69 73 69 6f 6e 73 20 77 68 69 63 68 20 64 69 73  isions which dis
36f0: 67 72 65 65 20 77 69 74 68 20 74 68 65 69 72 20  gree with their 
3700: 6d 65 74 61 20 64 61 74 61 20 61 62 6f 75 74 0a  meta data about.
3710: 09 23 20 74 68 65 20 62 72 61 6e 63 68 2f 6c 69  .# the branch/li
3720: 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e  ne of developmen
3730: 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f  t they belong to
3740: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
3750: 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74  {Revisions and t
3760: 68 65 69 72 20 6d 65 74 61 20 64 61 74 61 20 68  heir meta data h
3770: 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68 65  ave to be in the
3780: 20 73 61 6d 65 20 4c 4f 44 7d 20 5c 0a 09 20 20   same LOD} \..  
3790: 20 20 7b 64 69 73 61 67 72 65 65 73 20 77 69 74    {disagrees wit
37a0: 68 20 69 74 73 20 6d 65 74 61 20 64 61 74 61 20  h its meta data 
37b0: 61 62 6f 75 74 20 6f 77 6e 69 6e 67 20 4c 4f 44  about owning LOD
37c0: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
37d0: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
37e0: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 6d 65  M revision R, me
37f0: 74 61 20 4d 2c 20 66 69 6c 65 20 46 0a 09 09 57  ta M, file F...W
3800: 48 45 52 45 20 52 2e 6d 69 64 20 3d 20 4d 2e 6d  HERE R.mid = M.m
3810: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64  id...AND   R.lod
3820: 20 21 3d 20 4d 2e 62 69 64 0a 09 09 41 4e 44 20   != M.bid...AND 
3830: 20 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a    R.fid = F.fid.
3840: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69  ..;..    }..# Fi
3850: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
3860: 20 77 69 74 68 20 61 20 70 72 69 6d 61 72 79 20   with a primary 
3870: 63 68 69 6c 64 20 77 68 69 63 68 20 64 69 73 61  child which disa
3880: 67 72 65 65 73 0a 09 23 20 61 62 6f 75 74 20 74  grees..# about t
3890: 68 65 20 66 69 6c 65 20 74 68 65 79 20 62 65 6c  he file they bel
38a0: 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c  ong to...Check \
38b0: 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73  ..    {Revisions
38c0: 20 61 6e 64 20 74 68 65 69 72 20 70 72 69 6d 61   and their prima
38d0: 72 79 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65  ry children have
38e0: 20 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61   to be in the sa
38f0: 6d 65 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20  me file} \..    
3900: 7b 64 69 73 61 67 72 65 65 73 20 77 69 74 68 20  {disagrees with 
3910: 69 74 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c  its primary chil
3920: 64 20 61 62 6f 75 74 20 74 68 65 20 6f 77 6e 69  d about the owni
3930: 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09 53 45 4c  ng file} {...SEL
3940: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
3950: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f  v...FROM revisio
3960: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c  n R, revision C,
3970: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
3980: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
3990: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 49 53  AND   R.child IS
39a0: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20   NOT NULL...AND 
39b0: 20 20 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69    R.child = C.ri
39c0: 64 0a 09 09 41 4e 44 20 20 20 43 2e 66 69 64 20  d...AND   C.fid 
39d0: 21 3d 20 52 2e 66 69 64 0a 09 09 3b 0a 09 20 20  != R.fid...;..  
39e0: 20 20 7d 0a 0a 09 23 20 46 69 6e 64 20 61 6c 6c    }...# Find all
39f0: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
3a00: 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20  a branch parent 
3a10: 73 79 6d 62 6f 6c 20 77 68 6f 73 65 20 70 61 72  symbol whose par
3a20: 65 6e 74 0a 09 23 20 64 69 73 61 67 72 65 65 73  ent..# disagrees
3a30: 20 61 62 6f 75 74 20 74 68 65 20 66 69 6c 65 20   about the file 
3a40: 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a  they belong to..
3a50: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52  .Check \..    {R
3a60: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65  evisions and the
3a70: 69 72 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72  ir branch childr
3a80: 65 6e 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e  en have to be in
3a90: 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 7d 20   the same file} 
3aa0: 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65 20 62  \..    {at the b
3ab0: 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20  eginning of its 
3ac0: 62 72 61 6e 63 68 20 61 6e 64 20 69 74 73 20 70  branch and its p
3ad0: 61 72 65 6e 74 20 64 69 73 61 67 72 65 65 20 61  arent disagree a
3ae0: 62 6f 75 74 20 74 68 65 20 6f 77 6e 69 6e 67 20  bout the owning 
3af0: 66 69 6c 65 7d 20 7b 0a 09 09 53 45 4c 45 43 54  file} {...SELECT
3b00: 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09   F.name, R.rev..
3b10: 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52  .FROM revision R
3b20: 2c 20 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69  , revision P, fi
3b30: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66  le F...WHERE R.f
3b40: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
3b50: 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20     R.bparent IS 
3b60: 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20  NOT NULL...AND  
3b70: 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72 69   R.parent = P.ri
3b80: 64 0a 09 09 41 4e 44 20 20 20 52 2e 66 69 64 20  d...AND   R.fid 
3b90: 21 3d 20 50 2e 66 69 64 0a 09 09 3b 0a 09 20 20  != P.fid...;..  
3ba0: 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20    }..# Find all 
3bb0: 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61  revisions with a
3bc0: 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20   non-NTDB child 
3bd0: 77 68 69 63 68 20 64 69 73 61 67 72 65 65 73 0a  which disagrees.
3be0: 09 23 20 61 62 6f 75 74 20 74 68 65 20 66 69 6c  .# about the fil
3bf0: 65 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f  e they belong to
3c00: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
3c10: 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74  {Revisions and t
3c20: 68 65 69 72 20 6e 6f 6e 2d 4e 54 44 42 20 63 68  heir non-NTDB ch
3c30: 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62  ildren have to b
3c40: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 66 69  e in the same fi
3c50: 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61  le} \..    {disa
3c60: 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6e  grees with its n
3c70: 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20 61 62  on-NTDB child ab
3c80: 6f 75 74 20 74 68 65 20 6f 77 6e 69 6e 67 20 66  out the owning f
3c90: 69 6c 65 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20  ile} {...SELECT 
3ca0: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
3cb0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
3cc0: 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c   revision C, fil
3cd0: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69  e F...WHERE R.fi
3ce0: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20  d = F.fid...AND 
3cf0: 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e    R.dbchild IS N
3d00: 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20  OT NULL...AND   
3d10: 52 2e 64 62 63 68 69 6c 64 20 3d 20 43 2e 72 69  R.dbchild = C.ri
3d20: 64 0a 09 09 41 4e 44 20 20 20 43 2e 66 69 64 20  d...AND   C.fid 
3d30: 21 3d 20 52 2e 66 69 64 0a 09 09 3b 0a 09 20 20  != R.fid...;..  
3d40: 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20    }..# Find all 
3d50: 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20  revisions which 
3d60: 68 61 76 65 20 61 20 70 72 69 6d 61 72 79 20 63  have a primary c
3d70: 68 69 6c 64 2c 20 62 75 74 20 74 68 65 20 63 68  hild, but the ch
3d80: 69 6c 64 0a 09 23 20 64 6f 65 73 20 6e 6f 74 20  ild..# does not 
3d90: 68 61 76 65 20 74 68 65 6d 20 61 73 20 70 61 72  have them as par
3da0: 65 6e 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  ent...Check \.. 
3db0: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 68 61     {Revisions ha
3dc0: 76 65 20 74 6f 20 62 65 20 70 61 72 65 6e 74 73  ve to be parents
3dd0: 20 6f 66 20 74 68 65 69 72 20 70 72 69 6d 61 72   of their primar
3de0: 79 20 63 68 69 6c 64 72 65 6e 7d 20 5c 0a 09 20  y children} \.. 
3df0: 20 20 20 7b 69 73 20 6e 6f 74 20 74 68 65 20 70     {is not the p
3e00: 61 72 65 6e 74 20 6f 66 20 69 74 73 20 70 72 69  arent of its pri
3e10: 6d 61 72 79 20 63 68 69 6c 64 7d 20 7b 0a 09 09  mary child} {...
3e20: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52  SELECT F.name, R
3e30: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69  .rev...FROM revi
3e40: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
3e50: 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   C, file F...WHE
3e60: 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  RE R.fid = F.fid
3e70: 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64  ...AND   R.child
3e80: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41   IS NOT NULL...A
3e90: 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 3d 20 43  ND   R.child = C
3ea0: 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e 70  .rid...AND   C.p
3eb0: 61 72 65 6e 74 20 21 3d 20 52 2e 72 69 64 0a 09  arent != R.rid..
3ec0: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
3ed0: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
3ee0: 77 68 69 63 68 20 68 61 76 65 20 61 20 70 72 69  which have a pri
3ef0: 6d 72 61 72 79 20 63 68 69 6c 64 2c 20 62 75 74  mrary child, but
3f00: 20 74 68 65 0a 09 23 20 63 68 69 6c 64 20 68 61   the..# child ha
3f10: 73 20 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e  s a branch paren
3f20: 74 20 73 79 6d 62 6f 6c 20 6d 61 6b 69 6e 67 20  t symbol making 
3f30: 74 68 65 6d 20 62 72 61 63 68 20 73 74 61 72 74  them brach start
3f40: 65 72 73 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  ers...Check \.. 
3f50: 20 20 20 7b 50 72 69 6d 61 72 79 20 63 68 69 6c     {Primary chil
3f60: 64 72 65 6e 20 6f 66 20 72 65 76 69 73 69 6f 6e  dren of revision
3f70: 73 20 6d 75 73 74 20 6e 6f 74 20 73 74 61 72 74  s must not start
3f80: 20 62 72 61 6e 63 68 65 73 7d 20 5c 0a 09 20 20   branches} \..  
3f90: 20 20 7b 69 73 20 70 61 72 65 6e 74 20 6f 66 20    {is parent of 
3fa0: 61 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20  a primary child 
3fb0: 77 68 69 63 68 20 69 73 20 74 68 65 20 62 65 67  which is the beg
3fc0: 69 6e 6e 69 6e 67 20 6f 66 20 61 20 62 72 61 6e  inning of a bran
3fd0: 63 68 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  ch} {...SELECT F
3fe0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
3ff0: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  ROM revision R, 
4000: 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65  revision C, file
4010: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   F...WHERE R.fid
4020: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
4030: 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20   R.child IS NOT 
4040: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 63  NULL...AND   R.c
4050: 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41  hild = C.rid...A
4060: 4e 44 20 20 20 43 2e 62 70 61 72 65 6e 74 20 49  ND   C.bparent I
4070: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 3b 0a 09  S NOT NULL...;..
4080: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
4090: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68  l revisions with
40a0: 6f 75 74 20 62 72 61 6e 63 68 20 70 61 72 65 6e  out branch paren
40b0: 74 20 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 68  t symbol which h
40c0: 61 76 65 20 61 0a 09 23 20 70 61 72 65 6e 74 2c  ave a..# parent,
40d0: 20 62 75 74 20 74 68 65 20 70 61 72 65 6e 74 20   but the parent 
40e0: 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 68  does not have th
40f0: 65 6d 20 61 73 20 70 72 69 6d 61 72 79 20 63 68  em as primary ch
4100: 69 6c 64 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  ild...Check \.. 
4110: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 68 61     {Revisions ha
4120: 76 65 20 74 6f 20 62 65 20 70 72 69 6d 61 72 79  ve to be primary
4130: 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 74 68 65   children of the
4140: 69 72 20 70 61 72 65 6e 74 73 2c 20 69 66 20 61  ir parents, if a
4150: 6e 79 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20 6e  ny} \..    {is n
4160: 6f 74 20 74 68 65 20 63 68 69 6c 64 20 6f 66 20  ot the child of 
4170: 69 74 73 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09  its parent} {...
4180: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52  SELECT F.name, R
4190: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69  .rev...FROM revi
41a0: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
41b0: 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   P, file F...WHE
41c0: 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  RE R.fid = F.fid
41d0: 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65  ...AND   R.bpare
41e0: 6e 74 20 49 53 20 4e 55 4c 4c 0a 09 09 41 4e 44  nt IS NULL...AND
41f0: 20 20 20 52 2e 70 61 72 65 6e 74 20 49 53 20 4e     R.parent IS N
4200: 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20  OT NULL...AND   
4210: 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72 69 64  R.parent = P.rid
4220: 0a 09 09 41 4e 44 20 20 20 50 2e 63 68 69 6c 64  ...AND   P.child
4230: 20 21 3d 20 52 2e 72 69 64 0a 09 09 3b 0a 09 20   != R.rid...;.. 
4240: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
4250: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
4260: 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20  a branch parent 
4270: 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 64 6f 20  symbol which do 
4280: 6e 6f 74 0a 09 23 20 68 61 76 65 20 61 20 70 61  not..# have a pa
4290: 72 65 6e 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  rent...Check \..
42a0: 20 20 20 20 7b 42 72 61 6e 63 68 20 73 74 61 72      {Branch star
42b0: 74 69 6e 67 20 72 65 76 69 73 69 6f 6e 73 20 68  ting revisions h
42c0: 61 76 65 20 74 6f 20 68 61 76 65 20 61 20 70 61  ave to have a pa
42d0: 72 65 6e 74 7d 20 5c 0a 09 20 20 20 20 7b 61 74  rent} \..    {at
42e0: 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f   the beginning o
42f0: 66 20 69 74 73 20 62 72 61 6e 63 68 20 68 61 73  f its branch has
4300: 20 6e 6f 20 70 61 72 65 6e 74 7d 20 7b 0a 09 09   no parent} {...
4310: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52  SELECT F.name, R
4320: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69  .rev...FROM revi
4330: 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09  sion R, file F..
4340: 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46  .WHERE R.fid = F
4350: 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62  .fid...AND   R.b
4360: 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55  parent IS NOT NU
4370: 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72  LL...AND   R.par
4380: 65 6e 74 20 49 53 20 4e 55 4c 4c 0a 09 09 3b 0a  ent IS NULL...;.
4390: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
43a0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74  ll revisions wit
43b0: 68 20 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e  h a branch paren
43c0: 74 20 73 79 6d 62 6f 6c 20 77 68 6f 73 65 20 70  t symbol whose p
43d0: 61 72 65 6e 74 0a 09 23 20 68 61 73 20 74 68 65  arent..# has the
43e0: 6d 20 61 73 20 70 72 69 6d 61 72 79 20 63 68 69  m as primary chi
43f0: 6c 64 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20  ld...Check \..  
4400: 20 20 7b 42 72 61 6e 63 68 20 73 74 61 72 74 69    {Branch starti
4410: 6e 67 20 72 65 76 69 73 69 6f 6e 73 20 6d 75 73  ng revisions mus
4420: 74 20 6e 6f 74 20 62 65 20 70 72 69 6d 61 72 79  t not be primary
4430: 20 63 68 69 6c 64 72 65 6e 20 6f 66 20 74 68 65   children of the
4440: 69 72 20 70 61 72 65 6e 74 73 7d 20 5c 0a 09 20  ir parents} \.. 
4450: 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e     {at the begin
4460: 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e  ning of its bran
4470: 63 68 20 69 73 20 74 68 65 20 70 72 69 6d 61 72  ch is the primar
4480: 79 20 63 68 69 6c 64 20 6f 66 20 69 74 73 20 70  y child of its p
4490: 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45 4c 45 43  arent} {...SELEC
44a0: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
44b0: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
44c0: 52 2c 20 72 65 76 69 73 69 6f 6e 20 50 2c 20 66  R, revision P, f
44d0: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e  ile F...WHERE R.
44e0: 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e  fid = F.fid...AN
44f0: 44 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53  D   R.bparent IS
4500: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20   NOT NULL...AND 
4510: 20 20 52 2e 70 61 72 65 6e 74 20 49 53 20 4e 4f    R.parent IS NO
4520: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
4530: 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72 69 64 0a  .parent = P.rid.
4540: 09 09 41 4e 44 20 20 20 50 2e 63 68 69 6c 64 20  ..AND   P.child 
4550: 3d 20 52 2e 72 69 64 0a 09 09 3b 0a 09 20 20 20  = R.rid...;..   
4560: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72   }..# Find all r
4570: 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20  evisions with a 
4580: 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20 77  non-NTDB child w
4590: 68 69 63 68 20 61 72 65 20 6e 6f 74 20 6f 6e 0a  hich are not on.
45a0: 09 23 20 74 68 65 20 4e 54 44 42 2e 0a 09 43 68  .# the NTDB...Ch
45b0: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 4e 54 44 42  eck \..    {NTDB
45c0: 20 74 6f 20 74 72 75 6e 6b 20 74 72 61 6e 73 69   to trunk transi
45d0: 74 69 6f 6e 20 68 61 73 20 74 6f 20 62 65 67 69  tion has to begi
45e0: 6e 20 6f 6e 20 4e 54 44 42 7d 20 5c 0a 09 20 20  n on NTDB} \..  
45f0: 20 20 7b 68 61 73 20 61 20 6e 6f 6e 2d 4e 54 44    {has a non-NTD
4600: 42 20 63 68 69 6c 64 2c 20 79 65 74 20 69 73 20  B child, yet is 
4610: 6e 6f 74 20 6f 6e 20 74 68 65 20 4e 54 44 42 7d  not on the NTDB}
4620: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
4630: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
4640: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c   revision R, fil
4650: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69  e F...WHERE R.fi
4660: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20  d = F.fid...AND 
4670: 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e    R.dbchild IS N
4680: 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20  OT NULL...AND   
4690: 4e 4f 54 20 52 2e 69 73 64 65 66 61 75 6c 74 0a  NOT R.isdefault.
46a0: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69  ..;..    }..# Fi
46b0: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
46c0: 20 77 69 74 68 20 61 20 4e 54 44 42 20 70 61 72   with a NTDB par
46d0: 65 6e 74 20 77 68 69 63 68 20 61 72 65 20 6f 6e  ent which are on
46e0: 20 74 68 65 20 4e 54 44 42 2e 0a 09 43 68 65 63   the NTDB...Chec
46f0: 6b 20 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 74  k \..    {NTDB t
4700: 6f 20 74 72 75 6e 6b 20 74 72 61 6e 73 69 74 69  o trunk transiti
4710: 6f 6e 20 68 61 73 20 74 6f 20 65 6e 64 20 6f 6e  on has to end on
4720: 20 6e 6f 6e 2d 4e 54 44 42 7d 20 5c 0a 09 20 20   non-NTDB} \..  
4730: 20 20 7b 68 61 73 20 61 20 4e 54 44 42 20 70 61    {has a NTDB pa
4740: 72 65 6e 74 2c 20 79 65 74 20 69 73 20 6f 6e 20  rent, yet is on 
4750: 74 68 65 20 4e 54 44 42 7d 20 7b 0a 09 09 53 45  the NTDB} {...SE
4760: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
4770: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69  ev...FROM revisi
4780: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57  on R, file F...W
4790: 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66  HERE R.fid = F.f
47a0: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 70  id...AND   R.dbp
47b0: 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c  arent IS NOT NUL
47c0: 4c 0a 09 09 41 4e 44 20 20 20 52 2e 69 73 64 65  L...AND   R.isde
47d0: 66 61 75 6c 74 0a 09 09 3b 0a 09 20 20 20 20 7d  fault...;..    }
47e0: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
47f0: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 63 68  isions with a ch
4800: 69 6c 64 20 77 68 69 63 68 20 64 69 73 61 67 72  ild which disagr
4810: 65 65 73 20 61 62 6f 75 74 20 74 68 65 0a 09 23  ees about the..#
4820: 20 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70   line of develop
4830: 6d 65 6e 74 20 74 68 65 79 20 62 65 6c 6f 6e 67  ment they belong
4840: 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20   to...Check \.. 
4850: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e     {Revisions an
4860: 64 20 74 68 65 69 72 20 70 72 69 6d 61 72 79 20  d their primary 
4870: 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f  children have to
4880: 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20   be in the same 
4890: 4c 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 61 6e 64  LOD} \..    {and
48a0: 20 69 74 73 20 70 72 69 6d 61 72 79 20 63 68 69   its primary chi
48b0: 6c 64 20 64 69 73 61 67 72 65 65 20 61 62 6f 75  ld disagree abou
48c0: 74 20 74 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09  t their LOD} {..
48d0: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20  .SELECT F.name, 
48e0: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76  R.rev...FROM rev
48f0: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
4900: 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n C, file F...WH
4910: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
4920: 64 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c  d...AND   R.chil
4930: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  d IS NOT NULL...
4940: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 3d 20  AND   R.child = 
4950: 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e  C.rid...AND   C.
4960: 6c 6f 64 20 21 3d 20 52 2e 6c 6f 64 0a 09 09 3b  lod != R.lod...;
4970: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
4980: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
4990: 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68  th a non-NTDB ch
49a0: 69 6c 64 20 77 68 69 63 68 20 61 67 72 65 65 73  ild which agrees
49b0: 20 61 62 6f 75 74 0a 09 23 20 74 68 65 20 6c 69   about..# the li
49c0: 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e  ne of developmen
49d0: 74 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f  t they belong to
49e0: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
49f0: 7b 4e 54 44 42 20 61 6e 64 20 74 72 75 6e 6b 20  {NTDB and trunk 
4a00: 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74  revisions have t
4a10: 6f 20 62 65 20 69 6e 20 64 69 66 66 65 72 65 6e  o be in differen
4a20: 74 20 4c 4f 44 73 7d 20 5c 0a 09 20 20 20 20 7b  t LODs} \..    {
4a30: 6f 6e 20 4e 54 44 42 20 61 6e 64 20 69 74 73 20  on NTDB and its 
4a40: 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20 77  non-NTDB child w
4a50: 72 6f 6e 67 6c 79 20 61 67 72 65 65 20 61 62 6f  rongly agree abo
4a60: 75 74 20 74 68 65 69 72 20 4c 4f 44 7d 20 7b 0a  ut their LOD} {.
4a70: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
4a80: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
4a90: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69  vision R, revisi
4aa0: 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57  on C, file F...W
4ab0: 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66  HERE R.fid = F.f
4ac0: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 63  id...AND   R.dbc
4ad0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
4ae0: 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 63 68 69  ...AND   R.dbchi
4af0: 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44  ld = C.rid...AND
4b00: 20 20 20 43 2e 6c 6f 64 20 3d 20 52 2e 6c 6f 64     C.lod = R.lod
4b10: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46  ...;..    }..# F
4b20: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  ind all revision
4b30: 73 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 20  s with a branch 
4b40: 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68  parent symbol wh
4b50: 69 63 68 20 69 73 20 6e 6f 74 0a 09 23 20 74 68  ich is not..# th
4b60: 65 69 72 20 4c 4f 44 2e 0a 09 43 68 65 63 6b 20  eir LOD...Check 
4b70: 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63 68 20 73  \..    {Branch s
4b80: 74 61 72 74 69 6e 67 20 72 65 76 69 73 69 6f 6e  tarting revision
4b90: 73 20 68 61 76 65 20 74 6f 20 68 61 76 65 20 74  s have to have t
4ba0: 68 65 69 72 20 4c 4f 44 20 61 73 20 62 72 61 6e  heir LOD as bran
4bb0: 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c  ch parent symbol
4bc0: 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65  } \..    {at the
4bd0: 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74   beginning of it
4be0: 73 20 62 72 61 6e 63 68 20 64 6f 65 73 20 6e 6f  s branch does no
4bf0: 74 20 68 61 76 65 20 74 68 65 20 62 72 61 6e 63  t have the branc
4c00: 68 20 73 79 6d 62 6f 6c 20 61 73 20 69 74 73 20  h symbol as its 
4c10: 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20  LOD} {...SELECT 
4c20: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
4c30: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
4c40: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
4c50: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
4c60: 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e 74 20  AND   R.bparent 
4c70: 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e  IS NOT NULL...AN
4c80: 44 20 20 20 52 2e 6c 6f 64 20 21 3d 20 52 2e 62  D   R.lod != R.b
4c90: 70 61 72 65 6e 74 0a 09 09 3b 0a 09 20 20 20 20  parent...;..    
4ca0: 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  }..# Find all re
4cb0: 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62  visions with a b
4cc0: 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d  ranch parent sym
4cd0: 62 6f 6c 20 77 68 6f 73 65 20 70 61 72 65 6e 74  bol whose parent
4ce0: 0a 09 23 20 69 73 20 69 6e 20 74 68 65 20 73 61  ..# is in the sa
4cf0: 6d 65 20 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c  me line of devel
4d00: 6f 70 6d 65 6e 74 2e 0a 09 43 68 65 63 6b 20 5c  opment...Check \
4d10: 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73  ..    {Revisions
4d20: 20 61 6e 64 20 74 68 65 69 72 20 62 72 61 6e 63   and their branc
4d30: 68 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20  h children have 
4d40: 74 6f 20 62 65 20 69 6e 20 64 69 66 66 65 72 65  to be in differe
4d50: 6e 74 20 4c 4f 44 73 7d 20 5c 0a 09 20 20 20 20  nt LODs} \..    
4d60: 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e  {at the beginnin
4d70: 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68 20  g of its branch 
4d80: 61 6e 64 20 69 74 73 20 70 61 72 65 6e 74 20 77  and its parent w
4d90: 72 6f 6e 67 6c 79 20 61 67 72 65 65 20 61 62 6f  rongly agree abo
4da0: 75 74 20 74 68 65 69 72 20 4c 4f 44 7d 20 7b 0a  ut their LOD} {.
4db0: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
4dc0: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
4dd0: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69  vision R, revisi
4de0: 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 09 57  on P, file F...W
4df0: 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66  HERE R.fid = F.f
4e00: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61  id...AND   R.bpa
4e10: 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  rent IS NOT NULL
4e20: 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e  ...AND   R.paren
4e30: 74 20 3d 20 50 2e 72 69 64 0a 09 09 41 4e 44 20  t = P.rid...AND 
4e40: 20 20 52 2e 6c 6f 64 20 3d 20 50 2e 6c 6f 64 0a    R.lod = P.lod.
4e50: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 72 65 74 75  ..;..    }..retu
4e60: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  rn.    }..    pr
4e70: 6f 63 20 43 68 65 63 6b 20 7b 68 65 61 64 65 72  oc Check {header
4e80: 20 6c 61 62 65 6c 20 73 71 6c 7d 20 7b 0a 09 75   label sql} {..u
4e90: 70 76 61 72 20 31 20 6e 20 6e 0a 09 73 65 74 20  pvar 1 n n..set 
4ea0: 6f 6b 20 31 0a 09 66 6f 72 65 61 63 68 20 7b 66  ok 1..foreach {f
4eb0: 6e 61 6d 65 20 72 65 76 6e 72 7d 20 5b 73 74 61  name revnr} [sta
4ec0: 74 65 20 72 75 6e 20 24 73 71 6c 5d 20 7b 0a 09  te run $sql] {..
4ed0: 20 20 20 20 73 65 74 20 6f 6b 20 30 0a 09 20 20      set ok 0..  
4ee0: 20 20 74 72 6f 75 62 6c 65 20 66 61 74 61 6c 20    trouble fatal 
4ef0: 22 24 66 6e 61 6d 65 20 3c 24 72 65 76 6e 72 3e  "$fname <$revnr>
4f00: 20 24 6c 61 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67   $label"..}..log
4f10: 20 77 72 69 74 65 20 35 20 63 6f 6c 6c 72 65 76   write 5 collrev
4f20: 20 22 5c 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64   "\[[format %02d
4f30: 20 5b 69 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78   [incr n]]\] [ex
4f40: 70 72 20 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20  pr {$ok ? "Ok   
4f50: 20 22 20 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20   " : "Failed"}] 
4f60: 2e 2e 2e 20 24 68 65 61 64 65 72 22 0a 09 72 65  ... $header"..re
4f70: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
4f80: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
4f90: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
4fa0: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 49  #######.    ## I
4fb0: 6e 74 65 72 6e 61 6c 20 6d 65 74 68 6f 64 73 0a  nternal methods.
4fc0: 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20  .    # # ## ### 
4fd0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
4fe0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20  ############.   
4ff0: 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74 69 6f   ## Configuratio
5000: 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68  n..    pragma -h
5010: 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20 6e 6f  asinstances   no
5020: 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e 0a 20   ; # singleton. 
5030: 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79     pragma -hasty
5040: 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b 20 23  peinfo    no ; #
5050: 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74 69 6f   no introspectio
5060: 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61  n.    pragma -ha
5070: 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e 6f 20  stypedestroy no 
5080: 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 0a 20 20  ; # immortal..  
5090: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
50a0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
50b0: 23 23 23 23 23 23 23 23 23 0a 7d 0a 0a 6e 61 6d  #########.}..nam
50c0: 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a 76 63  espace eval ::vc
50d0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
50e0: 3a 3a 63 76 73 3a 3a 70 61 73 73 20 7b 0a 20 20  ::cvs::pass {.  
50f0: 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 70 6f    namespace expo
5100: 72 74 20 63 6f 6c 6c 72 65 76 0a 20 20 20 20 6e  rt collrev.    n
5110: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 63 6f  amespace eval co
5120: 6c 6c 72 65 76 20 7b 0a 09 6e 61 6d 65 73 70 61  llrev {..namespa
5130: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
5140: 72 63 73 3a 3a 70 61 72 73 65 72 0a 09 6e 61 6d  rcs::parser..nam
5150: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
5160: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
5170: 72 74 3a 3a 63 76 73 3a 3a 72 65 70 6f 73 69 74  rt::cvs::reposit
5180: 6f 72 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ory..namespace i
5190: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73  mport ::vc::foss
51a0: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
51b0: 3a 73 74 61 74 65 0a 09 6e 61 6d 65 73 70 61 63  :state..namespac
51c0: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
51d0: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
51e0: 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09 6e  vs::integrity..n
51f0: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 70 72  amespace eval pr
5200: 6f 6a 65 63 74 20 7b 0a 09 20 20 20 20 6e 61 6d  oject {..    nam
5210: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
5220: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
5230: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74  rt::cvs::project
5240: 3a 3a 73 79 6d 0a 09 7d 0a 09 6e 61 6d 65 73 70  ::sym..}..namesp
5250: 61 63 65 20 65 76 61 6c 20 66 69 6c 65 20 7b 0a  ace eval file {.
5260: 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69  .    namespace i
5270: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73  mport ::vc::foss
5280: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
5290: 3a 66 69 6c 65 3a 3a 72 65 76 0a 09 7d 0a 09 6e  :file::rev..}..n
52a0: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
52b0: 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f  ::vc::tools::tro
52c0: 75 62 6c 65 0a 09 6e 61 6d 65 73 70 61 63 65 20  uble..namespace 
52d0: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f  import ::vc::too
52e0: 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65 67  ls::log..log reg
52f0: 69 73 74 65 72 20 63 6f 6c 6c 72 65 76 0a 20 20  ister collrev.  
5300: 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23    }.}..# # ## ##
5310: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
5320: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23   ############# #
5330: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
5340: 23 23 23 23 0a 23 23 20 52 65 61 64 79 0a 0a 70  ####.## Ready..p
5350: 61 63 6b 61 67 65 20 70 72 6f 76 69 64 65 20 76  ackage provide v
5360: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
5370: 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 63 6f  t::cvs::pass::co
5380: 6c 6c 72 65 76 20 31 2e 30 0a 72 65 74 75 72 6e  llrev 1.0.return
5390: 0a                                               .