Hex Artifact Content
Not logged in

Artifact c7ce4a70d0c4f5dc677ebcc0586d38cb4e9ae02c:

File tools/cvs2fossil/lib/c2f_pfiltersym.tcl part of check-in [70acbf63ec] - Print the tree of symbols (i.e. definite parents) at high verbosity levels. by aku on 2008-02-06 04:51:51.

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 50 72 69 6e 74 53 79 6d  s...    PrintSym
0bb0: 62 6f 6c 54 72 65 65 0a 09 20 20 20 20 72 65 70  bolTree..    rep
0bc0: 6f 73 69 74 6f 72 79 20 70 72 69 6e 74 72 65 76  ository printrev
0bd0: 73 74 61 74 69 73 74 69 63 73 0a 0a 09 20 20 20  statistics...   
0be0: 20 23 20 53 74 72 69 63 74 20 69 6e 74 65 67 72   # Strict integr
0bf0: 69 74 79 20 65 6e 66 6f 72 63 65 73 20 74 68 61  ity enforces tha
0c00: 74 20 61 6c 6c 20 6d 65 74 61 20 65 6e 74 72 69  t all meta entri
0c10: 65 73 20 61 72 65 20 69 6e 0a 09 20 20 20 20 23  es are in..    #
0c20: 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 20 61 73   the same LOD as
0c30: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 75 73   the revision us
0c40: 69 6e 67 20 74 68 65 6d 2e 20 41 74 20 74 68 69  ing them. At thi
0c50: 73 20 70 6f 69 6e 74 0a 09 20 20 20 20 23 20 74  s point..    # t
0c60: 68 69 73 20 6d 61 79 20 6e 6f 74 20 62 65 20 74  his may not be t
0c70: 72 75 65 20 61 6e 79 20 6c 6f 6e 67 65 72 2e 20  rue any longer. 
0c80: 49 66 20 61 20 4e 54 44 42 20 77 61 73 20 65 78  If a NTDB was ex
0c90: 63 6c 75 64 65 64 0a 09 20 20 20 20 23 20 74 68  cluded..    # th
0ca0: 65 6e 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  en all revisions
0cb0: 20 69 74 20 73 68 61 72 65 64 20 77 69 74 68 20   it shared with 
0cc0: 74 68 65 20 74 72 75 6e 6b 20 77 65 72 65 20 6d  the trunk were m
0cd0: 6f 76 65 64 0a 09 20 20 20 20 23 20 74 6f 20 74  oved..    # to t
0ce0: 68 65 20 74 72 75 6e 6b 20 4c 4f 44 2c 20 68 6f  he trunk LOD, ho
0cf0: 77 65 76 65 72 20 74 68 65 69 72 20 6d 65 74 61  wever their meta
0d00: 20 65 6e 74 72 69 65 73 20 77 69 6c 6c 20 73 74   entries will st
0d10: 69 6c 6c 0a 09 20 20 20 20 23 20 72 65 66 65 72  ill..    # refer
0d20: 20 74 6f 20 74 68 65 20 6e 6f 77 20 67 6f 6e 65   to the now gone
0d30: 20 4c 4f 44 20 73 79 6d 62 6f 6c 2e 20 54 68 69   LOD symbol. Thi
0d40: 73 20 69 73 20 66 69 6e 65 20 68 6f 77 65 76 65  s is fine howeve
0d50: 72 2c 0a 09 20 20 20 20 23 20 69 74 20 77 69 6c  r,..    # it wil
0d60: 6c 20 6e 6f 74 20 61 66 66 65 63 74 20 6f 75 72  l not affect our
0d70: 20 61 62 69 6c 69 74 79 20 74 6f 20 75 73 65 20   ability to use 
0d80: 74 68 65 20 6d 65 74 61 20 65 6e 74 72 69 65 73  the meta entries
0d90: 0a 09 20 20 20 20 23 20 74 6f 20 64 69 73 74 69  ..    # to disti
0da0: 6e 67 75 69 73 68 20 61 6e 64 20 67 72 6f 75 70  nguish and group
0db0: 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 74 6f 20   revisions into 
0dc0: 63 68 61 6e 67 65 73 65 74 73 2e 20 49 74 0a 09  changesets. It..
0dd0: 20 20 20 20 23 20 73 68 6f 75 6c 64 20 62 65 20      # should be 
0de0: 6e 6f 74 65 64 20 74 68 61 74 20 77 65 20 63 61  noted that we ca
0df0: 6e 6e 6f 74 20 73 69 6d 70 6c 79 20 73 77 69 74  nnot simply swit
0e00: 63 68 20 74 68 65 20 6d 65 74 61 0a 09 20 20 20  ch the meta..   
0e10: 20 23 20 65 6e 74 72 69 65 73 20 6f 76 65 72 20   # entries over 
0e20: 74 6f 20 74 68 65 20 74 72 75 6e 6b 20 65 69 74  to the trunk eit
0e30: 68 65 72 2c 20 61 73 20 74 68 61 74 20 6d 61 79  her, as that may
0e40: 20 63 61 75 73 65 20 74 68 65 0a 09 20 20 20 20   cause the..    
0e50: 23 20 6d 6f 64 69 66 69 65 64 20 65 6e 74 72 69  # modified entri
0e60: 65 73 20 74 6f 20 76 69 6f 6c 61 74 65 20 74 68  es to violate th
0e70: 65 20 75 6e 69 71 75 65 2d 6e 65 73 73 20 63 6f  e unique-ness co
0e80: 6e 73 74 72 61 69 6e 74 0a 09 20 20 20 20 23 20  nstraint..    # 
0e90: 73 65 74 20 6f 6e 20 74 68 61 74 20 74 61 62 6c  set on that tabl
0ea0: 65 2e 0a 09 20 20 20 20 69 6e 74 65 67 72 69 74  e...    integrit
0eb0: 79 20 6d 65 74 61 72 65 6c 61 78 65 64 0a 09 7d  y metarelaxed..}
0ec0: 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 20 66  ...log write 1 f
0ed0: 69 6c 74 65 72 73 79 6d 20 22 46 69 6c 74 65 72  iltersym "Filter
0ee0: 69 6e 67 20 63 6f 6d 70 6c 65 74 65 64 22 0a 09  ing completed"..
0ef0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
0f00: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 64 69 73    typemethod dis
0f10: 63 61 72 64 20 7b 7d 20 7b 0a 09 23 20 50 61 73  card {} {..# Pas
0f20: 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65 72 66  s manager interf
0f30: 61 63 65 2e 20 45 78 65 63 75 74 65 64 20 66 6f  ace. Executed fo
0f40: 72 20 61 6c 6c 20 70 61 73 73 65 73 20 61 66 74  r all passes aft
0f50: 65 72 20 74 68 65 0a 09 23 20 72 75 6e 20 70 61  er the..# run pa
0f60: 73 73 65 73 2c 20 74 6f 20 72 65 6d 6f 76 65 20  sses, to remove 
0f70: 61 6c 6c 20 64 61 74 61 20 6f 66 20 74 68 69 73  all data of this
0f80: 20 70 61 73 73 20 66 72 6f 6d 20 74 68 65 20 73   pass from the s
0f90: 74 61 74 65 2c 0a 09 23 20 61 73 20 62 65 69 6e  tate,..# as bein
0fa0: 67 20 6f 75 74 20 6f 66 20 64 61 74 65 2e 0a 09  g out of date...
0fb0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
0fc0: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
0fd0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
0fe0: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
0ff0: 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68 6f 64   Internal method
1000: 73 0a 0a 20 20 20 20 70 72 6f 63 20 46 69 6c 74  s..    proc Filt
1010: 65 72 45 78 63 6c 75 64 65 64 53 79 6d 62 6f 6c  erExcludedSymbol
1020: 73 20 7b 7d 20 7b 0a 09 6c 6f 67 20 77 72 69 74  s {} {..log writ
1030: 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 52  e 3 filtersym "R
1040: 65 6d 6f 76 65 20 74 68 65 20 65 78 63 6c 75 64  emove the exclud
1050: 65 64 20 73 79 6d 62 6f 6c 73 20 61 6e 64 20 74  ed symbols and t
1060: 68 65 69 72 20 75 73 65 72 73 22 0a 0a 09 23 20  heir users"...# 
1070: 57 65 20 70 75 6c 6c 20 61 6c 6c 20 74 68 65 20  We pull all the 
1080: 65 78 63 6c 75 64 65 64 20 73 79 6d 62 6f 6c 73  excluded symbols
1090: 20 74 6f 67 65 74 68 65 72 20 69 6e 74 6f 20 61   together into a
10a0: 20 74 61 62 6c 65 20 66 6f 72 0a 09 23 20 65 61   table for..# ea
10b0: 73 79 20 72 65 66 65 72 65 6e 63 65 20 62 79 20  sy reference by 
10c0: 74 68 65 20 75 70 63 6f 6d 69 6e 67 20 44 45 4c  the upcoming DEL
10d0: 45 54 45 20 61 6e 64 20 6f 74 68 65 72 20 73 74  ETE and other st
10e0: 61 74 65 6d 65 6e 74 73 2e 0a 09 23 20 28 27 78  atements...# ('x
10f0: 20 49 4e 20 74 61 62 6c 65 27 20 63 6c 61 75 73   IN table' claus
1100: 65 73 29 2e 0a 0a 09 73 65 74 20 65 78 63 6c 20  es)....set excl 
1110: 5b 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 65 78  [project::sym ex
1120: 63 6c 75 64 65 64 5d 0a 0a 09 73 74 61 74 65 20  cluded]...state 
1130: 72 75 6e 20 7b 0a 09 20 20 20 20 43 52 45 41 54  run {..    CREAT
1140: 45 20 54 45 4d 50 4f 52 41 52 59 20 54 41 42 4c  E TEMPORARY TABL
1150: 45 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c  E excludedsymbol
1160: 73 20 41 53 0a 09 20 20 20 20 53 45 4c 45 43 54  s AS..    SELECT
1170: 20 73 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20   sid..    FROM  
1180: 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20 57 48 45   symbol..    WHE
1190: 52 45 20 20 74 79 70 65 20 3d 20 24 65 78 63 6c  RE  type = $excl
11a0: 0a 09 7d 0a 0a 09 23 20 46 69 72 73 74 20 77 65  ..}...# First we
11b0: 20 68 61 76 65 20 74 6f 20 68 61 6e 64 6c 65 20   have to handle 
11c0: 74 68 65 20 70 6f 73 73 69 62 69 6c 69 74 79 20  the possibility 
11d0: 6f 66 20 61 6e 20 65 78 63 6c 75 64 65 64 0a 09  of an excluded..
11e0: 23 20 4e 54 44 42 2e 20 54 68 69 73 20 69 73 20  # NTDB. This is 
11f0: 61 20 73 70 65 63 69 61 6c 20 73 70 65 63 69 61  a special specia
1200: 6c 20 63 61 73 65 20 74 68 65 72 65 20 77 65 20  l case there we 
1210: 68 61 76 65 20 74 6f 0a 09 23 20 72 65 67 72 61  have to..# regra
1220: 66 74 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73  ft the revisions
1230: 20 77 68 69 63 68 20 61 72 65 20 73 68 61 72 65   which are share
1240: 64 20 62 65 74 77 65 65 6e 20 74 68 65 20 4e 54  d between the NT
1250: 44 42 20 61 6e 64 0a 09 23 20 54 72 75 6e 6b 20  DB and..# Trunk 
1260: 6f 6e 74 6f 20 74 68 65 20 74 72 75 6e 6b 2c 20  onto the trunk, 
1270: 70 72 65 76 65 6e 74 69 6e 67 20 74 68 65 69 72  preventing their
1280: 20 64 65 6c 65 74 69 6f 6e 20 6c 61 74 65 72 2e   deletion later.
1290: 20 57 65 0a 09 23 20 68 61 76 65 20 63 6f 64 65   We..# have code
12a0: 20 66 6f 72 20 74 68 61 74 20 69 6e 20 27 66 69   for that in 'fi
12b0: 6c 65 27 2c 20 68 6f 77 65 76 65 72 20 74 68 61  le', however tha
12c0: 74 20 6f 70 65 72 61 74 65 64 20 6f 6e 20 74 68  t operated on th
12d0: 65 0a 09 23 20 69 6e 2d 6d 65 6d 6f 72 79 20 72  e..# in-memory r
12e0: 65 76 69 73 69 6f 6e 20 6f 62 6a 65 63 74 73 2c  evision objects,
12f0: 20 77 68 69 63 68 20 77 65 20 64 6f 20 6e 6f 74   which we do not
1300: 20 68 61 76 65 20 68 65 72 65 2e 20 57 65 20 64   have here. We d
1310: 6f 0a 09 23 20 74 68 65 20 73 61 6d 65 20 6e 6f  o..# the same no
1320: 77 20 77 69 74 68 6f 75 74 20 6f 62 6a 65 63 74  w without object
1330: 2c 20 62 79 20 64 69 72 65 63 74 6c 79 20 6d 61  , by directly ma
1340: 6e 69 70 75 6c 61 74 69 6e 67 20 74 68 65 0a 09  nipulating the..
1350: 23 20 6c 69 6e 6b 73 20 69 6e 20 74 68 65 20 64  # links in the d
1360: 61 74 61 62 61 73 65 2e 0a 0a 09 61 72 72 61 79  atabase....array
1370: 20 73 65 74 20 6e 74 64 62 20 7b 7d 0a 09 61 72   set ntdb {}..ar
1380: 72 61 79 20 73 65 74 20 6c 69 6e 6b 20 7b 7d 0a  ray set link {}.
1390: 0a 09 66 6f 72 65 61 63 68 20 7b 69 64 20 70 61  ..foreach {id pa
13a0: 72 65 6e 74 20 74 72 61 6e 73 66 65 72 7d 20 5b  rent transfer} [
13b0: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20  state run {..   
13c0: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52   SELECT R.rid, R
13d0: 2e 70 61 72 65 6e 74 2c 20 52 2e 64 62 63 68 69  .parent, R.dbchi
13e0: 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 72 65  ld..    FROM  re
13f0: 76 69 73 69 6f 6e 20 52 2c 20 73 79 6d 62 6f 6c  vision R, symbol
1400: 20 53 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e   S..    WHERE R.
1410: 6c 6f 64 20 3d 20 53 2e 73 69 64 20 20 20 20 20  lod = S.sid     
1420: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 73 79         -- Get sy
1430: 6d 62 6f 6c 20 6f 66 20 6c 69 6e 65 2d 6f 66 2d  mbol of line-of-
1440: 64 65 76 65 6c 6f 70 6d 65 6e 74 20 6f 66 20 61  development of a
1450: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 0a 09 20 20  ll revisions..  
1460: 20 20 41 4e 44 20 20 20 53 2e 73 69 64 20 49 4e    AND   S.sid IN
1470: 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73   excludedsymbols
1480: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
1490: 74 68 65 20 65 78 63 6c 75 64 65 64 20 73 79 6d  the excluded sym
14a0: 62 6f 6c 73 0a 09 20 20 20 20 41 4e 44 20 20 20  bols..    AND   
14b0: 52 2e 69 73 64 65 66 61 75 6c 74 20 20 20 20 20  R.isdefault     
14c0: 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74           -- Rest
14d0: 72 69 63 74 20 74 6f 20 4e 54 44 42 20 72 65 76  rict to NTDB rev
14e0: 69 73 69 6f 6e 73 0a 09 7d 5d 20 7b 0a 09 20 20  isions..}] {..  
14f0: 20 20 73 65 74 20 6e 74 64 62 28 24 69 64 29 20    set ntdb($id) 
1500: 24 70 61 72 65 6e 74 0a 09 20 20 20 20 69 66 20  $parent..    if 
1510: 7b 24 74 72 61 6e 73 66 65 72 20 65 71 20 22 22  {$transfer eq ""
1520: 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20  } continue..    
1530: 73 65 74 20 6c 69 6e 6b 28 24 69 64 29 20 24 74  set link($id) $t
1540: 72 61 6e 73 66 65 72 0a 09 7d 0a 0a 09 66 6f 72  ransfer..}...for
1550: 65 61 63 68 20 6a 6f 69 6e 74 20 5b 61 72 72 61  each joint [arra
1560: 79 20 6e 61 6d 65 73 20 6c 69 6e 6b 5d 20 7b 0a  y names link] {.
1570: 09 20 20 20 20 23 20 54 68 65 20 6a 6f 69 6e 74  .    # The joint
1580: 73 20 61 72 65 20 74 68 65 20 68 69 67 68 65 73  s are the highes
1590: 74 20 4e 54 44 42 20 72 65 76 69 73 69 6f 6e 73  t NTDB revisions
15a0: 20 77 68 69 63 68 20 61 72 65 0a 09 20 20 20 20   which are..    
15b0: 23 20 73 68 61 72 65 64 20 77 69 74 68 20 74 68  # shared with th
15c0: 65 69 72 20 72 65 73 70 65 63 74 69 76 65 20 74  eir respective t
15d0: 72 75 6e 6b 2e 20 57 65 20 64 69 73 63 6f 6e 6e  runk. We disconn
15e0: 65 63 74 20 66 72 6f 6d 0a 09 20 20 20 20 23 20  ect from..    # 
15f0: 74 68 65 69 72 20 4e 54 44 42 20 63 68 69 6c 64  their NTDB child
1600: 72 65 6e 2c 20 61 6e 64 20 6d 61 6b 65 20 74 68  ren, and make th
1610: 65 6d 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68  em parents of th
1620: 65 69 72 0a 09 20 20 20 20 23 20 27 64 62 63 68  eir..    # 'dbch
1630: 69 6c 64 27 2e 20 54 68 65 20 61 73 73 6f 63 69  ild'. The associ
1640: 61 74 65 64 20 27 64 62 70 61 72 65 6e 74 27 20  ated 'dbparent' 
1650: 69 73 20 73 71 75 61 73 68 65 64 0a 09 20 20 20  is squashed..   
1660: 20 23 20 69 6e 73 74 65 61 64 2e 20 41 6c 6c 20   # instead. All 
1670: 70 61 72 65 6e 74 73 20 6f 66 20 74 68 65 20 6a  parents of the j
1680: 6f 69 6e 74 73 20 61 72 65 20 6d 6f 76 65 64 20  oints are moved 
1690: 74 6f 20 74 68 65 0a 09 20 20 20 20 23 20 74 72  to the..    # tr
16a0: 75 6e 6b 20 61 73 20 77 65 6c 6c 2e 0a 0a 09 20  unk as well.... 
16b0: 20 20 20 73 65 74 20 74 6a 6f 69 6e 74 20 24 6c     set tjoint $l
16c0: 69 6e 6b 28 24 6a 6f 69 6e 74 29 0a 09 20 20 20  ink($joint)..   
16d0: 20 73 65 74 20 74 6c 6f 64 20 5b 73 74 61 74 65   set tlod [state
16e0: 20 6f 6e 65 20 7b 0a 09 09 53 45 4c 45 43 54 20   one {...SELECT 
16f0: 6c 6f 64 20 46 52 4f 4d 20 72 65 76 69 73 69 6f  lod FROM revisio
1700: 6e 20 57 48 45 52 45 20 72 69 64 20 3d 20 24 74  n WHERE rid = $t
1710: 6a 6f 69 6e 74 0a 09 20 20 20 20 7d 5d 0a 0a 09  joint..    }]...
1720: 20 20 20 20 23 20 43 6f 76 6e 65 72 74 20 64 62      # Covnert db
1730: 2f 70 61 72 65 6e 74 2f 63 68 69 6c 64 20 69 6e  /parent/child in
1740: 74 6f 20 72 65 67 75 6c 61 72 20 70 61 72 65 6e  to regular paren
1750: 74 2f 63 68 69 6c 64 20 6c 69 6e 6b 73 2e 0a 09  t/child links...
1760: 20 20 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a      state run {.
1770: 09 09 55 50 44 41 54 45 20 72 65 76 69 73 69 6f  ..UPDATE revisio
1780: 6e 20 53 45 54 20 64 62 70 61 72 65 6e 74 20 3d  n SET dbparent =
1790: 20 4e 55 4c 4c 2c 20 70 61 72 65 6e 74 20 3d 20   NULL, parent = 
17a0: 24 6a 6f 69 6e 74 20 20 57 48 45 52 45 20 72 69  $joint  WHERE ri
17b0: 64 20 3d 20 24 74 6a 6f 69 6e 74 20 3b 0a 09 09  d = $tjoint ;...
17c0: 55 50 44 41 54 45 20 72 65 76 69 73 69 6f 6e 20  UPDATE revision 
17d0: 53 45 54 20 64 62 63 68 69 6c 64 20 20 3d 20 4e  SET dbchild  = N
17e0: 55 4c 4c 2c 20 63 68 69 6c 64 20 20 3d 20 24 74  ULL, child  = $t
17f0: 6a 6f 69 6e 74 20 57 48 45 52 45 20 72 69 64 20  joint WHERE rid 
1800: 3d 20 24 6a 6f 69 6e 74 20 20 3b 0a 09 20 20 20  = $joint  ;..   
1810: 20 7d 0a 09 20 20 20 20 77 68 69 6c 65 20 7b 31   }..    while {1
1820: 7d 20 7b 0a 09 09 23 20 4d 6f 76 65 20 74 68 65  } {...# Move the
1830: 20 4e 54 44 42 20 74 72 75 6e 6b 20 72 65 76 69   NTDB trunk revi
1840: 73 69 6f 6e 73 20 74 6f 20 74 72 75 6e 6b 2e 0a  sions to trunk..
1850: 09 09 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09  ..state run {...
1860: 20 20 20 20 55 50 44 41 54 45 20 72 65 76 69 73      UPDATE revis
1870: 69 6f 6e 20 53 45 54 20 6c 6f 64 20 3d 20 24 74  ion SET lod = $t
1880: 6c 6f 64 2c 20 69 73 64 65 66 61 75 6c 74 20 3d  lod, isdefault =
1890: 20 30 20 57 48 45 52 45 20 72 69 64 20 3d 20 24   0 WHERE rid = $
18a0: 6a 6f 69 6e 74 0a 09 09 7d 0a 09 09 73 65 74 20  joint...}...set 
18b0: 6c 61 73 74 20 24 6a 6f 69 6e 74 0a 09 09 73 65  last $joint...se
18c0: 74 20 6a 6f 69 6e 74 20 24 6e 74 64 62 28 24 6a  t joint $ntdb($j
18d0: 6f 69 6e 74 29 0a 09 09 69 66 20 7b 21 5b 69 6e  oint)...if {![in
18e0: 66 6f 20 65 78 69 73 74 73 20 6e 74 64 62 28 24  fo exists ntdb($
18f0: 6a 6f 69 6e 74 29 5d 7d 20 62 72 65 61 6b 0a 09  joint)]} break..
1900: 20 20 20 20 7d 0a 0a 09 20 20 20 20 23 20 52 65      }...    # Re
1910: 61 63 68 65 64 20 74 68 65 20 4e 54 44 42 20 62  ached the NTDB b
1920: 61 73 69 73 20 69 6e 20 74 68 65 20 74 72 75 6e  asis in the trun
1930: 6b 2e 20 46 69 6e 61 6c 69 7a 65 20 74 68 65 0a  k. Finalize the.
1940: 09 20 20 20 20 23 20 70 61 72 65 6e 74 2f 63 68  .    # parent/ch
1950: 69 6c 64 20 6c 69 6e 6b 61 67 65 20 61 6e 64 20  ild linkage and 
1960: 73 71 75 61 73 68 20 74 68 65 20 62 72 61 6e 63  squash the branc
1970: 68 20 70 61 72 65 6e 74 20 73 79 6d 62 6f 6c 0a  h parent symbol.
1980: 09 20 20 20 20 23 20 72 65 66 65 72 65 6e 63 65  .    # reference
1990: 2e 0a 0a 09 20 20 20 20 73 74 61 74 65 20 72 75  ....    state ru
19a0: 6e 20 7b 0a 09 09 55 50 44 41 54 45 20 72 65 76  n {...UPDATE rev
19b0: 69 73 69 6f 6e 20 53 45 54 20 63 68 69 6c 64 20  ision SET child 
19c0: 20 20 3d 20 24 6c 61 73 74 20 57 48 45 52 45 20    = $last WHERE 
19d0: 72 69 64 20 3d 20 24 6a 6f 69 6e 74 20 3b 0a 09  rid = $joint ;..
19e0: 09 55 50 44 41 54 45 20 72 65 76 69 73 69 6f 6e  .UPDATE revision
19f0: 20 53 45 54 20 62 70 61 72 65 6e 74 20 3d 20 4e   SET bparent = N
1a00: 55 4c 4c 20 20 57 48 45 52 45 20 72 69 64 20 3d  ULL  WHERE rid =
1a10: 20 24 6c 61 73 74 20 20 3b 0a 09 20 20 20 20 7d   $last  ;..    }
1a20: 0a 09 7d 0a 0a 09 23 20 4e 6f 77 20 74 68 61 74  ..}...# Now that
1a30: 20 74 68 65 20 73 70 65 63 69 61 6c 20 63 61 73   the special cas
1a40: 65 20 69 73 20 64 6f 6e 65 20 77 65 20 63 61 6e  e is done we can
1a50: 20 73 69 6d 70 6c 79 20 6b 69 6c 6c 20 61 6c 6c   simply kill all
1a60: 20 74 68 65 0a 09 23 20 72 65 76 69 73 69 6f 6e   the..# revision
1a70: 73 2c 20 74 61 67 73 2c 20 61 6e 64 20 62 72 61  s, tags, and bra
1a80: 6e 63 68 65 73 20 72 65 66 65 72 65 6e 63 69 6e  nches referencin
1a90: 67 20 61 6e 79 20 6f 66 20 74 68 65 0a 09 23 20  g any of the..# 
1aa0: 65 78 63 6c 75 64 65 64 20 73 79 6d 62 6f 6c 73  excluded symbols
1ab0: 20 69 6e 20 73 6f 6d 65 20 77 61 79 2e 20 54 68   in some way. Th
1ac0: 69 73 20 69 73 20 65 61 73 79 20 61 73 20 77 65  is is easy as we
1ad0: 20 64 6f 20 6e 6f 74 20 68 61 76 65 0a 09 23 20   do not have..# 
1ae0: 74 6f 20 73 65 6c 65 63 74 20 74 68 65 6d 20 61  to select them a
1af0: 67 61 69 6e 20 61 6e 64 20 61 67 61 69 6e 20 66  gain and again f
1b00: 72 6f 6d 20 74 68 65 20 62 61 73 65 20 74 61 62  rom the base tab
1b10: 6c 65 73 20 61 6e 79 0a 09 23 20 6c 6f 6e 67 65  les any..# longe
1b20: 72 2e 0a 0a 09 73 74 61 74 65 20 72 75 6e 20 7b  r....state run {
1b30: 0a 09 20 20 20 20 43 52 45 41 54 45 20 54 45 4d  ..    CREATE TEM
1b40: 50 4f 52 41 52 59 20 54 41 42 4c 45 20 65 78 63  PORARY TABLE exc
1b50: 6c 75 64 65 64 72 65 76 69 73 69 6f 6e 73 20 41  ludedrevisions A
1b60: 53 0a 09 20 20 20 20 53 45 4c 45 43 54 20 72 69  S..    SELECT ri
1b70: 64 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  d FROM revision 
1b80: 57 48 45 52 45 20 6c 6f 64 20 49 4e 20 65 78 63  WHERE lod IN exc
1b90: 6c 75 64 65 64 73 79 6d 62 6f 6c 73 3b 0a 0a 09  ludedsymbols;...
1ba0: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20      DELETE FROM 
1bb0: 72 65 76 69 73 69 6f 6e 20 57 48 45 52 45 20 6c  revision WHERE l
1bc0: 6f 64 20 49 4e 20 65 78 63 6c 75 64 65 64 73 79  od IN excludedsy
1bd0: 6d 62 6f 6c 73 3b 0a 09 20 20 20 20 44 45 4c 45  mbols;..    DELE
1be0: 54 45 20 46 52 4f 4d 20 74 61 67 20 20 20 20 20  TE FROM tag     
1bf0: 20 57 48 45 52 45 20 6c 6f 64 20 49 4e 20 65 78   WHERE lod IN ex
1c00: 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73 3b 0a 09  cludedsymbols;..
1c10: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20      DELETE FROM 
1c20: 74 61 67 20 20 20 20 20 20 57 48 45 52 45 20 73  tag      WHERE s
1c30: 69 64 20 49 4e 20 65 78 63 6c 75 64 65 64 73 79  id IN excludedsy
1c40: 6d 62 6f 6c 73 3b 0a 09 20 20 20 20 44 45 4c 45  mbols;..    DELE
1c50: 54 45 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 20  TE FROM branch  
1c60: 20 57 48 45 52 45 20 6c 6f 64 20 49 4e 20 65 78   WHERE lod IN ex
1c70: 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73 3b 0a 09  cludedsymbols;..
1c80: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20      DELETE FROM 
1c90: 62 72 61 6e 63 68 20 20 20 57 48 45 52 45 20 73  branch   WHERE s
1ca0: 69 64 20 49 4e 20 65 78 63 6c 75 64 65 64 73 79  id IN excludedsy
1cb0: 6d 62 6f 6c 73 3b 0a 0a 09 20 20 20 20 44 45 4c  mbols;...    DEL
1cc0: 45 54 45 20 46 52 4f 4d 20 72 65 76 69 73 69 6f  ETE FROM revisio
1cd0: 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20  nbranchchildren 
1ce0: 57 48 45 52 45 20 72 69 64 20 20 49 4e 20 65 78  WHERE rid  IN ex
1cf0: 63 6c 75 64 65 64 72 65 76 69 73 69 6f 6e 73 3b  cludedrevisions;
1d00: 0a 09 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f  ..    DELETE FRO
1d10: 4d 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68  M revisionbranch
1d20: 63 68 69 6c 64 72 65 6e 20 57 48 45 52 45 20 62  children WHERE b
1d30: 72 69 64 20 49 4e 20 65 78 63 6c 75 64 65 64 72  rid IN excludedr
1d40: 65 76 69 73 69 6f 6e 73 3b 0a 09 20 20 20 20 44  evisions;..    D
1d50: 45 4c 45 54 45 20 46 52 4f 4d 20 62 6c 6f 62 20  ELETE FROM blob 
1d60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1d70: 20 20 57 48 45 52 45 20 72 69 64 20 20 49 4e 20    WHERE rid  IN 
1d80: 65 78 63 6c 75 64 65 64 72 65 76 69 73 69 6f 6e  excludedrevision
1d90: 73 3b 0a 0a 09 20 20 20 20 44 52 4f 50 20 54 41  s;...    DROP TA
1da0: 42 4c 45 20 65 78 63 6c 75 64 65 64 72 65 76 69  BLE excludedrevi
1db0: 73 69 6f 6e 73 3b 0a 09 20 20 20 20 44 52 4f 50  sions;..    DROP
1dc0: 20 54 41 42 4c 45 20 65 78 63 6c 75 64 65 64 73   TABLE excludeds
1dd0: 79 6d 62 6f 6c 73 3b 0a 09 7d 0a 09 72 65 74 75  ymbols;..}..retu
1de0: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  rn.    }..    pr
1df0: 6f 63 20 4d 75 74 61 74 65 53 79 6d 62 6f 6c 73  oc MutateSymbols
1e00: 20 7b 7d 20 7b 0a 09 23 20 4e 65 78 74 2c 20 6e   {} {..# Next, n
1e10: 6f 77 20 74 68 61 74 20 77 65 20 6b 6e 6f 77 20  ow that we know 
1e20: 77 68 69 63 68 20 73 79 6d 62 6f 6c 73 20 61 72  which symbols ar
1e30: 65 20 77 68 61 74 20 77 65 20 6c 6f 6f 6b 20 66  e what we look f
1e40: 6f 72 0a 09 23 20 66 69 6c 65 20 6c 65 76 65 6c  or..# file level
1e50: 20 74 61 67 73 20 77 68 69 63 68 20 61 72 65 20   tags which are 
1e60: 61 63 74 75 61 6c 6c 79 20 63 6f 6e 76 65 72 74  actually convert
1e70: 65 64 20 61 73 20 62 72 61 6e 63 68 65 73 0a 09  ed as branches..
1e80: 23 20 28 70 72 6f 6a 65 63 74 20 6c 65 76 65 6c  # (project level
1e90: 2c 20 61 6e 64 20 76 69 63 65 20 76 65 72 73 61  , and vice versa
1ea0: 29 2c 20 61 6e 64 20 6d 6f 76 65 20 74 68 65 6d  ), and move them
1eb0: 20 74 6f 20 74 68 65 0a 09 23 20 63 6f 72 72 65   to the..# corre
1ec0: 63 74 20 74 61 62 6c 65 73 2e 0a 0a 09 23 20 23  ct tables....# #
1ed0: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
1ee0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
1ef0: 23 23 23 23 0a 0a 09 6c 6f 67 20 77 72 69 74 65  ####...log write
1f00: 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 4d 75   3 filtersym "Mu
1f10: 74 61 74 65 20 73 79 6d 62 6f 6c 73 2c 20 70 72  tate symbols, pr
1f20: 65 70 61 72 61 74 69 6f 6e 22 0a 0a 09 73 65 74  eparation"...set
1f30: 20 62 72 61 6e 63 68 20 5b 70 72 6f 6a 65 63 74   branch [project
1f40: 3a 3a 73 79 6d 20 62 72 61 6e 63 68 5d 0a 09 73  ::sym branch]..s
1f50: 65 74 20 74 61 67 20 20 20 20 5b 70 72 6f 6a 65  et tag    [proje
1f60: 63 74 3a 3a 73 79 6d 20 74 61 67 5d 0a 0a 09 73  ct::sym tag]...s
1f70: 65 74 20 74 61 67 73 74 6f 6d 75 74 61 74 65 20  et tagstomutate 
1f80: 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20  [state run {..  
1f90: 20 20 53 45 4c 45 43 54 20 54 2e 74 69 64 2c 20    SELECT T.tid, 
1fa0: 54 2e 66 69 64 2c 20 54 2e 6c 6f 64 2c 20 54 2e  T.fid, T.lod, T.
1fb0: 73 69 64 2c 20 54 2e 72 65 76 0a 09 20 20 20 20  sid, T.rev..    
1fc0: 46 52 4f 4d 20 74 61 67 20 54 2c 20 73 79 6d 62  FROM tag T, symb
1fd0: 6f 6c 20 53 0a 09 20 20 20 20 57 48 45 52 45 20  ol S..    WHERE 
1fe0: 54 2e 73 69 64 20 3d 20 53 2e 73 69 64 0a 09 20  T.sid = S.sid.. 
1ff0: 20 20 20 41 4e 44 20 53 2e 74 79 70 65 20 3d 20     AND S.type = 
2000: 24 62 72 61 6e 63 68 0a 09 7d 5d 0a 0a 09 73 65  $branch..}]...se
2010: 74 20 62 72 61 6e 63 68 65 73 74 6f 6d 75 74 61  t branchestomuta
2020: 74 65 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a  te [state run {.
2030: 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69  .    SELECT B.bi
2040: 64 2c 20 42 2e 66 69 64 2c 20 42 2e 6c 6f 64 2c  d, B.fid, B.lod,
2050: 20 42 2e 73 69 64 2c 20 42 2e 72 6f 6f 74 2c 20   B.sid, B.root, 
2060: 42 2e 66 69 72 73 74 2c 20 42 2e 62 72 61 0a 09  B.first, B.bra..
2070: 20 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20      FROM branch 
2080: 42 2c 20 73 79 6d 62 6f 6c 20 53 0a 09 20 20 20  B, symbol S..   
2090: 20 57 48 45 52 45 20 42 2e 73 69 64 20 3d 20 53   WHERE B.sid = S
20a0: 2e 73 69 64 0a 09 20 20 20 20 41 4e 44 20 53 2e  .sid..    AND S.
20b0: 74 79 70 65 20 3d 20 24 74 61 67 0a 09 7d 5d 0a  type = $tag..}].
20c0: 0a 09 73 65 74 20 6e 74 20 5b 65 78 70 72 20 7b  ..set nt [expr {
20d0: 5b 6c 6c 65 6e 67 74 68 20 24 74 61 67 73 74 6f  [llength $tagsto
20e0: 6d 75 74 61 74 65 5d 2f 35 7d 5d 0a 09 73 65 74  mutate]/5}]..set
20f0: 20 6e 62 20 5b 65 78 70 72 20 7b 5b 6c 6c 65 6e   nb [expr {[llen
2100: 67 74 68 20 24 62 72 61 6e 63 68 65 73 74 6f 6d  gth $branchestom
2110: 75 74 61 74 65 5d 2f 37 7d 5d 0a 0a 09 6c 6f 67  utate]/7}]...log
2120: 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73   write 4 filters
2130: 79 6d 20 22 43 68 61 6e 67 69 6e 67 20 5b 6e 73  ym "Changing [ns
2140: 70 20 24 6e 74 20 74 61 67 5d 20 69 6e 74 6f 20  p $nt tag] into 
2150: 20 5b 6e 73 70 20 24 6e 74 20 62 72 61 6e 63 68   [nsp $nt branch
2160: 20 62 72 61 6e 63 68 65 73 5d 22 0a 09 6c 6f 67   branches]"..log
2170: 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73   write 4 filters
2180: 79 6d 20 22 43 68 61 6e 67 69 6e 67 20 5b 6e 73  ym "Changing [ns
2190: 70 20 24 6e 62 20 62 72 61 6e 63 68 20 62 72 61  p $nb branch bra
21a0: 6e 63 68 65 73 5d 20 69 6e 74 6f 20 20 5b 6e 73  nches] into  [ns
21b0: 70 20 24 6e 62 20 74 61 67 5d 22 0a 0a 09 23 20  p $nb tag]"...# 
21c0: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
21d0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
21e0: 23 23 23 23 23 0a 0a 09 6c 6f 67 20 77 72 69 74  #####...log writ
21f0: 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 4d  e 3 filtersym "M
2200: 75 74 61 74 65 20 74 61 67 73 20 74 6f 20 62 72  utate tags to br
2210: 61 6e 63 68 65 73 22 0a 0a 09 66 6f 72 65 61 63  anches"...foreac
2220: 68 20 7b 69 64 20 66 69 64 20 6c 6f 64 20 73 69  h {id fid lod si
2230: 64 20 72 65 76 7d 20 24 74 61 67 73 74 6f 6d 75  d rev} $tagstomu
2240: 74 61 74 65 20 7b 0a 09 20 20 20 20 73 74 61 74  tate {..    stat
2250: 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54 45  e run {...DELETE
2260: 20 46 52 4f 4d 20 74 61 67 20 57 48 45 52 45 20   FROM tag WHERE 
2270: 74 69 64 20 3d 20 24 69 64 20 3b 0a 09 09 49 4e  tid = $id ;...IN
2280: 53 45 52 54 20 49 4e 54 4f 20 62 72 61 6e 63 68  SERT INTO branch
2290: 20 28 62 69 64 2c 20 66 69 64 2c 20 20 6c 6f 64   (bid, fid,  lod
22a0: 2c 20 20 73 69 64 2c 20 20 72 6f 6f 74 2c 20 66  ,  sid,  root, f
22b0: 69 72 73 74 2c 20 62 72 61 2c 20 70 6f 73 29 0a  irst, bra, pos).
22c0: 09 09 56 41 4c 55 45 53 20 20 20 20 20 20 20 20  ..VALUES        
22d0: 20 20 20 20 20 28 24 69 64 2c 20 24 66 69 64 2c       ($id, $fid,
22e0: 20 24 6c 6f 64 2c 20 24 73 69 64 2c 20 24 72 65   $lod, $sid, $re
22f0: 76 2c 20 4e 55 4c 4c 2c 20 20 27 27 2c 20 20 2d  v, NULL,  '',  -
2300: 31 29 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09  1);..    }..}...
2310: 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c 74  log write 3 filt
2320: 65 72 73 79 6d 20 22 4f 6b 2e 22 0a 0a 09 23 20  ersym "Ok."...# 
2330: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
2340: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
2350: 23 23 23 23 23 0a 0a 09 6c 6f 67 20 77 72 69 74  #####...log writ
2360: 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 4d  e 3 filtersym "M
2370: 75 74 61 74 65 20 62 72 61 6e 63 68 65 73 20 74  utate branches t
2380: 6f 20 74 61 67 73 22 0a 0a 09 66 6f 72 65 61 63  o tags"...foreac
2390: 68 20 7b 69 64 20 66 69 64 20 6c 6f 64 20 73 69  h {id fid lod si
23a0: 64 20 72 6f 6f 74 20 66 69 72 73 74 20 62 72 61  d root first bra
23b0: 7d 20 24 62 72 61 6e 63 68 65 73 74 6f 6d 75 74  } $branchestomut
23c0: 61 74 65 20 7b 0a 09 20 20 20 20 73 74 61 74 65  ate {..    state
23d0: 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54 45 20   run {...DELETE 
23e0: 46 52 4f 4d 20 62 72 61 6e 63 68 20 57 48 45 52  FROM branch WHER
23f0: 45 20 62 69 64 20 3d 20 24 69 64 20 3b 0a 09 09  E bid = $id ;...
2400: 49 4e 53 45 52 54 20 49 4e 54 4f 20 74 61 67 20  INSERT INTO tag 
2410: 28 74 69 64 2c 20 66 69 64 2c 20 20 6c 6f 64 2c  (tid, fid,  lod,
2420: 20 20 73 69 64 2c 20 20 72 65 76 29 0a 09 09 56    sid,  rev)...V
2430: 41 4c 55 45 53 20 20 20 20 20 20 20 20 20 20 28  ALUES          (
2440: 24 69 64 2c 20 24 66 69 64 2c 20 24 6c 6f 64 2c  $id, $fid, $lod,
2450: 20 24 73 69 64 2c 20 24 72 6f 6f 74 29 3b 0a 09   $sid, $root);..
2460: 20 20 20 20 7d 0a 09 7d 0a 0a 09 6c 6f 67 20 77      }..}...log w
2470: 72 69 74 65 20 33 20 66 69 6c 74 65 72 73 79 6d  rite 3 filtersym
2480: 20 22 4f 6b 2e 22 0a 0a 09 23 20 23 20 23 23 20   "Ok."...# # ## 
2490: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
24a0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
24b0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
24c0: 20 20 20 20 23 20 41 64 6a 75 73 74 20 74 68 65      # Adjust the
24d0: 20 70 61 72 65 6e 74 73 20 6f 66 20 73 79 6d 62   parents of symb
24e0: 6f 6c 73 20 74 6f 20 74 68 65 69 72 20 70 72 65  ols to their pre
24f0: 66 65 72 72 65 64 20 70 61 72 65 6e 74 73 2e 0a  ferred parents..
2500: 0a 20 20 20 20 23 20 49 66 20 61 20 66 69 6c 65  .    # If a file
2510: 20 6c 65 76 65 6c 20 79 6d 62 6f 6c 20 68 61 73   level ymbol has
2520: 20 61 20 70 72 65 66 65 72 72 65 64 20 70 61 72   a preferred par
2530: 65 6e 74 20 74 68 61 74 20 69 73 20 64 69 66 66  ent that is diff
2540: 65 72 65 6e 74 0a 20 20 20 20 23 20 74 68 61 6e  erent.    # than
2550: 20 69 74 73 20 63 75 72 72 65 6e 74 20 70 61 72   its current par
2560: 65 6e 74 2c 20 61 6e 64 20 69 66 20 74 68 65 20  ent, and if the 
2570: 70 72 65 66 65 72 72 65 64 20 70 61 72 65 6e 74  preferred parent
2580: 20 69 73 20 61 6e 0a 20 20 20 20 23 20 61 6c 6c   is an.    # all
2590: 6f 77 65 64 20 70 61 72 65 6e 74 20 6f 66 20 74  owed parent of t
25a0: 68 65 20 73 79 6d 62 6f 6c 20 69 6e 20 74 68 69  he symbol in thi
25b0: 73 20 66 69 6c 65 2c 20 74 68 65 6e 20 77 65 20  s file, then we 
25c0: 67 72 61 66 74 20 74 68 65 0a 20 20 20 20 23 20  graft the.    # 
25d0: 61 53 79 6d 62 6f 6c 20 6f 6e 74 6f 20 69 74 73  aSymbol onto its
25e0: 20 70 72 65 66 65 72 72 65 64 20 70 61 72 65 6e   preferred paren
25f0: 74 2e 0a 0a 20 20 20 20 70 72 6f 63 20 41 64 6a  t...    proc Adj
2600: 75 73 74 50 61 72 65 6e 74 73 20 7b 7d 20 7b 0a  ustParents {} {.
2610: 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c  .log write 3 fil
2620: 74 65 72 73 79 6d 20 22 41 64 6a 75 73 74 20 70  tersym "Adjust p
2630: 61 72 65 6e 74 73 2c 20 6c 6f 61 64 69 6e 67 20  arents, loading 
2640: 64 61 74 61 20 69 6e 20 70 72 65 70 61 72 61 74  data in preparat
2650: 69 6f 6e 22 0a 0a 09 23 20 57 65 20 70 75 6c 6c  ion"...# We pull
2660: 20 69 6d 70 6f 72 74 61 6e 74 20 6d 61 70 73 20   important maps 
2670: 6f 6e 63 65 20 69 6e 74 6f 20 6d 65 6d 6f 72 79  once into memory
2680: 20 73 6f 20 74 68 61 74 20 77 65 20 64 6f 20 71   so that we do q
2690: 75 69 63 6b 0a 09 23 20 68 61 73 68 20 6c 6f 6f  uick..# hash loo
26a0: 6b 75 70 20 6c 61 74 65 72 20 77 68 65 6e 20 70  kup later when p
26b0: 72 6f 63 65 73 73 69 6e 67 20 74 68 65 20 67 72  rocessing the gr
26c0: 61 66 74 20 63 61 6e 64 69 64 61 74 65 73 2e 0a  aft candidates..
26d0: 0a 09 23 20 54 61 67 2f 42 72 61 6e 63 68 20 6e  ..# Tag/Branch n
26e0: 61 6d 65 73 20 2e 2e 2e 0a 09 61 72 72 61 79 20  ames .....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 54 2e 74 69 64  n { SELECT T.tid
2710: 2c 20 53 2e 6e 61 6d 65 20 46 52 4f 4d 20 74 61  , S.name FROM ta
2720: 67 20 54 2c 20 20 20 20 73 79 6d 62 6f 6c 20 53  g T,    symbol S
2730: 20 57 48 45 52 45 20 54 2e 73 69 64 20 3d 20 53   WHERE T.sid = S
2740: 2e 73 69 64 20 7d 5d 0a 09 61 72 72 61 79 20 73  .sid }]..array s
2750: 65 74 20 73 6e 20 5b 73 74 61 74 65 20 72 75 6e  et sn [state run
2760: 20 7b 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c   { SELECT B.bid,
2770: 20 53 2e 6e 61 6d 65 20 46 52 4f 4d 20 62 72 61   S.name FROM bra
2780: 6e 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20 53 20  nch B, symbol S 
2790: 57 48 45 52 45 20 42 2e 73 69 64 20 3d 20 53 2e  WHERE B.sid = S.
27a0: 73 69 64 20 7d 5d 0a 09 23 20 53 79 6d 62 6f 6c  sid }]..# Symbol
27b0: 20 6e 61 6d 65 73 20 2e 2e 2e 0a 09 61 72 72 61   names .....arra
27c0: 79 20 73 65 74 20 73 78 20 5b 73 74 61 74 65 20  y set sx [state 
27d0: 72 75 6e 20 7b 20 53 45 4c 45 43 54 20 4c 2e 73  run { SELECT L.s
27e0: 69 64 2c 20 4c 2e 6e 61 6d 65 20 46 52 4f 4d 20  id, L.name FROM 
27f0: 73 79 6d 62 6f 6c 20 4c 20 7d 5d 0a 09 23 20 46  symbol L }]..# F
2800: 69 6c 65 73 20 61 6e 64 20 70 72 6f 6a 65 63 74  iles and project
2810: 73 2e 0a 09 61 72 72 61 79 20 73 65 74 20 66 70  s...array set fp
2820: 6e 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b 69  n {}..foreach {i
2830: 64 20 66 6e 20 70 6e 7d 20 5b 73 74 61 74 65 20  d fn pn} [state 
2840: 72 75 6e 20 7b 0a 09 09 53 45 4c 45 43 54 20 46  run {...SELECT F
2850: 2e 66 69 64 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e  .fid, F.name, P.
2860: 6e 61 6d 65 0a 09 09 46 52 4f 4d 20 20 20 66 69  name...FROM   fi
2870: 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a  le F, project P.
2880: 09 09 57 48 45 52 45 20 20 46 2e 70 69 64 20 3d  ..WHERE  F.pid =
2890: 20 50 2e 70 69 64 0a 09 7d 5d 20 7b 20 73 65 74   P.pid..}] { set
28a0: 20 66 70 6e 28 24 69 64 29 20 5b 6c 69 73 74 20   fpn($id) [list 
28b0: 24 66 6e 20 24 70 6e 5d 20 7d 0a 0a 09 73 65 74  $fn $pn] }...set
28c0: 20 74 61 67 73 74 6f 61 64 6a 75 73 74 20 5b 73   tagstoadjust [s
28d0: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
28e0: 53 45 4c 45 43 54 20 54 2e 74 69 64 2c 20 54 2e  SELECT T.tid, T.
28f0: 66 69 64 2c 20 54 2e 6c 6f 64 2c 20 50 2e 70 69  fid, T.lod, P.pi
2900: 64 2c 20 53 2e 6e 61 6d 65 2c 20 52 2e 72 65 76  d, S.name, R.rev
2910: 2c 20 52 2e 72 69 64 0a 09 20 20 20 20 46 52 4f  , R.rid..    FRO
2920: 4d 20 74 61 67 20 54 2c 20 70 72 65 66 65 72 65  M tag T, prefere
2930: 64 70 61 72 65 6e 74 20 50 2c 20 73 79 6d 62 6f  dparent P, symbo
2940: 6c 20 53 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a  l S, revision R.
2950: 09 20 20 20 20 57 48 45 52 45 20 54 2e 73 69 64  .    WHERE T.sid
2960: 20 3d 20 50 2e 73 69 64 20 20 20 20 20 20 20 20   = P.sid        
2970: 2d 2d 20 46 6f 72 20 61 6c 6c 20 74 61 67 73 2c  -- For all tags,
2980: 20 67 65 74 20 6c 65 66 74 2d 68 61 6e 64 20 6f   get left-hand o
2990: 66 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e  f prefered paren
29a0: 74 20 76 69 61 20 73 79 6d 62 6f 6c 0a 09 20 20  t via symbol..  
29b0: 20 20 41 4e 44 20 20 20 54 2e 6c 6f 64 20 21 3d    AND   T.lod !=
29c0: 20 50 2e 70 69 64 20 20 20 20 20 20 20 2d 2d 20   P.pid       -- 
29d0: 52 65 73 74 72 69 63 74 20 74 6f 20 74 61 67 73  Restrict to tags
29e0: 20 77 68 6f 73 65 20 4c 4f 44 20 69 73 20 6e 6f   whose LOD is no
29f0: 74 20 74 68 65 69 72 20 70 72 65 66 65 72 65 64  t their prefered
2a00: 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44   parent..    AND
2a10: 20 20 20 50 2e 70 69 64 20 3d 20 53 2e 73 69 64     P.pid = S.sid
2a20: 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 73          -- Get s
2a30: 79 6d 62 6f 6c 20 6f 66 20 70 72 65 66 65 72 65  ymbol of prefere
2a40: 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e  d parent..    AN
2a50: 44 20 20 20 53 2e 6e 61 6d 65 20 21 3d 20 27 3a  D   S.name != ':
2a60: 74 72 75 6e 6b 3a 27 20 20 2d 2d 20 45 78 63 6c  trunk:'  -- Excl
2a70: 75 64 65 20 74 72 75 6e 6b 20 70 61 72 65 6e 74  ude trunk parent
2a80: 61 67 65 0a 09 20 20 20 20 41 4e 44 20 20 20 54  age..    AND   T
2a90: 2e 72 65 76 20 3d 20 52 2e 72 69 64 20 20 20 20  .rev = R.rid    
2aa0: 20 20 20 20 2d 2d 20 47 65 74 20 72 65 76 69 73      -- Get revis
2ab0: 69 6f 6e 20 74 68 65 20 74 61 67 20 69 73 20 61  ion the tag is a
2ac0: 74 74 61 63 68 65 64 20 74 6f 2e 0a 09 7d 5d 0a  ttached to...}].
2ad0: 0a 09 73 65 74 20 62 72 61 6e 63 68 65 73 74 6f  ..set branchesto
2ae0: 61 64 6a 75 73 74 20 5b 73 74 61 74 65 20 72 75  adjust [state ru
2af0: 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20  n {..    SELECT 
2b00: 42 2e 62 69 64 2c 20 42 2e 66 69 64 2c 20 42 2e  B.bid, B.fid, B.
2b10: 6c 6f 64 2c 20 42 2e 70 6f 73 2c 20 50 2e 70 69  lod, B.pos, P.pi
2b20: 64 2c 20 53 2e 6e 61 6d 65 2c 20 4e 55 4c 4c 2c  d, S.name, NULL,
2b30: 20 4e 55 4c 4c 0a 09 20 20 20 20 46 52 4f 4d 20   NULL..    FROM 
2b40: 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72  branch B, prefer
2b50: 65 64 70 61 72 65 6e 74 20 50 2c 20 73 79 6d 62  edparent P, symb
2b60: 6f 6c 20 53 0a 09 20 20 20 20 57 48 45 52 45 20  ol S..    WHERE 
2b70: 42 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20  B.sid = P.sid   
2b80: 20 20 20 20 20 2d 2d 20 46 6f 72 20 61 6c 6c 20       -- For all 
2b90: 62 72 61 6e 63 68 65 73 2c 20 67 65 74 20 6c 65  branches, get le
2ba0: 66 74 2d 68 61 6e 64 20 6f 66 20 70 72 65 66 65  ft-hand of prefe
2bb0: 72 65 64 20 70 61 72 65 6e 74 20 76 69 61 20 73  red parent via s
2bc0: 79 6d 62 6f 6c 0a 09 20 20 20 20 41 4e 44 20 20  ymbol..    AND  
2bd0: 20 42 2e 6c 6f 64 20 21 3d 20 50 2e 70 69 64 20   B.lod != P.pid 
2be0: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63        -- Restric
2bf0: 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 77 68  t to branches wh
2c00: 6f 73 65 20 4c 4f 44 20 69 73 20 6e 6f 74 20 74  ose LOD is not t
2c10: 68 65 69 72 20 70 72 65 66 65 72 65 64 20 70 61  heir prefered pa
2c20: 72 65 6e 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rent..    AND   
2c30: 50 2e 70 69 64 20 3d 20 53 2e 73 69 64 20 20 20  P.pid = S.sid   
2c40: 20 20 20 20 20 2d 2d 20 47 65 74 20 73 79 6d 62       -- Get symb
2c50: 6f 6c 20 6f 66 20 70 72 65 66 65 72 65 64 20 70  ol of prefered p
2c60: 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44 20 20  arent..    AND  
2c70: 20 53 2e 6e 61 6d 65 20 21 3d 20 27 3a 74 72 75   S.name != ':tru
2c80: 6e 6b 3a 27 20 20 2d 2d 20 45 78 63 6c 75 64 65  nk:'  -- Exclude
2c90: 20 74 72 75 6e 6b 20 70 61 72 65 6e 74 61 67 65   trunk parentage
2ca0: 0a 09 20 20 20 20 41 4e 44 20 20 20 42 2e 72 6f  ..    AND   B.ro
2cb0: 6f 74 20 49 53 20 4e 55 4c 4c 20 20 20 20 20 20  ot IS NULL      
2cc0: 20 2d 2d 20 41 63 63 65 70 74 20 66 72 65 65 2d   -- Accept free-
2cd0: 66 6c 6f 61 74 69 6e 67 20 62 72 61 6e 63 68 0a  floating branch.
2ce0: 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53      UNION..    S
2cf0: 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 2e 66  ELECT B.bid, B.f
2d00: 69 64 2c 20 42 2e 6c 6f 64 2c 20 42 2e 70 6f 73  id, B.lod, B.pos
2d10: 2c 20 50 2e 70 69 64 2c 20 53 2e 6e 61 6d 65 2c  , P.pid, S.name,
2d20: 20 52 2e 72 65 76 2c 20 52 2e 72 69 64 0a 09 20   R.rev, R.rid.. 
2d30: 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42     FROM branch B
2d40: 2c 20 70 72 65 66 65 72 65 64 70 61 72 65 6e 74  , preferedparent
2d50: 20 50 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 72 65   P, symbol S, re
2d60: 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48  vision R..    WH
2d70: 45 52 45 20 42 2e 73 69 64 20 3d 20 50 2e 73 69  ERE B.sid = P.si
2d80: 64 20 20 20 20 20 20 20 20 2d 2d 20 46 6f 72 20  d        -- For 
2d90: 61 6c 6c 20 62 72 61 6e 63 68 65 73 2c 20 67 65  all branches, ge
2da0: 74 20 6c 65 66 74 2d 68 61 6e 64 20 6f 66 20 70  t left-hand of p
2db0: 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20 76  refered parent v
2dc0: 69 61 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20 41  ia symbol..    A
2dd0: 4e 44 20 20 20 42 2e 6c 6f 64 20 21 3d 20 50 2e  ND   B.lod != P.
2de0: 70 69 64 20 20 20 20 20 20 20 2d 2d 20 52 65 73  pid       -- Res
2df0: 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65  trict to branche
2e00: 73 20 77 68 6f 73 65 20 4c 4f 44 20 69 73 20 6e  s whose LOD is n
2e10: 6f 74 20 74 68 65 69 72 20 70 72 65 66 65 72 65  ot their prefere
2e20: 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e  d parent..    AN
2e30: 44 20 20 20 50 2e 70 69 64 20 3d 20 53 2e 73 69  D   P.pid = S.si
2e40: 64 09 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20  d.       -- Get 
2e50: 73 79 6d 62 6f 6c 20 6f 66 20 70 72 65 66 65 72  symbol of prefer
2e60: 65 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41  ed parent..    A
2e70: 4e 44 20 20 20 53 2e 6e 61 6d 65 20 21 3d 20 27  ND   S.name != '
2e80: 3a 74 72 75 6e 6b 3a 27 20 20 2d 2d 20 45 78 63  :trunk:'  -- Exc
2e90: 6c 75 64 65 20 74 72 75 6e 6b 20 70 61 72 65 6e  lude trunk paren
2ea0: 74 61 67 65 0a 09 20 20 20 20 41 4e 44 20 20 20  tage..    AND   
2eb0: 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69 64 20 20  B.root = R.rid  
2ec0: 20 20 20 20 20 2d 2d 20 47 65 74 20 72 6f 6f 74       -- Get root
2ed0: 20 72 65 76 69 73 69 6f 6e 20 6f 66 20 74 68 65   revision of the
2ee0: 20 62 72 61 6e 63 68 0a 09 7d 5d 0a 0a 09 73 65   branch..}]...se
2ef0: 74 20 74 6d 61 78 20 5b 65 78 70 72 20 7b 5b 6c  t tmax [expr {[l
2f00: 6c 65 6e 67 74 68 20 24 74 61 67 73 74 6f 61 64  length $tagstoad
2f10: 6a 75 73 74 5d 20 2f 20 37 7d 5d 0a 09 73 65 74  just] / 7}]..set
2f20: 20 62 6d 61 78 20 5b 65 78 70 72 20 7b 5b 6c 6c   bmax [expr {[ll
2f30: 65 6e 67 74 68 20 24 62 72 61 6e 63 68 65 73 74  ength $branchest
2f40: 6f 61 64 6a 75 73 74 5d 20 2f 20 38 7d 5d 0a 0a  oadjust] / 8}]..
2f50: 09 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69 6c  .log write 4 fil
2f60: 74 65 72 73 79 6d 20 22 52 65 70 61 72 65 6e 74  tersym "Reparent
2f70: 69 6e 67 20 61 74 20 6d 6f 73 74 20 5b 6e 73 70  ing at most [nsp
2f80: 20 24 74 6d 61 78 20 74 61 67 5d 22 0a 09 6c 6f   $tmax tag]"..lo
2f90: 67 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72  g write 4 filter
2fa0: 73 79 6d 20 22 52 65 70 61 72 65 6e 74 69 6e 67  sym "Reparenting
2fb0: 20 61 74 20 6d 6f 73 74 20 5b 6e 73 70 20 24 62   at most [nsp $b
2fc0: 6d 61 78 20 62 72 61 6e 63 68 20 62 72 61 6e 63  max branch branc
2fd0: 68 65 73 5d 22 0a 0a 09 6c 6f 67 20 77 72 69 74  hes]"...log writ
2fe0: 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 41  e 3 filtersym "A
2ff0: 64 6a 75 73 74 20 74 61 67 20 70 61 72 65 6e 74  djust tag parent
3000: 73 22 0a 0a 09 23 20 46 69 6e 64 20 74 68 65 20  s"...# Find the 
3010: 74 61 67 73 20 77 68 6f 73 65 20 63 75 72 72 65  tags whose curre
3020: 6e 74 20 70 61 72 65 6e 74 20 28 6c 6f 64 29 20  nt parent (lod) 
3030: 69 73 20 6e 6f 74 20 74 68 65 20 70 72 65 66 65  is not the prefe
3040: 72 65 64 0a 09 23 20 70 61 72 65 6e 74 2c 20 74  red..# parent, t
3050: 68 65 20 70 72 65 66 65 72 65 64 20 70 61 72 65  he prefered pare
3060: 6e 74 20 69 73 20 6e 6f 74 20 74 68 65 20 74 72  nt is not the tr
3070: 75 6e 6b 2c 20 61 6e 64 20 74 68 65 0a 09 23 20  unk, and the..# 
3080: 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20  prefered parent 
3090: 69 73 20 61 20 70 6f 73 73 69 62 6c 65 20 70 61  is a possible pa
30a0: 72 65 6e 74 20 70 65 72 20 74 68 65 20 74 61 67  rent per the tag
30b0: 27 73 20 72 65 76 69 73 69 6f 6e 2e 0a 0a 09 73  's revision....s
30c0: 65 74 20 66 6d 74 20 25 5b 73 74 72 69 6e 67 20  et fmt %[string 
30d0: 6c 65 6e 67 74 68 20 24 74 6d 61 78 5d 73 0a 09  length $tmax]s..
30e0: 73 65 74 20 6d 78 73 20 5b 66 6f 72 6d 61 74 20  set mxs [format 
30f0: 24 66 6d 74 20 24 74 6d 61 78 5d 0a 0a 09 73 65  $fmt $tmax]...se
3100: 74 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 20 7b  t n 0..foreach {
3110: 69 64 20 66 69 64 20 6c 6f 64 20 70 69 64 20 70  id fid lod pid p
3120: 72 65 66 65 72 65 64 6e 61 6d 65 20 72 65 76 6e  referedname revn
3130: 72 20 72 69 64 7d 20 24 74 61 67 73 74 6f 61 64  r rid} $tagstoad
3140: 6a 75 73 74 20 7b 0a 09 20 20 20 20 23 20 42 4f  just {..    # BO
3150: 54 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 09 20  TTLE-NECK ..... 
3160: 20 20 20 23 0a 09 20 20 20 20 23 20 54 68 65 20     #..    # The 
3170: 63 68 65 63 6b 20 69 66 20 74 68 65 20 63 61 6e  check if the can
3180: 64 69 64 61 74 65 20 28 70 69 64 29 20 69 73 20  didate (pid) is 
3190: 74 72 75 6c 79 20 76 69 61 62 6c 65 20 69 73 0a  truly viable is.
31a0: 09 20 20 20 20 23 20 62 61 73 65 64 20 6f 6e 20  .    # based on 
31b0: 66 69 6e 64 69 6e 67 20 74 68 65 20 62 72 61 6e  finding the bran
31c0: 63 68 20 61 73 20 70 6f 73 73 69 62 6c 65 20 70  ch as possible p
31d0: 61 72 65 6e 74 2c 20 61 6e 64 20 64 6f 6e 65 0a  arent, and done.
31e0: 09 20 20 20 20 23 20 6e 6f 77 20 69 6e 73 74 65  .    # now inste
31f0: 61 64 20 6f 66 20 61 73 20 70 61 72 74 20 6f 66  ad of as part of
3200: 20 74 68 65 20 61 6c 72 65 61 64 79 20 63 6f 6d   the already com
3210: 70 6c 65 78 20 6a 6f 69 6e 2e 0a 09 20 20 20 20  plex join...    
3220: 23 0a 09 20 20 20 20 23 20 2e 2e 2e 20 41 4e 44  #..    # ... AND
3230: 20 50 2e 70 69 64 20 49 4e 20 28 53 45 4c 45 43   P.pid IN (SELEC
3240: 54 20 42 2e 73 69 64 0a 09 20 20 20 20 23 20 20  T B.sid..    #  
3250: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3260: 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 0a 09   FROM branch B..
3270: 20 20 20 20 23 20 20 20 20 20 20 20 20 20 20 20      #           
3280: 20 20 20 20 20 20 20 20 57 48 45 52 45 20 42 2e          WHERE B.
3290: 72 6f 6f 74 20 3d 20 52 2e 72 69 64 29 0a 0a 09  root = R.rid)...
32a0: 20 20 20 20 69 66 20 7b 21 5b 73 74 61 74 65 20      if {![state 
32b0: 6f 6e 65 20 7b 0a 09 09 53 45 4c 45 43 54 20 43  one {...SELECT C
32c0: 4f 55 4e 54 28 2a 29 20 20 20 20 20 20 20 2d 2d  OUNT(*)       --
32d0: 20 43 6f 75 6e 74 20 3c 3d 3e 20 43 68 65 63 6b   Count <=> Check
32e0: 20 65 78 69 73 74 65 6e 63 65 2e 0a 09 09 46 52   existence....FR
32f0: 4f 4d 20 62 72 61 6e 63 68 20 42 0a 09 09 57 48  OM branch B...WH
3300: 45 52 45 20 20 42 2e 73 69 64 20 20 3d 20 24 70  ERE  B.sid  = $p
3310: 69 64 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20  id  -- Restrict 
3320: 74 6f 20 62 72 61 6e 63 68 20 66 6f 72 20 74 68  to branch for th
3330: 61 74 20 73 79 6d 62 6f 6c 0a 09 09 41 4e 44 20  at symbol...AND 
3340: 20 20 20 42 2e 72 6f 6f 74 20 3d 20 24 72 69 64     B.root = $rid
3350: 20 20 2d 2d 20 61 74 74 61 63 68 65 64 20 74 6f    -- attached to
3360: 20 74 68 61 74 20 72 65 76 69 73 69 6f 6e 0a 09   that revision..
3370: 20 20 20 20 7d 5d 7d 20 7b 0a 09 09 69 6e 63 72      }]} {...incr
3380: 20 74 6d 61 78 20 2d 31 0a 09 09 73 65 74 20 20   tmax -1...set  
3390: 6d 78 73 20 5b 66 6f 72 6d 61 74 20 24 66 6d 74  mxs [format $fmt
33a0: 20 24 74 6d 61 78 5d 0a 09 09 63 6f 6e 74 69 6e   $tmax]...contin
33b0: 75 65 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20  ue..    }...    
33c0: 23 0a 09 20 20 20 20 23 20 42 4f 54 54 4c 45 2d  #..    # BOTTLE-
33d0: 4e 45 43 4b 20 2e 2e 2e 0a 0a 09 20 20 20 20 23  NECK ......    #
33e0: 20 54 68 65 20 6e 61 6d 65 73 20 66 6f 72 20 75   The names for u
33f0: 73 65 20 69 6e 20 74 68 65 20 6c 6f 67 20 6f 75  se in the log ou
3400: 74 70 75 74 20 61 72 65 20 72 65 74 72 69 65 76  tput are retriev
3410: 65 64 0a 09 20 20 20 20 23 20 73 65 70 61 72 61  ed..    # separa
3420: 74 65 6c 79 2c 20 74 6f 20 6b 65 65 70 20 74 68  tely, to keep th
3430: 65 20 6a 6f 69 6e 20 73 65 6c 65 63 74 69 6e 67  e join selecting
3440: 20 74 68 65 20 61 64 6a 75 73 74 61 62 6c 65 0a   the adjustable.
3450: 09 20 20 20 20 23 20 74 61 67 73 20 73 6d 61 6c  .    # tags smal
3460: 6c 2c 20 6e 6f 74 20 62 75 72 64 65 6e 65 64 20  l, not burdened 
3470: 77 69 74 68 20 74 68 65 20 64 65 72 65 66 65 72  with the derefer
3480: 65 6e 63 69 6e 67 20 6f 66 20 6c 69 6e 6b 73 0a  encing of links.
3490: 09 20 20 20 20 23 20 74 6f 20 6e 61 6d 65 2e 0a  .    # to name..
34a0: 0a 09 20 20 20 20 73 65 74 20 74 61 67 6e 61 6d  ..    set tagnam
34b0: 65 20 24 73 6e 28 24 69 64 29 0a 09 20 20 20 20  e $sn($id)..    
34c0: 73 65 74 20 6f 6c 64 6e 61 6d 65 20 24 73 78 28  set oldname $sx(
34d0: 24 6c 6f 64 29 0a 09 20 20 20 20 73 74 72 75 63  $lod)..    struc
34e0: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24  t::list assign $
34f0: 66 70 6e 28 24 66 69 64 29 20 66 6e 61 6d 65 20  fpn($fid) fname 
3500: 70 72 6e 61 6d 65 0a 0a 09 20 20 20 20 23 20 44  prname...    # D
3510: 6f 20 74 68 65 20 67 72 61 66 74 69 6e 67 2e 0a  o the grafting..
3520: 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20  ..    log write 
3530: 34 20 66 69 6c 74 65 72 73 79 6d 20 7b 5c 5b 5b  4 filtersym {\[[
3540: 66 6f 72 6d 61 74 20 24 66 6d 74 20 24 6e 5d 2f  format $fmt $n]/
3550: 24 6d 78 73 5c 5d 20 24 70 72 6e 61 6d 65 20 3a  $mxs\] $prname :
3560: 20 47 72 61 66 74 69 6e 67 20 74 61 67 20 27 24   Grafting tag '$
3570: 74 61 67 6e 61 6d 65 27 20 6f 6e 20 24 66 6e 61  tagname' on $fna
3580: 6d 65 2f 24 72 65 76 6e 72 20 66 72 6f 6d 20 27  me/$revnr from '
3590: 24 6f 6c 64 6e 61 6d 65 27 20 6f 6e 74 6f 20 27  $oldname' onto '
35a0: 24 70 72 65 66 65 72 65 64 6e 61 6d 65 27 7d 0a  $preferedname'}.
35b0: 09 20 20 20 20 73 74 61 74 65 20 72 75 6e 20 7b  .    state run {
35c0: 20 55 50 44 41 54 45 20 74 61 67 20 53 45 54 20   UPDATE tag SET 
35d0: 6c 6f 64 20 3d 20 24 70 69 64 20 57 48 45 52 45  lod = $pid WHERE
35e0: 20 74 69 64 20 3d 20 24 69 64 20 7d 0a 09 20 20   tid = $id }..  
35f0: 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 0a 09 6c 6f    incr n..}...lo
3600: 67 20 77 72 69 74 65 20 33 20 66 69 6c 74 65 72  g write 3 filter
3610: 73 79 6d 20 22 52 65 70 61 72 65 6e 74 65 64 20  sym "Reparented 
3620: 5b 6e 73 70 20 24 6e 20 74 61 67 5d 22 0a 0a 09  [nsp $n tag]"...
3630: 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c 74  log write 3 filt
3640: 65 72 73 79 6d 20 22 41 64 6a 75 73 74 20 62 72  ersym "Adjust br
3650: 61 6e 63 68 20 70 61 72 65 6e 74 73 22 0a 0a 09  anch parents"...
3660: 23 20 46 69 6e 64 20 74 68 65 20 62 72 61 6e 63  # Find the branc
3670: 68 65 73 20 77 68 6f 73 65 20 63 75 72 72 65 6e  hes whose curren
3680: 74 20 70 61 72 65 6e 74 20 28 6c 6f 64 29 20 69  t parent (lod) i
3690: 73 20 6e 6f 74 20 74 68 65 0a 09 23 20 70 72 65  s not the..# pre
36a0: 66 65 72 65 64 20 70 61 72 65 6e 74 2c 20 74 68  fered parent, th
36b0: 65 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e  e prefered paren
36c0: 74 20 69 73 20 6e 6f 74 20 74 68 65 20 74 72 75  t is not the tru
36d0: 6e 6b 2c 20 61 6e 64 0a 09 23 20 74 68 65 20 70  nk, and..# the p
36e0: 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20 69  refered parent i
36f0: 73 20 61 20 70 6f 73 73 69 62 6c 65 20 70 61 72  s a possible par
3700: 65 6e 74 20 70 65 72 20 74 68 65 20 62 72 61 6e  ent per the bran
3710: 63 68 27 73 0a 09 23 20 72 65 76 69 73 69 6f 6e  ch's..# revision
3720: 2e 0a 0a 09 73 65 74 20 66 6d 74 20 25 5b 73 74  ....set fmt %[st
3730: 72 69 6e 67 20 6c 65 6e 67 74 68 20 24 62 6d 61  ring length $bma
3740: 78 5d 73 0a 09 73 65 74 20 6d 78 73 20 5b 66 6f  x]s..set mxs [fo
3750: 72 6d 61 74 20 24 66 6d 74 20 24 62 6d 61 78 5d  rmat $fmt $bmax]
3760: 0a 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 65  ...set n 0..fore
3770: 61 63 68 20 7b 69 64 20 66 69 64 20 6c 6f 64 20  ach {id fid lod 
3780: 70 6f 73 20 70 69 64 20 70 72 65 66 65 72 65 64  pos pid prefered
3790: 6e 61 6d 65 20 72 65 76 6e 72 20 72 69 64 7d 20  name revnr rid} 
37a0: 24 62 72 61 6e 63 68 65 73 74 6f 61 64 6a 75 73  $branchestoadjus
37b0: 74 20 7b 0a 0a 09 20 20 20 20 23 20 42 4f 54 54  t {...    # BOTT
37c0: 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 09 20 20 20  LE-NECK .....   
37d0: 20 23 0a 09 20 20 20 20 23 20 54 68 65 20 63 68   #..    # The ch
37e0: 65 63 6b 20 69 66 20 74 68 65 20 63 61 6e 64 69  eck if the candi
37f0: 64 61 74 65 20 28 70 69 64 29 20 69 73 20 74 72  date (pid) is tr
3800: 75 6c 79 20 76 69 61 62 6c 65 20 69 73 0a 09 20  uly viable is.. 
3810: 20 20 20 23 20 62 61 73 65 64 20 6f 6e 20 74 68     # based on th
3820: 65 20 62 72 61 6e 63 68 20 70 6f 73 69 74 69 6f  e branch positio
3830: 6e 73 20 69 6e 20 74 68 65 20 73 70 61 77 6e 69  ns in the spawni
3840: 6e 67 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20  ng revision,..  
3850: 20 20 23 20 61 6e 64 20 64 6f 6e 65 20 6e 6f 77    # and done now
3860: 20 69 6e 73 74 65 61 64 20 6f 66 20 61 73 20 70   instead of as p
3870: 61 72 74 20 6f 66 20 74 68 65 20 61 6c 72 65 61  art of the alrea
3880: 64 79 20 63 6f 6d 70 6c 65 78 0a 09 20 20 20 20  dy complex..    
3890: 23 20 6a 6f 69 6e 2e 0a 09 20 20 20 20 23 0a 09  # join...    #..
38a0: 20 20 20 20 23 20 2e 2e 2e 20 41 4e 44 20 50 2e      # ... AND P.
38b0: 70 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20 42  pid IN (SELECT B
38c0: 58 2e 73 69 64 0a 09 20 20 20 20 23 20 20 20 20  X.sid..    #    
38d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 46                 F
38e0: 52 4f 4d 20 62 72 61 6e 63 68 20 42 58 0a 09 20  ROM branch BX.. 
38f0: 20 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20     #            
3900: 20 20 20 20 20 20 20 57 48 45 52 45 20 42 58 2e         WHERE BX.
3910: 72 6f 6f 74 20 3d 20 52 2e 72 69 64 0a 09 20 20  root = R.rid..  
3920: 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20 20    #             
3930: 20 20 20 20 20 20 41 4e 44 20 20 20 42 58 2e 70        AND   BX.p
3940: 6f 73 20 3e 20 42 2e 70 6f 73 29 0a 0a 09 20 20  os > B.pos)...  
3950: 20 20 23 20 4e 6f 74 65 3a 20 72 69 64 20 65 71    # Note: rid eq
3960: 20 22 22 20 68 65 61 72 20 6d 65 61 6e 73 20 74   "" hear means t
3970: 68 61 74 20 74 68 69 73 20 69 73 20 61 20 66 72  hat this is a fr
3980: 65 65 2d 66 6c 6f 61 74 69 6e 67 0a 09 20 20 20  ee-floating..   
3990: 20 23 20 62 72 61 6e 63 68 2c 20 77 68 6f 73 65   # branch, whose
39a0: 20 6f 72 69 67 69 6e 61 6c 20 72 6f 6f 74 20 77   original root w
39b0: 61 73 20 72 65 6d 6f 76 65 64 20 61 73 20 61 20  as removed as a 
39c0: 75 6e 6e 65 63 65 73 73 61 72 79 0a 09 20 20 20  unnecessary..   
39d0: 20 23 20 64 65 61 64 20 72 65 76 69 73 69 6f 6e   # dead revision
39e0: 20 28 53 65 65 20 27 66 69 6c 65 3a 3a 52 65 6d   (See 'file::Rem
39f0: 6f 76 65 49 72 72 65 6c 65 76 61 6e 74 44 65 6c  oveIrrelevantDel
3a00: 65 74 69 6f 6e 73 27 29 2e 0a 09 20 20 20 20 23  etions')...    #
3a10: 20 53 75 63 68 20 61 20 62 72 61 6e 63 68 20 63   Such a branch c
3a20: 61 6e 20 62 65 20 72 65 67 72 61 66 74 65 64 20  an be regrafted 
3a30: 77 69 74 68 6f 75 74 20 74 72 6f 75 62 6c 65 20  without trouble 
3a40: 61 6e 64 20 74 68 65 72 65 0a 09 20 20 20 20 23  and there..    #
3a50: 20 69 73 20 6e 6f 20 6e 65 65 64 20 74 6f 20 6c   is no need to l
3a60: 6f 6f 6b 20 66 6f 72 20 74 68 65 20 6e 65 77 20  ook for the new 
3a70: 70 61 72 65 6e 74 20 69 6e 20 69 74 73 0a 09 20  parent in its.. 
3a80: 20 20 20 23 20 6e 6f 6e 2d 65 78 69 73 74 65 6e     # non-existen
3a90: 74 20 72 6f 6f 74 2e 0a 0a 09 20 20 20 20 69 66  t root....    if
3aa0: 20 7b 28 24 72 69 64 20 6e 65 20 22 22 29 20 26   {($rid ne "") &
3ab0: 26 20 21 5b 73 74 61 74 65 20 6f 6e 65 20 7b 0a  & ![state one {.
3ac0: 09 09 53 45 4c 45 43 54 20 43 4f 55 4e 54 28 2a  ..SELECT COUNT(*
3ad0: 29 20 20 20 20 20 20 20 2d 2d 20 43 6f 75 6e 74  )       -- Count
3ae0: 20 3c 3d 3e 20 43 68 65 63 6b 20 65 78 69 73 74   <=> Check exist
3af0: 65 6e 63 65 2e 0a 09 09 46 52 4f 4d 20 62 72 61  ence....FROM bra
3b00: 6e 63 68 20 42 0a 09 09 57 48 45 52 45 20 20 42  nch B...WHERE  B
3b10: 2e 73 69 64 20 20 3d 20 24 70 69 64 20 20 2d 2d  .sid  = $pid  --
3b20: 20 4c 6f 6f 6b 20 66 6f 72 20 62 72 61 6e 63 68   Look for branch
3b30: 20 62 79 20 73 79 6d 62 6f 6c 0a 09 09 41 4e 44   by symbol...AND
3b40: 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20 24 72 69      B.root = $ri
3b50: 64 20 20 2d 2d 20 53 70 61 77 6e 65 64 20 62 79  d  -- Spawned by
3b60: 20 74 68 65 20 67 69 76 65 6e 20 72 65 76 69 73   the given revis
3b70: 69 6f 6e 0a 09 09 41 4e 44 20 20 20 20 42 2e 70  ion...AND    B.p
3b80: 6f 73 20 20 3e 20 24 70 6f 73 20 20 2d 2d 20 41  os  > $pos  -- A
3b90: 6e 64 20 64 65 66 69 6e 65 64 20 62 65 66 6f 72  nd defined befor
3ba0: 65 20 62 72 61 6e 63 68 20 74 6f 20 6d 75 74 61  e branch to muta
3bb0: 74 65 0a 09 20 20 20 20 7d 5d 7d 20 7b 0a 09 09  te..    }]} {...
3bc0: 69 6e 63 72 20 62 6d 61 78 20 2d 31 0a 09 09 73  incr bmax -1...s
3bd0: 65 74 20 20 6d 78 73 20 5b 66 6f 72 6d 61 74 20  et  mxs [format 
3be0: 24 66 6d 74 20 24 62 6d 61 78 5d 0a 09 09 63 6f  $fmt $bmax]...co
3bf0: 6e 74 69 6e 75 65 0a 09 20 20 20 20 7d 0a 0a 09  ntinue..    }...
3c00: 20 20 20 20 23 0a 09 20 20 20 20 23 20 42 4f 54      #..    # BOT
3c10: 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 0a 09 20  TLE-NECK ...... 
3c20: 20 20 20 23 20 54 68 65 20 6e 61 6d 65 73 20 66     # The names f
3c30: 6f 72 20 75 73 65 20 69 6e 20 74 68 65 20 6c 6f  or use in the lo
3c40: 67 20 6f 75 74 70 75 74 20 61 72 65 20 72 65 74  g output are ret
3c50: 72 69 65 76 65 64 0a 09 20 20 20 20 23 20 73 65  rieved..    # se
3c60: 70 61 72 61 74 65 6c 79 2c 20 74 6f 20 6b 65 65  parately, to kee
3c70: 70 20 74 68 65 20 6a 6f 69 6e 20 73 65 6c 65 63  p the join selec
3c80: 74 69 6e 67 20 74 68 65 20 61 64 6a 75 73 74 61  ting the adjusta
3c90: 62 6c 65 0a 09 20 20 20 20 23 20 74 61 67 73 20  ble..    # tags 
3ca0: 73 6d 61 6c 6c 2c 20 6e 6f 74 20 62 75 72 64 65  small, not burde
3cb0: 6e 65 64 20 77 69 74 68 20 74 68 65 20 64 65 72  ned with the der
3cc0: 65 66 65 72 65 6e 63 69 6e 67 20 6f 66 20 6c 69  eferencing of li
3cd0: 6e 6b 73 0a 09 20 20 20 20 23 20 74 6f 20 6e 61  nks..    # to na
3ce0: 6d 65 2e 0a 0a 09 20 20 20 20 73 65 74 20 62 72  me....    set br
3cf0: 61 6e 61 6d 65 20 24 73 6e 28 24 69 64 29 0a 09  aname $sn($id)..
3d00: 20 20 20 20 73 65 74 20 6f 6c 64 6e 61 6d 65 20      set oldname 
3d10: 24 73 78 28 24 6c 6f 64 29 0a 09 20 20 20 20 73  $sx($lod)..    s
3d20: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69  truct::list assi
3d30: 67 6e 20 24 66 70 6e 28 24 66 69 64 29 20 66 6e  gn $fpn($fid) fn
3d40: 61 6d 65 20 70 72 6e 61 6d 65 0a 0a 09 20 20 20  ame prname...   
3d50: 20 23 20 44 6f 20 74 68 65 20 67 72 61 66 74 69   # Do the grafti
3d60: 6e 67 2e 0a 0a 09 20 20 20 20 6c 6f 67 20 77 72  ng....    log wr
3d70: 69 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d 20  ite 4 filtersym 
3d80: 7b 5c 5b 5b 66 6f 72 6d 61 74 20 24 66 6d 74 20  {\[[format $fmt 
3d90: 24 6e 5d 2f 24 6d 78 73 5c 5d 20 24 70 72 6e 61  $n]/$mxs\] $prna
3da0: 6d 65 20 3a 20 47 72 61 66 74 69 6e 67 20 62 72  me : Grafting br
3db0: 61 6e 63 68 20 27 24 62 72 61 6e 61 6d 65 27 20  anch '$braname' 
3dc0: 6f 6e 20 24 66 6e 61 6d 65 2f 24 72 65 76 6e 72  on $fname/$revnr
3dd0: 20 66 72 6f 6d 20 27 24 6f 6c 64 6e 61 6d 65 27   from '$oldname'
3de0: 20 6f 6e 74 6f 20 27 24 70 72 65 66 65 72 65 64   onto '$prefered
3df0: 6e 61 6d 65 27 7d 0a 09 20 20 20 20 73 74 61 74  name'}..    stat
3e00: 65 20 72 75 6e 20 7b 20 55 50 44 41 54 45 20 62  e run { UPDATE b
3e10: 72 61 6e 63 68 20 53 45 54 20 6c 6f 64 20 3d 20  ranch SET lod = 
3e20: 24 70 69 64 20 57 48 45 52 45 20 62 69 64 20 3d  $pid WHERE bid =
3e30: 20 24 69 64 20 7d 0a 09 20 20 20 20 69 6e 63 72   $id }..    incr
3e40: 20 6e 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74   n..}...log writ
3e50: 65 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 52  e 3 filtersym "R
3e60: 65 70 61 72 65 6e 74 65 64 20 5b 6e 73 70 20 24  eparented [nsp $
3e70: 6e 20 62 72 61 6e 63 68 20 62 72 61 6e 63 68 65  n branch branche
3e80: 73 5d 22 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  s]"..return.    
3e90: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 52 65 66 69  }..    proc Refi
3ea0: 6e 65 53 79 6d 62 6f 6c 73 20 7b 7d 20 7b 0a 09  neSymbols {} {..
3eb0: 23 20 54 61 67 73 20 61 6e 64 20 62 72 61 6e 63  # Tags and branc
3ec0: 68 65 73 20 61 72 65 20 6d 61 72 6b 65 64 20 61  hes are marked a
3ed0: 73 20 6e 6f 72 6d 61 6c 2f 6e 6f 6f 70 20 62 61  s normal/noop ba
3ee0: 73 65 64 20 6f 6e 20 74 68 65 20 6f 70 0a 09 23  sed on the op..#
3ef0: 20 6f 66 20 74 68 65 69 72 20 72 65 76 69 73 69   of their revisi
3f00: 6f 6e 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  on....log write 
3f10: 33 20 66 69 6c 74 65 72 73 79 6d 20 22 52 65 66  3 filtersym "Ref
3f20: 69 6e 65 20 73 79 6d 62 6f 6c 73 20 28 6e 6f 2d  ine symbols (no-
3f30: 6f 70 20 6f 72 20 6e 6f 74 3f 29 22 0a 0a 09 23  op or not?)"...#
3f40: 20 4e 6f 74 65 3a 20 54 68 65 20 6e 6f 6f 70 20   Note: The noop 
3f50: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 6e  information is n
3f60: 6f 74 20 75 73 65 64 20 61 6e 79 77 68 65 72 65  ot used anywhere
3f70: 2e 20 43 6f 6e 73 69 64 65 72 0a 09 23 20 64 69  . Consider..# di
3f80: 73 61 62 6c 69 6e 67 20 74 68 69 73 20 63 6f 64  sabling this cod
3f90: 65 2c 20 61 6e 64 20 72 65 6d 6f 76 69 6e 67 20  e, and removing 
3fa0: 74 68 65 20 64 61 74 61 20 66 72 6f 6d 20 74 68  the data from th
3fb0: 65 20 73 74 61 74 65 2e 0a 0a 09 6c 6f 67 20 77  e state....log w
3fc0: 72 69 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d  rite 4 filtersym
3fd0: 20 22 20 20 20 20 52 65 67 75 6c 61 72 20 74 61   "    Regular ta
3fe0: 67 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20 7b  gs"..state run {
3ff0: 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ..    INSERT INT
4000: 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c 45  O noop..    SELE
4010: 43 54 20 54 2e 74 69 64 2c 20 30 0a 09 20 20 20  CT T.tid, 0..   
4020: 20 46 52 4f 4d 20 74 61 67 20 54 2c 20 72 65 76   FROM tag T, rev
4030: 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45  ision R..    WHE
4040: 52 45 20 54 2e 72 65 76 20 20 3d 20 52 2e 72 69  RE T.rev  = R.ri
4050: 64 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 6f  d..    AND   R.o
4060: 70 20 20 21 3d 20 30 20 2d 2d 20 30 20 3d 3d 20  p  != 0 -- 0 == 
4070: 6e 6f 74 68 69 6e 67 0a 09 7d 0a 0a 09 6c 6f 67  nothing..}...log
4080: 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73   write 4 filters
4090: 79 6d 20 22 20 20 20 20 4e 6f 2d 6f 70 20 74 61  ym "    No-op ta
40a0: 67 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20 7b  gs"..state run {
40b0: 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ..    INSERT INT
40c0: 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c 45  O noop..    SELE
40d0: 43 54 20 54 2e 74 69 64 2c 20 31 0a 09 20 20 20  CT T.tid, 1..   
40e0: 20 46 52 4f 4d 20 74 61 67 20 54 2c 20 72 65 76   FROM tag T, rev
40f0: 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45  ision R..    WHE
4100: 52 45 20 54 2e 72 65 76 20 20 3d 20 52 2e 72 69  RE T.rev  = R.ri
4110: 64 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 6f  d..    AND   R.o
4120: 70 20 20 20 3d 20 30 20 2d 2d 20 6e 6f 74 68 69  p   = 0 -- nothi
4130: 6e 67 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74  ng..}...log writ
4140: 65 20 34 20 66 69 6c 74 65 72 73 79 6d 20 22 20  e 4 filtersym " 
4150: 20 20 20 52 65 67 75 6c 61 72 20 62 72 61 6e 63     Regular branc
4160: 68 65 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20  hes"..state run 
4170: 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e  {..    INSERT IN
4180: 54 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c  TO noop..    SEL
4190: 45 43 54 20 42 2e 62 69 64 2c 20 30 0a 09 20 20  ECT B.bid, 0..  
41a0: 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 2c    FROM branch B,
41b0: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20   revision R..   
41c0: 20 57 48 45 52 45 20 42 2e 72 6f 6f 74 20 3d 20   WHERE B.root = 
41d0: 52 2e 72 69 64 0a 09 20 20 20 20 41 4e 44 20 20  R.rid..    AND  
41e0: 20 52 2e 6f 70 20 20 21 3d 20 30 20 2d 2d 20 6e   R.op  != 0 -- n
41f0: 6f 74 68 69 6e 67 0a 09 7d 0a 0a 09 6c 6f 67 20  othing..}...log 
4200: 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73 79  write 4 filtersy
4210: 6d 20 22 20 20 20 20 4e 6f 2d 6f 70 20 62 72 61  m "    No-op bra
4220: 6e 63 68 65 73 22 0a 09 73 74 61 74 65 20 72 75  nches"..state ru
4230: 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20  n {..    INSERT 
4240: 49 4e 54 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53  INTO noop..    S
4250: 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 31 0a 09  ELECT B.bid, 1..
4260: 20 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20      FROM branch 
4270: 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20  B, revision R.. 
4280: 20 20 20 57 48 45 52 45 20 42 2e 72 6f 6f 74 20     WHERE B.root 
4290: 3d 20 52 2e 72 69 64 0a 09 20 20 20 20 41 4e 44  = R.rid..    AND
42a0: 20 20 20 52 2e 6f 70 20 20 20 3d 20 30 20 2d 2d     R.op   = 0 --
42b0: 20 6e 6f 74 68 69 6e 67 0a 09 7d 0a 09 72 65 74   nothing..}..ret
42c0: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70  urn.    }..    p
42d0: 72 6f 63 20 6d 61 78 6c 65 6e 20 7b 76 20 73 74  roc maxlen {v st
42e0: 72 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 76  r} {..upvar 1 $v
42f0: 20 6e 0a 09 73 65 74 20 6c 20 5b 73 74 72 69 6e   n..set l [strin
4300: 67 20 6c 65 6e 67 74 68 20 24 73 74 72 5d 0a 09  g length $str]..
4310: 69 66 20 7b 24 6c 20 3c 3d 20 24 6e 7d 20 72 65  if {$l <= $n} re
4320: 74 75 72 6e 0a 09 73 65 74 20 6e 20 24 6c 0a 09  turn..set n $l..
4330: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
4340: 20 20 70 72 6f 63 20 50 72 69 6e 74 53 79 6d 62    proc PrintSymb
4350: 6f 6c 54 72 65 65 20 7b 7d 20 7b 0a 09 69 66 20  olTree {} {..if 
4360: 7b 21 5b 6c 6f 67 20 76 69 73 69 62 6c 65 3f 20  {![log visible? 
4370: 39 5d 7d 20 72 65 74 75 72 6e 0a 0a 09 61 72 72  9]} return...arr
4380: 61 79 20 73 65 74 20 73 79 6d 20 7b 7d 0a 09 73  ay set sym {}..s
4390: 65 74 20 6e 20 30 0a 09 73 65 74 20 74 20 30 0a  et n 0..set t 0.
43a0: 09 73 65 74 20 63 20 30 0a 0a 09 66 6f 72 65 61  .set c 0...forea
43b0: 63 68 20 7b 73 20 73 74 79 70 65 20 63 63 20 70  ch {s stype cc p
43c0: 20 70 74 79 70 65 7d 20 5b 73 74 61 74 65 20 72   ptype} [state r
43d0: 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  un {..    SELECT
43e0: 20 53 2e 6e 61 6d 65 2c 20 41 2e 6e 61 6d 65 2c   S.name, A.name,
43f0: 20 53 2e 63 6f 6d 6d 69 74 5f 63 6f 75 6e 74 2c   S.commit_count,
4400: 20 50 2e 6e 61 6d 65 2c 20 42 2e 6e 61 6d 65 0a   P.name, B.name.
4410: 09 20 20 20 20 46 52 4f 4d 20 20 20 74 61 67 20  .    FROM   tag 
4420: 54 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 73 79 6d  T, symbol S, sym
4430: 62 6f 6c 20 50 2c 20 73 79 6d 74 79 70 65 20 41  bol P, symtype A
4440: 2c 20 73 79 6d 74 79 70 65 20 42 0a 09 20 20 20  , symtype B..   
4450: 20 57 48 45 52 45 20 20 53 2e 73 69 64 20 3d 20   WHERE  S.sid = 
4460: 54 2e 73 69 64 0a 09 20 20 20 20 41 4e 44 20 20  T.sid..    AND  
4470: 20 20 50 2e 73 69 64 20 3d 20 54 2e 6c 6f 64 0a    P.sid = T.lod.
4480: 09 20 20 20 20 41 4e 44 20 20 20 20 41 2e 74 69  .    AND    A.ti
4490: 64 20 3d 20 53 2e 74 79 70 65 0a 09 20 20 20 20  d = S.type..    
44a0: 41 4e 44 20 20 20 20 42 2e 74 69 64 20 3d 20 50  AND    B.tid = P
44b0: 2e 74 79 70 65 0a 09 20 20 20 20 55 4e 49 4f 4e  .type..    UNION
44c0: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e  ..    SELECT S.n
44d0: 61 6d 65 2c 20 41 2e 6e 61 6d 65 2c 20 53 2e 63  ame, A.name, S.c
44e0: 6f 6d 6d 69 74 5f 63 6f 75 6e 74 2c 20 50 2e 6e  ommit_count, P.n
44f0: 61 6d 65 2c 20 42 2e 6e 61 6d 65 0a 09 20 20 20  ame, B.name..   
4500: 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42   FROM   branch B
4510: 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 73 79 6d 62  , symbol S, symb
4520: 6f 6c 20 50 2c 20 73 79 6d 74 79 70 65 20 41 2c  ol P, symtype A,
4530: 20 73 79 6d 74 79 70 65 20 42 0a 09 20 20 20 20   symtype B..    
4540: 57 48 45 52 45 20 20 53 2e 73 69 64 20 3d 20 42  WHERE  S.sid = B
4550: 2e 73 69 64 0a 09 20 20 20 20 41 4e 44 20 20 20  .sid..    AND   
4560: 20 50 2e 73 69 64 20 3d 20 42 2e 6c 6f 64 0a 09   P.sid = B.lod..
4570: 20 20 20 20 41 4e 44 20 20 20 20 41 2e 74 69 64      AND    A.tid
4580: 20 3d 20 53 2e 74 79 70 65 0a 09 20 20 20 20 41   = S.type..    A
4590: 4e 44 20 20 20 20 42 2e 74 69 64 20 3d 20 50 2e  ND    B.tid = P.
45a0: 74 79 70 65 0a 09 7d 5d 20 7b 0a 09 20 20 20 20  type..}] {..    
45b0: 6c 61 70 70 65 6e 64 20 73 79 6d 28 24 73 29 20  lappend sym($s) 
45c0: 24 70 20 24 73 74 79 70 65 20 24 70 74 79 70 65  $p $stype $ptype
45d0: 20 24 63 63 0a 09 20 20 20 20 6d 61 78 6c 65 6e   $cc..    maxlen
45e0: 20 6e 20 24 73 0a 09 20 20 20 20 6d 61 78 6c 65   n $s..    maxle
45f0: 6e 20 74 20 24 73 74 79 70 65 0a 09 20 20 20 20  n t $stype..    
4600: 6d 61 78 6c 65 6e 20 74 20 24 70 74 79 70 65 0a  maxlen t $ptype.
4610: 09 20 20 20 20 6d 61 78 6c 65 6e 20 63 20 24 63  .    maxlen c $c
4620: 63 0a 09 7d 0a 0a 09 66 6f 72 65 61 63 68 20 73  c..}...foreach s
4630: 20 5b 6c 73 6f 72 74 20 2d 64 69 63 74 20 5b 61   [lsort -dict [a
4640: 72 72 61 79 20 6e 61 6d 65 73 20 73 79 6d 5d 5d  rray names sym]]
4650: 20 7b 0a 09 20 20 20 20 73 74 72 75 63 74 3a 3a   {..    struct::
4660: 6c 69 73 74 20 61 73 73 69 67 6e 20 24 73 79 6d  list assign $sym
4670: 28 24 73 29 20 70 20 73 74 79 70 65 20 70 74 79  ($s) p stype pty
4680: 70 65 20 63 63 0a 0a 09 20 20 20 20 6c 6f 67 20  pe cc...    log 
4690: 77 72 69 74 65 20 39 20 66 69 6c 74 65 72 73 79  write 9 filtersy
46a0: 6d 20 7b 54 72 65 65 3a 20 5b 66 6f 72 6d 61 74  m {Tree: [format
46b0: 20 25 2d 24 7b 74 7d 73 20 24 73 74 79 70 65 5d   %-${t}s $stype]
46c0: 20 28 5b 66 6f 72 6d 61 74 20 25 2d 24 7b 63 7d   ([format %-${c}
46d0: 64 20 24 63 63 5d 29 20 5b 66 6f 72 6d 61 74 20  d $cc]) [format 
46e0: 25 2d 24 7b 6e 7d 73 20 24 73 5d 20 3c 2d 2d 20  %-${n}s $s] <-- 
46f0: 5b 66 6f 72 6d 61 74 20 25 2d 24 7b 74 7d 73 20  [format %-${t}s 
4700: 24 70 74 79 70 65 5d 20 24 70 7d 0a 09 7d 0a 09  $ptype] $p}..}..
4710: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
4720: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
4730: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
4740: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
4750: 20 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a   Configuration..
4760: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69      pragma -hasi
4770: 6e 73 74 61 6e 63 65 73 20 20 20 6e 6f 20 3b 20  nstances   no ; 
4780: 23 20 73 69 6e 67 6c 65 74 6f 6e 0a 20 20 20 20  # singleton.    
4790: 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65 69  pragma -hastypei
47a0: 6e 66 6f 20 20 20 20 6e 6f 20 3b 20 23 20 6e 6f  nfo    no ; # no
47b0: 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20   introspection. 
47c0: 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79     pragma -hasty
47d0: 70 65 64 65 73 74 72 6f 79 20 6e 6f 20 3b 20 23  pedestroy no ; #
47e0: 20 69 6d 6d 6f 72 74 61 6c 0a 0a 20 20 20 20 23   immortal..    #
47f0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
4800: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
4810: 23 23 23 23 23 23 0a 7d 0a 0a 6e 61 6d 65 73 70  ######.}..namesp
4820: 61 63 65 20 65 76 61 6c 20 3a 3a 76 63 3a 3a 66  ace eval ::vc::f
4830: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
4840: 76 73 3a 3a 70 61 73 73 20 7b 0a 20 20 20 20 6e  vs::pass {.    n
4850: 61 6d 65 73 70 61 63 65 20 65 78 70 6f 72 74 20  amespace export 
4860: 66 69 6c 74 65 72 73 79 6d 0a 20 20 20 20 6e 61  filtersym.    na
4870: 6d 65 73 70 61 63 65 20 65 76 61 6c 20 66 69 6c  mespace eval fil
4880: 74 65 72 73 79 6d 20 7b 0a 09 6e 61 6d 65 73 70  tersym {..namesp
4890: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
48a0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
48b0: 3a 63 76 73 3a 3a 72 65 70 6f 73 69 74 6f 72 79  :cvs::repository
48c0: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
48d0: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  rt ::vc::fossil:
48e0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74  :import::cvs::st
48f0: 61 74 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ate..namespace i
4900: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73  mport ::vc::foss
4910: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
4920: 3a 69 6e 74 65 67 72 69 74 79 0a 09 6e 61 6d 65  :integrity..name
4930: 73 70 61 63 65 20 65 76 61 6c 20 70 72 6f 6a 65  space eval proje
4940: 63 74 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70  ct {..    namesp
4950: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
4960: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
4970: 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 73  :cvs::project::s
4980: 79 6d 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65  ym..}..namespace
4990: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f   import ::vc::to
49a0: 6f 6c 73 3a 3a 6d 69 73 63 3a 3a 6e 73 70 0a 09  ols::misc::nsp..
49b0: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
49c0: 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f   ::vc::tools::lo
49d0: 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65 72 20  g..log register 
49e0: 66 69 6c 74 65 72 73 79 6d 0a 20 20 20 20 7d 0a  filtersym.    }.
49f0: 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23  }..# # ## ### ##
4a00: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
4a10: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23  ########## #####
4a20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
4a30: 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 63 6b 61  .## Ready..packa
4a40: 67 65 20 70 72 6f 76 69 64 65 20 76 63 3a 3a 66  ge provide vc::f
4a50: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
4a60: 76 73 3a 3a 70 61 73 73 3a 3a 66 69 6c 74 65 72  vs::pass::filter
4a70: 73 79 6d 20 31 2e 30 0a 72 65 74 75 72 6e 0a     sym 1.0.return.