Hex Artifact Content
Not logged in

Artifact 4afc72092adc06b4df9f8c73bc1ecd18c29d8cf8:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [530168ec30] - Split internals of breakinternaldependencies into more manageable pieces in prep for upcoming work on the handling of pseudo-dependencies. by aku on 2008-02-23 20:18:35.

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: 09 09 73 65 74 20 63 72 6f 73 73 65 73 20 7b 7d  ..set crosses {}
6870: 0a 0a 09 09 69 66 20 7b 24 73 74 61 72 74 20 3e  ....if {$start >
6880: 20 24 65 6e 64 7d 20 7b 0a 09 09 20 20 20 20 77   $end} {...    w
6890: 68 69 6c 65 20 7b 24 65 6e 64 20 3c 20 24 73 74  hile {$end < $st
68a0: 61 72 74 7d 20 7b 0a 09 09 09 6c 61 70 70 65 6e  art} {....lappen
68b0: 64 20 63 72 6f 73 73 65 73 20 24 65 6e 64 0a 09  d crosses $end..
68c0: 09 09 69 6e 63 72 20 63 72 6f 73 73 28 24 65 6e  ..incr cross($en
68d0: 64 29 0a 09 09 09 69 6e 63 72 20 65 6e 64 0a 09  d)....incr end..
68e0: 09 20 20 20 20 7d 0a 09 09 7d 20 65 6c 73 65 20  .    }...} else 
68f0: 7b 0a 09 09 20 20 20 20 77 68 69 6c 65 20 7b 24  {...    while {$
6900: 73 74 61 72 74 20 3c 20 24 65 6e 64 7d 20 7b 0a  start < $end} {.
6910: 09 09 09 6c 61 70 70 65 6e 64 20 63 72 6f 73 73  ...lappend cross
6920: 65 73 20 24 73 74 61 72 74 0a 09 09 09 69 6e 63  es $start....inc
6930: 72 20 63 72 6f 73 73 28 24 73 74 61 72 74 29 0a  r cross($start).
6940: 09 09 09 69 6e 63 72 20 73 74 61 72 74 0a 09 09  ...incr start...
6950: 20 20 20 20 7d 0a 09 09 7d 0a 09 09 73 65 74 20      }...}...set 
6960: 64 65 70 63 28 24 64 6b 65 79 29 20 24 63 72 6f  depc($dkey) $cro
6970: 73 73 65 73 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  sses..    }..}..
6980: 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63 73  .log write 14 cs
6990: 65 74 73 20 7b 49 42 53 3a 20 70 6f 73 2f 5b 61  ets {IBS: pos/[a
69a0: 72 72 61 79 20 73 69 7a 65 20 70 6f 73 5d 2c 20  rray size pos], 
69b0: 63 72 6f 73 73 2f 5b 61 72 72 61 79 20 73 69 7a  cross/[array siz
69c0: 65 20 63 72 6f 73 73 5d 2c 20 64 65 70 63 2f 5b  e cross], depc/[
69d0: 61 72 72 61 79 20 73 69 7a 65 20 64 65 70 63 5d  array size depc]
69e0: 20 28 66 6f 72 20 5b 6c 6c 65 6e 67 74 68 20 24   (for [llength $
69f0: 72 65 76 69 73 69 6f 6e 73 5d 29 7d 0a 09 6c 6f  revisions])}..lo
6a00: 67 20 77 72 69 74 65 20 31 34 20 63 73 65 74 73  g write 14 csets
6a10: 20 7b 49 42 53 3a 20 74 69 6d 65 73 74 61 6d 70   {IBS: timestamp
6a20: 73 2c 20 64 65 6c 74 61 73 7d 0a 0a 09 49 6e 69  s, deltas}...Ini
6a30: 74 69 61 6c 69 7a 65 44 65 6c 74 61 73 20 24 72  tializeDeltas $r
6a40: 65 76 69 73 69 6f 6e 73 0a 0a 09 6c 6f 67 20 77  evisions...log w
6a50: 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b 49  rite 14 csets {I
6a60: 42 53 3a 20 64 65 6c 74 61 20 5b 61 72 72 61 79  BS: delta [array
6a70: 20 73 69 7a 65 20 64 65 6c 74 61 5d 7d 0a 09 72   size delta]}..r
6a80: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
6a90: 20 70 72 6f 63 20 49 6e 69 74 69 61 6c 69 7a 65   proc Initialize
6aa0: 44 65 6c 74 61 73 20 7b 72 65 76 69 73 69 6f 6e  Deltas {revision
6ab0: 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 64 65  s} {..upvar 1 de
6ac0: 6c 74 61 20 64 65 6c 74 61 0a 0a 09 23 20 50 75  lta delta...# Pu
6ad0: 6c 6c 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70  ll the timestamp
6ae0: 73 20 66 6f 72 20 61 6c 6c 20 72 65 76 69 73 69  s for all revisi
6af0: 6f 6e 73 20 69 6e 20 74 68 65 20 63 68 61 6e 67  ons in the chang
6b00: 65 73 65 74 73 20 61 6e 64 0a 09 23 20 63 6f 6d  esets and..# com
6b10: 70 75 74 65 20 74 68 65 69 72 20 64 65 6c 74 61  pute their delta
6b20: 73 20 66 6f 72 20 75 73 65 20 62 79 20 74 68 65  s for use by the
6b30: 20 62 72 65 61 6b 20 66 69 6e 64 65 72 2e 0a 0a   break finder...
6b40: 09 61 72 72 61 79 20 73 65 74 20 64 65 6c 74 61  .array set delta
6b50: 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 20 73   {}..array set s
6b60: 74 61 6d 70 20 7b 7d 0a 0a 09 73 65 74 20 74 68  tamp {}...set th
6b70: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65  eset ('[join $re
6b80: 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29  visions {','}]')
6b90: 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 74  ..foreach {rid t
6ba0: 69 6d 65 7d 20 5b 73 74 61 74 65 20 72 75 6e 20  ime} [state run 
6bb0: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e  [subst -nocomman
6bc0: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65  ds -nobackslashe
6bd0: 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20  s {..    SELECT 
6be0: 52 2e 72 69 64 2c 20 52 2e 64 61 74 65 0a 09 20  R.rid, R.date.. 
6bf0: 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e     FROM revision
6c00: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e   R..    WHERE R.
6c10: 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 0a 09  rid IN $theset..
6c20: 7d 5d 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 73  }]] {..    set s
6c30: 74 61 6d 70 28 24 72 69 64 29 20 24 74 69 6d 65  tamp($rid) $time
6c40: 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  ..}...log write 
6c50: 31 34 20 63 73 65 74 73 20 7b 49 42 53 3a 20 73  14 csets {IBS: s
6c60: 74 61 6d 70 20 5b 61 72 72 61 79 20 73 69 7a 65  tamp [array size
6c70: 20 73 74 61 6d 70 5d 7d 0a 0a 09 73 65 74 20 6e   stamp]}...set n
6c80: 20 30 0a 09 66 6f 72 65 61 63 68 20 72 69 64 20   0..foreach rid 
6c90: 5b 6c 72 61 6e 67 65 20 24 72 65 76 69 73 69 6f  [lrange $revisio
6ca0: 6e 73 20 30 20 65 6e 64 2d 31 5d 20 72 6e 65 78  ns 0 end-1] rnex
6cb0: 74 20 5b 6c 72 61 6e 67 65 20 24 72 65 76 69 73  t [lrange $revis
6cc0: 69 6f 6e 73 20 31 20 65 6e 64 5d 20 7b 0a 09 20  ions 1 end] {.. 
6cd0: 20 20 20 73 65 74 20 64 65 6c 74 61 28 24 6e 29     set delta($n)
6ce0: 20 5b 65 78 70 72 20 7b 24 73 74 61 6d 70 28 24   [expr {$stamp($
6cf0: 72 6e 65 78 74 29 20 2d 20 24 73 74 61 6d 70 28  rnext) - $stamp(
6d00: 24 72 69 64 29 7d 5d 0a 09 20 20 20 20 69 6e 63  $rid)}]..    inc
6d10: 72 20 6e 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20  r n..}..return. 
6d20: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 46     }..    proc F
6d30: 69 6e 64 42 65 73 74 42 72 65 61 6b 20 7b 72 61  indBestBreak {ra
6d40: 6e 67 65 7d 20 7b 0a 09 75 70 76 61 72 20 31 20  nge} {..upvar 1 
6d50: 63 72 6f 73 73 20 63 72 6f 73 73 20 64 65 6c 74  cross cross delt
6d60: 61 20 64 65 6c 74 61 0a 0a 09 23 20 44 65 74 65  a delta...# Dete
6d70: 72 6d 69 6e 65 20 74 68 65 20 62 65 73 74 20 62  rmine the best b
6d80: 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 20 69 6e  reak location in
6d90: 20 74 68 65 20 67 69 76 65 6e 20 72 61 6e 67 65   the given range
6da0: 20 6f 66 0a 09 23 20 70 6f 73 69 74 69 6f 6e 73   of..# positions
6db0: 2e 20 46 69 72 73 74 20 77 65 20 6c 6f 6f 6b 20  . First we look 
6dc0: 66 6f 72 20 74 68 65 20 6c 6f 63 61 74 69 6f 6e  for the location
6dd0: 73 20 77 69 74 68 20 74 68 65 20 6d 61 78 69 6d  s with the maxim
6de0: 61 6c 0a 09 23 20 6e 75 6d 62 65 72 20 6f 66 20  al..# number of 
6df0: 63 72 6f 73 73 69 6e 67 73 2e 20 49 66 20 74 68  crossings. If th
6e00: 65 72 65 20 61 72 65 20 73 65 76 65 72 61 6c 20  ere are several 
6e10: 77 65 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 0a  we look for the.
6e20: 09 23 20 73 68 6f 72 74 65 73 74 20 74 69 6d 65  .# shortest time
6e30: 20 69 6e 74 65 72 76 61 6c 20 61 6d 6f 6e 67 20   interval among 
6e40: 74 68 65 6d 2e 20 49 66 20 77 65 20 73 74 69 6c  them. If we stil
6e50: 6c 20 68 61 76 65 20 6d 75 6c 74 69 70 6c 65 0a  l have multiple.
6e60: 09 23 20 70 6f 73 73 69 62 69 6c 69 74 69 65 73  .# possibilities
6e70: 20 61 66 74 65 72 20 74 68 61 74 20 77 65 20 73   after that we s
6e80: 65 6c 65 63 74 20 74 68 65 20 65 61 72 6c 69 65  elect the earlie
6e90: 73 74 20 6c 6f 63 61 74 69 6f 6e 0a 09 23 20 61  st location..# a
6ea0: 6d 6f 6e 67 20 74 68 65 73 65 2e 0a 0a 09 23 20  mong these....# 
6eb0: 4e 6f 74 65 3a 20 49 66 20 74 68 65 20 6d 61 78  Note: If the max
6ec0: 69 6d 61 6c 20 6e 75 6d 62 65 72 20 6f 66 20 63  imal number of c
6ed0: 72 6f 73 73 69 6e 67 73 20 69 73 20 30 20 74 68  rossings is 0 th
6ee0: 65 6e 20 74 68 65 20 72 61 6e 67 65 0a 09 23 20  en the range..# 
6ef0: 20 20 20 20 20 20 68 61 73 20 6e 6f 20 69 6e 74        has no int
6f00: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
6f10: 65 73 2c 20 61 6e 64 20 6e 6f 20 62 72 65 61 6b  es, and no break
6f20: 20 6c 6f 63 61 74 69 6f 6e 20 61 74 0a 09 23 20   location at..# 
6f30: 20 20 20 20 20 20 61 6c 6c 2e 20 54 68 69 73 20        all. This 
6f40: 70 6f 73 73 69 62 69 6c 69 74 79 20 69 73 20 73  possibility is s
6f50: 69 67 6e 61 6c 65 64 20 76 69 61 20 72 65 73 75  ignaled via resu
6f60: 6c 74 20 2d 31 2e 0a 0a 09 23 20 4e 6f 74 65 3a  lt -1....# Note:
6f70: 20 41 20 72 61 6e 67 65 20 6f 66 20 6c 65 6e 67   A range of leng
6f80: 74 68 20 31 20 6f 72 20 6c 65 73 73 20 63 61 6e  th 1 or less can
6f90: 6e 6f 74 20 68 61 76 65 20 69 6e 74 65 72 6e 61  not have interna
6fa0: 6c 0a 09 23 20 20 20 20 20 20 20 64 65 70 65 6e  l..#       depen
6fb0: 64 65 6e 63 69 65 73 2c 20 61 73 20 74 68 61 74  dencies, as that
6fc0: 20 6e 65 65 64 73 20 61 74 20 6c 65 61 73 74 20   needs at least 
6fd0: 74 77 6f 20 72 65 76 69 73 69 6f 6e 73 20 69 6e  two revisions in
6fe0: 0a 09 23 20 20 20 20 20 20 20 74 68 65 20 72 61  ..#       the ra
6ff0: 6e 67 65 2e 0a 0a 09 69 66 20 7b 5b 6c 6c 65 6e  nge....if {[llen
7000: 67 74 68 20 24 72 61 6e 67 65 5d 20 3c 20 32 7d  gth $range] < 2}
7010: 20 7b 20 72 65 74 75 72 6e 20 2d 31 20 7d 0a 0a   { return -1 }..
7020: 09 73 65 74 20 6d 61 78 20 2d 31 0a 09 73 65 74  .set max -1..set
7030: 20 62 65 73 74 20 7b 7d 0a 0a 09 66 6f 72 65 61   best {}...forea
7040: 63 68 20 6c 6f 63 61 74 69 6f 6e 20 24 72 61 6e  ch location $ran
7050: 67 65 20 7b 0a 09 20 20 20 20 73 65 74 20 63 72  ge {..    set cr
7060: 6f 73 73 69 6e 67 73 20 24 63 72 6f 73 73 28 24  ossings $cross($
7070: 6c 6f 63 61 74 69 6f 6e 29 0a 09 20 20 20 20 69  location)..    i
7080: 66 20 7b 24 63 72 6f 73 73 69 6e 67 73 20 3e 20  f {$crossings > 
7090: 24 6d 61 78 7d 20 7b 0a 09 09 73 65 74 20 6d 61  $max} {...set ma
70a0: 78 20 20 24 63 72 6f 73 73 69 6e 67 73 0a 09 09  x  $crossings...
70b0: 73 65 74 20 62 65 73 74 20 5b 6c 69 73 74 20 24  set best [list $
70c0: 6c 6f 63 61 74 69 6f 6e 5d 0a 09 09 63 6f 6e 74  location]...cont
70d0: 69 6e 75 65 0a 09 20 20 20 20 7d 20 65 6c 73 65  inue..    } else
70e0: 69 66 20 7b 24 63 72 6f 73 73 69 6e 67 73 20 3d  if {$crossings =
70f0: 3d 20 24 6d 61 78 7d 20 7b 0a 09 09 6c 61 70 70  = $max} {...lapp
7100: 65 6e 64 20 62 65 73 74 20 24 6c 6f 63 61 74 69  end best $locati
7110: 6f 6e 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69  on..    }..}...i
7120: 66 20 7b 24 6d 61 78 20 3d 3d 20 30 7d 20 20 20  f {$max == 0}   
7130: 20 20 20 20 20 20 20 20 20 7b 20 72 65 74 75 72           { retur
7140: 6e 20 2d 31 20 7d 0a 09 69 66 20 7b 5b 6c 6c 65  n -1 }..if {[lle
7150: 6e 67 74 68 20 24 62 65 73 74 5d 20 3d 3d 20 31  ngth $best] == 1
7160: 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69 6e 64  } { return [lind
7170: 65 78 20 24 62 65 73 74 20 30 5d 20 7d 0a 0a 09  ex $best 0] }...
7180: 73 65 74 20 6c 6f 63 61 74 69 6f 6e 73 20 24 62  set locations $b
7190: 65 73 74 0a 09 73 65 74 20 62 65 73 74 20 7b 7d  est..set best {}
71a0: 0a 09 73 65 74 20 6d 69 6e 20 2d 31 0a 0a 09 66  ..set min -1...f
71b0: 6f 72 65 61 63 68 20 6c 6f 63 61 74 69 6f 6e 20  oreach location 
71c0: 24 6c 6f 63 61 74 69 6f 6e 73 20 7b 0a 09 20 20  $locations {..  
71d0: 20 20 73 65 74 20 69 6e 74 65 72 76 61 6c 20 24    set interval $
71e0: 64 65 6c 74 61 28 24 6c 6f 63 61 74 69 6f 6e 29  delta($location)
71f0: 0a 09 20 20 20 20 69 66 20 7b 28 24 6d 69 6e 20  ..    if {($min 
7200: 3c 20 30 29 20 7c 7c 20 28 24 69 6e 74 65 72 76  < 0) || ($interv
7210: 61 6c 20 3c 20 24 6d 69 6e 29 7d 20 7b 0a 09 09  al < $min)} {...
7220: 73 65 74 20 6d 69 6e 20 20 24 69 6e 74 65 72 76  set min  $interv
7230: 61 6c 0a 09 09 73 65 74 20 62 65 73 74 20 5b 6c  al...set best [l
7240: 69 73 74 20 24 6c 6f 63 61 74 69 6f 6e 5d 0a 09  ist $location]..
7250: 20 20 20 20 7d 20 65 6c 73 65 69 66 20 7b 24 69      } elseif {$i
7260: 6e 74 65 72 76 61 6c 20 3d 3d 20 24 6d 69 6e 7d  nterval == $min}
7270: 20 7b 0a 09 09 6c 61 70 70 65 6e 64 20 62 65 73   {...lappend bes
7280: 74 20 24 6c 6f 63 61 74 69 6f 6e 0a 09 20 20 20  t $location..   
7290: 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b 5b 6c 6c 65   }..}...if {[lle
72a0: 6e 67 74 68 20 24 62 65 73 74 5d 20 3d 3d 20 31  ngth $best] == 1
72b0: 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69 6e 64  } { return [lind
72c0: 65 78 20 24 62 65 73 74 20 30 5d 20 7d 0a 0a 09  ex $best 0] }...
72d0: 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78 20 5b  return [lindex [
72e0: 6c 73 6f 72 74 20 2d 69 6e 74 65 67 65 72 20 2d  lsort -integer -
72f0: 69 6e 63 72 65 61 73 69 6e 67 20 24 62 65 73 74  increasing $best
7300: 5d 20 30 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  ] 0].    }..    
7310: 70 72 6f 63 20 43 75 74 41 74 20 7b 6c 6f 63 61  proc CutAt {loca
7320: 74 69 6f 6e 7d 20 7b 0a 09 75 70 76 61 72 20 31  tion} {..upvar 1
7330: 20 63 72 6f 73 73 20 63 72 6f 73 73 20 64 65 70   cross cross dep
7340: 63 20 64 65 70 63 0a 0a 09 23 20 49 74 20 77 61  c depc...# It wa
7350: 73 20 64 65 63 69 64 65 64 20 74 6f 20 73 70 6c  s decided to spl
7360: 69 74 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  it the changeset
7370: 20 61 74 20 74 68 65 20 67 69 76 65 6e 0a 09 23   at the given..#
7380: 20 6c 6f 63 61 74 69 6f 6e 2e 20 54 68 69 73 20   location. This 
7390: 63 75 74 73 20 61 20 6e 75 6d 62 65 72 20 6f 66  cuts a number of
73a0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 20 48   dependencies. H
73b0: 65 72 65 20 77 65 20 75 70 64 61 74 65 0a 09 23  ere we update..#
73c0: 20 74 68 65 20 63 72 6f 73 73 20 69 6e 66 6f 72   the cross infor
73d0: 6d 61 74 69 6f 6e 20 73 6f 20 74 68 61 74 20 74  mation so that t
73e0: 68 65 20 62 72 65 61 6b 20 66 69 6e 64 65 72 20  he break finder 
73f0: 68 61 73 20 61 63 63 75 72 61 74 65 0a 09 23 20  has accurate..# 
7400: 64 61 74 61 20 77 68 65 6e 20 77 65 20 6c 6f 6f  data when we loo
7410: 6b 20 61 74 20 74 68 65 20 67 65 6e 65 72 61 74  k at the generat
7420: 65 64 20 66 72 61 67 6d 65 6e 74 73 2e 0a 0a 09  ed fragments....
7430: 73 65 74 20 73 69 78 20 5b 6c 6f 67 20 76 69 73  set six [log vis
7440: 69 62 6c 65 3f 20 36 5d 0a 0a 09 66 6f 72 65 61  ible? 6]...forea
7450: 63 68 20 7b 64 65 70 20 72 61 6e 67 65 7d 20 5b  ch {dep range} [
7460: 61 72 72 61 79 20 67 65 74 20 64 65 70 63 5d 20  array get depc] 
7470: 7b 0a 09 20 20 20 20 23 20 43 68 65 63 6b 20 61  {..    # Check a
7480: 6c 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  ll dependencies 
7490: 73 74 69 6c 6c 20 6b 6e 6f 77 6e 2c 20 74 61 6b  still known, tak
74a0: 65 20 74 68 65 69 72 20 72 61 6e 67 65 20 61 6e  e their range an
74b0: 64 0a 09 20 20 20 20 23 20 73 65 65 20 69 66 20  d..    # see if 
74c0: 74 68 65 20 62 72 65 61 6b 20 6c 6f 63 61 74 69  the break locati
74d0: 6f 6e 20 66 61 6c 6c 73 20 77 69 74 68 69 6e 2e  on falls within.
74e0: 0a 0a 09 20 20 20 20 42 6f 72 64 65 72 20 24 72  ...    Border $r
74f0: 61 6e 67 65 20 73 20 65 0a 09 20 20 20 20 69 66  ange s e..    if
7500: 20 7b 24 6c 6f 63 61 74 69 6f 6e 20 3c 20 24 73   {$location < $s
7510: 7d 20 63 6f 6e 74 69 6e 75 65 20 3b 20 23 20 62  } continue ; # b
7520: 72 65 61 6b 20 62 65 66 6f 72 65 20 72 61 6e 67  reak before rang
7530: 65 2c 20 69 67 6e 6f 72 65 0a 09 20 20 20 20 69  e, ignore..    i
7540: 66 20 7b 24 6c 6f 63 61 74 69 6f 6e 20 3e 20 24  f {$location > $
7550: 65 7d 20 63 6f 6e 74 69 6e 75 65 20 3b 20 23 20  e} continue ; # 
7560: 62 72 65 61 6b 20 61 66 74 65 72 20 72 61 6e 67  break after rang
7570: 65 2c 20 69 67 6e 6f 72 65 2e 0a 0a 09 20 20 20  e, ignore....   
7580: 20 23 20 54 68 69 73 20 64 65 70 65 6e 64 65 6e   # This dependen
7590: 63 79 20 63 72 6f 73 73 65 73 20 74 68 65 20 62  cy crosses the b
75a0: 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 2e 20 57  reak location. W
75b0: 65 20 72 65 6d 6f 76 65 20 69 74 0a 09 20 20 20  e remove it..   
75c0: 20 23 20 66 72 6f 6d 20 74 68 65 20 63 72 6f 73   # from the cros
75d0: 73 69 6e 67 73 20 63 6f 75 6e 74 65 72 73 2c 20  sings counters, 
75e0: 61 6e 64 20 74 68 65 6e 20 61 6c 73 6f 20 66 72  and then also fr
75f0: 6f 6d 20 74 68 65 20 73 65 74 0a 09 20 20 20 20  om the set..    
7600: 23 20 6f 66 20 6b 6e 6f 77 6e 20 64 65 70 65 6e  # of known depen
7610: 64 65 6e 63 69 65 73 2c 20 61 73 20 77 65 20 61  dencies, as we a
7620: 72 65 20 64 6f 6e 65 20 77 69 74 68 20 69 74 2e  re done with it.
7630: 0a 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20 6c  ...    foreach l
7640: 6f 63 20 24 64 65 70 63 28 24 64 65 70 29 20 7b  oc $depc($dep) {
7650: 20 69 6e 63 72 20 63 72 6f 73 73 28 24 6c 6f 63   incr cross($loc
7660: 29 20 2d 31 20 7d 0a 09 20 20 20 20 75 6e 73 65  ) -1 }..    unse
7670: 74 20 64 65 70 63 28 24 64 65 70 29 0a 0a 09 20  t depc($dep)... 
7680: 20 20 20 69 66 20 7b 21 24 73 69 78 7d 20 63 6f     if {!$six} co
7690: 6e 74 69 6e 75 65 0a 0a 09 20 20 20 20 73 74 72  ntinue...    str
76a0: 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e  uct::list assign
76b0: 20 24 64 65 70 20 70 61 72 65 6e 74 20 63 68 69   $dep parent chi
76c0: 6c 64 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74  ld..    log writ
76d0: 65 20 35 20 63 73 65 74 73 20 22 42 72 6f 6b 65  e 5 csets "Broke
76e0: 20 64 65 70 65 6e 64 65 6e 63 79 20 5b 50 44 20   dependency [PD 
76f0: 24 70 61 72 65 6e 74 5d 20 2d 2d 3e 20 5b 50 44  $parent] --> [PD
7700: 20 24 63 68 69 6c 64 5d 22 0a 09 7d 0a 0a 09 72   $child]"..}...r
7710: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
7720: 20 23 20 50 72 69 6e 74 20 69 64 65 6e 74 69 66   # Print identif
7730: 79 69 6e 67 20 64 61 74 61 20 66 6f 72 20 61 20  ying data for a 
7740: 72 65 76 69 73 69 6f 6e 20 28 70 72 6f 6a 65 63  revision (projec
7750: 74 2c 20 66 69 6c 65 2c 20 64 6f 74 74 65 64 20  t, file, dotted 
7760: 72 65 76 0a 20 20 20 20 23 20 6e 75 6d 62 65 72  rev.    # number
7770: 29 2c 20 66 6f 72 20 68 69 67 68 20 76 65 72 62  ), for high verb
7780: 6f 73 69 74 79 20 6c 6f 67 20 6f 75 74 70 75 74  osity log output
7790: 2e 0a 20 20 20 20 23 20 54 4f 44 4f 3a 20 52 65  ..    # TODO: Re
77a0: 70 6c 61 63 65 20 77 69 74 68 20 63 61 6c 6c 20  place with call 
77b0: 74 6f 20 69 74 65 6d 73 74 72 20 28 6c 69 73 74  to itemstr (list
77c0: 20 72 65 76 20 24 69 64 29 0a 0a 20 20 20 20 70   rev $id)..    p
77d0: 72 6f 63 20 50 44 20 7b 69 64 7d 20 7b 0a 09 66  roc PD {id} {..f
77e0: 6f 72 65 61 63 68 20 7b 70 20 66 20 72 7d 20 5b  oreach {p f r} [
77f0: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 45  state run {...SE
7800: 4c 45 43 54 20 50 2e 6e 61 6d 65 20 2c 20 46 2e  LECT P.name , F.
7810: 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52  name, R.rev...FR
7820: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66  OM revision R, f
7830: 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50  ile F, project P
7840: 0a 09 09 57 48 45 52 45 20 52 2e 72 69 64 20 3d  ...WHERE R.rid =
7850: 20 24 69 64 20 20 20 20 2d 2d 20 46 69 6e 64 20   $id    -- Find 
7860: 73 70 65 63 69 66 69 65 64 20 66 69 6c 65 20 72  specified file r
7870: 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20  evision...AND   
7880: 46 2e 66 69 64 20 3d 20 52 2e 66 69 64 20 20 2d  F.fid = R.fid  -
7890: 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 74 68  - Get file of th
78a0: 65 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44  e revision...AND
78b0: 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 69 64     P.pid = F.pid
78c0: 20 20 2d 2d 20 47 65 74 20 70 72 6f 6a 65 63 74    -- Get project
78d0: 20 6f 66 20 74 68 65 20 66 69 6c 65 2e 0a 09 7d   of the file...}
78e0: 5d 20 62 72 65 61 6b 0a 09 72 65 74 75 72 6e 20  ] break..return 
78f0: 22 27 24 70 20 3a 20 24 66 2f 24 72 27 22 0a 20  "'$p : $f/$r'". 
7900: 20 20 20 7d 0a 0a 20 20 20 20 23 20 50 72 69 6e     }..    # Prin
7910: 74 69 6e 67 20 6f 6e 65 20 6f 72 20 6d 6f 72 65  ting one or more
7920: 20 72 61 6e 67 65 73 2c 20 66 6f 72 6d 61 74 74   ranges, formatt
7930: 65 64 2c 20 61 6e 64 20 6f 6e 6c 79 20 74 68 65  ed, and only the
7940: 69 72 20 62 6f 72 64 65 72 20 74 6f 0a 20 20 20  ir border to.   
7950: 20 23 20 6b 65 65 70 20 74 68 65 20 73 74 72 69   # keep the stri
7960: 6e 67 73 20 73 68 6f 72 74 2e 0a 0a 20 20 20 20  ngs short...    
7970: 70 72 6f 63 20 50 52 73 20 7b 72 61 6e 67 65 73  proc PRs {ranges
7980: 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 73 74 72  } {..return [str
7990: 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 72  uct::list map $r
79a0: 61 6e 67 65 73 20 5b 6d 79 70 72 6f 63 20 50 52  anges [myproc PR
79b0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  ]].    }..    pr
79c0: 6f 63 20 50 52 20 7b 72 61 6e 67 65 7d 20 7b 0a  oc PR {range} {.
79d0: 09 42 6f 72 64 65 72 20 24 72 61 6e 67 65 20 73  .Border $range s
79e0: 20 65 0a 09 72 65 74 75 72 6e 20 3c 24 7b 73 7d   e..return <${s}
79f0: 2e 2e 2e 24 7b 65 7d 3e 0a 20 20 20 20 7d 0a 0a  ...${e}>.    }..
7a00: 20 20 20 20 70 72 6f 63 20 42 6f 72 64 65 72 20      proc Border 
7a10: 7b 72 61 6e 67 65 20 73 76 20 65 76 7d 20 7b 0a  {range sv ev} {.
7a20: 09 75 70 76 61 72 20 31 20 24 73 76 20 73 20 24  .upvar 1 $sv s $
7a30: 65 76 20 65 0a 09 73 65 74 20 73 20 5b 6c 69 6e  ev e..set s [lin
7a40: 64 65 78 20 24 72 61 6e 67 65 20 30 5d 0a 09 73  dex $range 0]..s
7a50: 65 74 20 65 20 5b 6c 69 6e 64 65 78 20 24 72 61  et e [lindex $ra
7a60: 6e 67 65 20 65 6e 64 5d 0a 09 72 65 74 75 72 6e  nge end]..return
7a70: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20  .    }..    # # 
7a80: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
7a90: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
7aa0: 23 23 23 0a 0a 20 20 20 20 70 72 6f 63 20 55 6e  ###..    proc Un
7ab0: 6d 61 70 49 74 65 6d 73 20 7b 74 68 65 74 79 70  mapItems {thetyp
7ac0: 65 20 74 68 65 69 74 65 6d 73 7d 20 7b 0a 09 23  e theitems} {..#
7ad0: 20 28 2a 29 20 57 65 20 63 6c 65 61 72 20 6f 75   (*) We clear ou
7ae0: 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65 64  t the associated
7af0: 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d 79 69   part of the myi
7b00: 74 65 6d 6d 61 70 0a 09 23 20 69 6e 2d 6d 65 6d  temmap..# in-mem
7b10: 6f 72 79 20 69 6e 64 65 78 20 69 6e 20 70 72 65  ory index in pre
7b20: 70 61 72 61 74 69 6f 6e 20 66 6f 72 20 6e 65 77  paration for new
7b30: 20 64 61 74 61 2c 20 6f 72 20 61 73 20 70 61 72   data, or as par
7b40: 74 20 6f 66 0a 09 23 20 6f 62 6a 65 63 74 20 64  t of..# object d
7b50: 65 73 74 72 75 63 74 69 6f 6e 2e 20 41 20 73 69  estruction. A si
7b60: 6d 70 6c 65 20 75 6e 73 65 74 20 69 73 20 65 6e  mple unset is en
7b70: 6f 75 67 68 2c 20 77 65 20 68 61 76 65 20 6e 6f  ough, we have no
7b80: 0a 09 23 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67  ..# symbol chang
7b90: 65 73 65 74 73 20 61 74 20 74 68 69 73 20 74 69  esets at this ti
7ba0: 6d 65 2c 20 61 6e 64 20 74 68 75 73 20 6e 65 76  me, and thus nev
7bb0: 65 72 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65  er more than one
7bc0: 0a 09 23 20 72 65 66 65 72 65 6e 63 65 20 69 6e  ..# reference in
7bd0: 20 74 68 65 20 6c 69 73 74 2e 0a 0a 09 75 70 76   the list....upv
7be0: 61 72 20 31 20 6d 79 69 74 65 6d 6d 61 70 20 6d  ar 1 myitemmap m
7bf0: 79 69 74 65 6d 6d 61 70 20 73 65 6c 66 20 73 65  yitemmap self se
7c00: 6c 66 0a 09 66 6f 72 65 61 63 68 20 69 69 64 20  lf..foreach iid 
7c10: 24 74 68 65 69 74 65 6d 73 20 7b 0a 09 20 20 20  $theitems {..   
7c20: 20 73 65 74 20 6b 65 79 20 5b 6c 69 73 74 20 24   set key [list $
7c30: 74 68 65 74 79 70 65 20 24 69 69 64 5d 0a 09 20  thetype $iid].. 
7c40: 20 20 20 75 6e 73 65 74 20 6d 79 69 74 65 6d 6d     unset myitemm
7c50: 61 70 28 24 6b 65 79 29 0a 09 20 20 20 20 6c 6f  ap($key)..    lo
7c60: 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20  g write 8 csets 
7c70: 7b 4d 41 50 2d 20 69 74 65 6d 20 3c 24 6b 65 79  {MAP- item <$key
7c80: 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c 66  > $self = [$self
7c90: 20 73 74 72 5d 7d 0a 09 7d 0a 09 72 65 74 75 72   str]}..}..retur
7ca0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f  n.    }..    pro
7cb0: 63 20 4d 61 70 49 74 65 6d 73 20 7b 74 68 65 74  c MapItems {thet
7cc0: 79 70 65 20 74 68 65 69 74 65 6d 73 7d 20 7b 0a  ype theitems} {.
7cd0: 09 75 70 76 61 72 20 31 20 6d 79 69 74 65 6d 6d  .upvar 1 myitemm
7ce0: 61 70 20 6d 79 69 74 65 6d 6d 61 70 20 73 65 6c  ap myitemmap sel
7cf0: 66 20 73 65 6c 66 0a 0a 09 66 6f 72 65 61 63 68  f self...foreach
7d00: 20 69 69 64 20 24 74 68 65 69 74 65 6d 73 20 7b   iid $theitems {
7d10: 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c  ..    set key [l
7d20: 69 73 74 20 24 74 68 65 74 79 70 65 20 24 69 69  ist $thetype $ii
7d30: 64 5d 0a 09 20 20 20 20 73 65 74 20 6d 79 69 74  d]..    set myit
7d40: 65 6d 6d 61 70 28 24 6b 65 79 29 20 24 73 65 6c  emmap($key) $sel
7d50: 66 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65  f..    log write
7d60: 20 38 20 63 73 65 74 73 20 7b 4d 41 50 2b 20 69   8 csets {MAP+ i
7d70: 74 65 6d 20 3c 24 6b 65 79 3e 20 24 73 65 6c 66  tem <$key> $self
7d80: 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d 7d 0a   = [$self str]}.
7d90: 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  .}..return.    }
7da0: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
7db0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
7dc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a 20  #############.. 
7dd0: 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 20     typevariable 
7de0: 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20 20 20  mychangesets    
7df0: 20 20 20 20 20 7b 7d 20 3b 20 23 20 4c 69 73 74       {} ; # List
7e00: 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 0a 09 09   of all known...
7e10: 09 09 09 20 20 20 23 20 63 68 61 6e 67 65 73 65  ...   # changese
7e20: 74 73 2e 0a 0a 20 20 20 20 23 20 4c 69 73 74 20  ts...    # List 
7e30: 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 20 63 68 61  of all known cha
7e40: 6e 67 65 73 65 74 73 20 6f 66 20 61 20 74 79 70  ngesets of a typ
7e50: 65 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 61  e..    typevaria
7e60: 62 6c 65 20 6d 79 74 63 68 61 6e 67 65 73 65 74  ble mytchangeset
7e70: 73 20 2d 61 72 72 61 79 20 7b 0a 09 73 79 6d 3a  s -array {..sym:
7e80: 3a 62 72 61 6e 63 68 20 7b 7d 0a 09 73 79 6d 3a  :branch {}..sym:
7e90: 3a 74 61 67 20 20 20 20 7b 7d 0a 09 72 65 76 20  :tag    {}..rev 
7ea0: 20 20 20 20 20 20 20 20 7b 7d 0a 20 20 20 20 7d          {}.    }
7eb0: 0a 09 09 09 09 09 0a 20 20 20 20 74 79 70 65 76  .......    typev
7ec0: 61 72 69 61 62 6c 65 20 6d 79 69 74 65 6d 6d 61  ariable myitemma
7ed0: 70 20 20 20 20 20 2d 61 72 72 61 79 20 7b 7d 20  p     -array {} 
7ee0: 3b 20 23 20 4d 61 70 20 66 72 6f 6d 20 69 74 65  ; # Map from ite
7ef0: 6d 73 20 28 74 61 67 67 65 64 29 0a 09 09 09 09  ms (tagged).....
7f00: 09 20 20 20 23 20 74 6f 20 74 68 65 20 6c 69 73  .   # to the lis
7f10: 74 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73 0a  t of changesets.
7f20: 09 09 09 09 09 20 20 20 23 20 63 6f 6e 74 61 69  .....   # contai
7f30: 6e 69 6e 67 20 69 74 2e 20 45 61 63 68 20 69 74  ning it. Each it
7f40: 65 6d 0a 09 09 09 09 09 20 20 20 23 20 63 61 6e  em......   # can
7f50: 20 62 65 20 75 73 65 64 20 62 79 20 6f 6e 6c 79   be used by only
7f60: 20 6f 6e 65 0a 09 09 09 09 09 20 20 20 23 20 63   one......   # c
7f70: 68 61 6e 67 65 73 65 74 2e 0a 20 20 20 20 74 79  hangeset..    ty
7f80: 70 65 76 61 72 69 61 62 6c 65 20 6d 79 69 64 6d  pevariable myidm
7f90: 61 70 20 20 20 2d 61 72 72 61 79 20 7b 7d 20 3b  ap   -array {} ;
7fa0: 20 23 20 4d 61 70 20 66 72 6f 6d 20 63 68 61 6e   # Map from chan
7fb0: 67 65 73 65 74 20 69 64 20 74 6f 0a 09 09 09 09  geset id to.....
7fc0: 20 20 20 20 20 20 20 23 20 63 68 61 6e 67 65 73         # changes
7fd0: 65 74 2e 0a 0a 20 20 20 20 74 79 70 65 6d 65 74  et...    typemet
7fe0: 68 6f 64 20 61 6c 6c 20 20 20 20 7b 7d 20 20 20  hod all    {}   
7ff0: 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 63 68 61   { return $mycha
8000: 6e 67 65 73 65 74 73 20 7d 0a 20 20 20 20 74 79  ngesets }.    ty
8010: 70 65 6d 65 74 68 6f 64 20 6f 66 20 20 20 20 20  pemethod of     
8020: 7b 63 69 64 7d 20 7b 20 72 65 74 75 72 6e 20 24  {cid} { return $
8030: 6d 79 69 64 6d 61 70 28 24 63 69 64 29 20 7d 0a  myidmap($cid) }.
8040: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6f      typemethod o
8050: 66 69 74 65 6d 20 7b 69 69 64 7d 20 7b 20 72 65  fitem {iid} { re
8060: 74 75 72 6e 20 24 6d 79 69 74 65 6d 6d 61 70 28  turn $myitemmap(
8070: 24 69 69 64 29 20 7d 0a 0a 20 20 20 20 74 79 70  $iid) }..    typ
8080: 65 6d 65 74 68 6f 64 20 72 65 76 20 20 20 20 7b  emethod rev    {
8090: 7d 20 20 20 20 7b 20 72 65 74 75 72 6e 20 24 6d  }    { return $m
80a0: 79 74 63 68 61 6e 67 65 73 65 74 73 28 72 65 76  ytchangesets(rev
80b0: 29 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68  ) }.    typemeth
80c0: 6f 64 20 73 79 6d 20 20 20 20 7b 7d 20 20 20 20  od sym    {}    
80d0: 7b 20 72 65 74 75 72 6e 20 5b 63 6f 6e 63 61 74  { return [concat
80e0: 20 5c 0a 09 09 09 09 09 20 20 24 7b 6d 79 74 63   \......  ${mytc
80f0: 68 61 6e 67 65 73 65 74 73 28 73 79 6d 3a 3a 62  hangesets(sym::b
8100: 72 61 6e 63 68 29 7d 20 5c 0a 09 09 09 09 09 20  ranch)} \...... 
8110: 20 24 7b 6d 79 74 63 68 61 6e 67 65 73 65 74 73   ${mytchangesets
8120: 28 73 79 6d 3a 3a 74 61 67 29 7d 5d 20 7d 0a 0a  (sym::tag)}] }..
8130: 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23      # # ## ### #
8140: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
8150: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20  ###########.    
8160: 23 23 20 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e  ## Configuration
8170: 0a 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61  ..    pragma -ha
8180: 73 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20  stypeinfo    no 
8190: 20 3b 20 23 20 6e 6f 20 74 79 70 65 20 69 6e 74   ; # no type int
81a0: 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70  rospection.    p
81b0: 72 61 67 6d 61 20 2d 68 61 73 69 6e 66 6f 20 20  ragma -hasinfo  
81c0: 20 20 20 20 20 20 6e 6f 20 20 3b 20 23 20 6e 6f        no  ; # no
81d0: 20 6f 62 6a 65 63 74 20 69 6e 74 72 6f 73 70 65   object introspe
81e0: 63 74 69 6f 6e 0a 0a 20 20 20 20 23 20 23 20 23  ction..    # # #
81f0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
8200: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
8210: 23 23 0a 7d 0a 0a 23 23 0a 23 23 20 4e 4f 54 45  ##.}..##.## NOTE
8220: 3a 20 54 68 65 20 73 75 63 63 65 73 73 6f 72 20  : The successor 
8230: 61 6e 64 20 70 72 65 64 65 63 65 73 73 6f 72 20  and predecessor 
8240: 6d 65 74 68 6f 64 73 20 64 65 66 69 6e 65 64 20  methods defined 
8250: 62 79 20 74 68 65 20 63 6c 61 73 73 65 73 0a 23  by the classes.#
8260: 23 20 20 20 20 20 20 20 62 65 6c 6f 77 20 61 72  #       below ar
8270: 65 20 2d 2d 20 62 6f 74 74 6c 65 20 6e 65 63 6b  e -- bottle neck
8280: 73 20 2d 2d 2e 20 4c 6f 6f 6b 20 66 6f 72 20 77  s --. Look for w
8290: 61 79 73 20 74 6f 20 6d 61 6b 65 20 74 68 65 20  ays to make the 
82a0: 53 51 4c 0a 23 23 20 20 20 20 20 20 20 66 61 73  SQL.##       fas
82b0: 74 65 72 2e 0a 23 23 0a 0a 23 20 23 20 23 23 20  ter..##..# # ## 
82c0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
82d0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
82e0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23   ###############
82f0: 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65 72  ######.## Helper
8300: 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d 6d   singleton. Comm
8310: 61 6e 64 73 20 66 6f 72 20 72 65 76 69 73 69 6f  ands for revisio
8320: 6e 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 73  n changesets...s
8330: 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a  nit::type ::vc::
8340: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
8350: 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65  cvs::project::re
8360: 76 3a 3a 72 65 76 20 7b 0a 20 20 20 20 74 79 70  v::rev {.    typ
8370: 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 69  emethod byrevisi
8380: 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31  on {} { return 1
8390: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f   }.    typemetho
83a0: 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20  d bysymbol   {} 
83b0: 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20  { return 0 }.   
83c0: 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74 61   typemethod ista
83d0: 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 75  g      {} { retu
83e0: 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d  rn 0 }.    typem
83f0: 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20 20  ethod isbranch  
8400: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d   {} { return 0 }
8410: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
8420: 20 73 74 72 20 7b 72 65 76 69 73 69 6f 6e 7d 20   str {revision} 
8430: 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  {..struct::list 
8440: 61 73 73 69 67 6e 20 5b 73 74 61 74 65 20 72 75  assign [state ru
8450: 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20  n {..    SELECT 
8460: 52 2e 72 65 76 2c 20 46 2e 6e 61 6d 65 2c 20 50  R.rev, F.name, P
8470: 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20  .name..    FROM 
8480: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69    revision R, fi
8490: 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a  le F, project P.
84a0: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
84b0: 64 20 3d 20 24 72 65 76 69 73 69 6f 6e 20 2d 2d  d = $revision --
84c0: 20 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 20   Find specified 
84d0: 66 69 6c 65 20 72 65 76 69 73 69 6f 6e 0a 09 20  file revision.. 
84e0: 20 20 20 41 4e 44 20 20 20 20 46 2e 66 69 64 20     AND    F.fid 
84f0: 3d 20 52 2e 66 69 64 20 20 20 20 20 2d 2d 20 47  = R.fid     -- G
8500: 65 74 20 66 69 6c 65 20 6f 66 20 74 68 65 20 72  et file of the r
8510: 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 41 4e 44  evision..    AND
8520: 20 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 69      P.pid = F.pi
8530: 64 20 20 20 20 20 2d 2d 20 47 65 74 20 70 72 6f  d     -- Get pro
8540: 6a 65 63 74 20 6f 66 20 74 68 65 20 66 69 6c 65  ject of the file
8550: 2e 0a 09 7d 5d 20 72 65 76 6e 72 20 66 6e 61 6d  ...}] revnr fnam
8560: 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20  e pname..return 
8570: 22 24 70 6e 61 6d 65 2f 24 7b 72 65 76 6e 72 7d  "$pname/${revnr}
8580: 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20 20 7d 0a  ::$fname".    }.
8590: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20  .    # result = 
85a0: 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20 6d  list (mintime, m
85b0: 61 78 74 69 6d 65 29 0a 20 20 20 20 74 79 70 65  axtime).    type
85c0: 6d 65 74 68 6f 64 20 74 69 6d 65 72 61 6e 67 65  method timerange
85d0: 20 7b 69 74 65 6d 73 7d 20 7b 0a 09 73 65 74 20   {items} {..set 
85e0: 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24  theset ('[join $
85f0: 69 74 65 6d 73 20 7b 27 2c 27 7d 5d 27 29 0a 09  items {','}]')..
8600: 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75  return [state ru
8610: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
8620: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
8630: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  hes {..    SELEC
8640: 54 20 4d 49 4e 28 52 2e 64 61 74 65 29 2c 20 4d  T MIN(R.date), M
8650: 41 58 28 52 2e 64 61 74 65 29 0a 09 20 20 20 20  AX(R.date)..    
8660: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 0a  FROM revision R.
8670: 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64  .    WHERE R.rid
8680: 20 49 4e 20 24 74 68 65 73 65 74 20 2d 2d 20 52   IN $theset -- R
8690: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
86a0: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
86b0: 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20  ..}]].    }..   
86c0: 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 63   # var(dv) = dic
86d0: 74 20 28 72 65 76 69 73 69 6f 6e 20 2d 3e 20 6c  t (revision -> l
86e0: 69 73 74 20 28 72 65 76 69 73 69 6f 6e 29 29 0a  ist (revision)).
86f0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69      typemethod i
8700: 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f 72  nternalsuccessor
8710: 73 20 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 7d  s {dv revisions}
8720: 20 7b 0a 09 75 70 76 61 72 20 31 20 24 64 76 20   {..upvar 1 $dv 
8730: 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 65  dependencies..se
8740: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
8750: 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27   $revisions {','
8760: 7d 5d 27 29 0a 0a 09 6c 6f 67 20 77 72 69 74 65  }]')...log write
8770: 20 31 34 20 63 73 65 74 73 20 69 6e 74 65 72 6e   14 csets intern
8780: 61 6c 73 75 63 63 65 73 73 6f 72 73 0a 0a 09 23  alsuccessors...#
8790: 20 53 65 65 20 27 73 75 63 63 65 73 73 6f 72 73   See 'successors
87a0: 27 20 62 65 6c 6f 77 20 66 6f 72 20 74 68 65 20  ' below for the 
87b0: 6d 61 69 6e 20 65 78 70 6c 61 6e 61 74 69 6f 6e  main explanation
87c0: 20 6f 66 0a 09 23 20 74 68 65 20 76 61 72 69 6f   of..# the vario
87d0: 75 73 20 63 61 73 65 73 2e 20 54 68 69 73 20 70  us cases. This p
87e0: 69 65 63 65 20 69 73 20 73 70 65 63 69 61 6c 20  iece is special 
87f0: 69 6e 20 74 68 61 74 20 69 74 0a 09 23 20 72 65  in that it..# re
8800: 73 74 72 69 63 74 73 20 74 68 65 20 73 75 63 63  stricts the succ
8810: 65 73 73 6f 72 73 20 77 65 20 6c 6f 6f 6b 20 66  essors we look f
8820: 6f 72 20 74 6f 20 74 68 65 20 73 61 6d 65 20 73  or to the same s
8830: 65 74 20 6f 66 0a 09 23 20 72 65 76 69 73 69 6f  et of..# revisio
8840: 6e 73 20 77 65 20 73 74 61 72 74 20 66 72 6f 6d  ns we start from
8850: 2e 20 53 65 6e 73 69 62 6c 65 20 61 73 20 77 65  . Sensible as we
8860: 20 61 72 65 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72   are looking for
8870: 0a 09 23 20 63 68 61 6e 67 65 73 65 74 20 69 6e  ..# changeset in
8880: 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63  ternal dependenc
8890: 69 65 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 74  ies....array set
88a0: 20 64 65 70 20 7b 7d 0a 0a 09 66 6f 72 65 61 63   dep {}...foreac
88b0: 68 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73  h {rid child} [s
88c0: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
88d0: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
88e0: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 20 20 20  ackslashes {.   
88f0: 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 72 79 20   -- (1) Primary 
8900: 63 68 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 43  child..    SELEC
8910: 54 20 52 2e 72 69 64 2c 20 52 2e 63 68 69 6c 64  T R.rid, R.child
8920: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76  ..    FROM   rev
8930: 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45  ision R..    WHE
8940: 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24  RE  R.rid   IN $
8950: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65  theset     -- Re
8960: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
8970: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  ons of interest.
8980: 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68  .    AND    R.ch
8990: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ild IS NOT NULL 
89a0: 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72     -- Has primar
89b0: 79 20 63 68 69 6c 64 0a 09 20 20 20 20 41 4e 44  y child..    AND
89c0: 20 20 20 20 52 2e 63 68 69 6c 64 20 49 4e 20 24      R.child IN $
89d0: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 57 68  theset     -- Wh
89e0: 69 63 68 20 69 73 20 61 6c 73 6f 20 6f 66 20 69  ich is also of i
89f0: 6e 74 65 72 65 73 74 0a 20 20 20 20 55 4e 49 4f  nterest.    UNIO
8a00: 4e 0a 20 20 20 20 2d 2d 20 28 32 29 20 53 65 63  N.    -- (2) Sec
8a10: 6f 6e 64 61 72 79 20 28 62 72 61 6e 63 68 29 20  ondary (branch) 
8a20: 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 53 45  children..    SE
8a30: 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 72  LECT R.rid, B.br
8a40: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72  id..    FROM   r
8a50: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73  evision R, revis
8a60: 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65  ionbranchchildre
8a70: 6e 20 42 0a 09 20 20 20 20 57 48 45 52 45 20 20  n B..    WHERE  
8a80: 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73  R.rid   IN $thes
8a90: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  et     -- Restri
8aa0: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
8ab0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
8ac0: 20 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20   AND    R.rid = 
8ad0: 42 2e 72 69 64 20 20 20 20 20 20 20 20 20 20 2d  B.rid          -
8ae0: 2d 20 53 65 6c 65 63 74 20 73 75 62 73 65 74 20  - Select subset 
8af0: 6f 66 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72  of branch childr
8b00: 65 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  en..    AND    B
8b10: 2e 62 72 69 64 20 49 4e 20 24 74 68 65 73 65 74  .brid IN $theset
8b20: 20 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20 69        -- Which i
8b30: 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72 65  s also of intere
8b40: 73 74 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20  st.    UNION.   
8b50: 20 2d 2d 20 28 34 29 20 43 68 69 6c 64 20 6f 66   -- (4) Child of
8b60: 20 74 72 75 6e 6b 20 72 6f 6f 74 20 73 75 63 63   trunk root succ
8b70: 65 73 73 6f 72 20 6f 66 20 6c 61 73 74 20 4e 54  essor of last NT
8b80: 44 42 20 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20 20  DB on trunk...  
8b90: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20    SELECT R.rid, 
8ba0: 52 41 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52  RA.child..    FR
8bb0: 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72  OM revision R, r
8bc0: 65 76 69 73 69 6f 6e 20 52 41 0a 09 20 20 20 20  evision RA..    
8bd0: 57 48 45 52 45 20 52 2e 72 69 64 20 20 20 49 4e  WHERE R.rid   IN
8be0: 20 24 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d   $theset      --
8bf0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76   Restrict to rev
8c00: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65  isions of intere
8c10: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e  st..    AND   R.
8c20: 69 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20  isdefault       
8c30: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63        -- Restric
8c40: 74 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41  t to NTDB..    A
8c50: 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49  ND   R.dbchild I
8c60: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20  S NOT NULL   -- 
8c70: 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65  and last NTDB be
8c80: 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b  longing to trunk
8c90: 0a 09 20 20 20 20 41 4e 44 20 20 20 52 41 2e 72  ..    AND   RA.r
8ca0: 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 20  id = R.dbchild  
8cb0: 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 74      -- Go direct
8cc0: 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f 74  ly to trunk root
8cd0: 0a 09 20 20 20 20 41 4e 44 20 20 20 52 41 2e 63  ..    AND   RA.c
8ce0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
8cf0: 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61      -- Has prima
8d00: 72 79 20 63 68 69 6c 64 2e 0a 20 20 20 20 20 20  ry child..      
8d10: 20 20 20 20 20 20 41 4e 44 20 20 20 52 41 2e 63        AND   RA.c
8d20: 68 69 6c 64 20 49 4e 20 24 74 68 65 73 65 74 20  hild IN $theset 
8d30: 20 20 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20      -- Which is 
8d40: 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74  also of interest
8d50: 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 23 20 43  ..}]] {..    # C
8d60: 6f 6e 73 69 64 65 72 20 6d 6f 76 69 6e 67 20 74  onsider moving t
8d70: 68 69 73 20 74 6f 20 74 68 65 20 69 6e 74 65 67  his to the integ
8d80: 72 69 74 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 20  rity module...  
8d90: 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73 65    integrity asse
8da0: 72 74 20 7b 24 72 69 64 20 21 3d 20 24 63 68 69  rt {$rid != $chi
8db0: 6c 64 7d 20 7b 52 65 76 69 73 69 6f 6e 20 24 72  ld} {Revision $r
8dc0: 69 64 20 64 65 70 65 6e 64 73 20 6f 6e 20 69 74  id depends on it
8dd0: 73 65 6c 66 2e 7d 0a 09 20 20 20 20 6c 61 70 70  self.}..    lapp
8de0: 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73  end dependencies
8df0: 28 24 72 69 64 29 20 24 63 68 69 6c 64 0a 09 20  ($rid) $child.. 
8e00: 20 20 20 73 65 74 20 64 65 70 28 24 72 69 64 2c     set dep($rid,
8e10: 24 63 68 69 6c 64 29 20 2e 0a 09 7d 0a 0a 09 23  $child) ...}...#
8e20: 20 54 68 65 20 73 71 6c 20 73 74 61 74 65 6d 65   The sql stateme
8e30: 6e 74 73 20 61 62 6f 76 65 20 6c 6f 6f 6b 73 20  nts above looks 
8e40: 6f 6e 6c 79 20 66 6f 72 20 64 69 72 65 63 74 20  only for direct 
8e50: 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 23 20  dependencies..# 
8e60: 62 65 74 77 65 65 6e 20 72 65 76 69 73 69 6f 6e  between revision
8e70: 20 69 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65   in the changese
8e80: 74 2e 20 48 6f 77 65 76 65 72 20 64 75 65 20 74  t. However due t
8e90: 6f 20 74 68 65 0a 09 23 20 76 61 67 61 72 69 65  o the..# vagarie
8ea0: 73 20 6f 66 20 6d 65 74 61 20 64 61 74 61 20 69  s of meta data i
8eb0: 74 20 69 73 20 70 6f 73 73 69 62 6c 65 20 66 6f  t is possible fo
8ec0: 72 20 74 77 6f 20 72 65 76 69 73 69 6f 6e 73 20  r two revisions 
8ed0: 6f 66 0a 09 23 20 74 68 65 20 73 61 6d 65 20 66  of..# the same f
8ee0: 69 6c 65 20 74 6f 20 65 6e 64 20 75 70 20 69 6e  ile to end up in
8ef0: 20 74 68 65 20 73 61 6d 65 20 63 68 61 6e 67 65   the same change
8f00: 73 65 74 2c 20 77 69 74 68 6f 75 74 20 61 0a 09  set, without a..
8f10: 23 20 64 69 72 65 63 74 20 64 65 70 65 6e 64 65  # direct depende
8f20: 6e 63 79 20 62 65 74 77 65 65 6e 20 74 68 65 6d  ncy between them
8f30: 2e 20 48 6f 77 65 76 65 72 20 77 65 20 6b 6e 6f  . However we kno
8f40: 77 20 74 68 61 74 20 74 68 65 72 65 0a 09 23 20  w that there..# 
8f50: 68 61 73 20 74 6f 20 62 65 20 61 20 61 6e 20 69  has to be a an i
8f60: 6e 64 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e  ndirect dependen
8f70: 63 79 2c 20 62 65 20 69 74 20 74 68 72 6f 75 67  cy, be it throug
8f80: 68 20 70 72 69 6d 61 72 79 0a 09 23 20 63 68 69  h primary..# chi
8f90: 6c 64 72 65 6e 2c 20 62 72 61 6e 63 68 20 63 68  ldren, branch ch
8fa0: 69 6c 64 72 65 6e 2c 20 6f 72 20 61 20 63 6f 6d  ildren, or a com
8fb0: 62 69 6e 61 74 69 6f 6e 20 74 68 65 72 65 6f 66  bination thereof
8fc0: 2e 0a 0a 09 23 20 57 65 20 6e 6f 77 20 66 69 6c  ....# We now fil
8fd0: 6c 20 69 6e 20 74 68 65 73 65 20 70 73 65 75 64  l in these pseud
8fe0: 6f 2d 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20  o-dependencies, 
8ff0: 69 66 20 6e 6f 20 73 75 63 68 0a 09 23 20 64 65  if no such..# de
9000: 70 65 6e 64 65 6e 63 79 20 65 78 69 73 74 73 20  pendency exists 
9010: 61 6c 72 65 61 64 79 2e 20 54 68 65 20 64 69 72  already. The dir
9020: 65 63 74 69 6f 6e 20 6f 66 20 74 68 65 20 64 65  ection of the de
9030: 70 65 6e 64 65 6e 63 79 0a 09 23 20 69 73 20 61  pendency..# is a
9040: 63 74 75 61 6c 6c 79 20 69 72 72 65 6c 65 76 61  ctually irreleva
9050: 6e 74 20 66 6f 72 20 74 68 69 73 2e 0a 0a 09 23  nt for this....#
9060: 20 4e 4f 54 45 3a 20 54 68 69 73 20 69 73 20 64   NOTE: This is d
9070: 69 66 66 65 72 65 6e 74 20 66 72 6f 6d 20 63 76  ifferent from cv
9080: 73 32 73 76 6e 2e 20 4f 75 72 20 73 70 69 72 69  s2svn. Our spiri
9090: 74 75 61 6c 20 61 6e 63 65 73 74 6f 72 0a 09 23  tual ancestor..#
90a0: 20 64 6f 65 73 20 6e 6f 74 20 75 73 65 20 73 75   does not use su
90b0: 63 68 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64  ch pseudo-depend
90c0: 65 6e 63 69 65 73 2c 20 68 6f 77 65 76 65 72 20  encies, however 
90d0: 69 74 20 75 73 65 73 20 61 0a 09 23 20 43 4f 4d  it uses a..# COM
90e0: 4d 49 54 5f 54 48 52 45 53 48 4f 4c 44 2c 20 61  MIT_THRESHOLD, a
90f0: 20 74 69 6d 65 20 69 6e 74 65 72 76 61 6c 20 63   time interval c
9100: 6f 6d 6d 69 74 73 20 73 68 6f 75 6c 64 20 66 61  ommits should fa
9110: 6c 6c 2e 20 54 68 69 73 0a 09 23 20 77 69 6c 6c  ll. This..# will
9120: 20 67 72 65 61 74 6c 79 20 72 65 64 75 63 65 73   greatly reduces
9130: 20 74 68 65 20 72 69 73 6b 20 6f 66 20 67 65 74   the risk of get
9140: 74 69 6e 67 20 66 61 72 20 73 65 70 61 72 61 74  ting far separat
9150: 65 64 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 20  ed..# revisions 
9160: 6f 66 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65  of the same file
9170: 20 69 6e 74 6f 20 6f 6e 65 20 63 68 61 6e 67 65   into one change
9180: 73 65 74 2e 0a 0a 09 23 20 57 65 20 61 6c 6c 6f  set....# We allo
9190: 77 20 72 65 76 69 73 69 6f 6e 73 20 74 6f 20 62  w revisions to b
91a0: 65 20 66 61 72 20 61 70 61 72 74 20 69 6e 20 74  e far apart in t
91b0: 69 6d 65 20 69 6e 20 74 68 65 20 73 61 6d 65 0a  ime in the same.
91c0: 09 23 20 63 68 61 6e 67 65 73 65 74 2c 20 62 75  .# changeset, bu
91d0: 74 20 69 6e 20 74 75 72 6e 20 6e 65 65 64 20 74  t in turn need t
91e0: 68 65 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64  he pseudo-depend
91f0: 65 6e 63 69 65 73 20 74 6f 0a 09 23 20 68 61 6e  encies to..# han
9200: 64 6c 65 20 74 68 69 73 2e 0a 0a 09 6c 6f 67 20  dle this....log 
9210: 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b  write 14 csets {
9220: 69 6e 74 65 72 6e 61 6c 20 20 5b 61 72 72 61 79  internal  [array
9230: 20 73 69 7a 65 20 64 65 70 5d 7d 0a 09 6c 6f 67   size dep]}..log
9240: 20 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20   write 14 csets 
9250: 7b 63 6f 6c 6c 65 63 74 65 64 20 5b 61 72 72 61  {collected [arra
9260: 79 20 73 69 7a 65 20 64 65 70 65 6e 64 65 6e 63  y size dependenc
9270: 69 65 73 5d 7d 0a 09 6c 6f 67 20 77 72 69 74 65  ies]}..log write
9280: 20 31 34 20 63 73 65 74 73 20 70 73 65 75 64 6f   14 csets pseudo
9290: 2d 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73  -internalsuccess
92a0: 6f 72 73 0a 0a 09 61 72 72 61 79 20 73 65 74 20  ors...array set 
92b0: 66 69 64 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68  fids {}..foreach
92c0: 20 7b 72 69 64 20 66 69 64 7d 20 5b 73 74 61 74   {rid fid} [stat
92d0: 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f  e run [subst -no
92e0: 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b  commands -noback
92f0: 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53  slashes {..    S
9300: 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 2e 66  ELECT R.rid, R.f
9310: 69 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 46  id.            F
9320: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
9330: 0a 20 20 20 20 20 20 20 20 20 20 20 20 57 48 45  .            WHE
9340: 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24 74 68  RE  R.rid IN $th
9350: 65 73 65 74 0a 09 7d 5d 5d 20 7b 20 6c 61 70 70  eset..}]] { lapp
9360: 65 6e 64 20 66 69 64 73 28 24 66 69 64 29 20 24  end fids($fid) $
9370: 72 69 64 20 7d 0a 0a 09 73 65 74 20 67 72 6f 75  rid }...set grou
9380: 70 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b  ps {}..foreach {
9390: 66 69 64 20 72 69 64 73 7d 20 5b 61 72 72 61 79  fid rids} [array
93a0: 20 67 65 74 20 66 69 64 73 5d 20 7b 0a 09 20 20   get fids] {..  
93b0: 20 20 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24    if {[llength $
93c0: 72 69 64 73 5d 20 3c 20 32 7d 20 63 6f 6e 74 69  rids] < 2} conti
93d0: 6e 75 65 0a 09 20 20 20 20 66 6f 72 65 61 63 68  nue..    foreach
93e0: 20 61 20 24 72 69 64 73 20 7b 0a 09 09 66 6f 72   a $rids {...for
93f0: 65 61 63 68 20 62 20 24 72 69 64 73 20 7b 0a 09  each b $rids {..
9400: 09 20 20 20 20 69 66 20 7b 24 61 20 3d 3d 20 24  .    if {$a == $
9410: 62 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20  b} continue...  
9420: 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73    if {[info exis
9430: 74 73 20 64 65 70 28 24 61 2c 24 62 29 5d 7d 20  ts dep($a,$b)]} 
9440: 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20 20 69  continue...    i
9450: 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 73 20  f {[info exists 
9460: 64 65 70 28 24 62 2c 24 61 29 5d 7d 20 63 6f 6e  dep($b,$a)]} con
9470: 74 69 6e 75 65 0a 09 09 20 20 20 20 6c 61 70 70  tinue...    lapp
9480: 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73  end dependencies
9490: 28 24 61 29 20 24 62 0a 09 09 20 20 20 20 73 65  ($a) $b...    se
94a0: 74 20 64 65 70 28 24 61 2c 24 62 29 20 2e 0a 09  t dep($a,$b) ...
94b0: 09 20 20 20 20 73 65 74 20 64 65 70 28 24 62 2c  .    set dep($b,
94c0: 24 61 29 20 2e 0a 09 09 7d 0a 09 20 20 20 20 7d  $a) ....}..    }
94d0: 0a 09 20 20 20 20 73 65 74 20 6e 20 5b 6c 6c 65  ..    set n [lle
94e0: 6e 67 74 68 20 24 72 69 64 73 5d 0a 09 20 20 20  ngth $rids]..   
94f0: 20 6c 61 70 70 65 6e 64 20 67 72 6f 75 70 73 20   lappend groups 
9500: 5b 6c 69 73 74 20 24 6e 20 5b 65 78 70 72 20 7b  [list $n [expr {
9510: 28 24 6e 2a 24 6e 2d 24 6e 29 2f 32 7d 5d 5d 0a  ($n*$n-$n)/2}]].
9520: 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 31  .}...log write 1
9530: 34 20 63 73 65 74 73 20 7b 70 73 65 75 64 6f 20  4 csets {pseudo 
9540: 20 20 20 5b 61 72 72 61 79 20 73 69 7a 65 20 66     [array size f
9550: 69 64 73 5d 20 28 5b 6c 73 6f 72 74 20 2d 69 6e  ids] ([lsort -in
9560: 64 65 78 20 30 20 2d 64 65 63 72 65 61 73 69 6e  dex 0 -decreasin
9570: 67 20 2d 69 6e 74 65 67 65 72 20 24 67 72 6f 75  g -integer $grou
9580: 70 73 5d 29 7d 0a 09 6c 6f 67 20 77 72 69 74 65  ps])}..log write
9590: 20 31 34 20 63 73 65 74 73 20 7b 69 6e 74 65 72   14 csets {inter
95a0: 6e 61 6c 20 20 5b 61 72 72 61 79 20 73 69 7a 65  nal  [array size
95b0: 20 64 65 70 5d 7d 0a 09 6c 6f 67 20 77 72 69 74   dep]}..log writ
95c0: 65 20 31 34 20 63 73 65 74 73 20 7b 63 6f 6c 6c  e 14 csets {coll
95d0: 65 63 74 65 64 20 5b 61 72 72 61 79 20 73 69 7a  ected [array siz
95e0: 65 20 64 65 70 65 6e 64 65 6e 63 69 65 73 5d 7d  e dependencies]}
95f0: 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63  ..log write 14 c
9600: 73 65 74 73 20 63 6f 6d 70 6c 65 74 65 0a 09 72  sets complete..r
9610: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
9620: 20 23 20 72 65 73 75 6c 74 20 3d 20 34 2d 6c 69   # result = 4-li
9630: 73 74 20 28 69 74 65 6d 74 79 70 65 20 69 74 65  st (itemtype ite
9640: 6d 69 64 20 6e 65 78 74 69 74 65 6d 74 79 70 65  mid nextitemtype
9650: 20 6e 65 78 74 69 74 65 6d 69 64 20 2e 2e 2e 29   nextitemid ...)
9660: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
9670: 6c 6f 6f 70 73 20 7b 72 65 76 69 73 69 6f 6e 73  loops {revisions
9680: 7d 20 7b 0a 09 23 20 4e 6f 74 65 3a 20 54 61 67  } {..# Note: Tag
9690: 73 20 61 6e 64 20 62 72 61 6e 63 68 65 73 20 63  s and branches c
96a0: 61 6e 6e 6f 74 20 63 61 75 73 65 20 74 68 65 20  annot cause the 
96b0: 6c 6f 6f 70 2e 20 54 68 65 69 72 20 69 64 27 73  loop. Their id's
96c0: 2c 0a 09 23 20 62 65 69 6e 67 20 6f 66 20 61 20  ,..# being of a 
96d0: 66 75 6e 64 61 6d 65 6e 74 61 6c 6c 79 20 64 69  fundamentally di
96e0: 66 66 65 72 65 6e 74 20 74 79 70 65 20 74 68 61  fferent type tha
96f0: 6e 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 0a  n the revisions.
9700: 09 23 20 63 6f 6d 69 6e 67 20 69 6e 20 63 61 6e  .# coming in can
9710: 6e 6f 74 20 62 65 20 69 6e 20 74 68 65 20 73 65  not be in the se
9720: 74 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20  t....set theset 
9730: 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f  ('[join $revisio
9740: 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74  ns {','}]')..ret
9750: 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b  urn [state run [
9760: 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64  subst -nocommand
9770: 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73  s -nobackslashes
9780: 20 7b 0a 09 20 20 20 20 2d 2d 20 28 31 29 20 50   {..    -- (1) P
9790: 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20  rimary child..  
97a0: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20    SELECT R.rid, 
97b0: 52 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f  R.child..    FRO
97c0: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09  M   revision R..
97d0: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64      WHERE  R.rid
97e0: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20     IN $theset   
97f0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
9800: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
9810: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
9820: 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f     R.child IS NO
9830: 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73  T NULL    -- Has
9840: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09   primary child..
9850: 20 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69      AND    R.chi
9860: 6c 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20  ld IN $theset   
9870: 20 20 2d 2d 20 4c 6f 6f 70 0a 09 20 20 20 20 2d    -- Loop..    -
9880: 2d 0a 09 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20  -..    UNION..  
9890: 20 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61    -- (2) Seconda
98a0: 72 79 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c  ry (branch) chil
98b0: 64 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54  dren..    SELECT
98c0: 20 52 2e 72 69 64 2c 20 42 2e 62 72 69 64 0a 09   R.rid, B.brid..
98d0: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
98e0: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 62  ion R, revisionb
98f0: 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20 42 0a  ranchchildren B.
9900: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
9910: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20  d   IN $theset  
9920: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
9930: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
9940: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
9950: 20 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69      R.rid = B.ri
9960: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65  d          -- Se
9970: 6c 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62  lect subset of b
9980: 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 09  ranch children..
9990: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 69 64      AND    B.rid
99a0: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20     IN $theset   
99b0: 20 20 2d 2d 20 4c 6f 6f 70 0a 09 20 20 20 20 2d    -- Loop..    -
99c0: 2d 0a 09 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20  -..    UNION..  
99d0: 20 20 2d 2d 20 28 34 29 20 43 68 69 6c 64 20 6f    -- (4) Child o
99e0: 66 20 74 72 75 6e 6b 20 72 6f 6f 74 20 73 75 63  f trunk root suc
99f0: 63 65 73 73 6f 72 20 6f 66 20 6c 61 73 74 20 4e  cessor of last N
9a00: 54 44 42 20 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20  TDB on trunk... 
9a10: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
9a20: 20 52 41 2e 63 68 69 6c 64 0a 09 20 20 20 20 46   RA.child..    F
9a30: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
9a40: 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 0a 09 20  , revision RA.. 
9a50: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
9a60: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20     IN $theset   
9a70: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
9a80: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
9a90: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
9aa0: 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74 20 20     R.isdefault  
9ab0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65             -- Re
9ac0: 73 74 72 69 63 74 20 74 6f 20 4e 54 44 42 0a 09  strict to NTDB..
9ad0: 20 20 20 20 41 4e 44 20 20 20 20 52 2e 64 62 63      AND    R.dbc
9ae0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
9af0: 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74 20 4e     -- and last N
9b00: 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f  TDB belonging to
9b10: 20 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e 44 20   trunk..    AND 
9b20: 20 20 20 52 41 2e 72 69 64 20 3d 20 52 2e 64 62     RA.rid = R.db
9b30: 63 68 69 6c 64 20 20 20 20 20 20 2d 2d 20 47 6f  child      -- Go
9b40: 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 72 75   directly to tru
9b50: 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e 44  nk root..    AND
9b60: 20 20 20 20 52 41 2e 63 68 69 6c 64 20 49 53 20      RA.child IS 
9b70: 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48  NOT NULL    -- H
9b80: 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  as primary child
9b90: 2e 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41  ...    AND    RA
9ba0: 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73 65  .child IN $these
9bb0: 74 20 20 20 20 20 2d 2d 20 4c 6f 6f 70 0a 09 7d  t     -- Loop..}
9bc0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  ]].    }..    # 
9bd0: 76 61 72 28 64 76 29 20 3d 20 64 69 63 74 20 28  var(dv) = dict (
9be0: 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69 74  item -> list (it
9bf0: 65 6d 29 29 2c 20 69 74 65 6d 20 20 3d 20 6c 69  em)), item  = li
9c00: 73 74 20 28 74 79 70 65 20 69 64 29 0a 20 20 20  st (type id).   
9c10: 20 74 79 70 65 6d 65 74 68 6f 64 20 73 75 63 63   typemethod succ
9c20: 65 73 73 6f 72 73 20 7b 64 76 20 72 65 76 69 73  essors {dv revis
9c30: 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31  ions} {..upvar 1
9c40: 20 24 64 76 20 64 65 70 65 6e 64 65 6e 63 69 65   $dv dependencie
9c50: 73 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27  s..set theset ('
9c60: 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73  [join $revisions
9c70: 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 23 20 54 68   {','}]')...# Th
9c80: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 61 73 65  e following case
9c90: 73 20 73 70 65 63 69 66 79 20 77 68 65 6e 20 61  s specify when a
9ca0: 20 72 65 76 69 73 69 6f 6e 20 53 20 69 73 20 61   revision S is a
9cb0: 20 73 75 63 63 65 73 73 6f 72 0a 09 23 20 6f 66   successor..# of
9cc0: 20 61 20 72 65 76 69 73 69 6f 6e 20 52 2e 20 45   a revision R. E
9cd0: 61 63 68 20 6f 66 20 74 68 65 20 63 61 73 65 73  ach of the cases
9ce0: 20 74 72 61 6e 73 6c 61 74 65 73 20 69 6e 74 6f   translates into
9cf0: 20 6f 6e 65 20 6f 66 0a 09 23 20 74 68 65 20 62   one of..# the b
9d00: 72 61 6e 63 68 65 73 20 6f 66 20 74 68 65 20 53  ranches of the S
9d10: 51 4c 20 55 4e 49 4f 4e 20 63 6f 6d 69 6e 67 20  QL UNION coming 
9d20: 62 65 6c 6f 77 2e 0a 09 23 0a 09 23 20 28 31 29  below...#..# (1)
9d30: 20 53 20 63 61 6e 20 62 65 20 61 20 70 72 69 6d   S can be a prim
9d40: 61 72 79 20 63 68 69 6c 64 20 6f 66 20 52 2c 20  ary child of R, 
9d50: 69 2e 65 2e 20 69 6e 20 74 68 65 20 73 61 6d 65  i.e. in the same
9d60: 20 4c 4f 44 2e 20 52 0a 09 23 20 20 20 20 20 72   LOD. R..#     r
9d70: 65 66 65 72 65 6e 63 65 73 20 53 20 64 69 72 65  eferences S dire
9d80: 63 74 6c 79 2e 20 52 2e 63 68 69 6c 64 20 3d 20  ctly. R.child = 
9d90: 53 28 2e 72 69 64 29 2c 20 69 66 20 69 74 20 65  S(.rid), if it e
9da0: 78 69 73 74 73 2e 0a 09 23 0a 09 23 20 28 32 29  xists...#..# (2)
9db0: 20 53 20 63 61 6e 20 62 65 20 61 20 73 65 63 6f   S can be a seco
9dc0: 6e 64 61 72 79 2c 20 69 2e 65 2e 20 62 72 61 6e  ndary, i.e. bran
9dd0: 63 68 2c 20 63 68 69 6c 64 20 6f 66 20 52 2e 20  ch, child of R. 
9de0: 48 65 72 65 20 74 68 65 0a 09 23 20 20 20 20 20  Here the..#     
9df0: 6c 69 6e 6b 20 69 73 20 6d 61 64 65 20 74 68 72  link is made thr
9e00: 6f 75 67 68 20 74 68 65 20 68 65 6c 70 65 72 20  ough the helper 
9e10: 74 61 62 6c 65 0a 09 23 20 20 20 20 20 52 45 56  table..#     REV
9e20: 49 53 49 4f 4e 42 52 41 4e 43 48 43 48 49 4c 44  ISIONBRANCHCHILD
9e30: 52 45 4e 2e 20 52 2e 72 69 64 20 2d 3e 20 52 42  REN. R.rid -> RB
9e40: 43 2e 72 69 64 2c 20 52 42 43 2e 62 72 69 64 20  C.rid, RBC.brid 
9e50: 3d 0a 09 23 20 20 20 20 20 53 28 2e 72 69 64 29  =..#     S(.rid)
9e60: 0a 09 23 0a 09 23 20 28 33 29 20 4f 72 69 67 69  ..#..# (3) Origi
9e70: 6e 61 6c 6c 79 20 74 68 69 73 20 75 73 65 20 63  nally this use c
9e80: 61 73 65 20 64 65 66 69 6e 65 64 20 74 68 65 20  ase defined the 
9e90: 72 6f 6f 74 20 6f 66 20 61 20 64 65 74 61 63 68  root of a detach
9ea0: 65 64 0a 09 23 20 20 20 20 20 4e 54 44 42 20 61  ed..#     NTDB a
9eb0: 73 20 74 68 65 20 73 75 63 63 65 73 73 6f 72 20  s the successor 
9ec0: 6f 66 20 74 68 65 20 74 72 75 6e 6b 20 72 6f 6f  of the trunk roo
9ed0: 74 2e 20 54 68 69 73 20 6c 65 61 64 73 20 74 6f  t. This leads to
9ee0: 20 61 0a 09 23 20 20 20 20 20 62 61 64 20 74 61   a..#     bad ta
9ef0: 6e 67 6c 65 20 6c 61 74 65 72 20 6f 6e 2e 20 57  ngle later on. W
9f00: 69 74 68 20 61 20 64 65 74 61 63 68 65 64 20 4e  ith a detached N
9f10: 54 44 42 20 74 68 65 20 6f 72 69 67 69 6e 61 6c  TDB the original
9f20: 0a 09 23 20 20 20 20 20 74 72 75 6e 6b 20 72 6f  ..#     trunk ro
9f30: 6f 74 20 72 65 76 69 73 69 6f 6e 20 77 61 73 20  ot revision was 
9f40: 72 65 6d 6f 76 65 64 20 61 73 20 69 72 72 65 6c  removed as irrel
9f50: 65 76 61 6e 74 2c 20 61 6c 6c 6f 77 69 6e 67 0a  evant, allowing.
9f60: 09 23 20 20 20 20 20 74 68 65 20 6e 6f 6d 69 6e  .#     the nomin
9f70: 61 6c 20 72 6f 6f 74 20 74 6f 20 62 65 20 6c 61  al root to be la
9f80: 74 65 72 20 69 6e 20 74 69 6d 65 20 74 68 61 6e  ter in time than
9f90: 20 74 68 65 20 4e 54 44 42 0a 09 23 20 20 20 20   the NTDB..#    
9fa0: 20 72 6f 6f 74 2e 20 4e 6f 77 20 73 65 74 74 69   root. Now setti
9fb0: 6e 67 20 74 68 69 73 20 64 65 70 65 6e 64 65 6e  ng this dependen
9fc0: 63 79 20 77 69 6c 6c 20 62 65 20 62 61 63 6b 77  cy will be backw
9fd0: 61 72 64 20 69 6e 0a 09 23 20 20 20 20 20 74 69  ard in..#     ti
9fe0: 6d 65 2e 20 52 45 4d 4f 56 45 44 2e 0a 09 23 0a  me. REMOVED...#.
9ff0: 09 23 20 28 34 29 20 49 66 20 52 20 69 73 20 74  .# (4) If R is t
a000: 68 65 20 6c 61 73 74 20 6f 66 20 74 68 65 20 4e  he last of the N
a010: 54 44 42 20 72 65 76 69 73 69 6f 6e 73 20 77 68  TDB revisions wh
a020: 69 63 68 20 62 65 6c 6f 6e 67 20 74 6f 0a 09 23  ich belong to..#
a030: 20 20 20 20 20 74 68 65 20 74 72 75 6e 6b 2c 20       the trunk, 
a040: 74 68 65 6e 20 74 68 65 20 70 72 69 6d 61 72 79  then the primary
a050: 20 63 68 69 6c 64 20 6f 66 20 74 68 65 20 74 72   child of the tr
a060: 75 6e 6b 20 72 6f 6f 74 20 28 74 68 65 0a 09 23  unk root (the..#
a070: 20 20 20 20 20 27 31 2e 32 27 20 72 65 76 69 73       '1.2' revis
a080: 69 6f 6e 29 20 69 73 20 61 20 73 75 63 63 65 73  ion) is a succes
a090: 73 6f 72 2c 20 69 66 20 69 74 20 65 78 69 73 74  sor, if it exist
a0a0: 73 2e 0a 0a 09 23 20 4e 6f 74 65 20 74 68 61 74  s....# Note that
a0b0: 20 74 68 65 20 62 72 61 6e 63 68 65 73 20 73 70   the branches sp
a0c0: 61 77 6e 65 64 20 66 72 6f 6d 20 74 68 65 20 72  awned from the r
a0d0: 65 76 69 73 69 6f 6e 73 2c 20 61 6e 64 20 74 68  evisions, and th
a0e0: 65 0a 09 23 20 74 61 67 73 20 61 73 73 6f 63 69  e..# tags associ
a0f0: 61 74 65 64 20 77 69 74 68 20 74 68 65 6d 20 61  ated with them a
a100: 72 65 20 73 75 63 63 65 73 73 6f 72 73 20 61 73  re successors as
a110: 20 77 65 6c 6c 2e 0a 0a 09 66 6f 72 65 61 63 68   well....foreach
a120: 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74   {rid child} [st
a130: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
a140: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
a150: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 20 20 20 20  ckslashes {.    
a160: 2d 2d 20 28 31 29 20 50 72 69 6d 61 72 79 20 63  -- (1) Primary c
a170: 68 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 43 54  hild..    SELECT
a180: 20 52 2e 72 69 64 2c 20 52 2e 63 68 69 6c 64 0a   R.rid, R.child.
a190: 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69  .    FROM   revi
a1a0: 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52  sion R..    WHER
a1b0: 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74  E  R.rid   IN $t
a1c0: 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73  heset     -- Res
a1d0: 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f  trict to revisio
a1e0: 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  ns of interest..
a1f0: 20 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69      AND    R.chi
a200: 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20  ld IS NOT NULL  
a210: 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79    -- Has primary
a220: 20 63 68 69 6c 64 0a 20 20 20 20 55 4e 49 4f 4e   child.    UNION
a230: 0a 20 20 20 20 2d 2d 20 28 32 29 20 53 65 63 6f  .    -- (2) Seco
a240: 6e 64 61 72 79 20 28 62 72 61 6e 63 68 29 20 63  ndary (branch) c
a250: 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 53 45 4c  hildren..    SEL
a260: 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 72 69  ECT R.rid, B.bri
a270: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65  d..    FROM   re
a280: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69  vision R, revisi
a290: 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65 6e  onbranchchildren
a2a0: 20 42 0a 09 20 20 20 20 57 48 45 52 45 20 20 52   B..    WHERE  R
a2b0: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65  .rid   IN $these
a2c0: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63  t     -- Restric
a2d0: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f  t to revisions o
a2e0: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20  f interest..    
a2f0: 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20 42  AND    R.rid = B
a300: 2e 72 69 64 20 20 20 20 20 20 20 20 20 20 2d 2d  .rid          --
a310: 20 53 65 6c 65 63 74 20 73 75 62 73 65 74 20 6f   Select subset o
a320: 66 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72 65  f branch childre
a330: 6e 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20  n.    UNION.    
a340: 2d 2d 20 28 34 29 20 43 68 69 6c 64 20 6f 66 20  -- (4) Child of 
a350: 74 72 75 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65  trunk root succe
a360: 73 73 6f 72 20 6f 66 20 6c 61 73 74 20 4e 54 44  ssor of last NTD
a370: 42 20 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20  B on trunk...   
a380: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52   SELECT R.rid, R
a390: 41 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f  A.child..    FRO
a3a0: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65  M revision R, re
a3b0: 76 69 73 69 6f 6e 20 52 41 0a 09 20 20 20 20 57  vision RA..    W
a3c0: 48 45 52 45 20 52 2e 72 69 64 20 20 20 49 4e 20  HERE R.rid   IN 
a3d0: 24 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20  $theset      -- 
a3e0: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
a3f0: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
a400: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 69  t..    AND   R.i
a410: 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20  sdefault        
a420: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
a430: 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e   to NTDB..    AN
a440: 44 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53  D   R.dbchild IS
a450: 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 61   NOT NULL   -- a
a460: 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65 6c  nd last NTDB bel
a470: 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b 0a  onging to trunk.
a480: 09 20 20 20 20 41 4e 44 20 20 20 52 41 2e 72 69  .    AND   RA.ri
a490: 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 20 20  d = R.dbchild   
a4a0: 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 74 6c     -- Go directl
a4b0: 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 0a  y to trunk root.
a4c0: 09 20 20 20 20 41 4e 44 20 20 20 52 41 2e 63 68  .    AND   RA.ch
a4d0: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ild IS NOT NULL 
a4e0: 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72     -- Has primar
a4f0: 79 20 63 68 69 6c 64 2e 0a 09 7d 5d 5d 20 7b 0a  y child...}]] {.
a500: 09 20 20 20 20 23 20 43 6f 6e 73 69 64 65 72 20  .    # Consider 
a510: 6d 6f 76 69 6e 67 20 74 68 69 73 20 74 6f 20 74  moving this to t
a520: 68 65 20 69 6e 74 65 67 72 69 74 79 20 6d 6f 64  he integrity mod
a530: 75 6c 65 2e 0a 09 20 20 20 20 69 6e 74 65 67 72  ule...    integr
a540: 69 74 79 20 61 73 73 65 72 74 20 7b 24 72 69 64  ity assert {$rid
a550: 20 21 3d 20 24 63 68 69 6c 64 7d 20 7b 52 65 76   != $child} {Rev
a560: 69 73 69 6f 6e 20 24 72 69 64 20 64 65 70 65 6e  ision $rid depen
a570: 64 73 20 6f 6e 20 69 74 73 65 6c 66 2e 7d 0a 09  ds on itself.}..
a580: 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65      lappend depe
a590: 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 72  ndencies([list r
a5a0: 65 76 20 24 72 69 64 5d 29 20 5b 6c 69 73 74 20  ev $rid]) [list 
a5b0: 72 65 76 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09  rev $child]..}..
a5c0: 66 6f 72 65 61 63 68 20 7b 72 69 64 20 63 68 69  foreach {rid chi
a5d0: 6c 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 5b  ld} [state run [
a5e0: 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64  subst -nocommand
a5f0: 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73  s -nobackslashes
a600: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52   {..    SELECT R
a610: 2e 72 69 64 2c 20 54 2e 74 69 64 0a 09 20 20 20  .rid, T.tid..   
a620: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
a630: 20 52 2c 20 74 61 67 20 54 0a 09 20 20 20 20 57   R, tag T..    W
a640: 48 45 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24  HERE  R.rid IN $
a650: 74 68 65 73 65 74 20 20 20 20 20 20 20 2d 2d 20  theset       -- 
a660: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
a670: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
a680: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 54 2e  t..    AND    T.
a690: 72 65 76 20 3d 20 52 2e 72 69 64 20 20 20 20 20  rev = R.rid     
a6a0: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 74       -- Select t
a6b0: 61 67 73 20 61 74 74 61 63 68 65 64 20 74 6f 20  ags attached to 
a6c0: 74 68 65 6d 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20  them..}]] {..   
a6d0: 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65   lappend depende
a6e0: 6e 63 69 65 73 28 5b 6c 69 73 74 20 72 65 76 20  ncies([list rev 
a6f0: 24 72 69 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d  $rid]) [list sym
a700: 3a 3a 74 61 67 20 24 63 68 69 6c 64 5d 0a 09 7d  ::tag $child]..}
a710: 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 63  ..foreach {rid c
a720: 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75 6e  hild} [state run
a730: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
a740: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
a750: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  es {..    SELECT
a760: 20 52 2e 72 69 64 2c 20 42 2e 62 69 64 0a 09 20   R.rid, B.bid.. 
a770: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69     FROM   revisi
a780: 6f 6e 20 52 2c 20 62 72 61 6e 63 68 20 42 0a 09  on R, branch B..
a790: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64      WHERE  R.rid
a7a0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
a7b0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
a7c0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
a7d0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
a7e0: 20 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69     B.root = R.ri
a7f0: 64 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c  d         -- Sel
a800: 65 63 74 20 62 72 61 6e 63 68 65 73 20 61 74 74  ect branches att
a810: 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 09 7d  ached to them..}
a820: 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e  ]] {..    lappen
a830: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b  d dependencies([
a840: 6c 69 73 74 20 72 65 76 20 24 72 69 64 5d 29 20  list rev $rid]) 
a850: 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63  [list sym::branc
a860: 68 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 72 65  h $child]..}..re
a870: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
a880: 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20  # result = list 
a890: 28 63 68 61 6e 67 65 73 65 74 2d 69 64 29 0a 20  (changeset-id). 
a8a0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73     typemethod cs
a8b0: 5f 73 75 63 63 65 73 73 6f 72 73 20 7b 72 65 76  _successors {rev
a8c0: 69 73 69 6f 6e 73 7d 20 7b 0a 20 20 20 20 20 20  isions} {.      
a8d0: 20 20 23 20 54 68 69 73 20 69 73 20 61 20 76 61    # This is a va
a8e0: 72 69 61 6e 74 20 6f 66 20 27 73 75 63 63 65 73  riant of 'succes
a8f0: 73 6f 72 73 27 20 77 68 69 63 68 20 6d 61 70 73  sors' which maps
a900: 20 74 68 65 20 6c 6f 77 2d 6c 65 76 65 6c 0a 20   the low-level. 
a910: 20 20 20 20 20 20 20 23 20 64 61 74 61 20 64 69         # data di
a920: 72 65 63 74 6c 79 20 74 6f 20 74 68 65 20 61 73  rectly to the as
a930: 73 6f 63 69 61 74 65 64 20 63 68 61 6e 67 65 73  sociated changes
a940: 65 74 73 2e 20 49 2e 65 2e 20 69 6e 73 74 65 61  ets. I.e. instea
a950: 64 0a 20 20 20 20 20 20 20 20 23 20 6d 69 6c 6c  d.        # mill
a960: 69 6f 6e 73 20 6f 66 20 64 65 70 65 6e 64 65 6e  ions of dependen
a970: 63 79 20 70 61 69 72 73 20 28 69 6e 20 65 78 74  cy pairs (in ext
a980: 72 65 6d 65 20 63 61 73 65 73 20 28 45 78 61 6d  reme cases (Exam
a990: 70 6c 65 3a 20 54 63 6c 0a 20 20 20 20 20 20 20  ple: Tcl.       
a9a0: 20 23 20 43 56 53 29 29 20 77 65 20 72 65 74 75   # CVS)) we retu
a9b0: 72 6e 20 61 20 76 65 72 79 20 73 68 6f 72 74 20  rn a very short 
a9c0: 61 6e 64 20 6d 75 63 68 20 6d 6f 72 65 20 6d 61  and much more ma
a9d0: 6e 61 67 65 61 62 6c 65 20 6c 69 73 74 0a 20 20  nageable list.  
a9e0: 20 20 20 20 20 20 23 20 6f 66 20 63 68 61 6e 67        # of chang
a9f0: 65 73 65 74 73 2e 0a 0a 09 73 65 74 20 74 68 65  esets....set the
aa00: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76  set ('[join $rev
aa10: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a  isions {','}]').
aa20: 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72  .return [state r
aa30: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d  un [subst -nocom
aa40: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61  mands -nobacksla
aa50: 73 68 65 73 20 7b 0a 20 20 20 20 2d 2d 20 28 31  shes {.    -- (1
aa60: 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c 64 0a  ) Primary child.
aa70: 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69  .    SELECT C.ci
aa80: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65  d..    FROM   re
aa90: 76 69 73 69 6f 6e 20 52 2c 20 63 73 69 74 65 6d  vision R, csitem
aaa0: 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43   CI, changeset C
aab0: 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72  ..    WHERE  R.r
aac0: 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20  id   IN $theset 
aad0: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
aae0: 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20  to revisions of 
aaf0: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e  interest..    AN
ab00: 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20  D    R.child IS 
ab10: 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48  NOT NULL    -- H
ab20: 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  as primary child
ab30: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
ab40: 20 20 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 63      CI.iid = R.c
ab50: 68 69 6c 64 20 20 20 20 20 20 20 2d 2d 20 53 65  hild       -- Se
ab60: 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73  lect all changes
ab70: 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 20  ets.            
ab80: 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43  AND    C.cid = C
ab90: 49 2e 63 69 64 20 20 20 20 20 20 20 20 20 2d 2d  I.cid         --
aba0: 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20   containing the 
abb0: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 20 20  primary child.  
abc0: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
abd0: 20 43 2e 74 79 70 65 20 3d 20 30 20 20 20 20 20   C.type = 0     
abe0: 20 20 20 20 20 20 20 20 2d 2d 20 77 68 69 63 68          -- which
abf0: 20 61 72 65 20 72 65 76 69 73 69 6f 6e 20 63 68   are revision ch
ac00: 61 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49  angesets.    UNI
ac10: 4f 4e 0a 20 20 20 20 2d 2d 20 28 32 29 20 53 65  ON.    -- (2) Se
ac20: 63 6f 6e 64 61 72 79 20 28 62 72 61 6e 63 68 29  condary (branch)
ac30: 20 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 53   children..    S
ac40: 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20  ELECT C.cid..   
ac50: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
ac60: 20 52 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e   R, revisionbran
ac70: 63 68 63 68 69 6c 64 72 65 6e 20 42 2c 20 63 73  chchildren B, cs
ac80: 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73  item CI, changes
ac90: 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20  et C..    WHERE 
aca0: 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65   R.rid   IN $the
acb0: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72  set     -- Restr
acc0: 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73  ict to revisions
acd0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
ace0: 20 20 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d    AND    R.rid =
acf0: 20 42 2e 72 69 64 20 20 20 20 20 20 20 20 20 20   B.rid          
ad00: 2d 2d 20 53 65 6c 65 63 74 20 73 75 62 73 65 74  -- Select subset
ad10: 20 6f 66 20 62 72 61 6e 63 68 20 63 68 69 6c 64   of branch child
ad20: 72 65 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20  ren.            
ad30: 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20  AND    CI.iid = 
ad40: 42 2e 62 72 69 64 20 20 20 20 20 20 20 20 2d 2d  B.brid        --
ad50: 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e   Select all chan
ad60: 67 65 73 65 74 73 0a 20 20 20 20 20 20 20 20 20  gesets.         
ad70: 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20     AND    C.cid 
ad80: 3d 20 43 49 2e 63 69 64 09 20 20 2d 2d 20 63 6f  = CI.cid.  -- co
ad90: 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 62 72 61  ntaining the bra
ada0: 6e 63 68 0a 20 20 20 20 20 20 20 20 20 20 20 20  nch.            
adb0: 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20  AND    C.type = 
adc0: 30 09 09 20 20 2d 2d 20 77 68 69 63 68 20 61 72  0..  -- which ar
add0: 65 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67  e revision chang
ade0: 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a  esets.    UNION.
adf0: 20 20 20 20 2d 2d 20 28 34 29 20 43 68 69 6c 64      -- (4) Child
ae00: 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74 20 73   of trunk root s
ae10: 75 63 63 65 73 73 6f 72 20 6f 66 20 6c 61 73 74  uccessor of last
ae20: 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b 2e 0a   NTDB on trunk..
ae30: 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69  .    SELECT C.ci
ae40: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65  d..    FROM   re
ae50: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69  vision R, revisi
ae60: 6f 6e 20 52 41 2c 20 63 73 69 74 65 6d 20 43 49  on RA, csitem CI
ae70: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20  , changeset C.. 
ae80: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
ae90: 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20    IN $theset    
aea0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
aeb0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
aec0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
aed0: 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74 20 20     R.isdefault  
aee0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65             -- Re
aef0: 73 74 72 69 63 74 20 74 6f 20 4e 54 44 42 0a 09  strict to NTDB..
af00: 20 20 20 20 41 4e 44 20 20 20 20 52 2e 64 62 63      AND    R.dbc
af10: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
af20: 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74 20 4e     -- and last N
af30: 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f  TDB belonging to
af40: 20 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e 44 20   trunk..    AND 
af50: 20 20 20 52 41 2e 72 69 64 20 3d 20 52 2e 64 62     RA.rid = R.db
af60: 63 68 69 6c 64 20 20 20 20 20 20 2d 2d 20 47 6f  child      -- Go
af70: 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 72 75   directly to tru
af80: 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e 44  nk root..    AND
af90: 20 20 20 20 52 41 2e 63 68 69 6c 64 20 49 53 20      RA.child IS 
afa0: 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48  NOT NULL    -- H
afb0: 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  as primary child
afc0: 2e 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e  ..            AN
afd0: 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20 52 41  D    CI.iid = RA
afe0: 2e 63 68 69 6c 64 20 20 20 20 20 20 20 2d 2d 20  .child       -- 
aff0: 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67  Select all chang
b000: 65 73 65 74 73 0a 20 20 20 20 20 20 20 20 20 20  esets.          
b010: 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d    AND    C.cid =
b020: 20 43 49 2e 63 69 64 09 20 20 20 2d 2d 20 63 6f   CI.cid.   -- co
b030: 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 70 72 69  ntaining the pri
b040: 6d 61 72 79 20 63 68 69 6c 64 0a 20 20 20 20 20  mary child.     
b050: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e         AND    C.
b060: 74 79 70 65 20 3d 20 30 09 09 20 20 20 2d 2d 20  type = 0..   -- 
b070: 77 68 69 63 68 20 61 72 65 20 72 65 76 69 73 69  which are revisi
b080: 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20  on changesets.  
b090: 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c    UNION..    SEL
b0a0: 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46  ECT C.cid..    F
b0b0: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
b0c0: 2c 20 74 61 67 20 54 2c 20 63 73 69 74 65 6d 20  , tag T, csitem 
b0d0: 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a  CI, changeset C.
b0e0: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
b0f0: 64 20 69 6e 20 24 74 68 65 73 65 74 20 20 20 20  d in $theset    
b100: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
b110: 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20  to revisions of 
b120: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e  interest..    AN
b130: 44 20 20 20 20 54 2e 72 65 76 20 3d 20 52 2e 72  D    T.rev = R.r
b140: 69 64 09 20 20 20 2d 2d 20 53 65 6c 65 63 74 20  id.   -- Select 
b150: 74 61 67 73 20 61 74 74 61 63 68 65 64 20 74 6f  tags attached to
b160: 20 74 68 65 6d 0a 20 20 20 20 20 20 20 20 20 20   them.          
b170: 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20    AND    CI.iid 
b180: 3d 20 54 2e 74 69 64 20 20 20 20 20 20 20 20 20  = T.tid         
b190: 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63   -- Select all c
b1a0: 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20  hangesets.      
b1b0: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63        AND    C.c
b1c0: 69 64 20 3d 20 43 49 2e 63 69 64 09 20 20 20 2d  id = CI.cid.   -
b1d0: 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65  - containing the
b1e0: 20 74 61 67 73 0a 20 20 20 20 20 20 20 20 20 20   tags.          
b1f0: 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20    AND    C.type 
b200: 3d 20 31 09 09 20 20 20 2d 2d 20 77 68 69 63 68  = 1..   -- which
b210: 20 61 72 65 20 74 61 67 20 63 68 61 6e 67 65 73   are tag changes
b220: 65 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20  ets.    UNION.. 
b230: 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a     SELECT C.cid.
b240: 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69  .    FROM   revi
b250: 73 69 6f 6e 20 52 2c 20 62 72 61 6e 63 68 20 42  sion R, branch B
b260: 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61  , csitem CI, cha
b270: 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48  ngeset C..    WH
b280: 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20 24 74  ERE  R.rid in $t
b290: 68 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d 20  heset        -- 
b2a0: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
b2b0: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
b2c0: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e  t..    AND    B.
b2d0: 72 6f 6f 74 20 3d 20 52 2e 72 69 64 09 20 20 20  root = R.rid.   
b2e0: 2d 2d 20 53 65 6c 65 63 74 20 62 72 61 6e 63 68  -- Select branch
b2f0: 65 73 20 61 74 74 61 63 68 65 64 20 74 6f 20 74  es attached to t
b300: 68 65 6d 0a 20 20 20 20 20 20 20 20 20 20 20 20  hem.            
b310: 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20  AND    CI.iid = 
b320: 42 2e 62 69 64 20 20 20 20 20 20 20 20 20 20 2d  B.bid          -
b330: 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61  - Select all cha
b340: 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20 20 20  ngesets.        
b350: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64      AND    C.cid
b360: 20 3d 20 43 49 2e 63 69 64 09 20 20 20 2d 2d 20   = CI.cid.   -- 
b370: 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20 62  containing the b
b380: 72 61 6e 63 68 65 73 0a 20 20 20 20 20 20 20 20  ranches.        
b390: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70      AND    C.typ
b3a0: 65 20 3d 20 32 09 09 20 20 20 2d 2d 20 77 68 69  e = 2..   -- whi
b3b0: 63 68 20 61 72 65 20 62 72 61 6e 63 68 20 63 68  ch are branch ch
b3c0: 61 6e 67 65 73 65 74 73 0a 09 7d 5d 5d 0a 20 20  angesets..}]].  
b3d0: 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c    }..    # resul
b3e0: 74 20 3d 20 73 79 6d 62 6f 6c 20 6e 61 6d 65 0a  t = symbol name.
b3f0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63      typemethod c
b400: 73 5f 6c 6f 64 20 7b 72 65 76 69 73 69 6f 6e 73  s_lod {revisions
b410: 7d 20 7b 0a 09 23 20 44 65 74 65 72 6d 69 6e 65  } {..# Determine
b420: 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68  s the name of th
b430: 65 20 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 69  e symbol which i
b440: 73 20 74 68 65 20 6c 69 6e 65 20 6f 66 0a 09 23  s the line of..#
b450: 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 66 6f 72   development for
b460: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 20 69   the revisions i
b470: 6e 20 61 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a  n a changeset...
b480: 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a  .set theset ('[j
b490: 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b  oin $revisions {
b4a0: 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20  ','}]')..return 
b4b0: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
b4c0: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
b4d0: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09  obackslashes {..
b4e0: 20 20 20 20 53 45 4c 45 43 54 0a 09 20 20 20 20      SELECT..    
b4f0: 44 49 53 54 49 4e 43 54 20 4c 2e 6e 61 6d 65 0a  DISTINCT L.name.
b500: 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69  .    FROM   revi
b510: 73 69 6f 6e 20 52 2c 20 73 79 6d 62 6f 6c 20 4c  sion R, symbol L
b520: 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72  ..    WHERE  R.r
b530: 69 64 20 69 6e 20 24 74 68 65 73 65 74 20 20 20  id in $theset   
b540: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
b550: 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66   to revisions of
b560: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41   interest..    A
b570: 4e 44 20 20 20 20 4c 2e 73 69 64 20 3d 20 52 2e  ND    L.sid = R.
b580: 6c 6f 64 20 20 20 20 20 20 20 20 20 20 20 2d 2d  lod           --
b590: 20 47 65 74 20 6c 6f 64 20 73 79 6d 62 6f 6c 20   Get lod symbol 
b5a0: 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 7d 5d 5d  of revision..}]]
b5b0: 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23  .    }.}..# # ##
b5c0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
b5d0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
b5e0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23  # ##############
b5f0: 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65  #######.## Helpe
b600: 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d  r singleton. Com
b610: 6d 61 6e 64 73 20 66 6f 72 20 74 61 67 20 73 79  mands for tag sy
b620: 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 2e  mbol changesets.
b630: 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76  ..snit::type ::v
b640: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
b650: 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a  t::cvs::project:
b660: 3a 72 65 76 3a 3a 73 79 6d 3a 3a 74 61 67 20 7b  :rev::sym::tag {
b670: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
b680: 62 79 72 65 76 69 73 69 6f 6e 20 7b 7d 20 7b 20  byrevision {} { 
b690: 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74  return 0 }.    t
b6a0: 79 70 65 6d 65 74 68 6f 64 20 62 79 73 79 6d 62  ypemethod bysymb
b6b0: 6f 6c 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e  ol   {} { return
b6c0: 20 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74   1 }.    typemet
b6d0: 68 6f 64 20 69 73 74 61 67 20 20 20 20 20 20 7b  hod istag      {
b6e0: 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20  } { return 1 }. 
b6f0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73     typemethod is
b700: 62 72 61 6e 63 68 20 20 20 7b 7d 20 7b 20 72 65  branch   {} { re
b710: 74 75 72 6e 20 30 20 7d 0a 0a 20 20 20 20 74 79  turn 0 }..    ty
b720: 70 65 6d 65 74 68 6f 64 20 73 74 72 20 7b 74 61  pemethod str {ta
b730: 67 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69  g} {..struct::li
b740: 73 74 20 61 73 73 69 67 6e 20 5b 73 74 61 74 65  st assign [state
b750: 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45   run {..    SELE
b760: 43 54 20 53 2e 6e 61 6d 65 2c 20 46 2e 6e 61 6d  CT S.name, F.nam
b770: 65 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20 20 46  e, P.name..    F
b780: 52 4f 4d 20 20 20 74 61 67 20 54 2c 20 73 79 6d  ROM   tag T, sym
b790: 62 6f 6c 20 53 2c 20 66 69 6c 65 20 46 2c 20 70  bol S, file F, p
b7a0: 72 6f 6a 65 63 74 20 50 0a 09 20 20 20 20 57 48  roject P..    WH
b7b0: 45 52 45 20 20 54 2e 74 69 64 20 3d 20 24 74 61  ERE  T.tid = $ta
b7c0: 67 20 20 20 2d 2d 20 46 69 6e 64 20 73 70 65 63  g   -- Find spec
b7d0: 69 66 69 65 64 20 74 61 67 0a 09 20 20 20 20 41  ified tag..    A
b7e0: 4e 44 20 20 20 20 46 2e 66 69 64 20 3d 20 54 2e  ND    F.fid = T.
b7f0: 66 69 64 20 20 2d 2d 20 47 65 74 20 66 69 6c 65  fid  -- Get file
b800: 20 6f 66 20 74 61 67 0a 09 20 20 20 20 41 4e 44   of tag..    AND
b810: 20 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 69      P.pid = F.pi
b820: 64 20 20 2d 2d 20 47 65 74 20 70 72 6f 6a 65 63  d  -- Get projec
b830: 74 20 6f 66 20 66 69 6c 65 0a 09 20 20 20 20 41  t of file..    A
b840: 4e 44 20 20 20 20 53 2e 73 69 64 20 3d 20 54 2e  ND    S.sid = T.
b850: 73 69 64 20 20 2d 2d 20 47 65 74 20 73 79 6d 62  sid  -- Get symb
b860: 6f 6c 20 6f 66 20 74 61 67 0a 09 7d 5d 20 73 6e  ol of tag..}] sn
b870: 61 6d 65 20 66 6e 61 6d 65 20 70 6e 61 6d 65 0a  ame fname pname.
b880: 09 72 65 74 75 72 6e 20 22 24 70 6e 61 6d 65 2f  .return "$pname/
b890: 54 27 24 7b 73 6e 61 6d 65 7d 27 3a 3a 24 66 6e  T'${sname}'::$fn
b8a0: 61 6d 65 22 0a 20 20 20 20 7d 0a 0a 20 20 20 20  ame".    }..    
b8b0: 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20  # result = list 
b8c0: 28 6d 69 6e 74 69 6d 65 2c 20 6d 61 78 74 69 6d  (mintime, maxtim
b8d0: 65 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  e).    typemetho
b8e0: 64 20 74 69 6d 65 72 61 6e 67 65 20 7b 74 61 67  d timerange {tag
b8f0: 73 7d 20 7b 0a 09 23 20 54 68 65 20 72 61 6e 67  s} {..# The rang
b900: 65 20 69 73 20 64 65 66 69 6e 65 64 20 61 73 20  e is defined as 
b910: 74 68 65 20 72 61 6e 67 65 20 6f 66 20 74 68 65  the range of the
b920: 20 72 65 76 69 73 69 6f 6e 73 20 74 68 65 20 74   revisions the t
b930: 61 67 73 0a 09 23 20 61 72 65 20 61 74 74 61 63  ags..# are attac
b940: 68 65 64 20 74 6f 2e 0a 0a 09 73 65 74 20 74 68  hed to....set th
b950: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 74 61  eset ('[join $ta
b960: 67 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74  gs {','}]')..ret
b970: 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b  urn [state run [
b980: 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64  subst -nocommand
b990: 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73  s -nobackslashes
b9a0: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 4d   {..    SELECT M
b9b0: 49 4e 28 52 2e 64 61 74 65 29 2c 20 4d 41 58 28  IN(R.date), MAX(
b9c0: 52 2e 64 61 74 65 29 0a 09 20 20 20 20 46 52 4f  R.date)..    FRO
b9d0: 4d 20 20 20 74 61 67 20 54 2c 20 72 65 76 69 73  M   tag T, revis
b9e0: 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45  ion R..    WHERE
b9f0: 20 20 54 2e 74 69 64 20 49 4e 20 24 74 68 65 73    T.tid IN $thes
ba00: 65 74 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20  et  -- Restrict 
ba10: 74 6f 20 74 61 67 73 20 6f 66 20 69 6e 74 65 72  to tags of inter
ba20: 65 73 74 0a 20 20 20 20 20 20 20 20 20 20 20 20  est.            
ba30: 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20 54  AND    R.rid = T
ba40: 2e 72 65 76 20 20 20 20 20 2d 2d 20 53 65 6c 65  .rev     -- Sele
ba50: 63 74 20 74 61 67 20 70 61 72 65 6e 74 20 72 65  ct tag parent re
ba60: 76 69 73 69 6f 6e 73 0a 09 7d 5d 5d 0a 20 20 20  visions..}]].   
ba70: 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76   }..    # var(dv
ba80: 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d  ) = dict (item -
ba90: 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20  > list (item)), 
baa0: 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79  item  = list (ty
bab0: 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d  pe id).    typem
bac0: 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73  ethod successors
bad0: 20 7b 64 76 20 74 61 67 73 7d 20 7b 0a 09 23 20   {dv tags} {..# 
bae0: 54 61 67 73 20 68 61 76 65 20 6e 6f 20 73 75 63  Tags have no suc
baf0: 63 65 73 73 6f 72 73 2e 0a 09 72 65 74 75 72 6e  cessors...return
bb00: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65  .    }..    # re
bb10: 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28 69  sult = 4-list (i
bb20: 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 20 6e  temtype itemid n
bb30: 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 78 74  extitemtype next
bb40: 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 20  itemid ...).    
bb50: 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 73  typemethod loops
bb60: 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20 54 61 67   {tags} {..# Tag
bb70: 73 20 68 61 76 65 20 6e 6f 20 73 75 63 63 65 73  s have no succes
bb80: 73 6f 72 73 2c 20 74 68 65 72 65 66 6f 72 65 20  sors, therefore 
bb90: 63 61 6e 6e 6f 74 20 63 61 75 73 65 20 6c 6f 6f  cannot cause loo
bba0: 70 73 0a 09 72 65 74 75 72 6e 20 7b 7d 0a 20 20  ps..return {}.  
bbb0: 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c    }..    # resul
bbc0: 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65  t = list (change
bbd0: 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79 70 65  set-id).    type
bbe0: 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63 65 73  method cs_succes
bbf0: 73 6f 72 73 20 7b 74 61 67 73 7d 20 7b 0a 09 23  sors {tags} {..#
bc00: 20 54 61 67 73 20 68 61 76 65 20 6e 6f 20 73 75   Tags have no su
bc10: 63 63 65 73 73 6f 72 73 2e 0a 09 72 65 74 75 72  ccessors...retur
bc20: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72  n.    }..    # r
bc30: 65 73 75 6c 74 20 3d 20 73 79 6d 62 6f 6c 20 6e  esult = symbol n
bc40: 61 6d 65 0a 20 20 20 20 74 79 70 65 6d 65 74 68  ame.    typemeth
bc50: 6f 64 20 63 73 5f 6c 6f 64 20 7b 74 61 67 73 7d  od cs_lod {tags}
bc60: 20 7b 0a 09 23 20 44 65 74 65 72 6d 69 6e 65 73   {..# Determines
bc70: 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65   the name of the
bc80: 20 73 79 6d 62 6f 6c 20 77 68 69 63 68 20 69 73   symbol which is
bc90: 20 74 68 65 20 6c 69 6e 65 20 6f 66 0a 09 23 20   the line of..# 
bca0: 64 65 76 65 6c 6f 70 6d 65 6e 74 20 66 6f 72 20  development for 
bcb0: 74 68 65 20 74 61 67 73 20 69 6e 20 61 20 63 68  the tags in a ch
bcc0: 61 6e 67 65 73 65 74 2e 0a 0a 09 73 65 74 20 74  angeset....set t
bcd0: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 74  heset ('[join $t
bce0: 61 67 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65  ags {','}]')..re
bcf0: 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20  turn [state run 
bd00: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e  [subst -nocomman
bd10: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65  ds -nobackslashe
bd20: 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 0a  s {..    SELECT.
bd30: 09 20 20 20 20 44 49 53 54 49 4e 43 54 20 4c 2e  .    DISTINCT L.
bd40: 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20  name..    FROM  
bd50: 20 74 61 67 20 54 2c 20 73 79 6d 62 6f 6c 20 4c   tag T, symbol L
bd60: 0a 09 20 20 20 20 57 48 45 52 45 20 20 54 2e 74  ..    WHERE  T.t
bd70: 69 64 20 69 6e 20 24 74 68 65 73 65 74 20 20 20  id in $theset   
bd80: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
bd90: 20 74 6f 20 74 61 67 73 20 6f 66 20 69 6e 74 65   to tags of inte
bda0: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rest..    AND   
bdb0: 20 4c 2e 73 69 64 20 3d 20 54 2e 6c 6f 64 20 20   L.sid = T.lod  
bdc0: 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20           -- Get 
bdd0: 6c 6f 64 20 73 79 6d 62 6f 6c 20 6f 66 20 74 61  lod symbol of ta
bde0: 67 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 7d 0a 0a  g..}]].    }.}..
bdf0: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
be00: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
be10: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
be20: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23  #############.##
be30: 20 48 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f   Helper singleto
be40: 6e 2e 20 43 6f 6d 6d 61 6e 64 73 20 66 6f 72 20  n. Commands for 
be50: 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68  branch symbol ch
be60: 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e 69 74 3a  angesets...snit:
be70: 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73  :type ::vc::foss
be80: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
be90: 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a 73  :project::rev::s
bea0: 79 6d 3a 3a 62 72 61 6e 63 68 20 7b 0a 20 20 20  ym::branch {.   
beb0: 20 74 79 70 65 6d 65 74 68 6f 64 20 62 79 72 65   typemethod byre
bec0: 76 69 73 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75  vision {} { retu
bed0: 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d  rn 0 }.    typem
bee0: 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20  ethod bysymbol  
bef0: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d   {} { return 1 }
bf00: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
bf10: 69 73 74 61 67 20 20 20 20 20 20 7b 7d 20 7b 20  istag      {} { 
bf20: 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74  return 0 }.    t
bf30: 79 70 65 6d 65 74 68 6f 64 20 69 73 62 72 61 6e  ypemethod isbran
bf40: 63 68 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e  ch   {} { return
bf50: 20 31 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65   1 }..    typeme
bf60: 74 68 6f 64 20 73 74 72 20 7b 62 72 61 6e 63 68  thod str {branch
bf70: 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73  } {..struct::lis
bf80: 74 20 61 73 73 69 67 6e 20 5b 73 74 61 74 65 20  t assign [state 
bf90: 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  run {..    SELEC
bfa0: 54 20 53 2e 6e 61 6d 65 2c 20 46 2e 6e 61 6d 65  T S.name, F.name
bfb0: 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52  , P.name..    FR
bfc0: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 73  OM   branch B, s
bfd0: 79 6d 62 6f 6c 20 53 2c 20 66 69 6c 65 20 46 2c  ymbol S, file F,
bfe0: 20 70 72 6f 6a 65 63 74 20 50 0a 09 20 20 20 20   project P..    
bff0: 57 48 45 52 45 20 20 42 2e 62 69 64 20 3d 20 24  WHERE  B.bid = $
c000: 62 72 61 6e 63 68 20 20 2d 2d 20 46 69 6e 64 20  branch  -- Find 
c010: 73 70 65 63 69 66 69 65 64 20 62 72 61 6e 63 68  specified branch
c020: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46 2e 66  ..    AND    F.f
c030: 69 64 20 3d 20 42 2e 66 69 64 20 20 20 20 2d 2d  id = B.fid    --
c040: 20 47 65 74 20 66 69 6c 65 20 6f 66 20 62 72 61   Get file of bra
c050: 6e 63 68 0a 09 20 20 20 20 41 4e 44 20 20 20 20  nch..    AND    
c060: 50 2e 70 69 64 20 3d 20 46 2e 70 69 64 20 20 20  P.pid = F.pid   
c070: 20 2d 2d 20 47 65 74 20 70 72 6f 6a 65 63 74 20   -- Get project 
c080: 6f 66 20 66 69 6c 65 0a 09 20 20 20 20 41 4e 44  of file..    AND
c090: 20 20 20 20 53 2e 73 69 64 20 3d 20 42 2e 73 69      S.sid = B.si
c0a0: 64 20 20 20 20 2d 2d 20 47 65 74 20 73 79 6d 62  d    -- Get symb
c0b0: 6f 6c 20 6f 66 20 62 72 61 6e 63 68 0a 09 7d 5d  ol of branch..}]
c0c0: 20 73 6e 61 6d 65 20 66 6e 61 6d 65 20 70 6e 61   sname fname pna
c0d0: 6d 65 0a 09 72 65 74 75 72 6e 20 22 24 70 6e 61  me..return "$pna
c0e0: 6d 65 2f 42 27 24 7b 73 6e 61 6d 65 7d 27 3a 3a  me/B'${sname}'::
c0f0: 24 66 6e 61 6d 65 22 0a 20 20 20 20 7d 0a 0a 20  $fname".    }.. 
c100: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69     # result = li
c110: 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20 6d 61 78  st (mintime, max
c120: 74 69 6d 65 29 0a 20 20 20 20 74 79 70 65 6d 65  time).    typeme
c130: 74 68 6f 64 20 74 69 6d 65 72 61 6e 67 65 20 7b  thod timerange {
c140: 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 23 20 54  branches} {..# T
c150: 68 65 20 72 61 6e 67 65 20 6f 66 20 61 20 62 72  he range of a br
c160: 61 6e 63 68 20 69 73 20 64 65 66 69 6e 65 64 20  anch is defined 
c170: 61 73 20 74 68 65 20 72 61 6e 67 65 20 6f 66 20  as the range of 
c180: 74 68 65 0a 09 23 20 72 65 76 69 73 69 6f 6e 73  the..# revisions
c190: 20 74 68 65 20 62 72 61 6e 63 68 65 73 20 61 72   the branches ar
c1a0: 65 20 73 70 61 77 6e 65 64 20 62 79 2e 20 4e 4f  e spawned by. NO
c1b0: 54 45 20 68 6f 77 65 76 65 72 20 74 68 61 74 20  TE however that 
c1c0: 74 68 65 0a 09 23 20 62 72 61 6e 63 68 65 73 20  the..# branches 
c1d0: 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 20  associated with 
c1e0: 61 20 64 65 74 61 63 68 65 64 20 4e 54 44 42 20  a detached NTDB 
c1f0: 77 69 6c 6c 20 68 61 76 65 20 6e 6f 20 72 6f 6f  will have no roo
c200: 74 0a 09 23 20 73 70 61 77 6e 69 6e 67 20 74 68  t..# spawning th
c210: 65 6d 2c 20 68 65 6e 63 65 20 74 68 65 79 20 68  em, hence they h
c220: 61 76 65 20 6e 6f 20 72 65 61 6c 20 74 69 6d 65  ave no real time
c230: 72 61 6e 67 65 20 61 6e 79 0a 09 23 20 6c 6f 6e  range any..# lon
c240: 67 65 72 2e 20 42 79 20 75 73 69 6e 67 20 30 20  ger. By using 0 
c250: 77 65 20 70 75 74 20 74 68 65 6d 20 69 6e 20 66  we put them in f
c260: 72 6f 6e 74 20 6f 66 20 65 76 65 72 79 74 68 69  ront of everythi
c270: 6e 67 20 65 6c 73 65 2c 0a 09 23 20 61 73 20 74  ng else,..# as t
c280: 68 65 79 20 6c 6f 67 69 63 61 6c 6c 79 20 61 72  hey logically ar
c290: 65 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20  e....set theset 
c2a0: 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63 68 65  ('[join $branche
c2b0: 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75  s {','}]')..retu
c2c0: 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73  rn [state run [s
c2d0: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73  ubst -nocommands
c2e0: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20   -nobackslashes 
c2f0: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 49 46  {..    SELECT IF
c300: 4e 55 4c 4c 28 4d 49 4e 28 52 2e 64 61 74 65 29  NULL(MIN(R.date)
c310: 2c 30 29 2c 20 49 46 4e 55 4c 4c 28 4d 41 58 28  ,0), IFNULL(MAX(
c320: 52 2e 64 61 74 65 29 2c 30 29 0a 09 20 20 20 20  R.date),0)..    
c330: 46 52 4f 4d 20 20 62 72 61 6e 63 68 20 42 2c 20  FROM  branch B, 
c340: 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20  revision R..    
c350: 57 48 45 52 45 20 42 2e 62 69 64 20 49 4e 20 24  WHERE B.bid IN $
c360: 74 68 65 73 65 74 20 20 20 2d 2d 20 52 65 73 74  theset   -- Rest
c370: 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73  rict to branches
c380: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20 20   of interest.   
c390: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 52           AND   R
c3a0: 2e 72 69 64 20 3d 20 42 2e 72 6f 6f 74 20 20 20  .rid = B.root   
c3b0: 20 20 2d 2d 20 53 65 6c 65 63 74 20 62 72 61 6e    -- Select bran
c3c0: 63 68 20 70 61 72 65 6e 74 20 72 65 76 69 73 69  ch parent revisi
c3d0: 6f 6e 73 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a  ons..}]].    }..
c3e0: 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 34      # result = 4
c3f0: 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70 65 20  -list (itemtype 
c400: 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65 6d 74  itemid nextitemt
c410: 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64 20 2e  ype nextitemid .
c420: 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68  ..).    typemeth
c430: 6f 64 20 6c 6f 6f 70 73 20 7b 62 72 61 6e 63 68  od loops {branch
c440: 65 73 7d 20 7b 0a 09 23 20 4e 6f 74 65 3a 20 52  es} {..# Note: R
c450: 65 76 69 73 69 6f 6e 73 20 61 6e 64 20 74 61 67  evisions and tag
c460: 73 20 63 61 6e 6e 6f 74 20 63 61 75 73 65 20 74  s cannot cause t
c470: 68 65 20 6c 6f 6f 70 2e 20 42 65 69 6e 67 20 6f  he loop. Being o
c480: 66 20 61 0a 09 23 20 66 75 6e 64 61 6d 65 6e 74  f a..# fundament
c490: 61 6c 6c 79 20 64 69 66 66 65 72 65 6e 74 20 74  ally different t
c4a0: 79 70 65 20 74 68 65 79 20 63 61 6e 6e 6f 74 20  ype they cannot 
c4b0: 62 65 20 69 6e 20 74 68 65 20 69 6e 63 6f 6d 69  be in the incomi
c4c0: 6e 67 0a 09 23 20 73 65 74 20 6f 66 20 69 64 73  ng..# set of ids
c4d0: 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28  ....set theset (
c4e0: 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63 68 65 73  '[join $branches
c4f0: 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72   {','}]')..retur
c500: 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75  n [state run [su
c510: 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20  bst -nocommands 
c520: 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b  -nobackslashes {
c530: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62  ..    SELECT B.b
c540: 69 64 2c 20 42 58 2e 62 69 64 0a 09 20 20 20 20  id, BX.bid..    
c550: 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c  FROM   branch B,
c560: 20 70 72 65 66 65 72 65 64 70 61 72 65 6e 74 20   preferedparent 
c570: 50 2c 20 62 72 61 6e 63 68 20 42 58 0a 09 20 20  P, branch BX..  
c580: 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 49    WHERE  B.bid I
c590: 4e 20 24 74 68 65 73 65 74 20 20 20 2d 2d 20 52  N $theset   -- R
c5a0: 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63  estrict to branc
c5b0: 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  hes of interest.
c5c0: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 73 69  .    AND    B.si
c5d0: 64 20 3d 20 50 2e 70 69 64 20 20 20 20 20 20 2d  d = P.pid      -
c5e0: 2d 20 47 65 74 20 74 68 65 20 70 72 65 66 65 72  - Get the prefer
c5f0: 65 64 20 62 72 61 6e 63 68 65 73 20 76 69 61 0a  ed branches via.
c600: 09 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e 73  .    AND    BX.s
c610: 69 64 20 3d 20 50 2e 73 69 64 20 20 20 20 20 2d  id = P.sid     -
c620: 2d 20 74 68 65 20 62 72 61 6e 63 68 20 73 79 6d  - the branch sym
c630: 62 6f 6c 73 0a 09 20 20 20 20 41 4e 44 20 20 20  bols..    AND   
c640: 20 42 58 2e 62 69 64 20 49 4e 20 24 74 68 65 73   BX.bid IN $thes
c650: 65 74 20 20 2d 2d 20 4c 6f 6f 70 0a 09 7d 5d 5d  et  -- Loop..}]]
c660: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 76 61  .    }..    # va
c670: 72 28 64 76 29 20 3d 20 64 69 63 74 20 28 69 74  r(dv) = dict (it
c680: 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69 74 65 6d  em -> list (item
c690: 29 29 2c 20 69 74 65 6d 20 20 3d 20 6c 69 73 74  )), item  = list
c6a0: 20 28 74 79 70 65 20 69 64 29 0a 20 20 20 20 74   (type id).    t
c6b0: 79 70 65 6d 65 74 68 6f 64 20 73 75 63 63 65 73  ypemethod succes
c6c0: 73 6f 72 73 20 7b 64 76 20 62 72 61 6e 63 68 65  sors {dv branche
c6d0: 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 64  s} {..upvar 1 $d
c6e0: 76 20 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 09  v dependencies..
c6f0: 23 20 54 68 65 20 66 69 72 73 74 20 72 65 76 69  # The first revi
c700: 73 69 6f 6e 20 63 6f 6d 6d 69 74 74 65 64 20 6f  sion committed o
c710: 6e 20 61 20 62 72 61 6e 63 68 2c 20 61 6e 64 20  n a branch, and 
c720: 61 6c 6c 20 62 72 61 6e 63 68 65 73 0a 09 23 20  all branches..# 
c730: 61 6e 64 20 74 61 67 73 20 77 68 69 63 68 20 68  and tags which h
c740: 61 76 65 20 69 74 20 61 73 20 74 68 65 69 72 20  ave it as their 
c750: 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 20  prefered parent 
c760: 61 72 65 20 74 68 65 0a 09 23 20 73 75 63 63 65  are the..# succe
c770: 73 73 6f 72 73 20 6f 66 20 61 20 62 72 61 6e 63  ssors of a branc
c780: 68 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20  h....set theset 
c790: 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63 68 65  ('[join $branche
c7a0: 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 66 6f 72 65  s {','}]')..fore
c7b0: 61 63 68 20 7b 62 69 64 20 63 68 69 6c 64 7d 20  ach {bid child} 
c7c0: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
c7d0: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
c7e0: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09  obackslashes {..
c7f0: 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64      SELECT B.bid
c800: 2c 20 52 2e 72 69 64 0a 09 20 20 20 20 46 52 4f  , R.rid..    FRO
c810: 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 72 65  M   branch B, re
c820: 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48  vision R..    WH
c830: 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74  ERE  B.bid IN $t
c840: 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73  heset     -- Res
c850: 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65  trict to branche
c860: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
c870: 20 20 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73     AND    B.firs
c880: 74 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 2d  t = R.rid      -
c890: 2d 20 47 65 74 20 66 69 72 73 74 20 72 65 76 69  - Get first revi
c8a0: 73 69 6f 6e 20 6f 6e 20 74 68 65 20 62 72 61 6e  sion on the bran
c8b0: 63 68 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c  ch..}]] {..    l
c8c0: 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63  append dependenc
c8d0: 69 65 73 28 5b 6c 69 73 74 20 73 79 6d 3a 3a 62  ies([list sym::b
c8e0: 72 61 6e 63 68 20 24 62 69 64 5d 29 20 5b 6c 69  ranch $bid]) [li
c8f0: 73 74 20 72 65 76 20 24 63 68 69 6c 64 5d 0a 09  st rev $child]..
c900: 7d 0a 09 66 6f 72 65 61 63 68 20 7b 62 69 64 20  }..foreach {bid 
c910: 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75  child} [state ru
c920: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
c930: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
c940: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  hes {..    SELEC
c950: 54 20 42 2e 62 69 64 2c 20 42 58 2e 62 69 64 0a  T B.bid, BX.bid.
c960: 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e  .    FROM   bran
c970: 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 70 61  ch B, preferedpa
c980: 72 65 6e 74 20 50 2c 20 62 72 61 6e 63 68 20 42  rent P, branch B
c990: 58 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e  X..    WHERE  B.
c9a0: 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  bid IN $theset  
c9b0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
c9c0: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e  o branches of in
c9d0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
c9e0: 20 20 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 64     B.sid = P.pid
c9f0: 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 73          -- Get s
ca00: 75 62 6f 72 64 69 6e 61 74 65 20 62 72 61 6e 63  ubordinate branc
ca10: 68 65 73 20 76 69 61 20 74 68 65 0a 09 20 20 20  hes via the..   
ca20: 20 41 4e 44 20 20 20 20 42 58 2e 73 69 64 20 3d   AND    BX.sid =
ca30: 20 50 2e 73 69 64 20 20 20 20 20 20 20 2d 2d 20   P.sid       -- 
ca40: 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 73  prefered parents
ca50: 20 6f 66 20 74 68 65 69 72 20 73 79 6d 62 6f 6c   of their symbol
ca60: 73 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61  s..}]] {..    la
ca70: 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69  ppend dependenci
ca80: 65 73 28 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 72  es([list sym::br
ca90: 61 6e 63 68 20 24 62 69 64 5d 29 20 5b 6c 69 73  anch $bid]) [lis
caa0: 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 63  t sym::branch $c
cab0: 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 61 63  hild]..}..foreac
cac0: 68 20 7b 62 69 64 20 63 68 69 6c 64 7d 20 5b 73  h {bid child} [s
cad0: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
cae0: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
caf0: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
cb00: 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20    SELECT B.bid, 
cb10: 54 2e 74 69 64 0a 09 20 20 20 20 46 52 4f 4d 20  T.tid..    FROM 
cb20: 20 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66    branch B, pref
cb30: 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20 74 61  eredparent P, ta
cb40: 67 20 54 0a 09 20 20 20 20 57 48 45 52 45 20 20  g T..    WHERE  
cb50: 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74  B.bid IN $theset
cb60: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
cb70: 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20   to branches of 
cb80: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e  interest..    AN
cb90: 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e 70  D    B.sid = P.p
cba0: 69 64 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74  id        -- Get
cbb0: 20 73 75 62 6f 72 64 69 6e 61 74 65 20 74 61 67   subordinate tag
cbc0: 73 20 76 69 61 20 74 68 65 0a 09 20 20 20 20 41  s via the..    A
cbd0: 4e 44 20 20 20 20 54 2e 73 69 64 20 3d 20 50 2e  ND    T.sid = P.
cbe0: 73 69 64 20 20 20 20 20 20 20 20 2d 2d 20 70 72  sid        -- pr
cbf0: 65 66 65 72 65 64 20 70 61 72 65 6e 74 73 20 6f  efered parents o
cc00: 66 20 74 68 65 69 72 20 73 79 6d 62 6f 6c 73 0a  f their symbols.
cc10: 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70  .}]] {..    lapp
cc20: 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73  end dependencies
cc30: 28 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e  ([list sym::bran
cc40: 63 68 20 24 62 69 64 5d 29 20 5b 6c 69 73 74 20  ch $bid]) [list 
cc50: 73 79 6d 3a 3a 74 61 67 20 24 63 68 69 6c 64 5d  sym::tag $child]
cc60: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ..}..return.    
cc70: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20  }..    # result 
cc80: 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65  = list (changese
cc90: 74 2d 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65  t-id).    typeme
cca0: 74 68 6f 64 20 63 73 5f 73 75 63 63 65 73 73 6f  thod cs_successo
ccb0: 72 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a  rs {branches} {.
ccc0: 20 20 20 20 20 20 20 20 23 20 54 68 69 73 20 69          # This i
ccd0: 73 20 61 20 76 61 72 69 61 6e 74 20 6f 66 20 27  s a variant of '
cce0: 73 75 63 63 65 73 73 6f 72 73 27 20 77 68 69 63  successors' whic
ccf0: 68 20 6d 61 70 73 20 74 68 65 20 6c 6f 77 2d 6c  h maps the low-l
cd00: 65 76 65 6c 0a 20 20 20 20 20 20 20 20 23 20 64  evel.        # d
cd10: 61 74 61 20 64 69 72 65 63 74 6c 79 20 74 6f 20  ata directly to 
cd20: 74 68 65 20 61 73 73 6f 63 69 61 74 65 64 20 63  the associated c
cd30: 68 61 6e 67 65 73 65 74 73 2e 20 49 2e 65 2e 20  hangesets. I.e. 
cd40: 69 6e 73 74 65 61 64 0a 20 20 20 20 20 20 20 20  instead.        
cd50: 23 20 6d 69 6c 6c 69 6f 6e 73 20 6f 66 20 64 65  # millions of de
cd60: 70 65 6e 64 65 6e 63 79 20 70 61 69 72 73 20 28  pendency pairs (
cd70: 69 6e 20 65 78 74 72 65 6d 65 20 63 61 73 65 73  in extreme cases
cd80: 20 28 45 78 61 6d 70 6c 65 3a 20 54 63 6c 0a 20   (Example: Tcl. 
cd90: 20 20 20 20 20 20 20 23 20 43 56 53 29 29 20 77         # CVS)) w
cda0: 65 20 72 65 74 75 72 6e 20 61 20 76 65 72 79 20  e return a very 
cdb0: 73 68 6f 72 74 20 61 6e 64 20 6d 75 63 68 20 6d  short and much m
cdc0: 6f 72 65 20 6d 61 6e 61 67 65 61 62 6c 65 20 6c  ore manageable l
cdd0: 69 73 74 0a 20 20 20 20 20 20 20 20 23 20 6f 66  ist.        # of
cde0: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09 73   changesets....s
cdf0: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
ce00: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27  n $branches {','
ce10: 7d 5d 27 29 0a 20 20 20 20 20 20 20 20 72 65 74  }]').        ret
ce20: 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b  urn [state run [
ce30: 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64  subst -nocommand
ce40: 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73  s -nobackslashes
ce50: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43   {..    SELECT C
ce60: 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  .cid..    FROM  
ce70: 20 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73   branch B, revis
ce80: 69 6f 6e 20 52 2c 20 63 73 69 74 65 6d 20 43 49  ion R, csitem CI
ce90: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20  , changeset C.. 
cea0: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20     WHERE  B.bid 
ceb0: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
cec0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72  - Restrict to br
ced0: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65  anches of intere
cee0: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  st..    AND    B
cef0: 2e 66 69 72 73 74 20 3d 20 52 2e 72 69 64 09 2d  .first = R.rid.-
cf00: 2d 20 47 65 74 20 66 69 72 73 74 20 72 65 76 69  - Get first revi
cf10: 73 69 6f 6e 20 6f 6e 20 74 68 65 20 62 72 61 6e  sion on the bran
cf20: 63 68 0a 20 20 20 20 20 20 20 20 20 20 20 20 41  ch.            A
cf30: 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20 52  ND    CI.iid = R
cf40: 2e 72 69 64 20 20 20 20 20 20 20 2d 2d 20 53 65  .rid       -- Se
cf50: 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73  lect all changes
cf60: 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 20  ets.            
cf70: 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43  AND    C.cid = C
cf80: 49 2e 63 69 64 09 2d 2d 20 63 6f 6e 74 61 69 6e  I.cid.-- contain
cf90: 69 6e 67 20 74 68 69 73 20 72 65 76 69 73 69 6f  ing this revisio
cfa0: 6e 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e  n.            AN
cfb0: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30 09  D    C.type = 0.
cfc0: 09 2d 2d 20 77 68 69 63 68 20 61 72 65 20 72 65  .-- which are re
cfd0: 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74  vision changeset
cfe0: 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20  s.    UNION..   
cff0: 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20   SELECT C.cid.. 
d000: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68     FROM   branch
d010: 20 42 2c 20 70 72 65 66 65 72 65 64 70 61 72 65   B, preferedpare
d020: 6e 74 20 50 2c 20 62 72 61 6e 63 68 20 42 58 2c  nt P, branch BX,
d030: 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e   csitem CI, chan
d040: 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45  geset C..    WHE
d050: 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68  RE  B.bid IN $th
d060: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74  eset     -- Rest
d070: 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73  rict to branches
d080: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
d090: 20 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20 3d    AND    B.sid =
d0a0: 20 50 2e 70 69 64 09 2d 2d 20 47 65 74 20 73 75   P.pid.-- Get su
d0b0: 62 6f 72 64 69 6e 61 74 65 20 62 72 61 6e 63 68  bordinate branch
d0c0: 65 73 20 76 69 61 20 74 68 65 0a 09 20 20 20 20  es via the..    
d0d0: 41 4e 44 20 20 20 20 42 58 2e 73 69 64 20 3d 20  AND    BX.sid = 
d0e0: 50 2e 73 69 64 09 2d 2d 20 70 72 65 66 65 72 65  P.sid.-- prefere
d0f0: 64 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68 65  d parents of the
d100: 69 72 20 73 79 6d 62 6f 6c 73 0a 20 20 20 20 20  ir symbols.     
d110: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49         AND    CI
d120: 2e 69 69 64 20 3d 20 42 58 2e 62 69 64 20 20 20  .iid = BX.bid   
d130: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c     -- Select all
d140: 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20   changesets.    
d150: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
d160: 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 2d 2d  .cid = CI.cid.--
d170: 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 20   containing the 
d180: 73 75 62 6f 72 64 69 6e 61 74 65 20 62 72 61 6e  subordinate bran
d190: 63 68 65 73 0a 20 20 20 20 20 20 20 20 20 20 20  ches.           
d1a0: 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d   AND    C.type =
d1b0: 20 32 09 09 2d 2d 20 77 68 69 63 68 20 61 72 65   2..-- which are
d1c0: 20 62 72 61 6e 63 68 20 63 68 61 6e 67 65 73 65   branch changese
d1d0: 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20  ts.    UNION..  
d1e0: 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09    SELECT C.cid..
d1f0: 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63      FROM   branc
d200: 68 20 42 2c 20 70 72 65 66 65 72 65 64 70 61 72  h B, preferedpar
d210: 65 6e 74 20 50 2c 20 74 61 67 20 54 2c 20 63 73  ent P, tag T, cs
d220: 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73  item CI, changes
d230: 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20  et C..    WHERE 
d240: 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65   B.bid IN $these
d250: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63  t     -- Restric
d260: 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66  t to branches of
d270: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41   interest..    A
d280: 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e  ND    B.sid = P.
d290: 70 69 64 09 2d 2d 20 47 65 74 20 73 75 62 6f 72  pid.-- Get subor
d2a0: 64 69 6e 61 74 65 20 74 61 67 73 20 76 69 61 20  dinate tags via 
d2b0: 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20  the..    AND    
d2c0: 54 2e 73 69 64 20 3d 20 50 2e 73 69 64 09 2d 2d  T.sid = P.sid.--
d2d0: 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74   prefered parent
d2e0: 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d 62 6f  s of their symbo
d2f0: 6c 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41  ls.            A
d300: 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20 54  ND    CI.iid = T
d310: 2e 74 69 64 20 20 20 20 20 20 20 2d 2d 20 53 65  .tid       -- Se
d320: 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73  lect all changes
d330: 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 20  ets.            
d340: 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43  AND    C.cid = C
d350: 49 2e 63 69 64 09 2d 2d 20 63 6f 6e 74 61 69 6e  I.cid.-- contain
d360: 69 6e 67 20 74 68 65 20 73 75 62 6f 72 64 69 6e  ing the subordin
d370: 61 74 65 20 74 61 67 73 0a 20 20 20 20 20 20 20  ate tags.       
d380: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79       AND    C.ty
d390: 70 65 20 3d 20 31 09 09 2d 2d 20 77 68 69 63 68  pe = 1..-- which
d3a0: 20 61 72 65 20 74 61 67 20 63 68 61 6e 67 65 73   are tag changes
d3b0: 65 74 73 0a 09 7d 5d 5d 0a 09 72 65 74 75 72 6e  ets..}]]..return
d3c0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65  .    }..    # re
d3d0: 73 75 6c 74 20 3d 20 73 79 6d 62 6f 6c 20 6e 61  sult = symbol na
d3e0: 6d 65 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  me.    typemetho
d3f0: 64 20 63 73 5f 6c 6f 64 20 7b 62 72 61 6e 63 68  d cs_lod {branch
d400: 65 73 7d 20 7b 0a 09 23 20 44 65 74 65 72 6d 69  es} {..# Determi
d410: 6e 65 73 20 74 68 65 20 6e 61 6d 65 20 6f 66 20  nes the name of 
d420: 74 68 65 20 73 79 6d 62 6f 6c 20 77 68 69 63 68  the symbol which
d430: 20 69 73 20 74 68 65 20 6c 69 6e 65 20 6f 66 0a   is the line of.
d440: 09 23 20 64 65 76 65 6c 6f 70 6d 65 6e 74 20 66  .# development f
d450: 6f 72 20 74 68 65 20 62 72 61 6e 63 68 65 73 20  or the branches 
d460: 69 6e 20 61 20 63 68 61 6e 67 65 73 65 74 2e 0a  in a changeset..
d470: 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b  ..set theset ('[
d480: 6a 6f 69 6e 20 24 62 72 61 6e 63 68 65 73 20 7b  join $branches {
d490: 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20  ','}]')..return 
d4a0: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
d4b0: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
d4c0: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09  obackslashes {..
d4d0: 20 20 20 20 53 45 4c 45 43 54 0a 09 20 20 20 20      SELECT..    
d4e0: 44 49 53 54 49 4e 43 54 20 4c 2e 6e 61 6d 65 0a  DISTINCT L.name.
d4f0: 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e  .    FROM   bran
d500: 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20 4c 0a 09  ch B, symbol L..
d510: 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64      WHERE  B.bid
d520: 20 69 6e 20 24 74 68 65 73 65 74 20 20 20 20 20   in $theset     
d530: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
d540: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e  o branches of in
d550: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
d560: 20 20 20 4c 2e 73 69 64 20 3d 20 42 2e 6c 6f 64     L.sid = B.lod
d570: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 47 65             -- Ge
d580: 74 20 6c 6f 64 20 73 79 6d 62 6f 6c 20 6f 66 20  t lod symbol of 
d590: 62 72 61 6e 63 68 0a 09 7d 5d 5d 0a 20 20 20 20  branch..}]].    
d5a0: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
d5b0: 64 20 6c 69 6d 69 74 73 20 7b 62 72 61 6e 63 68  d limits {branch
d5c0: 65 73 7d 20 7b 0a 09 23 20 4e 6f 74 65 73 2e 20  es} {..# Notes. 
d5d0: 54 68 69 73 20 6d 65 74 68 6f 64 20 65 78 69 73  This method exis
d5e0: 74 73 20 6f 6e 6c 79 20 66 6f 72 20 62 72 61 6e  ts only for bran
d5f0: 63 68 65 73 2e 20 49 74 20 69 73 20 6e 65 65 64  ches. It is need
d600: 65 64 20 74 6f 0a 09 23 20 67 65 74 20 64 65 74  ed to..# get det
d610: 61 69 6c 65 64 20 69 6e 66 6f 72 6d 61 74 69 6f  ailed informatio
d620: 6e 20 61 62 6f 75 74 20 61 20 62 61 63 6b 77 61  n about a backwa
d630: 72 64 20 62 72 61 6e 63 68 2e 20 49 74 20 64 6f  rd branch. It do
d640: 65 73 0a 09 23 20 6e 6f 74 20 61 70 70 6c 79 20  es..# not apply 
d650: 74 6f 20 74 61 67 73 2c 20 6e 6f 72 20 72 65 76  to tags, nor rev
d660: 69 73 69 6f 6e 73 2e 20 54 68 65 20 71 75 65 72  isions. The quer
d670: 69 65 73 20 63 61 6e 20 61 6c 73 6f 0a 09 23 20  ies can also..# 
d680: 72 65 73 74 72 69 63 74 20 74 68 65 6d 73 65 6c  restrict themsel
d690: 76 65 73 20 74 6f 20 74 68 65 20 72 65 76 69 73  ves to the revis
d6a0: 69 6f 6e 20 73 75 63 65 73 73 6f 72 73 2f 70 72  ion sucessors/pr
d6b0: 65 64 65 63 65 73 73 6f 72 73 0a 09 23 20 6f 66  edecessors..# of
d6c0: 20 62 72 61 6e 63 68 65 73 2c 20 61 73 20 6f 6e   branches, as on
d6d0: 6c 79 20 74 68 65 79 20 68 61 76 65 20 6f 72 64  ly they have ord
d6e0: 65 72 69 6e 67 20 64 61 74 61 20 61 6e 64 20 74  ering data and t
d6f0: 68 75 73 20 63 61 6e 0a 09 23 20 63 61 75 73 65  hus can..# cause
d700: 20 74 68 65 20 62 61 63 6b 77 61 72 64 6e 65 73   the backwardnes
d710: 73 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20  s....set theset 
d720: 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63 68 65  ('[join $branche
d730: 73 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 73 65 74  s {','}]')...set
d740: 20 6d 61 78 70 20 5b 73 74 61 74 65 20 72 75 6e   maxp [state run
d750: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
d760: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
d770: 65 73 20 7b 0a 09 20 20 20 20 2d 2d 20 6d 61 78  es {..    -- max
d780: 69 6d 61 6c 20 70 72 65 64 65 63 65 73 73 6f 72  imal predecessor
d790: 20 70 6f 73 69 74 69 6f 6e 20 70 65 72 20 62 72   position per br
d7a0: 61 6e 63 68 0a 09 20 20 20 20 53 45 4c 45 43 54  anch..    SELECT
d7b0: 20 42 2e 62 69 64 2c 20 4d 41 58 20 28 43 4f 2e   B.bid, MAX (CO.
d7c0: 70 6f 73 29 0a 09 20 20 20 20 46 52 4f 4d 20 20  pos)..    FROM  
d7d0: 20 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73   branch B, revis
d7e0: 69 6f 6e 20 52 2c 20 63 73 69 74 65 6d 20 43 49  ion R, csitem CI
d7f0: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63  , changeset C, c
d800: 73 6f 72 64 65 72 20 43 4f 0a 09 20 20 20 20 57  sorder CO..    W
d810: 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24  HERE  B.bid IN $
d820: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65  theset     -- Re
d830: 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68  strict to branch
d840: 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  es of interest..
d850: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 6f 6f      AND    B.roo
d860: 74 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 20  t = R.rid       
d870: 2d 2d 20 47 65 74 20 62 72 61 6e 63 68 20 72 6f  -- Get branch ro
d880: 6f 74 20 72 65 76 69 73 69 6f 6e 73 0a 09 20 20  ot revisions..  
d890: 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20    AND    CI.iid 
d8a0: 3d 20 52 2e 72 69 64 20 20 20 20 20 20 20 2d 2d  = R.rid       --
d8b0: 20 47 65 74 20 63 68 61 6e 67 65 73 65 74 73 20   Get changesets 
d8c0: 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 0a 09  containing the..
d8d0: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64      AND    C.cid
d8e0: 20 3d 20 43 49 2e 63 69 64 20 20 20 20 20 20 20   = CI.cid       
d8f0: 2d 2d 20 72 6f 6f 74 20 72 65 76 69 73 69 6f 6e  -- root revision
d900: 73 2c 20 77 68 69 63 68 20 61 72 65 0a 09 20 20  s, which are..  
d910: 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20    AND    C.type 
d920: 3d 20 30 20 20 20 20 20 20 20 20 20 20 20 2d 2d  = 0           --
d930: 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65   revision change
d940: 73 65 74 73 0a 09 20 20 20 20 41 4e 44 20 20 20  sets..    AND   
d950: 20 43 4f 2e 63 69 64 20 3d 20 43 2e 63 69 64 20   CO.cid = C.cid 
d960: 20 20 20 20 20 20 2d 2d 20 47 65 74 20 74 68 65        -- Get the
d970: 69 72 20 74 6f 70 6f 6c 6f 67 69 63 61 6c 20 6f  ir topological o
d980: 72 64 65 72 69 6e 67 0a 09 20 20 20 20 47 52 4f  rdering..    GRO
d990: 55 50 20 42 59 20 42 2e 62 69 64 0a 09 7d 5d 5d  UP BY B.bid..}]]
d9a0: 0a 0a 09 73 65 74 20 6d 69 6e 73 20 5b 73 74 61  ...set mins [sta
d9b0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
d9c0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
d9d0: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
d9e0: 2d 2d 20 6d 69 6e 69 6d 61 6c 20 73 75 63 63 65  -- minimal succe
d9f0: 73 73 6f 72 20 70 6f 73 69 74 69 6f 6e 20 70 65  ssor position pe
da00: 72 20 62 72 61 6e 63 68 0a 09 20 20 20 20 53 45  r branch..    SE
da10: 4c 45 43 54 20 42 2e 62 69 64 2c 20 4d 49 4e 20  LECT B.bid, MIN 
da20: 28 43 4f 2e 70 6f 73 29 0a 09 20 20 20 20 46 52  (CO.pos)..    FR
da30: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 72  OM   branch B, r
da40: 65 76 69 73 69 6f 6e 20 52 2c 20 63 73 69 74 65  evision R, csite
da50: 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20  m CI, changeset 
da60: 43 2c 20 63 73 6f 72 64 65 72 20 43 4f 0a 09 20  C, csorder CO.. 
da70: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20     WHERE  B.bid 
da80: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
da90: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72  - Restrict to br
daa0: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65  anches of intere
dab0: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  st..    AND    B
dac0: 2e 66 69 72 73 74 20 3d 20 52 2e 72 69 64 20 20  .first = R.rid  
dad0: 20 20 20 20 2d 2d 20 47 65 74 20 74 68 65 20 66      -- Get the f
dae0: 69 72 73 74 20 72 65 76 69 73 69 6f 6e 73 20 6f  irst revisions o
daf0: 6e 20 74 68 65 20 62 72 61 6e 63 68 65 73 0a 09  n the branches..
db00: 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69      AND    CI.ii
db10: 64 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 20  d = R.rid       
db20: 2d 2d 20 47 65 74 20 63 68 61 6e 67 65 73 65 74  -- Get changeset
db30: 73 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65  s containing the
db40: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63  ..    AND    C.c
db50: 69 64 20 3d 20 43 49 2e 63 69 64 09 2d 2d 20 66  id = CI.cid.-- f
db60: 69 72 73 74 20 72 65 76 69 73 69 6f 6e 73 2c 20  irst revisions, 
db70: 77 68 69 63 68 20 61 72 65 0a 09 20 20 20 20 41  which are..    A
db80: 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30  ND    C.type = 0
db90: 09 09 2d 2d 20 72 65 76 69 73 69 6f 6e 20 63 68  ..-- revision ch
dba0: 61 6e 67 65 73 65 74 73 0a 09 20 20 20 20 41 4e  angesets..    AN
dbb0: 44 20 20 20 20 43 4f 2e 63 69 64 20 3d 20 43 2e  D    CO.cid = C.
dbc0: 63 69 64 09 2d 2d 20 47 65 74 20 74 68 65 69 72  cid.-- Get their
dbd0: 20 74 6f 70 6f 6c 6f 67 69 63 61 6c 20 6f 72 64   topological ord
dbe0: 65 72 69 6e 67 0a 09 20 20 20 20 47 52 4f 55 50  ering..    GROUP
dbf0: 20 42 59 20 42 2e 62 69 64 0a 09 7d 5d 5d 0a 0a   BY B.bid..}]]..
dc00: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 5b          return [
dc10: 6c 69 73 74 20 24 6d 61 78 70 20 24 6d 69 6e 73  list $maxp $mins
dc20: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23  ].    }..    # #
dc30: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
dc40: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
dc50: 23 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66  ####.    ## Conf
dc60: 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70  iguration..    p
dc70: 72 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e  ragma -hasinstan
dc80: 63 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e  ces   no ; # sin
dc90: 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d  gleton.    pragm
dca0: 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20  a -hastypeinfo  
dcb0: 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72    no ; # no intr
dcc0: 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72  ospection.    pr
dcd0: 61 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73  agma -hastypedes
dce0: 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f  troy no ; # immo
dcf0: 72 74 61 6c 0a 7d 0a 0a 23 20 23 20 23 23 20 23  rtal.}..# # ## #
dd00: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
dd10: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20  # ############# 
dd20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
dd30: 23 23 23 23 23 0a 23 23 0a 0a 6e 61 6d 65 73 70  #####.##..namesp
dd40: 61 63 65 20 65 76 61 6c 20 3a 3a 76 63 3a 3a 66  ace eval ::vc::f
dd50: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
dd60: 76 73 3a 3a 70 72 6f 6a 65 63 74 20 7b 0a 20 20  vs::project {.  
dd70: 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 70 6f    namespace expo
dd80: 72 74 20 72 65 76 0a 20 20 20 20 6e 61 6d 65 73  rt rev.    names
dd90: 70 61 63 65 20 65 76 61 6c 20 72 65 76 20 7b 0a  pace eval rev {.
dda0: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
ddb0: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
ddc0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61  import::cvs::sta
ddd0: 74 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d  te..namespace im
dde0: 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  port ::vc::fossi
ddf0: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
de00: 69 6e 74 65 67 72 69 74 79 0a 09 6e 61 6d 65 73  integrity..names
de10: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
de20: 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63 3a 3a 2a  ::tools::misc::*
de30: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
de40: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  rt ::vc::tools::
de50: 74 72 6f 75 62 6c 65 0a 09 6e 61 6d 65 73 70 61  trouble..namespa
de60: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
de70: 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20  tools::log..log 
de80: 72 65 67 69 73 74 65 72 20 63 73 65 74 73 0a 0a  register csets..
de90: 09 23 20 53 65 74 20 75 70 20 74 68 65 20 68 65  .# Set up the he
dea0: 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 73 0a  lper singletons.
deb0: 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
dec0: 72 65 76 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73  rev {..    names
ded0: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
dee0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
def0: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 20 20  ::cvs::state..  
df00: 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f    namespace impo
df10: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  rt ::vc::fossil:
df20: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e  :import::cvs::in
df30: 74 65 67 72 69 74 79 0a 09 20 20 20 20 6e 61 6d  tegrity..    nam
df40: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
df50: 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09  vc::tools::log..
df60: 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61  }..namespace eva
df70: 6c 20 73 79 6d 3a 3a 74 61 67 20 7b 0a 09 20 20  l sym::tag {..  
df80: 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f    namespace impo
df90: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  rt ::vc::fossil:
dfa0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74  :import::cvs::st
dfb0: 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 61  ate..    namespa
dfc0: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
dfd0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
dfe0: 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09  cvs::integrity..
dff0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d      namespace im
e000: 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73  port ::vc::tools
e010: 3a 3a 6c 6f 67 0a 09 7d 0a 09 6e 61 6d 65 73 70  ::log..}..namesp
e020: 61 63 65 20 65 76 61 6c 20 73 79 6d 3a 3a 62 72  ace eval sym::br
e030: 61 6e 63 68 20 7b 0a 09 20 20 20 20 6e 61 6d 65  anch {..    name
e040: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
e050: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
e060: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 20  t::cvs::state.. 
e070: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70     namespace imp
e080: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
e090: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69  ::import::cvs::i
e0a0: 6e 74 65 67 72 69 74 79 0a 09 20 20 20 20 6e 61  ntegrity..    na
e0b0: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
e0c0: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a  :vc::tools::log.
e0d0: 09 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20  .}.    }.}..# # 
e0e0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
e0f0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
e100: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
e110: 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 61  #########.## Rea
e120: 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76  dy..package prov
e130: 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  ide vc::fossil::
e140: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f  import::cvs::pro
e150: 6a 65 63 74 3a 3a 72 65 76 20 31 2e 30 0a 72 65  ject::rev 1.0.re
e160: 74 75 72 6e 0a                                   turn.