Hex Artifact Content
Not logged in

Artifact 1e64f84c5d05c923f4eb70815334fcdc1711954b:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [59b54efab5] - Changed the encoding of the values stored in DEPC. Keep only start/end of the range, not the list of all positions in it. That caused the memory-blowup. by aku on 2008-02-24 00:14: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 52 65 76 69 73 69 6f 6e 73 20 70 65 72 20  # Revisions per 
0210: 70 72 6f 6a 65 63 74 2c 20 61 6b 61 20 43 68 61  project, aka Cha
0220: 6e 67 65 73 65 74 73 2e 20 54 68 65 73 65 20 6f  ngesets. These o
0230: 62 6a 65 63 74 73 20 61 72 65 20 66 69 72 73 74  bjects are first
0240: 20 75 73 65 64 0a 23 23 20 69 6e 20 70 61 73 73   used.## in pass
0250: 20 35 2c 20 77 68 69 63 68 20 63 72 65 61 74 65   5, which create
0260: 73 20 74 68 65 20 69 6e 69 74 69 61 6c 20 73 65  s the initial se
0270: 74 20 63 6f 76 65 72 69 6e 67 20 74 68 65 20 72  t covering the r
0280: 65 70 6f 73 69 74 6f 72 79 2e 0a 0a 23 20 23 20  epository...# # 
0290: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
02a0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
02b0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
02c0: 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 71  #########.## Req
02d0: 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61 63 6b 61  uirements..packa
02e0: 67 65 20 72 65 71 75 69 72 65 20 54 63 6c 20 38  ge require Tcl 8
02f0: 2e 34 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .4              
0300: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0310: 20 3b 20 23 20 52 65 71 75 69 72 65 64 20 72 75   ; # Required ru
0320: 6e 74 69 6d 65 2e 0a 70 61 63 6b 61 67 65 20 72  ntime..package r
0330: 65 71 75 69 72 65 20 73 6e 69 74 20 20 20 20 20  equire snit     
0340: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0350: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23               ; #
0360: 20 4f 4f 20 73 79 73 74 65 6d 2e 0a 70 61 63 6b   OO system..pack
0370: 61 67 65 20 72 65 71 75 69 72 65 20 73 74 72 75  age require stru
0380: 63 74 3a 3a 73 65 74 20 20 20 20 20 20 20 20 20  ct::set         
0390: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03a0: 20 20 3b 20 23 20 53 65 74 20 6f 70 65 72 61 74    ; # Set operat
03b0: 69 6f 6e 73 2e 0a 70 61 63 6b 61 67 65 20 72 65  ions..package re
03c0: 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a  quire vc::tools:
03d0: 3a 6d 69 73 63 20 20 20 20 20 20 20 20 20 20 20  :misc           
03e0: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20              ; # 
03f0: 54 65 78 74 20 66 6f 72 6d 61 74 74 69 6e 67 0a  Text formatting.
0400: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20  package require 
0410: 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62  vc::tools::troub
0420: 6c 65 20 20 20 20 20 20 20 20 20 20 20 20 20 20  le              
0430: 20 20 20 20 20 20 3b 20 23 20 45 72 72 6f 72 20        ; # Error 
0440: 72 65 70 6f 72 74 69 6e 67 2e 0a 70 61 63 6b 61  reporting..packa
0450: 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74  ge require vc::t
0460: 6f 6f 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20 20  ools::log       
0470: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0480: 20 3b 20 23 20 55 73 65 72 20 66 65 65 64 62 61   ; # User feedba
0490: 63 6b 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75  ck..package requ
04a0: 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  ire vc::fossil::
04b0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61  import::cvs::sta
04c0: 74 65 20 20 20 20 20 20 20 20 3b 20 23 20 53 74  te        ; # St
04d0: 61 74 65 20 73 74 6f 72 61 67 65 2e 0a 70 61 63  ate storage..pac
04e0: 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a  kage require vc:
04f0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
0500: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 20  :cvs::integrity 
0510: 20 20 20 3b 20 23 20 53 74 61 74 65 20 69 6e 74     ; # State int
0520: 65 67 72 69 74 79 20 63 68 65 63 6b 73 2e 0a 0a  egrity checks...
0530: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
0540: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
0550: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
0560: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23  #############.##
0570: 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76  ..snit::type ::v
0580: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
0590: 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a  t::cvs::project:
05a0: 3a 72 65 76 20 7b 0a 20 20 20 20 23 20 23 20 23  :rev {.    # # #
05b0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
05c0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
05d0: 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69 63  ##.    ## Public
05e0: 20 41 50 49 0a 0a 20 20 20 20 63 6f 6e 73 74 72   API..    constr
05f0: 75 63 74 6f 72 20 7b 70 72 6f 6a 65 63 74 20 63  uctor {project c
0600: 73 74 79 70 65 20 73 72 63 69 64 20 69 74 65 6d  stype srcid item
0610: 73 20 7b 74 68 65 69 64 20 7b 7d 7d 7d 20 7b 0a  s {theid {}}} {.
0620: 09 69 66 20 7b 24 74 68 65 69 64 20 6e 65 20 22  .if {$theid ne "
0630: 22 7d 20 7b 0a 09 20 20 20 20 73 65 74 20 6d 79  "} {..    set my
0640: 69 64 20 24 74 68 65 69 64 0a 09 7d 20 65 6c 73  id $theid..} els
0650: 65 20 7b 0a 09 20 20 20 20 73 65 74 20 6d 79 69  e {..    set myi
0660: 64 20 5b 69 6e 63 72 20 6d 79 63 6f 75 6e 74 65  d [incr mycounte
0670: 72 5d 0a 09 7d 0a 0a 09 69 6e 74 65 67 72 69 74  r]..}...integrit
0680: 79 20 61 73 73 65 72 74 20 7b 0a 09 20 20 20 20  y assert {..    
0690: 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 6d 79 63  [info exists myc
06a0: 73 74 79 70 65 28 24 63 73 74 79 70 65 29 5d 0a  stype($cstype)].
06b0: 09 7d 20 7b 42 61 64 20 63 68 61 6e 67 65 73 65  .} {Bad changese
06c0: 74 20 74 79 70 65 20 27 24 63 73 74 79 70 65 27  t type '$cstype'
06d0: 2e 7d 0a 0a 09 73 65 74 20 6d 79 70 72 6f 6a 65  .}...set myproje
06e0: 63 74 20 20 20 24 70 72 6f 6a 65 63 74 0a 09 73  ct   $project..s
06f0: 65 74 20 6d 79 74 79 70 65 20 20 20 20 20 20 24  et mytype      $
0700: 63 73 74 79 70 65 0a 09 73 65 74 20 6d 79 74 79  cstype..set myty
0710: 70 65 6f 62 6a 20 20 20 3a 3a 76 63 3a 3a 66 6f  peobj   ::vc::fo
0720: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
0730: 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a  s::project::rev:
0740: 3a 24 7b 63 73 74 79 70 65 7d 0a 09 73 65 74 20  :${cstype}..set 
0750: 6d 79 73 72 63 69 64 09 24 73 72 63 69 64 0a 09  mysrcid.$srcid..
0760: 73 65 74 20 6d 79 69 74 65 6d 73 20 20 20 20 20  set myitems     
0770: 24 69 74 65 6d 73 0a 09 73 65 74 20 6d 79 70 6f  $items..set mypo
0780: 73 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 43  s       {} ; # C
0790: 6f 6d 6d 69 74 20 6c 6f 63 61 74 69 6f 6e 20 69  ommit location i
07a0: 73 20 6e 6f 74 20 6b 6e 6f 77 6e 20 79 65 74 2e  s not known yet.
07b0: 0a 0a 09 23 20 4b 65 65 70 20 74 72 61 63 6b 20  ...# Keep track 
07c0: 6f 66 20 74 68 65 20 67 65 6e 65 72 61 74 65 64  of the generated
07d0: 20 63 68 61 6e 67 65 73 65 74 73 20 61 6e 64 20   changesets and 
07e0: 6f 66 20 74 68 65 20 69 6e 76 65 72 73 65 0a 09  of the inverse..
07f0: 23 20 6d 61 70 70 69 6e 67 20 66 72 6f 6d 20 69  # mapping from i
0800: 74 65 6d 73 20 74 6f 20 74 68 65 6d 2e 0a 09 6c  tems to them...l
0810: 61 70 70 65 6e 64 20 6d 79 63 68 61 6e 67 65 73  append mychanges
0820: 65 74 73 20 20 20 24 73 65 6c 66 0a 09 6c 61 70  ets   $self..lap
0830: 70 65 6e 64 20 6d 79 74 63 68 61 6e 67 65 73 65  pend mytchangese
0840: 74 73 28 24 63 73 74 79 70 65 29 20 24 73 65 6c  ts($cstype) $sel
0850: 66 0a 09 73 65 74 20 20 20 20 20 6d 79 69 64 6d  f..set     myidm
0860: 61 70 28 24 6d 79 69 64 29 20 24 73 65 6c 66 0a  ap($myid) $self.
0870: 09 66 6f 72 65 61 63 68 20 69 69 64 20 24 69 74  .foreach iid $it
0880: 65 6d 73 20 7b 20 6c 61 70 70 65 6e 64 20 6d 79  ems { lappend my
0890: 74 69 74 65 6d 73 20 5b 6c 69 73 74 20 24 63 73  titems [list $cs
08a0: 74 79 70 65 20 24 69 69 64 5d 20 7d 0a 0a 09 4d  type $iid] }...M
08b0: 61 70 49 74 65 6d 73 20 24 63 73 74 79 70 65 20  apItems $cstype 
08c0: 24 69 74 65 6d 73 0a 09 72 65 74 75 72 6e 0a 20  $items..return. 
08d0: 20 20 20 7d 0a 0a 20 20 20 20 64 65 73 74 72 75     }..    destru
08e0: 63 74 6f 72 20 7b 0a 09 23 20 54 68 65 20 6d 61  ctor {..# The ma
08f0: 69 6e 20 74 68 69 6e 67 20 69 73 20 74 6f 20 6b  in thing is to k
0900: 65 65 70 20 74 72 61 63 6b 20 6f 66 20 74 68 65  eep track of the
0910: 20 69 74 65 6d 6d 61 70 20 61 6e 64 20 72 65 6d   itemmap and rem
0920: 6f 76 65 0a 09 23 20 74 68 65 20 6f 62 6a 65 63  ove..# the objec
0930: 74 20 66 72 6f 6d 20 69 74 2e 20 54 68 65 20 6c  t from it. The l
0940: 69 73 74 73 20 6f 66 20 63 68 61 6e 67 65 73 65  ists of changese
0950: 74 73 20 28 6d 79 63 68 61 6e 67 65 73 65 74 73  ts (mychangesets
0960: 2c 0a 09 23 20 6d 79 74 63 68 61 6e 67 65 73 65  ,..# mytchangese
0970: 74 73 29 20 61 72 65 20 6e 6f 74 20 6d 61 69 6e  ts) are not main
0980: 74 61 69 6e 65 64 20 28 3d 20 72 65 64 75 63 65  tained (= reduce
0990: 64 29 2c 20 66 6f 72 20 74 68 65 0a 09 23 20 6d  d), for the..# m
09a0: 6f 6d 65 6e 74 2e 20 57 65 20 6d 61 79 20 62 65  oment. We may be
09b0: 20 61 62 6c 65 20 74 6f 20 67 65 74 20 72 69 64   able to get rid
09c0: 20 6f 66 20 74 68 69 73 20 65 6e 74 69 72 65 6c   of this entirel
09d0: 79 2c 20 61 74 20 6c 65 61 73 74 0a 09 23 20 66  y, at least..# f
09e0: 6f 72 20 28 64 65 29 63 6f 6e 73 74 72 75 63 74  or (de)construct
09f0: 69 6f 6e 20 61 6e 64 20 70 61 73 73 20 49 6e 69  ion and pass Ini
0a00: 74 43 53 65 74 73 2e 0a 0a 09 55 6e 6d 61 70 49  tCSets....UnmapI
0a10: 74 65 6d 73 20 24 6d 79 74 79 70 65 20 24 6d 79  tems $mytype $my
0a20: 69 74 65 6d 73 0a 09 72 65 74 75 72 6e 0a 20 20  items..return.  
0a30: 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20    }..    method 
0a40: 73 74 72 20 7b 7d 20 7b 0a 09 73 65 74 20 73 74  str {} {..set st
0a50: 72 20 20 20 20 22 3c 22 0a 09 73 65 74 20 64 65  r    "<"..set de
0a60: 74 61 69 6c 20 22 22 0a 09 69 66 20 7b 5b 24 6d  tail ""..if {[$m
0a70: 79 74 79 70 65 6f 62 6a 20 62 79 73 79 6d 62 6f  ytypeobj bysymbo
0a80: 6c 5d 7d 20 7b 0a 09 20 20 20 20 73 65 74 20 64  l]} {..    set d
0a90: 65 74 61 69 6c 20 22 20 27 5b 73 74 61 74 65 20  etail " '[state 
0aa0: 6f 6e 65 20 7b 0a 09 09 53 45 4c 45 43 54 20 53  one {...SELECT S
0ab0: 2e 6e 61 6d 65 0a 09 09 46 52 4f 4d 20 20 20 73  .name...FROM   s
0ac0: 79 6d 62 6f 6c 20 53 0a 09 09 57 48 45 52 45 20  ymbol S...WHERE 
0ad0: 20 53 2e 73 69 64 20 3d 20 24 6d 79 73 72 63 69   S.sid = $mysrci
0ae0: 64 0a 09 20 20 20 20 7d 5d 27 22 0a 09 7d 0a 09  d..    }]'"..}..
0af0: 61 70 70 65 6e 64 20 73 74 72 20 22 24 6d 79 74  append str "$myt
0b00: 79 70 65 20 24 7b 6d 79 69 64 7d 24 7b 64 65 74  ype ${myid}${det
0b10: 61 69 6c 7d 3e 22 0a 09 72 65 74 75 72 6e 20 24  ail}>"..return $
0b20: 73 74 72 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d  str.    }..    m
0b30: 65 74 68 6f 64 20 6c 6f 64 20 7b 7d 20 7b 0a 09  ethod lod {} {..
0b40: 72 65 74 75 72 6e 20 5b 24 6d 79 74 79 70 65 6f  return [$mytypeo
0b50: 62 6a 20 63 73 5f 6c 6f 64 20 24 6d 79 69 74 65  bj cs_lod $myite
0b60: 6d 73 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d  ms].    }..    m
0b70: 65 74 68 6f 64 20 69 64 20 20 20 20 7b 7d 20 7b  ethod id    {} {
0b80: 20 72 65 74 75 72 6e 20 24 6d 79 69 64 20 7d 0a   return $myid }.
0b90: 20 20 20 20 6d 65 74 68 6f 64 20 69 74 65 6d 73      method items
0ba0: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 24 6d 79   {} { return $my
0bb0: 74 69 74 65 6d 73 20 7d 0a 20 20 20 20 6d 65 74  titems }.    met
0bc0: 68 6f 64 20 64 61 74 61 20 20 7b 7d 20 7b 20 72  hod data  {} { r
0bd0: 65 74 75 72 6e 20 5b 6c 69 73 74 20 24 6d 79 70  eturn [list $myp
0be0: 72 6f 6a 65 63 74 20 24 6d 79 74 79 70 65 20 24  roject $mytype $
0bf0: 6d 79 73 72 63 69 64 5d 20 7d 0a 0a 20 20 20 20  mysrcid] }..    
0c00: 64 65 6c 65 67 61 74 65 20 6d 65 74 68 6f 64 20  delegate method 
0c10: 62 79 73 79 6d 62 6f 6c 20 20 20 74 6f 20 6d 79  bysymbol   to my
0c20: 74 79 70 65 6f 62 6a 0a 20 20 20 20 64 65 6c 65  typeobj.    dele
0c30: 67 61 74 65 20 6d 65 74 68 6f 64 20 62 79 72 65  gate method byre
0c40: 76 69 73 69 6f 6e 20 74 6f 20 6d 79 74 79 70 65  vision to mytype
0c50: 6f 62 6a 0a 20 20 20 20 64 65 6c 65 67 61 74 65  obj.    delegate
0c60: 20 6d 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68   method isbranch
0c70: 20 20 20 74 6f 20 6d 79 74 79 70 65 6f 62 6a 0a     to mytypeobj.
0c80: 20 20 20 20 64 65 6c 65 67 61 74 65 20 6d 65 74      delegate met
0c90: 68 6f 64 20 69 73 74 61 67 20 20 20 20 20 20 74  hod istag      t
0ca0: 6f 20 6d 79 74 79 70 65 6f 62 6a 0a 0a 20 20 20  o mytypeobj..   
0cb0: 20 6d 65 74 68 6f 64 20 73 65 74 70 6f 73 20 7b   method setpos {
0cc0: 70 7d 20 7b 20 73 65 74 20 6d 79 70 6f 73 20 24  p} { set mypos $
0cd0: 70 20 3b 20 72 65 74 75 72 6e 20 7d 0a 20 20 20  p ; return }.   
0ce0: 20 6d 65 74 68 6f 64 20 70 6f 73 20 20 20 20 7b   method pos    {
0cf0: 7d 20 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 70  }  { return $myp
0d00: 6f 73 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64  os }..    method
0d10: 20 64 65 74 65 72 6d 69 6e 65 73 75 63 63 65 73   determinesucces
0d20: 73 6f 72 73 20 7b 7d 20 7b 0a 09 23 20 50 61 73  sors {} {..# Pas
0d30: 73 20 36 20 6f 70 65 72 61 74 69 6f 6e 2e 20 43  s 6 operation. C
0d40: 6f 6d 70 75 74 65 20 70 72 6f 6a 65 63 74 2d 6c  ompute project-l
0d50: 65 76 65 6c 20 64 65 70 65 6e 64 65 6e 63 69 65  evel dependencie
0d60: 73 20 66 72 6f 6d 0a 09 23 20 74 68 65 20 66 69  s from..# the fi
0d70: 6c 65 2d 6c 65 76 65 6c 20 64 61 74 61 20 61 6e  le-level data an
0d80: 64 20 73 61 76 65 20 69 74 20 62 61 63 6b 20 74  d save it back t
0d90: 6f 20 74 68 65 20 73 74 61 74 65 2e 20 54 68 69  o the state. Thi
0da0: 73 20 6d 61 79 0a 09 23 20 62 65 20 63 61 6c 6c  s may..# be call
0db0: 65 64 20 64 75 72 69 6e 67 20 74 68 65 20 63 79  ed during the cy
0dc0: 63 6c 65 20 62 72 65 61 6b 65 72 20 70 61 73 73  cle breaker pass
0dd0: 65 73 20 61 73 20 77 65 6c 6c 2c 20 74 6f 20 61  es as well, to a
0de0: 64 6a 75 73 74 0a 09 23 20 74 68 65 20 73 75 63  djust..# the suc
0df0: 63 65 73 73 6f 72 20 69 6e 66 6f 72 6d 61 74 69  cessor informati
0e00: 6f 6e 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73  on of changesets
0e10: 20 77 68 69 63 68 20 61 72 65 20 74 68 65 0a 09   which are the..
0e20: 23 20 70 72 65 64 65 63 65 73 73 6f 72 73 20 6f  # predecessors o
0e30: 66 20 64 72 6f 70 70 65 64 20 63 68 61 6e 67 65  f dropped change
0e40: 73 65 74 73 2e 20 46 6f 72 20 74 68 65 6d 20 77  sets. For them w
0e50: 65 20 68 61 76 65 20 74 6f 0a 09 23 20 72 65 6d  e have to..# rem
0e60: 6f 76 65 20 74 68 65 69 72 20 65 78 69 73 74 69  ove their existi
0e70: 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 66  ng information f
0e80: 69 72 73 74 20 62 65 66 6f 72 65 20 69 6e 73 65  irst before inse
0e90: 72 74 69 6e 67 20 74 68 65 0a 09 23 20 6e 65 77  rting the..# new
0ea0: 20 64 61 74 61 2e 0a 09 73 74 61 74 65 20 72 75   data...state ru
0eb0: 6e 20 7b 0a 09 20 20 20 20 44 45 4c 45 54 45 20  n {..    DELETE 
0ec0: 46 52 4f 4d 20 63 73 73 75 63 63 65 73 73 6f 72  FROM cssuccessor
0ed0: 20 57 48 45 52 45 20 63 69 64 20 3d 20 24 6d 79   WHERE cid = $my
0ee0: 69 64 3b 0a 09 7d 0a 09 73 65 74 20 6c 6f 6f 70  id;..}..set loop
0ef0: 20 30 0a 09 66 6f 72 65 61 63 68 20 6e 69 64 20   0..foreach nid 
0f00: 5b 24 6d 79 74 79 70 65 6f 62 6a 20 63 73 5f 73  [$mytypeobj cs_s
0f10: 75 63 63 65 73 73 6f 72 73 20 24 6d 79 69 74 65  uccessors $myite
0f20: 6d 73 5d 20 7b 0a 09 20 20 20 20 73 74 61 74 65  ms] {..    state
0f30: 20 72 75 6e 20 7b 0a 09 09 49 4e 53 45 52 54 20   run {...INSERT 
0f40: 49 4e 54 4f 20 63 73 73 75 63 63 65 73 73 6f 72  INTO cssuccessor
0f50: 20 28 63 69 64 2c 20 20 6e 69 64 29 0a 09 09 56   (cid,  nid)...V
0f60: 41 4c 55 45 53 20 20 20 20 20 20 20 20 20 20 20  ALUES           
0f70: 20 20 20 20 20 20 20 28 24 6d 79 69 64 2c 24 6e         ($myid,$n
0f80: 69 64 29 0a 09 20 20 20 20 7d 0a 09 20 20 20 20  id)..    }..    
0f90: 69 66 20 7b 24 6e 69 64 20 3d 3d 20 24 6d 79 69  if {$nid == $myi
0fa0: 64 7d 20 7b 20 73 65 74 20 6c 6f 6f 70 20 31 20  d} { set loop 1 
0fb0: 7d 0a 09 7d 0a 09 23 20 52 65 70 6f 72 74 20 61  }..}..# Report a
0fc0: 66 74 65 72 20 74 68 65 20 63 6f 6d 70 6c 65 74  fter the complet
0fd0: 65 20 73 74 72 75 63 74 75 72 65 20 68 61 73 20  e structure has 
0fe0: 62 65 65 6e 20 73 61 76 65 64 2e 0a 09 69 66 20  been saved...if 
0ff0: 7b 24 6c 6f 6f 70 7d 20 7b 20 24 73 65 6c 66 20  {$loop} { $self 
1000: 72 65 70 6f 72 74 6c 6f 6f 70 20 7d 0a 09 72 65  reportloop }..re
1010: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
1020: 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20  # result = list 
1030: 28 63 68 61 6e 67 65 73 65 74 29 0a 20 20 20 20  (changeset).    
1040: 6d 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72  method successor
1050: 73 20 7b 7d 20 7b 0a 09 23 20 55 73 65 20 74 68  s {} {..# Use th
1060: 65 20 64 61 74 61 20 73 61 76 65 64 20 62 79 20  e data saved by 
1070: 70 61 73 73 20 36 2e 0a 09 72 65 74 75 72 6e 20  pass 6...return 
1080: 5b 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61  [struct::list ma
1090: 70 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09  p [state run {..
10a0: 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e 69 64      SELECT S.nid
10b0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 63 73 73  ..    FROM   css
10c0: 75 63 63 65 73 73 6f 72 20 53 0a 09 20 20 20 20  uccessor S..    
10d0: 57 48 45 52 45 20 20 53 2e 63 69 64 20 3d 20 24  WHERE  S.cid = $
10e0: 6d 79 69 64 0a 09 7d 5d 20 5b 6d 79 74 79 70 65  myid..}] [mytype
10f0: 6d 65 74 68 6f 64 20 6f 66 5d 5d 0a 20 20 20 20  method of]].    
1100: 7d 0a 0a 20 20 20 20 23 20 69 74 65 6d 20 2d 3e  }..    # item ->
1110: 20 6c 69 73 74 20 28 69 74 65 6d 29 0a 20 20 20   list (item).   
1120: 20 6d 65 74 68 6f 64 20 6e 65 78 74 6d 61 70 20   method nextmap 
1130: 7b 7d 20 7b 0a 09 24 6d 79 74 79 70 65 6f 62 6a  {} {..$mytypeobj
1140: 20 73 75 63 63 65 73 73 6f 72 73 20 74 6d 70 20   successors tmp 
1150: 24 6d 79 69 74 65 6d 73 0a 09 72 65 74 75 72 6e  $myitems..return
1160: 20 5b 61 72 72 61 79 20 67 65 74 20 74 6d 70 5d   [array get tmp]
1170: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68  .    }..    meth
1180: 6f 64 20 62 72 65 61 6b 69 6e 74 65 72 6e 61 6c  od breakinternal
1190: 64 65 70 65 6e 64 65 6e 63 69 65 73 20 7b 63 76  dependencies {cv
11a0: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 63 76  } {..upvar 1 $cv
11b0: 20 63 6f 75 6e 74 65 72 0a 09 6c 6f 67 20 77 72   counter..log wr
11c0: 69 74 65 20 31 34 20 63 73 65 74 73 20 7b 5b 24  ite 14 csets {[$
11d0: 73 65 6c 66 20 73 74 72 5d 20 42 49 44 7d 0a 09  self str] BID}..
11e0: 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 65 6d 3a 3a  vc::tools::mem::
11f0: 6d 61 72 6b 0a 09 23 23 0a 09 23 23 20 4e 4f 54  mark..##..## NOT
1200: 45 3a 20 54 68 69 73 20 6d 65 74 68 6f 64 2c 20  E: This method, 
1210: 6d 61 79 62 65 20 69 6e 20 63 6f 6e 6a 75 6e 63  maybe in conjunc
1220: 74 69 6f 6e 20 77 69 74 68 20 69 74 73 20 63 61  tion with its ca
1230: 6c 6c 65 72 0a 09 23 23 20 20 20 20 20 20 20 73  ller..##       s
1240: 65 65 6d 73 20 74 6f 20 62 65 20 61 20 6d 65 6d  eems to be a mem
1250: 6f 72 79 20 68 6f 67 2c 20 65 73 70 65 63 69 61  ory hog, especia
1260: 6c 6c 79 20 66 6f 72 20 6c 61 72 67 65 0a 09 23  lly for large..#
1270: 23 20 20 20 20 20 20 20 63 68 61 6e 67 65 73 65  #       changese
1280: 74 73 2c 20 77 69 74 68 20 27 6c 61 72 67 65 27  ts, with 'large'
1290: 20 6d 65 61 6e 69 6e 67 20 74 6f 20 68 61 76 65   meaning to have
12a0: 20 61 20 27 6c 6f 6e 67 20 6c 69 73 74 0a 09 23   a 'long list..#
12b0: 23 20 20 20 20 20 20 20 6f 66 20 69 74 65 6d 73  #       of items
12c0: 2c 20 73 65 76 65 72 61 6c 20 74 68 6f 75 73 61  , several thousa
12d0: 6e 64 27 2e 20 49 6e 76 65 73 74 69 67 61 74 65  nd'. Investigate
12e0: 20 77 68 65 72 65 20 74 68 65 0a 09 23 23 20 20   where the..##  
12f0: 20 20 20 20 20 6d 65 6d 6f 72 79 20 69 73 20 73       memory is s
1300: 70 65 6e 74 20 61 6e 64 20 74 68 65 6e 20 6c 6f  pent and then lo
1310: 6f 6b 20 66 6f 72 20 77 61 79 73 20 6f 66 20 72  ok for ways of r
1320: 65 63 74 69 66 79 69 6e 67 0a 09 23 23 20 20 20  ectifying..##   
1330: 20 20 20 20 74 68 65 20 70 72 6f 62 6c 65 6d 2e      the problem.
1340: 0a 09 23 23 0a 0a 09 23 20 54 68 69 73 20 6d 65  ..##...# This me
1350: 74 68 6f 64 20 69 6e 73 70 65 63 74 73 20 74 68  thod inspects th
1360: 65 20 63 68 61 6e 67 65 73 65 74 73 20 66 6f 72  e changesets for
1370: 20 69 6e 74 65 72 6e 61 6c 0a 09 23 20 64 65 70   internal..# dep
1380: 65 6e 64 65 6e 63 69 65 73 2e 20 4e 6f 74 68 69  endencies. Nothi
1390: 6e 67 20 69 73 20 64 6f 6e 65 20 69 66 20 74 68  ng is done if th
13a0: 65 72 65 20 61 72 65 20 6e 6f 0a 09 23 20 73 75  ere are no..# su
13b0: 63 68 2e 20 4f 74 68 65 72 77 69 73 65 20 74 68  ch. Otherwise th
13c0: 65 20 63 68 61 6e 67 65 73 65 74 20 69 73 20 73  e changeset is s
13d0: 70 6c 69 74 20 69 6e 74 6f 20 61 20 73 65 74 20  plit into a set 
13e0: 6f 66 0a 09 23 20 66 72 61 67 6d 65 6e 74 73 20  of..# fragments 
13f0: 77 69 74 68 6f 75 74 20 69 6e 74 65 72 6e 61 6c  without internal
1400: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 74   dependencies, t
1410: 72 61 6e 73 66 6f 72 6d 69 6e 67 20 74 68 65 0a  ransforming the.
1420: 09 23 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65  .# internal depe
1430: 6e 64 65 6e 63 69 65 73 20 69 6e 74 6f 20 65 78  ndencies into ex
1440: 74 65 72 6e 61 6c 20 6f 6e 65 73 2e 20 54 68 65  ternal ones. The
1450: 20 6e 65 77 20 63 68 61 6e 67 65 73 65 74 73 0a   new changesets.
1460: 09 23 20 67 65 6e 65 72 61 74 65 64 20 66 72 6f  .# generated fro
1470: 6d 20 74 68 65 20 66 72 61 67 6d 65 6e 74 20 69  m the fragment i
1480: 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 72 65 20 61  nformation are a
1490: 64 64 65 64 20 74 6f 20 74 68 65 0a 09 23 20 6c  dded to the..# l
14a0: 69 73 74 20 6f 66 20 61 6c 6c 20 63 68 61 6e 67  ist of all chang
14b0: 65 73 65 74 73 2e 0a 0a 09 23 20 54 68 65 20 63  esets....# The c
14c0: 6f 64 65 20 63 68 65 63 6b 73 20 6f 6e 6c 79 20  ode checks only 
14d0: 73 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e 64  successor depend
14e0: 65 6e 63 69 65 73 2c 20 61 73 20 74 68 69 73 0a  encies, as this.
14f0: 09 23 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79  .# automatically
1500: 20 63 6f 76 65 72 73 20 74 68 65 20 70 72 65 64   covers the pred
1510: 65 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e  ecessor dependen
1520: 63 69 65 73 20 61 73 20 77 65 6c 6c 20 28 41 0a  cies as well (A.
1530: 09 23 20 73 75 63 63 65 73 73 6f 72 20 64 65 70  .# successor dep
1540: 65 6e 64 65 6e 63 79 20 61 20 2d 3e 20 62 20 69  endency a -> b i
1550: 73 20 61 6c 73 6f 20 61 20 70 72 65 64 65 63 65  s also a predece
1560: 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 79 0a  ssor dependency.
1570: 09 23 20 62 20 2d 3e 20 61 29 2e 0a 0a 09 23 20  .# b -> a)....# 
1580: 41 72 72 61 79 20 6f 66 20 64 65 70 65 6e 64 65  Array of depende
1590: 6e 63 69 65 73 20 28 70 61 72 65 6e 74 20 2d 3e  ncies (parent ->
15a0: 20 63 68 69 6c 64 29 2e 20 54 68 69 73 20 69 73   child). This is
15b0: 20 70 75 6c 6c 65 64 20 66 72 6f 6d 0a 09 23 20   pulled from..# 
15c0: 74 68 65 20 73 74 61 74 65 2c 20 61 6e 64 20 6c  the state, and l
15d0: 69 6d 69 74 65 64 20 74 6f 20 73 75 63 63 65 73  imited to succes
15e0: 73 6f 72 73 20 77 69 74 68 69 6e 20 74 68 65 20  sors within the 
15f0: 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 61 72 72  changeset....arr
1600: 61 79 20 73 65 74 20 62 72 65 61 6b 73 20 7b 7d  ay set breaks {}
1610: 0a 0a 09 73 65 74 20 66 72 61 67 6d 65 6e 74 73  ...set fragments
1620: 20 5b 42 72 65 61 6b 44 69 72 65 63 74 44 65 70   [BreakDirectDep
1630: 65 6e 64 65 6e 63 69 65 73 20 24 6d 79 69 74 65  endencies $myite
1640: 6d 73 20 62 72 65 61 6b 73 5d 0a 0a 09 69 66 20  ms breaks]...if 
1650: 7b 21 5b 6c 6c 65 6e 67 74 68 20 24 66 72 61 67  {![llength $frag
1660: 6d 65 6e 74 73 5d 7d 20 7b 20 72 65 74 75 72 6e  ments]} { return
1670: 20 7b 7d 20 7d 0a 0a 09 72 65 74 75 72 6e 20 5b   {} }...return [
1680: 24 73 65 6c 66 20 43 72 65 61 74 65 46 72 6f 6d  $self CreateFrom
1690: 46 72 61 67 6d 65 6e 74 73 20 24 66 72 61 67 6d  Fragments $fragm
16a0: 65 6e 74 73 20 63 6f 75 6e 74 65 72 20 62 72 65  ents counter bre
16b0: 61 6b 73 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  aks].    }..    
16c0: 6d 65 74 68 6f 64 20 70 65 72 73 69 73 74 20 7b  method persist {
16d0: 7d 20 7b 0a 09 73 65 74 20 74 69 64 20 24 6d 79  } {..set tid $my
16e0: 63 73 74 79 70 65 28 24 6d 79 74 79 70 65 29 0a  cstype($mytype).
16f0: 09 73 65 74 20 70 69 64 20 5b 24 6d 79 70 72 6f  .set pid [$mypro
1700: 6a 65 63 74 20 69 64 5d 0a 09 73 65 74 20 70 6f  ject id]..set po
1710: 73 20 30 0a 0a 09 73 74 61 74 65 20 74 72 61 6e  s 0...state tran
1720: 73 61 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73  saction {..    s
1730: 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 49 4e 53  tate run {...INS
1740: 45 52 54 20 49 4e 54 4f 20 63 68 61 6e 67 65 73  ERT INTO changes
1750: 65 74 20 28 63 69 64 2c 20 20 20 70 69 64 2c 20  et (cid,   pid, 
1760: 20 74 79 70 65 2c 20 73 72 63 29 0a 09 09 56 41   type, src)...VA
1770: 4c 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20  LUES            
1780: 20 20 20 20 28 24 6d 79 69 64 2c 20 24 70 69 64      ($myid, $pid
1790: 2c 20 24 74 69 64 2c 20 24 6d 79 73 72 63 69 64  , $tid, $mysrcid
17a0: 29 3b 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20  );..    }...    
17b0: 66 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79 69  foreach iid $myi
17c0: 74 65 6d 73 20 7b 0a 09 09 73 74 61 74 65 20 72  tems {...state r
17d0: 75 6e 20 7b 0a 09 09 20 20 20 20 49 4e 53 45 52  un {...    INSER
17e0: 54 20 49 4e 54 4f 20 63 73 69 74 65 6d 20 28 63  T INTO csitem (c
17f0: 69 64 2c 20 20 20 70 6f 73 2c 20 20 69 69 64 29  id,   pos,  iid)
1800: 0a 09 09 20 20 20 20 56 41 4c 55 45 53 20 20 20  ...    VALUES   
1810: 20 20 20 20 20 20 20 20 20 20 28 24 6d 79 69 64            ($myid
1820: 2c 20 24 70 6f 73 2c 20 24 69 69 64 29 3b 0a 09  , $pos, $iid);..
1830: 09 7d 0a 09 09 69 6e 63 72 20 70 6f 73 0a 09 20  .}...incr pos.. 
1840: 20 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a     }..}..return.
1850: 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f      }..    metho
1860: 64 20 74 69 6d 65 72 61 6e 67 65 20 7b 7d 20 7b  d timerange {} {
1870: 20 72 65 74 75 72 6e 20 5b 24 6d 79 74 79 70 65   return [$mytype
1880: 6f 62 6a 20 74 69 6d 65 72 61 6e 67 65 20 24 6d  obj timerange $m
1890: 79 69 74 65 6d 73 5d 20 7d 0a 0a 20 20 20 20 6d  yitems] }..    m
18a0: 65 74 68 6f 64 20 6c 69 6d 69 74 73 20 7b 7d 20  ethod limits {} 
18b0: 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  {..struct::list 
18c0: 61 73 73 69 67 6e 20 5b 24 6d 79 74 79 70 65 6f  assign [$mytypeo
18d0: 62 6a 20 6c 69 6d 69 74 73 20 24 6d 79 69 74 65  bj limits $myite
18e0: 6d 73 5d 20 6d 61 78 70 20 6d 69 6e 73 0a 09 72  ms] maxp mins..r
18f0: 65 74 75 72 6e 20 5b 6c 69 73 74 20 5b 54 61 67  eturn [list [Tag
1900: 49 74 65 6d 44 69 63 74 20 24 6d 61 78 70 20 24  ItemDict $maxp $
1910: 6d 79 74 79 70 65 5d 20 5b 54 61 67 49 74 65 6d  mytype] [TagItem
1920: 44 69 63 74 20 24 6d 69 6e 73 20 24 6d 79 74 79  Dict $mins $myty
1930: 70 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  pe]].    }..    
1940: 6d 65 74 68 6f 64 20 64 72 6f 70 20 7b 7d 20 7b  method drop {} {
1950: 0a 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73  ..log write 8 cs
1960: 65 74 73 20 7b 44 72 6f 70 70 69 6e 67 20 24 73  ets {Dropping $s
1970: 65 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72  elf = [$self str
1980: 5d 7d 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73  ]}...state trans
1990: 61 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74  action {..    st
19a0: 61 74 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45  ate run {...DELE
19b0: 54 45 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65  TE FROM changese
19c0: 74 20 20 20 57 48 45 52 45 20 63 69 64 20 3d 20  t   WHERE cid = 
19d0: 24 6d 79 69 64 3b 0a 09 09 44 45 4c 45 54 45 20  $myid;...DELETE 
19e0: 46 52 4f 4d 20 63 73 69 74 65 6d 20 20 20 20 20  FROM csitem     
19f0: 20 57 48 45 52 45 20 63 69 64 20 3d 20 24 6d 79   WHERE cid = $my
1a00: 69 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f  id;...DELETE FRO
1a10: 4d 20 63 73 73 75 63 63 65 73 73 6f 72 20 57 48  M cssuccessor WH
1a20: 45 52 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b  ERE cid = $myid;
1a30: 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 55 6e 6d  ..    }..}...Unm
1a40: 61 70 49 74 65 6d 73 20 24 6d 79 74 79 70 65 20  apItems $mytype 
1a50: 24 6d 79 69 74 65 6d 73 0a 0a 09 73 65 74 20 70  $myitems...set p
1a60: 6f 73 20 20 20 20 20 20 20 20 20 20 20 20 20 20  os              
1a70: 20 20 20 20 20 20 5b 6c 73 65 61 72 63 68 20 2d        [lsearch -
1a80: 65 78 61 63 74 20 24 6d 79 63 68 61 6e 67 65 73  exact $mychanges
1a90: 65 74 73 20 24 73 65 6c 66 5d 0a 09 73 65 74 20  ets $self]..set 
1aa0: 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20 20 20  mychangesets    
1ab0: 20 20 20 20 20 20 20 5b 6c 72 65 70 6c 61 63 65         [lreplace
1ac0: 20 20 20 20 20 20 20 24 6d 79 63 68 61 6e 67 65         $mychange
1ad0: 73 65 74 73 20 24 70 6f 73 20 24 70 6f 73 5d 0a  sets $pos $pos].
1ae0: 09 73 65 74 20 70 6f 73 20 20 20 20 20 20 20 20  .set pos        
1af0: 20 20 20 20 20 20 20 20 20 20 20 20 5b 6c 73 65              [lse
1b00: 61 72 63 68 20 2d 65 78 61 63 74 20 24 6d 79 74  arch -exact $myt
1b10: 63 68 61 6e 67 65 73 65 74 73 28 24 6d 79 74 79  changesets($myty
1b20: 70 65 29 20 24 73 65 6c 66 5d 0a 09 73 65 74 20  pe) $self]..set 
1b30: 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 24 6d  mytchangesets($m
1b40: 79 74 79 70 65 29 20 5b 6c 72 65 70 6c 61 63 65  ytype) [lreplace
1b50: 20 20 20 20 20 20 20 24 6d 79 74 63 68 61 6e 67         $mytchang
1b60: 65 73 65 74 73 28 24 6d 79 74 79 70 65 29 20 24  esets($mytype) $
1b70: 70 6f 73 20 24 70 6f 73 5d 0a 0a 09 23 20 52 65  pos $pos]...# Re
1b80: 74 75 72 6e 20 74 68 65 20 6c 69 73 74 20 6f 66  turn the list of
1b90: 20 70 72 65 64 65 63 65 73 73 6f 72 73 20 73 6f   predecessors so
1ba0: 20 74 68 61 74 20 74 68 65 79 20 63 61 6e 20 62   that they can b
1bb0: 65 20 61 64 6a 75 73 74 65 64 2e 0a 09 72 65 74  e adjusted...ret
1bc0: 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69 73  urn [struct::lis
1bd0: 74 20 6d 61 70 20 5b 73 74 61 74 65 20 72 75 6e  t map [state run
1be0: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 63   {..    SELECT c
1bf0: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 63  id..    FROM   c
1c00: 73 73 75 63 63 65 73 73 6f 72 0a 09 20 20 20 20  ssuccessor..    
1c10: 57 48 45 52 45 20 20 6e 69 64 20 3d 20 24 6d 79  WHERE  nid = $my
1c20: 69 64 0a 09 7d 5d 20 5b 6d 79 74 79 70 65 6d 65  id..}] [mytypeme
1c30: 74 68 6f 64 20 6f 66 5d 5d 0a 20 20 20 20 7d 0a  thod of]].    }.
1c40: 0a 20 20 20 20 6d 65 74 68 6f 64 20 72 65 70 6f  .    method repo
1c50: 72 74 6c 6f 6f 70 20 7b 7b 6b 69 6c 6c 20 31 7d  rtloop {{kill 1}
1c60: 7d 20 7b 0a 09 23 20 57 65 20 70 72 69 6e 74 20  } {..# We print 
1c70: 74 68 65 20 69 74 65 6d 73 20 77 68 69 63 68 20  the items which 
1c80: 61 72 65 20 70 72 6f 64 75 63 69 6e 67 20 74 68  are producing th
1c90: 65 20 6c 6f 6f 70 2c 20 61 6e 64 20 68 6f 77 2e  e loop, and how.
1ca0: 0a 0a 09 73 65 74 20 68 64 72 20 22 53 65 6c 66  ...set hdr "Self
1cb0: 2d 72 65 66 65 72 65 6e 74 69 61 6c 20 63 68 61  -referential cha
1cc0: 6e 67 65 73 65 74 20 5b 24 73 65 6c 66 20 73 74  ngeset [$self st
1cd0: 72 5d 20 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f  r] _____________
1ce0: 5f 5f 5f 5f 5f 22 0a 09 73 65 74 20 66 74 72 20  _____"..set ftr 
1cf0: 5b 72 65 67 73 75 62 20 2d 61 6c 6c 20 7b 5b 5e  [regsub -all {[^
1d00: 20 09 5d 7d 20 24 68 64 72 20 7b 5f 7d 5d 0a 0a   .]} $hdr {_}]..
1d10: 09 6c 6f 67 20 77 72 69 74 65 20 30 20 63 73 65  .log write 0 cse
1d20: 74 73 20 24 68 64 72 0a 09 66 6f 72 65 61 63 68  ts $hdr..foreach
1d30: 20 7b 69 74 65 6d 20 6e 65 78 74 69 74 65 6d 7d   {item nextitem}
1d40: 20 5b 24 6d 79 74 79 70 65 6f 62 6a 20 6c 6f 6f   [$mytypeobj loo
1d50: 70 73 20 24 6d 79 69 74 65 6d 73 5d 20 7b 0a 09  ps $myitems] {..
1d60: 20 20 20 20 23 20 43 72 65 61 74 65 20 74 61 67      # Create tag
1d70: 67 65 64 20 69 74 65 6d 73 20 66 72 6f 6d 20 74  ged items from t
1d80: 68 65 20 69 64 20 61 6e 64 20 6f 75 72 20 74 79  he id and our ty
1d90: 70 65 2e 0a 09 20 20 20 20 73 65 74 20 69 74 65  pe...    set ite
1da0: 6d 20 20 20 20 20 5b 6c 69 73 74 20 24 6d 79 74  m     [list $myt
1db0: 79 70 65 20 20 24 69 74 65 6d 5d 0a 09 20 20 20  ype  $item]..   
1dc0: 20 73 65 74 20 6e 65 78 74 69 74 65 6d 20 5b 6c   set nextitem [l
1dd0: 69 73 74 20 24 6d 79 74 79 70 65 20 24 6e 65 78  ist $mytype $nex
1de0: 74 69 74 65 6d 5d 0a 09 20 20 20 20 23 20 50 72  titem]..    # Pr
1df0: 69 6e 74 61 62 6c 65 20 6c 61 62 65 6c 73 2e 0a  intable labels..
1e00: 09 20 20 20 20 73 65 74 20 69 20 20 22 3c 5b 24  .    set i  "<[$
1e10: 74 79 70 65 20 69 74 65 6d 73 74 72 20 24 69 74  type itemstr $it
1e20: 65 6d 5d 3e 22 0a 09 20 20 20 20 73 65 74 20 6e  em]>"..    set n
1e30: 20 20 22 3c 5b 24 74 79 70 65 20 69 74 65 6d 73    "<[$type items
1e40: 74 72 20 24 6e 65 78 74 69 74 65 6d 5d 3e 22 0a  tr $nextitem]>".
1e50: 09 20 20 20 20 73 65 74 20 6e 63 73 20 24 6d 79  .    set ncs $my
1e60: 69 74 65 6d 6d 61 70 28 24 6e 65 78 74 69 74 65  itemmap($nextite
1e70: 6d 29 0a 09 20 20 20 20 23 20 50 72 69 6e 74 0a  m)..    # Print.
1e80: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 30  .    log write 0
1e90: 20 63 73 65 74 73 20 7b 2a 20 24 69 20 2d 2d 3e   csets {* $i -->
1ea0: 20 24 6e 20 2d 2d 3e 20 63 73 20 5b 24 6e 63 73   $n --> cs [$ncs
1eb0: 20 73 74 72 5d 7d 0a 09 7d 0a 09 6c 6f 67 20 77   str]}..}..log w
1ec0: 72 69 74 65 20 30 20 63 73 65 74 73 20 24 66 74  rite 0 csets $ft
1ed0: 72 0a 0a 09 69 66 20 7b 21 24 6b 69 6c 6c 7d 20  r...if {!$kill} 
1ee0: 72 65 74 75 72 6e 0a 09 74 72 6f 75 62 6c 65 20  return..trouble 
1ef0: 69 6e 74 65 72 6e 61 6c 20 22 5b 24 73 65 6c 66  internal "[$self
1f00: 20 73 74 72 5d 20 64 65 70 65 6e 64 73 20 6f 6e   str] depends on
1f10: 20 69 74 73 65 6c 66 22 0a 09 72 65 74 75 72 6e   itself"..return
1f20: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68  .    }..    meth
1f30: 6f 64 20 70 75 73 68 74 6f 20 7b 72 65 70 6f 73  od pushto {repos
1f40: 69 74 6f 72 79 20 64 61 74 65 20 72 73 74 61 74  itory date rstat
1f50: 65 7d 20 7b 0a 09 23 20 47 65 6e 65 72 61 74 65  e} {..# Generate
1f60: 20 61 6e 64 20 69 6d 70 6f 72 74 20 74 68 65 20   and import the 
1f70: 6d 61 6e 69 66 65 73 74 20 66 6f 72 20 74 68 69  manifest for thi
1f80: 73 20 63 68 61 6e 67 65 73 65 74 2e 0a 09 23 0a  s changeset...#.
1f90: 09 23 20 44 61 74 61 20 6e 65 65 64 65 64 3a 0a  .# Data needed:.
1fa0: 09 23 20 2d 20 43 6f 6d 6d 69 74 20 6d 65 73 73  .# - Commit mess
1fb0: 61 67 65 20 20 20 20 20 20 20 20 20 20 20 20 20  age             
1fc0: 20 20 28 2d 2d 20 6d 79 73 72 63 69 64 20 2d 3e    (-- mysrcid ->
1fd0: 20 72 65 70 6f 73 69 74 6f 72 79 20 6d 65 74 61   repository meta
1fe0: 29 0a 09 23 20 2d 20 55 73 65 72 20 64 6f 69 6e  )..# - User doin
1ff0: 67 20 74 68 65 20 63 6f 6d 6d 69 74 20 20 20 20  g the commit    
2000: 20 20 20 20 28 73 2e 61 2e 29 0a 09 23 0a 09 23      (s.a.)..#..#
2010: 20 2d 20 54 69 6d 65 73 74 61 6d 70 20 6f 66 20   - Timestamp of 
2020: 77 68 65 6e 20 63 6f 6d 6d 69 74 74 65 64 20 20  when committed  
2030: 28 63 6f 6d 6d 61 6e 64 20 61 72 67 75 6d 65 6e  (command argumen
2040: 74 29 0a 09 23 0a 09 23 20 2d 20 54 68 65 20 70  t)..#..# - The p
2050: 61 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2c  arent changeset,
2060: 20 69 66 20 61 6e 79 2e 20 49 66 20 74 68 65 72   if any. If ther
2070: 65 20 69 73 20 6e 6f 20 70 61 72 65 6e 74 20 66  e is no parent f
2080: 6f 73 73 69 6c 0a 09 23 20 20 20 77 69 6c 6c 20  ossil..#   will 
2090: 75 73 65 20 74 68 65 20 65 6d 70 74 79 20 62 61  use the empty ba
20a0: 73 65 20 72 65 76 69 73 69 6f 6e 20 61 73 20 70  se revision as p
20b0: 61 72 65 6e 74 2e 0a 09 23 0a 09 23 20 2d 20 4c  arent...#..# - L
20c0: 69 73 74 20 6f 66 20 74 68 65 20 66 69 6c 65 20  ist of the file 
20d0: 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 74 68 65  revisions in the
20e0: 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 73 74   changeset....st
20f0: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
2100: 6e 20 5b 24 6d 79 70 72 6f 6a 65 63 74 20 67 65  n [$myproject ge
2110: 74 6d 65 74 61 20 24 6d 79 73 72 63 69 64 5d 20  tmeta $mysrcid] 
2120: 5f 5f 20 5f 5f 20 75 73 65 72 20 6d 65 73 73 61  __ __ user messa
2130: 67 65 0a 0a 09 23 20 57 65 20 64 65 72 69 76 65  ge...# We derive
2140: 20 74 68 65 20 6c 6f 64 20 69 6e 66 6f 72 6d 61   the lod informa
2150: 74 69 6f 6e 20 64 69 72 65 63 74 6c 79 20 66 72  tion directly fr
2160: 6f 6d 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73  om the revisions
2170: 20 6f 66 0a 09 23 20 74 68 65 20 63 68 61 6e 67   of..# the chang
2180: 65 73 65 74 2c 20 61 73 20 74 68 65 20 62 72 61  eset, as the bra
2190: 6e 63 68 20 70 61 72 74 20 6f 66 20 74 68 65 20  nch part of the 
21a0: 6d 65 74 61 20 64 61 74 61 20 28 73 2e 61 2e 29  meta data (s.a.)
21b0: 20 69 73 0a 09 23 20 6f 75 74 64 61 74 65 64 20   is..# outdated 
21c0: 73 69 6e 63 65 20 70 61 73 73 20 46 69 6c 74 65  since pass Filte
21d0: 72 53 79 6d 62 6f 6c 73 2e 0a 0a 09 73 65 74 20  rSymbols....set 
21e0: 6c 6f 64 6e 61 6d 65 20 5b 24 73 65 6c 66 20 6c  lodname [$self l
21f0: 6f 64 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  od]...log write 
2200: 32 20 63 73 65 74 73 20 7b 49 6d 70 6f 72 74 69  2 csets {Importi
2210: 6e 67 20 72 65 76 69 73 69 6f 6e 20 5b 24 73 65  ng revision [$se
2220: 6c 66 20 73 74 72 5d 20 6f 6e 20 24 6c 6f 64 6e  lf str] on $lodn
2230: 61 6d 65 7d 0a 0a 09 23 20 50 65 72 66 6f 72 6d  ame}...# Perform
2240: 20 74 68 65 20 69 6d 70 6f 72 74 2e 20 41 73 20   the import. As 
2250: 70 61 72 74 20 6f 66 20 74 68 61 74 20 77 65 20  part of that we 
2260: 64 65 74 65 72 6d 69 6e 65 20 74 68 65 20 70 61  determine the pa
2270: 72 65 6e 74 0a 09 23 20 77 65 20 6e 65 65 64 2c  rent..# we need,
2280: 20 61 6e 64 20 63 6f 6e 76 65 72 74 20 74 68 65   and convert the
2290: 20 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20 69   list of items i
22a0: 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20  n the changeset 
22b0: 69 6e 74 6f 0a 09 23 20 75 75 69 64 73 20 61 6e  into..# uuids an
22c0: 64 20 70 72 69 6e 74 61 62 6c 65 20 64 61 74 61  d printable data
22d0: 2e 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74  ....struct::list
22e0: 20 61 73 73 69 67 6e 20 5b 47 65 74 69 73 64 65   assign [Getisde
22f0: 66 61 75 6c 74 20 24 6d 79 69 74 65 6d 73 5d 20  fault $myitems] 
2300: 69 73 64 65 66 61 75 6c 74 20 6c 61 73 74 64 65  isdefault lastde
2310: 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 0a 0a 09 6c  faultontrunk...l
2320: 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73  og write 8 csets
2330: 20 7b 4c 4f 44 20 20 20 20 27 24 6c 6f 64 6e 61   {LOD    '$lodna
2340: 6d 65 27 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20  me'}..log write 
2350: 38 20 63 73 65 74 73 20 7b 20 64 65 66 3f 20 20  8 csets { def?  
2360: 24 69 73 64 65 66 61 75 6c 74 7d 0a 09 6c 6f 67  $isdefault}..log
2370: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b   write 8 csets {
2380: 20 6c 61 73 74 3f 20 24 6c 61 73 74 64 65 66 61   last? $lastdefa
2390: 75 6c 74 6f 6e 74 72 75 6e 6b 7d 0a 0a 09 73 65  ultontrunk}...se
23a0: 74 20 6c 77 73 20 20 5b 47 65 74 77 6f 72 6b 73  t lws  [Getworks
23b0: 70 61 63 65 20 20 20 20 24 72 73 74 61 74 65 20  pace    $rstate 
23c0: 24 6c 6f 64 6e 61 6d 65 20 24 6d 79 70 72 6f 6a  $lodname $myproj
23d0: 65 63 74 20 24 69 73 64 65 66 61 75 6c 74 5d 0a  ect $isdefault].
23e0: 09 24 6c 77 73 20 61 64 64 20 5b 47 65 74 72 65  .$lws add [Getre
23f0: 76 69 73 69 6f 6e 69 6e 66 6f 20 24 6d 79 69 74  visioninfo $myit
2400: 65 6d 73 5d 0a 0a 09 73 65 74 20 75 75 69 64 20  ems]...set uuid 
2410: 5b 24 72 65 70 6f 73 69 74 6f 72 79 20 69 6d 70  [$repository imp
2420: 6f 72 74 72 65 76 69 73 69 6f 6e 20 5b 24 73 65  ortrevision [$se
2430: 6c 66 20 73 74 72 5d 20 5c 0a 09 09 20 20 20 20  lf str] \...    
2440: 20 20 24 75 73 65 72 20 24 6d 65 73 73 61 67 65    $user $message
2450: 20 24 64 61 74 65 20 5c 0a 09 09 20 20 20 20 20   $date \...     
2460: 20 5b 24 6c 77 73 20 67 65 74 69 64 5d 20 5b 24   [$lws getid] [$
2470: 6c 77 73 20 67 65 74 5d 5d 0a 0a 09 23 20 52 65  lws get]]...# Re
2480: 6d 65 6d 62 65 72 20 74 68 65 20 69 6d 70 6f 72  member the impor
2490: 74 65 64 20 63 68 61 6e 67 65 73 65 74 20 69 6e  ted changeset in
24a0: 20 74 68 65 20 73 74 61 74 65 2c 20 75 6e 64 65   the state, unde
24b0: 72 20 6f 75 72 0a 09 23 20 4c 4f 44 2e 20 41 6e  r our..# LOD. An
24c0: 64 20 69 66 20 69 74 20 69 73 20 74 68 65 20 6c  d if it is the l
24d0: 61 73 74 20 74 72 75 6e 6b 20 63 68 61 6e 67 65  ast trunk change
24e0: 73 65 74 20 6f 6e 20 74 68 65 20 76 65 6e 64 6f  set on the vendo
24f0: 72 0a 09 23 20 62 72 61 6e 63 68 20 74 68 65 6e  r..# branch then
2500: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 69 73   the revision is
2510: 20 61 6c 73 6f 20 74 68 65 20 61 63 74 75 61 6c   also the actual
2520: 20 72 6f 6f 74 20 6f 66 20 74 68 65 0a 09 23 20   root of the..# 
2530: 3a 74 72 75 6e 6b 3a 2c 20 73 6f 20 77 65 20 72  :trunk:, so we r
2540: 65 6d 65 6d 62 65 72 20 69 74 20 61 73 20 73 75  emember it as su
2550: 63 68 20 69 6e 20 74 68 65 20 73 74 61 74 65 2e  ch in the state.
2560: 20 48 6f 77 65 76 65 72 20 69 66 0a 09 23 20 74   However if..# t
2570: 68 65 20 74 72 75 6e 6b 20 61 6c 72 65 61 64 79  he trunk already
2580: 20 65 78 69 73 74 73 20 74 68 65 6e 20 74 68 65   exists then the
2590: 20 63 68 61 6e 67 65 73 65 74 20 63 61 6e 6e 6f   changeset canno
25a0: 74 20 62 65 20 6f 6e 20 69 74 0a 09 23 20 61 6e  t be on it..# an
25b0: 79 20 6d 6f 72 65 2e 20 54 68 69 73 20 69 6e 64  y more. This ind
25c0: 69 63 61 74 65 73 20 77 65 69 72 64 6e 65 73 73  icates weirdness
25d0: 20 69 6e 20 74 68 65 20 73 65 74 75 70 20 6f 66   in the setup of
25e0: 20 74 68 65 0a 09 23 20 76 65 6e 64 6f 72 20 62   the..# vendor b
25f0: 72 61 6e 63 68 2c 20 62 75 74 20 6f 6e 65 20 77  ranch, but one w
2600: 65 20 63 61 6e 20 77 6f 72 6b 20 61 72 6f 75 6e  e can work aroun
2610: 64 2e 0a 0a 09 24 6c 77 73 20 64 65 66 69 64 20  d....$lws defid 
2620: 24 75 75 69 64 0a 09 69 66 20 7b 24 6c 61 73 74  $uuid..if {$last
2630: 64 65 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 7d 20  defaultontrunk} 
2640: 7b 0a 09 20 20 20 20 69 66 20 7b 5b 24 72 73 74  {..    if {[$rst
2650: 61 74 65 20 68 61 73 20 3a 74 72 75 6e 6b 3a 5d  ate has :trunk:]
2660: 7d 20 7b 0a 09 09 6c 6f 67 20 77 72 69 74 65 20  } {...log write 
2670: 32 20 63 73 65 74 73 20 7b 4d 75 6c 74 69 70 6c  2 csets {Multipl
2680: 65 20 63 68 61 6e 67 65 73 65 74 73 20 64 65 63  e changesets dec
2690: 6c 61 72 65 64 20 74 6f 20 62 65 20 74 68 65 20  lared to be the 
26a0: 6c 61 73 74 20 74 72 75 6e 6b 20 63 68 61 6e 67  last trunk chang
26b0: 65 73 65 74 20 6f 6e 20 74 68 65 20 76 65 6e 64  eset on the vend
26c0: 6f 72 2d 62 72 61 6e 63 68 7d 0a 09 20 20 20 20  or-branch}..    
26d0: 7d 20 65 6c 73 65 20 7b 0a 09 09 24 72 73 74 61  } else {...$rsta
26e0: 74 65 20 6e 65 77 20 3a 74 72 75 6e 6b 3a 20 5b  te new :trunk: [
26f0: 24 6c 77 73 20 6e 61 6d 65 5d 0a 09 20 20 20 20  $lws name]..    
2700: 7d 0a 09 7d 0a 0a 09 23 20 52 65 6d 65 6d 62 65  }..}...# Remembe
2710: 72 20 74 68 65 20 77 68 6f 6c 65 20 63 68 61 6e  r the whole chan
2720: 67 65 73 65 74 20 2f 20 75 75 69 64 20 6d 61 70  geset / uuid map
2730: 70 69 6e 67 2c 20 66 6f 72 20 74 68 65 20 74 61  ping, for the ta
2740: 67 73 2e 0a 0a 09 73 74 61 74 65 20 72 75 6e 20  gs....state run 
2750: 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e  {..    INSERT IN
2760: 54 4f 20 63 73 75 75 69 64 20 28 63 69 64 2c 20  TO csuuid (cid, 
2770: 20 20 75 75 69 64 29 0a 09 20 20 20 20 56 41 4c    uuid)..    VAL
2780: 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20  UES             
2790: 28 24 6d 79 69 64 2c 20 24 75 75 69 64 29 0a 09  ($myid, $uuid)..
27a0: 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  }..return.    }.
27b0: 0a 20 20 20 20 70 72 6f 63 20 47 65 74 72 65 76  .    proc Getrev
27c0: 69 73 69 6f 6e 69 6e 66 6f 20 7b 72 65 76 69 73  isioninfo {revis
27d0: 69 6f 6e 73 7d 20 7b 0a 09 73 65 74 20 74 68 65  ions} {..set the
27e0: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76  set ('[join $rev
27f0: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a  isions {','}]').
2800: 09 73 65 74 20 72 65 76 69 73 69 6f 6e 73 20 7b  .set revisions {
2810: 7d 0a 09 66 6f 72 65 61 63 68 20 7b 66 72 69 64  }..foreach {frid
2820: 20 70 61 74 68 20 66 6e 61 6d 65 20 72 65 76 6e   path fname revn
2830: 72 20 72 6f 70 7d 20 5b 73 74 61 74 65 20 72 75  r rop} [state ru
2840: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
2850: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
2860: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  hes {..    SELEC
2870: 54 20 55 2e 75 75 69 64 2c 20 46 2e 76 69 73 69  T U.uuid, F.visi
2880: 62 6c 65 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72  ble, F.name, R.r
2890: 65 76 2c 20 52 2e 6f 70 0a 09 20 20 20 20 46 52  ev, R.op..    FR
28a0: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
28b0: 20 72 65 76 75 75 69 64 20 55 2c 20 66 69 6c 65   revuuid U, file
28c0: 20 46 0a 09 20 20 20 20 57 48 45 52 45 20 20 52   F..    WHERE  R
28d0: 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .rid IN $theset 
28e0: 20 2d 2d 20 41 6c 6c 20 73 70 65 63 69 66 69 65   -- All specifie
28f0: 64 20 72 65 76 69 73 69 6f 6e 73 0a 09 20 20 20  d revisions..   
2900: 20 41 4e 44 20 20 20 20 55 2e 72 69 64 20 3d 20   AND    U.rid = 
2910: 52 2e 72 69 64 20 20 20 20 20 2d 2d 20 67 65 74  R.rid     -- get
2920: 20 66 6f 73 73 69 6c 20 75 75 69 64 20 6f 66 20   fossil uuid of 
2930: 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 41 4e  revision..    AN
2940: 44 20 20 20 20 46 2e 66 69 64 20 3d 20 52 2e 66  D    F.fid = R.f
2950: 69 64 20 20 20 20 20 2d 2d 20 67 65 74 20 66 69  id     -- get fi
2960: 6c 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09  le of revision..
2970: 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65  }]] {..    lappe
2980: 6e 64 20 72 65 76 69 73 69 6f 6e 73 20 24 66 72  nd revisions $fr
2990: 69 64 20 24 70 61 74 68 20 24 66 6e 61 6d 65 2f  id $path $fname/
29a0: 24 72 65 76 6e 72 20 24 72 6f 70 0a 09 7d 0a 09  $revnr $rop..}..
29b0: 72 65 74 75 72 6e 20 24 72 65 76 69 73 69 6f 6e  return $revision
29c0: 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f  s.    }..    pro
29d0: 63 20 47 65 74 77 6f 72 6b 73 70 61 63 65 20 7b  c Getworkspace {
29e0: 72 73 74 61 74 65 20 6c 6f 64 6e 61 6d 65 20 70  rstate lodname p
29f0: 72 6f 6a 65 63 74 20 69 73 64 65 66 61 75 6c 74  roject isdefault
2a00: 7d 20 7b 0a 0a 09 23 20 54 68 65 20 73 74 61 74  } {...# The stat
2a10: 65 20 6f 62 6a 65 63 74 20 68 6f 6c 64 73 20 74  e object holds t
2a20: 68 65 20 77 6f 72 6b 73 70 61 63 65 20 73 74 61  he workspace sta
2a30: 74 65 20 6f 66 20 65 61 63 68 20 6b 6e 6f 77 6e  te of each known
2a40: 0a 09 23 20 6c 69 6e 65 2d 6f 66 2d 64 65 76 65  ..# line-of-deve
2a50: 6c 6f 70 6d 65 6e 74 20 28 4c 4f 44 29 2c 20 75  lopment (LOD), u
2a60: 70 20 74 6f 20 74 68 65 20 6c 61 73 74 20 63 6f  p to the last co
2a70: 6d 6d 69 74 74 65 64 0a 09 23 20 63 68 61 6e 67  mmitted..# chang
2a80: 65 73 65 74 20 62 65 6c 6f 6e 67 69 6e 67 20 74  eset belonging t
2a90: 6f 20 74 68 61 74 20 4c 4f 44 2e 0a 0a 09 23 20  o that LOD....# 
2aa0: 28 2a 29 20 53 74 61 6e 64 61 72 64 20 68 61 6e  (*) Standard han
2ab0: 64 6c 69 6e 67 20 69 66 20 69 6e 2d 4c 4f 44 20  dling if in-LOD 
2ac0: 63 68 61 6e 67 65 73 65 74 73 2e 20 49 66 20 74  changesets. If t
2ad0: 68 65 20 4c 4f 44 20 6f 66 0a 09 23 20 20 20 20  he LOD of..#    
2ae0: 20 74 68 65 20 63 75 72 72 65 6e 74 20 63 68 61   the current cha
2af0: 6e 67 65 73 65 74 20 65 78 69 73 74 73 20 69 6e  ngeset exists in
2b00: 20 74 68 65 20 73 74 61 74 65 20 28 3d 20 68 61   the state (= ha
2b10: 73 20 62 65 65 6e 0a 09 23 20 20 20 20 20 63 6f  s been..#     co
2b20: 6d 6d 69 74 74 65 64 20 74 6f 29 20 74 68 65 6e  mmitted to) then
2b30: 20 74 68 69 73 20 69 74 20 68 61 73 20 74 68 65   this it has the
2b40: 20 77 6f 72 6b 73 70 61 63 65 20 77 65 20 61 72   workspace we ar
2b50: 65 0a 09 23 20 20 20 20 20 6c 6f 6f 6b 69 6e 67  e..#     looking
2b60: 20 66 6f 72 2e 0a 0a 09 69 66 20 7b 5b 24 72 73   for....if {[$rs
2b70: 74 61 74 65 20 68 61 73 20 24 6c 6f 64 6e 61 6d  tate has $lodnam
2b80: 65 5d 7d 20 7b 0a 09 20 20 20 20 72 65 74 75 72  e]} {..    retur
2b90: 6e 20 5b 24 72 73 74 61 74 65 20 67 65 74 20 24  n [$rstate get $
2ba0: 6c 6f 64 6e 61 6d 65 5d 0a 09 7d 0a 0a 09 23 20  lodname]..}...# 
2bb0: 49 66 20 74 68 65 20 4c 4f 44 20 69 73 20 68 6f  If the LOD is ho
2bc0: 77 65 76 65 72 20 6e 6f 74 20 79 65 74 20 6b 6e  wever not yet kn
2bd0: 6f 77 6e 2c 20 74 68 65 6e 20 74 68 65 20 63 75  own, then the cu
2be0: 72 72 65 6e 74 0a 09 23 20 63 68 61 6e 67 65 73  rrent..# changes
2bf0: 65 74 20 63 61 6e 20 62 65 20 65 69 74 68 65 72  et can be either
2c00: 20 6f 66 0a 09 23 20 28 61 29 20 72 6f 6f 74 20   of..# (a) root 
2c10: 6f 66 20 61 20 76 65 6e 64 6f 72 20 62 72 61 6e  of a vendor bran
2c20: 63 68 2c 0a 09 23 20 28 62 29 20 72 6f 6f 74 20  ch,..# (b) root 
2c30: 6f 66 20 74 68 65 20 74 72 75 6e 6b 20 4c 4f 44  of the trunk LOD
2c40: 2c 20 6f 72 0a 09 23 20 28 63 29 20 74 68 65 20  , or..# (c) the 
2c50: 66 69 72 73 74 20 63 68 61 6e 67 65 73 65 74 20  first changeset 
2c60: 69 6e 20 61 20 6e 65 77 20 4c 4f 44 20 77 68 69  in a new LOD whi
2c70: 63 68 20 77 61 73 20 73 70 61 77 6e 65 64 20 66  ch was spawned f
2c80: 72 6f 6d 0a 09 23 20 20 20 20 20 61 6e 20 65 78  rom..#     an ex
2c90: 69 73 74 69 6e 67 20 4c 4f 44 2e 0a 0a 09 23 20  isting LOD....# 
2ca0: 46 6f 72 20 62 6f 74 68 20 28 61 29 20 61 6e 64  For both (a) and
2cb0: 20 28 62 29 20 77 65 20 68 61 76 65 20 74 6f 20   (b) we have to 
2cc0: 63 72 65 61 74 65 20 61 20 6e 65 77 20 77 6f 72  create a new wor
2cd0: 6b 73 70 61 63 65 20 66 6f 72 0a 09 23 20 74 68  kspace for..# th
2ce0: 65 20 6c 6f 64 2c 20 61 6e 64 20 69 74 20 64 6f  e lod, and it do
2cf0: 65 73 6e 27 74 20 69 6e 68 65 72 69 74 20 66 72  esn't inherit fr
2d00: 6f 6d 20 61 6e 79 74 68 69 6e 67 2e 0a 0a 09 23  om anything....#
2d10: 20 4f 6e 65 20 65 78 63 65 70 74 69 6f 6e 20 66   One exception f
2d20: 6f 72 20 28 61 29 2e 20 49 66 20 77 65 20 61 6c  or (a). If we al
2d30: 72 65 61 64 79 20 68 61 76 65 20 61 20 3a 76 65  ready have a :ve
2d40: 6e 64 6f 72 3a 20 62 72 61 6e 63 68 0a 09 23 20  ndor: branch..# 
2d50: 74 68 65 6e 20 6d 75 6c 74 69 70 6c 65 20 73 79  then multiple sy
2d60: 6d 62 6f 6c 73 20 77 65 72 65 20 75 73 65 64 20  mbols were used 
2d70: 66 6f 72 20 74 68 65 20 76 65 6e 64 6f 72 20 62  for the vendor b
2d80: 72 61 6e 63 68 20 62 79 0a 09 23 20 64 69 66 66  ranch by..# diff
2d90: 65 72 65 6e 74 20 66 69 6c 65 73 2e 20 49 6e 20  erent files. In 
2da0: 74 68 61 74 20 63 61 73 65 20 74 68 65 20 27 6e  that case the 'n
2db0: 65 77 27 20 62 72 61 6e 63 68 20 69 73 20 6d 61  ew' branch is ma
2dc0: 64 65 20 61 6e 0a 09 23 20 61 6c 69 61 73 20 6f  de an..# alias o
2dd0: 66 20 74 68 65 20 3a 76 65 6e 64 6f 72 3a 2c 20  f the :vendor:, 
2de0: 65 66 66 65 63 74 69 76 65 6c 79 20 6d 65 72 67  effectively merg
2df0: 69 6e 67 20 74 68 65 20 73 79 6d 62 6f 6c 73 0a  ing the symbols.
2e00: 09 23 20 74 6f 67 65 74 68 65 72 2e 0a 0a 09 23  .# together....#
2e10: 20 4e 6f 74 65 20 74 68 61 74 20 63 61 73 65 20   Note that case 
2e20: 28 62 29 20 6d 61 79 20 6e 65 76 65 72 20 6f 63  (b) may never oc
2e30: 63 75 72 2e 20 53 65 65 20 74 68 65 20 76 61 72  cur. See the var
2e40: 69 61 62 6c 65 0a 09 23 20 27 6c 61 73 74 64 65  iable..# 'lastde
2e50: 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 27 20 69 6e  faultontrunk' in
2e60: 20 74 68 65 20 63 61 6c 6c 65 72 20 28 6d 65 74   the caller (met
2e70: 68 6f 64 20 70 75 73 68 74 6f 29 2e 20 54 68 69  hod pushto). Thi
2e80: 73 0a 09 23 20 66 6c 61 67 20 63 61 6e 20 74 68  s..# flag can th
2e90: 65 20 67 65 6e 65 72 61 74 69 6f 6e 20 6f 66 20  e generation of 
2ea0: 74 68 65 20 77 6f 72 6b 73 70 61 63 65 20 66 6f  the workspace fo
2eb0: 72 20 74 68 65 20 3a 74 72 75 6e 6b 3a 20 4c 4f  r the :trunk: LO
2ec0: 44 0a 09 23 20 61 73 20 77 65 6c 6c 2c 20 6d 61  D..# as well, ma
2ed0: 6b 69 6e 67 20 69 74 20 69 6e 68 65 72 69 74 20  king it inherit 
2ee0: 74 68 65 20 73 74 61 74 65 20 6f 66 20 74 68 65  the state of the
2ef0: 20 6c 61 73 74 0a 09 23 20 74 72 75 6e 6b 2d 63   last..# trunk-c
2f00: 68 61 6e 67 65 73 65 74 20 6f 6e 20 74 68 65 20  hangeset on the 
2f10: 76 65 6e 64 6f 72 2d 62 72 61 6e 63 68 2e 0a 0a  vendor-branch...
2f20: 09 69 66 20 7b 24 69 73 64 65 66 61 75 6c 74 7d  .if {$isdefault}
2f30: 20 7b 0a 09 20 20 20 20 69 66 20 7b 21 5b 24 72   {..    if {![$r
2f40: 73 74 61 74 65 20 68 61 73 20 22 3a 76 65 6e 64  state has ":vend
2f50: 6f 72 3a 22 5d 7d 20 7b 0a 09 09 23 20 43 72 65  or:"]} {...# Cre
2f60: 61 74 65 20 74 68 65 20 76 65 6e 64 6f 72 20 62  ate the vendor b
2f70: 72 61 6e 63 68 20 69 66 20 6e 6f 74 20 70 72 65  ranch if not pre
2f80: 73 65 6e 74 20 61 6c 72 65 61 64 79 2e 0a 09 09  sent already....
2f90: 24 72 73 74 61 74 65 20 6e 65 77 20 3a 76 65 6e  $rstate new :ven
2fa0: 64 6f 72 3a 0a 09 20 20 20 20 7d 0a 09 20 20 20  dor:..    }..   
2fb0: 20 23 20 4d 65 72 67 65 20 74 68 65 20 6e 65 77   # Merge the new
2fc0: 20 73 79 6d 62 6f 6c 20 74 6f 20 74 68 65 20 76   symbol to the v
2fd0: 65 6e 64 6f 72 20 62 72 61 6e 63 68 0a 09 20 20  endor branch..  
2fe0: 20 20 24 72 73 74 61 74 65 20 64 75 70 20 24 6c    $rstate dup $l
2ff0: 6f 64 6e 61 6d 65 20 3c 2d 2d 20 3a 76 65 6e 64  odname <-- :vend
3000: 6f 72 3a 0a 09 20 20 20 20 72 65 74 75 72 6e 20  or:..    return 
3010: 5b 24 72 73 74 61 74 65 20 67 65 74 20 24 6c 6f  [$rstate get $lo
3020: 64 6e 61 6d 65 5d 0a 09 7d 0a 0a 09 69 66 20 7b  dname]..}...if {
3030: 24 6c 6f 64 6e 61 6d 65 20 65 71 20 22 3a 74 72  $lodname eq ":tr
3040: 75 6e 6b 3a 22 7d 20 7b 0a 09 20 20 20 20 72 65  unk:"} {..    re
3050: 74 75 72 6e 20 5b 24 72 73 74 61 74 65 20 6e 65  turn [$rstate ne
3060: 77 20 24 6c 6f 64 6e 61 6d 65 5d 0a 09 7d 0a 0a  w $lodname]..}..
3070: 09 23 20 43 61 73 65 20 28 63 29 2e 20 57 65 20  .# Case (c). We 
3080: 66 69 6e 64 20 74 68 65 20 70 61 72 65 6e 74 20  find the parent 
3090: 4c 4f 44 20 6f 66 20 6f 75 72 20 4c 4f 44 20 61  LOD of our LOD a
30a0: 6e 64 20 6c 65 74 20 74 68 65 20 6e 65 77 0a 09  nd let the new..
30b0: 23 20 77 6f 72 6b 73 70 61 63 65 20 69 6e 68 65  # workspace inhe
30c0: 72 69 74 20 66 72 6f 6d 20 74 68 65 20 70 61 72  rit from the par
30d0: 65 6e 74 27 73 20 77 6f 72 6b 73 70 61 63 65 2e  ent's workspace.
30e0: 0a 0a 09 73 65 74 20 70 6c 6f 64 6e 61 6d 65 20  ...set plodname 
30f0: 5b 5b 5b 24 70 72 6f 6a 65 63 74 20 67 65 74 73  [[[$project gets
3100: 79 6d 62 6f 6c 20 24 6c 6f 64 6e 61 6d 65 5d 20  ymbol $lodname] 
3110: 70 61 72 65 6e 74 5d 20 6e 61 6d 65 5d 0a 0a 09  parent] name]...
3120: 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74  log write 8 cset
3130: 73 20 7b 70 4c 4f 44 20 20 20 27 24 70 6c 6f 64  s {pLOD   '$plod
3140: 6e 61 6d 65 27 7d 0a 0a 09 69 66 20 7b 5b 24 72  name'}...if {[$r
3150: 73 74 61 74 65 20 68 61 73 20 24 70 6c 6f 64 6e  state has $plodn
3160: 61 6d 65 5d 7d 20 7b 0a 09 20 20 20 20 72 65 74  ame]} {..    ret
3170: 75 72 6e 20 5b 24 72 73 74 61 74 65 20 6e 65 77  urn [$rstate new
3180: 20 24 6c 6f 64 6e 61 6d 65 20 24 70 6c 6f 64 6e   $lodname $plodn
3190: 61 6d 65 5d 0a 09 7d 0a 0a 09 66 6f 72 65 61 63  ame]..}...foreac
31a0: 68 20 6b 20 5b 6c 73 6f 72 74 20 5b 24 72 73 74  h k [lsort [$rst
31b0: 61 74 65 20 6e 61 6d 65 73 5d 5d 20 7b 0a 09 20  ate names]] {.. 
31c0: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63     log write 8 c
31d0: 73 65 74 73 20 7b 20 20 20 20 24 6b 20 3d 20 5b  sets {    $k = [
31e0: 5b 24 72 73 74 61 74 65 20 67 65 74 20 24 6b 5d  [$rstate get $k]
31f0: 20 67 65 74 69 64 5d 7d 0a 09 7d 0a 0a 09 74 72   getid]}..}...tr
3200: 6f 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 7b  ouble internal {
3210: 55 6e 61 62 6c 65 20 74 6f 20 64 65 74 65 72 6d  Unable to determ
3220: 69 6e 65 20 63 68 61 6e 67 65 73 65 74 20 70 61  ine changeset pa
3230: 72 65 6e 74 7d 0a 09 72 65 74 75 72 6e 0a 20 20  rent}..return.  
3240: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 47 65    }..    proc Ge
3250: 74 69 73 64 65 66 61 75 6c 74 20 7b 72 65 76 69  tisdefault {revi
3260: 73 69 6f 6e 73 7d 20 7b 0a 09 73 65 74 20 74 68  sions} {..set th
3270: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65  eset ('[join $re
3280: 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29  visions {','}]')
3290: 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  ...struct::list 
32a0: 61 73 73 69 67 6e 20 5b 73 74 61 74 65 20 72 75  assign [state ru
32b0: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
32c0: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
32d0: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  hes {..    SELEC
32e0: 54 20 52 2e 69 73 64 65 66 61 75 6c 74 2c 20 52  T R.isdefault, R
32f0: 2e 64 62 63 68 69 6c 64 0a 09 20 20 20 20 46 52  .dbchild..    FR
3300: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a  OM   revision R.
3310: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
3320: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d  d IN $theset  --
3330: 20 41 6c 6c 20 73 70 65 63 69 66 69 65 64 20 72   All specified r
3340: 65 76 69 73 69 6f 6e 73 0a 09 20 20 20 20 4c 49  evisions..    LI
3350: 4d 49 54 20 31 0a 09 7d 5d 5d 20 64 65 66 20 6c  MIT 1..}]] def l
3360: 61 73 74 0a 0a 09 23 20 54 4f 44 4f 2f 43 48 45  ast...# TODO/CHE
3370: 43 4b 3a 20 6c 6f 6f 6b 20 66 6f 72 20 63 68 61  CK: look for cha
3380: 6e 67 65 73 65 74 73 20 77 68 65 72 65 20 69 73  ngesets where is
3390: 64 65 66 61 75 6c 74 2f 64 62 63 68 69 6c 64 20  default/dbchild 
33a0: 69 73 0a 09 23 20 61 6d 62 69 67 6f 75 73 2e 0a  is..# ambigous..
33b0: 0a 09 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24  ..return [list $
33c0: 64 65 66 20 5b 65 78 70 72 20 7b 24 6c 61 73 74  def [expr {$last
33d0: 20 6e 65 20 22 22 7d 5d 5d 0a 20 20 20 20 7d 0a   ne ""}]].    }.
33e0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
33f0: 73 70 6c 69 74 20 7b 63 73 65 74 20 61 72 67 73  split {cset args
3400: 7d 20 7b 0a 09 23 20 41 73 20 70 61 72 74 20 6f  } {..# As part o
3410: 66 20 74 68 65 20 63 72 65 61 74 69 6f 6e 20 6f  f the creation o
3420: 66 20 74 68 65 20 6e 65 77 20 63 68 61 6e 67 65  f the new change
3430: 73 65 74 73 20 73 70 65 63 69 66 69 65 64 20 69  sets specified i
3440: 6e 0a 09 23 20 41 52 47 53 20 61 73 20 73 65 74  n..# ARGS as set
3450: 73 20 6f 66 20 69 74 65 6d 73 2c 20 61 6c 6c 20  s of items, all 
3460: 73 75 62 73 65 74 73 20 6f 66 20 43 53 45 54 27  subsets of CSET'
3470: 73 20 69 74 65 6d 20 73 65 74 2c 20 43 53 45 54  s item set, CSET
3480: 0a 09 23 20 77 69 6c 6c 20 62 65 20 64 72 6f 70  ..# will be drop
3490: 70 65 64 20 66 72 6f 6d 20 61 6c 6c 20 64 61 74  ped from all dat
34a0: 61 62 61 73 65 73 2c 20 69 6e 20 61 6e 64 20 6f  abases, in and o
34b0: 75 74 20 6f 66 20 6d 65 6d 6f 72 79 2c 0a 09 23  ut of memory,..#
34c0: 20 61 6e 64 20 74 68 65 6e 20 64 65 73 74 72 6f   and then destro
34d0: 79 65 64 2e 0a 09 23 0a 09 23 20 4e 6f 74 65 3a  yed...#..# Note:
34e0: 20 54 68 65 20 69 74 65 6d 20 6c 69 73 74 73 20   The item lists 
34f0: 66 6f 75 6e 64 20 69 6e 20 61 72 67 73 20 61 72  found in args ar
3500: 65 20 74 61 67 67 65 64 20 69 74 65 6d 73 2e 20  e tagged items. 
3510: 54 68 65 79 0a 09 23 20 68 61 76 65 20 74 6f 20  They..# have to 
3520: 68 61 76 65 20 74 68 65 20 73 61 6d 65 20 74 79  have the same ty
3530: 70 65 20 61 73 20 74 68 65 20 63 68 61 6e 67 65  pe as the change
3540: 73 65 74 2c 20 62 65 69 6e 67 20 73 75 62 73 65  set, being subse
3550: 74 73 0a 09 23 20 6f 66 20 69 74 73 20 69 74 65  ts..# of its ite
3560: 6d 73 2e 20 54 68 69 73 20 69 73 20 63 68 65 63  ms. This is chec
3570: 6b 65 64 20 69 6e 20 55 6e 74 61 67 31 2e 0a 0a  ked in Untag1...
3580: 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65  .log write 8 cse
3590: 74 73 20 7b 4f 4c 44 3a 20 5b 6c 73 6f 72 74 20  ts {OLD: [lsort 
35a0: 5b 24 63 73 65 74 20 69 74 65 6d 73 5d 5d 7d 0a  [$cset items]]}.
35b0: 09 56 61 6c 69 64 61 74 65 46 72 61 67 6d 65 6e  .ValidateFragmen
35c0: 74 73 20 24 63 73 65 74 20 24 61 72 67 73 0a 0a  ts $cset $args..
35d0: 09 23 20 41 6c 6c 20 63 68 65 63 6b 73 20 70 61  .# All checks pa
35e0: 73 73 2c 20 61 63 74 75 61 6c 6c 79 20 70 65 72  ss, actually per
35f0: 66 6f 72 6d 20 74 68 65 20 73 70 6c 69 74 2e 0a  form the split..
3600: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61  ..struct::list a
3610: 73 73 69 67 6e 20 5b 24 63 73 65 74 20 64 61 74  ssign [$cset dat
3620: 61 5d 20 70 72 6f 6a 65 63 74 20 63 73 74 79 70  a] project cstyp
3630: 65 20 63 73 73 72 63 0a 0a 09 73 65 74 20 70 72  e cssrc...set pr
3640: 65 64 65 63 65 73 73 6f 72 73 20 5b 24 63 73 65  edecessors [$cse
3650: 74 20 64 72 6f 70 5d 0a 09 24 63 73 65 74 20 64  t drop]..$cset d
3660: 65 73 74 72 6f 79 0a 0a 09 73 65 74 20 6e 65 77  estroy...set new
3670: 63 73 65 74 73 20 7b 7d 0a 09 66 6f 72 65 61 63  csets {}..foreac
3680: 68 20 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 20  h fragmentitems 
3690: 24 61 72 67 73 20 7b 0a 09 20 20 20 20 6c 6f 67  $args {..    log
36a0: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b   write 8 csets {
36b0: 4d 41 4b 45 3a 20 5b 6c 73 6f 72 74 20 24 66 72  MAKE: [lsort $fr
36c0: 61 67 6d 65 6e 74 69 74 65 6d 73 5d 7d 0a 0a 09  agmentitems]}...
36d0: 20 20 20 20 73 65 74 20 66 72 61 67 6d 65 6e 74      set fragment
36e0: 20 5b 24 74 79 70 65 20 25 41 55 54 4f 25 20 24   [$type %AUTO% $
36f0: 70 72 6f 6a 65 63 74 20 24 63 73 74 79 70 65 20  project $cstype 
3700: 24 63 73 73 72 63 20 5c 0a 09 09 09 20 20 20 20  $cssrc \....    
3710: 20 20 5b 55 6e 74 61 67 20 24 66 72 61 67 6d 65    [Untag $fragme
3720: 6e 74 69 74 65 6d 73 20 24 63 73 74 79 70 65 5d  ntitems $cstype]
3730: 5d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 6e  ]..    lappend n
3740: 65 77 63 73 65 74 73 20 24 66 72 61 67 6d 65 6e  ewcsets $fragmen
3750: 74 0a 0a 09 20 20 20 20 24 66 72 61 67 6d 65 6e  t...    $fragmen
3760: 74 20 70 65 72 73 69 73 74 0a 09 20 20 20 20 24  t persist..    $
3770: 66 72 61 67 6d 65 6e 74 20 64 65 74 65 72 6d 69  fragment determi
3780: 6e 65 73 75 63 63 65 73 73 6f 72 73 0a 09 7d 0a  nesuccessors..}.
3790: 0a 09 23 20 54 68 65 20 70 72 65 64 65 63 65 73  ..# The predeces
37a0: 73 6f 72 73 20 68 61 76 65 20 74 6f 20 72 65 63  sors have to rec
37b0: 6f 6d 70 75 74 65 20 74 68 65 69 72 20 73 75 63  ompute their suc
37c0: 63 65 73 73 6f 72 73 2c 20 69 2e 65 2e 0a 09 23  cessors, i.e...#
37d0: 20 72 65 6d 6f 76 65 20 74 68 65 20 64 72 6f 70   remove the drop
37e0: 70 65 64 20 63 68 61 6e 67 65 73 65 74 20 61 6e  ped changeset an
37f0: 64 20 70 75 74 20 6f 6e 65 20 6f 66 20 74 68 65  d put one of the
3800: 20 66 72 61 67 6d 65 6e 74 73 0a 09 23 20 69 6e   fragments..# in
3810: 74 6f 20 69 74 73 20 70 6c 61 63 65 2e 0a 09 66  to its place...f
3820: 6f 72 65 61 63 68 20 70 20 24 70 72 65 64 65 63  oreach p $predec
3830: 65 73 73 6f 72 73 20 7b 0a 09 20 20 20 20 24 70  essors {..    $p
3840: 20 64 65 74 65 72 6d 69 6e 65 73 75 63 63 65 73   determinesucces
3850: 73 6f 72 73 0a 09 7d 0a 0a 09 72 65 74 75 72 6e  sors..}...return
3860: 20 24 6e 65 77 63 73 65 74 73 0a 20 20 20 20 7d   $newcsets.    }
3870: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
3880: 20 69 74 65 6d 73 74 72 20 7b 69 74 65 6d 7d 20   itemstr {item} 
3890: 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  {..struct::list 
38a0: 61 73 73 69 67 6e 20 24 69 74 65 6d 20 69 74 79  assign $item ity
38b0: 70 65 20 69 69 64 0a 09 72 65 74 75 72 6e 20 5b  pe iid..return [
38c0: 24 69 74 79 70 65 20 73 74 72 20 24 69 69 64 5d  $itype str $iid]
38d0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65  .    }..    type
38e0: 6d 65 74 68 6f 64 20 73 74 72 6c 69 73 74 20 7b  method strlist {
38f0: 63 68 61 6e 67 65 73 65 74 73 7d 20 7b 0a 09 72  changesets} {..r
3900: 65 74 75 72 6e 20 5b 6a 6f 69 6e 20 5b 73 74 72  eturn [join [str
3910: 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 63  uct::list map $c
3920: 68 61 6e 67 65 73 65 74 73 20 5b 6d 79 70 72 6f  hangesets [mypro
3930: 63 20 49 44 5d 5d 5d 0a 20 20 20 20 7d 0a 0a 20  c ID]]].    }.. 
3940: 20 20 20 70 72 6f 63 20 49 44 20 7b 63 73 65 74     proc ID {cset
3950: 7d 20 7b 20 24 63 73 65 74 20 73 74 72 20 7d 0a  } { $cset str }.
3960: 0a 20 20 20 20 70 72 6f 63 20 55 6e 74 61 67 20  .    proc Untag 
3970: 7b 74 61 67 67 65 64 69 74 65 6d 73 20 63 73 74  {taggeditems cst
3980: 79 70 65 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b  ype} {..return [
3990: 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70  struct::list map
39a0: 20 24 74 61 67 67 65 64 69 74 65 6d 73 20 5b 6d   $taggeditems [m
39b0: 79 70 72 6f 63 20 55 6e 74 61 67 31 20 24 63 73  yproc Untag1 $cs
39c0: 74 79 70 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20  type]].    }..  
39d0: 20 20 70 72 6f 63 20 55 6e 74 61 67 31 20 7b 63    proc Untag1 {c
39e0: 73 74 79 70 65 20 74 68 65 69 74 65 6d 7d 20 7b  stype theitem} {
39f0: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61  ..struct::list a
3a00: 73 73 69 67 6e 20 24 74 68 65 69 74 65 6d 20 74  ssign $theitem t
3a10: 20 69 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73   i..integrity as
3a20: 73 65 72 74 20 7b 24 63 73 74 79 70 65 20 65 71  sert {$cstype eq
3a30: 20 24 74 7d 20 7b 49 74 65 6d 20 24 69 27 73 20   $t} {Item $i's 
3a40: 74 79 70 65 20 69 73 20 27 24 74 27 2c 20 65 78  type is '$t', ex
3a50: 70 65 63 74 65 64 20 27 24 63 73 74 79 70 65 27  pected '$cstype'
3a60: 7d 0a 09 72 65 74 75 72 6e 20 24 69 0a 20 20 20  }..return $i.   
3a70: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 54 61 67   }..    proc Tag
3a80: 49 74 65 6d 44 69 63 74 20 7b 69 74 65 6d 64 69  ItemDict {itemdi
3a90: 63 74 20 63 73 74 79 70 65 7d 20 7b 0a 09 73 65  ct cstype} {..se
3aa0: 74 20 72 65 73 20 7b 7d 0a 09 66 6f 72 65 61 63  t res {}..foreac
3ab0: 68 20 7b 69 20 76 7d 20 24 69 74 65 6d 64 69 63  h {i v} $itemdic
3ac0: 74 20 7b 20 6c 61 70 70 65 6e 64 20 72 65 73 20  t { lappend res 
3ad0: 5b 6c 69 73 74 20 24 63 73 74 79 70 65 20 24 69  [list $cstype $i
3ae0: 5d 20 24 76 20 7d 0a 09 72 65 74 75 72 6e 20 24  ] $v }..return $
3af0: 72 65 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70  res.    }..    p
3b00: 72 6f 63 20 56 61 6c 69 64 61 74 65 46 72 61 67  roc ValidateFrag
3b10: 6d 65 6e 74 73 20 7b 63 73 65 74 20 66 72 61 67  ments {cset frag
3b20: 6d 65 6e 74 73 7d 20 7b 0a 09 23 20 43 68 65 63  ments} {..# Chec
3b30: 6b 20 74 68 65 20 76 61 72 69 6f 75 73 20 69 6e  k the various in
3b40: 74 65 67 72 69 74 79 20 63 6f 6e 73 74 72 61 69  tegrity constrai
3b50: 6e 74 73 20 66 6f 72 20 74 68 65 20 66 72 61 67  nts for the frag
3b60: 6d 65 6e 74 73 0a 09 23 20 73 70 65 63 69 66 79  ments..# specify
3b70: 69 6e 67 20 68 6f 77 20 74 6f 20 73 70 6c 69 74  ing how to split
3b80: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 3a 0a   the changeset:.
3b90: 09 23 0a 09 23 20 2a 20 57 65 20 6d 75 73 74 20  .#..# * We must 
3ba0: 68 61 76 65 20 74 77 6f 20 6f 72 20 6d 6f 72 65  have two or more
3bb0: 20 66 72 61 67 6d 65 6e 74 73 2c 20 61 73 20 73   fragments, as s
3bc0: 70 6c 69 74 74 69 6e 67 20 61 0a 09 23 20 20 20  plitting a..#   
3bd0: 63 68 61 6e 67 65 73 65 74 20 69 6e 74 6f 20 6f  changeset into o
3be0: 6e 65 20 6d 61 6b 65 73 20 6e 6f 20 73 65 6e 73  ne makes no sens
3bf0: 65 2e 0a 09 23 20 2a 20 4e 6f 20 66 72 61 67 6d  e...# * No fragm
3c00: 65 6e 74 20 6d 61 79 20 62 65 20 65 6d 70 74 79  ent may be empty
3c10: 2e 0a 09 23 20 2a 20 41 6c 6c 20 66 72 61 67 6d  ...# * All fragm
3c20: 65 6e 74 73 20 68 61 76 65 20 74 6f 20 62 65 20  ents have to be 
3c30: 74 72 75 65 20 73 75 62 73 65 74 73 20 6f 66 20  true subsets of 
3c40: 74 68 65 20 69 74 65 6d 73 20 69 6e 20 74 68 65  the items in the
3c50: 0a 09 23 20 20 20 63 68 61 6e 67 65 73 65 74 20  ..#   changeset 
3c60: 74 6f 20 73 70 6c 69 74 2e 20 54 68 65 20 27 74  to split. The 't
3c70: 72 75 65 27 20 69 73 20 69 6d 70 6c 69 65 64 20  rue' is implied 
3c80: 62 65 63 61 75 73 65 20 6e 6f 6e 65 20 61 72 65  because none are
3c90: 0a 09 23 20 20 20 61 6c 6c 6f 77 65 64 20 74 6f  ..#   allowed to
3ca0: 20 62 65 20 65 6d 70 74 79 2c 20 73 6f 20 65 61   be empty, so ea
3cb0: 63 68 20 68 61 73 20 74 6f 20 62 65 20 73 6d 61  ch has to be sma
3cc0: 6c 6c 65 72 20 74 68 61 6e 20 74 68 65 0a 09 23  ller than the..#
3cd0: 20 20 20 74 6f 74 61 6c 2e 0a 09 23 20 2a 20 54     total...# * T
3ce0: 68 65 20 75 6e 69 6f 6e 20 6f 66 20 74 68 65 20  he union of the 
3cf0: 66 72 61 67 6d 65 6e 74 73 20 68 61 73 20 74 6f  fragments has to
3d00: 20 62 65 20 74 68 65 20 69 74 65 6d 20 73 65 74   be the item set
3d10: 20 6f 66 20 74 68 65 0a 09 23 20 20 20 63 68 61   of the..#   cha
3d20: 6e 67 65 73 65 74 2e 0a 09 23 20 2a 20 54 68 65  ngeset...# * The
3d30: 20 66 72 61 67 6d 65 6e 74 20 6d 75 73 74 20 6e   fragment must n
3d40: 6f 74 20 6f 76 65 72 6c 61 70 2c 20 69 2e 65 2e  ot overlap, i.e.
3d50: 20 74 68 65 69 72 20 70 61 69 72 77 69 73 65 0a   their pairwise.
3d60: 09 23 20 20 20 69 6e 74 65 72 73 65 63 74 69 6f  .#   intersectio
3d70: 6e 73 20 68 61 76 65 20 74 6f 20 62 65 20 65 6d  ns have to be em
3d80: 70 74 79 2e 0a 0a 09 73 65 74 20 63 6f 76 65 72  pty....set cover
3d90: 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 66 72 61   {}..foreach fra
3da0: 67 6d 65 6e 74 69 74 65 6d 73 20 24 66 72 61 67  gmentitems $frag
3db0: 6d 65 6e 74 73 20 7b 0a 09 20 20 20 20 6c 6f 67  ments {..    log
3dc0: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b   write 8 csets {
3dd0: 4e 45 57 3a 20 5b 6c 73 6f 72 74 20 24 66 72 61  NEW: [lsort $fra
3de0: 67 6d 65 6e 74 69 74 65 6d 73 5d 7d 0a 0a 09 20  gmentitems]}... 
3df0: 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73     integrity ass
3e00: 65 72 74 20 7b 0a 09 09 21 5b 73 74 72 75 63 74  ert {...![struct
3e10: 3a 3a 73 65 74 20 65 6d 70 74 79 20 24 66 72 61  ::set empty $fra
3e20: 67 6d 65 6e 74 69 74 65 6d 73 5d 0a 09 20 20 20  gmentitems]..   
3e30: 20 7d 20 7b 63 68 61 6e 67 65 73 65 74 20 66 72   } {changeset fr
3e40: 61 67 6d 65 6e 74 20 69 73 20 65 6d 70 74 79 7d  agment is empty}
3e50: 0a 0a 09 20 20 20 20 69 6e 74 65 67 72 69 74 79  ...    integrity
3e60: 20 61 73 73 65 72 74 20 7b 0a 09 09 5b 73 74 72   assert {...[str
3e70: 75 63 74 3a 3a 73 65 74 20 73 75 62 73 65 74 6f  uct::set subseto
3e80: 66 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d 73  f $fragmentitems
3e90: 20 5b 24 63 73 65 74 20 69 74 65 6d 73 5d 5d 0a   [$cset items]].
3ea0: 09 20 20 20 20 7d 20 7b 63 68 61 6e 67 65 73 65  .    } {changese
3eb0: 74 20 66 72 61 67 6d 65 6e 74 20 69 73 20 6e 6f  t fragment is no
3ec0: 74 20 61 20 73 75 62 73 65 74 7d 0a 09 20 20 20  t a subset}..   
3ed0: 20 73 74 72 75 63 74 3a 3a 73 65 74 20 61 64 64   struct::set add
3ee0: 20 63 6f 76 65 72 20 24 66 72 61 67 6d 65 6e 74   cover $fragment
3ef0: 69 74 65 6d 73 0a 09 7d 0a 0a 09 69 6e 74 65 67  items..}...integ
3f00: 72 69 74 79 20 61 73 73 65 72 74 20 7b 0a 09 20  rity assert {.. 
3f10: 20 20 20 5b 73 74 72 75 63 74 3a 3a 73 65 74 20     [struct::set 
3f20: 65 71 75 61 6c 20 24 63 6f 76 65 72 20 5b 24 63  equal $cover [$c
3f30: 73 65 74 20 69 74 65 6d 73 5d 5d 0a 09 20 7d 20  set items]].. } 
3f40: 7b 54 68 65 20 66 72 61 67 6d 65 6e 74 73 20 64  {The fragments d
3f50: 6f 20 6e 6f 74 20 63 6f 76 65 72 20 74 68 65 20  o not cover the 
3f60: 6f 72 69 67 69 6e 61 6c 20 63 68 61 6e 67 65 73  original changes
3f70: 65 74 7d 0a 0a 09 73 65 74 20 69 20 31 0a 09 66  et}...set i 1..f
3f80: 6f 72 65 61 63 68 20 66 69 61 20 24 66 72 61 67  oreach fia $frag
3f90: 6d 65 6e 74 73 20 7b 0a 09 20 20 20 20 66 6f 72  ments {..    for
3fa0: 65 61 63 68 20 66 69 62 20 5b 6c 72 61 6e 67 65  each fib [lrange
3fb0: 20 24 66 72 61 67 6d 65 6e 74 73 20 24 69 20 65   $fragments $i e
3fc0: 6e 64 5d 20 7b 0a 09 09 69 6e 74 65 67 72 69 74  nd] {...integrit
3fd0: 79 20 61 73 73 65 72 74 20 7b 0a 09 09 20 20 20  y assert {...   
3fe0: 20 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 65 6d   [struct::set em
3ff0: 70 74 79 20 5b 73 74 72 75 63 74 3a 3a 73 65 74  pty [struct::set
4000: 20 69 6e 74 65 72 73 65 63 74 20 24 66 69 61 20   intersect $fia 
4010: 24 66 69 62 5d 5d 0a 09 09 7d 20 7b 54 68 65 20  $fib]]...} {The 
4020: 66 72 61 67 6d 65 6e 74 73 20 3c 24 66 69 61 3e  fragments <$fia>
4030: 20 61 6e 64 20 3c 24 66 69 62 3e 20 6f 76 65 72   and <$fib> over
4040: 6c 61 70 7d 0a 09 20 20 20 20 7d 0a 09 20 20 20  lap}..    }..   
4050: 20 69 6e 63 72 20 69 0a 09 7d 0a 0a 09 72 65 74   incr i..}...ret
4060: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23  urn.    }..    #
4070: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
4080: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
4090: 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 53 74  ######.    ## St
40a0: 61 74 65 0a 0a 20 20 20 20 76 61 72 69 61 62 6c  ate..    variabl
40b0: 65 20 6d 79 69 64 20 20 20 20 20 20 20 20 7b 7d  e myid        {}
40c0: 20 3b 20 23 20 49 64 20 6f 66 20 74 68 65 20 63   ; # Id of the c
40d0: 73 65 74 20 66 6f 72 20 74 68 65 20 70 65 72 73  set for the pers
40e0: 69 73 74 65 6e 74 0a 09 09 09 20 20 20 20 20 20  istent....      
40f0: 23 20 73 74 61 74 65 2e 0a 20 20 20 20 76 61 72  # state..    var
4100: 69 61 62 6c 65 20 6d 79 70 72 6f 6a 65 63 74 20  iable myproject 
4110: 20 20 7b 7d 20 3b 20 23 20 52 65 66 65 72 65 6e    {} ; # Referen
4120: 63 65 20 6f 66 20 74 68 65 20 70 72 6f 6a 65 63  ce of the projec
4130: 74 20 6f 62 6a 65 63 74 20 74 68 65 0a 09 09 09  t object the....
4140: 20 20 20 20 20 20 23 20 63 68 61 6e 67 65 73 65        # changese
4150: 74 20 62 65 6c 6f 6e 67 73 20 74 6f 2e 0a 20 20  t belongs to..  
4160: 20 20 76 61 72 69 61 62 6c 65 20 6d 79 74 79 70    variable mytyp
4170: 65 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 57 68  e      {} ; # Wh
4180: 61 74 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  at the changeset
4190: 20 69 73 20 62 61 73 65 64 20 6f 6e 0a 09 09 09   is based on....
41a0: 20 20 20 20 20 20 23 20 28 72 65 76 69 73 69 6f        # (revisio
41b0: 6e 73 2c 20 74 61 67 73 2c 20 6f 72 20 62 72 61  ns, tags, or bra
41c0: 6e 63 68 65 73 29 2e 0a 09 09 09 20 20 20 20 20  nches).....     
41d0: 20 23 20 56 61 6c 75 65 73 3a 20 53 65 65 20 6d   # Values: See m
41e0: 79 63 73 74 79 70 65 2e 20 4e 6f 74 65 20 74 68  ycstype. Note th
41f0: 61 74 20 77 65 0a 09 09 09 20 20 20 20 20 20 23  at we....      #
4200: 20 68 61 76 65 20 74 6f 20 6b 65 65 70 20 74 68   have to keep th
4210: 65 20 6e 61 6d 65 73 20 6f 66 20 74 68 65 20 68  e names of the h
4220: 65 6c 70 65 72 0a 09 09 09 20 20 20 20 20 20 23  elper....      #
4230: 20 73 69 6e 67 6c 65 74 6f 6e 73 20 69 6e 20 73   singletons in s
4240: 79 6e 63 20 77 69 74 68 20 74 68 65 20 63 6f 6e  ync with the con
4250: 74 65 6e 74 73 0a 09 09 09 20 20 20 20 20 20 23  tents....      #
4260: 20 6f 66 20 73 74 61 74 65 20 74 61 62 6c 65 20   of state table 
4270: 27 63 73 74 79 70 65 27 2c 20 61 6e 64 20 76 61  'cstype', and va
4280: 72 69 6f 75 73 0a 09 09 09 20 20 20 20 20 20 23  rious....      #
4290: 20 6f 74 68 65 72 20 70 6c 61 63 65 73 20 75 73   other places us
42a0: 69 6e 67 20 74 68 65 6d 20 68 61 72 64 77 69 72  ing them hardwir
42b0: 65 64 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65  ed..    variable
42c0: 20 6d 79 74 79 70 65 6f 62 6a 20 20 20 7b 7d 20   mytypeobj   {} 
42d0: 3b 20 23 20 52 65 66 65 72 65 6e 63 65 20 74 6f  ; # Reference to
42e0: 20 74 68 65 20 63 6f 6e 74 61 69 6e 65 72 20 66   the container f
42f0: 6f 72 20 74 68 65 0a 09 09 09 20 20 20 20 20 20  or the....      
4300: 23 20 74 79 70 65 20 64 65 70 65 6e 64 65 6e 74  # type dependent
4310: 20 63 6f 64 65 2e 20 44 65 72 69 76 65 64 20 66   code. Derived f
4320: 72 6f 6d 0a 09 09 09 20 20 20 20 20 20 23 20 6d  rom....      # m
4330: 79 74 79 70 65 2e 0a 20 20 20 20 76 61 72 69 61  ytype..    varia
4340: 62 6c 65 20 6d 79 73 72 63 69 64 20 20 20 20 20  ble mysrcid     
4350: 7b 7d 20 3b 20 23 20 49 64 20 6f 66 20 74 68 65  {} ; # Id of the
4360: 20 6d 65 74 61 64 61 74 61 20 6f 72 20 73 79 6d   metadata or sym
4370: 62 6f 6c 20 74 68 65 20 63 73 65 74 0a 09 09 09  bol the cset....
4380: 20 20 20 20 20 20 23 20 69 73 20 62 61 73 65 64        # is based
4390: 20 6f 6e 2e 0a 20 20 20 20 76 61 72 69 61 62 6c   on..    variabl
43a0: 65 20 6d 79 69 74 65 6d 73 20 20 20 20 20 7b 7d  e myitems     {}
43b0: 20 3b 20 23 20 4c 69 73 74 20 6f 66 20 74 68 65   ; # List of the
43c0: 20 66 69 6c 65 20 6c 65 76 65 6c 20 72 65 76 69   file level revi
43d0: 73 69 6f 6e 73 2c 0a 09 09 09 20 20 20 20 20 20  sions,....      
43e0: 23 20 74 61 67 73 2c 20 6f 72 20 62 72 61 6e 63  # tags, or branc
43f0: 68 65 73 20 69 6e 20 74 68 65 20 63 73 65 74 2c  hes in the cset,
4400: 20 61 73 0a 09 09 09 20 20 20 20 20 20 23 20 69   as....      # i
4410: 64 73 2e 20 4e 6f 74 20 74 61 67 67 65 64 2e 0a  ds. Not tagged..
4420: 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 74      variable myt
4430: 69 74 65 6d 73 20 20 20 20 7b 7d 20 3b 20 23 20  items    {} ; # 
4440: 41 73 20 6d 79 69 74 65 6d 73 2c 20 74 68 65 20  As myitems, the 
4450: 74 61 67 67 65 64 20 66 6f 72 6d 2e 0a 20 20 20  tagged form..   
4460: 20 76 61 72 69 61 62 6c 65 20 6d 79 70 6f 73 20   variable mypos 
4470: 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 43 6f 6d        {} ; # Com
4480: 6d 69 74 20 70 6f 73 69 74 69 6f 6e 20 6f 66 20  mit position of 
4490: 74 68 65 20 63 68 61 6e 67 65 73 65 74 2c 20 69  the changeset, i
44a0: 66 0a 09 09 09 20 20 20 20 20 20 23 20 6b 6e 6f  f....      # kno
44b0: 77 6e 2e 0a 0a 20 20 20 20 23 20 23 20 23 23 20  wn...    # # ## 
44c0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
44d0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
44e0: 0a 20 20 20 20 23 23 20 49 6e 74 65 72 6e 61 6c  .    ## Internal
44f0: 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20 20 74 79   methods..    ty
4500: 70 65 76 61 72 69 61 62 6c 65 20 6d 79 63 6f 75  pevariable mycou
4510: 6e 74 65 72 20 20 20 20 20 20 20 20 30 20 3b 20  nter        0 ; 
4520: 23 20 49 64 20 63 6f 75 6e 74 65 72 20 66 6f 72  # Id counter for
4530: 20 63 73 65 74 73 2e 20 4c 61 73 74 20 69 64 0a   csets. Last id.
4540: 09 09 09 09 20 20 20 20 20 20 23 20 75 73 65 64  ....      # used
4550: 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62  ..    typevariab
4560: 6c 65 20 6d 79 63 73 74 79 70 65 20 2d 61 72 72  le mycstype -arr
4570: 61 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 63 73  ay {} ; # Map cs
4580: 74 79 70 65 73 20 28 6e 61 6d 65 73 29 20 74 6f  types (names) to
4590: 20 70 65 72 73 69 73 74 65 6e 74 0a 09 09 09 09   persistent.....
45a0: 20 20 20 20 20 20 23 20 69 64 73 2e 20 4e 6f 74        # ids. Not
45b0: 65 20 74 68 61 74 20 77 65 20 68 61 76 65 20 74  e that we have t
45c0: 6f 20 6b 65 65 70 0a 09 09 09 09 20 20 20 20 20  o keep.....     
45d0: 20 23 20 74 68 65 20 6e 61 6d 65 73 20 69 6e 20   # the names in 
45e0: 74 68 65 20 74 61 62 6c 65 20 27 63 73 74 79 70  the table 'cstyp
45f0: 65 27 0a 09 09 09 09 20 20 20 20 20 20 23 20 69  e'.....      # i
4600: 6e 20 73 79 6e 63 20 77 69 74 68 20 74 68 65 20  n sync with the 
4610: 6e 61 6d 65 73 20 6f 66 20 74 68 65 0a 09 09 09  names of the....
4620: 09 20 20 20 20 20 20 23 20 68 65 6c 70 65 72 20  .      # helper 
4630: 73 69 6e 67 6c 65 74 6f 6e 73 2e 0a 0a 20 20 20  singletons...   
4640: 20 74 79 70 65 6d 65 74 68 6f 64 20 69 6e 6f 72   typemethod inor
4650: 64 65 72 20 7b 70 72 6f 6a 65 63 74 69 64 7d 20  der {projectid} 
4660: 7b 0a 09 23 20 52 65 74 75 72 6e 20 61 6c 6c 20  {..# Return all 
4670: 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73  revision changes
4680: 65 74 73 20 66 6f 72 20 74 68 65 20 73 70 65 63  ets for the spec
4690: 69 66 69 65 64 20 70 72 6f 6a 65 63 74 2c 20 69  ified project, i
46a0: 6e 0a 09 23 20 74 68 65 20 6f 72 64 65 72 20 67  n..# the order g
46b0: 69 76 65 6e 20 74 6f 20 74 68 65 6d 20 62 79 20  iven to them by 
46c0: 74 68 65 20 73 6f 72 74 20 70 61 73 73 65 73 2e  the sort passes.
46d0: 20 42 6f 74 68 20 74 68 65 0a 09 23 20 66 69 6c   Both the..# fil
46e0: 74 65 72 69 6e 67 20 62 79 20 70 72 6f 6a 65 63  tering by projec
46f0: 74 20 61 6e 64 20 73 6f 72 74 69 6e 67 20 6d 61  t and sorting ma
4700: 6b 65 20 75 73 65 20 6f 66 20 27 70 72 6f 6a 65  ke use of 'proje
4710: 63 74 3a 3a 72 65 76 0a 09 23 20 72 65 76 27 20  ct::rev..# rev' 
4720: 69 6d 70 6f 73 73 69 62 6c 65 2e 0a 0a 09 73 65  impossible....se
4730: 74 20 72 65 73 20 7b 7d 0a 09 66 6f 72 65 61 63  t res {}..foreac
4740: 68 20 7b 63 69 64 20 63 64 61 74 65 7d 20 5b 73  h {cid cdate} [s
4750: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
4760: 53 45 4c 45 43 54 20 43 2e 63 69 64 2c 20 54 2e  SELECT C.cid, T.
4770: 64 61 74 65 0a 09 20 20 20 20 46 52 4f 4d 20 20  date..    FROM  
4780: 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73   changeset C, cs
4790: 74 69 6d 65 73 74 61 6d 70 20 54 0a 09 20 20 20  timestamp T..   
47a0: 20 57 48 45 52 45 20 20 43 2e 74 79 70 65 20 3d   WHERE  C.type =
47b0: 20 30 20 20 20 20 20 20 20 20 20 20 2d 2d 20 6c   0          -- l
47c0: 69 6d 69 74 20 74 6f 20 72 65 76 69 73 69 6f 6e  imit to revision
47d0: 20 63 68 61 6e 67 65 73 65 74 73 0a 09 20 20 20   changesets..   
47e0: 20 41 4e 44 20 20 20 20 43 2e 70 69 64 20 20 3d   AND    C.pid  =
47f0: 20 24 70 72 6f 6a 65 63 74 69 64 20 2d 2d 20 6c   $projectid -- l
4800: 69 6d 69 74 20 74 6f 20 63 68 61 6e 67 65 73 65  imit to changese
4810: 74 73 20 69 6e 20 70 72 6f 6a 65 63 74 0a 09 20  ts in project.. 
4820: 20 20 20 41 4e 44 20 20 20 20 54 2e 63 69 64 20     AND    T.cid 
4830: 20 3d 20 43 2e 63 69 64 20 20 20 20 20 20 2d 2d   = C.cid      --
4840: 20 67 65 74 20 6f 72 64 65 72 69 6e 67 20 69 6e   get ordering in
4850: 66 6f 72 6d 61 74 69 6f 6e 0a 09 20 20 20 20 4f  formation..    O
4860: 52 44 45 52 20 42 59 20 54 2e 64 61 74 65 20 20  RDER BY T.date  
4870: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 73 6f 72            -- sor
4880: 74 20 69 6e 74 6f 20 63 6f 6d 6d 69 74 20 6f 72  t into commit or
4890: 64 65 72 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 6c  der..}] {..    l
48a0: 61 70 70 65 6e 64 20 72 65 73 20 24 6d 79 69 64  append res $myid
48b0: 6d 61 70 28 24 63 69 64 29 20 24 63 64 61 74 65  map($cid) $cdate
48c0: 0a 09 7d 0a 09 72 65 74 75 72 6e 20 24 72 65 73  ..}..return $res
48d0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65  .    }..    type
48e0: 6d 65 74 68 6f 64 20 67 65 74 63 73 74 79 70 65  method getcstype
48f0: 73 20 7b 7d 20 7b 0a 09 66 6f 72 65 61 63 68 20  s {} {..foreach 
4900: 7b 74 69 64 20 6e 61 6d 65 7d 20 5b 73 74 61 74  {tid name} [stat
4910: 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c  e run {..    SEL
4920: 45 43 54 20 74 69 64 2c 20 6e 61 6d 65 20 46 52  ECT tid, name FR
4930: 4f 4d 20 63 73 74 79 70 65 3b 0a 09 7d 5d 20 7b  OM cstype;..}] {
4940: 20 73 65 74 20 6d 79 63 73 74 79 70 65 28 24 6e   set mycstype($n
4950: 61 6d 65 29 20 24 74 69 64 20 7d 0a 09 72 65 74  ame) $tid }..ret
4960: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74  urn.    }..    t
4970: 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61 64 20 7b  ypemethod load {
4980: 72 65 70 6f 73 69 74 6f 72 79 7d 20 7b 0a 09 73  repository} {..s
4990: 65 74 20 6e 20 30 0a 09 6c 6f 67 20 77 72 69 74  et n 0..log writ
49a0: 65 20 32 20 63 73 65 74 73 20 7b 4c 6f 61 64 69  e 2 csets {Loadi
49b0: 6e 67 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  ng the changeset
49c0: 73 7d 0a 09 66 6f 72 65 61 63 68 20 7b 69 64 20  s}..foreach {id 
49d0: 70 69 64 20 63 73 74 79 70 65 20 73 72 63 69 64  pid cstype srcid
49e0: 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09  } [state run {..
49f0: 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64      SELECT C.cid
4a00: 2c 20 43 2e 70 69 64 2c 20 43 53 2e 6e 61 6d 65  , C.pid, CS.name
4a10: 2c 20 43 2e 73 72 63 0a 09 20 20 20 20 46 52 4f  , C.src..    FRO
4a20: 4d 20 20 20 63 68 61 6e 67 65 73 65 74 20 43 2c  M   changeset C,
4a30: 20 63 73 74 79 70 65 20 43 53 0a 09 20 20 20 20   cstype CS..    
4a40: 57 48 45 52 45 20 20 43 2e 74 79 70 65 20 3d 20  WHERE  C.type = 
4a50: 43 53 2e 74 69 64 0a 09 20 20 20 20 4f 52 44 45  CS.tid..    ORDE
4a60: 52 20 42 59 20 43 2e 63 69 64 0a 09 7d 5d 20 7b  R BY C.cid..}] {
4a70: 0a 09 20 20 20 20 6c 6f 67 20 70 72 6f 67 72 65  ..    log progre
4a80: 73 73 20 32 20 63 73 65 74 73 20 24 6e 20 7b 7d  ss 2 csets $n {}
4a90: 0a 09 20 20 20 20 73 65 74 20 72 20 5b 24 74 79  ..    set r [$ty
4aa0: 70 65 20 25 41 55 54 4f 25 20 5b 24 72 65 70 6f  pe %AUTO% [$repo
4ab0: 73 69 74 6f 72 79 20 70 72 6f 6a 65 63 74 6f 66  sitory projectof
4ac0: 20 24 70 69 64 5d 20 24 63 73 74 79 70 65 20 24   $pid] $cstype $
4ad0: 73 72 63 69 64 20 5b 73 74 61 74 65 20 72 75 6e  srcid [state run
4ae0: 20 7b 0a 09 09 53 45 4c 45 43 54 20 43 2e 69 69   {...SELECT C.ii
4af0: 64 0a 09 09 46 52 4f 4d 20 20 20 63 73 69 74 65  d...FROM   csite
4b00: 6d 20 43 0a 09 09 57 48 45 52 45 20 20 43 2e 63  m C...WHERE  C.c
4b10: 69 64 20 3d 20 24 69 64 0a 09 09 4f 52 44 45 52  id = $id...ORDER
4b20: 20 42 59 20 43 2e 70 6f 73 0a 09 20 20 20 20 7d   BY C.pos..    }
4b30: 5d 20 24 69 64 5d 0a 09 20 20 20 20 69 6e 63 72  ] $id]..    incr
4b40: 20 6e 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20   n..}..return.  
4b50: 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74    }..    typemet
4b60: 68 6f 64 20 6c 6f 61 64 63 6f 75 6e 74 65 72 20  hod loadcounter 
4b70: 7b 7d 20 7b 0a 09 23 20 49 6e 69 74 69 61 6c 69  {} {..# Initiali
4b80: 7a 65 20 74 68 65 20 63 6f 75 6e 74 65 72 20 66  ze the counter f
4b90: 72 6f 6d 20 74 68 65 20 73 74 61 74 65 0a 09 6c  rom the state..l
4ba0: 6f 67 20 77 72 69 74 65 20 32 20 63 73 65 74 73  og write 2 csets
4bb0: 20 7b 4c 6f 61 64 69 6e 67 20 63 68 61 6e 67 65   {Loading change
4bc0: 73 65 74 20 63 6f 75 6e 74 65 72 7d 0a 09 73 65  set counter}..se
4bd0: 74 20 6d 79 63 6f 75 6e 74 65 72 20 5b 73 74 61  t mycounter [sta
4be0: 74 65 20 6f 6e 65 20 7b 20 53 45 4c 45 43 54 20  te one { SELECT 
4bf0: 4d 41 58 28 63 69 64 29 20 46 52 4f 4d 20 63 68  MAX(cid) FROM ch
4c00: 61 6e 67 65 73 65 74 20 7d 5d 0a 09 72 65 74 75  angeset }]..retu
4c10: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79  rn.    }..    ty
4c20: 70 65 6d 65 74 68 6f 64 20 6e 75 6d 20 7b 7d 20  pemethod num {} 
4c30: 7b 20 72 65 74 75 72 6e 20 24 6d 79 63 6f 75 6e  { return $mycoun
4c40: 74 65 72 20 7d 0a 0a 20 20 20 20 23 20 23 20 23  ter }..    # # #
4c50: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
4c60: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
4c70: 23 23 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 43  ##..    method C
4c80: 72 65 61 74 65 46 72 6f 6d 46 72 61 67 6d 65 6e  reateFromFragmen
4c90: 74 73 20 7b 66 72 61 67 6d 65 6e 74 73 20 63 76  ts {fragments cv
4ca0: 20 62 76 7d 20 7b 0a 09 75 70 76 61 72 20 31 20   bv} {..upvar 1 
4cb0: 24 63 76 20 63 6f 75 6e 74 65 72 20 24 62 76 20  $cv counter $bv 
4cc0: 62 72 65 61 6b 73 0a 09 55 6e 6d 61 70 49 74 65  breaks..UnmapIte
4cd0: 6d 73 20 24 6d 79 74 79 70 65 20 24 6d 79 69 74  ms $mytype $myit
4ce0: 65 6d 73 0a 0a 09 23 20 43 72 65 61 74 65 20 63  ems...# Create c
4cf0: 68 61 6e 67 65 73 65 74 73 20 66 6f 72 20 74 68  hangesets for th
4d00: 65 20 66 72 61 67 6d 65 6e 74 73 2c 20 72 65 75  e fragments, reu
4d10: 73 69 6e 67 20 74 68 65 20 63 75 72 72 65 6e 74  sing the current
4d20: 20 6f 6e 65 0a 09 23 20 66 6f 72 20 74 68 65 20   one..# for the 
4d30: 66 69 72 73 74 20 66 72 61 67 6d 65 6e 74 2e 20  first fragment. 
4d40: 57 65 20 73 6f 72 74 20 74 68 65 6d 20 69 6e 20  We sort them in 
4d50: 6f 72 64 65 72 20 74 6f 20 61 6c 6c 6f 77 0a 09  order to allow..
4d60: 23 20 63 68 65 63 6b 69 6e 67 20 66 6f 72 20 67  # checking for g
4d70: 61 70 73 20 61 6e 64 20 6e 69 63 65 20 6d 65 73  aps and nice mes
4d80: 73 61 67 65 73 2e 0a 0a 09 73 65 74 20 6e 65 77  sages....set new
4d90: 63 73 65 74 73 20 20 7b 7d 0a 09 73 65 74 20 66  csets  {}..set f
4da0: 72 61 67 6d 65 6e 74 73 20 5b 6c 73 6f 72 74 20  ragments [lsort 
4db0: 2d 69 6e 64 65 78 20 30 20 2d 69 6e 74 65 67 65  -index 0 -intege
4dc0: 72 20 24 66 72 61 67 6d 65 6e 74 73 5d 0a 0a 09  r $fragments]...
4dd0: 23 70 75 74 73 20 5c 74 2e 5b 6a 6f 69 6e 20 5b  #puts \t.[join [
4de0: 50 52 73 20 24 66 72 61 67 6d 65 6e 74 73 5d 20  PRs $fragments] 
4df0: 2e 5c 6e 5c 74 2e 5d 2e 0a 0a 09 42 6f 72 64 65  .\n\t.]....Borde
4e00: 72 20 5b 6c 69 6e 64 65 78 20 24 66 72 61 67 6d  r [lindex $fragm
4e10: 65 6e 74 73 20 30 5d 20 66 69 72 73 74 73 20 66  ents 0] firsts f
4e20: 69 72 73 74 65 0a 0a 09 69 6e 74 65 67 72 69 74  irste...integrit
4e30: 79 20 61 73 73 65 72 74 20 7b 24 66 69 72 73 74  y assert {$first
4e40: 73 20 3d 3d 20 30 7d 20 7b 42 61 64 20 66 72 61  s == 0} {Bad fra
4e50: 67 6d 65 6e 74 20 73 74 61 72 74 20 40 20 24 66  gment start @ $f
4e60: 69 72 73 74 73 2c 20 67 61 70 2c 20 6f 72 20 62  irsts, gap, or b
4e70: 65 66 6f 72 65 20 62 65 67 69 6e 6e 69 6e 67 20  efore beginning 
4e80: 6f 66 20 74 68 65 20 72 61 6e 67 65 7d 0a 0a 09  of the range}...
4e90: 73 65 74 20 6c 61 73 74 65 20 24 66 69 72 73 74  set laste $first
4ea0: 65 0a 09 66 6f 72 65 61 63 68 20 66 72 61 67 6d  e..foreach fragm
4eb0: 65 6e 74 20 5b 6c 72 61 6e 67 65 20 24 66 72 61  ent [lrange $fra
4ec0: 67 6d 65 6e 74 73 20 31 20 65 6e 64 5d 20 7b 0a  gments 1 end] {.
4ed0: 09 20 20 20 20 42 6f 72 64 65 72 20 24 66 72 61  .    Border $fra
4ee0: 67 6d 65 6e 74 20 73 20 65 0a 09 20 20 20 20 69  gment s e..    i
4ef0: 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20  ntegrity assert 
4f00: 7b 24 6c 61 73 74 65 20 3d 3d 20 28 24 73 20 2d  {$laste == ($s -
4f10: 20 31 29 7d 20 7b 42 61 64 20 66 72 61 67 6d 65   1)} {Bad fragme
4f20: 6e 74 20 62 6f 72 64 65 72 20 3c 24 6c 61 73 74  nt border <$last
4f30: 65 20 7c 20 24 73 3e 2c 20 67 61 70 20 6f 72 20  e | $s>, gap or 
4f40: 6f 76 65 72 6c 61 70 7d 0a 0a 09 20 20 20 20 73  overlap}...    s
4f50: 65 74 20 6e 65 77 20 5b 24 74 79 70 65 20 25 41  et new [$type %A
4f60: 55 54 4f 25 20 24 6d 79 70 72 6f 6a 65 63 74 20  UTO% $myproject 
4f70: 24 6d 79 74 79 70 65 20 24 6d 79 73 72 63 69 64  $mytype $mysrcid
4f80: 20 5b 6c 72 61 6e 67 65 20 24 6d 79 69 74 65 6d   [lrange $myitem
4f90: 73 20 24 73 20 24 65 5d 5d 0a 09 20 20 20 20 6c  s $s $e]]..    l
4fa0: 61 70 70 65 6e 64 20 6e 65 77 63 73 65 74 73 20  append newcsets 
4fb0: 24 6e 65 77 0a 09 20 20 20 20 69 6e 63 72 20 63  $new..    incr c
4fc0: 6f 75 6e 74 65 72 0a 0a 20 20 20 20 20 20 20 20  ounter..        
4fd0: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 34 20      log write 4 
4fe0: 63 73 65 74 73 20 22 42 72 65 61 6b 69 6e 67 20  csets "Breaking 
4ff0: 5b 24 73 65 6c 66 20 73 74 72 20 5d 20 40 20 24  [$self str ] @ $
5000: 6c 61 73 74 65 2c 20 6e 65 77 20 5b 24 6e 65 77  laste, new [$new
5010: 20 73 74 72 5d 2c 20 63 75 74 74 69 6e 67 20 24   str], cutting $
5020: 62 72 65 61 6b 73 28 24 6c 61 73 74 65 29 22 0a  breaks($laste)".
5030: 0a 09 20 20 20 20 73 65 74 20 6c 61 73 74 65 20  ..    set laste 
5040: 24 65 0a 09 7d 0a 0a 09 69 6e 74 65 67 72 69 74  $e..}...integrit
5050: 79 20 61 73 73 65 72 74 20 7b 0a 09 20 20 20 20  y assert {..    
5060: 24 6c 61 73 74 65 20 3d 3d 20 28 5b 6c 6c 65 6e  $laste == ([llen
5070: 67 74 68 20 24 6d 79 69 74 65 6d 73 5d 2d 31 29  gth $myitems]-1)
5080: 0a 09 7d 20 7b 42 61 64 20 66 72 61 67 6d 65 6e  ..} {Bad fragmen
5090: 74 20 65 6e 64 20 40 20 24 6c 61 73 74 65 2c 20  t end @ $laste, 
50a0: 67 61 70 2c 20 6f 72 20 62 65 79 6f 6e 64 20 65  gap, or beyond e
50b0: 6e 64 20 6f 66 20 74 68 65 20 72 61 6e 67 65 7d  nd of the range}
50c0: 0a 0a 09 23 20 50 75 74 20 74 68 65 20 66 69 72  ...# Put the fir
50d0: 73 74 20 66 72 61 67 6d 65 6e 74 20 69 6e 74 6f  st fragment into
50e0: 20 74 68 65 20 63 75 72 72 65 6e 74 20 63 68 61   the current cha
50f0: 6e 67 65 73 65 74 2c 20 61 6e 64 0a 09 23 20 75  ngeset, and..# u
5100: 70 64 61 74 65 20 74 68 65 20 69 6e 2d 6d 65 6d  pdate the in-mem
5110: 6f 72 79 20 69 6e 64 65 78 2e 20 57 65 20 63 61  ory index. We ca
5120: 6e 20 73 69 6d 70 6c 79 20 28 72 65 29 61 64 64  n simply (re)add
5130: 20 74 68 65 20 69 74 65 6d 73 0a 09 23 20 62 65   the items..# be
5140: 63 61 75 73 65 20 77 65 20 63 6c 65 61 72 65 64  cause we cleared
5150: 20 74 68 65 20 70 72 65 76 69 6f 75 73 6c 79 20   the previously 
5160: 65 78 69 73 74 69 6e 67 20 69 6e 66 6f 72 6d 61  existing informa
5170: 74 69 6f 6e 2c 20 73 65 65 0a 09 23 20 27 55 6e  tion, see..# 'Un
5180: 6d 61 70 49 74 65 6d 73 27 20 61 62 6f 76 65 2e  mapItems' above.
5190: 20 50 65 72 73 69 73 74 65 6e 63 65 20 64 6f 65   Persistence doe
51a0: 73 20 6e 6f 74 20 6d 61 74 74 65 72 20 68 65 72  s not matter her
51b0: 65 2c 20 6e 6f 6e 65 0a 09 23 20 6f 66 20 74 68  e, none..# of th
51c0: 65 20 63 68 61 6e 67 65 73 65 74 73 20 68 61 73  e changesets has
51d0: 20 62 65 65 6e 20 73 61 76 65 64 20 74 6f 20 74   been saved to t
51e0: 68 65 20 70 65 72 73 69 73 74 65 6e 74 20 73 74  he persistent st
51f0: 61 74 65 0a 09 23 20 79 65 74 2e 0a 0a 09 73 65  ate..# yet....se
5200: 74 20 6d 79 69 74 65 6d 73 20 20 5b 6c 72 61 6e  t myitems  [lran
5210: 67 65 20 24 6d 79 69 74 65 6d 73 20 20 30 20 24  ge $myitems  0 $
5220: 66 69 72 73 74 65 5d 0a 09 73 65 74 20 6d 79 74  firste]..set myt
5230: 69 74 65 6d 73 20 5b 6c 72 61 6e 67 65 20 24 6d  items [lrange $m
5240: 79 74 69 74 65 6d 73 20 30 20 24 66 69 72 73 74  ytitems 0 $first
5250: 65 5d 0a 09 4d 61 70 49 74 65 6d 73 20 24 6d 79  e]..MapItems $my
5260: 74 79 70 65 20 24 6d 79 69 74 65 6d 73 0a 09 72  type $myitems..r
5270: 65 74 75 72 6e 20 24 6e 65 77 63 73 65 74 73 0a  eturn $newcsets.
5280: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23      }..    # # #
5290: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
52a0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
52b0: 23 23 0a 0a 20 20 20 20 70 72 6f 63 20 42 72 65  ##..    proc Bre
52c0: 61 6b 44 69 72 65 63 74 44 65 70 65 6e 64 65 6e  akDirectDependen
52d0: 63 69 65 73 20 7b 74 68 65 69 74 65 6d 73 20 62  cies {theitems b
52e0: 76 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 6d 79  v} {..upvar 1 my
52f0: 74 79 70 65 6f 62 6a 20 6d 79 74 79 70 65 6f 62  typeobj mytypeob
5300: 6a 20 73 65 6c 66 20 73 65 6c 66 20 24 62 76 20  j self self $bv 
5310: 62 72 65 61 6b 73 0a 0a 09 61 72 72 61 79 20 73  breaks...array s
5320: 65 74 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  et dependencies 
5330: 7b 7d 0a 09 24 6d 79 74 79 70 65 6f 62 6a 20 69  {}..$mytypeobj i
5340: 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f 72  nternalsuccessor
5350: 73 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 24  s dependencies $
5360: 74 68 65 69 74 65 6d 73 0a 09 69 66 20 7b 21 5b  theitems..if {![
5370: 61 72 72 61 79 20 73 69 7a 65 20 64 65 70 65 6e  array size depen
5380: 64 65 6e 63 69 65 73 5d 7d 20 7b 0a 09 20 20 20  dencies]} {..   
5390: 20 72 65 74 75 72 6e 20 7b 7d 0a 09 7d 20 3b 20   return {}..} ; 
53a0: 23 20 4e 6f 74 68 69 6e 67 20 74 6f 20 62 72 65  # Nothing to bre
53b0: 61 6b 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  ak....log write 
53c0: 35 20 63 73 65 74 73 20 2e 2e 2e 5b 24 73 65 6c  5 csets ...[$sel
53d0: 66 20 73 74 72 5d 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  f str]..........
53e0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
53f0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
5400: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 09 76  ...............v
5410: 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 65 6d 3a 3a 6d  c::tools::mem::m
5420: 61 72 6b 0a 0a 09 72 65 74 75 72 6e 20 5b 42 72  ark...return [Br
5430: 65 61 6b 65 72 43 6f 72 65 20 24 74 68 65 69 74  eakerCore $theit
5440: 65 6d 73 20 64 65 70 65 6e 64 65 6e 63 69 65 73  ems dependencies
5450: 20 62 72 65 61 6b 73 5d 0a 20 20 20 20 7d 0a 0a   breaks].    }..
5460: 20 20 20 20 70 72 6f 63 20 42 72 65 61 6b 65 72      proc Breaker
5470: 43 6f 72 65 20 7b 74 68 65 69 74 65 6d 73 20 64  Core {theitems d
5480: 76 20 62 76 7d 20 7b 0a 09 23 20 42 72 65 61 6b  v bv} {..# Break
5490: 20 61 20 73 65 74 20 6f 66 20 72 65 76 69 73 69   a set of revisi
54a0: 6f 6e 73 20 69 6e 74 6f 20 66 72 61 67 6d 65 6e  ons into fragmen
54b0: 74 73 20 77 68 69 63 68 20 68 61 76 65 20 6e 6f  ts which have no
54c0: 0a 09 23 20 69 6e 74 65 72 6e 61 6c 20 64 65 70  ..# internal dep
54d0: 65 6e 64 65 6e 63 69 65 73 2e 0a 0a 09 23 20 57  endencies....# W
54e0: 65 20 70 65 72 66 6f 72 6d 20 61 6c 6c 20 6e 65  e perform all ne
54f0: 63 65 73 73 61 72 79 20 73 70 6c 69 74 73 20 69  cessary splits i
5500: 6e 20 6f 6e 65 20 67 6f 2c 20 69 6e 73 74 65 61  n one go, instea
5510: 64 20 6f 66 20 6f 6e 6c 79 0a 09 23 20 6f 6e 65  d of only..# one
5520: 2e 20 54 68 65 20 70 72 65 76 69 6f 75 73 20 61  . The previous a
5530: 6c 67 6f 72 69 74 68 6d 2c 20 61 64 61 70 74 65  lgorithm, adapte
5540: 64 20 66 72 6f 6d 20 63 76 73 32 73 76 6e 2c 20  d from cvs2svn, 
5550: 63 6f 6d 70 75 74 65 64 0a 09 23 20 61 20 6c 6f  computed..# a lo
5560: 74 20 6f 66 20 73 74 61 74 65 20 77 68 69 63 68  t of state which
5570: 20 77 61 73 20 74 68 72 6f 77 6e 20 61 77 61 79   was thrown away
5580: 20 61 6e 64 20 74 68 65 6e 20 63 6f 6d 70 75 74   and then comput
5590: 65 64 20 61 67 61 69 6e 0a 09 23 20 66 6f 72 20  ed again..# for 
55a0: 65 61 63 68 20 6f 66 20 74 68 65 20 66 72 61 67  each of the frag
55b0: 6d 65 6e 74 73 2e 20 49 74 20 73 68 6f 75 6c 64  ments. It should
55c0: 20 62 65 20 65 61 73 69 65 72 20 74 6f 20 75 70   be easier to up
55d0: 64 61 74 65 20 61 6e 64 0a 09 23 20 72 65 75 73  date and..# reus
55e0: 65 20 74 68 61 74 20 73 74 61 74 65 2e 0a 0a 09  e that state....
55f0: 75 70 76 61 72 20 31 20 24 64 76 20 64 65 70 65  upvar 1 $dv depe
5600: 6e 64 65 6e 63 69 65 73 20 24 62 76 20 62 72 65  ndencies $bv bre
5610: 61 6b 73 0a 0a 09 23 20 57 65 20 68 61 76 65 20  aks...# We have 
5620: 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65  internal depende
5630: 6e 63 69 65 73 20 74 6f 20 62 72 65 61 6b 2e 20  ncies to break. 
5640: 57 65 20 6e 6f 77 20 69 74 65 72 61 74 65 20 6f  We now iterate o
5650: 76 65 72 0a 09 23 20 61 6c 6c 20 70 6f 73 69 74  ver..# all posit
5660: 69 6f 6e 73 20 69 6e 20 74 68 65 20 6c 69 73 74  ions in the list
5670: 20 28 77 68 69 63 68 20 69 73 20 63 68 72 6f 6e   (which is chron
5680: 6f 6c 6f 67 69 63 61 6c 2c 20 61 74 20 6c 65 61  ological, at lea
5690: 73 74 0a 09 23 20 61 73 20 66 61 72 20 61 73 20  st..# as far as 
56a0: 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20 61  the timestamps a
56b0: 72 65 20 63 6f 72 72 65 63 74 20 61 6e 64 20 75  re correct and u
56c0: 6e 69 71 75 65 29 20 61 6e 64 0a 09 23 20 64 65  nique) and..# de
56d0: 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65 73 74  termine the best
56e0: 20 70 6f 73 69 74 69 6f 6e 20 66 6f 72 20 74 68   position for th
56f0: 65 20 62 72 65 61 6b 2c 20 62 79 20 74 72 79 69  e break, by tryi
5700: 6e 67 20 74 6f 0a 09 23 20 62 72 65 61 6b 20 61  ng to..# break a
5710: 73 20 6d 61 6e 79 20 64 65 70 65 6e 64 65 6e 63  s many dependenc
5720: 69 65 73 20 61 73 20 70 6f 73 73 69 62 6c 65 20  ies as possible 
5730: 69 6e 20 6f 6e 65 20 67 6f 2e 20 57 68 65 6e 20  in one go. When 
5740: 61 0a 09 23 20 62 72 65 61 6b 20 77 61 73 20 66  a..# break was f
5750: 6f 75 6e 64 20 74 68 69 73 20 69 73 20 72 65 64  ound this is red
5760: 6f 6e 65 20 66 6f 72 20 74 68 65 20 66 72 61 67  one for the frag
5770: 6d 65 6e 74 73 20 63 6f 6d 69 6e 67 20 61 6e 64  ments coming and
5780: 0a 09 23 20 61 66 74 65 72 2c 20 61 66 74 65 72  ..# after, after
5790: 20 75 70 64 69 6e 67 20 74 68 65 20 63 72 6f 73   upding the cros
57a0: 73 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e  sing information
57b0: 2e 0a 0a 09 23 20 44 61 74 61 20 73 74 72 75 63  ....# Data struc
57c0: 74 75 72 65 73 3a 0a 09 23 20 4d 61 70 3a 20 20  tures:..# Map:  
57d0: 50 4f 53 20 20 20 72 65 76 69 73 69 6f 6e 20 69  POS   revision i
57e0: 64 20 20 20 20 20 20 2d 3e 20 70 6f 73 69 74 69  d      -> positi
57f0: 6f 6e 20 69 6e 20 6c 69 73 74 2e 0a 09 23 20 20  on in list...#  
5800: 20 20 20 20 20 43 52 4f 53 53 20 70 6f 73 69 74       CROSS posit
5810: 69 6f 6e 20 69 6e 20 6c 69 73 74 20 2d 3e 20 6e  ion in list -> n
5820: 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 65  umber of depende
5830: 6e 63 69 65 73 20 63 72 6f 73 73 69 6e 67 20 69  ncies crossing i
5840: 74 0a 09 23 20 20 20 20 20 20 20 44 45 50 43 20  t..#       DEPC 
5850: 20 64 65 70 65 6e 64 65 6e 63 79 20 20 20 20 20   dependency     
5860: 20 20 2d 3e 20 70 6f 73 69 74 69 6f 6e 73 20 69    -> positions i
5870: 74 20 63 72 6f 73 73 65 73 0a 09 23 20 4c 69 73  t crosses..# Lis
5880: 74 3a 20 52 41 4e 47 45 20 4f 66 20 74 68 65 20  t: RANGE Of the 
5890: 70 6f 73 69 74 69 6f 6e 73 20 69 74 73 65 6c 66  positions itself
58a0: 2e 0a 09 23 20 4d 61 70 3a 20 20 44 45 4c 54 41  ...# Map:  DELTA
58b0: 20 70 6f 73 69 74 69 6f 6e 20 69 6e 20 6c 69 73   position in lis
58c0: 74 20 2d 3e 20 74 69 6d 65 20 64 65 6c 74 61 20  t -> time delta 
58d0: 62 65 74 77 65 65 6e 20 69 74 73 20 72 65 76 69  between its revi
58e0: 73 69 6f 6e 0a 09 23 20 20 20 20 20 20 20 20 20  sion..#         
58f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5900: 20 20 20 20 20 20 20 20 61 6e 64 20 74 68 65 20          and the 
5910: 6e 65 78 74 2c 20 69 66 20 61 6e 79 2e 0a 09 23  next, if any...#
5920: 20 41 20 64 65 70 65 6e 64 65 6e 63 79 20 69 73   A dependency is
5930: 20 61 20 73 69 6e 67 6c 65 2d 65 6c 65 6d 65 6e   a single-elemen
5940: 74 20 6d 61 70 20 70 61 72 65 6e 74 20 2d 3e 20  t map parent -> 
5950: 63 68 69 6c 64 0a 0a 09 23 20 49 6e 69 74 69 61  child...# Initia
5960: 6c 69 7a 65 42 72 65 61 6b 53 74 61 74 65 20 69  lizeBreakState i
5970: 6e 69 74 69 61 6c 69 7a 65 73 20 74 68 65 69 72  nitializes their
5980: 20 63 6f 6e 74 65 6e 74 73 20 61 66 74 65 72 0a   contents after.
5990: 09 23 20 75 70 76 61 72 27 69 6e 67 20 74 68 65  .# upvar'ing the
59a0: 6d 20 66 72 6f 6d 20 74 68 69 73 20 73 63 6f 70  m from this scop
59b0: 65 2e 20 49 74 20 75 73 65 73 20 74 68 65 20 69  e. It uses the i
59c0: 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 6e 0a 09 23  nformation in..#
59d0: 20 44 45 50 45 4e 44 45 4e 43 49 45 53 20 74 6f   DEPENDENCIES to
59e0: 20 64 6f 20 73 6f 2e 0a 0a 09 49 6e 69 74 69 61   do so....Initia
59f0: 6c 69 7a 65 42 72 65 61 6b 53 74 61 74 65 20 24  lizeBreakState $
5a00: 74 68 65 69 74 65 6d 73 0a 0a 09 73 65 74 20 66  theitems...set f
5a10: 72 61 67 6d 65 6e 74 73 20 7b 7d 0a 09 73 65 74  ragments {}..set
5a20: 20 6e 65 77 20 20 20 20 20 20 20 5b 6c 69 73 74   new       [list
5a30: 20 24 72 61 6e 67 65 5d 0a 0a 09 23 20 49 6e 73   $range]...# Ins
5a40: 74 65 61 64 20 6f 66 20 6f 6e 65 20 6c 69 73 74  tead of one list
5a50: 20 68 6f 6c 64 69 6e 67 20 62 6f 74 68 20 70 72   holding both pr
5a60: 6f 63 65 73 73 65 64 20 61 6e 64 20 70 65 6e 64  ocessed and pend
5a70: 69 6e 67 0a 09 23 20 66 72 61 67 6d 65 6e 74 73  ing..# fragments
5a80: 20 77 65 20 75 73 65 20 74 77 6f 2c 20 6f 6e 65   we use two, one
5a90: 20 66 6f 72 20 74 68 65 20 66 72 61 6d 65 6e 74   for the frament
5aa0: 73 20 74 6f 20 70 72 6f 63 65 73 73 2c 20 6f 6e  s to process, on
5ab0: 65 0a 09 23 20 74 6f 20 68 6f 6c 64 20 74 68 65  e..# to hold the
5ac0: 20 6e 65 77 20 66 72 61 67 6d 65 6e 74 73 2c 20   new fragments, 
5ad0: 61 6e 64 20 74 68 65 20 6c 61 74 74 65 72 20 69  and the latter i
5ae0: 73 20 63 6f 70 69 65 64 20 74 6f 20 74 68 65 0a  s copied to the.
5af0: 09 23 20 66 6f 72 6d 65 72 20 77 68 65 6e 20 74  .# former when t
5b00: 68 65 79 20 72 75 6e 20 6f 75 74 2e 20 54 68 69  hey run out. Thi
5b10: 73 20 6b 65 65 70 73 20 74 68 65 20 6c 69 73 74  s keeps the list
5b20: 20 6f 66 20 70 65 6e 64 69 6e 67 0a 09 23 20 66   of pending..# f
5b30: 72 61 67 6d 65 6e 74 73 20 73 68 6f 72 74 20 77  ragments short w
5b40: 69 74 68 6f 75 74 20 73 61 63 72 69 66 69 63 69  ithout sacrifici
5b50: 6e 67 20 73 70 65 65 64 20 62 79 20 73 68 69 66  ng speed by shif
5b60: 74 69 6e 67 20 73 74 75 66 66 0a 09 23 20 64 6f  ting stuff..# do
5b70: 77 6e 2e 20 57 65 20 65 73 70 65 63 69 61 6c 6c  wn. We especiall
5b80: 79 20 64 72 6f 70 20 74 68 65 20 6d 65 6d 6f 72  y drop the memor
5b90: 79 20 6f 66 20 66 72 61 67 6d 65 6e 74 73 20 62  y of fragments b
5ba0: 72 6f 6b 65 6e 0a 09 23 20 64 75 72 69 6e 67 20  roken..# during 
5bb0: 70 72 6f 63 65 73 73 69 6e 67 20 61 66 74 65 72  processing after
5bc0: 20 61 20 73 68 6f 72 74 20 74 69 6d 65 2c 20 69   a short time, i
5bd0: 6e 73 74 65 61 64 20 6f 66 20 6c 65 74 74 69 6e  nstead of lettin
5be0: 67 20 69 74 0a 09 23 20 63 6f 6e 73 75 6d 65 20  g it..# consume 
5bf0: 6d 65 6d 6f 72 79 2e 0a 0a 09 77 68 69 6c 65 20  memory....while 
5c00: 7b 5b 6c 6c 65 6e 67 74 68 20 24 6e 65 77 5d 7d  {[llength $new]}
5c10: 20 7b 0a 0a 09 20 20 20 20 73 65 74 20 70 65 6e   {...    set pen
5c20: 64 69 6e 67 20 24 6e 65 77 0a 09 20 20 20 20 73  ding $new..    s
5c30: 65 74 20 6e 65 77 20 20 20 20 20 7b 7d 0a 09 20  et new     {}.. 
5c40: 20 20 20 73 65 74 20 61 74 20 20 20 20 20 20 30     set at      0
5c50: 0a 0a 09 20 20 20 20 77 68 69 6c 65 20 7b 24 61  ...    while {$a
5c60: 74 20 3c 20 5b 6c 6c 65 6e 67 74 68 20 24 70 65  t < [llength $pe
5c70: 6e 64 69 6e 67 5d 7d 20 7b 0a 09 09 73 65 74 20  nding]} {...set 
5c80: 63 75 72 72 65 6e 74 20 5b 6c 69 6e 64 65 78 20  current [lindex 
5c90: 24 70 65 6e 64 69 6e 67 20 24 61 74 5d 0a 0a 09  $pending $at]...
5ca0: 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65  .log write 6 cse
5cb0: 74 73 20 7b 2e 20 2e 20 2e 2e 20 2e 2e 2e 20 2e  ts {. . .. ... .
5cc0: 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e 2e  .... ........ ..
5cd0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 7d 0a 09 09 6c  ...........}...l
5ce0: 6f 67 20 77 72 69 74 65 20 36 20 63 73 65 74 73  og write 6 csets
5cf0: 20 7b 53 63 68 65 64 75 6c 65 64 20 20 20 5b 6a   {Scheduled   [j
5d00: 6f 69 6e 20 5b 50 52 73 20 5b 6c 72 61 6e 67 65  oin [PRs [lrange
5d10: 20 24 70 65 6e 64 69 6e 67 20 24 61 74 20 65 6e   $pending $at en
5d20: 64 5d 5d 20 7b 20 7d 5d 7d 0a 09 09 6c 6f 67 20  d]] { }]}...log 
5d30: 77 72 69 74 65 20 36 20 63 73 65 74 73 20 7b 43  write 6 csets {C
5d40: 6f 6e 73 69 64 65 72 69 6e 67 20 5b 50 52 20 24  onsidering [PR $
5d50: 63 75 72 72 65 6e 74 5d 20 5c 5b 24 61 74 2f 5b  current] \[$at/[
5d60: 6c 6c 65 6e 67 74 68 20 24 70 65 6e 64 69 6e 67  llength $pending
5d70: 5d 5c 5d 7d 0a 0a 09 09 73 65 74 20 62 65 73 74  ]\]}....set best
5d80: 20 5b 46 69 6e 64 42 65 73 74 42 72 65 61 6b 20   [FindBestBreak 
5d90: 24 63 75 72 72 65 6e 74 5d 0a 0a 09 09 69 66 20  $current]....if 
5da0: 7b 24 62 65 73 74 20 3c 20 30 7d 20 7b 0a 09 09  {$best < 0} {...
5db0: 20 20 20 20 23 20 54 68 65 20 69 6e 73 70 65 63      # The inspec
5dc0: 74 65 64 20 72 61 6e 67 65 20 68 61 73 20 6e 6f  ted range has no
5dd0: 20 69 6e 74 65 72 6e 61 6c 0a 09 09 20 20 20 20   internal...    
5de0: 23 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 20  # dependencies. 
5df0: 54 68 69 73 20 69 73 20 61 20 63 6f 6d 70 6c 65  This is a comple
5e00: 74 65 20 66 72 61 67 6d 65 6e 74 2e 0a 09 09 20  te fragment.... 
5e10: 20 20 20 6c 61 70 70 65 6e 64 20 66 72 61 67 6d     lappend fragm
5e20: 65 6e 74 73 20 24 63 75 72 72 65 6e 74 0a 0a 09  ents $current...
5e30: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36  .    log write 6
5e40: 20 63 73 65 74 73 20 22 4e 6f 20 62 72 65 61 6b   csets "No break
5e50: 73 2c 20 66 69 6e 61 6c 22 0a 09 09 7d 20 65 6c  s, final"...} el
5e60: 73 65 20 7b 0a 09 09 20 20 20 20 23 20 53 70 6c  se {...    # Spl
5e70: 69 74 20 74 68 65 20 72 61 6e 67 65 20 61 6e 64  it the range and
5e80: 20 73 63 68 65 64 75 6c 65 20 74 68 65 20 72 65   schedule the re
5e90: 73 75 6c 74 69 6e 67 0a 09 09 20 20 20 20 23 20  sulting...    # 
5ea0: 66 72 61 67 6d 65 6e 74 73 20 66 6f 72 20 66 75  fragments for fu
5eb0: 72 74 68 65 72 20 69 6e 73 70 65 63 74 69 6f 6e  rther inspection
5ec0: 2e 20 52 65 6d 65 6d 62 65 72 20 74 68 65 0a 09  . Remember the..
5ed0: 09 20 20 20 20 23 20 6e 75 6d 62 65 72 20 6f 66  .    # number of
5ee0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 63 75   dependencies cu
5ef0: 74 20 62 65 66 6f 72 65 20 77 65 20 72 65 6d 6f  t before we remo
5f00: 76 65 20 74 68 65 6d 0a 09 09 20 20 20 20 23 20  ve them...    # 
5f10: 66 72 6f 6d 20 63 6f 6e 73 69 64 65 72 61 74 69  from considerati
5f20: 6f 6e 2c 20 66 6f 72 20 64 6f 63 75 6d 65 6e 74  on, for document
5f30: 61 74 69 6f 6e 20 6c 61 74 65 72 2e 0a 0a 09 09  ation later.....
5f40: 20 20 20 20 73 65 74 20 62 72 65 61 6b 73 28 24      set breaks($
5f50: 62 65 73 74 29 20 24 63 72 6f 73 73 28 24 62 65  best) $cross($be
5f60: 73 74 29 0a 0a 09 09 20 20 20 20 6c 6f 67 20 77  st)....    log w
5f70: 72 69 74 65 20 36 20 63 73 65 74 73 20 22 42 65  rite 6 csets "Be
5f80: 73 74 20 62 72 65 61 6b 20 40 20 24 62 65 73 74  st break @ $best
5f90: 2c 20 63 75 74 74 69 6e 67 20 5b 6e 73 70 20 24  , cutting [nsp $
5fa0: 63 72 6f 73 73 28 24 62 65 73 74 29 20 64 65 70  cross($best) dep
5fb0: 65 6e 64 65 6e 63 79 20 64 65 70 65 6e 64 65 6e  endency dependen
5fc0: 63 69 65 73 5d 22 0a 0a 09 09 20 20 20 20 23 20  cies]"....    # 
5fd0: 4e 6f 74 65 3a 20 54 68 65 20 76 61 6c 75 65 20  Note: The value 
5fe0: 6f 66 20 62 65 73 74 20 69 73 20 61 6e 20 61 62  of best is an ab
5ff0: 6f 6c 75 74 65 20 6c 6f 63 61 74 69 6f 6e 0a 09  olute location..
6000: 09 20 20 20 20 23 20 69 6e 20 6d 79 69 74 65 6d  .    # in myitem
6010: 73 2e 20 55 73 65 20 74 68 65 20 73 74 61 72 74  s. Use the start
6020: 20 6f 66 20 63 75 72 72 65 6e 74 20 74 6f 20 6d   of current to m
6030: 61 6b 65 20 69 74 0a 09 09 20 20 20 20 23 20 61  ake it...    # a
6040: 6e 20 69 6e 64 65 78 20 61 62 73 6f 6c 75 74 65  n index absolute
6050: 20 74 6f 20 63 75 72 72 65 6e 74 2e 0a 0a 09 09   to current.....
6060: 20 20 20 20 73 65 74 20 62 72 65 6c 20 5b 65 78      set brel [ex
6070: 70 72 20 7b 24 62 65 73 74 20 2d 20 5b 6c 69 6e  pr {$best - [lin
6080: 64 65 78 20 24 63 75 72 72 65 6e 74 20 30 5d 7d  dex $current 0]}
6090: 5d 0a 09 09 20 20 20 20 73 65 74 20 62 6e 65 78  ]...    set bnex
60a0: 74 20 24 62 72 65 6c 20 3b 20 69 6e 63 72 20 62  t $brel ; incr b
60b0: 6e 65 78 74 0a 09 09 20 20 20 20 73 65 74 20 66  next...    set f
60c0: 72 61 67 62 65 66 6f 72 65 20 5b 6c 72 61 6e 67  ragbefore [lrang
60d0: 65 20 24 63 75 72 72 65 6e 74 20 30 20 24 62 72  e $current 0 $br
60e0: 65 6c 5d 0a 09 09 20 20 20 20 73 65 74 20 66 72  el]...    set fr
60f0: 61 67 61 66 74 65 72 20 20 5b 6c 72 61 6e 67 65  agafter  [lrange
6100: 20 24 63 75 72 72 65 6e 74 20 24 62 6e 65 78 74   $current $bnext
6110: 20 65 6e 64 5d 0a 0a 09 09 20 20 20 20 6c 6f 67   end]....    log
6120: 20 77 72 69 74 65 20 36 20 63 73 65 74 73 20 22   write 6 csets "
6130: 4e 65 77 20 70 69 65 63 65 73 20 20 5b 50 52 20  New pieces  [PR 
6140: 24 66 72 61 67 62 65 66 6f 72 65 5d 20 5b 50 52  $fragbefore] [PR
6150: 20 24 66 72 61 67 61 66 74 65 72 5d 22 0a 0a 09   $fragafter]"...
6160: 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61  .    integrity a
6170: 73 73 65 72 74 20 7b 5b 6c 6c 65 6e 67 74 68 20  ssert {[llength 
6180: 24 66 72 61 67 62 65 66 6f 72 65 5d 7d 20 7b 46  $fragbefore]} {F
6190: 6f 75 6e 64 20 7a 65 72 6f 2d 6c 65 6e 67 74 68  ound zero-length
61a0: 20 66 72 61 67 6d 65 6e 74 20 61 74 20 74 68 65   fragment at the
61b0: 20 62 65 67 69 6e 6e 69 6e 67 7d 0a 09 09 20 20   beginning}...  
61c0: 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73 65    integrity asse
61d0: 72 74 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 66 72  rt {[llength $fr
61e0: 61 67 61 66 74 65 72 5d 7d 20 20 7b 46 6f 75 6e  agafter]}  {Foun
61f0: 64 20 7a 65 72 6f 2d 6c 65 6e 67 74 68 20 66 72  d zero-length fr
6200: 61 67 6d 65 6e 74 20 61 74 20 74 68 65 20 65 6e  agment at the en
6210: 64 7d 0a 0a 09 09 20 20 20 20 6c 61 70 70 65 6e  d}....    lappen
6220: 64 20 6e 65 77 20 24 66 72 61 67 62 65 66 6f 72  d new $fragbefor
6230: 65 20 24 66 72 61 67 61 66 74 65 72 0a 09 09 20  e $fragafter... 
6240: 20 20 20 43 75 74 41 74 20 24 62 65 73 74 0a 09     CutAt $best..
6250: 09 7d 0a 0a 09 09 69 6e 63 72 20 61 74 0a 09 20  .}....incr at.. 
6260: 20 20 20 7d 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72     }..}...log wr
6270: 69 74 65 20 36 20 63 73 65 74 73 20 22 2e 20 2e  ite 6 csets ". .
6280: 20 2e 2e 20 2e 2e 2e 20 2e 2e 2e 2e 2e 20 2e 2e   .. ... ..... ..
6290: 2e 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 2e  ...... .........
62a0: 2e 2e 2e 2e 22 0a 0a 09 72 65 74 75 72 6e 20 24  ...."...return $
62b0: 66 72 61 67 6d 65 6e 74 73 0a 20 20 20 20 7d 0a  fragments.    }.
62c0: 0a 20 20 20 20 70 72 6f 63 20 49 6e 69 74 69 61  .    proc Initia
62d0: 6c 69 7a 65 42 72 65 61 6b 53 74 61 74 65 20 7b  lizeBreakState {
62e0: 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70  revisions} {..up
62f0: 76 61 72 20 31 20 70 6f 73 20 70 6f 73 20 63 72  var 1 pos pos cr
6300: 6f 73 73 20 63 72 6f 73 73 20 72 61 6e 67 65 20  oss cross range 
6310: 72 61 6e 67 65 20 64 65 70 63 20 64 65 70 63 20  range depc depc 
6320: 64 65 6c 74 61 20 64 65 6c 74 61 20 5c 0a 09 20  delta delta \.. 
6330: 20 20 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20     dependencies 
6340: 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 0a 09 23  dependencies...#
6350: 20 46 69 72 73 74 20 77 65 20 63 72 65 61 74 65   First we create
6360: 20 61 20 6d 61 70 20 6f 66 20 70 6f 73 69 74 69   a map of positi
6370: 6f 6e 73 20 74 6f 20 6d 61 6b 65 20 69 74 20 65  ons to make it e
6380: 61 73 69 65 72 20 74 6f 0a 09 23 20 64 65 74 65  asier to..# dete
6390: 72 6d 69 6e 65 20 77 68 65 74 68 65 72 20 61 20  rmine whether a 
63a0: 64 65 70 65 6e 64 65 6e 63 79 20 63 72 6f 73 73  dependency cross
63b0: 65 73 20 61 20 70 61 72 74 69 63 75 6c 61 72 20  es a particular 
63c0: 69 6e 64 65 78 2e 0a 0a 09 6c 6f 67 20 77 72 69  index....log wri
63d0: 74 65 20 31 34 20 63 73 65 74 73 20 7b 49 42 53  te 14 csets {IBS
63e0: 3a 20 23 72 65 76 20 5b 6c 6c 65 6e 67 74 68 20  : #rev [llength 
63f0: 24 72 65 76 69 73 69 6f 6e 73 5d 7d 0a 09 6c 6f  $revisions]}..lo
6400: 67 20 77 72 69 74 65 20 31 34 20 63 73 65 74 73  g write 14 csets
6410: 20 7b 49 42 53 3a 20 70 6f 73 20 6d 61 70 2c 20   {IBS: pos map, 
6420: 63 72 6f 73 73 20 63 6f 75 6e 74 65 72 7d 0a 0a  cross counter}..
6430: 09 61 72 72 61 79 20 73 65 74 20 70 6f 73 20 20  .array set pos  
6440: 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 20 63   {}..array set c
6450: 72 6f 73 73 20 7b 7d 0a 09 61 72 72 61 79 20 73  ross {}..array s
6460: 65 74 20 64 65 70 63 20 20 7b 7d 0a 09 73 65 74  et depc  {}..set
6470: 20 72 61 6e 67 65 20 20 20 20 20 20 20 7b 7d 0a   range       {}.
6480: 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 65 61 63  .set n 0..foreac
6490: 68 20 72 65 76 20 24 72 65 76 69 73 69 6f 6e 73  h rev $revisions
64a0: 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20   {..    lappend 
64b0: 72 61 6e 67 65 20 24 6e 0a 09 20 20 20 20 73 65  range $n..    se
64c0: 74 20 70 6f 73 28 24 72 65 76 29 20 24 6e 0a 09  t pos($rev) $n..
64d0: 20 20 20 20 73 65 74 20 63 72 6f 73 73 28 24 6e      set cross($n
64e0: 29 20 30 0a 09 20 20 20 20 69 6e 63 72 20 6e 0a  ) 0..    incr n.
64f0: 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 31  .}...log write 1
6500: 34 20 63 73 65 74 73 20 7b 49 42 53 3a 20 70 6f  4 csets {IBS: po
6510: 73 2f 5b 61 72 72 61 79 20 73 69 7a 65 20 70 6f  s/[array size po
6520: 73 5d 2c 20 63 72 6f 73 73 2f 5b 61 72 72 61 79  s], cross/[array
6530: 20 73 69 7a 65 20 63 72 6f 73 73 5d 7d 0a 0a 09   size cross]}...
6540: 23 20 53 65 63 6f 6e 64 6c 79 20 77 65 20 63 6f  # Secondly we co
6550: 75 6e 74 20 74 68 65 20 63 72 6f 73 73 69 6e 67  unt the crossing
6560: 73 20 70 65 72 20 70 6f 73 69 74 69 6f 6e 2c 20  s per position, 
6570: 62 79 20 69 74 65 72 61 74 69 6e 67 0a 09 23 20  by iterating..# 
6580: 6f 76 65 72 20 74 68 65 20 72 65 63 6f 72 64 65  over the recorde
6590: 64 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e  d internal depen
65a0: 64 65 6e 63 69 65 73 2e 0a 0a 09 23 20 4e 6f 74  dencies....# Not
65b0: 65 3a 20 49 66 20 74 68 65 20 74 69 6d 65 73 74  e: If the timest
65c0: 61 6d 70 73 20 61 72 65 20 62 61 64 6c 79 20 6f  amps are badly o
65d0: 75 74 20 6f 66 20 6f 72 64 65 72 20 69 74 20 69  ut of order it i
65e0: 73 0a 09 23 20 20 20 20 20 20 20 70 6f 73 73 69  s..#       possi
65f0: 62 6c 65 20 74 6f 20 68 61 76 65 20 61 20 62 61  ble to have a ba
6600: 63 6b 77 61 72 64 20 73 75 63 63 65 73 73 6f 72  ckward successor
6610: 20 64 65 70 65 6e 64 65 6e 63 79 2c 0a 09 23 20   dependency,..# 
6620: 20 20 20 20 20 20 69 2e 65 2e 20 77 69 74 68 20        i.e. with 
6630: 73 74 61 72 74 20 3e 20 65 6e 64 2e 20 57 65 20  start > end. We 
6640: 6d 61 79 20 68 61 76 65 20 74 6f 20 73 77 61 70  may have to swap
6650: 20 74 68 65 20 69 6e 64 69 63 65 73 0a 09 23 20   the indices..# 
6660: 20 20 20 20 20 20 74 6f 20 65 6e 73 75 72 65 20        to ensure 
6670: 74 68 61 74 20 74 68 65 20 66 6f 6c 6c 6f 77 69  that the followi
6680: 6e 67 20 6c 6f 6f 70 20 72 75 6e 73 20 63 6f 72  ng loop runs cor
6690: 72 65 63 74 6c 79 2e 0a 09 23 0a 09 23 20 4e 6f  rectly...#..# No
66a0: 74 65 20 32 3a 20 73 74 61 72 74 20 3d 3d 20 65  te 2: start == e
66b0: 6e 64 20 69 73 20 6e 6f 74 20 70 6f 73 73 69 62  nd is not possib
66c0: 6c 65 2e 20 49 74 20 69 6e 64 69 63 61 74 65 73  le. It indicates
66d0: 20 61 0a 09 23 20 20 20 20 20 20 20 20 20 73 65   a..#         se
66e0: 6c 66 2d 64 65 70 65 6e 64 65 6e 63 79 20 64 75  lf-dependency du
66f0: 65 20 74 6f 20 74 68 65 20 75 6e 69 71 75 65 6e  e to the uniquen
6700: 65 73 73 20 6f 66 20 70 6f 73 69 74 69 6f 6e 73  ess of positions
6710: 2c 0a 09 23 20 20 20 20 20 20 20 20 20 61 6e 64  ,..#         and
6720: 20 74 68 61 74 20 69 73 20 73 6f 6d 65 74 68 69   that is somethi
6730: 6e 67 20 77 65 20 68 61 76 65 20 72 75 6c 65 64  ng we have ruled
6740: 20 6f 75 74 20 61 6c 72 65 61 64 79 2c 20 73 65   out already, se
6750: 65 0a 09 23 20 20 20 20 20 20 20 20 20 27 72 65  e..#         're
6760: 76 20 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73  v internalsucces
6770: 73 6f 72 73 27 2e 0a 0a 09 6c 6f 67 20 77 72 69  sors'....log wri
6780: 74 65 20 31 34 20 63 73 65 74 73 20 7b 49 42 53  te 14 csets {IBS
6790: 3a 20 63 72 6f 73 73 20 63 6f 75 6e 74 65 72 20  : cross counter 
67a0: 66 69 6c 6c 69 6e 67 2c 20 70 6f 73 2f 63 72 6f  filling, pos/cro
67b0: 73 73 20 6d 61 70 7d 0a 0a 09 66 6f 72 65 61 63  ss map}...foreac
67c0: 68 20 7b 72 69 64 20 63 68 69 6c 64 72 65 6e 7d  h {rid children}
67d0: 20 5b 61 72 72 61 79 20 67 65 74 20 64 65 70 65   [array get depe
67e0: 6e 64 65 6e 63 69 65 73 5d 20 7b 0a 09 20 20 20  ndencies] {..   
67f0: 20 66 6f 72 65 61 63 68 20 63 68 69 6c 64 20 24   foreach child $
6800: 63 68 69 6c 64 72 65 6e 20 7b 0a 09 09 73 65 74  children {...set
6810: 20 64 6b 65 79 20 20 20 20 5b 6c 69 73 74 20 24   dkey    [list $
6820: 72 69 64 20 24 63 68 69 6c 64 5d 0a 09 09 73 65  rid $child]...se
6830: 74 20 73 74 61 72 74 20 20 20 24 70 6f 73 28 24  t start   $pos($
6840: 72 69 64 29 0a 09 09 73 65 74 20 65 6e 64 20 20  rid)...set end  
6850: 20 20 20 24 70 6f 73 28 24 63 68 69 6c 64 29 0a     $pos($child).
6860: 0a 09 09 69 66 20 7b 24 73 74 61 72 74 20 3e 20  ...if {$start > 
6870: 24 65 6e 64 7d 20 7b 0a 09 09 20 20 20 20 73 65  $end} {...    se
6880: 74 20 63 72 6f 73 73 65 73 20 5b 6c 69 73 74 20  t crosses [list 
6890: 24 65 6e 64 20 5b 65 78 70 72 20 7b 24 73 74 61  $end [expr {$sta
68a0: 72 74 2d 31 7d 5d 5d 0a 09 09 20 20 20 20 77 68  rt-1}]]...    wh
68b0: 69 6c 65 20 7b 24 65 6e 64 20 3c 20 24 73 74 61  ile {$end < $sta
68c0: 72 74 7d 20 7b 0a 09 09 09 69 6e 63 72 20 63 72  rt} {....incr cr
68d0: 6f 73 73 28 24 65 6e 64 29 0a 09 09 09 69 6e 63  oss($end)....inc
68e0: 72 20 65 6e 64 0a 09 09 20 20 20 20 7d 0a 09 09  r end...    }...
68f0: 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20 20 20 73  } else {...    s
6900: 65 74 20 63 72 6f 73 73 65 73 20 5b 6c 69 73 74  et crosses [list
6910: 20 24 73 74 61 72 74 20 5b 65 78 70 72 20 7b 24   $start [expr {$
6920: 65 6e 64 2d 31 7d 5d 5d 0a 09 09 20 20 20 20 77  end-1}]]...    w
6930: 68 69 6c 65 20 7b 24 73 74 61 72 74 20 3c 20 24  hile {$start < $
6940: 65 6e 64 7d 20 7b 0a 09 09 09 69 6e 63 72 20 63  end} {....incr c
6950: 72 6f 73 73 28 24 73 74 61 72 74 29 0a 09 09 09  ross($start)....
6960: 69 6e 63 72 20 73 74 61 72 74 0a 09 09 20 20 20  incr start...   
6970: 20 7d 0a 09 09 7d 0a 09 09 73 65 74 20 64 65 70   }...}...set dep
6980: 63 28 24 64 6b 65 79 29 20 24 63 72 6f 73 73 65  c($dkey) $crosse
6990: 73 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 6c 6f  s..    }..}...lo
69a0: 67 20 77 72 69 74 65 20 31 34 20 63 73 65 74 73  g write 14 csets
69b0: 20 7b 49 42 53 3a 20 70 6f 73 2f 5b 61 72 72 61   {IBS: pos/[arra
69c0: 79 20 73 69 7a 65 20 70 6f 73 5d 2c 20 63 72 6f  y size pos], cro
69d0: 73 73 2f 5b 61 72 72 61 79 20 73 69 7a 65 20 63  ss/[array size c
69e0: 72 6f 73 73 5d 2c 20 64 65 70 63 2f 5b 61 72 72  ross], depc/[arr
69f0: 61 79 20 73 69 7a 65 20 64 65 70 63 5d 20 28 66  ay size depc] (f
6a00: 6f 72 20 5b 6c 6c 65 6e 67 74 68 20 24 72 65 76  or [llength $rev
6a10: 69 73 69 6f 6e 73 5d 29 7d 0a 09 6c 6f 67 20 77  isions])}..log w
6a20: 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b 49  rite 14 csets {I
6a30: 42 53 3a 20 74 69 6d 65 73 74 61 6d 70 73 2c 20  BS: timestamps, 
6a40: 64 65 6c 74 61 73 7d 0a 0a 09 49 6e 69 74 69 61  deltas}...Initia
6a50: 6c 69 7a 65 44 65 6c 74 61 73 20 24 72 65 76 69  lizeDeltas $revi
6a60: 73 69 6f 6e 73 0a 0a 09 6c 6f 67 20 77 72 69 74  sions...log writ
6a70: 65 20 31 34 20 63 73 65 74 73 20 7b 49 42 53 3a  e 14 csets {IBS:
6a80: 20 64 65 6c 74 61 20 5b 61 72 72 61 79 20 73 69   delta [array si
6a90: 7a 65 20 64 65 6c 74 61 5d 7d 0a 09 72 65 74 75  ze delta]}..retu
6aa0: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  rn.    }..    pr
6ab0: 6f 63 20 49 6e 69 74 69 61 6c 69 7a 65 44 65 6c  oc InitializeDel
6ac0: 74 61 73 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20  tas {revisions} 
6ad0: 7b 0a 09 75 70 76 61 72 20 31 20 64 65 6c 74 61  {..upvar 1 delta
6ae0: 20 64 65 6c 74 61 0a 0a 09 23 20 50 75 6c 6c 20   delta...# Pull 
6af0: 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20 66  the timestamps f
6b00: 6f 72 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73  or all revisions
6b10: 20 69 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65   in the changese
6b20: 74 73 20 61 6e 64 0a 09 23 20 63 6f 6d 70 75 74  ts and..# comput
6b30: 65 20 74 68 65 69 72 20 64 65 6c 74 61 73 20 66  e their deltas f
6b40: 6f 72 20 75 73 65 20 62 79 20 74 68 65 20 62 72  or use by the br
6b50: 65 61 6b 20 66 69 6e 64 65 72 2e 0a 0a 09 61 72  eak finder....ar
6b60: 72 61 79 20 73 65 74 20 64 65 6c 74 61 20 7b 7d  ray set delta {}
6b70: 0a 09 61 72 72 61 79 20 73 65 74 20 73 74 61 6d  ..array set stam
6b80: 70 20 7b 7d 0a 0a 09 73 65 74 20 74 68 65 73 65  p {}...set these
6b90: 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73  t ('[join $revis
6ba0: 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 66  ions {','}]')..f
6bb0: 6f 72 65 61 63 68 20 7b 72 69 64 20 74 69 6d 65  oreach {rid time
6bc0: 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75  } [state run [su
6bd0: 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20  bst -nocommands 
6be0: 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b  -nobackslashes {
6bf0: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72  ..    SELECT R.r
6c00: 69 64 2c 20 52 2e 64 61 74 65 0a 09 20 20 20 20  id, R.date..    
6c10: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 0a  FROM revision R.
6c20: 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64  .    WHERE R.rid
6c30: 20 49 4e 20 24 74 68 65 73 65 74 0a 09 7d 5d 5d   IN $theset..}]]
6c40: 20 7b 0a 09 20 20 20 20 73 65 74 20 73 74 61 6d   {..    set stam
6c50: 70 28 24 72 69 64 29 20 24 74 69 6d 65 0a 09 7d  p($rid) $time..}
6c60: 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20  ...log write 14 
6c70: 63 73 65 74 73 20 7b 49 42 53 3a 20 73 74 61 6d  csets {IBS: stam
6c80: 70 20 5b 61 72 72 61 79 20 73 69 7a 65 20 73 74  p [array size st
6c90: 61 6d 70 5d 7d 0a 0a 09 73 65 74 20 6e 20 30 0a  amp]}...set n 0.
6ca0: 09 66 6f 72 65 61 63 68 20 72 69 64 20 5b 6c 72  .foreach rid [lr
6cb0: 61 6e 67 65 20 24 72 65 76 69 73 69 6f 6e 73 20  ange $revisions 
6cc0: 30 20 65 6e 64 2d 31 5d 20 72 6e 65 78 74 20 5b  0 end-1] rnext [
6cd0: 6c 72 61 6e 67 65 20 24 72 65 76 69 73 69 6f 6e  lrange $revision
6ce0: 73 20 31 20 65 6e 64 5d 20 7b 0a 09 20 20 20 20  s 1 end] {..    
6cf0: 73 65 74 20 64 65 6c 74 61 28 24 6e 29 20 5b 65  set delta($n) [e
6d00: 78 70 72 20 7b 24 73 74 61 6d 70 28 24 72 6e 65  xpr {$stamp($rne
6d10: 78 74 29 20 2d 20 24 73 74 61 6d 70 28 24 72 69  xt) - $stamp($ri
6d20: 64 29 7d 5d 0a 09 20 20 20 20 69 6e 63 72 20 6e  d)}]..    incr n
6d30: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ..}..return.    
6d40: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 46 69 6e 64  }..    proc Find
6d50: 42 65 73 74 42 72 65 61 6b 20 7b 72 61 6e 67 65  BestBreak {range
6d60: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 63 72 6f  } {..upvar 1 cro
6d70: 73 73 20 63 72 6f 73 73 20 64 65 6c 74 61 20 64  ss cross delta d
6d80: 65 6c 74 61 0a 0a 09 23 20 44 65 74 65 72 6d 69  elta...# Determi
6d90: 6e 65 20 74 68 65 20 62 65 73 74 20 62 72 65 61  ne the best brea
6da0: 6b 20 6c 6f 63 61 74 69 6f 6e 20 69 6e 20 74 68  k location in th
6db0: 65 20 67 69 76 65 6e 20 72 61 6e 67 65 20 6f 66  e given range of
6dc0: 0a 09 23 20 70 6f 73 69 74 69 6f 6e 73 2e 20 46  ..# positions. F
6dd0: 69 72 73 74 20 77 65 20 6c 6f 6f 6b 20 66 6f 72  irst we look for
6de0: 20 74 68 65 20 6c 6f 63 61 74 69 6f 6e 73 20 77   the locations w
6df0: 69 74 68 20 74 68 65 20 6d 61 78 69 6d 61 6c 0a  ith the maximal.
6e00: 09 23 20 6e 75 6d 62 65 72 20 6f 66 20 63 72 6f  .# number of cro
6e10: 73 73 69 6e 67 73 2e 20 49 66 20 74 68 65 72 65  ssings. If there
6e20: 20 61 72 65 20 73 65 76 65 72 61 6c 20 77 65 20   are several we 
6e30: 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 0a 09 23 20  look for the..# 
6e40: 73 68 6f 72 74 65 73 74 20 74 69 6d 65 20 69 6e  shortest time in
6e50: 74 65 72 76 61 6c 20 61 6d 6f 6e 67 20 74 68 65  terval among the
6e60: 6d 2e 20 49 66 20 77 65 20 73 74 69 6c 6c 20 68  m. If we still h
6e70: 61 76 65 20 6d 75 6c 74 69 70 6c 65 0a 09 23 20  ave multiple..# 
6e80: 70 6f 73 73 69 62 69 6c 69 74 69 65 73 20 61 66  possibilities af
6e90: 74 65 72 20 74 68 61 74 20 77 65 20 73 65 6c 65  ter that we sele
6ea0: 63 74 20 74 68 65 20 65 61 72 6c 69 65 73 74 20  ct the earliest 
6eb0: 6c 6f 63 61 74 69 6f 6e 0a 09 23 20 61 6d 6f 6e  location..# amon
6ec0: 67 20 74 68 65 73 65 2e 0a 0a 09 23 20 4e 6f 74  g these....# Not
6ed0: 65 3a 20 49 66 20 74 68 65 20 6d 61 78 69 6d 61  e: If the maxima
6ee0: 6c 20 6e 75 6d 62 65 72 20 6f 66 20 63 72 6f 73  l number of cros
6ef0: 73 69 6e 67 73 20 69 73 20 30 20 74 68 65 6e 20  sings is 0 then 
6f00: 74 68 65 20 72 61 6e 67 65 0a 09 23 20 20 20 20  the range..#    
6f10: 20 20 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e     has no intern
6f20: 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c  al dependencies,
6f30: 20 61 6e 64 20 6e 6f 20 62 72 65 61 6b 20 6c 6f   and no break lo
6f40: 63 61 74 69 6f 6e 20 61 74 0a 09 23 20 20 20 20  cation at..#    
6f50: 20 20 20 61 6c 6c 2e 20 54 68 69 73 20 70 6f 73     all. This pos
6f60: 73 69 62 69 6c 69 74 79 20 69 73 20 73 69 67 6e  sibility is sign
6f70: 61 6c 65 64 20 76 69 61 20 72 65 73 75 6c 74 20  aled via result 
6f80: 2d 31 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 41 20  -1....# Note: A 
6f90: 72 61 6e 67 65 20 6f 66 20 6c 65 6e 67 74 68 20  range of length 
6fa0: 31 20 6f 72 20 6c 65 73 73 20 63 61 6e 6e 6f 74  1 or less cannot
6fb0: 20 68 61 76 65 20 69 6e 74 65 72 6e 61 6c 0a 09   have internal..
6fc0: 23 20 20 20 20 20 20 20 64 65 70 65 6e 64 65 6e  #       dependen
6fd0: 63 69 65 73 2c 20 61 73 20 74 68 61 74 20 6e 65  cies, as that ne
6fe0: 65 64 73 20 61 74 20 6c 65 61 73 74 20 74 77 6f  eds at least two
6ff0: 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 0a 09 23   revisions in..#
7000: 20 20 20 20 20 20 20 74 68 65 20 72 61 6e 67 65         the range
7010: 2e 0a 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68  ....if {[llength
7020: 20 24 72 61 6e 67 65 5d 20 3c 20 32 7d 20 7b 20   $range] < 2} { 
7030: 72 65 74 75 72 6e 20 2d 31 20 7d 0a 0a 09 73 65  return -1 }...se
7040: 74 20 6d 61 78 20 2d 31 0a 09 73 65 74 20 62 65  t max -1..set be
7050: 73 74 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68 20  st {}...foreach 
7060: 6c 6f 63 61 74 69 6f 6e 20 24 72 61 6e 67 65 20  location $range 
7070: 7b 0a 09 20 20 20 20 73 65 74 20 63 72 6f 73 73  {..    set cross
7080: 69 6e 67 73 20 24 63 72 6f 73 73 28 24 6c 6f 63  ings $cross($loc
7090: 61 74 69 6f 6e 29 0a 09 20 20 20 20 69 66 20 7b  ation)..    if {
70a0: 24 63 72 6f 73 73 69 6e 67 73 20 3e 20 24 6d 61  $crossings > $ma
70b0: 78 7d 20 7b 0a 09 09 73 65 74 20 6d 61 78 20 20  x} {...set max  
70c0: 24 63 72 6f 73 73 69 6e 67 73 0a 09 09 73 65 74  $crossings...set
70d0: 20 62 65 73 74 20 5b 6c 69 73 74 20 24 6c 6f 63   best [list $loc
70e0: 61 74 69 6f 6e 5d 0a 09 09 63 6f 6e 74 69 6e 75  ation]...continu
70f0: 65 0a 09 20 20 20 20 7d 20 65 6c 73 65 69 66 20  e..    } elseif 
7100: 7b 24 63 72 6f 73 73 69 6e 67 73 20 3d 3d 20 24  {$crossings == $
7110: 6d 61 78 7d 20 7b 0a 09 09 6c 61 70 70 65 6e 64  max} {...lappend
7120: 20 62 65 73 74 20 24 6c 6f 63 61 74 69 6f 6e 0a   best $location.
7130: 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b  .    }..}...if {
7140: 24 6d 61 78 20 3d 3d 20 30 7d 20 20 20 20 20 20  $max == 0}      
7150: 20 20 20 20 20 20 7b 20 72 65 74 75 72 6e 20 2d        { return -
7160: 31 20 7d 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74  1 }..if {[llengt
7170: 68 20 24 62 65 73 74 5d 20 3d 3d 20 31 7d 20 7b  h $best] == 1} {
7180: 20 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78 20   return [lindex 
7190: 24 62 65 73 74 20 30 5d 20 7d 0a 0a 09 73 65 74  $best 0] }...set
71a0: 20 6c 6f 63 61 74 69 6f 6e 73 20 24 62 65 73 74   locations $best
71b0: 0a 09 73 65 74 20 62 65 73 74 20 7b 7d 0a 09 73  ..set best {}..s
71c0: 65 74 20 6d 69 6e 20 2d 31 0a 0a 09 66 6f 72 65  et min -1...fore
71d0: 61 63 68 20 6c 6f 63 61 74 69 6f 6e 20 24 6c 6f  ach location $lo
71e0: 63 61 74 69 6f 6e 73 20 7b 0a 09 20 20 20 20 73  cations {..    s
71f0: 65 74 20 69 6e 74 65 72 76 61 6c 20 24 64 65 6c  et interval $del
7200: 74 61 28 24 6c 6f 63 61 74 69 6f 6e 29 0a 09 20  ta($location).. 
7210: 20 20 20 69 66 20 7b 28 24 6d 69 6e 20 3c 20 30     if {($min < 0
7220: 29 20 7c 7c 20 28 24 69 6e 74 65 72 76 61 6c 20  ) || ($interval 
7230: 3c 20 24 6d 69 6e 29 7d 20 7b 0a 09 09 73 65 74  < $min)} {...set
7240: 20 6d 69 6e 20 20 24 69 6e 74 65 72 76 61 6c 0a   min  $interval.
7250: 09 09 73 65 74 20 62 65 73 74 20 5b 6c 69 73 74  ..set best [list
7260: 20 24 6c 6f 63 61 74 69 6f 6e 5d 0a 09 20 20 20   $location]..   
7270: 20 7d 20 65 6c 73 65 69 66 20 7b 24 69 6e 74 65   } elseif {$inte
7280: 72 76 61 6c 20 3d 3d 20 24 6d 69 6e 7d 20 7b 0a  rval == $min} {.
7290: 09 09 6c 61 70 70 65 6e 64 20 62 65 73 74 20 24  ..lappend best $
72a0: 6c 6f 63 61 74 69 6f 6e 0a 09 20 20 20 20 7d 0a  location..    }.
72b0: 09 7d 0a 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74  .}...if {[llengt
72c0: 68 20 24 62 65 73 74 5d 20 3d 3d 20 31 7d 20 7b  h $best] == 1} {
72d0: 20 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78 20   return [lindex 
72e0: 24 62 65 73 74 20 30 5d 20 7d 0a 0a 09 72 65 74  $best 0] }...ret
72f0: 75 72 6e 20 5b 6c 69 6e 64 65 78 20 5b 6c 73 6f  urn [lindex [lso
7300: 72 74 20 2d 69 6e 74 65 67 65 72 20 2d 69 6e 63  rt -integer -inc
7310: 72 65 61 73 69 6e 67 20 24 62 65 73 74 5d 20 30  reasing $best] 0
7320: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f  ].    }..    pro
7330: 63 20 43 75 74 41 74 20 7b 6c 6f 63 61 74 69 6f  c CutAt {locatio
7340: 6e 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 63 72  n} {..upvar 1 cr
7350: 6f 73 73 20 63 72 6f 73 73 20 64 65 70 63 20 64  oss cross depc d
7360: 65 70 63 0a 0a 09 23 20 49 74 20 77 61 73 20 64  epc...# It was d
7370: 65 63 69 64 65 64 20 74 6f 20 73 70 6c 69 74 20  ecided to split 
7380: 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 61 74  the changeset at
7390: 20 74 68 65 20 67 69 76 65 6e 0a 09 23 20 6c 6f   the given..# lo
73a0: 63 61 74 69 6f 6e 2e 20 54 68 69 73 20 63 75 74  cation. This cut
73b0: 73 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 64 65  s a number of de
73c0: 70 65 6e 64 65 6e 63 69 65 73 2e 20 48 65 72 65  pendencies. Here
73d0: 20 77 65 20 75 70 64 61 74 65 0a 09 23 20 74 68   we update..# th
73e0: 65 20 63 72 6f 73 73 20 69 6e 66 6f 72 6d 61 74  e cross informat
73f0: 69 6f 6e 20 73 6f 20 74 68 61 74 20 74 68 65 20  ion so that the 
7400: 62 72 65 61 6b 20 66 69 6e 64 65 72 20 68 61 73  break finder has
7410: 20 61 63 63 75 72 61 74 65 0a 09 23 20 64 61 74   accurate..# dat
7420: 61 20 77 68 65 6e 20 77 65 20 6c 6f 6f 6b 20 61  a when we look a
7430: 74 20 74 68 65 20 67 65 6e 65 72 61 74 65 64 20  t the generated 
7440: 66 72 61 67 6d 65 6e 74 73 2e 0a 0a 09 73 65 74  fragments....set
7450: 20 73 69 78 20 5b 6c 6f 67 20 76 69 73 69 62 6c   six [log visibl
7460: 65 3f 20 36 5d 0a 0a 09 23 20 4e 6f 74 65 3a 20  e? 6]...# Note: 
7470: 54 68 65 20 6c 6f 6f 70 20 62 65 6c 6f 77 20 63  The loop below c
7480: 6f 75 6c 64 20 62 65 20 6d 61 64 65 20 66 61 73  ould be made fas
7490: 74 65 72 20 62 79 20 6b 65 65 70 69 6e 67 20 61  ter by keeping a
74a0: 20 6d 61 70 0a 09 23 20 66 72 6f 6d 20 70 6f 73   map..# from pos
74b0: 69 74 69 6f 6e 73 20 74 6f 20 74 68 65 20 64 65  itions to the de
74c0: 70 65 6e 64 65 6e 63 69 65 73 20 63 72 6f 73 73  pendencies cross
74d0: 69 6e 67 2e 20 41 6e 20 65 78 74 65 6e 73 69 6f  ing. An extensio
74e0: 6e 20 6f 66 0a 09 23 20 43 52 4f 53 53 2c 20 69  n of..# CROSS, i
74f0: 2e 65 2e 20 6c 69 73 74 20 6f 66 20 64 65 70 65  .e. list of depe
7500: 6e 64 65 6e 63 69 65 73 2c 20 63 6f 75 6e 74 65  ndencies, counte
7510: 72 20 69 73 20 69 6d 70 6c 69 65 64 2e 20 54 61  r is implied. Ta
7520: 6b 65 73 0a 09 23 20 61 20 6c 6f 74 20 6d 6f 72  kes..# a lot mor
7530: 65 20 6d 65 6d 6f 72 79 20 68 6f 77 65 76 65 72  e memory however
7540: 2c 20 61 6e 64 20 74 61 6b 65 73 20 74 69 6d 65  , and takes time
7550: 20 74 6f 20 75 70 64 61 74 65 20 68 65 72 65 0a   to update here.
7560: 09 23 20 28 54 68 65 20 69 6e 6e 65 72 20 6c 6f  .# (The inner lo
7570: 6f 70 20 69 73 20 6e 6f 74 20 69 6e 63 72 20 2d  op is not incr -
7580: 31 2c 20 62 75 74 20 6c 64 65 6c 65 74 65 29 2e  1, but ldelete).
7590: 0a 0a 09 66 6f 72 65 61 63 68 20 64 65 70 20 5b  ...foreach dep [
75a0: 61 72 72 61 79 20 6e 61 6d 65 73 20 64 65 70 63  array names depc
75b0: 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 72 61 6e  ] {..    set ran
75c0: 67 65 20 24 64 65 70 63 28 24 64 65 70 29 0a 09  ge $depc($dep)..
75d0: 20 20 20 20 23 20 43 68 65 63 6b 20 61 6c 6c 20      # Check all 
75e0: 64 65 70 65 6e 64 65 6e 63 69 65 73 20 73 74 69  dependencies sti
75f0: 6c 6c 20 6b 6e 6f 77 6e 2c 20 74 61 6b 65 20 74  ll known, take t
7600: 68 65 69 72 20 72 61 6e 67 65 20 61 6e 64 0a 09  heir range and..
7610: 20 20 20 20 23 20 73 65 65 20 69 66 20 74 68 65      # see if the
7620: 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 20   break location 
7630: 66 61 6c 6c 73 20 77 69 74 68 69 6e 2e 0a 0a 09  falls within....
7640: 20 20 20 20 42 6f 72 64 65 72 20 24 72 61 6e 67      Border $rang
7650: 65 20 73 20 65 0a 09 20 20 20 20 69 66 20 7b 24  e s e..    if {$
7660: 6c 6f 63 61 74 69 6f 6e 20 3c 20 24 73 7d 20 63  location < $s} c
7670: 6f 6e 74 69 6e 75 65 20 3b 20 23 20 62 72 65 61  ontinue ; # brea
7680: 6b 20 62 65 66 6f 72 65 20 72 61 6e 67 65 2c 20  k before range, 
7690: 69 67 6e 6f 72 65 0a 09 20 20 20 20 69 66 20 7b  ignore..    if {
76a0: 24 6c 6f 63 61 74 69 6f 6e 20 3e 20 24 65 7d 20  $location > $e} 
76b0: 63 6f 6e 74 69 6e 75 65 20 3b 20 23 20 62 72 65  continue ; # bre
76c0: 61 6b 20 61 66 74 65 72 20 72 61 6e 67 65 2c 20  ak after range, 
76d0: 69 67 6e 6f 72 65 2e 0a 0a 09 20 20 20 20 23 20  ignore....    # 
76e0: 54 68 69 73 20 64 65 70 65 6e 64 65 6e 63 79 20  This dependency 
76f0: 63 72 6f 73 73 65 73 20 74 68 65 20 62 72 65 61  crosses the brea
7700: 6b 20 6c 6f 63 61 74 69 6f 6e 2e 20 57 65 20 72  k location. We r
7710: 65 6d 6f 76 65 20 69 74 0a 09 20 20 20 20 23 20  emove it..    # 
7720: 66 72 6f 6d 20 74 68 65 20 63 72 6f 73 73 69 6e  from the crossin
7730: 67 73 20 63 6f 75 6e 74 65 72 73 2c 20 61 6e 64  gs counters, and
7740: 20 74 68 65 6e 20 61 6c 73 6f 20 66 72 6f 6d 20   then also from 
7750: 74 68 65 20 73 65 74 0a 09 20 20 20 20 23 20 6f  the set..    # o
7760: 66 20 6b 6e 6f 77 6e 20 64 65 70 65 6e 64 65 6e  f known dependen
7770: 63 69 65 73 2c 20 61 73 20 77 65 20 61 72 65 20  cies, as we are 
7780: 64 6f 6e 65 20 77 69 74 68 20 69 74 2e 0a 0a 09  done with it....
7790: 20 20 20 20 42 6f 72 64 65 72 20 24 64 65 70 63      Border $depc
77a0: 28 24 64 65 70 29 20 64 73 20 64 65 0a 09 20 20  ($dep) ds de..  
77b0: 20 20 66 6f 72 20 7b 73 65 74 20 6c 6f 63 20 24    for {set loc $
77c0: 64 73 7d 20 7b 24 6c 6f 63 20 3c 3d 20 24 64 65  ds} {$loc <= $de
77d0: 7d 20 7b 69 6e 63 72 20 6c 6f 63 7d 20 7b 0a 09  } {incr loc} {..
77e0: 09 69 6e 63 72 20 63 72 6f 73 73 28 24 6c 6f 63  .incr cross($loc
77f0: 29 20 2d 31 0a 09 20 20 20 20 7d 0a 09 20 20 20  ) -1..    }..   
7800: 20 75 6e 73 65 74 20 64 65 70 63 28 24 64 65 70   unset depc($dep
7810: 29 0a 0a 09 20 20 20 20 69 66 20 7b 21 24 73 69  )...    if {!$si
7820: 78 7d 20 63 6f 6e 74 69 6e 75 65 0a 0a 09 20 20  x} continue...  
7830: 20 20 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61    struct::list a
7840: 73 73 69 67 6e 20 24 64 65 70 20 70 61 72 65 6e  ssign $dep paren
7850: 74 20 63 68 69 6c 64 0a 09 20 20 20 20 6c 6f 67  t child..    log
7860: 20 77 72 69 74 65 20 35 20 63 73 65 74 73 20 22   write 5 csets "
7870: 42 72 6f 6b 65 20 64 65 70 65 6e 64 65 6e 63 79  Broke dependency
7880: 20 5b 50 44 20 24 70 61 72 65 6e 74 5d 20 2d 2d   [PD $parent] --
7890: 3e 20 5b 50 44 20 24 63 68 69 6c 64 5d 22 0a 09  > [PD $child]"..
78a0: 7d 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  }...return.    }
78b0: 0a 0a 20 20 20 20 23 20 50 72 69 6e 74 20 69 64  ..    # Print id
78c0: 65 6e 74 69 66 79 69 6e 67 20 64 61 74 61 20 66  entifying data f
78d0: 6f 72 20 61 20 72 65 76 69 73 69 6f 6e 20 28 70  or a revision (p
78e0: 72 6f 6a 65 63 74 2c 20 66 69 6c 65 2c 20 64 6f  roject, file, do
78f0: 74 74 65 64 20 72 65 76 0a 20 20 20 20 23 20 6e  tted rev.    # n
7900: 75 6d 62 65 72 29 2c 20 66 6f 72 20 68 69 67 68  umber), for high
7910: 20 76 65 72 62 6f 73 69 74 79 20 6c 6f 67 20 6f   verbosity log o
7920: 75 74 70 75 74 2e 0a 20 20 20 20 23 20 54 4f 44  utput..    # TOD
7930: 4f 3a 20 52 65 70 6c 61 63 65 20 77 69 74 68 20  O: Replace with 
7940: 63 61 6c 6c 20 74 6f 20 69 74 65 6d 73 74 72 20  call to itemstr 
7950: 28 6c 69 73 74 20 72 65 76 20 24 69 64 29 0a 0a  (list rev $id)..
7960: 20 20 20 20 70 72 6f 63 20 50 44 20 7b 69 64 7d      proc PD {id}
7970: 20 7b 0a 09 66 6f 72 65 61 63 68 20 7b 70 20 66   {..foreach {p f
7980: 20 72 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b   r} [state run {
7990: 0a 09 09 53 45 4c 45 43 54 20 50 2e 6e 61 6d 65  ...SELECT P.name
79a0: 20 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76   , F.name, R.rev
79b0: 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e  ...FROM revision
79c0: 20 52 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a   R, file F, proj
79d0: 65 63 74 20 50 0a 09 09 57 48 45 52 45 20 52 2e  ect P...WHERE R.
79e0: 72 69 64 20 3d 20 24 69 64 20 20 20 20 2d 2d 20  rid = $id    -- 
79f0: 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 20 66  Find specified f
7a00: 69 6c 65 20 72 65 76 69 73 69 6f 6e 0a 09 09 41  ile revision...A
7a10: 4e 44 20 20 20 46 2e 66 69 64 20 3d 20 52 2e 66  ND   F.fid = R.f
7a20: 69 64 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20  id  -- Get file 
7a30: 6f 66 20 74 68 65 20 72 65 76 69 73 69 6f 6e 0a  of the revision.
7a40: 09 09 41 4e 44 20 20 20 50 2e 70 69 64 20 3d 20  ..AND   P.pid = 
7a50: 46 2e 70 69 64 20 20 2d 2d 20 47 65 74 20 70 72  F.pid  -- Get pr
7a60: 6f 6a 65 63 74 20 6f 66 20 74 68 65 20 66 69 6c  oject of the fil
7a70: 65 2e 0a 09 7d 5d 20 62 72 65 61 6b 0a 09 72 65  e...}] break..re
7a80: 74 75 72 6e 20 22 27 24 70 20 3a 20 24 66 2f 24  turn "'$p : $f/$
7a90: 72 27 22 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23  r'".    }..    #
7aa0: 20 50 72 69 6e 74 69 6e 67 20 6f 6e 65 20 6f 72   Printing one or
7ab0: 20 6d 6f 72 65 20 72 61 6e 67 65 73 2c 20 66 6f   more ranges, fo
7ac0: 72 6d 61 74 74 65 64 2c 20 61 6e 64 20 6f 6e 6c  rmatted, and onl
7ad0: 79 20 74 68 65 69 72 20 62 6f 72 64 65 72 20 74  y their border t
7ae0: 6f 0a 20 20 20 20 23 20 6b 65 65 70 20 74 68 65  o.    # keep the
7af0: 20 73 74 72 69 6e 67 73 20 73 68 6f 72 74 2e 0a   strings short..
7b00: 0a 20 20 20 20 70 72 6f 63 20 50 52 73 20 7b 72  .    proc PRs {r
7b10: 61 6e 67 65 73 7d 20 7b 0a 09 72 65 74 75 72 6e  anges} {..return
7b20: 20 5b 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d   [struct::list m
7b30: 61 70 20 24 72 61 6e 67 65 73 20 5b 6d 79 70 72  ap $ranges [mypr
7b40: 6f 63 20 50 52 5d 5d 0a 20 20 20 20 7d 0a 0a 20  oc PR]].    }.. 
7b50: 20 20 20 70 72 6f 63 20 50 52 20 7b 72 61 6e 67     proc PR {rang
7b60: 65 7d 20 7b 0a 09 42 6f 72 64 65 72 20 24 72 61  e} {..Border $ra
7b70: 6e 67 65 20 73 20 65 0a 09 72 65 74 75 72 6e 20  nge s e..return 
7b80: 3c 24 7b 73 7d 2e 2e 2e 24 7b 65 7d 3e 0a 20 20  <${s}...${e}>.  
7b90: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 42 6f    }..    proc Bo
7ba0: 72 64 65 72 20 7b 72 61 6e 67 65 20 73 76 20 65  rder {range sv e
7bb0: 76 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 73  v} {..upvar 1 $s
7bc0: 76 20 73 20 24 65 76 20 65 0a 09 73 65 74 20 73  v s $ev e..set s
7bd0: 20 5b 6c 69 6e 64 65 78 20 24 72 61 6e 67 65 20   [lindex $range 
7be0: 30 5d 0a 09 73 65 74 20 65 20 5b 6c 69 6e 64 65  0]..set e [linde
7bf0: 78 20 24 72 61 6e 67 65 20 65 6e 64 5d 0a 09 72  x $range end]..r
7c00: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
7c10: 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23   # # ## ### ####
7c20: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
7c30: 23 23 23 23 23 23 23 23 0a 0a 20 20 20 20 70 72  ########..    pr
7c40: 6f 63 20 55 6e 6d 61 70 49 74 65 6d 73 20 7b 74  oc UnmapItems {t
7c50: 68 65 74 79 70 65 20 74 68 65 69 74 65 6d 73 7d  hetype theitems}
7c60: 20 7b 0a 09 23 20 28 2a 29 20 57 65 20 63 6c 65   {..# (*) We cle
7c70: 61 72 20 6f 75 74 20 74 68 65 20 61 73 73 6f 63  ar out the assoc
7c80: 69 61 74 65 64 20 70 61 72 74 20 6f 66 20 74 68  iated part of th
7c90: 65 20 6d 79 69 74 65 6d 6d 61 70 0a 09 23 20 69  e myitemmap..# i
7ca0: 6e 2d 6d 65 6d 6f 72 79 20 69 6e 64 65 78 20 69  n-memory index i
7cb0: 6e 20 70 72 65 70 61 72 61 74 69 6f 6e 20 66 6f  n preparation fo
7cc0: 72 20 6e 65 77 20 64 61 74 61 2c 20 6f 72 20 61  r new data, or a
7cd0: 73 20 70 61 72 74 20 6f 66 0a 09 23 20 6f 62 6a  s part of..# obj
7ce0: 65 63 74 20 64 65 73 74 72 75 63 74 69 6f 6e 2e  ect destruction.
7cf0: 20 41 20 73 69 6d 70 6c 65 20 75 6e 73 65 74 20   A simple unset 
7d00: 69 73 20 65 6e 6f 75 67 68 2c 20 77 65 20 68 61  is enough, we ha
7d10: 76 65 20 6e 6f 0a 09 23 20 73 79 6d 62 6f 6c 20  ve no..# symbol 
7d20: 63 68 61 6e 67 65 73 65 74 73 20 61 74 20 74 68  changesets at th
7d30: 69 73 20 74 69 6d 65 2c 20 61 6e 64 20 74 68 75  is time, and thu
7d40: 73 20 6e 65 76 65 72 20 6d 6f 72 65 20 74 68 61  s never more tha
7d50: 6e 20 6f 6e 65 0a 09 23 20 72 65 66 65 72 65 6e  n one..# referen
7d60: 63 65 20 69 6e 20 74 68 65 20 6c 69 73 74 2e 0a  ce in the list..
7d70: 0a 09 75 70 76 61 72 20 31 20 6d 79 69 74 65 6d  ..upvar 1 myitem
7d80: 6d 61 70 20 6d 79 69 74 65 6d 6d 61 70 20 73 65  map myitemmap se
7d90: 6c 66 20 73 65 6c 66 0a 09 66 6f 72 65 61 63 68  lf self..foreach
7da0: 20 69 69 64 20 24 74 68 65 69 74 65 6d 73 20 7b   iid $theitems {
7db0: 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c  ..    set key [l
7dc0: 69 73 74 20 24 74 68 65 74 79 70 65 20 24 69 69  ist $thetype $ii
7dd0: 64 5d 0a 09 20 20 20 20 75 6e 73 65 74 20 6d 79  d]..    unset my
7de0: 69 74 65 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20  itemmap($key).. 
7df0: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63     log write 8 c
7e00: 73 65 74 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20  sets {MAP- item 
7e10: 3c 24 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b  <$key> $self = [
7e20: 24 73 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 09  $self str]}..}..
7e30: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
7e40: 20 20 70 72 6f 63 20 4d 61 70 49 74 65 6d 73 20    proc MapItems 
7e50: 7b 74 68 65 74 79 70 65 20 74 68 65 69 74 65 6d  {thetype theitem
7e60: 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 6d 79  s} {..upvar 1 my
7e70: 69 74 65 6d 6d 61 70 20 6d 79 69 74 65 6d 6d 61  itemmap myitemma
7e80: 70 20 73 65 6c 66 20 73 65 6c 66 0a 0a 09 66 6f  p self self...fo
7e90: 72 65 61 63 68 20 69 69 64 20 24 74 68 65 69 74  reach iid $theit
7ea0: 65 6d 73 20 7b 0a 09 20 20 20 20 73 65 74 20 6b  ems {..    set k
7eb0: 65 79 20 5b 6c 69 73 74 20 24 74 68 65 74 79 70  ey [list $thetyp
7ec0: 65 20 24 69 69 64 5d 0a 09 20 20 20 20 73 65 74  e $iid]..    set
7ed0: 20 6d 79 69 74 65 6d 6d 61 70 28 24 6b 65 79 29   myitemmap($key)
7ee0: 20 24 73 65 6c 66 0a 09 20 20 20 20 6c 6f 67 20   $self..    log 
7ef0: 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b 4d  write 8 csets {M
7f00: 41 50 2b 20 69 74 65 6d 20 3c 24 6b 65 79 3e 20  AP+ item <$key> 
7f10: 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73  $self = [$self s
7f20: 74 72 5d 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a  tr]}..}..return.
7f30: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23      }..    # # #
7f40: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
7f50: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
7f60: 23 23 0a 0a 20 20 20 20 74 79 70 65 76 61 72 69  ##..    typevari
7f70: 61 62 6c 65 20 6d 79 63 68 61 6e 67 65 73 65 74  able mychangeset
7f80: 73 20 20 20 20 20 20 20 20 20 7b 7d 20 3b 20 23  s         {} ; #
7f90: 20 4c 69 73 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f   List of all kno
7fa0: 77 6e 0a 09 09 09 09 09 20 20 20 23 20 63 68 61  wn......   # cha
7fb0: 6e 67 65 73 65 74 73 2e 0a 0a 20 20 20 20 23 20  ngesets...    # 
7fc0: 4c 69 73 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77  List of all know
7fd0: 6e 20 63 68 61 6e 67 65 73 65 74 73 20 6f 66 20  n changesets of 
7fe0: 61 20 74 79 70 65 2e 0a 20 20 20 20 74 79 70 65  a type..    type
7ff0: 76 61 72 69 61 62 6c 65 20 6d 79 74 63 68 61 6e  variable mytchan
8000: 67 65 73 65 74 73 20 2d 61 72 72 61 79 20 7b 0a  gesets -array {.
8010: 09 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b 7d 0a  .sym::branch {}.
8020: 09 73 79 6d 3a 3a 74 61 67 20 20 20 20 7b 7d 0a  .sym::tag    {}.
8030: 09 72 65 76 20 20 20 20 20 20 20 20 20 7b 7d 0a  .rev         {}.
8040: 20 20 20 20 7d 0a 09 09 09 09 09 0a 20 20 20 20      }.......    
8050: 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 69  typevariable myi
8060: 74 65 6d 6d 61 70 20 20 20 20 20 2d 61 72 72 61  temmap     -arra
8070: 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f  y {} ; # Map fro
8080: 6d 20 69 74 65 6d 73 20 28 74 61 67 67 65 64 29  m items (tagged)
8090: 0a 09 09 09 09 09 20 20 20 23 20 74 6f 20 74 68  ......   # to th
80a0: 65 20 6c 69 73 74 20 6f 66 20 63 68 61 6e 67 65  e list of change
80b0: 73 65 74 73 0a 09 09 09 09 09 20 20 20 23 20 63  sets......   # c
80c0: 6f 6e 74 61 69 6e 69 6e 67 20 69 74 2e 20 45 61  ontaining it. Ea
80d0: 63 68 20 69 74 65 6d 0a 09 09 09 09 09 20 20 20  ch item......   
80e0: 23 20 63 61 6e 20 62 65 20 75 73 65 64 20 62 79  # can be used by
80f0: 20 6f 6e 6c 79 20 6f 6e 65 0a 09 09 09 09 09 20   only one...... 
8100: 20 20 23 20 63 68 61 6e 67 65 73 65 74 2e 0a 20    # changeset.. 
8110: 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 20     typevariable 
8120: 6d 79 69 64 6d 61 70 20 20 20 2d 61 72 72 61 79  myidmap   -array
8130: 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d   {} ; # Map from
8140: 20 63 68 61 6e 67 65 73 65 74 20 69 64 20 74 6f   changeset id to
8150: 0a 09 09 09 09 20 20 20 20 20 20 20 23 20 63 68  .....       # ch
8160: 61 6e 67 65 73 65 74 2e 0a 0a 20 20 20 20 74 79  angeset...    ty
8170: 70 65 6d 65 74 68 6f 64 20 61 6c 6c 20 20 20 20  pemethod all    
8180: 7b 7d 20 20 20 20 7b 20 72 65 74 75 72 6e 20 24  {}    { return $
8190: 6d 79 63 68 61 6e 67 65 73 65 74 73 20 7d 0a 20  mychangesets }. 
81a0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6f 66     typemethod of
81b0: 20 20 20 20 20 7b 63 69 64 7d 20 7b 20 72 65 74       {cid} { ret
81c0: 75 72 6e 20 24 6d 79 69 64 6d 61 70 28 24 63 69  urn $myidmap($ci
81d0: 64 29 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74  d) }.    typemet
81e0: 68 6f 64 20 6f 66 69 74 65 6d 20 7b 69 69 64 7d  hod ofitem {iid}
81f0: 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 69 74 65   { return $myite
8200: 6d 6d 61 70 28 24 69 69 64 29 20 7d 0a 0a 20 20  mmap($iid) }..  
8210: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 72 65 76    typemethod rev
8220: 20 20 20 20 7b 7d 20 20 20 20 7b 20 72 65 74 75      {}    { retu
8230: 72 6e 20 24 6d 79 74 63 68 61 6e 67 65 73 65 74  rn $mytchangeset
8240: 73 28 72 65 76 29 20 7d 0a 20 20 20 20 74 79 70  s(rev) }.    typ
8250: 65 6d 65 74 68 6f 64 20 73 79 6d 20 20 20 20 7b  emethod sym    {
8260: 7d 20 20 20 20 7b 20 72 65 74 75 72 6e 20 5b 63  }    { return [c
8270: 6f 6e 63 61 74 20 5c 0a 09 09 09 09 09 20 20 24  oncat \......  $
8280: 7b 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 73  {mytchangesets(s
8290: 79 6d 3a 3a 62 72 61 6e 63 68 29 7d 20 5c 0a 09  ym::branch)} \..
82a0: 09 09 09 09 20 20 24 7b 6d 79 74 63 68 61 6e 67  ....  ${mytchang
82b0: 65 73 65 74 73 28 73 79 6d 3a 3a 74 61 67 29 7d  esets(sym::tag)}
82c0: 5d 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20  ] }..    # # ## 
82d0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
82e0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
82f0: 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72  .    ## Configur
8300: 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d  ation..    pragm
8310: 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20  a -hastypeinfo  
8320: 20 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 74 79 70    no  ; # no typ
8330: 65 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a  e introspection.
8340: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69      pragma -hasi
8350: 6e 66 6f 20 20 20 20 20 20 20 20 6e 6f 20 20 3b  nfo        no  ;
8360: 20 23 20 6e 6f 20 6f 62 6a 65 63 74 20 69 6e 74   # no object int
8370: 72 6f 73 70 65 63 74 69 6f 6e 0a 0a 20 20 20 20  rospection..    
8380: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
8390: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
83a0: 23 23 23 23 23 23 23 0a 7d 0a 0a 23 23 0a 23 23  #######.}..##.##
83b0: 20 4e 4f 54 45 3a 20 54 68 65 20 73 75 63 63 65   NOTE: The succe
83c0: 73 73 6f 72 20 61 6e 64 20 70 72 65 64 65 63 65  ssor and predece
83d0: 73 73 6f 72 20 6d 65 74 68 6f 64 73 20 64 65 66  ssor methods def
83e0: 69 6e 65 64 20 62 79 20 74 68 65 20 63 6c 61 73  ined by the clas
83f0: 73 65 73 0a 23 23 20 20 20 20 20 20 20 62 65 6c  ses.##       bel
8400: 6f 77 20 61 72 65 20 2d 2d 20 62 6f 74 74 6c 65  ow are -- bottle
8410: 20 6e 65 63 6b 73 20 2d 2d 2e 20 4c 6f 6f 6b 20   necks --. Look 
8420: 66 6f 72 20 77 61 79 73 20 74 6f 20 6d 61 6b 65  for ways to make
8430: 20 74 68 65 20 53 51 4c 0a 23 23 20 20 20 20 20   the SQL.##     
8440: 20 20 66 61 73 74 65 72 2e 0a 23 23 0a 0a 23 20    faster..##..# 
8450: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
8460: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
8470: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
8480: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 48  ###########.## H
8490: 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 2e  elper singleton.
84a0: 20 43 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 72 65   Commands for re
84b0: 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74  vision changeset
84c0: 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a  s...snit::type :
84d0: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
84e0: 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63  ort::cvs::projec
84f0: 74 3a 3a 72 65 76 3a 3a 72 65 76 20 7b 0a 20 20  t::rev::rev {.  
8500: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62 79 72    typemethod byr
8510: 65 76 69 73 69 6f 6e 20 7b 7d 20 7b 20 72 65 74  evision {} { ret
8520: 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 65  urn 1 }.    type
8530: 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20  method bysymbol 
8540: 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20    {} { return 0 
8550: 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  }.    typemethod
8560: 20 69 73 74 61 67 20 20 20 20 20 20 7b 7d 20 7b   istag      {} {
8570: 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20   return 0 }.    
8580: 74 79 70 65 6d 65 74 68 6f 64 20 69 73 62 72 61  typemethod isbra
8590: 6e 63 68 20 20 20 7b 7d 20 7b 20 72 65 74 75 72  nch   {} { retur
85a0: 6e 20 30 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d  n 0 }..    typem
85b0: 65 74 68 6f 64 20 73 74 72 20 7b 72 65 76 69 73  ethod str {revis
85c0: 69 6f 6e 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a  ion} {..struct::
85d0: 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 73 74 61  list assign [sta
85e0: 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45  te run {..    SE
85f0: 4c 45 43 54 20 52 2e 72 65 76 2c 20 46 2e 6e 61  LECT R.rev, F.na
8600: 6d 65 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20 20  me, P.name..    
8610: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
8620: 52 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65  R, file F, proje
8630: 63 74 20 50 0a 09 20 20 20 20 57 48 45 52 45 20  ct P..    WHERE 
8640: 20 52 2e 72 69 64 20 3d 20 24 72 65 76 69 73 69   R.rid = $revisi
8650: 6f 6e 20 2d 2d 20 46 69 6e 64 20 73 70 65 63 69  on -- Find speci
8660: 66 69 65 64 20 66 69 6c 65 20 72 65 76 69 73 69  fied file revisi
8670: 6f 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46  on..    AND    F
8680: 2e 66 69 64 20 3d 20 52 2e 66 69 64 20 20 20 20  .fid = R.fid    
8690: 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20   -- Get file of 
86a0: 74 68 65 20 72 65 76 69 73 69 6f 6e 0a 09 20 20  the revision..  
86b0: 20 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20 3d    AND    P.pid =
86c0: 20 46 2e 70 69 64 20 20 20 20 20 2d 2d 20 47 65   F.pid     -- Ge
86d0: 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 74 68 65  t project of the
86e0: 20 66 69 6c 65 2e 0a 09 7d 5d 20 72 65 76 6e 72   file...}] revnr
86f0: 20 66 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65   fname pname..re
8700: 74 75 72 6e 20 22 24 70 6e 61 6d 65 2f 24 7b 72  turn "$pname/${r
8710: 65 76 6e 72 7d 3a 3a 24 66 6e 61 6d 65 22 0a 20  evnr}::$fname". 
8720: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75     }..    # resu
8730: 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69  lt = list (minti
8740: 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20  me, maxtime).   
8750: 20 74 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65   typemethod time
8760: 72 61 6e 67 65 20 7b 69 74 65 6d 73 7d 20 7b 0a  range {items} {.
8770: 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a  .set theset ('[j
8780: 6f 69 6e 20 24 69 74 65 6d 73 20 7b 27 2c 27 7d  oin $items {','}
8790: 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61  ]')..return [sta
87a0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
87b0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
87c0: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
87d0: 53 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64 61 74  SELECT MIN(R.dat
87e0: 65 29 2c 20 4d 41 58 28 52 2e 64 61 74 65 29 0a  e), MAX(R.date).
87f0: 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69  .    FROM revisi
8800: 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20  on R..    WHERE 
8810: 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74  R.rid IN $theset
8820: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
8830: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74  revisions of int
8840: 65 72 65 73 74 0a 09 7d 5d 5d 0a 20 20 20 20 7d  erest..}]].    }
8850: 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 29 20  ..    # var(dv) 
8860: 3d 20 64 69 63 74 20 28 72 65 76 69 73 69 6f 6e  = dict (revision
8870: 20 2d 3e 20 6c 69 73 74 20 28 72 65 76 69 73 69   -> list (revisi
8880: 6f 6e 29 29 0a 20 20 20 20 74 79 70 65 6d 65 74  on)).    typemet
8890: 68 6f 64 20 69 6e 74 65 72 6e 61 6c 73 75 63 63  hod internalsucc
88a0: 65 73 73 6f 72 73 20 7b 64 76 20 72 65 76 69 73  essors {dv revis
88b0: 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31  ions} {..upvar 1
88c0: 20 24 64 76 20 64 65 70 65 6e 64 65 6e 63 69 65   $dv dependencie
88d0: 73 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27  s..set theset ('
88e0: 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73  [join $revisions
88f0: 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 6c 6f 67 20   {','}]')...log 
8900: 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20 69  write 14 csets i
8910: 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f 72  nternalsuccessor
8920: 73 0a 0a 09 23 20 53 65 65 20 27 73 75 63 63 65  s...# See 'succe
8930: 73 73 6f 72 73 27 20 62 65 6c 6f 77 20 66 6f 72  ssors' below for
8940: 20 74 68 65 20 6d 61 69 6e 20 65 78 70 6c 61 6e   the main explan
8950: 61 74 69 6f 6e 20 6f 66 0a 09 23 20 74 68 65 20  ation of..# the 
8960: 76 61 72 69 6f 75 73 20 63 61 73 65 73 2e 20 54  various cases. T
8970: 68 69 73 20 70 69 65 63 65 20 69 73 20 73 70 65  his piece is spe
8980: 63 69 61 6c 20 69 6e 20 74 68 61 74 20 69 74 0a  cial in that it.
8990: 09 23 20 72 65 73 74 72 69 63 74 73 20 74 68 65  .# restricts the
89a0: 20 73 75 63 63 65 73 73 6f 72 73 20 77 65 20 6c   successors we l
89b0: 6f 6f 6b 20 66 6f 72 20 74 6f 20 74 68 65 20 73  ook for to the s
89c0: 61 6d 65 20 73 65 74 20 6f 66 0a 09 23 20 72 65  ame set of..# re
89d0: 76 69 73 69 6f 6e 73 20 77 65 20 73 74 61 72 74  visions we start
89e0: 20 66 72 6f 6d 2e 20 53 65 6e 73 69 62 6c 65 20   from. Sensible 
89f0: 61 73 20 77 65 20 61 72 65 20 6c 6f 6f 6b 69 6e  as we are lookin
8a00: 67 20 66 6f 72 0a 09 23 20 63 68 61 6e 67 65 73  g for..# changes
8a10: 65 74 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65  et internal depe
8a20: 6e 64 65 6e 63 69 65 73 2e 0a 0a 09 61 72 72 61  ndencies....arra
8a30: 79 20 73 65 74 20 64 65 70 20 7b 7d 0a 0a 09 66  y set dep {}...f
8a40: 6f 72 65 61 63 68 20 7b 72 69 64 20 63 68 69 6c  oreach {rid chil
8a50: 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73  d} [state run [s
8a60: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73  ubst -nocommands
8a70: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20   -nobackslashes 
8a80: 7b 0a 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69  {.    -- (1) Pri
8a90: 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20  mary child..    
8aa0: 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 2e  SELECT R.rid, R.
8ab0: 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20  child..    FROM 
8ac0: 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20    revision R..  
8ad0: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20    WHERE  R.rid  
8ae0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
8af0: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72  -- Restrict to r
8b00: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65  evisions of inte
8b10: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rest..    AND   
8b20: 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20   R.child IS NOT 
8b30: 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70  NULL    -- Has p
8b40: 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20  rimary child..  
8b50: 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64    AND    R.child
8b60: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
8b70: 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c 73 6f  -- Which is also
8b80: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20 20   of interest.   
8b90: 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 32   UNION.    -- (2
8ba0: 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72 61  ) Secondary (bra
8bb0: 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 20  nch) children.. 
8bc0: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
8bd0: 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46 52 4f   B.brid..    FRO
8be0: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
8bf0: 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68  revisionbranchch
8c00: 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 57 48  ildren B..    WH
8c10: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20  ERE  R.rid   IN 
8c20: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52  $theset     -- R
8c30: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
8c40: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
8c50: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72  ..    AND    R.r
8c60: 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20 20  id = B.rid      
8c70: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73 75      -- Select su
8c80: 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20 63  bset of branch c
8c90: 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 41 4e 44  hildren..    AND
8ca0: 20 20 20 20 42 2e 62 72 69 64 20 49 4e 20 24 74      B.brid IN $t
8cb0: 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 57 68  heset      -- Wh
8cc0: 69 63 68 20 69 73 20 61 6c 73 6f 20 6f 66 20 69  ich is also of i
8cd0: 6e 74 65 72 65 73 74 0a 20 20 20 20 55 4e 49 4f  nterest.    UNIO
8ce0: 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20 43 68 69  N.    -- (4) Chi
8cf0: 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74  ld of trunk root
8d00: 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 6c 61   successor of la
8d10: 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b  st NTDB on trunk
8d20: 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e  ...    SELECT R.
8d30: 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09 20  rid, RA.child.. 
8d40: 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e     FROM revision
8d50: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 0a   R, revision RA.
8d60: 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64  .    WHERE R.rid
8d70: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20     IN $theset   
8d80: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
8d90: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
8da0: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
8db0: 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74 20 20     R.isdefault  
8dc0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65             -- Re
8dd0: 73 74 72 69 63 74 20 74 6f 20 4e 54 44 42 0a 09  strict to NTDB..
8de0: 20 20 20 20 41 4e 44 20 20 20 52 2e 64 62 63 68      AND   R.dbch
8df0: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ild IS NOT NULL 
8e00: 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74 20 4e 54    -- and last NT
8e10: 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20  DB belonging to 
8e20: 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e 44 20 20  trunk..    AND  
8e30: 20 52 41 2e 72 69 64 20 3d 20 52 2e 64 62 63 68   RA.rid = R.dbch
8e40: 69 6c 64 20 20 20 20 20 20 2d 2d 20 47 6f 20 64  ild      -- Go d
8e50: 69 72 65 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b  irectly to trunk
8e60: 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e 44 20 20   root..    AND  
8e70: 20 52 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54   RA.child IS NOT
8e80: 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20   NULL    -- Has 
8e90: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 20  primary child.. 
8ea0: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
8eb0: 20 52 41 2e 63 68 69 6c 64 20 49 4e 20 24 74 68   RA.child IN $th
8ec0: 65 73 65 74 20 20 20 20 20 2d 2d 20 57 68 69 63  eset     -- Whic
8ed0: 68 20 69 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74  h is also of int
8ee0: 65 72 65 73 74 0a 09 7d 5d 5d 20 7b 0a 09 20 20  erest..}]] {..  
8ef0: 20 20 23 20 43 6f 6e 73 69 64 65 72 20 6d 6f 76    # Consider mov
8f00: 69 6e 67 20 74 68 69 73 20 74 6f 20 74 68 65 20  ing this to the 
8f10: 69 6e 74 65 67 72 69 74 79 20 6d 6f 64 75 6c 65  integrity module
8f20: 2e 0a 09 20 20 20 20 69 6e 74 65 67 72 69 74 79  ...    integrity
8f30: 20 61 73 73 65 72 74 20 7b 24 72 69 64 20 21 3d   assert {$rid !=
8f40: 20 24 63 68 69 6c 64 7d 20 7b 52 65 76 69 73 69   $child} {Revisi
8f50: 6f 6e 20 24 72 69 64 20 64 65 70 65 6e 64 73 20  on $rid depends 
8f60: 6f 6e 20 69 74 73 65 6c 66 2e 7d 0a 09 20 20 20  on itself.}..   
8f70: 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65   lappend depende
8f80: 6e 63 69 65 73 28 24 72 69 64 29 20 24 63 68 69  ncies($rid) $chi
8f90: 6c 64 0a 09 20 20 20 20 73 65 74 20 64 65 70 28  ld..    set dep(
8fa0: 24 72 69 64 2c 24 63 68 69 6c 64 29 20 2e 0a 09  $rid,$child) ...
8fb0: 7d 0a 0a 09 23 20 54 68 65 20 73 71 6c 20 73 74  }...# The sql st
8fc0: 61 74 65 6d 65 6e 74 73 20 61 62 6f 76 65 20 6c  atements above l
8fd0: 6f 6f 6b 73 20 6f 6e 6c 79 20 66 6f 72 20 64 69  ooks only for di
8fe0: 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63 69 65  rect dependencie
8ff0: 73 0a 09 23 20 62 65 74 77 65 65 6e 20 72 65 76  s..# between rev
9000: 69 73 69 6f 6e 20 69 6e 20 74 68 65 20 63 68 61  ision in the cha
9010: 6e 67 65 73 65 74 2e 20 48 6f 77 65 76 65 72 20  ngeset. However 
9020: 64 75 65 20 74 6f 20 74 68 65 0a 09 23 20 76 61  due to the..# va
9030: 67 61 72 69 65 73 20 6f 66 20 6d 65 74 61 20 64  garies of meta d
9040: 61 74 61 20 69 74 20 69 73 20 70 6f 73 73 69 62  ata it is possib
9050: 6c 65 20 66 6f 72 20 74 77 6f 20 72 65 76 69 73  le for two revis
9060: 69 6f 6e 73 20 6f 66 0a 09 23 20 74 68 65 20 73  ions of..# the s
9070: 61 6d 65 20 66 69 6c 65 20 74 6f 20 65 6e 64 20  ame file to end 
9080: 75 70 20 69 6e 20 74 68 65 20 73 61 6d 65 20 63  up in the same c
9090: 68 61 6e 67 65 73 65 74 2c 20 77 69 74 68 6f 75  hangeset, withou
90a0: 74 20 61 0a 09 23 20 64 69 72 65 63 74 20 64 65  t a..# direct de
90b0: 70 65 6e 64 65 6e 63 79 20 62 65 74 77 65 65 6e  pendency between
90c0: 20 74 68 65 6d 2e 20 48 6f 77 65 76 65 72 20 77   them. However w
90d0: 65 20 6b 6e 6f 77 20 74 68 61 74 20 74 68 65 72  e know that ther
90e0: 65 0a 09 23 20 68 61 73 20 74 6f 20 62 65 20 61  e..# has to be a
90f0: 20 61 6e 20 69 6e 64 69 72 65 63 74 20 64 65 70   an indirect dep
9100: 65 6e 64 65 6e 63 79 2c 20 62 65 20 69 74 20 74  endency, be it t
9110: 68 72 6f 75 67 68 20 70 72 69 6d 61 72 79 0a 09  hrough primary..
9120: 23 20 63 68 69 6c 64 72 65 6e 2c 20 62 72 61 6e  # children, bran
9130: 63 68 20 63 68 69 6c 64 72 65 6e 2c 20 6f 72 20  ch children, or 
9140: 61 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 74 68  a combination th
9150: 65 72 65 6f 66 2e 0a 0a 09 23 20 57 65 20 6e 6f  ereof....# We no
9160: 77 20 66 69 6c 6c 20 69 6e 20 74 68 65 73 65 20  w fill in these 
9170: 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 6e 63  pseudo-dependenc
9180: 69 65 73 2c 20 69 66 20 6e 6f 20 73 75 63 68 0a  ies, if no such.
9190: 09 23 20 64 65 70 65 6e 64 65 6e 63 79 20 65 78  .# dependency ex
91a0: 69 73 74 73 20 61 6c 72 65 61 64 79 2e 20 54 68  ists already. Th
91b0: 65 20 64 69 72 65 63 74 69 6f 6e 20 6f 66 20 74  e direction of t
91c0: 68 65 20 64 65 70 65 6e 64 65 6e 63 79 0a 09 23  he dependency..#
91d0: 20 69 73 20 61 63 74 75 61 6c 6c 79 20 69 72 72   is actually irr
91e0: 65 6c 65 76 61 6e 74 20 66 6f 72 20 74 68 69 73  elevant for this
91f0: 2e 0a 0a 09 23 20 4e 4f 54 45 3a 20 54 68 69 73  ....# NOTE: This
9200: 20 69 73 20 64 69 66 66 65 72 65 6e 74 20 66 72   is different fr
9210: 6f 6d 20 63 76 73 32 73 76 6e 2e 20 4f 75 72 20  om cvs2svn. Our 
9220: 73 70 69 72 69 74 75 61 6c 20 61 6e 63 65 73 74  spiritual ancest
9230: 6f 72 0a 09 23 20 64 6f 65 73 20 6e 6f 74 20 75  or..# does not u
9240: 73 65 20 73 75 63 68 20 70 73 65 75 64 6f 2d 64  se such pseudo-d
9250: 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 68 6f 77  ependencies, how
9260: 65 76 65 72 20 69 74 20 75 73 65 73 20 61 0a 09  ever it uses a..
9270: 23 20 43 4f 4d 4d 49 54 5f 54 48 52 45 53 48 4f  # COMMIT_THRESHO
9280: 4c 44 2c 20 61 20 74 69 6d 65 20 69 6e 74 65 72  LD, a time inter
9290: 76 61 6c 20 63 6f 6d 6d 69 74 73 20 73 68 6f 75  val commits shou
92a0: 6c 64 20 66 61 6c 6c 2e 20 54 68 69 73 0a 09 23  ld fall. This..#
92b0: 20 77 69 6c 6c 20 67 72 65 61 74 6c 79 20 72 65   will greatly re
92c0: 64 75 63 65 73 20 74 68 65 20 72 69 73 6b 20 6f  duces the risk o
92d0: 66 20 67 65 74 74 69 6e 67 20 66 61 72 20 73 65  f getting far se
92e0: 70 61 72 61 74 65 64 0a 09 23 20 72 65 76 69 73  parated..# revis
92f0: 69 6f 6e 73 20 6f 66 20 74 68 65 20 73 61 6d 65  ions of the same
9300: 20 66 69 6c 65 20 69 6e 74 6f 20 6f 6e 65 20 63   file into one c
9310: 68 61 6e 67 65 73 65 74 2e 0a 0a 09 23 20 57 65  hangeset....# We
9320: 20 61 6c 6c 6f 77 20 72 65 76 69 73 69 6f 6e 73   allow revisions
9330: 20 74 6f 20 62 65 20 66 61 72 20 61 70 61 72 74   to be far apart
9340: 20 69 6e 20 74 69 6d 65 20 69 6e 20 74 68 65 20   in time in the 
9350: 73 61 6d 65 0a 09 23 20 63 68 61 6e 67 65 73 65  same..# changese
9360: 74 2c 20 62 75 74 20 69 6e 20 74 75 72 6e 20 6e  t, but in turn n
9370: 65 65 64 20 74 68 65 20 70 73 65 75 64 6f 2d 64  eed the pseudo-d
9380: 65 70 65 6e 64 65 6e 63 69 65 73 20 74 6f 0a 09  ependencies to..
9390: 23 20 68 61 6e 64 6c 65 20 74 68 69 73 2e 0a 0a  # handle this...
93a0: 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63 73  .log write 14 cs
93b0: 65 74 73 20 7b 69 6e 74 65 72 6e 61 6c 20 20 5b  ets {internal  [
93c0: 61 72 72 61 79 20 73 69 7a 65 20 64 65 70 5d 7d  array size dep]}
93d0: 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63  ..log write 14 c
93e0: 73 65 74 73 20 7b 63 6f 6c 6c 65 63 74 65 64 20  sets {collected 
93f0: 5b 61 72 72 61 79 20 73 69 7a 65 20 64 65 70 65  [array size depe
9400: 6e 64 65 6e 63 69 65 73 5d 7d 0a 09 6c 6f 67 20  ndencies]}..log 
9410: 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20 70  write 14 csets p
9420: 73 65 75 64 6f 2d 69 6e 74 65 72 6e 61 6c 73 75  seudo-internalsu
9430: 63 63 65 73 73 6f 72 73 0a 0a 09 61 72 72 61 79  ccessors...array
9440: 20 73 65 74 20 66 69 64 73 20 7b 7d 0a 09 66 6f   set fids {}..fo
9450: 72 65 61 63 68 20 7b 72 69 64 20 66 69 64 7d 20  reach {rid fid} 
9460: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
9470: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
9480: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09  obackslashes {..
9490: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64      SELECT R.rid
94a0: 2c 20 52 2e 66 69 64 0a 20 20 20 20 20 20 20 20  , R.fid.        
94b0: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
94c0: 69 6f 6e 20 52 0a 20 20 20 20 20 20 20 20 20 20  ion R.          
94d0: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 49    WHERE  R.rid I
94e0: 4e 20 24 74 68 65 73 65 74 0a 09 7d 5d 5d 20 7b  N $theset..}]] {
94f0: 20 6c 61 70 70 65 6e 64 20 66 69 64 73 28 24 66   lappend fids($f
9500: 69 64 29 20 24 72 69 64 20 7d 0a 0a 09 73 65 74  id) $rid }...set
9510: 20 67 72 6f 75 70 73 20 7b 7d 0a 09 66 6f 72 65   groups {}..fore
9520: 61 63 68 20 7b 66 69 64 20 72 69 64 73 7d 20 5b  ach {fid rids} [
9530: 61 72 72 61 79 20 67 65 74 20 66 69 64 73 5d 20  array get fids] 
9540: 7b 0a 09 20 20 20 20 69 66 20 7b 5b 6c 6c 65 6e  {..    if {[llen
9550: 67 74 68 20 24 72 69 64 73 5d 20 3c 20 32 7d 20  gth $rids] < 2} 
9560: 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 66 6f  continue..    fo
9570: 72 65 61 63 68 20 61 20 24 72 69 64 73 20 7b 0a  reach a $rids {.
9580: 09 09 66 6f 72 65 61 63 68 20 62 20 24 72 69 64  ..foreach b $rid
9590: 73 20 7b 0a 09 09 20 20 20 20 69 66 20 7b 24 61  s {...    if {$a
95a0: 20 3d 3d 20 24 62 7d 20 63 6f 6e 74 69 6e 75 65   == $b} continue
95b0: 0a 09 09 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f  ...    if {[info
95c0: 20 65 78 69 73 74 73 20 64 65 70 28 24 61 2c 24   exists dep($a,$
95d0: 62 29 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09  b)]} continue...
95e0: 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78      if {[info ex
95f0: 69 73 74 73 20 64 65 70 28 24 62 2c 24 61 29 5d  ists dep($b,$a)]
9600: 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20  } continue...   
9610: 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65   lappend depende
9620: 6e 63 69 65 73 28 24 61 29 20 24 62 0a 09 09 20  ncies($a) $b... 
9630: 20 20 20 73 65 74 20 64 65 70 28 24 61 2c 24 62     set dep($a,$b
9640: 29 20 2e 0a 09 09 20 20 20 20 73 65 74 20 64 65  ) ....    set de
9650: 70 28 24 62 2c 24 61 29 20 2e 0a 09 09 7d 0a 09  p($b,$a) ....}..
9660: 20 20 20 20 7d 0a 09 20 20 20 20 73 65 74 20 6e      }..    set n
9670: 20 5b 6c 6c 65 6e 67 74 68 20 24 72 69 64 73 5d   [llength $rids]
9680: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 67 72  ..    lappend gr
9690: 6f 75 70 73 20 5b 6c 69 73 74 20 24 6e 20 5b 65  oups [list $n [e
96a0: 78 70 72 20 7b 28 24 6e 2a 24 6e 2d 24 6e 29 2f  xpr {($n*$n-$n)/
96b0: 32 7d 5d 5d 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72  2}]]..}...log wr
96c0: 69 74 65 20 31 34 20 63 73 65 74 73 20 7b 70 73  ite 14 csets {ps
96d0: 65 75 64 6f 20 20 20 20 5b 61 72 72 61 79 20 73  eudo    [array s
96e0: 69 7a 65 20 66 69 64 73 5d 20 28 5b 6c 73 6f 72  ize fids] ([lsor
96f0: 74 20 2d 69 6e 64 65 78 20 30 20 2d 64 65 63 72  t -index 0 -decr
9700: 65 61 73 69 6e 67 20 2d 69 6e 74 65 67 65 72 20  easing -integer 
9710: 24 67 72 6f 75 70 73 5d 29 7d 0a 09 6c 6f 67 20  $groups])}..log 
9720: 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b  write 14 csets {
9730: 69 6e 74 65 72 6e 61 6c 20 20 5b 61 72 72 61 79  internal  [array
9740: 20 73 69 7a 65 20 64 65 70 5d 7d 0a 09 6c 6f 67   size dep]}..log
9750: 20 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20   write 14 csets 
9760: 7b 63 6f 6c 6c 65 63 74 65 64 20 5b 61 72 72 61  {collected [arra
9770: 79 20 73 69 7a 65 20 64 65 70 65 6e 64 65 6e 63  y size dependenc
9780: 69 65 73 5d 7d 0a 09 6c 6f 67 20 77 72 69 74 65  ies]}..log write
9790: 20 31 34 20 63 73 65 74 73 20 63 6f 6d 70 6c 65   14 csets comple
97a0: 74 65 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  te..return.    }
97b0: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d  ..    # result =
97c0: 20 34 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70   4-list (itemtyp
97d0: 65 20 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65  e itemid nextite
97e0: 6d 74 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64  mtype nextitemid
97f0: 20 2e 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65   ...).    typeme
9800: 74 68 6f 64 20 6c 6f 6f 70 73 20 7b 72 65 76 69  thod loops {revi
9810: 73 69 6f 6e 73 7d 20 7b 0a 09 23 20 4e 6f 74 65  sions} {..# Note
9820: 3a 20 54 61 67 73 20 61 6e 64 20 62 72 61 6e 63  : Tags and branc
9830: 68 65 73 20 63 61 6e 6e 6f 74 20 63 61 75 73 65  hes cannot cause
9840: 20 74 68 65 20 6c 6f 6f 70 2e 20 54 68 65 69 72   the loop. Their
9850: 20 69 64 27 73 2c 0a 09 23 20 62 65 69 6e 67 20   id's,..# being 
9860: 6f 66 20 61 20 66 75 6e 64 61 6d 65 6e 74 61 6c  of a fundamental
9870: 6c 79 20 64 69 66 66 65 72 65 6e 74 20 74 79 70  ly different typ
9880: 65 20 74 68 61 6e 20 74 68 65 20 72 65 76 69 73  e than the revis
9890: 69 6f 6e 73 0a 09 23 20 63 6f 6d 69 6e 67 20 69  ions..# coming i
98a0: 6e 20 63 61 6e 6e 6f 74 20 62 65 20 69 6e 20 74  n cannot be in t
98b0: 68 65 20 73 65 74 2e 0a 0a 09 73 65 74 20 74 68  he set....set th
98c0: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65  eset ('[join $re
98d0: 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29  visions {','}]')
98e0: 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20  ..return [state 
98f0: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
9900: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
9910: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 2d 2d 20  ashes {..    -- 
9920: 28 31 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c  (1) Primary chil
9930: 64 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e  d..    SELECT R.
9940: 72 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20  rid, R.child..  
9950: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f    FROM   revisio
9960: 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20  n R..    WHERE  
9970: 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73  R.rid   IN $thes
9980: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  et     -- Restri
9990: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
99a0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
99b0: 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20   AND    R.child 
99c0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d  IS NOT NULL    -
99d0: 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68  - Has primary ch
99e0: 69 6c 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ild..    AND    
99f0: 52 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73  R.child IN $thes
9a00: 65 74 20 20 20 20 20 2d 2d 20 4c 6f 6f 70 0a 09  et     -- Loop..
9a10: 20 20 20 20 2d 2d 0a 09 20 20 20 20 55 4e 49 4f      --..    UNIO
9a20: 4e 0a 09 20 20 20 20 2d 2d 20 28 32 29 20 53 65  N..    -- (2) Se
9a30: 63 6f 6e 64 61 72 79 20 28 62 72 61 6e 63 68 29  condary (branch)
9a40: 20 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 53   children..    S
9a50: 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62  ELECT R.rid, B.b
9a60: 72 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  rid..    FROM   
9a70: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69  revision R, revi
9a80: 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72  sionbranchchildr
9a90: 65 6e 20 42 0a 09 20 20 20 20 57 48 45 52 45 20  en B..    WHERE 
9aa0: 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65   R.rid   IN $the
9ab0: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72  set     -- Restr
9ac0: 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73  ict to revisions
9ad0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
9ae0: 20 20 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d    AND    R.rid =
9af0: 20 42 2e 72 69 64 20 20 20 20 20 20 20 20 20 20   B.rid          
9b00: 2d 2d 20 53 65 6c 65 63 74 20 73 75 62 73 65 74  -- Select subset
9b10: 20 6f 66 20 62 72 61 6e 63 68 20 63 68 69 6c 64   of branch child
9b20: 72 65 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ren..    AND    
9b30: 42 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73  B.rid   IN $thes
9b40: 65 74 20 20 20 20 20 2d 2d 20 4c 6f 6f 70 0a 09  et     -- Loop..
9b50: 20 20 20 20 2d 2d 0a 09 20 20 20 20 55 4e 49 4f      --..    UNIO
9b60: 4e 0a 09 20 20 20 20 2d 2d 20 28 34 29 20 43 68  N..    -- (4) Ch
9b70: 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f  ild of trunk roo
9b80: 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 6c  t successor of l
9b90: 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e  ast NTDB on trun
9ba0: 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52  k...    SELECT R
9bb0: 2e 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09  .rid, RA.child..
9bc0: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
9bd0: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
9be0: 52 41 0a 09 20 20 20 20 57 48 45 52 45 20 20 52  RA..    WHERE  R
9bf0: 2e 72 69 64 20 20 20 20 49 4e 20 24 74 68 65 73  .rid    IN $thes
9c00: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  et     -- Restri
9c10: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
9c20: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
9c30: 20 41 4e 44 20 20 20 20 52 2e 69 73 64 65 66 61   AND    R.isdefa
9c40: 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20  ult             
9c50: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e  -- Restrict to N
9c60: 54 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 20  TDB..    AND    
9c70: 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54  R.dbchild IS NOT
9c80: 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c   NULL   -- and l
9c90: 61 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69  ast NTDB belongi
9ca0: 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20  ng to trunk..   
9cb0: 20 41 4e 44 20 20 20 20 52 41 2e 72 69 64 20 3d   AND    RA.rid =
9cc0: 20 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20   R.dbchild      
9cd0: 2d 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74  -- Go directly t
9ce0: 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20  o trunk root..  
9cf0: 20 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c    AND    RA.chil
9d00: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20  d IS NOT NULL   
9d10: 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20   -- Has primary 
9d20: 63 68 69 6c 64 2e 0a 09 20 20 20 20 41 4e 44 20  child...    AND 
9d30: 20 20 20 52 41 2e 63 68 69 6c 64 20 49 4e 20 24     RA.child IN $
9d40: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c 6f  theset     -- Lo
9d50: 6f 70 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20  op..}]].    }.. 
9d60: 20 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64     # var(dv) = d
9d70: 69 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73  ict (item -> lis
9d80: 74 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20  t (item)), item 
9d90: 20 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69 64   = list (type id
9da0: 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ).    typemethod
9db0: 20 73 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20   successors {dv 
9dc0: 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70  revisions} {..up
9dd0: 76 61 72 20 31 20 24 64 76 20 64 65 70 65 6e 64  var 1 $dv depend
9de0: 65 6e 63 69 65 73 0a 09 73 65 74 20 74 68 65 73  encies..set thes
9df0: 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69  et ('[join $revi
9e00: 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 0a  sions {','}]')..
9e10: 09 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67  .# The following
9e20: 20 63 61 73 65 73 20 73 70 65 63 69 66 79 20 77   cases specify w
9e30: 68 65 6e 20 61 20 72 65 76 69 73 69 6f 6e 20 53  hen a revision S
9e40: 20 69 73 20 61 20 73 75 63 63 65 73 73 6f 72 0a   is a successor.
9e50: 09 23 20 6f 66 20 61 20 72 65 76 69 73 69 6f 6e  .# of a revision
9e60: 20 52 2e 20 45 61 63 68 20 6f 66 20 74 68 65 20   R. Each of the 
9e70: 63 61 73 65 73 20 74 72 61 6e 73 6c 61 74 65 73  cases translates
9e80: 20 69 6e 74 6f 20 6f 6e 65 20 6f 66 0a 09 23 20   into one of..# 
9e90: 74 68 65 20 62 72 61 6e 63 68 65 73 20 6f 66 20  the branches of 
9ea0: 74 68 65 20 53 51 4c 20 55 4e 49 4f 4e 20 63 6f  the SQL UNION co
9eb0: 6d 69 6e 67 20 62 65 6c 6f 77 2e 0a 09 23 0a 09  ming below...#..
9ec0: 23 20 28 31 29 20 53 20 63 61 6e 20 62 65 20 61  # (1) S can be a
9ed0: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 6f   primary child o
9ee0: 66 20 52 2c 20 69 2e 65 2e 20 69 6e 20 74 68 65  f R, i.e. in the
9ef0: 20 73 61 6d 65 20 4c 4f 44 2e 20 52 0a 09 23 20   same LOD. R..# 
9f00: 20 20 20 20 72 65 66 65 72 65 6e 63 65 73 20 53      references S
9f10: 20 64 69 72 65 63 74 6c 79 2e 20 52 2e 63 68 69   directly. R.chi
9f20: 6c 64 20 3d 20 53 28 2e 72 69 64 29 2c 20 69 66  ld = S(.rid), if
9f30: 20 69 74 20 65 78 69 73 74 73 2e 0a 09 23 0a 09   it exists...#..
9f40: 23 20 28 32 29 20 53 20 63 61 6e 20 62 65 20 61  # (2) S can be a
9f50: 20 73 65 63 6f 6e 64 61 72 79 2c 20 69 2e 65 2e   secondary, i.e.
9f60: 20 62 72 61 6e 63 68 2c 20 63 68 69 6c 64 20 6f   branch, child o
9f70: 66 20 52 2e 20 48 65 72 65 20 74 68 65 0a 09 23  f R. Here the..#
9f80: 20 20 20 20 20 6c 69 6e 6b 20 69 73 20 6d 61 64       link is mad
9f90: 65 20 74 68 72 6f 75 67 68 20 74 68 65 20 68 65  e through the he
9fa0: 6c 70 65 72 20 74 61 62 6c 65 0a 09 23 20 20 20  lper table..#   
9fb0: 20 20 52 45 56 49 53 49 4f 4e 42 52 41 4e 43 48    REVISIONBRANCH
9fc0: 43 48 49 4c 44 52 45 4e 2e 20 52 2e 72 69 64 20  CHILDREN. R.rid 
9fd0: 2d 3e 20 52 42 43 2e 72 69 64 2c 20 52 42 43 2e  -> RBC.rid, RBC.
9fe0: 62 72 69 64 20 3d 0a 09 23 20 20 20 20 20 53 28  brid =..#     S(
9ff0: 2e 72 69 64 29 0a 09 23 0a 09 23 20 28 33 29 20  .rid)..#..# (3) 
a000: 4f 72 69 67 69 6e 61 6c 6c 79 20 74 68 69 73 20  Originally this 
a010: 75 73 65 20 63 61 73 65 20 64 65 66 69 6e 65 64  use case defined
a020: 20 74 68 65 20 72 6f 6f 74 20 6f 66 20 61 20 64   the root of a d
a030: 65 74 61 63 68 65 64 0a 09 23 20 20 20 20 20 4e  etached..#     N
a040: 54 44 42 20 61 73 20 74 68 65 20 73 75 63 63 65  TDB as the succe
a050: 73 73 6f 72 20 6f 66 20 74 68 65 20 74 72 75 6e  ssor of the trun
a060: 6b 20 72 6f 6f 74 2e 20 54 68 69 73 20 6c 65 61  k root. This lea
a070: 64 73 20 74 6f 20 61 0a 09 23 20 20 20 20 20 62  ds to a..#     b
a080: 61 64 20 74 61 6e 67 6c 65 20 6c 61 74 65 72 20  ad tangle later 
a090: 6f 6e 2e 20 57 69 74 68 20 61 20 64 65 74 61 63  on. With a detac
a0a0: 68 65 64 20 4e 54 44 42 20 74 68 65 20 6f 72 69  hed NTDB the ori
a0b0: 67 69 6e 61 6c 0a 09 23 20 20 20 20 20 74 72 75  ginal..#     tru
a0c0: 6e 6b 20 72 6f 6f 74 20 72 65 76 69 73 69 6f 6e  nk root revision
a0d0: 20 77 61 73 20 72 65 6d 6f 76 65 64 20 61 73 20   was removed as 
a0e0: 69 72 72 65 6c 65 76 61 6e 74 2c 20 61 6c 6c 6f  irrelevant, allo
a0f0: 77 69 6e 67 0a 09 23 20 20 20 20 20 74 68 65 20  wing..#     the 
a100: 6e 6f 6d 69 6e 61 6c 20 72 6f 6f 74 20 74 6f 20  nominal root to 
a110: 62 65 20 6c 61 74 65 72 20 69 6e 20 74 69 6d 65  be later in time
a120: 20 74 68 61 6e 20 74 68 65 20 4e 54 44 42 0a 09   than the NTDB..
a130: 23 20 20 20 20 20 72 6f 6f 74 2e 20 4e 6f 77 20  #     root. Now 
a140: 73 65 74 74 69 6e 67 20 74 68 69 73 20 64 65 70  setting this dep
a150: 65 6e 64 65 6e 63 79 20 77 69 6c 6c 20 62 65 20  endency will be 
a160: 62 61 63 6b 77 61 72 64 20 69 6e 0a 09 23 20 20  backward in..#  
a170: 20 20 20 74 69 6d 65 2e 20 52 45 4d 4f 56 45 44     time. REMOVED
a180: 2e 0a 09 23 0a 09 23 20 28 34 29 20 49 66 20 52  ...#..# (4) If R
a190: 20 69 73 20 74 68 65 20 6c 61 73 74 20 6f 66 20   is the last of 
a1a0: 74 68 65 20 4e 54 44 42 20 72 65 76 69 73 69 6f  the NTDB revisio
a1b0: 6e 73 20 77 68 69 63 68 20 62 65 6c 6f 6e 67 20  ns which belong 
a1c0: 74 6f 0a 09 23 20 20 20 20 20 74 68 65 20 74 72  to..#     the tr
a1d0: 75 6e 6b 2c 20 74 68 65 6e 20 74 68 65 20 70 72  unk, then the pr
a1e0: 69 6d 61 72 79 20 63 68 69 6c 64 20 6f 66 20 74  imary child of t
a1f0: 68 65 20 74 72 75 6e 6b 20 72 6f 6f 74 20 28 74  he trunk root (t
a200: 68 65 0a 09 23 20 20 20 20 20 27 31 2e 32 27 20  he..#     '1.2' 
a210: 72 65 76 69 73 69 6f 6e 29 20 69 73 20 61 20 73  revision) is a s
a220: 75 63 63 65 73 73 6f 72 2c 20 69 66 20 69 74 20  uccessor, if it 
a230: 65 78 69 73 74 73 2e 0a 0a 09 23 20 4e 6f 74 65  exists....# Note
a240: 20 74 68 61 74 20 74 68 65 20 62 72 61 6e 63 68   that the branch
a250: 65 73 20 73 70 61 77 6e 65 64 20 66 72 6f 6d 20  es spawned from 
a260: 74 68 65 20 72 65 76 69 73 69 6f 6e 73 2c 20 61  the revisions, a
a270: 6e 64 20 74 68 65 0a 09 23 20 74 61 67 73 20 61  nd the..# tags a
a280: 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74  ssociated with t
a290: 68 65 6d 20 61 72 65 20 73 75 63 63 65 73 73 6f  hem are successo
a2a0: 72 73 20 61 73 20 77 65 6c 6c 2e 0a 0a 09 66 6f  rs as well....fo
a2b0: 72 65 61 63 68 20 7b 72 69 64 20 63 68 69 6c 64  reach {rid child
a2c0: 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75  } [state run [su
a2d0: 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20  bst -nocommands 
a2e0: 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b  -nobackslashes {
a2f0: 0a 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d  .    -- (1) Prim
a300: 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53  ary child..    S
a310: 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 2e 63  ELECT R.rid, R.c
a320: 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  hild..    FROM  
a330: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20   revision R..   
a340: 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20   WHERE  R.rid   
a350: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
a360: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65  - Restrict to re
a370: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72  visions of inter
a380: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  est..    AND    
a390: 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e  R.child IS NOT N
a3a0: 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72  ULL    -- Has pr
a3b0: 69 6d 61 72 79 20 63 68 69 6c 64 0a 20 20 20 20  imary child.    
a3c0: 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 32 29  UNION.    -- (2)
a3d0: 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72 61 6e   Secondary (bran
a3e0: 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 20 20  ch) children..  
a3f0: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20    SELECT R.rid, 
a400: 42 2e 62 72 69 64 0a 09 20 20 20 20 46 52 4f 4d  B.brid..    FROM
a410: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72     revision R, r
a420: 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69  evisionbranchchi
a430: 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 57 48 45  ldren B..    WHE
a440: 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24  RE  R.rid   IN $
a450: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65  theset     -- Re
a460: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
a470: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  ons of interest.
a480: 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72 69  .    AND    R.ri
a490: 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20 20 20  d = B.rid       
a4a0: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73 75 62     -- Select sub
a4b0: 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20 63 68  set of branch ch
a4c0: 69 6c 64 72 65 6e 0a 20 20 20 20 55 4e 49 4f 4e  ildren.    UNION
a4d0: 0a 20 20 20 20 2d 2d 20 28 34 29 20 43 68 69 6c  .    -- (4) Chil
a4e0: 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74 20  d of trunk root 
a4f0: 73 75 63 63 65 73 73 6f 72 20 6f 66 20 6c 61 73  successor of las
a500: 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b 2e  t NTDB on trunk.
a510: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72  ..    SELECT R.r
a520: 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09 20 20  id, RA.child..  
a530: 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20    FROM revision 
a540: 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 0a 09  R, revision RA..
a550: 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64 20      WHERE R.rid 
a560: 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20    IN $theset    
a570: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
a580: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
a590: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
a5a0: 20 20 52 2e 69 73 64 65 66 61 75 6c 74 20 20 20    R.isdefault   
a5b0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73            -- Res
a5c0: 74 72 69 63 74 20 74 6f 20 4e 54 44 42 0a 09 20  trict to NTDB.. 
a5d0: 20 20 20 41 4e 44 20 20 20 52 2e 64 62 63 68 69     AND   R.dbchi
a5e0: 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20  ld IS NOT NULL  
a5f0: 20 2d 2d 20 61 6e 64 20 6c 61 73 74 20 4e 54 44   -- and last NTD
a600: 42 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74  B belonging to t
a610: 72 75 6e 6b 0a 09 20 20 20 20 41 4e 44 20 20 20  runk..    AND   
a620: 52 41 2e 72 69 64 20 3d 20 52 2e 64 62 63 68 69  RA.rid = R.dbchi
a630: 6c 64 20 20 20 20 20 20 2d 2d 20 47 6f 20 64 69  ld      -- Go di
a640: 72 65 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20  rectly to trunk 
a650: 72 6f 6f 74 0a 09 20 20 20 20 41 4e 44 20 20 20  root..    AND   
a660: 52 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20  RA.child IS NOT 
a670: 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70  NULL    -- Has p
a680: 72 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 7d  rimary child...}
a690: 5d 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73  ]] {..    # Cons
a6a0: 69 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69 73  ider moving this
a6b0: 20 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69 74   to the integrit
a6c0: 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69  y module...    i
a6d0: 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20  ntegrity assert 
a6e0: 7b 24 72 69 64 20 21 3d 20 24 63 68 69 6c 64 7d  {$rid != $child}
a6f0: 20 7b 52 65 76 69 73 69 6f 6e 20 24 72 69 64 20   {Revision $rid 
a700: 64 65 70 65 6e 64 73 20 6f 6e 20 69 74 73 65 6c  depends on itsel
a710: 66 2e 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64  f.}..    lappend
a720: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c   dependencies([l
a730: 69 73 74 20 72 65 76 20 24 72 69 64 5d 29 20 5b  ist rev $rid]) [
a740: 6c 69 73 74 20 72 65 76 20 24 63 68 69 6c 64 5d  list rev $child]
a750: 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b 72 69  ..}..foreach {ri
a760: 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20  d child} [state 
a770: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
a780: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
a790: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c  ashes {..    SEL
a7a0: 45 43 54 20 52 2e 72 69 64 2c 20 54 2e 74 69 64  ECT R.rid, T.tid
a7b0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76  ..    FROM   rev
a7c0: 69 73 69 6f 6e 20 52 2c 20 74 61 67 20 54 0a 09  ision R, tag T..
a7d0: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64      WHERE  R.rid
a7e0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
a7f0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
a800: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
a810: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
a820: 20 20 20 54 2e 72 65 76 20 3d 20 52 2e 72 69 64     T.rev = R.rid
a830: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c            -- Sel
a840: 65 63 74 20 74 61 67 73 20 61 74 74 61 63 68 65  ect tags attache
a850: 64 20 74 6f 20 74 68 65 6d 0a 09 7d 5d 5d 20 7b  d to them..}]] {
a860: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65  ..    lappend de
a870: 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74  pendencies([list
a880: 20 72 65 76 20 24 72 69 64 5d 29 20 5b 6c 69 73   rev $rid]) [lis
a890: 74 20 73 79 6d 3a 3a 74 61 67 20 24 63 68 69 6c  t sym::tag $chil
a8a0: 64 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b  d]..}..foreach {
a8b0: 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74  rid child} [stat
a8c0: 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f  e run [subst -no
a8d0: 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b  commands -noback
a8e0: 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53  slashes {..    S
a8f0: 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62  ELECT R.rid, B.b
a900: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72  id..    FROM   r
a910: 65 76 69 73 69 6f 6e 20 52 2c 20 62 72 61 6e 63  evision R, branc
a920: 68 20 42 0a 09 20 20 20 20 57 48 45 52 45 20 20  h B..    WHERE  
a930: 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74  R.rid IN $theset
a940: 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69         -- Restri
a950: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
a960: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
a970: 20 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d   AND    B.root =
a980: 20 52 2e 72 69 64 20 20 20 20 20 20 20 20 20 2d   R.rid         -
a990: 2d 20 53 65 6c 65 63 74 20 62 72 61 6e 63 68 65  - Select branche
a9a0: 73 20 61 74 74 61 63 68 65 64 20 74 6f 20 74 68  s attached to th
a9b0: 65 6d 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c  em..}]] {..    l
a9c0: 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63  append dependenc
a9d0: 69 65 73 28 5b 6c 69 73 74 20 72 65 76 20 24 72  ies([list rev $r
a9e0: 69 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d 3a 3a  id]) [list sym::
a9f0: 62 72 61 6e 63 68 20 24 63 68 69 6c 64 5d 0a 09  branch $child]..
aa00: 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  }..return.    }.
aa10: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20  .    # result = 
aa20: 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65 74 2d  list (changeset-
aa30: 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68  id).    typemeth
aa40: 6f 64 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73  od cs_successors
aa50: 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 20   {revisions} {. 
aa60: 20 20 20 20 20 20 20 23 20 54 68 69 73 20 69 73         # This is
aa70: 20 61 20 76 61 72 69 61 6e 74 20 6f 66 20 27 73   a variant of 's
aa80: 75 63 63 65 73 73 6f 72 73 27 20 77 68 69 63 68  uccessors' which
aa90: 20 6d 61 70 73 20 74 68 65 20 6c 6f 77 2d 6c 65   maps the low-le
aaa0: 76 65 6c 0a 20 20 20 20 20 20 20 20 23 20 64 61  vel.        # da
aab0: 74 61 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74  ta directly to t
aac0: 68 65 20 61 73 73 6f 63 69 61 74 65 64 20 63 68  he associated ch
aad0: 61 6e 67 65 73 65 74 73 2e 20 49 2e 65 2e 20 69  angesets. I.e. i
aae0: 6e 73 74 65 61 64 0a 20 20 20 20 20 20 20 20 23  nstead.        #
aaf0: 20 6d 69 6c 6c 69 6f 6e 73 20 6f 66 20 64 65 70   millions of dep
ab00: 65 6e 64 65 6e 63 79 20 70 61 69 72 73 20 28 69  endency pairs (i
ab10: 6e 20 65 78 74 72 65 6d 65 20 63 61 73 65 73 20  n extreme cases 
ab20: 28 45 78 61 6d 70 6c 65 3a 20 54 63 6c 0a 20 20  (Example: Tcl.  
ab30: 20 20 20 20 20 20 23 20 43 56 53 29 29 20 77 65        # CVS)) we
ab40: 20 72 65 74 75 72 6e 20 61 20 76 65 72 79 20 73   return a very s
ab50: 68 6f 72 74 20 61 6e 64 20 6d 75 63 68 20 6d 6f  hort and much mo
ab60: 72 65 20 6d 61 6e 61 67 65 61 62 6c 65 20 6c 69  re manageable li
ab70: 73 74 0a 20 20 20 20 20 20 20 20 23 20 6f 66 20  st.        # of 
ab80: 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09 73 65  changesets....se
ab90: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
aba0: 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27   $revisions {','
abb0: 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74  }]')..return [st
abc0: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
abd0: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
abe0: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 20 20 20 20  ckslashes {.    
abf0: 2d 2d 20 28 31 29 20 50 72 69 6d 61 72 79 20 63  -- (1) Primary c
ac00: 68 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 43 54  hild..    SELECT
ac10: 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d   C.cid..    FROM
ac20: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 63     revision R, c
ac30: 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65  sitem CI, change
ac40: 73 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 45  set C..    WHERE
ac50: 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68    R.rid   IN $th
ac60: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74  eset     -- Rest
ac70: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e  rict to revision
ac80: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
ac90: 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c     AND    R.chil
aca0: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20  d IS NOT NULL   
acb0: 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20   -- Has primary 
acc0: 63 68 69 6c 64 0a 20 20 20 20 20 20 20 20 20 20  child.          
acd0: 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20    AND    CI.iid 
ace0: 3d 20 52 2e 63 68 69 6c 64 20 20 20 20 20 20 20  = R.child       
acf0: 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68  -- Select all ch
ad00: 61 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20 20  angesets.       
ad10: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69       AND    C.ci
ad20: 64 20 3d 20 43 49 2e 63 69 64 20 20 20 20 20 20  d = CI.cid      
ad30: 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67     -- containing
ad40: 20 74 68 65 20 70 72 69 6d 61 72 79 20 63 68 69   the primary chi
ad50: 6c 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 41  ld.            A
ad60: 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30  ND    C.type = 0
ad70: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20               -- 
ad80: 77 68 69 63 68 20 61 72 65 20 72 65 76 69 73 69  which are revisi
ad90: 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20  on changesets.  
ada0: 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28    UNION.    -- (
adb0: 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72  2) Secondary (br
adc0: 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09  anch) children..
add0: 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64      SELECT C.cid
ade0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76  ..    FROM   rev
adf0: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
ae00: 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20  nbranchchildren 
ae10: 42 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68  B, csitem CI, ch
ae20: 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57  angeset C..    W
ae30: 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e  HERE  R.rid   IN
ae40: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
ae50: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
ae60: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
ae70: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
ae80: 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20  rid = B.rid     
ae90: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73       -- Select s
aea0: 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20  ubset of branch 
aeb0: 63 68 69 6c 64 72 65 6e 0a 20 20 20 20 20 20 20  children.       
aec0: 20 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69       AND    CI.i
aed0: 69 64 20 3d 20 42 2e 62 72 69 64 20 20 20 20 20  id = B.brid     
aee0: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c     -- Select all
aef0: 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20   changesets.    
af00: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
af10: 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 20 20  .cid = CI.cid.  
af20: 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68  -- containing th
af30: 65 20 62 72 61 6e 63 68 0a 20 20 20 20 20 20 20  e branch.       
af40: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79       AND    C.ty
af50: 70 65 20 3d 20 30 09 09 20 20 2d 2d 20 77 68 69  pe = 0..  -- whi
af60: 63 68 20 61 72 65 20 72 65 76 69 73 69 6f 6e 20  ch are revision 
af70: 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 55  changesets.    U
af80: 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20  NION.    -- (4) 
af90: 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72  Child of trunk r
afa0: 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66  oot successor of
afb0: 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72   last NTDB on tr
afc0: 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54  unk...    SELECT
afd0: 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d   C.cid..    FROM
afe0: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72     revision R, r
aff0: 65 76 69 73 69 6f 6e 20 52 41 2c 20 63 73 69 74  evision RA, csit
b000: 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74  em CI, changeset
b010: 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 52   C..    WHERE  R
b020: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65  .rid   IN $these
b030: 74 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  t      -- Restri
b040: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
b050: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
b060: 20 41 4e 44 20 20 20 20 52 2e 69 73 64 65 66 61   AND    R.isdefa
b070: 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20  ult             
b080: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e  -- Restrict to N
b090: 54 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 20  TDB..    AND    
b0a0: 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54  R.dbchild IS NOT
b0b0: 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c   NULL   -- and l
b0c0: 61 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69  ast NTDB belongi
b0d0: 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20  ng to trunk..   
b0e0: 20 41 4e 44 20 20 20 20 52 41 2e 72 69 64 20 3d   AND    RA.rid =
b0f0: 20 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20   R.dbchild      
b100: 2d 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74  -- Go directly t
b110: 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20  o trunk root..  
b120: 20 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c    AND    RA.chil
b130: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20  d IS NOT NULL   
b140: 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20   -- Has primary 
b150: 63 68 69 6c 64 2e 0a 20 20 20 20 20 20 20 20 20  child..         
b160: 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64     AND    CI.iid
b170: 20 3d 20 52 41 2e 63 68 69 6c 64 20 20 20 20 20   = RA.child     
b180: 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20    -- Select all 
b190: 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 20  changesets.     
b1a0: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e         AND    C.
b1b0: 63 69 64 20 3d 20 43 49 2e 63 69 64 09 20 20 20  cid = CI.cid.   
b1c0: 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68  -- containing th
b1d0: 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a  e primary child.
b1e0: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20              AND 
b1f0: 20 20 20 43 2e 74 79 70 65 20 3d 20 30 09 09 20     C.type = 0.. 
b200: 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 72    -- which are r
b210: 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65  evision changese
b220: 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20  ts.    UNION..  
b230: 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09    SELECT C.cid..
b240: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
b250: 69 6f 6e 20 52 2c 20 74 61 67 20 54 2c 20 63 73  ion R, tag T, cs
b260: 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73  item CI, changes
b270: 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20  et C..    WHERE 
b280: 20 52 2e 72 69 64 20 69 6e 20 24 74 68 65 73 65   R.rid in $these
b290: 74 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74  t        -- Rest
b2a0: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e  rict to revision
b2b0: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
b2c0: 20 20 20 41 4e 44 20 20 20 20 54 2e 72 65 76 20     AND    T.rev 
b2d0: 3d 20 52 2e 72 69 64 09 20 20 20 2d 2d 20 53 65  = R.rid.   -- Se
b2e0: 6c 65 63 74 20 74 61 67 73 20 61 74 74 61 63 68  lect tags attach
b2f0: 65 64 20 74 6f 20 74 68 65 6d 0a 20 20 20 20 20  ed to them.     
b300: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49         AND    CI
b310: 2e 69 69 64 20 3d 20 54 2e 74 69 64 20 20 20 20  .iid = T.tid    
b320: 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20        -- Select 
b330: 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20  all changesets. 
b340: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
b350: 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64    C.cid = CI.cid
b360: 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e  .   -- containin
b370: 67 20 74 68 65 20 74 61 67 73 0a 20 20 20 20 20  g the tags.     
b380: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e         AND    C.
b390: 74 79 70 65 20 3d 20 31 09 09 20 20 20 2d 2d 20  type = 1..   -- 
b3a0: 77 68 69 63 68 20 61 72 65 20 74 61 67 20 63 68  which are tag ch
b3b0: 61 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49  angesets.    UNI
b3c0: 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43  ON..    SELECT C
b3d0: 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  .cid..    FROM  
b3e0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 62 72 61   revision R, bra
b3f0: 6e 63 68 20 42 2c 20 63 73 69 74 65 6d 20 43 49  nch B, csitem CI
b400: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20  , changeset C.. 
b410: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
b420: 69 6e 20 24 74 68 65 73 65 74 20 20 20 20 20 20  in $theset      
b430: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
b440: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
b450: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
b460: 20 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69     B.root = R.ri
b470: 64 09 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 62  d.   -- Select b
b480: 72 61 6e 63 68 65 73 20 61 74 74 61 63 68 65 64  ranches attached
b490: 20 74 6f 20 74 68 65 6d 0a 20 20 20 20 20 20 20   to them.       
b4a0: 20 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69       AND    CI.i
b4b0: 69 64 20 3d 20 42 2e 62 69 64 20 20 20 20 20 20  id = B.bid      
b4c0: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c      -- Select al
b4d0: 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20  l changesets.   
b4e0: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
b4f0: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 20  C.cid = CI.cid. 
b500: 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20    -- containing 
b510: 74 68 65 20 62 72 61 6e 63 68 65 73 0a 20 20 20  the branches.   
b520: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
b530: 43 2e 74 79 70 65 20 3d 20 32 09 09 20 20 20 2d  C.type = 2..   -
b540: 2d 20 77 68 69 63 68 20 61 72 65 20 62 72 61 6e  - which are bran
b550: 63 68 20 63 68 61 6e 67 65 73 65 74 73 0a 09 7d  ch changesets..}
b560: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  ]].    }..    # 
b570: 72 65 73 75 6c 74 20 3d 20 73 79 6d 62 6f 6c 20  result = symbol 
b580: 6e 61 6d 65 0a 20 20 20 20 74 79 70 65 6d 65 74  name.    typemet
b590: 68 6f 64 20 63 73 5f 6c 6f 64 20 7b 72 65 76 69  hod cs_lod {revi
b5a0: 73 69 6f 6e 73 7d 20 7b 0a 09 23 20 44 65 74 65  sions} {..# Dete
b5b0: 72 6d 69 6e 65 73 20 74 68 65 20 6e 61 6d 65 20  rmines the name 
b5c0: 6f 66 20 74 68 65 20 73 79 6d 62 6f 6c 20 77 68  of the symbol wh
b5d0: 69 63 68 20 69 73 20 74 68 65 20 6c 69 6e 65 20  ich is the line 
b5e0: 6f 66 0a 09 23 20 64 65 76 65 6c 6f 70 6d 65 6e  of..# developmen
b5f0: 74 20 66 6f 72 20 74 68 65 20 72 65 76 69 73 69  t for the revisi
b600: 6f 6e 73 20 69 6e 20 61 20 63 68 61 6e 67 65 73  ons in a changes
b610: 65 74 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74  et....set theset
b620: 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69   ('[join $revisi
b630: 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65  ons {','}]')..re
b640: 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20  turn [state run 
b650: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e  [subst -nocomman
b660: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65  ds -nobackslashe
b670: 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 0a  s {..    SELECT.
b680: 09 20 20 20 20 44 49 53 54 49 4e 43 54 20 4c 2e  .    DISTINCT L.
b690: 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20  name..    FROM  
b6a0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 73 79 6d   revision R, sym
b6b0: 62 6f 6c 20 4c 0a 09 20 20 20 20 57 48 45 52 45  bol L..    WHERE
b6c0: 20 20 52 2e 72 69 64 20 69 6e 20 24 74 68 65 73    R.rid in $thes
b6d0: 65 74 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73  et        -- Res
b6e0: 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f  trict to revisio
b6f0: 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  ns of interest..
b700: 20 20 20 20 41 4e 44 20 20 20 20 4c 2e 73 69 64      AND    L.sid
b710: 20 3d 20 52 2e 6c 6f 64 20 20 20 20 20 20 20 20   = R.lod        
b720: 20 20 20 2d 2d 20 47 65 74 20 6c 6f 64 20 73 79     -- Get lod sy
b730: 6d 62 6f 6c 20 6f 66 20 72 65 76 69 73 69 6f 6e  mbol of revision
b740: 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 7d 0a 0a 23  ..}]].    }.}..#
b750: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
b760: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
b770: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
b780: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
b790: 48 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e  Helper singleton
b7a0: 2e 20 43 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 74  . Commands for t
b7b0: 61 67 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65  ag symbol change
b7c0: 73 65 74 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70  sets...snit::typ
b7d0: 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  e ::vc::fossil::
b7e0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f  import::cvs::pro
b7f0: 6a 65 63 74 3a 3a 72 65 76 3a 3a 73 79 6d 3a 3a  ject::rev::sym::
b800: 74 61 67 20 7b 0a 20 20 20 20 74 79 70 65 6d 65  tag {.    typeme
b810: 74 68 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20  thod byrevision 
b820: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a  {} { return 0 }.
b830: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62      typemethod b
b840: 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 7b 20 72  ysymbol   {} { r
b850: 65 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79  eturn 1 }.    ty
b860: 70 65 6d 65 74 68 6f 64 20 69 73 74 61 67 20 20  pemethod istag  
b870: 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20      {} { return 
b880: 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68  1 }.    typemeth
b890: 6f 64 20 69 73 62 72 61 6e 63 68 20 20 20 7b 7d  od isbranch   {}
b8a0: 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 0a 20   { return 0 }.. 
b8b0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 74     typemethod st
b8c0: 72 20 7b 74 61 67 7d 20 7b 0a 09 73 74 72 75 63  r {tag} {..struc
b8d0: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b  t::list assign [
b8e0: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20  state run {..   
b8f0: 20 53 45 4c 45 43 54 20 53 2e 6e 61 6d 65 2c 20   SELECT S.name, 
b900: 46 2e 6e 61 6d 65 2c 20 50 2e 6e 61 6d 65 0a 09  F.name, P.name..
b910: 20 20 20 20 46 52 4f 4d 20 20 20 74 61 67 20 54      FROM   tag T
b920: 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 66 69 6c 65  , symbol S, file
b930: 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a 09 20   F, project P.. 
b940: 20 20 20 57 48 45 52 45 20 20 54 2e 74 69 64 20     WHERE  T.tid 
b950: 3d 20 24 74 61 67 20 20 20 2d 2d 20 46 69 6e 64  = $tag   -- Find
b960: 20 73 70 65 63 69 66 69 65 64 20 74 61 67 0a 09   specified tag..
b970: 20 20 20 20 41 4e 44 20 20 20 20 46 2e 66 69 64      AND    F.fid
b980: 20 3d 20 54 2e 66 69 64 20 20 2d 2d 20 47 65 74   = T.fid  -- Get
b990: 20 66 69 6c 65 20 6f 66 20 74 61 67 0a 09 20 20   file of tag..  
b9a0: 20 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20 3d    AND    P.pid =
b9b0: 20 46 2e 70 69 64 20 20 2d 2d 20 47 65 74 20 70   F.pid  -- Get p
b9c0: 72 6f 6a 65 63 74 20 6f 66 20 66 69 6c 65 0a 09  roject of file..
b9d0: 20 20 20 20 41 4e 44 20 20 20 20 53 2e 73 69 64      AND    S.sid
b9e0: 20 3d 20 54 2e 73 69 64 20 20 2d 2d 20 47 65 74   = T.sid  -- Get
b9f0: 20 73 79 6d 62 6f 6c 20 6f 66 20 74 61 67 0a 09   symbol of tag..
ba00: 7d 5d 20 73 6e 61 6d 65 20 66 6e 61 6d 65 20 70  }] sname fname p
ba10: 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20 22 24 70  name..return "$p
ba20: 6e 61 6d 65 2f 54 27 24 7b 73 6e 61 6d 65 7d 27  name/T'${sname}'
ba30: 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20 20 7d 0a  ::$fname".    }.
ba40: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20  .    # result = 
ba50: 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20 6d  list (mintime, m
ba60: 61 78 74 69 6d 65 29 0a 20 20 20 20 74 79 70 65  axtime).    type
ba70: 6d 65 74 68 6f 64 20 74 69 6d 65 72 61 6e 67 65  method timerange
ba80: 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20 54 68 65   {tags} {..# The
ba90: 20 72 61 6e 67 65 20 69 73 20 64 65 66 69 6e 65   range is define
baa0: 64 20 61 73 20 74 68 65 20 72 61 6e 67 65 20 6f  d as the range o
bab0: 66 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 20  f the revisions 
bac0: 74 68 65 20 74 61 67 73 0a 09 23 20 61 72 65 20  the tags..# are 
bad0: 61 74 74 61 63 68 65 64 20 74 6f 2e 0a 0a 09 73  attached to....s
bae0: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
baf0: 6e 20 24 74 61 67 73 20 7b 27 2c 27 7d 5d 27 29  n $tags {','}]')
bb00: 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20  ..return [state 
bb10: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
bb20: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
bb30: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c  ashes {..    SEL
bb40: 45 43 54 20 4d 49 4e 28 52 2e 64 61 74 65 29 2c  ECT MIN(R.date),
bb50: 20 4d 41 58 28 52 2e 64 61 74 65 29 0a 09 20 20   MAX(R.date)..  
bb60: 20 20 46 52 4f 4d 20 20 20 74 61 67 20 54 2c 20    FROM   tag T, 
bb70: 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20  revision R..    
bb80: 57 48 45 52 45 20 20 54 2e 74 69 64 20 49 4e 20  WHERE  T.tid IN 
bb90: 24 74 68 65 73 65 74 20 20 2d 2d 20 52 65 73 74  $theset  -- Rest
bba0: 72 69 63 74 20 74 6f 20 74 61 67 73 20 6f 66 20  rict to tags of 
bbb0: 69 6e 74 65 72 65 73 74 0a 20 20 20 20 20 20 20  interest.       
bbc0: 20 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72 69       AND    R.ri
bbd0: 64 20 3d 20 54 2e 72 65 76 20 20 20 20 20 2d 2d  d = T.rev     --
bbe0: 20 53 65 6c 65 63 74 20 74 61 67 20 70 61 72 65   Select tag pare
bbf0: 6e 74 20 72 65 76 69 73 69 6f 6e 73 0a 09 7d 5d  nt revisions..}]
bc00: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 76  ].    }..    # v
bc10: 61 72 28 64 76 29 20 3d 20 64 69 63 74 20 28 69  ar(dv) = dict (i
bc20: 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69 74 65  tem -> list (ite
bc30: 6d 29 29 2c 20 69 74 65 6d 20 20 3d 20 6c 69 73  m)), item  = lis
bc40: 74 20 28 74 79 70 65 20 69 64 29 0a 20 20 20 20  t (type id).    
bc50: 74 79 70 65 6d 65 74 68 6f 64 20 73 75 63 63 65  typemethod succe
bc60: 73 73 6f 72 73 20 7b 64 76 20 74 61 67 73 7d 20  ssors {dv tags} 
bc70: 7b 0a 09 23 20 54 61 67 73 20 68 61 76 65 20 6e  {..# Tags have n
bc80: 6f 20 73 75 63 63 65 73 73 6f 72 73 2e 0a 09 72  o successors...r
bc90: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
bca0: 20 23 20 72 65 73 75 6c 74 20 3d 20 34 2d 6c 69   # result = 4-li
bcb0: 73 74 20 28 69 74 65 6d 74 79 70 65 20 69 74 65  st (itemtype ite
bcc0: 6d 69 64 20 6e 65 78 74 69 74 65 6d 74 79 70 65  mid nextitemtype
bcd0: 20 6e 65 78 74 69 74 65 6d 69 64 20 2e 2e 2e 29   nextitemid ...)
bce0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
bcf0: 6c 6f 6f 70 73 20 7b 74 61 67 73 7d 20 7b 0a 09  loops {tags} {..
bd00: 23 20 54 61 67 73 20 68 61 76 65 20 6e 6f 20 73  # Tags have no s
bd10: 75 63 63 65 73 73 6f 72 73 2c 20 74 68 65 72 65  uccessors, there
bd20: 66 6f 72 65 20 63 61 6e 6e 6f 74 20 63 61 75 73  fore cannot caus
bd30: 65 20 6c 6f 6f 70 73 0a 09 72 65 74 75 72 6e 20  e loops..return 
bd40: 7b 7d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  {}.    }..    # 
bd50: 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 63  result = list (c
bd60: 68 61 6e 67 65 73 65 74 2d 69 64 29 0a 20 20 20  hangeset-id).   
bd70: 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f 73   typemethod cs_s
bd80: 75 63 63 65 73 73 6f 72 73 20 7b 74 61 67 73 7d  uccessors {tags}
bd90: 20 7b 0a 09 23 20 54 61 67 73 20 68 61 76 65 20   {..# Tags have 
bda0: 6e 6f 20 73 75 63 63 65 73 73 6f 72 73 2e 0a 09  no successors...
bdb0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
bdc0: 20 20 23 20 72 65 73 75 6c 74 20 3d 20 73 79 6d    # result = sym
bdd0: 62 6f 6c 20 6e 61 6d 65 0a 20 20 20 20 74 79 70  bol name.    typ
bde0: 65 6d 65 74 68 6f 64 20 63 73 5f 6c 6f 64 20 7b  emethod cs_lod {
bdf0: 74 61 67 73 7d 20 7b 0a 09 23 20 44 65 74 65 72  tags} {..# Deter
be00: 6d 69 6e 65 73 20 74 68 65 20 6e 61 6d 65 20 6f  mines the name o
be10: 66 20 74 68 65 20 73 79 6d 62 6f 6c 20 77 68 69  f the symbol whi
be20: 63 68 20 69 73 20 74 68 65 20 6c 69 6e 65 20 6f  ch is the line o
be30: 66 0a 09 23 20 64 65 76 65 6c 6f 70 6d 65 6e 74  f..# development
be40: 20 66 6f 72 20 74 68 65 20 74 61 67 73 20 69 6e   for the tags in
be50: 20 61 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09   a changeset....
be60: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f  set theset ('[jo
be70: 69 6e 20 24 74 61 67 73 20 7b 27 2c 27 7d 5d 27  in $tags {','}]'
be80: 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65  )..return [state
be90: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63   run [subst -noc
bea0: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73  ommands -nobacks
beb0: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45  lashes {..    SE
bec0: 4c 45 43 54 0a 09 20 20 20 20 44 49 53 54 49 4e  LECT..    DISTIN
bed0: 43 54 20 4c 2e 6e 61 6d 65 0a 09 20 20 20 20 46  CT L.name..    F
bee0: 52 4f 4d 20 20 20 74 61 67 20 54 2c 20 73 79 6d  ROM   tag T, sym
bef0: 62 6f 6c 20 4c 0a 09 20 20 20 20 57 48 45 52 45  bol L..    WHERE
bf00: 20 20 54 2e 74 69 64 20 69 6e 20 24 74 68 65 73    T.tid in $thes
bf10: 65 74 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73  et        -- Res
bf20: 74 72 69 63 74 20 74 6f 20 74 61 67 73 20 6f 66  trict to tags of
bf30: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41   interest..    A
bf40: 4e 44 20 20 20 20 4c 2e 73 69 64 20 3d 20 54 2e  ND    L.sid = T.
bf50: 6c 6f 64 20 20 20 20 20 20 20 20 20 20 20 2d 2d  lod           --
bf60: 20 47 65 74 20 6c 6f 64 20 73 79 6d 62 6f 6c 20   Get lod symbol 
bf70: 6f 66 20 74 61 67 0a 09 7d 5d 5d 0a 20 20 20 20  of tag..}]].    
bf80: 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20  }.}..# # ## ### 
bf90: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
bfa0: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23  ############ ###
bfb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
bfc0: 23 23 0a 23 23 20 48 65 6c 70 65 72 20 73 69 6e  ##.## Helper sin
bfd0: 67 6c 65 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73  gleton. Commands
bfe0: 20 66 6f 72 20 62 72 61 6e 63 68 20 73 79 6d 62   for branch symb
bff0: 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a  ol changesets...
c000: 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a  snit::type ::vc:
c010: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
c020: 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72  :cvs::project::r
c030: 65 76 3a 3a 73 79 6d 3a 3a 62 72 61 6e 63 68 20  ev::sym::branch 
c040: 7b 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  {.    typemethod
c050: 20 62 79 72 65 76 69 73 69 6f 6e 20 7b 7d 20 7b   byrevision {} {
c060: 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20   return 0 }.    
c070: 74 79 70 65 6d 65 74 68 6f 64 20 62 79 73 79 6d  typemethod bysym
c080: 62 6f 6c 20 20 20 7b 7d 20 7b 20 72 65 74 75 72  bol   {} { retur
c090: 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65  n 1 }.    typeme
c0a0: 74 68 6f 64 20 69 73 74 61 67 20 20 20 20 20 20  thod istag      
c0b0: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a  {} { return 0 }.
c0c0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69      typemethod i
c0d0: 73 62 72 61 6e 63 68 20 20 20 7b 7d 20 7b 20 72  sbranch   {} { r
c0e0: 65 74 75 72 6e 20 31 20 7d 0a 0a 20 20 20 20 74  eturn 1 }..    t
c0f0: 79 70 65 6d 65 74 68 6f 64 20 73 74 72 20 7b 62  ypemethod str {b
c100: 72 61 6e 63 68 7d 20 7b 0a 09 73 74 72 75 63 74  ranch} {..struct
c110: 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 73  ::list assign [s
c120: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
c130: 53 45 4c 45 43 54 20 53 2e 6e 61 6d 65 2c 20 46  SELECT S.name, F
c140: 2e 6e 61 6d 65 2c 20 50 2e 6e 61 6d 65 0a 09 20  .name, P.name.. 
c150: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68     FROM   branch
c160: 20 42 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 66 69   B, symbol S, fi
c170: 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a  le F, project P.
c180: 09 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69  .    WHERE  B.bi
c190: 64 20 3d 20 24 62 72 61 6e 63 68 20 20 2d 2d 20  d = $branch  -- 
c1a0: 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 20 62  Find specified b
c1b0: 72 61 6e 63 68 0a 09 20 20 20 20 41 4e 44 20 20  ranch..    AND  
c1c0: 20 20 46 2e 66 69 64 20 3d 20 42 2e 66 69 64 20    F.fid = B.fid 
c1d0: 20 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f     -- Get file o
c1e0: 66 20 62 72 61 6e 63 68 0a 09 20 20 20 20 41 4e  f branch..    AN
c1f0: 44 20 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70  D    P.pid = F.p
c200: 69 64 20 20 20 20 2d 2d 20 47 65 74 20 70 72 6f  id    -- Get pro
c210: 6a 65 63 74 20 6f 66 20 66 69 6c 65 0a 09 20 20  ject of file..  
c220: 20 20 41 4e 44 20 20 20 20 53 2e 73 69 64 20 3d    AND    S.sid =
c230: 20 42 2e 73 69 64 20 20 20 20 2d 2d 20 47 65 74   B.sid    -- Get
c240: 20 73 79 6d 62 6f 6c 20 6f 66 20 62 72 61 6e 63   symbol of branc
c250: 68 0a 09 7d 5d 20 73 6e 61 6d 65 20 66 6e 61 6d  h..}] sname fnam
c260: 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20  e pname..return 
c270: 22 24 70 6e 61 6d 65 2f 42 27 24 7b 73 6e 61 6d  "$pname/B'${snam
c280: 65 7d 27 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20  e}'::$fname".   
c290: 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74   }..    # result
c2a0: 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65   = list (mintime
c2b0: 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74  , maxtime).    t
c2c0: 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61  ypemethod timera
c2d0: 6e 67 65 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b  nge {branches} {
c2e0: 0a 09 23 20 54 68 65 20 72 61 6e 67 65 20 6f 66  ..# The range of
c2f0: 20 61 20 62 72 61 6e 63 68 20 69 73 20 64 65 66   a branch is def
c300: 69 6e 65 64 20 61 73 20 74 68 65 20 72 61 6e 67  ined as the rang
c310: 65 20 6f 66 20 74 68 65 0a 09 23 20 72 65 76 69  e of the..# revi
c320: 73 69 6f 6e 73 20 74 68 65 20 62 72 61 6e 63 68  sions the branch
c330: 65 73 20 61 72 65 20 73 70 61 77 6e 65 64 20 62  es are spawned b
c340: 79 2e 20 4e 4f 54 45 20 68 6f 77 65 76 65 72 20  y. NOTE however 
c350: 74 68 61 74 20 74 68 65 0a 09 23 20 62 72 61 6e  that the..# bran
c360: 63 68 65 73 20 61 73 73 6f 63 69 61 74 65 64 20  ches associated 
c370: 77 69 74 68 20 61 20 64 65 74 61 63 68 65 64 20  with a detached 
c380: 4e 54 44 42 20 77 69 6c 6c 20 68 61 76 65 20 6e  NTDB will have n
c390: 6f 20 72 6f 6f 74 0a 09 23 20 73 70 61 77 6e 69  o root..# spawni
c3a0: 6e 67 20 74 68 65 6d 2c 20 68 65 6e 63 65 20 74  ng them, hence t
c3b0: 68 65 79 20 68 61 76 65 20 6e 6f 20 72 65 61 6c  hey have no real
c3c0: 20 74 69 6d 65 72 61 6e 67 65 20 61 6e 79 0a 09   timerange any..
c3d0: 23 20 6c 6f 6e 67 65 72 2e 20 42 79 20 75 73 69  # longer. By usi
c3e0: 6e 67 20 30 20 77 65 20 70 75 74 20 74 68 65 6d  ng 0 we put them
c3f0: 20 69 6e 20 66 72 6f 6e 74 20 6f 66 20 65 76 65   in front of eve
c400: 72 79 74 68 69 6e 67 20 65 6c 73 65 2c 0a 09 23  rything else,..#
c410: 20 61 73 20 74 68 65 79 20 6c 6f 67 69 63 61 6c   as they logical
c420: 6c 79 20 61 72 65 2e 0a 0a 09 73 65 74 20 74 68  ly are....set th
c430: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72  eset ('[join $br
c440: 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a  anches {','}]').
c450: 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72  .return [state r
c460: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d  un [subst -nocom
c470: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61  mands -nobacksla
c480: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45  shes {..    SELE
c490: 43 54 20 49 46 4e 55 4c 4c 28 4d 49 4e 28 52 2e  CT IFNULL(MIN(R.
c4a0: 64 61 74 65 29 2c 30 29 2c 20 49 46 4e 55 4c 4c  date),0), IFNULL
c4b0: 28 4d 41 58 28 52 2e 64 61 74 65 29 2c 30 29 0a  (MAX(R.date),0).
c4c0: 09 20 20 20 20 46 52 4f 4d 20 20 62 72 61 6e 63  .    FROM  branc
c4d0: 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a  h B, revision R.
c4e0: 09 20 20 20 20 57 48 45 52 45 20 42 2e 62 69 64  .    WHERE B.bid
c4f0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 2d 2d   IN $theset   --
c500: 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 61   Restrict to bra
c510: 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73  nches of interes
c520: 74 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e  t.            AN
c530: 44 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 6f  D   R.rid = B.ro
c540: 6f 74 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74  ot     -- Select
c550: 20 62 72 61 6e 63 68 20 70 61 72 65 6e 74 20 72   branch parent r
c560: 65 76 69 73 69 6f 6e 73 0a 09 7d 5d 5d 0a 20 20  evisions..}]].  
c570: 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c    }..    # resul
c580: 74 20 3d 20 34 2d 6c 69 73 74 20 28 69 74 65 6d  t = 4-list (item
c590: 74 79 70 65 20 69 74 65 6d 69 64 20 6e 65 78 74  type itemid next
c5a0: 69 74 65 6d 74 79 70 65 20 6e 65 78 74 69 74 65  itemtype nextite
c5b0: 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 20 74 79 70  mid ...).    typ
c5c0: 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 73 20 7b 62  emethod loops {b
c5d0: 72 61 6e 63 68 65 73 7d 20 7b 0a 09 23 20 4e 6f  ranches} {..# No
c5e0: 74 65 3a 20 52 65 76 69 73 69 6f 6e 73 20 61 6e  te: Revisions an
c5f0: 64 20 74 61 67 73 20 63 61 6e 6e 6f 74 20 63 61  d tags cannot ca
c600: 75 73 65 20 74 68 65 20 6c 6f 6f 70 2e 20 42 65  use the loop. Be
c610: 69 6e 67 20 6f 66 20 61 0a 09 23 20 66 75 6e 64  ing of a..# fund
c620: 61 6d 65 6e 74 61 6c 6c 79 20 64 69 66 66 65 72  amentally differ
c630: 65 6e 74 20 74 79 70 65 20 74 68 65 79 20 63 61  ent type they ca
c640: 6e 6e 6f 74 20 62 65 20 69 6e 20 74 68 65 20 69  nnot be in the i
c650: 6e 63 6f 6d 69 6e 67 0a 09 23 20 73 65 74 20 6f  ncoming..# set o
c660: 66 20 69 64 73 2e 0a 0a 09 73 65 74 20 74 68 65  f ids....set the
c670: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61  set ('[join $bra
c680: 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 09  nches {','}]')..
c690: 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75  return [state ru
c6a0: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
c6b0: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
c6c0: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  hes {..    SELEC
c6d0: 54 20 42 2e 62 69 64 2c 20 42 58 2e 62 69 64 0a  T B.bid, BX.bid.
c6e0: 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e  .    FROM   bran
c6f0: 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 70 61  ch B, preferedpa
c700: 72 65 6e 74 20 50 2c 20 62 72 61 6e 63 68 20 42  rent P, branch B
c710: 58 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e  X..    WHERE  B.
c720: 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  bid IN $theset  
c730: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
c740: 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65  branches of inte
c750: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rest..    AND   
c760: 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 64 20 20   B.sid = P.pid  
c770: 20 20 20 20 2d 2d 20 47 65 74 20 74 68 65 20 70      -- Get the p
c780: 72 65 66 65 72 65 64 20 62 72 61 6e 63 68 65 73  refered branches
c790: 20 76 69 61 0a 09 20 20 20 20 41 4e 44 20 20 20   via..    AND   
c7a0: 20 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 64 20   BX.sid = P.sid 
c7b0: 20 20 20 20 2d 2d 20 74 68 65 20 62 72 61 6e 63      -- the branc
c7c0: 68 20 73 79 6d 62 6f 6c 73 0a 09 20 20 20 20 41  h symbols..    A
c7d0: 4e 44 20 20 20 20 42 58 2e 62 69 64 20 49 4e 20  ND    BX.bid IN 
c7e0: 24 74 68 65 73 65 74 20 20 2d 2d 20 4c 6f 6f 70  $theset  -- Loop
c7f0: 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20  ..}]].    }..   
c800: 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 63   # var(dv) = dic
c810: 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20  t (item -> list 
c820: 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 3d  (item)), item  =
c830: 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29 0a   list (type id).
c840: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73      typemethod s
c850: 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20 62 72  uccessors {dv br
c860: 61 6e 63 68 65 73 7d 20 7b 0a 09 75 70 76 61 72  anches} {..upvar
c870: 20 31 20 24 64 76 20 64 65 70 65 6e 64 65 6e 63   1 $dv dependenc
c880: 69 65 73 0a 09 23 20 54 68 65 20 66 69 72 73 74  ies..# The first
c890: 20 72 65 76 69 73 69 6f 6e 20 63 6f 6d 6d 69 74   revision commit
c8a0: 74 65 64 20 6f 6e 20 61 20 62 72 61 6e 63 68 2c  ted on a branch,
c8b0: 20 61 6e 64 20 61 6c 6c 20 62 72 61 6e 63 68 65   and all branche
c8c0: 73 0a 09 23 20 61 6e 64 20 74 61 67 73 20 77 68  s..# and tags wh
c8d0: 69 63 68 20 68 61 76 65 20 69 74 20 61 73 20 74  ich have it as t
c8e0: 68 65 69 72 20 70 72 65 66 65 72 65 64 20 70 61  heir prefered pa
c8f0: 72 65 6e 74 20 61 72 65 20 74 68 65 0a 09 23 20  rent are the..# 
c900: 73 75 63 63 65 73 73 6f 72 73 20 6f 66 20 61 20  successors of a 
c910: 62 72 61 6e 63 68 2e 0a 0a 09 73 65 74 20 74 68  branch....set th
c920: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72  eset ('[join $br
c930: 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a  anches {','}]').
c940: 09 66 6f 72 65 61 63 68 20 7b 62 69 64 20 63 68  .foreach {bid ch
c950: 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20  ild} [state run 
c960: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e  [subst -nocomman
c970: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65  ds -nobackslashe
c980: 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20  s {..    SELECT 
c990: 42 2e 62 69 64 2c 20 52 2e 72 69 64 0a 09 20 20  B.bid, R.rid..  
c9a0: 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20    FROM   branch 
c9b0: 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20  B, revision R.. 
c9c0: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20     WHERE  B.bid 
c9d0: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
c9e0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72  - Restrict to br
c9f0: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65  anches of intere
ca00: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  st..    AND    B
ca10: 2e 66 69 72 73 74 20 3d 20 52 2e 72 69 64 20 20  .first = R.rid  
ca20: 20 20 20 20 2d 2d 20 47 65 74 20 66 69 72 73 74      -- Get first
ca30: 20 72 65 76 69 73 69 6f 6e 20 6f 6e 20 74 68 65   revision on the
ca40: 20 62 72 61 6e 63 68 0a 09 7d 5d 5d 20 7b 0a 09   branch..}]] {..
ca50: 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65      lappend depe
ca60: 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 73  ndencies([list s
ca70: 79 6d 3a 3a 62 72 61 6e 63 68 20 24 62 69 64 5d  ym::branch $bid]
ca80: 29 20 5b 6c 69 73 74 20 72 65 76 20 24 63 68 69  ) [list rev $chi
ca90: 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20  ld]..}..foreach 
caa0: 7b 62 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61  {bid child} [sta
cab0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
cac0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
cad0: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
cae0: 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 58  SELECT B.bid, BX
caf0: 2e 62 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  .bid..    FROM  
cb00: 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65   branch B, prefe
cb10: 72 65 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61  redparent P, bra
cb20: 6e 63 68 20 42 58 0a 09 20 20 20 20 57 48 45 52  nch BX..    WHER
cb30: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65  E  B.bid IN $the
cb40: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72  set     -- Restr
cb50: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20  ict to branches 
cb60: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
cb70: 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20   AND    B.sid = 
cb80: 50 2e 70 69 64 20 20 20 20 20 20 20 20 2d 2d 20  P.pid        -- 
cb90: 47 65 74 20 73 75 62 6f 72 64 69 6e 61 74 65 20  Get subordinate 
cba0: 62 72 61 6e 63 68 65 73 20 76 69 61 20 74 68 65  branches via the
cbb0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e  ..    AND    BX.
cbc0: 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20 20 20  sid = P.sid     
cbd0: 20 20 2d 2d 20 70 72 65 66 65 72 65 64 20 70 61    -- prefered pa
cbe0: 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20 73  rents of their s
cbf0: 79 6d 62 6f 6c 73 0a 09 7d 5d 5d 20 7b 0a 09 20  ymbols..}]] {.. 
cc00: 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e     lappend depen
cc10: 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 73 79  dencies([list sy
cc20: 6d 3a 3a 62 72 61 6e 63 68 20 24 62 69 64 5d 29  m::branch $bid])
cc30: 20 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e   [list sym::bran
cc40: 63 68 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66  ch $child]..}..f
cc50: 6f 72 65 61 63 68 20 7b 62 69 64 20 63 68 69 6c  oreach {bid chil
cc60: 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73  d} [state run [s
cc70: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73  ubst -nocommands
cc80: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20   -nobackslashes 
cc90: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e  {..    SELECT B.
cca0: 62 69 64 2c 20 54 2e 74 69 64 0a 09 20 20 20 20  bid, T.tid..    
ccb0: 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c  FROM   branch B,
ccc0: 20 70 72 65 66 65 72 65 64 70 61 72 65 6e 74 20   preferedparent 
ccd0: 50 2c 20 74 61 67 20 54 0a 09 20 20 20 20 57 48  P, tag T..    WH
cce0: 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74  ERE  B.bid IN $t
ccf0: 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73  heset     -- Res
cd00: 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65  trict to branche
cd10: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
cd20: 20 20 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20     AND    B.sid 
cd30: 3d 20 50 2e 70 69 64 20 20 20 20 20 20 20 20 2d  = P.pid        -
cd40: 2d 20 47 65 74 20 73 75 62 6f 72 64 69 6e 61 74  - Get subordinat
cd50: 65 20 74 61 67 73 20 76 69 61 20 74 68 65 0a 09  e tags via the..
cd60: 20 20 20 20 41 4e 44 20 20 20 20 54 2e 73 69 64      AND    T.sid
cd70: 20 3d 20 50 2e 73 69 64 20 20 20 20 20 20 20 20   = P.sid        
cd80: 2d 2d 20 70 72 65 66 65 72 65 64 20 70 61 72 65  -- prefered pare
cd90: 6e 74 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d  nts of their sym
cda0: 62 6f 6c 73 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20  bols..}]] {..   
cdb0: 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65   lappend depende
cdc0: 6e 63 69 65 73 28 5b 6c 69 73 74 20 73 79 6d 3a  ncies([list sym:
cdd0: 3a 62 72 61 6e 63 68 20 24 62 69 64 5d 29 20 5b  :branch $bid]) [
cde0: 6c 69 73 74 20 73 79 6d 3a 3a 74 61 67 20 24 63  list sym::tag $c
cdf0: 68 69 6c 64 5d 0a 09 7d 0a 09 72 65 74 75 72 6e  hild]..}..return
ce00: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65  .    }..    # re
ce10: 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61  sult = list (cha
ce20: 6e 67 65 73 65 74 2d 69 64 29 0a 20 20 20 20 74  ngeset-id).    t
ce30: 79 70 65 6d 65 74 68 6f 64 20 63 73 5f 73 75 63  ypemethod cs_suc
ce40: 63 65 73 73 6f 72 73 20 7b 62 72 61 6e 63 68 65  cessors {branche
ce50: 73 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 20 54  s} {.        # T
ce60: 68 69 73 20 69 73 20 61 20 76 61 72 69 61 6e 74  his is a variant
ce70: 20 6f 66 20 27 73 75 63 63 65 73 73 6f 72 73 27   of 'successors'
ce80: 20 77 68 69 63 68 20 6d 61 70 73 20 74 68 65 20   which maps the 
ce90: 6c 6f 77 2d 6c 65 76 65 6c 0a 20 20 20 20 20 20  low-level.      
cea0: 20 20 23 20 64 61 74 61 20 64 69 72 65 63 74 6c    # data directl
ceb0: 79 20 74 6f 20 74 68 65 20 61 73 73 6f 63 69 61  y to the associa
cec0: 74 65 64 20 63 68 61 6e 67 65 73 65 74 73 2e 20  ted changesets. 
ced0: 49 2e 65 2e 20 69 6e 73 74 65 61 64 0a 20 20 20  I.e. instead.   
cee0: 20 20 20 20 20 23 20 6d 69 6c 6c 69 6f 6e 73 20       # millions 
cef0: 6f 66 20 64 65 70 65 6e 64 65 6e 63 79 20 70 61  of dependency pa
cf00: 69 72 73 20 28 69 6e 20 65 78 74 72 65 6d 65 20  irs (in extreme 
cf10: 63 61 73 65 73 20 28 45 78 61 6d 70 6c 65 3a 20  cases (Example: 
cf20: 54 63 6c 0a 20 20 20 20 20 20 20 20 23 20 43 56  Tcl.        # CV
cf30: 53 29 29 20 77 65 20 72 65 74 75 72 6e 20 61 20  S)) we return a 
cf40: 76 65 72 79 20 73 68 6f 72 74 20 61 6e 64 20 6d  very short and m
cf50: 75 63 68 20 6d 6f 72 65 20 6d 61 6e 61 67 65 61  uch more managea
cf60: 62 6c 65 20 6c 69 73 74 0a 20 20 20 20 20 20 20  ble list.       
cf70: 20 23 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73   # of changesets
cf80: 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28  ....set theset (
cf90: 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63 68 65 73  '[join $branches
cfa0: 20 7b 27 2c 27 7d 5d 27 29 0a 20 20 20 20 20 20   {','}]').      
cfb0: 20 20 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20    return [state 
cfc0: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
cfd0: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
cfe0: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c  ashes {..    SEL
cff0: 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46  ECT C.cid..    F
d000: 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20  ROM   branch B, 
d010: 72 65 76 69 73 69 6f 6e 20 52 2c 20 63 73 69 74  revision R, csit
d020: 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74  em CI, changeset
d030: 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 42   C..    WHERE  B
d040: 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .bid IN $theset 
d050: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
d060: 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69  to branches of i
d070: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
d080: 20 20 20 20 42 2e 66 69 72 73 74 20 3d 20 52 2e      B.first = R.
d090: 72 69 64 09 2d 2d 20 47 65 74 20 66 69 72 73 74  rid.-- Get first
d0a0: 20 72 65 76 69 73 69 6f 6e 20 6f 6e 20 74 68 65   revision on the
d0b0: 20 62 72 61 6e 63 68 0a 20 20 20 20 20 20 20 20   branch.        
d0c0: 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69      AND    CI.ii
d0d0: 64 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 20  d = R.rid       
d0e0: 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68  -- Select all ch
d0f0: 61 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20 20  angesets.       
d100: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69       AND    C.ci
d110: 64 20 3d 20 43 49 2e 63 69 64 09 2d 2d 20 63 6f  d = CI.cid.-- co
d120: 6e 74 61 69 6e 69 6e 67 20 74 68 69 73 20 72 65  ntaining this re
d130: 76 69 73 69 6f 6e 0a 20 20 20 20 20 20 20 20 20  vision.         
d140: 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65     AND    C.type
d150: 20 3d 20 30 09 09 2d 2d 20 77 68 69 63 68 20 61   = 0..-- which a
d160: 72 65 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e  re revision chan
d170: 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f 4e  gesets.    UNION
d180: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63  ..    SELECT C.c
d190: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62  id..    FROM   b
d1a0: 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65  ranch B, prefere
d1b0: 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61 6e 63  dparent P, branc
d1c0: 68 20 42 58 2c 20 63 73 69 74 65 6d 20 43 49 2c  h BX, csitem CI,
d1d0: 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20 20   changeset C..  
d1e0: 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 49    WHERE  B.bid I
d1f0: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d  N $theset     --
d200: 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 61   Restrict to bra
d210: 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73  nches of interes
d220: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e  t..    AND    B.
d230: 73 69 64 20 3d 20 50 2e 70 69 64 09 2d 2d 20 47  sid = P.pid.-- G
d240: 65 74 20 73 75 62 6f 72 64 69 6e 61 74 65 20 62  et subordinate b
d250: 72 61 6e 63 68 65 73 20 76 69 61 20 74 68 65 0a  ranches via the.
d260: 09 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e 73  .    AND    BX.s
d270: 69 64 20 3d 20 50 2e 73 69 64 09 2d 2d 20 70 72  id = P.sid.-- pr
d280: 65 66 65 72 65 64 20 70 61 72 65 6e 74 73 20 6f  efered parents o
d290: 66 20 74 68 65 69 72 20 73 79 6d 62 6f 6c 73 0a  f their symbols.
d2a0: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20              AND 
d2b0: 20 20 20 43 49 2e 69 69 64 20 3d 20 42 58 2e 62     CI.iid = BX.b
d2c0: 69 64 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63  id      -- Selec
d2d0: 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73  t all changesets
d2e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
d2f0: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63      C.cid = CI.c
d300: 69 64 09 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67  id.-- containing
d310: 20 74 68 65 20 73 75 62 6f 72 64 69 6e 61 74 65   the subordinate
d320: 20 62 72 61 6e 63 68 65 73 0a 20 20 20 20 20 20   branches.      
d330: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74        AND    C.t
d340: 79 70 65 20 3d 20 32 09 09 2d 2d 20 77 68 69 63  ype = 2..-- whic
d350: 68 20 61 72 65 20 62 72 61 6e 63 68 20 63 68 61  h are branch cha
d360: 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f  ngesets.    UNIO
d370: 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e  N..    SELECT C.
d380: 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  cid..    FROM   
d390: 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72  branch B, prefer
d3a0: 65 64 70 61 72 65 6e 74 20 50 2c 20 74 61 67 20  edparent P, tag 
d3b0: 54 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68  T, csitem CI, ch
d3c0: 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57  angeset C..    W
d3d0: 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24  HERE  B.bid IN $
d3e0: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65  theset     -- Re
d3f0: 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68  strict to branch
d400: 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  es of interest..
d410: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 73 69 64      AND    B.sid
d420: 20 3d 20 50 2e 70 69 64 09 2d 2d 20 47 65 74 20   = P.pid.-- Get 
d430: 73 75 62 6f 72 64 69 6e 61 74 65 20 74 61 67 73  subordinate tags
d440: 20 76 69 61 20 74 68 65 0a 09 20 20 20 20 41 4e   via the..    AN
d450: 44 20 20 20 20 54 2e 73 69 64 20 3d 20 50 2e 73  D    T.sid = P.s
d460: 69 64 09 2d 2d 20 70 72 65 66 65 72 65 64 20 70  id.-- prefered p
d470: 61 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20  arents of their 
d480: 73 79 6d 62 6f 6c 73 0a 20 20 20 20 20 20 20 20  symbols.        
d490: 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69      AND    CI.ii
d4a0: 64 20 3d 20 54 2e 74 69 64 20 20 20 20 20 20 20  d = T.tid       
d4b0: 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68  -- Select all ch
d4c0: 61 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20 20  angesets.       
d4d0: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69       AND    C.ci
d4e0: 64 20 3d 20 43 49 2e 63 69 64 09 2d 2d 20 63 6f  d = CI.cid.-- co
d4f0: 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 73 75 62  ntaining the sub
d500: 6f 72 64 69 6e 61 74 65 20 74 61 67 73 0a 20 20  ordinate tags.  
d510: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
d520: 20 43 2e 74 79 70 65 20 3d 20 31 09 09 2d 2d 20   C.type = 1..-- 
d530: 77 68 69 63 68 20 61 72 65 20 74 61 67 20 63 68  which are tag ch
d540: 61 6e 67 65 73 65 74 73 0a 09 7d 5d 5d 0a 09 72  angesets..}]]..r
d550: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
d560: 20 23 20 72 65 73 75 6c 74 20 3d 20 73 79 6d 62   # result = symb
d570: 6f 6c 20 6e 61 6d 65 0a 20 20 20 20 74 79 70 65  ol name.    type
d580: 6d 65 74 68 6f 64 20 63 73 5f 6c 6f 64 20 7b 62  method cs_lod {b
d590: 72 61 6e 63 68 65 73 7d 20 7b 0a 09 23 20 44 65  ranches} {..# De
d5a0: 74 65 72 6d 69 6e 65 73 20 74 68 65 20 6e 61 6d  termines the nam
d5b0: 65 20 6f 66 20 74 68 65 20 73 79 6d 62 6f 6c 20  e of the symbol 
d5c0: 77 68 69 63 68 20 69 73 20 74 68 65 20 6c 69 6e  which is the lin
d5d0: 65 20 6f 66 0a 09 23 20 64 65 76 65 6c 6f 70 6d  e of..# developm
d5e0: 65 6e 74 20 66 6f 72 20 74 68 65 20 62 72 61 6e  ent for the bran
d5f0: 63 68 65 73 20 69 6e 20 61 20 63 68 61 6e 67 65  ches in a change
d600: 73 65 74 2e 0a 0a 09 73 65 74 20 74 68 65 73 65  set....set these
d610: 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63  t ('[join $branc
d620: 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65  hes {','}]')..re
d630: 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20  turn [state run 
d640: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e  [subst -nocomman
d650: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65  ds -nobackslashe
d660: 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 0a  s {..    SELECT.
d670: 09 20 20 20 20 44 49 53 54 49 4e 43 54 20 4c 2e  .    DISTINCT L.
d680: 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20  name..    FROM  
d690: 20 62 72 61 6e 63 68 20 42 2c 20 73 79 6d 62 6f   branch B, symbo
d6a0: 6c 20 4c 0a 09 20 20 20 20 57 48 45 52 45 20 20  l L..    WHERE  
d6b0: 42 2e 62 69 64 20 69 6e 20 24 74 68 65 73 65 74  B.bid in $theset
d6c0: 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72          -- Restr
d6d0: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20  ict to branches 
d6e0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
d6f0: 20 41 4e 44 20 20 20 20 4c 2e 73 69 64 20 3d 20   AND    L.sid = 
d700: 42 2e 6c 6f 64 20 20 20 20 20 20 20 20 20 20 20  B.lod           
d710: 2d 2d 20 47 65 74 20 6c 6f 64 20 73 79 6d 62 6f  -- Get lod symbo
d720: 6c 20 6f 66 20 62 72 61 6e 63 68 0a 09 7d 5d 5d  l of branch..}]]
d730: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65  .    }..    type
d740: 6d 65 74 68 6f 64 20 6c 69 6d 69 74 73 20 7b 62  method limits {b
d750: 72 61 6e 63 68 65 73 7d 20 7b 0a 09 23 20 4e 6f  ranches} {..# No
d760: 74 65 73 2e 20 54 68 69 73 20 6d 65 74 68 6f 64  tes. This method
d770: 20 65 78 69 73 74 73 20 6f 6e 6c 79 20 66 6f 72   exists only for
d780: 20 62 72 61 6e 63 68 65 73 2e 20 49 74 20 69 73   branches. It is
d790: 20 6e 65 65 64 65 64 20 74 6f 0a 09 23 20 67 65   needed to..# ge
d7a0: 74 20 64 65 74 61 69 6c 65 64 20 69 6e 66 6f 72  t detailed infor
d7b0: 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20 61 20 62  mation about a b
d7c0: 61 63 6b 77 61 72 64 20 62 72 61 6e 63 68 2e 20  ackward branch. 
d7d0: 49 74 20 64 6f 65 73 0a 09 23 20 6e 6f 74 20 61  It does..# not a
d7e0: 70 70 6c 79 20 74 6f 20 74 61 67 73 2c 20 6e 6f  pply to tags, no
d7f0: 72 20 72 65 76 69 73 69 6f 6e 73 2e 20 54 68 65  r revisions. The
d800: 20 71 75 65 72 69 65 73 20 63 61 6e 20 61 6c 73   queries can als
d810: 6f 0a 09 23 20 72 65 73 74 72 69 63 74 20 74 68  o..# restrict th
d820: 65 6d 73 65 6c 76 65 73 20 74 6f 20 74 68 65 20  emselves to the 
d830: 72 65 76 69 73 69 6f 6e 20 73 75 63 65 73 73 6f  revision sucesso
d840: 72 73 2f 70 72 65 64 65 63 65 73 73 6f 72 73 0a  rs/predecessors.
d850: 09 23 20 6f 66 20 62 72 61 6e 63 68 65 73 2c 20  .# of branches, 
d860: 61 73 20 6f 6e 6c 79 20 74 68 65 79 20 68 61 76  as only they hav
d870: 65 20 6f 72 64 65 72 69 6e 67 20 64 61 74 61 20  e ordering data 
d880: 61 6e 64 20 74 68 75 73 20 63 61 6e 0a 09 23 20  and thus can..# 
d890: 63 61 75 73 65 20 74 68 65 20 62 61 63 6b 77 61  cause the backwa
d8a0: 72 64 6e 65 73 73 2e 0a 0a 09 73 65 74 20 74 68  rdness....set th
d8b0: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72  eset ('[join $br
d8c0: 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a  anches {','}]').
d8d0: 0a 09 73 65 74 20 6d 61 78 70 20 5b 73 74 61 74  ..set maxp [stat
d8e0: 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f  e run [subst -no
d8f0: 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b  commands -noback
d900: 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 2d  slashes {..    -
d910: 2d 20 6d 61 78 69 6d 61 6c 20 70 72 65 64 65 63  - maximal predec
d920: 65 73 73 6f 72 20 70 6f 73 69 74 69 6f 6e 20 70  essor position p
d930: 65 72 20 62 72 61 6e 63 68 0a 09 20 20 20 20 53  er branch..    S
d940: 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 4d 41 58  ELECT B.bid, MAX
d950: 20 28 43 4f 2e 70 6f 73 29 0a 09 20 20 20 20 46   (CO.pos)..    F
d960: 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20  ROM   branch B, 
d970: 72 65 76 69 73 69 6f 6e 20 52 2c 20 63 73 69 74  revision R, csit
d980: 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74  em CI, changeset
d990: 20 43 2c 20 63 73 6f 72 64 65 72 20 43 4f 0a 09   C, csorder CO..
d9a0: 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64      WHERE  B.bid
d9b0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
d9c0: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62  -- Restrict to b
d9d0: 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72  ranches of inter
d9e0: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  est..    AND    
d9f0: 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69 64 20 20  B.root = R.rid  
da00: 20 20 20 20 20 2d 2d 20 47 65 74 20 62 72 61 6e       -- Get bran
da10: 63 68 20 72 6f 6f 74 20 72 65 76 69 73 69 6f 6e  ch root revision
da20: 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 49  s..    AND    CI
da30: 2e 69 69 64 20 3d 20 52 2e 72 69 64 20 20 20 20  .iid = R.rid    
da40: 20 20 20 2d 2d 20 47 65 74 20 63 68 61 6e 67 65     -- Get change
da50: 73 65 74 73 20 63 6f 6e 74 61 69 6e 69 6e 67 20  sets containing 
da60: 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20  the..    AND    
da70: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 20 20  C.cid = CI.cid  
da80: 20 20 20 20 20 2d 2d 20 72 6f 6f 74 20 72 65 76       -- root rev
da90: 69 73 69 6f 6e 73 2c 20 77 68 69 63 68 20 61 72  isions, which ar
daa0: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 2e  e..    AND    C.
dab0: 74 79 70 65 20 3d 20 30 20 20 20 20 20 20 20 20  type = 0        
dac0: 20 20 20 2d 2d 20 72 65 76 69 73 69 6f 6e 20 63     -- revision c
dad0: 68 61 6e 67 65 73 65 74 73 0a 09 20 20 20 20 41  hangesets..    A
dae0: 4e 44 20 20 20 20 43 4f 2e 63 69 64 20 3d 20 43  ND    CO.cid = C
daf0: 2e 63 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65  .cid       -- Ge
db00: 74 20 74 68 65 69 72 20 74 6f 70 6f 6c 6f 67 69  t their topologi
db10: 63 61 6c 20 6f 72 64 65 72 69 6e 67 0a 09 20 20  cal ordering..  
db20: 20 20 47 52 4f 55 50 20 42 59 20 42 2e 62 69 64    GROUP BY B.bid
db30: 0a 09 7d 5d 5d 0a 0a 09 73 65 74 20 6d 69 6e 73  ..}]]...set mins
db40: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62   [state run [sub
db50: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d  st -nocommands -
db60: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a  nobackslashes {.
db70: 09 20 20 20 20 2d 2d 20 6d 69 6e 69 6d 61 6c 20  .    -- minimal 
db80: 73 75 63 63 65 73 73 6f 72 20 70 6f 73 69 74 69  successor positi
db90: 6f 6e 20 70 65 72 20 62 72 61 6e 63 68 0a 09 20  on per branch.. 
dba0: 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c     SELECT B.bid,
dbb0: 20 4d 49 4e 20 28 43 4f 2e 70 6f 73 29 0a 09 20   MIN (CO.pos).. 
dbc0: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68     FROM   branch
dbd0: 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c 20   B, revision R, 
dbe0: 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67  csitem CI, chang
dbf0: 65 73 65 74 20 43 2c 20 63 73 6f 72 64 65 72 20  eset C, csorder 
dc00: 43 4f 0a 09 20 20 20 20 57 48 45 52 45 20 20 42  CO..    WHERE  B
dc10: 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .bid IN $theset 
dc20: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
dc30: 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69  to branches of i
dc40: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
dc50: 20 20 20 20 42 2e 66 69 72 73 74 20 3d 20 52 2e      B.first = R.
dc60: 72 69 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20  rid      -- Get 
dc70: 74 68 65 20 66 69 72 73 74 20 72 65 76 69 73 69  the first revisi
dc80: 6f 6e 73 20 6f 6e 20 74 68 65 20 62 72 61 6e 63  ons on the branc
dc90: 68 65 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20  hes..    AND    
dca0: 43 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 20 20  CI.iid = R.rid  
dcb0: 20 20 20 20 20 2d 2d 20 47 65 74 20 63 68 61 6e       -- Get chan
dcc0: 67 65 73 65 74 73 20 63 6f 6e 74 61 69 6e 69 6e  gesets containin
dcd0: 67 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20  g the..    AND  
dce0: 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64    C.cid = CI.cid
dcf0: 09 2d 2d 20 66 69 72 73 74 20 72 65 76 69 73 69  .-- first revisi
dd00: 6f 6e 73 2c 20 77 68 69 63 68 20 61 72 65 0a 09  ons, which are..
dd10: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70      AND    C.typ
dd20: 65 20 3d 20 30 09 09 2d 2d 20 72 65 76 69 73 69  e = 0..-- revisi
dd30: 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 09 20  on changesets.. 
dd40: 20 20 20 41 4e 44 20 20 20 20 43 4f 2e 63 69 64     AND    CO.cid
dd50: 20 3d 20 43 2e 63 69 64 09 2d 2d 20 47 65 74 20   = C.cid.-- Get 
dd60: 74 68 65 69 72 20 74 6f 70 6f 6c 6f 67 69 63 61  their topologica
dd70: 6c 20 6f 72 64 65 72 69 6e 67 0a 09 20 20 20 20  l ordering..    
dd80: 47 52 4f 55 50 20 42 59 20 42 2e 62 69 64 0a 09  GROUP BY B.bid..
dd90: 7d 5d 5d 0a 0a 20 20 20 20 20 20 20 20 72 65 74  }]]..        ret
dda0: 75 72 6e 20 5b 6c 69 73 74 20 24 6d 61 78 70 20  urn [list $maxp 
ddb0: 24 6d 69 6e 73 5d 0a 20 20 20 20 7d 0a 0a 20 20  $mins].    }..  
ddc0: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
ddd0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
dde0: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
ddf0: 20 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a   Configuration..
de00: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69      pragma -hasi
de10: 6e 73 74 61 6e 63 65 73 20 20 20 6e 6f 20 3b 20  nstances   no ; 
de20: 23 20 73 69 6e 67 6c 65 74 6f 6e 0a 20 20 20 20  # singleton.    
de30: 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65 69  pragma -hastypei
de40: 6e 66 6f 20 20 20 20 6e 6f 20 3b 20 23 20 6e 6f  nfo    no ; # no
de50: 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20   introspection. 
de60: 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79     pragma -hasty
de70: 70 65 64 65 73 74 72 6f 79 20 6e 6f 20 3b 20 23  pedestroy no ; #
de80: 20 69 6d 6d 6f 72 74 61 6c 0a 7d 0a 0a 23 20 23   immortal.}..# #
de90: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
dea0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
deb0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
dec0: 23 23 23 23 23 23 23 23 23 23 0a 23 23 0a 0a 6e  ##########.##..n
ded0: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a  amespace eval ::
dee0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
def0: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74  rt::cvs::project
df00: 20 7b 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65   {.    namespace
df10: 20 65 78 70 6f 72 74 20 72 65 76 0a 20 20 20 20   export rev.    
df20: 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 72  namespace eval r
df30: 65 76 20 7b 0a 09 6e 61 6d 65 73 70 61 63 65 20  ev {..namespace 
df40: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73  import ::vc::fos
df50: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
df60: 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65 73 70 61  ::state..namespa
df70: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
df80: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
df90: 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09  cvs::integrity..
dfa0: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
dfb0: 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69   ::vc::tools::mi
dfc0: 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73 70 61 63 65  sc::*..namespace
dfd0: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f   import ::vc::to
dfe0: 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 0a 09 6e 61  ols::trouble..na
dff0: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
e000: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a  :vc::tools::log.
e010: 09 6c 6f 67 20 72 65 67 69 73 74 65 72 20 63 73  .log register cs
e020: 65 74 73 0a 0a 09 23 20 53 65 74 20 75 70 20 74  ets...# Set up t
e030: 68 65 20 68 65 6c 70 65 72 20 73 69 6e 67 6c 65  he helper single
e040: 74 6f 6e 73 0a 09 6e 61 6d 65 73 70 61 63 65 20  tons..namespace 
e050: 65 76 61 6c 20 72 65 76 20 7b 0a 09 20 20 20 20  eval rev {..    
e060: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
e070: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
e080: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74  mport::cvs::stat
e090: 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65  e..    namespace
e0a0: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f   import ::vc::fo
e0b0: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
e0c0: 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09 20 20  s::integrity..  
e0d0: 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f    namespace impo
e0e0: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  rt ::vc::tools::
e0f0: 6c 6f 67 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63  log..}..namespac
e100: 65 20 65 76 61 6c 20 73 79 6d 3a 3a 74 61 67 20  e eval sym::tag 
e110: 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65  {..    namespace
e120: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f   import ::vc::fo
e130: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
e140: 73 3a 3a 73 74 61 74 65 0a 09 20 20 20 20 6e 61  s::state..    na
e150: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
e160: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
e170: 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72  ort::cvs::integr
e180: 69 74 79 0a 09 20 20 20 20 6e 61 6d 65 73 70 61  ity..    namespa
e190: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
e1a0: 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 7d 0a 09 6e  tools::log..}..n
e1b0: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 73 79  amespace eval sy
e1c0: 6d 3a 3a 62 72 61 6e 63 68 20 7b 0a 09 20 20 20  m::branch {..   
e1d0: 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72   namespace impor
e1e0: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
e1f0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61  import::cvs::sta
e200: 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63  te..    namespac
e210: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66  e import ::vc::f
e220: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
e230: 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09 20  vs::integrity.. 
e240: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70     namespace imp
e250: 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a  ort ::vc::tools:
e260: 3a 6c 6f 67 0a 09 7d 0a 20 20 20 20 7d 0a 7d 0a  :log..}.    }.}.
e270: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23  .# # ## ### ####
e280: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
e290: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
e2a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23  ##############.#
e2b0: 23 20 52 65 61 64 79 0a 0a 70 61 63 6b 61 67 65  # Ready..package
e2c0: 20 70 72 6f 76 69 64 65 20 76 63 3a 3a 66 6f 73   provide vc::fos
e2d0: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
e2e0: 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20 31  ::project::rev 1
e2f0: 2e 30 0a 72 65 74 75 72 6e 0a                    .0.return.