Hex Artifact Content
Not logged in

Artifact 98fd60f5700afe6687e8683d096f7c0ff0e82a19:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [f888f06fe3] - Continued work on pass 3, added code to determine the type of symbols based on the tag-, branch-, and commit-counts. Hook for handling data coming from the option processoris present (UserConfig), but only as a placeholder. by aku on 2007-11-02 06:06:24.

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: 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 3b 20 23  project::sym ; #
0510: 20 50 72 6f 6a 65 63 74 20 6c 65 76 65 6c 20 73   Project level s
0520: 79 6d 62 6f 6c 73 0a 70 61 63 6b 61 67 65 20 72  ymbols.package r
0530: 65 71 75 69 72 65 20 76 63 3a 3a 72 63 73 3a 3a  equire vc::rcs::
0540: 70 61 72 73 65 72 20 20 20 20 20 20 20 20 20 20  parser          
0550: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23               ; #
0560: 20 52 63 73 20 61 72 63 68 69 76 65 20 64 61 74   Rcs archive dat
0570: 61 20 65 78 74 72 61 63 74 69 6f 6e 2e 0a 0a 23  a extraction...#
0580: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
0590: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
05a0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
05b0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
05c0: 52 65 67 69 73 74 65 72 20 74 68 65 20 70 61 73  Register the pas
05d0: 73 20 77 69 74 68 20 74 68 65 20 6d 61 6e 61 67  s with the manag
05e0: 65 6d 65 6e 74 0a 0a 76 63 3a 3a 66 6f 73 73 69  ement..vc::fossi
05f0: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
0600: 70 61 73 73 20 64 65 66 69 6e 65 20 5c 0a 20 20  pass define \.  
0610: 20 20 43 6f 6c 6c 65 63 74 52 65 76 20 5c 0a 20    CollectRev \. 
0620: 20 20 20 7b 43 6f 6c 6c 65 63 74 20 72 65 76 69     {Collect revi
0630: 73 69 6f 6e 73 20 61 6e 64 20 73 79 6d 62 6f 6c  sions and symbol
0640: 73 7d 20 5c 0a 20 20 20 20 3a 3a 76 63 3a 3a 66  s} \.    ::vc::f
0650: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
0660: 76 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c 6c 72 65  vs::pass::collre
0670: 76 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23  v..# # ## ### ##
0680: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
0690: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23  ########## #####
06a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
06b0: 0a 23 23 20 0a 0a 73 6e 69 74 3a 3a 74 79 70 65  .## ..snit::type
06c0: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
06d0: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73  mport::cvs::pass
06e0: 3a 3a 63 6f 6c 6c 72 65 76 20 7b 0a 20 20 20 20  ::collrev {.    
06f0: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
0700: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
0710: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 50  #######.    ## P
0720: 75 62 6c 69 63 20 41 50 49 0a 0a 20 20 20 20 74  ublic API..    t
0730: 79 70 65 6d 65 74 68 6f 64 20 73 65 74 75 70 20  ypemethod setup 
0740: 7b 7d 20 7b 0a 09 23 20 44 65 66 69 6e 65 20 6e  {} {..# Define n
0750: 61 6d 65 73 20 61 6e 64 20 73 74 72 75 63 74 75  ames and structu
0760: 72 65 20 6f 66 20 74 68 65 20 70 65 72 73 69 73  re of the persis
0770: 74 65 6e 74 20 73 74 61 74 65 20 6f 66 20 74 68  tent state of th
0780: 69 73 0a 09 23 20 70 61 73 73 2e 0a 0a 09 73 74  is..# pass....st
0790: 61 74 65 20 72 65 61 64 69 6e 67 20 70 72 6f 6a  ate reading proj
07a0: 65 63 74 0a 09 73 74 61 74 65 20 72 65 61 64 69  ect..state readi
07b0: 6e 67 20 66 69 6c 65 0a 0a 09 23 20 57 65 20 64  ng file...# We d
07c0: 65 61 6c 20 77 69 74 68 20 70 65 72 20 70 72 6f  eal with per pro
07d0: 6a 65 63 74 20 61 6e 64 20 70 65 72 20 66 69 6c  ject and per fil
07e0: 65 20 64 61 74 61 2c 20 74 68 65 20 66 69 72 73  e data, the firs
07f0: 74 0a 09 23 20 63 6f 6c 6c 61 74 65 64 20 66 72  t..# collated fr
0800: 6f 6d 20 74 68 65 20 73 65 63 6f 6e 64 2e 0a 0a  om the second...
0810: 09 23 20 50 65 72 20 66 69 6c 65 20 77 65 20 68  .# Per file we h
0820: 61 76 65 20 67 65 6e 65 72 61 6c 20 69 6e 66 6f  ave general info
0830: 72 6d 61 74 69 6f 6e 2c 20 2e 2e 2e 2c 20 61 6e  rmation, ..., an
0840: 64 20 74 68 65 6e 0a 09 23 20 72 65 76 69 73 69  d then..# revisi
0850: 6f 6e 73 20 61 6e 64 20 73 79 6d 62 6f 6c 73 2e  ons and symbols.
0860: 20 54 68 65 20 6c 61 74 74 65 72 20 63 61 6e 20   The latter can 
0870: 62 65 20 66 75 72 74 68 65 72 20 73 65 70 61 72  be further separ
0880: 61 74 65 64 0a 09 23 20 69 6e 74 6f 20 74 61 67  ated..# into tag
0890: 73 20 61 6e 64 20 62 72 61 6e 63 68 65 73 2e 20  s and branches. 
08a0: 41 74 20 70 72 6f 6a 65 63 74 20 6c 65 76 65 6c  At project level
08b0: 20 74 68 65 20 70 65 72 2d 66 69 6c 65 0a 09 23   the per-file..#
08c0: 20 73 79 6d 62 6f 6c 73 20 69 6e 66 6f 72 6d 61   symbols informa
08d0: 74 69 6f 6e 20 69 73 20 6d 65 72 67 65 64 2e 0a  tion is merged..
08e0: 0a 09 23 20 46 69 6c 65 20 6c 65 76 65 6c 20 2e  ..# File level .
08f0: 2e 2e 0a 09 23 09 52 65 76 69 73 69 6f 6e 73 2c  ....#.Revisions,
0900: 20 42 72 61 6e 63 68 65 73 2c 20 54 61 67 73 0a   Branches, Tags.
0910: 09 23 0a 09 23 20 50 73 65 75 64 6f 20 63 6c 61  .#..# Pseudo cla
0920: 73 73 20 68 69 65 72 61 72 63 68 79 0a 09 23 09  ss hierarchy..#.
0930: 54 61 67 20 20 20 20 20 20 3c 2d 20 53 79 6d 62  Tag      <- Symb
0940: 6f 6c 20 3c 2d 20 45 76 65 6e 74 0a 09 23 09 42  ol <- Event..#.B
0950: 72 61 6e 63 68 20 20 20 3c 2d 20 53 79 6d 62 6f  ranch   <- Symbo
0960: 6c 20 3c 2d 20 45 76 65 6e 74 0a 09 23 09 52 65  l <- Event..#.Re
0970: 76 69 73 69 6f 6e 20 20 20 20 20 20 20 20 20 20  vision          
0980: 20 3c 2d 20 45 76 65 6e 74 0a 0a 09 73 74 61 74   <- Event...stat
0990: 65 20 77 72 69 74 69 6e 67 20 72 65 76 69 73 69  e writing revisi
09a0: 6f 6e 20 7b 0a 09 20 20 20 20 2d 2d 20 52 65 76  on {..    -- Rev
09b0: 69 73 69 6f 6e 73 2e 20 49 64 65 6e 74 69 66 69  isions. Identifi
09c0: 65 64 20 62 79 20 61 20 67 6c 6f 62 61 6c 20 6e  ed by a global n
09d0: 75 6d 65 72 69 63 20 69 64 20 65 61 63 68 0a 09  umeric id each..
09e0: 20 20 20 20 2d 2d 20 62 65 6c 6f 6e 67 73 20 74      -- belongs t
09f0: 6f 20 61 20 73 69 6e 67 6c 65 20 66 69 6c 65 2c  o a single file,
0a00: 20 69 64 65 6e 74 69 66 69 65 64 20 62 79 20 69   identified by i
0a10: 74 73 20 69 64 2e 20 49 74 0a 09 20 20 20 20 2d  ts id. It..    -
0a20: 2d 20 66 75 72 74 68 65 72 20 68 61 73 20 61 20  - further has a 
0a30: 64 6f 74 74 65 64 20 72 65 76 69 73 69 6f 6e 20  dotted revision 
0a40: 6e 75 6d 62 65 72 20 28 44 54 4e 29 2e 0a 09 20  number (DTN)... 
0a50: 20 20 20 2d 2d 0a 09 20 20 20 20 2d 2d 20 43 6f     --..    -- Co
0a60: 6e 73 74 72 61 69 6e 74 3a 20 54 68 65 20 64 6f  nstraint: The do
0a70: 74 74 65 64 20 72 65 76 69 73 69 6f 6e 20 6e 75  tted revision nu
0a80: 6d 62 65 72 20 69 73 20 75 6e 69 71 75 65 20 77  mber is unique w
0a90: 69 74 68 69 6e 0a 20 20 20 20 20 20 20 20 20 20  ithin.          
0aa0: 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20    --            
0ab0: 20 74 68 65 20 66 69 6c 65 2e 20 53 65 65 20 65   the file. See e
0ac0: 6e 64 20 6f 66 20 64 65 66 69 6e 69 74 69 6f 6e  nd of definition
0ad0: 2e 0a 0a 09 20 20 20 20 72 69 64 20 20 49 4e 54  ....    rid  INT
0ae0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
0af0: 50 52 49 4d 41 52 59 20 4b 45 59 20 41 55 54 4f  PRIMARY KEY AUTO
0b00: 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20  INCREMENT,..    
0b10: 66 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  fid  INTEGER  NO
0b20: 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43  T NULL  REFERENC
0b30: 45 53 20 66 69 6c 65 2c 20 20 20 2d 2d 20 46 69  ES file,   -- Fi
0b40: 6c 65 20 6f 77 6e 69 6e 67 20 72 65 76 69 73 69  le owning revisi
0b50: 6f 6e 2e 0a 09 20 20 20 20 72 65 76 20 20 54 45  on...    rev  TE
0b60: 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c  XT     NOT NULL,
0b70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0b80: 20 20 20 20 2d 2d 20 44 6f 74 74 65 64 20 52 65      -- Dotted Re
0b90: 76 20 4e 75 6d 62 65 72 2e 0a 0a 09 20 20 20 20  v Number....    
0ba0: 2d 2d 20 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73  -- All revisions
0bb0: 20 62 65 6c 6f 6e 67 20 74 6f 20 61 20 6c 69 6e   belong to a lin
0bc0: 65 2d 6f 66 2d 64 65 76 65 6c 6f 70 6d 65 6e 74  e-of-development
0bd0: 2c 0a 09 20 20 20 20 2d 2d 20 69 64 65 6e 74 69  ,..    -- identi
0be0: 66 69 65 64 20 62 79 20 61 20 73 79 6d 62 6f 6c  fied by a symbol
0bf0: 20 28 70 72 6f 6a 65 63 74 20 6c 65 76 65 6c 29   (project level)
0c00: 2e 20 44 75 72 69 6e 67 20 64 61 74 61 0a 09 20  . During data.. 
0c10: 20 20 20 2d 2d 20 63 6f 6c 6c 65 63 74 69 6f 6e     -- collection
0c20: 20 69 74 20 77 61 73 20 61 20 66 69 6c 65 2d 6c   it was a file-l
0c30: 65 76 65 6c 20 62 72 61 6e 63 68 20 73 79 6d 62  evel branch symb
0c40: 6f 6c 2e 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20  ol...    --..   
0c50: 20 2d 2d 20 43 6f 6e 73 74 72 61 69 6e 74 3a 20   -- Constraint: 
0c60: 41 6c 6c 20 74 68 65 20 4c 4f 44 20 73 79 6d 62  All the LOD symb
0c70: 6f 6c 73 20 61 72 65 20 69 6e 20 74 68 65 20 73  ols are in the s
0c80: 61 6d 65 20 70 72 6f 6a 65 63 74 0a 09 20 20 20  ame project..   
0c90: 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20   --             
0ca0: 61 73 20 74 68 65 20 66 69 6c 65 20 69 74 73 65  as the file itse
0cb0: 6c 66 2e 20 54 68 69 73 20 63 61 6e 6e 6f 74 20  lf. This cannot 
0cc0: 62 65 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20  be..    --      
0cd0: 20 20 20 20 20 20 20 65 78 70 72 65 73 73 65 64         expressed
0ce0: 20 69 6e 20 43 52 45 41 54 45 20 54 41 42 4c 45   in CREATE TABLE
0cf0: 20 73 79 6e 74 61 78 2e 0a 0a 09 20 20 20 20 6c   syntax....    l
0d00: 6f 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  od  INTEGER  NOT
0d10: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
0d20: 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20 4c 69 6e  S symbol, -- Lin
0d30: 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74  e of development
0d40: 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65 20 72 65  ...    -- The re
0d50: 76 69 73 69 6f 6e 73 20 69 6e 20 61 20 66 69 6c  visions in a fil
0d60: 65 20 61 72 65 20 6f 72 67 61 6e 69 7a 65 64 20  e are organized 
0d70: 69 6e 20 61 20 66 6f 72 65 73 74 20 6f 66 0a 09  in a forest of..
0d80: 20 20 20 20 2d 2d 20 74 72 65 65 73 2c 20 77 69      -- trees, wi
0d90: 74 68 20 74 68 65 20 6d 61 69 6e 20 6c 69 6e 65  th the main line
0da0: 73 20 64 65 66 69 6e 65 64 20 74 68 72 6f 75 67  s defined throug
0db0: 68 20 74 68 65 20 70 61 72 65 6e 74 20 2f 0a 09  h the parent /..
0dc0: 20 20 20 20 2d 2d 20 63 68 69 6c 64 20 72 65 66      -- child ref
0dd0: 65 72 65 6e 63 65 73 2e 20 41 20 72 65 76 69 73  erences. A revis
0de0: 69 6f 6e 20 77 69 74 68 6f 75 74 20 61 20 70 61  ion without a pa
0df0: 72 65 6e 74 20 69 73 20 74 68 65 0a 09 20 20 20  rent is the..   
0e00: 20 2d 2d 20 72 6f 6f 74 20 6f 66 20 61 20 74 72   -- root of a tr
0e10: 65 65 2c 20 61 6e 64 20 61 20 72 65 76 69 73 69  ee, and a revisi
0e20: 6f 6e 20 77 69 74 68 6f 75 74 20 61 20 63 68 69  on without a chi
0e30: 6c 64 20 69 73 20 61 0a 09 20 20 20 20 2d 2d 20  ld is a..    -- 
0e40: 6c 65 61 66 2e 0a 0a 09 20 20 20 20 2d 2d 20 43  leaf....    -- C
0e50: 6f 6e 73 74 72 61 69 6e 74 73 3a 20 41 6c 6c 20  onstraints: All 
0e60: 72 65 76 69 73 69 6f 6e 73 20 63 6f 75 70 6c 65  revisions couple
0e70: 64 20 74 68 72 6f 75 67 68 20 70 61 72 65 6e 74  d through parent
0e80: 2f 63 68 69 6c 64 0a 09 20 20 20 20 2d 2d 20 20  /child..    --  
0e90: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 65              refe
0ea0: 72 20 74 6f 20 74 68 65 20 73 61 6d 65 20 4c 4f  r to the same LO
0eb0: 44 20 73 79 6d 62 6f 6c 2e 20 54 68 65 20 70 61  D symbol. The pa
0ec0: 72 65 6e 74 0a 09 20 20 20 20 2d 2d 20 20 20 20  rent..    --    
0ed0: 20 20 20 20 20 20 20 20 20 20 6f 66 20 61 20 63            of a c
0ee0: 68 69 6c 64 20 6f 66 20 58 20 69 73 20 58 2e 20  hild of X is X. 
0ef0: 54 68 65 20 63 68 69 6c 64 20 6f 66 20 61 0a 09  The child of a..
0f00: 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20      --          
0f10: 20 20 20 20 70 61 72 65 6e 74 20 6f 66 20 58 20      parent of X 
0f20: 69 73 20 58 2e 0a 0a 09 20 20 20 20 70 61 72 65  is X....    pare
0f30: 6e 74 20 20 49 4e 54 45 47 45 52 20 20 20 20 20  nt  INTEGER     
0f40: 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45         REFERENCE
0f50: 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20 20  S revision,..   
0f60: 20 63 68 69 6c 64 20 20 20 49 4e 54 45 47 45 52   child   INTEGER
0f70: 20 20 20 20 20 20 20 20 20 20 20 20 52 45 46 45              REFE
0f80: 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c  RENCES revision,
0f90: 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65 20 72 65  ...    -- The re
0fa0: 70 72 65 73 65 6e 74 61 74 69 6f 6e 20 6f 66 20  presentation of 
0fb0: 61 20 62 72 61 6e 63 68 20 69 6e 20 61 20 74 72  a branch in a tr
0fc0: 65 65 20 69 73 20 74 68 65 0a 09 20 20 20 20 2d  ee is the..    -
0fd0: 2d 20 65 78 63 65 70 74 69 6f 6e 20 74 6f 20 74  - exception to t
0fe0: 68 65 20 74 68 72 65 65 20 63 6f 6e 73 74 72 61  he three constra
0ff0: 69 6e 74 73 20 61 62 6f 76 65 2e 0a 0a 09 20 20  ints above....  
1000: 20 20 2d 2d 20 54 68 65 20 62 65 67 69 6e 6e 69    -- The beginni
1010: 6e 67 20 6f 66 20 61 20 62 72 61 6e 63 68 20 69  ng of a branch i
1020: 73 20 72 65 70 72 65 73 65 6e 74 65 64 20 62 79  s represented by
1030: 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 0a 09 20 20 20   a non-NULL..   
1040: 20 2d 2d 20 62 70 61 72 65 6e 74 20 6f 66 20 61   -- bparent of a
1050: 20 72 65 76 69 73 69 6f 6e 2e 20 54 68 69 73 20   revision. This 
1060: 72 65 76 69 73 69 6f 6e 20 42 20 69 73 20 74 68  revision B is th
1070: 65 20 66 69 72 73 74 20 6f 6e 0a 09 20 20 20 20  e first on..    
1080: 2d 2d 20 74 68 65 20 62 72 61 6e 63 68 2e 20 49  -- the branch. I
1090: 74 73 20 70 61 72 65 6e 74 20 50 20 69 73 20 74  ts parent P is t
10a0: 68 65 20 72 65 76 69 73 69 6f 6e 20 74 68 65 20  he revision the 
10b0: 62 72 61 6e 63 68 20 69 73 0a 09 20 20 20 20 2d  branch is..    -
10c0: 2d 20 72 6f 6f 74 65 64 20 69 6e 2c 20 61 6e 64  - rooted in, and
10d0: 20 69 74 20 69 73 20 6e 6f 74 20 74 68 65 20 63   it is not the c
10e0: 68 69 6c 64 20 6f 66 20 50 2e 20 42 20 61 6e 64  hild of P. B and
10f0: 20 50 20 72 65 66 65 72 0a 09 20 20 20 20 2d 2d   P refer..    --
1100: 20 74 6f 20 64 69 66 66 65 72 65 6e 74 20 4c 4f   to different LO
1110: 44 20 73 79 6d 62 6f 6c 73 2e 20 54 68 65 20 62  D symbols. The b
1120: 70 61 72 65 6e 74 20 6f 66 20 42 20 69 73 20 61  parent of B is a
1130: 6c 73 6f 20 69 74 73 0a 09 20 20 20 20 2d 2d 20  lso its..    -- 
1140: 4c 4f 44 2c 20 61 6e 64 20 74 68 65 20 4c 4f 44  LOD, and the LOD
1150: 20 6f 66 20 69 74 73 20 63 68 69 6c 64 72 65 6e   of its children
1160: 2e 0a 0a 09 20 20 20 20 62 70 61 72 65 6e 74 20  ....    bparent 
1170: 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 20  INTEGER         
1180: 20 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79     REFERENCES sy
1190: 6d 62 6f 6c 2c 0a 0a 09 20 20 20 20 2d 2d 20 4c  mbol,...    -- L
11a0: 61 73 74 6c 79 20 77 65 20 6b 65 65 70 20 69 6e  astly we keep in
11b0: 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 61 62 6f  formation is abo
11c0: 75 74 20 6e 6f 6e 2d 74 72 75 6e 6b 20 64 65 66  ut non-trunk def
11d0: 61 75 6c 74 0a 09 20 20 20 20 2d 2d 20 62 72 61  ault..    -- bra
11e0: 6e 63 68 65 73 20 28 4e 54 44 42 29 20 69 6e 20  nches (NTDB) in 
11f0: 74 68 65 20 72 65 76 69 73 69 6f 6e 73 2e 0a 0a  the revisions...
1200: 09 20 20 20 20 2d 2d 20 41 6c 6c 20 72 65 76 69  .    -- All revi
1210: 73 69 6f 6e 73 20 6f 6e 20 74 68 65 20 4e 54 44  sions on the NTD
1220: 42 20 68 61 76 65 20 27 69 73 64 65 66 61 75 6c  B have 'isdefaul
1230: 74 27 20 54 52 55 45 2c 0a 09 20 20 20 20 2d 2d  t' TRUE,..    --
1240: 20 65 76 65 72 79 6f 6e 65 20 65 6c 73 65 20 46   everyone else F
1250: 41 4c 53 45 2e 20 54 68 65 20 6c 61 73 74 20 72  ALSE. The last r
1260: 65 76 69 73 69 6f 6e 20 58 20 6f 6e 20 74 68 65  evision X on the
1270: 20 4e 54 44 42 0a 09 20 20 20 20 2d 2d 20 77 68   NTDB..    -- wh
1280: 69 63 68 20 69 73 20 73 74 69 6c 6c 20 63 6f 6e  ich is still con
1290: 73 69 64 65 72 65 64 20 74 6f 20 62 65 20 6f 6e  sidered to be on
12a0: 20 74 68 65 20 74 72 75 6e 6b 20 61 73 20 77 65   the trunk as we
12b0: 6c 6c 0a 09 20 20 20 20 2d 2d 20 68 61 73 20 61  ll..    -- has a
12c0: 20 6e 6f 6e 2d 4e 55 4c 4c 20 27 64 62 63 68 69   non-NULL 'dbchi
12d0: 6c 64 27 20 77 68 69 63 68 20 72 65 66 65 72 73  ld' which refers
12e0: 20 74 6f 20 74 68 65 20 72 6f 6f 74 20 6f 66 0a   to the root of.
12f0: 09 20 20 20 20 2d 2d 20 74 68 65 20 74 72 75 6e  .    -- the trun
1300: 6b 2e 20 54 68 65 20 72 6f 6f 74 20 61 6c 73 6f  k. The root also
1310: 20 68 61 73 20 61 20 6e 6f 6e 2d 4e 55 4c 4c 20   has a non-NULL 
1320: 64 62 70 61 72 65 6e 74 0a 09 20 20 20 20 2d 2d  dbparent..    --
1330: 20 72 65 66 65 72 69 6e 67 20 74 6f 20 58 2e 0a   refering to X..
1340: 0a 09 20 20 20 20 69 73 64 65 66 61 75 6c 74 20  ..    isdefault 
1350: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1360: 4c 2c 0a 09 20 20 20 20 64 62 70 61 72 65 6e 74  L,..    dbparent
1370: 20 20 49 4e 54 45 47 45 52 20 20 20 20 20 20 20    INTEGER       
1380: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
1390: 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20 20 20 64  revision,..    d
13a0: 62 63 68 69 6c 64 20 20 20 49 4e 54 45 47 45 52  bchild   INTEGER
13b0: 20 20 20 20 20 20 20 20 20 20 20 20 52 45 46 45              REFE
13c0: 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c  RENCES revision,
13d0: 0a 0a 09 20 20 20 20 2d 2d 20 54 68 65 20 6d 61  ...    -- The ma
13e0: 69 6e 20 70 61 79 6c 6f 61 64 20 6f 66 20 74 68  in payload of th
13f0: 65 20 72 65 76 69 73 69 6f 6e 20 61 72 65 20 74  e revision are t
1400: 68 65 20 64 61 74 65 2f 74 69 6d 65 20 69 74 0a  he date/time it.
1410: 09 20 20 20 20 2d 2d 20 77 61 73 20 65 6e 74 65  .    -- was ente
1420: 72 65 64 2c 20 69 74 73 20 73 74 61 74 65 2c 20  red, its state, 
1430: 6f 70 65 72 61 74 69 6f 6e 20 28 3d 20 74 79 70  operation (= typ
1440: 65 2f 63 6c 61 73 73 29 2c 20 74 65 78 74 0a 09  e/class), text..
1450: 20 20 20 20 2d 2d 20 63 6f 6e 74 65 6e 74 2c 20      -- content, 
1460: 61 6e 64 20 6d 65 74 61 20 64 61 74 61 20 28 61  and meta data (a
1470: 75 74 68 6f 72 2c 20 6c 6f 67 20 6d 65 73 73 61  uthor, log messa
1480: 67 65 2c 20 62 72 61 6e 63 68 2c 0a 09 20 20 20  ge, branch,..   
1490: 20 2d 2d 20 70 72 6f 6a 65 63 74 29 2e 20 54 68   -- project). Th
14a0: 65 20 6c 61 73 74 20 69 73 20 65 6e 63 6f 64 65  e last is encode
14b0: 64 20 61 73 20 73 69 6e 67 6c 65 20 69 64 2c 20  d as single id, 
14c0: 73 65 65 20 74 61 62 6c 65 0a 09 20 20 20 20 2d  see table..    -
14d0: 2d 20 27 6d 65 74 61 27 2e 20 54 68 65 20 64 61  - 'meta'. The da
14e0: 74 65 2f 74 69 6d 65 20 69 73 20 67 69 76 65 6e  te/time is given
14f0: 20 69 6e 20 73 65 63 6f 6e 64 73 20 73 69 6e 63   in seconds sinc
1500: 65 20 74 68 65 0a 09 20 20 20 20 2d 2d 20 65 70  e the..    -- ep
1510: 6f 63 68 2c 20 66 6f 72 20 65 61 73 79 20 63 6f  och, for easy co
1520: 6d 70 61 72 69 73 6f 6e 2e 20 54 68 65 20 74 65  mparison. The te
1530: 78 74 20 63 6f 6e 74 65 6e 74 20 69 73 20 61 6e  xt content is an
1540: 0a 09 20 20 20 20 2d 2d 20 28 6f 66 66 73 65 74  ..    -- (offset
1550: 2c 6c 65 6e 67 74 68 29 20 70 61 69 72 20 69 6e  ,length) pair in
1560: 74 6f 20 74 68 65 20 72 63 73 20 61 72 63 68 69  to the rcs archi
1570: 76 65 2e 0a 0a 09 20 20 20 20 6f 70 20 20 20 20  ve....    op    
1580: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1590: 4c 2c 0a 09 20 20 20 20 64 61 74 65 20 20 49 4e  L,..    date  IN
15a0: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c  TEGER  NOT NULL,
15b0: 0a 09 20 20 20 20 73 74 61 74 65 20 54 45 58 54  ..    state TEXT
15c0: 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09       NOT NULL,..
15d0: 20 20 20 20 6d 69 64 20 20 20 49 4e 54 45 47 45      mid   INTEGE
15e0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 52 45 46 45  R  NOT NULL REFE
15f0: 52 45 4e 43 45 53 20 6d 65 74 61 2c 0a 09 20 20  RENCES meta,..  
1600: 20 20 63 6f 66 66 20 20 49 4e 54 45 47 45 52 20    coff  INTEGER 
1610: 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20   NOT NULL,..    
1620: 63 6c 65 6e 20 20 49 4e 54 45 47 45 52 20 20 4e  clen  INTEGER  N
1630: 4f 54 20 4e 55 4c 4c 2c 0a 0a 09 20 20 20 20 55  OT NULL,...    U
1640: 4e 49 51 55 45 20 28 66 69 64 2c 20 72 65 76 29  NIQUE (fid, rev)
1650: 20 2d 2d 20 54 68 65 20 44 54 4e 20 69 73 20 75   -- The DTN is u
1660: 6e 69 71 75 65 20 77 69 74 68 69 6e 20 74 68 65  nique within the
1670: 20 72 65 76 69 73 69 6f 6e 27 73 20 66 69 6c 65   revision's file
1680: 2e 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77 72 69  ...}...state wri
1690: 74 69 6e 67 20 74 61 67 20 7b 0a 09 20 20 20 20  ting tag {..    
16a0: 74 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  tid  INTEGER  NO
16b0: 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20  T NULL  PRIMARY 
16c0: 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45 4e  KEY AUTOINCREMEN
16d0: 54 2c 0a 09 20 20 20 20 66 69 64 20 20 49 4e 54  T,..    fid  INT
16e0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
16f0: 52 45 46 45 52 45 4e 43 45 53 20 66 69 6c 65 2c  REFERENCES file,
1700: 20 20 20 20 20 2d 2d 20 46 69 6c 65 20 74 68 65       -- File the
1710: 20 69 74 65 6d 20 62 65 6c 6f 6e 67 73 20 74 6f   item belongs to
1720: 0a 09 20 20 20 20 6c 6f 64 20 20 49 4e 54 45 47  ..    lod  INTEG
1730: 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52 45  ER            RE
1740: 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c  FERENCES symbol,
1750: 20 20 20 2d 2d 20 4c 69 6e 65 20 6f 66 20 64 65     -- Line of de
1760: 76 65 6c 6f 70 6d 65 6e 74 20 28 4e 55 4c 4c 20  velopment (NULL 
1770: 3d 3e 20 54 72 75 6e 6b 29 0a 0a 09 20 20 20 20  => Trunk)...    
1780: 73 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  sid  INTEGER  NO
1790: 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43  T NULL  REFERENC
17a0: 45 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20  ES symbol,   -- 
17b0: 53 79 6d 62 6f 6c 20 63 61 70 74 75 72 69 6e 67  Symbol capturing
17c0: 20 74 68 65 20 74 61 67 0a 0a 09 20 20 20 20 72   the tag...    r
17d0: 65 76 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  ev  INTEGER  NOT
17e0: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
17f0: 53 20 72 65 76 69 73 69 6f 6e 20 20 2d 2d 20 54  S revision  -- T
1800: 68 65 20 72 65 76 69 73 69 6f 6e 20 62 65 69 6e  he revision bein
1810: 67 20 74 61 67 67 65 64 2e 0a 09 7d 0a 0a 09 73  g tagged...}...s
1820: 74 61 74 65 20 77 72 69 74 69 6e 67 20 62 72 61  tate writing bra
1830: 6e 63 68 20 7b 0a 09 20 20 20 20 62 69 64 20 20  nch {..    bid  
1840: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1850: 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20  LL  PRIMARY KEY 
1860: 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09  AUTOINCREMENT,..
1870: 20 20 20 20 66 69 64 20 20 20 49 4e 54 45 47 45      fid   INTEGE
1880: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1890: 45 52 45 4e 43 45 53 20 66 69 6c 65 2c 20 20 20  ERENCES file,   
18a0: 20 20 2d 2d 20 46 69 6c 65 20 74 68 65 20 69 74    -- File the it
18b0: 65 6d 20 62 65 6c 6f 6e 67 73 20 74 6f 0a 09 20  em belongs to.. 
18c0: 20 20 20 6c 6f 64 20 20 20 49 4e 54 45 47 45 52     lod   INTEGER
18d0: 20 20 20 20 20 20 20 20 20 20 20 20 52 45 46 45              REFE
18e0: 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 20  RENCES symbol,  
18f0: 20 2d 2d 20 4c 69 6e 65 20 6f 66 20 64 65 76 65   -- Line of deve
1900: 6c 6f 70 6d 65 6e 74 20 28 4e 55 4c 4c 20 3d 3e  lopment (NULL =>
1910: 20 54 72 75 6e 6b 29 0a 0a 09 20 20 20 20 73 69   Trunk)...    si
1920: 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  d   INTEGER  NOT
1930: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
1940: 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20 53  S symbol,   -- S
1950: 79 6d 62 6f 6c 20 63 61 70 74 75 72 69 6e 67 20  ymbol capturing 
1960: 74 68 65 20 62 72 61 6e 63 68 0a 0a 09 20 20 20  the branch...   
1970: 20 72 6f 6f 74 20 20 49 4e 54 45 47 45 52 20 20   root  INTEGER  
1980: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
1990: 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 20 2d  NCES revision, -
19a0: 2d 20 52 65 76 69 73 69 6f 6e 20 74 68 65 20 62  - Revision the b
19b0: 72 61 6e 63 68 20 73 70 72 6f 75 74 73 20 66 72  ranch sprouts fr
19c0: 6f 6d 0a 09 20 20 20 20 66 69 72 73 74 20 49 4e  om..    first IN
19d0: 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20  TEGER           
19e0: 20 52 45 46 45 52 45 4e 43 45 53 20 72 65 76 69   REFERENCES revi
19f0: 73 69 6f 6e 2c 20 2d 2d 20 46 69 72 73 74 20 72  sion, -- First r
1a00: 65 76 69 73 69 6f 6e 20 63 6f 6d 6d 69 74 74 65  evision committe
1a10: 64 20 74 6f 20 74 68 65 20 62 72 61 6e 63 68 0a  d to the branch.
1a20: 09 20 20 20 20 62 72 61 20 20 20 54 45 58 54 20  .    bra   TEXT 
1a30: 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20      NOT NULL    
1a40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1a50: 20 20 20 2d 2d 20 62 72 61 6e 63 68 20 6e 75 6d     -- branch num
1a60: 62 65 72 0a 09 7d 0a 0a 09 23 20 50 72 6f 6a 65  ber..}...# Proje
1a70: 63 74 20 6c 65 76 65 6c 20 2e 2e 2e 0a 09 23 09  ct level .....#.
1a80: 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d 65  pLineOfDevelopme
1a90: 6e 74 2c 20 70 53 79 6d 62 6f 6c 2c 20 70 42 72  nt, pSymbol, pBr
1aa0: 61 6e 63 68 2c 20 70 54 61 67 2c 20 70 54 72 75  anch, pTag, pTru
1ab0: 6e 6b 0a 09 23 0a 09 23 09 70 54 72 75 6e 6b 20  nk..#..#.pTrunk 
1ac0: 20 3c 2d 20 70 4c 69 6e 65 4f 66 44 65 76 65 6c   <- pLineOfDevel
1ad0: 6f 70 6d 65 6e 74 0a 09 23 09 70 42 72 61 6e 63  opment..#.pBranc
1ae0: 68 20 3c 2d 20 70 53 79 6d 62 6f 6c 2c 20 70 4c  h <- pSymbol, pL
1af0: 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d 65 6e 74  ineOfDevelopment
1b00: 0a 09 23 09 70 54 61 67 20 20 20 20 3c 2d 20 70  ..#.pTag    <- p
1b10: 53 79 6d 62 6f 6c 2c 20 70 4c 69 6e 65 4f 66 44  Symbol, pLineOfD
1b20: 65 76 65 6c 6f 70 6d 65 6e 74 0a 0a 09 73 74 61  evelopment...sta
1b30: 74 65 20 77 72 69 74 69 6e 67 20 73 79 6d 62 6f  te writing symbo
1b40: 6c 20 7b 0a 09 20 20 20 20 73 69 64 20 20 49 4e  l {..    sid  IN
1b50: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
1b60: 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41 55 54   PRIMARY KEY AUT
1b70: 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20  OINCREMENT,..   
1b80: 20 70 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e   pid  INTEGER  N
1b90: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
1ba0: 43 45 53 20 70 72 6f 6a 65 63 74 2c 20 20 2d 2d  CES project,  --
1bb0: 20 50 72 6f 6a 65 63 74 20 74 68 65 20 73 79 6d   Project the sym
1bc0: 62 6f 6c 20 62 65 6c 6f 6e 67 73 20 74 6f 0a 09  bol belongs to..
1bd0: 20 20 20 20 6e 61 6d 65 20 54 45 58 54 20 20 20      name TEXT   
1be0: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20    NOT NULL,..   
1bf0: 20 74 79 70 65 20 49 4e 54 45 47 45 52 20 20 4e   type INTEGER  N
1c00: 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e  OT NULL  REFEREN
1c10: 43 45 53 20 73 79 6d 74 79 70 65 2c 20 20 2d 2d  CES symtype,  --
1c20: 20 65 6e 75 6d 20 7b 20 65 78 63 6c 75 64 65 64   enum { excluded
1c30: 20 3d 20 30 2c 20 74 61 67 2c 20 62 72 61 6e 63   = 0, tag, branc
1c40: 68 2c 20 75 6e 64 65 66 69 6e 65 64 20 7d 0a 0a  h, undefined }..
1c50: 09 20 20 20 20 74 61 67 5f 63 6f 75 6e 74 20 20  .    tag_count  
1c60: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
1c70: 55 4c 4c 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65  ULL, -- How ofte
1c80: 6e 20 74 68 65 20 73 79 6d 62 6f 6c 20 69 73 20  n the symbol is 
1c90: 75 73 65 64 20 61 73 20 74 61 67 2e 0a 09 20 20  used as tag...  
1ca0: 20 20 62 72 61 6e 63 68 5f 63 6f 75 6e 74 20 49    branch_count I
1cb0: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1cc0: 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 74  , -- How often t
1cd0: 68 65 20 73 79 6d 62 6f 6c 20 69 73 20 75 73 65  he symbol is use
1ce0: 64 20 61 73 20 62 72 61 6e 63 68 0a 09 20 20 20  d as branch..   
1cf0: 20 63 6f 6d 6d 69 74 5f 63 6f 75 6e 74 20 49 4e   commit_count IN
1d00: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c  TEGER  NOT NULL,
1d10: 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 61 20   -- How often a 
1d20: 66 69 6c 65 20 77 61 73 20 63 6f 6d 6d 69 74 74  file was committ
1d30: 65 64 20 6f 6e 20 74 68 65 20 73 79 6d 62 6f 6c  ed on the symbol
1d40: 0a 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 70  ...    UNIQUE (p
1d50: 69 64 2c 20 6e 61 6d 65 29 20 2d 2d 20 53 79 6d  id, name) -- Sym
1d60: 62 6f 6c 73 20 61 72 65 20 75 6e 69 71 75 65 20  bols are unique 
1d70: 77 69 74 68 69 6e 20 74 68 65 20 70 72 6f 6a 65  within the proje
1d80: 63 74 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77 72  ct..}...state wr
1d90: 69 74 69 6e 67 20 62 6c 6f 63 6b 65 72 20 7b 0a  iting blocker {.
1da0: 09 20 20 20 20 2d 2d 20 46 6f 72 20 65 61 63 68  .    -- For each
1db0: 20 73 79 6d 62 6f 6c 20 77 65 20 73 61 76 65 20   symbol we save 
1dc0: 77 68 69 63 68 20 6f 74 68 65 72 20 73 79 6d 62  which other symb
1dd0: 6f 6c 73 20 61 72 65 0a 09 20 20 20 20 2d 2d 20  ols are..    -- 
1de0: 62 6c 6f 63 6b 69 6e 67 20 69 74 73 20 72 65 6d  blocking its rem
1df0: 6f 76 61 6c 20 28 69 66 20 74 68 65 20 75 73 65  oval (if the use
1e00: 72 20 61 73 6b 73 20 66 6f 72 20 69 74 29 2e 0a  r asks for it)..
1e10: 0a 09 20 20 20 20 73 69 64 20 49 4e 54 45 47 45  ..    sid INTEGE
1e20: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1e30: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
1e40: 2d 2d 20 0a 09 20 20 20 20 62 69 64 20 49 4e 54  -- ..    bid INT
1e50: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
1e60: 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f  REFERENCES symbo
1e70: 6c 2c 20 2d 2d 20 53 70 72 6f 75 74 65 64 20 66  l, -- Sprouted f
1e80: 72 6f 6d 20 73 69 64 2c 20 62 6c 6f 63 6b 73 20  rom sid, blocks 
1e90: 69 74 2e 0a 09 20 20 20 20 55 4e 49 51 55 45 20  it...    UNIQUE 
1ea0: 28 73 69 64 2c 20 62 69 64 29 0a 09 7d 0a 0a 09  (sid, bid)..}...
1eb0: 73 74 61 74 65 20 77 72 69 74 69 6e 67 20 70 61  state writing pa
1ec0: 72 65 6e 74 20 7b 0a 09 20 20 20 20 2d 2d 20 46  rent {..    -- F
1ed0: 6f 72 20 65 61 63 68 20 73 79 6d 62 6f 6c 20 77  or each symbol w
1ee0: 65 20 73 61 76 65 20 77 68 69 63 68 20 6f 74 68  e save which oth
1ef0: 65 72 20 73 79 6d 62 6f 6c 73 20 63 61 6e 20 61  er symbols can a
1f00: 63 74 20 61 73 0a 09 20 20 20 20 2d 2d 20 61 20  ct as..    -- a 
1f10: 70 6f 73 73 69 62 6c 65 20 70 61 72 65 6e 74 20  possible parent 
1f20: 69 6e 20 73 6f 6d 65 20 66 69 6c 65 2c 20 61 6e  in some file, an
1f30: 64 20 68 6f 77 20 6f 66 74 65 6e 2e 0a 0a 09 20  d how often.... 
1f40: 20 20 20 73 69 64 20 49 4e 54 45 47 45 52 20 20     sid INTEGER  
1f50: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
1f60: 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20  NCES symbol, -- 
1f70: 0a 09 20 20 20 20 70 69 64 20 49 4e 54 45 47 45  ..    pid INTEGE
1f80: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1f90: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
1fa0: 2d 2d 20 50 6f 73 73 69 62 6c 65 20 70 61 72 65  -- Possible pare
1fb0: 6e 74 20 6f 66 20 73 69 64 0a 09 20 20 20 20 6e  nt of sid..    n
1fc0: 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20     INTEGER  NOT 
1fd0: 4e 55 4c 4c 2c 20 20 20 20 20 20 20 20 20 20 20  NULL,           
1fe0: 20 20 20 20 20 20 20 20 20 2d 2d 20 48 6f 77 20           -- How 
1ff0: 6f 66 74 65 6e 20 70 69 64 20 63 61 6e 20 61 63  often pid can ac
2000: 74 20 61 73 20 70 61 72 65 6e 74 2e 0a 09 20 20  t as parent...  
2010: 20 20 55 4e 49 51 55 45 20 28 73 69 64 2c 20 70    UNIQUE (sid, p
2020: 69 64 29 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77  id)..}...state w
2030: 72 69 74 69 6e 67 20 73 79 6d 74 79 70 65 20 7b  riting symtype {
2040: 0a 09 20 20 20 20 74 69 64 20 20 20 20 49 4e 54  ..    tid    INT
2050: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
2060: 50 52 49 4d 41 52 59 20 4b 45 59 2c 0a 09 20 20  PRIMARY KEY,..  
2070: 20 20 6e 61 6d 65 20 20 20 54 45 58 54 20 20 20    name   TEXT   
2080: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20    NOT NULL,..   
2090: 20 70 6c 75 72 61 6c 20 54 45 58 54 20 20 20 20   plural TEXT    
20a0: 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20   NOT NULL,..    
20b0: 55 4e 49 51 55 45 20 28 6e 61 6d 65 29 0a 09 20  UNIQUE (name).. 
20c0: 20 20 20 55 4e 49 51 55 45 20 28 70 6c 75 72 61     UNIQUE (plura
20d0: 6c 29 0a 09 7d 0a 09 73 74 61 74 65 20 72 75 6e  l)..}..state run
20e0: 20 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49   {..    INSERT I
20f0: 4e 54 4f 20 73 79 6d 74 79 70 65 20 56 41 4c 55  NTO symtype VALU
2100: 45 53 20 28 30 2c 27 65 78 63 6c 75 64 65 64 27  ES (0,'excluded'
2110: 29 3b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49  );..    INSERT I
2120: 4e 54 4f 20 73 79 6d 74 79 70 65 20 56 41 4c 55  NTO symtype VALU
2130: 45 53 20 28 31 2c 27 74 61 67 27 29 3b 0a 09 20  ES (1,'tag');.. 
2140: 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 73     INSERT INTO s
2150: 79 6d 74 79 70 65 20 56 41 4c 55 45 53 20 28 32  ymtype VALUES (2
2160: 2c 27 62 72 61 6e 63 68 27 29 3b 0a 09 20 20 20  ,'branch');..   
2170: 20 49 4e 53 45 52 54 20 49 4e 54 4f 20 73 79 6d   INSERT INTO sym
2180: 74 79 70 65 20 56 41 4c 55 45 53 20 28 33 2c 27  type VALUES (3,'
2190: 75 6e 64 65 66 69 6e 65 64 27 29 3b 0a 09 7d 0a  undefined');..}.
21a0: 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e 67 20  ..state writing 
21b0: 6d 65 74 61 20 7b 0a 09 20 20 20 20 2d 2d 20 4d  meta {..    -- M
21c0: 65 74 61 20 64 61 74 61 20 6f 66 20 72 65 76 69  eta data of revi
21d0: 73 69 6f 6e 73 2e 20 53 65 65 20 72 65 76 69 73  sions. See revis
21e0: 69 6f 6e 2e 6d 69 64 20 66 6f 72 20 74 68 65 0a  ion.mid for the.
21f0: 09 20 20 20 20 2d 2d 20 72 65 66 65 72 65 6e 63  .    -- referenc
2200: 65 2e 20 4d 61 6e 79 20 72 65 76 69 73 69 6f 6e  e. Many revision
2210: 73 20 63 61 6e 20 73 68 61 72 65 20 6d 65 74 61  s can share meta
2220: 20 64 61 74 61 2e 20 54 68 69 73 20 69 73 0a 09   data. This is..
2230: 20 20 20 20 2d 2d 20 61 63 74 75 61 6c 6c 79 20      -- actually 
2240: 6f 6e 65 20 6f 66 20 74 68 65 20 63 72 69 74 65  one of the crite
2250: 72 69 6f 6e 73 20 75 73 65 64 20 74 6f 20 73 6f  rions used to so
2260: 72 74 20 72 65 76 69 73 69 6f 6e 73 0a 09 20 20  rt revisions..  
2270: 20 20 2d 2d 20 69 6e 74 6f 20 63 68 61 6e 67 65    -- into change
2280: 73 65 74 73 2e 0a 0a 09 20 20 20 20 6d 69 64 20  sets....    mid 
2290: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
22a0: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20  L  PRIMARY KEY  
22b0: 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 0a  AUTOINCREMENT,..
22c0: 09 20 20 20 20 2d 2d 20 4d 65 74 61 20 64 61 74  .    -- Meta dat
22d0: 61 20 62 65 6c 6f 6e 67 73 20 74 6f 20 61 20 73  a belongs to a s
22e0: 70 65 63 69 66 69 63 20 70 72 6f 6a 65 63 74 2c  pecific project,
22f0: 20 73 74 72 6f 6e 67 65 72 2c 20 74 6f 20 61 0a   stronger, to a.
2300: 09 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 20 69  .    -- branch i
2310: 6e 20 74 68 61 74 20 70 72 6f 6a 65 63 74 2e 20  n that project. 
2320: 49 74 20 66 75 72 74 68 65 72 20 68 61 73 20 61  It further has a
2330: 20 6c 6f 67 20 6d 65 73 73 61 67 65 2c 0a 09 20   log message,.. 
2340: 20 20 20 2d 2d 20 61 6e 64 20 69 74 73 20 61 75     -- and its au
2350: 74 68 6f 72 2e 20 54 68 69 73 20 69 73 20 75 6e  thor. This is un
2360: 69 71 75 65 20 77 69 74 68 20 74 68 65 20 70 72  ique with the pr
2370: 6f 6a 65 63 74 20 61 6e 64 0a 09 20 20 20 20 2d  oject and..    -
2380: 2d 20 62 72 61 6e 63 68 2e 0a 0a 09 20 20 20 20  - branch....    
2390: 70 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  pid INTEGER  NOT
23a0: 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45   NULL  REFERENCE
23b0: 53 20 70 72 6f 6a 65 63 74 2c 20 20 2d 2d 0a 09  S project,  --..
23c0: 20 20 20 20 62 69 64 20 49 4e 54 45 47 45 52 20      bid INTEGER 
23d0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52   NOT NULL  REFER
23e0: 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 20 20  ENCES symbol,   
23f0: 2d 2d 0a 09 20 20 20 20 61 69 64 20 49 4e 54 45  --..    aid INTE
2400: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52  GER  NOT NULL  R
2410: 45 46 45 52 45 4e 43 45 53 20 61 75 74 68 6f 72  EFERENCES author
2420: 2c 20 20 20 2d 2d 0a 09 20 20 20 20 63 69 64 20  ,   --..    cid 
2430: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
2440: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 63 6d  L  REFERENCES cm
2450: 65 73 73 61 67 65 2c 20 2d 2d 0a 0a 09 20 20 20  essage, --...   
2460: 20 55 4e 49 51 55 45 20 28 70 69 64 2c 20 62 69   UNIQUE (pid, bi
2470: 64 2c 20 61 69 64 2c 20 63 69 64 29 0a 0a 09 20  d, aid, cid)... 
2480: 20 20 20 2d 2d 20 43 6f 6e 73 74 72 61 69 6e 74     -- Constraint
2490: 73 3a 20 54 68 65 20 70 72 6f 6a 65 63 74 20 6f  s: The project o
24a0: 66 20 74 68 65 20 6d 65 74 61 20 64 61 74 61 20  f the meta data 
24b0: 6f 66 20 61 20 72 65 76 69 73 69 6f 6e 0a 09 20  of a revision.. 
24c0: 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20     --           
24d0: 20 20 20 58 20 69 73 20 74 68 65 20 73 61 6d 65     X is the same
24e0: 20 61 73 20 74 68 65 20 70 72 6f 6a 65 63 74 20   as the project 
24f0: 6f 66 20 58 20 69 74 73 65 6c 66 2e 0a 09 20 20  of X itself...  
2500: 20 20 2d 2d 0a 09 20 20 20 20 2d 2d 20 2e 2e 2e    --..    -- ...
2510: 2e 2e 2e 2e 2e 2e 2e 2e 2e 20 54 68 65 20 62 72  ......... The br
2520: 61 6e 63 68 20 6f 66 20 74 68 65 20 6d 65 74 61  anch of the meta
2530: 20 64 61 74 61 20 6f 66 20 61 20 72 65 76 69 73   data of a revis
2540: 69 6f 6e 0a 09 20 20 20 20 2d 2d 20 20 20 20 20  ion..    --     
2550: 20 20 20 20 20 20 20 20 20 58 20 69 73 20 74 68           X is th
2560: 65 20 73 61 6d 65 20 61 73 20 74 68 65 20 6c 69  e same as the li
2570: 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e  ne of developmen
2580: 74 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20  t..    --       
2590: 20 20 20 20 20 20 20 6f 66 20 58 20 69 74 73 65         of X itse
25a0: 6c 66 2e 0a 09 7d 0a 0a 09 23 20 41 75 74 68 6f  lf...}...# Autho
25b0: 72 73 20 61 6e 64 20 63 6f 6d 6d 69 74 20 6d 65  rs and commit me
25c0: 73 73 61 67 65 73 20 61 72 65 20 66 75 6c 6c 79  ssages are fully
25d0: 20 67 6c 6f 62 61 6c 2c 20 69 2e 65 2e 20 70 65   global, i.e. pe
25e0: 72 0a 09 23 20 72 65 70 6f 73 69 74 6f 72 79 2e  r..# repository.
25f0: 0a 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e 67  ...state writing
2600: 20 61 75 74 68 6f 72 20 7b 0a 09 20 20 20 20 61   author {..    a
2610: 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54  id  INTEGER  NOT
2620: 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b   NULL  PRIMARY K
2630: 45 59 20 20 41 55 54 4f 49 4e 43 52 45 4d 45 4e  EY  AUTOINCREMEN
2640: 54 2c 0a 09 20 20 20 20 6e 61 6d 65 20 54 45 58  T,..    name TEX
2650: 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  T     NOT NULL  
2660: 55 4e 49 51 55 45 0a 09 7d 0a 0a 09 73 74 61 74  UNIQUE..}...stat
2670: 65 20 77 72 69 74 69 6e 67 20 63 6d 65 73 73 61  e writing cmessa
2680: 67 65 20 7b 0a 09 20 20 20 20 63 69 64 20 20 49  ge {..    cid  I
2690: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
26a0: 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20 41    PRIMARY KEY  A
26b0: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20  UTOINCREMENT,.. 
26c0: 20 20 20 74 65 78 74 20 54 45 58 54 20 20 20 20     text TEXT    
26d0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 55 4e 49 51 55   NOT NULL  UNIQU
26e0: 45 0a 09 7d 0a 0a 09 70 72 6f 6a 65 63 74 3a 3a  E..}...project::
26f0: 73 79 6d 20 67 65 74 73 79 6d 74 79 70 65 73 0a  sym getsymtypes.
2700: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
2710: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f     typemethod lo
2720: 61 64 20 7b 7d 20 7b 0a 09 73 74 61 74 65 20 72  ad {} {..state r
2730: 65 61 64 69 6e 67 20 73 79 6d 62 6f 6c 0a 09 73  eading symbol..s
2740: 74 61 74 65 20 72 65 61 64 69 6e 67 20 73 79 6d  tate reading sym
2750: 74 79 70 65 0a 0a 09 70 72 6f 6a 65 63 74 3a 3a  type...project::
2760: 73 79 6d 20 67 65 74 73 79 6d 74 79 70 65 73 0a  sym getsymtypes.
2770: 09 72 65 70 6f 73 69 74 6f 72 79 20 20 20 6c 6f  .repository   lo
2780: 61 64 73 79 6d 62 6f 6c 73 0a 09 72 65 74 75 72  adsymbols..retur
2790: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70  n.    }..    typ
27a0: 65 6d 65 74 68 6f 64 20 72 75 6e 20 7b 7d 20 7b  emethod run {} {
27b0: 0a 09 23 20 50 61 73 73 20 6d 61 6e 61 67 65 72  ..# Pass manager
27c0: 20 69 6e 74 65 72 66 61 63 65 2e 20 45 78 65 63   interface. Exec
27d0: 75 74 65 64 20 74 6f 20 70 65 72 66 6f 72 6d 20  uted to perform 
27e0: 74 68 65 0a 09 23 20 66 75 6e 63 74 69 6f 6e 61  the..# functiona
27f0: 6c 69 74 79 20 6f 66 20 74 68 65 20 70 61 73 73  lity of the pass
2800: 2e 0a 0a 09 73 65 74 20 72 62 61 73 65 20 5b 72  ....set rbase [r
2810: 65 70 6f 73 69 74 6f 72 79 20 62 61 73 65 3f 5d  epository base?]
2820: 0a 09 66 6f 72 65 61 63 68 20 70 72 6f 6a 65 63  ..foreach projec
2830: 74 20 5b 72 65 70 6f 73 69 74 6f 72 79 20 70 72  t [repository pr
2840: 6f 6a 65 63 74 73 5d 20 7b 0a 09 20 20 20 20 73  ojects] {..    s
2850: 65 74 20 62 61 73 65 20 5b 66 69 6c 65 20 6a 6f  et base [file jo
2860: 69 6e 20 24 72 62 61 73 65 20 5b 24 70 72 6f 6a  in $rbase [$proj
2870: 65 63 74 20 62 61 73 65 5d 5d 0a 09 20 20 20 20  ect base]]..    
2880: 6c 6f 67 20 77 72 69 74 65 20 31 20 63 6f 6c 6c  log write 1 coll
2890: 72 65 76 20 22 50 72 6f 63 65 73 73 69 6e 67 20  rev "Processing 
28a0: 24 62 61 73 65 22 0a 0a 09 20 20 20 20 66 6f 72  $base"...    for
28b0: 65 61 63 68 20 66 69 6c 65 20 5b 24 70 72 6f 6a  each file [$proj
28c0: 65 63 74 20 66 69 6c 65 73 5d 20 7b 0a 09 09 73  ect files] {...s
28d0: 65 74 20 70 61 74 68 20 5b 24 66 69 6c 65 20 70  et path [$file p
28e0: 61 74 68 5d 0a 09 09 6c 6f 67 20 77 72 69 74 65  ath]...log write
28f0: 20 32 20 63 6f 6c 6c 72 65 76 20 22 50 61 72 73   2 collrev "Pars
2900: 69 6e 67 20 24 70 61 74 68 22 0a 09 09 69 66 20  ing $path"...if 
2910: 7b 5b 63 61 74 63 68 20 7b 0a 09 09 20 20 20 20  {[catch {...    
2920: 70 61 72 73 65 72 20 70 72 6f 63 65 73 73 20 5b  parser process [
2930: 66 69 6c 65 20 6a 6f 69 6e 20 24 62 61 73 65 20  file join $base 
2940: 24 70 61 74 68 5d 20 24 66 69 6c 65 0a 09 09 7d  $path] $file...}
2950: 20 6d 73 67 5d 7d 20 7b 0a 09 09 20 20 20 20 67   msg]} {...    g
2960: 6c 6f 62 61 6c 20 65 72 72 6f 72 43 6f 64 65 0a  lobal errorCode.
2970: 09 09 20 20 20 20 69 66 20 7b 24 65 72 72 6f 72  ..    if {$error
2980: 43 6f 64 65 20 65 71 20 22 76 63 3a 3a 72 63 73  Code eq "vc::rcs
2990: 3a 3a 70 61 72 73 65 72 22 7d 20 7b 0a 09 09 09  ::parser"} {....
29a0: 74 72 6f 75 62 6c 65 20 66 61 74 61 6c 20 22 24  trouble fatal "$
29b0: 70 61 74 68 20 69 73 20 6e 6f 74 20 61 20 76 61  path is not a va
29c0: 6c 69 64 20 52 43 53 20 61 72 63 68 69 76 65 20  lid RCS archive 
29d0: 28 24 6d 73 67 29 22 0a 09 09 20 20 20 20 7d 20  ($msg)"...    } 
29e0: 65 6c 73 65 20 7b 0a 09 09 09 67 6c 6f 62 61 6c  else {....global
29f0: 20 65 72 72 6f 72 49 6e 66 6f 0a 09 09 09 74 72   errorInfo....tr
2a00: 6f 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 24  ouble internal $
2a10: 65 72 72 6f 72 49 6e 66 6f 0a 09 09 20 20 20 20  errorInfo...    
2a20: 7d 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20  }...} else {... 
2a30: 20 20 20 23 20 57 65 20 70 65 72 73 69 73 74 20     # We persist 
2a40: 74 68 65 20 63 6f 72 65 20 6f 66 20 74 68 65 20  the core of the 
2a50: 64 61 74 61 20 63 6f 6c 6c 65 63 74 65 64 20 61  data collected a
2a60: 62 6f 75 74 0a 09 09 20 20 20 20 23 20 65 61 63  bout...    # eac
2a70: 68 20 66 69 6c 65 20 69 6d 6d 65 64 69 61 74 65  h file immediate
2a80: 6c 79 20 61 66 74 65 72 20 69 74 20 68 61 73 20  ly after it has 
2a90: 62 65 65 6e 20 70 61 72 73 65 64 0a 09 09 20 20  been parsed...  
2aa0: 20 20 23 20 61 6e 64 20 77 72 61 6e 67 6c 65 64    # and wrangled
2ab0: 20 69 6e 74 6f 20 73 68 61 70 65 2c 20 61 6e 64   into shape, and
2ac0: 20 74 68 65 6e 20 64 72 6f 70 20 69 74 20 66 72   then drop it fr
2ad0: 6f 6d 0a 09 09 20 20 20 20 23 20 6d 65 6d 6f 72  om...    # memor
2ae0: 79 2e 20 54 68 69 73 20 69 73 20 64 6f 6e 65 20  y. This is done 
2af0: 74 6f 20 6b 65 65 70 20 74 68 65 20 61 6d 6f 75  to keep the amou
2b00: 6e 74 20 6f 66 0a 09 09 20 20 20 20 23 20 72 65  nt of...    # re
2b10: 71 75 69 72 65 64 20 6d 65 6d 6f 72 79 20 77 69  quired memory wi
2b20: 74 68 69 6e 20 73 65 6e 73 69 62 6c 65 20 6c 69  thin sensible li
2b30: 6d 69 74 73 2e 20 57 69 74 68 6f 75 74 0a 09 09  mits. Without...
2b40: 20 20 20 20 23 20 64 6f 69 6e 67 20 69 74 20 74      # doing it t
2b50: 68 69 73 20 77 61 79 20 77 65 20 77 6f 75 6c 64  his way we would
2b60: 20 65 61 73 69 6c 79 20 67 6f 62 62 6c 65 20 75   easily gobble u
2b70: 70 20 31 47 0a 09 09 20 20 20 20 23 20 6f 66 20  p 1G...    # of 
2b80: 52 41 4d 20 6f 72 20 6d 6f 72 65 20 77 69 74 68  RAM or more with
2b90: 20 61 6c 6c 20 74 68 65 20 6f 62 6a 65 63 74 73   all the objects
2ba0: 20 28 72 65 76 69 73 69 6f 6e 73 0a 09 09 20 20   (revisions...  
2bb0: 20 20 23 20 61 6e 64 20 66 69 6c 65 2d 6c 65 76    # and file-lev
2bc0: 65 6c 20 73 79 6d 62 6f 6c 73 29 2e 0a 0a 09 09  el symbols).....
2bd0: 20 20 20 20 24 66 69 6c 65 20 70 65 72 73 69 73      $file persis
2be0: 74 0a 09 09 7d 0a 0a 09 09 24 66 69 6c 65 20 64  t...}....$file d
2bf0: 72 6f 70 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20  rop..    }...   
2c00: 20 24 70 72 6f 6a 65 63 74 20 70 75 72 67 65 67   $project purgeg
2c10: 68 6f 73 74 73 79 6d 62 6f 6c 73 0a 09 7d 0a 0a  hostsymbols..}..
2c20: 09 72 65 70 6f 73 69 74 6f 72 79 20 70 72 69 6e  .repository prin
2c30: 74 72 65 76 73 74 61 74 69 73 74 69 63 73 0a 09  trevstatistics..
2c40: 72 65 70 6f 73 69 74 6f 72 79 20 70 65 72 73 69  repository persi
2c50: 73 74 72 65 76 0a 0a 09 6c 6f 67 20 77 72 69 74  strev...log writ
2c60: 65 20 31 20 63 6f 6c 6c 72 65 76 20 22 53 63 61  e 1 collrev "Sca
2c70: 6e 20 63 6f 6d 70 6c 65 74 65 64 22 0a 09 50 61  n completed"..Pa
2c80: 72 61 6e 6f 69 61 0a 09 72 65 74 75 72 6e 0a 20  ranoia..return. 
2c90: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65     }..    typeme
2ca0: 74 68 6f 64 20 64 69 73 63 61 72 64 20 7b 7d 20  thod discard {} 
2cb0: 7b 0a 09 23 20 50 61 73 73 20 6d 61 6e 61 67 65  {..# Pass manage
2cc0: 72 20 69 6e 74 65 72 66 61 63 65 2e 20 45 78 65  r interface. Exe
2cd0: 63 75 74 65 64 20 66 6f 72 20 61 6c 6c 20 70 61  cuted for all pa
2ce0: 73 73 65 73 20 61 66 74 65 72 20 74 68 65 0a 09  sses after the..
2cf0: 23 20 72 75 6e 20 70 61 73 73 65 73 2c 20 74 6f  # run passes, to
2d00: 20 72 65 6d 6f 76 65 20 61 6c 6c 20 64 61 74 61   remove all data
2d10: 20 6f 66 20 74 68 69 73 20 70 61 73 73 20 66 72   of this pass fr
2d20: 6f 6d 20 74 68 65 20 73 74 61 74 65 2c 0a 09 23  om the state,..#
2d30: 20 61 73 20 62 65 69 6e 67 20 6f 75 74 20 6f 66   as being out of
2d40: 20 64 61 74 65 2e 0a 0a 09 73 74 61 74 65 20 64   date....state d
2d50: 69 73 63 61 72 64 20 72 65 76 69 73 69 6f 6e 0a  iscard revision.
2d60: 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20 74  .state discard t
2d70: 61 67 0a 09 73 74 61 74 65 20 64 69 73 63 61 72  ag..state discar
2d80: 64 20 62 72 61 6e 63 68 0a 09 73 74 61 74 65 20  d branch..state 
2d90: 64 69 73 63 61 72 64 20 73 79 6d 62 6f 6c 0a 09  discard symbol..
2da0: 73 74 61 74 65 20 64 69 73 63 61 72 64 20 62 6c  state discard bl
2db0: 6f 63 6b 65 72 0a 09 73 74 61 74 65 20 64 69 73  ocker..state dis
2dc0: 63 61 72 64 20 70 61 72 65 6e 74 0a 09 73 74 61  card parent..sta
2dd0: 74 65 20 64 69 73 63 61 72 64 20 73 79 6d 74 79  te discard symty
2de0: 70 65 0a 09 73 74 61 74 65 20 64 69 73 63 61 72  pe..state discar
2df0: 64 20 6d 65 74 61 0a 09 73 74 61 74 65 20 64 69  d meta..state di
2e00: 73 63 61 72 64 20 61 75 74 68 6f 72 0a 09 73 74  scard author..st
2e10: 61 74 65 20 64 69 73 63 61 72 64 20 63 6d 65 73  ate discard cmes
2e20: 73 61 67 65 0a 09 72 65 74 75 72 6e 0a 20 20 20  sage..return.   
2e30: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 61 72   }..    proc Par
2e40: 61 6e 6f 69 61 20 7b 7d 20 7b 0a 09 23 20 54 68  anoia {} {..# Th
2e50: 69 73 20 63 6f 64 65 20 70 65 72 66 6f 72 6d 73  is code performs
2e60: 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 70 61 72   a number of par
2e70: 61 6e 6f 69 64 20 63 68 65 63 6b 73 20 6f 66 20  anoid checks of 
2e80: 74 68 65 0a 09 23 20 64 61 74 61 62 61 73 65 2c  the..# database,
2e90: 20 73 65 61 72 63 68 69 6e 67 20 66 6f 72 20 69   searching for i
2ea0: 6e 63 6f 6e 73 69 73 74 65 6e 74 20 63 72 6f 73  nconsistent cros
2eb0: 73 2d 72 65 66 65 72 65 6e 63 65 73 2e 0a 09 6c  s-references...l
2ec0: 6f 67 20 77 72 69 74 65 20 34 20 63 6f 6c 6c 72  og write 4 collr
2ed0: 65 76 20 7b 43 68 65 63 6b 20 64 61 74 61 62 61  ev {Check databa
2ee0: 73 65 20 63 6f 6e 73 69 73 74 65 6e 63 79 7d 0a  se consistency}.
2ef0: 0a 09 73 65 74 20 6e 20 30 20 3b 20 23 20 43 6f  ..set n 0 ; # Co
2f00: 75 6e 74 65 72 20 66 6f 72 20 74 68 65 20 63 68  unter for the ch
2f10: 65 63 6b 73 20 28 77 65 20 70 72 69 6e 74 20 61  ecks (we print a
2f20: 6e 20 69 64 20 62 65 66 6f 72 65 20 74 68 65 0a  n id before the.
2f30: 09 09 20 20 23 20 6d 61 69 6e 20 6c 61 62 65 6c  ..  # main label
2f40: 29 2e 0a 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20  )....# Find all 
2f50: 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20  revisions which 
2f60: 64 69 73 61 67 72 65 65 20 77 69 74 68 20 74 68  disagree with th
2f70: 65 69 72 20 6c 69 6e 65 20 6f 66 0a 09 23 20 64  eir line of..# d
2f80: 65 76 65 6c 6f 70 6d 65 6e 74 20 61 62 6f 75 74  evelopment about
2f90: 20 74 68 65 20 70 72 6f 6a 65 63 74 20 74 68 65   the project the
2fa0: 79 20 61 72 65 20 6f 77 6e 65 64 20 62 79 2e 0a  y are owned by..
2fb0: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52  .Check \..    {R
2fc0: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65  evisions and the
2fd0: 69 72 20 4c 4f 44 73 20 68 61 76 65 20 74 6f 20  ir LODs have to 
2fe0: 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70  be in the same p
2ff0: 72 6f 6a 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b  roject} \..    {
3000: 64 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69  disagrees with i
3010: 74 73 20 4c 4f 44 20 61 62 6f 75 74 20 6f 77 6e  ts LOD about own
3020: 69 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b 0a 09  ing project} {..
3030: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20  .SELECT F.name, 
3040: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76  R.rev...FROM rev
3050: 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c  ision R, file F,
3060: 20 73 79 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52   symbol S...WHER
3070: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
3080: 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20 3d 20  ..AND   R.lod = 
3090: 53 2e 73 69 64 0a 09 09 41 4e 44 20 20 20 46 2e  S.sid...AND   F.
30a0: 70 69 64 20 21 3d 20 53 2e 70 69 64 0a 09 09 3b  pid != S.pid...;
30b0: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
30c0: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68  all revisions wh
30d0: 69 63 68 20 64 69 73 67 72 65 65 20 77 69 74 68  ich disgree with
30e0: 20 74 68 65 69 72 20 6d 65 74 61 20 64 61 74 61   their meta data
30f0: 20 61 62 6f 75 74 0a 09 23 20 74 68 65 20 70 72   about..# the pr
3100: 6f 6a 65 63 74 20 74 68 65 79 20 61 72 65 20 6f  oject they are o
3110: 77 6e 65 64 20 62 79 2e 0a 09 43 68 65 63 6b 20  wned by...Check 
3120: 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e  \..    {Revision
3130: 73 20 61 6e 64 20 74 68 65 69 72 20 6d 65 74 61  s and their meta
3140: 20 64 61 74 61 20 68 61 76 65 20 74 6f 20 62 65   data have to be
3150: 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70 72 6f   in the same pro
3160: 6a 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b 64 69  ject} \..    {di
3170: 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73  sagrees with its
3180: 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f 75 74   meta data about
3190: 20 6f 77 6e 69 6e 67 20 70 72 6f 6a 65 63 74 7d   owning project}
31a0: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
31b0: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
31c0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c   revision R, fil
31d0: 65 20 46 2c 20 6d 65 74 61 20 4d 0a 09 09 57 48  e F, meta M...WH
31e0: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
31f0: 64 0a 09 09 41 4e 44 20 20 20 52 2e 6d 69 64 20  d...AND   R.mid 
3200: 3d 20 4d 2e 6d 69 64 0a 09 09 41 4e 44 20 20 20  = M.mid...AND   
3210: 46 2e 70 69 64 20 21 3d 20 4d 2e 70 69 64 0a 09  F.pid != M.pid..
3220: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
3230: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
3240: 77 68 69 63 68 20 64 69 73 67 72 65 65 20 77 69  which disgree wi
3250: 74 68 20 74 68 65 69 72 20 6d 65 74 61 20 64 61  th their meta da
3260: 74 61 20 61 62 6f 75 74 0a 09 23 20 74 68 65 20  ta about..# the 
3270: 62 72 61 6e 63 68 2f 6c 69 6e 65 20 6f 66 20 64  branch/line of d
3280: 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20  evelopment they 
3290: 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63  belong to...Chec
32a0: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
32b0: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 6d 65  ons and their me
32c0: 74 61 20 64 61 74 61 20 68 61 76 65 20 74 6f 20  ta data have to 
32d0: 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c  be in the same L
32e0: 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61  OD} \..    {disa
32f0: 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 6d  grees with its m
3300: 65 74 61 20 64 61 74 61 20 61 62 6f 75 74 20 6f  eta data about o
3310: 77 6e 69 6e 67 20 4c 4f 44 7d 20 7b 0a 09 09 53  wning LOD} {...S
3320: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
3330: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
3340: 69 6f 6e 20 52 2c 20 6d 65 74 61 20 4d 2c 20 66  ion R, meta M, f
3350: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e  ile F...WHERE R.
3360: 6d 69 64 20 3d 20 4d 2e 6d 69 64 0a 09 09 41 4e  mid = M.mid...AN
3370: 44 20 20 20 52 2e 6c 6f 64 20 21 3d 20 4d 2e 62  D   R.lod != M.b
3380: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 66 69 64  id...AND   R.fid
3390: 20 3d 20 46 2e 66 69 64 0a 09 09 3b 0a 09 20 20   = F.fid...;..  
33a0: 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20    }..# Find all 
33b0: 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61  revisions with a
33c0: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 77   primary child w
33d0: 68 69 63 68 20 64 69 73 61 67 72 65 65 73 0a 09  hich disagrees..
33e0: 23 20 61 62 6f 75 74 20 74 68 65 20 66 69 6c 65  # about the file
33f0: 20 74 68 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e   they belong to.
3400: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b  ..Check \..    {
3410: 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68  Revisions and th
3420: 65 69 72 20 70 72 69 6d 61 72 79 20 63 68 69 6c  eir primary chil
3430: 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65 20  dren have to be 
3440: 69 6e 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65  in the same file
3450: 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61 67 72  } \..    {disagr
3460: 65 65 73 20 77 69 74 68 20 69 74 73 20 70 72 69  ees with its pri
3470: 6d 61 72 79 20 63 68 69 6c 64 20 61 62 6f 75 74  mary child about
3480: 20 74 68 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65   the owning file
3490: 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e  } {...SELECT F.n
34a0: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
34b0: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65  M revision R, re
34c0: 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c 65 20 46  vision C, file F
34d0: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
34e0: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
34f0: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  .child IS NOT NU
3500: 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69  LL...AND   R.chi
3510: 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44  ld = C.rid...AND
3520: 20 20 20 43 2e 66 69 64 20 21 3d 20 52 2e 66 69     C.fid != R.fi
3530: 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 0a 09 23  d...;..    }...#
3540: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69   Find all revisi
3550: 6f 6e 73 20 77 69 74 68 20 61 20 62 72 61 6e 63  ons with a branc
3560: 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20  h parent symbol 
3570: 77 68 6f 73 65 20 70 61 72 65 6e 74 0a 09 23 20  whose parent..# 
3580: 64 69 73 61 67 72 65 65 73 20 61 62 6f 75 74 20  disagrees about 
3590: 74 68 65 20 66 69 6c 65 20 74 68 65 79 20 62 65  the file they be
35a0: 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b 20  long to...Check 
35b0: 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e  \..    {Revision
35c0: 73 20 61 6e 64 20 74 68 65 69 72 20 62 72 61 6e  s and their bran
35d0: 63 68 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65  ch children have
35e0: 20 74 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61   to be in the sa
35f0: 6d 65 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20  me file} \..    
3600: 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e  {at the beginnin
3610: 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63 68 20  g of its branch 
3620: 61 6e 64 20 69 74 73 20 70 61 72 65 6e 74 20 64  and its parent d
3630: 69 73 61 67 72 65 65 20 61 62 6f 75 74 20 74 68  isagree about th
3640: 65 20 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b  e owning file} {
3650: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65  ...SELECT F.name
3660: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72  , R.rev...FROM r
3670: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73  evision R, revis
3680: 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 09  ion P, file F...
3690: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e  WHERE R.fid = F.
36a0: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70  fid...AND   R.bp
36b0: 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c  arent IS NOT NUL
36c0: 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65  L...AND   R.pare
36d0: 6e 74 20 3d 20 50 2e 72 69 64 0a 09 09 41 4e 44  nt = P.rid...AND
36e0: 20 20 20 52 2e 66 69 64 20 21 3d 20 50 2e 66 69     R.fid != P.fi
36f0: 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20  d...;..    }..# 
3700: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f  Find all revisio
3710: 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54  ns with a non-NT
3720: 44 42 20 63 68 69 6c 64 20 77 68 69 63 68 20 64  DB child which d
3730: 69 73 61 67 72 65 65 73 0a 09 23 20 61 62 6f 75  isagrees..# abou
3740: 74 20 74 68 65 20 66 69 6c 65 20 74 68 65 79 20  t the file they 
3750: 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63  belong to...Chec
3760: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
3770: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 6e 6f  ons and their no
3780: 6e 2d 4e 54 44 42 20 63 68 69 6c 64 72 65 6e 20  n-NTDB children 
3790: 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 74 68  have to be in th
37a0: 65 20 73 61 6d 65 20 66 69 6c 65 7d 20 5c 0a 09  e same file} \..
37b0: 20 20 20 20 7b 64 69 73 61 67 72 65 65 73 20 77      {disagrees w
37c0: 69 74 68 20 69 74 73 20 6e 6f 6e 2d 4e 54 44 42  ith its non-NTDB
37d0: 20 63 68 69 6c 64 20 61 62 6f 75 74 20 74 68 65   child about the
37e0: 20 6f 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a   owning file} {.
37f0: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
3800: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
3810: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69  vision R, revisi
3820: 6f 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57  on C, file F...W
3830: 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66  HERE R.fid = F.f
3840: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 63  id...AND   R.dbc
3850: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
3860: 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 63 68 69  ...AND   R.dbchi
3870: 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09 41 4e 44  ld = C.rid...AND
3880: 20 20 20 43 2e 66 69 64 20 21 3d 20 52 2e 66 69     C.fid != R.fi
3890: 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20  d...;..    }..# 
38a0: 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f  Find all revisio
38b0: 6e 73 20 77 68 69 63 68 20 68 61 76 65 20 61 20  ns which have a 
38c0: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2c 20 62  primary child, b
38d0: 75 74 20 74 68 65 20 63 68 69 6c 64 0a 09 23 20  ut the child..# 
38e0: 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 74 68  does not have th
38f0: 65 6d 20 61 73 20 70 61 72 65 6e 74 2e 0a 09 43  em as parent...C
3900: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76  heck \..    {Rev
3910: 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 62  isions have to b
3920: 65 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68 65  e parents of the
3930: 69 72 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  ir primary child
3940: 72 65 6e 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20  ren} \..    {is 
3950: 6e 6f 74 20 74 68 65 20 70 61 72 65 6e 74 20 6f  not the parent o
3960: 66 20 69 74 73 20 70 72 69 6d 61 72 79 20 63 68  f its primary ch
3970: 69 6c 64 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20  ild} {...SELECT 
3980: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
3990: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
39a0: 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c   revision C, fil
39b0: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69  e F...WHERE R.fi
39c0: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20  d = F.fid...AND 
39d0: 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54    R.child IS NOT
39e0: 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e   NULL...AND   R.
39f0: 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09  child = C.rid...
3a00: 41 4e 44 20 20 20 43 2e 70 61 72 65 6e 74 20 21  AND   C.parent !
3a10: 3d 20 52 2e 72 69 64 0a 09 09 3b 0a 09 20 20 20  = R.rid...;..   
3a20: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72   }..# Find all r
3a30: 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 68  evisions which h
3a40: 61 76 65 20 61 20 70 72 69 6d 72 61 72 79 20 63  ave a primrary c
3a50: 68 69 6c 64 2c 20 62 75 74 20 74 68 65 0a 09 23  hild, but the..#
3a60: 20 63 68 69 6c 64 20 68 61 73 20 61 20 62 72 61   child has a bra
3a70: 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f  nch parent symbo
3a80: 6c 20 6d 61 6b 69 6e 67 20 74 68 65 6d 20 62 72  l making them br
3a90: 61 63 68 20 73 74 61 72 74 65 72 73 2e 0a 09 43  ach starters...C
3aa0: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 50 72 69  heck \..    {Pri
3ab0: 6d 61 72 79 20 63 68 69 6c 64 72 65 6e 20 6f 66  mary children of
3ac0: 20 72 65 76 69 73 69 6f 6e 73 20 6d 75 73 74 20   revisions must 
3ad0: 6e 6f 74 20 73 74 61 72 74 20 62 72 61 6e 63 68  not start branch
3ae0: 65 73 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20 70  es} \..    {is p
3af0: 61 72 65 6e 74 20 6f 66 20 61 20 70 72 69 6d 61  arent of a prima
3b00: 72 79 20 63 68 69 6c 64 20 77 68 69 63 68 20 69  ry child which i
3b10: 73 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20  s the beginning 
3b20: 6f 66 20 61 20 62 72 61 6e 63 68 7d 20 7b 0a 09  of a branch} {..
3b30: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20  .SELECT F.name, 
3b40: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76  R.rev...FROM rev
3b50: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
3b60: 6e 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n C, file F...WH
3b70: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
3b80: 64 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c  d...AND   R.chil
3b90: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  d IS NOT NULL...
3ba0: 41 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 3d 20  AND   R.child = 
3bb0: 43 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e  C.rid...AND   C.
3bc0: 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e  bparent IS NOT N
3bd0: 55 4c 4c 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09  ULL...;..    }..
3be0: 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73  # Find all revis
3bf0: 69 6f 6e 73 20 77 69 74 68 6f 75 74 20 62 72 61  ions without bra
3c00: 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f  nch parent symbo
3c10: 6c 20 77 68 69 63 68 20 68 61 76 65 20 61 0a 09  l which have a..
3c20: 23 20 70 61 72 65 6e 74 2c 20 62 75 74 20 74 68  # parent, but th
3c30: 65 20 70 61 72 65 6e 74 20 64 6f 65 73 20 6e 6f  e parent does no
3c40: 74 20 68 61 76 65 20 74 68 65 6d 20 61 73 20 70  t have them as p
3c50: 72 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 43  rimary child...C
3c60: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76  heck \..    {Rev
3c70: 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20 62  isions have to b
3c80: 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72  e primary childr
3c90: 65 6e 20 6f 66 20 74 68 65 69 72 20 70 61 72 65  en of their pare
3ca0: 6e 74 73 2c 20 69 66 20 61 6e 79 7d 20 5c 0a 09  nts, if any} \..
3cb0: 20 20 20 20 7b 69 73 20 6e 6f 74 20 74 68 65 20      {is not the 
3cc0: 63 68 69 6c 64 20 6f 66 20 69 74 73 20 70 61 72  child of its par
3cd0: 65 6e 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20  ent} {...SELECT 
3ce0: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
3cf0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
3d00: 20 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c   revision P, fil
3d10: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69  e F...WHERE R.fi
3d20: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20  d = F.fid...AND 
3d30: 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e    R.bparent IS N
3d40: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61  ULL...AND   R.pa
3d50: 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  rent IS NOT NULL
3d60: 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e  ...AND   R.paren
3d70: 74 20 3d 20 50 2e 72 69 64 0a 09 09 41 4e 44 20  t = P.rid...AND 
3d80: 20 20 50 2e 63 68 69 6c 64 20 21 3d 20 52 2e 72    P.child != R.r
3d90: 69 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23  id...;..    }..#
3da0: 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69   Find all revisi
3db0: 6f 6e 73 20 77 69 74 68 20 61 20 62 72 61 6e 63  ons with a branc
3dc0: 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20  h parent symbol 
3dd0: 77 68 69 63 68 20 64 6f 20 6e 6f 74 0a 09 23 20  which do not..# 
3de0: 68 61 76 65 20 61 20 70 61 72 65 6e 74 2e 0a 09  have a parent...
3df0: 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 42 72  Check \..    {Br
3e00: 61 6e 63 68 20 73 74 61 72 74 69 6e 67 20 72 65  anch starting re
3e10: 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f 20  visions have to 
3e20: 68 61 76 65 20 61 20 70 61 72 65 6e 74 7d 20 5c  have a parent} \
3e30: 0a 09 20 20 20 20 7b 61 74 20 74 68 65 20 62 65  ..    {at the be
3e40: 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62  ginning of its b
3e50: 72 61 6e 63 68 20 68 61 73 20 6e 6f 20 70 61 72  ranch has no par
3e60: 65 6e 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20  ent} {...SELECT 
3e70: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
3e80: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
3e90: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
3ea0: 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09  R.fid = F.fid...
3eb0: 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e 74 20  AND   R.bparent 
3ec0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e  IS NOT NULL...AN
3ed0: 44 20 20 20 52 2e 70 61 72 65 6e 74 20 49 53 20  D   R.parent IS 
3ee0: 4e 55 4c 4c 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  NULL...;..    }.
3ef0: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
3f00: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 62 72 61  sions with a bra
3f10: 6e 63 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f  nch parent symbo
3f20: 6c 20 77 68 6f 73 65 20 70 61 72 65 6e 74 0a 09  l whose parent..
3f30: 23 20 68 61 73 20 74 68 65 6d 20 61 73 20 70 72  # has them as pr
3f40: 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 43 68  imary child...Ch
3f50: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e  eck \..    {Bran
3f60: 63 68 20 73 74 61 72 74 69 6e 67 20 72 65 76 69  ch starting revi
3f70: 73 69 6f 6e 73 20 6d 75 73 74 20 6e 6f 74 20 62  sions must not b
3f80: 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72  e primary childr
3f90: 65 6e 20 6f 66 20 74 68 65 69 72 20 70 61 72 65  en of their pare
3fa0: 6e 74 73 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20  nts} \..    {at 
3fb0: 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66  the beginning of
3fc0: 20 69 74 73 20 62 72 61 6e 63 68 20 69 73 20 74   its branch is t
3fd0: 68 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  he primary child
3fe0: 20 6f 66 20 69 74 73 20 70 61 72 65 6e 74 7d 20   of its parent} 
3ff0: 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d  {...SELECT F.nam
4000: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20  e, R.rev...FROM 
4010: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69  revision R, revi
4020: 73 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09  sion P, file F..
4030: 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46  .WHERE R.fid = F
4040: 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62  .fid...AND   R.b
4050: 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55  parent IS NOT NU
4060: 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61 72  LL...AND   R.par
4070: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a  ent IS NOT NULL.
4080: 09 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74  ..AND   R.parent
4090: 20 3d 20 50 2e 72 69 64 0a 09 09 41 4e 44 20 20   = P.rid...AND  
40a0: 20 50 2e 63 68 69 6c 64 20 3d 20 52 2e 72 69 64   P.child = R.rid
40b0: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46  ...;..    }..# F
40c0: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  ind all revision
40d0: 73 20 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44  s with a non-NTD
40e0: 42 20 63 68 69 6c 64 20 77 68 69 63 68 20 61 72  B child which ar
40f0: 65 20 6e 6f 74 20 6f 6e 0a 09 23 20 74 68 65 20  e not on..# the 
4100: 4e 54 44 42 2e 0a 09 43 68 65 63 6b 20 5c 0a 09  NTDB...Check \..
4110: 20 20 20 20 7b 4e 54 44 42 20 74 6f 20 74 72 75      {NTDB to tru
4120: 6e 6b 20 74 72 61 6e 73 69 74 69 6f 6e 20 68 61  nk transition ha
4130: 73 20 74 6f 20 62 65 67 69 6e 20 6f 6e 20 4e 54  s to begin on NT
4140: 44 42 7d 20 5c 0a 09 20 20 20 20 7b 68 61 73 20  DB} \..    {has 
4150: 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64  a non-NTDB child
4160: 2c 20 79 65 74 20 69 73 20 6e 6f 74 20 6f 6e 20  , yet is not on 
4170: 74 68 65 20 4e 54 44 42 7d 20 7b 0a 09 09 53 45  the NTDB} {...SE
4180: 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  LECT F.name, R.r
4190: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69  ev...FROM revisi
41a0: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57  on R, file F...W
41b0: 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66  HERE R.fid = F.f
41c0: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 63  id...AND   R.dbc
41d0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
41e0: 0a 09 09 41 4e 44 20 20 20 4e 4f 54 20 52 2e 69  ...AND   NOT R.i
41f0: 73 64 65 66 61 75 6c 74 0a 09 09 3b 0a 09 20 20  sdefault...;..  
4200: 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20    }..# Find all 
4210: 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61  revisions with a
4220: 20 4e 54 44 42 20 70 61 72 65 6e 74 20 77 68 69   NTDB parent whi
4230: 63 68 20 61 72 65 20 6f 6e 20 74 68 65 20 4e 54  ch are on the NT
4240: 44 42 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20  DB...Check \..  
4250: 20 20 7b 4e 54 44 42 20 74 6f 20 74 72 75 6e 6b    {NTDB to trunk
4260: 20 74 72 61 6e 73 69 74 69 6f 6e 20 68 61 73 20   transition has 
4270: 74 6f 20 65 6e 64 20 6f 6e 20 6e 6f 6e 2d 4e 54  to end on non-NT
4280: 44 42 7d 20 5c 0a 09 20 20 20 20 7b 68 61 73 20  DB} \..    {has 
4290: 61 20 4e 54 44 42 20 70 61 72 65 6e 74 2c 20 79  a NTDB parent, y
42a0: 65 74 20 69 73 20 6f 6e 20 74 68 65 20 4e 54 44  et is on the NTD
42b0: 42 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  B} {...SELECT F.
42c0: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
42d0: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66  OM revision R, f
42e0: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e  ile F...WHERE R.
42f0: 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e  fid = F.fid...AN
4300: 44 20 20 20 52 2e 64 62 70 61 72 65 6e 74 20 49  D   R.dbparent I
4310: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44  S NOT NULL...AND
4320: 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74 0a 09     R.isdefault..
4330: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
4340: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
4350: 77 69 74 68 20 61 20 63 68 69 6c 64 20 77 68 69  with a child whi
4360: 63 68 20 64 69 73 61 67 72 65 65 73 20 61 62 6f  ch disagrees abo
4370: 75 74 20 74 68 65 0a 09 23 20 6c 69 6e 65 20 6f  ut the..# line o
4380: 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68  f development th
4390: 65 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43  ey belong to...C
43a0: 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76  heck \..    {Rev
43b0: 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72  isions and their
43c0: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 72 65   primary childre
43d0: 6e 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20  n have to be in 
43e0: 74 68 65 20 73 61 6d 65 20 4c 4f 44 7d 20 5c 0a  the same LOD} \.
43f0: 09 20 20 20 20 7b 61 6e 64 20 69 74 73 20 70 72  .    {and its pr
4400: 69 6d 61 72 79 20 63 68 69 6c 64 20 64 69 73 61  imary child disa
4410: 67 72 65 65 20 61 62 6f 75 74 20 74 68 65 69 72  gree about their
4420: 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43 54   LOD} {...SELECT
4430: 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09   F.name, R.rev..
4440: 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52  .FROM revision R
4450: 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69  , revision C, fi
4460: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66  le F...WHERE R.f
4470: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
4480: 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f     R.child IS NO
4490: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
44a0: 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09  .child = C.rid..
44b0: 09 41 4e 44 20 20 20 43 2e 6c 6f 64 20 21 3d 20  .AND   C.lod != 
44c0: 52 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20 20 20 7d  R.lod...;..    }
44d0: 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76  ..# Find all rev
44e0: 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f  isions with a no
44f0: 6e 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69  n-NTDB child whi
4500: 63 68 20 61 67 72 65 65 73 20 61 62 6f 75 74 0a  ch agrees about.
4510: 09 23 20 74 68 65 20 6c 69 6e 65 20 6f 66 20 64  .# the line of d
4520: 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20  evelopment they 
4530: 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63  belong to...Chec
4540: 6b 20 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 61  k \..    {NTDB a
4550: 6e 64 20 74 72 75 6e 6b 20 72 65 76 69 73 69 6f  nd trunk revisio
4560: 6e 73 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e  ns have to be in
4570: 20 64 69 66 66 65 72 65 6e 74 20 4c 4f 44 73 7d   different LODs}
4580: 20 5c 0a 09 20 20 20 20 7b 6f 6e 20 4e 54 44 42   \..    {on NTDB
4590: 20 61 6e 64 20 69 74 73 20 6e 6f 6e 2d 4e 54 44   and its non-NTD
45a0: 42 20 63 68 69 6c 64 20 77 72 6f 6e 67 6c 79 20  B child wrongly 
45b0: 61 67 72 65 65 20 61 62 6f 75 74 20 74 68 65 69  agree about thei
45c0: 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43  r LOD} {...SELEC
45d0: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
45e0: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
45f0: 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66  R, revision C, f
4600: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e  ile F...WHERE R.
4610: 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e  fid = F.fid...AN
4620: 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53  D   R.dbchild IS
4630: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20   NOT NULL...AND 
4640: 20 20 52 2e 64 62 63 68 69 6c 64 20 3d 20 43 2e    R.dbchild = C.
4650: 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e 6c 6f  rid...AND   C.lo
4660: 64 20 3d 20 52 2e 6c 6f 64 0a 09 09 3b 0a 09 20  d = R.lod...;.. 
4670: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
4680: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
4690: 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20  a branch parent 
46a0: 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 69 73 20  symbol which is 
46b0: 6e 6f 74 0a 09 23 20 74 68 65 69 72 20 4c 4f 44  not..# their LOD
46c0: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
46d0: 7b 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67  {Branch starting
46e0: 20 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20   revisions have 
46f0: 74 6f 20 68 61 76 65 20 74 68 65 69 72 20 4c 4f  to have their LO
4700: 44 20 61 73 20 62 72 61 6e 63 68 20 70 61 72 65  D as branch pare
4710: 6e 74 20 73 79 6d 62 6f 6c 7d 20 5c 0a 09 20 20  nt symbol} \..  
4720: 20 20 7b 61 74 20 74 68 65 20 62 65 67 69 6e 6e    {at the beginn
4730: 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61 6e 63  ing of its branc
4740: 68 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20  h does not have 
4750: 74 68 65 20 62 72 61 6e 63 68 20 73 79 6d 62 6f  the branch symbo
4760: 6c 20 61 73 20 69 74 73 20 4c 4f 44 7d 20 7b 0a  l as its LOD} {.
4770: 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c  ..SELECT F.name,
4780: 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65   R.rev...FROM re
4790: 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46  vision R, file F
47a0: 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64 20 3d  ...WHERE R.fid =
47b0: 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 52   F.fid...AND   R
47c0: 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20  .bparent IS NOT 
47d0: 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 6c  NULL...AND   R.l
47e0: 6f 64 20 21 3d 20 52 2e 62 70 61 72 65 6e 74 0a  od != R.bparent.
47f0: 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69  ..;..    }..# Fi
4800: 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  nd all revisions
4810: 20 77 69 74 68 20 61 20 62 72 61 6e 63 68 20 70   with a branch p
4820: 61 72 65 6e 74 20 73 79 6d 62 6f 6c 20 77 68 6f  arent symbol who
4830: 73 65 20 70 61 72 65 6e 74 0a 09 23 20 69 73 20  se parent..# is 
4840: 69 6e 20 74 68 65 20 73 61 6d 65 20 6c 69 6e 65  in the same line
4850: 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 2e   of development.
4860: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b  ..Check \..    {
4870: 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 68  Revisions and th
4880: 65 69 72 20 62 72 61 6e 63 68 20 63 68 69 6c 64  eir branch child
4890: 72 65 6e 20 68 61 76 65 20 74 6f 20 62 65 20 69  ren have to be i
48a0: 6e 20 64 69 66 66 65 72 65 6e 74 20 4c 4f 44 73  n different LODs
48b0: 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65  } \..    {at the
48c0: 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74   beginning of it
48d0: 73 20 62 72 61 6e 63 68 20 61 6e 64 20 69 74 73  s branch and its
48e0: 20 70 61 72 65 6e 74 20 77 72 6f 6e 67 6c 79 20   parent wrongly 
48f0: 61 67 72 65 65 20 61 62 6f 75 74 20 74 68 65 69  agree about thei
4900: 72 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c 45 43  r LOD} {...SELEC
4910: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
4920: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
4930: 52 2c 20 72 65 76 69 73 69 6f 6e 20 50 2c 20 66  R, revision P, f
4940: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e  ile F...WHERE R.
4950: 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e  fid = F.fid...AN
4960: 44 20 20 20 52 2e 62 70 61 72 65 6e 74 20 49 53  D   R.bparent IS
4970: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20   NOT NULL...AND 
4980: 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e 72    R.parent = P.r
4990: 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64  id...AND   R.lod
49a0: 20 3d 20 50 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20   = P.lod...;..  
49b0: 20 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20    }..return.    
49c0: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 43 68 65 63  }..    proc Chec
49d0: 6b 20 7b 68 65 61 64 65 72 20 6c 61 62 65 6c 20  k {header label 
49e0: 73 71 6c 7d 20 7b 0a 09 75 70 76 61 72 20 31 20  sql} {..upvar 1 
49f0: 6e 20 6e 0a 09 73 65 74 20 6f 6b 20 31 0a 09 66  n n..set ok 1..f
4a00: 6f 72 65 61 63 68 20 7b 66 6e 61 6d 65 20 72 65  oreach {fname re
4a10: 76 6e 72 7d 20 5b 73 74 61 74 65 20 72 75 6e 20  vnr} [state run 
4a20: 24 73 71 6c 5d 20 7b 0a 09 20 20 20 20 73 65 74  $sql] {..    set
4a30: 20 6f 6b 20 30 0a 09 20 20 20 20 74 72 6f 75 62   ok 0..    troub
4a40: 6c 65 20 66 61 74 61 6c 20 22 24 66 6e 61 6d 65  le fatal "$fname
4a50: 20 3c 24 72 65 76 6e 72 3e 20 24 6c 61 62 65 6c   <$revnr> $label
4a60: 22 0a 09 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20  "..}..log write 
4a70: 35 20 63 6f 6c 6c 72 65 76 20 22 5c 5b 5b 66 6f  5 collrev "\[[fo
4a80: 72 6d 61 74 20 25 30 32 64 20 5b 69 6e 63 72 20  rmat %02d [incr 
4a90: 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20 7b 24 6f 6b  n]]\] [expr {$ok
4aa0: 20 3f 20 22 4f 6b 20 20 20 20 22 20 3a 20 22 46   ? "Ok    " : "F
4ab0: 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e 20 24 68 65  ailed"}] ... $he
4ac0: 61 64 65 72 22 0a 09 72 65 74 75 72 6e 0a 20 20  ader"..return.  
4ad0: 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20    }..    # # ## 
4ae0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
4af0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
4b00: 0a 20 20 20 20 23 23 20 49 6e 74 65 72 6e 61 6c  .    ## Internal
4b10: 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20 20 23 20   methods..    # 
4b20: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
4b30: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
4b40: 23 23 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e  #####.    ## Con
4b50: 66 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20  figuration..    
4b60: 70 72 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61  pragma -hasinsta
4b70: 6e 63 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69  nces   no ; # si
4b80: 6e 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67  ngleton.    prag
4b90: 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20  ma -hastypeinfo 
4ba0: 20 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74     no ; # no int
4bb0: 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70  rospection.    p
4bc0: 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65  ragma -hastypede
4bd0: 73 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d  stroy no ; # imm
4be0: 6f 72 74 61 6c 0a 0a 20 20 20 20 23 20 23 20 23  ortal..    # # #
4bf0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
4c00: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
4c10: 23 23 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20  ##.}..namespace 
4c20: 65 76 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  eval ::vc::fossi
4c30: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
4c40: 70 61 73 73 20 7b 0a 20 20 20 20 6e 61 6d 65 73  pass {.    names
4c50: 70 61 63 65 20 65 78 70 6f 72 74 20 63 6f 6c 6c  pace export coll
4c60: 72 65 76 0a 20 20 20 20 6e 61 6d 65 73 70 61 63  rev.    namespac
4c70: 65 20 65 76 61 6c 20 63 6f 6c 6c 72 65 76 20 7b  e eval collrev {
4c80: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
4c90: 72 74 20 3a 3a 76 63 3a 3a 72 63 73 3a 3a 70 61  rt ::vc::rcs::pa
4ca0: 72 73 65 72 0a 09 6e 61 6d 65 73 70 61 63 65 20  rser..namespace 
4cb0: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73  import ::vc::fos
4cc0: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
4cd0: 3a 3a 72 65 70 6f 73 69 74 6f 72 79 0a 09 6e 61  ::repository..na
4ce0: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
4cf0: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
4d00: 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a  ort::cvs::state.
4d10: 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
4d20: 70 72 6f 6a 65 63 74 20 7b 0a 09 20 20 20 20 6e  project {..    n
4d30: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
4d40: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
4d50: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65  port::cvs::proje
4d60: 63 74 3a 3a 73 79 6d 0a 09 7d 0a 09 6e 61 6d 65  ct::sym..}..name
4d70: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
4d80: 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c  c::tools::troubl
4d90: 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70  e..namespace imp
4da0: 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a  ort ::vc::tools:
4db0: 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74  :log..log regist
4dc0: 65 72 20 63 6f 6c 6c 72 65 76 0a 20 20 20 20 7d  er collrev.    }
4dd0: 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23  .}..# # ## ### #
4de0: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
4df0: 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23  ########### ####
4e00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
4e10: 23 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 63 6b  #.## Ready..pack
4e20: 61 67 65 20 70 72 6f 76 69 64 65 20 76 63 3a 3a  age provide vc::
4e30: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
4e40: 63 76 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c 6c 72  cvs::pass::collr
4e50: 65 76 20 31 2e 30 0a 72 65 74 75 72 6e 0a        ev 1.0.return.