Hex Artifact Content
Not logged in

Artifact 1a642fd724fe0933e25ef4a5bb63bdbfbf505f89:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [2434ad3bfe] - Added lots of checks looking for inconsistent references between the various objects, mainly revisions. by aku on 2007-10-26 05:29:46.

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 65 63  parses the colec
0220: 74 65 64 20 72 63 73 20 61 72 63 68 69 76 65 73  ted rcs archives
0230: 20 61 6e 64 20 65 78 74 72 61 63 74 73 0a 23 23   and extracts.##
0240: 20 61 6c 6c 20 74 68 65 20 69 6e 66 6f 72 6d 61   all the informa
0250: 74 69 6f 6e 20 74 68 65 79 20 63 6f 6e 74 61 69  tion they contai
0260: 6e 20 28 72 65 76 69 73 69 6f 6e 73 2c 20 61 6e  n (revisions, an
0270: 64 20 73 79 6d 62 6f 6c 73 29 2e 0a 0a 23 20 23  d symbols)...# #
0280: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
0290: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
02a0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
02b0: 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65  ##########.## Re
02c0: 71 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61 63 6b  quirements..pack
02d0: 61 67 65 20 72 65 71 75 69 72 65 20 54 63 6c 20  age require Tcl 
02e0: 38 2e 34 20 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: 3b 20 23 20 52 65 71 75 69 72 65 64 20 72 75 6e  ; # Required run
0310: 74 69 6d 65 2e 0a 70 61 63 6b 61 67 65 20 72 65  time..package re
0320: 71 75 69 72 65 20 73 6e 69 74 20 20 20 20 20 20  quire 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 3b 20 23 20 4f 4f            ; # OO
0350: 20 73 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67 65   system..package
0360: 20 72 65 71 75 69 72 65 20 66 69 6c 65 75 74 69   require fileuti
0370: 6c 3a 3a 74 72 61 76 65 72 73 65 20 20 20 20 20  l::traverse     
0380: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23               ; #
0390: 20 44 69 72 65 63 74 6f 72 79 20 74 72 61 76 65   Directory trave
03a0: 72 73 61 6c 2e 0a 70 61 63 6b 61 67 65 20 72 65  rsal..package re
03b0: 71 75 69 72 65 20 66 69 6c 65 75 74 69 6c 20 20  quire fileutil  
03c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03d0: 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 46 69            ; # Fi
03e0: 6c 65 20 26 20 70 61 74 68 20 75 74 69 6c 69 74  le & path utilit
03f0: 69 65 73 2e 0a 70 61 63 6b 61 67 65 20 72 65 71  ies..package req
0400: 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  uire vc::tools::
0410: 74 72 6f 75 62 6c 65 20 20 20 20 20 20 20 20 20  trouble         
0420: 20 20 20 20 20 20 20 20 20 3b 20 23 20 45 72 72           ; # Err
0430: 6f 72 20 72 65 70 6f 72 74 69 6e 67 2e 0a 70 61  or reporting..pa
0440: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
0450: 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 20 20 20 20  ::tools::log    
0460: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0470: 20 20 3b 20 23 20 55 73 65 72 20 66 65 65 64 62    ; # User feedb
0480: 61 63 6b 2e 0a 70 61 63 6b 61 67 65 20 72 65 71  ack..package req
0490: 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a  uire vc::fossil:
04a0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61  :import::cvs::pa
04b0: 73 73 20 20 20 20 20 20 20 3b 20 23 20 50 61 73  ss       ; # Pas
04c0: 73 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70 61  s management..pa
04d0: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
04e0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
04f0: 3a 3a 63 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72  ::cvs::repositor
0500: 79 20 3b 20 23 20 52 65 70 6f 73 69 74 6f 72 79  y ; # Repository
0510: 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70 61 63   management..pac
0520: 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a  kage require vc:
0530: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
0540: 3a 63 76 73 3a 3a 73 74 61 74 65 20 20 20 20 20  :cvs::state     
0550: 20 3b 20 23 20 53 74 61 74 65 20 73 74 6f 72 61   ; # State stora
0560: 67 65 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75  ge..package requ
0570: 69 72 65 20 76 63 3a 3a 72 63 73 3a 3a 70 61 72  ire vc::rcs::par
0580: 73 65 72 20 20 20 20 20 20 20 20 20 20 20 20 20  ser             
0590: 20 20 20 20 20 20 20 20 3b 20 23 20 52 63 73 20          ; # Rcs 
05a0: 61 72 63 68 69 76 65 20 64 61 74 61 20 65 78 74  archive data ext
05b0: 72 61 63 74 69 6f 6e 2e 0a 0a 23 20 23 20 23 23  raction...# # ##
05c0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
05d0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
05e0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23  # ##############
05f0: 23 23 23 23 23 23 23 0a 23 23 20 52 65 67 69 73  #######.## Regis
0600: 74 65 72 20 74 68 65 20 70 61 73 73 20 77 69 74  ter the pass wit
0610: 68 20 74 68 65 20 6d 61 6e 61 67 65 6d 65 6e 74  h the management
0620: 0a 0a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ..vc::fossil::im
0630: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20  port::cvs::pass 
0640: 64 65 66 69 6e 65 20 5c 0a 20 20 20 20 43 6f 6c  define \.    Col
0650: 6c 65 63 74 52 65 76 20 5c 0a 20 20 20 20 7b 43  lectRev \.    {C
0660: 6f 6c 6c 65 63 74 20 72 65 76 69 73 69 6f 6e 73  ollect revisions
0670: 20 61 6e 64 20 73 79 6d 62 6f 6c 73 7d 20 5c 0a   and symbols} \.
0680: 20 20 20 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c      ::vc::fossil
0690: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70  ::import::cvs::p
06a0: 61 73 73 3a 3a 63 6f 6c 6c 72 65 76 0a 0a 23 20  ass::collrev..# 
06b0: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
06c0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
06d0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
06e0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 0a  ###########.## .
06f0: 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63  .snit::type ::vc
0700: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
0710: 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c  ::cvs::pass::col
0720: 6c 72 65 76 20 7b 0a 20 20 20 20 23 20 23 20 23  lrev {.    # # #
0730: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
0740: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
0750: 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69 63  ##.    ## Public
0760: 20 41 50 49 0a 0a 20 20 20 20 74 79 70 65 6d 65   API..    typeme
0770: 74 68 6f 64 20 73 65 74 75 70 20 7b 7d 20 7b 0a  thod setup {} {.
0780: 09 23 20 44 65 66 69 6e 65 20 6e 61 6d 65 73 20  .# Define names 
0790: 61 6e 64 20 73 74 72 75 63 74 75 72 65 20 6f 66  and structure of
07a0: 20 74 68 65 20 70 65 72 73 69 73 74 65 6e 74 20   the persistent 
07b0: 73 74 61 74 65 20 6f 66 20 74 68 69 73 0a 09 23  state of this..#
07c0: 20 70 61 73 73 2e 0a 0a 09 73 74 61 74 65 20 72   pass....state r
07d0: 65 61 64 69 6e 67 20 70 72 6f 6a 65 63 74 0a 09  eading project..
07e0: 73 74 61 74 65 20 72 65 61 64 69 6e 67 20 66 69  state reading fi
07f0: 6c 65 0a 0a 09 23 20 57 65 20 64 65 61 6c 20 77  le...# We deal w
0800: 69 74 68 20 70 65 72 20 70 72 6f 6a 65 63 74 20  ith per project 
0810: 61 6e 64 20 70 65 72 20 66 69 6c 65 20 64 61 74  and per file dat
0820: 61 2c 20 74 68 65 20 66 69 72 73 74 0a 09 23 20  a, the first..# 
0830: 63 6f 6c 6c 61 74 65 64 20 66 72 6f 6d 20 74 68  collated from th
0840: 65 20 73 65 63 6f 6e 64 2e 0a 0a 09 23 20 50 65  e second....# Pe
0850: 72 20 66 69 6c 65 20 77 65 20 68 61 76 65 20 67  r file we have g
0860: 65 6e 65 72 61 6c 20 69 6e 66 6f 72 6d 61 74 69  eneral informati
0870: 6f 6e 2c 20 2e 2e 2e 2c 20 61 6e 64 20 74 68 65  on, ..., and the
0880: 6e 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 20 61  n..# revisions a
0890: 6e 64 20 73 79 6d 62 6f 6c 73 2e 20 54 68 65 20  nd symbols. The 
08a0: 6c 61 74 74 65 72 20 63 61 6e 20 62 65 20 66 75  latter can be fu
08b0: 72 74 68 65 72 20 73 65 70 61 72 61 74 65 64 0a  rther separated.
08c0: 09 23 20 69 6e 74 6f 20 74 61 67 73 20 61 6e 64  .# into tags and
08d0: 20 62 72 61 6e 63 68 65 73 2e 20 41 74 20 70 72   branches. At pr
08e0: 6f 6a 65 63 74 20 6c 65 76 65 6c 20 74 68 65 20  oject level the 
08f0: 70 65 72 2d 66 69 6c 65 0a 09 23 20 73 79 6d 62  per-file..# symb
0900: 6f 6c 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20  ols information 
0910: 69 73 20 6d 65 72 67 65 64 2e 0a 0a 09 23 20 46  is merged....# F
0920: 69 6c 65 20 6c 65 76 65 6c 20 2e 2e 2e 0a 09 23  ile level .....#
0930: 09 52 65 76 69 73 69 6f 6e 73 2c 20 42 72 61 6e  .Revisions, Bran
0940: 63 68 65 73 2c 20 54 61 67 73 0a 09 23 0a 09 23  ches, Tags..#..#
0950: 20 50 73 65 75 64 6f 20 63 6c 61 73 73 20 68 69   Pseudo class hi
0960: 65 72 61 72 63 68 79 0a 09 23 09 54 61 67 20 20  erarchy..#.Tag  
0970: 20 20 20 20 3c 2d 20 53 79 6d 62 6f 6c 20 3c 2d      <- Symbol <-
0980: 20 45 76 65 6e 74 0a 09 23 09 42 72 61 6e 63 68   Event..#.Branch
0990: 20 20 20 3c 2d 20 53 79 6d 62 6f 6c 20 3c 2d 20     <- Symbol <- 
09a0: 45 76 65 6e 74 0a 09 23 09 52 65 76 69 73 69 6f  Event..#.Revisio
09b0: 6e 20 20 20 20 20 20 20 20 20 20 20 3c 2d 20 45  n           <- E
09c0: 76 65 6e 74 0a 0a 09 73 74 61 74 65 20 77 72 69  vent...state wri
09d0: 74 69 6e 67 20 72 65 76 69 73 69 6f 6e 20 7b 0a  ting revision {.
09e0: 09 20 20 20 20 2d 2d 20 52 65 76 69 73 69 6f 6e  .    -- Revision
09f0: 73 2e 20 49 64 65 6e 74 69 66 69 65 64 20 62 79  s. Identified by
0a00: 20 61 20 67 6c 6f 62 61 6c 20 6e 75 6d 65 72 69   a global numeri
0a10: 63 20 69 64 20 65 61 63 68 0a 09 20 20 20 20 2d  c id each..    -
0a20: 2d 20 62 65 6c 6f 6e 67 73 20 74 6f 20 61 20 73  - belongs to a s
0a30: 69 6e 67 6c 65 20 66 69 6c 65 2c 20 69 64 65 6e  ingle file, iden
0a40: 74 69 66 69 65 64 20 62 79 20 69 74 73 20 69 64  tified by its id
0a50: 2e 20 49 74 0a 09 20 20 20 20 2d 2d 20 66 75 72  . It..    -- fur
0a60: 74 68 65 72 20 68 61 73 20 61 20 64 6f 74 74 65  ther has a dotte
0a70: 64 20 72 65 76 69 73 69 6f 6e 20 6e 75 6d 62 65  d revision numbe
0a80: 72 20 28 44 54 4e 29 2e 0a 09 20 20 20 20 2d 2d  r (DTN)...    --
0a90: 0a 09 20 20 20 20 2d 2d 20 43 6f 6e 73 74 72 61  ..    -- Constra
0aa0: 69 6e 74 3a 20 54 68 65 20 64 6f 74 74 65 64 20  int: The dotted 
0ab0: 72 65 76 69 73 69 6f 6e 20 6e 75 6d 62 65 72 20  revision number 
0ac0: 69 73 20 75 6e 69 71 75 65 20 77 69 74 68 69 6e  is unique within
0ad0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20  .            -- 
0ae0: 20 20 20 20 20 20 20 20 20 20 20 20 74 68 65 20              the 
0af0: 66 69 6c 65 2e 20 53 65 65 20 65 6e 64 20 6f 66  file. See end of
0b00: 20 64 65 66 69 6e 69 74 69 6f 6e 2e 0a 0a 09 20   definition.... 
0b10: 20 20 20 72 69 64 20 20 49 4e 54 45 47 45 52 20     rid  INTEGER 
0b20: 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41   NOT NULL  PRIMA
0b30: 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45  RY KEY AUTOINCRE
0b40: 4d 45 4e 54 2c 0a 09 20 20 20 20 66 69 64 20 20  MENT,..    fid  
0b50: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
0b60: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 66 69  L  REFERENCES fi
0b70: 6c 65 2c 20 20 20 2d 2d 20 46 69 6c 65 20 6f 77  le,   -- File ow
0b80: 6e 69 6e 67 20 72 65 76 69 73 69 6f 6e 2e 0a 09  ning revision...
0b90: 20 20 20 20 72 65 76 20 20 54 45 58 54 20 20 20      rev  TEXT   
0ba0: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 20 20 20 20    NOT NULL,     
0bb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d                 -
0bc0: 2d 20 44 6f 74 74 65 64 20 52 65 76 20 4e 75 6d  - Dotted Rev Num
0bd0: 62 65 72 2e 0a 0a 09 20 20 20 20 2d 2d 20 41 6c  ber....    -- Al
0be0: 6c 20 72 65 76 69 73 69 6f 6e 73 20 62 65 6c 6f  l revisions belo
0bf0: 6e 67 20 74 6f 20 61 20 6c 69 6e 65 2d 6f 66 2d  ng to a line-of-
0c00: 64 65 76 65 6c 6f 70 6d 65 6e 74 2c 0a 09 20 20  development,..  
0c10: 20 20 2d 2d 20 69 64 65 6e 74 69 66 69 65 64 20    -- identified 
0c20: 62 79 20 61 20 73 79 6d 62 6f 6c 20 28 70 72 6f  by a symbol (pro
0c30: 6a 65 63 74 20 6c 65 76 65 6c 29 2e 20 44 75 72  ject level). Dur
0c40: 69 6e 67 20 64 61 74 61 0a 09 20 20 20 20 2d 2d  ing data..    --
0c50: 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 69 74 20 77   collection it w
0c60: 61 73 20 61 20 66 69 6c 65 2d 6c 65 76 65 6c 20  as a file-level 
0c70: 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 2e 0a 09  branch symbol...
0c80: 20 20 20 20 2d 2d 0a 09 20 20 20 20 2d 2d 20 43      --..    -- C
0c90: 6f 6e 73 74 72 61 69 6e 74 3a 20 41 6c 6c 20 74  onstraint: All t
0ca0: 68 65 20 4c 4f 44 20 73 79 6d 62 6f 6c 73 20 61  he LOD symbols a
0cb0: 72 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70  re in the same p
0cc0: 72 6f 6a 65 63 74 0a 09 20 20 20 20 2d 2d 20 20  roject..    --  
0cd0: 20 20 20 20 20 20 20 20 20 20 20 61 73 20 74 68             as th
0ce0: 65 20 66 69 6c 65 20 69 74 73 65 6c 66 2e 20 54  e file itself. T
0cf0: 68 69 73 20 63 61 6e 6e 6f 74 20 62 65 0a 09 20  his cannot be.. 
0d00: 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20 20     --           
0d10: 20 20 65 78 70 72 65 73 73 65 64 20 69 6e 20 43    expressed in C
0d20: 52 45 41 54 45 20 54 41 42 4c 45 20 73 79 6e 74  REATE TABLE synt
0d30: 61 78 2e 0a 0a 09 20 20 20 20 6c 6f 64 20 20 49  ax....    lod  I
0d40: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
0d50: 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d    REFERENCES sym
0d60: 62 6f 6c 2c 20 2d 2d 20 4c 69 6e 65 20 6f 66 20  bol, -- Line of 
0d70: 64 65 76 65 6c 6f 70 6d 65 6e 74 0a 0a 09 20 20  development...  
0d80: 20 20 2d 2d 20 54 68 65 20 72 65 76 69 73 69 6f    -- The revisio
0d90: 6e 73 20 69 6e 20 61 20 66 69 6c 65 20 61 72 65  ns in a file are
0da0: 20 6f 72 67 61 6e 69 7a 65 64 20 69 6e 20 61 20   organized in a 
0db0: 66 6f 72 65 73 74 20 6f 66 0a 09 20 20 20 20 2d  forest of..    -
0dc0: 2d 20 74 72 65 65 73 2c 20 77 69 74 68 20 74 68  - trees, with th
0dd0: 65 20 6d 61 69 6e 20 6c 69 6e 65 73 20 64 65 66  e main lines def
0de0: 69 6e 65 64 20 74 68 72 6f 75 67 68 20 74 68 65  ined through the
0df0: 20 70 61 72 65 6e 74 20 2f 0a 09 20 20 20 20 2d   parent /..    -
0e00: 2d 20 63 68 69 6c 64 20 72 65 66 65 72 65 6e 63  - child referenc
0e10: 65 73 2e 20 41 20 72 65 76 69 73 69 6f 6e 20 77  es. A revision w
0e20: 69 74 68 6f 75 74 20 61 20 70 61 72 65 6e 74 20  ithout a parent 
0e30: 69 73 20 74 68 65 0a 09 20 20 20 20 2d 2d 20 72  is the..    -- r
0e40: 6f 6f 74 20 6f 66 20 61 20 74 72 65 65 2c 20 61  oot of a tree, a
0e50: 6e 64 20 61 20 72 65 76 69 73 69 6f 6e 20 77 69  nd a revision wi
0e60: 74 68 6f 75 74 20 61 20 63 68 69 6c 64 20 69 73  thout a child is
0e70: 20 61 0a 09 20 20 20 20 2d 2d 20 6c 65 61 66 2e   a..    -- leaf.
0e80: 0a 0a 09 20 20 20 20 2d 2d 20 43 6f 6e 73 74 72  ...    -- Constr
0e90: 61 69 6e 74 73 3a 20 41 6c 6c 20 72 65 76 69 73  aints: All revis
0ea0: 69 6f 6e 73 20 63 6f 75 70 6c 65 64 20 74 68 72  ions coupled thr
0eb0: 6f 75 67 68 20 70 61 72 65 6e 74 2f 63 68 69 6c  ough parent/chil
0ec0: 64 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20  d..    --       
0ed0: 20 20 20 20 20 20 20 72 65 66 65 72 20 74 6f 20         refer to 
0ee0: 74 68 65 20 73 61 6d 65 20 4c 4f 44 20 73 79 6d  the same LOD sym
0ef0: 62 6f 6c 2e 20 54 68 65 20 70 61 72 65 6e 74 0a  bol. The parent.
0f00: 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20  .    --         
0f10: 20 20 20 20 20 6f 66 20 61 20 63 68 69 6c 64 20       of a child 
0f20: 6f 66 20 58 20 69 73 20 58 2e 20 54 68 65 20 63  of X is X. The c
0f30: 68 69 6c 64 20 6f 66 20 61 0a 09 20 20 20 20 2d  hild of a..    -
0f40: 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70  -              p
0f50: 61 72 65 6e 74 20 6f 66 20 58 20 69 73 20 58 2e  arent of X is X.
0f60: 0a 0a 09 20 20 20 20 70 61 72 65 6e 74 20 20 49  ...    parent  I
0f70: 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20  NTEGER          
0f80: 20 20 52 45 46 45 52 45 4e 43 45 53 20 72 65 76    REFERENCES rev
0f90: 69 73 69 6f 6e 2c 0a 09 20 20 20 20 63 68 69 6c  ision,..    chil
0fa0: 64 20 20 20 49 4e 54 45 47 45 52 20 20 20 20 20  d   INTEGER     
0fb0: 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45         REFERENCE
0fc0: 53 20 72 65 76 69 73 69 6f 6e 2c 0a 0a 09 20 20  S revision,...  
0fd0: 20 20 2d 2d 20 54 68 65 20 72 65 70 72 65 73 65    -- The represe
0fe0: 6e 74 61 74 69 6f 6e 20 6f 66 20 61 20 62 72 61  ntation of a bra
0ff0: 6e 63 68 20 69 6e 20 61 20 74 72 65 65 20 69 73  nch in a tree is
1000: 20 74 68 65 0a 09 20 20 20 20 2d 2d 20 65 78 63   the..    -- exc
1010: 65 70 74 69 6f 6e 20 74 6f 20 74 68 65 20 74 68  eption to the th
1020: 72 65 65 20 63 6f 6e 73 74 72 61 69 6e 74 73 20  ree constraints 
1030: 61 62 6f 76 65 2e 0a 0a 09 20 20 20 20 2d 2d 20  above....    -- 
1040: 54 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66  The beginning of
1050: 20 61 20 62 72 61 6e 63 68 20 69 73 20 72 65 70   a branch is rep
1060: 72 65 73 65 6e 74 65 64 20 62 79 20 61 20 6e 6f  resented by a no
1070: 6e 2d 4e 55 4c 4c 0a 09 20 20 20 20 2d 2d 20 62  n-NULL..    -- b
1080: 70 61 72 65 6e 74 20 6f 66 20 61 20 72 65 76 69  parent of a revi
1090: 73 69 6f 6e 2e 20 54 68 69 73 20 72 65 76 69 73  sion. This revis
10a0: 69 6f 6e 20 42 20 69 73 20 74 68 65 20 66 69 72  ion B is the fir
10b0: 73 74 20 6f 6e 0a 09 20 20 20 20 2d 2d 20 74 68  st on..    -- th
10c0: 65 20 62 72 61 6e 63 68 2e 20 49 74 73 20 70 61  e branch. Its pa
10d0: 72 65 6e 74 20 50 20 69 73 20 74 68 65 20 72 65  rent P is the re
10e0: 76 69 73 69 6f 6e 20 74 68 65 20 62 72 61 6e 63  vision the branc
10f0: 68 20 69 73 0a 09 20 20 20 20 2d 2d 20 72 6f 6f  h is..    -- roo
1100: 74 65 64 20 69 6e 2c 20 61 6e 64 20 69 74 20 69  ted in, and it i
1110: 73 20 6e 6f 74 20 74 68 65 20 63 68 69 6c 64 20  s not the child 
1120: 6f 66 20 50 2e 20 42 20 61 6e 64 20 50 20 72 65  of P. B and P re
1130: 66 65 72 0a 09 20 20 20 20 2d 2d 20 74 6f 20 64  fer..    -- to d
1140: 69 66 66 65 72 65 6e 74 20 4c 4f 44 20 73 79 6d  ifferent LOD sym
1150: 62 6f 6c 73 2e 20 54 68 65 20 62 70 61 72 65 6e  bols. The bparen
1160: 74 20 6f 66 20 42 20 69 73 20 61 6c 73 6f 20 69  t of B is also i
1170: 74 73 0a 09 20 20 20 20 2d 2d 20 4c 4f 44 2c 20  ts..    -- LOD, 
1180: 61 6e 64 20 74 68 65 20 4c 4f 44 20 6f 66 20 69  and the LOD of i
1190: 74 73 20 63 68 69 6c 64 72 65 6e 2e 0a 0a 09 20  ts children.... 
11a0: 20 20 20 62 70 61 72 65 6e 74 20 49 4e 54 45 47     bparent INTEG
11b0: 45 52 20 20 20 20 20 20 20 20 20 20 20 20 52 45  ER            RE
11c0: 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c  FERENCES symbol,
11d0: 0a 0a 09 20 20 20 20 2d 2d 20 4c 61 73 74 6c 79  ...    -- Lastly
11e0: 20 77 65 20 6b 65 65 70 20 69 6e 66 6f 72 6d 61   we keep informa
11f0: 74 69 6f 6e 20 69 73 20 61 62 6f 75 74 20 6e 6f  tion is about no
1200: 6e 2d 74 72 75 6e 6b 20 64 65 66 61 75 6c 74 0a  n-trunk default.
1210: 09 20 20 20 20 2d 2d 20 62 72 61 6e 63 68 65 73  .    -- branches
1220: 20 28 4e 54 44 42 29 20 69 6e 20 74 68 65 20 72   (NTDB) in the r
1230: 65 76 69 73 69 6f 6e 73 2e 0a 0a 09 20 20 20 20  evisions....    
1240: 2d 2d 20 41 6c 6c 20 72 65 76 69 73 69 6f 6e 73  -- All revisions
1250: 20 6f 6e 20 74 68 65 20 4e 54 44 42 20 68 61 76   on the NTDB hav
1260: 65 20 27 69 73 64 65 66 61 75 6c 74 27 20 54 52  e 'isdefault' TR
1270: 55 45 2c 0a 09 20 20 20 20 2d 2d 20 65 76 65 72  UE,..    -- ever
1280: 79 6f 6e 65 20 65 6c 73 65 20 46 41 4c 53 45 2e  yone else FALSE.
1290: 20 54 68 65 20 6c 61 73 74 20 72 65 76 69 73 69   The last revisi
12a0: 6f 6e 20 58 20 6f 6e 20 74 68 65 20 4e 54 44 42  on X on the NTDB
12b0: 0a 09 20 20 20 20 2d 2d 20 77 68 69 63 68 20 69  ..    -- which i
12c0: 73 20 73 74 69 6c 6c 20 63 6f 6e 73 69 64 65 72  s still consider
12d0: 65 64 20 74 6f 20 62 65 20 6f 6e 20 74 68 65 20  ed to be on the 
12e0: 74 72 75 6e 6b 20 61 73 20 77 65 6c 6c 0a 09 20  trunk as well.. 
12f0: 20 20 20 2d 2d 20 68 61 73 20 61 20 6e 6f 6e 2d     -- has a non-
1300: 4e 55 4c 4c 20 27 64 62 63 68 69 6c 64 27 20 77  NULL 'dbchild' w
1310: 68 69 63 68 20 72 65 66 65 72 73 20 74 6f 20 74  hich refers to t
1320: 68 65 20 72 6f 6f 74 20 6f 66 0a 09 20 20 20 20  he root of..    
1330: 2d 2d 20 74 68 65 20 74 72 75 6e 6b 2e 20 54 68  -- the trunk. Th
1340: 65 20 72 6f 6f 74 20 61 6c 73 6f 20 68 61 73 20  e root also has 
1350: 61 20 6e 6f 6e 2d 4e 55 4c 4c 20 64 62 70 61 72  a non-NULL dbpar
1360: 65 6e 74 0a 09 20 20 20 20 2d 2d 20 72 65 66 65  ent..    -- refe
1370: 72 69 6e 67 20 74 6f 20 58 2e 0a 0a 09 20 20 20  ring to X....   
1380: 20 69 73 64 65 66 61 75 6c 74 20 49 4e 54 45 47   isdefault INTEG
1390: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20  ER  NOT NULL,.. 
13a0: 20 20 20 64 62 70 61 72 65 6e 74 20 20 49 4e 54     dbparent  INT
13b0: 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20 20  EGER            
13c0: 52 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73  REFERENCES revis
13d0: 69 6f 6e 2c 0a 09 20 20 20 20 64 62 63 68 69 6c  ion,..    dbchil
13e0: 64 20 20 20 49 4e 54 45 47 45 52 20 20 20 20 20  d   INTEGER     
13f0: 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45         REFERENCE
1400: 53 20 72 65 76 69 73 69 6f 6e 2c 0a 0a 09 20 20  S revision,...  
1410: 20 20 2d 2d 20 54 68 65 20 6d 61 69 6e 20 70 61    -- The main pa
1420: 79 6c 6f 61 64 20 6f 66 20 74 68 65 20 72 65 76  yload of the rev
1430: 69 73 69 6f 6e 20 61 72 65 20 74 68 65 20 64 61  ision are the da
1440: 74 65 2f 74 69 6d 65 20 69 74 0a 09 20 20 20 20  te/time it..    
1450: 2d 2d 20 77 61 73 20 65 6e 74 65 72 65 64 2c 20  -- was entered, 
1460: 69 74 73 20 73 74 61 74 65 2c 20 6f 70 65 72 61  its state, opera
1470: 74 69 6f 6e 20 28 3d 20 74 79 70 65 2f 63 6c 61  tion (= type/cla
1480: 73 73 29 2c 20 74 65 78 74 0a 09 20 20 20 20 2d  ss), text..    -
1490: 2d 20 63 6f 6e 74 65 6e 74 2c 20 61 6e 64 20 6d  - content, and m
14a0: 65 74 61 20 64 61 74 61 20 28 61 75 74 68 6f 72  eta data (author
14b0: 2c 20 6c 6f 67 20 6d 65 73 73 61 67 65 2c 20 62  , log message, b
14c0: 72 61 6e 63 68 2c 0a 09 20 20 20 20 2d 2d 20 70  ranch,..    -- p
14d0: 72 6f 6a 65 63 74 29 2e 20 54 68 65 20 6c 61 73  roject). The las
14e0: 74 20 69 73 20 65 6e 63 6f 64 65 64 20 61 73 20  t is encoded as 
14f0: 73 69 6e 67 6c 65 20 69 64 2c 20 73 65 65 20 74  single id, see t
1500: 61 62 6c 65 0a 09 20 20 20 20 2d 2d 20 27 6d 65  able..    -- 'me
1510: 74 61 27 2e 20 54 68 65 20 64 61 74 65 2f 74 69  ta'. The date/ti
1520: 6d 65 20 69 73 20 67 69 76 65 6e 20 69 6e 20 73  me is given in s
1530: 65 63 6f 6e 64 73 20 73 69 6e 63 65 20 74 68 65  econds since the
1540: 0a 09 20 20 20 20 2d 2d 20 65 70 6f 63 68 2c 20  ..    -- epoch, 
1550: 66 6f 72 20 65 61 73 79 20 63 6f 6d 70 61 72 69  for easy compari
1560: 73 6f 6e 2e 20 54 68 65 20 74 65 78 74 20 63 6f  son. The text co
1570: 6e 74 65 6e 74 20 69 73 20 61 6e 0a 09 20 20 20  ntent is an..   
1580: 20 2d 2d 20 28 6f 66 66 73 65 74 2c 6c 65 6e 67   -- (offset,leng
1590: 74 68 29 20 70 61 69 72 20 69 6e 74 6f 20 74 68  th) pair into th
15a0: 65 20 72 63 73 20 61 72 63 68 69 76 65 2e 0a 0a  e rcs archive...
15b0: 09 20 20 20 20 6f 70 20 20 20 20 49 4e 54 45 47  .    op    INTEG
15c0: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20  ER  NOT NULL,.. 
15d0: 20 20 20 64 61 74 65 20 20 49 4e 54 45 47 45 52     date  INTEGER
15e0: 20 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20    NOT NULL,..   
15f0: 20 73 74 61 74 65 20 54 45 58 54 20 20 20 20 20   state TEXT     
1600: 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 6d  NOT NULL,..    m
1610: 69 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  id   INTEGER  NO
1620: 54 20 4e 55 4c 4c 20 52 45 46 45 52 45 4e 43 45  T NULL REFERENCE
1630: 53 20 6d 65 74 61 2c 0a 09 20 20 20 20 63 6f 66  S meta,..    cof
1640: 66 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  f  INTEGER  NOT 
1650: 4e 55 4c 4c 2c 0a 09 20 20 20 20 63 6c 65 6e 20  NULL,..    clen 
1660: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1670: 4c 4c 2c 0a 0a 09 20 20 20 20 55 4e 49 51 55 45  LL,...    UNIQUE
1680: 20 28 66 69 64 2c 20 72 65 76 29 20 2d 2d 20 54   (fid, rev) -- T
1690: 68 65 20 44 54 4e 20 69 73 20 75 6e 69 71 75 65  he DTN is unique
16a0: 20 77 69 74 68 69 6e 20 74 68 65 20 72 65 76 69   within the revi
16b0: 73 69 6f 6e 27 73 20 66 69 6c 65 2e 0a 09 7d 0a  sion's file...}.
16c0: 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e 67 20  ..state writing 
16d0: 74 61 67 20 7b 0a 09 20 20 20 20 74 69 64 20 20  tag {..    tid  
16e0: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
16f0: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 41  L  PRIMARY KEY A
1700: 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20  UTOINCREMENT,.. 
1710: 20 20 20 66 69 64 20 20 49 4e 54 45 47 45 52 20     fid  INTEGER 
1720: 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52   NOT NULL  REFER
1730: 45 4e 43 45 53 20 66 69 6c 65 2c 20 20 20 20 20  ENCES file,     
1740: 2d 2d 20 46 69 6c 65 20 74 68 65 20 69 74 65 6d  -- File the item
1750: 20 62 65 6c 6f 6e 67 73 20 74 6f 0a 09 20 20 20   belongs to..   
1760: 20 6c 6f 64 20 20 49 4e 54 45 47 45 52 20 20 20   lod  INTEGER   
1770: 20 20 20 20 20 20 20 20 20 52 45 46 45 52 45 4e           REFEREN
1780: 43 45 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d  CES symbol,   --
1790: 20 4c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70   Line of develop
17a0: 6d 65 6e 74 20 28 4e 55 4c 4c 20 3d 3e 20 54 72  ment (NULL => Tr
17b0: 75 6e 6b 29 0a 0a 09 20 20 20 20 73 69 64 20 20  unk)...    sid  
17c0: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
17d0: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79  L  REFERENCES sy
17e0: 6d 62 6f 6c 2c 20 20 20 2d 2d 20 53 79 6d 62 6f  mbol,   -- Symbo
17f0: 6c 20 63 61 70 74 75 72 69 6e 67 20 74 68 65 20  l capturing the 
1800: 74 61 67 0a 0a 09 20 20 20 20 72 65 76 20 20 49  tag...    rev  I
1810: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1820: 20 20 52 45 46 45 52 45 4e 43 45 53 20 72 65 76    REFERENCES rev
1830: 69 73 69 6f 6e 20 20 2d 2d 20 54 68 65 20 72 65  ision  -- The re
1840: 76 69 73 69 6f 6e 20 62 65 69 6e 67 20 74 61 67  vision being tag
1850: 67 65 64 2e 0a 09 7d 0a 0a 09 73 74 61 74 65 20  ged...}...state 
1860: 77 72 69 74 69 6e 67 20 62 72 61 6e 63 68 20 7b  writing branch {
1870: 0a 09 20 20 20 20 62 69 64 20 20 20 49 4e 54 45  ..    bid   INTE
1880: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50  GER  NOT NULL  P
1890: 52 49 4d 41 52 59 20 4b 45 59 20 41 55 54 4f 49  RIMARY KEY AUTOI
18a0: 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 66  NCREMENT,..    f
18b0: 69 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f  id   INTEGER  NO
18c0: 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43  T NULL  REFERENC
18d0: 45 53 20 66 69 6c 65 2c 20 20 20 20 20 2d 2d 20  ES file,     -- 
18e0: 46 69 6c 65 20 74 68 65 20 69 74 65 6d 20 62 65  File the item be
18f0: 6c 6f 6e 67 73 20 74 6f 0a 09 20 20 20 20 6c 6f  longs to..    lo
1900: 64 20 20 20 49 4e 54 45 47 45 52 20 20 20 20 20  d   INTEGER     
1910: 20 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45         REFERENCE
1920: 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 20 4c  S symbol,   -- L
1930: 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d 65  ine of developme
1940: 6e 74 20 28 4e 55 4c 4c 20 3d 3e 20 54 72 75 6e  nt (NULL => Trun
1950: 6b 29 0a 0a 09 20 20 20 20 73 69 64 20 20 20 49  k)...    sid   I
1960: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1970: 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d    REFERENCES sym
1980: 62 6f 6c 2c 20 20 20 2d 2d 20 53 79 6d 62 6f 6c  bol,   -- Symbol
1990: 20 63 61 70 74 75 72 69 6e 67 20 74 68 65 20 62   capturing the b
19a0: 72 61 6e 63 68 0a 0a 09 20 20 20 20 72 6f 6f 74  ranch...    root
19b0: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
19c0: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
19d0: 72 65 76 69 73 69 6f 6e 2c 20 2d 2d 20 52 65 76  revision, -- Rev
19e0: 69 73 69 6f 6e 20 74 68 65 20 62 72 61 6e 63 68  ision the branch
19f0: 20 73 70 72 6f 75 74 73 20 66 72 6f 6d 0a 09 20   sprouts from.. 
1a00: 20 20 20 66 69 72 73 74 20 49 4e 54 45 47 45 52     first INTEGER
1a10: 20 20 20 20 20 20 20 20 20 20 20 20 52 45 46 45              REFE
1a20: 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c  RENCES revision,
1a30: 20 2d 2d 20 46 69 72 73 74 20 72 65 76 69 73 69   -- First revisi
1a40: 6f 6e 20 63 6f 6d 6d 69 74 74 65 64 20 74 6f 20  on committed to 
1a50: 74 68 65 20 62 72 61 6e 63 68 0a 09 20 20 20 20  the branch..    
1a60: 62 72 61 20 20 20 54 45 58 54 20 20 20 20 20 4e  bra   TEXT     N
1a70: 4f 54 20 4e 55 4c 4c 20 20 20 20 20 20 20 20 20  OT NULL         
1a80: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d                --
1a90: 20 62 72 61 6e 63 68 20 6e 75 6d 62 65 72 0a 09   branch number..
1aa0: 7d 0a 0a 09 23 20 50 72 6f 6a 65 63 74 20 6c 65  }...# Project le
1ab0: 76 65 6c 20 2e 2e 2e 0a 09 23 09 70 4c 69 6e 65  vel .....#.pLine
1ac0: 4f 66 44 65 76 65 6c 6f 70 6d 65 6e 74 2c 20 70  OfDevelopment, p
1ad0: 53 79 6d 62 6f 6c 2c 20 70 42 72 61 6e 63 68 2c  Symbol, pBranch,
1ae0: 20 70 54 61 67 2c 20 70 54 72 75 6e 6b 0a 09 23   pTag, pTrunk..#
1af0: 0a 09 23 09 70 54 72 75 6e 6b 20 20 3c 2d 20 70  ..#.pTrunk  <- p
1b00: 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d 65 6e  LineOfDevelopmen
1b10: 74 0a 09 23 09 70 42 72 61 6e 63 68 20 3c 2d 20  t..#.pBranch <- 
1b20: 70 53 79 6d 62 6f 6c 2c 20 70 4c 69 6e 65 4f 66  pSymbol, pLineOf
1b30: 44 65 76 65 6c 6f 70 6d 65 6e 74 0a 09 23 09 70  Development..#.p
1b40: 54 61 67 20 20 20 20 3c 2d 20 70 53 79 6d 62 6f  Tag    <- pSymbo
1b50: 6c 2c 20 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f  l, pLineOfDevelo
1b60: 70 6d 65 6e 74 0a 0a 09 73 74 61 74 65 20 77 72  pment...state wr
1b70: 69 74 69 6e 67 20 73 79 6d 62 6f 6c 20 7b 0a 09  iting symbol {..
1b80: 20 20 20 20 73 69 64 20 20 49 4e 54 45 47 45 52      sid  INTEGER
1b90: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d    NOT NULL  PRIM
1ba0: 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43 52  ARY KEY AUTOINCR
1bb0: 45 4d 45 4e 54 2c 0a 09 20 20 20 20 70 69 64 20  EMENT,..    pid 
1bc0: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1bd0: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 70  LL  REFERENCES p
1be0: 72 6f 6a 65 63 74 2c 20 20 2d 2d 20 50 72 6f 6a  roject,  -- Proj
1bf0: 65 63 74 20 74 68 65 20 73 79 6d 62 6f 6c 20 62  ect the symbol b
1c00: 65 6c 6f 6e 67 73 20 74 6f 0a 09 20 20 20 20 6e  elongs to..    n
1c10: 61 6d 65 20 54 45 58 54 20 20 20 20 20 4e 4f 54  ame TEXT     NOT
1c20: 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 74 79 70 65   NULL,..    type
1c30: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
1c40: 4c 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20 20  LL,             
1c50: 20 20 20 20 20 20 20 20 20 2d 2d 20 65 6e 75 6d           -- enum
1c60: 20 7b 20 74 61 67 20 3d 20 31 2c 20 62 72 61 6e   { tag = 1, bran
1c70: 63 68 2c 20 75 6e 64 65 66 69 6e 65 64 20 7d 0a  ch, undefined }.
1c80: 0a 09 20 20 20 20 74 61 67 5f 63 6f 75 6e 74 20  ..    tag_count 
1c90: 20 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20     INTEGER  NOT 
1ca0: 4e 55 4c 4c 2c 20 2d 2d 20 48 6f 77 20 6f 66 74  NULL, -- How oft
1cb0: 65 6e 20 74 68 65 20 73 79 6d 62 6f 6c 20 69 73  en the symbol is
1cc0: 20 75 73 65 64 20 61 73 20 74 61 67 2e 0a 09 20   used as tag... 
1cd0: 20 20 20 62 72 61 6e 63 68 5f 63 6f 75 6e 74 20     branch_count 
1ce0: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1cf0: 4c 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20  L, -- How often 
1d00: 74 68 65 20 73 79 6d 62 6f 6c 20 69 73 20 75 73  the symbol is us
1d10: 65 64 20 61 73 20 62 72 61 6e 63 68 0a 09 20 20  ed as branch..  
1d20: 20 20 63 6f 6d 6d 69 74 5f 63 6f 75 6e 74 20 49    commit_count I
1d30: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1d40: 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 61  , -- How often a
1d50: 20 66 69 6c 65 20 77 61 73 20 63 6f 6d 6d 69 74   file was commit
1d60: 74 65 64 20 6f 6e 20 74 68 65 20 73 79 6d 62 6f  ted on the symbo
1d70: 6c 0a 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28  l...    UNIQUE (
1d80: 70 69 64 2c 20 6e 61 6d 65 29 20 2d 2d 20 53 79  pid, name) -- Sy
1d90: 6d 62 6f 6c 73 20 61 72 65 20 75 6e 69 71 75 65  mbols are unique
1da0: 20 77 69 74 68 69 6e 20 74 68 65 20 70 72 6f 6a   within the proj
1db0: 65 63 74 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77  ect..}...state w
1dc0: 72 69 74 69 6e 67 20 62 6c 6f 63 6b 65 72 20 7b  riting blocker {
1dd0: 0a 09 20 20 20 20 73 69 64 20 49 4e 54 45 47 45  ..    sid INTEGE
1de0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1df0: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
1e00: 2d 2d 20 0a 09 20 20 20 20 62 69 64 20 49 4e 54  -- ..    bid INT
1e10: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
1e20: 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f  REFERENCES symbo
1e30: 6c 2c 20 2d 2d 20 53 70 72 6f 75 74 65 64 20 66  l, -- Sprouted f
1e40: 72 6f 6d 20 73 69 64 2c 20 62 6c 6f 63 6b 73 20  rom sid, blocks 
1e50: 69 74 2e 0a 09 20 20 20 20 55 4e 49 51 55 45 20  it...    UNIQUE 
1e60: 28 73 69 64 2c 20 62 69 64 29 0a 09 7d 0a 0a 09  (sid, bid)..}...
1e70: 73 74 61 74 65 20 77 72 69 74 69 6e 67 20 70 61  state writing pa
1e80: 72 65 6e 74 20 7b 0a 09 20 20 20 20 73 69 64 20  rent {..    sid 
1e90: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1ea0: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79  L  REFERENCES sy
1eb0: 6d 62 6f 6c 2c 20 2d 2d 20 0a 09 20 20 20 20 70  mbol, -- ..    p
1ec0: 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20  id INTEGER  NOT 
1ed0: 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53  NULL  REFERENCES
1ee0: 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20 50 6f 73 73   symbol, -- Poss
1ef0: 69 62 6c 65 20 70 61 72 65 6e 74 20 6f 66 20 73  ible parent of s
1f00: 69 64 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28  id..    UNIQUE (
1f10: 73 69 64 2c 20 70 69 64 29 0a 09 7d 0a 0a 09 73  sid, pid)..}...s
1f20: 74 61 74 65 20 77 72 69 74 69 6e 67 20 6d 65 74  tate writing met
1f30: 61 20 7b 0a 09 20 20 20 20 2d 2d 20 4d 65 74 61  a {..    -- Meta
1f40: 20 64 61 74 61 20 6f 66 20 72 65 76 69 73 69 6f   data of revisio
1f50: 6e 73 2e 20 53 65 65 20 72 65 76 69 73 69 6f 6e  ns. See revision
1f60: 2e 6d 69 64 20 66 6f 72 20 74 68 65 0a 09 20 20  .mid for the..  
1f70: 20 20 2d 2d 20 72 65 66 65 72 65 6e 63 65 2e 20    -- reference. 
1f80: 4d 61 6e 79 20 72 65 76 69 73 69 6f 6e 73 20 63  Many revisions c
1f90: 61 6e 20 73 68 61 72 65 20 6d 65 74 61 20 64 61  an share meta da
1fa0: 74 61 2e 20 54 68 69 73 20 69 73 0a 09 20 20 20  ta. This is..   
1fb0: 20 2d 2d 20 61 63 74 75 61 6c 6c 79 20 6f 6e 65   -- actually one
1fc0: 20 6f 66 20 74 68 65 20 63 72 69 74 65 72 69 6f   of the criterio
1fd0: 6e 73 20 75 73 65 64 20 74 6f 20 73 6f 72 74 20  ns used to sort 
1fe0: 72 65 76 69 73 69 6f 6e 73 0a 09 20 20 20 20 2d  revisions..    -
1ff0: 2d 20 69 6e 74 6f 20 63 68 61 6e 67 65 73 65 74  - into changeset
2000: 73 2e 0a 0a 09 20 20 20 20 6d 69 64 20 49 4e 54  s....    mid INT
2010: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
2020: 50 52 49 4d 41 52 59 20 4b 45 59 20 20 41 55 54  PRIMARY KEY  AUT
2030: 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 0a 09 20 20  OINCREMENT,...  
2040: 20 20 2d 2d 20 4d 65 74 61 20 64 61 74 61 20 62    -- Meta data b
2050: 65 6c 6f 6e 67 73 20 74 6f 20 61 20 73 70 65 63  elongs to a spec
2060: 69 66 69 63 20 70 72 6f 6a 65 63 74 2c 20 73 74  ific project, st
2070: 72 6f 6e 67 65 72 2c 20 74 6f 20 61 0a 09 20 20  ronger, to a..  
2080: 20 20 2d 2d 20 62 72 61 6e 63 68 20 69 6e 20 74    -- branch in t
2090: 68 61 74 20 70 72 6f 6a 65 63 74 2e 20 49 74 20  hat project. It 
20a0: 66 75 72 74 68 65 72 20 68 61 73 20 61 20 6c 6f  further has a lo
20b0: 67 20 6d 65 73 73 61 67 65 2c 0a 09 20 20 20 20  g message,..    
20c0: 2d 2d 20 61 6e 64 20 69 74 73 20 61 75 74 68 6f  -- and its autho
20d0: 72 2e 20 54 68 69 73 20 69 73 20 75 6e 69 71 75  r. This is uniqu
20e0: 65 20 77 69 74 68 20 74 68 65 20 70 72 6f 6a 65  e with the proje
20f0: 63 74 20 61 6e 64 0a 09 20 20 20 20 2d 2d 20 62  ct and..    -- b
2100: 72 61 6e 63 68 2e 0a 0a 09 20 20 20 20 70 69 64  ranch....    pid
2110: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
2120: 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 70  LL  REFERENCES p
2130: 72 6f 6a 65 63 74 2c 20 20 2d 2d 0a 09 20 20 20  roject,  --..   
2140: 20 62 69 64 20 49 4e 54 45 47 45 52 20 20 4e 4f   bid INTEGER  NO
2150: 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45 4e 43  T NULL  REFERENC
2160: 45 53 20 73 79 6d 62 6f 6c 2c 20 20 20 2d 2d 0a  ES symbol,   --.
2170: 09 20 20 20 20 61 69 64 20 49 4e 54 45 47 45 52  .    aid INTEGER
2180: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
2190: 52 45 4e 43 45 53 20 61 75 74 68 6f 72 2c 20 20  RENCES author,  
21a0: 20 2d 2d 0a 09 20 20 20 20 63 69 64 20 49 4e 54   --..    cid INT
21b0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
21c0: 52 45 46 45 52 45 4e 43 45 53 20 63 6d 65 73 73  REFERENCES cmess
21d0: 61 67 65 2c 20 2d 2d 0a 0a 09 20 20 20 20 55 4e  age, --...    UN
21e0: 49 51 55 45 20 28 70 69 64 2c 20 62 69 64 2c 20  IQUE (pid, bid, 
21f0: 61 69 64 2c 20 63 69 64 29 0a 0a 09 20 20 20 20  aid, cid)...    
2200: 2d 2d 20 43 6f 6e 73 74 72 61 69 6e 74 73 3a 20  -- Constraints: 
2210: 54 68 65 20 70 72 6f 6a 65 63 74 20 6f 66 20 74  The project of t
2220: 68 65 20 6d 65 74 61 20 64 61 74 61 20 6f 66 20  he meta data of 
2230: 61 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20  a revision..    
2240: 2d 2d 20 20 20 20 20 20 20 20 20 20 20 20 20 20  --              
2250: 58 20 69 73 20 74 68 65 20 73 61 6d 65 20 61 73  X is the same as
2260: 20 74 68 65 20 70 72 6f 6a 65 63 74 20 6f 66 20   the project of 
2270: 58 20 69 74 73 65 6c 66 2e 0a 09 20 20 20 20 2d  X itself...    -
2280: 2d 0a 09 20 20 20 20 2d 2d 20 2e 2e 2e 2e 2e 2e  -..    -- ......
2290: 2e 2e 2e 2e 2e 2e 20 54 68 65 20 62 72 61 6e 63  ...... The branc
22a0: 68 20 6f 66 20 74 68 65 20 6d 65 74 61 20 64 61  h of the meta da
22b0: 74 61 20 6f 66 20 61 20 72 65 76 69 73 69 6f 6e  ta of a revision
22c0: 0a 09 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20  ..    --        
22d0: 20 20 20 20 20 20 58 20 69 73 20 74 68 65 20 73        X is the s
22e0: 61 6d 65 20 61 73 20 74 68 65 20 6c 69 6e 65 20  ame as the line 
22f0: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 0a 09  of development..
2300: 20 20 20 20 2d 2d 20 20 20 20 20 20 20 20 20 20      --          
2310: 20 20 20 20 6f 66 20 58 20 69 74 73 65 6c 66 2e      of X itself.
2320: 0a 09 7d 0a 0a 09 23 20 41 75 74 68 6f 72 73 20  ..}...# Authors 
2330: 61 6e 64 20 63 6f 6d 6d 69 74 20 6d 65 73 73 61  and commit messa
2340: 67 65 73 20 61 72 65 20 66 75 6c 6c 79 20 67 6c  ges are fully gl
2350: 6f 62 61 6c 2c 20 69 2e 65 2e 20 70 65 72 0a 09  obal, i.e. per..
2360: 23 20 72 65 70 6f 73 69 74 6f 72 79 2e 0a 0a 09  # repository....
2370: 73 74 61 74 65 20 77 72 69 74 69 6e 67 20 61 75  state writing au
2380: 74 68 6f 72 20 7b 0a 09 20 20 20 20 61 69 64 20  thor {..    aid 
2390: 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55   INTEGER  NOT NU
23a0: 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20  LL  PRIMARY KEY 
23b0: 20 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a   AUTOINCREMENT,.
23c0: 09 20 20 20 20 6e 61 6d 65 20 54 45 58 54 20 20  .    name TEXT  
23d0: 20 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 55 4e 49     NOT NULL  UNI
23e0: 51 55 45 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77  QUE..}...state w
23f0: 72 69 74 69 6e 67 20 63 6d 65 73 73 61 67 65 20  riting cmessage 
2400: 7b 0a 09 20 20 20 20 63 69 64 20 20 49 4e 54 45  {..    cid  INTE
2410: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50  GER  NOT NULL  P
2420: 52 49 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f  RIMARY KEY  AUTO
2430: 49 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20  INCREMENT,..    
2440: 74 65 78 74 20 54 45 58 54 20 20 20 20 20 4e 4f  text TEXT     NO
2450: 54 20 4e 55 4c 4c 20 20 55 4e 49 51 55 45 0a 09  T NULL  UNIQUE..
2460: 7d 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  }...return.    }
2470: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
2480: 20 6c 6f 61 64 20 7b 7d 20 7b 0a 09 23 20 54 4f   load {} {..# TO
2490: 44 4f 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  DO..return.    }
24a0: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
24b0: 20 72 75 6e 20 7b 7d 20 7b 0a 09 23 20 50 61 73   run {} {..# Pas
24c0: 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65 72 66  s manager interf
24d0: 61 63 65 2e 20 45 78 65 63 75 74 65 64 20 74 6f  ace. Executed to
24e0: 20 70 65 72 66 6f 72 6d 20 74 68 65 0a 09 23 20   perform the..# 
24f0: 66 75 6e 63 74 69 6f 6e 61 6c 69 74 79 20 6f 66  functionality of
2500: 20 74 68 65 20 70 61 73 73 2e 0a 0a 09 73 65 74   the pass....set
2510: 20 72 62 61 73 65 20 5b 72 65 70 6f 73 69 74 6f   rbase [reposito
2520: 72 79 20 62 61 73 65 3f 5d 0a 09 66 6f 72 65 61  ry base?]..forea
2530: 63 68 20 70 72 6f 6a 65 63 74 20 5b 72 65 70 6f  ch project [repo
2540: 73 69 74 6f 72 79 20 70 72 6f 6a 65 63 74 73 5d  sitory projects]
2550: 20 7b 0a 09 20 20 20 20 73 65 74 20 62 61 73 65   {..    set base
2560: 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 24 72 62 61   [file join $rba
2570: 73 65 20 5b 24 70 72 6f 6a 65 63 74 20 62 61 73  se [$project bas
2580: 65 5d 5d 0a 09 20 20 20 20 6c 6f 67 20 77 72 69  e]]..    log wri
2590: 74 65 20 31 20 63 6f 6c 6c 72 65 76 20 22 50 72  te 1 collrev "Pr
25a0: 6f 63 65 73 73 69 6e 67 20 24 62 61 73 65 22 0a  ocessing $base".
25b0: 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20 66 69  ..    foreach fi
25c0: 6c 65 20 5b 24 70 72 6f 6a 65 63 74 20 66 69 6c  le [$project fil
25d0: 65 73 5d 20 7b 0a 09 09 73 65 74 20 70 61 74 68  es] {...set path
25e0: 20 5b 24 66 69 6c 65 20 70 61 74 68 5d 0a 09 09   [$file path]...
25f0: 6c 6f 67 20 77 72 69 74 65 20 32 20 63 6f 6c 6c  log write 2 coll
2600: 72 65 76 20 22 50 61 72 73 69 6e 67 20 24 70 61  rev "Parsing $pa
2610: 74 68 22 0a 09 09 69 66 20 7b 5b 63 61 74 63 68  th"...if {[catch
2620: 20 7b 0a 09 09 20 20 20 20 70 61 72 73 65 72 20   {...    parser 
2630: 70 72 6f 63 65 73 73 20 5b 66 69 6c 65 20 6a 6f  process [file jo
2640: 69 6e 20 24 62 61 73 65 20 24 70 61 74 68 5d 20  in $base $path] 
2650: 24 66 69 6c 65 0a 09 09 7d 20 6d 73 67 5d 7d 20  $file...} msg]} 
2660: 7b 0a 09 09 20 20 20 20 67 6c 6f 62 61 6c 20 65  {...    global e
2670: 72 72 6f 72 43 6f 64 65 0a 09 09 20 20 20 20 69  rrorCode...    i
2680: 66 20 7b 24 65 72 72 6f 72 43 6f 64 65 20 65 71  f {$errorCode eq
2690: 20 22 76 63 3a 3a 72 63 73 3a 3a 70 61 72 73 65   "vc::rcs::parse
26a0: 72 22 7d 20 7b 0a 09 09 09 74 72 6f 75 62 6c 65  r"} {....trouble
26b0: 20 66 61 74 61 6c 20 22 24 70 61 74 68 20 69 73   fatal "$path is
26c0: 20 6e 6f 74 20 61 20 76 61 6c 69 64 20 52 43 53   not a valid RCS
26d0: 20 61 72 63 68 69 76 65 20 28 24 6d 73 67 29 22   archive ($msg)"
26e0: 0a 09 09 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a  ...    } else {.
26f0: 09 09 09 67 6c 6f 62 61 6c 20 65 72 72 6f 72 49  ...global errorI
2700: 6e 66 6f 0a 09 09 09 74 72 6f 75 62 6c 65 20 69  nfo....trouble i
2710: 6e 74 65 72 6e 61 6c 20 24 65 72 72 6f 72 49 6e  nternal $errorIn
2720: 66 6f 0a 09 09 20 20 20 20 7d 0a 09 09 7d 20 65  fo...    }...} e
2730: 6c 73 65 20 7b 0a 09 09 20 20 20 20 23 20 57 65  lse {...    # We
2740: 20 70 65 72 73 69 73 74 20 74 68 65 20 63 6f 72   persist the cor
2750: 65 20 6f 66 20 74 68 65 20 64 61 74 61 20 63 6f  e of the data co
2760: 6c 6c 65 63 74 65 64 20 61 62 6f 75 74 0a 09 09  llected about...
2770: 20 20 20 20 23 20 65 61 63 68 20 66 69 6c 65 20      # each file 
2780: 69 6d 6d 65 64 69 61 74 65 6c 79 20 61 66 74 65  immediately afte
2790: 72 20 69 74 20 68 61 73 20 62 65 65 6e 20 70 61  r it has been pa
27a0: 72 73 65 64 0a 09 09 20 20 20 20 23 20 61 6e 64  rsed...    # and
27b0: 20 77 72 61 6e 67 6c 65 64 20 69 6e 74 6f 20 73   wrangled into s
27c0: 68 61 70 65 2c 20 61 6e 64 20 74 68 65 6e 20 64  hape, and then d
27d0: 72 6f 70 20 69 74 20 66 72 6f 6d 0a 09 09 20 20  rop it from...  
27e0: 20 20 23 20 6d 65 6d 6f 72 79 2e 20 54 68 69 73    # memory. This
27f0: 20 69 73 20 64 6f 6e 65 20 74 6f 20 6b 65 65 70   is done to keep
2800: 20 74 68 65 20 61 6d 6f 75 6e 74 20 6f 66 0a 09   the amount of..
2810: 09 20 20 20 20 23 20 72 65 71 75 69 72 65 64 20  .    # required 
2820: 6d 65 6d 6f 72 79 20 77 69 74 68 69 6e 20 73 65  memory within se
2830: 6e 73 69 62 6c 65 20 6c 69 6d 69 74 73 2e 20 57  nsible limits. W
2840: 69 74 68 6f 75 74 0a 09 09 20 20 20 20 23 20 64  ithout...    # d
2850: 6f 69 6e 67 20 69 74 20 74 68 69 73 20 77 61 79  oing it this way
2860: 20 77 65 20 77 6f 75 6c 64 20 65 61 73 69 6c 79   we would easily
2870: 20 67 6f 62 62 6c 65 20 75 70 20 31 47 0a 09 09   gobble up 1G...
2880: 20 20 20 20 23 20 6f 66 20 52 41 4d 20 6f 72 20      # of RAM or 
2890: 6d 6f 72 65 20 77 69 74 68 20 61 6c 6c 20 74 68  more with all th
28a0: 65 20 6f 62 6a 65 63 74 73 20 28 72 65 76 69 73  e objects (revis
28b0: 69 6f 6e 73 0a 09 09 20 20 20 20 23 20 61 6e 64  ions...    # and
28c0: 20 66 69 6c 65 2d 6c 65 76 65 6c 20 73 79 6d 62   file-level symb
28d0: 6f 6c 73 29 2e 0a 0a 09 09 20 20 20 20 24 66 69  ols).....    $fi
28e0: 6c 65 20 70 65 72 73 69 73 74 0a 09 09 7d 0a 0a  le persist...}..
28f0: 09 09 24 66 69 6c 65 20 64 72 6f 70 0a 09 20 20  ..$file drop..  
2900: 20 20 7d 0a 09 7d 0a 0a 09 72 65 70 6f 73 69 74    }..}...reposit
2910: 6f 72 79 20 70 72 69 6e 74 72 65 76 73 74 61 74  ory printrevstat
2920: 69 73 74 69 63 73 0a 09 72 65 70 6f 73 69 74 6f  istics..reposito
2930: 72 79 20 70 65 72 73 69 73 74 72 65 76 0a 0a 09  ry persistrev...
2940: 6c 6f 67 20 77 72 69 74 65 20 31 20 63 6f 6c 6c  log write 1 coll
2950: 72 65 76 20 22 53 63 61 6e 20 63 6f 6d 70 6c 65  rev "Scan comple
2960: 74 65 64 22 0a 09 50 61 72 61 6e 6f 69 61 0a 09  ted"..Paranoia..
2970: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
2980: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 64 69 73    typemethod dis
2990: 63 61 72 64 20 7b 7d 20 7b 0a 09 23 20 50 61 73  card {} {..# Pas
29a0: 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65 72 66  s manager interf
29b0: 61 63 65 2e 20 45 78 65 63 75 74 65 64 20 66 6f  ace. Executed fo
29c0: 72 20 61 6c 6c 20 70 61 73 73 65 73 20 61 66 74  r all passes aft
29d0: 65 72 20 74 68 65 0a 09 23 20 72 75 6e 20 70 61  er the..# run pa
29e0: 73 73 65 73 2c 20 74 6f 20 72 65 6d 6f 76 65 20  sses, to remove 
29f0: 61 6c 6c 20 64 61 74 61 20 6f 66 20 74 68 69 73  all data of this
2a00: 20 70 61 73 73 20 66 72 6f 6d 20 74 68 65 20 73   pass from the s
2a10: 74 61 74 65 2c 0a 09 23 20 61 73 20 62 65 69 6e  tate,..# as bein
2a20: 67 20 6f 75 74 20 6f 66 20 64 61 74 65 2e 0a 0a  g out of date...
2a30: 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20 72  .state discard r
2a40: 65 76 69 73 69 6f 6e 0a 09 73 74 61 74 65 20 64  evision..state d
2a50: 69 73 63 61 72 64 20 74 61 67 0a 09 73 74 61 74  iscard tag..stat
2a60: 65 20 64 69 73 63 61 72 64 20 62 72 61 6e 63 68  e discard branch
2a70: 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20  ..state discard 
2a80: 73 79 6d 62 6f 6c 0a 09 73 74 61 74 65 20 64 69  symbol..state di
2a90: 73 63 61 72 64 20 62 6c 6f 63 6b 65 72 0a 09 73  scard blocker..s
2aa0: 74 61 74 65 20 64 69 73 63 61 72 64 20 70 61 72  tate discard par
2ab0: 65 6e 74 0a 09 73 74 61 74 65 20 64 69 73 63 61  ent..state disca
2ac0: 72 64 20 6d 65 74 61 0a 09 73 74 61 74 65 20 64  rd meta..state d
2ad0: 69 73 63 61 72 64 20 61 75 74 68 6f 72 0a 09 73  iscard author..s
2ae0: 74 61 74 65 20 64 69 73 63 61 72 64 20 63 6d 65  tate discard cme
2af0: 73 73 61 67 65 0a 09 72 65 74 75 72 6e 0a 20 20  ssage..return.  
2b00: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 61    }..    proc Pa
2b10: 72 61 6e 6f 69 61 20 7b 7d 20 7b 0a 09 23 20 54  ranoia {} {..# T
2b20: 68 69 73 20 63 6f 64 65 20 70 65 72 66 6f 72 6d  his code perform
2b30: 73 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 70 61  s a number of pa
2b40: 72 61 6e 6f 69 64 20 63 68 65 63 6b 73 20 6f 66  ranoid checks of
2b50: 20 74 68 65 0a 09 23 20 64 61 74 61 62 61 73 65   the..# database
2b60: 20 66 6f 72 20 69 6e 63 6f 6e 73 69 73 74 65 6e   for inconsisten
2b70: 74 20 63 72 6f 73 73 2d 72 65 66 65 72 65 6e 63  t cross-referenc
2b80: 65 73 2e 0a 09 6c 6f 67 20 77 72 69 74 65 20 34  es...log write 4
2b90: 20 63 6f 6c 6c 72 65 76 20 7b 43 68 65 63 6b 20   collrev {Check 
2ba0: 64 61 74 61 62 61 73 65 20 63 6f 6e 73 69 73 74  database consist
2bb0: 65 6e 63 79 7d 0a 0a 09 23 0a 09 23 20 20 20 20  ency}...#..#    
2bc0: 2b 2d 3e 20 53 79 6d 62 6f 6c 20 2d 2d 2d 2d 2d  +-> Symbol -----
2bd0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2b 0a 09  -------------+..
2be0: 23 20 20 20 20 7c 20 20 20 20 20 20 5e 20 20 20  #    |      ^   
2bf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2c00: 20 20 7c 20 5b 31 5d 0a 09 23 20 20 20 20 7c 20    | [1]..#    | 
2c10: 20 20 20 20 20 7c 20 20 20 20 20 20 20 20 20 20       |          
2c20: 20 20 20 20 20 20 20 20 20 20 20 56 0a 09 23 20             V..# 
2c30: 20 20 20 7c 20 20 20 52 65 76 69 73 69 6f 6e 20     |   Revision 
2c40: 2d 2d 3e 20 46 69 6c 65 20 2d 2d 3e 20 50 72 6f  --> File --> Pro
2c50: 6a 65 63 74 0a 09 23 20 20 20 20 7c 20 5b 33 5d  ject..#    | [3]
2c60: 20 20 7c 20 20 20 20 20 20 20 20 20 20 20 20 20    |             
2c70: 20 20 20 20 20 20 20 20 5e 0a 09 23 20 20 20 20          ^..#    
2c80: 7c 20 20 20 20 20 20 56 20 20 20 20 20 20 20 20  |      V        
2c90: 20 20 20 20 20 20 20 20 20 20 20 20 20 7c 20 5b               | [
2ca0: 32 5d 0a 09 23 20 20 20 20 2b 2d 2d 2d 20 4d 65  2]..#    +--- Me
2cb0: 74 61 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ta -------------
2cc0: 2d 2d 2d 2d 2d 2d 2b 0a 09 23 0a 0a 09 73 65 74  ------+..#...set
2cd0: 20 6e 20 30 0a 0a 09 23 20 46 69 6e 64 20 61 6c   n 0...# Find al
2ce0: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63  l revisions whic
2cf0: 68 20 64 69 73 61 67 72 65 65 20 77 69 74 68 20  h disagree with 
2d00: 74 68 65 69 72 20 6c 69 6e 65 20 6f 66 0a 09 23  their line of..#
2d10: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 61 62 6f   development abo
2d20: 75 74 20 74 68 65 20 70 72 6f 6a 65 63 74 20 74  ut the project t
2d30: 68 65 79 20 61 72 65 20 6f 77 6e 65 64 20 62 79  hey are owned by
2d40: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
2d50: 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74  {Revisions and t
2d60: 68 65 69 72 20 4c 4f 44 73 20 68 61 76 65 20 74  heir LODs have t
2d70: 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65  o be in the same
2d80: 20 70 72 6f 6a 65 63 74 7d 20 5c 0a 09 20 20 20   project} \..   
2d90: 20 7b 64 69 73 61 67 72 65 65 73 20 77 69 74 68   {disagrees with
2da0: 20 69 74 73 20 4c 4f 44 20 61 62 6f 75 74 20 6f   its LOD about o
2db0: 77 6e 69 6e 67 20 70 72 6f 6a 65 63 74 7d 20 7b  wning project} {
2dc0: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65  ...SELECT F.name
2dd0: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72  , R.rev...FROM r
2de0: 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20  evision R, file 
2df0: 46 2c 20 73 79 6d 62 6f 6c 20 53 0a 09 09 57 48  F, symbol S...WH
2e00: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
2e10: 64 0a 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20  d...AND   R.lod 
2e20: 3d 20 53 2e 73 69 64 0a 09 09 41 4e 44 20 20 20  = S.sid...AND   
2e30: 46 2e 70 69 64 20 21 3d 20 53 2e 70 69 64 0a 09  F.pid != S.pid..
2e40: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
2e50: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
2e60: 77 68 69 63 68 20 64 69 73 67 72 65 65 20 77 69  which disgree wi
2e70: 74 68 20 74 68 65 69 72 20 6d 65 74 61 20 64 61  th their meta da
2e80: 74 61 20 61 62 6f 75 74 0a 09 23 20 74 68 65 20  ta about..# the 
2e90: 70 72 6f 6a 65 63 74 20 74 68 65 79 20 61 72 65  project they are
2ea0: 20 6f 77 6e 65 64 20 62 79 2e 0a 09 43 68 65 63   owned by...Chec
2eb0: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
2ec0: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 6d 65  ons and their me
2ed0: 74 61 20 64 61 74 61 20 68 61 76 65 20 74 6f 20  ta data have to 
2ee0: 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 70  be in the same p
2ef0: 72 6f 6a 65 63 74 7d 20 5c 0a 09 20 20 20 20 7b  roject} \..    {
2f00: 64 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69  disagrees with i
2f10: 74 73 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f  ts meta data abo
2f20: 75 74 20 6f 77 6e 69 6e 67 20 70 72 6f 6a 65 63  ut owning projec
2f30: 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e  t} {...SELECT F.
2f40: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
2f50: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66  OM revision R, f
2f60: 69 6c 65 20 46 2c 20 6d 65 74 61 20 4d 0a 09 09  ile F, meta M...
2f70: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e  WHERE R.fid = F.
2f80: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 6d 69  fid...AND   R.mi
2f90: 64 20 3d 20 4d 2e 6d 69 64 0a 09 09 41 4e 44 20  d = M.mid...AND 
2fa0: 20 20 46 2e 70 69 64 20 21 3d 20 4d 2e 70 69 64    F.pid != M.pid
2fb0: 0a 09 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46  ...;..    }..# F
2fc0: 69 6e 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  ind all revision
2fd0: 73 20 77 68 69 63 68 20 64 69 73 67 72 65 65 20  s which disgree 
2fe0: 77 69 74 68 20 74 68 65 69 72 20 6d 65 74 61 20  with their meta 
2ff0: 64 61 74 61 20 61 62 6f 75 74 0a 09 23 20 74 68  data about..# th
3000: 65 20 62 72 61 6e 63 68 2f 6c 69 6e 65 20 6f 66  e branch/line of
3010: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65   development the
3020: 79 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68  y belong to...Ch
3030: 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69  eck \..    {Revi
3040: 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20  sions and their 
3050: 6d 65 74 61 20 64 61 74 61 20 68 61 76 65 20 74  meta data have t
3060: 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65  o be in the same
3070: 20 4c 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 64 69   LOD} \..    {di
3080: 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74 73  sagrees with its
3090: 20 6d 65 74 61 20 64 61 74 61 20 61 62 6f 75 74   meta data about
30a0: 20 6f 77 6e 69 6e 67 20 4c 4f 44 7d 20 7b 0a 09   owning LOD} {..
30b0: 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20  .SELECT F.name, 
30c0: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76  R.rev...FROM rev
30d0: 69 73 69 6f 6e 20 52 2c 20 6d 65 74 61 20 4d 2c  ision R, meta M,
30e0: 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20   file F...WHERE 
30f0: 52 2e 6d 69 64 20 3d 20 4d 2e 6d 69 64 0a 09 09  R.mid = M.mid...
3100: 41 4e 44 20 20 20 52 2e 6c 6f 64 20 21 3d 20 4d  AND   R.lod != M
3110: 2e 62 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 66  .bid...AND   R.f
3120: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 3b 0a 09  id = F.fid...;..
3130: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
3140: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68  l revisions with
3150: 20 61 20 63 68 69 6c 64 20 77 68 69 63 68 20 64   a child which d
3160: 69 73 61 67 72 65 65 73 20 61 62 6f 75 74 20 74  isagrees about t
3170: 68 65 0a 09 23 20 66 69 6c 65 20 74 68 65 79 20  he..# file they 
3180: 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63  belong to...Chec
3190: 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73 69  k \..    {Revisi
31a0: 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 63 68  ons and their ch
31b0: 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20 62  ildren have to b
31c0: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 66 69  e in the same fi
31d0: 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 64 69 73 61  le} \..    {disa
31e0: 67 72 65 65 73 20 77 69 74 68 20 69 74 73 20 63  grees with its c
31f0: 68 69 6c 64 20 61 62 6f 75 74 20 74 68 65 20 6f  hild about the o
3200: 77 6e 69 6e 67 20 66 69 6c 65 7d 20 7b 0a 09 09  wning file} {...
3210: 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52  SELECT F.name, R
3220: 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69  .rev...FROM revi
3230: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
3240: 20 43 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   C, file F...WHE
3250: 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  RE R.fid = F.fid
3260: 0a 09 09 41 4e 44 20 20 20 52 2e 63 68 69 6c 64  ...AND   R.child
3270: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41   IS NOT NULL...A
3280: 4e 44 20 20 20 52 2e 63 68 69 6c 64 20 3d 20 43  ND   R.child = C
3290: 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e 66  .rid...AND   C.f
32a0: 69 64 20 21 3d 20 52 2e 66 69 64 0a 09 09 3b 0a  id != R.fid...;.
32b0: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
32c0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74  ll revisions wit
32d0: 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69  h a non-NTDB chi
32e0: 6c 64 20 77 68 69 63 68 20 64 69 73 61 67 72 65  ld which disagre
32f0: 65 73 0a 09 23 20 61 62 6f 75 74 20 74 68 65 20  es..# about the 
3300: 66 69 6c 65 20 74 68 65 79 20 62 65 6c 6f 6e 67  file they belong
3310: 20 74 6f 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20   to...Check \.. 
3320: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e     {Revisions an
3330: 64 20 74 68 65 69 72 20 6e 6f 6e 2d 4e 54 44 42  d their non-NTDB
3340: 20 63 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74   children have t
3350: 6f 20 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65  o be in the same
3360: 20 66 69 6c 65 7d 20 5c 0a 09 20 20 20 20 7b 64   file} \..    {d
3370: 69 73 61 67 72 65 65 73 20 77 69 74 68 20 69 74  isagrees with it
3380: 73 20 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64  s non-NTDB child
3390: 20 61 62 6f 75 74 20 74 68 65 20 6f 77 6e 69 6e   about the ownin
33a0: 67 20 66 69 6c 65 7d 20 7b 0a 09 09 53 45 4c 45  g file} {...SELE
33b0: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
33c0: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
33d0: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20   R, revision C, 
33e0: 66 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52  file F...WHERE R
33f0: 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41  .fid = F.fid...A
3400: 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49  ND   R.dbchild I
3410: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44  S NOT NULL...AND
3420: 20 20 20 52 2e 64 62 63 68 69 6c 64 20 3d 20 43     R.dbchild = C
3430: 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e 66  .rid...AND   C.f
3440: 69 64 20 21 3d 20 52 2e 66 69 64 0a 09 09 3b 0a  id != R.fid...;.
3450: 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61  .    }..# Find a
3460: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69  ll revisions whi
3470: 63 68 20 68 61 76 65 20 61 20 63 68 69 6c 64 2c  ch have a child,
3480: 20 62 75 74 20 74 68 65 20 63 68 69 6c 64 20 64   but the child d
3490: 6f 65 73 0a 09 23 20 6e 6f 74 20 68 61 76 65 20  oes..# not have 
34a0: 74 68 65 6d 20 61 73 20 70 61 72 65 6e 74 2e 0a  them as parent..
34b0: 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b 52  .Check \..    {R
34c0: 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20 74 6f  evisions have to
34d0: 20 62 65 20 70 61 72 65 6e 74 73 20 6f 66 20 74   be parents of t
34e0: 68 65 69 72 20 63 68 69 6c 64 72 65 6e 7d 20 5c  heir children} \
34f0: 0a 09 20 20 20 20 7b 69 73 20 6e 6f 74 20 74 68  ..    {is not th
3500: 65 20 70 61 72 65 6e 74 20 6f 66 20 69 74 73 20  e parent of its 
3510: 63 68 69 6c 64 7d 20 7b 0a 09 09 53 45 4c 45 43  child} {...SELEC
3520: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
3530: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
3540: 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66  R, revision C, f
3550: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e  ile F...WHERE R.
3560: 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e  fid = F.fid...AN
3570: 44 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e  D   R.child IS N
3580: 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20  OT NULL...AND   
3590: 52 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a  R.child = C.rid.
35a0: 09 09 41 4e 44 20 20 20 43 2e 70 61 72 65 6e 74  ..AND   C.parent
35b0: 20 21 3d 20 52 2e 72 69 64 0a 09 09 3b 0a 09 20   != R.rid...;.. 
35c0: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
35d0: 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68   revisions which
35e0: 20 68 61 76 65 20 61 20 63 68 69 6c 64 2c 20 62   have a child, b
35f0: 75 74 20 74 68 65 20 63 68 69 6c 64 20 68 61 73  ut the child has
3600: 20 61 0a 09 23 20 62 72 61 6e 63 68 20 70 61 72   a..# branch par
3610: 65 6e 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  ent...Check \.. 
3620: 20 20 20 7b 52 65 76 69 73 69 6f 6e 27 73 20 63     {Revision's c
3630: 68 69 6c 64 72 65 6e 20 6d 75 73 74 20 6e 6f 74  hildren must not
3640: 20 62 65 20 62 72 61 6e 63 68 20 73 74 61 72 74   be branch start
3650: 65 72 73 7d 20 5c 0a 09 20 20 20 20 7b 69 73 20  ers} \..    {is 
3660: 70 61 72 65 6e 74 20 6f 66 20 61 20 63 68 69 6c  parent of a chil
3670: 64 20 77 68 69 63 68 20 69 73 20 74 68 65 20 62  d which is the b
3680: 65 67 69 6e 6e 69 6e 67 20 6f 66 20 61 20 62 72  eginning of a br
3690: 61 6e 63 68 7d 20 7b 0a 09 09 53 45 4c 45 43 54  anch} {...SELECT
36a0: 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09   F.name, R.rev..
36b0: 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52  .FROM revision R
36c0: 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69  , revision C, fi
36d0: 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66  le F...WHERE R.f
36e0: 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44  id = F.fid...AND
36f0: 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f     R.child IS NO
3700: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
3710: 2e 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09  .child = C.rid..
3720: 09 41 4e 44 20 20 20 43 2e 62 70 61 72 65 6e 74  .AND   C.bparent
3730: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 3b   IS NOT NULL...;
3740: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
3750: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
3760: 74 68 6f 75 74 20 62 72 61 6e 63 68 20 70 61 72  thout branch par
3770: 65 6e 74 20 77 68 69 63 68 20 68 61 76 65 20 61  ent which have a
3780: 0a 09 23 20 70 61 72 65 6e 74 2c 20 62 75 74 20  ..# parent, but 
3790: 74 68 65 20 70 61 72 65 6e 74 20 64 6f 65 73 20  the parent does 
37a0: 6e 6f 74 20 68 61 76 65 20 74 68 65 6d 20 61 73  not have them as
37b0: 20 63 68 69 6c 64 2e 0a 09 43 68 65 63 6b 20 5c   child...Check \
37c0: 0a 09 20 20 20 20 7b 52 65 76 69 73 69 6f 6e 73  ..    {Revisions
37d0: 20 68 61 76 65 20 74 6f 20 62 65 20 63 68 69 6c   have to be chil
37e0: 64 72 65 6e 20 6f 66 20 74 68 65 69 72 20 70 61  dren of their pa
37f0: 72 65 6e 74 73 7d 20 5c 0a 09 20 20 20 20 7b 69  rents} \..    {i
3800: 73 20 6e 6f 74 20 74 68 65 20 63 68 69 6c 64 20  s not the child 
3810: 6f 66 20 69 74 73 20 70 61 72 65 6e 74 7d 20 7b  of its parent} {
3820: 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61 6d 65  ...SELECT F.name
3830: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72  , R.rev...FROM r
3840: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73  evision R, revis
3850: 69 6f 6e 20 50 2c 20 66 69 6c 65 20 46 0a 09 09  ion P, file F...
3860: 57 48 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e  WHERE R.fid = F.
3870: 66 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70  fid...AND   R.bp
3880: 61 72 65 6e 74 20 49 53 20 4e 55 4c 4c 0a 09 09  arent IS NULL...
3890: 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 49  AND   R.parent I
38a0: 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44  S NOT NULL...AND
38b0: 20 20 20 52 2e 70 61 72 65 6e 74 20 3d 20 50 2e     R.parent = P.
38c0: 72 69 64 0a 09 09 41 4e 44 20 20 20 50 2e 63 68  rid...AND   P.ch
38d0: 69 6c 64 20 21 3d 20 52 2e 72 69 64 0a 09 09 3b  ild != R.rid...;
38e0: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
38f0: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
3900: 74 68 20 61 20 62 72 61 6e 63 68 20 70 61 72 65  th a branch pare
3910: 6e 74 20 77 68 69 63 68 20 64 6f 20 6e 6f 74 20  nt which do not 
3920: 68 61 76 65 20 61 0a 09 23 20 70 61 72 65 6e 74  have a..# parent
3930: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
3940: 7b 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67  {Branch starting
3950: 20 72 65 76 69 73 69 6f 6e 73 20 68 61 76 65 20   revisions have 
3960: 74 6f 20 68 61 76 65 20 61 20 70 61 72 65 6e 74  to have a parent
3970: 7d 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65  } \..    {at the
3980: 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74   beginning of it
3990: 73 20 62 72 61 6e 63 68 20 68 61 73 20 6e 6f 20  s branch has no 
39a0: 70 61 72 65 6e 74 7d 20 7b 0a 09 09 53 45 4c 45  parent} {...SELE
39b0: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
39c0: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
39d0: 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   R, file F...WHE
39e0: 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  RE R.fid = F.fid
39f0: 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65  ...AND   R.bpare
3a00: 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09  nt IS NOT NULL..
3a10: 09 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20  .AND   R.parent 
3a20: 49 53 20 4e 55 4c 4c 0a 09 09 3b 0a 09 20 20 20  IS NULL...;..   
3a30: 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72   }..# Find all r
3a40: 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20  evisions with a 
3a50: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 77 68  branch parent wh
3a60: 6f 73 65 20 70 61 72 65 6e 74 20 68 61 73 0a 09  ose parent has..
3a70: 23 20 74 68 65 6d 20 61 73 20 63 68 69 6c 64 2e  # them as child.
3a80: 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20 7b  ..Check \..    {
3a90: 42 72 61 6e 63 68 20 73 74 61 72 74 69 6e 67 20  Branch starting 
3aa0: 72 65 76 69 73 69 6f 6e 73 20 6d 75 73 74 20 6e  revisions must n
3ab0: 6f 74 20 62 65 20 63 68 69 6c 64 72 65 6e 20 6f  ot be children o
3ac0: 66 20 74 68 65 69 72 20 70 61 72 65 6e 74 73 7d  f their parents}
3ad0: 20 5c 0a 09 20 20 20 20 7b 61 74 20 74 68 65 20   \..    {at the 
3ae0: 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 69 74 73  beginning of its
3af0: 20 62 72 61 6e 63 68 20 69 73 20 74 68 65 20 63   branch is the c
3b00: 68 69 6c 64 20 6f 66 20 69 74 73 20 70 61 72 65  hild of its pare
3b10: 6e 74 7d 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  nt} {...SELECT F
3b20: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46  .name, R.rev...F
3b30: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  ROM revision R, 
3b40: 72 65 76 69 73 69 6f 6e 20 50 2c 20 66 69 6c 65  revision P, file
3b50: 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69 64   F...WHERE R.fid
3b60: 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20 20   = F.fid...AND  
3b70: 20 52 2e 62 70 61 72 65 6e 74 20 49 53 20 4e 4f   R.bparent IS NO
3b80: 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52  T NULL...AND   R
3b90: 2e 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e  .parent IS NOT N
3ba0: 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e 70 61  ULL...AND   R.pa
3bb0: 72 65 6e 74 20 3d 20 50 2e 63 68 69 6c 64 0a 09  rent = P.child..
3bc0: 09 3b 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e  .;..    }..# Fin
3bd0: 64 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20  d all revisions 
3be0: 77 69 74 68 20 61 20 6e 6f 6e 2d 4e 54 44 42 20  with a non-NTDB 
3bf0: 63 68 69 6c 64 20 77 68 69 63 68 20 61 72 65 20  child which are 
3c00: 6e 6f 74 20 6f 6e 0a 09 23 20 74 68 65 20 4e 54  not on..# the NT
3c10: 44 42 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20  DB...Check \..  
3c20: 20 20 7b 4e 54 44 42 20 74 6f 20 74 72 75 6e 6b    {NTDB to trunk
3c30: 20 74 72 61 6e 73 69 74 69 6f 6e 20 68 61 73 20   transition has 
3c40: 74 6f 20 62 65 67 69 6e 20 6f 6e 20 4e 54 44 42  to begin on NTDB
3c50: 7d 20 5c 0a 09 20 20 20 20 7b 68 61 73 20 61 20  } \..    {has a 
3c60: 6e 6f 6e 2d 4e 54 44 42 20 63 68 69 6c 64 2c 20  non-NTDB child, 
3c70: 79 65 74 20 69 73 20 6e 6f 74 20 6f 6e 20 74 68  yet is not on th
3c80: 65 20 4e 54 44 42 7d 20 7b 0a 09 09 53 45 4c 45  e NTDB} {...SELE
3c90: 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  CT F.name, R.rev
3ca0: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
3cb0: 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45   R, file F...WHE
3cc0: 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64  RE R.fid = F.fid
3cd0: 0a 09 09 41 4e 44 20 20 20 52 2e 64 62 63 68 69  ...AND   R.dbchi
3ce0: 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09  ld IS NOT NULL..
3cf0: 09 41 4e 44 20 20 20 4e 4f 54 20 52 2e 69 73 64  .AND   NOT R.isd
3d00: 65 66 61 75 6c 74 0a 09 09 3b 0a 09 20 20 20 20  efault...;..    
3d10: 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65  }..# Find all re
3d20: 76 69 73 69 6f 6e 73 20 77 69 74 68 20 61 20 4e  visions with a N
3d30: 54 44 42 20 70 61 72 65 6e 74 20 77 68 69 63 68  TDB parent which
3d40: 20 61 72 65 20 6f 6e 20 74 68 65 20 4e 54 44 42   are on the NTDB
3d50: 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20 20 20 20  ...Check \..    
3d60: 7b 4e 54 44 42 20 74 6f 20 74 72 75 6e 6b 20 74  {NTDB to trunk t
3d70: 72 61 6e 73 69 74 69 6f 6e 20 68 61 73 20 74 6f  ransition has to
3d80: 20 65 6e 64 20 6f 6e 20 6e 6f 6e 2d 4e 54 44 42   end on non-NTDB
3d90: 7d 20 5c 0a 09 20 20 20 20 7b 68 61 73 20 61 20  } \..    {has a 
3da0: 4e 54 44 42 20 70 61 72 65 6e 74 2c 20 79 65 74  NTDB parent, yet
3db0: 20 69 73 20 6f 6e 20 74 68 65 20 4e 54 44 42 7d   is on the NTDB}
3dc0: 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 6e 61   {...SELECT F.na
3dd0: 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d  me, R.rev...FROM
3de0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c   revision R, fil
3df0: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69  e F...WHERE R.fi
3e00: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20  d = F.fid...AND 
3e10: 20 20 52 2e 64 62 70 61 72 65 6e 74 20 49 53 20    R.dbparent IS 
3e20: 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20  NOT NULL...AND  
3e30: 20 52 2e 69 73 64 65 66 61 75 6c 74 0a 09 09 3b   R.isdefault...;
3e40: 0a 09 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20  ..    }..# Find 
3e50: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69  all revisions wi
3e60: 74 68 20 61 20 63 68 69 6c 64 20 77 68 69 63 68  th a child which
3e70: 20 64 69 73 61 67 72 65 65 73 20 61 62 6f 75 74   disagrees about
3e80: 20 74 68 65 0a 09 23 20 6c 69 6e 65 20 6f 66 20   the..# line of 
3e90: 64 65 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79  development they
3ea0: 20 62 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65   belong to...Che
3eb0: 63 6b 20 5c 0a 09 20 20 20 20 7b 52 65 76 69 73  ck \..    {Revis
3ec0: 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 20 63  ions and their c
3ed0: 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20  hildren have to 
3ee0: 62 65 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c  be in the same L
3ef0: 4f 44 7d 20 5c 0a 09 20 20 20 20 7b 61 6e 64 20  OD} \..    {and 
3f00: 69 74 73 20 63 68 69 6c 64 20 64 69 73 61 67 72  its child disagr
3f10: 65 65 20 61 62 6f 75 74 20 74 68 65 69 72 20 4c  ee about their L
3f20: 4f 44 7d 20 7b 0a 0a 09 09 53 45 4c 45 43 54 20  OD} {....SELECT 
3f30: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
3f40: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
3f50: 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66 69 6c   revision C, fil
3f60: 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e 66 69  e F...WHERE R.fi
3f70: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20  d = F.fid...AND 
3f80: 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54    R.child IS NOT
3f90: 20 4e 55 4c 4c 0a 09 09 41 4e 44 20 20 20 52 2e   NULL...AND   R.
3fa0: 63 68 69 6c 64 20 3d 20 43 2e 72 69 64 0a 09 09  child = C.rid...
3fb0: 41 4e 44 20 20 20 43 2e 6c 6f 64 20 21 3d 20 52  AND   C.lod != R
3fc0: 2e 6c 6f 64 0a 09 09 3b 0a 09 20 20 20 20 7d 0a  .lod...;..    }.
3fd0: 09 23 20 46 69 6e 64 20 61 6c 6c 20 72 65 76 69  .# Find all revi
3fe0: 73 69 6f 6e 73 20 77 69 74 68 20 61 20 6e 6f 6e  sions with a non
3ff0: 2d 4e 54 44 42 20 63 68 69 6c 64 20 77 68 69 63  -NTDB child whic
4000: 68 20 61 67 72 65 65 73 20 61 62 6f 75 74 0a 09  h agrees about..
4010: 23 20 74 68 65 20 6c 69 6e 65 20 6f 66 20 64 65  # the line of de
4020: 76 65 6c 6f 70 6d 65 6e 74 20 74 68 65 79 20 62  velopment they b
4030: 65 6c 6f 6e 67 20 74 6f 2e 0a 09 43 68 65 63 6b  elong to...Check
4040: 20 5c 0a 09 20 20 20 20 7b 4e 54 44 42 20 61 6e   \..    {NTDB an
4050: 64 20 74 72 75 6e 6b 20 72 65 76 69 73 69 6f 6e  d trunk revision
4060: 73 20 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20  s have to be in 
4070: 64 69 66 66 65 72 65 6e 74 20 4c 4f 44 73 7d 20  different LODs} 
4080: 5c 0a 09 20 20 20 20 7b 6f 6e 20 4e 54 44 42 20  \..    {on NTDB 
4090: 61 6e 64 20 69 74 73 20 6e 6f 6e 2d 4e 54 44 42  and its non-NTDB
40a0: 20 63 68 69 6c 64 20 77 72 6f 6e 67 6c 79 20 61   child wrongly a
40b0: 67 72 65 65 20 61 62 6f 75 74 20 74 68 65 69 72  gree about their
40c0: 20 4c 4f 44 7d 20 7b 0a 0a 09 09 53 45 4c 45 43   LOD} {....SELEC
40d0: 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  T F.name, R.rev.
40e0: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
40f0: 52 2c 20 72 65 76 69 73 69 6f 6e 20 43 2c 20 66  R, revision C, f
4100: 69 6c 65 20 46 0a 09 09 57 48 45 52 45 20 52 2e  ile F...WHERE R.
4110: 66 69 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e  fid = F.fid...AN
4120: 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53  D   R.dbchild IS
4130: 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09 41 4e 44 20   NOT NULL...AND 
4140: 20 20 52 2e 64 62 63 68 69 6c 64 20 3d 20 43 2e    R.dbchild = C.
4150: 72 69 64 0a 09 09 41 4e 44 20 20 20 43 2e 6c 6f  rid...AND   C.lo
4160: 64 20 3d 20 52 2e 6c 6f 64 0a 09 09 3b 0a 09 20  d = R.lod...;.. 
4170: 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c 6c     }..# Find all
4180: 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68 20   revisions with 
4190: 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20  a branch parent 
41a0: 77 68 69 63 68 20 69 73 20 6e 6f 74 20 74 68 65  which is not the
41b0: 69 72 0a 09 23 20 6c 69 6e 65 20 6f 66 20 64 65  ir..# line of de
41c0: 76 65 6c 6f 70 6d 65 6e 74 2e 0a 09 43 68 65 63  velopment...Chec
41d0: 6b 20 5c 0a 09 20 20 20 20 7b 42 72 61 6e 63 68  k \..    {Branch
41e0: 20 73 74 61 72 74 69 6e 67 20 72 65 76 69 73 69   starting revisi
41f0: 6f 6e 73 20 68 61 76 65 20 74 6f 20 68 61 76 65  ons have to have
4200: 20 74 68 65 69 72 20 4c 4f 44 20 61 73 20 62 72   their LOD as br
4210: 61 6e 63 68 20 70 61 72 65 6e 74 7d 20 5c 0a 09  anch parent} \..
4220: 20 20 20 20 7b 61 74 20 74 68 65 20 62 65 67 69      {at the begi
4230: 6e 6e 69 6e 67 20 6f 66 20 69 74 73 20 62 72 61  nning of its bra
4240: 6e 63 68 20 64 6f 65 73 20 6e 6f 74 20 68 61 76  nch does not hav
4250: 65 20 74 68 65 20 62 72 61 6e 63 68 20 61 73 20  e the branch as 
4260: 69 74 73 20 4c 4f 44 7d 20 7b 0a 09 09 53 45 4c  its LOD} {...SEL
4270: 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  ECT F.name, R.re
4280: 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f  v...FROM revisio
4290: 6e 20 52 2c 20 66 69 6c 65 20 46 0a 09 09 57 48  n R, file F...WH
42a0: 45 52 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69  ERE R.fid = F.fi
42b0: 64 0a 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72  d...AND   R.bpar
42c0: 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a  ent IS NOT NULL.
42d0: 09 09 41 4e 44 20 20 20 52 2e 6c 6f 64 20 21 3d  ..AND   R.lod !=
42e0: 20 52 2e 62 70 61 72 65 6e 74 0a 09 09 3b 0a 09   R.bparent...;..
42f0: 20 20 20 20 7d 0a 09 23 20 46 69 6e 64 20 61 6c      }..# Find al
4300: 6c 20 72 65 76 69 73 69 6f 6e 73 20 77 69 74 68  l revisions with
4310: 20 61 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74   a branch parent
4320: 20 77 68 6f 73 65 20 70 61 72 65 6e 74 20 69 73   whose parent is
4330: 20 69 6e 0a 09 23 20 74 68 65 20 73 61 6d 65 20   in..# the same 
4340: 6c 69 6e 65 20 6f 66 20 64 65 76 65 6c 6f 70 6d  line of developm
4350: 65 6e 74 2e 0a 09 43 68 65 63 6b 20 5c 0a 09 20  ent...Check \.. 
4360: 20 20 20 7b 52 65 76 69 73 69 6f 6e 73 20 61 6e     {Revisions an
4370: 64 20 74 68 65 69 72 20 62 72 61 6e 63 68 20 63  d their branch c
4380: 68 69 6c 64 72 65 6e 20 68 61 76 65 20 74 6f 20  hildren have to 
4390: 62 65 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20  be in different 
43a0: 4c 4f 44 73 7d 20 5c 0a 09 20 20 20 20 7b 61 74  LODs} \..    {at
43b0: 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f   the beginning o
43c0: 66 20 69 74 73 20 62 72 61 6e 63 68 20 61 6e 64  f its branch and
43d0: 20 69 74 73 20 70 61 72 65 6e 74 20 77 72 6f 6e   its parent wron
43e0: 67 6c 79 20 61 67 72 65 65 20 61 62 6f 75 74 20  gly agree about 
43f0: 74 68 65 69 72 20 4c 4f 44 7d 20 7b 0a 09 09 53  their LOD} {...S
4400: 45 4c 45 43 54 20 46 2e 6e 61 6d 65 2c 20 52 2e  ELECT F.name, R.
4410: 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73  rev...FROM revis
4420: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
4430: 50 2c 20 66 69 6c 65 20 46 0a 09 09 57 48 45 52  P, file F...WHER
4440: 45 20 52 2e 66 69 64 20 3d 20 46 2e 66 69 64 0a  E R.fid = F.fid.
4450: 09 09 41 4e 44 20 20 20 52 2e 62 70 61 72 65 6e  ..AND   R.bparen
4460: 74 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 0a 09 09  t IS NOT NULL...
4470: 41 4e 44 20 20 20 52 2e 70 61 72 65 6e 74 20 3d  AND   R.parent =
4480: 20 50 2e 72 69 64 0a 09 09 41 4e 44 20 20 20 52   P.rid...AND   R
4490: 2e 6c 6f 64 20 3d 20 50 2e 6c 6f 64 0a 09 09 3b  .lod = P.lod...;
44a0: 0a 09 20 20 20 20 7d 0a 09 72 65 74 75 72 6e 0a  ..    }..return.
44b0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20      }..    proc 
44c0: 43 68 65 63 6b 20 7b 68 65 61 64 65 72 20 6c 61  Check {header la
44d0: 62 65 6c 20 73 71 6c 7d 20 7b 0a 09 75 70 76 61  bel sql} {..upva
44e0: 72 20 31 20 6e 20 6e 0a 09 73 65 74 20 6f 6b 20  r 1 n n..set ok 
44f0: 31 0a 09 66 6f 72 65 61 63 68 20 7b 66 6e 61 6d  1..foreach {fnam
4500: 65 20 72 65 76 6e 72 7d 20 5b 73 74 61 74 65 20  e revnr} [state 
4510: 72 75 6e 20 24 73 71 6c 5d 20 7b 0a 09 20 20 20  run $sql] {..   
4520: 20 73 65 74 20 6f 6b 20 30 0a 09 20 20 20 20 74   set ok 0..    t
4530: 72 6f 75 62 6c 65 20 66 61 74 61 6c 20 22 24 66  rouble fatal "$f
4540: 6e 61 6d 65 20 3c 24 72 65 76 6e 72 3e 20 24 6c  name <$revnr> $l
4550: 61 62 65 6c 22 0a 09 7d 0a 09 6c 6f 67 20 77 72  abel"..}..log wr
4560: 69 74 65 20 35 20 63 6f 6c 6c 72 65 76 20 22 5c  ite 5 collrev "\
4570: 5b 5b 66 6f 72 6d 61 74 20 25 30 32 64 20 5b 69  [[format %02d [i
4580: 6e 63 72 20 6e 5d 5d 5c 5d 20 5b 65 78 70 72 20  ncr n]]\] [expr 
4590: 7b 24 6f 6b 20 3f 20 22 4f 6b 20 20 20 20 22 20  {$ok ? "Ok    " 
45a0: 3a 20 22 46 61 69 6c 65 64 22 7d 5d 20 2e 2e 2e  : "Failed"}] ...
45b0: 20 24 68 65 61 64 65 72 22 0a 09 72 65 74 75 72   $header"..retur
45c0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23  n.    }..    # #
45d0: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
45e0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
45f0: 23 23 23 23 0a 20 20 20 20 23 23 20 49 6e 74 65  ####.    ## Inte
4600: 72 6e 61 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20  rnal methods..  
4610: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
4620: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
4630: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
4640: 20 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a   Configuration..
4650: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69      pragma -hasi
4660: 6e 73 74 61 6e 63 65 73 20 20 20 6e 6f 20 3b 20  nstances   no ; 
4670: 23 20 73 69 6e 67 6c 65 74 6f 6e 0a 20 20 20 20  # singleton.    
4680: 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65 69  pragma -hastypei
4690: 6e 66 6f 20 20 20 20 6e 6f 20 3b 20 23 20 6e 6f  nfo    no ; # no
46a0: 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20   introspection. 
46b0: 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79     pragma -hasty
46c0: 70 65 64 65 73 74 72 6f 79 20 6e 6f 20 3b 20 23  pedestroy no ; #
46d0: 20 69 6d 6d 6f 72 74 61 6c 0a 0a 20 20 20 20 23   immortal..    #
46e0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
46f0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
4700: 23 23 23 23 23 23 0a 7d 0a 0a 6e 61 6d 65 73 70  ######.}..namesp
4710: 61 63 65 20 65 76 61 6c 20 3a 3a 76 63 3a 3a 66  ace eval ::vc::f
4720: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
4730: 76 73 3a 3a 70 61 73 73 20 7b 0a 20 20 20 20 6e  vs::pass {.    n
4740: 61 6d 65 73 70 61 63 65 20 65 78 70 6f 72 74 20  amespace export 
4750: 63 6f 6c 6c 72 65 76 0a 20 20 20 20 6e 61 6d 65  collrev.    name
4760: 73 70 61 63 65 20 65 76 61 6c 20 63 6f 6c 6c 72  space eval collr
4770: 65 76 20 7b 0a 09 6e 61 6d 65 73 70 61 63 65 20  ev {..namespace 
4780: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 72 63 73  import ::vc::rcs
4790: 3a 3a 70 61 72 73 65 72 0a 09 6e 61 6d 65 73 70  ::parser..namesp
47a0: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
47b0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
47c0: 3a 63 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72 79  :cvs::repository
47d0: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
47e0: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  rt ::vc::fossil:
47f0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74  :import::cvs::st
4800: 61 74 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ate..namespace i
4810: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c  mport ::vc::tool
4820: 73 3a 3a 74 72 6f 75 62 6c 65 0a 09 6e 61 6d 65  s::trouble..name
4830: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
4840: 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c  c::tools::log..l
4850: 6f 67 20 72 65 67 69 73 74 65 72 20 63 6f 6c 6c  og register coll
4860: 72 65 76 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23  rev.    }.}..# #
4870: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
4880: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
4890: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
48a0: 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65  ##########.## Re
48b0: 61 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f  ady..package pro
48c0: 76 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a  vide vc::fossil:
48d0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61  :import::cvs::pa
48e0: 73 73 3a 3a 63 6f 6c 6c 72 65 76 20 31 2e 30 0a  ss::collrev 1.0.
48f0: 72 65 74 75 72 6e 0a                             return.