Hex Artifact Content
Not logged in

Artifact 20a9a93ee26690a72ddc85b573b9e9afc4c38693:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [383c10f004] - Merged bugfix b3d61d7829 into this semi-abandoned branch just in case we will work on it again. Do it now instead of forgetting it later. by aku on 2008-02-23 06:37:54.

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 23  tems to them...#
0810: 6c 61 70 70 65 6e 64 20 6d 79 63 68 61 6e 67 65  lappend mychange
0820: 73 65 74 73 20 20 20 24 73 65 6c 66 0a 09 23 6c  sets   $self..#l
0830: 61 70 70 65 6e 64 20 6d 79 74 63 68 61 6e 67 65  append mytchange
0840: 73 65 74 73 28 24 63 73 74 79 70 65 29 20 24 73  sets($cstype) $s
0850: 65 6c 66 0a 09 73 65 74 20 20 20 20 20 6d 79 69  elf..set     myi
0860: 64 6d 61 70 28 24 6d 79 69 64 29 20 24 73 65 6c  dmap($myid) $sel
0870: 66 0a 09 66 6f 72 65 61 63 68 20 69 69 64 20 24  f..foreach iid $
0880: 69 74 65 6d 73 20 7b 0a 09 20 20 20 20 73 65 74  items {..    set
0890: 20 6b 65 79 20 5b 6c 69 73 74 20 24 63 73 74 79   key [list $csty
08a0: 70 65 20 24 69 69 64 5d 0a 09 20 20 20 20 23 73  pe $iid]..    #s
08b0: 65 74 20 6d 79 69 74 65 6d 6d 61 70 28 24 6b 65  et myitemmap($ke
08c0: 79 29 20 24 73 65 6c 66 0a 09 20 20 20 20 6c 61  y) $self..    la
08d0: 70 70 65 6e 64 20 6d 79 74 69 74 65 6d 73 20 24  ppend mytitems $
08e0: 6b 65 79 0a 09 20 20 20 20 6c 6f 67 20 77 72 69  key..    log wri
08f0: 74 65 20 38 20 63 73 65 74 73 20 7b 4d 41 50 2b  te 8 csets {MAP+
0900: 20 69 74 65 6d 20 3c 24 6b 65 79 3e 20 24 73 65   item <$key> $se
0910: 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d  lf = [$self str]
0920: 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20  }..}..return.   
0930: 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 6c   }..    method l
0940: 6f 61 64 6d 61 70 73 20 7b 7d 20 7b 0a 09 23 20  oadmaps {} {..# 
0950: 4b 65 65 70 20 74 72 61 63 6b 20 6f 66 20 74 68  Keep track of th
0960: 65 20 67 65 6e 65 72 61 74 65 64 20 63 68 61 6e  e generated chan
0970: 67 65 73 65 74 73 20 61 6e 64 20 6f 66 20 74 68  gesets and of th
0980: 65 20 69 6e 76 65 72 73 65 0a 09 23 20 6d 61 70  e inverse..# map
0990: 70 69 6e 67 20 66 72 6f 6d 20 69 74 65 6d 73 20  ping from items 
09a0: 74 6f 20 74 68 65 6d 2e 0a 09 6c 61 70 70 65 6e  to them...lappen
09b0: 64 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20  d mychangesets  
09c0: 20 24 73 65 6c 66 0a 09 6c 61 70 70 65 6e 64 20   $self..lappend 
09d0: 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 24 6d  mytchangesets($m
09e0: 79 74 79 70 65 29 20 24 73 65 6c 66 0a 09 73 65  ytype) $self..se
09f0: 74 20 20 20 20 20 6d 79 69 64 6d 61 70 28 24 6d  t     myidmap($m
0a00: 79 69 64 29 20 24 73 65 6c 66 0a 09 66 6f 72 65  yid) $self..fore
0a10: 61 63 68 20 69 69 64 20 24 6d 79 69 74 65 6d 73  ach iid $myitems
0a20: 20 7b 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20   {..    set key 
0a30: 5b 6c 69 73 74 20 24 6d 79 74 79 70 65 20 24 69  [list $mytype $i
0a40: 69 64 5d 0a 09 20 20 20 20 73 65 74 20 6d 79 69  id]..    set myi
0a50: 74 65 6d 6d 61 70 28 24 6b 65 79 29 20 24 73 65  temmap($key) $se
0a60: 6c 66 0a 09 20 20 20 20 23 6c 6f 67 20 77 72 69  lf..    #log wri
0a70: 74 65 20 38 20 63 73 65 74 73 20 7b 4d 41 50 2b  te 8 csets {MAP+
0a80: 20 69 74 65 6d 20 3c 24 6b 65 79 3e 20 24 73 65   item <$key> $se
0a90: 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d  lf = [$self str]
0aa0: 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20  }..}..return.   
0ab0: 20 7d 0a 0a 20 20 20 20 64 65 73 74 72 75 63 74   }..    destruct
0ac0: 6f 72 20 7b 0a 09 23 20 54 68 65 20 6d 61 69 6e  or {..# The main
0ad0: 20 74 68 69 6e 67 20 69 73 20 74 6f 20 6b 65 65   thing is to kee
0ae0: 70 20 74 72 61 63 6b 20 6f 66 20 74 68 65 20 69  p track of the i
0af0: 74 65 6d 6d 61 70 20 61 6e 64 20 72 65 6d 6f 76  temmap and remov
0b00: 65 0a 09 23 20 74 68 65 20 6f 62 6a 65 63 74 20  e..# the object 
0b10: 66 72 6f 6d 20 69 74 2e 20 54 68 65 20 6c 69 73  from it. The lis
0b20: 74 73 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73  ts of changesets
0b30: 20 28 6d 79 63 68 61 6e 67 65 73 65 74 73 2c 0a   (mychangesets,.
0b40: 09 23 20 6d 79 74 63 68 61 6e 67 65 73 65 74 73  .# mytchangesets
0b50: 29 20 61 72 65 20 6e 6f 74 20 6d 61 69 6e 74 61  ) are not mainta
0b60: 69 6e 65 64 20 28 3d 20 72 65 64 75 63 65 64 29  ined (= reduced)
0b70: 2c 20 66 6f 72 20 74 68 65 0a 09 23 20 6d 6f 6d  , for the..# mom
0b80: 65 6e 74 2e 20 57 65 20 6d 61 79 20 62 65 20 61  ent. We may be a
0b90: 62 6c 65 20 74 6f 20 67 65 74 20 72 69 64 20 6f  ble to get rid o
0ba0: 66 20 74 68 69 73 20 65 6e 74 69 72 65 6c 79 2c  f this entirely,
0bb0: 20 61 74 20 6c 65 61 73 74 0a 09 23 20 66 6f 72   at least..# for
0bc0: 20 28 64 65 29 63 6f 6e 73 74 72 75 63 74 69 6f   (de)constructio
0bd0: 6e 20 61 6e 64 20 70 61 73 73 20 49 6e 69 74 43  n and pass InitC
0be0: 53 65 74 73 2e 0a 0a 09 66 6f 72 65 61 63 68 20  Sets....foreach 
0bf0: 69 69 64 20 24 6d 79 69 74 65 6d 73 20 7b 0a 09  iid $myitems {..
0c00: 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c 69 73      set key [lis
0c10: 74 20 24 6d 79 74 79 70 65 20 24 69 69 64 5d 0a  t $mytype $iid].
0c20: 09 20 20 20 20 23 75 6e 73 65 74 20 6d 79 69 74  .    #unset myit
0c30: 65 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20 20 20  emmap($key)..   
0c40: 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65   log write 8 cse
0c50: 74 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20 3c 24  ts {MAP- item <$
0c60: 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73  key> $self = [$s
0c70: 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 09 72 65  elf str]}..}..re
0c80: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
0c90: 6d 65 74 68 6f 64 20 73 74 72 20 7b 7d 20 7b 0a  method str {} {.
0ca0: 09 73 65 74 20 73 74 72 20 20 20 20 22 3c 22 0a  .set str    "<".
0cb0: 09 73 65 74 20 64 65 74 61 69 6c 20 22 22 0a 09  .set detail ""..
0cc0: 69 66 20 7b 5b 24 6d 79 74 79 70 65 6f 62 6a 20  if {[$mytypeobj 
0cd0: 62 79 73 79 6d 62 6f 6c 5d 7d 20 7b 0a 09 20 20  bysymbol]} {..  
0ce0: 20 20 73 65 74 20 64 65 74 61 69 6c 20 22 20 27    set detail " '
0cf0: 5b 73 74 61 74 65 20 6f 6e 65 20 7b 0a 09 09 53  [state one {...S
0d00: 45 4c 45 43 54 20 53 2e 6e 61 6d 65 0a 09 09 46  ELECT S.name...F
0d10: 52 4f 4d 20 20 20 73 79 6d 62 6f 6c 20 53 0a 09  ROM   symbol S..
0d20: 09 57 48 45 52 45 20 20 53 2e 73 69 64 20 3d 20  .WHERE  S.sid = 
0d30: 24 6d 79 73 72 63 69 64 0a 09 20 20 20 20 7d 5d  $mysrcid..    }]
0d40: 27 22 0a 09 7d 0a 09 61 70 70 65 6e 64 20 73 74  '"..}..append st
0d50: 72 20 22 24 6d 79 74 79 70 65 20 24 7b 6d 79 69  r "$mytype ${myi
0d60: 64 7d 24 7b 64 65 74 61 69 6c 7d 3e 22 0a 09 72  d}${detail}>"..r
0d70: 65 74 75 72 6e 20 24 73 74 72 0a 20 20 20 20 7d  eturn $str.    }
0d80: 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 6c 6f 64  ..    method lod
0d90: 20 7b 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 24   {} {..return [$
0da0: 6d 79 74 79 70 65 6f 62 6a 20 63 73 5f 6c 6f 64  mytypeobj cs_lod
0db0: 20 24 6d 79 69 74 65 6d 73 5d 0a 20 20 20 20 7d   $myitems].    }
0dc0: 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 69 64 20  ..    method id 
0dd0: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 24     {} { return $
0de0: 6d 79 69 64 20 7d 0a 20 20 20 20 6d 65 74 68 6f  myid }.    metho
0df0: 64 20 69 74 65 6d 73 20 7b 7d 20 7b 20 72 65 74  d items {} { ret
0e00: 75 72 6e 20 24 6d 79 74 69 74 65 6d 73 20 7d 0a  urn $mytitems }.
0e10: 20 20 20 20 6d 65 74 68 6f 64 20 64 61 74 61 20      method data 
0e20: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69   {} { return [li
0e30: 73 74 20 24 6d 79 70 72 6f 6a 65 63 74 20 24 6d  st $myproject $m
0e40: 79 74 79 70 65 20 24 6d 79 73 72 63 69 64 5d 20  ytype $mysrcid] 
0e50: 7d 0a 0a 20 20 20 20 64 65 6c 65 67 61 74 65 20  }..    delegate 
0e60: 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20  method bysymbol 
0e70: 20 20 74 6f 20 6d 79 74 79 70 65 6f 62 6a 0a 20    to mytypeobj. 
0e80: 20 20 20 64 65 6c 65 67 61 74 65 20 6d 65 74 68     delegate meth
0e90: 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20 74 6f  od byrevision to
0ea0: 20 6d 79 74 79 70 65 6f 62 6a 0a 20 20 20 20 64   mytypeobj.    d
0eb0: 65 6c 65 67 61 74 65 20 6d 65 74 68 6f 64 20 69  elegate method i
0ec0: 73 62 72 61 6e 63 68 20 20 20 74 6f 20 6d 79 74  sbranch   to myt
0ed0: 79 70 65 6f 62 6a 0a 20 20 20 20 64 65 6c 65 67  ypeobj.    deleg
0ee0: 61 74 65 20 6d 65 74 68 6f 64 20 69 73 74 61 67  ate method istag
0ef0: 20 20 20 20 20 20 74 6f 20 6d 79 74 79 70 65 6f        to mytypeo
0f00: 62 6a 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 73  bj..    method s
0f10: 65 74 70 6f 73 20 7b 70 7d 20 7b 20 73 65 74 20  etpos {p} { set 
0f20: 6d 79 70 6f 73 20 24 70 20 3b 20 72 65 74 75 72  mypos $p ; retur
0f30: 6e 20 7d 0a 20 20 20 20 6d 65 74 68 6f 64 20 70  n }.    method p
0f40: 6f 73 20 20 20 20 7b 7d 20 20 7b 20 72 65 74 75  os    {}  { retu
0f50: 72 6e 20 24 6d 79 70 6f 73 20 7d 0a 0a 20 20 20  rn $mypos }..   
0f60: 20 6d 65 74 68 6f 64 20 64 65 74 65 72 6d 69 6e   method determin
0f70: 65 73 75 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b  esuccessors {} {
0f80: 0a 09 23 20 50 61 73 73 20 36 20 6f 70 65 72 61  ..# Pass 6 opera
0f90: 74 69 6f 6e 2e 20 43 6f 6d 70 75 74 65 20 70 72  tion. Compute pr
0fa0: 6f 6a 65 63 74 2d 6c 65 76 65 6c 20 64 65 70 65  oject-level depe
0fb0: 6e 64 65 6e 63 69 65 73 20 66 72 6f 6d 0a 09 23  ndencies from..#
0fc0: 20 74 68 65 20 66 69 6c 65 2d 6c 65 76 65 6c 20   the file-level 
0fd0: 64 61 74 61 20 61 6e 64 20 73 61 76 65 20 69 74  data and save it
0fe0: 20 62 61 63 6b 20 74 6f 20 74 68 65 20 73 74 61   back to the sta
0ff0: 74 65 2e 20 54 68 69 73 20 6d 61 79 0a 09 23 20  te. This may..# 
1000: 62 65 20 63 61 6c 6c 65 64 20 64 75 72 69 6e 67  be called during
1010: 20 74 68 65 20 63 79 63 6c 65 20 62 72 65 61 6b   the cycle break
1020: 65 72 20 70 61 73 73 65 73 20 61 73 20 77 65 6c  er passes as wel
1030: 6c 2c 20 74 6f 20 61 64 6a 75 73 74 0a 09 23 20  l, to adjust..# 
1040: 74 68 65 20 73 75 63 63 65 73 73 6f 72 20 69 6e  the successor in
1050: 66 6f 72 6d 61 74 69 6f 6e 20 6f 66 20 63 68 61  formation of cha
1060: 6e 67 65 73 65 74 73 20 77 68 69 63 68 20 61 72  ngesets which ar
1070: 65 20 74 68 65 0a 09 23 20 70 72 65 64 65 63 65  e the..# predece
1080: 73 73 6f 72 73 20 6f 66 20 64 72 6f 70 70 65 64  ssors of dropped
1090: 20 63 68 61 6e 67 65 73 65 74 73 2e 20 46 6f 72   changesets. For
10a0: 20 74 68 65 6d 20 77 65 20 68 61 76 65 20 74 6f   them we have to
10b0: 0a 09 23 20 72 65 6d 6f 76 65 20 74 68 65 69 72  ..# remove their
10c0: 20 65 78 69 73 74 69 6e 67 20 69 6e 66 6f 72 6d   existing inform
10d0: 61 74 69 6f 6e 20 66 69 72 73 74 20 62 65 66 6f  ation first befo
10e0: 72 65 20 69 6e 73 65 72 74 69 6e 67 20 74 68 65  re inserting the
10f0: 0a 09 23 20 6e 65 77 20 64 61 74 61 2e 0a 09 73  ..# new data...s
1100: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
1110: 44 45 4c 45 54 45 20 46 52 4f 4d 20 63 73 73 75  DELETE FROM cssu
1120: 63 63 65 73 73 6f 72 20 57 48 45 52 45 20 63 69  ccessor WHERE ci
1130: 64 20 3d 20 24 6d 79 69 64 3b 0a 09 7d 0a 09 73  d = $myid;..}..s
1140: 65 74 20 6c 6f 6f 70 20 30 0a 09 66 6f 72 65 61  et loop 0..forea
1150: 63 68 20 6e 69 64 20 5b 24 6d 79 74 79 70 65 6f  ch nid [$mytypeo
1160: 62 6a 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73  bj cs_successors
1170: 20 24 6d 79 69 74 65 6d 73 5d 20 7b 0a 09 20 20   $myitems] {..  
1180: 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09    state run {...
1190: 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 73 73 75  INSERT INTO cssu
11a0: 63 63 65 73 73 6f 72 20 28 63 69 64 2c 20 20 6e  ccessor (cid,  n
11b0: 69 64 29 0a 09 09 56 41 4c 55 45 53 20 20 20 20  id)...VALUES    
11c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 24                ($
11d0: 6d 79 69 64 2c 24 6e 69 64 29 0a 09 20 20 20 20  myid,$nid)..    
11e0: 7d 0a 09 20 20 20 20 69 66 20 7b 24 6e 69 64 20  }..    if {$nid 
11f0: 3d 3d 20 24 6d 79 69 64 7d 20 7b 20 73 65 74 20  == $myid} { set 
1200: 6c 6f 6f 70 20 31 20 7d 0a 09 7d 0a 09 23 20 52  loop 1 }..}..# R
1210: 65 70 6f 72 74 20 61 66 74 65 72 20 74 68 65 20  eport after the 
1220: 63 6f 6d 70 6c 65 74 65 20 73 74 72 75 63 74 75  complete structu
1230: 72 65 20 68 61 73 20 62 65 65 6e 20 73 61 76 65  re has been save
1240: 64 2e 0a 09 69 66 20 7b 24 6c 6f 6f 70 7d 20 7b  d...if {$loop} {
1250: 20 24 73 65 6c 66 20 72 65 70 6f 72 74 6c 6f 6f   $self reportloo
1260: 70 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  p }..return.    
1270: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20  }..    # result 
1280: 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65  = list (changese
1290: 74 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 73 75  t).    method su
12a0: 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b 0a 09 23  ccessors {} {..#
12b0: 20 55 73 65 20 74 68 65 20 64 61 74 61 20 73 61   Use the data sa
12c0: 76 65 64 20 62 79 20 70 61 73 73 20 36 2e 0a 09  ved by pass 6...
12d0: 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a  return [struct::
12e0: 6c 69 73 74 20 6d 61 70 20 5b 73 74 61 74 65 20  list map [state 
12f0: 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  run {..    SELEC
1300: 54 20 53 2e 6e 69 64 0a 09 20 20 20 20 46 52 4f  T S.nid..    FRO
1310: 4d 20 20 20 63 73 73 75 63 63 65 73 73 6f 72 20  M   cssuccessor 
1320: 53 0a 09 20 20 20 20 57 48 45 52 45 20 20 53 2e  S..    WHERE  S.
1330: 63 69 64 20 3d 20 24 6d 79 69 64 0a 09 7d 5d 20  cid = $myid..}] 
1340: 5b 6d 79 74 79 70 65 6d 65 74 68 6f 64 20 6f 66  [mytypemethod of
1350: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  ]].    }..    # 
1360: 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69 74  item -> list (it
1370: 65 6d 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 6e  em).    method n
1380: 65 78 74 6d 61 70 20 7b 7d 20 7b 0a 09 24 6d 79  extmap {} {..$my
1390: 74 79 70 65 6f 62 6a 20 73 75 63 63 65 73 73 6f  typeobj successo
13a0: 72 73 20 74 6d 70 20 24 6d 79 69 74 65 6d 73 0a  rs tmp $myitems.
13b0: 09 72 65 74 75 72 6e 20 5b 61 72 72 61 79 20 67  .return [array g
13c0: 65 74 20 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20  et tmp].    }.. 
13d0: 20 20 20 6d 65 74 68 6f 64 20 62 72 65 61 6b 69     method breaki
13e0: 6e 74 65 72 6e 61 6c 64 65 70 65 6e 64 65 6e 63  nternaldependenc
13f0: 69 65 73 20 7b 63 76 7d 20 7b 0a 09 75 70 76 61  ies {cv} {..upva
1400: 72 20 31 20 24 63 76 20 63 6f 75 6e 74 65 72 0a  r 1 $cv counter.
1410: 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63 73  .log write 14 cs
1420: 65 74 73 20 7b 5b 24 73 65 6c 66 20 73 74 72 5d  ets {[$self str]
1430: 20 42 49 44 7d 0a 09 76 63 3a 3a 74 6f 6f 6c 73   BID}..vc::tools
1440: 3a 3a 6d 65 6d 3a 3a 6d 61 72 6b 0a 09 23 23 0a  ::mem::mark..##.
1450: 09 23 23 20 4e 4f 54 45 3a 20 54 68 69 73 20 6d  .## NOTE: This m
1460: 65 74 68 6f 64 2c 20 6d 61 79 62 65 20 69 6e 20  ethod, maybe in 
1470: 63 6f 6e 6a 75 6e 63 74 69 6f 6e 20 77 69 74 68  conjunction with
1480: 20 69 74 73 20 63 61 6c 6c 65 72 0a 09 23 23 20   its caller..## 
1490: 20 20 20 20 20 20 73 65 65 6d 73 20 74 6f 20 62        seems to b
14a0: 65 20 61 20 6d 65 6d 6f 72 79 20 68 6f 67 2c 20  e a memory hog, 
14b0: 65 73 70 65 63 69 61 6c 6c 79 20 66 6f 72 20 6c  especially for l
14c0: 61 72 67 65 0a 09 23 23 20 20 20 20 20 20 20 63  arge..##       c
14d0: 68 61 6e 67 65 73 65 74 73 2c 20 77 69 74 68 20  hangesets, with 
14e0: 27 6c 61 72 67 65 27 20 6d 65 61 6e 69 6e 67 20  'large' meaning 
14f0: 74 6f 20 68 61 76 65 20 61 20 27 6c 6f 6e 67 20  to have a 'long 
1500: 6c 69 73 74 0a 09 23 23 20 20 20 20 20 20 20 6f  list..##       o
1510: 66 20 69 74 65 6d 73 2c 20 73 65 76 65 72 61 6c  f items, several
1520: 20 74 68 6f 75 73 61 6e 64 27 2e 20 49 6e 76 65   thousand'. Inve
1530: 73 74 69 67 61 74 65 20 77 68 65 72 65 20 74 68  stigate where th
1540: 65 0a 09 23 23 20 20 20 20 20 20 20 6d 65 6d 6f  e..##       memo
1550: 72 79 20 69 73 20 73 70 65 6e 74 20 61 6e 64 20  ry is spent and 
1560: 74 68 65 6e 20 6c 6f 6f 6b 20 66 6f 72 20 77 61  then look for wa
1570: 79 73 20 6f 66 20 72 65 63 74 69 66 79 69 6e 67  ys of rectifying
1580: 0a 09 23 23 20 20 20 20 20 20 20 74 68 65 20 70  ..##       the p
1590: 72 6f 62 6c 65 6d 2e 0a 09 23 23 0a 0a 09 23 20  roblem...##...# 
15a0: 54 68 69 73 20 6d 65 74 68 6f 64 20 69 6e 73 70  This method insp
15b0: 65 63 74 73 20 74 68 65 20 63 68 61 6e 67 65 73  ects the changes
15c0: 65 74 73 20 66 6f 72 20 69 6e 74 65 72 6e 61 6c  ets for internal
15d0: 0a 09 23 20 64 65 70 65 6e 64 65 6e 63 69 65 73  ..# dependencies
15e0: 2e 20 4e 6f 74 68 69 6e 67 20 69 73 20 64 6f 6e  . Nothing is don
15f0: 65 20 69 66 20 74 68 65 72 65 20 61 72 65 20 6e  e if there are n
1600: 6f 0a 09 23 20 73 75 63 68 2e 20 4f 74 68 65 72  o..# such. Other
1610: 77 69 73 65 20 74 68 65 20 63 68 61 6e 67 65 73  wise the changes
1620: 65 74 20 69 73 20 73 70 6c 69 74 20 69 6e 74 6f  et is split into
1630: 20 61 20 73 65 74 20 6f 66 0a 09 23 20 66 72 61   a set of..# fra
1640: 67 6d 65 6e 74 73 20 77 69 74 68 6f 75 74 20 69  gments without i
1650: 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e  nternal dependen
1660: 63 69 65 73 2c 20 74 72 61 6e 73 66 6f 72 6d 69  cies, transformi
1670: 6e 67 20 74 68 65 0a 09 23 20 69 6e 74 65 72 6e  ng the..# intern
1680: 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  al dependencies 
1690: 69 6e 74 6f 20 65 78 74 65 72 6e 61 6c 20 6f 6e  into external on
16a0: 65 73 2e 20 54 68 65 20 6e 65 77 20 63 68 61 6e  es. The new chan
16b0: 67 65 73 65 74 73 0a 09 23 20 61 72 65 20 61 64  gesets..# are ad
16c0: 64 65 64 20 74 6f 20 74 68 65 20 6c 69 73 74 20  ded to the list 
16d0: 6f 66 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74  of all changeset
16e0: 73 2e 0a 0a 09 23 20 57 65 20 70 65 72 66 6f 72  s....# We perfor
16f0: 6d 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20  m all necessary 
1700: 73 70 6c 69 74 73 20 69 6e 20 6f 6e 65 20 67 6f  splits in one go
1710: 2c 20 69 6e 73 74 65 61 64 20 6f 66 20 6f 6e 6c  , instead of onl
1720: 79 0a 09 23 20 6f 6e 65 2e 20 54 68 65 20 70 72  y..# one. The pr
1730: 65 76 69 6f 75 73 20 61 6c 67 6f 72 69 74 68 6d  evious algorithm
1740: 2c 20 61 64 61 70 74 65 64 20 66 72 6f 6d 20 63  , adapted from c
1750: 76 73 32 73 76 6e 2c 20 63 6f 6d 70 75 74 65 64  vs2svn, computed
1760: 0a 09 23 20 61 20 6c 6f 74 20 6f 66 20 73 74 61  ..# a lot of sta
1770: 74 65 20 77 68 69 63 68 20 77 61 73 20 74 68 72  te which was thr
1780: 6f 77 6e 20 61 77 61 79 20 61 6e 64 20 74 68 65  own away and the
1790: 6e 20 63 6f 6d 70 75 74 65 64 20 61 67 61 69 6e  n computed again
17a0: 0a 09 23 20 66 6f 72 20 65 61 63 68 20 6f 66 20  ..# for each of 
17b0: 74 68 65 20 66 72 61 67 6d 65 6e 74 73 2e 20 49  the fragments. I
17c0: 74 20 73 68 6f 75 6c 64 20 62 65 20 65 61 73 69  t should be easi
17d0: 65 72 20 74 6f 20 75 70 64 61 74 65 20 61 6e 64  er to update and
17e0: 0a 09 23 20 72 65 75 73 65 20 74 68 61 74 20 73  ..# reuse that s
17f0: 74 61 74 65 2e 0a 0a 09 23 20 54 68 65 20 63 6f  tate....# The co
1800: 64 65 20 63 68 65 63 6b 73 20 6f 6e 6c 79 20 73  de checks only s
1810: 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65  uccessor depende
1820: 6e 63 69 65 73 2c 20 61 73 20 74 68 69 73 0a 09  ncies, as this..
1830: 23 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20  # automatically 
1840: 63 6f 76 65 72 73 20 74 68 65 20 70 72 65 64 65  covers the prede
1850: 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63  cessor dependenc
1860: 69 65 73 20 61 73 20 77 65 6c 6c 20 28 41 0a 09  ies as well (A..
1870: 23 20 73 75 63 63 65 73 73 6f 72 20 64 65 70 65  # successor depe
1880: 6e 64 65 6e 63 79 20 61 20 2d 3e 20 62 20 69 73  ndency a -> b is
1890: 20 61 6c 73 6f 20 61 20 70 72 65 64 65 63 65 73   also a predeces
18a0: 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 79 0a 09  sor dependency..
18b0: 23 20 62 20 2d 3e 20 61 29 2e 0a 0a 09 23 20 41  # b -> a)....# A
18c0: 72 72 61 79 20 6f 66 20 64 65 70 65 6e 64 65 6e  rray of dependen
18d0: 63 69 65 73 20 28 70 61 72 65 6e 74 20 2d 3e 20  cies (parent -> 
18e0: 63 68 69 6c 64 29 2e 20 54 68 69 73 20 69 73 20  child). This is 
18f0: 70 75 6c 6c 65 64 20 66 72 6f 6d 0a 09 23 20 74  pulled from..# t
1900: 68 65 20 73 74 61 74 65 2c 20 61 6e 64 20 6c 69  he state, and li
1910: 6d 69 74 65 64 20 74 6f 20 73 75 63 63 65 73 73  mited to success
1920: 6f 72 73 20 77 69 74 68 69 6e 20 74 68 65 20 63  ors within the c
1930: 68 61 6e 67 65 73 65 74 2e 0a 0a 09 61 72 72 61  hangeset....arra
1940: 79 20 73 65 74 20 64 65 70 65 6e 64 65 6e 63 69  y set dependenci
1950: 65 73 20 7b 7d 0a 09 24 6d 79 74 79 70 65 6f 62  es {}..$mytypeob
1960: 6a 20 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73  j internalsucces
1970: 73 6f 72 73 20 64 65 70 65 6e 64 65 6e 63 69 65  sors dependencie
1980: 73 20 24 6d 79 69 74 65 6d 73 0a 09 69 66 20 7b  s $myitems..if {
1990: 21 5b 61 72 72 61 79 20 73 69 7a 65 20 64 65 70  ![array size dep
19a0: 65 6e 64 65 6e 63 69 65 73 5d 7d 20 7b 0a 09 20  endencies]} {.. 
19b0: 20 20 20 72 65 74 75 72 6e 20 7b 7d 0a 09 7d 20     return {}..} 
19c0: 3b 20 23 20 4e 6f 74 68 69 6e 67 20 74 6f 20 62  ; # Nothing to b
19d0: 72 65 61 6b 2e 0a 0a 09 6c 6f 67 20 77 72 69 74  reak....log writ
19e0: 65 20 35 20 63 73 65 74 73 20 2e 2e 2e 5b 24 73  e 5 csets ...[$s
19f0: 65 6c 66 20 73 74 72 5d 2e 2e 2e 2e 2e 2e 2e 2e  elf str]........
1a00: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1a10: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1a20: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a  ................
1a30: 09 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 65 6d 3a  .vc::tools::mem:
1a40: 3a 6d 61 72 6b 0a 0a 09 23 20 57 65 20 68 61 76  :mark...# We hav
1a50: 65 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e  e internal depen
1a60: 64 65 6e 63 69 65 73 20 74 6f 20 62 72 65 61 6b  dencies to break
1a70: 2e 20 57 65 20 6e 6f 77 20 69 74 65 72 61 74 65  . We now iterate
1a80: 20 6f 76 65 72 0a 09 23 20 61 6c 6c 20 70 6f 73   over..# all pos
1a90: 69 74 69 6f 6e 73 20 69 6e 20 74 68 65 20 6c 69  itions in the li
1aa0: 73 74 20 28 77 68 69 63 68 20 69 73 20 63 68 72  st (which is chr
1ab0: 6f 6e 6f 6c 6f 67 69 63 61 6c 2c 20 61 74 20 6c  onological, at l
1ac0: 65 61 73 74 0a 09 23 20 61 73 20 66 61 72 20 61  east..# as far a
1ad0: 73 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73  s the timestamps
1ae0: 20 61 72 65 20 63 6f 72 72 65 63 74 20 61 6e 64   are correct and
1af0: 20 75 6e 69 71 75 65 29 20 61 6e 64 0a 09 23 20   unique) and..# 
1b00: 64 65 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65  determine the be
1b10: 73 74 20 70 6f 73 69 74 69 6f 6e 20 66 6f 72 20  st position for 
1b20: 74 68 65 20 62 72 65 61 6b 2c 20 62 79 20 74 72  the break, by tr
1b30: 79 69 6e 67 20 74 6f 0a 09 23 20 62 72 65 61 6b  ying to..# break
1b40: 20 61 73 20 6d 61 6e 79 20 64 65 70 65 6e 64 65   as many depende
1b50: 6e 63 69 65 73 20 61 73 20 70 6f 73 73 69 62 6c  ncies as possibl
1b60: 65 20 69 6e 20 6f 6e 65 20 67 6f 2e 20 57 68 65  e in one go. Whe
1b70: 6e 20 61 0a 09 23 20 62 72 65 61 6b 20 77 61 73  n a..# break was
1b80: 20 66 6f 75 6e 64 20 74 68 69 73 20 69 73 20 72   found this is r
1b90: 65 64 6f 6e 65 20 66 6f 72 20 74 68 65 20 66 72  edone for the fr
1ba0: 61 67 6d 65 6e 74 73 20 63 6f 6d 69 6e 67 20 61  agments coming a
1bb0: 6e 64 0a 09 23 20 61 66 74 65 72 2c 20 61 66 74  nd..# after, aft
1bc0: 65 72 20 75 70 64 69 6e 67 20 74 68 65 20 63 72  er upding the cr
1bd0: 6f 73 73 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69  ossing informati
1be0: 6f 6e 2e 0a 0a 09 23 20 44 61 74 61 20 73 74 72  on....# Data str
1bf0: 75 63 74 75 72 65 73 3a 0a 09 23 20 4d 61 70 3a  uctures:..# Map:
1c00: 20 20 50 4f 53 20 20 20 72 65 76 69 73 69 6f 6e    POS   revision
1c10: 20 69 64 20 20 20 20 20 20 2d 3e 20 70 6f 73 69   id      -> posi
1c20: 74 69 6f 6e 20 69 6e 20 6c 69 73 74 2e 0a 09 23  tion in list...#
1c30: 20 20 20 20 20 20 20 43 52 4f 53 53 20 70 6f 73         CROSS pos
1c40: 69 74 69 6f 6e 20 69 6e 20 6c 69 73 74 20 2d 3e  ition in list ->
1c50: 20 6e 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e   number of depen
1c60: 64 65 6e 63 69 65 73 20 63 72 6f 73 73 69 6e 67  dencies crossing
1c70: 20 69 74 0a 09 23 20 20 20 20 20 20 20 44 45 50   it..#       DEP
1c80: 43 20 20 64 65 70 65 6e 64 65 6e 63 79 20 20 20  C  dependency   
1c90: 20 20 20 20 2d 3e 20 70 6f 73 69 74 69 6f 6e 73      -> positions
1ca0: 20 69 74 20 63 72 6f 73 73 65 73 0a 09 23 20 4c   it crosses..# L
1cb0: 69 73 74 3a 20 52 41 4e 47 45 20 4f 66 20 74 68  ist: RANGE Of th
1cc0: 65 20 70 6f 73 69 74 69 6f 6e 73 20 69 74 73 65  e positions itse
1cd0: 6c 66 2e 0a 09 23 20 41 20 64 65 70 65 6e 64 65  lf...# A depende
1ce0: 6e 63 79 20 69 73 20 61 20 73 69 6e 67 6c 65 2d  ncy is a single-
1cf0: 65 6c 65 6d 65 6e 74 20 6d 61 70 20 70 61 72 65  element map pare
1d00: 6e 74 20 2d 3e 20 63 68 69 6c 64 0a 0a 09 49 6e  nt -> child...In
1d10: 69 74 69 61 6c 69 7a 65 42 72 65 61 6b 53 74 61  itializeBreakSta
1d20: 74 65 20 24 6d 79 69 74 65 6d 73 0a 0a 09 73 65  te $myitems...se
1d30: 74 20 66 72 61 67 6d 65 6e 74 73 20 7b 7d 0a 09  t fragments {}..
1d40: 73 65 74 20 6e 65 77 20 20 20 20 20 20 20 5b 6c  set new       [l
1d50: 69 73 74 20 24 72 61 6e 67 65 5d 0a 09 61 72 72  ist $range]..arr
1d60: 61 79 20 73 65 74 20 62 72 65 61 6b 73 20 7b 7d  ay set breaks {}
1d70: 0a 0a 09 23 20 49 6e 73 74 65 61 64 20 6f 66 20  ...# Instead of 
1d80: 6f 6e 65 20 6c 69 73 74 20 68 6f 6c 64 69 6e 67  one list holding
1d90: 20 62 6f 74 68 20 70 72 6f 63 65 73 73 65 64 20   both processed 
1da0: 61 6e 64 20 70 65 6e 64 69 6e 67 0a 09 23 20 66  and pending..# f
1db0: 72 61 67 6d 65 6e 74 73 20 77 65 20 75 73 65 20  ragments we use 
1dc0: 74 77 6f 2c 20 6f 6e 65 20 66 6f 72 20 74 68 65  two, one for the
1dd0: 20 66 72 61 6d 65 6e 74 73 20 74 6f 20 70 72 6f   framents to pro
1de0: 63 65 73 73 2c 20 6f 6e 65 0a 09 23 20 74 6f 20  cess, one..# to 
1df0: 68 6f 6c 64 20 74 68 65 20 6e 65 77 20 66 72 61  hold the new fra
1e00: 67 6d 65 6e 74 73 2c 20 61 6e 64 20 74 68 65 20  gments, and the 
1e10: 6c 61 74 74 65 72 20 69 73 20 63 6f 70 69 65 64  latter is copied
1e20: 20 74 6f 20 74 68 65 0a 09 23 20 66 6f 72 6d 65   to the..# forme
1e30: 72 20 77 68 65 6e 20 74 68 65 79 20 72 75 6e 20  r when they run 
1e40: 6f 75 74 2e 20 54 68 69 73 20 6b 65 65 70 73 20  out. This keeps 
1e50: 74 68 65 20 6c 69 73 74 20 6f 66 20 70 65 6e 64  the list of pend
1e60: 69 6e 67 0a 09 23 20 66 72 61 67 6d 65 6e 74 73  ing..# fragments
1e70: 20 73 68 6f 72 74 20 77 69 74 68 6f 75 74 20 73   short without s
1e80: 61 63 72 69 66 69 63 69 6e 67 20 73 70 65 65 64  acrificing speed
1e90: 20 62 79 20 73 68 69 66 74 69 6e 67 20 73 74 75   by shifting stu
1ea0: 66 66 0a 09 23 20 64 6f 77 6e 2e 20 57 65 20 65  ff..# down. We e
1eb0: 73 70 65 63 69 61 6c 6c 79 20 64 72 6f 70 20 74  specially drop t
1ec0: 68 65 20 6d 65 6d 6f 72 79 20 6f 66 20 66 72 61  he memory of fra
1ed0: 67 6d 65 6e 74 73 20 62 72 6f 6b 65 6e 0a 09 23  gments broken..#
1ee0: 20 64 75 72 69 6e 67 20 70 72 6f 63 65 73 73 69   during processi
1ef0: 6e 67 20 61 66 74 65 72 20 61 20 73 68 6f 72 74  ng after a short
1f00: 20 74 69 6d 65 2c 20 69 6e 73 74 65 61 64 20 6f   time, instead o
1f10: 66 20 6c 65 74 74 69 6e 67 20 69 74 0a 09 23 20  f letting it..# 
1f20: 63 6f 6e 73 75 6d 65 20 6d 65 6d 6f 72 79 2e 0a  consume memory..
1f30: 0a 09 77 68 69 6c 65 20 7b 5b 6c 6c 65 6e 67 74  ..while {[llengt
1f40: 68 20 24 6e 65 77 5d 7d 20 7b 0a 0a 09 20 20 20  h $new]} {...   
1f50: 20 73 65 74 20 70 65 6e 64 69 6e 67 20 24 6e 65   set pending $ne
1f60: 77 0a 09 20 20 20 20 73 65 74 20 6e 65 77 20 20  w..    set new  
1f70: 20 20 20 7b 7d 0a 09 20 20 20 20 73 65 74 20 61     {}..    set a
1f80: 74 20 20 20 20 20 20 30 0a 0a 09 20 20 20 20 77  t      0...    w
1f90: 68 69 6c 65 20 7b 24 61 74 20 3c 20 5b 6c 6c 65  hile {$at < [lle
1fa0: 6e 67 74 68 20 24 70 65 6e 64 69 6e 67 5d 7d 20  ngth $pending]} 
1fb0: 7b 0a 09 09 73 65 74 20 63 75 72 72 65 6e 74 20  {...set current 
1fc0: 5b 6c 69 6e 64 65 78 20 24 70 65 6e 64 69 6e 67  [lindex $pending
1fd0: 20 24 61 74 5d 0a 0a 09 09 6c 6f 67 20 77 72 69   $at]....log wri
1fe0: 74 65 20 36 20 63 73 65 74 73 20 7b 2e 20 2e 20  te 6 csets {. . 
1ff0: 2e 2e 20 2e 2e 2e 20 2e 2e 2e 2e 2e 20 2e 2e 2e  .. ... ..... ...
2000: 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ..... ..........
2010: 2e 2e 2e 7d 0a 09 09 6c 6f 67 20 77 72 69 74 65  ...}...log write
2020: 20 36 20 63 73 65 74 73 20 7b 53 63 68 65 64 75   6 csets {Schedu
2030: 6c 65 64 20 20 20 5b 6a 6f 69 6e 20 5b 50 52 73  led   [join [PRs
2040: 20 5b 6c 72 61 6e 67 65 20 24 70 65 6e 64 69 6e   [lrange $pendin
2050: 67 20 24 61 74 20 65 6e 64 5d 5d 20 7b 20 7d 5d  g $at end]] { }]
2060: 7d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 36 20  }...log write 6 
2070: 63 73 65 74 73 20 7b 43 6f 6e 73 69 64 65 72 69  csets {Consideri
2080: 6e 67 20 5b 50 52 20 24 63 75 72 72 65 6e 74 5d  ng [PR $current]
2090: 20 5c 5b 24 61 74 2f 5b 6c 6c 65 6e 67 74 68 20   \[$at/[llength 
20a0: 24 70 65 6e 64 69 6e 67 5d 5c 5d 7d 0a 0a 09 09  $pending]\]}....
20b0: 73 65 74 20 62 65 73 74 20 5b 46 69 6e 64 42 65  set best [FindBe
20c0: 73 74 42 72 65 61 6b 20 24 63 75 72 72 65 6e 74  stBreak $current
20d0: 5d 0a 0a 09 09 69 66 20 7b 24 62 65 73 74 20 3c  ]....if {$best <
20e0: 20 30 7d 20 7b 0a 09 09 20 20 20 20 23 20 54 68   0} {...    # Th
20f0: 65 20 69 6e 73 70 65 63 74 65 64 20 72 61 6e 67  e inspected rang
2100: 65 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61  e has no interna
2110: 6c 0a 09 09 20 20 20 20 23 20 64 65 70 65 6e 64  l...    # depend
2120: 65 6e 63 69 65 73 2e 20 54 68 69 73 20 69 73 20  encies. This is 
2130: 61 20 63 6f 6d 70 6c 65 74 65 20 66 72 61 67 6d  a complete fragm
2140: 65 6e 74 2e 0a 09 09 20 20 20 20 6c 61 70 70 65  ent....    lappe
2150: 6e 64 20 66 72 61 67 6d 65 6e 74 73 20 24 63 75  nd fragments $cu
2160: 72 72 65 6e 74 0a 0a 09 09 20 20 20 20 6c 6f 67  rrent....    log
2170: 20 77 72 69 74 65 20 36 20 63 73 65 74 73 20 22   write 6 csets "
2180: 4e 6f 20 62 72 65 61 6b 73 2c 20 66 69 6e 61 6c  No breaks, final
2190: 22 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20  "...} else {... 
21a0: 20 20 20 23 20 53 70 6c 69 74 20 74 68 65 20 72     # Split the r
21b0: 61 6e 67 65 20 61 6e 64 20 73 63 68 65 64 75 6c  ange and schedul
21c0: 65 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 0a  e the resulting.
21d0: 09 09 20 20 20 20 23 20 66 72 61 67 6d 65 6e 74  ..    # fragment
21e0: 73 20 66 6f 72 20 66 75 72 74 68 65 72 20 69 6e  s for further in
21f0: 73 70 65 63 74 69 6f 6e 2e 20 52 65 6d 65 6d 62  spection. Rememb
2200: 65 72 20 74 68 65 0a 09 09 20 20 20 20 23 20 6e  er the...    # n
2210: 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 65  umber of depende
2220: 6e 63 69 65 73 20 63 75 74 20 62 65 66 6f 72 65  ncies cut before
2230: 20 77 65 20 72 65 6d 6f 76 65 20 74 68 65 6d 0a   we remove them.
2240: 09 09 20 20 20 20 23 20 66 72 6f 6d 20 63 6f 6e  ..    # from con
2250: 73 69 64 65 72 61 74 69 6f 6e 2c 20 66 6f 72 20  sideration, for 
2260: 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 6c 61  documentation la
2270: 74 65 72 2e 0a 0a 09 09 20 20 20 20 73 65 74 20  ter.....    set 
2280: 62 72 65 61 6b 73 28 24 62 65 73 74 29 20 24 63  breaks($best) $c
2290: 72 6f 73 73 28 24 62 65 73 74 29 0a 0a 09 09 20  ross($best).... 
22a0: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20 63     log write 6 c
22b0: 73 65 74 73 20 22 42 65 73 74 20 62 72 65 61 6b  sets "Best break
22c0: 20 40 20 24 62 65 73 74 2c 20 63 75 74 74 69 6e   @ $best, cuttin
22d0: 67 20 5b 6e 73 70 20 24 63 72 6f 73 73 28 24 62  g [nsp $cross($b
22e0: 65 73 74 29 20 64 65 70 65 6e 64 65 6e 63 79 20  est) dependency 
22f0: 64 65 70 65 6e 64 65 6e 63 69 65 73 5d 22 0a 0a  dependencies]"..
2300: 09 09 20 20 20 20 23 20 4e 6f 74 65 3a 20 54 68  ..    # Note: Th
2310: 65 20 76 61 6c 75 65 20 6f 66 20 62 65 73 74 20  e value of best 
2320: 69 73 20 61 6e 20 61 62 6f 6c 75 74 65 20 6c 6f  is an abolute lo
2330: 63 61 74 69 6f 6e 0a 09 09 20 20 20 20 23 20 69  cation...    # i
2340: 6e 20 6d 79 69 74 65 6d 73 2e 20 55 73 65 20 74  n myitems. Use t
2350: 68 65 20 73 74 61 72 74 20 6f 66 20 63 75 72 72  he start of curr
2360: 65 6e 74 20 74 6f 20 6d 61 6b 65 20 69 74 0a 09  ent to make it..
2370: 09 20 20 20 20 23 20 61 6e 20 69 6e 64 65 78 20  .    # an index 
2380: 61 62 73 6f 6c 75 74 65 20 74 6f 20 63 75 72 72  absolute to curr
2390: 65 6e 74 2e 0a 0a 09 09 20 20 20 20 73 65 74 20  ent.....    set 
23a0: 62 72 65 6c 20 5b 65 78 70 72 20 7b 24 62 65 73  brel [expr {$bes
23b0: 74 20 2d 20 5b 6c 69 6e 64 65 78 20 24 63 75 72  t - [lindex $cur
23c0: 72 65 6e 74 20 30 5d 7d 5d 0a 09 09 20 20 20 20  rent 0]}]...    
23d0: 73 65 74 20 62 6e 65 78 74 20 24 62 72 65 6c 20  set bnext $brel 
23e0: 3b 20 69 6e 63 72 20 62 6e 65 78 74 0a 09 09 20  ; incr bnext... 
23f0: 20 20 20 73 65 74 20 66 72 61 67 62 65 66 6f 72     set fragbefor
2400: 65 20 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65  e [lrange $curre
2410: 6e 74 20 30 20 24 62 72 65 6c 5d 0a 09 09 20 20  nt 0 $brel]...  
2420: 20 20 73 65 74 20 66 72 61 67 61 66 74 65 72 20    set fragafter 
2430: 20 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 6e   [lrange $curren
2440: 74 20 24 62 6e 65 78 74 20 65 6e 64 5d 0a 0a 09  t $bnext end]...
2450: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36  .    log write 6
2460: 20 63 73 65 74 73 20 22 4e 65 77 20 70 69 65 63   csets "New piec
2470: 65 73 20 20 5b 50 52 20 24 66 72 61 67 62 65 66  es  [PR $fragbef
2480: 6f 72 65 5d 20 5b 50 52 20 24 66 72 61 67 61 66  ore] [PR $fragaf
2490: 74 65 72 5d 22 0a 0a 09 09 20 20 20 20 69 6e 74  ter]"....    int
24a0: 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 5b  egrity assert {[
24b0: 6c 6c 65 6e 67 74 68 20 24 66 72 61 67 62 65 66  llength $fragbef
24c0: 6f 72 65 5d 7d 20 7b 46 6f 75 6e 64 20 7a 65 72  ore]} {Found zer
24d0: 6f 2d 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 6e  o-length fragmen
24e0: 74 20 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69  t at the beginni
24f0: 6e 67 7d 0a 09 09 20 20 20 20 69 6e 74 65 67 72  ng}...    integr
2500: 69 74 79 20 61 73 73 65 72 74 20 7b 5b 6c 6c 65  ity assert {[lle
2510: 6e 67 74 68 20 24 66 72 61 67 61 66 74 65 72 5d  ngth $fragafter]
2520: 7d 20 20 7b 46 6f 75 6e 64 20 7a 65 72 6f 2d 6c  }  {Found zero-l
2530: 65 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 20 61  ength fragment a
2540: 74 20 74 68 65 20 65 6e 64 7d 0a 0a 09 09 20 20  t the end}....  
2550: 20 20 6c 61 70 70 65 6e 64 20 6e 65 77 20 24 66    lappend new $f
2560: 72 61 67 62 65 66 6f 72 65 20 24 66 72 61 67 61  ragbefore $fraga
2570: 66 74 65 72 0a 09 09 20 20 20 20 43 75 74 41 74  fter...    CutAt
2580: 20 24 62 65 73 74 0a 09 09 7d 0a 0a 09 09 69 6e   $best...}....in
2590: 63 72 20 61 74 0a 09 20 20 20 20 7d 0a 09 7d 0a  cr at..    }..}.
25a0: 0a 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73  ..log write 6 cs
25b0: 65 74 73 20 22 2e 20 2e 20 2e 2e 20 2e 2e 2e 20  ets ". . .. ... 
25c0: 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e  ..... ........ .
25d0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 22 0a 0a 09  ............"...
25e0: 23 20 28 2a 29 20 57 65 20 63 6c 65 61 72 20 6f  # (*) We clear o
25f0: 75 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65  ut the associate
2600: 64 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d 79  d part of the my
2610: 69 74 65 6d 6d 61 70 0a 09 23 20 69 6e 2d 6d 65  itemmap..# in-me
2620: 6d 6f 72 79 20 69 6e 64 65 78 20 69 6e 20 70 72  mory index in pr
2630: 65 70 61 72 61 74 69 6f 6e 20 66 6f 72 20 6e 65  eparation for ne
2640: 77 20 64 61 74 61 2e 20 41 20 73 69 6d 70 6c 65  w data. A simple
2650: 20 75 6e 73 65 74 0a 09 23 20 69 73 20 65 6e 6f   unset..# is eno
2660: 75 67 68 2c 20 77 65 20 68 61 76 65 20 6e 6f 20  ugh, we have no 
2670: 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74  symbol changeset
2680: 73 20 61 74 20 74 68 69 73 20 74 69 6d 65 2c 20  s at this time, 
2690: 61 6e 64 0a 09 23 20 74 68 75 73 20 6e 65 76 65  and..# thus neve
26a0: 72 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20  r more than one 
26b0: 72 65 66 65 72 65 6e 63 65 20 69 6e 20 74 68 65  reference in the
26c0: 20 6c 69 73 74 2e 0a 0a 09 66 6f 72 65 61 63 68   list....foreach
26d0: 20 69 69 64 20 24 6d 79 69 74 65 6d 73 20 7b 0a   iid $myitems {.
26e0: 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c 69  .    set key [li
26f0: 73 74 20 24 6d 79 74 79 70 65 20 24 69 69 64 5d  st $mytype $iid]
2700: 0a 09 20 20 20 20 23 75 6e 73 65 74 20 6d 79 69  ..    #unset myi
2710: 74 65 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20 20  temmap($key)..  
2720: 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73    log write 8 cs
2730: 65 74 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20 3c  ets {MAP- item <
2740: 24 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24  $key> $self = [$
2750: 73 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 0a 09  self str]}..}...
2760: 23 20 43 72 65 61 74 65 20 63 68 61 6e 67 65 73  # Create changes
2770: 65 74 73 20 66 6f 72 20 74 68 65 20 66 72 61 67  ets for the frag
2780: 6d 65 6e 74 73 2c 20 72 65 75 73 69 6e 67 20 74  ments, reusing t
2790: 68 65 20 63 75 72 72 65 6e 74 20 6f 6e 65 0a 09  he current one..
27a0: 23 20 66 6f 72 20 74 68 65 20 66 69 72 73 74 20  # for the first 
27b0: 66 72 61 67 6d 65 6e 74 2e 20 57 65 20 73 6f 72  fragment. We sor
27c0: 74 20 74 68 65 6d 20 69 6e 20 6f 72 64 65 72 20  t them in order 
27d0: 74 6f 20 61 6c 6c 6f 77 0a 09 23 20 63 68 65 63  to allow..# chec
27e0: 6b 69 6e 67 20 66 6f 72 20 67 61 70 73 20 61 6e  king for gaps an
27f0: 64 20 6e 69 63 65 20 6d 65 73 73 61 67 65 73 2e  d nice messages.
2800: 0a 0a 09 73 65 74 20 6e 65 77 63 73 65 74 73 20  ...set newcsets 
2810: 20 7b 7d 0a 09 73 65 74 20 66 72 61 67 6d 65 6e   {}..set fragmen
2820: 74 73 20 5b 6c 73 6f 72 74 20 2d 69 6e 64 65 78  ts [lsort -index
2830: 20 30 20 2d 69 6e 74 65 67 65 72 20 24 66 72 61   0 -integer $fra
2840: 67 6d 65 6e 74 73 5d 0a 0a 09 23 70 75 74 73 20  gments]...#puts 
2850: 5c 74 2e 5b 6a 6f 69 6e 20 5b 50 52 73 20 24 66  \t.[join [PRs $f
2860: 72 61 67 6d 65 6e 74 73 5d 20 2e 5c 6e 5c 74 2e  ragments] .\n\t.
2870: 5d 2e 0a 0a 09 42 6f 72 64 65 72 20 5b 6c 69 6e  ]....Border [lin
2880: 64 65 78 20 24 66 72 61 67 6d 65 6e 74 73 20 30  dex $fragments 0
2890: 5d 20 66 69 72 73 74 73 20 66 69 72 73 74 65 0a  ] firsts firste.
28a0: 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65  ..integrity asse
28b0: 72 74 20 7b 24 66 69 72 73 74 73 20 3d 3d 20 30  rt {$firsts == 0
28c0: 7d 20 7b 42 61 64 20 66 72 61 67 6d 65 6e 74 20  } {Bad fragment 
28d0: 73 74 61 72 74 20 40 20 24 66 69 72 73 74 73 2c  start @ $firsts,
28e0: 20 67 61 70 2c 20 6f 72 20 62 65 66 6f 72 65 20   gap, or before 
28f0: 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 74 68 65  beginning of the
2900: 20 72 61 6e 67 65 7d 0a 0a 09 73 65 74 20 6c 61   range}...set la
2910: 73 74 65 20 24 66 69 72 73 74 65 0a 09 66 6f 72  ste $firste..for
2920: 65 61 63 68 20 66 72 61 67 6d 65 6e 74 20 5b 6c  each fragment [l
2930: 72 61 6e 67 65 20 24 66 72 61 67 6d 65 6e 74 73  range $fragments
2940: 20 31 20 65 6e 64 5d 20 7b 0a 09 20 20 20 20 42   1 end] {..    B
2950: 6f 72 64 65 72 20 24 66 72 61 67 6d 65 6e 74 20  order $fragment 
2960: 73 20 65 0a 09 20 20 20 20 69 6e 74 65 67 72 69  s e..    integri
2970: 74 79 20 61 73 73 65 72 74 20 7b 24 6c 61 73 74  ty assert {$last
2980: 65 20 3d 3d 20 28 24 73 20 2d 20 31 29 7d 20 7b  e == ($s - 1)} {
2990: 42 61 64 20 66 72 61 67 6d 65 6e 74 20 62 6f 72  Bad fragment bor
29a0: 64 65 72 20 3c 24 6c 61 73 74 65 20 7c 20 24 73  der <$laste | $s
29b0: 3e 2c 20 67 61 70 20 6f 72 20 6f 76 65 72 6c 61  >, gap or overla
29c0: 70 7d 0a 0a 09 20 20 20 20 73 65 74 20 6e 65 77  p}...    set new
29d0: 20 5b 24 74 79 70 65 20 25 41 55 54 4f 25 20 24   [$type %AUTO% $
29e0: 6d 79 70 72 6f 6a 65 63 74 20 24 6d 79 74 79 70  myproject $mytyp
29f0: 65 20 24 6d 79 73 72 63 69 64 20 5b 6c 72 61 6e  e $mysrcid [lran
2a00: 67 65 20 24 6d 79 69 74 65 6d 73 20 24 73 20 24  ge $myitems $s $
2a10: 65 5d 5d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64  e]]..    lappend
2a20: 20 6e 65 77 63 73 65 74 73 20 24 6e 65 77 0a 09   newcsets $new..
2a30: 20 20 20 20 69 6e 63 72 20 63 6f 75 6e 74 65 72      incr counter
2a40: 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c 6f  ..            lo
2a50: 67 20 77 72 69 74 65 20 34 20 63 73 65 74 73 20  g write 4 csets 
2a60: 22 42 72 65 61 6b 69 6e 67 20 5b 24 73 65 6c 66  "Breaking [$self
2a70: 20 73 74 72 20 5d 20 40 20 24 6c 61 73 74 65 2c   str ] @ $laste,
2a80: 20 6e 65 77 20 5b 24 6e 65 77 20 73 74 72 5d 2c   new [$new str],
2a90: 20 63 75 74 74 69 6e 67 20 24 62 72 65 61 6b 73   cutting $breaks
2aa0: 28 24 6c 61 73 74 65 29 22 0a 0a 09 20 20 20 20  ($laste)"...    
2ab0: 73 65 74 20 6c 61 73 74 65 20 24 65 0a 09 7d 0a  set laste $e..}.
2ac0: 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65  ..integrity asse
2ad0: 72 74 20 7b 0a 09 20 20 20 20 24 6c 61 73 74 65  rt {..    $laste
2ae0: 20 3d 3d 20 28 5b 6c 6c 65 6e 67 74 68 20 24 6d   == ([llength $m
2af0: 79 69 74 65 6d 73 5d 2d 31 29 0a 09 7d 20 7b 42  yitems]-1)..} {B
2b00: 61 64 20 66 72 61 67 6d 65 6e 74 20 65 6e 64 20  ad fragment end 
2b10: 40 20 24 6c 61 73 74 65 2c 20 67 61 70 2c 20 6f  @ $laste, gap, o
2b20: 72 20 62 65 79 6f 6e 64 20 65 6e 64 20 6f 66 20  r beyond end of 
2b30: 74 68 65 20 72 61 6e 67 65 7d 0a 0a 09 23 20 50  the range}...# P
2b40: 75 74 20 74 68 65 20 66 69 72 73 74 20 66 72 61  ut the first fra
2b50: 67 6d 65 6e 74 20 69 6e 74 6f 20 74 68 65 20 63  gment into the c
2b60: 75 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74  urrent changeset
2b70: 2c 20 61 6e 64 0a 09 23 20 75 70 64 61 74 65 20  , and..# update 
2b80: 74 68 65 20 69 6e 2d 6d 65 6d 6f 72 79 20 69 6e  the in-memory in
2b90: 64 65 78 2e 20 57 65 20 63 61 6e 20 73 69 6d 70  dex. We can simp
2ba0: 6c 79 20 28 72 65 29 61 64 64 20 74 68 65 20 69  ly (re)add the i
2bb0: 74 65 6d 73 0a 09 23 20 62 65 63 61 75 73 65 20  tems..# because 
2bc0: 77 65 20 63 6c 65 61 72 65 64 20 74 68 65 20 70  we cleared the p
2bd0: 72 65 76 69 6f 75 73 6c 79 20 65 78 69 73 74 69  reviously existi
2be0: 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20  ng information, 
2bf0: 73 65 65 0a 09 23 20 28 2a 29 20 61 62 6f 76 65  see..# (*) above
2c00: 2e 20 50 65 72 73 69 73 74 65 6e 63 65 20 64 6f  . Persistence do
2c10: 65 73 20 6e 6f 74 20 6d 61 74 74 65 72 20 68 65  es not matter he
2c20: 72 65 2c 20 6e 6f 6e 65 20 6f 66 20 74 68 65 0a  re, none of the.
2c30: 09 23 20 63 68 61 6e 67 65 73 65 74 73 20 68 61  .# changesets ha
2c40: 73 20 62 65 65 6e 20 73 61 76 65 64 20 74 6f 20  s been saved to 
2c50: 74 68 65 20 70 65 72 73 69 73 74 65 6e 74 20 73  the persistent s
2c60: 74 61 74 65 20 79 65 74 2e 0a 0a 09 73 65 74 20  tate yet....set 
2c70: 6d 79 69 74 65 6d 73 20 20 5b 6c 72 61 6e 67 65  myitems  [lrange
2c80: 20 24 6d 79 69 74 65 6d 73 20 20 30 20 24 66 69   $myitems  0 $fi
2c90: 72 73 74 65 5d 0a 09 73 65 74 20 6d 79 74 69 74  rste]..set mytit
2ca0: 65 6d 73 20 5b 6c 72 61 6e 67 65 20 24 6d 79 74  ems [lrange $myt
2cb0: 69 74 65 6d 73 20 30 20 24 66 69 72 73 74 65 5d  items 0 $firste]
2cc0: 0a 09 66 6f 72 65 61 63 68 20 69 69 64 20 24 6d  ..foreach iid $m
2cd0: 79 69 74 65 6d 73 20 7b 0a 09 20 20 20 20 73 65  yitems {..    se
2ce0: 74 20 6b 65 79 20 5b 6c 69 73 74 20 24 6d 79 74  t key [list $myt
2cf0: 79 70 65 20 24 69 69 64 5d 0a 09 20 20 20 20 23  ype $iid]..    #
2d00: 73 65 74 20 6d 79 69 74 65 6d 6d 61 70 28 24 6b  set myitemmap($k
2d10: 65 79 29 20 24 73 65 6c 66 0a 09 20 20 20 20 6c  ey) $self..    l
2d20: 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73  og write 8 csets
2d30: 20 7b 4d 41 50 2b 20 69 74 65 6d 20 3c 24 6b 65   {MAP+ item <$ke
2d40: 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c  y> $self = [$sel
2d50: 66 20 73 74 72 5d 7d 0a 09 7d 0a 0a 09 72 65 74  f str]}..}...ret
2d60: 75 72 6e 20 24 6e 65 77 63 73 65 74 73 0a 20 20  urn $newcsets.  
2d70: 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20    }..    method 
2d80: 70 65 72 73 69 73 74 20 7b 7d 20 7b 0a 09 73 65  persist {} {..se
2d90: 74 20 74 69 64 20 24 6d 79 63 73 74 79 70 65 28  t tid $mycstype(
2da0: 24 6d 79 74 79 70 65 29 0a 09 73 65 74 20 70 69  $mytype)..set pi
2db0: 64 20 5b 24 6d 79 70 72 6f 6a 65 63 74 20 69 64  d [$myproject id
2dc0: 5d 0a 09 73 65 74 20 70 6f 73 20 30 0a 0a 09 73  ]..set pos 0...s
2dd0: 74 61 74 65 20 74 72 61 6e 73 61 63 74 69 6f 6e  tate transaction
2de0: 20 7b 0a 09 20 20 20 20 73 74 61 74 65 20 72 75   {..    state ru
2df0: 6e 20 7b 0a 09 09 49 4e 53 45 52 54 20 49 4e 54  n {...INSERT INT
2e00: 4f 20 63 68 61 6e 67 65 73 65 74 20 28 63 69 64  O changeset (cid
2e10: 2c 20 20 20 70 69 64 2c 20 20 74 79 70 65 2c 20  ,   pid,  type, 
2e20: 73 72 63 29 0a 09 09 56 41 4c 55 45 53 20 20 20  src)...VALUES   
2e30: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 24 6d               ($m
2e40: 79 69 64 2c 20 24 70 69 64 2c 20 24 74 69 64 2c  yid, $pid, $tid,
2e50: 20 24 6d 79 73 72 63 69 64 29 3b 0a 09 20 20 20   $mysrcid);..   
2e60: 20 7d 0a 0a 09 20 20 20 20 66 6f 72 65 61 63 68   }...    foreach
2e70: 20 69 69 64 20 24 6d 79 69 74 65 6d 73 20 7b 0a   iid $myitems {.
2e80: 09 09 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09  ..state run {...
2e90: 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f 20      INSERT INTO 
2ea0: 63 73 69 74 65 6d 20 28 63 69 64 2c 20 20 20 70  csitem (cid,   p
2eb0: 6f 73 2c 20 20 69 69 64 29 0a 09 09 20 20 20 20  os,  iid)...    
2ec0: 56 41 4c 55 45 53 20 20 20 20 20 20 20 20 20 20  VALUES          
2ed0: 20 20 20 28 24 6d 79 69 64 2c 20 24 70 6f 73 2c     ($myid, $pos,
2ee0: 20 24 69 69 64 29 3b 0a 09 09 7d 0a 09 09 69 6e   $iid);...}...in
2ef0: 63 72 20 70 6f 73 0a 09 20 20 20 20 7d 0a 09 7d  cr pos..    }..}
2f00: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
2f10: 20 20 20 20 6d 65 74 68 6f 64 20 74 69 6d 65 72      method timer
2f20: 61 6e 67 65 20 7b 7d 20 7b 20 72 65 74 75 72 6e  ange {} { return
2f30: 20 5b 24 6d 79 74 79 70 65 6f 62 6a 20 74 69 6d   [$mytypeobj tim
2f40: 65 72 61 6e 67 65 20 24 6d 79 69 74 65 6d 73 5d  erange $myitems]
2f50: 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 6c   }..    method l
2f60: 69 6d 69 74 73 20 7b 7d 20 7b 0a 09 73 74 72 75  imits {} {..stru
2f70: 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20  ct::list assign 
2f80: 5b 24 6d 79 74 79 70 65 6f 62 6a 20 6c 69 6d 69  [$mytypeobj limi
2f90: 74 73 20 24 6d 79 69 74 65 6d 73 5d 20 6d 61 78  ts $myitems] max
2fa0: 70 20 6d 69 6e 73 0a 09 72 65 74 75 72 6e 20 5b  p mins..return [
2fb0: 6c 69 73 74 20 5b 54 61 67 49 74 65 6d 44 69 63  list [TagItemDic
2fc0: 74 20 24 6d 61 78 70 20 24 6d 79 74 79 70 65 5d  t $maxp $mytype]
2fd0: 20 5b 54 61 67 49 74 65 6d 44 69 63 74 20 24 6d   [TagItemDict $m
2fe0: 69 6e 73 20 24 6d 79 74 79 70 65 5d 5d 0a 20 20  ins $mytype]].  
2ff0: 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20    }..    method 
3000: 64 72 6f 70 20 7b 7d 20 7b 0a 09 6c 6f 67 20 77  drop {} {..log w
3010: 72 69 74 65 20 38 20 63 73 65 74 73 20 7b 44 72  rite 8 csets {Dr
3020: 6f 70 70 69 6e 67 20 24 73 65 6c 66 20 3d 20 5b  opping $self = [
3030: 24 73 65 6c 66 20 73 74 72 5d 7d 0a 0a 09 73 74  $self str]}...st
3040: 61 74 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20  ate transaction 
3050: 7b 0a 09 20 20 20 20 73 74 61 74 65 20 72 75 6e  {..    state run
3060: 20 7b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f 4d   {...DELETE FROM
3070: 20 63 68 61 6e 67 65 73 65 74 20 20 20 57 48 45   changeset   WHE
3080: 52 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b 0a  RE cid = $myid;.
3090: 09 09 44 45 4c 45 54 45 20 46 52 4f 4d 20 63 73  ..DELETE FROM cs
30a0: 69 74 65 6d 20 20 20 20 20 20 57 48 45 52 45 20  item      WHERE 
30b0: 63 69 64 20 3d 20 24 6d 79 69 64 3b 0a 09 09 44  cid = $myid;...D
30c0: 45 4c 45 54 45 20 46 52 4f 4d 20 63 73 73 75 63  ELETE FROM cssuc
30d0: 63 65 73 73 6f 72 20 57 48 45 52 45 20 63 69 64  cessor WHERE cid
30e0: 20 3d 20 24 6d 79 69 64 3b 0a 09 20 20 20 20 7d   = $myid;..    }
30f0: 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 69 69 64  ..}..foreach iid
3100: 20 24 6d 79 69 74 65 6d 73 20 7b 0a 09 20 20 20   $myitems {..   
3110: 20 73 65 74 20 6b 65 79 20 5b 6c 69 73 74 20 24   set key [list $
3120: 6d 79 74 79 70 65 20 24 69 69 64 5d 0a 09 20 20  mytype $iid]..  
3130: 20 20 75 6e 73 65 74 20 6d 79 69 74 65 6d 6d 61    unset myitemma
3140: 70 28 24 6b 65 79 29 0a 09 20 20 20 20 6c 6f 67  p($key)..    log
3150: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b   write 8 csets {
3160: 4d 41 50 2d 20 69 74 65 6d 20 3c 24 6b 65 79 3e  MAP- item <$key>
3170: 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c 66 20   $self = [$self 
3180: 73 74 72 5d 7d 0a 09 7d 0a 09 73 65 74 20 70 6f  str]}..}..set po
3190: 73 20 20 20 20 20 20 20 20 20 20 5b 6c 73 65 61  s          [lsea
31a0: 72 63 68 20 2d 65 78 61 63 74 20 24 6d 79 63 68  rch -exact $mych
31b0: 61 6e 67 65 73 65 74 73 20 24 73 65 6c 66 5d 0a  angesets $self].
31c0: 09 73 65 74 20 6d 79 63 68 61 6e 67 65 73 65 74  .set mychangeset
31d0: 73 20 5b 6c 72 65 70 6c 61 63 65 20 24 6d 79 63  s [lreplace $myc
31e0: 68 61 6e 67 65 73 65 74 73 20 24 70 6f 73 20 24  hangesets $pos $
31f0: 70 6f 73 5d 0a 09 73 65 74 20 70 6f 73 20 20 20  pos]..set pos   
3200: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3210: 20 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 63 74   [lsearch -exact
3220: 20 24 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28   $mytchangesets(
3230: 24 6d 79 74 79 70 65 29 20 24 73 65 6c 66 5d 0a  $mytype) $self].
3240: 09 73 65 74 20 6d 79 74 63 68 61 6e 67 65 73 65  .set mytchangese
3250: 74 73 28 24 6d 79 74 79 70 65 29 20 5b 6c 72 65  ts($mytype) [lre
3260: 70 6c 61 63 65 20 24 6d 79 74 63 68 61 6e 67 65  place $mytchange
3270: 73 65 74 73 28 24 6d 79 74 79 70 65 29 20 24 70  sets($mytype) $p
3280: 6f 73 20 24 70 6f 73 5d 0a 0a 09 23 20 52 65 74  os $pos]...# Ret
3290: 75 72 6e 20 74 68 65 20 6c 69 73 74 20 6f 66 20  urn the list of 
32a0: 70 72 65 64 65 63 65 73 73 6f 72 73 20 73 6f 20  predecessors so 
32b0: 74 68 61 74 20 74 68 65 79 20 63 61 6e 20 62 65  that they can be
32c0: 20 61 64 6a 75 73 74 65 64 2e 0a 09 72 65 74 75   adjusted...retu
32d0: 72 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69 73 74  rn [struct::list
32e0: 20 6d 61 70 20 5b 73 74 61 74 65 20 72 75 6e 20   map [state run 
32f0: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 63 69  {..    SELECT ci
3300: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 63 73  d..    FROM   cs
3310: 73 75 63 63 65 73 73 6f 72 0a 09 20 20 20 20 57  successor..    W
3320: 48 45 52 45 20 20 6e 69 64 20 3d 20 24 6d 79 69  HERE  nid = $myi
3330: 64 0a 09 7d 5d 20 5b 6d 79 74 79 70 65 6d 65 74  d..}] [mytypemet
3340: 68 6f 64 20 6f 66 5d 5d 0a 20 20 20 20 7d 0a 0a  hod of]].    }..
3350: 20 20 20 20 6d 65 74 68 6f 64 20 72 65 70 6f 72      method repor
3360: 74 6c 6f 6f 70 20 7b 7b 6b 69 6c 6c 20 31 7d 7d  tloop {{kill 1}}
3370: 20 7b 0a 09 23 20 57 65 20 70 72 69 6e 74 20 74   {..# We print t
3380: 68 65 20 69 74 65 6d 73 20 77 68 69 63 68 20 61  he items which a
3390: 72 65 20 70 72 6f 64 75 63 69 6e 67 20 74 68 65  re producing the
33a0: 20 6c 6f 6f 70 2c 20 61 6e 64 20 68 6f 77 2e 0a   loop, and how..
33b0: 0a 09 73 65 74 20 68 64 72 20 22 53 65 6c 66 2d  ..set hdr "Self-
33c0: 72 65 66 65 72 65 6e 74 69 61 6c 20 63 68 61 6e  referential chan
33d0: 67 65 73 65 74 20 5b 24 73 65 6c 66 20 73 74 72  geset [$self str
33e0: 5d 20 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f  ] ______________
33f0: 5f 5f 5f 5f 22 0a 09 73 65 74 20 66 74 72 20 5b  ____"..set ftr [
3400: 72 65 67 73 75 62 20 2d 61 6c 6c 20 7b 5b 5e 20  regsub -all {[^ 
3410: 09 5d 7d 20 24 68 64 72 20 7b 5f 7d 5d 0a 0a 09  .]} $hdr {_}]...
3420: 6c 6f 67 20 77 72 69 74 65 20 30 20 63 73 65 74  log write 0 cset
3430: 73 20 24 68 64 72 0a 09 66 6f 72 65 61 63 68 20  s $hdr..foreach 
3440: 7b 69 74 65 6d 20 6e 65 78 74 69 74 65 6d 7d 20  {item nextitem} 
3450: 5b 24 6d 79 74 79 70 65 6f 62 6a 20 6c 6f 6f 70  [$mytypeobj loop
3460: 73 20 24 6d 79 69 74 65 6d 73 5d 20 7b 0a 09 20  s $myitems] {.. 
3470: 20 20 20 23 20 43 72 65 61 74 65 20 74 61 67 67     # Create tagg
3480: 65 64 20 69 74 65 6d 73 20 66 72 6f 6d 20 74 68  ed items from th
3490: 65 20 69 64 20 61 6e 64 20 6f 75 72 20 74 79 70  e id and our typ
34a0: 65 2e 0a 09 20 20 20 20 73 65 74 20 69 74 65 6d  e...    set item
34b0: 20 20 20 20 20 5b 6c 69 73 74 20 24 6d 79 74 79       [list $myty
34c0: 70 65 20 20 24 69 74 65 6d 5d 0a 09 20 20 20 20  pe  $item]..    
34d0: 73 65 74 20 6e 65 78 74 69 74 65 6d 20 5b 6c 69  set nextitem [li
34e0: 73 74 20 24 6d 79 74 79 70 65 20 24 6e 65 78 74  st $mytype $next
34f0: 69 74 65 6d 5d 0a 09 20 20 20 20 23 20 50 72 69  item]..    # Pri
3500: 6e 74 61 62 6c 65 20 6c 61 62 65 6c 73 2e 0a 09  ntable labels...
3510: 20 20 20 20 73 65 74 20 69 20 20 22 3c 5b 24 74      set i  "<[$t
3520: 79 70 65 20 69 74 65 6d 73 74 72 20 24 69 74 65  ype itemstr $ite
3530: 6d 5d 3e 22 0a 09 20 20 20 20 73 65 74 20 6e 20  m]>"..    set n 
3540: 20 22 3c 5b 24 74 79 70 65 20 69 74 65 6d 73 74   "<[$type itemst
3550: 72 20 24 6e 65 78 74 69 74 65 6d 5d 3e 22 0a 09  r $nextitem]>"..
3560: 20 20 20 20 73 65 74 20 6e 63 73 20 24 6d 79 69      set ncs $myi
3570: 74 65 6d 6d 61 70 28 24 6e 65 78 74 69 74 65 6d  temmap($nextitem
3580: 29 0a 09 20 20 20 20 23 20 50 72 69 6e 74 0a 09  )..    # Print..
3590: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 30 20      log write 0 
35a0: 63 73 65 74 73 20 7b 2a 20 24 69 20 2d 2d 3e 20  csets {* $i --> 
35b0: 24 6e 20 2d 2d 3e 20 63 73 20 5b 24 6e 63 73 20  $n --> cs [$ncs 
35c0: 73 74 72 5d 7d 0a 09 7d 0a 09 6c 6f 67 20 77 72  str]}..}..log wr
35d0: 69 74 65 20 30 20 63 73 65 74 73 20 24 66 74 72  ite 0 csets $ftr
35e0: 0a 0a 09 69 66 20 7b 21 24 6b 69 6c 6c 7d 20 72  ...if {!$kill} r
35f0: 65 74 75 72 6e 0a 09 74 72 6f 75 62 6c 65 20 69  eturn..trouble i
3600: 6e 74 65 72 6e 61 6c 20 22 5b 24 73 65 6c 66 20  nternal "[$self 
3610: 73 74 72 5d 20 64 65 70 65 6e 64 73 20 6f 6e 20  str] depends on 
3620: 69 74 73 65 6c 66 22 0a 09 72 65 74 75 72 6e 0a  itself"..return.
3630: 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f      }..    metho
3640: 64 20 70 75 73 68 74 6f 20 7b 72 65 70 6f 73 69  d pushto {reposi
3650: 74 6f 72 79 20 64 61 74 65 20 72 73 74 61 74 65  tory date rstate
3660: 7d 20 7b 0a 09 23 20 47 65 6e 65 72 61 74 65 20  } {..# Generate 
3670: 61 6e 64 20 69 6d 70 6f 72 74 20 74 68 65 20 6d  and import the m
3680: 61 6e 69 66 65 73 74 20 66 6f 72 20 74 68 69 73  anifest for this
3690: 20 63 68 61 6e 67 65 73 65 74 2e 0a 09 23 0a 09   changeset...#..
36a0: 23 20 44 61 74 61 20 6e 65 65 64 65 64 3a 0a 09  # Data needed:..
36b0: 23 20 2d 20 43 6f 6d 6d 69 74 20 6d 65 73 73 61  # - Commit messa
36c0: 67 65 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ge              
36d0: 20 28 2d 2d 20 6d 79 73 72 63 69 64 20 2d 3e 20   (-- mysrcid -> 
36e0: 72 65 70 6f 73 69 74 6f 72 79 20 6d 65 74 61 29  repository meta)
36f0: 0a 09 23 20 2d 20 55 73 65 72 20 64 6f 69 6e 67  ..# - User doing
3700: 20 74 68 65 20 63 6f 6d 6d 69 74 20 20 20 20 20   the commit     
3710: 20 20 20 28 73 2e 61 2e 29 0a 09 23 0a 09 23 20     (s.a.)..#..# 
3720: 2d 20 54 69 6d 65 73 74 61 6d 70 20 6f 66 20 77  - Timestamp of w
3730: 68 65 6e 20 63 6f 6d 6d 69 74 74 65 64 20 20 28  hen committed  (
3740: 63 6f 6d 6d 61 6e 64 20 61 72 67 75 6d 65 6e 74  command argument
3750: 29 0a 09 23 0a 09 23 20 2d 20 54 68 65 20 70 61  )..#..# - The pa
3760: 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2c 20  rent changeset, 
3770: 69 66 20 61 6e 79 2e 20 49 66 20 74 68 65 72 65  if any. If there
3780: 20 69 73 20 6e 6f 20 70 61 72 65 6e 74 20 66 6f   is no parent fo
3790: 73 73 69 6c 0a 09 23 20 20 20 77 69 6c 6c 20 75  ssil..#   will u
37a0: 73 65 20 74 68 65 20 65 6d 70 74 79 20 62 61 73  se the empty bas
37b0: 65 20 72 65 76 69 73 69 6f 6e 20 61 73 20 70 61  e revision as pa
37c0: 72 65 6e 74 2e 0a 09 23 0a 09 23 20 2d 20 4c 69  rent...#..# - Li
37d0: 73 74 20 6f 66 20 74 68 65 20 66 69 6c 65 20 72  st of the file r
37e0: 65 76 69 73 69 6f 6e 73 20 69 6e 20 74 68 65 20  evisions in the 
37f0: 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 73 74 72  changeset....str
3800: 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e  uct::list assign
3810: 20 5b 24 6d 79 70 72 6f 6a 65 63 74 20 67 65 74   [$myproject get
3820: 6d 65 74 61 20 24 6d 79 73 72 63 69 64 5d 20 5f  meta $mysrcid] _
3830: 5f 20 5f 5f 20 75 73 65 72 20 6d 65 73 73 61 67  _ __ user messag
3840: 65 0a 0a 09 23 20 57 65 20 64 65 72 69 76 65 20  e...# We derive 
3850: 74 68 65 20 6c 6f 64 20 69 6e 66 6f 72 6d 61 74  the lod informat
3860: 69 6f 6e 20 64 69 72 65 63 74 6c 79 20 66 72 6f  ion directly fro
3870: 6d 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 20  m the revisions 
3880: 6f 66 0a 09 23 20 74 68 65 20 63 68 61 6e 67 65  of..# the change
3890: 73 65 74 2c 20 61 73 20 74 68 65 20 62 72 61 6e  set, as the bran
38a0: 63 68 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d  ch part of the m
38b0: 65 74 61 20 64 61 74 61 20 28 73 2e 61 2e 29 20  eta data (s.a.) 
38c0: 69 73 0a 09 23 20 6f 75 74 64 61 74 65 64 20 73  is..# outdated s
38d0: 69 6e 63 65 20 70 61 73 73 20 46 69 6c 74 65 72  ince pass Filter
38e0: 53 79 6d 62 6f 6c 73 2e 0a 0a 09 73 65 74 20 6c  Symbols....set l
38f0: 6f 64 6e 61 6d 65 20 5b 24 73 65 6c 66 20 6c 6f  odname [$self lo
3900: 64 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 32  d]...log write 2
3910: 20 63 73 65 74 73 20 7b 49 6d 70 6f 72 74 69 6e   csets {Importin
3920: 67 20 72 65 76 69 73 69 6f 6e 20 5b 24 73 65 6c  g revision [$sel
3930: 66 20 73 74 72 5d 20 6f 6e 20 24 6c 6f 64 6e 61  f str] on $lodna
3940: 6d 65 7d 0a 0a 09 23 20 50 65 72 66 6f 72 6d 20  me}...# Perform 
3950: 74 68 65 20 69 6d 70 6f 72 74 2e 20 41 73 20 70  the import. As p
3960: 61 72 74 20 6f 66 20 74 68 61 74 20 77 65 20 64  art of that we d
3970: 65 74 65 72 6d 69 6e 65 20 74 68 65 20 70 61 72  etermine the par
3980: 65 6e 74 0a 09 23 20 77 65 20 6e 65 65 64 2c 20  ent..# we need, 
3990: 61 6e 64 20 63 6f 6e 76 65 72 74 20 74 68 65 20  and convert the 
39a0: 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20 69 6e  list of items in
39b0: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 69   the changeset i
39c0: 6e 74 6f 0a 09 23 20 75 75 69 64 73 20 61 6e 64  nto..# uuids and
39d0: 20 70 72 69 6e 74 61 62 6c 65 20 64 61 74 61 2e   printable data.
39e0: 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  ...struct::list 
39f0: 61 73 73 69 67 6e 20 5b 47 65 74 69 73 64 65 66  assign [Getisdef
3a00: 61 75 6c 74 20 24 6d 79 69 74 65 6d 73 5d 20 69  ault $myitems] i
3a10: 73 64 65 66 61 75 6c 74 20 6c 61 73 74 64 65 66  sdefault lastdef
3a20: 61 75 6c 74 6f 6e 74 72 75 6e 6b 0a 0a 09 6c 6f  aultontrunk...lo
3a30: 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20  g write 8 csets 
3a40: 7b 4c 4f 44 20 20 20 20 27 24 6c 6f 64 6e 61 6d  {LOD    '$lodnam
3a50: 65 27 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 38  e'}..log write 8
3a60: 20 63 73 65 74 73 20 7b 20 64 65 66 3f 20 20 24   csets { def?  $
3a70: 69 73 64 65 66 61 75 6c 74 7d 0a 09 6c 6f 67 20  isdefault}..log 
3a80: 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b 20  write 8 csets { 
3a90: 6c 61 73 74 3f 20 24 6c 61 73 74 64 65 66 61 75  last? $lastdefau
3aa0: 6c 74 6f 6e 74 72 75 6e 6b 7d 0a 0a 09 73 65 74  ltontrunk}...set
3ab0: 20 6c 77 73 20 20 5b 47 65 74 77 6f 72 6b 73 70   lws  [Getworksp
3ac0: 61 63 65 20 20 20 20 24 72 73 74 61 74 65 20 24  ace    $rstate $
3ad0: 6c 6f 64 6e 61 6d 65 20 24 6d 79 70 72 6f 6a 65  lodname $myproje
3ae0: 63 74 20 24 69 73 64 65 66 61 75 6c 74 5d 0a 09  ct $isdefault]..
3af0: 24 6c 77 73 20 61 64 64 20 5b 47 65 74 72 65 76  $lws add [Getrev
3b00: 69 73 69 6f 6e 69 6e 66 6f 20 24 6d 79 69 74 65  isioninfo $myite
3b10: 6d 73 5d 0a 0a 09 73 65 74 20 75 75 69 64 20 5b  ms]...set uuid [
3b20: 24 72 65 70 6f 73 69 74 6f 72 79 20 69 6d 70 6f  $repository impo
3b30: 72 74 72 65 76 69 73 69 6f 6e 20 5b 24 73 65 6c  rtrevision [$sel
3b40: 66 20 73 74 72 5d 20 5c 0a 09 09 20 20 20 20 20  f str] \...     
3b50: 20 24 75 73 65 72 20 24 6d 65 73 73 61 67 65 20   $user $message 
3b60: 24 64 61 74 65 20 5c 0a 09 09 20 20 20 20 20 20  $date \...      
3b70: 5b 24 6c 77 73 20 67 65 74 69 64 5d 20 5b 24 6c  [$lws getid] [$l
3b80: 77 73 20 67 65 74 5d 5d 0a 0a 09 23 20 52 65 6d  ws get]]...# Rem
3b90: 65 6d 62 65 72 20 74 68 65 20 69 6d 70 6f 72 74  ember the import
3ba0: 65 64 20 63 68 61 6e 67 65 73 65 74 20 69 6e 20  ed changeset in 
3bb0: 74 68 65 20 73 74 61 74 65 2c 20 75 6e 64 65 72  the state, under
3bc0: 20 6f 75 72 0a 09 23 20 4c 4f 44 2e 20 41 6e 64   our..# LOD. And
3bd0: 20 69 66 20 69 74 20 69 73 20 74 68 65 20 6c 61   if it is the la
3be0: 73 74 20 74 72 75 6e 6b 20 63 68 61 6e 67 65 73  st trunk changes
3bf0: 65 74 20 6f 6e 20 74 68 65 20 76 65 6e 64 6f 72  et on the vendor
3c00: 0a 09 23 20 62 72 61 6e 63 68 20 74 68 65 6e 20  ..# branch then 
3c10: 74 68 65 20 72 65 76 69 73 69 6f 6e 20 69 73 20  the revision is 
3c20: 61 6c 73 6f 20 74 68 65 20 61 63 74 75 61 6c 20  also the actual 
3c30: 72 6f 6f 74 20 6f 66 20 74 68 65 0a 09 23 20 3a  root of the..# :
3c40: 74 72 75 6e 6b 3a 2c 20 73 6f 20 77 65 20 72 65  trunk:, so we re
3c50: 6d 65 6d 62 65 72 20 69 74 20 61 73 20 73 75 63  member it as suc
3c60: 68 20 69 6e 20 74 68 65 20 73 74 61 74 65 2e 20  h in the state. 
3c70: 48 6f 77 65 76 65 72 20 69 66 0a 09 23 20 74 68  However if..# th
3c80: 65 20 74 72 75 6e 6b 20 61 6c 72 65 61 64 79 20  e trunk already 
3c90: 65 78 69 73 74 73 20 74 68 65 6e 20 74 68 65 20  exists then the 
3ca0: 63 68 61 6e 67 65 73 65 74 20 63 61 6e 6e 6f 74  changeset cannot
3cb0: 20 62 65 20 6f 6e 20 69 74 0a 09 23 20 61 6e 79   be on it..# any
3cc0: 20 6d 6f 72 65 2e 20 54 68 69 73 20 69 6e 64 69   more. This indi
3cd0: 63 61 74 65 73 20 77 65 69 72 64 6e 65 73 73 20  cates weirdness 
3ce0: 69 6e 20 74 68 65 20 73 65 74 75 70 20 6f 66 20  in the setup of 
3cf0: 74 68 65 0a 09 23 20 76 65 6e 64 6f 72 20 62 72  the..# vendor br
3d00: 61 6e 63 68 2c 20 62 75 74 20 6f 6e 65 20 77 65  anch, but one we
3d10: 20 63 61 6e 20 77 6f 72 6b 20 61 72 6f 75 6e 64   can work around
3d20: 2e 0a 0a 09 24 6c 77 73 20 64 65 66 69 64 20 24  ....$lws defid $
3d30: 75 75 69 64 0a 09 69 66 20 7b 24 6c 61 73 74 64  uuid..if {$lastd
3d40: 65 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 7d 20 7b  efaultontrunk} {
3d50: 0a 09 20 20 20 20 69 66 20 7b 5b 24 72 73 74 61  ..    if {[$rsta
3d60: 74 65 20 68 61 73 20 3a 74 72 75 6e 6b 3a 5d 7d  te has :trunk:]}
3d70: 20 7b 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 32   {...log write 2
3d80: 20 63 73 65 74 73 20 7b 4d 75 6c 74 69 70 6c 65   csets {Multiple
3d90: 20 63 68 61 6e 67 65 73 65 74 73 20 64 65 63 6c   changesets decl
3da0: 61 72 65 64 20 74 6f 20 62 65 20 74 68 65 20 6c  ared to be the l
3db0: 61 73 74 20 74 72 75 6e 6b 20 63 68 61 6e 67 65  ast trunk change
3dc0: 73 65 74 20 6f 6e 20 74 68 65 20 76 65 6e 64 6f  set on the vendo
3dd0: 72 2d 62 72 61 6e 63 68 7d 0a 09 20 20 20 20 7d  r-branch}..    }
3de0: 20 65 6c 73 65 20 7b 0a 09 09 24 72 73 74 61 74   else {...$rstat
3df0: 65 20 6e 65 77 20 3a 74 72 75 6e 6b 3a 20 5b 24  e new :trunk: [$
3e00: 6c 77 73 20 6e 61 6d 65 5d 0a 09 20 20 20 20 7d  lws name]..    }
3e10: 0a 09 7d 0a 0a 09 23 20 52 65 6d 65 6d 62 65 72  ..}...# Remember
3e20: 20 74 68 65 20 77 68 6f 6c 65 20 63 68 61 6e 67   the whole chang
3e30: 65 73 65 74 20 2f 20 75 75 69 64 20 6d 61 70 70  eset / uuid mapp
3e40: 69 6e 67 2c 20 66 6f 72 20 74 68 65 20 74 61 67  ing, for the tag
3e50: 73 2e 0a 0a 09 73 74 61 74 65 20 72 75 6e 20 7b  s....state run {
3e60: 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54  ..    INSERT INT
3e70: 4f 20 63 73 75 75 69 64 20 28 63 69 64 2c 20 20  O csuuid (cid,  
3e80: 20 75 75 69 64 29 0a 09 20 20 20 20 56 41 4c 55   uuid)..    VALU
3e90: 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20 28  ES             (
3ea0: 24 6d 79 69 64 2c 20 24 75 75 69 64 29 0a 09 7d  $myid, $uuid)..}
3eb0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
3ec0: 20 20 20 20 70 72 6f 63 20 47 65 74 72 65 76 69      proc Getrevi
3ed0: 73 69 6f 6e 69 6e 66 6f 20 7b 72 65 76 69 73 69  sioninfo {revisi
3ee0: 6f 6e 73 7d 20 7b 0a 09 73 65 74 20 74 68 65 73  ons} {..set thes
3ef0: 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69  et ('[join $revi
3f00: 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 09  sions {','}]')..
3f10: 73 65 74 20 72 65 76 69 73 69 6f 6e 73 20 7b 7d  set revisions {}
3f20: 0a 09 66 6f 72 65 61 63 68 20 7b 66 72 69 64 20  ..foreach {frid 
3f30: 70 61 74 68 20 66 6e 61 6d 65 20 72 65 76 6e 72  path fname revnr
3f40: 20 72 6f 70 7d 20 5b 73 74 61 74 65 20 72 75 6e   rop} [state run
3f50: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
3f60: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
3f70: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  es {..    SELECT
3f80: 20 55 2e 75 75 69 64 2c 20 46 2e 76 69 73 69 62   U.uuid, F.visib
3f90: 6c 65 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65  le, F.name, R.re
3fa0: 76 2c 20 52 2e 6f 70 0a 09 20 20 20 20 46 52 4f  v, R.op..    FRO
3fb0: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
3fc0: 72 65 76 75 75 69 64 20 55 2c 20 66 69 6c 65 20  revuuid U, file 
3fd0: 46 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e  F..    WHERE  R.
3fe0: 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  rid IN $theset  
3ff0: 2d 2d 20 41 6c 6c 20 73 70 65 63 69 66 69 65 64  -- All specified
4000: 20 72 65 76 69 73 69 6f 6e 73 0a 09 20 20 20 20   revisions..    
4010: 41 4e 44 20 20 20 20 55 2e 72 69 64 20 3d 20 52  AND    U.rid = R
4020: 2e 72 69 64 20 20 20 20 20 2d 2d 20 67 65 74 20  .rid     -- get 
4030: 66 6f 73 73 69 6c 20 75 75 69 64 20 6f 66 20 72  fossil uuid of r
4040: 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 41 4e 44  evision..    AND
4050: 20 20 20 20 46 2e 66 69 64 20 3d 20 52 2e 66 69      F.fid = R.fi
4060: 64 20 20 20 20 20 2d 2d 20 67 65 74 20 66 69 6c  d     -- get fil
4070: 65 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 7d  e of revision..}
4080: 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e  ]] {..    lappen
4090: 64 20 72 65 76 69 73 69 6f 6e 73 20 24 66 72 69  d revisions $fri
40a0: 64 20 24 70 61 74 68 20 24 66 6e 61 6d 65 2f 24  d $path $fname/$
40b0: 72 65 76 6e 72 20 24 72 6f 70 0a 09 7d 0a 09 72  revnr $rop..}..r
40c0: 65 74 75 72 6e 20 24 72 65 76 69 73 69 6f 6e 73  eturn $revisions
40d0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63  .    }..    proc
40e0: 20 47 65 74 77 6f 72 6b 73 70 61 63 65 20 7b 72   Getworkspace {r
40f0: 73 74 61 74 65 20 6c 6f 64 6e 61 6d 65 20 70 72  state lodname pr
4100: 6f 6a 65 63 74 20 69 73 64 65 66 61 75 6c 74 7d  oject isdefault}
4110: 20 7b 0a 0a 09 23 20 54 68 65 20 73 74 61 74 65   {...# The state
4120: 20 6f 62 6a 65 63 74 20 68 6f 6c 64 73 20 74 68   object holds th
4130: 65 20 77 6f 72 6b 73 70 61 63 65 20 73 74 61 74  e workspace stat
4140: 65 20 6f 66 20 65 61 63 68 20 6b 6e 6f 77 6e 0a  e of each known.
4150: 09 23 20 6c 69 6e 65 2d 6f 66 2d 64 65 76 65 6c  .# line-of-devel
4160: 6f 70 6d 65 6e 74 20 28 4c 4f 44 29 2c 20 75 70  opment (LOD), up
4170: 20 74 6f 20 74 68 65 20 6c 61 73 74 20 63 6f 6d   to the last com
4180: 6d 69 74 74 65 64 0a 09 23 20 63 68 61 6e 67 65  mitted..# change
4190: 73 65 74 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f  set belonging to
41a0: 20 74 68 61 74 20 4c 4f 44 2e 0a 0a 09 23 20 28   that LOD....# (
41b0: 2a 29 20 53 74 61 6e 64 61 72 64 20 68 61 6e 64  *) Standard hand
41c0: 6c 69 6e 67 20 69 66 20 69 6e 2d 4c 4f 44 20 63  ling if in-LOD c
41d0: 68 61 6e 67 65 73 65 74 73 2e 20 49 66 20 74 68  hangesets. If th
41e0: 65 20 4c 4f 44 20 6f 66 0a 09 23 20 20 20 20 20  e LOD of..#     
41f0: 74 68 65 20 63 75 72 72 65 6e 74 20 63 68 61 6e  the current chan
4200: 67 65 73 65 74 20 65 78 69 73 74 73 20 69 6e 20  geset exists in 
4210: 74 68 65 20 73 74 61 74 65 20 28 3d 20 68 61 73  the state (= has
4220: 20 62 65 65 6e 0a 09 23 20 20 20 20 20 63 6f 6d   been..#     com
4230: 6d 69 74 74 65 64 20 74 6f 29 20 74 68 65 6e 20  mitted to) then 
4240: 74 68 69 73 20 69 74 20 68 61 73 20 74 68 65 20  this it has the 
4250: 77 6f 72 6b 73 70 61 63 65 20 77 65 20 61 72 65  workspace we are
4260: 0a 09 23 20 20 20 20 20 6c 6f 6f 6b 69 6e 67 20  ..#     looking 
4270: 66 6f 72 2e 0a 0a 09 69 66 20 7b 5b 24 72 73 74  for....if {[$rst
4280: 61 74 65 20 68 61 73 20 24 6c 6f 64 6e 61 6d 65  ate has $lodname
4290: 5d 7d 20 7b 0a 09 20 20 20 20 72 65 74 75 72 6e  ]} {..    return
42a0: 20 5b 24 72 73 74 61 74 65 20 67 65 74 20 24 6c   [$rstate get $l
42b0: 6f 64 6e 61 6d 65 5d 0a 09 7d 0a 0a 09 23 20 49  odname]..}...# I
42c0: 66 20 74 68 65 20 4c 4f 44 20 69 73 20 68 6f 77  f the LOD is how
42d0: 65 76 65 72 20 6e 6f 74 20 79 65 74 20 6b 6e 6f  ever not yet kno
42e0: 77 6e 2c 20 74 68 65 6e 20 74 68 65 20 63 75 72  wn, then the cur
42f0: 72 65 6e 74 0a 09 23 20 63 68 61 6e 67 65 73 65  rent..# changese
4300: 74 20 63 61 6e 20 62 65 20 65 69 74 68 65 72 20  t can be either 
4310: 6f 66 0a 09 23 20 28 61 29 20 72 6f 6f 74 20 6f  of..# (a) root o
4320: 66 20 61 20 76 65 6e 64 6f 72 20 62 72 61 6e 63  f a vendor branc
4330: 68 2c 0a 09 23 20 28 62 29 20 72 6f 6f 74 20 6f  h,..# (b) root o
4340: 66 20 74 68 65 20 74 72 75 6e 6b 20 4c 4f 44 2c  f the trunk LOD,
4350: 20 6f 72 0a 09 23 20 28 63 29 20 74 68 65 20 66   or..# (c) the f
4360: 69 72 73 74 20 63 68 61 6e 67 65 73 65 74 20 69  irst changeset i
4370: 6e 20 61 20 6e 65 77 20 4c 4f 44 20 77 68 69 63  n a new LOD whic
4380: 68 20 77 61 73 20 73 70 61 77 6e 65 64 20 66 72  h was spawned fr
4390: 6f 6d 0a 09 23 20 20 20 20 20 61 6e 20 65 78 69  om..#     an exi
43a0: 73 74 69 6e 67 20 4c 4f 44 2e 0a 0a 09 23 20 46  sting LOD....# F
43b0: 6f 72 20 62 6f 74 68 20 28 61 29 20 61 6e 64 20  or both (a) and 
43c0: 28 62 29 20 77 65 20 68 61 76 65 20 74 6f 20 63  (b) we have to c
43d0: 72 65 61 74 65 20 61 20 6e 65 77 20 77 6f 72 6b  reate a new work
43e0: 73 70 61 63 65 20 66 6f 72 0a 09 23 20 74 68 65  space for..# the
43f0: 20 6c 6f 64 2c 20 61 6e 64 20 69 74 20 64 6f 65   lod, and it doe
4400: 73 6e 27 74 20 69 6e 68 65 72 69 74 20 66 72 6f  sn't inherit fro
4410: 6d 20 61 6e 79 74 68 69 6e 67 2e 0a 0a 09 23 20  m anything....# 
4420: 4f 6e 65 20 65 78 63 65 70 74 69 6f 6e 20 66 6f  One exception fo
4430: 72 20 28 61 29 2e 20 49 66 20 77 65 20 61 6c 72  r (a). If we alr
4440: 65 61 64 79 20 68 61 76 65 20 61 20 3a 76 65 6e  eady have a :ven
4450: 64 6f 72 3a 20 62 72 61 6e 63 68 0a 09 23 20 74  dor: branch..# t
4460: 68 65 6e 20 6d 75 6c 74 69 70 6c 65 20 73 79 6d  hen multiple sym
4470: 62 6f 6c 73 20 77 65 72 65 20 75 73 65 64 20 66  bols were used f
4480: 6f 72 20 74 68 65 20 76 65 6e 64 6f 72 20 62 72  or the vendor br
4490: 61 6e 63 68 20 62 79 0a 09 23 20 64 69 66 66 65  anch by..# diffe
44a0: 72 65 6e 74 20 66 69 6c 65 73 2e 20 49 6e 20 74  rent files. In t
44b0: 68 61 74 20 63 61 73 65 20 74 68 65 20 27 6e 65  hat case the 'ne
44c0: 77 27 20 62 72 61 6e 63 68 20 69 73 20 6d 61 64  w' branch is mad
44d0: 65 20 61 6e 0a 09 23 20 61 6c 69 61 73 20 6f 66  e an..# alias of
44e0: 20 74 68 65 20 3a 76 65 6e 64 6f 72 3a 2c 20 65   the :vendor:, e
44f0: 66 66 65 63 74 69 76 65 6c 79 20 6d 65 72 67 69  ffectively mergi
4500: 6e 67 20 74 68 65 20 73 79 6d 62 6f 6c 73 0a 09  ng the symbols..
4510: 23 20 74 6f 67 65 74 68 65 72 2e 0a 0a 09 23 20  # together....# 
4520: 4e 6f 74 65 20 74 68 61 74 20 63 61 73 65 20 28  Note that case (
4530: 62 29 20 6d 61 79 20 6e 65 76 65 72 20 6f 63 63  b) may never occ
4540: 75 72 2e 20 53 65 65 20 74 68 65 20 76 61 72 69  ur. See the vari
4550: 61 62 6c 65 0a 09 23 20 27 6c 61 73 74 64 65 66  able..# 'lastdef
4560: 61 75 6c 74 6f 6e 74 72 75 6e 6b 27 20 69 6e 20  aultontrunk' in 
4570: 74 68 65 20 63 61 6c 6c 65 72 20 28 6d 65 74 68  the caller (meth
4580: 6f 64 20 70 75 73 68 74 6f 29 2e 20 54 68 69 73  od pushto). This
4590: 0a 09 23 20 66 6c 61 67 20 63 61 6e 20 74 68 65  ..# flag can the
45a0: 20 67 65 6e 65 72 61 74 69 6f 6e 20 6f 66 20 74   generation of t
45b0: 68 65 20 77 6f 72 6b 73 70 61 63 65 20 66 6f 72  he workspace for
45c0: 20 74 68 65 20 3a 74 72 75 6e 6b 3a 20 4c 4f 44   the :trunk: LOD
45d0: 0a 09 23 20 61 73 20 77 65 6c 6c 2c 20 6d 61 6b  ..# as well, mak
45e0: 69 6e 67 20 69 74 20 69 6e 68 65 72 69 74 20 74  ing it inherit t
45f0: 68 65 20 73 74 61 74 65 20 6f 66 20 74 68 65 20  he state of the 
4600: 6c 61 73 74 0a 09 23 20 74 72 75 6e 6b 2d 63 68  last..# trunk-ch
4610: 61 6e 67 65 73 65 74 20 6f 6e 20 74 68 65 20 76  angeset on the v
4620: 65 6e 64 6f 72 2d 62 72 61 6e 63 68 2e 0a 0a 09  endor-branch....
4630: 69 66 20 7b 24 69 73 64 65 66 61 75 6c 74 7d 20  if {$isdefault} 
4640: 7b 0a 09 20 20 20 20 69 66 20 7b 21 5b 24 72 73  {..    if {![$rs
4650: 74 61 74 65 20 68 61 73 20 22 3a 76 65 6e 64 6f  tate has ":vendo
4660: 72 3a 22 5d 7d 20 7b 0a 09 09 23 20 43 72 65 61  r:"]} {...# Crea
4670: 74 65 20 74 68 65 20 76 65 6e 64 6f 72 20 62 72  te the vendor br
4680: 61 6e 63 68 20 69 66 20 6e 6f 74 20 70 72 65 73  anch if not pres
4690: 65 6e 74 20 61 6c 72 65 61 64 79 2e 0a 09 09 24  ent already....$
46a0: 72 73 74 61 74 65 20 6e 65 77 20 3a 76 65 6e 64  rstate new :vend
46b0: 6f 72 3a 0a 09 20 20 20 20 7d 0a 09 20 20 20 20  or:..    }..    
46c0: 23 20 4d 65 72 67 65 20 74 68 65 20 6e 65 77 20  # Merge the new 
46d0: 73 79 6d 62 6f 6c 20 74 6f 20 74 68 65 20 76 65  symbol to the ve
46e0: 6e 64 6f 72 20 62 72 61 6e 63 68 0a 09 20 20 20  ndor branch..   
46f0: 20 24 72 73 74 61 74 65 20 64 75 70 20 24 6c 6f   $rstate dup $lo
4700: 64 6e 61 6d 65 20 3c 2d 2d 20 3a 76 65 6e 64 6f  dname <-- :vendo
4710: 72 3a 0a 09 20 20 20 20 72 65 74 75 72 6e 20 5b  r:..    return [
4720: 24 72 73 74 61 74 65 20 67 65 74 20 24 6c 6f 64  $rstate get $lod
4730: 6e 61 6d 65 5d 0a 09 7d 0a 0a 09 69 66 20 7b 24  name]..}...if {$
4740: 6c 6f 64 6e 61 6d 65 20 65 71 20 22 3a 74 72 75  lodname eq ":tru
4750: 6e 6b 3a 22 7d 20 7b 0a 09 20 20 20 20 72 65 74  nk:"} {..    ret
4760: 75 72 6e 20 5b 24 72 73 74 61 74 65 20 6e 65 77  urn [$rstate new
4770: 20 24 6c 6f 64 6e 61 6d 65 5d 0a 09 7d 0a 0a 09   $lodname]..}...
4780: 23 20 43 61 73 65 20 28 63 29 2e 20 57 65 20 66  # Case (c). We f
4790: 69 6e 64 20 74 68 65 20 70 61 72 65 6e 74 20 4c  ind the parent L
47a0: 4f 44 20 6f 66 20 6f 75 72 20 4c 4f 44 20 61 6e  OD of our LOD an
47b0: 64 20 6c 65 74 20 74 68 65 20 6e 65 77 0a 09 23  d let the new..#
47c0: 20 77 6f 72 6b 73 70 61 63 65 20 69 6e 68 65 72   workspace inher
47d0: 69 74 20 66 72 6f 6d 20 74 68 65 20 70 61 72 65  it from the pare
47e0: 6e 74 27 73 20 77 6f 72 6b 73 70 61 63 65 2e 0a  nt's workspace..
47f0: 0a 09 73 65 74 20 70 6c 6f 64 6e 61 6d 65 20 5b  ..set plodname [
4800: 5b 5b 24 70 72 6f 6a 65 63 74 20 67 65 74 73 79  [[$project getsy
4810: 6d 62 6f 6c 20 24 6c 6f 64 6e 61 6d 65 5d 20 70  mbol $lodname] p
4820: 61 72 65 6e 74 5d 20 6e 61 6d 65 5d 0a 0a 09 6c  arent] name]...l
4830: 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73  og write 8 csets
4840: 20 7b 70 4c 4f 44 20 20 20 27 24 70 6c 6f 64 6e   {pLOD   '$plodn
4850: 61 6d 65 27 7d 0a 0a 09 69 66 20 7b 5b 24 72 73  ame'}...if {[$rs
4860: 74 61 74 65 20 68 61 73 20 24 70 6c 6f 64 6e 61  tate has $plodna
4870: 6d 65 5d 7d 20 7b 0a 09 20 20 20 20 72 65 74 75  me]} {..    retu
4880: 72 6e 20 5b 24 72 73 74 61 74 65 20 6e 65 77 20  rn [$rstate new 
4890: 24 6c 6f 64 6e 61 6d 65 20 24 70 6c 6f 64 6e 61  $lodname $plodna
48a0: 6d 65 5d 0a 09 7d 0a 0a 09 66 6f 72 65 61 63 68  me]..}...foreach
48b0: 20 6b 20 5b 6c 73 6f 72 74 20 5b 24 72 73 74 61   k [lsort [$rsta
48c0: 74 65 20 6e 61 6d 65 73 5d 5d 20 7b 0a 09 20 20  te names]] {..  
48d0: 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73    log write 8 cs
48e0: 65 74 73 20 7b 20 20 20 20 24 6b 20 3d 20 5b 5b  ets {    $k = [[
48f0: 24 72 73 74 61 74 65 20 67 65 74 20 24 6b 5d 20  $rstate get $k] 
4900: 67 65 74 69 64 5d 7d 0a 09 7d 0a 0a 09 74 72 6f  getid]}..}...tro
4910: 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 7b 55  uble internal {U
4920: 6e 61 62 6c 65 20 74 6f 20 64 65 74 65 72 6d 69  nable to determi
4930: 6e 65 20 63 68 61 6e 67 65 73 65 74 20 70 61 72  ne changeset par
4940: 65 6e 74 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20  ent}..return.   
4950: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 47 65 74   }..    proc Get
4960: 69 73 64 65 66 61 75 6c 74 20 7b 72 65 76 69 73  isdefault {revis
4970: 69 6f 6e 73 7d 20 7b 0a 09 73 65 74 20 74 68 65  ions} {..set the
4980: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76  set ('[join $rev
4990: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a  isions {','}]').
49a0: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61  ..struct::list a
49b0: 73 73 69 67 6e 20 5b 73 74 61 74 65 20 72 75 6e  ssign [state run
49c0: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
49d0: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
49e0: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  es {..    SELECT
49f0: 20 52 2e 69 73 64 65 66 61 75 6c 74 2c 20 52 2e   R.isdefault, R.
4a00: 64 62 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f  dbchild..    FRO
4a10: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09  M   revision R..
4a20: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64      WHERE  R.rid
4a30: 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d 20   IN $theset  -- 
4a40: 41 6c 6c 20 73 70 65 63 69 66 69 65 64 20 72 65  All specified re
4a50: 76 69 73 69 6f 6e 73 0a 09 20 20 20 20 4c 49 4d  visions..    LIM
4a60: 49 54 20 31 0a 09 7d 5d 5d 20 64 65 66 20 6c 61  IT 1..}]] def la
4a70: 73 74 0a 0a 09 23 20 54 4f 44 4f 2f 43 48 45 43  st...# TODO/CHEC
4a80: 4b 3a 20 6c 6f 6f 6b 20 66 6f 72 20 63 68 61 6e  K: look for chan
4a90: 67 65 73 65 74 73 20 77 68 65 72 65 20 69 73 64  gesets where isd
4aa0: 65 66 61 75 6c 74 2f 64 62 63 68 69 6c 64 20 69  efault/dbchild i
4ab0: 73 0a 09 23 20 61 6d 62 69 67 6f 75 73 2e 0a 0a  s..# ambigous...
4ac0: 09 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24 64  .return [list $d
4ad0: 65 66 20 5b 65 78 70 72 20 7b 24 6c 61 73 74 20  ef [expr {$last 
4ae0: 6e 65 20 22 22 7d 5d 5d 0a 20 20 20 20 7d 0a 0a  ne ""}]].    }..
4af0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73      typemethod s
4b00: 70 6c 69 74 20 7b 63 73 65 74 20 61 72 67 73 7d  plit {cset args}
4b10: 20 7b 0a 09 23 20 41 73 20 70 61 72 74 20 6f 66   {..# As part of
4b20: 20 74 68 65 20 63 72 65 61 74 69 6f 6e 20 6f 66   the creation of
4b30: 20 74 68 65 20 6e 65 77 20 63 68 61 6e 67 65 73   the new changes
4b40: 65 74 73 20 73 70 65 63 69 66 69 65 64 20 69 6e  ets specified in
4b50: 0a 09 23 20 41 52 47 53 20 61 73 20 73 65 74 73  ..# ARGS as sets
4b60: 20 6f 66 20 69 74 65 6d 73 2c 20 61 6c 6c 20 73   of items, all s
4b70: 75 62 73 65 74 73 20 6f 66 20 43 53 45 54 27 73  ubsets of CSET's
4b80: 20 69 74 65 6d 20 73 65 74 2c 20 43 53 45 54 0a   item set, CSET.
4b90: 09 23 20 77 69 6c 6c 20 62 65 20 64 72 6f 70 70  .# will be dropp
4ba0: 65 64 20 66 72 6f 6d 20 61 6c 6c 20 64 61 74 61  ed from all data
4bb0: 62 61 73 65 73 2c 20 69 6e 20 61 6e 64 20 6f 75  bases, in and ou
4bc0: 74 20 6f 66 20 6d 65 6d 6f 72 79 2c 0a 09 23 20  t of memory,..# 
4bd0: 61 6e 64 20 74 68 65 6e 20 64 65 73 74 72 6f 79  and then destroy
4be0: 65 64 2e 0a 09 23 0a 09 23 20 4e 6f 74 65 3a 20  ed...#..# Note: 
4bf0: 54 68 65 20 69 74 65 6d 20 6c 69 73 74 73 20 66  The item lists f
4c00: 6f 75 6e 64 20 69 6e 20 61 72 67 73 20 61 72 65  ound in args are
4c10: 20 74 61 67 67 65 64 20 69 74 65 6d 73 2e 20 54   tagged items. T
4c20: 68 65 79 0a 09 23 20 68 61 76 65 20 74 6f 20 68  hey..# have to h
4c30: 61 76 65 20 74 68 65 20 73 61 6d 65 20 74 79 70  ave the same typ
4c40: 65 20 61 73 20 74 68 65 20 63 68 61 6e 67 65 73  e as the changes
4c50: 65 74 2c 20 62 65 69 6e 67 20 73 75 62 73 65 74  et, being subset
4c60: 73 0a 09 23 20 6f 66 20 69 74 73 20 69 74 65 6d  s..# of its item
4c70: 73 2e 20 54 68 69 73 20 69 73 20 63 68 65 63 6b  s. This is check
4c80: 65 64 20 69 6e 20 55 6e 74 61 67 31 2e 0a 0a 09  ed in Untag1....
4c90: 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74  log write 8 cset
4ca0: 73 20 7b 4f 4c 44 3a 20 5b 6c 73 6f 72 74 20 5b  s {OLD: [lsort [
4cb0: 24 63 73 65 74 20 69 74 65 6d 73 5d 5d 7d 0a 09  $cset items]]}..
4cc0: 56 61 6c 69 64 61 74 65 46 72 61 67 6d 65 6e 74  ValidateFragment
4cd0: 73 20 24 63 73 65 74 20 24 61 72 67 73 0a 0a 09  s $cset $args...
4ce0: 23 20 41 6c 6c 20 63 68 65 63 6b 73 20 70 61 73  # All checks pas
4cf0: 73 2c 20 61 63 74 75 61 6c 6c 79 20 70 65 72 66  s, actually perf
4d00: 6f 72 6d 20 74 68 65 20 73 70 6c 69 74 2e 0a 0a  orm the split...
4d10: 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73  .struct::list as
4d20: 73 69 67 6e 20 5b 24 63 73 65 74 20 64 61 74 61  sign [$cset data
4d30: 5d 20 70 72 6f 6a 65 63 74 20 63 73 74 79 70 65  ] project cstype
4d40: 20 63 73 73 72 63 0a 0a 09 73 65 74 20 70 72 65   cssrc...set pre
4d50: 64 65 63 65 73 73 6f 72 73 20 5b 24 63 73 65 74  decessors [$cset
4d60: 20 64 72 6f 70 5d 0a 09 24 63 73 65 74 20 64 65   drop]..$cset de
4d70: 73 74 72 6f 79 0a 0a 09 73 65 74 20 6e 65 77 63  stroy...set newc
4d80: 73 65 74 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68  sets {}..foreach
4d90: 20 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 20 24   fragmentitems $
4da0: 61 72 67 73 20 7b 0a 09 20 20 20 20 6c 6f 67 20  args {..    log 
4db0: 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b 4d  write 8 csets {M
4dc0: 41 4b 45 3a 20 5b 6c 73 6f 72 74 20 24 66 72 61  AKE: [lsort $fra
4dd0: 67 6d 65 6e 74 69 74 65 6d 73 5d 7d 0a 0a 09 20  gmentitems]}... 
4de0: 20 20 20 73 65 74 20 66 72 61 67 6d 65 6e 74 20     set fragment 
4df0: 5b 24 74 79 70 65 20 25 41 55 54 4f 25 20 24 70  [$type %AUTO% $p
4e00: 72 6f 6a 65 63 74 20 24 63 73 74 79 70 65 20 24  roject $cstype $
4e10: 63 73 73 72 63 20 5c 0a 09 09 09 20 20 20 20 20  cssrc \....     
4e20: 20 5b 55 6e 74 61 67 20 24 66 72 61 67 6d 65 6e   [Untag $fragmen
4e30: 74 69 74 65 6d 73 20 24 63 73 74 79 70 65 5d 5d  titems $cstype]]
4e40: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 6e 65  ..    lappend ne
4e50: 77 63 73 65 74 73 20 24 66 72 61 67 6d 65 6e 74  wcsets $fragment
4e60: 0a 0a 09 20 20 20 20 24 66 72 61 67 6d 65 6e 74  ...    $fragment
4e70: 20 70 65 72 73 69 73 74 0a 09 20 20 20 20 24 66   persist..    $f
4e80: 72 61 67 6d 65 6e 74 20 64 65 74 65 72 6d 69 6e  ragment determin
4e90: 65 73 75 63 63 65 73 73 6f 72 73 0a 09 7d 0a 0a  esuccessors..}..
4ea0: 09 23 20 54 68 65 20 70 72 65 64 65 63 65 73 73  .# The predecess
4eb0: 6f 72 73 20 68 61 76 65 20 74 6f 20 72 65 63 6f  ors have to reco
4ec0: 6d 70 75 74 65 20 74 68 65 69 72 20 73 75 63 63  mpute their succ
4ed0: 65 73 73 6f 72 73 2c 20 69 2e 65 2e 0a 09 23 20  essors, i.e...# 
4ee0: 72 65 6d 6f 76 65 20 74 68 65 20 64 72 6f 70 70  remove the dropp
4ef0: 65 64 20 63 68 61 6e 67 65 73 65 74 20 61 6e 64  ed changeset and
4f00: 20 70 75 74 20 6f 6e 65 20 6f 66 20 74 68 65 20   put one of the 
4f10: 66 72 61 67 6d 65 6e 74 73 0a 09 23 20 69 6e 74  fragments..# int
4f20: 6f 20 69 74 73 20 70 6c 61 63 65 2e 0a 09 66 6f  o its place...fo
4f30: 72 65 61 63 68 20 70 20 24 70 72 65 64 65 63 65  reach p $predece
4f40: 73 73 6f 72 73 20 7b 0a 09 20 20 20 20 24 70 20  ssors {..    $p 
4f50: 64 65 74 65 72 6d 69 6e 65 73 75 63 63 65 73 73  determinesuccess
4f60: 6f 72 73 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 20  ors..}...return 
4f70: 24 6e 65 77 63 73 65 74 73 0a 20 20 20 20 7d 0a  $newcsets.    }.
4f80: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
4f90: 69 74 65 6d 73 74 72 20 7b 69 74 65 6d 7d 20 7b  itemstr {item} {
4fa0: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61  ..struct::list a
4fb0: 73 73 69 67 6e 20 24 69 74 65 6d 20 69 74 79 70  ssign $item ityp
4fc0: 65 20 69 69 64 0a 09 72 65 74 75 72 6e 20 5b 24  e iid..return [$
4fd0: 69 74 79 70 65 20 73 74 72 20 24 69 69 64 5d 0a  itype str $iid].
4fe0: 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d      }..    typem
4ff0: 65 74 68 6f 64 20 73 74 72 6c 69 73 74 20 7b 63  ethod strlist {c
5000: 68 61 6e 67 65 73 65 74 73 7d 20 7b 0a 09 72 65  hangesets} {..re
5010: 74 75 72 6e 20 5b 6a 6f 69 6e 20 5b 73 74 72 75  turn [join [stru
5020: 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 63 68  ct::list map $ch
5030: 61 6e 67 65 73 65 74 73 20 5b 6d 79 70 72 6f 63  angesets [myproc
5040: 20 49 44 5d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20   ID]]].    }..  
5050: 20 20 70 72 6f 63 20 49 44 20 7b 63 73 65 74 7d    proc ID {cset}
5060: 20 7b 20 24 63 73 65 74 20 73 74 72 20 7d 0a 0a   { $cset str }..
5070: 20 20 20 20 70 72 6f 63 20 55 6e 74 61 67 20 7b      proc Untag {
5080: 74 61 67 67 65 64 69 74 65 6d 73 20 63 73 74 79  taggeditems csty
5090: 70 65 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 73  pe} {..return [s
50a0: 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20  truct::list map 
50b0: 24 74 61 67 67 65 64 69 74 65 6d 73 20 5b 6d 79  $taggeditems [my
50c0: 70 72 6f 63 20 55 6e 74 61 67 31 20 24 63 73 74  proc Untag1 $cst
50d0: 79 70 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20  ype]].    }..   
50e0: 20 70 72 6f 63 20 55 6e 74 61 67 31 20 7b 63 73   proc Untag1 {cs
50f0: 74 79 70 65 20 74 68 65 69 74 65 6d 7d 20 7b 0a  type theitem} {.
5100: 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73  .struct::list as
5110: 73 69 67 6e 20 24 74 68 65 69 74 65 6d 20 74 20  sign $theitem t 
5120: 69 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73 73  i..integrity ass
5130: 65 72 74 20 7b 24 63 73 74 79 70 65 20 65 71 20  ert {$cstype eq 
5140: 24 74 7d 20 7b 49 74 65 6d 20 24 69 27 73 20 74  $t} {Item $i's t
5150: 79 70 65 20 69 73 20 27 24 74 27 2c 20 65 78 70  ype is '$t', exp
5160: 65 63 74 65 64 20 27 24 63 73 74 79 70 65 27 7d  ected '$cstype'}
5170: 0a 09 72 65 74 75 72 6e 20 24 69 0a 20 20 20 20  ..return $i.    
5180: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 54 61 67 49  }..    proc TagI
5190: 74 65 6d 44 69 63 74 20 7b 69 74 65 6d 64 69 63  temDict {itemdic
51a0: 74 20 63 73 74 79 70 65 7d 20 7b 0a 09 73 65 74  t cstype} {..set
51b0: 20 72 65 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68   res {}..foreach
51c0: 20 7b 69 20 76 7d 20 24 69 74 65 6d 64 69 63 74   {i v} $itemdict
51d0: 20 7b 20 6c 61 70 70 65 6e 64 20 72 65 73 20 5b   { lappend res [
51e0: 6c 69 73 74 20 24 63 73 74 79 70 65 20 24 69 5d  list $cstype $i]
51f0: 20 24 76 20 7d 0a 09 72 65 74 75 72 6e 20 24 72   $v }..return $r
5200: 65 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  es.    }..    pr
5210: 6f 63 20 56 61 6c 69 64 61 74 65 46 72 61 67 6d  oc ValidateFragm
5220: 65 6e 74 73 20 7b 63 73 65 74 20 66 72 61 67 6d  ents {cset fragm
5230: 65 6e 74 73 7d 20 7b 0a 09 23 20 43 68 65 63 6b  ents} {..# Check
5240: 20 74 68 65 20 76 61 72 69 6f 75 73 20 69 6e 74   the various int
5250: 65 67 72 69 74 79 20 63 6f 6e 73 74 72 61 69 6e  egrity constrain
5260: 74 73 20 66 6f 72 20 74 68 65 20 66 72 61 67 6d  ts for the fragm
5270: 65 6e 74 73 0a 09 23 20 73 70 65 63 69 66 79 69  ents..# specifyi
5280: 6e 67 20 68 6f 77 20 74 6f 20 73 70 6c 69 74 20  ng how to split 
5290: 74 68 65 20 63 68 61 6e 67 65 73 65 74 3a 0a 09  the changeset:..
52a0: 23 0a 09 23 20 2a 20 57 65 20 6d 75 73 74 20 68  #..# * We must h
52b0: 61 76 65 20 74 77 6f 20 6f 72 20 6d 6f 72 65 20  ave two or more 
52c0: 66 72 61 67 6d 65 6e 74 73 2c 20 61 73 20 73 70  fragments, as sp
52d0: 6c 69 74 74 69 6e 67 20 61 0a 09 23 20 20 20 63  litting a..#   c
52e0: 68 61 6e 67 65 73 65 74 20 69 6e 74 6f 20 6f 6e  hangeset into on
52f0: 65 20 6d 61 6b 65 73 20 6e 6f 20 73 65 6e 73 65  e makes no sense
5300: 2e 0a 09 23 20 2a 20 4e 6f 20 66 72 61 67 6d 65  ...# * No fragme
5310: 6e 74 20 6d 61 79 20 62 65 20 65 6d 70 74 79 2e  nt may be empty.
5320: 0a 09 23 20 2a 20 41 6c 6c 20 66 72 61 67 6d 65  ..# * All fragme
5330: 6e 74 73 20 68 61 76 65 20 74 6f 20 62 65 20 74  nts have to be t
5340: 72 75 65 20 73 75 62 73 65 74 73 20 6f 66 20 74  rue subsets of t
5350: 68 65 20 69 74 65 6d 73 20 69 6e 20 74 68 65 0a  he items in the.
5360: 09 23 20 20 20 63 68 61 6e 67 65 73 65 74 20 74  .#   changeset t
5370: 6f 20 73 70 6c 69 74 2e 20 54 68 65 20 27 74 72  o split. The 'tr
5380: 75 65 27 20 69 73 20 69 6d 70 6c 69 65 64 20 62  ue' is implied b
5390: 65 63 61 75 73 65 20 6e 6f 6e 65 20 61 72 65 0a  ecause none are.
53a0: 09 23 20 20 20 61 6c 6c 6f 77 65 64 20 74 6f 20  .#   allowed to 
53b0: 62 65 20 65 6d 70 74 79 2c 20 73 6f 20 65 61 63  be empty, so eac
53c0: 68 20 68 61 73 20 74 6f 20 62 65 20 73 6d 61 6c  h has to be smal
53d0: 6c 65 72 20 74 68 61 6e 20 74 68 65 0a 09 23 20  ler than the..# 
53e0: 20 20 74 6f 74 61 6c 2e 0a 09 23 20 2a 20 54 68    total...# * Th
53f0: 65 20 75 6e 69 6f 6e 20 6f 66 20 74 68 65 20 66  e union of the f
5400: 72 61 67 6d 65 6e 74 73 20 68 61 73 20 74 6f 20  ragments has to 
5410: 62 65 20 74 68 65 20 69 74 65 6d 20 73 65 74 20  be the item set 
5420: 6f 66 20 74 68 65 0a 09 23 20 20 20 63 68 61 6e  of the..#   chan
5430: 67 65 73 65 74 2e 0a 09 23 20 2a 20 54 68 65 20  geset...# * The 
5440: 66 72 61 67 6d 65 6e 74 20 6d 75 73 74 20 6e 6f  fragment must no
5450: 74 20 6f 76 65 72 6c 61 70 2c 20 69 2e 65 2e 20  t overlap, i.e. 
5460: 74 68 65 69 72 20 70 61 69 72 77 69 73 65 0a 09  their pairwise..
5470: 23 20 20 20 69 6e 74 65 72 73 65 63 74 69 6f 6e  #   intersection
5480: 73 20 68 61 76 65 20 74 6f 20 62 65 20 65 6d 70  s have to be emp
5490: 74 79 2e 0a 0a 09 73 65 74 20 63 6f 76 65 72 20  ty....set cover 
54a0: 7b 7d 0a 09 66 6f 72 65 61 63 68 20 66 72 61 67  {}..foreach frag
54b0: 6d 65 6e 74 69 74 65 6d 73 20 24 66 72 61 67 6d  mentitems $fragm
54c0: 65 6e 74 73 20 7b 0a 09 20 20 20 20 6c 6f 67 20  ents {..    log 
54d0: 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b 4e  write 8 csets {N
54e0: 45 57 3a 20 5b 6c 73 6f 72 74 20 24 66 72 61 67  EW: [lsort $frag
54f0: 6d 65 6e 74 69 74 65 6d 73 5d 7d 0a 0a 09 20 20  mentitems]}...  
5500: 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73 65    integrity asse
5510: 72 74 20 7b 0a 09 09 21 5b 73 74 72 75 63 74 3a  rt {...![struct:
5520: 3a 73 65 74 20 65 6d 70 74 79 20 24 66 72 61 67  :set empty $frag
5530: 6d 65 6e 74 69 74 65 6d 73 5d 0a 09 20 20 20 20  mentitems]..    
5540: 7d 20 7b 63 68 61 6e 67 65 73 65 74 20 66 72 61  } {changeset fra
5550: 67 6d 65 6e 74 20 69 73 20 65 6d 70 74 79 7d 0a  gment is empty}.
5560: 0a 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20  ..    integrity 
5570: 61 73 73 65 72 74 20 7b 0a 09 09 5b 73 74 72 75  assert {...[stru
5580: 63 74 3a 3a 73 65 74 20 73 75 62 73 65 74 6f 66  ct::set subsetof
5590: 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 20   $fragmentitems 
55a0: 5b 24 63 73 65 74 20 69 74 65 6d 73 5d 5d 0a 09  [$cset items]]..
55b0: 20 20 20 20 7d 20 7b 63 68 61 6e 67 65 73 65 74      } {changeset
55c0: 20 66 72 61 67 6d 65 6e 74 20 69 73 20 6e 6f 74   fragment is not
55d0: 20 61 20 73 75 62 73 65 74 7d 0a 09 20 20 20 20   a subset}..    
55e0: 73 74 72 75 63 74 3a 3a 73 65 74 20 61 64 64 20  struct::set add 
55f0: 63 6f 76 65 72 20 24 66 72 61 67 6d 65 6e 74 69  cover $fragmenti
5600: 74 65 6d 73 0a 09 7d 0a 0a 09 69 6e 74 65 67 72  tems..}...integr
5610: 69 74 79 20 61 73 73 65 72 74 20 7b 0a 09 20 20  ity assert {..  
5620: 20 20 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 65    [struct::set e
5630: 71 75 61 6c 20 24 63 6f 76 65 72 20 5b 24 63 73  qual $cover [$cs
5640: 65 74 20 69 74 65 6d 73 5d 5d 0a 09 20 7d 20 7b  et items]].. } {
5650: 54 68 65 20 66 72 61 67 6d 65 6e 74 73 20 64 6f  The fragments do
5660: 20 6e 6f 74 20 63 6f 76 65 72 20 74 68 65 20 6f   not cover the o
5670: 72 69 67 69 6e 61 6c 20 63 68 61 6e 67 65 73 65  riginal changese
5680: 74 7d 0a 0a 09 73 65 74 20 69 20 31 0a 09 66 6f  t}...set i 1..fo
5690: 72 65 61 63 68 20 66 69 61 20 24 66 72 61 67 6d  reach fia $fragm
56a0: 65 6e 74 73 20 7b 0a 09 20 20 20 20 66 6f 72 65  ents {..    fore
56b0: 61 63 68 20 66 69 62 20 5b 6c 72 61 6e 67 65 20  ach fib [lrange 
56c0: 24 66 72 61 67 6d 65 6e 74 73 20 24 69 20 65 6e  $fragments $i en
56d0: 64 5d 20 7b 0a 09 09 69 6e 74 65 67 72 69 74 79  d] {...integrity
56e0: 20 61 73 73 65 72 74 20 7b 0a 09 09 20 20 20 20   assert {...    
56f0: 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 65 6d 70  [struct::set emp
5700: 74 79 20 5b 73 74 72 75 63 74 3a 3a 73 65 74 20  ty [struct::set 
5710: 69 6e 74 65 72 73 65 63 74 20 24 66 69 61 20 24  intersect $fia $
5720: 66 69 62 5d 5d 0a 09 09 7d 20 7b 54 68 65 20 66  fib]]...} {The f
5730: 72 61 67 6d 65 6e 74 73 20 3c 24 66 69 61 3e 20  ragments <$fia> 
5740: 61 6e 64 20 3c 24 66 69 62 3e 20 6f 76 65 72 6c  and <$fib> overl
5750: 61 70 7d 0a 09 20 20 20 20 7d 0a 09 20 20 20 20  ap}..    }..    
5760: 69 6e 63 72 20 69 0a 09 7d 0a 0a 09 72 65 74 75  incr i..}...retu
5770: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  rn.    }..    # 
5780: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
5790: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
57a0: 23 23 23 23 23 0a 20 20 20 20 23 23 20 53 74 61  #####.    ## Sta
57b0: 74 65 0a 0a 20 20 20 20 76 61 72 69 61 62 6c 65  te..    variable
57c0: 20 6d 79 69 64 20 20 20 20 20 20 20 20 7b 7d 20   myid        {} 
57d0: 3b 20 23 20 49 64 20 6f 66 20 74 68 65 20 63 73  ; # Id of the cs
57e0: 65 74 20 66 6f 72 20 74 68 65 20 70 65 72 73 69  et for the persi
57f0: 73 74 65 6e 74 0a 09 09 09 20 20 20 20 20 20 23  stent....      #
5800: 20 73 74 61 74 65 2e 0a 20 20 20 20 76 61 72 69   state..    vari
5810: 61 62 6c 65 20 6d 79 70 72 6f 6a 65 63 74 20 20  able myproject  
5820: 20 7b 7d 20 3b 20 23 20 52 65 66 65 72 65 6e 63   {} ; # Referenc
5830: 65 20 6f 66 20 74 68 65 20 70 72 6f 6a 65 63 74  e of the project
5840: 20 6f 62 6a 65 63 74 20 74 68 65 0a 09 09 09 20   object the.... 
5850: 20 20 20 20 20 23 20 63 68 61 6e 67 65 73 65 74       # changeset
5860: 20 62 65 6c 6f 6e 67 73 20 74 6f 2e 0a 20 20 20   belongs to..   
5870: 20 76 61 72 69 61 62 6c 65 20 6d 79 74 79 70 65   variable mytype
5880: 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 57 68 61        {} ; # Wha
5890: 74 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20  t the changeset 
58a0: 69 73 20 62 61 73 65 64 20 6f 6e 0a 09 09 09 20  is based on.... 
58b0: 20 20 20 20 20 23 20 28 72 65 76 69 73 69 6f 6e       # (revision
58c0: 73 2c 20 74 61 67 73 2c 20 6f 72 20 62 72 61 6e  s, tags, or bran
58d0: 63 68 65 73 29 2e 0a 09 09 09 20 20 20 20 20 20  ches).....      
58e0: 23 20 56 61 6c 75 65 73 3a 20 53 65 65 20 6d 79  # Values: See my
58f0: 63 73 74 79 70 65 2e 20 4e 6f 74 65 20 74 68 61  cstype. Note tha
5900: 74 20 77 65 0a 09 09 09 20 20 20 20 20 20 23 20  t we....      # 
5910: 68 61 76 65 20 74 6f 20 6b 65 65 70 20 74 68 65  have to keep the
5920: 20 6e 61 6d 65 73 20 6f 66 20 74 68 65 20 68 65   names of the he
5930: 6c 70 65 72 0a 09 09 09 20 20 20 20 20 20 23 20  lper....      # 
5940: 73 69 6e 67 6c 65 74 6f 6e 73 20 69 6e 20 73 79  singletons in sy
5950: 6e 63 20 77 69 74 68 20 74 68 65 20 63 6f 6e 74  nc with the cont
5960: 65 6e 74 73 0a 09 09 09 20 20 20 20 20 20 23 20  ents....      # 
5970: 6f 66 20 73 74 61 74 65 20 74 61 62 6c 65 20 27  of state table '
5980: 63 73 74 79 70 65 27 2c 20 61 6e 64 20 76 61 72  cstype', and var
5990: 69 6f 75 73 0a 09 09 09 20 20 20 20 20 20 23 20  ious....      # 
59a0: 6f 74 68 65 72 20 70 6c 61 63 65 73 20 75 73 69  other places usi
59b0: 6e 67 20 74 68 65 6d 20 68 61 72 64 77 69 72 65  ng them hardwire
59c0: 64 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20  d..    variable 
59d0: 6d 79 74 79 70 65 6f 62 6a 20 20 20 7b 7d 20 3b  mytypeobj   {} ;
59e0: 20 23 20 52 65 66 65 72 65 6e 63 65 20 74 6f 20   # Reference to 
59f0: 74 68 65 20 63 6f 6e 74 61 69 6e 65 72 20 66 6f  the container fo
5a00: 72 20 74 68 65 0a 09 09 09 20 20 20 20 20 20 23  r the....      #
5a10: 20 74 79 70 65 20 64 65 70 65 6e 64 65 6e 74 20   type dependent 
5a20: 63 6f 64 65 2e 20 44 65 72 69 76 65 64 20 66 72  code. Derived fr
5a30: 6f 6d 0a 09 09 09 20 20 20 20 20 20 23 20 6d 79  om....      # my
5a40: 74 79 70 65 2e 0a 20 20 20 20 76 61 72 69 61 62  type..    variab
5a50: 6c 65 20 6d 79 73 72 63 69 64 20 20 20 20 20 7b  le mysrcid     {
5a60: 7d 20 3b 20 23 20 49 64 20 6f 66 20 74 68 65 20  } ; # Id of the 
5a70: 6d 65 74 61 64 61 74 61 20 6f 72 20 73 79 6d 62  metadata or symb
5a80: 6f 6c 20 74 68 65 20 63 73 65 74 0a 09 09 09 20  ol the cset.... 
5a90: 20 20 20 20 20 23 20 69 73 20 62 61 73 65 64 20       # is based 
5aa0: 6f 6e 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65  on..    variable
5ab0: 20 6d 79 69 74 65 6d 73 20 20 20 20 20 7b 7d 20   myitems     {} 
5ac0: 3b 20 23 20 4c 69 73 74 20 6f 66 20 74 68 65 20  ; # List of the 
5ad0: 66 69 6c 65 20 6c 65 76 65 6c 20 72 65 76 69 73  file level revis
5ae0: 69 6f 6e 73 2c 0a 09 09 09 20 20 20 20 20 20 23  ions,....      #
5af0: 20 74 61 67 73 2c 20 6f 72 20 62 72 61 6e 63 68   tags, or branch
5b00: 65 73 20 69 6e 20 74 68 65 20 63 73 65 74 2c 20  es in the cset, 
5b10: 61 73 0a 09 09 09 20 20 20 20 20 20 23 20 69 64  as....      # id
5b20: 73 2e 20 4e 6f 74 20 74 61 67 67 65 64 2e 0a 20  s. Not tagged.. 
5b30: 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 74 69     variable myti
5b40: 74 65 6d 73 20 20 20 20 7b 7d 20 3b 20 23 20 41  tems    {} ; # A
5b50: 73 20 6d 79 69 74 65 6d 73 2c 20 74 68 65 20 74  s myitems, the t
5b60: 61 67 67 65 64 20 66 6f 72 6d 2e 0a 20 20 20 20  agged form..    
5b70: 76 61 72 69 61 62 6c 65 20 6d 79 70 6f 73 20 20  variable mypos  
5b80: 20 20 20 20 20 7b 7d 20 3b 20 23 20 43 6f 6d 6d       {} ; # Comm
5b90: 69 74 20 70 6f 73 69 74 69 6f 6e 20 6f 66 20 74  it position of t
5ba0: 68 65 20 63 68 61 6e 67 65 73 65 74 2c 20 69 66  he changeset, if
5bb0: 0a 09 09 09 20 20 20 20 20 20 23 20 6b 6e 6f 77  ....      # know
5bc0: 6e 2e 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23  n...    # # ## #
5bd0: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
5be0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  # #############.
5bf0: 20 20 20 20 23 23 20 49 6e 74 65 72 6e 61 6c 20      ## Internal 
5c00: 6d 65 74 68 6f 64 73 0a 0a 20 20 20 20 74 79 70  methods..    typ
5c10: 65 76 61 72 69 61 62 6c 65 20 6d 79 63 6f 75 6e  evariable mycoun
5c20: 74 65 72 20 20 20 20 20 20 20 20 30 20 3b 20 23  ter        0 ; #
5c30: 20 49 64 20 63 6f 75 6e 74 65 72 20 66 6f 72 20   Id counter for 
5c40: 63 73 65 74 73 2e 20 4c 61 73 74 20 69 64 0a 09  csets. Last id..
5c50: 09 09 09 20 20 20 20 20 20 23 20 75 73 65 64 2e  ...      # used.
5c60: 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c  .    typevariabl
5c70: 65 20 6d 79 63 73 74 79 70 65 20 2d 61 72 72 61  e mycstype -arra
5c80: 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 63 73 74  y {} ; # Map cst
5c90: 79 70 65 73 20 28 6e 61 6d 65 73 29 20 74 6f 20  ypes (names) to 
5ca0: 70 65 72 73 69 73 74 65 6e 74 0a 09 09 09 09 20  persistent..... 
5cb0: 20 20 20 20 20 23 20 69 64 73 2e 20 4e 6f 74 65       # ids. Note
5cc0: 20 74 68 61 74 20 77 65 20 68 61 76 65 20 74 6f   that we have to
5cd0: 20 6b 65 65 70 0a 09 09 09 09 20 20 20 20 20 20   keep.....      
5ce0: 23 20 74 68 65 20 6e 61 6d 65 73 20 69 6e 20 74  # the names in t
5cf0: 68 65 20 74 61 62 6c 65 20 27 63 73 74 79 70 65  he table 'cstype
5d00: 27 0a 09 09 09 09 20 20 20 20 20 20 23 20 69 6e  '.....      # in
5d10: 20 73 79 6e 63 20 77 69 74 68 20 74 68 65 20 6e   sync with the n
5d20: 61 6d 65 73 20 6f 66 20 74 68 65 0a 09 09 09 09  ames of the.....
5d30: 20 20 20 20 20 20 23 20 68 65 6c 70 65 72 20 73        # helper s
5d40: 69 6e 67 6c 65 74 6f 6e 73 2e 0a 0a 20 20 20 20  ingletons...    
5d50: 74 79 70 65 6d 65 74 68 6f 64 20 69 6e 6f 72 64  typemethod inord
5d60: 65 72 20 7b 70 72 6f 6a 65 63 74 69 64 7d 20 7b  er {projectid} {
5d70: 0a 09 23 20 52 65 74 75 72 6e 20 61 6c 6c 20 72  ..# Return all r
5d80: 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65  evision changese
5d90: 74 73 20 66 6f 72 20 74 68 65 20 73 70 65 63 69  ts for the speci
5da0: 66 69 65 64 20 70 72 6f 6a 65 63 74 2c 20 69 6e  fied project, in
5db0: 0a 09 23 20 74 68 65 20 6f 72 64 65 72 20 67 69  ..# the order gi
5dc0: 76 65 6e 20 74 6f 20 74 68 65 6d 20 62 79 20 74  ven to them by t
5dd0: 68 65 20 73 6f 72 74 20 70 61 73 73 65 73 2e 20  he sort passes. 
5de0: 42 6f 74 68 20 74 68 65 0a 09 23 20 66 69 6c 74  Both the..# filt
5df0: 65 72 69 6e 67 20 62 79 20 70 72 6f 6a 65 63 74  ering by project
5e00: 20 61 6e 64 20 73 6f 72 74 69 6e 67 20 6d 61 6b   and sorting mak
5e10: 65 20 75 73 65 20 6f 66 20 27 70 72 6f 6a 65 63  e use of 'projec
5e20: 74 3a 3a 72 65 76 0a 09 23 20 72 65 76 27 20 69  t::rev..# rev' i
5e30: 6d 70 6f 73 73 69 62 6c 65 2e 0a 0a 09 73 65 74  mpossible....set
5e40: 20 72 65 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68   res {}..foreach
5e50: 20 7b 63 69 64 20 63 64 61 74 65 7d 20 5b 73 74   {cid cdate} [st
5e60: 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53  ate run {..    S
5e70: 45 4c 45 43 54 20 43 2e 63 69 64 2c 20 54 2e 64  ELECT C.cid, T.d
5e80: 61 74 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  ate..    FROM   
5e90: 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 74  changeset C, cst
5ea0: 69 6d 65 73 74 61 6d 70 20 54 0a 09 20 20 20 20  imestamp T..    
5eb0: 57 48 45 52 45 20 20 43 2e 74 79 70 65 20 3d 20  WHERE  C.type = 
5ec0: 30 20 20 20 20 20 20 20 20 20 20 2d 2d 20 6c 69  0          -- li
5ed0: 6d 69 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 20  mit to revision 
5ee0: 63 68 61 6e 67 65 73 65 74 73 0a 09 20 20 20 20  changesets..    
5ef0: 41 4e 44 20 20 20 20 43 2e 70 69 64 20 20 3d 20  AND    C.pid  = 
5f00: 24 70 72 6f 6a 65 63 74 69 64 20 2d 2d 20 6c 69  $projectid -- li
5f10: 6d 69 74 20 74 6f 20 63 68 61 6e 67 65 73 65 74  mit to changeset
5f20: 73 20 69 6e 20 70 72 6f 6a 65 63 74 0a 09 20 20  s in project..  
5f30: 20 20 41 4e 44 20 20 20 20 54 2e 63 69 64 20 20    AND    T.cid  
5f40: 3d 20 43 2e 63 69 64 20 20 20 20 20 20 2d 2d 20  = C.cid      -- 
5f50: 67 65 74 20 6f 72 64 65 72 69 6e 67 20 69 6e 66  get ordering inf
5f60: 6f 72 6d 61 74 69 6f 6e 0a 09 20 20 20 20 4f 52  ormation..    OR
5f70: 44 45 52 20 42 59 20 54 2e 64 61 74 65 20 20 20  DER BY T.date   
5f80: 20 20 20 20 20 20 20 20 20 2d 2d 20 73 6f 72 74           -- sort
5f90: 20 69 6e 74 6f 20 63 6f 6d 6d 69 74 20 6f 72 64   into commit ord
5fa0: 65 72 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 6c 61  er..}] {..    la
5fb0: 70 70 65 6e 64 20 72 65 73 20 24 6d 79 69 64 6d  ppend res $myidm
5fc0: 61 70 28 24 63 69 64 29 20 24 63 64 61 74 65 0a  ap($cid) $cdate.
5fd0: 09 7d 0a 09 72 65 74 75 72 6e 20 24 72 65 73 0a  .}..return $res.
5fe0: 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d      }..    typem
5ff0: 65 74 68 6f 64 20 67 65 74 63 73 74 79 70 65 73  ethod getcstypes
6000: 20 7b 7d 20 7b 0a 09 66 6f 72 65 61 63 68 20 7b   {} {..foreach {
6010: 74 69 64 20 6e 61 6d 65 7d 20 5b 73 74 61 74 65  tid name} [state
6020: 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45   run {..    SELE
6030: 43 54 20 74 69 64 2c 20 6e 61 6d 65 20 46 52 4f  CT tid, name FRO
6040: 4d 20 63 73 74 79 70 65 3b 0a 09 7d 5d 20 7b 20  M cstype;..}] { 
6050: 73 65 74 20 6d 79 63 73 74 79 70 65 28 24 6e 61  set mycstype($na
6060: 6d 65 29 20 24 74 69 64 20 7d 0a 09 72 65 74 75  me) $tid }..retu
6070: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79  rn.    }..    ty
6080: 70 65 6d 65 74 68 6f 64 20 6c 6f 61 64 20 7b 72  pemethod load {r
6090: 65 70 6f 73 69 74 6f 72 79 7d 20 7b 0a 09 73 65  epository} {..se
60a0: 74 20 6e 20 30 0a 09 6c 6f 67 20 77 72 69 74 65  t n 0..log write
60b0: 20 32 20 63 73 65 74 73 20 7b 4c 6f 61 64 69 6e   2 csets {Loadin
60c0: 67 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 73  g the changesets
60d0: 7d 0a 09 66 6f 72 65 61 63 68 20 7b 69 64 20 70  }..foreach {id p
60e0: 69 64 20 63 73 74 79 70 65 20 73 72 63 69 64 7d  id cstype srcid}
60f0: 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20   [state run {.. 
6100: 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 2c     SELECT C.cid,
6110: 20 43 2e 70 69 64 2c 20 43 53 2e 6e 61 6d 65 2c   C.pid, CS.name,
6120: 20 43 2e 73 72 63 0a 09 20 20 20 20 46 52 4f 4d   C.src..    FROM
6130: 20 20 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20     changeset C, 
6140: 63 73 74 79 70 65 20 43 53 0a 09 20 20 20 20 57  cstype CS..    W
6150: 48 45 52 45 20 20 43 2e 74 79 70 65 20 3d 20 43  HERE  C.type = C
6160: 53 2e 74 69 64 0a 09 20 20 20 20 4f 52 44 45 52  S.tid..    ORDER
6170: 20 42 59 20 43 2e 63 69 64 0a 09 7d 5d 20 7b 0a   BY C.cid..}] {.
6180: 09 20 20 20 20 6c 6f 67 20 70 72 6f 67 72 65 73  .    log progres
6190: 73 20 32 20 63 73 65 74 73 20 24 6e 20 7b 7d 0a  s 2 csets $n {}.
61a0: 09 20 20 20 20 73 65 74 20 72 20 5b 24 74 79 70  .    set r [$typ
61b0: 65 20 25 41 55 54 4f 25 20 5b 24 72 65 70 6f 73  e %AUTO% [$repos
61c0: 69 74 6f 72 79 20 70 72 6f 6a 65 63 74 6f 66 20  itory projectof 
61d0: 24 70 69 64 5d 20 24 63 73 74 79 70 65 20 24 73  $pid] $cstype $s
61e0: 72 63 69 64 20 5b 73 74 61 74 65 20 72 75 6e 20  rcid [state run 
61f0: 7b 0a 09 09 53 45 4c 45 43 54 20 43 2e 69 69 64  {...SELECT C.iid
6200: 0a 09 09 46 52 4f 4d 20 20 20 63 73 69 74 65 6d  ...FROM   csitem
6210: 20 43 0a 09 09 57 48 45 52 45 20 20 43 2e 63 69   C...WHERE  C.ci
6220: 64 20 3d 20 24 69 64 0a 09 09 4f 52 44 45 52 20  d = $id...ORDER 
6230: 42 59 20 43 2e 70 6f 73 0a 09 20 20 20 20 7d 5d  BY C.pos..    }]
6240: 20 24 69 64 5d 0a 09 20 20 20 20 24 72 20 6c 6f   $id]..    $r lo
6250: 61 64 6d 61 70 73 0a 09 20 20 20 20 69 6e 63 72  admaps..    incr
6260: 20 6e 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20   n..}..return.  
6270: 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74    }..    typemet
6280: 68 6f 64 20 6c 6f 61 64 63 6f 75 6e 74 65 72 20  hod loadcounter 
6290: 7b 7d 20 7b 0a 09 23 20 49 6e 69 74 69 61 6c 69  {} {..# Initiali
62a0: 7a 65 20 74 68 65 20 63 6f 75 6e 74 65 72 20 66  ze the counter f
62b0: 72 6f 6d 20 74 68 65 20 73 74 61 74 65 0a 09 6c  rom the state..l
62c0: 6f 67 20 77 72 69 74 65 20 32 20 63 73 65 74 73  og write 2 csets
62d0: 20 7b 4c 6f 61 64 69 6e 67 20 63 68 61 6e 67 65   {Loading change
62e0: 73 65 74 20 63 6f 75 6e 74 65 72 7d 0a 09 73 65  set counter}..se
62f0: 74 20 6d 79 63 6f 75 6e 74 65 72 20 5b 73 74 61  t mycounter [sta
6300: 74 65 20 6f 6e 65 20 7b 20 53 45 4c 45 43 54 20  te one { SELECT 
6310: 4d 41 58 28 63 69 64 29 20 46 52 4f 4d 20 63 68  MAX(cid) FROM ch
6320: 61 6e 67 65 73 65 74 20 7d 5d 0a 09 72 65 74 75  angeset }]..retu
6330: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79  rn.    }..    ty
6340: 70 65 6d 65 74 68 6f 64 20 6e 75 6d 20 7b 7d 20  pemethod num {} 
6350: 7b 20 72 65 74 75 72 6e 20 24 6d 79 63 6f 75 6e  { return $mycoun
6360: 74 65 72 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20  ter }..    proc 
6370: 49 6e 69 74 69 61 6c 69 7a 65 42 72 65 61 6b 53  InitializeBreakS
6380: 74 61 74 65 20 7b 72 65 76 69 73 69 6f 6e 73 7d  tate {revisions}
6390: 20 7b 0a 09 75 70 76 61 72 20 31 20 70 6f 73 20   {..upvar 1 pos 
63a0: 70 6f 73 20 63 72 6f 73 73 20 63 72 6f 73 73 20  pos cross cross 
63b0: 72 61 6e 67 65 20 72 61 6e 67 65 20 64 65 70 63  range range depc
63c0: 20 64 65 70 63 20 64 65 6c 74 61 20 64 65 6c 74   depc delta delt
63d0: 61 20 5c 0a 09 20 20 20 20 64 65 70 65 6e 64 65  a \..    depende
63e0: 6e 63 69 65 73 20 64 65 70 65 6e 64 65 6e 63 69  ncies dependenci
63f0: 65 73 0a 0a 09 23 20 46 69 72 73 74 20 77 65 20  es...# First we 
6400: 63 72 65 61 74 65 20 61 20 6d 61 70 20 6f 66 20  create a map of 
6410: 70 6f 73 69 74 69 6f 6e 73 20 74 6f 20 6d 61 6b  positions to mak
6420: 65 20 69 74 20 65 61 73 69 65 72 20 74 6f 0a 09  e it easier to..
6430: 23 20 64 65 74 65 72 6d 69 6e 65 20 77 68 65 74  # determine whet
6440: 68 65 72 20 61 20 64 65 70 65 6e 64 65 6e 63 79  her a dependency
6450: 20 63 72 6f 73 73 65 73 20 61 20 70 61 72 74 69   crosses a parti
6460: 63 75 6c 61 72 20 69 6e 64 65 78 2e 0a 0a 09 61  cular index....a
6470: 72 72 61 79 20 73 65 74 20 70 6f 73 20 20 20 7b  rray set pos   {
6480: 7d 0a 09 61 72 72 61 79 20 73 65 74 20 63 72 6f  }..array set cro
6490: 73 73 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 74  ss {}..array set
64a0: 20 64 65 70 63 20 20 7b 7d 0a 09 73 65 74 20 72   depc  {}..set r
64b0: 61 6e 67 65 20 20 20 20 20 20 20 7b 7d 0a 09 73  ange       {}..s
64c0: 65 74 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 20  et n 0..foreach 
64d0: 72 65 76 20 24 72 65 76 69 73 69 6f 6e 73 20 7b  rev $revisions {
64e0: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 72 61  ..    lappend ra
64f0: 6e 67 65 20 24 6e 0a 09 20 20 20 20 73 65 74 20  nge $n..    set 
6500: 70 6f 73 28 24 72 65 76 29 20 24 6e 0a 09 20 20  pos($rev) $n..  
6510: 20 20 73 65 74 20 63 72 6f 73 73 28 24 6e 29 20    set cross($n) 
6520: 30 0a 09 20 20 20 20 69 6e 63 72 20 6e 0a 09 7d  0..    incr n..}
6530: 0a 0a 09 23 20 53 65 63 6f 6e 64 6c 79 20 77 65  ...# Secondly we
6540: 20 63 6f 75 6e 74 20 74 68 65 20 63 72 6f 73 73   count the cross
6550: 69 6e 67 73 20 70 65 72 20 70 6f 73 69 74 69 6f  ings per positio
6560: 6e 2c 20 62 79 20 69 74 65 72 61 74 69 6e 67 0a  n, by iterating.
6570: 09 23 20 6f 76 65 72 20 74 68 65 20 72 65 63 6f  .# over the reco
6580: 72 64 65 64 20 69 6e 74 65 72 6e 61 6c 20 64 65  rded internal de
6590: 70 65 6e 64 65 6e 63 69 65 73 2e 0a 0a 09 23 20  pendencies....# 
65a0: 4e 6f 74 65 3a 20 49 66 20 74 68 65 20 74 69 6d  Note: If the tim
65b0: 65 73 74 61 6d 70 73 20 61 72 65 20 62 61 64 6c  estamps are badl
65c0: 79 20 6f 75 74 20 6f 66 20 6f 72 64 65 72 20 69  y out of order i
65d0: 74 20 69 73 0a 09 23 20 20 20 20 20 20 20 70 6f  t is..#       po
65e0: 73 73 69 62 6c 65 20 74 6f 20 68 61 76 65 20 61  ssible to have a
65f0: 20 62 61 63 6b 77 61 72 64 20 73 75 63 63 65 73   backward succes
6600: 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 79 2c 0a  sor dependency,.
6610: 09 23 20 20 20 20 20 20 20 69 2e 65 2e 20 77 69  .#       i.e. wi
6620: 74 68 20 73 74 61 72 74 20 3e 20 65 6e 64 2e 20  th start > end. 
6630: 57 65 20 6d 61 79 20 68 61 76 65 20 74 6f 20 73  We may have to s
6640: 77 61 70 20 74 68 65 20 69 6e 64 69 63 65 73 0a  wap the indices.
6650: 09 23 20 20 20 20 20 20 20 74 6f 20 65 6e 73 75  .#       to ensu
6660: 72 65 20 74 68 61 74 20 74 68 65 20 66 6f 6c 6c  re that the foll
6670: 6f 77 69 6e 67 20 6c 6f 6f 70 20 72 75 6e 73 20  owing loop runs 
6680: 63 6f 72 72 65 63 74 6c 79 2e 0a 09 23 0a 09 23  correctly...#..#
6690: 20 4e 6f 74 65 20 32 3a 20 73 74 61 72 74 20 3d   Note 2: start =
66a0: 3d 20 65 6e 64 20 69 73 20 6e 6f 74 20 70 6f 73  = end is not pos
66b0: 73 69 62 6c 65 2e 20 49 74 20 69 6e 64 69 63 61  sible. It indica
66c0: 74 65 73 20 61 0a 09 23 20 20 20 20 20 20 20 20  tes a..#        
66d0: 20 73 65 6c 66 2d 64 65 70 65 6e 64 65 6e 63 79   self-dependency
66e0: 20 64 75 65 20 74 6f 20 74 68 65 20 75 6e 69 71   due to the uniq
66f0: 75 65 6e 65 73 73 20 6f 66 20 70 6f 73 69 74 69  ueness of positi
6700: 6f 6e 73 2c 0a 09 23 20 20 20 20 20 20 20 20 20  ons,..#         
6710: 61 6e 64 20 74 68 61 74 20 69 73 20 73 6f 6d 65  and that is some
6720: 74 68 69 6e 67 20 77 65 20 68 61 76 65 20 72 75  thing we have ru
6730: 6c 65 64 20 6f 75 74 20 61 6c 72 65 61 64 79 2c  led out already,
6740: 20 73 65 65 0a 09 23 20 20 20 20 20 20 20 20 20   see..#         
6750: 27 72 65 76 20 69 6e 74 65 72 6e 61 6c 73 75 63  'rev internalsuc
6760: 63 65 73 73 6f 72 73 27 2e 0a 0a 09 66 6f 72 65  cessors'....fore
6770: 61 63 68 20 7b 72 69 64 20 63 68 69 6c 64 72 65  ach {rid childre
6780: 6e 7d 20 5b 61 72 72 61 79 20 67 65 74 20 64 65  n} [array get de
6790: 70 65 6e 64 65 6e 63 69 65 73 5d 20 7b 0a 09 20  pendencies] {.. 
67a0: 20 20 20 66 6f 72 65 61 63 68 20 63 68 69 6c 64     foreach child
67b0: 20 24 63 68 69 6c 64 72 65 6e 20 7b 0a 09 09 73   $children {...s
67c0: 65 74 20 64 6b 65 79 20 20 20 20 5b 6c 69 73 74  et dkey    [list
67d0: 20 24 72 69 64 20 24 63 68 69 6c 64 5d 0a 09 09   $rid $child]...
67e0: 73 65 74 20 73 74 61 72 74 20 20 20 24 70 6f 73  set start   $pos
67f0: 28 24 72 69 64 29 0a 09 09 73 65 74 20 65 6e 64  ($rid)...set end
6800: 20 20 20 20 20 24 70 6f 73 28 24 63 68 69 6c 64       $pos($child
6810: 29 0a 09 09 73 65 74 20 63 72 6f 73 73 65 73 20  )...set crosses 
6820: 7b 7d 0a 0a 09 09 69 66 20 7b 24 73 74 61 72 74  {}....if {$start
6830: 20 3e 20 24 65 6e 64 7d 20 7b 0a 09 09 20 20 20   > $end} {...   
6840: 20 77 68 69 6c 65 20 7b 24 65 6e 64 20 3c 20 24   while {$end < $
6850: 73 74 61 72 74 7d 20 7b 0a 09 09 09 6c 61 70 70  start} {....lapp
6860: 65 6e 64 20 63 72 6f 73 73 65 73 20 24 65 6e 64  end crosses $end
6870: 0a 09 09 09 69 6e 63 72 20 63 72 6f 73 73 28 24  ....incr cross($
6880: 65 6e 64 29 0a 09 09 09 69 6e 63 72 20 65 6e 64  end)....incr end
6890: 0a 09 09 20 20 20 20 7d 0a 09 09 7d 20 65 6c 73  ...    }...} els
68a0: 65 20 7b 0a 09 09 20 20 20 20 77 68 69 6c 65 20  e {...    while 
68b0: 7b 24 73 74 61 72 74 20 3c 20 24 65 6e 64 7d 20  {$start < $end} 
68c0: 7b 0a 09 09 09 6c 61 70 70 65 6e 64 20 63 72 6f  {....lappend cro
68d0: 73 73 65 73 20 24 73 74 61 72 74 0a 09 09 09 69  sses $start....i
68e0: 6e 63 72 20 63 72 6f 73 73 28 24 73 74 61 72 74  ncr cross($start
68f0: 29 0a 09 09 09 69 6e 63 72 20 73 74 61 72 74 0a  )....incr start.
6900: 09 09 20 20 20 20 7d 0a 09 09 7d 0a 09 09 73 65  ..    }...}...se
6910: 74 20 64 65 70 63 28 24 64 6b 65 79 29 20 24 63  t depc($dkey) $c
6920: 72 6f 73 73 65 73 0a 09 20 20 20 20 7d 0a 09 7d  rosses..    }..}
6930: 0a 0a 09 49 6e 69 74 69 61 6c 69 7a 65 44 65 6c  ...InitializeDel
6940: 74 61 73 20 24 72 65 76 69 73 69 6f 6e 73 0a 09  tas $revisions..
6950: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
6960: 20 20 70 72 6f 63 20 49 6e 69 74 69 61 6c 69 7a    proc Initializ
6970: 65 44 65 6c 74 61 73 20 7b 72 65 76 69 73 69 6f  eDeltas {revisio
6980: 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 64  ns} {..upvar 1 d
6990: 65 6c 74 61 20 64 65 6c 74 61 0a 0a 09 23 20 50  elta delta...# P
69a0: 75 6c 6c 20 74 68 65 20 74 69 6d 65 73 74 61 6d  ull the timestam
69b0: 70 73 20 66 6f 72 20 61 6c 6c 20 72 65 76 69 73  ps for all revis
69c0: 69 6f 6e 73 20 69 6e 20 74 68 65 20 63 68 61 6e  ions in the chan
69d0: 67 65 73 65 74 73 20 61 6e 64 0a 09 23 20 63 6f  gesets and..# co
69e0: 6d 70 75 74 65 20 74 68 65 69 72 20 64 65 6c 74  mpute their delt
69f0: 61 73 20 66 6f 72 20 75 73 65 20 62 79 20 74 68  as for use by th
6a00: 65 20 62 72 65 61 6b 20 66 69 6e 64 65 72 2e 0a  e break finder..
6a10: 0a 09 61 72 72 61 79 20 73 65 74 20 64 65 6c 74  ..array set delt
6a20: 61 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 20  a {}..array set 
6a30: 73 74 61 6d 70 20 7b 7d 0a 0a 09 73 65 74 20 74  stamp {}...set t
6a40: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72  heset ('[join $r
6a50: 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27  evisions {','}]'
6a60: 29 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20  )..foreach {rid 
6a70: 74 69 6d 65 7d 20 5b 73 74 61 74 65 20 72 75 6e  time} [state run
6a80: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
6a90: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
6aa0: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  es {..    SELECT
6ab0: 20 52 2e 72 69 64 2c 20 52 2e 64 61 74 65 0a 09   R.rid, R.date..
6ac0: 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f      FROM revisio
6ad0: 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 52  n R..    WHERE R
6ae0: 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 0a  .rid IN $theset.
6af0: 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 73 65 74 20  .}]] {..    set 
6b00: 73 74 61 6d 70 28 24 72 69 64 29 20 24 74 69 6d  stamp($rid) $tim
6b10: 65 0a 09 7d 0a 0a 09 73 65 74 20 6e 20 30 0a 09  e..}...set n 0..
6b20: 66 6f 72 65 61 63 68 20 72 69 64 20 5b 6c 72 61  foreach rid [lra
6b30: 6e 67 65 20 24 72 65 76 69 73 69 6f 6e 73 20 30  nge $revisions 0
6b40: 20 65 6e 64 2d 31 5d 20 72 6e 65 78 74 20 5b 6c   end-1] rnext [l
6b50: 72 61 6e 67 65 20 24 72 65 76 69 73 69 6f 6e 73  range $revisions
6b60: 20 31 20 65 6e 64 5d 20 7b 0a 09 20 20 20 20 73   1 end] {..    s
6b70: 65 74 20 64 65 6c 74 61 28 24 6e 29 20 5b 65 78  et delta($n) [ex
6b80: 70 72 20 7b 24 73 74 61 6d 70 28 24 72 6e 65 78  pr {$stamp($rnex
6b90: 74 29 20 2d 20 24 73 74 61 6d 70 28 24 72 69 64  t) - $stamp($rid
6ba0: 29 7d 5d 0a 09 20 20 20 20 69 6e 63 72 20 6e 0a  )}]..    incr n.
6bb0: 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  .}..return.    }
6bc0: 0a 0a 20 20 20 20 70 72 6f 63 20 46 69 6e 64 42  ..    proc FindB
6bd0: 65 73 74 42 72 65 61 6b 20 7b 72 61 6e 67 65 7d  estBreak {range}
6be0: 20 7b 0a 09 75 70 76 61 72 20 31 20 63 72 6f 73   {..upvar 1 cros
6bf0: 73 20 63 72 6f 73 73 20 64 65 6c 74 61 20 64 65  s cross delta de
6c00: 6c 74 61 0a 0a 09 23 20 44 65 74 65 72 6d 69 6e  lta...# Determin
6c10: 65 20 74 68 65 20 62 65 73 74 20 62 72 65 61 6b  e the best break
6c20: 20 6c 6f 63 61 74 69 6f 6e 20 69 6e 20 74 68 65   location in the
6c30: 20 67 69 76 65 6e 20 72 61 6e 67 65 20 6f 66 0a   given range of.
6c40: 09 23 20 70 6f 73 69 74 69 6f 6e 73 2e 20 46 69  .# positions. Fi
6c50: 72 73 74 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20  rst we look for 
6c60: 74 68 65 20 6c 6f 63 61 74 69 6f 6e 73 20 77 69  the locations wi
6c70: 74 68 20 74 68 65 20 6d 61 78 69 6d 61 6c 0a 09  th the maximal..
6c80: 23 20 6e 75 6d 62 65 72 20 6f 66 20 63 72 6f 73  # number of cros
6c90: 73 69 6e 67 73 2e 20 49 66 20 74 68 65 72 65 20  sings. If there 
6ca0: 61 72 65 20 73 65 76 65 72 61 6c 20 77 65 20 6c  are several we l
6cb0: 6f 6f 6b 20 66 6f 72 20 74 68 65 0a 09 23 20 73  ook for the..# s
6cc0: 68 6f 72 74 65 73 74 20 74 69 6d 65 20 69 6e 74  hortest time int
6cd0: 65 72 76 61 6c 20 61 6d 6f 6e 67 20 74 68 65 6d  erval among them
6ce0: 2e 20 49 66 20 77 65 20 73 74 69 6c 6c 20 68 61  . If we still ha
6cf0: 76 65 20 6d 75 6c 74 69 70 6c 65 0a 09 23 20 70  ve multiple..# p
6d00: 6f 73 73 69 62 69 6c 69 74 69 65 73 20 61 66 74  ossibilities aft
6d10: 65 72 20 74 68 61 74 20 77 65 20 73 65 6c 65 63  er that we selec
6d20: 74 20 74 68 65 20 65 61 72 6c 69 65 73 74 20 6c  t the earliest l
6d30: 6f 63 61 74 69 6f 6e 0a 09 23 20 61 6d 6f 6e 67  ocation..# among
6d40: 20 74 68 65 73 65 2e 0a 0a 09 23 20 4e 6f 74 65   these....# Note
6d50: 3a 20 49 66 20 74 68 65 20 6d 61 78 69 6d 61 6c  : If the maximal
6d60: 20 6e 75 6d 62 65 72 20 6f 66 20 63 72 6f 73 73   number of cross
6d70: 69 6e 67 73 20 69 73 20 30 20 74 68 65 6e 20 74  ings is 0 then t
6d80: 68 65 20 72 61 6e 67 65 0a 09 23 20 20 20 20 20  he range..#     
6d90: 20 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61    has no interna
6da0: 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20  l dependencies, 
6db0: 61 6e 64 20 6e 6f 20 62 72 65 61 6b 20 6c 6f 63  and no break loc
6dc0: 61 74 69 6f 6e 20 61 74 0a 09 23 20 20 20 20 20  ation at..#     
6dd0: 20 20 61 6c 6c 2e 20 54 68 69 73 20 70 6f 73 73    all. This poss
6de0: 69 62 69 6c 69 74 79 20 69 73 20 73 69 67 6e 61  ibility is signa
6df0: 6c 65 64 20 76 69 61 20 72 65 73 75 6c 74 20 2d  led via result -
6e00: 31 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 41 20 72  1....# Note: A r
6e10: 61 6e 67 65 20 6f 66 20 6c 65 6e 67 74 68 20 31  ange of length 1
6e20: 20 6f 72 20 6c 65 73 73 20 63 61 6e 6e 6f 74 20   or less cannot 
6e30: 68 61 76 65 20 69 6e 74 65 72 6e 61 6c 0a 09 23  have internal..#
6e40: 20 20 20 20 20 20 20 64 65 70 65 6e 64 65 6e 63         dependenc
6e50: 69 65 73 2c 20 61 73 20 74 68 61 74 20 6e 65 65  ies, as that nee
6e60: 64 73 20 61 74 20 6c 65 61 73 74 20 74 77 6f 20  ds at least two 
6e70: 72 65 76 69 73 69 6f 6e 73 20 69 6e 0a 09 23 20  revisions in..# 
6e80: 20 20 20 20 20 20 74 68 65 20 72 61 6e 67 65 2e        the range.
6e90: 0a 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20  ...if {[llength 
6ea0: 24 72 61 6e 67 65 5d 20 3c 20 32 7d 20 7b 20 72  $range] < 2} { r
6eb0: 65 74 75 72 6e 20 2d 31 20 7d 0a 0a 09 73 65 74  eturn -1 }...set
6ec0: 20 6d 61 78 20 2d 31 0a 09 73 65 74 20 62 65 73   max -1..set bes
6ed0: 74 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68 20 6c  t {}...foreach l
6ee0: 6f 63 61 74 69 6f 6e 20 24 72 61 6e 67 65 20 7b  ocation $range {
6ef0: 0a 09 20 20 20 20 73 65 74 20 63 72 6f 73 73 69  ..    set crossi
6f00: 6e 67 73 20 24 63 72 6f 73 73 28 24 6c 6f 63 61  ngs $cross($loca
6f10: 74 69 6f 6e 29 0a 09 20 20 20 20 69 66 20 7b 24  tion)..    if {$
6f20: 63 72 6f 73 73 69 6e 67 73 20 3e 20 24 6d 61 78  crossings > $max
6f30: 7d 20 7b 0a 09 09 73 65 74 20 6d 61 78 20 20 24  } {...set max  $
6f40: 63 72 6f 73 73 69 6e 67 73 0a 09 09 73 65 74 20  crossings...set 
6f50: 62 65 73 74 20 5b 6c 69 73 74 20 24 6c 6f 63 61  best [list $loca
6f60: 74 69 6f 6e 5d 0a 09 09 63 6f 6e 74 69 6e 75 65  tion]...continue
6f70: 0a 09 20 20 20 20 7d 20 65 6c 73 65 69 66 20 7b  ..    } elseif {
6f80: 24 63 72 6f 73 73 69 6e 67 73 20 3d 3d 20 24 6d  $crossings == $m
6f90: 61 78 7d 20 7b 0a 09 09 6c 61 70 70 65 6e 64 20  ax} {...lappend 
6fa0: 62 65 73 74 20 24 6c 6f 63 61 74 69 6f 6e 0a 09  best $location..
6fb0: 20 20 20 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b 24      }..}...if {$
6fc0: 6d 61 78 20 3d 3d 20 30 7d 20 20 20 20 20 20 20  max == 0}       
6fd0: 20 20 20 20 20 7b 20 72 65 74 75 72 6e 20 2d 31       { return -1
6fe0: 20 7d 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68   }..if {[llength
6ff0: 20 24 62 65 73 74 5d 20 3d 3d 20 31 7d 20 7b 20   $best] == 1} { 
7000: 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78 20 24  return [lindex $
7010: 62 65 73 74 20 30 5d 20 7d 0a 0a 09 73 65 74 20  best 0] }...set 
7020: 6c 6f 63 61 74 69 6f 6e 73 20 24 62 65 73 74 0a  locations $best.
7030: 09 73 65 74 20 62 65 73 74 20 7b 7d 0a 09 73 65  .set best {}..se
7040: 74 20 6d 69 6e 20 2d 31 0a 0a 09 66 6f 72 65 61  t min -1...forea
7050: 63 68 20 6c 6f 63 61 74 69 6f 6e 20 24 6c 6f 63  ch location $loc
7060: 61 74 69 6f 6e 73 20 7b 0a 09 20 20 20 20 73 65  ations {..    se
7070: 74 20 69 6e 74 65 72 76 61 6c 20 24 64 65 6c 74  t interval $delt
7080: 61 28 24 6c 6f 63 61 74 69 6f 6e 29 0a 09 20 20  a($location)..  
7090: 20 20 69 66 20 7b 28 24 6d 69 6e 20 3c 20 30 29    if {($min < 0)
70a0: 20 7c 7c 20 28 24 69 6e 74 65 72 76 61 6c 20 3c   || ($interval <
70b0: 20 24 6d 69 6e 29 7d 20 7b 0a 09 09 73 65 74 20   $min)} {...set 
70c0: 6d 69 6e 20 20 24 69 6e 74 65 72 76 61 6c 0a 09  min  $interval..
70d0: 09 73 65 74 20 62 65 73 74 20 5b 6c 69 73 74 20  .set best [list 
70e0: 24 6c 6f 63 61 74 69 6f 6e 5d 0a 09 20 20 20 20  $location]..    
70f0: 7d 20 65 6c 73 65 69 66 20 7b 24 69 6e 74 65 72  } elseif {$inter
7100: 76 61 6c 20 3d 3d 20 24 6d 69 6e 7d 20 7b 0a 09  val == $min} {..
7110: 09 6c 61 70 70 65 6e 64 20 62 65 73 74 20 24 6c  .lappend best $l
7120: 6f 63 61 74 69 6f 6e 0a 09 20 20 20 20 7d 0a 09  ocation..    }..
7130: 7d 0a 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68  }...if {[llength
7140: 20 24 62 65 73 74 5d 20 3d 3d 20 31 7d 20 7b 20   $best] == 1} { 
7150: 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78 20 24  return [lindex $
7160: 62 65 73 74 20 30 5d 20 7d 0a 0a 09 72 65 74 75  best 0] }...retu
7170: 72 6e 20 5b 6c 69 6e 64 65 78 20 5b 6c 73 6f 72  rn [lindex [lsor
7180: 74 20 2d 69 6e 74 65 67 65 72 20 2d 69 6e 63 72  t -integer -incr
7190: 65 61 73 69 6e 67 20 24 62 65 73 74 5d 20 30 5d  easing $best] 0]
71a0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63  .    }..    proc
71b0: 20 43 75 74 41 74 20 7b 6c 6f 63 61 74 69 6f 6e   CutAt {location
71c0: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 63 72 6f  } {..upvar 1 cro
71d0: 73 73 20 63 72 6f 73 73 20 64 65 70 63 20 64 65  ss cross depc de
71e0: 70 63 0a 0a 09 23 20 49 74 20 77 61 73 20 64 65  pc...# It was de
71f0: 63 69 64 65 64 20 74 6f 20 73 70 6c 69 74 20 74  cided to split t
7200: 68 65 20 63 68 61 6e 67 65 73 65 74 20 61 74 20  he changeset at 
7210: 74 68 65 20 67 69 76 65 6e 0a 09 23 20 6c 6f 63  the given..# loc
7220: 61 74 69 6f 6e 2e 20 54 68 69 73 20 63 75 74 73  ation. This cuts
7230: 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 64 65 70   a number of dep
7240: 65 6e 64 65 6e 63 69 65 73 2e 20 48 65 72 65 20  endencies. Here 
7250: 77 65 20 75 70 64 61 74 65 0a 09 23 20 74 68 65  we update..# the
7260: 20 63 72 6f 73 73 20 69 6e 66 6f 72 6d 61 74 69   cross informati
7270: 6f 6e 20 73 6f 20 74 68 61 74 20 74 68 65 20 62  on so that the b
7280: 72 65 61 6b 20 66 69 6e 64 65 72 20 68 61 73 20  reak finder has 
7290: 61 63 63 75 72 61 74 65 0a 09 23 20 64 61 74 61  accurate..# data
72a0: 20 77 68 65 6e 20 77 65 20 6c 6f 6f 6b 20 61 74   when we look at
72b0: 20 74 68 65 20 67 65 6e 65 72 61 74 65 64 20 66   the generated f
72c0: 72 61 67 6d 65 6e 74 73 2e 0a 0a 09 73 65 74 20  ragments....set 
72d0: 73 69 78 20 5b 6c 6f 67 20 76 69 73 69 62 6c 65  six [log visible
72e0: 3f 20 36 5d 0a 0a 09 66 6f 72 65 61 63 68 20 7b  ? 6]...foreach {
72f0: 64 65 70 20 72 61 6e 67 65 7d 20 5b 61 72 72 61  dep range} [arra
7300: 79 20 67 65 74 20 64 65 70 63 5d 20 7b 0a 09 20  y get depc] {.. 
7310: 20 20 20 23 20 43 68 65 63 6b 20 61 6c 6c 20 64     # Check all d
7320: 65 70 65 6e 64 65 6e 63 69 65 73 20 73 74 69 6c  ependencies stil
7330: 6c 20 6b 6e 6f 77 6e 2c 20 74 61 6b 65 20 74 68  l known, take th
7340: 65 69 72 20 72 61 6e 67 65 20 61 6e 64 0a 09 20  eir range and.. 
7350: 20 20 20 23 20 73 65 65 20 69 66 20 74 68 65 20     # see if the 
7360: 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 20 66  break location f
7370: 61 6c 6c 73 20 77 69 74 68 69 6e 2e 0a 0a 09 20  alls within.... 
7380: 20 20 20 42 6f 72 64 65 72 20 24 72 61 6e 67 65     Border $range
7390: 20 73 20 65 0a 09 20 20 20 20 69 66 20 7b 24 6c   s e..    if {$l
73a0: 6f 63 61 74 69 6f 6e 20 3c 20 24 73 7d 20 63 6f  ocation < $s} co
73b0: 6e 74 69 6e 75 65 20 3b 20 23 20 62 72 65 61 6b  ntinue ; # break
73c0: 20 62 65 66 6f 72 65 20 72 61 6e 67 65 2c 20 69   before range, i
73d0: 67 6e 6f 72 65 0a 09 20 20 20 20 69 66 20 7b 24  gnore..    if {$
73e0: 6c 6f 63 61 74 69 6f 6e 20 3e 20 24 65 7d 20 63  location > $e} c
73f0: 6f 6e 74 69 6e 75 65 20 3b 20 23 20 62 72 65 61  ontinue ; # brea
7400: 6b 20 61 66 74 65 72 20 72 61 6e 67 65 2c 20 69  k after range, i
7410: 67 6e 6f 72 65 2e 0a 0a 09 20 20 20 20 23 20 54  gnore....    # T
7420: 68 69 73 20 64 65 70 65 6e 64 65 6e 63 79 20 63  his dependency c
7430: 72 6f 73 73 65 73 20 74 68 65 20 62 72 65 61 6b  rosses the break
7440: 20 6c 6f 63 61 74 69 6f 6e 2e 20 57 65 20 72 65   location. We re
7450: 6d 6f 76 65 20 69 74 0a 09 20 20 20 20 23 20 66  move it..    # f
7460: 72 6f 6d 20 74 68 65 20 63 72 6f 73 73 69 6e 67  rom the crossing
7470: 73 20 63 6f 75 6e 74 65 72 73 2c 20 61 6e 64 20  s counters, and 
7480: 74 68 65 6e 20 61 6c 73 6f 20 66 72 6f 6d 20 74  then also from t
7490: 68 65 20 73 65 74 0a 09 20 20 20 20 23 20 6f 66  he set..    # of
74a0: 20 6b 6e 6f 77 6e 20 64 65 70 65 6e 64 65 6e 63   known dependenc
74b0: 69 65 73 2c 20 61 73 20 77 65 20 61 72 65 20 64  ies, as we are d
74c0: 6f 6e 65 20 77 69 74 68 20 69 74 2e 0a 0a 09 20  one with it.... 
74d0: 20 20 20 66 6f 72 65 61 63 68 20 6c 6f 63 20 24     foreach loc $
74e0: 64 65 70 63 28 24 64 65 70 29 20 7b 20 69 6e 63  depc($dep) { inc
74f0: 72 20 63 72 6f 73 73 28 24 6c 6f 63 29 20 2d 31  r cross($loc) -1
7500: 20 7d 0a 09 20 20 20 20 75 6e 73 65 74 20 64 65   }..    unset de
7510: 70 63 28 24 64 65 70 29 0a 0a 09 20 20 20 20 69  pc($dep)...    i
7520: 66 20 7b 21 24 73 69 78 7d 20 63 6f 6e 74 69 6e  f {!$six} contin
7530: 75 65 0a 0a 09 20 20 20 20 73 74 72 75 63 74 3a  ue...    struct:
7540: 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24 64 65  :list assign $de
7550: 70 20 70 61 72 65 6e 74 20 63 68 69 6c 64 0a 09  p parent child..
7560: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 35 20      log write 5 
7570: 63 73 65 74 73 20 22 42 72 6f 6b 65 20 64 65 70  csets "Broke dep
7580: 65 6e 64 65 6e 63 79 20 5b 50 44 20 24 70 61 72  endency [PD $par
7590: 65 6e 74 5d 20 2d 2d 3e 20 5b 50 44 20 24 63 68  ent] --> [PD $ch
75a0: 69 6c 64 5d 22 0a 09 7d 0a 0a 09 72 65 74 75 72  ild]"..}...retur
75b0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 50  n.    }..    # P
75c0: 72 69 6e 74 20 69 64 65 6e 74 69 66 79 69 6e 67  rint identifying
75d0: 20 64 61 74 61 20 66 6f 72 20 61 20 72 65 76 69   data for a revi
75e0: 73 69 6f 6e 20 28 70 72 6f 6a 65 63 74 2c 20 66  sion (project, f
75f0: 69 6c 65 2c 20 64 6f 74 74 65 64 20 72 65 76 0a  ile, dotted rev.
7600: 20 20 20 20 23 20 6e 75 6d 62 65 72 29 2c 20 66      # number), f
7610: 6f 72 20 68 69 67 68 20 76 65 72 62 6f 73 69 74  or high verbosit
7620: 79 20 6c 6f 67 20 6f 75 74 70 75 74 2e 0a 20 20  y log output..  
7630: 20 20 23 20 54 4f 44 4f 3a 20 52 65 70 6c 61 63    # TODO: Replac
7640: 65 20 77 69 74 68 20 63 61 6c 6c 20 74 6f 20 69  e with call to i
7650: 74 65 6d 73 74 72 20 28 6c 69 73 74 20 72 65 76  temstr (list rev
7660: 20 24 69 64 29 0a 0a 20 20 20 20 70 72 6f 63 20   $id)..    proc 
7670: 50 44 20 7b 69 64 7d 20 7b 0a 09 66 6f 72 65 61  PD {id} {..forea
7680: 63 68 20 7b 70 20 66 20 72 7d 20 5b 73 74 61 74  ch {p f r} [stat
7690: 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c 45 43 54  e run {...SELECT
76a0: 20 50 2e 6e 61 6d 65 20 2c 20 46 2e 6e 61 6d 65   P.name , F.name
76b0: 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72  , R.rev...FROM r
76c0: 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20  evision R, file 
76d0: 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a 09 09 57  F, project P...W
76e0: 48 45 52 45 20 52 2e 72 69 64 20 3d 20 24 69 64  HERE R.rid = $id
76f0: 20 20 20 20 2d 2d 20 46 69 6e 64 20 73 70 65 63      -- Find spec
7700: 69 66 69 65 64 20 66 69 6c 65 20 72 65 76 69 73  ified file revis
7710: 69 6f 6e 0a 09 09 41 4e 44 20 20 20 46 2e 66 69  ion...AND   F.fi
7720: 64 20 3d 20 52 2e 66 69 64 20 20 2d 2d 20 47 65  d = R.fid  -- Ge
7730: 74 20 66 69 6c 65 20 6f 66 20 74 68 65 20 72 65  t file of the re
7740: 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 50  vision...AND   P
7750: 2e 70 69 64 20 3d 20 46 2e 70 69 64 20 20 2d 2d  .pid = F.pid  --
7760: 20 47 65 74 20 70 72 6f 6a 65 63 74 20 6f 66 20   Get project of 
7770: 74 68 65 20 66 69 6c 65 2e 0a 09 7d 5d 20 62 72  the file...}] br
7780: 65 61 6b 0a 09 72 65 74 75 72 6e 20 22 27 24 70  eak..return "'$p
7790: 20 3a 20 24 66 2f 24 72 27 22 0a 20 20 20 20 7d   : $f/$r'".    }
77a0: 0a 0a 20 20 20 20 23 20 50 72 69 6e 74 69 6e 67  ..    # Printing
77b0: 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 72 61 6e   one or more ran
77c0: 67 65 73 2c 20 66 6f 72 6d 61 74 74 65 64 2c 20  ges, formatted, 
77d0: 61 6e 64 20 6f 6e 6c 79 20 74 68 65 69 72 20 62  and only their b
77e0: 6f 72 64 65 72 20 74 6f 0a 20 20 20 20 23 20 6b  order to.    # k
77f0: 65 65 70 20 74 68 65 20 73 74 72 69 6e 67 73 20  eep the strings 
7800: 73 68 6f 72 74 2e 0a 0a 20 20 20 20 70 72 6f 63  short...    proc
7810: 20 50 52 73 20 7b 72 61 6e 67 65 73 7d 20 7b 0a   PRs {ranges} {.
7820: 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a  .return [struct:
7830: 3a 6c 69 73 74 20 6d 61 70 20 24 72 61 6e 67 65  :list map $range
7840: 73 20 5b 6d 79 70 72 6f 63 20 50 52 5d 5d 0a 20  s [myproc PR]]. 
7850: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50     }..    proc P
7860: 52 20 7b 72 61 6e 67 65 7d 20 7b 0a 09 42 6f 72  R {range} {..Bor
7870: 64 65 72 20 24 72 61 6e 67 65 20 73 20 65 0a 09  der $range s e..
7880: 72 65 74 75 72 6e 20 3c 24 7b 73 7d 2e 2e 2e 24  return <${s}...$
7890: 7b 65 7d 3e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  {e}>.    }..    
78a0: 70 72 6f 63 20 42 6f 72 64 65 72 20 7b 72 61 6e  proc Border {ran
78b0: 67 65 20 73 76 20 65 76 7d 20 7b 0a 09 75 70 76  ge sv ev} {..upv
78c0: 61 72 20 31 20 24 73 76 20 73 20 24 65 76 20 65  ar 1 $sv s $ev e
78d0: 0a 09 73 65 74 20 73 20 5b 6c 69 6e 64 65 78 20  ..set s [lindex 
78e0: 24 72 61 6e 67 65 20 30 5d 0a 09 73 65 74 20 65  $range 0]..set e
78f0: 20 5b 6c 69 6e 64 65 78 20 24 72 61 6e 67 65 20   [lindex $range 
7900: 65 6e 64 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20  end]..return.   
7910: 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23   }..    # # ## #
7920: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
7930: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  # #############.
7940: 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c  .    typevariabl
7950: 65 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20  e mychangesets  
7960: 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 4c 69         {} ; # Li
7970: 73 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 0a  st of all known.
7980: 09 09 09 09 09 20 20 20 23 20 63 68 61 6e 67 65  .....   # change
7990: 73 65 74 73 2e 0a 0a 20 20 20 20 23 20 4c 69 73  sets...    # Lis
79a0: 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 20 63  t of all known c
79b0: 68 61 6e 67 65 73 65 74 73 20 6f 66 20 61 20 74  hangesets of a t
79c0: 79 70 65 2e 0a 20 20 20 20 74 79 70 65 76 61 72  ype..    typevar
79d0: 69 61 62 6c 65 20 6d 79 74 63 68 61 6e 67 65 73  iable mytchanges
79e0: 65 74 73 20 2d 61 72 72 61 79 20 7b 0a 09 73 79  ets -array {..sy
79f0: 6d 3a 3a 62 72 61 6e 63 68 20 7b 7d 0a 09 73 79  m::branch {}..sy
7a00: 6d 3a 3a 74 61 67 20 20 20 20 7b 7d 0a 09 72 65  m::tag    {}..re
7a10: 76 20 20 20 20 20 20 20 20 20 7b 7d 0a 20 20 20  v         {}.   
7a20: 20 7d 0a 09 09 09 09 09 0a 20 20 20 20 74 79 70   }.......    typ
7a30: 65 76 61 72 69 61 62 6c 65 20 6d 79 69 74 65 6d  evariable myitem
7a40: 6d 61 70 20 20 20 20 20 2d 61 72 72 61 79 20 7b  map     -array {
7a50: 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d 20 69  } ; # Map from i
7a60: 74 65 6d 73 20 28 74 61 67 67 65 64 29 0a 09 09  tems (tagged)...
7a70: 09 09 09 20 20 20 23 20 74 6f 20 74 68 65 20 6c  ...   # to the l
7a80: 69 73 74 20 6f 66 20 63 68 61 6e 67 65 73 65 74  ist of changeset
7a90: 73 0a 09 09 09 09 09 20 20 20 23 20 63 6f 6e 74  s......   # cont
7aa0: 61 69 6e 69 6e 67 20 69 74 2e 20 45 61 63 68 20  aining it. Each 
7ab0: 69 74 65 6d 0a 09 09 09 09 09 20 20 20 23 20 63  item......   # c
7ac0: 61 6e 20 62 65 20 75 73 65 64 20 62 79 20 6f 6e  an be used by on
7ad0: 6c 79 20 6f 6e 65 0a 09 09 09 09 09 20 20 20 23  ly one......   #
7ae0: 20 63 68 61 6e 67 65 73 65 74 2e 0a 20 20 20 20   changeset..    
7af0: 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 69  typevariable myi
7b00: 64 6d 61 70 20 20 20 2d 61 72 72 61 79 20 7b 7d  dmap   -array {}
7b10: 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d 20 63 68   ; # Map from ch
7b20: 61 6e 67 65 73 65 74 20 69 64 20 74 6f 0a 09 09  angeset id to...
7b30: 09 09 20 20 20 20 20 20 20 23 20 63 68 61 6e 67  ..       # chang
7b40: 65 73 65 74 2e 0a 0a 20 20 20 20 74 79 70 65 6d  eset...    typem
7b50: 65 74 68 6f 64 20 61 6c 6c 20 20 20 20 7b 7d 20  ethod all    {} 
7b60: 20 20 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 63     { return $myc
7b70: 68 61 6e 67 65 73 65 74 73 20 7d 0a 20 20 20 20  hangesets }.    
7b80: 74 79 70 65 6d 65 74 68 6f 64 20 6f 66 20 20 20  typemethod of   
7b90: 20 20 7b 63 69 64 7d 20 7b 20 72 65 74 75 72 6e    {cid} { return
7ba0: 20 24 6d 79 69 64 6d 61 70 28 24 63 69 64 29 20   $myidmap($cid) 
7bb0: 7d 0a 20 20 20 20 23 74 79 70 65 6d 65 74 68 6f  }.    #typemetho
7bc0: 64 20 6f 66 69 74 65 6d 20 7b 69 69 64 7d 20 7b  d ofitem {iid} {
7bd0: 20 72 65 74 75 72 6e 20 24 6d 79 69 74 65 6d 6d   return $myitemm
7be0: 61 70 28 24 69 69 64 29 20 7d 0a 0a 20 20 20 20  ap($iid) }..    
7bf0: 74 79 70 65 6d 65 74 68 6f 64 20 72 65 76 20 20  typemethod rev  
7c00: 20 20 7b 7d 20 20 20 20 7b 20 72 65 74 75 72 6e    {}    { return
7c10: 20 24 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28   $mytchangesets(
7c20: 72 65 76 29 20 7d 0a 20 20 20 20 74 79 70 65 6d  rev) }.    typem
7c30: 65 74 68 6f 64 20 73 79 6d 20 20 20 20 7b 7d 20  ethod sym    {} 
7c40: 20 20 20 7b 20 72 65 74 75 72 6e 20 5b 63 6f 6e     { return [con
7c50: 63 61 74 20 5c 0a 09 09 09 09 09 20 20 24 7b 6d  cat \......  ${m
7c60: 79 74 63 68 61 6e 67 65 73 65 74 73 28 73 79 6d  ytchangesets(sym
7c70: 3a 3a 62 72 61 6e 63 68 29 7d 20 5c 0a 09 09 09  ::branch)} \....
7c80: 09 09 20 20 24 7b 6d 79 74 63 68 61 6e 67 65 73  ..  ${mytchanges
7c90: 65 74 73 28 73 79 6d 3a 3a 74 61 67 29 7d 5d 20  ets(sym::tag)}] 
7ca0: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23  }..    # # ## ##
7cb0: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
7cc0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
7cd0: 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74     ## Configurat
7ce0: 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20  ion..    pragma 
7cf0: 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20  -hastypeinfo    
7d00: 6e 6f 20 20 3b 20 23 20 6e 6f 20 74 79 70 65 20  no  ; # no type 
7d10: 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20  introspection.  
7d20: 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69 6e 66    pragma -hasinf
7d30: 6f 20 20 20 20 20 20 20 20 6e 6f 20 20 3b 20 23  o        no  ; #
7d40: 20 6e 6f 20 6f 62 6a 65 63 74 20 69 6e 74 72 6f   no object intro
7d50: 73 70 65 63 74 69 6f 6e 0a 0a 20 20 20 20 23 20  spection..    # 
7d60: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
7d70: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
7d80: 23 23 23 23 23 0a 7d 0a 0a 23 23 0a 23 23 20 4e  #####.}..##.## N
7d90: 4f 54 45 3a 20 54 68 65 20 73 75 63 63 65 73 73  OTE: The success
7da0: 6f 72 20 61 6e 64 20 70 72 65 64 65 63 65 73 73  or and predecess
7db0: 6f 72 20 6d 65 74 68 6f 64 73 20 64 65 66 69 6e  or methods defin
7dc0: 65 64 20 62 79 20 74 68 65 20 63 6c 61 73 73 65  ed by the classe
7dd0: 73 0a 23 23 20 20 20 20 20 20 20 62 65 6c 6f 77  s.##       below
7de0: 20 61 72 65 20 2d 2d 20 62 6f 74 74 6c 65 20 6e   are -- bottle n
7df0: 65 63 6b 73 20 2d 2d 2e 20 4c 6f 6f 6b 20 66 6f  ecks --. Look fo
7e00: 72 20 77 61 79 73 20 74 6f 20 6d 61 6b 65 20 74  r ways to make t
7e10: 68 65 20 53 51 4c 0a 23 23 20 20 20 20 20 20 20  he SQL.##       
7e20: 66 61 73 74 65 72 2e 0a 23 23 0a 0a 23 20 23 20  faster..##..# # 
7e30: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
7e40: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
7e50: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
7e60: 23 23 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c  #########.## Hel
7e70: 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43  per singleton. C
7e80: 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 72 65 76 69  ommands for revi
7e90: 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 2e  sion changesets.
7ea0: 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76  ..snit::type ::v
7eb0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
7ec0: 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a  t::cvs::project:
7ed0: 3a 72 65 76 3a 3a 72 65 76 20 7b 0a 20 20 20 20  :rev::rev {.    
7ee0: 74 79 70 65 6d 65 74 68 6f 64 20 62 79 72 65 76  typemethod byrev
7ef0: 69 73 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72  ision {} { retur
7f00: 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65  n 1 }.    typeme
7f10: 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20 20  thod bysymbol   
7f20: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a  {} { return 0 }.
7f30: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69      typemethod i
7f40: 73 74 61 67 20 20 20 20 20 20 7b 7d 20 7b 20 72  stag      {} { r
7f50: 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74 79  eturn 0 }.    ty
7f60: 70 65 6d 65 74 68 6f 64 20 69 73 62 72 61 6e 63  pemethod isbranc
7f70: 68 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20  h   {} { return 
7f80: 30 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74  0 }..    typemet
7f90: 68 6f 64 20 73 74 72 20 7b 72 65 76 69 73 69 6f  hod str {revisio
7fa0: 6e 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69  n} {..struct::li
7fb0: 73 74 20 61 73 73 69 67 6e 20 5b 73 74 61 74 65  st assign [state
7fc0: 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45   run {..    SELE
7fd0: 43 54 20 52 2e 72 65 76 2c 20 46 2e 6e 61 6d 65  CT R.rev, F.name
7fe0: 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52  , P.name..    FR
7ff0: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
8000: 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74   file F, project
8010: 20 50 0a 09 20 20 20 20 57 48 45 52 45 20 20 52   P..    WHERE  R
8020: 2e 72 69 64 20 3d 20 24 72 65 76 69 73 69 6f 6e  .rid = $revision
8030: 20 2d 2d 20 46 69 6e 64 20 73 70 65 63 69 66 69   -- Find specifi
8040: 65 64 20 66 69 6c 65 20 72 65 76 69 73 69 6f 6e  ed file revision
8050: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46 2e 66  ..    AND    F.f
8060: 69 64 20 3d 20 52 2e 66 69 64 20 20 20 20 20 2d  id = R.fid     -
8070: 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 74 68  - Get file of th
8080: 65 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20  e revision..    
8090: 41 4e 44 20 20 20 20 50 2e 70 69 64 20 3d 20 46  AND    P.pid = F
80a0: 2e 70 69 64 20 20 20 20 20 2d 2d 20 47 65 74 20  .pid     -- Get 
80b0: 70 72 6f 6a 65 63 74 20 6f 66 20 74 68 65 20 66  project of the f
80c0: 69 6c 65 2e 0a 09 7d 5d 20 72 65 76 6e 72 20 66  ile...}] revnr f
80d0: 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65 74 75  name pname..retu
80e0: 72 6e 20 22 24 70 6e 61 6d 65 2f 24 7b 72 65 76  rn "$pname/${rev
80f0: 6e 72 7d 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20  nr}::$fname".   
8100: 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74   }..    # result
8110: 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65   = list (mintime
8120: 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74  , maxtime).    t
8130: 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61  ypemethod timera
8140: 6e 67 65 20 7b 69 74 65 6d 73 7d 20 7b 0a 09 73  nge {items} {..s
8150: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
8160: 6e 20 24 69 74 65 6d 73 20 7b 27 2c 27 7d 5d 27  n $items {','}]'
8170: 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65  )..return [state
8180: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63   run [subst -noc
8190: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73  ommands -nobacks
81a0: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45  lashes {..    SE
81b0: 4c 45 43 54 20 4d 49 4e 28 52 2e 64 61 74 65 29  LECT MIN(R.date)
81c0: 2c 20 4d 41 58 28 52 2e 64 61 74 65 29 0a 09 20  , MAX(R.date).. 
81d0: 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e     FROM revision
81e0: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e   R..    WHERE R.
81f0: 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 2d  rid IN $theset -
8200: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65  - Restrict to re
8210: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72  visions of inter
8220: 65 73 74 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a  est..}]].    }..
8230: 20 20 20 20 23 20 76 61 72 28 64 76 29 20 3d 20      # var(dv) = 
8240: 64 69 63 74 20 28 72 65 76 69 73 69 6f 6e 20 2d  dict (revision -
8250: 3e 20 6c 69 73 74 20 28 72 65 76 69 73 69 6f 6e  > list (revision
8260: 29 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  )).    typemetho
8270: 64 20 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73  d internalsucces
8280: 73 6f 72 73 20 7b 64 76 20 72 65 76 69 73 69 6f  sors {dv revisio
8290: 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24  ns} {..upvar 1 $
82a0: 64 76 20 64 65 70 65 6e 64 65 6e 63 69 65 73 0a  dv dependencies.
82b0: 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a  .set theset ('[j
82c0: 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b  oin $revisions {
82d0: 27 2c 27 7d 5d 27 29 0a 0a 09 6c 6f 67 20 77 72  ','}]')...log wr
82e0: 69 74 65 20 31 34 20 63 73 65 74 20 69 6e 74 65  ite 14 cset inte
82f0: 72 6e 61 6c 73 75 63 63 65 73 73 6f 72 73 0a 0a  rnalsuccessors..
8300: 09 23 20 53 65 65 20 27 73 75 63 63 65 73 73 6f  .# See 'successo
8310: 72 73 27 20 62 65 6c 6f 77 20 66 6f 72 20 74 68  rs' below for th
8320: 65 20 6d 61 69 6e 20 65 78 70 6c 61 6e 61 74 69  e main explanati
8330: 6f 6e 20 6f 66 0a 09 23 20 74 68 65 20 76 61 72  on of..# the var
8340: 69 6f 75 73 20 63 61 73 65 73 2e 20 54 68 69 73  ious cases. This
8350: 20 70 69 65 63 65 20 69 73 20 73 70 65 63 69 61   piece is specia
8360: 6c 20 69 6e 20 74 68 61 74 20 69 74 0a 09 23 20  l in that it..# 
8370: 72 65 73 74 72 69 63 74 73 20 74 68 65 20 73 75  restricts the su
8380: 63 63 65 73 73 6f 72 73 20 77 65 20 6c 6f 6f 6b  ccessors we look
8390: 20 66 6f 72 20 74 6f 20 74 68 65 20 73 61 6d 65   for to the same
83a0: 20 73 65 74 20 6f 66 0a 09 23 20 72 65 76 69 73   set of..# revis
83b0: 69 6f 6e 73 20 77 65 20 73 74 61 72 74 20 66 72  ions we start fr
83c0: 6f 6d 2e 20 53 65 6e 73 69 62 6c 65 20 61 73 20  om. Sensible as 
83d0: 77 65 20 61 72 65 20 6c 6f 6f 6b 69 6e 67 20 66  we are looking f
83e0: 6f 72 0a 09 23 20 63 68 61 6e 67 65 73 65 74 20  or..# changeset 
83f0: 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65  internal depende
8400: 6e 63 69 65 73 2e 0a 0a 09 61 72 72 61 79 20 73  ncies....array s
8410: 65 74 20 64 65 70 20 7b 7d 0a 0a 09 66 6f 72 65  et dep {}...fore
8420: 61 63 68 20 7b 72 69 64 20 63 68 69 6c 64 7d 20  ach {rid child} 
8430: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
8440: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
8450: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 20  obackslashes {. 
8460: 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 72     -- (1) Primar
8470: 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53 45 4c  y child..    SEL
8480: 45 43 54 20 52 2e 72 69 64 2c 20 52 2e 63 68 69  ECT R.rid, R.chi
8490: 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72  ld..    FROM   r
84a0: 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57  evision R..    W
84b0: 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e  HERE  R.rid   IN
84c0: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
84d0: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
84e0: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
84f0: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
8500: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
8510: 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d  L    -- Has prim
8520: 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 41  ary child..    A
8530: 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 4e  ND    R.child IN
8540: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
8550: 57 68 69 63 68 20 69 73 20 61 6c 73 6f 20 6f 66  Which is also of
8560: 20 69 6e 74 65 72 65 73 74 0a 20 20 20 20 55 4e   interest.    UN
8570: 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 32 29 20 53  ION.    -- (2) S
8580: 65 63 6f 6e 64 61 72 79 20 28 62 72 61 6e 63 68  econdary (branch
8590: 29 20 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20  ) children..    
85a0: 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e  SELECT R.rid, B.
85b0: 62 72 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  brid..    FROM  
85c0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76   revision R, rev
85d0: 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64  isionbranchchild
85e0: 72 65 6e 20 42 0a 09 20 20 20 20 57 48 45 52 45  ren B..    WHERE
85f0: 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68    R.rid   IN $th
8600: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74  eset     -- Rest
8610: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e  rict to revision
8620: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
8630: 20 20 20 41 4e 44 20 20 20 20 52 2e 72 69 64 20     AND    R.rid 
8640: 3d 20 42 2e 72 69 64 20 20 20 20 20 20 20 20 20  = B.rid         
8650: 20 2d 2d 20 53 65 6c 65 63 74 20 73 75 62 73 65   -- Select subse
8660: 74 20 6f 66 20 62 72 61 6e 63 68 20 63 68 69 6c  t of branch chil
8670: 64 72 65 6e 0a 09 20 20 20 20 41 4e 44 20 20 20  dren..    AND   
8680: 20 42 2e 62 72 69 64 20 49 4e 20 24 74 68 65 73   B.brid IN $thes
8690: 65 74 20 20 20 20 20 20 2d 2d 20 57 68 69 63 68  et      -- Which
86a0: 20 69 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74 65   is also of inte
86b0: 72 65 73 74 0a 20 20 20 20 55 4e 49 4f 4e 0a 20  rest.    UNION. 
86c0: 20 20 20 2d 2d 20 28 34 29 20 43 68 69 6c 64 20     -- (4) Child 
86d0: 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74 20 73 75  of trunk root su
86e0: 63 63 65 73 73 6f 72 20 6f 66 20 6c 61 73 74 20  ccessor of last 
86f0: 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b 2e 0a 09  NTDB on trunk...
8700: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64      SELECT R.rid
8710: 2c 20 52 41 2e 63 68 69 6c 64 0a 09 20 20 20 20  , RA.child..    
8720: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
8730: 20 72 65 76 69 73 69 6f 6e 20 52 41 0a 09 20 20   revision RA..  
8740: 20 20 57 48 45 52 45 20 52 2e 72 69 64 20 20 20    WHERE R.rid   
8750: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 20  IN $theset      
8760: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72  -- Restrict to r
8770: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65  evisions of inte
8780: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rest..    AND   
8790: 52 2e 69 73 64 65 66 61 75 6c 74 20 20 20 20 20  R.isdefault     
87a0: 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72          -- Restr
87b0: 69 63 74 20 74 6f 20 4e 54 44 42 0a 09 20 20 20  ict to NTDB..   
87c0: 20 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c 64   AND   R.dbchild
87d0: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d   IS NOT NULL   -
87e0: 2d 20 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20  - and last NTDB 
87f0: 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75  belonging to tru
8800: 6e 6b 0a 09 20 20 20 20 41 4e 44 20 20 20 52 41  nk..    AND   RA
8810: 2e 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64  .rid = R.dbchild
8820: 20 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65        -- Go dire
8830: 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f  ctly to trunk ro
8840: 6f 74 0a 09 20 20 20 20 41 4e 44 20 20 20 52 41  ot..    AND   RA
8850: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  .child IS NOT NU
8860: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69  LL    -- Has pri
8870: 6d 61 72 79 20 63 68 69 6c 64 2e 0a 20 20 20 20  mary child..    
8880: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 52 41          AND   RA
8890: 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73 65  .child IN $these
88a0: 74 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20 69  t     -- Which i
88b0: 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72 65  s also of intere
88c0: 73 74 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 23  st..}]] {..    #
88d0: 20 43 6f 6e 73 69 64 65 72 20 6d 6f 76 69 6e 67   Consider moving
88e0: 20 74 68 69 73 20 74 6f 20 74 68 65 20 69 6e 74   this to the int
88f0: 65 67 72 69 74 79 20 6d 6f 64 75 6c 65 2e 0a 09  egrity module...
8900: 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73      integrity as
8910: 73 65 72 74 20 7b 24 72 69 64 20 21 3d 20 24 63  sert {$rid != $c
8920: 68 69 6c 64 7d 20 7b 52 65 76 69 73 69 6f 6e 20  hild} {Revision 
8930: 24 72 69 64 20 64 65 70 65 6e 64 73 20 6f 6e 20  $rid depends on 
8940: 69 74 73 65 6c 66 2e 7d 0a 09 20 20 20 20 6c 61  itself.}..    la
8950: 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69  ppend dependenci
8960: 65 73 28 24 72 69 64 29 20 24 63 68 69 6c 64 0a  es($rid) $child.
8970: 09 20 20 20 20 73 65 74 20 64 65 70 28 24 72 69  .    set dep($ri
8980: 64 2c 24 63 68 69 6c 64 29 20 2e 0a 09 7d 0a 0a  d,$child) ...}..
8990: 09 23 20 54 68 65 20 73 71 6c 20 73 74 61 74 65  .# The sql state
89a0: 6d 65 6e 74 73 20 61 62 6f 76 65 20 6c 6f 6f 6b  ments above look
89b0: 73 20 6f 6e 6c 79 20 66 6f 72 20 64 69 72 65 63  s only for direc
89c0: 74 20 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 09  t dependencies..
89d0: 23 20 62 65 74 77 65 65 6e 20 72 65 76 69 73 69  # between revisi
89e0: 6f 6e 20 69 6e 20 74 68 65 20 63 68 61 6e 67 65  on in the change
89f0: 73 65 74 2e 20 48 6f 77 65 76 65 72 20 64 75 65  set. However due
8a00: 20 74 6f 20 74 68 65 0a 09 23 20 76 61 67 61 72   to the..# vagar
8a10: 69 65 73 20 6f 66 20 6d 65 74 61 20 64 61 74 61  ies of meta data
8a20: 20 69 74 20 69 73 20 70 6f 73 73 69 62 6c 65 20   it is possible 
8a30: 66 6f 72 20 74 77 6f 20 72 65 76 69 73 69 6f 6e  for two revision
8a40: 73 20 6f 66 0a 09 23 20 74 68 65 20 73 61 6d 65  s of..# the same
8a50: 20 66 69 6c 65 20 74 6f 20 65 6e 64 20 75 70 20   file to end up 
8a60: 69 6e 20 74 68 65 20 73 61 6d 65 20 63 68 61 6e  in the same chan
8a70: 67 65 73 65 74 2c 20 77 69 74 68 6f 75 74 20 61  geset, without a
8a80: 0a 09 23 20 64 69 72 65 63 74 20 64 65 70 65 6e  ..# direct depen
8a90: 64 65 6e 63 79 20 62 65 74 77 65 65 6e 20 74 68  dency between th
8aa0: 65 6d 2e 20 48 6f 77 65 76 65 72 20 77 65 20 6b  em. However we k
8ab0: 6e 6f 77 20 74 68 61 74 20 74 68 65 72 65 0a 09  now that there..
8ac0: 23 20 68 61 73 20 74 6f 20 62 65 20 61 20 61 6e  # has to be a an
8ad0: 20 69 6e 64 69 72 65 63 74 20 64 65 70 65 6e 64   indirect depend
8ae0: 65 6e 63 79 2c 20 62 65 20 69 74 20 74 68 72 6f  ency, be it thro
8af0: 75 67 68 20 70 72 69 6d 61 72 79 0a 09 23 20 63  ugh primary..# c
8b00: 68 69 6c 64 72 65 6e 2c 20 62 72 61 6e 63 68 20  hildren, branch 
8b10: 63 68 69 6c 64 72 65 6e 2c 20 6f 72 20 61 20 63  children, or a c
8b20: 6f 6d 62 69 6e 61 74 69 6f 6e 20 74 68 65 72 65  ombination there
8b30: 6f 66 2e 0a 0a 09 23 20 57 65 20 6e 6f 77 20 66  of....# We now f
8b40: 69 6c 6c 20 69 6e 20 74 68 65 73 65 20 70 73 65  ill in these pse
8b50: 75 64 6f 2d 64 65 70 65 6e 64 65 6e 63 69 65 73  udo-dependencies
8b60: 2c 20 69 66 20 6e 6f 20 73 75 63 68 0a 09 23 20  , if no such..# 
8b70: 64 65 70 65 6e 64 65 6e 63 79 20 65 78 69 73 74  dependency exist
8b80: 73 20 61 6c 72 65 61 64 79 2e 20 54 68 65 20 64  s already. The d
8b90: 69 72 65 63 74 69 6f 6e 20 6f 66 20 74 68 65 20  irection of the 
8ba0: 64 65 70 65 6e 64 65 6e 63 79 0a 09 23 20 69 73  dependency..# is
8bb0: 20 61 63 74 75 61 6c 6c 79 20 69 72 72 65 6c 65   actually irrele
8bc0: 76 61 6e 74 20 66 6f 72 20 74 68 69 73 2e 0a 0a  vant for this...
8bd0: 09 23 20 4e 4f 54 45 3a 20 54 68 69 73 20 69 73  .# NOTE: This is
8be0: 20 64 69 66 66 65 72 65 6e 74 20 66 72 6f 6d 20   different from 
8bf0: 63 76 73 32 73 76 6e 2e 20 4f 75 72 20 73 70 69  cvs2svn. Our spi
8c00: 72 69 74 75 61 6c 20 61 6e 63 65 73 74 6f 72 0a  ritual ancestor.
8c10: 09 23 20 64 6f 65 73 20 6e 6f 74 20 75 73 65 20  .# does not use 
8c20: 73 75 63 68 20 70 73 65 75 64 6f 2d 64 65 70 65  such pseudo-depe
8c30: 6e 64 65 6e 63 69 65 73 2c 20 68 6f 77 65 76 65  ndencies, howeve
8c40: 72 20 69 74 20 75 73 65 73 20 61 0a 09 23 20 43  r it uses a..# C
8c50: 4f 4d 4d 49 54 5f 54 48 52 45 53 48 4f 4c 44 2c  OMMIT_THRESHOLD,
8c60: 20 61 20 74 69 6d 65 20 69 6e 74 65 72 76 61 6c   a time interval
8c70: 20 63 6f 6d 6d 69 74 73 20 73 68 6f 75 6c 64 20   commits should 
8c80: 66 61 6c 6c 2e 20 54 68 69 73 0a 09 23 20 77 69  fall. This..# wi
8c90: 6c 6c 20 67 72 65 61 74 6c 79 20 72 65 64 75 63  ll greatly reduc
8ca0: 65 73 20 74 68 65 20 72 69 73 6b 20 6f 66 20 67  es the risk of g
8cb0: 65 74 74 69 6e 67 20 66 61 72 20 73 65 70 61 72  etting far separ
8cc0: 61 74 65 64 0a 09 23 20 72 65 76 69 73 69 6f 6e  ated..# revision
8cd0: 73 20 6f 66 20 74 68 65 20 73 61 6d 65 20 66 69  s of the same fi
8ce0: 6c 65 20 69 6e 74 6f 20 6f 6e 65 20 63 68 61 6e  le into one chan
8cf0: 67 65 73 65 74 2e 0a 0a 09 23 20 57 65 20 61 6c  geset....# We al
8d00: 6c 6f 77 20 72 65 76 69 73 69 6f 6e 73 20 74 6f  low revisions to
8d10: 20 62 65 20 66 61 72 20 61 70 61 72 74 20 69 6e   be far apart in
8d20: 20 74 69 6d 65 20 69 6e 20 74 68 65 20 73 61 6d   time in the sam
8d30: 65 0a 09 23 20 63 68 61 6e 67 65 73 65 74 2c 20  e..# changeset, 
8d40: 62 75 74 20 69 6e 20 74 75 72 6e 20 6e 65 65 64  but in turn need
8d50: 20 74 68 65 20 70 73 65 75 64 6f 2d 64 65 70 65   the pseudo-depe
8d60: 6e 64 65 6e 63 69 65 73 20 74 6f 0a 09 23 20 68  ndencies to..# h
8d70: 61 6e 64 6c 65 20 74 68 69 73 2e 0a 0a 09 6c 6f  andle this....lo
8d80: 67 20 77 72 69 74 65 20 31 34 20 63 73 65 74 20  g write 14 cset 
8d90: 70 73 65 75 64 6f 2d 69 6e 74 65 72 6e 61 6c 73  pseudo-internals
8da0: 75 63 63 65 73 73 6f 72 73 0a 0a 09 61 72 72 61  uccessors...arra
8db0: 79 20 73 65 74 20 66 69 64 73 20 7b 7d 0a 09 66  y set fids {}..f
8dc0: 6f 72 65 61 63 68 20 7b 72 69 64 20 66 69 64 7d  oreach {rid fid}
8dd0: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62   [state run [sub
8de0: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d  st -nocommands -
8df0: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a  nobackslashes {.
8e00: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69  .    SELECT R.ri
8e10: 64 2c 20 52 2e 66 69 64 0a 20 20 20 20 20 20 20  d, R.fid.       
8e20: 20 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69       FROM   revi
8e30: 73 69 6f 6e 20 52 0a 20 20 20 20 20 20 20 20 20  sion R.         
8e40: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
8e50: 49 4e 20 24 74 68 65 73 65 74 0a 09 7d 5d 5d 20  IN $theset..}]] 
8e60: 7b 20 6c 61 70 70 65 6e 64 20 66 69 64 73 28 24  { lappend fids($
8e70: 66 69 64 29 20 24 72 69 64 20 7d 0a 0a 09 66 6f  fid) $rid }...fo
8e80: 72 65 61 63 68 20 7b 66 69 64 20 72 69 64 73 7d  reach {fid rids}
8e90: 20 5b 61 72 72 61 79 20 67 65 74 20 66 69 64 73   [array get fids
8ea0: 5d 20 7b 0a 09 20 20 20 20 69 66 20 7b 5b 6c 6c  ] {..    if {[ll
8eb0: 65 6e 67 74 68 20 24 72 69 64 73 5d 20 3c 20 32  ength $rids] < 2
8ec0: 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20  } continue..    
8ed0: 66 6f 72 65 61 63 68 20 61 20 24 72 69 64 73 20  foreach a $rids 
8ee0: 7b 0a 09 09 66 6f 72 65 61 63 68 20 62 20 24 72  {...foreach b $r
8ef0: 69 64 73 20 7b 0a 09 09 20 20 20 20 69 66 20 7b  ids {...    if {
8f00: 24 61 20 3d 3d 20 24 62 7d 20 63 6f 6e 74 69 6e  $a == $b} contin
8f10: 75 65 0a 09 09 20 20 20 20 69 66 20 7b 5b 69 6e  ue...    if {[in
8f20: 66 6f 20 65 78 69 73 74 73 20 64 65 70 28 24 61  fo exists dep($a
8f30: 2c 24 62 29 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a  ,$b)]} continue.
8f40: 09 09 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20  ..    if {[info 
8f50: 65 78 69 73 74 73 20 64 65 70 28 24 62 2c 24 61  exists dep($b,$a
8f60: 29 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20  )]} continue... 
8f70: 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e     lappend depen
8f80: 64 65 6e 63 69 65 73 28 24 61 29 20 24 62 0a 09  dencies($a) $b..
8f90: 09 20 20 20 20 73 65 74 20 64 65 70 28 24 61 2c  .    set dep($a,
8fa0: 24 62 29 20 2e 0a 09 09 20 20 20 20 73 65 74 20  $b) ....    set 
8fb0: 64 65 70 28 24 62 2c 24 61 29 20 2e 0a 09 09 7d  dep($b,$a) ....}
8fc0: 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 6c 6f 67  ..    }..}...log
8fd0: 20 77 72 69 74 65 20 31 34 20 63 73 65 74 20 63   write 14 cset c
8fe0: 6f 6d 70 6c 65 74 65 0a 09 72 65 74 75 72 6e 0a  omplete..return.
8ff0: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73      }..    # res
9000: 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28 69 74  ult = 4-list (it
9010: 65 6d 74 79 70 65 20 69 74 65 6d 69 64 20 6e 65  emtype itemid ne
9020: 78 74 69 74 65 6d 74 79 70 65 20 6e 65 78 74 69  xtitemtype nexti
9030: 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 20 74  temid ...).    t
9040: 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 73 20  ypemethod loops 
9050: 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 23  {revisions} {..#
9060: 20 4e 6f 74 65 3a 20 54 61 67 73 20 61 6e 64 20   Note: Tags and 
9070: 62 72 61 6e 63 68 65 73 20 63 61 6e 6e 6f 74 20  branches cannot 
9080: 63 61 75 73 65 20 74 68 65 20 6c 6f 6f 70 2e 20  cause the loop. 
9090: 54 68 65 69 72 20 69 64 27 73 2c 0a 09 23 20 62  Their id's,..# b
90a0: 65 69 6e 67 20 6f 66 20 61 20 66 75 6e 64 61 6d  eing of a fundam
90b0: 65 6e 74 61 6c 6c 79 20 64 69 66 66 65 72 65 6e  entally differen
90c0: 74 20 74 79 70 65 20 74 68 61 6e 20 74 68 65 20  t type than the 
90d0: 72 65 76 69 73 69 6f 6e 73 0a 09 23 20 63 6f 6d  revisions..# com
90e0: 69 6e 67 20 69 6e 20 63 61 6e 6e 6f 74 20 62 65  ing in cannot be
90f0: 20 69 6e 20 74 68 65 20 73 65 74 2e 0a 0a 09 73   in the set....s
9100: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
9110: 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c  n $revisions {',
9120: 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73  '}]')..return [s
9130: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
9140: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
9150: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
9160: 20 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 72 79    -- (1) Primary
9170: 20 63 68 69 6c 64 0a 09 20 20 20 20 53 45 4c 45   child..    SELE
9180: 43 54 20 52 2e 72 69 64 2c 20 52 2e 63 68 69 6c  CT R.rid, R.chil
9190: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65  d..    FROM   re
91a0: 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48  vision R..    WH
91b0: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20  ERE  R.rid   IN 
91c0: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52  $theset     -- R
91d0: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
91e0: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
91f0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 63  ..    AND    R.c
9200: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
9210: 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61      -- Has prima
9220: 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 41 4e  ry child..    AN
9230: 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 4e 20  D    R.child IN 
9240: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c  $theset     -- L
9250: 6f 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20  oop..    --..   
9260: 20 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20 28   UNION..    -- (
9270: 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72  2) Secondary (br
9280: 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09  anch) children..
9290: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64      SELECT R.rid
92a0: 2c 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46 52  , B.brid..    FR
92b0: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
92c0: 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63   revisionbranchc
92d0: 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 57  hildren B..    W
92e0: 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e  HERE  R.rid   IN
92f0: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
9300: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
9310: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
9320: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
9330: 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20  rid = B.rid     
9340: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73       -- Select s
9350: 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20  ubset of branch 
9360: 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 41 4e  children..    AN
9370: 44 20 20 20 20 42 2e 72 69 64 20 20 20 49 4e 20  D    B.rid   IN 
9380: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c  $theset     -- L
9390: 6f 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20  oop..    --..   
93a0: 20 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20 28   UNION..    -- (
93b0: 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75 6e  4) Child of trun
93c0: 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f 72  k root successor
93d0: 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e   of last NTDB on
93e0: 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c   trunk...    SEL
93f0: 45 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63 68  ECT R.rid, RA.ch
9400: 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  ild..    FROM   
9410: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69  revision R, revi
9420: 73 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 45  sion RA..    WHE
9430: 52 45 20 20 52 2e 72 69 64 20 20 20 20 49 4e 20  RE  R.rid    IN 
9440: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52  $theset     -- R
9450: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
9460: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
9470: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 69  ..    AND    R.i
9480: 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20  sdefault        
9490: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
94a0: 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e   to NTDB..    AN
94b0: 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49  D    R.dbchild I
94c0: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20  S NOT NULL   -- 
94d0: 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65  and last NTDB be
94e0: 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b  longing to trunk
94f0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e  ..    AND    RA.
9500: 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20  rid = R.dbchild 
9510: 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63       -- Go direc
9520: 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f  tly to trunk roo
9530: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41  t..    AND    RA
9540: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  .child IS NOT NU
9550: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69  LL    -- Has pri
9560: 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 20 20 20  mary child...   
9570: 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c 64   AND    RA.child
9580: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
9590: 2d 2d 20 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20 20  -- Loop..}]].   
95a0: 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76   }..    # var(dv
95b0: 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d  ) = dict (item -
95c0: 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20  > list (item)), 
95d0: 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79  item  = list (ty
95e0: 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d  pe id).    typem
95f0: 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73  ethod successors
9600: 20 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 7d 20   {dv revisions} 
9610: 7b 0a 09 75 70 76 61 72 20 31 20 24 64 76 20 64  {..upvar 1 $dv d
9620: 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 65 74  ependencies..set
9630: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20   theset ('[join 
9640: 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d  $revisions {','}
9650: 5d 27 29 0a 0a 09 23 20 54 68 65 20 66 6f 6c 6c  ]')...# The foll
9660: 6f 77 69 6e 67 20 63 61 73 65 73 20 73 70 65 63  owing cases spec
9670: 69 66 79 20 77 68 65 6e 20 61 20 72 65 76 69 73  ify when a revis
9680: 69 6f 6e 20 53 20 69 73 20 61 20 73 75 63 63 65  ion S is a succe
9690: 73 73 6f 72 0a 09 23 20 6f 66 20 61 20 72 65 76  ssor..# of a rev
96a0: 69 73 69 6f 6e 20 52 2e 20 45 61 63 68 20 6f 66  ision R. Each of
96b0: 20 74 68 65 20 63 61 73 65 73 20 74 72 61 6e 73   the cases trans
96c0: 6c 61 74 65 73 20 69 6e 74 6f 20 6f 6e 65 20 6f  lates into one o
96d0: 66 0a 09 23 20 74 68 65 20 62 72 61 6e 63 68 65  f..# the branche
96e0: 73 20 6f 66 20 74 68 65 20 53 51 4c 20 55 4e 49  s of the SQL UNI
96f0: 4f 4e 20 63 6f 6d 69 6e 67 20 62 65 6c 6f 77 2e  ON coming below.
9700: 0a 09 23 0a 09 23 20 28 31 29 20 53 20 63 61 6e  ..#..# (1) S can
9710: 20 62 65 20 61 20 70 72 69 6d 61 72 79 20 63 68   be a primary ch
9720: 69 6c 64 20 6f 66 20 52 2c 20 69 2e 65 2e 20 69  ild of R, i.e. i
9730: 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 2e 20  n the same LOD. 
9740: 52 0a 09 23 20 20 20 20 20 72 65 66 65 72 65 6e  R..#     referen
9750: 63 65 73 20 53 20 64 69 72 65 63 74 6c 79 2e 20  ces S directly. 
9760: 52 2e 63 68 69 6c 64 20 3d 20 53 28 2e 72 69 64  R.child = S(.rid
9770: 29 2c 20 69 66 20 69 74 20 65 78 69 73 74 73 2e  ), if it exists.
9780: 0a 09 23 0a 09 23 20 28 32 29 20 53 20 63 61 6e  ..#..# (2) S can
9790: 20 62 65 20 61 20 73 65 63 6f 6e 64 61 72 79 2c   be a secondary,
97a0: 20 69 2e 65 2e 20 62 72 61 6e 63 68 2c 20 63 68   i.e. branch, ch
97b0: 69 6c 64 20 6f 66 20 52 2e 20 48 65 72 65 20 74  ild of R. Here t
97c0: 68 65 0a 09 23 20 20 20 20 20 6c 69 6e 6b 20 69  he..#     link i
97d0: 73 20 6d 61 64 65 20 74 68 72 6f 75 67 68 20 74  s made through t
97e0: 68 65 20 68 65 6c 70 65 72 20 74 61 62 6c 65 0a  he helper table.
97f0: 09 23 20 20 20 20 20 52 45 56 49 53 49 4f 4e 42  .#     REVISIONB
9800: 52 41 4e 43 48 43 48 49 4c 44 52 45 4e 2e 20 52  RANCHCHILDREN. R
9810: 2e 72 69 64 20 2d 3e 20 52 42 43 2e 72 69 64 2c  .rid -> RBC.rid,
9820: 20 52 42 43 2e 62 72 69 64 20 3d 0a 09 23 20 20   RBC.brid =..#  
9830: 20 20 20 53 28 2e 72 69 64 29 0a 09 23 0a 09 23     S(.rid)..#..#
9840: 20 28 33 29 20 4f 72 69 67 69 6e 61 6c 6c 79 20   (3) Originally 
9850: 74 68 69 73 20 75 73 65 20 63 61 73 65 20 64 65  this use case de
9860: 66 69 6e 65 64 20 74 68 65 20 72 6f 6f 74 20 6f  fined the root o
9870: 66 20 61 20 64 65 74 61 63 68 65 64 0a 09 23 20  f a detached..# 
9880: 20 20 20 20 4e 54 44 42 20 61 73 20 74 68 65 20      NTDB as the 
9890: 73 75 63 63 65 73 73 6f 72 20 6f 66 20 74 68 65  successor of the
98a0: 20 74 72 75 6e 6b 20 72 6f 6f 74 2e 20 54 68 69   trunk root. Thi
98b0: 73 20 6c 65 61 64 73 20 74 6f 20 61 0a 09 23 20  s leads to a..# 
98c0: 20 20 20 20 62 61 64 20 74 61 6e 67 6c 65 20 6c      bad tangle l
98d0: 61 74 65 72 20 6f 6e 2e 20 57 69 74 68 20 61 20  ater on. With a 
98e0: 64 65 74 61 63 68 65 64 20 4e 54 44 42 20 74 68  detached NTDB th
98f0: 65 20 6f 72 69 67 69 6e 61 6c 0a 09 23 20 20 20  e original..#   
9900: 20 20 74 72 75 6e 6b 20 72 6f 6f 74 20 72 65 76    trunk root rev
9910: 69 73 69 6f 6e 20 77 61 73 20 72 65 6d 6f 76 65  ision was remove
9920: 64 20 61 73 20 69 72 72 65 6c 65 76 61 6e 74 2c  d as irrelevant,
9930: 20 61 6c 6c 6f 77 69 6e 67 0a 09 23 20 20 20 20   allowing..#    
9940: 20 74 68 65 20 6e 6f 6d 69 6e 61 6c 20 72 6f 6f   the nominal roo
9950: 74 20 74 6f 20 62 65 20 6c 61 74 65 72 20 69 6e  t to be later in
9960: 20 74 69 6d 65 20 74 68 61 6e 20 74 68 65 20 4e   time than the N
9970: 54 44 42 0a 09 23 20 20 20 20 20 72 6f 6f 74 2e  TDB..#     root.
9980: 20 4e 6f 77 20 73 65 74 74 69 6e 67 20 74 68 69   Now setting thi
9990: 73 20 64 65 70 65 6e 64 65 6e 63 79 20 77 69 6c  s dependency wil
99a0: 6c 20 62 65 20 62 61 63 6b 77 61 72 64 20 69 6e  l be backward in
99b0: 0a 09 23 20 20 20 20 20 74 69 6d 65 2e 20 52 45  ..#     time. RE
99c0: 4d 4f 56 45 44 2e 0a 09 23 0a 09 23 20 28 34 29  MOVED...#..# (4)
99d0: 20 49 66 20 52 20 69 73 20 74 68 65 20 6c 61 73   If R is the las
99e0: 74 20 6f 66 20 74 68 65 20 4e 54 44 42 20 72 65  t of the NTDB re
99f0: 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 62 65  visions which be
9a00: 6c 6f 6e 67 20 74 6f 0a 09 23 20 20 20 20 20 74  long to..#     t
9a10: 68 65 20 74 72 75 6e 6b 2c 20 74 68 65 6e 20 74  he trunk, then t
9a20: 68 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  he primary child
9a30: 20 6f 66 20 74 68 65 20 74 72 75 6e 6b 20 72 6f   of the trunk ro
9a40: 6f 74 20 28 74 68 65 0a 09 23 20 20 20 20 20 27  ot (the..#     '
9a50: 31 2e 32 27 20 72 65 76 69 73 69 6f 6e 29 20 69  1.2' revision) i
9a60: 73 20 61 20 73 75 63 63 65 73 73 6f 72 2c 20 69  s a successor, i
9a70: 66 20 69 74 20 65 78 69 73 74 73 2e 0a 0a 09 23  f it exists....#
9a80: 20 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20 62   Note that the b
9a90: 72 61 6e 63 68 65 73 20 73 70 61 77 6e 65 64 20  ranches spawned 
9aa0: 66 72 6f 6d 20 74 68 65 20 72 65 76 69 73 69 6f  from the revisio
9ab0: 6e 73 2c 20 61 6e 64 20 74 68 65 0a 09 23 20 74  ns, and the..# t
9ac0: 61 67 73 20 61 73 73 6f 63 69 61 74 65 64 20 77  ags associated w
9ad0: 69 74 68 20 74 68 65 6d 20 61 72 65 20 73 75 63  ith them are suc
9ae0: 63 65 73 73 6f 72 73 20 61 73 20 77 65 6c 6c 2e  cessors as well.
9af0: 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20  ...foreach {rid 
9b00: 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75  child} [state ru
9b10: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
9b20: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
9b30: 68 65 73 20 7b 0a 20 20 20 20 2d 2d 20 28 31 29  hes {.    -- (1)
9b40: 20 50 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09   Primary child..
9b50: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64      SELECT R.rid
9b60: 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20 20 20 46  , R.child..    F
9b70: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
9b80: 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72  ..    WHERE  R.r
9b90: 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20  id   IN $theset 
9ba0: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
9bb0: 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20  to revisions of 
9bc0: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e  interest..    AN
9bd0: 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20  D    R.child IS 
9be0: 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48  NOT NULL    -- H
9bf0: 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  as primary child
9c00: 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d  .    UNION.    -
9c10: 2d 20 28 32 29 20 53 65 63 6f 6e 64 61 72 79 20  - (2) Secondary 
9c20: 28 62 72 61 6e 63 68 29 20 63 68 69 6c 64 72 65  (branch) childre
9c30: 6e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e  n..    SELECT R.
9c40: 72 69 64 2c 20 42 2e 62 72 69 64 0a 09 20 20 20  rid, B.brid..   
9c50: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
9c60: 20 52 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e   R, revisionbran
9c70: 63 68 63 68 69 6c 64 72 65 6e 20 42 0a 09 20 20  chchildren B..  
9c80: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20    WHERE  R.rid  
9c90: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
9ca0: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72  -- Restrict to r
9cb0: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65  evisions of inte
9cc0: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rest..    AND   
9cd0: 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 20 20   R.rid = B.rid  
9ce0: 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63          -- Selec
9cf0: 74 20 73 75 62 73 65 74 20 6f 66 20 62 72 61 6e  t subset of bran
9d00: 63 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 20 20  ch children.    
9d10: 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29  UNION.    -- (4)
9d20: 20 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20   Child of trunk 
9d30: 72 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f  root successor o
9d40: 66 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74  f last NTDB on t
9d50: 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43  runk...    SELEC
9d60: 54 20 52 2e 72 69 64 2c 20 52 41 2e 63 68 69 6c  T R.rid, RA.chil
9d70: 64 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69  d..    FROM revi
9d80: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e  sion R, revision
9d90: 20 52 41 0a 09 20 20 20 20 57 48 45 52 45 20 52   RA..    WHERE R
9da0: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65  .rid   IN $these
9db0: 74 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  t      -- Restri
9dc0: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
9dd0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
9de0: 20 41 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75   AND   R.isdefau
9df0: 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d  lt             -
9e00: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54  - Restrict to NT
9e10: 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e  DB..    AND   R.
9e20: 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e  dbchild IS NOT N
9e30: 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73  ULL   -- and las
9e40: 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67  t NTDB belonging
9e50: 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 41   to trunk..    A
9e60: 4e 44 20 20 20 52 41 2e 72 69 64 20 3d 20 52 2e  ND   RA.rid = R.
9e70: 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d 2d 20  dbchild      -- 
9e80: 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74  Go directly to t
9e90: 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41  runk root..    A
9ea0: 4e 44 20 20 20 52 41 2e 63 68 69 6c 64 20 49 53  ND   RA.child IS
9eb0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20   NOT NULL    -- 
9ec0: 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c  Has primary chil
9ed0: 64 2e 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 23  d...}]] {..    #
9ee0: 20 43 6f 6e 73 69 64 65 72 20 6d 6f 76 69 6e 67   Consider moving
9ef0: 20 74 68 69 73 20 74 6f 20 74 68 65 20 69 6e 74   this to the int
9f00: 65 67 72 69 74 79 20 6d 6f 64 75 6c 65 2e 0a 09  egrity module...
9f10: 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73      integrity as
9f20: 73 65 72 74 20 7b 24 72 69 64 20 21 3d 20 24 63  sert {$rid != $c
9f30: 68 69 6c 64 7d 20 7b 52 65 76 69 73 69 6f 6e 20  hild} {Revision 
9f40: 24 72 69 64 20 64 65 70 65 6e 64 73 20 6f 6e 20  $rid depends on 
9f50: 69 74 73 65 6c 66 2e 7d 0a 09 20 20 20 20 6c 61  itself.}..    la
9f60: 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69  ppend dependenci
9f70: 65 73 28 5b 6c 69 73 74 20 72 65 76 20 24 72 69  es([list rev $ri
9f80: 64 5d 29 20 5b 6c 69 73 74 20 72 65 76 20 24 63  d]) [list rev $c
9f90: 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 61 63  hild]..}..foreac
9fa0: 68 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73  h {rid child} [s
9fb0: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
9fc0: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
9fd0: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
9fe0: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20    SELECT R.rid, 
9ff0: 54 2e 74 69 64 0a 09 20 20 20 20 46 52 4f 4d 20  T.tid..    FROM 
a000: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 74 61    revision R, ta
a010: 67 20 54 0a 09 20 20 20 20 57 48 45 52 45 20 20  g T..    WHERE  
a020: 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74  R.rid IN $theset
a030: 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69         -- Restri
a040: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
a050: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
a060: 20 41 4e 44 20 20 20 20 54 2e 72 65 76 20 3d 20   AND    T.rev = 
a070: 52 2e 72 69 64 20 20 20 20 20 20 20 20 20 20 2d  R.rid          -
a080: 2d 20 53 65 6c 65 63 74 20 74 61 67 73 20 61 74  - Select tags at
a090: 74 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 09  tached to them..
a0a0: 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65  }]] {..    lappe
a0b0: 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28  nd dependencies(
a0c0: 5b 6c 69 73 74 20 72 65 76 20 24 72 69 64 5d 29  [list rev $rid])
a0d0: 20 5b 6c 69 73 74 20 73 79 6d 3a 3a 74 61 67 20   [list sym::tag 
a0e0: 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65  $child]..}..fore
a0f0: 61 63 68 20 7b 72 69 64 20 63 68 69 6c 64 7d 20  ach {rid child} 
a100: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
a110: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
a120: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09  obackslashes {..
a130: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64      SELECT R.rid
a140: 2c 20 42 2e 62 69 64 0a 09 20 20 20 20 46 52 4f  , B.bid..    FRO
a150: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
a160: 62 72 61 6e 63 68 20 42 0a 09 20 20 20 20 57 48  branch B..    WH
a170: 45 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24 74  ERE  R.rid IN $t
a180: 68 65 73 65 74 20 20 20 20 20 20 20 2d 2d 20 52  heset       -- R
a190: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
a1a0: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
a1b0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72  ..    AND    B.r
a1c0: 6f 6f 74 20 3d 20 52 2e 72 69 64 20 20 20 20 20  oot = R.rid     
a1d0: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 62 72      -- Select br
a1e0: 61 6e 63 68 65 73 20 61 74 74 61 63 68 65 64 20  anches attached 
a1f0: 74 6f 20 74 68 65 6d 0a 09 7d 5d 5d 20 7b 0a 09  to them..}]] {..
a200: 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65      lappend depe
a210: 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 72  ndencies([list r
a220: 65 76 20 24 72 69 64 5d 29 20 5b 6c 69 73 74 20  ev $rid]) [list 
a230: 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 63 68 69  sym::branch $chi
a240: 6c 64 5d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20  ld]..}..return. 
a250: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75     }..    # resu
a260: 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e 67  lt = list (chang
a270: 65 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79 70  eset-id).    typ
a280: 65 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63 65  emethod cs_succe
a290: 73 73 6f 72 73 20 7b 72 65 76 69 73 69 6f 6e 73  ssors {revisions
a2a0: 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 20 54 68  } {.        # Th
a2b0: 69 73 20 69 73 20 61 20 76 61 72 69 61 6e 74 20  is is a variant 
a2c0: 6f 66 20 27 73 75 63 63 65 73 73 6f 72 73 27 20  of 'successors' 
a2d0: 77 68 69 63 68 20 6d 61 70 73 20 74 68 65 20 6c  which maps the l
a2e0: 6f 77 2d 6c 65 76 65 6c 0a 20 20 20 20 20 20 20  ow-level.       
a2f0: 20 23 20 64 61 74 61 20 64 69 72 65 63 74 6c 79   # data directly
a300: 20 74 6f 20 74 68 65 20 61 73 73 6f 63 69 61 74   to the associat
a310: 65 64 20 63 68 61 6e 67 65 73 65 74 73 2e 20 49  ed changesets. I
a320: 2e 65 2e 20 69 6e 73 74 65 61 64 0a 20 20 20 20  .e. instead.    
a330: 20 20 20 20 23 20 6d 69 6c 6c 69 6f 6e 73 20 6f      # millions o
a340: 66 20 64 65 70 65 6e 64 65 6e 63 79 20 70 61 69  f dependency pai
a350: 72 73 20 28 69 6e 20 65 78 74 72 65 6d 65 20 63  rs (in extreme c
a360: 61 73 65 73 20 28 45 78 61 6d 70 6c 65 3a 20 54  ases (Example: T
a370: 63 6c 0a 20 20 20 20 20 20 20 20 23 20 43 56 53  cl.        # CVS
a380: 29 29 20 77 65 20 72 65 74 75 72 6e 20 61 20 76  )) we return a v
a390: 65 72 79 20 73 68 6f 72 74 20 61 6e 64 20 6d 75  ery short and mu
a3a0: 63 68 20 6d 6f 72 65 20 6d 61 6e 61 67 65 61 62  ch more manageab
a3b0: 6c 65 20 6c 69 73 74 0a 20 20 20 20 20 20 20 20  le list.        
a3c0: 23 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73 2e  # of changesets.
a3d0: 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27  ...set theset ('
a3e0: 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73  [join $revisions
a3f0: 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72   {','}]')..retur
a400: 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75  n [state run [su
a410: 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20  bst -nocommands 
a420: 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b  -nobackslashes {
a430: 0a 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d  .    -- (1) Prim
a440: 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53  ary child..    S
a450: 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20  ELECT C.cid..   
a460: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
a470: 20 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63   R, csitem CI, c
a480: 68 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20  hangeset C..    
a490: 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49  WHERE  R.rid   I
a4a0: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d  N $theset     --
a4b0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76   Restrict to rev
a4c0: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65  isions of intere
a4d0: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52  st..    AND    R
a4e0: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  .child IS NOT NU
a4f0: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69  LL    -- Has pri
a500: 6d 61 72 79 20 63 68 69 6c 64 0a 20 20 20 20 20  mary child.     
a510: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49         AND    CI
a520: 2e 69 69 64 20 3d 20 52 2e 63 68 69 6c 64 20 20  .iid = R.child  
a530: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61       -- Select a
a540: 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20  ll changesets.  
a550: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
a560: 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 20   C.cid = CI.cid 
a570: 20 20 20 20 20 20 20 20 2d 2d 20 63 6f 6e 74 61          -- conta
a580: 69 6e 69 6e 67 20 74 68 65 20 70 72 69 6d 61 72  ining the primar
a590: 79 20 63 68 69 6c 64 0a 20 20 20 20 20 20 20 20  y child.        
a5a0: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70      AND    C.typ
a5b0: 65 20 3d 20 30 20 20 20 20 20 20 20 20 20 20 20  e = 0           
a5c0: 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 72    -- which are r
a5d0: 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65  evision changese
a5e0: 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20  ts.    UNION.   
a5f0: 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61 72   -- (2) Secondar
a600: 79 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c 64  y (branch) child
a610: 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54 20  ren..    SELECT 
a620: 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20  C.cid..    FROM 
a630: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65    revision R, re
a640: 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c  visionbranchchil
a650: 64 72 65 6e 20 42 2c 20 63 73 69 74 65 6d 20 43  dren B, csitem C
a660: 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09  I, changeset C..
a670: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64      WHERE  R.rid
a680: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20     IN $theset   
a690: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
a6a0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
a6b0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
a6c0: 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64     R.rid = B.rid
a6d0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c            -- Sel
a6e0: 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62 72  ect subset of br
a6f0: 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 20 20  anch children.  
a700: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
a710: 20 43 49 2e 69 69 64 20 3d 20 42 2e 62 72 69 64   CI.iid = B.brid
a720: 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63          -- Selec
a730: 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73  t all changesets
a740: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
a750: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63      C.cid = CI.c
a760: 69 64 09 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69  id.  -- containi
a770: 6e 67 20 74 68 65 20 62 72 61 6e 63 68 0a 20 20  ng the branch.  
a780: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
a790: 20 43 2e 74 79 70 65 20 3d 20 30 09 09 20 20 2d   C.type = 0..  -
a7a0: 2d 20 77 68 69 63 68 20 61 72 65 20 72 65 76 69  - which are revi
a7b0: 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a  sion changesets.
a7c0: 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d      UNION.    --
a7d0: 20 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72   (4) Child of tr
a7e0: 75 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73  unk root success
a7f0: 6f 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20  or of last NTDB 
a800: 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53  on trunk...    S
a810: 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20  ELECT C.cid..   
a820: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
a830: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 2c   R, revision RA,
a840: 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e   csitem CI, chan
a850: 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45  geset C..    WHE
a860: 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24  RE  R.rid   IN $
a870: 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 52  theset      -- R
a880: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
a890: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
a8a0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 69  ..    AND    R.i
a8b0: 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20  sdefault        
a8c0: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
a8d0: 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e   to NTDB..    AN
a8e0: 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49  D    R.dbchild I
a8f0: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20  S NOT NULL   -- 
a900: 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65  and last NTDB be
a910: 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b  longing to trunk
a920: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e  ..    AND    RA.
a930: 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20  rid = R.dbchild 
a940: 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63       -- Go direc
a950: 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f  tly to trunk roo
a960: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41  t..    AND    RA
a970: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  .child IS NOT NU
a980: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69  LL    -- Has pri
a990: 6d 61 72 79 20 63 68 69 6c 64 2e 0a 20 20 20 20  mary child..    
a9a0: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
a9b0: 49 2e 69 69 64 20 3d 20 52 41 2e 63 68 69 6c 64  I.iid = RA.child
a9c0: 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74         -- Select
a9d0: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a   all changesets.
a9e0: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20              AND 
a9f0: 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69     C.cid = CI.ci
aa00: 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69  d.   -- containi
aa10: 6e 67 20 74 68 65 20 70 72 69 6d 61 72 79 20 63  ng the primary c
aa20: 68 69 6c 64 0a 20 20 20 20 20 20 20 20 20 20 20  hild.           
aa30: 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d   AND    C.type =
aa40: 20 30 09 09 20 20 20 2d 2d 20 77 68 69 63 68 20   0..   -- which 
aa50: 61 72 65 20 72 65 76 69 73 69 6f 6e 20 63 68 61  are revision cha
aa60: 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f  ngesets.    UNIO
aa70: 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e  N..    SELECT C.
aa80: 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  cid..    FROM   
aa90: 72 65 76 69 73 69 6f 6e 20 52 2c 20 74 61 67 20  revision R, tag 
aaa0: 54 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68  T, csitem CI, ch
aab0: 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57  angeset C..    W
aac0: 48 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20 24  HERE  R.rid in $
aad0: 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d  theset        --
aae0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76   Restrict to rev
aaf0: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65  isions of intere
ab00: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 54  st..    AND    T
ab10: 2e 72 65 76 20 3d 20 52 2e 72 69 64 09 20 20 20  .rev = R.rid.   
ab20: 2d 2d 20 53 65 6c 65 63 74 20 74 61 67 73 20 61  -- Select tags a
ab30: 74 74 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a  ttached to them.
ab40: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20              AND 
ab50: 20 20 20 43 49 2e 69 69 64 20 3d 20 54 2e 74 69     CI.iid = T.ti
ab60: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65  d          -- Se
ab70: 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73  lect all changes
ab80: 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 20  ets.            
ab90: 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43  AND    C.cid = C
aba0: 49 2e 63 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74  I.cid.   -- cont
abb0: 61 69 6e 69 6e 67 20 74 68 65 20 74 61 67 73 0a  aining the tags.
abc0: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20              AND 
abd0: 20 20 20 43 2e 74 79 70 65 20 3d 20 31 09 09 20     C.type = 1.. 
abe0: 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 74    -- which are t
abf0: 61 67 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20  ag changesets.  
ac00: 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c    UNION..    SEL
ac10: 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46  ECT C.cid..    F
ac20: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
ac30: 2c 20 62 72 61 6e 63 68 20 42 2c 20 63 73 69 74  , branch B, csit
ac40: 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74  em CI, changeset
ac50: 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 52   C..    WHERE  R
ac60: 2e 72 69 64 20 69 6e 20 24 74 68 65 73 65 74 20  .rid in $theset 
ac70: 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69         -- Restri
ac80: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
ac90: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
aca0: 20 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d   AND    B.root =
acb0: 20 52 2e 72 69 64 09 20 20 20 2d 2d 20 53 65 6c   R.rid.   -- Sel
acc0: 65 63 74 20 62 72 61 6e 63 68 65 73 20 61 74 74  ect branches att
acd0: 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 20 20  ached to them.  
ace0: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
acf0: 20 43 49 2e 69 69 64 20 3d 20 42 2e 62 69 64 20   CI.iid = B.bid 
ad00: 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65           -- Sele
ad10: 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74  ct all changeset
ad20: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e  s.            AN
ad30: 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e  D    C.cid = CI.
ad40: 63 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69  cid.   -- contai
ad50: 6e 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68 65  ning the branche
ad60: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e  s.            AN
ad70: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 32 09  D    C.type = 2.
ad80: 09 20 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65  .   -- which are
ad90: 20 62 72 61 6e 63 68 20 63 68 61 6e 67 65 73 65   branch changese
ada0: 74 73 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20  ts..}]].    }.. 
adb0: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 73 79     # result = sy
adc0: 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20 20 20 74 79  mbol name.    ty
add0: 70 65 6d 65 74 68 6f 64 20 63 73 5f 6c 6f 64 20  pemethod cs_lod 
ade0: 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 23  {revisions} {..#
adf0: 20 44 65 74 65 72 6d 69 6e 65 73 20 74 68 65 20   Determines the 
ae00: 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 79 6d 62  name of the symb
ae10: 6f 6c 20 77 68 69 63 68 20 69 73 20 74 68 65 20  ol which is the 
ae20: 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c  line of..# devel
ae30: 6f 70 6d 65 6e 74 20 66 6f 72 20 74 68 65 20 72  opment for the r
ae40: 65 76 69 73 69 6f 6e 73 20 69 6e 20 61 20 63 68  evisions in a ch
ae50: 61 6e 67 65 73 65 74 2e 0a 0a 09 73 65 74 20 74  angeset....set t
ae60: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72  heset ('[join $r
ae70: 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27  evisions {','}]'
ae80: 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65  )..return [state
ae90: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63   run [subst -noc
aea0: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73  ommands -nobacks
aeb0: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45  lashes {..    SE
aec0: 4c 45 43 54 0a 09 20 20 20 20 44 49 53 54 49 4e  LECT..    DISTIN
aed0: 43 54 20 4c 2e 6e 61 6d 65 0a 09 20 20 20 20 46  CT L.name..    F
aee0: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
aef0: 2c 20 73 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20  , symbol L..    
af00: 57 48 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20  WHERE  R.rid in 
af10: 24 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d  $theset        -
af20: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65  - Restrict to re
af30: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72  visions of inter
af40: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  est..    AND    
af50: 4c 2e 73 69 64 20 3d 20 52 2e 6c 6f 64 20 20 20  L.sid = R.lod   
af60: 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 6c          -- Get l
af70: 6f 64 20 73 79 6d 62 6f 6c 20 6f 66 20 72 65 76  od symbol of rev
af80: 69 73 69 6f 6e 0a 09 7d 5d 5d 0a 20 20 20 20 7d  ision..}]].    }
af90: 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23  .}..# # ## ### #
afa0: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
afb0: 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23  ########### ####
afc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
afd0: 23 0a 23 23 20 48 65 6c 70 65 72 20 73 69 6e 67  #.## Helper sing
afe0: 6c 65 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73 20  leton. Commands 
aff0: 66 6f 72 20 74 61 67 20 73 79 6d 62 6f 6c 20 63  for tag symbol c
b000: 68 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e 69 74  hangesets...snit
b010: 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73  ::type ::vc::fos
b020: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
b030: 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a  ::project::rev::
b040: 73 79 6d 3a 3a 74 61 67 20 7b 0a 20 20 20 20 74  sym::tag {.    t
b050: 79 70 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69  ypemethod byrevi
b060: 73 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e  sion {} { return
b070: 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74   0 }.    typemet
b080: 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b  hod bysymbol   {
b090: 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20  } { return 1 }. 
b0a0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73     typemethod is
b0b0: 74 61 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65  tag      {} { re
b0c0: 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70  turn 1 }.    typ
b0d0: 65 6d 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68  emethod isbranch
b0e0: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30     {} { return 0
b0f0: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68   }..    typemeth
b100: 6f 64 20 73 74 72 20 7b 74 61 67 7d 20 7b 0a 09  od str {tag} {..
b110: 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73  struct::list ass
b120: 69 67 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b  ign [state run {
b130: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e  ..    SELECT S.n
b140: 61 6d 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e  ame, F.name, P.n
b150: 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  ame..    FROM   
b160: 74 61 67 20 54 2c 20 73 79 6d 62 6f 6c 20 53 2c  tag T, symbol S,
b170: 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74   file F, project
b180: 20 50 0a 09 20 20 20 20 57 48 45 52 45 20 20 54   P..    WHERE  T
b190: 2e 74 69 64 20 3d 20 24 74 61 67 20 20 20 2d 2d  .tid = $tag   --
b1a0: 20 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 20   Find specified 
b1b0: 74 61 67 0a 09 20 20 20 20 41 4e 44 20 20 20 20  tag..    AND    
b1c0: 46 2e 66 69 64 20 3d 20 54 2e 66 69 64 20 20 2d  F.fid = T.fid  -
b1d0: 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 74 61  - Get file of ta
b1e0: 67 0a 09 20 20 20 20 41 4e 44 20 20 20 20 50 2e  g..    AND    P.
b1f0: 70 69 64 20 3d 20 46 2e 70 69 64 20 20 2d 2d 20  pid = F.pid  -- 
b200: 47 65 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 66  Get project of f
b210: 69 6c 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ile..    AND    
b220: 53 2e 73 69 64 20 3d 20 54 2e 73 69 64 20 20 2d  S.sid = T.sid  -
b230: 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20  - Get symbol of 
b240: 74 61 67 0a 09 7d 5d 20 73 6e 61 6d 65 20 66 6e  tag..}] sname fn
b250: 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72  ame pname..retur
b260: 6e 20 22 24 70 6e 61 6d 65 2f 54 27 24 7b 73 6e  n "$pname/T'${sn
b270: 61 6d 65 7d 27 3a 3a 24 66 6e 61 6d 65 22 0a 20  ame}'::$fname". 
b280: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75     }..    # resu
b290: 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69  lt = list (minti
b2a0: 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20  me, maxtime).   
b2b0: 20 74 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65   typemethod time
b2c0: 72 61 6e 67 65 20 7b 74 61 67 73 7d 20 7b 0a 09  range {tags} {..
b2d0: 23 20 54 68 65 20 72 61 6e 67 65 20 69 73 20 64  # The range is d
b2e0: 65 66 69 6e 65 64 20 61 73 20 74 68 65 20 72 61  efined as the ra
b2f0: 6e 67 65 20 6f 66 20 74 68 65 20 72 65 76 69 73  nge of the revis
b300: 69 6f 6e 73 20 74 68 65 20 74 61 67 73 0a 09 23  ions the tags..#
b310: 20 61 72 65 20 61 74 74 61 63 68 65 64 20 74 6f   are attached to
b320: 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28  ....set theset (
b330: 27 5b 6a 6f 69 6e 20 24 74 61 67 73 20 7b 27 2c  '[join $tags {',
b340: 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73  '}]')..return [s
b350: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
b360: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
b370: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
b380: 20 20 53 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64    SELECT MIN(R.d
b390: 61 74 65 29 2c 20 4d 41 58 28 52 2e 64 61 74 65  ate), MAX(R.date
b3a0: 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 74 61  )..    FROM   ta
b3b0: 67 20 54 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a  g T, revision R.
b3c0: 09 20 20 20 20 57 48 45 52 45 20 20 54 2e 74 69  .    WHERE  T.ti
b3d0: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d  d IN $theset  --
b3e0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 74 61 67   Restrict to tag
b3f0: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20  s of interest.  
b400: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
b410: 20 52 2e 72 69 64 20 3d 20 54 2e 72 65 76 20 20   R.rid = T.rev  
b420: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 74 61 67     -- Select tag
b430: 20 70 61 72 65 6e 74 20 72 65 76 69 73 69 6f 6e   parent revision
b440: 73 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20  s..}]].    }..  
b450: 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69    # var(dv) = di
b460: 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74  ct (item -> list
b470: 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20   (item)), item  
b480: 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29  = list (type id)
b490: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
b4a0: 73 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20 74  successors {dv t
b4b0: 61 67 73 7d 20 7b 0a 09 23 20 54 61 67 73 20 68  ags} {..# Tags h
b4c0: 61 76 65 20 6e 6f 20 73 75 63 63 65 73 73 6f 72  ave no successor
b4d0: 73 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  s...return.    }
b4e0: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d  ..    # result =
b4f0: 20 34 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70   4-list (itemtyp
b500: 65 20 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65  e itemid nextite
b510: 6d 74 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64  mtype nextitemid
b520: 20 2e 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65   ...).    typeme
b530: 74 68 6f 64 20 6c 6f 6f 70 73 20 7b 74 61 67 73  thod loops {tags
b540: 7d 20 7b 0a 09 23 20 54 61 67 73 20 68 61 76 65  } {..# Tags have
b550: 20 6e 6f 20 73 75 63 63 65 73 73 6f 72 73 2c 20   no successors, 
b560: 74 68 65 72 65 66 6f 72 65 20 63 61 6e 6e 6f 74  therefore cannot
b570: 20 63 61 75 73 65 20 6c 6f 6f 70 73 0a 09 72 65   cause loops..re
b580: 74 75 72 6e 20 7b 7d 0a 20 20 20 20 7d 0a 0a 20  turn {}.    }.. 
b590: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69     # result = li
b5a0: 73 74 20 28 63 68 61 6e 67 65 73 65 74 2d 69 64  st (changeset-id
b5b0: 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ).    typemethod
b5c0: 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73 20 7b   cs_successors {
b5d0: 74 61 67 73 7d 20 7b 0a 09 23 20 54 61 67 73 20  tags} {..# Tags 
b5e0: 68 61 76 65 20 6e 6f 20 73 75 63 63 65 73 73 6f  have no successo
b5f0: 72 73 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  rs...return.    
b600: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20  }..    # result 
b610: 3d 20 73 79 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20  = symbol name.  
b620: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f    typemethod cs_
b630: 6c 6f 64 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20  lod {tags} {..# 
b640: 44 65 74 65 72 6d 69 6e 65 73 20 74 68 65 20 6e  Determines the n
b650: 61 6d 65 20 6f 66 20 74 68 65 20 73 79 6d 62 6f  ame of the symbo
b660: 6c 20 77 68 69 63 68 20 69 73 20 74 68 65 20 6c  l which is the l
b670: 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c 6f  ine of..# develo
b680: 70 6d 65 6e 74 20 66 6f 72 20 74 68 65 20 74 61  pment for the ta
b690: 67 73 20 69 6e 20 61 20 63 68 61 6e 67 65 73 65  gs in a changese
b6a0: 74 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20  t....set theset 
b6b0: 28 27 5b 6a 6f 69 6e 20 24 74 61 67 73 20 7b 27  ('[join $tags {'
b6c0: 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b  ,'}]')..return [
b6d0: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74  state run [subst
b6e0: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f   -nocommands -no
b6f0: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20  backslashes {.. 
b700: 20 20 20 53 45 4c 45 43 54 0a 09 20 20 20 20 44     SELECT..    D
b710: 49 53 54 49 4e 43 54 20 4c 2e 6e 61 6d 65 0a 09  ISTINCT L.name..
b720: 20 20 20 20 46 52 4f 4d 20 20 20 74 61 67 20 54      FROM   tag T
b730: 2c 20 73 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20  , symbol L..    
b740: 57 48 45 52 45 20 20 54 2e 74 69 64 20 69 6e 20  WHERE  T.tid in 
b750: 24 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d  $theset        -
b760: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 74 61  - Restrict to ta
b770: 67 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  gs of interest..
b780: 20 20 20 20 41 4e 44 20 20 20 20 4c 2e 73 69 64      AND    L.sid
b790: 20 3d 20 54 2e 6c 6f 64 20 20 20 20 20 20 20 20   = T.lod        
b7a0: 20 20 20 2d 2d 20 47 65 74 20 6c 6f 64 20 73 79     -- Get lod sy
b7b0: 6d 62 6f 6c 20 6f 66 20 74 61 67 0a 09 7d 5d 5d  mbol of tag..}]]
b7c0: 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23  .    }.}..# # ##
b7d0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
b7e0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
b7f0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23  # ##############
b800: 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65  #######.## Helpe
b810: 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d  r singleton. Com
b820: 6d 61 6e 64 73 20 66 6f 72 20 62 72 61 6e 63 68  mands for branch
b830: 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65   symbol changese
b840: 74 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20  ts...snit::type 
b850: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
b860: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65  port::cvs::proje
b870: 63 74 3a 3a 72 65 76 3a 3a 73 79 6d 3a 3a 62 72  ct::rev::sym::br
b880: 61 6e 63 68 20 7b 0a 20 20 20 20 74 79 70 65 6d  anch {.    typem
b890: 65 74 68 6f 64 20 62 79 72 65 76 69 73 69 6f 6e  ethod byrevision
b8a0: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d   {} { return 0 }
b8b0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
b8c0: 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 7b 20  bysymbol   {} { 
b8d0: 72 65 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74  return 1 }.    t
b8e0: 79 70 65 6d 65 74 68 6f 64 20 69 73 74 61 67 20  ypemethod istag 
b8f0: 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e       {} { return
b900: 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74   0 }.    typemet
b910: 68 6f 64 20 69 73 62 72 61 6e 63 68 20 20 20 7b  hod isbranch   {
b920: 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 0a  } { return 1 }..
b930: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73      typemethod s
b940: 74 72 20 7b 62 72 61 6e 63 68 7d 20 7b 0a 09 73  tr {branch} {..s
b950: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69  truct::list assi
b960: 67 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a  gn [state run {.
b970: 09 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e 61  .    SELECT S.na
b980: 6d 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e 61  me, F.name, P.na
b990: 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62  me..    FROM   b
b9a0: 72 61 6e 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20  ranch B, symbol 
b9b0: 53 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65  S, file F, proje
b9c0: 63 74 20 50 0a 09 20 20 20 20 57 48 45 52 45 20  ct P..    WHERE 
b9d0: 20 42 2e 62 69 64 20 3d 20 24 62 72 61 6e 63 68   B.bid = $branch
b9e0: 20 20 2d 2d 20 46 69 6e 64 20 73 70 65 63 69 66    -- Find specif
b9f0: 69 65 64 20 62 72 61 6e 63 68 0a 09 20 20 20 20  ied branch..    
ba00: 41 4e 44 20 20 20 20 46 2e 66 69 64 20 3d 20 42  AND    F.fid = B
ba10: 2e 66 69 64 20 20 20 20 2d 2d 20 47 65 74 20 66  .fid    -- Get f
ba20: 69 6c 65 20 6f 66 20 62 72 61 6e 63 68 0a 09 20  ile of branch.. 
ba30: 20 20 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20     AND    P.pid 
ba40: 3d 20 46 2e 70 69 64 20 20 20 20 2d 2d 20 47 65  = F.pid    -- Ge
ba50: 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 66 69 6c  t project of fil
ba60: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 53 2e  e..    AND    S.
ba70: 73 69 64 20 3d 20 42 2e 73 69 64 20 20 20 20 2d  sid = B.sid    -
ba80: 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20  - Get symbol of 
ba90: 62 72 61 6e 63 68 0a 09 7d 5d 20 73 6e 61 6d 65  branch..}] sname
baa0: 20 66 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65   fname pname..re
bab0: 74 75 72 6e 20 22 24 70 6e 61 6d 65 2f 42 27 24  turn "$pname/B'$
bac0: 7b 73 6e 61 6d 65 7d 27 3a 3a 24 66 6e 61 6d 65  {sname}'::$fname
bad0: 22 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72  ".    }..    # r
bae0: 65 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69  esult = list (mi
baf0: 6e 74 69 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a  ntime, maxtime).
bb00: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 74      typemethod t
bb10: 69 6d 65 72 61 6e 67 65 20 7b 62 72 61 6e 63 68  imerange {branch
bb20: 65 73 7d 20 7b 0a 09 23 20 54 68 65 20 72 61 6e  es} {..# The ran
bb30: 67 65 20 6f 66 20 61 20 62 72 61 6e 63 68 20 69  ge of a branch i
bb40: 73 20 64 65 66 69 6e 65 64 20 61 73 20 74 68 65  s defined as the
bb50: 20 72 61 6e 67 65 20 6f 66 20 74 68 65 0a 09 23   range of the..#
bb60: 20 72 65 76 69 73 69 6f 6e 73 20 74 68 65 20 62   revisions the b
bb70: 72 61 6e 63 68 65 73 20 61 72 65 20 73 70 61 77  ranches are spaw
bb80: 6e 65 64 20 62 79 2e 20 4e 4f 54 45 20 68 6f 77  ned by. NOTE how
bb90: 65 76 65 72 20 74 68 61 74 20 74 68 65 0a 09 23  ever that the..#
bba0: 20 62 72 61 6e 63 68 65 73 20 61 73 73 6f 63 69   branches associ
bbb0: 61 74 65 64 20 77 69 74 68 20 61 20 64 65 74 61  ated with a deta
bbc0: 63 68 65 64 20 4e 54 44 42 20 77 69 6c 6c 20 68  ched NTDB will h
bbd0: 61 76 65 20 6e 6f 20 72 6f 6f 74 0a 09 23 20 73  ave no root..# s
bbe0: 70 61 77 6e 69 6e 67 20 74 68 65 6d 2c 20 68 65  pawning them, he
bbf0: 6e 63 65 20 74 68 65 79 20 68 61 76 65 20 6e 6f  nce they have no
bc00: 20 72 65 61 6c 20 74 69 6d 65 72 61 6e 67 65 20   real timerange 
bc10: 61 6e 79 0a 09 23 20 6c 6f 6e 67 65 72 2e 20 42  any..# longer. B
bc20: 79 20 75 73 69 6e 67 20 30 20 77 65 20 70 75 74  y using 0 we put
bc30: 20 74 68 65 6d 20 69 6e 20 66 72 6f 6e 74 20 6f   them in front o
bc40: 66 20 65 76 65 72 79 74 68 69 6e 67 20 65 6c 73  f everything els
bc50: 65 2c 0a 09 23 20 61 73 20 74 68 65 79 20 6c 6f  e,..# as they lo
bc60: 67 69 63 61 6c 6c 79 20 61 72 65 2e 0a 0a 09 73  gically are....s
bc70: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
bc80: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27  n $branches {','
bc90: 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74  }]')..return [st
bca0: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
bcb0: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
bcc0: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
bcd0: 20 53 45 4c 45 43 54 20 49 46 4e 55 4c 4c 28 4d   SELECT IFNULL(M
bce0: 49 4e 28 52 2e 64 61 74 65 29 2c 30 29 2c 20 49  IN(R.date),0), I
bcf0: 46 4e 55 4c 4c 28 4d 41 58 28 52 2e 64 61 74 65  FNULL(MAX(R.date
bd00: 29 2c 30 29 0a 09 20 20 20 20 46 52 4f 4d 20 20  ),0)..    FROM  
bd10: 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69  branch B, revisi
bd20: 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20  on R..    WHERE 
bd30: 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74  B.bid IN $theset
bd40: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
bd50: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e  o branches of in
bd60: 74 65 72 65 73 74 0a 20 20 20 20 20 20 20 20 20  terest.         
bd70: 20 20 20 41 4e 44 20 20 20 52 2e 72 69 64 20 3d     AND   R.rid =
bd80: 20 42 2e 72 6f 6f 74 20 20 20 20 20 2d 2d 20 53   B.root     -- S
bd90: 65 6c 65 63 74 20 62 72 61 6e 63 68 20 70 61 72  elect branch par
bda0: 65 6e 74 20 72 65 76 69 73 69 6f 6e 73 0a 09 7d  ent revisions..}
bdb0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  ]].    }..    # 
bdc0: 72 65 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20  result = 4-list 
bdd0: 28 69 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64  (itemtype itemid
bde0: 20 6e 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65   nextitemtype ne
bdf0: 78 74 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20  xtitemid ...).  
be00: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f    typemethod loo
be10: 70 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a  ps {branches} {.
be20: 09 23 20 4e 6f 74 65 3a 20 52 65 76 69 73 69 6f  .# Note: Revisio
be30: 6e 73 20 61 6e 64 20 74 61 67 73 20 63 61 6e 6e  ns and tags cann
be40: 6f 74 20 63 61 75 73 65 20 74 68 65 20 6c 6f 6f  ot cause the loo
be50: 70 2e 20 42 65 69 6e 67 20 6f 66 20 61 0a 09 23  p. Being of a..#
be60: 20 66 75 6e 64 61 6d 65 6e 74 61 6c 6c 79 20 64   fundamentally d
be70: 69 66 66 65 72 65 6e 74 20 74 79 70 65 20 74 68  ifferent type th
be80: 65 79 20 63 61 6e 6e 6f 74 20 62 65 20 69 6e 20  ey cannot be in 
be90: 74 68 65 20 69 6e 63 6f 6d 69 6e 67 0a 09 23 20  the incoming..# 
bea0: 73 65 74 20 6f 66 20 69 64 73 2e 0a 0a 09 73 65  set of ids....se
beb0: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
bec0: 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d   $branches {','}
bed0: 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61  ]')..return [sta
bee0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
bef0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
bf00: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
bf10: 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 58  SELECT B.bid, BX
bf20: 2e 62 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  .bid..    FROM  
bf30: 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65   branch B, prefe
bf40: 72 65 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61  redparent P, bra
bf50: 6e 63 68 20 42 58 0a 09 20 20 20 20 57 48 45 52  nch BX..    WHER
bf60: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65  E  B.bid IN $the
bf70: 73 65 74 20 20 20 2d 2d 20 52 65 73 74 72 69 63  set   -- Restric
bf80: 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66  t to branches of
bf90: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41   interest..    A
bfa0: 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e  ND    B.sid = P.
bfb0: 70 69 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20  pid      -- Get 
bfc0: 74 68 65 20 70 72 65 66 65 72 65 64 20 62 72 61  the prefered bra
bfd0: 6e 63 68 65 73 20 76 69 61 0a 09 20 20 20 20 41  nches via..    A
bfe0: 4e 44 20 20 20 20 42 58 2e 73 69 64 20 3d 20 50  ND    BX.sid = P
bff0: 2e 73 69 64 20 20 20 20 20 2d 2d 20 74 68 65 20  .sid     -- the 
c000: 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 73 0a 09  branch symbols..
c010: 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e 62 69      AND    BX.bi
c020: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d  d IN $theset  --
c030: 20 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20 20 20 7d   Loop..}]].    }
c040: 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 29 20  ..    # var(dv) 
c050: 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d 3e 20  = dict (item -> 
c060: 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20 69 74  list (item)), it
c070: 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79 70 65  em  = list (type
c080: 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74   id).    typemet
c090: 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73 20 7b  hod successors {
c0a0: 64 76 20 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09  dv branches} {..
c0b0: 75 70 76 61 72 20 31 20 24 64 76 20 64 65 70 65  upvar 1 $dv depe
c0c0: 6e 64 65 6e 63 69 65 73 0a 09 23 20 54 68 65 20  ndencies..# The 
c0d0: 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 63  first revision c
c0e0: 6f 6d 6d 69 74 74 65 64 20 6f 6e 20 61 20 62 72  ommitted on a br
c0f0: 61 6e 63 68 2c 20 61 6e 64 20 61 6c 6c 20 62 72  anch, and all br
c100: 61 6e 63 68 65 73 0a 09 23 20 61 6e 64 20 74 61  anches..# and ta
c110: 67 73 20 77 68 69 63 68 20 68 61 76 65 20 69 74  gs which have it
c120: 20 61 73 20 74 68 65 69 72 20 70 72 65 66 65 72   as their prefer
c130: 65 64 20 70 61 72 65 6e 74 20 61 72 65 20 74 68  ed parent are th
c140: 65 0a 09 23 20 73 75 63 63 65 73 73 6f 72 73 20  e..# successors 
c150: 6f 66 20 61 20 62 72 61 6e 63 68 2e 0a 0a 09 73  of a branch....s
c160: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
c170: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27  n $branches {','
c180: 7d 5d 27 29 0a 09 66 6f 72 65 61 63 68 20 7b 62  }]')..foreach {b
c190: 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65  id child} [state
c1a0: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63   run [subst -noc
c1b0: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73  ommands -nobacks
c1c0: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45  lashes {..    SE
c1d0: 4c 45 43 54 20 42 2e 62 69 64 2c 20 52 2e 72 69  LECT B.bid, R.ri
c1e0: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72  d..    FROM   br
c1f0: 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e  anch B, revision
c200: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 42   R..    WHERE  B
c210: 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .bid IN $theset 
c220: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
c230: 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69  to branches of i
c240: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
c250: 20 20 20 20 42 2e 66 69 72 73 74 20 3d 20 52 2e      B.first = R.
c260: 72 69 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20  rid      -- Get 
c270: 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 6f  first revision o
c280: 6e 20 74 68 65 20 62 72 61 6e 63 68 0a 09 7d 5d  n the branch..}]
c290: 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64  ] {..    lappend
c2a0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c   dependencies([l
c2b0: 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20  ist sym::branch 
c2c0: 24 62 69 64 5d 29 20 5b 6c 69 73 74 20 72 65 76  $bid]) [list rev
c2d0: 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72   $child]..}..for
c2e0: 65 61 63 68 20 7b 62 69 64 20 63 68 69 6c 64 7d  each {bid child}
c2f0: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62   [state run [sub
c300: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d  st -nocommands -
c310: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a  nobackslashes {.
c320: 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69  .    SELECT B.bi
c330: 64 2c 20 42 58 2e 62 69 64 0a 09 20 20 20 20 46  d, BX.bid..    F
c340: 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20  ROM   branch B, 
c350: 70 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 50  preferedparent P
c360: 2c 20 62 72 61 6e 63 68 20 42 58 0a 09 20 20 20  , branch BX..   
c370: 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e   WHERE  B.bid IN
c380: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
c390: 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e  Restrict to bran
c3a0: 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ches of interest
c3b0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 73  ..    AND    B.s
c3c0: 69 64 20 3d 20 50 2e 70 69 64 20 20 20 20 20 20  id = P.pid      
c3d0: 20 20 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 69    -- Get subordi
c3e0: 6e 61 74 65 20 62 72 61 6e 63 68 65 73 20 76 69  nate branches vi
c3f0: 61 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20  a the..    AND  
c400: 20 20 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 64    BX.sid = P.sid
c410: 20 20 20 20 20 20 20 2d 2d 20 70 72 65 66 65 72         -- prefer
c420: 65 64 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68  ed parents of th
c430: 65 69 72 20 73 79 6d 62 6f 6c 73 0a 09 7d 5d 5d  eir symbols..}]]
c440: 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20   {..    lappend 
c450: 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69  dependencies([li
c460: 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24  st sym::branch $
c470: 62 69 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d 3a  bid]) [list sym:
c480: 3a 62 72 61 6e 63 68 20 24 63 68 69 6c 64 5d 0a  :branch $child].
c490: 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b 62 69 64  .}..foreach {bid
c4a0: 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72   child} [state r
c4b0: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d  un [subst -nocom
c4c0: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61  mands -nobacksla
c4d0: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45  shes {..    SELE
c4e0: 43 54 20 42 2e 62 69 64 2c 20 54 2e 74 69 64 0a  CT B.bid, T.tid.
c4f0: 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e  .    FROM   bran
c500: 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 70 61  ch B, preferedpa
c510: 72 65 6e 74 20 50 2c 20 74 61 67 20 54 0a 09 20  rent P, tag T.. 
c520: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20     WHERE  B.bid 
c530: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
c540: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72  - Restrict to br
c550: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65  anches of intere
c560: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  st..    AND    B
c570: 2e 73 69 64 20 3d 20 50 2e 70 69 64 20 20 20 20  .sid = P.pid    
c580: 20 20 20 20 2d 2d 20 47 65 74 20 73 75 62 6f 72      -- Get subor
c590: 64 69 6e 61 74 65 20 74 61 67 73 20 76 69 61 20  dinate tags via 
c5a0: 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20  the..    AND    
c5b0: 54 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20  T.sid = P.sid   
c5c0: 20 20 20 20 20 2d 2d 20 70 72 65 66 65 72 65 64       -- prefered
c5d0: 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68 65 69   parents of thei
c5e0: 72 20 73 79 6d 62 6f 6c 73 0a 09 7d 5d 5d 20 7b  r symbols..}]] {
c5f0: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65  ..    lappend de
c600: 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74  pendencies([list
c610: 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 62 69   sym::branch $bi
c620: 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d 3a 3a 74  d]) [list sym::t
c630: 61 67 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 72  ag $child]..}..r
c640: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
c650: 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74   # result = list
c660: 20 28 63 68 61 6e 67 65 73 65 74 2d 69 64 29 0a   (changeset-id).
c670: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63      typemethod c
c680: 73 5f 73 75 63 63 65 73 73 6f 72 73 20 7b 62 72  s_successors {br
c690: 61 6e 63 68 65 73 7d 20 7b 0a 20 20 20 20 20 20  anches} {.      
c6a0: 20 20 23 20 54 68 69 73 20 69 73 20 61 20 76 61    # This is a va
c6b0: 72 69 61 6e 74 20 6f 66 20 27 73 75 63 63 65 73  riant of 'succes
c6c0: 73 6f 72 73 27 20 77 68 69 63 68 20 6d 61 70 73  sors' which maps
c6d0: 20 74 68 65 20 6c 6f 77 2d 6c 65 76 65 6c 0a 20   the low-level. 
c6e0: 20 20 20 20 20 20 20 23 20 64 61 74 61 20 64 69         # data di
c6f0: 72 65 63 74 6c 79 20 74 6f 20 74 68 65 20 61 73  rectly to the as
c700: 73 6f 63 69 61 74 65 64 20 63 68 61 6e 67 65 73  sociated changes
c710: 65 74 73 2e 20 49 2e 65 2e 20 69 6e 73 74 65 61  ets. I.e. instea
c720: 64 0a 20 20 20 20 20 20 20 20 23 20 6d 69 6c 6c  d.        # mill
c730: 69 6f 6e 73 20 6f 66 20 64 65 70 65 6e 64 65 6e  ions of dependen
c740: 63 79 20 70 61 69 72 73 20 28 69 6e 20 65 78 74  cy pairs (in ext
c750: 72 65 6d 65 20 63 61 73 65 73 20 28 45 78 61 6d  reme cases (Exam
c760: 70 6c 65 3a 20 54 63 6c 0a 20 20 20 20 20 20 20  ple: Tcl.       
c770: 20 23 20 43 56 53 29 29 20 77 65 20 72 65 74 75   # CVS)) we retu
c780: 72 6e 20 61 20 76 65 72 79 20 73 68 6f 72 74 20  rn a very short 
c790: 61 6e 64 20 6d 75 63 68 20 6d 6f 72 65 20 6d 61  and much more ma
c7a0: 6e 61 67 65 61 62 6c 65 20 6c 69 73 74 0a 20 20  nageable list.  
c7b0: 20 20 20 20 20 20 23 20 6f 66 20 63 68 61 6e 67        # of chang
c7c0: 65 73 65 74 73 2e 0a 0a 09 73 65 74 20 74 68 65  esets....set the
c7d0: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61  set ('[join $bra
c7e0: 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 20  nches {','}]'). 
c7f0: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 5b 73         return [s
c800: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
c810: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
c820: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
c830: 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09    SELECT C.cid..
c840: 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63      FROM   branc
c850: 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c  h B, revision R,
c860: 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e   csitem CI, chan
c870: 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45  geset C..    WHE
c880: 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68  RE  B.bid IN $th
c890: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74  eset     -- Rest
c8a0: 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73  rict to branches
c8b0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
c8c0: 20 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74    AND    B.first
c8d0: 20 3d 20 52 2e 72 69 64 09 2d 2d 20 47 65 74 20   = R.rid.-- Get 
c8e0: 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 6f  first revision o
c8f0: 6e 20 74 68 65 20 62 72 61 6e 63 68 0a 20 20 20  n the branch.   
c900: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
c910: 43 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 20 20  CI.iid = R.rid  
c920: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61       -- Select a
c930: 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20  ll changesets.  
c940: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
c950: 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09   C.cid = CI.cid.
c960: 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68  -- containing th
c970: 69 73 20 72 65 76 69 73 69 6f 6e 0a 20 20 20 20  is revision.    
c980: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
c990: 2e 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 77 68  .type = 0..-- wh
c9a0: 69 63 68 20 61 72 65 20 72 65 76 69 73 69 6f 6e  ich are revision
c9b0: 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20   changesets.    
c9c0: 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43  UNION..    SELEC
c9d0: 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f  T C.cid..    FRO
c9e0: 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70 72  M   branch B, pr
c9f0: 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20  eferedparent P, 
ca00: 62 72 61 6e 63 68 20 42 58 2c 20 63 73 69 74 65  branch BX, csite
ca10: 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20  m CI, changeset 
ca20: 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e  C..    WHERE  B.
ca30: 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  bid IN $theset  
ca40: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
ca50: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e  o branches of in
ca60: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
ca70: 20 20 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 64     B.sid = P.pid
ca80: 09 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 69 6e  .-- Get subordin
ca90: 61 74 65 20 62 72 61 6e 63 68 65 73 20 76 69 61  ate branches via
caa0: 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20   the..    AND   
cab0: 20 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 64 09   BX.sid = P.sid.
cac0: 2d 2d 20 70 72 65 66 65 72 65 64 20 70 61 72 65  -- prefered pare
cad0: 6e 74 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d  nts of their sym
cae0: 62 6f 6c 73 0a 20 20 20 20 20 20 20 20 20 20 20  bols.           
caf0: 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d   AND    CI.iid =
cb00: 20 42 58 2e 62 69 64 20 20 20 20 20 20 2d 2d 20   BX.bid      -- 
cb10: 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67  Select all chang
cb20: 65 73 65 74 73 0a 20 20 20 20 20 20 20 20 20 20  esets.          
cb30: 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d    AND    C.cid =
cb40: 20 43 49 2e 63 69 64 09 2d 2d 20 63 6f 6e 74 61   CI.cid.-- conta
cb50: 69 6e 69 6e 67 20 74 68 65 20 73 75 62 6f 72 64  ining the subord
cb60: 69 6e 61 74 65 20 62 72 61 6e 63 68 65 73 0a 20  inate branches. 
cb70: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
cb80: 20 20 43 2e 74 79 70 65 20 3d 20 32 09 09 2d 2d    C.type = 2..--
cb90: 20 77 68 69 63 68 20 61 72 65 20 62 72 61 6e 63   which are branc
cba0: 68 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20  h changesets.   
cbb0: 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45   UNION..    SELE
cbc0: 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52  CT C.cid..    FR
cbd0: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70  OM   branch B, p
cbe0: 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c  referedparent P,
cbf0: 20 74 61 67 20 54 2c 20 63 73 69 74 65 6d 20 43   tag T, csitem C
cc00: 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09  I, changeset C..
cc10: 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64      WHERE  B.bid
cc20: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
cc30: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62  -- Restrict to b
cc40: 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72  ranches of inter
cc50: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  est..    AND    
cc60: 42 2e 73 69 64 20 3d 20 50 2e 70 69 64 09 2d 2d  B.sid = P.pid.--
cc70: 20 47 65 74 20 73 75 62 6f 72 64 69 6e 61 74 65   Get subordinate
cc80: 20 74 61 67 73 20 76 69 61 20 74 68 65 0a 09 20   tags via the.. 
cc90: 20 20 20 41 4e 44 20 20 20 20 54 2e 73 69 64 20     AND    T.sid 
cca0: 3d 20 50 2e 73 69 64 09 2d 2d 20 70 72 65 66 65  = P.sid.-- prefe
ccb0: 72 65 64 20 70 61 72 65 6e 74 73 20 6f 66 20 74  red parents of t
ccc0: 68 65 69 72 20 73 79 6d 62 6f 6c 73 0a 20 20 20  heir symbols.   
ccd0: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
cce0: 43 49 2e 69 69 64 20 3d 20 54 2e 74 69 64 20 20  CI.iid = T.tid  
ccf0: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61       -- Select a
cd00: 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20  ll changesets.  
cd10: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
cd20: 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09   C.cid = CI.cid.
cd30: 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68  -- containing th
cd40: 65 20 73 75 62 6f 72 64 69 6e 61 74 65 20 74 61  e subordinate ta
cd50: 67 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41  gs.            A
cd60: 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 31  ND    C.type = 1
cd70: 09 09 2d 2d 20 77 68 69 63 68 20 61 72 65 20 74  ..-- which are t
cd80: 61 67 20 63 68 61 6e 67 65 73 65 74 73 0a 09 7d  ag changesets..}
cd90: 5d 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  ]]..return.    }
cda0: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d  ..    # result =
cdb0: 20 73 79 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20 20   symbol name.   
cdc0: 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f 6c   typemethod cs_l
cdd0: 6f 64 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a  od {branches} {.
cde0: 09 23 20 44 65 74 65 72 6d 69 6e 65 73 20 74 68  .# Determines th
cdf0: 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 79  e name of the sy
ce00: 6d 62 6f 6c 20 77 68 69 63 68 20 69 73 20 74 68  mbol which is th
ce10: 65 20 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76  e line of..# dev
ce20: 65 6c 6f 70 6d 65 6e 74 20 66 6f 72 20 74 68 65  elopment for the
ce30: 20 62 72 61 6e 63 68 65 73 20 69 6e 20 61 20 63   branches in a c
ce40: 68 61 6e 67 65 73 65 74 2e 0a 0a 09 73 65 74 20  hangeset....set 
ce50: 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24  theset ('[join $
ce60: 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27  branches {','}]'
ce70: 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65  )..return [state
ce80: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63   run [subst -noc
ce90: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73  ommands -nobacks
cea0: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45  lashes {..    SE
ceb0: 4c 45 43 54 0a 09 20 20 20 20 44 49 53 54 49 4e  LECT..    DISTIN
cec0: 43 54 20 4c 2e 6e 61 6d 65 0a 09 20 20 20 20 46  CT L.name..    F
ced0: 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20  ROM   branch B, 
cee0: 73 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20 57 48  symbol L..    WH
cef0: 45 52 45 20 20 42 2e 62 69 64 20 69 6e 20 24 74  ERE  B.bid in $t
cf00: 68 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d 20  heset        -- 
cf10: 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e  Restrict to bran
cf20: 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ches of interest
cf30: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 4c 2e 73  ..    AND    L.s
cf40: 69 64 20 3d 20 42 2e 6c 6f 64 20 20 20 20 20 20  id = B.lod      
cf50: 20 20 20 20 20 2d 2d 20 47 65 74 20 6c 6f 64 20       -- Get lod 
cf60: 73 79 6d 62 6f 6c 20 6f 66 20 62 72 61 6e 63 68  symbol of branch
cf70: 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20  ..}]].    }..   
cf80: 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 69 6d 69   typemethod limi
cf90: 74 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a  ts {branches} {.
cfa0: 09 23 20 4e 6f 74 65 73 2e 20 54 68 69 73 20 6d  .# Notes. This m
cfb0: 65 74 68 6f 64 20 65 78 69 73 74 73 20 6f 6e 6c  ethod exists onl
cfc0: 79 20 66 6f 72 20 62 72 61 6e 63 68 65 73 2e 20  y for branches. 
cfd0: 49 74 20 69 73 20 6e 65 65 64 65 64 20 74 6f 0a  It is needed to.
cfe0: 09 23 20 67 65 74 20 64 65 74 61 69 6c 65 64 20  .# get detailed 
cff0: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75  information abou
d000: 74 20 61 20 62 61 63 6b 77 61 72 64 20 62 72 61  t a backward bra
d010: 6e 63 68 2e 20 49 74 20 64 6f 65 73 0a 09 23 20  nch. It does..# 
d020: 6e 6f 74 20 61 70 70 6c 79 20 74 6f 20 74 61 67  not apply to tag
d030: 73 2c 20 6e 6f 72 20 72 65 76 69 73 69 6f 6e 73  s, nor revisions
d040: 2e 20 54 68 65 20 71 75 65 72 69 65 73 20 63 61  . The queries ca
d050: 6e 20 61 6c 73 6f 0a 09 23 20 72 65 73 74 72 69  n also..# restri
d060: 63 74 20 74 68 65 6d 73 65 6c 76 65 73 20 74 6f  ct themselves to
d070: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 73 75   the revision su
d080: 63 65 73 73 6f 72 73 2f 70 72 65 64 65 63 65 73  cessors/predeces
d090: 73 6f 72 73 0a 09 23 20 6f 66 20 62 72 61 6e 63  sors..# of branc
d0a0: 68 65 73 2c 20 61 73 20 6f 6e 6c 79 20 74 68 65  hes, as only the
d0b0: 79 20 68 61 76 65 20 6f 72 64 65 72 69 6e 67 20  y have ordering 
d0c0: 64 61 74 61 20 61 6e 64 20 74 68 75 73 20 63 61  data and thus ca
d0d0: 6e 0a 09 23 20 63 61 75 73 65 20 74 68 65 20 62  n..# cause the b
d0e0: 61 63 6b 77 61 72 64 6e 65 73 73 2e 0a 0a 09 73  ackwardness....s
d0f0: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
d100: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27  n $branches {','
d110: 7d 5d 27 29 0a 0a 09 73 65 74 20 6d 61 78 70 20  }]')...set maxp 
d120: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
d130: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
d140: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09  obackslashes {..
d150: 20 20 20 20 2d 2d 20 6d 61 78 69 6d 61 6c 20 70      -- maximal p
d160: 72 65 64 65 63 65 73 73 6f 72 20 70 6f 73 69 74  redecessor posit
d170: 69 6f 6e 20 70 65 72 20 62 72 61 6e 63 68 0a 09  ion per branch..
d180: 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64      SELECT B.bid
d190: 2c 20 4d 41 58 20 28 43 4f 2e 70 6f 73 29 0a 09  , MAX (CO.pos)..
d1a0: 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63      FROM   branc
d1b0: 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c  h B, revision R,
d1c0: 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e   csitem CI, chan
d1d0: 67 65 73 65 74 20 43 2c 20 63 73 6f 72 64 65 72  geset C, csorder
d1e0: 20 43 4f 0a 09 20 20 20 20 57 48 45 52 45 20 20   CO..    WHERE  
d1f0: 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74  B.bid IN $theset
d200: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
d210: 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20   to branches of 
d220: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e  interest..    AN
d230: 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e  D    B.root = R.
d240: 72 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74  rid       -- Get
d250: 20 62 72 61 6e 63 68 20 72 6f 6f 74 20 72 65 76   branch root rev
d260: 69 73 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20  isions..    AND 
d270: 20 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 72 69     CI.iid = R.ri
d280: 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 63  d       -- Get c
d290: 68 61 6e 67 65 73 65 74 73 20 63 6f 6e 74 61 69  hangesets contai
d2a0: 6e 69 6e 67 20 74 68 65 0a 09 20 20 20 20 41 4e  ning the..    AN
d2b0: 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e  D    C.cid = CI.
d2c0: 63 69 64 20 20 20 20 20 20 20 2d 2d 20 72 6f 6f  cid       -- roo
d2d0: 74 20 72 65 76 69 73 69 6f 6e 73 2c 20 77 68 69  t revisions, whi
d2e0: 63 68 20 61 72 65 0a 09 20 20 20 20 41 4e 44 20  ch are..    AND 
d2f0: 20 20 20 43 2e 74 79 70 65 20 3d 20 30 20 20 20     C.type = 0   
d300: 20 20 20 20 20 20 20 20 2d 2d 20 72 65 76 69 73          -- revis
d310: 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 09  ion changesets..
d320: 20 20 20 20 41 4e 44 20 20 20 20 43 4f 2e 63 69      AND    CO.ci
d330: 64 20 3d 20 43 2e 63 69 64 20 20 20 20 20 20 20  d = C.cid       
d340: 2d 2d 20 47 65 74 20 74 68 65 69 72 20 74 6f 70  -- Get their top
d350: 6f 6c 6f 67 69 63 61 6c 20 6f 72 64 65 72 69 6e  ological orderin
d360: 67 0a 09 20 20 20 20 47 52 4f 55 50 20 42 59 20  g..    GROUP BY 
d370: 42 2e 62 69 64 0a 09 7d 5d 5d 0a 0a 09 73 65 74  B.bid..}]]...set
d380: 20 6d 69 6e 73 20 5b 73 74 61 74 65 20 72 75 6e   mins [state run
d390: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
d3a0: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
d3b0: 65 73 20 7b 0a 09 20 20 20 20 2d 2d 20 6d 69 6e  es {..    -- min
d3c0: 69 6d 61 6c 20 73 75 63 63 65 73 73 6f 72 20 70  imal successor p
d3d0: 6f 73 69 74 69 6f 6e 20 70 65 72 20 62 72 61 6e  osition per bran
d3e0: 63 68 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42  ch..    SELECT B
d3f0: 2e 62 69 64 2c 20 4d 49 4e 20 28 43 4f 2e 70 6f  .bid, MIN (CO.po
d400: 73 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62  s)..    FROM   b
d410: 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f  ranch B, revisio
d420: 6e 20 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20  n R, csitem CI, 
d430: 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 6f  changeset C, cso
d440: 72 64 65 72 20 43 4f 0a 09 20 20 20 20 57 48 45  rder CO..    WHE
d450: 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68  RE  B.bid IN $th
d460: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74  eset     -- Rest
d470: 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73  rict to branches
d480: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
d490: 20 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74    AND    B.first
d4a0: 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 2d 2d   = R.rid      --
d4b0: 20 47 65 74 20 74 68 65 20 66 69 72 73 74 20 72   Get the first r
d4c0: 65 76 69 73 69 6f 6e 73 20 6f 6e 20 74 68 65 20  evisions on the 
d4d0: 62 72 61 6e 63 68 65 73 0a 09 20 20 20 20 41 4e  branches..    AN
d4e0: 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20 52 2e  D    CI.iid = R.
d4f0: 72 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74  rid       -- Get
d500: 20 63 68 61 6e 67 65 73 65 74 73 20 63 6f 6e 74   changesets cont
d510: 61 69 6e 69 6e 67 20 74 68 65 0a 09 20 20 20 20  aining the..    
d520: 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43  AND    C.cid = C
d530: 49 2e 63 69 64 09 2d 2d 20 66 69 72 73 74 20 72  I.cid.-- first r
d540: 65 76 69 73 69 6f 6e 73 2c 20 77 68 69 63 68 20  evisions, which 
d550: 61 72 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20  are..    AND    
d560: 43 2e 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 72  C.type = 0..-- r
d570: 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65  evision changese
d580: 74 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43  ts..    AND    C
d590: 4f 2e 63 69 64 20 3d 20 43 2e 63 69 64 09 2d 2d  O.cid = C.cid.--
d5a0: 20 47 65 74 20 74 68 65 69 72 20 74 6f 70 6f 6c   Get their topol
d5b0: 6f 67 69 63 61 6c 20 6f 72 64 65 72 69 6e 67 0a  ogical ordering.
d5c0: 09 20 20 20 20 47 52 4f 55 50 20 42 59 20 42 2e  .    GROUP BY B.
d5d0: 62 69 64 0a 09 7d 5d 5d 0a 0a 20 20 20 20 20 20  bid..}]]..      
d5e0: 20 20 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24    return [list $
d5f0: 6d 61 78 70 20 24 6d 69 6e 73 5d 0a 20 20 20 20  maxp $mins].    
d600: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23  }..    # # ## ##
d610: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
d620: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
d630: 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74     ## Configurat
d640: 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20  ion..    pragma 
d650: 2d 68 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20  -hasinstances   
d660: 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e  no ; # singleton
d670: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73  .    pragma -has
d680: 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b  typeinfo    no ;
d690: 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74   # no introspect
d6a0: 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d  ion.    pragma -
d6b0: 68 61 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e  hastypedestroy n
d6c0: 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 7d  o ; # immortal.}
d6d0: 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
d6e0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
d6f0: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23  ######### ######
d700: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
d710: 23 23 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76  ##..namespace ev
d720: 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  al ::vc::fossil:
d730: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72  :import::cvs::pr
d740: 6f 6a 65 63 74 20 7b 0a 20 20 20 20 6e 61 6d 65  oject {.    name
d750: 73 70 61 63 65 20 65 78 70 6f 72 74 20 72 65 76  space export rev
d760: 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65  .    namespace e
d770: 76 61 6c 20 72 65 76 20 7b 0a 09 6e 61 6d 65 73  val rev {..names
d780: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
d790: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
d7a0: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61  ::cvs::state..na
d7b0: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
d7c0: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
d7d0: 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72  ort::cvs::integr
d7e0: 69 74 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ity..namespace i
d7f0: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c  mport ::vc::tool
d800: 73 3a 3a 6d 69 73 63 3a 3a 2a 0a 09 6e 61 6d 65  s::misc::*..name
d810: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
d820: 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c  c::tools::troubl
d830: 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70  e..namespace imp
d840: 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a  ort ::vc::tools:
d850: 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74  :log..log regist
d860: 65 72 20 63 73 65 74 73 0a 0a 09 23 20 53 65 74  er csets...# Set
d870: 20 75 70 20 74 68 65 20 68 65 6c 70 65 72 20 73   up the helper s
d880: 69 6e 67 6c 65 74 6f 6e 73 0a 09 6e 61 6d 65 73  ingletons..names
d890: 70 61 63 65 20 65 76 61 6c 20 72 65 76 20 7b 0a  pace eval rev {.
d8a0: 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69  .    namespace i
d8b0: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73  mport ::vc::foss
d8c0: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
d8d0: 3a 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65  :state..    name
d8e0: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
d8f0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
d900: 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74  t::cvs::integrit
d910: 79 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65  y..    namespace
d920: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f   import ::vc::to
d930: 6f 6c 73 3a 3a 6c 6f 67 0a 09 7d 0a 09 6e 61 6d  ols::log..}..nam
d940: 65 73 70 61 63 65 20 65 76 61 6c 20 73 79 6d 3a  espace eval sym:
d950: 3a 74 61 67 20 7b 0a 09 20 20 20 20 6e 61 6d 65  :tag {..    name
d960: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
d970: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
d980: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 20  t::cvs::state.. 
d990: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70     namespace imp
d9a0: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
d9b0: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69  ::import::cvs::i
d9c0: 6e 74 65 67 72 69 74 79 0a 09 20 20 20 20 6e 61  ntegrity..    na
d9d0: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
d9e0: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a  :vc::tools::log.
d9f0: 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76  .}..namespace ev
da00: 61 6c 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b  al sym::branch {
da10: 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20  ..    namespace 
da20: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73  import ::vc::fos
da30: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
da40: 3a 3a 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d  ::state..    nam
da50: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
da60: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
da70: 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69  rt::cvs::integri
da80: 74 79 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63  ty..    namespac
da90: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74  e import ::vc::t
daa0: 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 7d 0a 20 20 20  ools::log..}.   
dab0: 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23   }.}..# # ## ###
dac0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
dad0: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23  ############# ##
dae0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
daf0: 23 23 23 0a 23 23 20 52 65 61 64 79 0a 0a 70 61  ###.## Ready..pa
db00: 63 6b 61 67 65 20 70 72 6f 76 69 64 65 20 76 63  ckage provide vc
db10: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
db20: 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a  ::cvs::project::
db30: 72 65 76 20 31 2e 30 0a 72 65 74 75 72 6e 0a     rev 1.0.return.