Hex Artifact Content
Not logged in

Artifact b7f9a11eac1125151d20af3eb7f0f9c594015ca6:

File tools/cvs2fossil/lib/c2f_pfiltersym.tcl part of check-in [66235f2430] - Updated the copyright information of all files touched in the new year. by aku on 2008-02-06 05:04:12. Also file tools/cvs2fossil/lib/c2f_pfiltersym.tcl part of check-in [6b78df3861] - Merge in changes from Andreas's branch. by drh on 2008-02-08 21:52:21.

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 66 6f 72 65 61 63 68 20 7b  k {}...foreach {
13a0: 69 64 20 70 61 72 65 6e 74 20 74 72 61 6e 73 66  id parent transf
13b0: 65 72 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b  er} [state run {
13c0: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72  ..    SELECT R.r
13d0: 69 64 2c 20 52 2e 70 61 72 65 6e 74 2c 20 52 2e  id, R.parent, R.
13e0: 64 62 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f  dbchild..    FRO
13f0: 4d 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 73  M  revision R, s
1400: 79 6d 62 6f 6c 20 53 0a 09 20 20 20 20 57 48 45  ymbol S..    WHE
1410: 52 45 20 52 2e 6c 6f 64 20 3d 20 53 2e 73 69 64  RE R.lod = S.sid
1420: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47              -- G
1430: 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 6c 69 6e  et symbol of lin
1440: 65 2d 6f 66 2d 64 65 76 65 6c 6f 70 6d 65 6e 74  e-of-development
1450: 20 6f 66 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e   of all revision
1460: 73 0a 09 20 20 20 20 41 4e 44 20 20 20 53 2e 73  s..    AND   S.s
1470: 69 64 20 49 4e 20 65 78 63 6c 75 64 65 64 73 79  id IN excludedsy
1480: 6d 62 6f 6c 73 20 2d 2d 20 52 65 73 74 72 69 63  mbols -- Restric
1490: 74 20 74 6f 20 74 68 65 20 65 78 63 6c 75 64 65  t to the exclude
14a0: 64 20 73 79 6d 62 6f 6c 73 0a 09 20 20 20 20 41  d symbols..    A
14b0: 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74  ND   R.isdefault
14c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d                --
14d0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 44   Restrict to NTD
14e0: 42 20 72 65 76 69 73 69 6f 6e 73 0a 09 7d 5d 20  B revisions..}] 
14f0: 7b 0a 09 20 20 20 20 73 65 74 20 6e 74 64 62 28  {..    set ntdb(
1500: 24 69 64 29 20 24 70 61 72 65 6e 74 0a 09 20 20  $id) $parent..  
1510: 20 20 69 66 20 7b 24 74 72 61 6e 73 66 65 72 20    if {$transfer 
1520: 65 71 20 22 22 7d 20 63 6f 6e 74 69 6e 75 65 0a  eq ""} continue.
1530: 09 20 20 20 20 73 65 74 20 6c 69 6e 6b 28 24 69  .    set link($i
1540: 64 29 20 24 74 72 61 6e 73 66 65 72 0a 09 7d 0a  d) $transfer..}.
1550: 0a 09 66 6f 72 65 61 63 68 20 6a 6f 69 6e 74 20  ..foreach joint 
1560: 5b 61 72 72 61 79 20 6e 61 6d 65 73 20 6c 69 6e  [array names lin
1570: 6b 5d 20 7b 0a 09 20 20 20 20 23 20 54 68 65 20  k] {..    # The 
1580: 6a 6f 69 6e 74 73 20 61 72 65 20 74 68 65 20 68  joints are the h
1590: 69 67 68 65 73 74 20 4e 54 44 42 20 72 65 76 69  ighest NTDB revi
15a0: 73 69 6f 6e 73 20 77 68 69 63 68 20 61 72 65 0a  sions which are.
15b0: 09 20 20 20 20 23 20 73 68 61 72 65 64 20 77 69  .    # shared wi
15c0: 74 68 20 74 68 65 69 72 20 72 65 73 70 65 63 74  th their respect
15d0: 69 76 65 20 74 72 75 6e 6b 2e 20 57 65 20 64 69  ive trunk. We di
15e0: 73 63 6f 6e 6e 65 63 74 20 66 72 6f 6d 0a 09 20  sconnect from.. 
15f0: 20 20 20 23 20 74 68 65 69 72 20 4e 54 44 42 20     # their NTDB 
1600: 63 68 69 6c 64 72 65 6e 2c 20 61 6e 64 20 6d 61  children, and ma
1610: 6b 65 20 74 68 65 6d 20 70 61 72 65 6e 74 73 20  ke them parents 
1620: 6f 66 20 74 68 65 69 72 0a 09 20 20 20 20 23 20  of their..    # 
1630: 27 64 62 63 68 69 6c 64 27 2e 20 54 68 65 20 61  'dbchild'. The a
1640: 73 73 6f 63 69 61 74 65 64 20 27 64 62 70 61 72  ssociated 'dbpar
1650: 65 6e 74 27 20 69 73 20 73 71 75 61 73 68 65 64  ent' is squashed
1660: 0a 09 20 20 20 20 23 20 69 6e 73 74 65 61 64 2e  ..    # instead.
1670: 20 41 6c 6c 20 70 61 72 65 6e 74 73 20 6f 66 20   All parents of 
1680: 74 68 65 20 6a 6f 69 6e 74 73 20 61 72 65 20 6d  the joints are m
1690: 6f 76 65 64 20 74 6f 20 74 68 65 0a 09 20 20 20  oved to the..   
16a0: 20 23 20 74 72 75 6e 6b 20 61 73 20 77 65 6c 6c   # trunk as well
16b0: 2e 0a 0a 09 20 20 20 20 73 65 74 20 74 6a 6f 69  ....    set tjoi
16c0: 6e 74 20 24 6c 69 6e 6b 28 24 6a 6f 69 6e 74 29  nt $link($joint)
16d0: 0a 09 20 20 20 20 73 65 74 20 74 6c 6f 64 20 5b  ..    set tlod [
16e0: 73 74 61 74 65 20 6f 6e 65 20 7b 0a 09 09 53 45  state one {...SE
16f0: 4c 45 43 54 20 6c 6f 64 20 46 52 4f 4d 20 72 65  LECT lod FROM re
1700: 76 69 73 69 6f 6e 20 57 48 45 52 45 20 72 69 64  vision WHERE rid
1710: 20 3d 20 24 74 6a 6f 69 6e 74 0a 09 20 20 20 20   = $tjoint..    
1720: 7d 5d 0a 0a 09 20 20 20 20 23 20 43 6f 76 6e 65  }]...    # Covne
1730: 72 74 20 64 62 2f 70 61 72 65 6e 74 2f 63 68 69  rt db/parent/chi
1740: 6c 64 20 69 6e 74 6f 20 72 65 67 75 6c 61 72 20  ld into regular 
1750: 70 61 72 65 6e 74 2f 63 68 69 6c 64 20 6c 69 6e  parent/child lin
1760: 6b 73 2e 0a 09 20 20 20 20 73 74 61 74 65 20 72  ks...    state r
1770: 75 6e 20 7b 0a 09 09 55 50 44 41 54 45 20 72 65  un {...UPDATE re
1780: 76 69 73 69 6f 6e 20 53 45 54 20 64 62 70 61 72  vision SET dbpar
1790: 65 6e 74 20 3d 20 4e 55 4c 4c 2c 20 70 61 72 65  ent = NULL, pare
17a0: 6e 74 20 3d 20 24 6a 6f 69 6e 74 20 20 57 48 45  nt = $joint  WHE
17b0: 52 45 20 72 69 64 20 3d 20 24 74 6a 6f 69 6e 74  RE rid = $tjoint
17c0: 20 3b 0a 09 09 55 50 44 41 54 45 20 72 65 76 69   ;...UPDATE revi
17d0: 73 69 6f 6e 20 53 45 54 20 64 62 63 68 69 6c 64  sion SET dbchild
17e0: 20 20 3d 20 4e 55 4c 4c 2c 20 63 68 69 6c 64 20    = NULL, child 
17f0: 20 3d 20 24 74 6a 6f 69 6e 74 20 57 48 45 52 45   = $tjoint WHERE
1800: 20 72 69 64 20 3d 20 24 6a 6f 69 6e 74 20 20 3b   rid = $joint  ;
1810: 0a 09 20 20 20 20 7d 0a 09 20 20 20 20 77 68 69  ..    }..    whi
1820: 6c 65 20 7b 31 7d 20 7b 0a 09 09 23 20 4d 6f 76  le {1} {...# Mov
1830: 65 20 74 68 65 20 4e 54 44 42 20 74 72 75 6e 6b  e the NTDB trunk
1840: 20 72 65 76 69 73 69 6f 6e 73 20 74 6f 20 74 72   revisions to tr
1850: 75 6e 6b 2e 0a 09 09 73 74 61 74 65 20 72 75 6e  unk....state run
1860: 20 7b 0a 09 09 20 20 20 20 55 50 44 41 54 45 20   {...    UPDATE 
1870: 72 65 76 69 73 69 6f 6e 20 53 45 54 20 6c 6f 64  revision SET lod
1880: 20 3d 20 24 74 6c 6f 64 2c 20 69 73 64 65 66 61   = $tlod, isdefa
1890: 75 6c 74 20 3d 20 30 20 57 48 45 52 45 20 72 69  ult = 0 WHERE ri
18a0: 64 20 3d 20 24 6a 6f 69 6e 74 0a 09 09 7d 0a 09  d = $joint...}..
18b0: 09 73 65 74 20 6c 61 73 74 20 24 6a 6f 69 6e 74  .set last $joint
18c0: 0a 09 09 73 65 74 20 6a 6f 69 6e 74 20 24 6e 74  ...set joint $nt
18d0: 64 62 28 24 6a 6f 69 6e 74 29 0a 09 09 69 66 20  db($joint)...if 
18e0: 7b 21 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 6e  {![info exists n
18f0: 74 64 62 28 24 6a 6f 69 6e 74 29 5d 7d 20 62 72  tdb($joint)]} br
1900: 65 61 6b 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20  eak..    }...   
1910: 20 23 20 52 65 61 63 68 65 64 20 74 68 65 20 4e   # Reached the N
1920: 54 44 42 20 62 61 73 69 73 20 69 6e 20 74 68 65  TDB basis in the
1930: 20 74 72 75 6e 6b 2e 20 46 69 6e 61 6c 69 7a 65   trunk. Finalize
1940: 20 74 68 65 0a 09 20 20 20 20 23 20 70 61 72 65   the..    # pare
1950: 6e 74 2f 63 68 69 6c 64 20 6c 69 6e 6b 61 67 65  nt/child linkage
1960: 20 61 6e 64 20 73 71 75 61 73 68 20 74 68 65 20   and squash the 
1970: 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 73 79  branch parent sy
1980: 6d 62 6f 6c 0a 09 20 20 20 20 23 20 72 65 66 65  mbol..    # refe
1990: 72 65 6e 63 65 2e 0a 0a 09 20 20 20 20 73 74 61  rence....    sta
19a0: 74 65 20 72 75 6e 20 7b 0a 09 09 55 50 44 41 54  te run {...UPDAT
19b0: 45 20 72 65 76 69 73 69 6f 6e 20 53 45 54 20 63  E revision SET c
19c0: 68 69 6c 64 20 20 20 3d 20 24 6c 61 73 74 20 57  hild   = $last W
19d0: 48 45 52 45 20 72 69 64 20 3d 20 24 6a 6f 69 6e  HERE rid = $join
19e0: 74 20 3b 0a 09 09 55 50 44 41 54 45 20 72 65 76  t ;...UPDATE rev
19f0: 69 73 69 6f 6e 20 53 45 54 20 62 70 61 72 65 6e  ision SET bparen
1a00: 74 20 3d 20 4e 55 4c 4c 20 20 57 48 45 52 45 20  t = NULL  WHERE 
1a10: 72 69 64 20 3d 20 24 6c 61 73 74 20 20 3b 0a 09  rid = $last  ;..
1a20: 20 20 20 20 7d 0a 09 7d 0a 0a 09 23 20 4e 6f 77      }..}...# Now
1a30: 20 74 68 61 74 20 74 68 65 20 73 70 65 63 69 61   that the specia
1a40: 6c 20 63 61 73 65 20 69 73 20 64 6f 6e 65 20 77  l case is done w
1a50: 65 20 63 61 6e 20 73 69 6d 70 6c 79 20 6b 69 6c  e can simply kil
1a60: 6c 20 61 6c 6c 20 74 68 65 0a 09 23 20 72 65 76  l all the..# rev
1a70: 69 73 69 6f 6e 73 2c 20 74 61 67 73 2c 20 61 6e  isions, tags, an
1a80: 64 20 62 72 61 6e 63 68 65 73 20 72 65 66 65 72  d branches refer
1a90: 65 6e 63 69 6e 67 20 61 6e 79 20 6f 66 20 74 68  encing any of th
1aa0: 65 0a 09 23 20 65 78 63 6c 75 64 65 64 20 73 79  e..# excluded sy
1ab0: 6d 62 6f 6c 73 20 69 6e 20 73 6f 6d 65 20 77 61  mbols in some wa
1ac0: 79 2e 20 54 68 69 73 20 69 73 20 65 61 73 79 20  y. This is easy 
1ad0: 61 73 20 77 65 20 64 6f 20 6e 6f 74 20 68 61 76  as we do not hav
1ae0: 65 0a 09 23 20 74 6f 20 73 65 6c 65 63 74 20 74  e..# to select t
1af0: 68 65 6d 20 61 67 61 69 6e 20 61 6e 64 20 61 67  hem again and ag
1b00: 61 69 6e 20 66 72 6f 6d 20 74 68 65 20 62 61 73  ain from the bas
1b10: 65 20 74 61 62 6c 65 73 20 61 6e 79 0a 09 23 20  e tables any..# 
1b20: 6c 6f 6e 67 65 72 2e 0a 0a 09 73 74 61 74 65 20  longer....state 
1b30: 72 75 6e 20 7b 0a 09 20 20 20 20 43 52 45 41 54  run {..    CREAT
1b40: 45 20 54 45 4d 50 4f 52 41 52 59 20 54 41 42 4c  E TEMPORARY TABL
1b50: 45 20 65 78 63 6c 75 64 65 64 72 65 76 69 73 69  E excludedrevisi
1b60: 6f 6e 73 20 41 53 0a 09 20 20 20 20 53 45 4c 45  ons AS..    SELE
1b70: 43 54 20 72 69 64 20 46 52 4f 4d 20 72 65 76 69  CT rid FROM revi
1b80: 73 69 6f 6e 20 57 48 45 52 45 20 6c 6f 64 20 49  sion WHERE lod I
1b90: 4e 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f 6c  N excludedsymbol
1ba0: 73 3b 0a 0a 09 20 20 20 20 44 45 4c 45 54 45 20  s;...    DELETE 
1bb0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 57 48  FROM revision WH
1bc0: 45 52 45 20 6c 6f 64 20 49 4e 20 65 78 63 6c 75  ERE lod IN exclu
1bd0: 64 65 64 73 79 6d 62 6f 6c 73 3b 0a 09 20 20 20  dedsymbols;..   
1be0: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 74 61 67   DELETE FROM tag
1bf0: 20 20 20 20 20 20 57 48 45 52 45 20 6c 6f 64 20        WHERE lod 
1c00: 49 4e 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f  IN excludedsymbo
1c10: 6c 73 3b 0a 09 20 20 20 20 44 45 4c 45 54 45 20  ls;..    DELETE 
1c20: 46 52 4f 4d 20 74 61 67 20 20 20 20 20 20 57 48  FROM tag      WH
1c30: 45 52 45 20 73 69 64 20 49 4e 20 65 78 63 6c 75  ERE sid IN exclu
1c40: 64 65 64 73 79 6d 62 6f 6c 73 3b 0a 09 20 20 20  dedsymbols;..   
1c50: 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 62 72 61   DELETE FROM bra
1c60: 6e 63 68 20 20 20 57 48 45 52 45 20 6c 6f 64 20  nch   WHERE lod 
1c70: 49 4e 20 65 78 63 6c 75 64 65 64 73 79 6d 62 6f  IN excludedsymbo
1c80: 6c 73 3b 0a 09 20 20 20 20 44 45 4c 45 54 45 20  ls;..    DELETE 
1c90: 46 52 4f 4d 20 62 72 61 6e 63 68 20 20 20 57 48  FROM branch   WH
1ca0: 45 52 45 20 73 69 64 20 49 4e 20 65 78 63 6c 75  ERE sid IN exclu
1cb0: 64 65 64 73 79 6d 62 6f 6c 73 3b 0a 0a 09 20 20  dedsymbols;...  
1cc0: 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 72 65    DELETE FROM re
1cd0: 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c  visionbranchchil
1ce0: 64 72 65 6e 20 57 48 45 52 45 20 72 69 64 20 20  dren WHERE rid  
1cf0: 49 4e 20 65 78 63 6c 75 64 65 64 72 65 76 69 73  IN excludedrevis
1d00: 69 6f 6e 73 3b 0a 09 20 20 20 20 44 45 4c 45 54  ions;..    DELET
1d10: 45 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 62  E FROM revisionb
1d20: 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20 57 48  ranchchildren WH
1d30: 45 52 45 20 62 72 69 64 20 49 4e 20 65 78 63 6c  ERE brid IN excl
1d40: 75 64 65 64 72 65 76 69 73 69 6f 6e 73 3b 0a 09  udedrevisions;..
1d50: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20      DELETE FROM 
1d60: 62 6c 6f 62 20 20 20 20 20 20 20 20 20 20 20 20  blob            
1d70: 20 20 20 20 20 20 20 57 48 45 52 45 20 72 69 64         WHERE rid
1d80: 20 20 49 4e 20 65 78 63 6c 75 64 65 64 72 65 76    IN excludedrev
1d90: 69 73 69 6f 6e 73 3b 0a 0a 09 20 20 20 20 44 52  isions;...    DR
1da0: 4f 50 20 54 41 42 4c 45 20 65 78 63 6c 75 64 65  OP TABLE exclude
1db0: 64 72 65 76 69 73 69 6f 6e 73 3b 0a 09 20 20 20  drevisions;..   
1dc0: 20 44 52 4f 50 20 54 41 42 4c 45 20 65 78 63 6c   DROP TABLE excl
1dd0: 75 64 65 64 73 79 6d 62 6f 6c 73 3b 0a 09 7d 0a  udedsymbols;..}.
1de0: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
1df0: 20 20 20 70 72 6f 63 20 4d 75 74 61 74 65 53 79     proc MutateSy
1e00: 6d 62 6f 6c 73 20 7b 7d 20 7b 0a 09 23 20 4e 65  mbols {} {..# Ne
1e10: 78 74 2c 20 6e 6f 77 20 74 68 61 74 20 77 65 20  xt, now that we 
1e20: 6b 6e 6f 77 20 77 68 69 63 68 20 73 79 6d 62 6f  know which symbo
1e30: 6c 73 20 61 72 65 20 77 68 61 74 20 77 65 20 6c  ls are what we l
1e40: 6f 6f 6b 20 66 6f 72 0a 09 23 20 66 69 6c 65 20  ook for..# file 
1e50: 6c 65 76 65 6c 20 74 61 67 73 20 77 68 69 63 68  level tags which
1e60: 20 61 72 65 20 61 63 74 75 61 6c 6c 79 20 63 6f   are actually co
1e70: 6e 76 65 72 74 65 64 20 61 73 20 62 72 61 6e 63  nverted as branc
1e80: 68 65 73 0a 09 23 20 28 70 72 6f 6a 65 63 74 20  hes..# (project 
1e90: 6c 65 76 65 6c 2c 20 61 6e 64 20 76 69 63 65 20  level, and vice 
1ea0: 76 65 72 73 61 29 2c 20 61 6e 64 20 6d 6f 76 65  versa), and move
1eb0: 20 74 68 65 6d 20 74 6f 20 74 68 65 0a 09 23 20   them to the..# 
1ec0: 63 6f 72 72 65 63 74 20 74 61 62 6c 65 73 2e 0a  correct tables..
1ed0: 0a 09 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
1ee0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
1ef0: 23 23 23 23 23 23 23 23 23 0a 0a 09 6c 6f 67 20  #########...log 
1f00: 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73 79  write 3 filtersy
1f10: 6d 20 22 4d 75 74 61 74 65 20 73 79 6d 62 6f 6c  m "Mutate symbol
1f20: 73 2c 20 70 72 65 70 61 72 61 74 69 6f 6e 22 0a  s, preparation".
1f30: 0a 09 73 65 74 20 62 72 61 6e 63 68 20 5b 70 72  ..set branch [pr
1f40: 6f 6a 65 63 74 3a 3a 73 79 6d 20 62 72 61 6e 63  oject::sym branc
1f50: 68 5d 0a 09 73 65 74 20 74 61 67 20 20 20 20 5b  h]..set tag    [
1f60: 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 74 61 67  project::sym tag
1f70: 5d 0a 0a 09 73 65 74 20 74 61 67 73 74 6f 6d 75  ]...set tagstomu
1f80: 74 61 74 65 20 5b 73 74 61 74 65 20 72 75 6e 20  tate [state run 
1f90: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 54 2e  {..    SELECT T.
1fa0: 74 69 64 2c 20 54 2e 66 69 64 2c 20 54 2e 6c 6f  tid, T.fid, T.lo
1fb0: 64 2c 20 54 2e 73 69 64 2c 20 54 2e 72 65 76 0a  d, T.sid, T.rev.
1fc0: 09 20 20 20 20 46 52 4f 4d 20 74 61 67 20 54 2c  .    FROM tag T,
1fd0: 20 73 79 6d 62 6f 6c 20 53 0a 09 20 20 20 20 57   symbol S..    W
1fe0: 48 45 52 45 20 54 2e 73 69 64 20 3d 20 53 2e 73  HERE T.sid = S.s
1ff0: 69 64 0a 09 20 20 20 20 41 4e 44 20 53 2e 74 79  id..    AND S.ty
2000: 70 65 20 3d 20 24 62 72 61 6e 63 68 0a 09 7d 5d  pe = $branch..}]
2010: 0a 0a 09 73 65 74 20 62 72 61 6e 63 68 65 73 74  ...set branchest
2020: 6f 6d 75 74 61 74 65 20 5b 73 74 61 74 65 20 72  omutate [state r
2030: 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  un {..    SELECT
2040: 20 42 2e 62 69 64 2c 20 42 2e 66 69 64 2c 20 42   B.bid, B.fid, B
2050: 2e 6c 6f 64 2c 20 42 2e 73 69 64 2c 20 42 2e 72  .lod, B.sid, B.r
2060: 6f 6f 74 2c 20 42 2e 66 69 72 73 74 2c 20 42 2e  oot, B.first, B.
2070: 62 72 61 0a 09 20 20 20 20 46 52 4f 4d 20 62 72  bra..    FROM br
2080: 61 6e 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20 53  anch B, symbol S
2090: 0a 09 20 20 20 20 57 48 45 52 45 20 42 2e 73 69  ..    WHERE B.si
20a0: 64 20 3d 20 53 2e 73 69 64 0a 09 20 20 20 20 41  d = S.sid..    A
20b0: 4e 44 20 53 2e 74 79 70 65 20 3d 20 24 74 61 67  ND S.type = $tag
20c0: 0a 09 7d 5d 0a 0a 09 73 65 74 20 6e 74 20 5b 65  ..}]...set nt [e
20d0: 78 70 72 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 74  xpr {[llength $t
20e0: 61 67 73 74 6f 6d 75 74 61 74 65 5d 2f 35 7d 5d  agstomutate]/5}]
20f0: 0a 09 73 65 74 20 6e 62 20 5b 65 78 70 72 20 7b  ..set nb [expr {
2100: 5b 6c 6c 65 6e 67 74 68 20 24 62 72 61 6e 63 68  [llength $branch
2110: 65 73 74 6f 6d 75 74 61 74 65 5d 2f 37 7d 5d 0a  estomutate]/7}].
2120: 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69  ..log write 4 fi
2130: 6c 74 65 72 73 79 6d 20 22 43 68 61 6e 67 69 6e  ltersym "Changin
2140: 67 20 5b 6e 73 70 20 24 6e 74 20 74 61 67 5d 20  g [nsp $nt tag] 
2150: 69 6e 74 6f 20 20 5b 6e 73 70 20 24 6e 74 20 62  into  [nsp $nt b
2160: 72 61 6e 63 68 20 62 72 61 6e 63 68 65 73 5d 22  ranch branches]"
2170: 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69  ..log write 4 fi
2180: 6c 74 65 72 73 79 6d 20 22 43 68 61 6e 67 69 6e  ltersym "Changin
2190: 67 20 5b 6e 73 70 20 24 6e 62 20 62 72 61 6e 63  g [nsp $nb branc
21a0: 68 20 62 72 61 6e 63 68 65 73 5d 20 69 6e 74 6f  h branches] into
21b0: 20 20 5b 6e 73 70 20 24 6e 62 20 74 61 67 5d 22    [nsp $nb tag]"
21c0: 0a 0a 09 23 20 23 20 23 23 20 23 23 23 20 23 23  ...# # ## ### ##
21d0: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
21e0: 23 23 23 23 23 23 23 23 23 23 0a 0a 09 6c 6f 67  ##########...log
21f0: 20 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73   write 3 filters
2200: 79 6d 20 22 4d 75 74 61 74 65 20 74 61 67 73 20  ym "Mutate tags 
2210: 74 6f 20 62 72 61 6e 63 68 65 73 22 0a 0a 09 66  to branches"...f
2220: 6f 72 65 61 63 68 20 7b 69 64 20 66 69 64 20 6c  oreach {id fid l
2230: 6f 64 20 73 69 64 20 72 65 76 7d 20 24 74 61 67  od sid rev} $tag
2240: 73 74 6f 6d 75 74 61 74 65 20 7b 0a 09 20 20 20  stomutate {..   
2250: 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 44   state run {...D
2260: 45 4c 45 54 45 20 46 52 4f 4d 20 74 61 67 20 57  ELETE FROM tag W
2270: 48 45 52 45 20 74 69 64 20 3d 20 24 69 64 20 3b  HERE tid = $id ;
2280: 0a 09 09 49 4e 53 45 52 54 20 49 4e 54 4f 20 62  ...INSERT INTO b
2290: 72 61 6e 63 68 20 28 62 69 64 2c 20 66 69 64 2c  ranch (bid, fid,
22a0: 20 20 6c 6f 64 2c 20 20 73 69 64 2c 20 20 72 6f    lod,  sid,  ro
22b0: 6f 74 2c 20 66 69 72 73 74 2c 20 62 72 61 2c 20  ot, first, bra, 
22c0: 70 6f 73 29 0a 09 09 56 41 4c 55 45 53 20 20 20  pos)...VALUES   
22d0: 20 20 20 20 20 20 20 20 20 20 28 24 69 64 2c 20            ($id, 
22e0: 24 66 69 64 2c 20 24 6c 6f 64 2c 20 24 73 69 64  $fid, $lod, $sid
22f0: 2c 20 24 72 65 76 2c 20 4e 55 4c 4c 2c 20 20 27  , $rev, NULL,  '
2300: 27 2c 20 20 2d 31 29 3b 0a 09 20 20 20 20 7d 0a  ',  -1);..    }.
2310: 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 33  .}...log write 3
2320: 20 66 69 6c 74 65 72 73 79 6d 20 22 4f 6b 2e 22   filtersym "Ok."
2330: 0a 0a 09 23 20 23 20 23 23 20 23 23 23 20 23 23  ...# # ## ### ##
2340: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
2350: 23 23 23 23 23 23 23 23 23 23 0a 0a 09 6c 6f 67  ##########...log
2360: 20 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73   write 3 filters
2370: 79 6d 20 22 4d 75 74 61 74 65 20 62 72 61 6e 63  ym "Mutate branc
2380: 68 65 73 20 74 6f 20 74 61 67 73 22 0a 0a 09 66  hes to tags"...f
2390: 6f 72 65 61 63 68 20 7b 69 64 20 66 69 64 20 6c  oreach {id fid l
23a0: 6f 64 20 73 69 64 20 72 6f 6f 74 20 66 69 72 73  od sid root firs
23b0: 74 20 62 72 61 7d 20 24 62 72 61 6e 63 68 65 73  t bra} $branches
23c0: 74 6f 6d 75 74 61 74 65 20 7b 0a 09 20 20 20 20  tomutate {..    
23d0: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 44 45  state run {...DE
23e0: 4c 45 54 45 20 46 52 4f 4d 20 62 72 61 6e 63 68  LETE FROM branch
23f0: 20 57 48 45 52 45 20 62 69 64 20 3d 20 24 69 64   WHERE bid = $id
2400: 20 3b 0a 09 09 49 4e 53 45 52 54 20 49 4e 54 4f   ;...INSERT INTO
2410: 20 74 61 67 20 28 74 69 64 2c 20 66 69 64 2c 20   tag (tid, fid, 
2420: 20 6c 6f 64 2c 20 20 73 69 64 2c 20 20 72 65 76   lod,  sid,  rev
2430: 29 0a 09 09 56 41 4c 55 45 53 20 20 20 20 20 20  )...VALUES      
2440: 20 20 20 20 28 24 69 64 2c 20 24 66 69 64 2c 20      ($id, $fid, 
2450: 24 6c 6f 64 2c 20 24 73 69 64 2c 20 24 72 6f 6f  $lod, $sid, $roo
2460: 74 29 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09  t);..    }..}...
2470: 6c 6f 67 20 77 72 69 74 65 20 33 20 66 69 6c 74  log write 3 filt
2480: 65 72 73 79 6d 20 22 4f 6b 2e 22 0a 0a 09 23 20  ersym "Ok."...# 
2490: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
24a0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
24b0: 23 23 23 23 23 0a 09 72 65 74 75 72 6e 0a 20 20  #####..return.  
24c0: 20 20 7d 0a 0a 20 20 20 20 23 20 41 64 6a 75 73    }..    # Adjus
24d0: 74 20 74 68 65 20 70 61 72 65 6e 74 73 20 6f 66  t the parents of
24e0: 20 73 79 6d 62 6f 6c 73 20 74 6f 20 74 68 65 69   symbols to thei
24f0: 72 20 70 72 65 66 65 72 72 65 64 20 70 61 72 65  r preferred pare
2500: 6e 74 73 2e 0a 0a 20 20 20 20 23 20 49 66 20 61  nts...    # If a
2510: 20 66 69 6c 65 20 6c 65 76 65 6c 20 79 6d 62 6f   file level ymbo
2520: 6c 20 68 61 73 20 61 20 70 72 65 66 65 72 72 65  l has a preferre
2530: 64 20 70 61 72 65 6e 74 20 74 68 61 74 20 69 73  d parent that is
2540: 20 64 69 66 66 65 72 65 6e 74 0a 20 20 20 20 23   different.    #
2550: 20 74 68 61 6e 20 69 74 73 20 63 75 72 72 65 6e   than its curren
2560: 74 20 70 61 72 65 6e 74 2c 20 61 6e 64 20 69 66  t parent, and if
2570: 20 74 68 65 20 70 72 65 66 65 72 72 65 64 20 70   the preferred p
2580: 61 72 65 6e 74 20 69 73 20 61 6e 0a 20 20 20 20  arent is an.    
2590: 23 20 61 6c 6c 6f 77 65 64 20 70 61 72 65 6e 74  # allowed parent
25a0: 20 6f 66 20 74 68 65 20 73 79 6d 62 6f 6c 20 69   of the symbol i
25b0: 6e 20 74 68 69 73 20 66 69 6c 65 2c 20 74 68 65  n this file, the
25c0: 6e 20 77 65 20 67 72 61 66 74 20 74 68 65 0a 20  n we graft the. 
25d0: 20 20 20 23 20 61 53 79 6d 62 6f 6c 20 6f 6e 74     # aSymbol ont
25e0: 6f 20 69 74 73 20 70 72 65 66 65 72 72 65 64 20  o its preferred 
25f0: 70 61 72 65 6e 74 2e 0a 0a 20 20 20 20 70 72 6f  parent...    pro
2600: 63 20 41 64 6a 75 73 74 50 61 72 65 6e 74 73 20  c AdjustParents 
2610: 7b 7d 20 7b 0a 09 6c 6f 67 20 77 72 69 74 65 20  {} {..log write 
2620: 33 20 66 69 6c 74 65 72 73 79 6d 20 22 41 64 6a  3 filtersym "Adj
2630: 75 73 74 20 70 61 72 65 6e 74 73 2c 20 6c 6f 61  ust parents, loa
2640: 64 69 6e 67 20 64 61 74 61 20 69 6e 20 70 72 65  ding data in pre
2650: 70 61 72 61 74 69 6f 6e 22 0a 0a 09 23 20 57 65  paration"...# We
2660: 20 70 75 6c 6c 20 69 6d 70 6f 72 74 61 6e 74 20   pull important 
2670: 6d 61 70 73 20 6f 6e 63 65 20 69 6e 74 6f 20 6d  maps once into m
2680: 65 6d 6f 72 79 20 73 6f 20 74 68 61 74 20 77 65  emory so that we
2690: 20 64 6f 20 71 75 69 63 6b 0a 09 23 20 68 61 73   do quick..# has
26a0: 68 20 6c 6f 6f 6b 75 70 20 6c 61 74 65 72 20 77  h lookup later w
26b0: 68 65 6e 20 70 72 6f 63 65 73 73 69 6e 67 20 74  hen processing t
26c0: 68 65 20 67 72 61 66 74 20 63 61 6e 64 69 64 61  he graft candida
26d0: 74 65 73 2e 0a 0a 09 23 20 54 61 67 2f 42 72 61  tes....# Tag/Bra
26e0: 6e 63 68 20 6e 61 6d 65 73 20 2e 2e 2e 0a 09 61  nch names .....a
26f0: 72 72 61 79 20 73 65 74 20 73 6e 20 5b 73 74 61  rray set sn [sta
2700: 74 65 20 72 75 6e 20 7b 20 53 45 4c 45 43 54 20  te run { SELECT 
2710: 54 2e 74 69 64 2c 20 53 2e 6e 61 6d 65 20 46 52  T.tid, S.name FR
2720: 4f 4d 20 74 61 67 20 54 2c 20 20 20 20 73 79 6d  OM tag T,    sym
2730: 62 6f 6c 20 53 20 57 48 45 52 45 20 54 2e 73 69  bol S WHERE T.si
2740: 64 20 3d 20 53 2e 73 69 64 20 7d 5d 0a 09 61 72  d = S.sid }]..ar
2750: 72 61 79 20 73 65 74 20 73 6e 20 5b 73 74 61 74  ray set sn [stat
2760: 65 20 72 75 6e 20 7b 20 53 45 4c 45 43 54 20 42  e run { SELECT B
2770: 2e 62 69 64 2c 20 53 2e 6e 61 6d 65 20 46 52 4f  .bid, S.name FRO
2780: 4d 20 62 72 61 6e 63 68 20 42 2c 20 73 79 6d 62  M branch B, symb
2790: 6f 6c 20 53 20 57 48 45 52 45 20 42 2e 73 69 64  ol S WHERE B.sid
27a0: 20 3d 20 53 2e 73 69 64 20 7d 5d 0a 09 23 20 53   = S.sid }]..# S
27b0: 79 6d 62 6f 6c 20 6e 61 6d 65 73 20 2e 2e 2e 0a  ymbol names ....
27c0: 09 61 72 72 61 79 20 73 65 74 20 73 78 20 5b 73  .array set sx [s
27d0: 74 61 74 65 20 72 75 6e 20 7b 20 53 45 4c 45 43  tate run { SELEC
27e0: 54 20 4c 2e 73 69 64 2c 20 4c 2e 6e 61 6d 65 20  T L.sid, L.name 
27f0: 46 52 4f 4d 20 73 79 6d 62 6f 6c 20 4c 20 7d 5d  FROM symbol L }]
2800: 0a 09 23 20 46 69 6c 65 73 20 61 6e 64 20 70 72  ..# Files and pr
2810: 6f 6a 65 63 74 73 2e 0a 09 61 72 72 61 79 20 73  ojects...array s
2820: 65 74 20 66 70 6e 20 7b 7d 0a 09 66 6f 72 65 61  et fpn {}..forea
2830: 63 68 20 7b 69 64 20 66 6e 20 70 6e 7d 20 5b 73  ch {id fn pn} [s
2840: 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c  tate run {...SEL
2850: 45 43 54 20 46 2e 66 69 64 2c 20 46 2e 6e 61 6d  ECT F.fid, F.nam
2860: 65 2c 20 50 2e 6e 61 6d 65 0a 09 09 46 52 4f 4d  e, P.name...FROM
2870: 20 20 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65     file F, proje
2880: 63 74 20 50 0a 09 09 57 48 45 52 45 20 20 46 2e  ct P...WHERE  F.
2890: 70 69 64 20 3d 20 50 2e 70 69 64 0a 09 7d 5d 20  pid = P.pid..}] 
28a0: 7b 20 73 65 74 20 66 70 6e 28 24 69 64 29 20 5b  { set fpn($id) [
28b0: 6c 69 73 74 20 24 66 6e 20 24 70 6e 5d 20 7d 0a  list $fn $pn] }.
28c0: 0a 09 73 65 74 20 74 61 67 73 74 6f 61 64 6a 75  ..set tagstoadju
28d0: 73 74 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a  st [state run {.
28e0: 09 20 20 20 20 53 45 4c 45 43 54 20 54 2e 74 69  .    SELECT T.ti
28f0: 64 2c 20 54 2e 66 69 64 2c 20 54 2e 6c 6f 64 2c  d, T.fid, T.lod,
2900: 20 50 2e 70 69 64 2c 20 53 2e 6e 61 6d 65 2c 20   P.pid, S.name, 
2910: 52 2e 72 65 76 2c 20 52 2e 72 69 64 0a 09 20 20  R.rev, R.rid..  
2920: 20 20 46 52 4f 4d 20 74 61 67 20 54 2c 20 70 72    FROM tag T, pr
2930: 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20  eferedparent P, 
2940: 73 79 6d 62 6f 6c 20 53 2c 20 72 65 76 69 73 69  symbol S, revisi
2950: 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20  on R..    WHERE 
2960: 54 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20  T.sid = P.sid   
2970: 20 20 20 20 20 2d 2d 20 46 6f 72 20 61 6c 6c 20       -- For all 
2980: 74 61 67 73 2c 20 67 65 74 20 6c 65 66 74 2d 68  tags, get left-h
2990: 61 6e 64 20 6f 66 20 70 72 65 66 65 72 65 64 20  and of prefered 
29a0: 70 61 72 65 6e 74 20 76 69 61 20 73 79 6d 62 6f  parent via symbo
29b0: 6c 0a 09 20 20 20 20 41 4e 44 20 20 20 54 2e 6c  l..    AND   T.l
29c0: 6f 64 20 21 3d 20 50 2e 70 69 64 20 20 20 20 20  od != P.pid     
29d0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
29e0: 20 74 61 67 73 20 77 68 6f 73 65 20 4c 4f 44 20   tags whose LOD 
29f0: 69 73 20 6e 6f 74 20 74 68 65 69 72 20 70 72 65  is not their pre
2a00: 66 65 72 65 64 20 70 61 72 65 6e 74 0a 09 20 20  fered parent..  
2a10: 20 20 41 4e 44 20 20 20 50 2e 70 69 64 20 3d 20    AND   P.pid = 
2a20: 53 2e 73 69 64 20 20 20 20 20 20 20 20 2d 2d 20  S.sid        -- 
2a30: 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 70 72  Get symbol of pr
2a40: 65 66 65 72 65 64 20 70 61 72 65 6e 74 0a 09 20  efered parent.. 
2a50: 20 20 20 41 4e 44 20 20 20 53 2e 6e 61 6d 65 20     AND   S.name 
2a60: 21 3d 20 27 3a 74 72 75 6e 6b 3a 27 20 20 2d 2d  != ':trunk:'  --
2a70: 20 45 78 63 6c 75 64 65 20 74 72 75 6e 6b 20 70   Exclude trunk p
2a80: 61 72 65 6e 74 61 67 65 0a 09 20 20 20 20 41 4e  arentage..    AN
2a90: 44 20 20 20 54 2e 72 65 76 20 3d 20 52 2e 72 69  D   T.rev = R.ri
2aa0: 64 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20  d        -- Get 
2ab0: 72 65 76 69 73 69 6f 6e 20 74 68 65 20 74 61 67  revision the tag
2ac0: 20 69 73 20 61 74 74 61 63 68 65 64 20 74 6f 2e   is attached to.
2ad0: 0a 09 7d 5d 0a 0a 09 73 65 74 20 62 72 61 6e 63  ..}]...set branc
2ae0: 68 65 73 74 6f 61 64 6a 75 73 74 20 5b 73 74 61  hestoadjust [sta
2af0: 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45  te run {..    SE
2b00: 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 2e 66 69  LECT B.bid, B.fi
2b10: 64 2c 20 42 2e 6c 6f 64 2c 20 42 2e 70 6f 73 2c  d, B.lod, B.pos,
2b20: 20 50 2e 70 69 64 2c 20 53 2e 6e 61 6d 65 2c 20   P.pid, S.name, 
2b30: 4e 55 4c 4c 2c 20 4e 55 4c 4c 0a 09 20 20 20 20  NULL, NULL..    
2b40: 46 52 4f 4d 20 62 72 61 6e 63 68 20 42 2c 20 70  FROM branch B, p
2b50: 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c  referedparent P,
2b60: 20 73 79 6d 62 6f 6c 20 53 0a 09 20 20 20 20 57   symbol S..    W
2b70: 48 45 52 45 20 42 2e 73 69 64 20 3d 20 50 2e 73  HERE B.sid = P.s
2b80: 69 64 20 20 20 20 20 20 20 20 2d 2d 20 46 6f 72  id        -- For
2b90: 20 61 6c 6c 20 62 72 61 6e 63 68 65 73 2c 20 67   all branches, g
2ba0: 65 74 20 6c 65 66 74 2d 68 61 6e 64 20 6f 66 20  et left-hand of 
2bb0: 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20  prefered parent 
2bc0: 76 69 61 20 73 79 6d 62 6f 6c 0a 09 20 20 20 20  via symbol..    
2bd0: 41 4e 44 20 20 20 42 2e 6c 6f 64 20 21 3d 20 50  AND   B.lod != P
2be0: 2e 70 69 64 20 20 20 20 20 20 20 2d 2d 20 52 65  .pid       -- Re
2bf0: 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68  strict to branch
2c00: 65 73 20 77 68 6f 73 65 20 4c 4f 44 20 69 73 20  es whose LOD is 
2c10: 6e 6f 74 20 74 68 65 69 72 20 70 72 65 66 65 72  not their prefer
2c20: 65 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41  ed parent..    A
2c30: 4e 44 20 20 20 50 2e 70 69 64 20 3d 20 53 2e 73  ND   P.pid = S.s
2c40: 69 64 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74  id        -- Get
2c50: 20 73 79 6d 62 6f 6c 20 6f 66 20 70 72 65 66 65   symbol of prefe
2c60: 72 65 64 20 70 61 72 65 6e 74 0a 09 20 20 20 20  red parent..    
2c70: 41 4e 44 20 20 20 53 2e 6e 61 6d 65 20 21 3d 20  AND   S.name != 
2c80: 27 3a 74 72 75 6e 6b 3a 27 20 20 2d 2d 20 45 78  ':trunk:'  -- Ex
2c90: 63 6c 75 64 65 20 74 72 75 6e 6b 20 70 61 72 65  clude trunk pare
2ca0: 6e 74 61 67 65 0a 09 20 20 20 20 41 4e 44 20 20  ntage..    AND  
2cb0: 20 42 2e 72 6f 6f 74 20 49 53 20 4e 55 4c 4c 20   B.root IS NULL 
2cc0: 20 20 20 20 20 20 2d 2d 20 41 63 63 65 70 74 20        -- Accept 
2cd0: 66 72 65 65 2d 66 6c 6f 61 74 69 6e 67 20 62 72  free-floating br
2ce0: 61 6e 63 68 0a 20 20 20 20 55 4e 49 4f 4e 0a 09  anch.    UNION..
2cf0: 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64      SELECT B.bid
2d00: 2c 20 42 2e 66 69 64 2c 20 42 2e 6c 6f 64 2c 20  , B.fid, B.lod, 
2d10: 42 2e 70 6f 73 2c 20 50 2e 70 69 64 2c 20 53 2e  B.pos, P.pid, S.
2d20: 6e 61 6d 65 2c 20 52 2e 72 65 76 2c 20 52 2e 72  name, R.rev, R.r
2d30: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 62 72 61  id..    FROM bra
2d40: 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 70  nch B, preferedp
2d50: 61 72 65 6e 74 20 50 2c 20 73 79 6d 62 6f 6c 20  arent P, symbol 
2d60: 53 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20  S, revision R.. 
2d70: 20 20 20 57 48 45 52 45 20 42 2e 73 69 64 20 3d     WHERE B.sid =
2d80: 20 50 2e 73 69 64 20 20 20 20 20 20 20 20 2d 2d   P.sid        --
2d90: 20 46 6f 72 20 61 6c 6c 20 62 72 61 6e 63 68 65   For all branche
2da0: 73 2c 20 67 65 74 20 6c 65 66 74 2d 68 61 6e 64  s, get left-hand
2db0: 20 6f 66 20 70 72 65 66 65 72 65 64 20 70 61 72   of prefered par
2dc0: 65 6e 74 20 76 69 61 20 73 79 6d 62 6f 6c 0a 09  ent via symbol..
2dd0: 20 20 20 20 41 4e 44 20 20 20 42 2e 6c 6f 64 20      AND   B.lod 
2de0: 21 3d 20 50 2e 70 69 64 20 20 20 20 20 20 20 2d  != P.pid       -
2df0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72  - Restrict to br
2e00: 61 6e 63 68 65 73 20 77 68 6f 73 65 20 4c 4f 44  anches whose LOD
2e10: 20 69 73 20 6e 6f 74 20 74 68 65 69 72 20 70 72   is not their pr
2e20: 65 66 65 72 65 64 20 70 61 72 65 6e 74 0a 09 20  efered parent.. 
2e30: 20 20 20 41 4e 44 20 20 20 50 2e 70 69 64 20 3d     AND   P.pid =
2e40: 20 53 2e 73 69 64 09 20 20 20 20 20 20 20 2d 2d   S.sid.       --
2e50: 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 70   Get symbol of p
2e60: 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 0a 09  refered parent..
2e70: 20 20 20 20 41 4e 44 20 20 20 53 2e 6e 61 6d 65      AND   S.name
2e80: 20 21 3d 20 27 3a 74 72 75 6e 6b 3a 27 20 20 2d   != ':trunk:'  -
2e90: 2d 20 45 78 63 6c 75 64 65 20 74 72 75 6e 6b 20  - Exclude trunk 
2ea0: 70 61 72 65 6e 74 61 67 65 0a 09 20 20 20 20 41  parentage..    A
2eb0: 4e 44 20 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e  ND   B.root = R.
2ec0: 72 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74  rid       -- Get
2ed0: 20 72 6f 6f 74 20 72 65 76 69 73 69 6f 6e 20 6f   root revision o
2ee0: 66 20 74 68 65 20 62 72 61 6e 63 68 0a 09 7d 5d  f the branch..}]
2ef0: 0a 0a 09 73 65 74 20 74 6d 61 78 20 5b 65 78 70  ...set tmax [exp
2f00: 72 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 74 61 67  r {[llength $tag
2f10: 73 74 6f 61 64 6a 75 73 74 5d 20 2f 20 37 7d 5d  stoadjust] / 7}]
2f20: 0a 09 73 65 74 20 62 6d 61 78 20 5b 65 78 70 72  ..set bmax [expr
2f30: 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 62 72 61 6e   {[llength $bran
2f40: 63 68 65 73 74 6f 61 64 6a 75 73 74 5d 20 2f 20  chestoadjust] / 
2f50: 38 7d 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  8}]...log write 
2f60: 34 20 66 69 6c 74 65 72 73 79 6d 20 22 52 65 70  4 filtersym "Rep
2f70: 61 72 65 6e 74 69 6e 67 20 61 74 20 6d 6f 73 74  arenting at most
2f80: 20 5b 6e 73 70 20 24 74 6d 61 78 20 74 61 67 5d   [nsp $tmax tag]
2f90: 22 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 66  "..log write 4 f
2fa0: 69 6c 74 65 72 73 79 6d 20 22 52 65 70 61 72 65  iltersym "Repare
2fb0: 6e 74 69 6e 67 20 61 74 20 6d 6f 73 74 20 5b 6e  nting at most [n
2fc0: 73 70 20 24 62 6d 61 78 20 62 72 61 6e 63 68 20  sp $bmax branch 
2fd0: 62 72 61 6e 63 68 65 73 5d 22 0a 0a 09 6c 6f 67  branches]"...log
2fe0: 20 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73   write 3 filters
2ff0: 79 6d 20 22 41 64 6a 75 73 74 20 74 61 67 20 70  ym "Adjust tag p
3000: 61 72 65 6e 74 73 22 0a 0a 09 23 20 46 69 6e 64  arents"...# Find
3010: 20 74 68 65 20 74 61 67 73 20 77 68 6f 73 65 20   the tags whose 
3020: 63 75 72 72 65 6e 74 20 70 61 72 65 6e 74 20 28  current parent (
3030: 6c 6f 64 29 20 69 73 20 6e 6f 74 20 74 68 65 20  lod) is not the 
3040: 70 72 65 66 65 72 65 64 0a 09 23 20 70 61 72 65  prefered..# pare
3050: 6e 74 2c 20 74 68 65 20 70 72 65 66 65 72 65 64  nt, the prefered
3060: 20 70 61 72 65 6e 74 20 69 73 20 6e 6f 74 20 74   parent is not t
3070: 68 65 20 74 72 75 6e 6b 2c 20 61 6e 64 20 74 68  he trunk, and th
3080: 65 0a 09 23 20 70 72 65 66 65 72 65 64 20 70 61  e..# prefered pa
3090: 72 65 6e 74 20 69 73 20 61 20 70 6f 73 73 69 62  rent is a possib
30a0: 6c 65 20 70 61 72 65 6e 74 20 70 65 72 20 74 68  le parent per th
30b0: 65 20 74 61 67 27 73 20 72 65 76 69 73 69 6f 6e  e tag's revision
30c0: 2e 0a 0a 09 73 65 74 20 66 6d 74 20 25 5b 73 74  ....set fmt %[st
30d0: 72 69 6e 67 20 6c 65 6e 67 74 68 20 24 74 6d 61  ring length $tma
30e0: 78 5d 73 0a 09 73 65 74 20 6d 78 73 20 5b 66 6f  x]s..set mxs [fo
30f0: 72 6d 61 74 20 24 66 6d 74 20 24 74 6d 61 78 5d  rmat $fmt $tmax]
3100: 0a 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 65  ...set n 0..fore
3110: 61 63 68 20 7b 69 64 20 66 69 64 20 6c 6f 64 20  ach {id fid lod 
3120: 70 69 64 20 70 72 65 66 65 72 65 64 6e 61 6d 65  pid preferedname
3130: 20 72 65 76 6e 72 20 72 69 64 7d 20 24 74 61 67   revnr rid} $tag
3140: 73 74 6f 61 64 6a 75 73 74 20 7b 0a 09 20 20 20  stoadjust {..   
3150: 20 23 20 42 4f 54 54 4c 45 2d 4e 45 43 4b 20 2e   # BOTTLE-NECK .
3160: 2e 2e 0a 09 20 20 20 20 23 0a 09 20 20 20 20 23  ....    #..    #
3170: 20 54 68 65 20 63 68 65 63 6b 20 69 66 20 74 68   The check if th
3180: 65 20 63 61 6e 64 69 64 61 74 65 20 28 70 69 64  e candidate (pid
3190: 29 20 69 73 20 74 72 75 6c 79 20 76 69 61 62 6c  ) is truly viabl
31a0: 65 20 69 73 0a 09 20 20 20 20 23 20 62 61 73 65  e is..    # base
31b0: 64 20 6f 6e 20 66 69 6e 64 69 6e 67 20 74 68 65  d on finding the
31c0: 20 62 72 61 6e 63 68 20 61 73 20 70 6f 73 73 69   branch as possi
31d0: 62 6c 65 20 70 61 72 65 6e 74 2c 20 61 6e 64 20  ble parent, and 
31e0: 64 6f 6e 65 0a 09 20 20 20 20 23 20 6e 6f 77 20  done..    # now 
31f0: 69 6e 73 74 65 61 64 20 6f 66 20 61 73 20 70 61  instead of as pa
3200: 72 74 20 6f 66 20 74 68 65 20 61 6c 72 65 61 64  rt of the alread
3210: 79 20 63 6f 6d 70 6c 65 78 20 6a 6f 69 6e 2e 0a  y complex join..
3220: 09 20 20 20 20 23 0a 09 20 20 20 20 23 20 2e 2e  .    #..    # ..
3230: 2e 20 41 4e 44 20 50 2e 70 69 64 20 49 4e 20 28  . AND P.pid IN (
3240: 53 45 4c 45 43 54 20 42 2e 73 69 64 0a 09 20 20  SELECT B.sid..  
3250: 20 20 23 20 20 20 20 20 20 20 20 20 20 20 20 20    #             
3260: 20 20 20 20 20 20 46 52 4f 4d 20 62 72 61 6e 63        FROM branc
3270: 68 20 42 0a 09 20 20 20 20 23 20 20 20 20 20 20  h B..    #      
3280: 20 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45               WHE
3290: 52 45 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69  RE B.root = R.ri
32a0: 64 29 0a 0a 09 20 20 20 20 69 66 20 7b 21 5b 73  d)...    if {![s
32b0: 74 61 74 65 20 6f 6e 65 20 7b 0a 09 09 53 45 4c  tate one {...SEL
32c0: 45 43 54 20 43 4f 55 4e 54 28 2a 29 20 20 20 20  ECT COUNT(*)    
32d0: 20 20 20 2d 2d 20 43 6f 75 6e 74 20 3c 3d 3e 20     -- Count <=> 
32e0: 43 68 65 63 6b 20 65 78 69 73 74 65 6e 63 65 2e  Check existence.
32f0: 0a 09 09 46 52 4f 4d 20 62 72 61 6e 63 68 20 42  ...FROM branch B
3300: 0a 09 09 57 48 45 52 45 20 20 42 2e 73 69 64 20  ...WHERE  B.sid 
3310: 20 3d 20 24 70 69 64 20 20 2d 2d 20 52 65 73 74   = $pid  -- Rest
3320: 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 20 66  rict to branch f
3330: 6f 72 20 74 68 61 74 20 73 79 6d 62 6f 6c 0a 09  or that symbol..
3340: 09 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d  .AND    B.root =
3350: 20 24 72 69 64 20 20 2d 2d 20 61 74 74 61 63 68   $rid  -- attach
3360: 65 64 20 74 6f 20 74 68 61 74 20 72 65 76 69 73  ed to that revis
3370: 69 6f 6e 0a 09 20 20 20 20 7d 5d 7d 20 7b 0a 09  ion..    }]} {..
3380: 09 69 6e 63 72 20 74 6d 61 78 20 2d 31 0a 09 09  .incr tmax -1...
3390: 73 65 74 20 20 6d 78 73 20 5b 66 6f 72 6d 61 74  set  mxs [format
33a0: 20 24 66 6d 74 20 24 74 6d 61 78 5d 0a 09 09 63   $fmt $tmax]...c
33b0: 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 7d 0a 0a  ontinue..    }..
33c0: 09 20 20 20 20 23 0a 09 20 20 20 20 23 20 42 4f  .    #..    # BO
33d0: 54 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e 0a 0a 09  TTLE-NECK ......
33e0: 20 20 20 20 23 20 54 68 65 20 6e 61 6d 65 73 20      # The names 
33f0: 66 6f 72 20 75 73 65 20 69 6e 20 74 68 65 20 6c  for use in the l
3400: 6f 67 20 6f 75 74 70 75 74 20 61 72 65 20 72 65  og output are re
3410: 74 72 69 65 76 65 64 0a 09 20 20 20 20 23 20 73  trieved..    # s
3420: 65 70 61 72 61 74 65 6c 79 2c 20 74 6f 20 6b 65  eparately, to ke
3430: 65 70 20 74 68 65 20 6a 6f 69 6e 20 73 65 6c 65  ep the join sele
3440: 63 74 69 6e 67 20 74 68 65 20 61 64 6a 75 73 74  cting the adjust
3450: 61 62 6c 65 0a 09 20 20 20 20 23 20 74 61 67 73  able..    # tags
3460: 20 73 6d 61 6c 6c 2c 20 6e 6f 74 20 62 75 72 64   small, not burd
3470: 65 6e 65 64 20 77 69 74 68 20 74 68 65 20 64 65  ened with the de
3480: 72 65 66 65 72 65 6e 63 69 6e 67 20 6f 66 20 6c  referencing of l
3490: 69 6e 6b 73 0a 09 20 20 20 20 23 20 74 6f 20 6e  inks..    # to n
34a0: 61 6d 65 2e 0a 0a 09 20 20 20 20 73 65 74 20 74  ame....    set t
34b0: 61 67 6e 61 6d 65 20 24 73 6e 28 24 69 64 29 0a  agname $sn($id).
34c0: 09 20 20 20 20 73 65 74 20 6f 6c 64 6e 61 6d 65  .    set oldname
34d0: 20 24 73 78 28 24 6c 6f 64 29 0a 09 20 20 20 20   $sx($lod)..    
34e0: 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73  struct::list ass
34f0: 69 67 6e 20 24 66 70 6e 28 24 66 69 64 29 20 66  ign $fpn($fid) f
3500: 6e 61 6d 65 20 70 72 6e 61 6d 65 0a 0a 09 20 20  name prname...  
3510: 20 20 23 20 44 6f 20 74 68 65 20 67 72 61 66 74    # Do the graft
3520: 69 6e 67 2e 0a 0a 09 20 20 20 20 6c 6f 67 20 77  ing....    log w
3530: 72 69 74 65 20 34 20 66 69 6c 74 65 72 73 79 6d  rite 4 filtersym
3540: 20 7b 5c 5b 5b 66 6f 72 6d 61 74 20 24 66 6d 74   {\[[format $fmt
3550: 20 24 6e 5d 2f 24 6d 78 73 5c 5d 20 24 70 72 6e   $n]/$mxs\] $prn
3560: 61 6d 65 20 3a 20 47 72 61 66 74 69 6e 67 20 74  ame : Grafting t
3570: 61 67 20 27 24 74 61 67 6e 61 6d 65 27 20 6f 6e  ag '$tagname' on
3580: 20 24 66 6e 61 6d 65 2f 24 72 65 76 6e 72 20 66   $fname/$revnr f
3590: 72 6f 6d 20 27 24 6f 6c 64 6e 61 6d 65 27 20 6f  rom '$oldname' o
35a0: 6e 74 6f 20 27 24 70 72 65 66 65 72 65 64 6e 61  nto '$preferedna
35b0: 6d 65 27 7d 0a 09 20 20 20 20 73 74 61 74 65 20  me'}..    state 
35c0: 72 75 6e 20 7b 20 55 50 44 41 54 45 20 74 61 67  run { UPDATE tag
35d0: 20 53 45 54 20 6c 6f 64 20 3d 20 24 70 69 64 20   SET lod = $pid 
35e0: 57 48 45 52 45 20 74 69 64 20 3d 20 24 69 64 20  WHERE tid = $id 
35f0: 7d 0a 09 20 20 20 20 69 6e 63 72 20 6e 0a 09 7d  }..    incr n..}
3600: 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 33 20 66  ...log write 3 f
3610: 69 6c 74 65 72 73 79 6d 20 22 52 65 70 61 72 65  iltersym "Repare
3620: 6e 74 65 64 20 5b 6e 73 70 20 24 6e 20 74 61 67  nted [nsp $n tag
3630: 5d 22 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 33  ]"...log write 3
3640: 20 66 69 6c 74 65 72 73 79 6d 20 22 41 64 6a 75   filtersym "Adju
3650: 73 74 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74  st branch parent
3660: 73 22 0a 0a 09 23 20 46 69 6e 64 20 74 68 65 20  s"...# Find the 
3670: 62 72 61 6e 63 68 65 73 20 77 68 6f 73 65 20 63  branches whose c
3680: 75 72 72 65 6e 74 20 70 61 72 65 6e 74 20 28 6c  urrent parent (l
3690: 6f 64 29 20 69 73 20 6e 6f 74 20 74 68 65 0a 09  od) is not the..
36a0: 23 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e  # prefered paren
36b0: 74 2c 20 74 68 65 20 70 72 65 66 65 72 65 64 20  t, the prefered 
36c0: 70 61 72 65 6e 74 20 69 73 20 6e 6f 74 20 74 68  parent is not th
36d0: 65 20 74 72 75 6e 6b 2c 20 61 6e 64 0a 09 23 20  e trunk, and..# 
36e0: 74 68 65 20 70 72 65 66 65 72 65 64 20 70 61 72  the prefered par
36f0: 65 6e 74 20 69 73 20 61 20 70 6f 73 73 69 62 6c  ent is a possibl
3700: 65 20 70 61 72 65 6e 74 20 70 65 72 20 74 68 65  e parent per the
3710: 20 62 72 61 6e 63 68 27 73 0a 09 23 20 72 65 76   branch's..# rev
3720: 69 73 69 6f 6e 2e 0a 0a 09 73 65 74 20 66 6d 74  ision....set fmt
3730: 20 25 5b 73 74 72 69 6e 67 20 6c 65 6e 67 74 68   %[string length
3740: 20 24 62 6d 61 78 5d 73 0a 09 73 65 74 20 6d 78   $bmax]s..set mx
3750: 73 20 5b 66 6f 72 6d 61 74 20 24 66 6d 74 20 24  s [format $fmt $
3760: 62 6d 61 78 5d 0a 0a 09 73 65 74 20 6e 20 30 0a  bmax]...set n 0.
3770: 09 66 6f 72 65 61 63 68 20 7b 69 64 20 66 69 64  .foreach {id fid
3780: 20 6c 6f 64 20 70 6f 73 20 70 69 64 20 70 72 65   lod pos pid pre
3790: 66 65 72 65 64 6e 61 6d 65 20 72 65 76 6e 72 20  feredname revnr 
37a0: 72 69 64 7d 20 24 62 72 61 6e 63 68 65 73 74 6f  rid} $branchesto
37b0: 61 64 6a 75 73 74 20 7b 0a 0a 09 20 20 20 20 23  adjust {...    #
37c0: 20 42 4f 54 54 4c 45 2d 4e 45 43 4b 20 2e 2e 2e   BOTTLE-NECK ...
37d0: 0a 09 20 20 20 20 23 0a 09 20 20 20 20 23 20 54  ..    #..    # T
37e0: 68 65 20 63 68 65 63 6b 20 69 66 20 74 68 65 20  he check if the 
37f0: 63 61 6e 64 69 64 61 74 65 20 28 70 69 64 29 20  candidate (pid) 
3800: 69 73 20 74 72 75 6c 79 20 76 69 61 62 6c 65 20  is truly viable 
3810: 69 73 0a 09 20 20 20 20 23 20 62 61 73 65 64 20  is..    # based 
3820: 6f 6e 20 74 68 65 20 62 72 61 6e 63 68 20 70 6f  on the branch po
3830: 73 69 74 69 6f 6e 73 20 69 6e 20 74 68 65 20 73  sitions in the s
3840: 70 61 77 6e 69 6e 67 20 72 65 76 69 73 69 6f 6e  pawning revision
3850: 2c 0a 09 20 20 20 20 23 20 61 6e 64 20 64 6f 6e  ,..    # and don
3860: 65 20 6e 6f 77 20 69 6e 73 74 65 61 64 20 6f 66  e now instead of
3870: 20 61 73 20 70 61 72 74 20 6f 66 20 74 68 65 20   as part of the 
3880: 61 6c 72 65 61 64 79 20 63 6f 6d 70 6c 65 78 0a  already complex.
3890: 09 20 20 20 20 23 20 6a 6f 69 6e 2e 0a 09 20 20  .    # join...  
38a0: 20 20 23 0a 09 20 20 20 20 23 20 2e 2e 2e 20 41    #..    # ... A
38b0: 4e 44 20 50 2e 70 69 64 20 49 4e 20 28 53 45 4c  ND P.pid IN (SEL
38c0: 45 43 54 20 42 58 2e 73 69 64 0a 09 20 20 20 20  ECT BX.sid..    
38d0: 23 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  #               
38e0: 20 20 20 20 46 52 4f 4d 20 62 72 61 6e 63 68 20      FROM branch 
38f0: 42 58 0a 09 20 20 20 20 23 20 20 20 20 20 20 20  BX..    #       
3900: 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45 52              WHER
3910: 45 20 42 58 2e 72 6f 6f 74 20 3d 20 52 2e 72 69  E BX.root = R.ri
3920: 64 0a 09 20 20 20 20 23 20 20 20 20 20 20 20 20  d..    #        
3930: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
3940: 20 42 58 2e 70 6f 73 20 3e 20 42 2e 70 6f 73 29   BX.pos > B.pos)
3950: 0a 0a 09 20 20 20 20 23 20 4e 6f 74 65 3a 20 72  ...    # Note: r
3960: 69 64 20 65 71 20 22 22 20 68 65 61 72 20 6d 65  id eq "" hear me
3970: 61 6e 73 20 74 68 61 74 20 74 68 69 73 20 69 73  ans that this is
3980: 20 61 20 66 72 65 65 2d 66 6c 6f 61 74 69 6e 67   a free-floating
3990: 0a 09 20 20 20 20 23 20 62 72 61 6e 63 68 2c 20  ..    # branch, 
39a0: 77 68 6f 73 65 20 6f 72 69 67 69 6e 61 6c 20 72  whose original r
39b0: 6f 6f 74 20 77 61 73 20 72 65 6d 6f 76 65 64 20  oot was removed 
39c0: 61 73 20 61 20 75 6e 6e 65 63 65 73 73 61 72 79  as a unnecessary
39d0: 0a 09 20 20 20 20 23 20 64 65 61 64 20 72 65 76  ..    # dead rev
39e0: 69 73 69 6f 6e 20 28 53 65 65 20 27 66 69 6c 65  ision (See 'file
39f0: 3a 3a 52 65 6d 6f 76 65 49 72 72 65 6c 65 76 61  ::RemoveIrreleva
3a00: 6e 74 44 65 6c 65 74 69 6f 6e 73 27 29 2e 0a 09  ntDeletions')...
3a10: 20 20 20 20 23 20 53 75 63 68 20 61 20 62 72 61      # Such a bra
3a20: 6e 63 68 20 63 61 6e 20 62 65 20 72 65 67 72 61  nch can be regra
3a30: 66 74 65 64 20 77 69 74 68 6f 75 74 20 74 72 6f  fted without tro
3a40: 75 62 6c 65 20 61 6e 64 20 74 68 65 72 65 0a 09  uble and there..
3a50: 20 20 20 20 23 20 69 73 20 6e 6f 20 6e 65 65 64      # is no need
3a60: 20 74 6f 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 65   to look for the
3a70: 20 6e 65 77 20 70 61 72 65 6e 74 20 69 6e 20 69   new parent in i
3a80: 74 73 0a 09 20 20 20 20 23 20 6e 6f 6e 2d 65 78  ts..    # non-ex
3a90: 69 73 74 65 6e 74 20 72 6f 6f 74 2e 0a 0a 09 20  istent root.... 
3aa0: 20 20 20 69 66 20 7b 28 24 72 69 64 20 6e 65 20     if {($rid ne 
3ab0: 22 22 29 20 26 26 20 21 5b 73 74 61 74 65 20 6f  "") && ![state o
3ac0: 6e 65 20 7b 0a 09 09 53 45 4c 45 43 54 20 43 4f  ne {...SELECT CO
3ad0: 55 4e 54 28 2a 29 20 20 20 20 20 20 20 2d 2d 20  UNT(*)       -- 
3ae0: 43 6f 75 6e 74 20 3c 3d 3e 20 43 68 65 63 6b 20  Count <=> Check 
3af0: 65 78 69 73 74 65 6e 63 65 2e 0a 09 09 46 52 4f  existence....FRO
3b00: 4d 20 62 72 61 6e 63 68 20 42 0a 09 09 57 48 45  M branch B...WHE
3b10: 52 45 20 20 42 2e 73 69 64 20 20 3d 20 24 70 69  RE  B.sid  = $pi
3b20: 64 20 20 2d 2d 20 4c 6f 6f 6b 20 66 6f 72 20 62  d  -- Look for b
3b30: 72 61 6e 63 68 20 62 79 20 73 79 6d 62 6f 6c 0a  ranch by symbol.
3b40: 09 09 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20  ..AND    B.root 
3b50: 3d 20 24 72 69 64 20 20 2d 2d 20 53 70 61 77 6e  = $rid  -- Spawn
3b60: 65 64 20 62 79 20 74 68 65 20 67 69 76 65 6e 20  ed by the given 
3b70: 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20  revision...AND  
3b80: 20 20 42 2e 70 6f 73 20 20 3e 20 24 70 6f 73 20    B.pos  > $pos 
3b90: 20 2d 2d 20 41 6e 64 20 64 65 66 69 6e 65 64 20   -- And defined 
3ba0: 62 65 66 6f 72 65 20 62 72 61 6e 63 68 20 74 6f  before branch to
3bb0: 20 6d 75 74 61 74 65 0a 09 20 20 20 20 7d 5d 7d   mutate..    }]}
3bc0: 20 7b 0a 09 09 69 6e 63 72 20 62 6d 61 78 20 2d   {...incr bmax -
3bd0: 31 0a 09 09 73 65 74 20 20 6d 78 73 20 5b 66 6f  1...set  mxs [fo
3be0: 72 6d 61 74 20 24 66 6d 74 20 24 62 6d 61 78 5d  rmat $fmt $bmax]
3bf0: 0a 09 09 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20  ...continue..   
3c00: 20 7d 0a 0a 09 20 20 20 20 23 0a 09 20 20 20 20   }...    #..    
3c10: 23 20 42 4f 54 54 4c 45 2d 4e 45 43 4b 20 2e 2e  # BOTTLE-NECK ..
3c20: 2e 0a 0a 09 20 20 20 20 23 20 54 68 65 20 6e 61  ....    # The na
3c30: 6d 65 73 20 66 6f 72 20 75 73 65 20 69 6e 20 74  mes for use in t
3c40: 68 65 20 6c 6f 67 20 6f 75 74 70 75 74 20 61 72  he log output ar
3c50: 65 20 72 65 74 72 69 65 76 65 64 0a 09 20 20 20  e retrieved..   
3c60: 20 23 20 73 65 70 61 72 61 74 65 6c 79 2c 20 74   # separately, t
3c70: 6f 20 6b 65 65 70 20 74 68 65 20 6a 6f 69 6e 20  o keep the join 
3c80: 73 65 6c 65 63 74 69 6e 67 20 74 68 65 20 61 64  selecting the ad
3c90: 6a 75 73 74 61 62 6c 65 0a 09 20 20 20 20 23 20  justable..    # 
3ca0: 74 61 67 73 20 73 6d 61 6c 6c 2c 20 6e 6f 74 20  tags small, not 
3cb0: 62 75 72 64 65 6e 65 64 20 77 69 74 68 20 74 68  burdened with th
3cc0: 65 20 64 65 72 65 66 65 72 65 6e 63 69 6e 67 20  e dereferencing 
3cd0: 6f 66 20 6c 69 6e 6b 73 0a 09 20 20 20 20 23 20  of links..    # 
3ce0: 74 6f 20 6e 61 6d 65 2e 0a 0a 09 20 20 20 20 73  to name....    s
3cf0: 65 74 20 62 72 61 6e 61 6d 65 20 24 73 6e 28 24  et braname $sn($
3d00: 69 64 29 0a 09 20 20 20 20 73 65 74 20 6f 6c 64  id)..    set old
3d10: 6e 61 6d 65 20 24 73 78 28 24 6c 6f 64 29 0a 09  name $sx($lod)..
3d20: 20 20 20 20 73 74 72 75 63 74 3a 3a 6c 69 73 74      struct::list
3d30: 20 61 73 73 69 67 6e 20 24 66 70 6e 28 24 66 69   assign $fpn($fi
3d40: 64 29 20 66 6e 61 6d 65 20 70 72 6e 61 6d 65 0a  d) fname prname.
3d50: 0a 09 20 20 20 20 23 20 44 6f 20 74 68 65 20 67  ..    # Do the g
3d60: 72 61 66 74 69 6e 67 2e 0a 0a 09 20 20 20 20 6c  rafting....    l
3d70: 6f 67 20 77 72 69 74 65 20 34 20 66 69 6c 74 65  og write 4 filte
3d80: 72 73 79 6d 20 7b 5c 5b 5b 66 6f 72 6d 61 74 20  rsym {\[[format 
3d90: 24 66 6d 74 20 24 6e 5d 2f 24 6d 78 73 5c 5d 20  $fmt $n]/$mxs\] 
3da0: 24 70 72 6e 61 6d 65 20 3a 20 47 72 61 66 74 69  $prname : Grafti
3db0: 6e 67 20 62 72 61 6e 63 68 20 27 24 62 72 61 6e  ng branch '$bran
3dc0: 61 6d 65 27 20 6f 6e 20 24 66 6e 61 6d 65 2f 24  ame' on $fname/$
3dd0: 72 65 76 6e 72 20 66 72 6f 6d 20 27 24 6f 6c 64  revnr from '$old
3de0: 6e 61 6d 65 27 20 6f 6e 74 6f 20 27 24 70 72 65  name' onto '$pre
3df0: 66 65 72 65 64 6e 61 6d 65 27 7d 0a 09 20 20 20  feredname'}..   
3e00: 20 73 74 61 74 65 20 72 75 6e 20 7b 20 55 50 44   state run { UPD
3e10: 41 54 45 20 62 72 61 6e 63 68 20 53 45 54 20 6c  ATE branch SET l
3e20: 6f 64 20 3d 20 24 70 69 64 20 57 48 45 52 45 20  od = $pid WHERE 
3e30: 62 69 64 20 3d 20 24 69 64 20 7d 0a 09 20 20 20  bid = $id }..   
3e40: 20 69 6e 63 72 20 6e 0a 09 7d 0a 0a 09 6c 6f 67   incr n..}...log
3e50: 20 77 72 69 74 65 20 33 20 66 69 6c 74 65 72 73   write 3 filters
3e60: 79 6d 20 22 52 65 70 61 72 65 6e 74 65 64 20 5b  ym "Reparented [
3e70: 6e 73 70 20 24 6e 20 62 72 61 6e 63 68 20 62 72  nsp $n branch br
3e80: 61 6e 63 68 65 73 5d 22 0a 09 72 65 74 75 72 6e  anches]"..return
3e90: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63  .    }..    proc
3ea0: 20 52 65 66 69 6e 65 53 79 6d 62 6f 6c 73 20 7b   RefineSymbols {
3eb0: 7d 20 7b 0a 09 23 20 54 61 67 73 20 61 6e 64 20  } {..# Tags and 
3ec0: 62 72 61 6e 63 68 65 73 20 61 72 65 20 6d 61 72  branches are mar
3ed0: 6b 65 64 20 61 73 20 6e 6f 72 6d 61 6c 2f 6e 6f  ked as normal/no
3ee0: 6f 70 20 62 61 73 65 64 20 6f 6e 20 74 68 65 20  op based on the 
3ef0: 6f 70 0a 09 23 20 6f 66 20 74 68 65 69 72 20 72  op..# of their r
3f00: 65 76 69 73 69 6f 6e 2e 0a 0a 09 6c 6f 67 20 77  evision....log w
3f10: 72 69 74 65 20 33 20 66 69 6c 74 65 72 73 79 6d  rite 3 filtersym
3f20: 20 22 52 65 66 69 6e 65 20 73 79 6d 62 6f 6c 73   "Refine symbols
3f30: 20 28 6e 6f 2d 6f 70 20 6f 72 20 6e 6f 74 3f 29   (no-op or not?)
3f40: 22 0a 0a 09 23 20 4e 6f 74 65 3a 20 54 68 65 20  "...# Note: The 
3f50: 6e 6f 6f 70 20 69 6e 66 6f 72 6d 61 74 69 6f 6e  noop information
3f60: 20 69 73 20 6e 6f 74 20 75 73 65 64 20 61 6e 79   is not used any
3f70: 77 68 65 72 65 2e 20 43 6f 6e 73 69 64 65 72 0a  where. Consider.
3f80: 09 23 20 64 69 73 61 62 6c 69 6e 67 20 74 68 69  .# disabling thi
3f90: 73 20 63 6f 64 65 2c 20 61 6e 64 20 72 65 6d 6f  s code, and remo
3fa0: 76 69 6e 67 20 74 68 65 20 64 61 74 61 20 66 72  ving the data fr
3fb0: 6f 6d 20 74 68 65 20 73 74 61 74 65 2e 0a 0a 09  om the state....
3fc0: 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69 6c 74  log write 4 filt
3fd0: 65 72 73 79 6d 20 22 20 20 20 20 52 65 67 75 6c  ersym "    Regul
3fe0: 61 72 20 74 61 67 73 22 0a 09 73 74 61 74 65 20  ar tags"..state 
3ff0: 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45 52  run {..    INSER
4000: 54 20 49 4e 54 4f 20 6e 6f 6f 70 0a 09 20 20 20  T INTO noop..   
4010: 20 53 45 4c 45 43 54 20 54 2e 74 69 64 2c 20 30   SELECT T.tid, 0
4020: 0a 09 20 20 20 20 46 52 4f 4d 20 74 61 67 20 54  ..    FROM tag T
4030: 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20  , revision R..  
4040: 20 20 57 48 45 52 45 20 54 2e 72 65 76 20 20 3d    WHERE T.rev  =
4050: 20 52 2e 72 69 64 0a 09 20 20 20 20 41 4e 44 20   R.rid..    AND 
4060: 20 20 52 2e 6f 70 20 20 21 3d 20 30 20 2d 2d 20    R.op  != 0 -- 
4070: 30 20 3d 3d 20 6e 6f 74 68 69 6e 67 0a 09 7d 0a  0 == nothing..}.
4080: 0a 09 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69  ..log write 4 fi
4090: 6c 74 65 72 73 79 6d 20 22 20 20 20 20 4e 6f 2d  ltersym "    No-
40a0: 6f 70 20 74 61 67 73 22 0a 09 73 74 61 74 65 20  op tags"..state 
40b0: 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45 52  run {..    INSER
40c0: 54 20 49 4e 54 4f 20 6e 6f 6f 70 0a 09 20 20 20  T INTO noop..   
40d0: 20 53 45 4c 45 43 54 20 54 2e 74 69 64 2c 20 31   SELECT T.tid, 1
40e0: 0a 09 20 20 20 20 46 52 4f 4d 20 74 61 67 20 54  ..    FROM tag T
40f0: 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20  , revision R..  
4100: 20 20 57 48 45 52 45 20 54 2e 72 65 76 20 20 3d    WHERE T.rev  =
4110: 20 52 2e 72 69 64 0a 09 20 20 20 20 41 4e 44 20   R.rid..    AND 
4120: 20 20 52 2e 6f 70 20 20 20 3d 20 30 20 2d 2d 20    R.op   = 0 -- 
4130: 6e 6f 74 68 69 6e 67 0a 09 7d 0a 0a 09 6c 6f 67  nothing..}...log
4140: 20 77 72 69 74 65 20 34 20 66 69 6c 74 65 72 73   write 4 filters
4150: 79 6d 20 22 20 20 20 20 52 65 67 75 6c 61 72 20  ym "    Regular 
4160: 62 72 61 6e 63 68 65 73 22 0a 09 73 74 61 74 65  branches"..state
4170: 20 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45   run {..    INSE
4180: 52 54 20 49 4e 54 4f 20 6e 6f 6f 70 0a 09 20 20  RT INTO noop..  
4190: 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20    SELECT B.bid, 
41a0: 30 0a 09 20 20 20 20 46 52 4f 4d 20 62 72 61 6e  0..    FROM bran
41b0: 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52  ch B, revision R
41c0: 0a 09 20 20 20 20 57 48 45 52 45 20 42 2e 72 6f  ..    WHERE B.ro
41d0: 6f 74 20 3d 20 52 2e 72 69 64 0a 09 20 20 20 20  ot = R.rid..    
41e0: 41 4e 44 20 20 20 52 2e 6f 70 20 20 21 3d 20 30  AND   R.op  != 0
41f0: 20 2d 2d 20 6e 6f 74 68 69 6e 67 0a 09 7d 0a 0a   -- nothing..}..
4200: 09 6c 6f 67 20 77 72 69 74 65 20 34 20 66 69 6c  .log write 4 fil
4210: 74 65 72 73 79 6d 20 22 20 20 20 20 4e 6f 2d 6f  tersym "    No-o
4220: 70 20 62 72 61 6e 63 68 65 73 22 0a 09 73 74 61  p branches"..sta
4230: 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e  te run {..    IN
4240: 53 45 52 54 20 49 4e 54 4f 20 6e 6f 6f 70 0a 09  SERT INTO noop..
4250: 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64      SELECT B.bid
4260: 2c 20 31 0a 09 20 20 20 20 46 52 4f 4d 20 62 72  , 1..    FROM br
4270: 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e  anch B, revision
4280: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 42 2e   R..    WHERE B.
4290: 72 6f 6f 74 20 3d 20 52 2e 72 69 64 0a 09 20 20  root = R.rid..  
42a0: 20 20 41 4e 44 20 20 20 52 2e 6f 70 20 20 20 3d    AND   R.op   =
42b0: 20 30 20 2d 2d 20 6e 6f 74 68 69 6e 67 0a 09 7d   0 -- nothing..}
42c0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
42d0: 20 20 20 20 70 72 6f 63 20 6d 61 78 6c 65 6e 20      proc maxlen 
42e0: 7b 76 20 73 74 72 7d 20 7b 0a 09 75 70 76 61 72  {v str} {..upvar
42f0: 20 31 20 24 76 20 6e 0a 09 73 65 74 20 6c 20 5b   1 $v n..set l [
4300: 73 74 72 69 6e 67 20 6c 65 6e 67 74 68 20 24 73  string length $s
4310: 74 72 5d 0a 09 69 66 20 7b 24 6c 20 3c 3d 20 24  tr]..if {$l <= $
4320: 6e 7d 20 72 65 74 75 72 6e 0a 09 73 65 74 20 6e  n} return..set n
4330: 20 24 6c 0a 09 72 65 74 75 72 6e 0a 20 20 20 20   $l..return.    
4340: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 72 69 6e  }..    proc Prin
4350: 74 53 79 6d 62 6f 6c 54 72 65 65 20 7b 7d 20 7b  tSymbolTree {} {
4360: 0a 09 69 66 20 7b 21 5b 6c 6f 67 20 76 69 73 69  ..if {![log visi
4370: 62 6c 65 3f 20 39 5d 7d 20 72 65 74 75 72 6e 0a  ble? 9]} return.
4380: 0a 09 61 72 72 61 79 20 73 65 74 20 73 79 6d 20  ..array set sym 
4390: 7b 7d 0a 09 73 65 74 20 6e 20 30 0a 09 73 65 74  {}..set n 0..set
43a0: 20 74 20 30 0a 09 73 65 74 20 63 20 30 0a 0a 09   t 0..set c 0...
43b0: 66 6f 72 65 61 63 68 20 7b 73 20 73 74 79 70 65  foreach {s stype
43c0: 20 63 63 20 70 20 70 74 79 70 65 7d 20 5b 73 74   cc p ptype} [st
43d0: 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53  ate run {..    S
43e0: 45 4c 45 43 54 20 53 2e 6e 61 6d 65 2c 20 41 2e  ELECT S.name, A.
43f0: 6e 61 6d 65 2c 20 53 2e 63 6f 6d 6d 69 74 5f 63  name, S.commit_c
4400: 6f 75 6e 74 2c 20 50 2e 6e 61 6d 65 2c 20 42 2e  ount, P.name, B.
4410: 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20  name..    FROM  
4420: 20 74 61 67 20 54 2c 20 73 79 6d 62 6f 6c 20 53   tag T, symbol S
4430: 2c 20 73 79 6d 62 6f 6c 20 50 2c 20 73 79 6d 74  , symbol P, symt
4440: 79 70 65 20 41 2c 20 73 79 6d 74 79 70 65 20 42  ype A, symtype B
4450: 0a 09 20 20 20 20 57 48 45 52 45 20 20 53 2e 73  ..    WHERE  S.s
4460: 69 64 20 3d 20 54 2e 73 69 64 0a 09 20 20 20 20  id = T.sid..    
4470: 41 4e 44 20 20 20 20 50 2e 73 69 64 20 3d 20 54  AND    P.sid = T
4480: 2e 6c 6f 64 0a 09 20 20 20 20 41 4e 44 20 20 20  .lod..    AND   
4490: 20 41 2e 74 69 64 20 3d 20 53 2e 74 79 70 65 0a   A.tid = S.type.
44a0: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 74 69  .    AND    B.ti
44b0: 64 20 3d 20 50 2e 74 79 70 65 0a 09 20 20 20 20  d = P.type..    
44c0: 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43  UNION..    SELEC
44d0: 54 20 53 2e 6e 61 6d 65 2c 20 41 2e 6e 61 6d 65  T S.name, A.name
44e0: 2c 20 53 2e 63 6f 6d 6d 69 74 5f 63 6f 75 6e 74  , S.commit_count
44f0: 2c 20 50 2e 6e 61 6d 65 2c 20 42 2e 6e 61 6d 65  , P.name, B.name
4500: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61  ..    FROM   bra
4510: 6e 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20 53 2c  nch B, symbol S,
4520: 20 73 79 6d 62 6f 6c 20 50 2c 20 73 79 6d 74 79   symbol P, symty
4530: 70 65 20 41 2c 20 73 79 6d 74 79 70 65 20 42 0a  pe A, symtype B.
4540: 09 20 20 20 20 57 48 45 52 45 20 20 53 2e 73 69  .    WHERE  S.si
4550: 64 20 3d 20 42 2e 73 69 64 0a 09 20 20 20 20 41  d = B.sid..    A
4560: 4e 44 20 20 20 20 50 2e 73 69 64 20 3d 20 42 2e  ND    P.sid = B.
4570: 6c 6f 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20  lod..    AND    
4580: 41 2e 74 69 64 20 3d 20 53 2e 74 79 70 65 0a 09  A.tid = S.type..
4590: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 74 69 64      AND    B.tid
45a0: 20 3d 20 50 2e 74 79 70 65 0a 09 7d 5d 20 7b 0a   = P.type..}] {.
45b0: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 73 79 6d  .    lappend sym
45c0: 28 24 73 29 20 24 70 20 24 73 74 79 70 65 20 24  ($s) $p $stype $
45d0: 70 74 79 70 65 20 24 63 63 0a 09 20 20 20 20 6d  ptype $cc..    m
45e0: 61 78 6c 65 6e 20 6e 20 24 73 0a 09 20 20 20 20  axlen n $s..    
45f0: 6d 61 78 6c 65 6e 20 74 20 24 73 74 79 70 65 0a  maxlen t $stype.
4600: 09 20 20 20 20 6d 61 78 6c 65 6e 20 74 20 24 70  .    maxlen t $p
4610: 74 79 70 65 0a 09 20 20 20 20 6d 61 78 6c 65 6e  type..    maxlen
4620: 20 63 20 24 63 63 0a 09 7d 0a 0a 09 66 6f 72 65   c $cc..}...fore
4630: 61 63 68 20 73 20 5b 6c 73 6f 72 74 20 2d 64 69  ach s [lsort -di
4640: 63 74 20 5b 61 72 72 61 79 20 6e 61 6d 65 73 20  ct [array names 
4650: 73 79 6d 5d 5d 20 7b 0a 09 20 20 20 20 73 74 72  sym]] {..    str
4660: 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e  uct::list assign
4670: 20 24 73 79 6d 28 24 73 29 20 70 20 73 74 79 70   $sym($s) p styp
4680: 65 20 70 74 79 70 65 20 63 63 0a 0a 09 20 20 20  e ptype cc...   
4690: 20 6c 6f 67 20 77 72 69 74 65 20 39 20 66 69 6c   log write 9 fil
46a0: 74 65 72 73 79 6d 20 7b 54 72 65 65 3a 20 5b 66  tersym {Tree: [f
46b0: 6f 72 6d 61 74 20 25 2d 24 7b 74 7d 73 20 24 73  ormat %-${t}s $s
46c0: 74 79 70 65 5d 20 28 5b 66 6f 72 6d 61 74 20 25  type] ([format %
46d0: 2d 24 7b 63 7d 64 20 24 63 63 5d 29 20 5b 66 6f  -${c}d $cc]) [fo
46e0: 72 6d 61 74 20 25 2d 24 7b 6e 7d 73 20 24 73 5d  rmat %-${n}s $s]
46f0: 20 3c 2d 2d 20 5b 66 6f 72 6d 61 74 20 25 2d 24   <-- [format %-$
4700: 7b 74 7d 73 20 24 70 74 79 70 65 5d 20 24 70 7d  {t}s $ptype] $p}
4710: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ..}..return.    
4720: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23  }..    # # ## ##
4730: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
4740: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
4750: 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74     ## Configurat
4760: 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20  ion..    pragma 
4770: 2d 68 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20  -hasinstances   
4780: 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e  no ; # singleton
4790: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73  .    pragma -has
47a0: 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b  typeinfo    no ;
47b0: 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74   # no introspect
47c0: 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d  ion.    pragma -
47d0: 68 61 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e  hastypedestroy n
47e0: 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 0a  o ; # immortal..
47f0: 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23      # # ## ### #
4800: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
4810: 23 23 23 23 23 23 23 23 23 23 23 0a 7d 0a 0a 6e  ###########.}..n
4820: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a  amespace eval ::
4830: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
4840: 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 20 7b 0a  rt::cvs::pass {.
4850: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78      namespace ex
4860: 70 6f 72 74 20 66 69 6c 74 65 72 73 79 6d 0a 20  port filtersym. 
4870: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61     namespace eva
4880: 6c 20 66 69 6c 74 65 72 73 79 6d 20 7b 0a 09 6e  l filtersym {..n
4890: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
48a0: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
48b0: 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70 6f 73  port::cvs::repos
48c0: 69 74 6f 72 79 0a 09 6e 61 6d 65 73 70 61 63 65  itory..namespace
48d0: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f   import ::vc::fo
48e0: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
48f0: 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65 73 70  s::state..namesp
4900: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
4910: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
4920: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a  :cvs::integrity.
4930: 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
4940: 70 72 6f 6a 65 63 74 20 7b 0a 09 20 20 20 20 6e  project {..    n
4950: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
4960: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
4970: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65  port::cvs::proje
4980: 63 74 3a 3a 73 79 6d 0a 09 7d 0a 09 6e 61 6d 65  ct::sym..}..name
4990: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
49a0: 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63 3a 3a  c::tools::misc::
49b0: 6e 73 70 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  nsp..namespace i
49c0: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c  mport ::vc::tool
49d0: 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69  s::log..log regi
49e0: 73 74 65 72 20 66 69 6c 74 65 72 73 79 6d 0a 20  ster filtersym. 
49f0: 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23     }.}..# # ## #
4a00: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
4a10: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20  # ############# 
4a20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
4a30: 23 23 23 23 23 0a 23 23 20 52 65 61 64 79 0a 0a  #####.## Ready..
4a40: 70 61 63 6b 61 67 65 20 70 72 6f 76 69 64 65 20  package provide 
4a50: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
4a60: 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 66  rt::cvs::pass::f
4a70: 69 6c 74 65 72 73 79 6d 20 31 2e 30 0a 72 65 74  iltersym 1.0.ret
4a80: 75 72 6e 0a                                      urn.