Hex Artifact Content
Not logged in

Artifact 77d474466172f34ed9e8f27f56c0b0c62d4e2973:

File tools/cvs2fossil/lib/c2f_pfiltersym.tcl part of check-in [ae53becda4] - Changed the printing of the symbol tree to be based on table 'preferedparent', and introduced two procs to shorten the fomratting code. by aku on 2008-03-02 01:09:16.

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 2d 32 30 30 38 20 41 6e 64 72 65 61 73 20  07-2008 Andreas 
0070: 4b 75 70 72 69 65 73 2e 0a 23 0a 23 20 54 68 69  Kupries..#.# Thi
0080: 73 20 73 6f 66 74 77 61 72 65 20 69 73 20 6c 69  s software is li
0090: 63 65 6e 73 65 64 20 61 73 20 64 65 73 63 72 69  censed as descri
00a0: 62 65 64 20 69 6e 20 74 68 65 20 66 69 6c 65 20  bed in the file 
00b0: 4c 49 43 45 4e 53 45 2c 20 77 68 69 63 68 0a 23  LICENSE, which.#
00c0: 20 79 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65   you should have
00d0: 20 72 65 63 65 69 76 65 64 20 61 73 20 70 61 72   received as par
00e0: 74 20 6f 66 20 74 68 69 73 20 64 69 73 74 72 69  t of this distri
00f0: 62 75 74 69 6f 6e 2e 0a 23 0a 23 20 54 68 69 73  bution..#.# This
0100: 20 73 6f 66 74 77 61 72 65 20 63 6f 6e 73 69 73   software consis
0110: 74 73 20 6f 66 20 76 6f 6c 75 6e 74 61 72 79 20  ts of voluntary 
0120: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 73 20 6d 61  contributions ma
0130: 64 65 20 62 79 20 6d 61 6e 79 0a 23 20 69 6e 64  de by many.# ind
0140: 69 76 69 64 75 61 6c 73 2e 20 20 46 6f 72 20 65  ividuals.  For e
0150: 78 61 63 74 20 63 6f 6e 74 72 69 62 75 74 69 6f  xact contributio
0160: 6e 20 68 69 73 74 6f 72 79 2c 20 73 65 65 20 74  n history, see t
0170: 68 65 20 72 65 76 69 73 69 6f 6e 0a 23 20 68 69  he revision.# hi
0180: 73 74 6f 72 79 20 61 6e 64 20 6c 6f 67 73 2c 20  story and logs, 
0190: 61 76 61 69 6c 61 62 6c 65 20 61 74 20 68 74 74  available at htt
01a0: 70 3a 2f 2f 66 6f 73 73 69 6c 2d 73 63 6d 2e 68  p://fossil-scm.h
01b0: 77 61 63 69 2e 63 6f 6d 2f 66 6f 73 73 69 6c 0a  waci.com/fossil.
01c0: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
01d0: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
01e0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
01f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a 23  #############..#
0200: 23 20 50 61 73 73 20 49 56 2e 20 43 6f 6d 69 6e  # Pass IV. Comin
0210: 67 20 61 66 74 65 72 20 74 68 65 20 73 79 6d 62  g after the symb
0220: 6f 6c 20 63 6f 6c 6c 61 74 69 6f 6e 20 70 61 73  ol collation pas
0230: 73 20 74 68 69 73 20 70 61 73 73 20 6e 6f 77 0a  s this pass now.
0240: 23 23 20 72 65 6d 6f 76 65 73 20 61 6c 6c 20 72  ## removes all r
0250: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 73 79 6d  evisions and sym
0260: 62 6f 6c 73 20 72 65 66 65 72 65 6e 63 69 6e 67  bols referencing
0270: 20 61 6e 79 20 6f 66 20 74 68 65 20 65 78 63 6c   any of the excl
0280: 75 64 65 64 0a 23 23 20 73 79 6d 62 6f 6c 73 20  uded.## symbols 
0290: 66 72 6f 6d 20 74 68 65 20 70 65 72 73 69 73 74  from the persist
02a0: 65 6e 74 20 64 61 74 61 62 61 73 65 2e 0a 0a 23  ent database...#
02b0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
02c0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
02d0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
02e0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
02f0: 52 65 71 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61  Requirements..pa
0300: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 54 63  ckage require Tc
0310: 6c 20 38 2e 34 20 20 20 20 20 20 20 20 20 20 20  l 8.4           
0320: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0330: 20 20 20 20 3b 20 23 20 52 65 71 75 69 72 65 64      ; # Required
0340: 20 72 75 6e 74 69 6d 65 2e 0a 70 61 63 6b 61 67   runtime..packag
0350: 65 20 72 65 71 75 69 72 65 20 73 6e 69 74 20 20  e require 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 20 20 20 20 20                  
0380: 3b 20 23 20 4f 4f 20 73 79 73 74 65 6d 2e 0a 70  ; # OO system..p
0390: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76  ackage require v
03a0: 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63 20 20  c::tools::misc  
03b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03c0: 20 20 20 20 20 3b 20 23 20 54 65 78 74 20 66 6f       ; # Text fo
03d0: 72 6d 61 74 74 69 6e 67 2e 0a 70 61 63 6b 61 67  rmatting..packag
03e0: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 6f  e require vc::to
03f0: 6f 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20 20 20  ols::log        
0400: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0410: 3b 20 23 20 55 73 65 72 20 66 65 65 64 62 61 63  ; # User feedbac
0420: 6b 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69  k..package requi
0430: 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69  re vc::fossil::i
0440: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70 6f  mport::cvs::repo
0450: 73 69 74 6f 72 79 20 20 20 3b 20 23 20 52 65 70  sitory   ; # Rep
0460: 6f 73 69 74 6f 72 79 20 6d 61 6e 61 67 65 6d 65  ository manageme
0470: 6e 74 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75  nt..package requ
0480: 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  ire vc::fossil::
0490: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61  import::cvs::sta
04a0: 74 65 20 20 20 20 20 20 20 20 3b 20 23 20 53 74  te        ; # St
04b0: 61 74 65 20 73 74 6f 72 61 67 65 2e 0a 70 61 63  ate storage..pac
04c0: 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a  kage require vc:
04d0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
04e0: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 20  :cvs::integrity 
04f0: 20 20 20 3b 20 23 20 53 74 61 74 65 20 73 74 6f     ; # State sto
0500: 72 61 67 65 20 69 6e 74 65 67 72 69 74 79 20 63  rage integrity c
0510: 68 65 63 6b 73 2e 0a 70 61 63 6b 61 67 65 20 72  hecks..package r
0520: 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69  equire vc::fossi
0530: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
0540: 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 3b 20 23  project::sym ; #
0550: 20 50 72 6f 6a 65 63 74 20 6c 65 76 65 6c 20 73   Project level s
0560: 79 6d 62 6f 6c 73 0a 0a 23 20 23 20 23 23 20 23  ymbols..# # ## #
0570: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
0580: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20  # ############# 
0590: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
05a0: 23 23 23 23 23 0a 23 23 20 52 65 67 69 73 74 65  #####.## Registe
05b0: 72 20 74 68 65 20 70 61 73 73 20 77 69 74 68 20  r the pass with 
05c0: 74 68 65 20 6d 61 6e 61 67 65 6d 65 6e 74 0a 0a  the management..
05d0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
05e0: 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20 64 65  rt::cvs::pass de
05f0: 66 69 6e 65 20 5c 0a 20 20 20 20 46 69 6c 74 65  fine \.    Filte
0600: 72 53 79 6d 62 6f 6c 73 20 5c 0a 20 20 20 20 7b  rSymbols \.    {
0610: 46 69 6c 74 65 72 20 73 79 6d 62 6f 6c 73 2c 20  Filter symbols, 
0620: 72 65 6d 6f 76 65 20 61 6c 6c 20 65 78 63 6c 75  remove all exclu
0630: 64 65 64 20 70 69 65 63 65 73 7d 20 5c 0a 20 20  ded pieces} \.  
0640: 20 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a    ::vc::fossil::
0650: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73  import::cvs::pas
0660: 73 3a 3a 66 69 6c 74 65 72 73 79 6d 0a 0a 23 20  s::filtersym..# 
0670: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
0680: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
0690: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
06a0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 0a 0a  ###########.##..
06b0: 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a  snit::type ::vc:
06c0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
06d0: 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 66 69 6c 74  :cvs::pass::filt
06e0: 65 72 73 79 6d 20 7b 0a 20 20 20 20 23 20 23 20  ersym {.    # # 
06f0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
0700: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
0710: 23 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69  ###.    ## Publi
0720: 63 20 41 50 49 0a 0a 20 20 20 20 74 79 70 65 6d  c API..    typem
0730: 65 74 68 6f 64 20 73 65 74 75 70 20 7b 7d 20 7b  ethod setup {} {
0740: 0a 09 23 20 44 65 66 69 6e 65 20 6e 61 6d 65 73  ..# Define names
0750: 20 61 6e 64 20 73 74 72 75 63 74 75 72 65 20 6f   and structure o
0760: 66 20 74 68 65 20 70 65 72 73 69 73 74 65 6e 74  f the persistent
0770: 20 73 74 61 74 65 20 6f 66 20 74 68 69 73 0a 09   state of this..
0780: 23 20 70 61 73 73 2e 0a 0a 09 73 74 61 74 65 20  # pass....state 
0790: 75 73 65 20 70 72 6f 6a 65 63 74 0a 09 73 74 61  use project..sta
07a0: 74 65 20 75 73 65 20 66 69 6c 65 0a 09 73 74 61  te use file..sta
07b0: 74 65 20 75 73 65 20 72 65 76 69 73 69 6f 6e 0a  te use revision.
07c0: 09 73 74 61 74 65 20 75 73 65 20 72 65 76 69 73  .state use revis
07d0: 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65  ionbranchchildre
07e0: 6e 0a 09 73 74 61 74 65 20 75 73 65 20 62 72 61  n..state use bra
07f0: 6e 63 68 0a 09 73 74 61 74 65 20 75 73 65 20 74  nch..state use t
0800: 61 67 0a 09 73 74 61 74 65 20 75 73 65 20 73 79  ag..state use sy
0810: 6d 62 6f 6c 0a 09 73 74 61 74 65 20 75 73 65 20  mbol..state use 
0820: 62 6c 6f 63 6b 65 72 0a 09 73 74 61 74 65 20 75  blocker..state u
0830: 73 65 20 70 61 72 65 6e 74 0a 09 73 74 61 74 65  se parent..state
0840: 20 75 73 65 20 61 75 74 68 6f 72 0a 09 73 74 61   use author..sta
0850: 74 65 20 75 73 65 20 63 6d 65 73 73 61 67 65 0a  te use cmessage.
0860: 09 73 74 61 74 65 20 75 73 65 20 70 72 65 66 65  .state use prefe
0870: 72 65 64 70 61 72 65 6e 74 0a 0a 09 23 20 4e 4f  redparent...# NO
0880: 54 45 3a 20 53 6f 20 66 61 72 20 6e 6f 20 70 61  TE: So far no pa
0890: 73 73 20 63 6f 6d 69 6e 67 20 61 66 74 65 72 20  ss coming after 
08a0: 74 68 69 73 20 6d 61 6b 65 73 20 75 73 20 6f 66  this makes us of
08b0: 20 74 68 69 73 20 69 6e 66 6f 72 6d 61 74 69 6f   this informatio
08c0: 6e 2e 0a 09 73 74 61 74 65 20 65 78 74 65 6e 64  n...state extend
08d0: 20 6e 6f 6f 70 20 7b 0a 09 20 20 20 20 69 64 20   noop {..    id 
08e0: 20 20 20 49 4e 54 45 47 45 52 20 4e 4f 54 20 4e     INTEGER NOT N
08f0: 55 4c 4c 20 20 50 52 49 4d 41 52 59 20 4b 45 59  ULL  PRIMARY KEY
0900: 2c 20 2d 2d 20 74 61 67 2f 62 72 61 6e 63 68 20  , -- tag/branch 
0910: 72 65 66 65 72 65 6e 63 65 0a 09 20 20 20 20 6e  reference..    n
0920: 6f 6f 70 20 20 49 4e 54 45 47 45 52 20 4e 4f 54  oop  INTEGER NOT
0930: 20 4e 55 4c 4c 0a 09 7d 0a 09 72 65 74 75 72 6e   NULL..}..return
0940: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65  .    }..    type
0950: 6d 65 74 68 6f 64 20 6c 6f 61 64 20 7b 7d 20 7b  method load {} {
0960: 0a 09 23 20 50 61 73 73 20 6d 61 6e 61 67 65 72  ..# Pass manager
0970: 20 69 6e 74 65 72 66 61 63 65 2e 20 45 78 65 63   interface. Exec
0980: 75 74 65 64 20 74 6f 20 6c 6f 61 64 20 64 61 74  uted to load dat
0990: 61 20 63 6f 6d 70 75 74 65 64 20 62 79 0a 09 23  a computed by..#
09a0: 20 74 68 69 73 20 70 61 73 73 20 69 6e 74 6f 20   this pass into 
09b0: 6d 65 6d 6f 72 79 20 77 68 65 6e 20 74 68 69 73  memory when this
09c0: 20 70 61 73 73 20 69 73 20 73 6b 69 70 70 65 64   pass is skipped
09d0: 20 69 6e 73 74 65 61 64 20 6f 66 0a 09 23 20 65   instead of..# e
09e0: 78 65 63 75 74 65 64 2e 0a 0a 09 23 20 54 68 65  xecuted....# The
09f0: 20 72 65 73 75 6c 74 73 20 6f 66 20 74 68 69 73   results of this
0a00: 20 70 61 73 73 20 61 72 65 20 66 75 6c 6c 79 20   pass are fully 
0a10: 69 6e 20 74 68 65 20 70 65 72 73 69 73 74 65 6e  in the persisten
0a20: 74 20 73 74 61 74 65 2c 0a 09 23 20 74 68 65 72  t state,..# ther
0a30: 65 20 69 73 20 6e 6f 74 68 69 6e 67 20 74 6f 20  e is nothing to 
0a40: 6c 6f 61 64 20 66 6f 72 20 74 68 65 20 6e 65 78  load for the nex
0a50: 74 20 6f 6e 65 2e 0a 09 72 65 74 75 72 6e 0a 20  t one...return. 
0a60: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65     }..    typeme
0a70: 74 68 6f 64 20 72 75 6e 20 7b 7d 20 7b 0a 09 23  thod run {} {..#
0a80: 20 50 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e   Pass manager in
0a90: 74 65 72 66 61 63 65 2e 20 45 78 65 63 75 74 65  terface. Execute
0aa0: 64 20 74 6f 20 70 65 72 66 6f 72 6d 20 74 68 65  d to perform the
0ab0: 0a 09 23 20 66 75 6e 63 74 69 6f 6e 61 6c 69 74  ..# functionalit
0ac0: 79 20 6f 66 20 74 68 65 20 70 61 73 73 2e 0a 0a  y of the pass...
0ad0: 09 23 20 54 68 65 20 72 65 6d 6f 76 61 6c 20 6f  .# The removal o
0ae0: 66 20 65 78 63 6c 75 64 65 64 20 73 79 6d 62 6f  f excluded symbo
0af0: 6c 73 20 61 6e 64 20 65 76 65 72 79 74 68 69 6e  ls and everythin
0b00: 67 20 72 65 66 65 72 65 6e 63 69 6e 67 0a 09 23  g referencing..#
0b10: 20 74 6f 20 74 68 65 6d 20 69 73 20 64 6f 6e 65   to them is done
0b20: 20 63 6f 6d 70 6c 65 74 65 6c 79 20 69 6e 20 74   completely in t
0b30: 68 65 20 64 61 74 61 62 61 73 65 2e 0a 0a 09 73  he database....s
0b40: 74 61 74 65 20 74 72 61 6e 73 61 63 74 69 6f 6e  tate transaction
0b50: 20 7b 0a 09 20 20 20 20 46 69 6c 74 65 72 45 78   {..    FilterEx
0b60: 63 6c 75 64 65 64 53 79 6d 62 6f 6c 73 0a 09 20  cludedSymbols.. 
0b70: 20 20 20 4d 75 74 61 74 65 53 79 6d 62 6f 6c 73     MutateSymbols
0b80: 0a 09 20 20 20 20 41 64 6a 75 73 74 50 61 72 65  ..    AdjustPare
0b90: 6e 74 73 0a 09 20 20 20 20 52 65 66 69 6e 65 53  nts..    RefineS
0ba0: 79 6d 62 6f 6c 73 0a 0a 09 20 20 20 20 50 72 69  ymbols...    Pri
0bb0: 6e 74 53 79 6d 62 6f 6c 54 72 65 65 0a 09 20 20  ntSymbolTree..  
0bc0: 20 20 72 65 70 6f 73 69 74 6f 72 79 20 70 72 69    repository pri
0bd0: 6e 74 72 65 76 73 74 61 74 69 73 74 69 63 73 0a  ntrevstatistics.
0be0: 0a 09 20 20 20 20 23 20 53 74 72 69 63 74 20 69  ..    # Strict i
0bf0: 6e 74 65 67 72 69 74 79 20 65 6e 66 6f 72 63 65  ntegrity enforce
0c00: 73 20 74 68 61 74 20 61 6c 6c 20 6d 65 74 61 20  s that all meta 
0c10: 65 6e 74 72 69 65 73 20 61 72 65 20 69 6e 0a 09  entries are in..
0c20: 20 20 20 20 23 20 74 68 65 20 73 61 6d 65 20 4c      # the same L
0c30: 4f 44 20 61 73 20 74 68 65 20 72 65 76 69 73 69  OD as the revisi
0c40: 6f 6e 20 75 73 69 6e 67 20 74 68 65 6d 2e 20 41  on using them. A
0c50: 74 20 74 68 69 73 20 70 6f 69 6e 74 0a 09 20 20  t this point..  
0c60: 20 20 23 20 74 68 69 73 20 6d 61 79 20 6e 6f 74    # this may not
0c70: 20 62 65 20 74 72 75 65 20 61 6e 79 20 6c 6f 6e   be true any lon
0c80: 67 65 72 2e 20 49 66 20 61 20 4e 54 44 42 20 77  ger. If a NTDB w
0c90: 61 73 20 65 78 63 6c 75 64 65 64 0a 09 20 20 20  as excluded..   
0ca0: 20 23 20 74 68 65 6e 20 61 6c 6c 20 72 65 76 69   # then all revi
0cb0: 73 69 6f 6e 73 20 69 74 20 73 68 61 72 65 64 20  sions it shared 
0cc0: 77 69 74 68 20 74 68 65 20 74 72 75 6e 6b 20 77  with the trunk w
0cd0: 65 72 65 20 6d 6f 76 65 64 0a 09 20 20 20 20 23  ere moved..    #
0ce0: 20 74 6f 20 74 68 65 20 74 72 75 6e 6b 20 4c 4f   to the trunk LO
0cf0: 44 2c 20 68 6f 77 65 76 65 72 20 74 68 65 69 72  D, however their
0d00: 20 6d 65 74 61 20 65 6e 74 72 69 65 73 20 77 69   meta entries wi
0d10: 6c 6c 20 73 74 69 6c 6c 0a 09 20 20 20 20 23 20  ll still..    # 
0d20: 72 65 66 65 72 20 74 6f 20 74 68 65 20 6e 6f 77  refer to the now
0d30: 20 67 6f 6e 65 20 4c 4f 44 20 73 79 6d 62 6f 6c   gone LOD symbol
0d40: 2e 20 54 68 69 73 20 69 73 20 66 69 6e 65 20 68  . This is fine h
0d50: 6f 77 65 76 65 72 2c 0a 09 20 20 20 20 23 20 69  owever,..    # i
0d60: 74 20 77 69 6c 6c 20 6e 6f 74 20 61 66 66 65 63  t will not affec
0d70: 74 20 6f 75 72 20 61 62 69 6c 69 74 79 20 74 6f  t our ability to
0d80: 20 75 73 65 20 74 68 65 20 6d 65 74 61 20 65 6e   use the meta en
0d90: 74 72 69 65 73 0a 09 20 20 20 20 23 20 74 6f 20  tries..    # to 
0da0: 64 69 73 74 69 6e 67 75 69 73 68 20 61 6e 64 20  distinguish and 
0db0: 67 72 6f 75 70 20 72 65 76 69 73 69 6f 6e 73 20  group revisions 
0dc0: 69 6e 74 6f 20 63 68 61 6e 67 65 73 65 74 73 2e  into changesets.
0dd0: 20 49 74 0a 09 20 20 20 20 23 20 73 68 6f 75 6c   It..    # shoul
0de0: 64 20 62 65 20 6e 6f 74 65 64 20 74 68 61 74 20  d be noted that 
0df0: 77 65 20 63 61 6e 6e 6f 74 20 73 69 6d 70 6c 79  we cannot simply
0e00: 20 73 77 69 74 63 68 20 74 68 65 20 6d 65 74 61   switch the meta
0e10: 0a 09 20 20 20 20 23 20 65 6e 74 72 69 65 73 20  ..    # entries 
0e20: 6f 76 65 72 20 74 6f 20 74 68 65 20 74 72 75 6e  over to the trun
0e30: 6b 20 65 69 74 68 65 72 2c 20 61 73 20 74 68 61  k either, as tha
0e40: 74 20 6d 61 79 20 63 61 75 73 65 20 74 68 65 0a  t may cause the.
0e50: 09 20 20 20 20 23 20 6d 6f 64 69 66 69 65 64 20  .    # modified 
0e60: 65 6e 74 72 69 65 73 20 74 6f 20 76 69 6f 6c 61  entries to viola
0e70: 74 65 20 74 68 65 20 75 6e 69 71 75 65 2d 6e 65  te the unique-ne
0e80: 73 73 20 63 6f 6e 73 74 72 61 69 6e 74 0a 09 20  ss constraint.. 
0e90: 20 20 20 23 20 73 65 74 20 6f 6e 20 74 68 61 74     # set on that
0ea0: 20 74 61 62 6c 65 2e 0a 09 20 20 20 20 69 6e 74   table...    int
0eb0: 65 67 72 69 74 79 20 6d 65 74 61 72 65 6c 61 78  egrity metarelax
0ec0: 65 64 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74  ed..}...log writ
0ed0: 65 20 31 20 66 69 6c 74 65 72 73 79 6d 20 22 46  e 1 filtersym "F
0ee0: 69 6c 74 65 72 69 6e 67 20 63 6f 6d 70 6c 65 74  iltering complet
0ef0: 65 64 22 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ed"..return.    
0f00: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
0f10: 64 20 64 69 73 63 61 72 64 20 7b 7d 20 7b 0a 09  d discard {} {..
0f20: 23 20 50 61 73 73 20 6d 61 6e 61 67 65 72 20 69  # Pass manager i
0f30: 6e 74 65 72 66 61 63 65 2e 20 45 78 65 63 75 74  nterface. Execut
0f40: 65 64 20 66 6f 72 20 61 6c 6c 20 70 61 73 73 65  ed for all passe
0f50: 73 20 61 66 74 65 72 20 74 68 65 0a 09 23 20 72  s after the..# r
0f60: 75 6e 20 70 61 73 73 65 73 2c 20 74 6f 20 72 65  un passes, to re
0f70: 6d 6f 76 65 20 61 6c 6c 20 64 61 74 61 20 6f 66  move all data of
0f80: 20 74 68 69 73 20 70 61 73 73 20 66 72 6f 6d 20   this pass from 
0f90: 74 68 65 20 73 74 61 74 65 2c 0a 09 23 20 61 73  the state,..# as
0fa0: 20 62 65 69 6e 67 20 6f 75 74 20 6f 66 20 64 61   being out of da
0fb0: 74 65 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  te...return.    
0fc0: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23  }..    # # ## ##
0fd0: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
0fe0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
0ff0: 20 20 20 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d     ## Internal m
1000: 65 74 68 6f 64 73 0a 0a 20 20 20 20 70 72 6f 63  ethods..    proc
1010: 20 46 69 6c 74 65 72 45 78 63 6c 75 64 65 64 53   FilterExcludedS
1020: 79 6d 62 6f 6c 73 20 7b 7d 20 7b 0a 09 6c 6f 67  ymbols {} {..log
1030: 20 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73   write 3 filters
1040: 79 6d 20 22 52 65 6d 6f 76 65 20 74 68 65 20 65  ym "Remove the e
1050: 78 63 6c 75 64 65 64 20 73 79 6d 62 6f 6c 73 20  xcluded symbols 
1060: 61 6e 64 20 74 68 65 69 72 20 75 73 65 72 73 22  and their users"
1070: 0a 0a 09 23 20 57 65 20 70 75 6c 6c 20 61 6c 6c  ...# We pull all
1080: 20 74 68 65 20 65 78 63 6c 75 64 65 64 20 73 79   the excluded sy
1090: 6d 62 6f 6c 73 20 74 6f 67 65 74 68 65 72 20 69  mbols together i
10a0: 6e 74 6f 20 61 20 74 61 62 6c 65 20 66 6f 72 0a  nto a table for.
10b0: 09 23 20 65 61 73 79 20 72 65 66 65 72 65 6e 63  .# easy referenc
10c0: 65 20 62 79 20 74 68 65 20 75 70 63 6f 6d 69 6e  e by the upcomin
10d0: 67 20 44 45 4c 45 54 45 20 61 6e 64 20 6f 74 68  g DELETE and oth
10e0: 65 72 20 73 74 61 74 65 6d 65 6e 74 73 2e 0a 09  er statements...
10f0: 23 20 28 27 78 20 49 4e 20 74 61 62 6c 65 27 20  # ('x IN table' 
1100: 63 6c 61 75 73 65 73 29 2e 0a 0a 09 73 65 74 20  clauses)....set 
1110: 65 78 63 6c 20 5b 70 72 6f 6a 65 63 74 3a 3a 73  excl [project::s
1120: 79 6d 20 65 78 63 6c 75 64 65 64 5d 0a 0a 09 73  ym excluded]...s
1130: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
1140: 43 52 45 41 54 45 20 54 45 4d 50 4f 52 41 52 59  CREATE TEMPORARY
1150: 20 54 41 42 4c 45 20 65 78 63 6c 75 64 65 64 73   TABLE excludeds
1160: 79 6d 62 6f 6c 73 20 41 53 0a 09 20 20 20 20 53  ymbols AS..    S
1170: 45 4c 45 43 54 20 73 69 64 0a 09 20 20 20 20 46  ELECT sid..    F
1180: 52 4f 4d 20 20 20 73 79 6d 62 6f 6c 0a 09 20 20  ROM   symbol..  
1190: 20 20 57 48 45 52 45 20 20 74 79 70 65 20 3d 20    WHERE  type = 
11a0: 24 65 78 63 6c 0a 09 7d 0a 0a 09 23 20 46 69 72  $excl..}...# Fir
11b0: 73 74 20 77 65 20 68 61 76 65 20 74 6f 20 68 61  st we have to ha
11c0: 6e 64 6c 65 20 74 68 65 20 70 6f 73 73 69 62 69  ndle the possibi
11d0: 6c 69 74 79 20 6f 66 20 61 6e 20 65 78 63 6c 75  lity of an exclu
11e0: 64 65 64 0a 09 23 20 4e 54 44 42 2e 20 54 68 69  ded..# NTDB. Thi
11f0: 73 20 69 73 20 61 20 73 70 65 63 69 61 6c 20 73  s is a special s
1200: 70 65 63 69 61 6c 20 63 61 73 65 20 74 68 65 72  pecial case ther
1210: 65 20 77 65 20 68 61 76 65 20 74 6f 0a 09 23 20  e we have to..# 
1220: 72 65 67 72 61 66 74 20 74 68 65 20 72 65 76 69  regraft the revi
1230: 73 69 6f 6e 73 20 77 68 69 63 68 20 61 72 65 20  sions which are 
1240: 73 68 61 72 65 64 20 62 65 74 77 65 65 6e 20 74  shared between t
1250: 68 65 20 4e 54 44 42 20 61 6e 64 0a 09 23 20 54  he NTDB and..# T
1260: 72 75 6e 6b 20 6f 6e 74 6f 20 74 68 65 20 74 72  runk onto the tr
1270: 75 6e 6b 2c 20 70 72 65 76 65 6e 74 69 6e 67 20  unk, preventing 
1280: 74 68 65 69 72 20 64 65 6c 65 74 69 6f 6e 20 6c  their deletion l
1290: 61 74 65 72 2e 20 57 65 0a 09 23 20 68 61 76 65  ater. We..# have
12a0: 20 63 6f 64 65 20 66 6f 72 20 74 68 61 74 20 69   code for that i
12b0: 6e 20 27 66 69 6c 65 27 2c 20 68 6f 77 65 76 65  n 'file', howeve
12c0: 72 20 74 68 61 74 20 6f 70 65 72 61 74 65 64 20  r that operated 
12d0: 6f 6e 20 74 68 65 0a 09 23 20 69 6e 2d 6d 65 6d  on the..# in-mem
12e0: 6f 72 79 20 72 65 76 69 73 69 6f 6e 20 6f 62 6a  ory revision obj
12f0: 65 63 74 73 2c 20 77 68 69 63 68 20 77 65 20 64  ects, which we d
1300: 6f 20 6e 6f 74 20 68 61 76 65 20 68 65 72 65 2e  o not have here.
1310: 20 57 65 20 64 6f 0a 09 23 20 74 68 65 20 73 61   We do..# the sa
1320: 6d 65 20 6e 6f 77 20 77 69 74 68 6f 75 74 20 6f  me now without o
1330: 62 6a 65 63 74 2c 20 62 79 20 64 69 72 65 63 74  bject, by direct
1340: 6c 79 20 6d 61 6e 69 70 75 6c 61 74 69 6e 67 20  ly manipulating 
1350: 74 68 65 0a 09 23 20 6c 69 6e 6b 73 20 69 6e 20  the..# links in 
1360: 74 68 65 20 64 61 74 61 62 61 73 65 2e 0a 0a 09  the database....
1370: 61 72 72 61 79 20 73 65 74 20 6e 74 64 62 20 7b  array set ntdb {
1380: 7d 0a 09 61 72 72 61 79 20 73 65 74 20 6c 69 6e  }..array set lin
1390: 6b 20 7b 7d 0a 0a 09 73 74 61 74 65 20 66 6f 72  k {}...state for
13a0: 65 61 63 68 72 6f 77 20 7b 0a 09 20 20 20 20 53  eachrow {..    S
13b0: 45 4c 45 43 54 20 52 2e 72 69 64 20 20 20 20 20  ELECT R.rid     
13c0: 41 53 20 78 69 64 2c 0a 09 20 20 20 20 20 20 20  AS xid,..       
13d0: 20 20 20 20 52 2e 70 61 72 65 6e 74 20 20 41 53      R.parent  AS
13e0: 20 78 70 61 72 65 6e 74 2c 0a 09 20 20 20 20 20   xparent,..     
13f0: 20 20 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20        R.dbchild 
1400: 41 53 20 74 72 61 6e 73 66 65 72 0a 09 20 20 20  AS transfer..   
1410: 20 46 52 4f 4d 20 20 72 65 76 69 73 69 6f 6e 20   FROM  revision 
1420: 52 2c 20 73 79 6d 62 6f 6c 20 53 0a 09 20 20 20  R, symbol S..   
1430: 20 57 48 45 52 45 20 52 2e 6c 6f 64 20 3d 20 53   WHERE R.lod = S
1440: 2e 73 69 64 20 20 20 20 20 20 20 20 20 20 20 20  .sid            
1450: 2d 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66  -- Get symbol of
1460: 20 6c 69 6e 65 2d 6f 66 2d 64 65 76 65 6c 6f 70   line-of-develop
1470: 6d 65 6e 74 20 6f 66 20 61 6c 6c 20 72 65 76 69  ment of all revi
1480: 73 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20 20  sions..    AND  
1490: 20 53 2e 73 69 64 20 49 4e 20 65 78 63 6c 75 64   S.sid IN exclud
14a0: 65 64 73 79 6d 62 6f 6c 73 20 2d 2d 20 52 65 73  edsymbols -- Res
14b0: 74 72 69 63 74 20 74 6f 20 74 68 65 20 65 78 63  trict to the exc
14c0: 6c 75 64 65 64 20 73 79 6d 62 6f 6c 73 0a 09 20  luded symbols.. 
14d0: 20 20 20 41 4e 44 20 20 20 52 2e 69 73 64 65 66     AND   R.isdef
14e0: 61 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20  ault            
14f0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
1500: 20 4e 54 44 42 20 72 65 76 69 73 69 6f 6e 73 0a   NTDB revisions.
1510: 09 7d 20 7b 0a 09 20 20 20 20 73 65 74 20 6e 74  .} {..    set nt
1520: 64 62 28 24 78 69 64 29 20 24 78 70 61 72 65 6e  db($xid) $xparen
1530: 74 0a 09 20 20 20 20 69 66 20 7b 24 74 72 61 6e  t..    if {$tran
1540: 73 66 65 72 20 65 71 20 22 22 7d 20 63 6f 6e 74  sfer eq ""} cont
1550: 69 6e 75 65 0a 09 20 20 20 20 73 65 74 20 6c 69  inue..    set li
1560: 6e 6b 28 24 78 69 64 29 20 24 74 72 61 6e 73 66  nk($xid) $transf
1570: 65 72 0a 09 7d 0a 0a 09 66 6f 72 65 61 63 68 20  er..}...foreach 
1580: 6a 6f 69 6e 74 20 5b 61 72 72 61 79 20 6e 61 6d  joint [array nam
1590: 65 73 20 6c 69 6e 6b 5d 20 7b 0a 09 20 20 20 20  es link] {..    
15a0: 23 20 54 68 65 20 6a 6f 69 6e 74 73 20 61 72 65  # The joints are
15b0: 20 74 68 65 20 68 69 67 68 65 73 74 20 4e 54 44   the highest NTD
15c0: 42 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63  B revisions whic
15d0: 68 20 61 72 65 0a 09 20 20 20 20 23 20 73 68 61  h are..    # sha
15e0: 72 65 64 20 77 69 74 68 20 74 68 65 69 72 20 72  red with their r
15f0: 65 73 70 65 63 74 69 76 65 20 74 72 75 6e 6b 2e  espective trunk.
1600: 20 57 65 20 64 69 73 63 6f 6e 6e 65 63 74 20 66   We disconnect f
1610: 72 6f 6d 0a 09 20 20 20 20 23 20 74 68 65 69 72  rom..    # their
1620: 20 4e 54 44 42 20 63 68 69 6c 64 72 65 6e 2c 20   NTDB children, 
1630: 61 6e 64 20 6d 61 6b 65 20 74 68 65 6d 20 70 61  and make them pa
1640: 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72 0a 09  rents of their..
1650: 20 20 20 20 23 20 27 64 62 63 68 69 6c 64 27 2e      # 'dbchild'.
1660: 20 54 68 65 20 61 73 73 6f 63 69 61 74 65 64 20   The associated 
1670: 27 64 62 70 61 72 65 6e 74 27 20 69 73 20 73 71  'dbparent' is sq
1680: 75 61 73 68 65 64 0a 09 20 20 20 20 23 20 69 6e  uashed..    # in
1690: 73 74 65 61 64 2e 20 41 6c 6c 20 70 61 72 65 6e  stead. All paren
16a0: 74 73 20 6f 66 20 74 68 65 20 6a 6f 69 6e 74 73  ts of the joints
16b0: 20 61 72 65 20 6d 6f 76 65 64 20 74 6f 20 74 68   are moved to th
16c0: 65 0a 09 20 20 20 20 23 20 74 72 75 6e 6b 20 61  e..    # trunk a
16d0: 73 20 77 65 6c 6c 2e 0a 0a 09 20 20 20 20 73 65  s well....    se
16e0: 74 20 74 6a 6f 69 6e 74 20 24 6c 69 6e 6b 28 24  t tjoint $link($
16f0: 6a 6f 69 6e 74 29 0a 09 20 20 20 20 73 65 74 20  joint)..    set 
1700: 74 6c 6f 64 20 5b 73 74 61 74 65 20 6f 6e 65 20  tlod [state one 
1710: 7b 0a 09 09 53 45 4c 45 43 54 20 6c 6f 64 20 46  {...SELECT lod F
1720: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 57 48 45  ROM revision WHE
1730: 52 45 20 72 69 64 20 3d 20 24 74 6a 6f 69 6e 74  RE rid = $tjoint
1740: 0a 09 20 20 20 20 7d 5d 0a 0a 09 20 20 20 20 23  ..    }]...    #
1750: 20 43 6f 76 6e 65 72 74 20 64 62 2f 70 61 72 65   Covnert db/pare
1760: 6e 74 2f 63 68 69 6c 64 20 69 6e 74 6f 20 72 65  nt/child into re
1770: 67 75 6c 61 72 20 70 61 72 65 6e 74 2f 63 68 69  gular parent/chi
1780: 6c 64 20 6c 69 6e 6b 73 2e 0a 09 20 20 20 20 73  ld links...    s
1790: 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 55 50 44  tate run {...UPD
17a0: 41 54 45 20 72 65 76 69 73 69 6f 6e 20 53 45 54  ATE revision SET
17b0: 20 64 62 70 61 72 65 6e 74 20 3d 20 4e 55 4c 4c   dbparent = NULL
17c0: 2c 20 70 61 72 65 6e 74 20 3d 20 24 6a 6f 69 6e  , parent = $join
17d0: 74 20 20 57 48 45 52 45 20 72 69 64 20 3d 20 24  t  WHERE rid = $
17e0: 74 6a 6f 69 6e 74 20 3b 0a 09 09 55 50 44 41 54  tjoint ;...UPDAT
17f0: 45 20 72 65 76 69 73 69 6f 6e 20 53 45 54 20 64  E revision SET d
1800: 62 63 68 69 6c 64 20 20 3d 20 4e 55 4c 4c 2c 20  bchild  = NULL, 
1810: 63 68 69 6c 64 20 20 3d 20 24 74 6a 6f 69 6e 74  child  = $tjoint
1820: 20 57 48 45 52 45 20 72 69 64 20 3d 20 24 6a 6f   WHERE rid = $jo
1830: 69 6e 74 20 20 3b 0a 09 20 20 20 20 7d 0a 09 20  int  ;..    }.. 
1840: 20 20 20 77 68 69 6c 65 20 7b 31 7d 20 7b 0a 09     while {1} {..
1850: 09 23 20 4d 6f 76 65 20 74 68 65 20 4e 54 44 42  .# Move the NTDB
1860: 20 74 72 75 6e 6b 20 72 65 76 69 73 69 6f 6e 73   trunk revisions
1870: 20 74 6f 20 74 72 75 6e 6b 2e 0a 09 09 73 74 61   to trunk....sta
1880: 74 65 20 72 75 6e 20 7b 0a 09 09 20 20 20 20 55  te run {...    U
1890: 50 44 41 54 45 20 72 65 76 69 73 69 6f 6e 20 53  PDATE revision S
18a0: 45 54 20 6c 6f 64 20 3d 20 24 74 6c 6f 64 2c 20  ET lod = $tlod, 
18b0: 69 73 64 65 66 61 75 6c 74 20 3d 20 30 20 57 48  isdefault = 0 WH
18c0: 45 52 45 20 72 69 64 20 3d 20 24 6a 6f 69 6e 74  ERE rid = $joint
18d0: 0a 09 09 7d 0a 09 09 73 65 74 20 6c 61 73 74 20  ...}...set last 
18e0: 24 6a 6f 69 6e 74 0a 09 09 73 65 74 20 6a 6f 69  $joint...set joi
18f0: 6e 74 20 24 6e 74 64 62 28 24 6a 6f 69 6e 74 29  nt $ntdb($joint)
1900: 0a 09 09 69 66 20 7b 21 5b 69 6e 66 6f 20 65 78  ...if {![info ex
1910: 69 73 74 73 20 6e 74 64 62 28 24 6a 6f 69 6e 74  ists ntdb($joint
1920: 29 5d 7d 20 62 72 65 61 6b 0a 09 20 20 20 20 7d  )]} break..    }
1930: 0a 0a 09 20 20 20 20 23 20 52 65 61 63 68 65 64  ...    # Reached
1940: 20 74 68 65 20 4e 54 44 42 20 62 61 73 69 73 20   the NTDB basis 
1950: 69 6e 20 74 68 65 20 74 72 75 6e 6b 2e 20 46 69  in the trunk. Fi
1960: 6e 61 6c 69 7a 65 20 74 68 65 0a 09 20 20 20 20  nalize the..    
1970: 23 20 70 61 72 65 6e 74 2f 63 68 69 6c 64 20 6c  # parent/child l
1980: 69 6e 6b 61 67 65 20 61 6e 64 20 73 71 75 61 73  inkage and squas
1990: 68 20 74 68 65 20 62 72 61 6e 63 68 20 70 61 72  h the branch par
19a0: 65 6e 74 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20  ent symbol..    
19b0: 23 20 72 65 66 65 72 65 6e 63 65 2e 0a 0a 09 20  # reference.... 
19c0: 20 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09     state run {..
19d0: 09 55 50 44 41 54 45 20 72 65 76 69 73 69 6f 6e  .UPDATE revision
19e0: 20 53 45 54 20 63 68 69 6c 64 20 20 20 3d 20 24   SET child   = $
19f0: 6c 61 73 74 20 57 48 45 52 45 20 72 69 64 20 3d  last WHERE rid =
1a00: 20 24 6a 6f 69 6e 74 20 3b 0a 09 09 55 50 44 41   $joint ;...UPDA
1a10: 54 45 20 72 65 76 69 73 69 6f 6e 20 53 45 54 20  TE revision SET 
1a20: 62 70 61 72 65 6e 74 20 3d 20 4e 55 4c 4c 20 20  bparent = NULL  
1a30: 57 48 45 52 45 20 72 69 64 20 3d 20 24 6c 61 73  WHERE rid = $las
1a40: 74 20 20 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  t  ;..    }..}..
1a50: 09 23 20 4e 6f 77 20 74 68 61 74 20 74 68 65 20  .# Now that the 
1a60: 73 70 65 63 69 61 6c 20 63 61 73 65 20 69 73 20  special case is 
1a70: 64 6f 6e 65 20 77 65 20 63 61 6e 20 73 69 6d 70  done we can simp
1a80: 6c 79 20 6b 69 6c 6c 20 61 6c 6c 20 74 68 65 0a  ly kill all the.
1a90: 09 23 20 72 65 76 69 73 69 6f 6e 73 2c 20 74 61  .# revisions, ta
1aa0: 67 73 2c 20 61 6e 64 20 62 72 61 6e 63 68 65 73  gs, and branches
1ab0: 20 72 65 66 65 72 65 6e 63 69 6e 67 20 61 6e 79   referencing any
1ac0: 20 6f 66 20 74 68 65 0a 09 23 20 65 78 63 6c 75   of the..# exclu
1ad0: 64 65 64 20 73 79 6d 62 6f 6c 73 20 69 6e 20 73  ded symbols in s
1ae0: 6f 6d 65 20 77 61 79 2e 20 54 68 69 73 20 69 73  ome way. This is
1af0: 20 65 61 73 79 20 61 73 20 77 65 20 64 6f 20 6e   easy as we do n
1b00: 6f 74 20 68 61 76 65 0a 09 23 20 74 6f 20 73 65  ot have..# to se
1b10: 6c 65 63 74 20 74 68 65 6d 20 61 67 61 69 6e 20  lect them again 
1b20: 61 6e 64 20 61 67 61 69 6e 20 66 72 6f 6d 20 74  and again from t
1b30: 68 65 20 62 61 73 65 20 74 61 62 6c 65 73 20 61  he base tables a
1b40: 6e 79 0a 09 23 20 6c 6f 6e 67 65 72 2e 0a 0a 09  ny..# longer....
1b50: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20  state run {..   
1b60: 20 43 52 45 41 54 45 20 54 45 4d 50 4f 52 41 52   CREATE TEMPORAR
1b70: 59 20 54 41 42 4c 45 20 65 78 63 6c 75 64 65 64  Y TABLE excluded
1b80: 72 65 76 69 73 69 6f 6e 73 20 41 53 0a 09 20 20  revisions AS..  
1b90: 20 20 53 45 4c 45 43 54 20 72 69 64 20 46 52 4f    SELECT rid FRO
1ba0: 4d 20 72 65 76 69 73 69 6f 6e 20 57 48 45 52 45  M revision WHERE
1bb0: 20 6c 6f 64 20 49 4e 20 65 78 63 6c 75 64 65 64   lod IN excluded
1bc0: 73 79 6d 62 6f 6c 73 3b 0a 0a 09 20 20 20 20 44  symbols;...    D
1bd0: 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 76 69 73  ELETE FROM revis
1be0: 69 6f 6e 20 57 48 45 52 45 20 6c 6f 64 20 49 4e  ion WHERE lod IN
1bf0: 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73   excludedsymbols
1c00: 3b 0a 09 20 20 20 20 44 45 4c 45 54 45 20 46 52  ;..    DELETE FR
1c10: 4f 4d 20 74 61 67 20 20 20 20 20 20 57 48 45 52  OM tag      WHER
1c20: 45 20 6c 6f 64 20 49 4e 20 65 78 63 6c 75 64 65  E lod IN exclude
1c30: 64 73 79 6d 62 6f 6c 73 3b 0a 09 20 20 20 20 44  dsymbols;..    D
1c40: 45 4c 45 54 45 20 46 52 4f 4d 20 74 61 67 20 20  ELETE FROM tag  
1c50: 20 20 20 20 57 48 45 52 45 20 73 69 64 20 49 4e      WHERE sid IN
1c60: 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73   excludedsymbols
1c70: 3b 0a 09 20 20 20 20 44 45 4c 45 54 45 20 46 52  ;..    DELETE FR
1c80: 4f 4d 20 62 72 61 6e 63 68 20 20 20 57 48 45 52  OM branch   WHER
1c90: 45 20 6c 6f 64 20 49 4e 20 65 78 63 6c 75 64 65  E lod IN exclude
1ca0: 64 73 79 6d 62 6f 6c 73 3b 0a 09 20 20 20 20 44  dsymbols;..    D
1cb0: 45 4c 45 54 45 20 46 52 4f 4d 20 62 72 61 6e 63  ELETE FROM branc
1cc0: 68 20 20 20 57 48 45 52 45 20 73 69 64 20 49 4e  h   WHERE sid IN
1cd0: 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c 73   excludedsymbols
1ce0: 3b 0a 0a 09 20 20 20 20 44 45 4c 45 54 45 20 46  ;...    DELETE F
1cf0: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 62 72 61 6e  ROM revisionbran
1d00: 63 68 63 68 69 6c 64 72 65 6e 20 57 48 45 52 45  chchildren WHERE
1d10: 20 72 69 64 20 20 49 4e 20 65 78 63 6c 75 64 65   rid  IN exclude
1d20: 64 72 65 76 69 73 69 6f 6e 73 3b 0a 09 20 20 20  drevisions;..   
1d30: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65 76   DELETE FROM rev
1d40: 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64  isionbranchchild
1d50: 72 65 6e 20 57 48 45 52 45 20 62 72 69 64 20 49  ren WHERE brid I
1d60: 4e 20 65 78 63 6c 75 64 65 64 72 65 76 69 73 69  N excludedrevisi
1d70: 6f 6e 73 3b 0a 09 20 20 20 20 44 45 4c 45 54 45  ons;..    DELETE
1d80: 20 46 52 4f 4d 20 62 6c 6f 62 20 20 20 20 20 20   FROM blob      
1d90: 20 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45               WHE
1da0: 52 45 20 72 69 64 20 20 49 4e 20 65 78 63 6c 75  RE rid  IN exclu
1db0: 64 65 64 72 65 76 69 73 69 6f 6e 73 3b 0a 0a 09  dedrevisions;...
1dc0: 20 20 20 20 44 52 4f 50 20 54 41 42 4c 45 20 65      DROP TABLE e
1dd0: 78 63 6c 75 64 65 64 72 65 76 69 73 69 6f 6e 73  xcludedrevisions
1de0: 3b 0a 09 20 20 20 20 44 52 4f 50 20 54 41 42 4c  ;..    DROP TABL
1df0: 45 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c  E excludedsymbol
1e00: 73 3b 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20  s;..}..return.  
1e10: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 4d 75    }..    proc Mu
1e20: 74 61 74 65 53 79 6d 62 6f 6c 73 20 7b 7d 20 7b  tateSymbols {} {
1e30: 0a 09 23 20 4e 65 78 74 2c 20 6e 6f 77 20 74 68  ..# Next, now th
1e40: 61 74 20 77 65 20 6b 6e 6f 77 20 77 68 69 63 68  at we know which
1e50: 20 73 79 6d 62 6f 6c 73 20 61 72 65 20 77 68 61   symbols are wha
1e60: 74 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 0a 09 23  t we look for..#
1e70: 20 66 69 6c 65 20 6c 65 76 65 6c 20 74 61 67 73   file level tags
1e80: 20 77 68 69 63 68 20 61 72 65 20 61 63 74 75 61   which are actua
1e90: 6c 6c 79 20 63 6f 6e 76 65 72 74 65 64 20 61 73  lly converted as
1ea0: 20 62 72 61 6e 63 68 65 73 0a 09 23 20 28 70 72   branches..# (pr
1eb0: 6f 6a 65 63 74 20 6c 65 76 65 6c 2c 20 61 6e 64  oject level, and
1ec0: 20 76 69 63 65 20 76 65 72 73 61 29 2c 20 61 6e   vice versa), an
1ed0: 64 20 6d 6f 76 65 20 74 68 65 6d 20 74 6f 20 74  d move them to t
1ee0: 68 65 0a 09 23 20 63 6f 72 72 65 63 74 20 74 61  he..# correct ta
1ef0: 62 6c 65 73 2e 0a 0a 09 23 20 23 20 23 23 20 23  bles....# # ## #
1f00: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
1f10: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  # #############.
1f20: 0a 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69  ..log write 3 fi
1f30: 6c 74 65 72 73 79 6d 20 22 4d 75 74 61 74 65 20  ltersym "Mutate 
1f40: 73 79 6d 62 6f 6c 73 2c 20 70 72 65 70 61 72 61  symbols, prepara
1f50: 74 69 6f 6e 22 0a 0a 09 73 65 74 20 62 72 61 6e  tion"...set bran
1f60: 63 68 20 5b 70 72 6f 6a 65 63 74 3a 3a 73 79 6d  ch [project::sym
1f70: 20 62 72 61 6e 63 68 5d 0a 09 73 65 74 20 74 61   branch]..set ta
1f80: 67 20 20 20 20 5b 70 72 6f 6a 65 63 74 3a 3a 73  g    [project::s
1f90: 79 6d 20 74 61 67 5d 0a 0a 09 73 65 74 20 74 61  ym tag]...set ta
1fa0: 67 73 74 6f 6d 75 74 61 74 65 20 5b 73 74 61 74  gstomutate [stat
1fb0: 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c  e run {..    SEL
1fc0: 45 43 54 20 54 2e 74 69 64 2c 20 54 2e 66 69 64  ECT T.tid, T.fid
1fd0: 2c 20 54 2e 6c 6f 64 2c 20 54 2e 73 69 64 2c 20  , T.lod, T.sid, 
1fe0: 54 2e 72 65 76 0a 09 20 20 20 20 46 52 4f 4d 20  T.rev..    FROM 
1ff0: 74 61 67 20 54 2c 20 73 79 6d 62 6f 6c 20 53 0a  tag T, symbol S.
2000: 09 20 20 20 20 57 48 45 52 45 20 54 2e 73 69 64  .    WHERE T.sid
2010: 20 3d 20 53 2e 73 69 64 0a 09 20 20 20 20 41 4e   = S.sid..    AN
2020: 44 20 53 2e 74 79 70 65 20 3d 20 24 62 72 61 6e  D S.type = $bran
2030: 63 68 0a 09 7d 5d 0a 0a 09 73 65 74 20 62 72 61  ch..}]...set bra
2040: 6e 63 68 65 73 74 6f 6d 75 74 61 74 65 20 5b 73  nchestomutate [s
2050: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
2060: 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 2e  SELECT B.bid, B.
2070: 66 69 64 2c 20 42 2e 6c 6f 64 2c 20 42 2e 73 69  fid, B.lod, B.si
2080: 64 2c 20 42 2e 72 6f 6f 74 2c 20 42 2e 66 69 72  d, B.root, B.fir
2090: 73 74 2c 20 42 2e 62 72 61 0a 09 20 20 20 20 46  st, B.bra..    F
20a0: 52 4f 4d 20 62 72 61 6e 63 68 20 42 2c 20 73 79  ROM branch B, sy
20b0: 6d 62 6f 6c 20 53 0a 09 20 20 20 20 57 48 45 52  mbol S..    WHER
20c0: 45 20 42 2e 73 69 64 20 3d 20 53 2e 73 69 64 0a  E B.sid = S.sid.
20d0: 09 20 20 20 20 41 4e 44 20 53 2e 74 79 70 65 20  .    AND S.type 
20e0: 3d 20 24 74 61 67 0a 09 7d 5d 0a 0a 09 73 65 74  = $tag..}]...set
20f0: 20 6e 74 20 5b 65 78 70 72 20 7b 5b 6c 6c 65 6e   nt [expr {[llen
2100: 67 74 68 20 24 74 61 67 73 74 6f 6d 75 74 61 74  gth $tagstomutat
2110: 65 5d 2f 35 7d 5d 0a 09 73 65 74 20 6e 62 20 5b  e]/5}]..set nb [
2120: 65 78 70 72 20 7b 5b 6c 6c 65 6e 67 74 68 20 24  expr {[llength $
2130: 62 72 61 6e 63 68 65 73 74 6f 6d 75 74 61 74 65  branchestomutate
2140: 5d 2f 37 7d 5d 0a 0a 09 6c 6f 67 20 77 72 69 74  ]/7}]...log writ
2150: 65 20 34 20 66 69 6c 74 65 72 73 79 6d 20 22 43  e 4 filtersym "C
2160: 68 61 6e 67 69 6e 67 20 5b 6e 73 70 20 24 6e 74  hanging [nsp $nt
2170: 20 74 61 67 5d 20 69 6e 74 6f 20 20 5b 6e 73 70   tag] into  [nsp
2180: 20 24 6e 74 20 62 72 61 6e 63 68 20 62 72 61 6e   $nt branch bran
2190: 63 68 65 73 5d 22 0a 09 6c 6f 67 20 77 72 69 74  ches]"..log writ
21a0: 65 20 34 20 66 69 6c 74 65 72 73 79 6d 20 22 43  e 4 filtersym "C
21b0: 68 61 6e 67 69 6e 67 20 5b 6e 73 70 20 24 6e 62  hanging [nsp $nb
21c0: 20 62 72 61 6e 63 68 20 62 72 61 6e 63 68 65 73   branch branches
21d0: 5d 20 69 6e 74 6f 20 20 5b 6e 73 70 20 24 6e 62  ] into  [nsp $nb
21e0: 20 74 61 67 5d 22 0a 0a 09 23 20 23 20 23 23 20   tag]"...# # ## 
21f0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
2200: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
2210: 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66  ...log write 3 f
2220: 69 6c 74 65 72 73 79 6d 20 22 4d 75 74 61 74 65  iltersym "Mutate
2230: 20 74 61 67 73 20 74 6f 20 62 72 61 6e 63 68 65   tags to branche
2240: 73 22 0a 0a 09 66 6f 72 65 61 63 68 20 7b 69 64  s"...foreach {id
2250: 20 66 69 64 20 6c 6f 64 20 73 69 64 20 72 65 76   fid lod sid rev
2260: 7d 20 24 74 61 67 73 74 6f 6d 75 74 61 74 65 20  } $tagstomutate 
2270: 7b 0a 09 20 20 20 20 73 74 61 74 65 20 72 75 6e  {..    state run
2280: 20 7b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f 4d   {...DELETE FROM
2290: 20 74 61 67 20 57 48 45 52 45 20 74 69 64 20 3d   tag WHERE tid =
22a0: 20 24 69 64 20 3b 0a 09 09 49 4e 53 45 52 54 20   $id ;...INSERT 
22b0: 49 4e 54 4f 20 62 72 61 6e 63 68 20 28 62 69 64  INTO branch (bid
22c0: 2c 20 66 69 64 2c 20 20 6c 6f 64 2c 20 20 73 69  , fid,  lod,  si
22d0: 64 2c 20 20 72 6f 6f 74 2c 20 66 69 72 73 74 2c  d,  root, first,
22e0: 20 62 72 61 2c 20 70 6f 73 29 0a 09 09 56 41 4c   bra, pos)...VAL
22f0: 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20  UES             
2300: 28 24 69 64 2c 20 24 66 69 64 2c 20 24 6c 6f 64  ($id, $fid, $lod
2310: 2c 20 24 73 69 64 2c 20 24 72 65 76 2c 20 4e 55  , $sid, $rev, NU
2320: 4c 4c 2c 20 20 27 27 2c 20 20 2d 31 29 3b 0a 09  LL,  '',  -1);..
2330: 20 20 20 20 7d 0a 09 7d 0a 0a 09 6c 6f 67 20 77      }..}...log w
2340: 72 69 74 65 20 33 20 66 69 6c 74 65 72 73 79 6d  rite 3 filtersym
2350: 20 22 4f 6b 2e 22 0a 0a 09 23 20 23 20 23 23 20   "Ok."...# # ## 
2360: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
2370: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
2380: 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66  ...log write 3 f
2390: 69 6c 74 65 72 73 79 6d 20 22 4d 75 74 61 74 65  iltersym "Mutate
23a0: 20 62 72 61 6e 63 68 65 73 20 74 6f 20 74 61 67   branches to tag
23b0: 73 22 0a 0a 09 66 6f 72 65 61 63 68 20 7b 69 64  s"...foreach {id
23c0: 20 66 69 64 20 6c 6f 64 20 73 69 64 20 72 6f 6f   fid lod sid roo
23d0: 74 20 66 69 72 73 74 20 62 72 61 7d 20 24 62 72  t first bra} $br
23e0: 61 6e 63 68 65 73 74 6f 6d 75 74 61 74 65 20 7b  anchestomutate {
23f0: 0a 09 20 20 20 20 73 74 61 74 65 20 72 75 6e 20  ..    state run 
2400: 7b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f 4d 20  {...DELETE FROM 
2410: 62 72 61 6e 63 68 20 57 48 45 52 45 20 62 69 64  branch WHERE bid
2420: 20 3d 20 24 69 64 20 3b 0a 09 09 49 4e 53 45 52   = $id ;...INSER
2430: 54 20 49 4e 54 4f 20 74 61 67 20 28 74 69 64 2c  T INTO tag (tid,
2440: 20 66 69 64 2c 20 20 6c 6f 64 2c 20 20 73 69 64   fid,  lod,  sid
2450: 2c 20 20 72 65 76 29 0a 09 09 56 41 4c 55 45 53  ,  rev)...VALUES
2460: 20 20 20 20 20 20 20 20 20 20 28 24 69 64 2c 20            ($id, 
2470: 24 66 69 64 2c 20 24 6c 6f 64 2c 20 24 73 69 64  $fid, $lod, $sid
2480: 2c 20 24 72 6f 6f 74 29 3b 0a 09 20 20 20 20 7d  , $root);..    }
2490: 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  ..}...log write 
24a0: 33 20 66 69 6c 74 65 72 73 79 6d 20 22 4f 6b 2e  3 filtersym "Ok.
24b0: 22 0a 0a 09 23 20 23 20 23 23 20 23 23 23 20 23  "...# # ## ### #
24c0: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
24d0: 23 23 23 23 23 23 23 23 23 23 23 0a 09 72 65 74  ###########..ret
24e0: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23  urn.    }..    #
24f0: 20 41 64 6a 75 73 74 20 74 68 65 20 70 61 72 65   Adjust the pare
2500: 6e 74 73 20 6f 66 20 73 79 6d 62 6f 6c 73 20 74  nts of symbols t
2510: 6f 20 74 68 65 69 72 20 70 72 65 66 65 72 72 65  o their preferre
2520: 64 20 70 61 72 65 6e 74 73 2e 0a 0a 20 20 20 20  d parents...    
2530: 23 20 49 66 20 61 20 66 69 6c 65 20 6c 65 76 65  # If a file leve
2540: 6c 20 79 6d 62 6f 6c 20 68 61 73 20 61 20 70 72  l ymbol has a pr
2550: 65 66 65 72 72 65 64 20 70 61 72 65 6e 74 20 74  eferred parent t
2560: 68 61 74 20 69 73 20 64 69 66 66 65 72 65 6e 74  hat is different
2570: 0a 20 20 20 20 23 20 74 68 61 6e 20 69 74 73 20  .    # than its 
2580: 63 75 72 72 65 6e 74 20 70 61 72 65 6e 74 2c 20  current parent, 
2590: 61 6e 64 20 69 66 20 74 68 65 20 70 72 65 66 65  and if the prefe
25a0: 72 72 65 64 20 70 61 72 65 6e 74 20 69 73 20 61  rred parent is a
25b0: 6e 0a 20 20 20 20 23 20 61 6c 6c 6f 77 65 64 20  n.    # allowed 
25c0: 70 61 72 65 6e 74 20 6f 66 20 74 68 65 20 73 79  parent of the sy
25d0: 6d 62 6f 6c 20 69 6e 20 74 68 69 73 20 66 69 6c  mbol in this fil
25e0: 65 2c 20 74 68 65 6e 20 77 65 20 67 72 61 66 74  e, then we graft
25f0: 20 74 68 65 0a 20 20 20 20 23 20 61 53 79 6d 62   the.    # aSymb
2600: 6f 6c 20 6f 6e 74 6f 20 69 74 73 20 70 72 65 66  ol onto its pref
2610: 65 72 72 65 64 20 70 61 72 65 6e 74 2e 0a 0a 20  erred parent... 
2620: 20 20 20 70 72 6f 63 20 41 64 6a 75 73 74 50 61     proc AdjustPa
2630: 72 65 6e 74 73 20 7b 7d 20 7b 0a 09 6c 6f 67 20  rents {} {..log 
2640: 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73 79  write 3 filtersy
2650: 6d 20 22 41 64 6a 75 73 74 20 70 61 72 65 6e 74  m "Adjust parent
2660: 73 2c 20 6c 6f 61 64 69 6e 67 20 64 61 74 61 20  s, loading data 
2670: 69 6e 20 70 72 65 70 61 72 61 74 69 6f 6e 22 0a  in preparation".
2680: 0a 09 23 20 57 65 20 70 75 6c 6c 20 69 6d 70 6f  ..# We pull impo
2690: 72 74 61 6e 74 20 6d 61 70 73 20 6f 6e 63 65 20  rtant maps once 
26a0: 69 6e 74 6f 20 6d 65 6d 6f 72 79 20 73 6f 20 74  into memory so t
26b0: 68 61 74 20 77 65 20 64 6f 20 71 75 69 63 6b 0a  hat we do quick.
26c0: 09 23 20 68 61 73 68 20 6c 6f 6f 6b 75 70 20 6c  .# hash lookup l
26d0: 61 74 65 72 20 77 68 65 6e 20 70 72 6f 63 65 73  ater when proces
26e0: 73 69 6e 67 20 74 68 65 20 67 72 61 66 74 20 63  sing the graft c
26f0: 61 6e 64 69 64 61 74 65 73 2e 0a 0a 09 23 20 54  andidates....# T
2700: 61 67 2f 42 72 61 6e 63 68 20 6e 61 6d 65 73 20  ag/Branch names 
2710: 2e 2e 2e 0a 09 61 72 72 61 79 20 73 65 74 20 73  .....array set s
2720: 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 20 53  n [state run { S
2730: 45 4c 45 43 54 20 54 2e 74 69 64 2c 20 53 2e 6e  ELECT T.tid, S.n
2740: 61 6d 65 20 46 52 4f 4d 20 74 61 67 20 54 2c 20  ame FROM tag T, 
2750: 20 20 20 73 79 6d 62 6f 6c 20 53 20 57 48 45 52     symbol S WHER
2760: 45 20 54 2e 73 69 64 20 3d 20 53 2e 73 69 64 20  E T.sid = S.sid 
2770: 7d 5d 0a 09 61 72 72 61 79 20 73 65 74 20 73 6e  }]..array set sn
2780: 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 20 53 45   [state run { SE
2790: 4c 45 43 54 20 42 2e 62 69 64 2c 20 53 2e 6e 61  LECT B.bid, S.na
27a0: 6d 65 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42  me FROM branch B
27b0: 2c 20 73 79 6d 62 6f 6c 20 53 20 57 48 45 52 45  , symbol S WHERE
27c0: 20 42 2e 73 69 64 20 3d 20 53 2e 73 69 64 20 7d   B.sid = S.sid }
27d0: 5d 0a 09 23 20 53 79 6d 62 6f 6c 20 6e 61 6d 65  ]..# Symbol name
27e0: 73 20 2e 2e 2e 0a 09 61 72 72 61 79 20 73 65 74  s .....array set
27f0: 20 73 78 20 5b 73 74 61 74 65 20 72 75 6e 20 7b   sx [state run {
2800: 20 53 45 4c 45 43 54 20 4c 2e 73 69 64 2c 20 4c   SELECT L.sid, L
2810: 2e 6e 61 6d 65 20 46 52 4f 4d 20 73 79 6d 62 6f  .name FROM symbo
2820: 6c 20 4c 20 7d 5d 0a 09 23 20 46 69 6c 65 73 20  l L }]..# Files 
2830: 61 6e 64 20 70 72 6f 6a 65 63 74 73 2e 0a 09 61  and projects...a
2840: 72 72 61 79 20 73 65 74 20 66 70 6e 20 7b 7d 0a  rray set fpn {}.
2850: 09 73 74 61 74 65 20 66 6f 72 65 61 63 68 72 6f  .state foreachro
2860: 77 20 7b 0a 09 09 53 45 4c 45 43 54 20 46 2e 66  w {...SELECT F.f
2870: 69 64 20 41 53 20 69 64 2c 20 46 2e 6e 61 6d 65  id AS id, F.name
2880: 20 41 53 20 66 6e 2c 20 50 2e 6e 61 6d 65 20 41   AS fn, P.name A
2890: 53 20 70 6e 0a 09 09 46 52 4f 4d 20 20 20 66 69  S pn...FROM   fi
28a0: 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a  le F, project P.
28b0: 09 09 57 48 45 52 45 20 20 46 2e 70 69 64 20 3d  ..WHERE  F.pid =
28c0: 20 50 2e 70 69 64 0a 09 7d 20 7b 20 73 65 74 20   P.pid..} { set 
28d0: 66 70 6e 28 24 69 64 29 20 5b 6c 69 73 74 20 24  fpn($id) [list $
28e0: 66 6e 20 24 70 6e 5d 20 7d 0a 0a 09 73 65 74 20  fn $pn] }...set 
28f0: 74 61 67 73 74 6f 61 64 6a 75 73 74 20 5b 73 74  tagstoadjust [st
2900: 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53  ate run {..    S
2910: 45 4c 45 43 54 20 54 2e 74 69 64 2c 20 54 2e 66  ELECT T.tid, T.f
2920: 69 64 2c 20 54 2e 6c 6f 64 2c 20 50 2e 70 69 64  id, T.lod, P.pid
2930: 2c 20 53 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 2c  , S.name, R.rev,
2940: 20 52 2e 72 69 64 0a 09 20 20 20 20 46 52 4f 4d   R.rid..    FROM
2950: 20 74 61 67 20 54 2c 20 70 72 65 66 65 72 65 64   tag T, prefered
2960: 70 61 72 65 6e 74 20 50 2c 20 73 79 6d 62 6f 6c  parent P, symbol
2970: 20 53 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09   S, revision R..
2980: 20 20 20 20 57 48 45 52 45 20 54 2e 73 69 64 20      WHERE T.sid 
2990: 3d 20 50 2e 73 69 64 20 20 20 20 20 20 20 20 2d  = P.sid        -
29a0: 2d 20 46 6f 72 20 61 6c 6c 20 74 61 67 73 2c 20  - For all tags, 
29b0: 67 65 74 20 6c 65 66 74 2d 68 61 6e 64 20 6f 66  get left-hand of
29c0: 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74   prefered parent
29d0: 20 76 69 61 20 73 79 6d 62 6f 6c 0a 09 20 20 20   via symbol..   
29e0: 20 41 4e 44 20 20 20 54 2e 6c 6f 64 20 21 3d 20   AND   T.lod != 
29f0: 50 2e 70 69 64 20 20 20 20 20 20 20 2d 2d 20 52  P.pid       -- R
2a00: 65 73 74 72 69 63 74 20 74 6f 20 74 61 67 73 20  estrict to tags 
2a10: 77 68 6f 73 65 20 4c 4f 44 20 69 73 20 6e 6f 74  whose LOD is not
2a20: 20 74 68 65 69 72 20 70 72 65 66 65 72 65 64 20   their prefered 
2a30: 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44 20  parent..    AND 
2a40: 20 20 50 2e 70 69 64 20 3d 20 53 2e 73 69 64 20    P.pid = S.sid 
2a50: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 73 79         -- Get sy
2a60: 6d 62 6f 6c 20 6f 66 20 70 72 65 66 65 72 65 64  mbol of prefered
2a70: 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44   parent..    AND
2a80: 20 20 20 53 2e 6e 61 6d 65 20 21 3d 20 27 3a 74     S.name != ':t
2a90: 72 75 6e 6b 3a 27 20 20 2d 2d 20 45 78 63 6c 75  runk:'  -- Exclu
2aa0: 64 65 20 74 72 75 6e 6b 20 70 61 72 65 6e 74 61  de trunk parenta
2ab0: 67 65 0a 09 20 20 20 20 41 4e 44 20 20 20 54 2e  ge..    AND   T.
2ac0: 72 65 76 20 3d 20 52 2e 72 69 64 20 20 20 20 20  rev = R.rid     
2ad0: 20 20 20 2d 2d 20 47 65 74 20 72 65 76 69 73 69     -- Get revisi
2ae0: 6f 6e 20 74 68 65 20 74 61 67 20 69 73 20 61 74  on the tag is at
2af0: 74 61 63 68 65 64 20 74 6f 2e 0a 09 7d 5d 0a 0a  tached to...}]..
2b00: 09 73 65 74 20 62 72 61 6e 63 68 65 73 74 6f 61  .set branchestoa
2b10: 64 6a 75 73 74 20 5b 73 74 61 74 65 20 72 75 6e  djust [state run
2b20: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42   {..    SELECT B
2b30: 2e 62 69 64 2c 20 42 2e 66 69 64 2c 20 42 2e 6c  .bid, B.fid, B.l
2b40: 6f 64 2c 20 42 2e 70 6f 73 2c 20 50 2e 70 69 64  od, B.pos, P.pid
2b50: 2c 20 53 2e 6e 61 6d 65 2c 20 4e 55 4c 4c 2c 20  , S.name, NULL, 
2b60: 4e 55 4c 4c 0a 09 20 20 20 20 46 52 4f 4d 20 62  NULL..    FROM b
2b70: 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65  ranch B, prefere
2b80: 64 70 61 72 65 6e 74 20 50 2c 20 73 79 6d 62 6f  dparent P, symbo
2b90: 6c 20 53 0a 09 20 20 20 20 57 48 45 52 45 20 42  l S..    WHERE B
2ba0: 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20 20  .sid = P.sid    
2bb0: 20 20 20 20 2d 2d 20 46 6f 72 20 61 6c 6c 20 62      -- For all b
2bc0: 72 61 6e 63 68 65 73 2c 20 67 65 74 20 6c 65 66  ranches, get lef
2bd0: 74 2d 68 61 6e 64 20 6f 66 20 70 72 65 66 65 72  t-hand of prefer
2be0: 65 64 20 70 61 72 65 6e 74 20 76 69 61 20 73 79  ed parent via sy
2bf0: 6d 62 6f 6c 0a 09 20 20 20 20 41 4e 44 20 20 20  mbol..    AND   
2c00: 42 2e 6c 6f 64 20 21 3d 20 50 2e 70 69 64 20 20  B.lod != P.pid  
2c10: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
2c20: 20 74 6f 20 62 72 61 6e 63 68 65 73 20 77 68 6f   to branches who
2c30: 73 65 20 4c 4f 44 20 69 73 20 6e 6f 74 20 74 68  se LOD is not th
2c40: 65 69 72 20 70 72 65 66 65 72 65 64 20 70 61 72  eir prefered par
2c50: 65 6e 74 0a 09 20 20 20 20 41 4e 44 20 20 20 50  ent..    AND   P
2c60: 2e 70 69 64 20 3d 20 53 2e 73 69 64 20 20 20 20  .pid = S.sid    
2c70: 20 20 20 20 2d 2d 20 47 65 74 20 73 79 6d 62 6f      -- Get symbo
2c80: 6c 20 6f 66 20 70 72 65 66 65 72 65 64 20 70 61  l of prefered pa
2c90: 72 65 6e 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rent..    AND   
2ca0: 53 2e 6e 61 6d 65 20 21 3d 20 27 3a 74 72 75 6e  S.name != ':trun
2cb0: 6b 3a 27 20 20 2d 2d 20 45 78 63 6c 75 64 65 20  k:'  -- Exclude 
2cc0: 74 72 75 6e 6b 20 70 61 72 65 6e 74 61 67 65 0a  trunk parentage.
2cd0: 09 20 20 20 20 41 4e 44 20 20 20 42 2e 72 6f 6f  .    AND   B.roo
2ce0: 74 20 49 53 20 4e 55 4c 4c 20 20 20 20 20 20 20  t IS NULL       
2cf0: 2d 2d 20 41 63 63 65 70 74 20 66 72 65 65 2d 66  -- Accept free-f
2d00: 6c 6f 61 74 69 6e 67 20 62 72 61 6e 63 68 0a 20  loating branch. 
2d10: 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45     UNION..    SE
2d20: 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 2e 66 69  LECT B.bid, B.fi
2d30: 64 2c 20 42 2e 6c 6f 64 2c 20 42 2e 70 6f 73 2c  d, B.lod, B.pos,
2d40: 20 50 2e 70 69 64 2c 20 53 2e 6e 61 6d 65 2c 20   P.pid, S.name, 
2d50: 52 2e 72 65 76 2c 20 52 2e 72 69 64 0a 09 20 20  R.rev, R.rid..  
2d60: 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 2c    FROM branch B,
2d70: 20 70 72 65 66 65 72 65 64 70 61 72 65 6e 74 20   preferedparent 
2d80: 50 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 72 65 76  P, symbol S, rev
2d90: 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45  ision R..    WHE
2da0: 52 45 20 42 2e 73 69 64 20 3d 20 50 2e 73 69 64  RE B.sid = P.sid
2db0: 20 20 20 20 20 20 20 20 2d 2d 20 46 6f 72 20 61          -- For a
2dc0: 6c 6c 20 62 72 61 6e 63 68 65 73 2c 20 67 65 74  ll branches, get
2dd0: 20 6c 65 66 74 2d 68 61 6e 64 20 6f 66 20 70 72   left-hand of pr
2de0: 65 66 65 72 65 64 20 70 61 72 65 6e 74 20 76 69  efered parent vi
2df0: 61 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20 41 4e  a symbol..    AN
2e00: 44 20 20 20 42 2e 6c 6f 64 20 21 3d 20 50 2e 70  D   B.lod != P.p
2e10: 69 64 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74  id       -- Rest
2e20: 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73  rict to branches
2e30: 20 77 68 6f 73 65 20 4c 4f 44 20 69 73 20 6e 6f   whose LOD is no
2e40: 74 20 74 68 65 69 72 20 70 72 65 66 65 72 65 64  t their prefered
2e50: 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44   parent..    AND
2e60: 20 20 20 50 2e 70 69 64 20 3d 20 53 2e 73 69 64     P.pid = S.sid
2e70: 09 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 73  .       -- Get s
2e80: 79 6d 62 6f 6c 20 6f 66 20 70 72 65 66 65 72 65  ymbol of prefere
2e90: 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e  d parent..    AN
2ea0: 44 20 20 20 53 2e 6e 61 6d 65 20 21 3d 20 27 3a  D   S.name != ':
2eb0: 74 72 75 6e 6b 3a 27 20 20 2d 2d 20 45 78 63 6c  trunk:'  -- Excl
2ec0: 75 64 65 20 74 72 75 6e 6b 20 70 61 72 65 6e 74  ude trunk parent
2ed0: 61 67 65 0a 09 20 20 20 20 41 4e 44 20 20 20 42  age..    AND   B
2ee0: 2e 72 6f 6f 74 20 3d 20 52 2e 72 69 64 20 20 20  .root = R.rid   
2ef0: 20 20 20 20 2d 2d 20 47 65 74 20 72 6f 6f 74 20      -- Get root 
2f00: 72 65 76 69 73 69 6f 6e 20 6f 66 20 74 68 65 20  revision of the 
2f10: 62 72 61 6e 63 68 0a 09 7d 5d 0a 0a 09 73 65 74  branch..}]...set
2f20: 20 74 6d 61 78 20 5b 65 78 70 72 20 7b 5b 6c 6c   tmax [expr {[ll
2f30: 65 6e 67 74 68 20 24 74 61 67 73 74 6f 61 64 6a  ength $tagstoadj
2f40: 75 73 74 5d 20 2f 20 37 7d 5d 0a 09 73 65 74 20  ust] / 7}]..set 
2f50: 62 6d 61 78 20 5b 65 78 70 72 20 7b 5b 6c 6c 65  bmax [expr {[lle
2f60: 6e 67 74 68 20 24 62 72 61 6e 63 68 65 73 74 6f  ngth $branchesto
2f70: 61 64 6a 75 73 74 5d 20 2f 20 38 7d 5d 0a 0a 09  adjust] / 8}]...
2f80: 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69 6c 74  log write 4 filt
2f90: 65 72 73 79 6d 20 22 52 65 70 61 72 65 6e 74 69  ersym "Reparenti
2fa0: 6e 67 20 61 74 20 6d 6f 73 74 20 5b 6e 73 70 20  ng at most [nsp 
2fb0: 24 74 6d 61 78 20 74 61 67 5d 22 0a 09 6c 6f 67  $tmax tag]"..log
2fc0: 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73   write 4 filters
2fd0: 79 6d 20 22 52 65 70 61 72 65 6e 74 69 6e 67 20  ym "Reparenting 
2fe0: 61 74 20 6d 6f 73 74 20 5b 6e 73 70 20 24 62 6d  at most [nsp $bm
2ff0: 61 78 20 62 72 61 6e 63 68 20 62 72 61 6e 63 68  ax branch branch
3000: 65 73 5d 22 0a 0a 09 6c 6f 67 20 77 72 69 74 65  es]"...log write
3010: 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 41 64   3 filtersym "Ad
3020: 6a 75 73 74 20 74 61 67 20 70 61 72 65 6e 74 73  just tag parents
3030: 22 0a 0a 09 23 20 46 69 6e 64 20 74 68 65 20 74  "...# Find the t
3040: 61 67 73 20 77 68 6f 73 65 20 63 75 72 72 65 6e  ags whose curren
3050: 74 20 70 61 72 65 6e 74 20 28 6c 6f 64 29 20 69  t parent (lod) i
3060: 73 20 6e 6f 74 20 74 68 65 20 70 72 65 66 65 72  s not the prefer
3070: 65 64 0a 09 23 20 70 61 72 65 6e 74 2c 20 74 68  ed..# parent, th
3080: 65 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e  e prefered paren
3090: 74 20 69 73 20 6e 6f 74 20 74 68 65 20 74 72 75  t is not the tru
30a0: 6e 6b 2c 20 61 6e 64 20 74 68 65 0a 09 23 20 70  nk, and the..# p
30b0: 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20 69  refered parent i
30c0: 73 20 61 20 70 6f 73 73 69 62 6c 65 20 70 61 72  s a possible par
30d0: 65 6e 74 20 70 65 72 20 74 68 65 20 74 61 67 27  ent per the tag'
30e0: 73 20 72 65 76 69 73 69 6f 6e 2e 0a 0a 09 73 65  s revision....se
30f0: 74 20 66 6d 74 20 25 5b 73 74 72 69 6e 67 20 6c  t fmt %[string l
3100: 65 6e 67 74 68 20 24 74 6d 61 78 5d 73 0a 09 73  ength $tmax]s..s
3110: 65 74 20 6d 78 73 20 5b 66 6f 72 6d 61 74 20 24  et mxs [format $
3120: 66 6d 74 20 24 74 6d 61 78 5d 0a 0a 09 73 65 74  fmt $tmax]...set
3130: 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 20 7b 69   n 0..foreach {i
3140: 64 20 66 69 64 20 6c 6f 64 20 70 69 64 20 70 72  d fid lod pid pr
3150: 65 66 65 72 65 64 6e 61 6d 65 20 72 65 76 6e 72  eferedname revnr
3160: 20 72 69 64 7d 20 24 74 61 67 73 74 6f 61 64 6a   rid} $tagstoadj
3170: 75 73 74 20 7b 0a 09 20 20 20 20 23 20 42 4f 54  ust {..    # BOT
3180: 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 09 20 20  TLE-NECK .....  
3190: 20 20 23 0a 09 20 20 20 20 23 20 54 68 65 20 63    #..    # The c
31a0: 68 65 63 6b 20 69 66 20 74 68 65 20 63 61 6e 64  heck if the cand
31b0: 69 64 61 74 65 20 28 70 69 64 29 20 69 73 20 74  idate (pid) is t
31c0: 72 75 6c 79 20 76 69 61 62 6c 65 20 69 73 0a 09  ruly viable is..
31d0: 20 20 20 20 23 20 62 61 73 65 64 20 6f 6e 20 66      # based on f
31e0: 69 6e 64 69 6e 67 20 74 68 65 20 62 72 61 6e 63  inding the branc
31f0: 68 20 61 73 20 70 6f 73 73 69 62 6c 65 20 70 61  h as possible pa
3200: 72 65 6e 74 2c 20 61 6e 64 20 64 6f 6e 65 0a 09  rent, and done..
3210: 20 20 20 20 23 20 6e 6f 77 20 69 6e 73 74 65 61      # now instea
3220: 64 20 6f 66 20 61 73 20 70 61 72 74 20 6f 66 20  d of as part of 
3230: 74 68 65 20 61 6c 72 65 61 64 79 20 63 6f 6d 70  the already comp
3240: 6c 65 78 20 6a 6f 69 6e 2e 0a 09 20 20 20 20 23  lex join...    #
3250: 0a 09 20 20 20 20 23 20 2e 2e 2e 20 41 4e 44 20  ..    # ... AND 
3260: 50 2e 70 69 64 20 49 4e 20 28 53 45 4c 45 43 54  P.pid IN (SELECT
3270: 20 42 2e 73 69 64 0a 09 20 20 20 20 23 20 20 20   B.sid..    #   
3280: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3290: 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 0a 09 20  FROM branch B.. 
32a0: 20 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20     #            
32b0: 20 20 20 20 20 20 20 57 48 45 52 45 20 42 2e 72         WHERE B.r
32c0: 6f 6f 74 20 3d 20 52 2e 72 69 64 29 0a 0a 09 20  oot = R.rid)... 
32d0: 20 20 20 69 66 20 7b 21 5b 73 74 61 74 65 20 6f     if {![state o
32e0: 6e 65 20 7b 0a 09 09 53 45 4c 45 43 54 20 43 4f  ne {...SELECT CO
32f0: 55 4e 54 28 2a 29 20 20 20 20 20 20 20 2d 2d 20  UNT(*)       -- 
3300: 43 6f 75 6e 74 20 3c 3d 3e 20 43 68 65 63 6b 20  Count <=> Check 
3310: 65 78 69 73 74 65 6e 63 65 2e 0a 09 09 46 52 4f  existence....FRO
3320: 4d 20 62 72 61 6e 63 68 20 42 0a 09 09 57 48 45  M branch B...WHE
3330: 52 45 20 20 42 2e 73 69 64 20 20 3d 20 24 70 69  RE  B.sid  = $pi
3340: 64 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74  d  -- Restrict t
3350: 6f 20 62 72 61 6e 63 68 20 66 6f 72 20 74 68 61  o branch for tha
3360: 74 20 73 79 6d 62 6f 6c 0a 09 09 41 4e 44 20 20  t symbol...AND  
3370: 20 20 42 2e 72 6f 6f 74 20 3d 20 24 72 69 64 20    B.root = $rid 
3380: 20 2d 2d 20 61 74 74 61 63 68 65 64 20 74 6f 20   -- attached to 
3390: 74 68 61 74 20 72 65 76 69 73 69 6f 6e 0a 09 20  that revision.. 
33a0: 20 20 20 7d 5d 7d 20 7b 0a 09 09 69 6e 63 72 20     }]} {...incr 
33b0: 74 6d 61 78 20 2d 31 0a 09 09 73 65 74 20 20 6d  tmax -1...set  m
33c0: 78 73 20 5b 66 6f 72 6d 61 74 20 24 66 6d 74 20  xs [format $fmt 
33d0: 24 74 6d 61 78 5d 0a 09 09 63 6f 6e 74 69 6e 75  $tmax]...continu
33e0: 65 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20 23  e..    }...    #
33f0: 0a 09 20 20 20 20 23 20 42 4f 54 54 4c 45 2d 4e  ..    # BOTTLE-N
3400: 45 43 4b 20 2e 2e 2e 0a 0a 09 20 20 20 20 23 20  ECK ......    # 
3410: 54 68 65 20 6e 61 6d 65 73 20 66 6f 72 20 75 73  The names for us
3420: 65 20 69 6e 20 74 68 65 20 6c 6f 67 20 6f 75 74  e in the log out
3430: 70 75 74 20 61 72 65 20 72 65 74 72 69 65 76 65  put are retrieve
3440: 64 0a 09 20 20 20 20 23 20 73 65 70 61 72 61 74  d..    # separat
3450: 65 6c 79 2c 20 74 6f 20 6b 65 65 70 20 74 68 65  ely, to keep the
3460: 20 6a 6f 69 6e 20 73 65 6c 65 63 74 69 6e 67 20   join selecting 
3470: 74 68 65 20 61 64 6a 75 73 74 61 62 6c 65 0a 09  the adjustable..
3480: 20 20 20 20 23 20 74 61 67 73 20 73 6d 61 6c 6c      # tags small
3490: 2c 20 6e 6f 74 20 62 75 72 64 65 6e 65 64 20 77  , not burdened w
34a0: 69 74 68 20 74 68 65 20 64 65 72 65 66 65 72 65  ith the derefere
34b0: 6e 63 69 6e 67 20 6f 66 20 6c 69 6e 6b 73 0a 09  ncing of links..
34c0: 20 20 20 20 23 20 74 6f 20 6e 61 6d 65 2e 0a 0a      # to name...
34d0: 09 20 20 20 20 73 65 74 20 74 61 67 6e 61 6d 65  .    set tagname
34e0: 20 24 73 6e 28 24 69 64 29 0a 09 20 20 20 20 73   $sn($id)..    s
34f0: 65 74 20 6f 6c 64 6e 61 6d 65 20 24 73 78 28 24  et oldname $sx($
3500: 6c 6f 64 29 0a 09 20 20 20 20 73 74 72 75 63 74  lod)..    struct
3510: 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24 66  ::list assign $f
3520: 70 6e 28 24 66 69 64 29 20 66 6e 61 6d 65 20 70  pn($fid) fname p
3530: 72 6e 61 6d 65 0a 0a 09 20 20 20 20 23 20 44 6f  rname...    # Do
3540: 20 74 68 65 20 67 72 61 66 74 69 6e 67 2e 0a 0a   the grafting...
3550: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 34  .    log write 4
3560: 20 66 69 6c 74 65 72 73 79 6d 20 7b 5c 5b 5b 66   filtersym {\[[f
3570: 6f 72 6d 61 74 20 24 66 6d 74 20 24 6e 5d 2f 24  ormat $fmt $n]/$
3580: 6d 78 73 5c 5d 20 24 70 72 6e 61 6d 65 20 3a 20  mxs\] $prname : 
3590: 47 72 61 66 74 69 6e 67 20 74 61 67 20 27 24 74  Grafting tag '$t
35a0: 61 67 6e 61 6d 65 27 20 6f 6e 20 24 66 6e 61 6d  agname' on $fnam
35b0: 65 2f 24 72 65 76 6e 72 20 66 72 6f 6d 20 27 24  e/$revnr from '$
35c0: 6f 6c 64 6e 61 6d 65 27 20 6f 6e 74 6f 20 27 24  oldname' onto '$
35d0: 70 72 65 66 65 72 65 64 6e 61 6d 65 27 7d 0a 09  preferedname'}..
35e0: 20 20 20 20 73 74 61 74 65 20 72 75 6e 20 7b 20      state run { 
35f0: 55 50 44 41 54 45 20 74 61 67 20 53 45 54 20 6c  UPDATE tag SET l
3600: 6f 64 20 3d 20 24 70 69 64 20 57 48 45 52 45 20  od = $pid WHERE 
3610: 74 69 64 20 3d 20 24 69 64 20 7d 0a 09 20 20 20  tid = $id }..   
3620: 20 69 6e 63 72 20 6e 0a 09 7d 0a 0a 09 6c 6f 67   incr n..}...log
3630: 20 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73   write 3 filters
3640: 79 6d 20 22 52 65 70 61 72 65 6e 74 65 64 20 5b  ym "Reparented [
3650: 6e 73 70 20 24 6e 20 74 61 67 5d 22 0a 0a 09 6c  nsp $n tag]"...l
3660: 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c 74 65  og write 3 filte
3670: 72 73 79 6d 20 22 41 64 6a 75 73 74 20 62 72 61  rsym "Adjust bra
3680: 6e 63 68 20 70 61 72 65 6e 74 73 22 0a 0a 09 23  nch parents"...#
3690: 20 46 69 6e 64 20 74 68 65 20 62 72 61 6e 63 68   Find the branch
36a0: 65 73 20 77 68 6f 73 65 20 63 75 72 72 65 6e 74  es whose current
36b0: 20 70 61 72 65 6e 74 20 28 6c 6f 64 29 20 69 73   parent (lod) is
36c0: 20 6e 6f 74 20 74 68 65 0a 09 23 20 70 72 65 66   not the..# pref
36d0: 65 72 65 64 20 70 61 72 65 6e 74 2c 20 74 68 65  ered parent, the
36e0: 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74   prefered parent
36f0: 20 69 73 20 6e 6f 74 20 74 68 65 20 74 72 75 6e   is not the trun
3700: 6b 2c 20 61 6e 64 0a 09 23 20 74 68 65 20 70 72  k, and..# the pr
3710: 65 66 65 72 65 64 20 70 61 72 65 6e 74 20 69 73  efered parent is
3720: 20 61 20 70 6f 73 73 69 62 6c 65 20 70 61 72 65   a possible pare
3730: 6e 74 20 70 65 72 20 74 68 65 20 62 72 61 6e 63  nt per the branc
3740: 68 27 73 0a 09 23 20 72 65 76 69 73 69 6f 6e 2e  h's..# revision.
3750: 0a 0a 09 73 65 74 20 66 6d 74 20 25 5b 73 74 72  ...set fmt %[str
3760: 69 6e 67 20 6c 65 6e 67 74 68 20 24 62 6d 61 78  ing length $bmax
3770: 5d 73 0a 09 73 65 74 20 6d 78 73 20 5b 66 6f 72  ]s..set mxs [for
3780: 6d 61 74 20 24 66 6d 74 20 24 62 6d 61 78 5d 0a  mat $fmt $bmax].
3790: 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 65 61  ..set n 0..forea
37a0: 63 68 20 7b 69 64 20 66 69 64 20 6c 6f 64 20 70  ch {id fid lod p
37b0: 6f 73 20 70 69 64 20 70 72 65 66 65 72 65 64 6e  os pid preferedn
37c0: 61 6d 65 20 72 65 76 6e 72 20 72 69 64 7d 20 24  ame revnr rid} $
37d0: 62 72 61 6e 63 68 65 73 74 6f 61 64 6a 75 73 74  branchestoadjust
37e0: 20 7b 0a 0a 09 20 20 20 20 23 20 42 4f 54 54 4c   {...    # BOTTL
37f0: 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 09 20 20 20 20  E-NECK .....    
3800: 23 0a 09 20 20 20 20 23 20 54 68 65 20 63 68 65  #..    # The che
3810: 63 6b 20 69 66 20 74 68 65 20 63 61 6e 64 69 64  ck if the candid
3820: 61 74 65 20 28 70 69 64 29 20 69 73 20 74 72 75  ate (pid) is tru
3830: 6c 79 20 76 69 61 62 6c 65 20 69 73 0a 09 20 20  ly viable is..  
3840: 20 20 23 20 62 61 73 65 64 20 6f 6e 20 74 68 65    # based on the
3850: 20 62 72 61 6e 63 68 20 70 6f 73 69 74 69 6f 6e   branch position
3860: 73 20 69 6e 20 74 68 65 20 73 70 61 77 6e 69 6e  s in the spawnin
3870: 67 20 72 65 76 69 73 69 6f 6e 2c 0a 09 20 20 20  g revision,..   
3880: 20 23 20 61 6e 64 20 64 6f 6e 65 20 6e 6f 77 20   # and done now 
3890: 69 6e 73 74 65 61 64 20 6f 66 20 61 73 20 70 61  instead of as pa
38a0: 72 74 20 6f 66 20 74 68 65 20 61 6c 72 65 61 64  rt of the alread
38b0: 79 20 63 6f 6d 70 6c 65 78 0a 09 20 20 20 20 23  y complex..    #
38c0: 20 6a 6f 69 6e 2e 0a 09 20 20 20 20 23 0a 09 20   join...    #.. 
38d0: 20 20 20 23 20 2e 2e 2e 20 41 4e 44 20 50 2e 70     # ... AND P.p
38e0: 69 64 20 49 4e 20 28 53 45 4c 45 43 54 20 42 58  id IN (SELECT BX
38f0: 2e 73 69 64 0a 09 20 20 20 20 23 20 20 20 20 20  .sid..    #     
3900: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 46 52                FR
3910: 4f 4d 20 62 72 61 6e 63 68 20 42 58 0a 09 20 20  OM branch BX..  
3920: 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20 20    #             
3930: 20 20 20 20 20 20 57 48 45 52 45 20 42 58 2e 72        WHERE BX.r
3940: 6f 6f 74 20 3d 20 52 2e 72 69 64 0a 09 20 20 20  oot = R.rid..   
3950: 20 23 20 20 20 20 20 20 20 20 20 20 20 20 20 20   #              
3960: 20 20 20 20 20 41 4e 44 20 20 20 42 58 2e 70 6f       AND   BX.po
3970: 73 20 3e 20 42 2e 70 6f 73 29 0a 0a 09 20 20 20  s > B.pos)...   
3980: 20 23 20 4e 6f 74 65 3a 20 72 69 64 20 65 71 20   # Note: rid eq 
3990: 22 22 20 68 65 61 72 20 6d 65 61 6e 73 20 74 68  "" hear means th
39a0: 61 74 20 74 68 69 73 20 69 73 20 61 20 66 72 65  at this is a fre
39b0: 65 2d 66 6c 6f 61 74 69 6e 67 0a 09 20 20 20 20  e-floating..    
39c0: 23 20 62 72 61 6e 63 68 2c 20 77 68 6f 73 65 20  # branch, whose 
39d0: 6f 72 69 67 69 6e 61 6c 20 72 6f 6f 74 20 77 61  original root wa
39e0: 73 20 72 65 6d 6f 76 65 64 20 61 73 20 61 20 75  s removed as a u
39f0: 6e 6e 65 63 65 73 73 61 72 79 0a 09 20 20 20 20  nnecessary..    
3a00: 23 20 64 65 61 64 20 72 65 76 69 73 69 6f 6e 20  # dead revision 
3a10: 28 53 65 65 20 27 66 69 6c 65 3a 3a 52 65 6d 6f  (See 'file::Remo
3a20: 76 65 49 72 72 65 6c 65 76 61 6e 74 44 65 6c 65  veIrrelevantDele
3a30: 74 69 6f 6e 73 27 29 2e 0a 09 20 20 20 20 23 20  tions')...    # 
3a40: 53 75 63 68 20 61 20 62 72 61 6e 63 68 20 63 61  Such a branch ca
3a50: 6e 20 62 65 20 72 65 67 72 61 66 74 65 64 20 77  n be regrafted w
3a60: 69 74 68 6f 75 74 20 74 72 6f 75 62 6c 65 20 61  ithout trouble a
3a70: 6e 64 20 74 68 65 72 65 0a 09 20 20 20 20 23 20  nd there..    # 
3a80: 69 73 20 6e 6f 20 6e 65 65 64 20 74 6f 20 6c 6f  is no need to lo
3a90: 6f 6b 20 66 6f 72 20 74 68 65 20 6e 65 77 20 70  ok for the new p
3aa0: 61 72 65 6e 74 20 69 6e 20 69 74 73 0a 09 20 20  arent in its..  
3ab0: 20 20 23 20 6e 6f 6e 2d 65 78 69 73 74 65 6e 74    # non-existent
3ac0: 20 72 6f 6f 74 2e 0a 0a 09 20 20 20 20 69 66 20   root....    if 
3ad0: 7b 28 24 72 69 64 20 6e 65 20 22 22 29 20 26 26  {($rid ne "") &&
3ae0: 20 21 5b 73 74 61 74 65 20 6f 6e 65 20 7b 0a 09   ![state one {..
3af0: 09 53 45 4c 45 43 54 20 43 4f 55 4e 54 28 2a 29  .SELECT COUNT(*)
3b00: 20 20 20 20 20 20 20 2d 2d 20 43 6f 75 6e 74 20         -- Count 
3b10: 3c 3d 3e 20 43 68 65 63 6b 20 65 78 69 73 74 65  <=> Check existe
3b20: 6e 63 65 2e 0a 09 09 46 52 4f 4d 20 62 72 61 6e  nce....FROM bran
3b30: 63 68 20 42 0a 09 09 57 48 45 52 45 20 20 42 2e  ch B...WHERE  B.
3b40: 73 69 64 20 20 3d 20 24 70 69 64 20 20 2d 2d 20  sid  = $pid  -- 
3b50: 4c 6f 6f 6b 20 66 6f 72 20 62 72 61 6e 63 68 20  Look for branch 
3b60: 62 79 20 73 79 6d 62 6f 6c 0a 09 09 41 4e 44 20  by symbol...AND 
3b70: 20 20 20 42 2e 72 6f 6f 74 20 3d 20 24 72 69 64     B.root = $rid
3b80: 20 20 2d 2d 20 53 70 61 77 6e 65 64 20 62 79 20    -- Spawned by 
3b90: 74 68 65 20 67 69 76 65 6e 20 72 65 76 69 73 69  the given revisi
3ba0: 6f 6e 0a 09 09 41 4e 44 20 20 20 20 42 2e 70 6f  on...AND    B.po
3bb0: 73 20 20 3e 20 24 70 6f 73 20 20 2d 2d 20 41 6e  s  > $pos  -- An
3bc0: 64 20 64 65 66 69 6e 65 64 20 62 65 66 6f 72 65  d defined before
3bd0: 20 62 72 61 6e 63 68 20 74 6f 20 6d 75 74 61 74   branch to mutat
3be0: 65 0a 09 20 20 20 20 7d 5d 7d 20 7b 0a 09 09 69  e..    }]} {...i
3bf0: 6e 63 72 20 62 6d 61 78 20 2d 31 0a 09 09 73 65  ncr bmax -1...se
3c00: 74 20 20 6d 78 73 20 5b 66 6f 72 6d 61 74 20 24  t  mxs [format $
3c10: 66 6d 74 20 24 62 6d 61 78 5d 0a 09 09 63 6f 6e  fmt $bmax]...con
3c20: 74 69 6e 75 65 0a 09 20 20 20 20 7d 0a 0a 09 20  tinue..    }... 
3c30: 20 20 20 23 0a 09 20 20 20 20 23 20 42 4f 54 54     #..    # BOTT
3c40: 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 0a 09 20 20  LE-NECK ......  
3c50: 20 20 23 20 54 68 65 20 6e 61 6d 65 73 20 66 6f    # The names fo
3c60: 72 20 75 73 65 20 69 6e 20 74 68 65 20 6c 6f 67  r use in the log
3c70: 20 6f 75 74 70 75 74 20 61 72 65 20 72 65 74 72   output are retr
3c80: 69 65 76 65 64 0a 09 20 20 20 20 23 20 73 65 70  ieved..    # sep
3c90: 61 72 61 74 65 6c 79 2c 20 74 6f 20 6b 65 65 70  arately, to keep
3ca0: 20 74 68 65 20 6a 6f 69 6e 20 73 65 6c 65 63 74   the join select
3cb0: 69 6e 67 20 74 68 65 20 61 64 6a 75 73 74 61 62  ing the adjustab
3cc0: 6c 65 0a 09 20 20 20 20 23 20 74 61 67 73 20 73  le..    # tags s
3cd0: 6d 61 6c 6c 2c 20 6e 6f 74 20 62 75 72 64 65 6e  mall, not burden
3ce0: 65 64 20 77 69 74 68 20 74 68 65 20 64 65 72 65  ed with the dere
3cf0: 66 65 72 65 6e 63 69 6e 67 20 6f 66 20 6c 69 6e  ferencing of lin
3d00: 6b 73 0a 09 20 20 20 20 23 20 74 6f 20 6e 61 6d  ks..    # to nam
3d10: 65 2e 0a 0a 09 20 20 20 20 73 65 74 20 62 72 61  e....    set bra
3d20: 6e 61 6d 65 20 24 73 6e 28 24 69 64 29 0a 09 20  name $sn($id).. 
3d30: 20 20 20 73 65 74 20 6f 6c 64 6e 61 6d 65 20 24     set oldname $
3d40: 73 78 28 24 6c 6f 64 29 0a 09 20 20 20 20 73 74  sx($lod)..    st
3d50: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
3d60: 6e 20 24 66 70 6e 28 24 66 69 64 29 20 66 6e 61  n $fpn($fid) fna
3d70: 6d 65 20 70 72 6e 61 6d 65 0a 0a 09 20 20 20 20  me prname...    
3d80: 23 20 44 6f 20 74 68 65 20 67 72 61 66 74 69 6e  # Do the graftin
3d90: 67 2e 0a 0a 09 20 20 20 20 6c 6f 67 20 77 72 69  g....    log wri
3da0: 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d 20 7b  te 4 filtersym {
3db0: 5c 5b 5b 66 6f 72 6d 61 74 20 24 66 6d 74 20 24  \[[format $fmt $
3dc0: 6e 5d 2f 24 6d 78 73 5c 5d 20 24 70 72 6e 61 6d  n]/$mxs\] $prnam
3dd0: 65 20 3a 20 47 72 61 66 74 69 6e 67 20 62 72 61  e : Grafting bra
3de0: 6e 63 68 20 27 24 62 72 61 6e 61 6d 65 27 20 6f  nch '$braname' o
3df0: 6e 20 24 66 6e 61 6d 65 2f 24 72 65 76 6e 72 20  n $fname/$revnr 
3e00: 66 72 6f 6d 20 27 24 6f 6c 64 6e 61 6d 65 27 20  from '$oldname' 
3e10: 6f 6e 74 6f 20 27 24 70 72 65 66 65 72 65 64 6e  onto '$preferedn
3e20: 61 6d 65 27 7d 0a 09 20 20 20 20 73 74 61 74 65  ame'}..    state
3e30: 20 72 75 6e 20 7b 20 55 50 44 41 54 45 20 62 72   run { UPDATE br
3e40: 61 6e 63 68 20 53 45 54 20 6c 6f 64 20 3d 20 24  anch SET lod = $
3e50: 70 69 64 20 57 48 45 52 45 20 62 69 64 20 3d 20  pid WHERE bid = 
3e60: 24 69 64 20 7d 0a 09 20 20 20 20 69 6e 63 72 20  $id }..    incr 
3e70: 6e 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65  n..}...log write
3e80: 20 33 20 66 69 6c 74 65 72 73 79 6d 20 22 52 65   3 filtersym "Re
3e90: 70 61 72 65 6e 74 65 64 20 5b 6e 73 70 20 24 6e  parented [nsp $n
3ea0: 20 62 72 61 6e 63 68 20 62 72 61 6e 63 68 65 73   branch branches
3eb0: 5d 22 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  ]"..return.    }
3ec0: 0a 0a 20 20 20 20 70 72 6f 63 20 52 65 66 69 6e  ..    proc Refin
3ed0: 65 53 79 6d 62 6f 6c 73 20 7b 7d 20 7b 0a 09 23  eSymbols {} {..#
3ee0: 20 54 61 67 73 20 61 6e 64 20 62 72 61 6e 63 68   Tags and branch
3ef0: 65 73 20 61 72 65 20 6d 61 72 6b 65 64 20 61 73  es are marked as
3f00: 20 6e 6f 72 6d 61 6c 2f 6e 6f 6f 70 20 62 61 73   normal/noop bas
3f10: 65 64 20 6f 6e 20 74 68 65 20 6f 70 0a 09 23 20  ed on the op..# 
3f20: 6f 66 20 74 68 65 69 72 20 72 65 76 69 73 69 6f  of their revisio
3f30: 6e 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 33  n....log write 3
3f40: 20 66 69 6c 74 65 72 73 79 6d 20 22 52 65 66 69   filtersym "Refi
3f50: 6e 65 20 73 79 6d 62 6f 6c 73 20 28 6e 6f 2d 6f  ne symbols (no-o
3f60: 70 20 6f 72 20 6e 6f 74 3f 29 22 0a 0a 09 23 20  p or not?)"...# 
3f70: 4e 6f 74 65 3a 20 54 68 65 20 6e 6f 6f 70 20 69  Note: The noop i
3f80: 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 6e 6f  nformation is no
3f90: 74 20 75 73 65 64 20 61 6e 79 77 68 65 72 65 2e  t used anywhere.
3fa0: 20 43 6f 6e 73 69 64 65 72 0a 09 23 20 64 69 73   Consider..# dis
3fb0: 61 62 6c 69 6e 67 20 74 68 69 73 20 63 6f 64 65  abling this code
3fc0: 2c 20 61 6e 64 20 72 65 6d 6f 76 69 6e 67 20 74  , and removing t
3fd0: 68 65 20 64 61 74 61 20 66 72 6f 6d 20 74 68 65  he data from the
3fe0: 20 73 74 61 74 65 2e 0a 0a 09 6c 6f 67 20 77 72   state....log wr
3ff0: 69 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d 20  ite 4 filtersym 
4000: 22 20 20 20 20 52 65 67 75 6c 61 72 20 74 61 67  "    Regular tag
4010: 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20 7b 0a  s"..state run {.
4020: 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
4030: 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c 45 43   noop..    SELEC
4040: 54 20 54 2e 74 69 64 2c 20 30 0a 09 20 20 20 20  T T.tid, 0..    
4050: 46 52 4f 4d 20 74 61 67 20 54 2c 20 72 65 76 69  FROM tag T, revi
4060: 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52  sion R..    WHER
4070: 45 20 54 2e 72 65 76 20 20 3d 20 52 2e 72 69 64  E T.rev  = R.rid
4080: 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 6f 70  ..    AND   R.op
4090: 20 20 21 3d 20 30 20 2d 2d 20 30 20 3d 3d 20 6e    != 0 -- 0 == n
40a0: 6f 74 68 69 6e 67 0a 09 7d 0a 0a 09 6c 6f 67 20  othing..}...log 
40b0: 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73 79  write 4 filtersy
40c0: 6d 20 22 20 20 20 20 4e 6f 2d 6f 70 20 74 61 67  m "    No-op tag
40d0: 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20 7b 0a  s"..state run {.
40e0: 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
40f0: 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c 45 43   noop..    SELEC
4100: 54 20 54 2e 74 69 64 2c 20 31 0a 09 20 20 20 20  T T.tid, 1..    
4110: 46 52 4f 4d 20 74 61 67 20 54 2c 20 72 65 76 69  FROM tag T, revi
4120: 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52  sion R..    WHER
4130: 45 20 54 2e 72 65 76 20 20 3d 20 52 2e 72 69 64  E T.rev  = R.rid
4140: 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 6f 70  ..    AND   R.op
4150: 20 20 20 3d 20 30 20 2d 2d 20 6e 6f 74 68 69 6e     = 0 -- nothin
4160: 67 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65  g..}...log write
4170: 20 34 20 66 69 6c 74 65 72 73 79 6d 20 22 20 20   4 filtersym "  
4180: 20 20 52 65 67 75 6c 61 72 20 62 72 61 6e 63 68    Regular branch
4190: 65 73 22 0a 09 73 74 61 74 65 20 72 75 6e 20 7b  es"..state run {
41a0: 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ..    INSERT INT
41b0: 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45 4c 45  O noop..    SELE
41c0: 43 54 20 42 2e 62 69 64 2c 20 30 0a 09 20 20 20  CT B.bid, 0..   
41d0: 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 2c 20   FROM branch B, 
41e0: 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20  revision R..    
41f0: 57 48 45 52 45 20 42 2e 72 6f 6f 74 20 3d 20 52  WHERE B.root = R
4200: 2e 72 69 64 0a 09 20 20 20 20 41 4e 44 20 20 20  .rid..    AND   
4210: 52 2e 6f 70 20 20 21 3d 20 30 20 2d 2d 20 6e 6f  R.op  != 0 -- no
4220: 74 68 69 6e 67 0a 09 7d 0a 0a 09 6c 6f 67 20 77  thing..}...log w
4230: 72 69 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d  rite 4 filtersym
4240: 20 22 20 20 20 20 4e 6f 2d 6f 70 20 62 72 61 6e   "    No-op bran
4250: 63 68 65 73 22 0a 09 73 74 61 74 65 20 72 75 6e  ches"..state run
4260: 20 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49   {..    INSERT I
4270: 4e 54 4f 20 6e 6f 6f 70 0a 09 20 20 20 20 53 45  NTO noop..    SE
4280: 4c 45 43 54 20 42 2e 62 69 64 2c 20 31 0a 09 20  LECT B.bid, 1.. 
4290: 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20 42     FROM branch B
42a0: 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20  , revision R..  
42b0: 20 20 57 48 45 52 45 20 42 2e 72 6f 6f 74 20 3d    WHERE B.root =
42c0: 20 52 2e 72 69 64 0a 09 20 20 20 20 41 4e 44 20   R.rid..    AND 
42d0: 20 20 52 2e 6f 70 20 20 20 3d 20 30 20 2d 2d 20    R.op   = 0 -- 
42e0: 6e 6f 74 68 69 6e 67 0a 09 7d 0a 09 72 65 74 75  nothing..}..retu
42f0: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  rn.    }..    pr
4300: 6f 63 20 6d 61 78 6c 65 6e 20 7b 76 20 73 74 72  oc maxlen {v str
4310: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 76 20  } {..upvar 1 $v 
4320: 6e 0a 09 73 65 74 20 6c 20 5b 73 74 72 69 6e 67  n..set l [string
4330: 20 6c 65 6e 67 74 68 20 24 73 74 72 5d 0a 09 69   length $str]..i
4340: 66 20 7b 24 6c 20 3c 3d 20 24 6e 7d 20 72 65 74  f {$l <= $n} ret
4350: 75 72 6e 0a 09 73 65 74 20 6e 20 24 6c 0a 09 72  urn..set n $l..r
4360: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
4370: 20 70 72 6f 63 20 50 72 69 6e 74 53 79 6d 62 6f   proc PrintSymbo
4380: 6c 54 72 65 65 20 7b 7d 20 7b 0a 09 69 66 20 7b  lTree {} {..if {
4390: 21 5b 6c 6f 67 20 76 69 73 69 62 6c 65 3f 20 39  ![log visible? 9
43a0: 5d 7d 20 72 65 74 75 72 6e 0a 0a 09 61 72 72 61  ]} return...arra
43b0: 79 20 73 65 74 20 73 79 6d 20 7b 7d 0a 09 73 65  y set sym {}..se
43c0: 74 20 6e 20 30 0a 09 73 65 74 20 74 20 30 0a 09  t n 0..set t 0..
43d0: 73 65 74 20 63 20 30 0a 09 73 65 74 20 70 20 30  set c 0..set p 0
43e0: 0a 0a 09 73 74 61 74 65 20 66 6f 72 65 61 63 68  ...state foreach
43f0: 72 6f 77 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  row {..    SELEC
4400: 54 20 53 2e 6e 61 6d 65 20 20 20 20 20 20 20 20  T S.name        
4410: 20 41 53 20 78 73 2c 0a 09 20 20 20 20 20 20 20   AS xs,..       
4420: 20 20 20 20 41 2e 6e 61 6d 65 20 20 20 20 20 20      A.name      
4430: 20 20 20 41 53 20 73 74 79 70 65 2c 0a 09 20 20     AS stype,..  
4440: 20 20 20 20 20 20 20 20 20 53 2e 63 6f 6d 6d 69           S.commi
4450: 74 5f 63 6f 75 6e 74 20 41 53 20 63 63 2c 0a 09  t_count AS cc,..
4460: 20 20 20 20 20 20 20 20 20 20 20 50 2e 6e 61 6d             P.nam
4470: 65 20 20 20 20 20 20 20 20 20 41 53 20 78 70 2c  e         AS xp,
4480: 0a 09 20 20 20 20 20 20 20 20 20 20 20 42 2e 6e  ..           B.n
4490: 61 6d 65 20 20 20 20 20 20 20 20 20 41 53 20 70  ame         AS p
44a0: 74 79 70 65 0a 09 20 20 20 20 46 52 4f 4d 20 73  type..    FROM s
44b0: 79 6d 62 6f 6c 20 53 2c 20 70 72 65 66 65 72 65  ymbol S, prefere
44c0: 64 70 61 72 65 6e 74 20 53 50 2c 20 73 79 6d 62  dparent SP, symb
44d0: 6f 6c 20 50 2c 20 73 79 6d 74 79 70 65 20 41 2c  ol P, symtype A,
44e0: 20 73 79 6d 74 79 70 65 20 42 0a 09 20 20 20 20   symtype B..    
44f0: 57 48 45 52 45 20 53 50 2e 73 69 64 20 3d 20 53  WHERE SP.sid = S
4500: 2e 73 69 64 0a 09 20 20 20 20 41 4e 44 20 20 20  .sid..    AND   
4510: 50 2e 73 69 64 20 3d 20 53 50 2e 70 69 64 0a 09  P.sid = SP.pid..
4520: 20 20 20 20 41 4e 44 20 20 20 41 2e 74 69 64 20      AND   A.tid 
4530: 3d 20 53 2e 74 79 70 65 0a 09 20 20 20 20 41 4e  = S.type..    AN
4540: 44 20 20 20 42 2e 74 69 64 20 3d 20 50 2e 74 79  D   B.tid = P.ty
4550: 70 65 0a 09 7d 20 7b 0a 09 20 20 20 20 6c 61 70  pe..} {..    lap
4560: 70 65 6e 64 20 73 79 6d 28 24 78 73 29 20 24 78  pend sym($xs) $x
4570: 70 20 24 73 74 79 70 65 20 24 70 74 79 70 65 20  p $stype $ptype 
4580: 24 63 63 0a 09 20 20 20 20 6d 61 78 6c 65 6e 20  $cc..    maxlen 
4590: 6e 20 24 78 73 0a 09 20 20 20 20 6d 61 78 6c 65  n $xs..    maxle
45a0: 6e 20 74 20 24 73 74 79 70 65 0a 09 20 20 20 20  n t $stype..    
45b0: 6d 61 78 6c 65 6e 20 74 20 24 70 74 79 70 65 0a  maxlen t $ptype.
45c0: 09 20 20 20 20 6d 61 78 6c 65 6e 20 63 20 24 63  .    maxlen c $c
45d0: 63 0a 09 20 20 20 20 6d 61 78 6c 65 6e 20 70 20  c..    maxlen p 
45e0: 24 78 70 0a 09 7d 0a 0a 09 66 6f 72 65 61 63 68  $xp..}...foreach
45f0: 20 78 73 20 5b 6c 73 6f 72 74 20 2d 64 69 63 74   xs [lsort -dict
4600: 20 5b 61 72 72 61 79 20 6e 61 6d 65 73 20 73 79   [array names sy
4610: 6d 5d 5d 20 7b 0a 09 20 20 20 20 73 74 72 75 63  m]] {..    struc
4620: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24  t::list assign $
4630: 73 79 6d 28 24 78 73 29 20 78 70 20 73 74 79 70  sym($xs) xp styp
4640: 65 20 70 74 79 70 65 20 63 63 0a 09 20 20 20 20  e ptype cc..    
4650: 6c 6f 67 20 77 72 69 74 65 20 39 20 66 69 6c 74  log write 9 filt
4660: 65 72 73 79 6d 20 7b 54 72 65 65 3a 20 5b 6c 6a  ersym {Tree: [lj
4670: 20 24 74 20 24 73 74 79 70 65 5d 20 28 5b 64 6a   $t $stype] ([dj
4680: 20 24 63 20 24 63 63 5d 29 20 5b 6c 6a 20 24 6e   $c $cc]) [lj $n
4690: 20 24 78 73 5d 20 3c 2d 2d 20 5b 6c 6a 20 24 74   $xs] <-- [lj $t
46a0: 20 24 70 74 79 70 65 5d 20 24 78 70 7d 0a 09 7d   $ptype] $xp}..}
46b0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
46c0: 20 20 20 20 70 72 6f 63 20 6c 6a 20 7b 6e 20 73      proc lj {n s
46d0: 7d 20 7b 20 3a 3a 66 6f 72 6d 61 74 20 25 2d 24  } { ::format %-$
46e0: 7b 6e 7d 73 20 24 73 20 7d 0a 20 20 20 20 70 72  {n}s $s }.    pr
46f0: 6f 63 20 64 6a 20 7b 6e 20 73 7d 20 7b 20 3a 3a  oc dj {n s} { ::
4700: 66 6f 72 6d 61 74 20 25 2d 24 7b 6e 7d 64 20 24  format %-${n}d $
4710: 73 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20  s }..    # # ## 
4720: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
4730: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
4740: 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72  .    ## Configur
4750: 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d  ation..    pragm
4760: 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 65 73 20  a -hasinstances 
4770: 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74    no ; # singlet
4780: 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68  on.    pragma -h
4790: 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f  astypeinfo    no
47a0: 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65   ; # no introspe
47b0: 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61  ction.    pragma
47c0: 20 2d 68 61 73 74 79 70 65 64 65 73 74 72 6f 79   -hastypedestroy
47d0: 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c   no ; # immortal
47e0: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
47f0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
4800: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 7d 0a  #############.}.
4810: 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
4820: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
4830: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20  port::cvs::pass 
4840: 7b 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20  {.    namespace 
4850: 65 78 70 6f 72 74 20 66 69 6c 74 65 72 73 79 6d  export filtersym
4860: 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65  .    namespace e
4870: 76 61 6c 20 66 69 6c 74 65 72 73 79 6d 20 7b 0a  val filtersym {.
4880: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
4890: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
48a0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70  import::cvs::rep
48b0: 6f 73 69 74 6f 72 79 0a 09 6e 61 6d 65 73 70 61  ository..namespa
48c0: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
48d0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
48e0: 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65  cvs::state..name
48f0: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
4900: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
4910: 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74  t::cvs::integrit
4920: 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61  y..namespace eva
4930: 6c 20 70 72 6f 6a 65 63 74 20 7b 0a 09 20 20 20  l project {..   
4940: 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72   namespace impor
4950: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
4960: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f  import::cvs::pro
4970: 6a 65 63 74 3a 3a 73 79 6d 0a 09 7d 0a 09 6e 61  ject::sym..}..na
4980: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
4990: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63  :vc::tools::misc
49a0: 3a 3a 6e 73 70 0a 09 6e 61 6d 65 73 70 61 63 65  ::nsp..namespace
49b0: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f   import ::vc::to
49c0: 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65  ols::log..log re
49d0: 67 69 73 74 65 72 20 66 69 6c 74 65 72 73 79 6d  gister filtersym
49e0: 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23  .    }.}..# # ##
49f0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
4a00: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
4a10: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23  # ##############
4a20: 23 23 23 23 23 23 23 0a 23 23 20 52 65 61 64 79  #######.## Ready
4a30: 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 69 64  ..package provid
4a40: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  e vc::fossil::im
4a50: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a  port::cvs::pass:
4a60: 3a 66 69 6c 74 65 72 73 79 6d 20 31 2e 30 0a 72  :filtersym 1.0.r
4a70: 65 74 75 72 6e 0a                                eturn.