Hex Artifact Content
Not logged in

Artifact a9820cd0e44b51ade84f38f88da4a8831cc3e34e:

File tools/cvs2fossil/lib/c2f_pfiltersym.tcl part of check-in [6809145eb1] - More comments on sql statements. by aku on 2008-01-19 06:07:49.

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 56 2e 20 43 6f 6d 69 6e 67 20 61 66 74  s IV. Coming aft
0210: 65 72 20 74 68 65 20 73 79 6d 62 6f 6c 20 63 6f  er the symbol co
0220: 6c 6c 61 74 69 6f 6e 20 70 61 73 73 20 74 68 69  llation pass thi
0230: 73 20 70 61 73 73 20 6e 6f 77 0a 23 23 20 72 65  s pass now.## re
0240: 6d 6f 76 65 73 20 61 6c 6c 20 72 65 76 69 73 69  moves all revisi
0250: 6f 6e 73 20 61 6e 64 20 73 79 6d 62 6f 6c 73 20  ons and symbols 
0260: 72 65 66 65 72 65 6e 63 69 6e 67 20 61 6e 79 20  referencing any 
0270: 6f 66 20 74 68 65 20 65 78 63 6c 75 64 65 64 0a  of the excluded.
0280: 23 23 20 73 79 6d 62 6f 6c 73 20 66 72 6f 6d 20  ## symbols from 
0290: 74 68 65 20 70 65 72 73 69 73 74 65 6e 74 20 64  the persistent d
02a0: 61 74 61 62 61 73 65 2e 0a 0a 23 20 23 20 23 23  atabase...# # ##
02b0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
02c0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
02d0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23  # ##############
02e0: 23 23 23 23 23 23 23 0a 23 23 20 52 65 71 75 69  #######.## Requi
02f0: 72 65 6d 65 6e 74 73 0a 0a 70 61 63 6b 61 67 65  rements..package
0300: 20 72 65 71 75 69 72 65 20 54 63 6c 20 38 2e 34   require Tcl 8.4
0310: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0320: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b                 ;
0330: 20 23 20 52 65 71 75 69 72 65 64 20 72 75 6e 74   # Required runt
0340: 69 6d 65 2e 0a 70 61 63 6b 61 67 65 20 72 65 71  ime..package req
0350: 75 69 72 65 20 73 6e 69 74 20 20 20 20 20 20 20  uire snit       
0360: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0370: 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 4f             ; # O
0380: 4f 20 73 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67  O system..packag
0390: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 6f  e require vc::to
03a0: 6f 6c 73 3a 3a 6d 69 73 63 20 20 20 20 20 20 20  ols::misc       
03b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03c0: 3b 20 23 20 54 65 78 74 20 66 6f 72 6d 61 74 74  ; # Text formatt
03d0: 69 6e 67 2e 0a 70 61 63 6b 61 67 65 20 72 65 71  ing..package req
03e0: 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  uire vc::tools::
03f0: 6c 6f 67 20 20 20 20 20 20 20 20 20 20 20 20 20  log             
0400: 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 55             ; # U
0410: 73 65 72 20 66 65 65 64 62 61 63 6b 2e 0a 70 61  ser feedback..pa
0420: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
0430: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
0440: 3a 3a 63 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72  ::cvs::repositor
0450: 79 20 20 20 3b 20 23 20 52 65 70 6f 73 69 74 6f  y   ; # Reposito
0460: 72 79 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70  ry management..p
0470: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76  ackage require v
0480: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
0490: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 20 20 20  t::cvs::state   
04a0: 20 20 20 20 20 3b 20 23 20 53 74 61 74 65 20 73       ; # State s
04b0: 74 6f 72 61 67 65 2e 0a 70 61 63 6b 61 67 65 20  torage..package 
04c0: 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73  require vc::foss
04d0: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
04e0: 3a 69 6e 74 65 67 72 69 74 79 20 20 20 20 3b 20  :integrity    ; 
04f0: 23 20 53 74 61 74 65 20 73 74 6f 72 61 67 65 20  # State storage 
0500: 69 6e 74 65 67 72 69 74 79 20 63 68 65 63 6b 73  integrity checks
0510: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72  ..package requir
0520: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  e vc::fossil::im
0530: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65  port::cvs::proje
0540: 63 74 3a 3a 73 79 6d 20 3b 20 23 20 50 72 6f 6a  ct::sym ; # Proj
0550: 65 63 74 20 6c 65 76 65 6c 20 73 79 6d 62 6f 6c  ect level symbol
0560: 73 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23  s..# # ## ### ##
0570: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
0580: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23  ########## #####
0590: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
05a0: 0a 23 23 20 52 65 67 69 73 74 65 72 20 74 68 65  .## Register the
05b0: 20 70 61 73 73 20 77 69 74 68 20 74 68 65 20 6d   pass with the m
05c0: 61 6e 61 67 65 6d 65 6e 74 0a 0a 76 63 3a 3a 66  anagement..vc::f
05d0: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
05e0: 76 73 3a 3a 70 61 73 73 20 64 65 66 69 6e 65 20  vs::pass define 
05f0: 5c 0a 20 20 20 20 46 69 6c 74 65 72 53 79 6d 62  \.    FilterSymb
0600: 6f 6c 73 20 5c 0a 20 20 20 20 7b 46 69 6c 74 65  ols \.    {Filte
0610: 72 20 73 79 6d 62 6f 6c 73 2c 20 72 65 6d 6f 76  r symbols, remov
0620: 65 20 61 6c 6c 20 65 78 63 6c 75 64 65 64 20 70  e all excluded p
0630: 69 65 63 65 73 7d 20 5c 0a 20 20 20 20 3a 3a 76  ieces} \.    ::v
0640: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
0650: 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 66 69  t::cvs::pass::fi
0660: 6c 74 65 72 73 79 6d 0a 0a 23 20 23 20 23 23 20  ltersym..# # ## 
0670: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
0680: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
0690: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23   ###############
06a0: 23 23 23 23 23 23 0a 23 23 0a 0a 73 6e 69 74 3a  ######.##..snit:
06b0: 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73  :type ::vc::foss
06c0: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
06d0: 3a 70 61 73 73 3a 3a 66 69 6c 74 65 72 73 79 6d  :pass::filtersym
06e0: 20 7b 0a 20 20 20 20 23 20 23 20 23 23 20 23 23   {.    # # ## ##
06f0: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
0700: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
0710: 20 20 20 23 23 20 50 75 62 6c 69 63 20 41 50 49     ## Public API
0720: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
0730: 20 73 65 74 75 70 20 7b 7d 20 7b 0a 09 23 20 44   setup {} {..# D
0740: 65 66 69 6e 65 20 6e 61 6d 65 73 20 61 6e 64 20  efine names and 
0750: 73 74 72 75 63 74 75 72 65 20 6f 66 20 74 68 65  structure of the
0760: 20 70 65 72 73 69 73 74 65 6e 74 20 73 74 61 74   persistent stat
0770: 65 20 6f 66 20 74 68 69 73 0a 09 23 20 70 61 73  e of this..# pas
0780: 73 2e 0a 0a 09 73 74 61 74 65 20 75 73 65 20 70  s....state use p
0790: 72 6f 6a 65 63 74 0a 09 73 74 61 74 65 20 75 73  roject..state us
07a0: 65 20 66 69 6c 65 0a 09 73 74 61 74 65 20 75 73  e file..state us
07b0: 65 20 72 65 76 69 73 69 6f 6e 0a 09 73 74 61 74  e revision..stat
07c0: 65 20 75 73 65 20 72 65 76 69 73 69 6f 6e 62 72  e use revisionbr
07d0: 61 6e 63 68 63 68 69 6c 64 72 65 6e 0a 09 73 74  anchchildren..st
07e0: 61 74 65 20 75 73 65 20 62 72 61 6e 63 68 0a 09  ate use branch..
07f0: 73 74 61 74 65 20 75 73 65 20 74 61 67 0a 09 73  state use tag..s
0800: 74 61 74 65 20 75 73 65 20 73 79 6d 62 6f 6c 0a  tate use symbol.
0810: 09 73 74 61 74 65 20 75 73 65 20 62 6c 6f 63 6b  .state use block
0820: 65 72 0a 09 73 74 61 74 65 20 75 73 65 20 70 61  er..state use pa
0830: 72 65 6e 74 0a 09 73 74 61 74 65 20 75 73 65 20  rent..state use 
0840: 61 75 74 68 6f 72 0a 09 73 74 61 74 65 20 75 73  author..state us
0850: 65 20 63 6d 65 73 73 61 67 65 0a 09 73 74 61 74  e cmessage..stat
0860: 65 20 75 73 65 20 70 72 65 66 65 72 65 64 70 61  e use preferedpa
0870: 72 65 6e 74 0a 0a 09 23 20 4e 4f 54 45 3a 20 53  rent...# NOTE: S
0880: 6f 20 66 61 72 20 6e 6f 20 70 61 73 73 20 63 6f  o far no pass co
0890: 6d 69 6e 67 20 61 66 74 65 72 20 74 68 69 73 20  ming after this 
08a0: 6d 61 6b 65 73 20 75 73 20 6f 66 20 74 68 69 73  makes us of this
08b0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e 0a 09 73   information...s
08c0: 74 61 74 65 20 65 78 74 65 6e 64 20 6e 6f 6f 70  tate extend noop
08d0: 20 7b 0a 09 20 20 20 20 69 64 20 20 20 20 49 4e   {..    id    IN
08e0: 54 45 47 45 52 20 4e 4f 54 20 4e 55 4c 4c 20 20  TEGER NOT NULL  
08f0: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 2d 2d 20  PRIMARY KEY, -- 
0900: 74 61 67 2f 62 72 61 6e 63 68 20 72 65 66 65 72  tag/branch refer
0910: 65 6e 63 65 0a 09 20 20 20 20 6e 6f 6f 70 20 20  ence..    noop  
0920: 49 4e 54 45 47 45 52 20 4e 4f 54 20 4e 55 4c 4c  INTEGER NOT NULL
0930: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ..}..return.    
0940: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
0950: 64 20 6c 6f 61 64 20 7b 7d 20 7b 0a 09 23 20 50  d load {} {..# P
0960: 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65  ass manager inte
0970: 72 66 61 63 65 2e 20 45 78 65 63 75 74 65 64 20  rface. Executed 
0980: 74 6f 20 6c 6f 61 64 20 64 61 74 61 20 63 6f 6d  to load data com
0990: 70 75 74 65 64 20 62 79 0a 09 23 20 74 68 69 73  puted by..# this
09a0: 20 70 61 73 73 20 69 6e 74 6f 20 6d 65 6d 6f 72   pass into memor
09b0: 79 20 77 68 65 6e 20 74 68 69 73 20 70 61 73 73  y when this pass
09c0: 20 69 73 20 73 6b 69 70 70 65 64 20 69 6e 73 74   is skipped inst
09d0: 65 61 64 20 6f 66 0a 09 23 20 65 78 65 63 75 74  ead of..# execut
09e0: 65 64 2e 0a 0a 09 23 20 54 68 65 20 72 65 73 75  ed....# The resu
09f0: 6c 74 73 20 6f 66 20 74 68 69 73 20 70 61 73 73  lts of this pass
0a00: 20 61 72 65 20 66 75 6c 6c 79 20 69 6e 20 74 68   are fully in th
0a10: 65 20 70 65 72 73 69 73 74 65 6e 74 20 73 74 61  e persistent sta
0a20: 74 65 2c 0a 09 23 20 74 68 65 72 65 20 69 73 20  te,..# there is 
0a30: 6e 6f 74 68 69 6e 67 20 74 6f 20 6c 6f 61 64 20  nothing to load 
0a40: 66 6f 72 20 74 68 65 20 6e 65 78 74 20 6f 6e 65  for the next one
0a50: 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  ...return.    }.
0a60: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
0a70: 72 75 6e 20 7b 7d 20 7b 0a 09 23 20 50 61 73 73  run {} {..# Pass
0a80: 20 6d 61 6e 61 67 65 72 20 69 6e 74 65 72 66 61   manager interfa
0a90: 63 65 2e 20 45 78 65 63 75 74 65 64 20 74 6f 20  ce. Executed to 
0aa0: 70 65 72 66 6f 72 6d 20 74 68 65 0a 09 23 20 66  perform the..# f
0ab0: 75 6e 63 74 69 6f 6e 61 6c 69 74 79 20 6f 66 20  unctionality of 
0ac0: 74 68 65 20 70 61 73 73 2e 0a 0a 09 23 20 54 68  the pass....# Th
0ad0: 65 20 72 65 6d 6f 76 61 6c 20 6f 66 20 65 78 63  e removal of exc
0ae0: 6c 75 64 65 64 20 73 79 6d 62 6f 6c 73 20 61 6e  luded symbols an
0af0: 64 20 65 76 65 72 79 74 68 69 6e 67 20 72 65 66  d everything ref
0b00: 65 72 65 6e 63 69 6e 67 0a 09 23 20 74 6f 20 74  erencing..# to t
0b10: 68 65 6d 20 69 73 20 64 6f 6e 65 20 63 6f 6d 70  hem is done comp
0b20: 6c 65 74 65 6c 79 20 69 6e 20 74 68 65 20 64 61  letely in the da
0b30: 74 61 62 61 73 65 2e 0a 0a 09 73 74 61 74 65 20  tabase....state 
0b40: 74 72 61 6e 73 61 63 74 69 6f 6e 20 7b 0a 09 20  transaction {.. 
0b50: 20 20 20 46 69 6c 74 65 72 45 78 63 6c 75 64 65     FilterExclude
0b60: 64 53 79 6d 62 6f 6c 73 0a 09 20 20 20 20 4d 75  dSymbols..    Mu
0b70: 74 61 74 65 53 79 6d 62 6f 6c 73 0a 09 20 20 20  tateSymbols..   
0b80: 20 41 64 6a 75 73 74 50 61 72 65 6e 74 73 0a 09   AdjustParents..
0b90: 20 20 20 20 52 65 66 69 6e 65 53 79 6d 62 6f 6c      RefineSymbol
0ba0: 73 0a 0a 09 20 20 20 20 72 65 70 6f 73 69 74 6f  s...    reposito
0bb0: 72 79 20 70 72 69 6e 74 72 65 76 73 74 61 74 69  ry printrevstati
0bc0: 73 74 69 63 73 0a 0a 09 20 20 20 20 23 20 53 74  stics...    # St
0bd0: 72 69 63 74 20 69 6e 74 65 67 72 69 74 79 20 65  rict integrity e
0be0: 6e 66 6f 72 63 65 73 20 74 68 61 74 20 61 6c 6c  nforces that all
0bf0: 20 6d 65 74 61 20 65 6e 74 72 69 65 73 20 61 72   meta entries ar
0c00: 65 20 69 6e 0a 09 20 20 20 20 23 20 74 68 65 20  e in..    # the 
0c10: 73 61 6d 65 20 4c 4f 44 20 61 73 20 74 68 65 20  same LOD as the 
0c20: 72 65 76 69 73 69 6f 6e 20 75 73 69 6e 67 20 74  revision using t
0c30: 68 65 6d 2e 20 41 74 20 74 68 69 73 20 70 6f 69  hem. At this poi
0c40: 6e 74 0a 09 20 20 20 20 23 20 74 68 69 73 20 6d  nt..    # this m
0c50: 61 79 20 6e 6f 74 20 62 65 20 74 72 75 65 20 61  ay not be true a
0c60: 6e 79 20 6c 6f 6e 67 65 72 2e 20 49 66 20 61 20  ny longer. If a 
0c70: 4e 54 44 42 20 77 61 73 20 65 78 63 6c 75 64 65  NTDB was exclude
0c80: 64 0a 09 20 20 20 20 23 20 74 68 65 6e 20 61 6c  d..    # then al
0c90: 6c 20 72 65 76 69 73 69 6f 6e 73 20 69 74 20 73  l revisions it s
0ca0: 68 61 72 65 64 20 77 69 74 68 20 74 68 65 20 74  hared with the t
0cb0: 72 75 6e 6b 20 77 65 72 65 20 6d 6f 76 65 64 0a  runk were moved.
0cc0: 09 20 20 20 20 23 20 74 6f 20 74 68 65 20 74 72  .    # to the tr
0cd0: 75 6e 6b 20 4c 4f 44 2c 20 68 6f 77 65 76 65 72  unk LOD, however
0ce0: 20 74 68 65 69 72 20 6d 65 74 61 20 65 6e 74 72   their meta entr
0cf0: 69 65 73 20 77 69 6c 6c 20 73 74 69 6c 6c 0a 09  ies will still..
0d00: 20 20 20 20 23 20 72 65 66 65 72 20 74 6f 20 74      # refer to t
0d10: 68 65 20 6e 6f 77 20 67 6f 6e 65 20 4c 4f 44 20  he now gone LOD 
0d20: 73 79 6d 62 6f 6c 2e 20 54 68 69 73 20 69 73 20  symbol. This is 
0d30: 66 69 6e 65 20 68 6f 77 65 76 65 72 2c 0a 09 20  fine however,.. 
0d40: 20 20 20 23 20 69 74 20 77 69 6c 6c 20 6e 6f 74     # it will not
0d50: 20 61 66 66 65 63 74 20 6f 75 72 20 61 62 69 6c   affect our abil
0d60: 69 74 79 20 74 6f 20 75 73 65 20 74 68 65 20 6d  ity to use the m
0d70: 65 74 61 20 65 6e 74 72 69 65 73 0a 09 20 20 20  eta entries..   
0d80: 20 23 20 74 6f 20 64 69 73 74 69 6e 67 75 69 73   # to distinguis
0d90: 68 20 61 6e 64 20 67 72 6f 75 70 20 72 65 76 69  h and group revi
0da0: 73 69 6f 6e 73 20 69 6e 74 6f 20 63 68 61 6e 67  sions into chang
0db0: 65 73 65 74 73 2e 20 49 74 0a 09 20 20 20 20 23  esets. It..    #
0dc0: 20 73 68 6f 75 6c 64 20 62 65 20 6e 6f 74 65 64   should be noted
0dd0: 20 74 68 61 74 20 77 65 20 63 61 6e 6e 6f 74 20   that we cannot 
0de0: 73 69 6d 70 6c 79 20 73 77 69 74 63 68 20 74 68  simply switch th
0df0: 65 20 6d 65 74 61 0a 09 20 20 20 20 23 20 65 6e  e meta..    # en
0e00: 74 72 69 65 73 20 6f 76 65 72 20 74 6f 20 74 68  tries over to th
0e10: 65 20 74 72 75 6e 6b 20 65 69 74 68 65 72 2c 20  e trunk either, 
0e20: 61 73 20 74 68 61 74 20 6d 61 79 20 63 61 75 73  as that may caus
0e30: 65 20 74 68 65 0a 09 20 20 20 20 23 20 6d 6f 64  e the..    # mod
0e40: 69 66 69 65 64 20 65 6e 74 72 69 65 73 20 74 6f  ified entries to
0e50: 20 76 69 6f 6c 61 74 65 20 74 68 65 20 75 6e 69   violate the uni
0e60: 71 75 65 2d 6e 65 73 73 20 63 6f 6e 73 74 72 61  que-ness constra
0e70: 69 6e 0a 09 20 20 20 20 23 20 73 65 74 20 6f 6e  in..    # set on
0e80: 20 74 68 61 74 20 74 61 62 6c 65 2e 0a 09 20 20   that table...  
0e90: 20 20 69 6e 74 65 67 72 69 74 79 20 6d 65 74 61    integrity meta
0ea0: 72 65 6c 61 78 65 64 0a 09 7d 0a 0a 09 6c 6f 67  relaxed..}...log
0eb0: 20 77 72 69 74 65 20 31 20 66 69 6c 74 65 72 73   write 1 filters
0ec0: 79 6d 20 22 46 69 6c 74 65 72 69 6e 67 20 63 6f  ym "Filtering co
0ed0: 6d 70 6c 65 74 65 64 22 0a 09 72 65 74 75 72 6e  mpleted"..return
0ee0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65  .    }..    type
0ef0: 6d 65 74 68 6f 64 20 64 69 73 63 61 72 64 20 7b  method discard {
0f00: 7d 20 7b 0a 09 23 20 50 61 73 73 20 6d 61 6e 61  } {..# Pass mana
0f10: 67 65 72 20 69 6e 74 65 72 66 61 63 65 2e 20 45  ger interface. E
0f20: 78 65 63 75 74 65 64 20 66 6f 72 20 61 6c 6c 20  xecuted for all 
0f30: 70 61 73 73 65 73 20 61 66 74 65 72 20 74 68 65  passes after the
0f40: 0a 09 23 20 72 75 6e 20 70 61 73 73 65 73 2c 20  ..# run passes, 
0f50: 74 6f 20 72 65 6d 6f 76 65 20 61 6c 6c 20 64 61  to remove all da
0f60: 74 61 20 6f 66 20 74 68 69 73 20 70 61 73 73 20  ta of this pass 
0f70: 66 72 6f 6d 20 74 68 65 20 73 74 61 74 65 2c 0a  from the state,.
0f80: 09 23 20 61 73 20 62 65 69 6e 67 20 6f 75 74 20  .# as being out 
0f90: 6f 66 20 64 61 74 65 2e 0a 09 72 65 74 75 72 6e  of date...return
0fa0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20  .    }..    # # 
0fb0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
0fc0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
0fd0: 23 23 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72  ###.    ## Inter
0fe0: 6e 61 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20  nal methods..   
0ff0: 20 70 72 6f 63 20 46 69 6c 74 65 72 45 78 63 6c   proc FilterExcl
1000: 75 64 65 64 53 79 6d 62 6f 6c 73 20 7b 7d 20 7b  udedSymbols {} {
1010: 0a 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69  ..log write 3 fi
1020: 6c 74 65 72 73 79 6d 20 22 52 65 6d 6f 76 65 20  ltersym "Remove 
1030: 74 68 65 20 65 78 63 6c 75 64 65 64 20 73 79 6d  the excluded sym
1040: 62 6f 6c 73 20 61 6e 64 20 74 68 65 69 72 20 75  bols and their u
1050: 73 65 72 73 22 0a 0a 09 23 20 57 65 20 70 75 6c  sers"...# We pul
1060: 6c 20 61 6c 6c 20 74 68 65 20 65 78 63 6c 75 64  l all the exclud
1070: 65 64 20 73 79 6d 62 6f 6c 73 20 74 6f 67 65 74  ed symbols toget
1080: 68 65 72 20 69 6e 74 6f 20 61 20 74 61 62 6c 65  her into a table
1090: 20 66 6f 72 0a 09 23 20 65 61 73 79 20 72 65 66   for..# easy ref
10a0: 65 72 65 6e 63 65 20 62 79 20 74 68 65 20 75 70  erence by the up
10b0: 63 6f 6d 69 6e 67 20 44 45 4c 45 54 45 20 61 6e  coming DELETE an
10c0: 64 20 6f 74 68 65 72 20 73 74 61 74 65 6d 65 6e  d other statemen
10d0: 74 73 2e 0a 09 23 20 28 27 78 20 49 4e 20 74 61  ts...# ('x IN ta
10e0: 62 6c 65 27 20 63 6c 61 75 73 65 73 29 2e 0a 0a  ble' clauses)...
10f0: 09 73 65 74 20 65 78 63 6c 20 5b 70 72 6f 6a 65  .set excl [proje
1100: 63 74 3a 3a 73 79 6d 20 65 78 63 6c 75 64 65 64  ct::sym excluded
1110: 5d 0a 0a 09 73 74 61 74 65 20 72 75 6e 20 7b 0a  ]...state run {.
1120: 09 20 20 20 20 43 52 45 41 54 45 20 54 45 4d 50  .    CREATE TEMP
1130: 4f 52 41 52 59 20 54 41 42 4c 45 20 65 78 63 6c  ORARY TABLE excl
1140: 75 64 65 64 73 79 6d 62 6f 6c 73 20 41 53 0a 09  udedsymbols AS..
1150: 20 20 20 20 53 45 4c 45 43 54 20 73 69 64 0a 09      SELECT sid..
1160: 20 20 20 20 46 52 4f 4d 20 20 20 73 79 6d 62 6f      FROM   symbo
1170: 6c 0a 09 20 20 20 20 57 48 45 52 45 20 20 74 79  l..    WHERE  ty
1180: 70 65 20 3d 20 24 65 78 63 6c 0a 09 7d 0a 0a 09  pe = $excl..}...
1190: 23 20 46 69 72 73 74 20 77 65 20 68 61 76 65 20  # First we have 
11a0: 74 6f 20 68 61 6e 64 6c 65 20 74 68 65 20 70 6f  to handle the po
11b0: 73 73 69 62 69 6c 69 74 79 20 6f 66 20 61 6e 20  ssibility of an 
11c0: 65 78 63 6c 75 64 65 64 0a 09 23 20 4e 54 44 42  excluded..# NTDB
11d0: 2e 20 54 68 69 73 20 69 73 20 61 20 73 70 65 63  . This is a spec
11e0: 69 61 6c 20 73 70 65 63 69 61 6c 20 63 61 73 65  ial special case
11f0: 20 74 68 65 72 65 20 77 65 20 68 61 76 65 20 74   there we have t
1200: 6f 0a 09 23 20 72 65 67 72 61 66 74 20 74 68 65  o..# regraft the
1210: 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68   revisions which
1220: 20 61 72 65 20 73 68 61 72 65 64 20 62 65 74 77   are shared betw
1230: 65 65 6e 20 74 68 65 20 4e 54 44 42 20 61 6e 64  een the NTDB and
1240: 0a 09 23 20 54 72 75 6e 6b 20 6f 6e 74 6f 20 74  ..# Trunk onto t
1250: 68 65 20 74 72 75 6e 6b 2c 20 70 72 65 76 65 6e  he trunk, preven
1260: 74 69 6e 67 20 74 68 65 69 72 20 64 65 6c 65 74  ting their delet
1270: 69 6f 6e 20 6c 61 74 65 72 2e 20 57 65 0a 09 23  ion later. We..#
1280: 20 68 61 76 65 20 63 6f 64 65 20 66 6f 72 20 74   have code for t
1290: 68 61 74 20 69 6e 20 27 66 69 6c 65 27 2c 20 68  hat in 'file', h
12a0: 6f 77 65 76 65 72 20 74 68 61 74 20 6f 70 65 72  owever that oper
12b0: 61 74 65 64 20 6f 6e 20 74 68 65 0a 09 23 20 69  ated on the..# i
12c0: 6e 2d 6d 65 6d 6f 72 79 20 72 65 76 69 73 69 6f  n-memory revisio
12d0: 6e 20 6f 62 6a 65 63 74 73 2c 20 77 68 69 63 68  n objects, which
12e0: 20 77 65 20 64 6f 20 6e 6f 74 20 68 61 76 65 20   we do not have 
12f0: 68 65 72 65 2e 20 57 65 20 64 6f 0a 09 23 20 74  here. We do..# t
1300: 68 65 20 73 61 6d 65 20 6e 6f 77 20 77 69 74 68  he same now with
1310: 6f 75 74 20 6f 62 6a 65 63 74 2c 20 62 79 20 64  out object, by d
1320: 69 72 65 63 74 6c 79 20 6d 61 6e 69 70 75 6c 61  irectly manipula
1330: 74 69 6e 67 20 74 68 65 0a 09 23 20 6c 69 6e 6b  ting the..# link
1340: 73 20 69 6e 20 74 68 65 20 64 61 74 61 62 61 73  s in the databas
1350: 65 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20 6e  e....array set n
1360: 74 64 62 20 7b 7d 0a 09 61 72 72 61 79 20 73 65  tdb {}..array se
1370: 74 20 6c 69 6e 6b 20 7b 7d 0a 0a 09 66 6f 72 65  t link {}...fore
1380: 61 63 68 20 7b 69 64 20 70 61 72 65 6e 74 20 74  ach {id parent t
1390: 72 61 6e 73 66 65 72 7d 20 5b 73 74 61 74 65 20  ransfer} [state 
13a0: 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  run {..    SELEC
13b0: 54 20 52 2e 72 69 64 2c 20 52 2e 70 61 72 65 6e  T R.rid, R.paren
13c0: 74 2c 20 52 2e 64 62 63 68 69 6c 64 0a 09 20 20  t, R.dbchild..  
13d0: 20 20 46 52 4f 4d 20 20 72 65 76 69 73 69 6f 6e    FROM  revision
13e0: 20 52 2c 20 73 79 6d 62 6f 6c 20 53 0a 09 20 20   R, symbol S..  
13f0: 20 20 57 48 45 52 45 20 52 2e 6c 6f 64 20 3d 20    WHERE R.lod = 
1400: 53 2e 73 69 64 20 20 20 20 20 20 20 20 20 20 20  S.sid           
1410: 20 2d 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f   -- Get symbol o
1420: 66 20 6c 69 6e 65 2d 6f 66 2d 64 65 76 65 6c 6f  f line-of-develo
1430: 70 6d 65 6e 74 20 6f 66 20 61 6c 6c 20 72 65 76  pment of all rev
1440: 69 73 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20  isions..    AND 
1450: 20 20 53 2e 73 69 64 20 49 4e 20 65 78 63 6c 75    S.sid IN exclu
1460: 64 65 64 73 79 6d 62 6f 6c 73 20 2d 2d 20 52 65  dedsymbols -- Re
1470: 73 74 72 69 63 74 20 74 6f 20 74 68 65 20 65 78  strict to the ex
1480: 63 6c 75 64 65 64 20 73 79 6d 62 6f 6c 73 0a 09  cluded symbols..
1490: 20 20 20 20 41 4e 44 20 20 20 52 2e 69 73 64 65      AND   R.isde
14a0: 66 61 75 6c 74 20 20 20 20 20 20 20 20 20 20 20  fault           
14b0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
14c0: 6f 20 4e 54 44 42 20 72 65 76 69 73 69 6f 6e 73  o NTDB revisions
14d0: 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 73 65 74 20  ..}] {..    set 
14e0: 6e 74 64 62 28 24 69 64 29 20 24 70 61 72 65 6e  ntdb($id) $paren
14f0: 74 0a 09 20 20 20 20 69 66 20 7b 24 74 72 61 6e  t..    if {$tran
1500: 73 66 65 72 20 65 71 20 22 22 7d 20 63 6f 6e 74  sfer eq ""} cont
1510: 69 6e 75 65 0a 09 20 20 20 20 73 65 74 20 6c 69  inue..    set li
1520: 6e 6b 28 24 69 64 29 20 24 74 72 61 6e 73 66 65  nk($id) $transfe
1530: 72 0a 09 7d 0a 0a 09 66 6f 72 65 61 63 68 20 6a  r..}...foreach j
1540: 6f 69 6e 74 20 5b 61 72 72 61 79 20 6e 61 6d 65  oint [array name
1550: 73 20 6c 69 6e 6b 5d 20 7b 0a 09 20 20 20 20 23  s link] {..    #
1560: 20 54 68 65 20 6a 6f 69 6e 74 73 20 61 72 65 20   The joints are 
1570: 74 68 65 20 68 69 67 68 65 73 74 20 4e 54 44 42  the highest NTDB
1580: 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68   revisions which
1590: 20 61 72 65 0a 09 20 20 20 20 23 20 73 68 61 72   are..    # shar
15a0: 65 64 20 77 69 74 68 20 74 68 65 69 72 20 72 65  ed with their re
15b0: 73 70 65 63 74 69 76 65 20 74 72 75 6e 6b 2e 20  spective trunk. 
15c0: 57 65 20 64 69 73 63 6f 6e 6e 65 63 74 20 66 72  We disconnect fr
15d0: 6f 6d 0a 09 20 20 20 20 23 20 74 68 65 69 72 20  om..    # their 
15e0: 4e 54 44 42 20 63 68 69 6c 64 72 65 6e 2c 20 61  NTDB children, a
15f0: 6e 64 20 6d 61 6b 65 20 74 68 65 6d 20 70 61 72  nd make them par
1600: 65 6e 74 73 20 6f 66 20 74 68 65 69 72 0a 09 20  ents of their.. 
1610: 20 20 20 23 20 27 64 62 63 68 69 6c 64 27 2e 20     # 'dbchild'. 
1620: 54 68 65 20 61 73 73 6f 63 69 61 74 65 64 20 27  The associated '
1630: 64 62 70 61 72 65 6e 74 27 20 69 73 20 73 71 75  dbparent' is squ
1640: 61 73 68 65 64 0a 09 20 20 20 20 23 20 69 6e 73  ashed..    # ins
1650: 74 65 61 64 2e 20 41 6c 6c 20 70 61 72 65 6e 74  tead. All parent
1660: 73 20 6f 66 20 74 68 65 20 6a 6f 69 6e 74 73 20  s of the joints 
1670: 61 72 65 20 6d 6f 76 65 64 20 74 6f 20 74 68 65  are moved to the
1680: 0a 09 20 20 20 20 23 20 74 72 75 6e 6b 20 61 73  ..    # trunk as
1690: 20 77 65 6c 6c 2e 0a 0a 09 20 20 20 20 73 65 74   well....    set
16a0: 20 74 6a 6f 69 6e 74 20 24 6c 69 6e 6b 28 24 6a   tjoint $link($j
16b0: 6f 69 6e 74 29 0a 09 20 20 20 20 73 65 74 20 74  oint)..    set t
16c0: 6c 6f 64 20 5b 73 74 61 74 65 20 6f 6e 65 20 7b  lod [state one {
16d0: 0a 09 09 53 45 4c 45 43 54 20 6c 6f 64 20 46 52  ...SELECT lod FR
16e0: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 57 48 45 52  OM revision WHER
16f0: 45 20 72 69 64 20 3d 20 24 74 6a 6f 69 6e 74 0a  E rid = $tjoint.
1700: 09 20 20 20 20 7d 5d 0a 0a 09 20 20 20 20 23 20  .    }]...    # 
1710: 43 6f 76 6e 65 72 74 20 64 62 2f 70 61 72 65 6e  Covnert db/paren
1720: 74 2f 63 68 69 6c 64 20 69 6e 74 6f 20 72 65 67  t/child into reg
1730: 75 6c 61 72 20 70 61 72 65 6e 74 2f 63 68 69 6c  ular parent/chil
1740: 64 20 6c 69 6e 6b 73 2e 0a 09 20 20 20 20 73 74  d links...    st
1750: 61 74 65 20 72 75 6e 20 7b 0a 09 09 55 50 44 41  ate run {...UPDA
1760: 54 45 20 72 65 76 69 73 69 6f 6e 20 53 45 54 20  TE revision SET 
1770: 64 62 70 61 72 65 6e 74 20 3d 20 4e 55 4c 4c 2c  dbparent = NULL,
1780: 20 70 61 72 65 6e 74 20 3d 20 24 6a 6f 69 6e 74   parent = $joint
1790: 20 20 57 48 45 52 45 20 72 69 64 20 3d 20 24 74    WHERE rid = $t
17a0: 6a 6f 69 6e 74 20 3b 0a 09 09 55 50 44 41 54 45  joint ;...UPDATE
17b0: 20 72 65 76 69 73 69 6f 6e 20 53 45 54 20 64 62   revision SET db
17c0: 63 68 69 6c 64 20 20 3d 20 4e 55 4c 4c 2c 20 63  child  = NULL, c
17d0: 68 69 6c 64 20 20 3d 20 24 74 6a 6f 69 6e 74 20  hild  = $tjoint 
17e0: 57 48 45 52 45 20 72 69 64 20 3d 20 24 6a 6f 69  WHERE rid = $joi
17f0: 6e 74 20 20 3b 0a 09 20 20 20 20 7d 0a 09 20 20  nt  ;..    }..  
1800: 20 20 77 68 69 6c 65 20 7b 31 7d 20 7b 0a 09 09    while {1} {...
1810: 23 20 4d 6f 76 65 20 74 68 65 20 4e 54 44 42 20  # Move the NTDB 
1820: 74 72 75 6e 6b 20 72 65 76 69 73 69 6f 6e 73 20  trunk revisions 
1830: 74 6f 20 74 72 75 6e 6b 2e 0a 09 09 73 74 61 74  to trunk....stat
1840: 65 20 72 75 6e 20 7b 0a 09 09 20 20 20 20 55 50  e run {...    UP
1850: 44 41 54 45 20 72 65 76 69 73 69 6f 6e 20 53 45  DATE revision SE
1860: 54 20 6c 6f 64 20 3d 20 24 74 6c 6f 64 2c 20 69  T lod = $tlod, i
1870: 73 64 65 66 61 75 6c 74 20 3d 20 30 20 57 48 45  sdefault = 0 WHE
1880: 52 45 20 72 69 64 20 3d 20 24 6a 6f 69 6e 74 0a  RE rid = $joint.
1890: 09 09 7d 0a 09 09 73 65 74 20 6c 61 73 74 20 24  ..}...set last $
18a0: 6a 6f 69 6e 74 0a 09 09 73 65 74 20 6a 6f 69 6e  joint...set join
18b0: 74 20 24 6e 74 64 62 28 24 6a 6f 69 6e 74 29 0a  t $ntdb($joint).
18c0: 09 09 69 66 20 7b 21 5b 69 6e 66 6f 20 65 78 69  ..if {![info exi
18d0: 73 74 73 20 6e 74 64 62 28 24 6a 6f 69 6e 74 29  sts ntdb($joint)
18e0: 5d 7d 20 62 72 65 61 6b 0a 09 20 20 20 20 7d 0a  ]} break..    }.
18f0: 0a 09 20 20 20 20 23 20 52 65 61 63 68 65 64 20  ..    # Reached 
1900: 74 68 65 20 4e 54 44 42 20 62 61 73 69 73 20 69  the NTDB basis i
1910: 6e 20 74 68 65 20 74 72 75 6e 6b 2e 20 46 69 6e  n the trunk. Fin
1920: 61 6c 69 7a 65 20 74 68 65 0a 09 20 20 20 20 23  alize the..    #
1930: 20 70 61 72 65 6e 74 2f 63 68 69 6c 64 20 6c 69   parent/child li
1940: 6e 6b 61 67 65 20 61 6e 64 20 73 71 75 61 73 68  nkage and squash
1950: 20 74 68 65 20 62 72 61 6e 63 68 20 70 61 72 65   the branch pare
1960: 6e 74 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20 23  nt symbol..    #
1970: 20 72 65 66 65 72 65 6e 63 65 2e 0a 0a 09 20 20   reference....  
1980: 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09    state run {...
1990: 55 50 44 41 54 45 20 72 65 76 69 73 69 6f 6e 20  UPDATE revision 
19a0: 53 45 54 20 63 68 69 6c 64 20 20 20 3d 20 24 6c  SET child   = $l
19b0: 61 73 74 20 57 48 45 52 45 20 72 69 64 20 3d 20  ast WHERE rid = 
19c0: 24 6a 6f 69 6e 74 20 3b 0a 09 09 55 50 44 41 54  $joint ;...UPDAT
19d0: 45 20 72 65 76 69 73 69 6f 6e 20 53 45 54 20 62  E revision SET b
19e0: 70 61 72 65 6e 74 20 3d 20 4e 55 4c 4c 20 20 57  parent = NULL  W
19f0: 48 45 52 45 20 72 69 64 20 3d 20 24 6c 61 73 74  HERE rid = $last
1a00: 20 20 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09    ;..    }..}...
1a10: 23 20 4e 6f 77 20 74 68 61 74 20 74 68 65 20 73  # Now that the s
1a20: 70 65 63 69 61 6c 20 63 61 73 65 20 69 73 20 64  pecial case is d
1a30: 6f 6e 65 20 77 65 20 63 61 6e 20 73 69 6d 70 6c  one we can simpl
1a40: 79 20 6b 69 6c 6c 20 61 6c 6c 20 74 68 65 0a 09  y kill all the..
1a50: 23 20 72 65 76 69 73 69 6f 6e 73 2c 20 74 61 67  # revisions, tag
1a60: 73 2c 20 61 6e 64 20 62 72 61 6e 63 68 65 73 20  s, and branches 
1a70: 72 65 66 65 72 65 6e 63 69 6e 67 20 61 6e 79 20  referencing any 
1a80: 6f 66 20 74 68 65 0a 09 23 20 65 78 63 6c 75 64  of the..# exclud
1a90: 65 64 20 73 79 6d 62 6f 6c 73 20 69 6e 20 73 6f  ed symbols in so
1aa0: 6d 65 20 77 61 79 2e 20 54 68 69 73 20 69 73 20  me way. This is 
1ab0: 65 61 73 79 20 61 73 20 77 65 20 64 6f 20 6e 6f  easy as we do no
1ac0: 74 20 68 61 76 65 0a 09 23 20 74 6f 20 73 65 6c  t have..# to sel
1ad0: 65 63 74 20 74 68 65 6d 20 61 67 61 69 6e 20 61  ect them again a
1ae0: 6e 64 20 61 67 61 69 6e 20 66 72 6f 6d 20 74 68  nd again from th
1af0: 65 20 62 61 73 65 20 74 61 62 6c 65 73 20 61 6e  e base tables an
1b00: 79 0a 09 23 20 6c 6f 6e 67 65 72 2e 0a 0a 09 73  y..# longer....s
1b10: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
1b20: 43 52 45 41 54 45 20 54 45 4d 50 4f 52 41 52 59  CREATE TEMPORARY
1b30: 20 54 41 42 4c 45 20 65 78 63 6c 75 64 65 64 72   TABLE excludedr
1b40: 65 76 69 73 69 6f 6e 73 20 41 53 0a 09 20 20 20  evisions AS..   
1b50: 20 53 45 4c 45 43 54 20 72 69 64 20 46 52 4f 4d   SELECT rid FROM
1b60: 20 72 65 76 69 73 69 6f 6e 20 57 48 45 52 45 20   revision WHERE 
1b70: 6c 6f 64 20 49 4e 20 65 78 63 6c 75 64 65 64 73  lod IN excludeds
1b80: 79 6d 62 6f 6c 73 3b 0a 0a 09 20 20 20 20 44 45  ymbols;...    DE
1b90: 4c 45 54 45 20 46 52 4f 4d 20 72 65 76 69 73 69  LETE FROM revisi
1ba0: 6f 6e 20 57 48 45 52 45 20 6c 6f 64 20 49 4e 20  on WHERE lod IN 
1bb0: 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73 3b  excludedsymbols;
1bc0: 0a 09 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f  ..    DELETE FRO
1bd0: 4d 20 74 61 67 20 20 20 20 20 20 57 48 45 52 45  M tag      WHERE
1be0: 20 6c 6f 64 20 49 4e 20 65 78 63 6c 75 64 65 64   lod IN excluded
1bf0: 73 79 6d 62 6f 6c 73 3b 0a 09 20 20 20 20 44 45  symbols;..    DE
1c00: 4c 45 54 45 20 46 52 4f 4d 20 74 61 67 20 20 20  LETE FROM tag   
1c10: 20 20 20 57 48 45 52 45 20 73 69 64 20 49 4e 20     WHERE sid IN 
1c20: 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73 3b  excludedsymbols;
1c30: 0a 09 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f  ..    DELETE FRO
1c40: 4d 20 62 72 61 6e 63 68 20 20 20 57 48 45 52 45  M branch   WHERE
1c50: 20 6c 6f 64 20 49 4e 20 65 78 63 6c 75 64 65 64   lod IN excluded
1c60: 73 79 6d 62 6f 6c 73 3b 0a 09 20 20 20 20 44 45  symbols;..    DE
1c70: 4c 45 54 45 20 46 52 4f 4d 20 62 72 61 6e 63 68  LETE FROM branch
1c80: 20 20 20 57 48 45 52 45 20 73 69 64 20 49 4e 20     WHERE sid IN 
1c90: 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73 3b  excludedsymbols;
1ca0: 0a 0a 09 20 20 20 20 44 45 4c 45 54 45 20 46 52  ...    DELETE FR
1cb0: 4f 4d 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63  OM revisionbranc
1cc0: 68 63 68 69 6c 64 72 65 6e 20 57 48 45 52 45 20  hchildren WHERE 
1cd0: 72 69 64 20 20 49 4e 20 65 78 63 6c 75 64 65 64  rid  IN excluded
1ce0: 72 65 76 69 73 69 6f 6e 73 3b 0a 09 20 20 20 20  revisions;..    
1cf0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 76 69  DELETE FROM revi
1d00: 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72  sionbranchchildr
1d10: 65 6e 20 57 48 45 52 45 20 62 72 69 64 20 49 4e  en WHERE brid IN
1d20: 20 65 78 63 6c 75 64 65 64 72 65 76 69 73 69 6f   excludedrevisio
1d30: 6e 73 3b 0a 0a 09 20 20 20 20 44 52 4f 50 20 54  ns;...    DROP T
1d40: 41 42 4c 45 20 65 78 63 6c 75 64 65 64 72 65 76  ABLE excludedrev
1d50: 69 73 69 6f 6e 73 3b 0a 09 20 20 20 20 44 52 4f  isions;..    DRO
1d60: 50 20 54 41 42 4c 45 20 65 78 63 6c 75 64 65 64  P TABLE excluded
1d70: 73 79 6d 62 6f 6c 73 3b 0a 09 7d 0a 09 72 65 74  symbols;..}..ret
1d80: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70  urn.    }..    p
1d90: 72 6f 63 20 4d 75 74 61 74 65 53 79 6d 62 6f 6c  roc MutateSymbol
1da0: 73 20 7b 7d 20 7b 0a 09 23 20 4e 65 78 74 2c 20  s {} {..# Next, 
1db0: 6e 6f 77 20 74 68 61 74 20 77 65 20 6b 6e 6f 77  now that we know
1dc0: 20 77 68 69 63 68 20 73 79 6d 62 6f 6c 73 20 61   which symbols a
1dd0: 72 65 20 77 68 61 74 20 77 65 20 6c 6f 6f 6b 20  re what we look 
1de0: 66 6f 72 0a 09 23 20 66 69 6c 65 20 6c 65 76 65  for..# file leve
1df0: 6c 20 74 61 67 73 20 77 68 69 63 68 20 61 72 65  l tags which are
1e00: 20 61 63 74 75 61 6c 6c 79 20 63 6f 6e 76 65 72   actually conver
1e10: 74 65 64 20 61 73 20 62 72 61 6e 63 68 65 73 0a  ted as branches.
1e20: 09 23 20 28 70 72 6f 6a 65 63 74 20 6c 65 76 65  .# (project leve
1e30: 6c 2c 20 61 6e 64 20 76 69 63 65 20 76 65 72 73  l, and vice vers
1e40: 61 29 2c 20 61 6e 64 20 6d 6f 76 65 20 74 68 65  a), and move the
1e50: 6d 20 74 6f 20 74 68 65 0a 09 23 20 63 6f 72 72  m to the..# corr
1e60: 65 63 74 20 74 61 62 6c 65 73 2e 0a 0a 09 23 20  ect tables....# 
1e70: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
1e80: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
1e90: 23 23 23 23 23 0a 0a 09 6c 6f 67 20 77 72 69 74  #####...log writ
1ea0: 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 4d  e 3 filtersym "M
1eb0: 75 74 61 74 65 20 73 79 6d 62 6f 6c 73 2c 20 70  utate symbols, p
1ec0: 72 65 70 61 72 61 74 69 6f 6e 22 0a 0a 09 73 65  reparation"...se
1ed0: 74 20 62 72 61 6e 63 68 20 5b 70 72 6f 6a 65 63  t branch [projec
1ee0: 74 3a 3a 73 79 6d 20 62 72 61 6e 63 68 5d 0a 09  t::sym branch]..
1ef0: 73 65 74 20 74 61 67 20 20 20 20 5b 70 72 6f 6a  set tag    [proj
1f00: 65 63 74 3a 3a 73 79 6d 20 74 61 67 5d 0a 0a 09  ect::sym tag]...
1f10: 73 65 74 20 74 61 67 73 74 6f 6d 75 74 61 74 65  set tagstomutate
1f20: 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20   [state run {.. 
1f30: 20 20 20 53 45 4c 45 43 54 20 54 2e 74 69 64 2c     SELECT T.tid,
1f40: 20 54 2e 66 69 64 2c 20 54 2e 6c 6f 64 2c 20 54   T.fid, T.lod, T
1f50: 2e 73 69 64 2c 20 54 2e 72 65 76 0a 09 20 20 20  .sid, T.rev..   
1f60: 20 46 52 4f 4d 20 74 61 67 20 54 2c 20 73 79 6d   FROM tag T, sym
1f70: 62 6f 6c 20 53 0a 09 20 20 20 20 57 48 45 52 45  bol S..    WHERE
1f80: 20 54 2e 73 69 64 20 3d 20 53 2e 73 69 64 0a 09   T.sid = S.sid..
1f90: 20 20 20 20 41 4e 44 20 53 2e 74 79 70 65 20 3d      AND S.type =
1fa0: 20 24 62 72 61 6e 63 68 0a 09 7d 5d 0a 0a 09 73   $branch..}]...s
1fb0: 65 74 20 62 72 61 6e 63 68 65 73 74 6f 6d 75 74  et branchestomut
1fc0: 61 74 65 20 5b 73 74 61 74 65 20 72 75 6e 20 7b  ate [state run {
1fd0: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62  ..    SELECT B.b
1fe0: 69 64 2c 20 42 2e 66 69 64 2c 20 42 2e 6c 6f 64  id, B.fid, B.lod
1ff0: 2c 20 42 2e 73 69 64 2c 20 42 2e 72 6f 6f 74 2c  , B.sid, B.root,
2000: 20 42 2e 66 69 72 73 74 2c 20 42 2e 62 72 61 0a   B.first, B.bra.
2010: 09 20 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68  .    FROM branch
2020: 20 42 2c 20 73 79 6d 62 6f 6c 20 53 0a 09 20 20   B, symbol S..  
2030: 20 20 57 48 45 52 45 20 42 2e 73 69 64 20 3d 20    WHERE B.sid = 
2040: 53 2e 73 69 64 0a 09 20 20 20 20 41 4e 44 20 53  S.sid..    AND S
2050: 2e 74 79 70 65 20 3d 20 24 74 61 67 0a 09 7d 5d  .type = $tag..}]
2060: 0a 0a 09 73 65 74 20 6e 74 20 5b 65 78 70 72 20  ...set nt [expr 
2070: 7b 5b 6c 6c 65 6e 67 74 68 20 24 74 61 67 73 74  {[llength $tagst
2080: 6f 6d 75 74 61 74 65 5d 2f 35 7d 5d 0a 09 73 65  omutate]/5}]..se
2090: 74 20 6e 62 20 5b 65 78 70 72 20 7b 5b 6c 6c 65  t nb [expr {[lle
20a0: 6e 67 74 68 20 24 62 72 61 6e 63 68 65 73 74 6f  ngth $branchesto
20b0: 6d 75 74 61 74 65 5d 2f 37 7d 5d 0a 0a 09 6c 6f  mutate]/7}]...lo
20c0: 67 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72  g write 4 filter
20d0: 73 79 6d 20 22 43 68 61 6e 67 69 6e 67 20 5b 6e  sym "Changing [n
20e0: 73 70 20 24 6e 74 20 74 61 67 5d 20 69 6e 74 6f  sp $nt tag] into
20f0: 20 20 5b 6e 73 70 20 24 6e 74 20 62 72 61 6e 63    [nsp $nt branc
2100: 68 20 62 72 61 6e 63 68 65 73 5d 22 0a 09 6c 6f  h branches]"..lo
2110: 67 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72  g write 4 filter
2120: 73 79 6d 20 22 43 68 61 6e 67 69 6e 67 20 5b 6e  sym "Changing [n
2130: 73 70 20 24 6e 62 20 62 72 61 6e 63 68 20 62 72  sp $nb branch br
2140: 61 6e 63 68 65 73 5d 20 69 6e 74 6f 20 20 5b 6e  anches] into  [n
2150: 73 70 20 24 6e 62 20 74 61 67 5d 22 0a 0a 09 23  sp $nb tag]"...#
2160: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
2170: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
2180: 23 23 23 23 23 23 0a 0a 09 6c 6f 67 20 77 72 69  ######...log wri
2190: 74 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22  te 3 filtersym "
21a0: 4d 75 74 61 74 65 20 74 61 67 73 20 74 6f 20 62  Mutate tags to b
21b0: 72 61 6e 63 68 65 73 22 0a 0a 09 66 6f 72 65 61  ranches"...forea
21c0: 63 68 20 7b 69 64 20 66 69 64 20 6c 6f 64 20 73  ch {id fid lod s
21d0: 69 64 20 72 65 76 7d 20 24 74 61 67 73 74 6f 6d  id rev} $tagstom
21e0: 75 74 61 74 65 20 7b 0a 09 20 20 20 20 73 74 61  utate {..    sta
21f0: 74 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54  te run {...DELET
2200: 45 20 46 52 4f 4d 20 74 61 67 20 57 48 45 52 45  E FROM tag WHERE
2210: 20 74 69 64 20 3d 20 24 69 64 20 3b 0a 09 09 49   tid = $id ;...I
2220: 4e 53 45 52 54 20 49 4e 54 4f 20 62 72 61 6e 63  NSERT INTO branc
2230: 68 20 28 62 69 64 2c 20 66 69 64 2c 20 20 6c 6f  h (bid, fid,  lo
2240: 64 2c 20 20 73 69 64 2c 20 20 72 6f 6f 74 2c 20  d,  sid,  root, 
2250: 66 69 72 73 74 2c 20 62 72 61 2c 20 70 6f 73 29  first, bra, pos)
2260: 0a 09 09 56 41 4c 55 45 53 20 20 20 20 20 20 20  ...VALUES       
2270: 20 20 20 20 20 20 28 24 69 64 2c 20 24 66 69 64        ($id, $fid
2280: 2c 20 24 6c 6f 64 2c 20 24 73 69 64 2c 20 24 72  , $lod, $sid, $r
2290: 65 76 2c 20 4e 55 4c 4c 2c 20 20 27 27 2c 20 20  ev, NULL,  '',  
22a0: 2d 31 29 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  -1);..    }..}..
22b0: 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c  .log write 3 fil
22c0: 74 65 72 73 79 6d 20 22 4f 6b 2e 22 0a 0a 09 23  tersym "Ok."...#
22d0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
22e0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
22f0: 23 23 23 23 23 23 0a 0a 09 6c 6f 67 20 77 72 69  ######...log wri
2300: 74 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22  te 3 filtersym "
2310: 4d 75 74 61 74 65 20 62 72 61 6e 63 68 65 73 20  Mutate branches 
2320: 74 6f 20 74 61 67 73 22 0a 0a 09 66 6f 72 65 61  to tags"...forea
2330: 63 68 20 7b 69 64 20 66 69 64 20 6c 6f 64 20 73  ch {id fid lod s
2340: 69 64 20 72 6f 6f 74 20 66 69 72 73 74 20 62 72  id root first br
2350: 61 7d 20 24 62 72 61 6e 63 68 65 73 74 6f 6d 75  a} $branchestomu
2360: 74 61 74 65 20 7b 0a 09 20 20 20 20 73 74 61 74  tate {..    stat
2370: 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54 45  e run {...DELETE
2380: 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 57 48 45   FROM branch WHE
2390: 52 45 20 62 69 64 20 3d 20 24 69 64 20 3b 0a 09  RE bid = $id ;..
23a0: 09 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 61 67  .INSERT INTO tag
23b0: 20 28 74 69 64 2c 20 66 69 64 2c 20 20 6c 6f 64   (tid, fid,  lod
23c0: 2c 20 20 73 69 64 2c 20 20 72 65 76 29 0a 09 09  ,  sid,  rev)...
23d0: 56 41 4c 55 45 53 20 20 20 20 20 20 20 20 20 20  VALUES          
23e0: 28 24 69 64 2c 20 24 66 69 64 2c 20 24 6c 6f 64  ($id, $fid, $lod
23f0: 2c 20 24 73 69 64 2c 20 24 72 6f 6f 74 29 3b 0a  , $sid, $root);.
2400: 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 6c 6f 67 20  .    }..}...log 
2410: 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73 79  write 3 filtersy
2420: 6d 20 22 4f 6b 2e 22 0a 0a 09 23 20 23 20 23 23  m "Ok."...# # ##
2430: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
2440: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
2450: 23 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  #..return.    }.
2460: 0a 20 20 20 20 23 20 41 64 6a 75 73 74 20 74 68  .    # Adjust th
2470: 65 20 70 61 72 65 6e 74 73 20 6f 66 20 73 79 6d  e parents of sym
2480: 62 6f 6c 73 20 74 6f 20 74 68 65 69 72 20 70 72  bols to their pr
2490: 65 66 65 72 72 65 64 20 70 61 72 65 6e 74 73 2e  eferred parents.
24a0: 0a 0a 20 20 20 20 23 20 49 66 20 61 20 66 69 6c  ..    # If a fil
24b0: 65 20 6c 65 76 65 6c 20 79 6d 62 6f 6c 20 68 61  e level ymbol ha
24c0: 73 20 61 20 70 72 65 66 65 72 72 65 64 20 70 61  s a preferred pa
24d0: 72 65 6e 74 20 74 68 61 74 20 69 73 20 64 69 66  rent that is dif
24e0: 66 65 72 65 6e 74 0a 20 20 20 20 23 20 74 68 61  ferent.    # tha
24f0: 6e 20 69 74 73 20 63 75 72 72 65 6e 74 20 70 61  n its current pa
2500: 72 65 6e 74 2c 20 61 6e 64 20 69 66 20 74 68 65  rent, and if the
2510: 20 70 72 65 66 65 72 72 65 64 20 70 61 72 65 6e   preferred paren
2520: 74 20 69 73 20 61 6e 0a 20 20 20 20 23 20 61 6c  t is an.    # al
2530: 6c 6f 77 65 64 20 70 61 72 65 6e 74 20 6f 66 20  lowed parent of 
2540: 74 68 65 20 73 79 6d 62 6f 6c 20 69 6e 20 74 68  the symbol in th
2550: 69 73 20 66 69 6c 65 2c 20 74 68 65 6e 20 77 65  is file, then we
2560: 20 67 72 61 66 74 20 74 68 65 0a 20 20 20 20 23   graft the.    #
2570: 20 61 53 79 6d 62 6f 6c 20 6f 6e 74 6f 20 69 74   aSymbol onto it
2580: 73 20 70 72 65 66 65 72 72 65 64 20 70 61 72 65  s preferred pare
2590: 6e 74 2e 0a 0a 20 20 20 20 70 72 6f 63 20 41 64  nt...    proc Ad
25a0: 6a 75 73 74 50 61 72 65 6e 74 73 20 7b 7d 20 7b  justParents {} {
25b0: 0a 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69  ..log write 3 fi
25c0: 6c 74 65 72 73 79 6d 20 22 41 64 6a 75 73 74 20  ltersym "Adjust 
25d0: 70 61 72 65 6e 74 73 2c 20 6c 6f 61 64 69 6e 67  parents, loading
25e0: 20 64 61 74 61 20 69 6e 20 70 72 65 70 61 72 61   data in prepara
25f0: 74 69 6f 6e 22 0a 0a 09 23 20 57 65 20 70 75 6c  tion"...# We pul
2600: 6c 20 69 6d 70 6f 72 74 61 6e 74 20 6d 61 70 73  l important maps
2610: 20 6f 6e 63 65 20 69 6e 74 6f 20 6d 65 6d 6f 72   once into memor
2620: 79 20 73 6f 20 74 68 61 74 20 77 65 20 64 6f 20  y so that we do 
2630: 71 75 69 63 6b 0a 09 23 20 68 61 73 68 20 6c 6f  quick..# hash lo
2640: 6f 6b 75 70 20 6c 61 74 65 72 20 77 68 65 6e 20  okup later when 
2650: 70 72 6f 63 65 73 73 69 6e 67 20 74 68 65 20 67  processing the g
2660: 72 61 66 74 20 63 61 6e 64 69 64 61 74 65 73 2e  raft candidates.
2670: 0a 0a 09 23 20 54 61 67 2f 42 72 61 6e 63 68 20  ...# Tag/Branch 
2680: 6e 61 6d 65 73 20 2e 2e 2e 0a 09 61 72 72 61 79  names .....array
2690: 20 73 65 74 20 73 6e 20 5b 73 74 61 74 65 20 72   set sn [state r
26a0: 75 6e 20 7b 20 53 45 4c 45 43 54 20 54 2e 74 69  un { SELECT T.ti
26b0: 64 2c 20 53 2e 6e 61 6d 65 20 46 52 4f 4d 20 74  d, S.name FROM t
26c0: 61 67 20 54 2c 20 20 20 20 73 79 6d 62 6f 6c 20  ag T,    symbol 
26d0: 53 20 57 48 45 52 45 20 54 2e 73 69 64 20 3d 20  S WHERE T.sid = 
26e0: 53 2e 73 69 64 20 7d 5d 0a 09 61 72 72 61 79 20  S.sid }]..array 
26f0: 73 65 74 20 73 6e 20 5b 73 74 61 74 65 20 72 75  set sn [state ru
2700: 6e 20 7b 20 53 45 4c 45 43 54 20 42 2e 62 69 64  n { SELECT B.bid
2710: 2c 20 53 2e 6e 61 6d 65 20 46 52 4f 4d 20 62 72  , S.name FROM br
2720: 61 6e 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20 53  anch B, symbol S
2730: 20 57 48 45 52 45 20 42 2e 73 69 64 20 3d 20 53   WHERE B.sid = S
2740: 2e 73 69 64 20 7d 5d 0a 09 23 20 53 79 6d 62 6f  .sid }]..# Symbo
2750: 6c 20 6e 61 6d 65 73 20 2e 2e 2e 0a 09 61 72 72  l names .....arr
2760: 61 79 20 73 65 74 20 73 78 20 5b 73 74 61 74 65  ay set sx [state
2770: 20 72 75 6e 20 7b 20 53 45 4c 45 43 54 20 4c 2e   run { SELECT L.
2780: 73 69 64 2c 20 4c 2e 6e 61 6d 65 20 46 52 4f 4d  sid, L.name FROM
2790: 20 73 79 6d 62 6f 6c 20 4c 20 7d 5d 0a 09 23 20   symbol L }]..# 
27a0: 46 69 6c 65 73 20 61 6e 64 20 70 72 6f 6a 65 63  Files and projec
27b0: 74 73 2e 0a 09 61 72 72 61 79 20 73 65 74 20 66  ts...array set f
27c0: 70 6e 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b  pn {}..foreach {
27d0: 69 64 20 66 6e 20 70 6e 7d 20 5b 73 74 61 74 65  id fn pn} [state
27e0: 20 72 75 6e 20 7b 0a 09 09 53 45 4c 45 43 54 20   run {...SELECT 
27f0: 46 2e 66 69 64 2c 20 46 2e 6e 61 6d 65 2c 20 50  F.fid, F.name, P
2800: 2e 6e 61 6d 65 0a 09 09 46 52 4f 4d 20 20 20 66  .name...FROM   f
2810: 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50  ile F, project P
2820: 0a 09 09 57 48 45 52 45 20 20 46 2e 70 69 64 20  ...WHERE  F.pid 
2830: 3d 20 50 2e 70 69 64 0a 09 7d 5d 20 7b 20 73 65  = P.pid..}] { se
2840: 74 20 66 70 6e 28 24 69 64 29 20 5b 6c 69 73 74  t fpn($id) [list
2850: 20 24 66 6e 20 24 70 6e 5d 20 7d 0a 0a 09 73 65   $fn $pn] }...se
2860: 74 20 74 61 67 73 74 6f 61 64 6a 75 73 74 20 5b  t tagstoadjust [
2870: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20  state run {..   
2880: 20 53 45 4c 45 43 54 20 54 2e 74 69 64 2c 20 54   SELECT T.tid, T
2890: 2e 66 69 64 2c 20 54 2e 6c 6f 64 2c 20 50 2e 70  .fid, T.lod, P.p
28a0: 69 64 2c 20 53 2e 6e 61 6d 65 2c 20 52 2e 72 65  id, S.name, R.re
28b0: 76 2c 20 52 2e 72 69 64 0a 09 20 20 20 20 46 52  v, R.rid..    FR
28c0: 4f 4d 20 74 61 67 20 54 2c 20 70 72 65 66 65 72  OM tag T, prefer
28d0: 65 64 70 61 72 65 6e 74 20 50 2c 20 73 79 6d 62  edparent P, symb
28e0: 6f 6c 20 53 2c 20 72 65 76 69 73 69 6f 6e 20 52  ol S, revision R
28f0: 0a 09 20 20 20 20 57 48 45 52 45 20 54 2e 73 69  ..    WHERE T.si
2900: 64 20 3d 20 50 2e 73 69 64 20 20 20 20 20 20 20  d = P.sid       
2910: 20 2d 2d 20 46 6f 72 20 61 6c 6c 20 74 61 67 73   -- For all tags
2920: 2c 20 67 65 74 20 6c 65 66 74 2d 68 61 6e 64 20  , get left-hand 
2930: 6f 66 20 70 72 65 66 65 72 65 64 20 70 61 72 65  of prefered pare
2940: 6e 74 20 76 69 61 20 73 79 6d 62 6f 6c 0a 09 20  nt via symbol.. 
2950: 20 20 20 41 4e 44 20 20 20 54 2e 6c 6f 64 20 21     AND   T.lod !
2960: 3d 20 50 2e 70 69 64 20 20 20 20 20 20 20 2d 2d  = P.pid       --
2970: 20 52 65 73 74 72 69 63 74 20 74 6f 20 74 61 67   Restrict to tag
2980: 73 20 77 68 6f 73 65 20 4c 4f 44 20 69 73 20 6e  s whose LOD is n
2990: 6f 74 20 74 68 65 69 72 20 70 72 65 66 65 72 65  ot their prefere
29a0: 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e  d parent..    AN
29b0: 44 20 20 20 50 2e 70 69 64 20 3d 20 53 2e 73 69  D   P.pid = S.si
29c0: 64 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20  d        -- Get 
29d0: 73 79 6d 62 6f 6c 20 6f 66 20 70 72 65 66 65 72  symbol of prefer
29e0: 65 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41  ed parent..    A
29f0: 4e 44 20 20 20 53 2e 6e 61 6d 65 20 21 3d 20 27  ND   S.name != '
2a00: 3a 74 72 75 6e 6b 3a 27 20 20 2d 2d 20 45 78 63  :trunk:'  -- Exc
2a10: 6c 75 64 65 20 74 72 75 6e 6b 20 70 61 72 65 6e  lude trunk paren
2a20: 74 61 67 65 0a 09 20 20 20 20 41 4e 44 20 20 20  tage..    AND   
2a30: 54 2e 72 65 76 20 3d 20 52 2e 72 69 64 20 20 20  T.rev = R.rid   
2a40: 20 20 20 20 20 2d 2d 20 47 65 74 20 72 65 76 69       -- Get revi
2a50: 73 69 6f 6e 20 74 68 65 20 74 61 67 20 69 73 20  sion the tag is 
2a60: 61 74 74 61 63 68 65 64 20 74 6f 2e 0a 09 7d 5d  attached to...}]
2a70: 0a 0a 09 73 65 74 20 62 72 61 6e 63 68 65 73 74  ...set branchest
2a80: 6f 61 64 6a 75 73 74 20 5b 73 74 61 74 65 20 72  oadjust [state r
2a90: 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  un {..    SELECT
2aa0: 20 42 2e 62 69 64 2c 20 42 2e 66 69 64 2c 20 42   B.bid, B.fid, B
2ab0: 2e 6c 6f 64 2c 20 42 2e 70 6f 73 2c 20 50 2e 70  .lod, B.pos, P.p
2ac0: 69 64 2c 20 53 2e 6e 61 6d 65 2c 20 4e 55 4c 4c  id, S.name, NULL
2ad0: 2c 20 4e 55 4c 4c 0a 09 20 20 20 20 46 52 4f 4d  , NULL..    FROM
2ae0: 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65   branch B, prefe
2af0: 72 65 64 70 61 72 65 6e 74 20 50 2c 20 73 79 6d  redparent P, sym
2b00: 62 6f 6c 20 53 0a 09 20 20 20 20 57 48 45 52 45  bol S..    WHERE
2b10: 20 42 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 20   B.sid = P.sid  
2b20: 20 20 20 20 20 20 2d 2d 20 46 6f 72 20 61 6c 6c        -- For all
2b30: 20 62 72 61 6e 63 68 65 73 2c 20 67 65 74 20 6c   branches, get l
2b40: 65 66 74 2d 68 61 6e 64 20 6f 66 20 70 72 65 66  eft-hand of pref
2b50: 65 72 65 64 20 70 61 72 65 6e 74 20 76 69 61 20  ered parent via 
2b60: 73 79 6d 62 6f 6c 0a 09 20 20 20 20 41 4e 44 20  symbol..    AND 
2b70: 20 20 42 2e 6c 6f 64 20 21 3d 20 50 2e 70 69 64    B.lod != P.pid
2b80: 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69         -- Restri
2b90: 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 77  ct to branches w
2ba0: 68 6f 73 65 20 4c 4f 44 20 69 73 20 6e 6f 74 20  hose LOD is not 
2bb0: 74 68 65 69 72 20 70 72 65 66 65 72 65 64 20 70  their prefered p
2bc0: 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44 20 20  arent..    AND  
2bd0: 20 50 2e 70 69 64 20 3d 20 53 2e 73 69 64 20 20   P.pid = S.sid  
2be0: 20 20 20 20 20 20 2d 2d 20 47 65 74 20 73 79 6d        -- Get sym
2bf0: 62 6f 6c 20 6f 66 20 70 72 65 66 65 72 65 64 20  bol of prefered 
2c00: 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44 20  parent..    AND 
2c10: 20 20 53 2e 6e 61 6d 65 20 21 3d 20 27 3a 74 72    S.name != ':tr
2c20: 75 6e 6b 3a 27 20 20 2d 2d 20 45 78 63 6c 75 64  unk:'  -- Exclud
2c30: 65 20 74 72 75 6e 6b 20 70 61 72 65 6e 74 61 67  e trunk parentag
2c40: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 42 2e 72  e..    AND   B.r
2c50: 6f 6f 74 20 49 53 20 4e 55 4c 4c 20 20 20 20 20  oot IS NULL     
2c60: 20 20 2d 2d 20 41 63 63 65 70 74 20 66 72 65 65    -- Accept free
2c70: 2d 66 6c 6f 61 74 69 6e 67 20 62 72 61 6e 63 68  -floating branch
2c80: 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20  .    UNION..    
2c90: 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 2e  SELECT B.bid, B.
2ca0: 66 69 64 2c 20 42 2e 6c 6f 64 2c 20 42 2e 70 6f  fid, B.lod, B.po
2cb0: 73 2c 20 50 2e 70 69 64 2c 20 53 2e 6e 61 6d 65  s, P.pid, S.name
2cc0: 2c 20 52 2e 72 65 76 2c 20 52 2e 72 69 64 0a 09  , R.rev, R.rid..
2cd0: 20 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20      FROM branch 
2ce0: 42 2c 20 70 72 65 66 65 72 65 64 70 61 72 65 6e  B, preferedparen
2cf0: 74 20 50 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 72  t P, symbol S, r
2d00: 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57  evision R..    W
2d10: 48 45 52 45 20 42 2e 73 69 64 20 3d 20 50 2e 73  HERE B.sid = P.s
2d20: 69 64 20 20 20 20 20 20 20 20 2d 2d 20 46 6f 72  id        -- For
2d30: 20 61 6c 6c 20 62 72 61 6e 63 68 65 73 2c 20 67   all branches, g
2d40: 65 74 20 6c 65 66 74 2d 68 61 6e 64 20 6f 66 20  et left-hand of 
2d50: 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20  prefered parent 
2d60: 76 69 61 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20  via symbol..    
2d70: 41 4e 44 20 20 20 42 2e 6c 6f 64 20 21 3d 20 50  AND   B.lod != P
2d80: 2e 70 69 64 20 20 20 20 20 20 20 2d 2d 20 52 65  .pid       -- Re
2d90: 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68  strict to branch
2da0: 65 73 20 77 68 6f 73 65 20 4c 4f 44 20 69 73 20  es whose LOD is 
2db0: 6e 6f 74 20 74 68 65 69 72 20 70 72 65 66 65 72  not their prefer
2dc0: 65 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41  ed parent..    A
2dd0: 4e 44 20 20 20 50 2e 70 69 64 20 3d 20 53 2e 73  ND   P.pid = S.s
2de0: 69 64 09 20 20 20 20 20 20 20 2d 2d 20 47 65 74  id.       -- Get
2df0: 20 73 79 6d 62 6f 6c 20 6f 66 20 70 72 65 66 65   symbol of prefe
2e00: 72 65 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20  red parent..    
2e10: 41 4e 44 20 20 20 53 2e 6e 61 6d 65 20 21 3d 20  AND   S.name != 
2e20: 27 3a 74 72 75 6e 6b 3a 27 20 20 2d 2d 20 45 78  ':trunk:'  -- Ex
2e30: 63 6c 75 64 65 20 74 72 75 6e 6b 20 70 61 72 65  clude trunk pare
2e40: 6e 74 61 67 65 0a 09 20 20 20 20 41 4e 44 20 20  ntage..    AND  
2e50: 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69 64 20   B.root = R.rid 
2e60: 20 20 20 20 20 20 2d 2d 20 47 65 74 20 72 6f 6f        -- Get roo
2e70: 74 20 72 65 76 69 73 69 6f 6e 20 6f 66 20 74 68  t revision of th
2e80: 65 20 62 72 61 6e 63 68 0a 09 7d 5d 0a 0a 09 73  e branch..}]...s
2e90: 65 74 20 74 6d 61 78 20 5b 65 78 70 72 20 7b 5b  et tmax [expr {[
2ea0: 6c 6c 65 6e 67 74 68 20 24 74 61 67 73 74 6f 61  llength $tagstoa
2eb0: 64 6a 75 73 74 5d 20 2f 20 37 7d 5d 0a 09 73 65  djust] / 7}]..se
2ec0: 74 20 62 6d 61 78 20 5b 65 78 70 72 20 7b 5b 6c  t bmax [expr {[l
2ed0: 6c 65 6e 67 74 68 20 24 62 72 61 6e 63 68 65 73  length $branches
2ee0: 74 6f 61 64 6a 75 73 74 5d 20 2f 20 38 7d 5d 0a  toadjust] / 8}].
2ef0: 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69  ..log write 4 fi
2f00: 6c 74 65 72 73 79 6d 20 22 52 65 70 61 72 65 6e  ltersym "Reparen
2f10: 74 69 6e 67 20 61 74 20 6d 6f 73 74 20 5b 6e 73  ting at most [ns
2f20: 70 20 24 74 6d 61 78 20 74 61 67 5d 22 0a 09 6c  p $tmax tag]"..l
2f30: 6f 67 20 77 72 69 74 65 20 34 20 66 69 6c 74 65  og write 4 filte
2f40: 72 73 79 6d 20 22 52 65 70 61 72 65 6e 74 69 6e  rsym "Reparentin
2f50: 67 20 61 74 20 6d 6f 73 74 20 5b 6e 73 70 20 24  g at most [nsp $
2f60: 62 6d 61 78 20 62 72 61 6e 63 68 20 62 72 61 6e  bmax branch bran
2f70: 63 68 65 73 5d 22 0a 0a 09 6c 6f 67 20 77 72 69  ches]"...log wri
2f80: 74 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22  te 3 filtersym "
2f90: 41 64 6a 75 73 74 20 74 61 67 20 70 61 72 65 6e  Adjust tag paren
2fa0: 74 73 22 0a 0a 09 23 20 46 69 6e 64 20 74 68 65  ts"...# Find the
2fb0: 20 74 61 67 73 20 77 68 6f 73 65 20 63 75 72 72   tags whose curr
2fc0: 65 6e 74 20 70 61 72 65 6e 74 20 28 6c 6f 64 29  ent parent (lod)
2fd0: 20 69 73 20 6e 6f 74 20 74 68 65 20 70 72 65 66   is not the pref
2fe0: 65 72 65 64 0a 09 23 20 70 61 72 65 6e 74 2c 20  ered..# parent, 
2ff0: 74 68 65 20 70 72 65 66 65 72 65 64 20 70 61 72  the prefered par
3000: 65 6e 74 20 69 73 20 6e 6f 74 20 74 68 65 20 74  ent is not the t
3010: 72 75 6e 6b 2c 20 61 6e 64 20 74 68 65 0a 09 23  runk, and the..#
3020: 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74   prefered parent
3030: 20 69 73 20 61 20 70 6f 73 73 69 62 6c 65 20 70   is a possible p
3040: 61 72 65 6e 74 20 70 65 72 20 74 68 65 20 74 61  arent per the ta
3050: 67 27 73 20 72 65 76 69 73 69 6f 6e 2e 0a 0a 09  g's revision....
3060: 73 65 74 20 66 6d 74 20 25 5b 73 74 72 69 6e 67  set fmt %[string
3070: 20 6c 65 6e 67 74 68 20 24 74 6d 61 78 5d 73 0a   length $tmax]s.
3080: 09 73 65 74 20 6d 78 73 20 5b 66 6f 72 6d 61 74  .set mxs [format
3090: 20 24 66 6d 74 20 24 74 6d 61 78 5d 0a 0a 09 73   $fmt $tmax]...s
30a0: 65 74 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 20  et n 0..foreach 
30b0: 7b 69 64 20 66 69 64 20 6c 6f 64 20 70 69 64 20  {id fid lod pid 
30c0: 70 72 65 66 65 72 65 64 6e 61 6d 65 20 72 65 76  preferedname rev
30d0: 6e 72 20 72 69 64 7d 20 24 74 61 67 73 74 6f 61  nr rid} $tagstoa
30e0: 64 6a 75 73 74 20 7b 0a 09 20 20 20 20 23 20 42  djust {..    # B
30f0: 4f 54 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 09  OTTLE-NECK .....
3100: 20 20 20 20 23 0a 09 20 20 20 20 23 20 54 68 65      #..    # The
3110: 20 63 68 65 63 6b 20 69 66 20 74 68 65 20 63 61   check if the ca
3120: 6e 64 69 64 61 74 65 20 28 70 69 64 29 20 69 73  ndidate (pid) is
3130: 20 74 72 75 6c 79 20 76 69 61 62 6c 65 20 69 73   truly viable is
3140: 0a 09 20 20 20 20 23 20 62 61 73 65 64 20 6f 6e  ..    # based on
3150: 20 66 69 6e 64 69 6e 67 20 74 68 65 20 62 72 61   finding the bra
3160: 6e 63 68 20 61 73 20 70 6f 73 73 69 62 6c 65 20  nch as possible 
3170: 70 61 72 65 6e 74 2c 20 61 6e 64 20 64 6f 6e 65  parent, and done
3180: 0a 09 20 20 20 20 23 20 6e 6f 77 20 69 6e 73 74  ..    # now inst
3190: 65 61 64 20 6f 66 20 61 73 20 70 61 72 74 20 6f  ead of as part o
31a0: 66 20 74 68 65 20 61 6c 72 65 61 64 79 20 63 6f  f the already co
31b0: 6d 70 6c 65 78 20 6a 6f 69 6e 2e 0a 09 20 20 20  mplex join...   
31c0: 20 23 0a 09 20 20 20 20 23 20 2e 2e 2e 20 41 4e   #..    # ... AN
31d0: 44 20 50 2e 70 69 64 20 49 4e 20 28 53 45 4c 45  D P.pid IN (SELE
31e0: 43 54 20 42 2e 73 69 64 0a 09 20 20 20 20 23 20  CT B.sid..    # 
31f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3200: 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 0a    FROM branch B.
3210: 09 20 20 20 20 23 20 20 20 20 20 20 20 20 20 20  .    #          
3220: 20 20 20 20 20 20 20 20 20 57 48 45 52 45 20 42           WHERE B
3230: 2e 72 6f 6f 74 20 3d 20 52 2e 72 69 64 29 0a 0a  .root = R.rid)..
3240: 09 20 20 20 20 69 66 20 7b 21 5b 73 74 61 74 65  .    if {![state
3250: 20 6f 6e 65 20 7b 0a 09 09 53 45 4c 45 43 54 20   one {...SELECT 
3260: 43 4f 55 4e 54 28 2a 29 20 20 20 20 20 20 20 2d  COUNT(*)       -
3270: 2d 20 43 6f 75 6e 74 20 3c 3d 3e 20 43 68 65 63  - Count <=> Chec
3280: 6b 20 65 78 69 73 74 65 6e 63 65 2e 0a 09 09 46  k existence....F
3290: 52 4f 4d 20 62 72 61 6e 63 68 20 42 0a 09 09 57  ROM branch B...W
32a0: 48 45 52 45 20 20 42 2e 73 69 64 20 20 3d 20 24  HERE  B.sid  = $
32b0: 70 69 64 20 20 2d 2d 20 52 65 73 74 72 69 63 74  pid  -- Restrict
32c0: 20 74 6f 20 62 72 61 6e 63 68 20 66 6f 72 20 74   to branch for t
32d0: 68 61 74 20 73 79 6d 62 6f 6c 0a 09 09 41 4e 44  hat symbol...AND
32e0: 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20 24 72 69      B.root = $ri
32f0: 64 20 20 2d 2d 20 61 74 74 61 63 68 65 64 20 74  d  -- attached t
3300: 6f 20 74 68 61 74 20 72 65 76 69 73 69 6f 6e 0a  o that revision.
3310: 09 20 20 20 20 7d 5d 7d 20 7b 0a 09 09 69 6e 63  .    }]} {...inc
3320: 72 20 74 6d 61 78 20 2d 31 0a 09 09 73 65 74 20  r tmax -1...set 
3330: 20 6d 78 73 20 5b 66 6f 72 6d 61 74 20 24 66 6d   mxs [format $fm
3340: 74 20 24 74 6d 61 78 5d 0a 09 09 63 6f 6e 74 69  t $tmax]...conti
3350: 6e 75 65 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20  nue..    }...   
3360: 20 23 0a 09 20 20 20 20 23 20 42 4f 54 54 4c 45   #..    # BOTTLE
3370: 2d 4e 45 43 4b 20 2e 2e 2e 0a 0a 09 20 20 20 20  -NECK ......    
3380: 23 20 54 68 65 20 6e 61 6d 65 73 20 66 6f 72 20  # The names for 
3390: 75 73 65 20 69 6e 20 74 68 65 20 6c 6f 67 20 6f  use in the log o
33a0: 75 74 70 75 74 20 61 72 65 20 72 65 74 72 69 65  utput are retrie
33b0: 76 65 64 0a 09 20 20 20 20 23 20 73 65 70 61 72  ved..    # separ
33c0: 61 74 65 6c 79 2c 20 74 6f 20 6b 65 65 70 20 74  ately, to keep t
33d0: 68 65 20 6a 6f 69 6e 20 73 65 6c 65 63 74 69 6e  he join selectin
33e0: 67 20 74 68 65 20 61 64 6a 75 73 74 61 62 6c 65  g the adjustable
33f0: 0a 09 20 20 20 20 23 20 74 61 67 73 20 73 6d 61  ..    # tags sma
3400: 6c 6c 2c 20 6e 6f 74 20 62 75 72 64 65 6e 65 64  ll, not burdened
3410: 20 77 69 74 68 20 74 68 65 20 64 65 72 65 66 65   with the derefe
3420: 72 65 6e 63 69 6e 67 20 6f 66 20 6c 69 6e 6b 73  rencing of links
3430: 0a 09 20 20 20 20 23 20 74 6f 20 6e 61 6d 65 2e  ..    # to name.
3440: 0a 0a 09 20 20 20 20 73 65 74 20 74 61 67 6e 61  ...    set tagna
3450: 6d 65 20 24 73 6e 28 24 69 64 29 0a 09 20 20 20  me $sn($id)..   
3460: 20 73 65 74 20 6f 6c 64 6e 61 6d 65 20 24 73 78   set oldname $sx
3470: 28 24 6c 6f 64 29 0a 09 20 20 20 20 73 74 72 75  ($lod)..    stru
3480: 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20  ct::list assign 
3490: 24 66 70 6e 28 24 66 69 64 29 20 66 6e 61 6d 65  $fpn($fid) fname
34a0: 20 70 72 6e 61 6d 65 0a 0a 09 20 20 20 20 23 20   prname...    # 
34b0: 44 6f 20 74 68 65 20 67 72 61 66 74 69 6e 67 2e  Do the grafting.
34c0: 0a 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65  ...    log write
34d0: 20 34 20 66 69 6c 74 65 72 73 79 6d 20 7b 5c 5b   4 filtersym {\[
34e0: 5b 66 6f 72 6d 61 74 20 24 66 6d 74 20 24 6e 5d  [format $fmt $n]
34f0: 2f 24 6d 78 73 5c 5d 20 24 70 72 6e 61 6d 65 20  /$mxs\] $prname 
3500: 3a 20 47 72 61 66 74 69 6e 67 20 74 61 67 20 27  : Grafting tag '
3510: 24 74 61 67 6e 61 6d 65 27 20 6f 6e 20 24 66 6e  $tagname' on $fn
3520: 61 6d 65 2f 24 72 65 76 6e 72 20 66 72 6f 6d 20  ame/$revnr from 
3530: 27 24 6f 6c 64 6e 61 6d 65 27 20 6f 6e 74 6f 20  '$oldname' onto 
3540: 27 24 70 72 65 66 65 72 65 64 6e 61 6d 65 27 7d  '$preferedname'}
3550: 0a 09 20 20 20 20 73 74 61 74 65 20 72 75 6e 20  ..    state run 
3560: 7b 20 55 50 44 41 54 45 20 74 61 67 20 53 45 54  { UPDATE tag SET
3570: 20 6c 6f 64 20 3d 20 24 70 69 64 20 57 48 45 52   lod = $pid WHER
3580: 45 20 74 69 64 20 3d 20 24 69 64 20 7d 0a 09 20  E tid = $id }.. 
3590: 20 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 0a 09 6c     incr n..}...l
35a0: 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c 74 65  og write 3 filte
35b0: 72 73 79 6d 20 22 52 65 70 61 72 65 6e 74 65 64  rsym "Reparented
35c0: 20 5b 6e 73 70 20 24 6e 20 74 61 67 5d 22 0a 0a   [nsp $n tag]"..
35d0: 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c  .log write 3 fil
35e0: 74 65 72 73 79 6d 20 22 41 64 6a 75 73 74 20 62  tersym "Adjust b
35f0: 72 61 6e 63 68 20 70 61 72 65 6e 74 73 22 0a 0a  ranch parents"..
3600: 09 23 20 46 69 6e 64 20 74 68 65 20 62 72 61 6e  .# Find the bran
3610: 63 68 65 73 20 77 68 6f 73 65 20 63 75 72 72 65  ches whose curre
3620: 6e 74 20 70 61 72 65 6e 74 20 28 6c 6f 64 29 20  nt parent (lod) 
3630: 69 73 20 6e 6f 74 20 74 68 65 0a 09 23 20 70 72  is not the..# pr
3640: 65 66 65 72 65 64 20 70 61 72 65 6e 74 2c 20 74  efered parent, t
3650: 68 65 20 70 72 65 66 65 72 65 64 20 70 61 72 65  he prefered pare
3660: 6e 74 20 69 73 20 6e 6f 74 20 74 68 65 20 74 72  nt is not the tr
3670: 75 6e 6b 2c 20 61 6e 64 0a 09 23 20 74 68 65 20  unk, and..# the 
3680: 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20  prefered parent 
3690: 69 73 20 61 20 70 6f 73 73 69 62 6c 65 20 70 61  is a possible pa
36a0: 72 65 6e 74 20 70 65 72 20 74 68 65 20 62 72 61  rent per the bra
36b0: 6e 63 68 27 73 0a 09 23 20 72 65 76 69 73 69 6f  nch's..# revisio
36c0: 6e 2e 0a 0a 09 73 65 74 20 66 6d 74 20 25 5b 73  n....set fmt %[s
36d0: 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 24 62 6d  tring length $bm
36e0: 61 78 5d 73 0a 09 73 65 74 20 6d 78 73 20 5b 66  ax]s..set mxs [f
36f0: 6f 72 6d 61 74 20 24 66 6d 74 20 24 62 6d 61 78  ormat $fmt $bmax
3700: 5d 0a 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72  ]...set n 0..for
3710: 65 61 63 68 20 7b 69 64 20 66 69 64 20 6c 6f 64  each {id fid lod
3720: 20 70 6f 73 20 70 69 64 20 70 72 65 66 65 72 65   pos pid prefere
3730: 64 6e 61 6d 65 20 72 65 76 6e 72 20 72 69 64 7d  dname revnr rid}
3740: 20 24 62 72 61 6e 63 68 65 73 74 6f 61 64 6a 75   $branchestoadju
3750: 73 74 20 7b 0a 0a 09 20 20 20 20 23 20 42 4f 54  st {...    # BOT
3760: 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 09 20 20  TLE-NECK .....  
3770: 20 20 23 0a 09 20 20 20 20 23 20 54 68 65 20 63    #..    # The c
3780: 68 65 63 6b 20 69 66 20 74 68 65 20 63 61 6e 64  heck if the cand
3790: 69 64 61 74 65 20 28 70 69 64 29 20 69 73 20 74  idate (pid) is t
37a0: 72 75 6c 79 20 76 69 61 62 6c 65 20 69 73 0a 09  ruly viable is..
37b0: 20 20 20 20 23 20 62 61 73 65 64 20 6f 6e 20 74      # based on t
37c0: 68 65 20 62 72 61 6e 63 68 20 70 6f 73 69 74 69  he branch positi
37d0: 6f 6e 73 20 69 6e 20 74 68 65 20 73 70 61 77 6e  ons in the spawn
37e0: 69 6e 67 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20  ing revision,.. 
37f0: 20 20 20 23 20 61 6e 64 20 64 6f 6e 65 20 6e 6f     # and done no
3800: 77 20 69 6e 73 74 65 61 64 20 6f 66 20 61 73 20  w instead of as 
3810: 70 61 72 74 20 6f 66 20 74 68 65 20 61 6c 72 65  part of the alre
3820: 61 64 79 20 63 6f 6d 70 6c 65 78 0a 09 20 20 20  ady complex..   
3830: 20 23 20 6a 6f 69 6e 2e 0a 09 20 20 20 20 23 0a   # join...    #.
3840: 09 20 20 20 20 23 20 2e 2e 2e 20 41 4e 44 20 50  .    # ... AND P
3850: 2e 70 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20  .pid IN (SELECT 
3860: 42 58 2e 73 69 64 0a 09 20 20 20 20 23 20 20 20  BX.sid..    #   
3870: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3880: 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 58 0a 09  FROM branch BX..
3890: 20 20 20 20 23 20 20 20 20 20 20 20 20 20 20 20      #           
38a0: 20 20 20 20 20 20 20 20 57 48 45 52 45 20 42 58          WHERE BX
38b0: 2e 72 6f 6f 74 20 3d 20 52 2e 72 69 64 0a 09 20  .root = R.rid.. 
38c0: 20 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20     #            
38d0: 20 20 20 20 20 20 20 41 4e 44 20 20 20 42 58 2e         AND   BX.
38e0: 70 6f 73 20 3e 20 42 2e 70 6f 73 29 0a 0a 09 20  pos > B.pos)... 
38f0: 20 20 20 23 20 4e 6f 74 65 3a 20 72 69 64 20 65     # Note: rid e
3900: 71 20 22 22 20 68 65 61 72 20 6d 65 61 6e 73 20  q "" hear means 
3910: 74 68 61 74 20 74 68 69 73 20 69 73 20 61 20 66  that this is a f
3920: 72 65 65 2d 66 6c 6f 61 74 69 6e 67 0a 09 20 20  ree-floating..  
3930: 20 20 23 20 62 72 61 6e 63 68 2c 20 77 68 6f 73    # branch, whos
3940: 65 20 6f 72 69 67 69 6e 61 6c 20 72 6f 6f 74 20  e original root 
3950: 77 61 73 20 72 65 6d 6f 76 65 64 20 61 73 20 61  was removed as a
3960: 20 75 6e 6e 65 63 65 73 73 61 72 79 0a 09 20 20   unnecessary..  
3970: 20 20 23 20 64 65 61 64 20 72 65 76 69 73 69 6f    # dead revisio
3980: 6e 20 28 53 65 65 20 27 66 69 6c 65 3a 3a 52 65  n (See 'file::Re
3990: 6d 6f 76 65 49 72 72 65 6c 65 76 61 6e 74 44 65  moveIrrelevantDe
39a0: 6c 65 74 69 6f 6e 73 27 29 2e 0a 09 20 20 20 20  letions')...    
39b0: 23 20 53 75 63 68 20 61 20 62 72 61 6e 63 68 20  # Such a branch 
39c0: 63 61 6e 20 62 65 20 72 65 67 72 61 66 74 65 64  can be regrafted
39d0: 20 77 69 74 68 6f 75 74 20 74 72 6f 75 62 6c 65   without trouble
39e0: 20 61 6e 64 20 74 68 65 72 65 0a 09 20 20 20 20   and there..    
39f0: 23 20 69 73 20 6e 6f 20 6e 65 65 64 20 74 6f 20  # is no need to 
3a00: 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 20 6e 65 77  look for the new
3a10: 20 70 61 72 65 6e 74 20 69 6e 20 69 74 73 0a 09   parent in its..
3a20: 20 20 20 20 23 20 6e 6f 6e 2d 65 78 69 73 74 65      # non-existe
3a30: 6e 74 20 72 6f 6f 74 2e 0a 0a 09 20 20 20 20 69  nt root....    i
3a40: 66 20 7b 28 24 72 69 64 20 6e 65 20 22 22 29 20  f {($rid ne "") 
3a50: 26 26 20 21 5b 73 74 61 74 65 20 6f 6e 65 20 7b  && ![state one {
3a60: 0a 09 09 53 45 4c 45 43 54 20 43 4f 55 4e 54 28  ...SELECT COUNT(
3a70: 2a 29 20 20 20 20 20 20 20 2d 2d 20 43 6f 75 6e  *)       -- Coun
3a80: 74 20 3c 3d 3e 20 43 68 65 63 6b 20 65 78 69 73  t <=> Check exis
3a90: 74 65 6e 63 65 2e 0a 09 09 46 52 4f 4d 20 62 72  tence....FROM br
3aa0: 61 6e 63 68 20 42 0a 09 09 57 48 45 52 45 20 20  anch B...WHERE  
3ab0: 42 2e 73 69 64 20 20 3d 20 24 70 69 64 20 20 2d  B.sid  = $pid  -
3ac0: 2d 20 4c 6f 6f 6b 20 66 6f 72 20 62 72 61 6e 63  - Look for branc
3ad0: 68 20 62 79 20 73 79 6d 62 6f 6c 0a 09 09 41 4e  h by symbol...AN
3ae0: 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20 24 72  D    B.root = $r
3af0: 69 64 20 20 2d 2d 20 53 70 61 77 6e 65 64 20 62  id  -- Spawned b
3b00: 79 20 74 68 65 20 67 69 76 65 6e 20 72 65 76 69  y the given revi
3b10: 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 42 2e  sion...AND    B.
3b20: 70 6f 73 20 20 3e 20 24 70 6f 73 20 20 2d 2d 20  pos  > $pos  -- 
3b30: 41 6e 64 20 64 65 66 69 6e 65 64 20 62 65 66 6f  And defined befo
3b40: 72 65 20 62 72 61 6e 63 68 20 74 6f 20 6d 75 74  re branch to mut
3b50: 61 74 65 0a 09 20 20 20 20 7d 5d 7d 20 7b 0a 09  ate..    }]} {..
3b60: 09 69 6e 63 72 20 62 6d 61 78 20 2d 31 0a 09 09  .incr bmax -1...
3b70: 73 65 74 20 20 6d 78 73 20 5b 66 6f 72 6d 61 74  set  mxs [format
3b80: 20 24 66 6d 74 20 24 62 6d 61 78 5d 0a 09 09 63   $fmt $bmax]...c
3b90: 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 7d 0a 0a  ontinue..    }..
3ba0: 09 20 20 20 20 23 0a 09 20 20 20 20 23 20 42 4f  .    #..    # BO
3bb0: 54 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 0a 09  TTLE-NECK ......
3bc0: 20 20 20 20 23 20 54 68 65 20 6e 61 6d 65 73 20      # The names 
3bd0: 66 6f 72 20 75 73 65 20 69 6e 20 74 68 65 20 6c  for use in the l
3be0: 6f 67 20 6f 75 74 70 75 74 20 61 72 65 20 72 65  og output are re
3bf0: 74 72 69 65 76 65 64 0a 09 20 20 20 20 23 20 73  trieved..    # s
3c00: 65 70 61 72 61 74 65 6c 79 2c 20 74 6f 20 6b 65  eparately, to ke
3c10: 65 70 20 74 68 65 20 6a 6f 69 6e 20 73 65 6c 65  ep the join sele
3c20: 63 74 69 6e 67 20 74 68 65 20 61 64 6a 75 73 74  cting the adjust
3c30: 61 62 6c 65 0a 09 20 20 20 20 23 20 74 61 67 73  able..    # tags
3c40: 20 73 6d 61 6c 6c 2c 20 6e 6f 74 20 62 75 72 64   small, not burd
3c50: 65 6e 65 64 20 77 69 74 68 20 74 68 65 20 64 65  ened with the de
3c60: 72 65 66 65 72 65 6e 63 69 6e 67 20 6f 66 20 6c  referencing of l
3c70: 69 6e 6b 73 0a 09 20 20 20 20 23 20 74 6f 20 6e  inks..    # to n
3c80: 61 6d 65 2e 0a 0a 09 20 20 20 20 73 65 74 20 62  ame....    set b
3c90: 72 61 6e 61 6d 65 20 24 73 6e 28 24 69 64 29 0a  raname $sn($id).
3ca0: 09 20 20 20 20 73 65 74 20 6f 6c 64 6e 61 6d 65  .    set oldname
3cb0: 20 24 73 78 28 24 6c 6f 64 29 0a 09 20 20 20 20   $sx($lod)..    
3cc0: 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73  struct::list ass
3cd0: 69 67 6e 20 24 66 70 6e 28 24 66 69 64 29 20 66  ign $fpn($fid) f
3ce0: 6e 61 6d 65 20 70 72 6e 61 6d 65 0a 0a 09 20 20  name prname...  
3cf0: 20 20 23 20 44 6f 20 74 68 65 20 67 72 61 66 74    # Do the graft
3d00: 69 6e 67 2e 0a 0a 09 20 20 20 20 6c 6f 67 20 77  ing....    log w
3d10: 72 69 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d  rite 4 filtersym
3d20: 20 7b 5c 5b 5b 66 6f 72 6d 61 74 20 24 66 6d 74   {\[[format $fmt
3d30: 20 24 6e 5d 2f 24 6d 78 73 5c 5d 20 24 70 72 6e   $n]/$mxs\] $prn
3d40: 61 6d 65 20 3a 20 47 72 61 66 74 69 6e 67 20 62  ame : Grafting b
3d50: 72 61 6e 63 68 20 27 24 62 72 61 6e 61 6d 65 27  ranch '$braname'
3d60: 20 6f 6e 20 24 66 6e 61 6d 65 2f 24 72 65 76 6e   on $fname/$revn
3d70: 72 20 66 72 6f 6d 20 27 24 6f 6c 64 6e 61 6d 65  r from '$oldname
3d80: 27 20 6f 6e 74 6f 20 27 24 70 72 65 66 65 72 65  ' onto '$prefere
3d90: 64 6e 61 6d 65 27 7d 0a 09 20 20 20 20 73 74 61  dname'}..    sta
3da0: 74 65 20 72 75 6e 20 7b 20 55 50 44 41 54 45 20  te run { UPDATE 
3db0: 62 72 61 6e 63 68 20 53 45 54 20 6c 6f 64 20 3d  branch SET lod =
3dc0: 20 24 70 69 64 20 57 48 45 52 45 20 62 69 64 20   $pid WHERE bid 
3dd0: 3d 20 24 69 64 20 7d 0a 09 20 20 20 20 69 6e 63  = $id }..    inc
3de0: 72 20 6e 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69  r n..}...log wri
3df0: 74 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22  te 3 filtersym "
3e00: 52 65 70 61 72 65 6e 74 65 64 20 5b 6e 73 70 20  Reparented [nsp 
3e10: 24 6e 20 62 72 61 6e 63 68 20 62 72 61 6e 63 68  $n branch branch
3e20: 65 73 5d 22 0a 09 72 65 74 75 72 6e 0a 20 20 20  es]"..return.   
3e30: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 52 65 66   }..    proc Ref
3e40: 69 6e 65 53 79 6d 62 6f 6c 73 20 7b 7d 20 7b 0a  ineSymbols {} {.
3e50: 09 23 20 54 61 67 73 20 61 6e 64 20 62 72 61 6e  .# Tags and bran
3e60: 63 68 65 73 20 61 72 65 20 6d 61 72 6b 65 64 20  ches are marked 
3e70: 61 73 20 6e 6f 72 6d 61 6c 2f 6e 6f 6f 70 20 62  as normal/noop b
3e80: 61 73 65 64 20 6f 6e 20 74 68 65 20 6f 70 0a 09  ased on the op..
3e90: 23 20 6f 66 20 74 68 65 69 72 20 72 65 76 69 73  # of their revis
3ea0: 69 6f 6e 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65  ion....log write
3eb0: 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 52 65   3 filtersym "Re
3ec0: 66 69 6e 65 20 73 79 6d 62 6f 6c 73 20 28 6e 6f  fine symbols (no
3ed0: 2d 6f 70 20 6f 72 20 6e 6f 74 3f 29 22 0a 0a 09  -op or not?)"...
3ee0: 23 20 4e 6f 74 65 3a 20 54 68 65 20 6e 6f 6f 70  # Note: The noop
3ef0: 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20   information is 
3f00: 6e 6f 74 20 75 73 65 64 20 61 6e 79 77 68 65 72  not used anywher
3f10: 65 2e 20 43 6f 6e 73 69 64 65 72 0a 09 23 20 64  e. Consider..# d
3f20: 69 73 61 62 6c 69 6e 67 20 74 68 69 73 20 63 6f  isabling this co
3f30: 64 65 2c 20 61 6e 64 20 72 65 6d 6f 76 69 6e 67  de, and removing
3f40: 20 74 68 65 20 64 61 74 61 20 66 72 6f 6d 20 74   the data from t
3f50: 68 65 20 73 74 61 74 65 2e 0a 0a 09 6c 6f 67 20  he state....log 
3f60: 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73 79  write 4 filtersy
3f70: 6d 20 22 20 20 20 20 52 65 67 75 6c 61 72 20 74  m "    Regular t
3f80: 61 67 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20  ags"..state run 
3f90: 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e  {..    INSERT IN
3fa0: 54 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c  TO noop..    SEL
3fb0: 45 43 54 20 54 2e 74 69 64 2c 20 30 0a 09 20 20  ECT T.tid, 0..  
3fc0: 20 20 46 52 4f 4d 20 74 61 67 20 54 2c 20 72 65    FROM tag T, re
3fd0: 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48  vision R..    WH
3fe0: 45 52 45 20 54 2e 72 65 76 20 20 3d 20 52 2e 72  ERE T.rev  = R.r
3ff0: 69 64 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e  id..    AND   R.
4000: 6f 70 20 20 21 3d 20 30 20 2d 2d 20 30 20 3d 3d  op  != 0 -- 0 ==
4010: 20 6e 6f 74 68 69 6e 67 0a 09 7d 0a 0a 09 6c 6f   nothing..}...lo
4020: 67 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72  g write 4 filter
4030: 73 79 6d 20 22 20 20 20 20 4e 6f 2d 6f 70 20 74  sym "    No-op t
4040: 61 67 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20  ags"..state run 
4050: 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e  {..    INSERT IN
4060: 54 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c  TO noop..    SEL
4070: 45 43 54 20 54 2e 74 69 64 2c 20 31 0a 09 20 20  ECT T.tid, 1..  
4080: 20 20 46 52 4f 4d 20 74 61 67 20 54 2c 20 72 65    FROM tag T, re
4090: 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48  vision R..    WH
40a0: 45 52 45 20 54 2e 72 65 76 20 20 3d 20 52 2e 72  ERE T.rev  = R.r
40b0: 69 64 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e  id..    AND   R.
40c0: 6f 70 20 20 20 3d 20 30 20 2d 2d 20 6e 6f 74 68  op   = 0 -- noth
40d0: 69 6e 67 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69  ing..}...log wri
40e0: 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d 20 22  te 4 filtersym "
40f0: 20 20 20 20 52 65 67 75 6c 61 72 20 62 72 61 6e      Regular bran
4100: 63 68 65 73 22 0a 09 73 74 61 74 65 20 72 75 6e  ches"..state run
4110: 20 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49   {..    INSERT I
4120: 4e 54 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45  NTO noop..    SE
4130: 4c 45 43 54 20 42 2e 62 69 64 2c 20 30 0a 09 20  LECT B.bid, 0.. 
4140: 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42     FROM branch B
4150: 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20  , revision R..  
4160: 20 20 57 48 45 52 45 20 42 2e 72 6f 6f 74 20 3d    WHERE B.root =
4170: 20 52 2e 72 69 64 0a 09 20 20 20 20 41 4e 44 20   R.rid..    AND 
4180: 20 20 52 2e 6f 70 20 20 21 3d 20 30 20 2d 2d 20    R.op  != 0 -- 
4190: 6e 6f 74 68 69 6e 67 0a 09 7d 0a 0a 09 6c 6f 67  nothing..}...log
41a0: 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73   write 4 filters
41b0: 79 6d 20 22 20 20 20 20 4e 6f 2d 6f 70 20 62 72  ym "    No-op br
41c0: 61 6e 63 68 65 73 22 0a 09 73 74 61 74 65 20 72  anches"..state r
41d0: 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45 52 54  un {..    INSERT
41e0: 20 49 4e 54 4f 20 6e 6f 6f 70 0a 09 20 20 20 20   INTO noop..    
41f0: 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 31 0a  SELECT B.bid, 1.
4200: 09 20 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68  .    FROM branch
4210: 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09   B, revision R..
4220: 20 20 20 20 57 48 45 52 45 20 42 2e 72 6f 6f 74      WHERE B.root
4230: 20 3d 20 52 2e 72 69 64 0a 09 20 20 20 20 41 4e   = R.rid..    AN
4240: 44 20 20 20 52 2e 6f 70 20 20 20 3d 20 30 20 2d  D   R.op   = 0 -
4250: 2d 20 6e 6f 74 68 69 6e 67 0a 09 7d 0a 09 72 65  - nothing..}..re
4260: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
4270: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
4280: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
4290: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 43  #######.    ## C
42a0: 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20  onfiguration..  
42b0: 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69 6e 73    pragma -hasins
42c0: 74 61 6e 63 65 73 20 20 20 6e 6f 20 3b 20 23 20  tances   no ; # 
42d0: 73 69 6e 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72  singleton.    pr
42e0: 61 67 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66  agma -hastypeinf
42f0: 6f 20 20 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69  o    no ; # no i
4300: 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20  ntrospection.   
4310: 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65   pragma -hastype
4320: 64 65 73 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69  destroy no ; # i
4330: 6d 6d 6f 72 74 61 6c 0a 0a 20 20 20 20 23 20 23  mmortal..    # #
4340: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
4350: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
4360: 23 23 23 23 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63  ####.}..namespac
4370: 65 20 65 76 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73  e eval ::vc::fos
4380: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
4390: 3a 3a 70 61 73 73 20 7b 0a 20 20 20 20 6e 61 6d  ::pass {.    nam
43a0: 65 73 70 61 63 65 20 65 78 70 6f 72 74 20 66 69  espace export fi
43b0: 6c 74 65 72 73 79 6d 0a 20 20 20 20 6e 61 6d 65  ltersym.    name
43c0: 73 70 61 63 65 20 65 76 61 6c 20 66 69 6c 74 65  space eval filte
43d0: 72 73 79 6d 20 7b 0a 09 6e 61 6d 65 73 70 61 63  rsym {..namespac
43e0: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
43f0: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
4400: 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72 79 0a 09  vs::repository..
4410: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
4420: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
4430: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74  mport::cvs::stat
4440: 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70  e..namespace imp
4450: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
4460: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69  ::import::cvs::i
4470: 6e 74 65 67 72 69 74 79 0a 09 6e 61 6d 65 73 70  ntegrity..namesp
4480: 61 63 65 20 65 76 61 6c 20 70 72 6f 6a 65 63 74  ace eval project
4490: 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63   {..    namespac
44a0: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
44b0: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
44c0: 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 73 79 6d  vs::project::sym
44d0: 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ..}..namespace i
44e0: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c  mport ::vc::tool
44f0: 73 3a 3a 6d 69 73 63 3a 3a 6e 73 70 0a 09 6e 61  s::misc::nsp..na
4500: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
4510: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a  :vc::tools::log.
4520: 09 6c 6f 67 20 72 65 67 69 73 74 65 72 20 66 69  .log register fi
4530: 6c 74 65 72 73 79 6d 0a 20 20 20 20 7d 0a 7d 0a  ltersym.    }.}.
4540: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23  .# # ## ### ####
4550: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
4560: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
4570: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23  ##############.#
4580: 23 20 52 65 61 64 79 0a 0a 70 61 63 6b 61 67 65  # Ready..package
4590: 20 70 72 6f 76 69 64 65 20 76 63 3a 3a 66 6f 73   provide vc::fos
45a0: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
45b0: 3a 3a 70 61 73 73 3a 3a 66 69 6c 74 65 72 73 79  ::pass::filtersy
45c0: 6d 20 31 2e 30 0a 72 65 74 75 72 6e 0a           m 1.0.return.