Hex Artifact Content
Not logged in

Artifact a41e2628dd39f79f3167df233cb6ce663d05ef0c:

File tools/cvs2fossil/lib/c2f_pcollrev.tcl part of check-in [adf168e23e] - Extended handling of id's for files so that we have them for backreferences from symbols and revisions. Completed persistence of revisions and symbols at file-level and fixed small problem with left-over links to branches. by aku on 2007-10-24 08:01:01.

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 72 69 64 20 20 49 4e 54 45 47 45  .    rid  INTEGE
09f0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49  R  NOT NULL  PRI
0a00: 4d 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43  MARY KEY AUTOINC
0a10: 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 66 69 64  REMENT,..    fid
0a20: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
0a30: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
0a40: 66 69 6c 65 2c 20 20 20 2d 2d 20 46 69 6c 65 20  file,   -- File 
0a50: 74 68 65 20 69 74 65 6d 20 62 65 6c 6f 6e 67 73  the item belongs
0a60: 20 74 6f 0a 09 20 20 20 20 6c 6f 64 20 20 49 4e   to..    lod  IN
0a70: 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20  TEGER           
0a80: 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62   REFERENCES symb
0a90: 6f 6c 2c 20 2d 2d 20 4c 69 6e 65 20 6f 66 20 64  ol, -- Line of d
0aa0: 65 76 65 6c 6f 70 6d 65 6e 74 20 28 4e 55 4c 4c  evelopment (NULL
0ab0: 20 3d 3e 20 54 72 75 6e 6b 29 0a 0a 09 20 20 20   => Trunk)...   
0ac0: 20 2d 2d 20 54 68 65 20 74 61 67 73 20 61 6e 64   -- The tags and
0ad0: 20 62 72 61 6e 63 68 65 73 20 62 65 6c 6f 6e 67   branches belong
0ae0: 69 6e 67 20 74 6f 20 61 20 72 65 76 69 73 69 6f  ing to a revisio
0af0: 6e 20 63 61 6e 20 62 65 0a 09 20 20 20 20 2d 2d  n can be..    --
0b00: 20 64 65 74 65 72 6d 69 6e 65 64 20 62 79 20 73   determined by s
0b10: 65 6c 65 63 74 69 6e 67 20 6f 6e 20 74 68 65 20  electing on the 
0b20: 62 61 63 6b 72 65 66 65 72 65 6e 63 65 73 20 69  backreferences i
0b30: 6e 20 74 68 65 0a 09 20 20 20 20 2d 2d 20 74 61  n the..    -- ta
0b40: 67 20 61 6e 64 20 62 72 61 6e 63 68 20 74 61 62  g and branch tab
0b50: 6c 65 73 2e 0a 0a 09 20 20 20 20 72 65 76 20 20  les....    rev  
0b60: 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55   TEXT     NOT NU
0b70: 4c 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20 20  LL,             
0b80: 20 20 20 20 2d 2d 20 72 65 76 69 73 69 6f 6e 20      -- revision 
0b90: 6e 75 6d 62 65 72 0a 09 20 20 20 20 64 61 74 65  number..    date
0ba0: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
0bb0: 55 4c 4c 2c 20 20 20 20 20 20 20 20 20 20 20 20  ULL,            
0bc0: 20 20 20 20 20 2d 2d 20 64 61 74 65 20 6f 66 20       -- date of 
0bd0: 65 6e 74 72 79 2c 20 73 65 63 6f 6e 64 73 20 73  entry, seconds s
0be0: 69 6e 63 65 20 65 70 6f 63 68 0a 09 20 20 20 20  ince epoch..    
0bf0: 73 74 61 74 65 20 54 45 58 54 20 20 20 20 20 4e  state TEXT     N
0c00: 4f 54 20 4e 55 4c 4c 2c 20 20 20 20 20 20 20 20  OT NULL,        
0c10: 20 20 20 20 20 20 20 20 20 2d 2d 20 73 74 61 74           -- stat
0c20: 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 20  e of revision.. 
0c30: 20 20 20 6d 69 64 20 20 20 49 4e 54 45 47 45 52     mid   INTEGER
0c40: 20 20 4e 4f 54 20 4e 55 4c 4c 20 52 45 46 45 52    NOT NULL REFER
0c50: 45 4e 43 45 53 20 6d 65 74 61 2c 20 2d 2d 20 6d  ENCES meta, -- m
0c60: 65 74 61 20 64 61 74 61 20 28 61 75 74 68 6f 72  eta data (author
0c70: 2c 20 63 6f 6d 6d 69 74 20 6d 65 73 73 61 67 65  , commit message
0c80: 29 0a 09 20 20 20 20 63 73 20 20 20 20 49 4e 54  )..    cs    INT
0c90: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20  EGER  NOT NULL, 
0ca0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0cb0: 2d 2d 20 52 65 76 69 73 69 6f 6e 20 63 6f 6e 74  -- Revision cont
0cc0: 65 6e 74 20 61 73 20 6f 66 66 73 65 74 20 61 6e  ent as offset an
0cd0: 64 0a 09 20 20 20 20 63 6c 20 20 20 20 49 4e 54  d..    cl    INT
0ce0: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20  EGER  NOT NULL, 
0cf0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0d00: 2d 2d 20 6c 65 6e 67 74 68 20 69 6e 74 6f 20 74  -- length into t
0d10: 68 65 20 61 72 63 68 69 76 65 20 66 69 6c 65 2e  he archive file.
0d20: 0a 0a 09 20 20 20 20 2d 2d 20 44 65 72 69 76 65  ...    -- Derive
0d30: 64 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20 61  d information, a
0d40: 6e 64 20 6c 69 6e 6b 73 0a 09 20 20 20 20 2d 2d  nd links..    --
0d50: 20 42 61 73 69 63 3a 20 50 61 72 65 6e 74 2f 43   Basic: Parent/C
0d60: 68 69 6c 64 0a 09 20 20 20 20 2d 2d 20 4e 54 44  hild..    -- NTD
0d70: 42 3a 20 20 44 65 66 61 75 6c 74 50 61 72 65 6e  B:  DefaultParen
0d80: 74 2f 44 65 66 61 75 6c 74 43 68 69 6c 64 0a 09  t/DefaultChild..
0d90: 20 20 20 20 2d 2d 20 42 72 61 6e 63 68 65 73 3a      -- Branches:
0da0: 20 42 72 61 6e 63 68 20 70 61 72 65 6e 74 20 72   Branch parent r
0db0: 65 76 69 73 69 6f 6e 0a 0a 09 20 20 20 20 6f 70  evision...    op
0dc0: 20 20 20 20 20 20 20 20 49 4e 54 45 47 45 52 20          INTEGER 
0dd0: 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20 69  NOT NULL,..    i
0de0: 73 64 65 66 61 75 6c 74 20 49 4e 54 45 47 45 52  sdefault INTEGER
0df0: 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 09 20 20 20 20   NOT NULL,..    
0e00: 70 61 72 65 6e 74 20 20 20 20 49 4e 54 45 47 45  parent    INTEGE
0e10: 52 20 20 20 20 20 20 20 20 52 45 46 45 52 45 4e  R        REFEREN
0e20: 43 45 53 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20  CES revision,.. 
0e30: 20 20 20 63 68 69 6c 64 20 20 20 20 20 49 4e 54     child     INT
0e40: 45 47 45 52 20 20 20 20 20 20 20 20 52 45 46 45  EGER        REFE
0e50: 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 2c  RENCES revision,
0e60: 0a 09 20 20 20 20 64 62 70 61 72 65 6e 74 20 20  ..    dbparent  
0e70: 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 52  INTEGER        R
0e80: 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69  EFERENCES revisi
0e90: 6f 6e 2c 0a 09 20 20 20 20 64 62 63 68 69 6c 64  on,..    dbchild
0ea0: 20 20 20 49 4e 54 45 47 45 52 20 20 20 20 20 20     INTEGER      
0eb0: 20 20 52 45 46 45 52 45 4e 43 45 53 20 72 65 76    REFERENCES rev
0ec0: 69 73 69 6f 6e 2c 0a 09 20 20 20 20 62 70 61 72  ision,..    bpar
0ed0: 65 6e 74 20 20 20 49 4e 54 45 47 45 52 20 20 20  ent   INTEGER   
0ee0: 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53 20       REFERENCES 
0ef0: 73 79 6d 62 6f 6c 0a 09 7d 0a 0a 09 73 74 61 74  symbol..}...stat
0f00: 65 20 77 72 69 74 69 6e 67 20 74 61 67 20 7b 0a  e writing tag {.
0f10: 09 20 20 20 20 74 69 64 20 20 49 4e 54 45 47 45  .    tid  INTEGE
0f20: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49  R  NOT NULL  PRI
0f30: 4d 41 52 59 20 4b 45 59 20 41 55 54 4f 49 4e 43  MARY KEY AUTOINC
0f40: 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 66 69 64  REMENT,..    fid
0f50: 20 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e    INTEGER  NOT N
0f60: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
0f70: 66 69 6c 65 2c 20 20 20 20 20 2d 2d 20 46 69 6c  file,     -- Fil
0f80: 65 20 74 68 65 20 69 74 65 6d 20 62 65 6c 6f 6e  e the item belon
0f90: 67 73 20 74 6f 0a 09 20 20 20 20 6c 6f 64 20 20  gs to..    lod  
0fa0: 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 20  INTEGER         
0fb0: 20 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79     REFERENCES sy
0fc0: 6d 62 6f 6c 2c 20 20 20 2d 2d 20 4c 69 6e 65 20  mbol,   -- Line 
0fd0: 6f 66 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 28  of development (
0fe0: 4e 55 4c 4c 20 3d 3e 20 54 72 75 6e 6b 29 0a 0a  NULL => Trunk)..
0ff0: 09 20 20 20 20 73 69 64 20 20 49 4e 54 45 47 45  .    sid  INTEGE
1000: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
1010: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
1020: 20 20 2d 2d 20 53 79 6d 62 6f 6c 20 63 61 70 74    -- Symbol capt
1030: 75 72 69 6e 67 20 74 68 65 20 74 61 67 0a 0a 09  uring the tag...
1040: 20 20 20 20 72 65 76 20 20 49 4e 54 45 47 45 52      rev  INTEGER
1050: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
1060: 52 45 4e 43 45 53 20 72 65 76 69 73 69 6f 6e 20  RENCES revision 
1070: 20 2d 2d 20 54 68 65 20 72 65 76 69 73 69 6f 6e   -- The revision
1080: 20 62 65 69 6e 67 20 74 61 67 67 65 64 2e 0a 09   being tagged...
1090: 7d 0a 0a 09 73 74 61 74 65 20 77 72 69 74 69 6e  }...state writin
10a0: 67 20 62 72 61 6e 63 68 20 7b 0a 09 20 20 20 20  g branch {..    
10b0: 62 69 64 20 20 20 49 4e 54 45 47 45 52 20 20 4e  bid   INTEGER  N
10c0: 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59  OT NULL  PRIMARY
10d0: 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45   KEY AUTOINCREME
10e0: 4e 54 2c 0a 09 20 20 20 20 66 69 64 20 20 20 49  NT,..    fid   I
10f0: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
1100: 20 20 52 45 46 45 52 45 4e 43 45 53 20 66 69 6c    REFERENCES fil
1110: 65 2c 20 20 20 20 20 2d 2d 20 46 69 6c 65 20 74  e,     -- File t
1120: 68 65 20 69 74 65 6d 20 62 65 6c 6f 6e 67 73 20  he item belongs 
1130: 74 6f 0a 09 20 20 20 20 6c 6f 64 20 20 20 49 4e  to..    lod   IN
1140: 54 45 47 45 52 20 20 20 20 20 20 20 20 20 20 20  TEGER           
1150: 20 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62   REFERENCES symb
1160: 6f 6c 2c 20 20 20 2d 2d 20 4c 69 6e 65 20 6f 66  ol,   -- Line of
1170: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 28 4e 55   development (NU
1180: 4c 4c 20 3d 3e 20 54 72 75 6e 6b 29 0a 0a 09 20  LL => Trunk)... 
1190: 20 20 20 73 69 64 20 20 20 49 4e 54 45 47 45 52     sid   INTEGER
11a0: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45    NOT NULL  REFE
11b0: 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 20  RENCES symbol,  
11c0: 20 2d 2d 20 53 79 6d 62 6f 6c 20 63 61 70 74 75   -- Symbol captu
11d0: 72 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68 0a  ring the branch.
11e0: 0a 09 20 20 20 20 72 6f 6f 74 20 20 49 4e 54 45  ..    root  INTE
11f0: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52  GER  NOT NULL  R
1200: 45 46 45 52 45 4e 43 45 53 20 72 65 76 69 73 69  EFERENCES revisi
1210: 6f 6e 2c 20 2d 2d 20 52 65 76 69 73 69 6f 6e 20  on, -- Revision 
1220: 74 68 65 20 62 72 61 6e 63 68 20 73 70 72 6f 75  the branch sprou
1230: 74 73 20 66 72 6f 6d 0a 09 20 20 20 20 66 69 72  ts from..    fir
1240: 73 74 20 49 4e 54 45 47 45 52 20 20 20 20 20 20  st INTEGER      
1250: 20 20 20 20 20 20 52 45 46 45 52 45 4e 43 45 53        REFERENCES
1260: 20 72 65 76 69 73 69 6f 6e 2c 20 2d 2d 20 46 69   revision, -- Fi
1270: 72 73 74 20 72 65 76 69 73 69 6f 6e 20 63 6f 6d  rst revision com
1280: 6d 69 74 74 65 64 20 74 6f 20 74 68 65 20 62 72  mitted to the br
1290: 61 6e 63 68 0a 09 20 20 20 20 62 72 61 20 20 20  anch..    bra   
12a0: 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55 4c  TEXT     NOT NUL
12b0: 4c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  L               
12c0: 20 20 20 20 20 20 20 20 2d 2d 20 62 72 61 6e 63          -- branc
12d0: 68 20 6e 75 6d 62 65 72 0a 09 7d 0a 0a 09 23 20  h number..}...# 
12e0: 49 74 20 69 73 20 69 6e 20 70 72 69 6e 63 69 70  It is in princip
12f0: 6c 65 20 70 6f 73 73 69 62 6c 65 20 74 6f 20 63  le possible to c
1300: 6f 6c 6c 61 70 73 65 20 74 68 65 20 66 6f 75 72  ollapse the four
1310: 20 74 61 62 6c 65 73 0a 09 23 20 61 62 6f 76 65   tables..# above
1320: 20 28 66 72 6f 6d 20 69 74 65 6d 20 74 6f 20 62   (from item to b
1330: 61 72 6e 63 68 29 20 69 6e 74 6f 20 61 20 73 69  arnch) into a si
1340: 6e 67 6c 65 20 74 61 62 6c 65 2c 20 77 69 74 68  ngle table, with
1350: 0a 09 23 20 73 69 6d 69 6c 61 72 20 63 6f 6c 75  ..# similar colu
1360: 6d 6e 73 20 6d 65 72 67 65 64 2c 20 61 6e 64 20  mns merged, and 
1370: 75 6e 75 73 65 64 20 63 6f 6c 75 6d 6e 73 20 61  unused columns a
1380: 6c 6c 6f 77 69 6e 67 20 4e 55 4c 4c 2c 0a 09 23  llowing NULL,..#
1390: 20 74 68 65 20 75 73 65 20 64 65 74 65 72 6d 69   the use determi
13a0: 6e 65 64 20 62 79 20 74 68 65 20 74 79 70 65 2e  ned by the type.
13b0: 20 57 65 20 6d 61 79 20 64 6f 20 74 68 61 74 20   We may do that 
13c0: 69 66 20 74 68 65 0a 09 23 20 70 65 72 66 6f 72  if the..# perfor
13d0: 6d 61 6e 63 65 20 69 73 20 6e 6f 74 20 67 6f 6f  mance is not goo
13e0: 64 20 65 6e 6f 75 67 68 2c 20 62 75 74 20 66 6f  d enough, but fo
13f0: 72 20 6e 6f 77 20 63 6c 61 72 69 74 79 20 6f 66  r now clarity of
1400: 0a 09 23 20 73 74 72 75 63 74 75 72 65 20 6f 76  ..# structure ov
1410: 65 72 20 65 66 66 69 63 69 65 6e 63 79 2e 0a 0a  er efficiency...
1420: 09 23 20 50 72 6f 6a 65 63 74 20 6c 65 76 65 6c  .# Project level
1430: 20 2e 2e 2e 0a 09 23 09 70 4c 69 6e 65 4f 66 44   .....#.pLineOfD
1440: 65 76 65 6c 6f 70 6d 65 6e 74 2c 20 70 53 79 6d  evelopment, pSym
1450: 62 6f 6c 2c 20 70 42 72 61 6e 63 68 2c 20 70 54  bol, pBranch, pT
1460: 61 67 2c 20 70 54 72 75 6e 6b 0a 09 23 0a 09 23  ag, pTrunk..#..#
1470: 09 70 54 72 75 6e 6b 20 20 3c 2d 20 70 4c 69 6e  .pTrunk  <- pLin
1480: 65 4f 66 44 65 76 65 6c 6f 70 6d 65 6e 74 0a 09  eOfDevelopment..
1490: 23 09 70 42 72 61 6e 63 68 20 3c 2d 20 70 53 79  #.pBranch <- pSy
14a0: 6d 62 6f 6c 2c 20 70 4c 69 6e 65 4f 66 44 65 76  mbol, pLineOfDev
14b0: 65 6c 6f 70 6d 65 6e 74 0a 09 23 09 70 54 61 67  elopment..#.pTag
14c0: 20 20 20 20 3c 2d 20 70 53 79 6d 62 6f 6c 2c 20      <- pSymbol, 
14d0: 70 4c 69 6e 65 4f 66 44 65 76 65 6c 6f 70 6d 65  pLineOfDevelopme
14e0: 6e 74 0a 0a 09 73 74 61 74 65 20 77 72 69 74 69  nt...state writi
14f0: 6e 67 20 73 79 6d 62 6f 6c 20 7b 0a 09 20 20 20  ng symbol {..   
1500: 20 73 69 64 20 20 49 4e 54 45 47 45 52 20 20 4e   sid  INTEGER  N
1510: 4f 54 20 4e 55 4c 4c 20 20 50 52 49 4d 41 52 59  OT NULL  PRIMARY
1520: 20 4b 45 59 20 41 55 54 4f 49 4e 43 52 45 4d 45   KEY AUTOINCREME
1530: 4e 54 2c 0a 09 20 20 20 20 70 69 64 20 20 49 4e  NT,..    pid  IN
1540: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
1550: 20 52 45 46 45 52 45 4e 43 45 53 20 70 72 6f 6a   REFERENCES proj
1560: 65 63 74 2c 20 20 2d 2d 20 50 72 6f 6a 65 63 74  ect,  -- Project
1570: 20 74 68 65 20 73 79 6d 62 6f 6c 20 62 65 6c 6f   the symbol belo
1580: 6e 67 73 20 74 6f 0a 09 20 20 20 20 6e 61 6d 65  ngs to..    name
1590: 20 54 45 58 54 20 20 20 20 20 4e 4f 54 20 4e 55   TEXT     NOT NU
15a0: 4c 4c 2c 0a 09 20 20 20 20 74 79 70 65 20 49 4e  LL,..    type IN
15b0: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c  TEGER  NOT NULL,
15c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15d0: 20 20 20 20 20 20 2d 2d 20 65 6e 75 6d 20 7b 20        -- enum { 
15e0: 74 61 67 20 3d 20 31 2c 20 62 72 61 6e 63 68 2c  tag = 1, branch,
15f0: 20 75 6e 64 65 66 69 6e 65 64 20 7d 0a 0a 09 20   undefined }... 
1600: 20 20 20 74 61 67 5f 63 6f 75 6e 74 20 20 20 20     tag_count    
1610: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1620: 4c 2c 20 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20  L, -- How often 
1630: 74 68 65 20 73 79 6d 62 6f 6c 20 69 73 20 75 73  the symbol is us
1640: 65 64 20 61 73 20 74 61 67 2e 0a 09 20 20 20 20  ed as tag...    
1650: 62 72 61 6e 63 68 5f 63 6f 75 6e 74 20 49 4e 54  branch_count INT
1660: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20  EGER  NOT NULL, 
1670: 2d 2d 20 48 6f 77 20 6f 66 74 65 6e 20 74 68 65  -- How often the
1680: 20 73 79 6d 62 6f 6c 20 69 73 20 75 73 65 64 20   symbol is used 
1690: 61 73 20 62 72 61 6e 63 68 0a 09 20 20 20 20 63  as branch..    c
16a0: 6f 6d 6d 69 74 5f 63 6f 75 6e 74 20 49 4e 54 45  ommit_count INTE
16b0: 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 2c 20 2d  GER  NOT NULL, -
16c0: 2d 20 48 6f 77 20 6f 66 74 65 6e 20 61 20 66 69  - How often a fi
16d0: 6c 65 20 77 61 73 20 63 6f 6d 6d 69 74 74 65 64  le was committed
16e0: 20 6f 6e 20 74 68 65 20 73 79 6d 62 6f 6c 0a 0a   on the symbol..
16f0: 09 20 20 20 20 55 4e 49 51 55 45 20 28 70 69 64  .    UNIQUE (pid
1700: 2c 20 6e 61 6d 65 29 20 2d 2d 20 53 79 6d 62 6f  , name) -- Symbo
1710: 6c 73 20 61 72 65 20 75 6e 69 71 75 65 20 77 69  ls are unique wi
1720: 74 68 69 6e 20 74 68 65 20 70 72 6f 6a 65 63 74  thin the project
1730: 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77 72 69 74  ..}...state writ
1740: 69 6e 67 20 62 6c 6f 63 6b 65 72 20 7b 0a 09 20  ing blocker {.. 
1750: 20 20 20 73 69 64 20 49 4e 54 45 47 45 52 20 20     sid INTEGER  
1760: 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46 45 52 45  NOT NULL  REFERE
1770: 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20 2d 2d 20  NCES symbol, -- 
1780: 0a 09 20 20 20 20 62 69 64 20 49 4e 54 45 47 45  ..    bid INTEGE
1790: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 52 45 46  R  NOT NULL  REF
17a0: 45 52 45 4e 43 45 53 20 73 79 6d 62 6f 6c 2c 20  ERENCES symbol, 
17b0: 2d 2d 20 53 70 72 6f 75 74 65 64 20 66 72 6f 6d  -- Sprouted from
17c0: 20 73 69 64 2c 20 62 6c 6f 63 6b 73 20 69 74 2e   sid, blocks it.
17d0: 0a 09 20 20 20 20 55 4e 49 51 55 45 20 28 73 69  ..    UNIQUE (si
17e0: 64 2c 20 62 69 64 29 0a 09 7d 0a 0a 09 73 74 61  d, bid)..}...sta
17f0: 74 65 20 77 72 69 74 69 6e 67 20 70 61 72 65 6e  te writing paren
1800: 74 20 7b 0a 09 20 20 20 20 73 69 64 20 49 4e 54  t {..    sid INT
1810: 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20  EGER  NOT NULL  
1820: 52 45 46 45 52 45 4e 43 45 53 20 73 79 6d 62 6f  REFERENCES symbo
1830: 6c 2c 20 2d 2d 20 0a 09 20 20 20 20 70 69 64 20  l, -- ..    pid 
1840: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1850: 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79  L  REFERENCES sy
1860: 6d 62 6f 6c 2c 20 2d 2d 20 50 6f 73 73 69 62 6c  mbol, -- Possibl
1870: 65 20 70 61 72 65 6e 74 20 6f 66 20 73 69 64 0a  e parent of sid.
1880: 09 20 20 20 20 55 4e 49 51 55 45 20 28 73 69 64  .    UNIQUE (sid
1890: 2c 20 70 69 64 29 0a 09 7d 0a 0a 09 73 74 61 74  , pid)..}...stat
18a0: 65 20 77 72 69 74 69 6e 67 20 6d 65 74 61 20 7b  e writing meta {
18b0: 0a 09 20 20 20 20 6d 69 64 20 49 4e 54 45 47 45  ..    mid INTEGE
18c0: 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52 49  R  NOT NULL  PRI
18d0: 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f 49 4e  MARY KEY  AUTOIN
18e0: 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 70 69  CREMENT,..    pi
18f0: 64 20 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e  d INTEGER  NOT N
1900: 55 4c 4c 20 20 52 45 46 45 52 45 4e 43 45 53 20  ULL  REFERENCES 
1910: 70 72 6f 6a 65 63 74 2c 20 20 2d 2d 20 70 72 6f  project,  -- pro
1920: 6a 65 63 74 20 74 68 65 20 63 6f 6d 6d 69 74 20  ject the commit 
1930: 77 61 73 20 6f 6e 0a 09 20 20 20 20 62 69 64 20  was on..    bid 
1940: 49 4e 54 45 47 45 52 20 20 20 20 20 20 20 20 20  INTEGER         
1950: 20 20 20 52 45 46 45 52 45 4e 43 45 53 20 73 79     REFERENCES sy
1960: 6d 62 6f 6c 2c 20 20 20 2d 2d 20 62 72 61 6e 63  mbol,   -- branc
1970: 68 20 74 68 65 20 63 6f 6d 6d 69 74 20 77 61 73  h the commit was
1980: 20 6f 6e 2c 20 4e 55 4c 4c 20 66 6f 72 20 3a 74   on, NULL for :t
1990: 72 75 6e 6b 3a 0a 09 20 20 20 20 61 69 64 20 49  runk:..    aid I
19a0: 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c  NTEGER  NOT NULL
19b0: 20 20 52 45 46 45 52 45 4e 43 45 53 20 61 75 74    REFERENCES aut
19c0: 68 6f 72 2c 0a 09 20 20 20 20 63 69 64 20 49 4e  hor,..    cid IN
19d0: 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20  TEGER  NOT NULL 
19e0: 20 52 45 46 45 52 45 4e 43 45 53 20 63 6d 65 73   REFERENCES cmes
19f0: 73 61 67 65 2c 0a 09 20 20 20 20 55 4e 49 51 55  sage,..    UNIQU
1a00: 45 20 28 70 69 64 2c 20 62 69 64 2c 20 61 69 64  E (pid, bid, aid
1a10: 2c 20 63 69 64 29 0a 09 7d 0a 0a 09 23 20 41 75  , cid)..}...# Au
1a20: 74 68 6f 72 20 61 6e 64 20 63 6f 6d 6d 69 74 20  thor and commit 
1a30: 6d 65 73 73 61 67 65 20 69 6e 66 6f 72 6d 61 74  message informat
1a40: 69 6f 6e 20 69 73 20 66 75 6c 6c 79 20 67 6c 6f  ion is fully glo
1a50: 62 61 6c 2c 0a 09 23 20 69 2e 65 2e 20 70 65 72  bal,..# i.e. per
1a60: 20 72 65 70 6f 73 69 74 6f 72 79 2e 0a 0a 09 73   repository....s
1a70: 74 61 74 65 20 77 72 69 74 69 6e 67 20 61 75 74  tate writing aut
1a80: 68 6f 72 20 7b 0a 09 20 20 20 20 61 69 64 20 20  hor {..    aid  
1a90: 49 4e 54 45 47 45 52 20 20 4e 4f 54 20 4e 55 4c  INTEGER  NOT NUL
1aa0: 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59 20 20  L  PRIMARY KEY  
1ab0: 41 55 54 4f 49 4e 43 52 45 4d 45 4e 54 2c 0a 09  AUTOINCREMENT,..
1ac0: 20 20 20 20 6e 61 6d 65 20 54 45 58 54 20 20 20      name TEXT   
1ad0: 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 55 4e 49 51    NOT NULL  UNIQ
1ae0: 55 45 0a 09 7d 0a 0a 09 73 74 61 74 65 20 77 72  UE..}...state wr
1af0: 69 74 69 6e 67 20 63 6d 65 73 73 61 67 65 20 7b  iting cmessage {
1b00: 0a 09 20 20 20 20 63 69 64 20 20 49 4e 54 45 47  ..    cid  INTEG
1b10: 45 52 20 20 4e 4f 54 20 4e 55 4c 4c 20 20 50 52  ER  NOT NULL  PR
1b20: 49 4d 41 52 59 20 4b 45 59 20 20 41 55 54 4f 49  IMARY KEY  AUTOI
1b30: 4e 43 52 45 4d 45 4e 54 2c 0a 09 20 20 20 20 74  NCREMENT,..    t
1b40: 65 78 74 20 54 45 58 54 20 20 20 20 20 4e 4f 54  ext TEXT     NOT
1b50: 20 4e 55 4c 4c 20 20 55 4e 49 51 55 45 0a 09 7d   NULL  UNIQUE..}
1b60: 0a 0a 09 23 20 43 6f 6e 73 69 73 74 65 6e 63 79  ...# Consistency
1b70: 20 63 6f 6e 73 74 72 61 69 6e 74 73 2e 0a 09 23   constraints...#
1b80: 0a 09 23 20 49 74 65 6d 73 20 28 54 61 67 73 2c  ..# Items (Tags,
1b90: 20 42 72 61 6e 63 68 65 73 2c 20 52 65 76 69 73   Branches, Revis
1ba0: 69 6f 6e 73 29 20 62 65 6c 6f 6e 67 20 74 6f 20  ions) belong to 
1bb0: 61 20 66 69 6c 65 20 74 6f 20 61 0a 09 23 20 70  a file to a..# p
1bc0: 72 6f 6a 65 63 74 2e 20 41 6c 6c 20 72 65 66 65  roject. All refe
1bd0: 72 20 74 6f 20 6f 74 68 65 72 20 69 74 65 6d 73  r to other items
1be0: 2c 20 61 6e 64 20 73 79 6d 62 6f 6c 73 2c 20 77  , and symbols, w
1bf0: 68 69 63 68 20 61 67 61 69 6e 0a 09 23 20 62 65  hich again..# be
1c00: 6c 6f 6e 67 20 74 6f 20 61 20 70 72 6f 6a 65 63  long to a projec
1c10: 74 2e 20 54 68 65 20 70 72 6f 6a 65 63 74 73 20  t. The projects 
1c20: 68 61 76 65 20 74 6f 20 61 67 72 65 65 20 77 69  have to agree wi
1c30: 74 68 20 65 61 63 68 0a 09 23 20 6f 74 68 65 72  th each..# other
1c40: 2e 20 49 2e 65 2e 20 69 74 65 6d 73 20 6d 61 79  . I.e. items may
1c50: 20 6e 6f 74 20 72 65 66 65 72 20 74 6f 20 69 74   not refer to it
1c60: 65 6d 73 20 6f 72 20 73 79 6d 62 6f 6c 73 20 77  ems or symbols w
1c70: 68 69 63 68 0a 09 23 20 62 65 6c 6f 6e 67 20 74  hich..# belong t
1c80: 6f 20 61 20 64 69 66 66 65 72 65 6e 74 20 70 72  o a different pr
1c90: 6f 6a 65 63 74 20 74 68 61 6e 20 74 68 65 69 72  oject than their
1ca0: 20 6f 77 6e 2e 0a 0a 09 72 65 74 75 72 6e 0a 20   own....return. 
1cb0: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65     }..    typeme
1cc0: 74 68 6f 64 20 6c 6f 61 64 20 7b 7d 20 7b 0a 09  thod load {} {..
1cd0: 23 20 54 4f 44 4f 0a 09 72 65 74 75 72 6e 0a 20  # TODO..return. 
1ce0: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65     }..    typeme
1cf0: 74 68 6f 64 20 72 75 6e 20 7b 7d 20 7b 0a 09 23  thod run {} {..#
1d00: 20 50 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e   Pass manager in
1d10: 74 65 72 66 61 63 65 2e 20 45 78 65 63 75 74 65  terface. Execute
1d20: 64 20 74 6f 20 70 65 72 66 6f 72 6d 20 74 68 65  d to perform the
1d30: 0a 09 23 20 66 75 6e 63 74 69 6f 6e 61 6c 69 74  ..# functionalit
1d40: 79 20 6f 66 20 74 68 65 20 70 61 73 73 2e 0a 0a  y of the pass...
1d50: 09 73 65 74 20 72 62 61 73 65 20 5b 72 65 70 6f  .set rbase [repo
1d60: 73 69 74 6f 72 79 20 62 61 73 65 3f 5d 0a 09 66  sitory base?]..f
1d70: 6f 72 65 61 63 68 20 70 72 6f 6a 65 63 74 20 5b  oreach project [
1d80: 72 65 70 6f 73 69 74 6f 72 79 20 70 72 6f 6a 65  repository proje
1d90: 63 74 73 5d 20 7b 0a 09 20 20 20 20 73 65 74 20  cts] {..    set 
1da0: 62 61 73 65 20 5b 66 69 6c 65 20 6a 6f 69 6e 20  base [file join 
1db0: 24 72 62 61 73 65 20 5b 24 70 72 6f 6a 65 63 74  $rbase [$project
1dc0: 20 62 61 73 65 5d 5d 0a 09 20 20 20 20 6c 6f 67   base]]..    log
1dd0: 20 77 72 69 74 65 20 31 20 63 6f 6c 6c 72 65 76   write 1 collrev
1de0: 20 22 50 72 6f 63 65 73 73 69 6e 67 20 24 62 61   "Processing $ba
1df0: 73 65 22 0a 0a 09 20 20 20 20 66 6f 72 65 61 63  se"...    foreac
1e00: 68 20 66 69 6c 65 20 5b 24 70 72 6f 6a 65 63 74  h file [$project
1e10: 20 66 69 6c 65 73 5d 20 7b 0a 09 09 73 65 74 20   files] {...set 
1e20: 70 61 74 68 20 5b 24 66 69 6c 65 20 70 61 74 68  path [$file path
1e30: 5d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 32 20  ]...log write 2 
1e40: 63 6f 6c 6c 72 65 76 20 22 50 61 72 73 69 6e 67  collrev "Parsing
1e50: 20 24 70 61 74 68 22 0a 09 09 69 66 20 7b 5b 63   $path"...if {[c
1e60: 61 74 63 68 20 7b 0a 09 09 20 20 20 20 70 61 72  atch {...    par
1e70: 73 65 72 20 70 72 6f 63 65 73 73 20 5b 66 69 6c  ser process [fil
1e80: 65 20 6a 6f 69 6e 20 24 62 61 73 65 20 24 70 61  e join $base $pa
1e90: 74 68 5d 20 24 66 69 6c 65 0a 09 09 7d 20 6d 73  th] $file...} ms
1ea0: 67 5d 7d 20 7b 0a 09 09 20 20 20 20 67 6c 6f 62  g]} {...    glob
1eb0: 61 6c 20 65 72 72 6f 72 43 6f 64 65 0a 09 09 20  al errorCode... 
1ec0: 20 20 20 69 66 20 7b 24 65 72 72 6f 72 43 6f 64     if {$errorCod
1ed0: 65 20 65 71 20 22 76 63 3a 3a 72 63 73 3a 3a 70  e eq "vc::rcs::p
1ee0: 61 72 73 65 72 22 7d 20 7b 0a 09 09 09 74 72 6f  arser"} {....tro
1ef0: 75 62 6c 65 20 66 61 74 61 6c 20 22 24 70 61 74  uble fatal "$pat
1f00: 68 20 69 73 20 6e 6f 74 20 61 20 76 61 6c 69 64  h is not a valid
1f10: 20 52 43 53 20 61 72 63 68 69 76 65 20 28 24 6d   RCS archive ($m
1f20: 73 67 29 22 0a 09 09 20 20 20 20 7d 20 65 6c 73  sg)"...    } els
1f30: 65 20 7b 0a 09 09 09 67 6c 6f 62 61 6c 20 65 72  e {....global er
1f40: 72 6f 72 49 6e 66 6f 0a 09 09 09 74 72 6f 75 62  rorInfo....troub
1f50: 6c 65 20 69 6e 74 65 72 6e 61 6c 20 24 65 72 72  le internal $err
1f60: 6f 72 49 6e 66 6f 0a 09 09 20 20 20 20 7d 0a 09  orInfo...    }..
1f70: 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20 20 20  .} else {...    
1f80: 23 20 57 65 20 70 65 72 73 69 73 74 20 74 68 65  # We persist the
1f90: 20 63 6f 72 65 20 6f 66 20 74 68 65 20 64 61 74   core of the dat
1fa0: 61 20 63 6f 6c 6c 65 63 74 65 64 20 61 62 6f 75  a collected abou
1fb0: 74 0a 09 09 20 20 20 20 23 20 65 61 63 68 20 66  t...    # each f
1fc0: 69 6c 65 20 69 6d 6d 65 64 69 61 74 65 6c 79 20  ile immediately 
1fd0: 61 66 74 65 72 20 69 74 20 68 61 73 20 62 65 65  after it has bee
1fe0: 6e 20 70 61 72 73 65 64 0a 09 09 20 20 20 20 23  n parsed...    #
1ff0: 20 61 6e 64 20 77 72 61 6e 67 6c 65 64 20 69 6e   and wrangled in
2000: 74 6f 20 73 68 61 70 65 2c 20 61 6e 64 20 74 68  to shape, and th
2010: 65 6e 20 64 72 6f 70 20 69 74 20 66 72 6f 6d 0a  en drop it from.
2020: 09 09 20 20 20 20 23 20 6d 65 6d 6f 72 79 2e 20  ..    # memory. 
2030: 54 68 69 73 20 69 73 20 64 6f 6e 65 20 74 6f 20  This is done to 
2040: 6b 65 65 70 20 74 68 65 20 61 6d 6f 75 6e 74 20  keep the amount 
2050: 6f 66 0a 09 09 20 20 20 20 23 20 72 65 71 75 69  of...    # requi
2060: 72 65 64 20 6d 65 6d 6f 72 79 20 77 69 74 68 69  red memory withi
2070: 6e 20 73 65 6e 73 69 62 6c 65 20 6c 69 6d 69 74  n sensible limit
2080: 73 2e 20 57 69 74 68 6f 75 74 0a 09 09 20 20 20  s. Without...   
2090: 20 23 20 64 6f 69 6e 67 20 69 74 20 74 68 69 73   # doing it this
20a0: 20 77 61 79 20 77 65 20 77 6f 75 6c 64 20 65 61   way we would ea
20b0: 73 69 6c 79 20 67 6f 62 62 6c 65 20 75 70 20 31  sily gobble up 1
20c0: 47 0a 09 09 20 20 20 20 23 20 6f 66 20 52 41 4d  G...    # of RAM
20d0: 20 6f 72 20 6d 6f 72 65 20 77 69 74 68 20 61 6c   or more with al
20e0: 6c 20 74 68 65 20 6f 62 6a 65 63 74 73 20 28 72  l the objects (r
20f0: 65 76 69 73 69 6f 6e 73 0a 09 09 20 20 20 20 23  evisions...    #
2100: 20 61 6e 64 20 66 69 6c 65 2d 6c 65 76 65 6c 20   and file-level 
2110: 73 79 6d 62 6f 6c 73 29 2e 0a 0a 09 09 20 20 20  symbols).....   
2120: 20 24 66 69 6c 65 20 70 65 72 73 69 73 74 0a 09   $file persist..
2130: 09 7d 0a 0a 09 09 24 66 69 6c 65 20 64 72 6f 70  .}....$file drop
2140: 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 72 65 70  ..    }..}...rep
2150: 6f 73 69 74 6f 72 79 20 70 72 69 6e 74 72 65 76  ository printrev
2160: 73 74 61 74 69 73 74 69 63 73 0a 09 72 65 70 6f  statistics..repo
2170: 73 69 74 6f 72 79 20 70 65 72 73 69 73 74 72 65  sitory persistre
2180: 76 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 20  v...log write 1 
2190: 63 6f 6c 6c 72 65 76 20 22 53 63 61 6e 20 63 6f  collrev "Scan co
21a0: 6d 70 6c 65 74 65 64 22 0a 09 72 65 74 75 72 6e  mpleted"..return
21b0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65  .    }..    type
21c0: 6d 65 74 68 6f 64 20 64 69 73 63 61 72 64 20 7b  method discard {
21d0: 7d 20 7b 0a 09 23 20 50 61 73 73 20 6d 61 6e 61  } {..# Pass mana
21e0: 67 65 72 20 69 6e 74 65 72 66 61 63 65 2e 20 45  ger interface. E
21f0: 78 65 63 75 74 65 64 20 66 6f 72 20 61 6c 6c 20  xecuted for all 
2200: 70 61 73 73 65 73 20 61 66 74 65 72 20 74 68 65  passes after the
2210: 0a 09 23 20 72 75 6e 20 70 61 73 73 65 73 2c 20  ..# run passes, 
2220: 74 6f 20 72 65 6d 6f 76 65 20 61 6c 6c 20 64 61  to remove all da
2230: 74 61 20 6f 66 20 74 68 69 73 20 70 61 73 73 20  ta of this pass 
2240: 66 72 6f 6d 20 74 68 65 20 73 74 61 74 65 2c 0a  from the state,.
2250: 09 23 20 61 73 20 62 65 69 6e 67 20 6f 75 74 20  .# as being out 
2260: 6f 66 20 64 61 74 65 2e 0a 0a 09 73 74 61 74 65  of date....state
2270: 20 64 69 73 63 61 72 64 20 72 65 76 69 73 69 6f   discard revisio
2280: 6e 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64  n..state discard
2290: 20 74 61 67 0a 09 73 74 61 74 65 20 64 69 73 63   tag..state disc
22a0: 61 72 64 20 62 72 61 6e 63 68 0a 09 73 74 61 74  ard branch..stat
22b0: 65 20 64 69 73 63 61 72 64 20 73 79 6d 62 6f 6c  e discard symbol
22c0: 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64 20  ..state discard 
22d0: 62 6c 6f 63 6b 65 72 0a 09 73 74 61 74 65 20 64  blocker..state d
22e0: 69 73 63 61 72 64 20 70 61 72 65 6e 74 0a 09 73  iscard parent..s
22f0: 74 61 74 65 20 64 69 73 63 61 72 64 20 6d 65 74  tate discard met
2300: 61 0a 09 73 74 61 74 65 20 64 69 73 63 61 72 64  a..state discard
2310: 20 61 75 74 68 6f 72 0a 09 73 74 61 74 65 20 64   author..state d
2320: 69 73 63 61 72 64 20 63 6d 65 73 73 61 67 65 0a  iscard cmessage.
2330: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
2340: 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23     # # ## ### ##
2350: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
2360: 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23  ##########.    #
2370: 23 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68 6f  # Internal metho
2380: 64 73 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23  ds..    # # ## #
2390: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
23a0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  # #############.
23b0: 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61      ## Configura
23c0: 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61  tion..    pragma
23d0: 20 2d 68 61 73 69 6e 73 74 61 6e 63 65 73 20 20   -hasinstances  
23e0: 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f   no ; # singleto
23f0: 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61  n.    pragma -ha
2400: 73 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20  stypeinfo    no 
2410: 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63  ; # no introspec
2420: 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20  tion.    pragma 
2430: 2d 68 61 73 74 79 70 65 64 65 73 74 72 6f 79 20  -hastypedestroy 
2440: 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a  no ; # immortal.
2450: 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20  .    # # ## ### 
2460: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
2470: 23 23 23 23 23 23 23 23 23 23 23 23 0a 7d 0a 0a  ############.}..
2480: 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a  namespace eval :
2490: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
24a0: 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20 7b  ort::cvs::pass {
24b0: 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65  .    namespace e
24c0: 78 70 6f 72 74 20 63 6f 6c 6c 72 65 76 0a 20 20  xport collrev.  
24d0: 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c    namespace eval
24e0: 20 63 6f 6c 6c 72 65 76 20 7b 0a 09 6e 61 6d 65   collrev {..name
24f0: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
2500: 63 3a 3a 72 63 73 3a 3a 70 61 72 73 65 72 0a 09  c::rcs::parser..
2510: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
2520: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
2530: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70 6f  mport::cvs::repo
2540: 73 69 74 6f 72 79 0a 09 6e 61 6d 65 73 70 61 63  sitory..namespac
2550: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
2560: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
2570: 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65 73  vs::state..names
2580: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
2590: 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65  ::tools::trouble
25a0: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
25b0: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  rt ::vc::tools::
25c0: 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65  log..log registe
25d0: 72 20 63 6f 6c 6c 72 65 76 0a 20 20 20 20 7d 0a  r collrev.    }.
25e0: 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23  }..# # ## ### ##
25f0: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
2600: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23  ########## #####
2610: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
2620: 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 63 6b 61  .## Ready..packa
2630: 67 65 20 70 72 6f 76 69 64 65 20 76 63 3a 3a 66  ge provide vc::f
2640: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
2650: 76 73 3a 3a 70 61 73 73 3a 3a 63 6f 6c 6c 72 65  vs::pass::collre
2660: 76 20 31 2e 30 0a 72 65 74 75 72 6e 0a           v 1.0.return.