Hex Artifact Content
Not logged in

Artifact 301208ccefc1e6e7c2d43bd3665afa9496735936:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [e8efbc317a] - Reworked the code determining the parent of the currently committed changeset. It should now handle the transition from vendor branch to trunk correctly. by aku on 2008-02-01 05:25:03.

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 20 41 6e 64 72 65 61 73 20 4b 75 70 72 69  07 Andreas Kupri
0070: 65 73 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66  es..#.# This sof
0080: 74 77 61 72 65 20 69 73 20 6c 69 63 65 6e 73 65  tware is license
0090: 64 20 61 73 20 64 65 73 63 72 69 62 65 64 20 69  d as described i
00a0: 6e 20 74 68 65 20 66 69 6c 65 20 4c 49 43 45 4e  n the file LICEN
00b0: 53 45 2c 20 77 68 69 63 68 0a 23 20 79 6f 75 20  SE, which.# you 
00c0: 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65  should have rece
00d0: 69 76 65 64 20 61 73 20 70 61 72 74 20 6f 66 20  ived as part of 
00e0: 74 68 69 73 20 64 69 73 74 72 69 62 75 74 69 6f  this distributio
00f0: 6e 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 74  n..#.# This soft
0100: 77 61 72 65 20 63 6f 6e 73 69 73 74 73 20 6f 66  ware consists of
0110: 20 76 6f 6c 75 6e 74 61 72 79 20 63 6f 6e 74 72   voluntary contr
0120: 69 62 75 74 69 6f 6e 73 20 6d 61 64 65 20 62 79  ibutions made by
0130: 20 6d 61 6e 79 0a 23 20 69 6e 64 69 76 69 64 75   many.# individu
0140: 61 6c 73 2e 20 20 46 6f 72 20 65 78 61 63 74 20  als.  For exact 
0150: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 20 68 69 73  contribution his
0160: 74 6f 72 79 2c 20 73 65 65 20 74 68 65 20 72 65  tory, see the re
0170: 76 69 73 69 6f 6e 0a 23 20 68 69 73 74 6f 72 79  vision.# history
0180: 20 61 6e 64 20 6c 6f 67 73 2c 20 61 76 61 69 6c   and logs, avail
0190: 61 62 6c 65 20 61 74 20 68 74 74 70 3a 2f 2f 66  able at http://f
01a0: 6f 73 73 69 6c 2d 73 63 6d 2e 68 77 61 63 69 2e  ossil-scm.hwaci.
01b0: 63 6f 6d 2f 66 6f 73 73 69 6c 0a 23 20 23 20 23  com/fossil.# # #
01c0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
01d0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
01e0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
01f0: 23 23 23 23 23 23 23 23 0a 0a 23 23 20 52 65 76  ########..## Rev
0200: 69 73 69 6f 6e 73 20 70 65 72 20 70 72 6f 6a 65  isions per proje
0210: 63 74 2c 20 61 6b 61 20 43 68 61 6e 67 65 73 65  ct, aka Changese
0220: 74 73 2e 20 54 68 65 73 65 20 6f 62 6a 65 63 74  ts. These object
0230: 73 20 61 72 65 20 66 69 72 73 74 20 75 73 65 64  s are first used
0240: 0a 23 23 20 69 6e 20 70 61 73 73 20 35 2c 20 77  .## in pass 5, w
0250: 68 69 63 68 20 63 72 65 61 74 65 73 20 74 68 65  hich creates the
0260: 20 69 6e 69 74 69 61 6c 20 73 65 74 20 63 6f 76   initial set cov
0270: 65 72 69 6e 67 20 74 68 65 20 72 65 70 6f 73 69  ering the reposi
0280: 74 6f 72 79 2e 0a 0a 23 20 23 20 23 23 20 23 23  tory...# # ## ##
0290: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
02a0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23   ############# #
02b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
02c0: 23 23 23 23 0a 23 23 20 52 65 71 75 69 72 65 6d  ####.## Requirem
02d0: 65 6e 74 73 0a 0a 70 61 63 6b 61 67 65 20 72 65  ents..package re
02e0: 71 75 69 72 65 20 54 63 6c 20 38 2e 34 20 20 20  quire Tcl 8.4   
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0300: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20              ; # 
0310: 52 65 71 75 69 72 65 64 20 72 75 6e 74 69 6d 65  Required runtime
0320: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72  ..package requir
0330: 65 20 73 6e 69 74 20 20 20 20 20 20 20 20 20 20  e 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 3b 20 23 20 4f 4f 20 73          ; # OO s
0360: 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67 65 20 72  ystem..package r
0370: 65 71 75 69 72 65 20 73 74 72 75 63 74 3a 3a 73  equire struct::s
0380: 65 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20  et              
0390: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23               ; #
03a0: 20 53 65 74 20 6f 70 65 72 61 74 69 6f 6e 73 2e   Set operations.
03b0: 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65  .package require
03c0: 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63   vc::tools::misc
03d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03e0: 20 20 20 20 20 20 20 3b 20 23 20 54 65 78 74 20         ; # Text 
03f0: 66 6f 72 6d 61 74 74 69 6e 67 0a 70 61 63 6b 61  formatting.packa
0400: 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74  ge require vc::t
0410: 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 20 20 20  ools::trouble   
0420: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0430: 20 3b 20 23 20 45 72 72 6f 72 20 72 65 70 6f 72   ; # Error repor
0440: 74 69 6e 67 2e 0a 70 61 63 6b 61 67 65 20 72 65  ting..package re
0450: 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a  quire vc::tools:
0460: 3a 6c 6f 67 20 20 20 20 20 20 20 20 20 20 20 20  :log            
0470: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20              ; # 
0480: 55 73 65 72 20 66 65 65 64 62 61 63 6b 2e 0a 70  User feedback..p
0490: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76  ackage require v
04a0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
04b0: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 20 20 20  t::cvs::state   
04c0: 20 20 20 20 20 3b 20 23 20 53 74 61 74 65 20 73       ; # State s
04d0: 74 6f 72 61 67 65 2e 0a 70 61 63 6b 61 67 65 20  torage..package 
04e0: 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73  require vc::foss
04f0: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
0500: 3a 69 6e 74 65 67 72 69 74 79 20 20 20 20 3b 20  :integrity    ; 
0510: 23 20 53 74 61 74 65 20 69 6e 74 65 67 72 69 74  # State integrit
0520: 79 20 63 68 65 63 6b 73 2e 0a 0a 23 20 23 20 23  y checks...# # #
0530: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
0540: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
0550: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
0560: 23 23 23 23 23 23 23 23 0a 23 23 0a 0a 73 6e 69  ########.##..sni
0570: 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f  t::type ::vc::fo
0580: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
0590: 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20  s::project::rev 
05a0: 7b 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  {.    # # ## ###
05b0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
05c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20  #############.  
05d0: 20 20 23 23 20 50 75 62 6c 69 63 20 41 50 49 0a    ## Public API.
05e0: 0a 20 20 20 20 63 6f 6e 73 74 72 75 63 74 6f 72  .    constructor
05f0: 20 7b 70 72 6f 6a 65 63 74 20 63 73 74 79 70 65   {project cstype
0600: 20 73 72 63 69 64 20 69 74 65 6d 73 20 7b 74 68   srcid items {th
0610: 65 69 64 20 7b 7d 7d 7d 20 7b 0a 09 69 66 20 7b  eid {}}} {..if {
0620: 24 74 68 65 69 64 20 6e 65 20 22 22 7d 20 7b 0a  $theid ne ""} {.
0630: 09 20 20 20 20 73 65 74 20 6d 79 69 64 20 24 74  .    set myid $t
0640: 68 65 69 64 0a 09 7d 20 65 6c 73 65 20 7b 0a 09  heid..} else {..
0650: 20 20 20 20 73 65 74 20 6d 79 69 64 20 5b 69 6e      set myid [in
0660: 63 72 20 6d 79 63 6f 75 6e 74 65 72 5d 0a 09 7d  cr mycounter]..}
0670: 0a 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73 73  ...integrity ass
0680: 65 72 74 20 7b 0a 09 20 20 20 20 5b 69 6e 66 6f  ert {..    [info
0690: 20 65 78 69 73 74 73 20 6d 79 63 73 74 79 70 65   exists mycstype
06a0: 28 24 63 73 74 79 70 65 29 5d 0a 09 7d 20 7b 42  ($cstype)]..} {B
06b0: 61 64 20 63 68 61 6e 67 65 73 65 74 20 74 79 70  ad changeset typ
06c0: 65 20 27 24 63 73 74 79 70 65 27 2e 7d 0a 0a 09  e '$cstype'.}...
06d0: 73 65 74 20 6d 79 70 72 6f 6a 65 63 74 20 20 20  set myproject   
06e0: 24 70 72 6f 6a 65 63 74 0a 09 73 65 74 20 6d 79  $project..set my
06f0: 74 79 70 65 20 20 20 20 20 20 24 63 73 74 79 70  type      $cstyp
0700: 65 0a 09 73 65 74 20 6d 79 74 79 70 65 6f 62 6a  e..set mytypeobj
0710: 20 20 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a     ::vc::fossil:
0720: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72  :import::cvs::pr
0730: 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a 24 7b 63 73  oject::rev::${cs
0740: 74 79 70 65 7d 0a 09 73 65 74 20 6d 79 73 72 63  type}..set mysrc
0750: 69 64 09 24 73 72 63 69 64 0a 09 73 65 74 20 6d  id.$srcid..set m
0760: 79 69 74 65 6d 73 20 20 20 20 20 24 69 74 65 6d  yitems     $item
0770: 73 0a 09 73 65 74 20 6d 79 70 6f 73 20 20 20 20  s..set mypos    
0780: 20 20 20 7b 7d 20 3b 20 23 20 43 6f 6d 6d 69 74     {} ; # Commit
0790: 20 6c 6f 63 61 74 69 6f 6e 20 69 73 20 6e 6f 74   location is not
07a0: 20 6b 6e 6f 77 6e 20 79 65 74 2e 0a 0a 09 23 20   known yet....# 
07b0: 4b 65 65 70 20 74 72 61 63 6b 20 6f 66 20 74 68  Keep track of th
07c0: 65 20 67 65 6e 65 72 61 74 65 64 20 63 68 61 6e  e generated chan
07d0: 67 65 73 65 74 73 20 61 6e 64 20 6f 66 20 74 68  gesets and of th
07e0: 65 20 69 6e 76 65 72 73 65 0a 09 23 20 6d 61 70  e inverse..# map
07f0: 70 69 6e 67 20 66 72 6f 6d 20 69 74 65 6d 73 20  ping from items 
0800: 74 6f 20 74 68 65 6d 2e 0a 09 6c 61 70 70 65 6e  to them...lappen
0810: 64 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20  d mychangesets  
0820: 20 24 73 65 6c 66 0a 09 6c 61 70 70 65 6e 64 20   $self..lappend 
0830: 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 24 63  mytchangesets($c
0840: 73 74 79 70 65 29 20 24 73 65 6c 66 0a 09 73 65  stype) $self..se
0850: 74 20 20 20 20 20 6d 79 69 64 6d 61 70 28 24 6d  t     myidmap($m
0860: 79 69 64 29 20 24 73 65 6c 66 0a 09 66 6f 72 65  yid) $self..fore
0870: 61 63 68 20 69 69 64 20 24 69 74 65 6d 73 20 7b  ach iid $items {
0880: 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c  ..    set key [l
0890: 69 73 74 20 24 63 73 74 79 70 65 20 24 69 69 64  ist $cstype $iid
08a0: 5d 0a 09 20 20 20 20 73 65 74 20 6d 79 69 74 65  ]..    set myite
08b0: 6d 6d 61 70 28 24 6b 65 79 29 20 24 73 65 6c 66  mmap($key) $self
08c0: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 6d 79  ..    lappend my
08d0: 74 69 74 65 6d 73 20 24 6b 65 79 0a 09 20 20 20  titems $key..   
08e0: 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65   log write 8 cse
08f0: 74 73 20 7b 4d 41 50 2b 20 69 74 65 6d 20 3c 24  ts {MAP+ item <$
0900: 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73  key> $self = [$s
0910: 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 09 72 65  elf str]}..}..re
0920: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
0930: 6d 65 74 68 6f 64 20 73 74 72 20 7b 7d 20 7b 0a  method str {} {.
0940: 09 73 65 74 20 73 74 72 20 20 20 20 22 3c 22 0a  .set str    "<".
0950: 09 73 65 74 20 64 65 74 61 69 6c 20 22 22 0a 09  .set detail ""..
0960: 69 66 20 7b 5b 24 6d 79 74 79 70 65 6f 62 6a 20  if {[$mytypeobj 
0970: 62 79 73 79 6d 62 6f 6c 5d 7d 20 7b 0a 09 20 20  bysymbol]} {..  
0980: 20 20 73 65 74 20 64 65 74 61 69 6c 20 22 20 27    set detail " '
0990: 5b 73 74 61 74 65 20 6f 6e 65 20 7b 0a 09 09 53  [state one {...S
09a0: 45 4c 45 43 54 20 53 2e 6e 61 6d 65 0a 09 09 46  ELECT S.name...F
09b0: 52 4f 4d 20 20 20 73 79 6d 62 6f 6c 20 53 0a 09  ROM   symbol S..
09c0: 09 57 48 45 52 45 20 20 53 2e 73 69 64 20 3d 20  .WHERE  S.sid = 
09d0: 24 6d 79 73 72 63 69 64 0a 09 20 20 20 20 7d 5d  $mysrcid..    }]
09e0: 27 22 0a 09 7d 0a 09 61 70 70 65 6e 64 20 73 74  '"..}..append st
09f0: 72 20 22 24 6d 79 74 79 70 65 20 24 7b 6d 79 69  r "$mytype ${myi
0a00: 64 7d 24 7b 64 65 74 61 69 6c 7d 3e 22 0a 09 72  d}${detail}>"..r
0a10: 65 74 75 72 6e 20 24 73 74 72 0a 20 20 20 20 7d  eturn $str.    }
0a20: 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 69 64 20  ..    method id 
0a30: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 24     {} { return $
0a40: 6d 79 69 64 20 7d 0a 20 20 20 20 6d 65 74 68 6f  myid }.    metho
0a50: 64 20 69 74 65 6d 73 20 7b 7d 20 7b 20 72 65 74  d items {} { ret
0a60: 75 72 6e 20 24 6d 79 74 69 74 65 6d 73 20 7d 0a  urn $mytitems }.
0a70: 20 20 20 20 6d 65 74 68 6f 64 20 64 61 74 61 20      method data 
0a80: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69   {} { return [li
0a90: 73 74 20 24 6d 79 70 72 6f 6a 65 63 74 20 24 6d  st $myproject $m
0aa0: 79 74 79 70 65 20 24 6d 79 73 72 63 69 64 5d 20  ytype $mysrcid] 
0ab0: 7d 0a 0a 20 20 20 20 64 65 6c 65 67 61 74 65 20  }..    delegate 
0ac0: 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20  method bysymbol 
0ad0: 20 20 74 6f 20 6d 79 74 79 70 65 6f 62 6a 0a 20    to mytypeobj. 
0ae0: 20 20 20 64 65 6c 65 67 61 74 65 20 6d 65 74 68     delegate meth
0af0: 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20 74 6f  od byrevision to
0b00: 20 6d 79 74 79 70 65 6f 62 6a 0a 20 20 20 20 64   mytypeobj.    d
0b10: 65 6c 65 67 61 74 65 20 6d 65 74 68 6f 64 20 69  elegate method i
0b20: 73 62 72 61 6e 63 68 20 20 20 74 6f 20 6d 79 74  sbranch   to myt
0b30: 79 70 65 6f 62 6a 0a 20 20 20 20 64 65 6c 65 67  ypeobj.    deleg
0b40: 61 74 65 20 6d 65 74 68 6f 64 20 69 73 74 61 67  ate method istag
0b50: 20 20 20 20 20 20 74 6f 20 6d 79 74 79 70 65 6f        to mytypeo
0b60: 62 6a 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 73  bj..    method s
0b70: 65 74 70 6f 73 20 7b 70 7d 20 7b 20 73 65 74 20  etpos {p} { set 
0b80: 6d 79 70 6f 73 20 24 70 20 3b 20 72 65 74 75 72  mypos $p ; retur
0b90: 6e 20 7d 0a 20 20 20 20 6d 65 74 68 6f 64 20 70  n }.    method p
0ba0: 6f 73 20 20 20 20 7b 7d 20 20 7b 20 72 65 74 75  os    {}  { retu
0bb0: 72 6e 20 24 6d 79 70 6f 73 20 7d 0a 0a 20 20 20  rn $mypos }..   
0bc0: 20 6d 65 74 68 6f 64 20 64 65 74 65 72 6d 69 6e   method determin
0bd0: 65 73 75 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b  esuccessors {} {
0be0: 0a 09 23 20 50 61 73 73 20 36 20 6f 70 65 72 61  ..# Pass 6 opera
0bf0: 74 69 6f 6e 2e 20 43 6f 6d 70 75 74 65 20 70 72  tion. Compute pr
0c00: 6f 6a 65 63 74 2d 6c 65 76 65 6c 20 64 65 70 65  oject-level depe
0c10: 6e 64 65 6e 63 69 65 73 20 66 72 6f 6d 0a 09 23  ndencies from..#
0c20: 20 74 68 65 20 66 69 6c 65 2d 6c 65 76 65 6c 20   the file-level 
0c30: 64 61 74 61 20 61 6e 64 20 73 61 76 65 20 69 74  data and save it
0c40: 20 62 61 63 6b 20 74 6f 20 74 68 65 20 73 74 61   back to the sta
0c50: 74 65 2e 20 54 68 69 73 20 6d 61 79 0a 09 23 20  te. This may..# 
0c60: 62 65 20 63 61 6c 6c 65 64 20 64 75 72 69 6e 67  be called during
0c70: 20 74 68 65 20 63 79 63 6c 65 20 62 72 65 61 6b   the cycle break
0c80: 65 72 20 70 61 73 73 65 73 20 61 73 20 77 65 6c  er passes as wel
0c90: 6c 2c 20 74 6f 20 61 64 6a 75 73 74 0a 09 23 20  l, to adjust..# 
0ca0: 74 68 65 20 73 75 63 63 65 73 73 6f 72 20 69 6e  the successor in
0cb0: 66 6f 72 6d 61 74 69 6f 6e 20 6f 66 20 63 68 61  formation of cha
0cc0: 6e 67 65 73 65 74 73 20 77 68 69 63 68 20 61 72  ngesets which ar
0cd0: 65 20 74 68 65 0a 09 23 20 70 72 65 64 65 63 65  e the..# predece
0ce0: 73 73 6f 72 73 20 6f 66 20 64 72 6f 70 70 65 64  ssors of dropped
0cf0: 20 63 68 61 6e 67 65 73 65 74 73 2e 20 46 6f 72   changesets. For
0d00: 20 74 68 65 6d 20 77 65 20 68 61 76 65 20 74 6f   them we have to
0d10: 0a 09 23 20 72 65 6d 6f 76 65 20 74 68 65 69 72  ..# remove their
0d20: 20 65 78 69 73 74 69 6e 67 20 69 6e 66 6f 72 6d   existing inform
0d30: 61 74 69 6f 6e 20 66 69 72 73 74 20 62 65 66 6f  ation first befo
0d40: 72 65 20 69 6e 73 65 72 74 69 6e 67 20 74 68 65  re inserting the
0d50: 0a 09 23 20 6e 65 77 20 64 61 74 61 2e 0a 09 73  ..# new data...s
0d60: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
0d70: 44 45 4c 45 54 45 20 46 52 4f 4d 20 63 73 73 75  DELETE FROM cssu
0d80: 63 63 65 73 73 6f 72 20 57 48 45 52 45 20 63 69  ccessor WHERE ci
0d90: 64 20 3d 20 24 6d 79 69 64 3b 0a 09 7d 0a 09 73  d = $myid;..}..s
0da0: 65 74 20 6c 6f 6f 70 20 30 0a 09 66 6f 72 65 61  et loop 0..forea
0db0: 63 68 20 6e 69 64 20 5b 24 6d 79 74 79 70 65 6f  ch nid [$mytypeo
0dc0: 62 6a 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73  bj cs_successors
0dd0: 20 24 6d 79 69 74 65 6d 73 5d 20 7b 0a 09 20 20   $myitems] {..  
0de0: 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09    state run {...
0df0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 73 73 75  INSERT INTO cssu
0e00: 63 63 65 73 73 6f 72 20 28 63 69 64 2c 20 20 6e  ccessor (cid,  n
0e10: 69 64 29 0a 09 09 56 41 4c 55 45 53 20 20 20 20  id)...VALUES    
0e20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 24                ($
0e30: 6d 79 69 64 2c 24 6e 69 64 29 0a 09 20 20 20 20  myid,$nid)..    
0e40: 7d 0a 09 20 20 20 20 69 66 20 7b 24 6e 69 64 20  }..    if {$nid 
0e50: 3d 3d 20 24 6d 79 69 64 7d 20 7b 20 73 65 74 20  == $myid} { set 
0e60: 6c 6f 6f 70 20 31 20 7d 0a 09 7d 0a 09 23 20 52  loop 1 }..}..# R
0e70: 65 70 6f 72 74 20 61 66 74 65 72 20 74 68 65 20  eport after the 
0e80: 63 6f 6d 70 6c 65 74 65 20 73 74 72 75 63 74 75  complete structu
0e90: 72 65 20 68 61 73 20 62 65 65 6e 20 73 61 76 65  re has been save
0ea0: 64 2e 0a 09 69 66 20 7b 24 6c 6f 6f 70 7d 20 7b  d...if {$loop} {
0eb0: 20 24 73 65 6c 66 20 72 65 70 6f 72 74 6c 6f 6f   $self reportloo
0ec0: 70 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  p }..return.    
0ed0: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20  }..    # result 
0ee0: 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65  = list (changese
0ef0: 74 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 73 75  t).    method su
0f00: 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b 0a 09 23  ccessors {} {..#
0f10: 20 55 73 65 20 74 68 65 20 64 61 74 61 20 73 61   Use the data sa
0f20: 76 65 64 20 62 79 20 70 61 73 73 20 36 2e 0a 09  ved by pass 6...
0f30: 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a  return [struct::
0f40: 6c 69 73 74 20 6d 61 70 20 5b 73 74 61 74 65 20  list map [state 
0f50: 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  run {..    SELEC
0f60: 54 20 53 2e 6e 69 64 0a 09 20 20 20 20 46 52 4f  T S.nid..    FRO
0f70: 4d 20 20 20 63 73 73 75 63 63 65 73 73 6f 72 20  M   cssuccessor 
0f80: 53 0a 09 20 20 20 20 57 48 45 52 45 20 20 53 2e  S..    WHERE  S.
0f90: 63 69 64 20 3d 20 24 6d 79 69 64 0a 09 7d 5d 20  cid = $myid..}] 
0fa0: 5b 6d 79 74 79 70 65 6d 65 74 68 6f 64 20 6f 66  [mytypemethod of
0fb0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  ]].    }..    # 
0fc0: 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69 74  item -> list (it
0fd0: 65 6d 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 6e  em).    method n
0fe0: 65 78 74 6d 61 70 20 7b 7d 20 7b 0a 09 24 6d 79  extmap {} {..$my
0ff0: 74 79 70 65 6f 62 6a 20 73 75 63 63 65 73 73 6f  typeobj successo
1000: 72 73 20 74 6d 70 20 24 6d 79 69 74 65 6d 73 0a  rs tmp $myitems.
1010: 09 72 65 74 75 72 6e 20 5b 61 72 72 61 79 20 67  .return [array g
1020: 65 74 20 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20  et tmp].    }.. 
1030: 20 20 20 6d 65 74 68 6f 64 20 62 72 65 61 6b 69     method breaki
1040: 6e 74 65 72 6e 61 6c 64 65 70 65 6e 64 65 6e 63  nternaldependenc
1050: 69 65 73 20 7b 7d 20 7b 0a 0a 09 23 23 0a 09 23  ies {} {...##..#
1060: 23 20 4e 4f 54 45 3a 20 54 68 69 73 20 6d 65 74  # NOTE: This met
1070: 68 6f 64 2c 20 6d 61 79 62 65 20 69 6e 20 63 6f  hod, maybe in co
1080: 6e 6a 75 6e 63 74 69 6f 6e 20 77 69 74 68 20 69  njunction with i
1090: 74 73 20 63 61 6c 6c 65 72 0a 09 23 23 20 20 20  ts caller..##   
10a0: 20 20 20 20 73 65 65 6d 73 20 74 6f 20 62 65 20      seems to be 
10b0: 61 20 6d 65 6d 6f 72 79 20 68 6f 67 2c 20 65 73  a memory hog, es
10c0: 70 65 63 69 61 6c 6c 79 20 66 6f 72 20 6c 61 72  pecially for lar
10d0: 67 65 0a 09 23 23 20 20 20 20 20 20 20 63 68 61  ge..##       cha
10e0: 6e 67 65 73 65 74 73 2c 20 77 69 74 68 20 27 6c  ngesets, with 'l
10f0: 61 72 67 65 27 20 6d 65 61 6e 69 6e 67 20 74 6f  arge' meaning to
1100: 20 68 61 76 65 20 61 20 27 6c 6f 6e 67 20 6c 69   have a 'long li
1110: 73 74 0a 09 23 23 20 20 20 20 20 20 20 6f 66 20  st..##       of 
1120: 69 74 65 6d 73 2c 20 73 65 76 65 72 61 6c 20 74  items, several t
1130: 68 6f 75 73 61 6e 64 27 2e 20 49 6e 76 65 73 74  housand'. Invest
1140: 69 67 61 74 65 20 77 68 65 72 65 20 74 68 65 0a  igate where the.
1150: 09 23 23 20 20 20 20 20 20 20 6d 65 6d 6f 72 79  .##       memory
1160: 20 69 73 20 73 70 65 6e 74 20 61 6e 64 20 74 68   is spent and th
1170: 65 6e 20 6c 6f 6f 6b 20 66 6f 72 20 77 61 79 73  en look for ways
1180: 20 6f 66 20 72 65 63 74 69 66 79 69 6e 67 0a 09   of rectifying..
1190: 23 23 20 20 20 20 20 20 20 74 68 65 20 70 72 6f  ##       the pro
11a0: 62 6c 65 6d 2e 0a 09 23 23 0a 0a 09 23 20 54 68  blem...##...# Th
11b0: 69 73 20 6d 65 74 68 6f 64 20 69 6e 73 70 65 63  is method inspec
11c0: 74 73 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  ts the changeset
11d0: 73 20 66 6f 72 20 69 6e 74 65 72 6e 61 6c 0a 09  s for internal..
11e0: 23 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 20  # dependencies. 
11f0: 4e 6f 74 68 69 6e 67 20 69 73 20 64 6f 6e 65 20  Nothing is done 
1200: 69 66 20 74 68 65 72 65 20 61 72 65 20 6e 6f 0a  if there are no.
1210: 09 23 20 73 75 63 68 2e 20 4f 74 68 65 72 77 69  .# such. Otherwi
1220: 73 65 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  se the changeset
1230: 20 69 73 20 73 70 6c 69 74 20 69 6e 74 6f 20 61   is split into a
1240: 20 73 65 74 20 6f 66 0a 09 23 20 66 72 61 67 6d   set of..# fragm
1250: 65 6e 74 73 20 77 69 74 68 6f 75 74 20 69 6e 74  ents without int
1260: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
1270: 65 73 2c 20 74 72 61 6e 73 66 6f 72 6d 69 6e 67  es, transforming
1280: 20 74 68 65 0a 09 23 20 69 6e 74 65 72 6e 61 6c   the..# internal
1290: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 69 6e   dependencies in
12a0: 74 6f 20 65 78 74 65 72 6e 61 6c 20 6f 6e 65 73  to external ones
12b0: 2e 20 54 68 65 20 6e 65 77 20 63 68 61 6e 67 65  . The new change
12c0: 73 65 74 73 0a 09 23 20 61 72 65 20 61 64 64 65  sets..# are adde
12d0: 64 20 74 6f 20 74 68 65 20 6c 69 73 74 20 6f 66  d to the list of
12e0: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 2e   all changesets.
12f0: 0a 0a 09 23 20 57 65 20 70 65 72 66 6f 72 6d 20  ...# We perform 
1300: 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20 73 70  all necessary sp
1310: 6c 69 74 73 20 69 6e 20 6f 6e 65 20 67 6f 2c 20  lits in one go, 
1320: 69 6e 73 74 65 61 64 20 6f 66 20 6f 6e 6c 79 0a  instead of only.
1330: 09 23 20 6f 6e 65 2e 20 54 68 65 20 70 72 65 76  .# one. The prev
1340: 69 6f 75 73 20 61 6c 67 6f 72 69 74 68 6d 2c 20  ious algorithm, 
1350: 61 64 61 70 74 65 64 20 66 72 6f 6d 20 63 76 73  adapted from cvs
1360: 32 73 76 6e 2c 20 63 6f 6d 70 75 74 65 64 0a 09  2svn, computed..
1370: 23 20 61 20 6c 6f 74 20 6f 66 20 73 74 61 74 65  # a lot of state
1380: 20 77 68 69 63 68 20 77 61 73 20 74 68 72 6f 77   which was throw
1390: 6e 20 61 77 61 79 20 61 6e 64 20 74 68 65 6e 20  n away and then 
13a0: 63 6f 6d 70 75 74 65 64 20 61 67 61 69 6e 0a 09  computed again..
13b0: 23 20 66 6f 72 20 65 61 63 68 20 6f 66 20 74 68  # for each of th
13c0: 65 20 66 72 61 67 6d 65 6e 74 73 2e 20 49 74 20  e fragments. It 
13d0: 73 68 6f 75 6c 64 20 62 65 20 65 61 73 69 65 72  should be easier
13e0: 20 74 6f 20 75 70 64 61 74 65 20 61 6e 64 0a 09   to update and..
13f0: 23 20 72 65 75 73 65 20 74 68 61 74 20 73 74 61  # reuse that sta
1400: 74 65 2e 0a 0a 09 23 20 54 68 65 20 63 6f 64 65  te....# The code
1410: 20 63 68 65 63 6b 73 20 6f 6e 6c 79 20 73 75 63   checks only suc
1420: 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63  cessor dependenc
1430: 69 65 73 2c 20 61 73 20 74 68 69 73 0a 09 23 20  ies, as this..# 
1440: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 63 6f  automatically co
1450: 76 65 72 73 20 74 68 65 20 70 72 65 64 65 63 65  vers the predece
1460: 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 69 65  ssor dependencie
1470: 73 20 61 73 20 77 65 6c 6c 20 28 41 0a 09 23 20  s as well (A..# 
1480: 73 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e 64  successor depend
1490: 65 6e 63 79 20 61 20 2d 3e 20 62 20 69 73 20 61  ency a -> b is a
14a0: 6c 73 6f 20 61 20 70 72 65 64 65 63 65 73 73 6f  lso a predecesso
14b0: 72 20 64 65 70 65 6e 64 65 6e 63 79 0a 09 23 20  r dependency..# 
14c0: 62 20 2d 3e 20 61 29 2e 0a 0a 09 23 20 41 72 72  b -> a)....# Arr
14d0: 61 79 20 6f 66 20 64 65 70 65 6e 64 65 6e 63 69  ay of dependenci
14e0: 65 73 20 28 70 61 72 65 6e 74 20 2d 3e 20 63 68  es (parent -> ch
14f0: 69 6c 64 29 2e 20 54 68 69 73 20 69 73 20 70 75  ild). This is pu
1500: 6c 6c 65 64 20 66 72 6f 6d 0a 09 23 20 74 68 65  lled from..# the
1510: 20 73 74 61 74 65 2c 20 61 6e 64 20 6c 69 6d 69   state, and limi
1520: 74 65 64 20 74 6f 20 73 75 63 63 65 73 73 6f 72  ted to successor
1530: 73 20 77 69 74 68 69 6e 20 74 68 65 20 63 68 61  s within the cha
1540: 6e 67 65 73 65 74 2e 0a 0a 09 61 72 72 61 79 20  ngeset....array 
1550: 73 65 74 20 64 65 70 65 6e 64 65 6e 63 69 65 73  set dependencies
1560: 20 7b 7d 0a 09 24 6d 79 74 79 70 65 6f 62 6a 20   {}..$mytypeobj 
1570: 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f  internalsuccesso
1580: 72 73 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  rs dependencies 
1590: 24 6d 79 69 74 65 6d 73 0a 09 69 66 20 7b 21 5b  $myitems..if {![
15a0: 61 72 72 61 79 20 73 69 7a 65 20 64 65 70 65 6e  array size depen
15b0: 64 65 6e 63 69 65 73 5d 7d 20 7b 72 65 74 75 72  dencies]} {retur
15c0: 6e 20 30 7d 20 3b 20 23 20 4e 6f 74 68 69 6e 67  n 0} ; # Nothing
15d0: 20 74 6f 20 62 72 65 61 6b 2e 0a 0a 09 6c 6f 67   to break....log
15e0: 20 77 72 69 74 65 20 35 20 63 73 65 74 73 20 2e   write 5 csets .
15f0: 2e 2e 5b 24 73 65 6c 66 20 73 74 72 5d 2e 2e 2e  ..[$self str]...
1600: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1610: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1620: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1630: 2e 2e 2e 2e 0a 0a 09 23 20 57 65 20 68 61 76 65  .......# We have
1640: 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64   internal depend
1650: 65 6e 63 69 65 73 20 74 6f 20 62 72 65 61 6b 2e  encies to break.
1660: 20 57 65 20 6e 6f 77 20 69 74 65 72 61 74 65 20   We now iterate 
1670: 6f 76 65 72 0a 09 23 20 61 6c 6c 20 70 6f 73 69  over..# all posi
1680: 74 69 6f 6e 73 20 69 6e 20 74 68 65 20 6c 69 73  tions in the lis
1690: 74 20 28 77 68 69 63 68 20 69 73 20 63 68 72 6f  t (which is chro
16a0: 6e 6f 6c 6f 67 69 63 61 6c 2c 20 61 74 20 6c 65  nological, at le
16b0: 61 73 74 0a 09 23 20 61 73 20 66 61 72 20 61 73  ast..# as far as
16c0: 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20   the timestamps 
16d0: 61 72 65 20 63 6f 72 72 65 63 74 20 61 6e 64 20  are correct and 
16e0: 75 6e 69 71 75 65 29 20 61 6e 64 0a 09 23 20 64  unique) and..# d
16f0: 65 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65 73  etermine the bes
1700: 74 20 70 6f 73 69 74 69 6f 6e 20 66 6f 72 20 74  t position for t
1710: 68 65 20 62 72 65 61 6b 2c 20 62 79 20 74 72 79  he break, by try
1720: 69 6e 67 20 74 6f 0a 09 23 20 62 72 65 61 6b 20  ing to..# break 
1730: 61 73 20 6d 61 6e 79 20 64 65 70 65 6e 64 65 6e  as many dependen
1740: 63 69 65 73 20 61 73 20 70 6f 73 73 69 62 6c 65  cies as possible
1750: 20 69 6e 20 6f 6e 65 20 67 6f 2e 20 57 68 65 6e   in one go. When
1760: 20 61 0a 09 23 20 62 72 65 61 6b 20 77 61 73 20   a..# break was 
1770: 66 6f 75 6e 64 20 74 68 69 73 20 69 73 20 72 65  found this is re
1780: 64 6f 6e 65 20 66 6f 72 20 74 68 65 20 66 72 61  done for the fra
1790: 67 6d 65 6e 74 73 20 63 6f 6d 69 6e 67 20 61 6e  gments coming an
17a0: 64 0a 09 23 20 61 66 74 65 72 2c 20 61 66 74 65  d..# after, afte
17b0: 72 20 75 70 64 69 6e 67 20 74 68 65 20 63 72 6f  r upding the cro
17c0: 73 73 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f  ssing informatio
17d0: 6e 2e 0a 0a 09 23 20 44 61 74 61 20 73 74 72 75  n....# Data stru
17e0: 63 74 75 72 65 73 3a 0a 09 23 20 4d 61 70 3a 20  ctures:..# Map: 
17f0: 20 50 4f 53 20 20 20 72 65 76 69 73 69 6f 6e 20   POS   revision 
1800: 69 64 20 20 20 20 20 20 2d 3e 20 70 6f 73 69 74  id      -> posit
1810: 69 6f 6e 20 69 6e 20 6c 69 73 74 2e 0a 09 23 20  ion in list...# 
1820: 20 20 20 20 20 20 43 52 4f 53 53 20 70 6f 73 69        CROSS posi
1830: 74 69 6f 6e 20 69 6e 20 6c 69 73 74 20 2d 3e 20  tion in list -> 
1840: 6e 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64  number of depend
1850: 65 6e 63 69 65 73 20 63 72 6f 73 73 69 6e 67 20  encies crossing 
1860: 69 74 0a 09 23 20 20 20 20 20 20 20 44 45 50 43  it..#       DEPC
1870: 20 20 64 65 70 65 6e 64 65 6e 63 79 20 20 20 20    dependency    
1880: 20 20 20 2d 3e 20 70 6f 73 69 74 69 6f 6e 73 20     -> positions 
1890: 69 74 20 63 72 6f 73 73 65 73 0a 09 23 20 4c 69  it crosses..# Li
18a0: 73 74 3a 20 52 41 4e 47 45 20 4f 66 20 74 68 65  st: RANGE Of the
18b0: 20 70 6f 73 69 74 69 6f 6e 73 20 69 74 73 65 6c   positions itsel
18c0: 66 2e 0a 09 23 20 41 20 64 65 70 65 6e 64 65 6e  f...# A dependen
18d0: 63 79 20 69 73 20 61 20 73 69 6e 67 6c 65 2d 65  cy is a single-e
18e0: 6c 65 6d 65 6e 74 20 6d 61 70 20 70 61 72 65 6e  lement map paren
18f0: 74 20 2d 3e 20 63 68 69 6c 64 0a 0a 09 49 6e 69  t -> child...Ini
1900: 74 69 61 6c 69 7a 65 42 72 65 61 6b 53 74 61 74  tializeBreakStat
1910: 65 20 24 6d 79 69 74 65 6d 73 0a 0a 09 73 65 74  e $myitems...set
1920: 20 66 72 61 67 6d 65 6e 74 73 20 7b 7d 0a 09 73   fragments {}..s
1930: 65 74 20 6e 65 77 20 20 20 20 20 20 20 5b 6c 69  et new       [li
1940: 73 74 20 24 72 61 6e 67 65 5d 0a 09 61 72 72 61  st $range]..arra
1950: 79 20 73 65 74 20 62 72 65 61 6b 73 20 7b 7d 0a  y set breaks {}.
1960: 0a 09 23 20 49 6e 73 74 65 61 64 20 6f 66 20 6f  ..# Instead of o
1970: 6e 65 20 6c 69 73 74 20 68 6f 6c 64 69 6e 67 20  ne list holding 
1980: 62 6f 74 68 20 70 72 6f 63 65 73 73 65 64 20 61  both processed a
1990: 6e 64 20 70 65 6e 64 69 6e 67 0a 09 23 20 66 72  nd pending..# fr
19a0: 61 67 6d 65 6e 74 73 20 77 65 20 75 73 65 20 74  agments we use t
19b0: 77 6f 2c 20 6f 6e 65 20 66 6f 72 20 74 68 65 20  wo, one for the 
19c0: 66 72 61 6d 65 6e 74 73 20 74 6f 20 70 72 6f 63  framents to proc
19d0: 65 73 73 2c 20 6f 6e 65 0a 09 23 20 74 6f 20 68  ess, one..# to h
19e0: 6f 6c 64 20 74 68 65 20 6e 65 77 20 66 72 61 67  old the new frag
19f0: 6d 65 6e 74 73 2c 20 61 6e 64 20 74 68 65 20 6c  ments, and the l
1a00: 61 74 74 65 72 20 69 73 20 63 6f 70 69 65 64 20  atter is copied 
1a10: 74 6f 20 74 68 65 0a 09 23 20 66 6f 72 6d 65 72  to the..# former
1a20: 20 77 68 65 6e 20 74 68 65 79 20 72 75 6e 20 6f   when they run o
1a30: 75 74 2e 20 54 68 69 73 20 6b 65 65 70 73 20 74  ut. This keeps t
1a40: 68 65 20 6c 69 73 74 20 6f 66 20 70 65 6e 64 69  he list of pendi
1a50: 6e 67 0a 09 23 20 66 72 61 67 6d 65 6e 74 73 20  ng..# fragments 
1a60: 73 68 6f 72 74 20 77 69 74 68 6f 75 74 20 73 61  short without sa
1a70: 63 72 69 66 69 63 69 6e 67 20 73 70 65 65 64 20  crificing speed 
1a80: 62 79 20 73 68 69 66 74 69 6e 67 20 73 74 75 66  by shifting stuf
1a90: 66 0a 09 23 20 64 6f 77 6e 2e 20 57 65 20 65 73  f..# down. We es
1aa0: 70 65 63 69 61 6c 6c 79 20 64 72 6f 70 20 74 68  pecially drop th
1ab0: 65 20 6d 65 6d 6f 72 79 20 6f 66 20 66 72 61 67  e memory of frag
1ac0: 6d 65 6e 74 73 20 62 72 6f 6b 65 6e 0a 09 23 20  ments broken..# 
1ad0: 64 75 72 69 6e 67 20 70 72 6f 63 65 73 73 69 6e  during processin
1ae0: 67 20 61 66 74 65 72 20 61 20 73 68 6f 72 74 20  g after a short 
1af0: 74 69 6d 65 2c 20 69 6e 73 74 65 61 64 20 6f 66  time, instead of
1b00: 20 6c 65 74 74 69 6e 67 20 69 74 0a 09 23 20 63   letting it..# c
1b10: 6f 6e 73 75 6d 65 20 6d 65 6d 6f 72 79 2e 0a 0a  onsume memory...
1b20: 09 77 68 69 6c 65 20 7b 5b 6c 6c 65 6e 67 74 68  .while {[llength
1b30: 20 24 6e 65 77 5d 7d 20 7b 0a 0a 09 20 20 20 20   $new]} {...    
1b40: 73 65 74 20 70 65 6e 64 69 6e 67 20 24 6e 65 77  set pending $new
1b50: 0a 09 20 20 20 20 73 65 74 20 6e 65 77 20 20 20  ..    set new   
1b60: 20 20 7b 7d 0a 09 20 20 20 20 73 65 74 20 61 74    {}..    set at
1b70: 20 20 20 20 20 20 30 0a 0a 09 20 20 20 20 77 68        0...    wh
1b80: 69 6c 65 20 7b 24 61 74 20 3c 20 5b 6c 6c 65 6e  ile {$at < [llen
1b90: 67 74 68 20 24 70 65 6e 64 69 6e 67 5d 7d 20 7b  gth $pending]} {
1ba0: 0a 09 09 73 65 74 20 63 75 72 72 65 6e 74 20 5b  ...set current [
1bb0: 6c 69 6e 64 65 78 20 24 70 65 6e 64 69 6e 67 20  lindex $pending 
1bc0: 24 61 74 5d 0a 0a 09 09 6c 6f 67 20 77 72 69 74  $at]....log writ
1bd0: 65 20 36 20 63 73 65 74 73 20 7b 2e 20 2e 20 2e  e 6 csets {. . .
1be0: 2e 20 2e 2e 2e 20 2e 2e 2e 2e 2e 20 2e 2e 2e 2e  . ... ..... ....
1bf0: 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  .... ...........
1c00: 2e 2e 7d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20  ..}...log write 
1c10: 36 20 63 73 65 74 73 20 7b 53 63 68 65 64 75 6c  6 csets {Schedul
1c20: 65 64 20 20 20 5b 6a 6f 69 6e 20 5b 50 52 73 20  ed   [join [PRs 
1c30: 5b 6c 72 61 6e 67 65 20 24 70 65 6e 64 69 6e 67  [lrange $pending
1c40: 20 24 61 74 20 65 6e 64 5d 5d 20 7b 20 7d 5d 7d   $at end]] { }]}
1c50: 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63  ...log write 6 c
1c60: 73 65 74 73 20 7b 43 6f 6e 73 69 64 65 72 69 6e  sets {Considerin
1c70: 67 20 5b 50 52 20 24 63 75 72 72 65 6e 74 5d 20  g [PR $current] 
1c80: 5c 5b 24 61 74 2f 5b 6c 6c 65 6e 67 74 68 20 24  \[$at/[llength $
1c90: 70 65 6e 64 69 6e 67 5d 5c 5d 7d 0a 0a 09 09 73  pending]\]}....s
1ca0: 65 74 20 62 65 73 74 20 5b 46 69 6e 64 42 65 73  et best [FindBes
1cb0: 74 42 72 65 61 6b 20 24 63 75 72 72 65 6e 74 5d  tBreak $current]
1cc0: 0a 0a 09 09 69 66 20 7b 24 62 65 73 74 20 3c 20  ....if {$best < 
1cd0: 30 7d 20 7b 0a 09 09 20 20 20 20 23 20 54 68 65  0} {...    # The
1ce0: 20 69 6e 73 70 65 63 74 65 64 20 72 61 6e 67 65   inspected range
1cf0: 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61 6c   has no internal
1d00: 0a 09 09 20 20 20 20 23 20 64 65 70 65 6e 64 65  ...    # depende
1d10: 6e 63 69 65 73 2e 20 54 68 69 73 20 69 73 20 61  ncies. This is a
1d20: 20 63 6f 6d 70 6c 65 74 65 20 66 72 61 67 6d 65   complete fragme
1d30: 6e 74 2e 0a 09 09 20 20 20 20 6c 61 70 70 65 6e  nt....    lappen
1d40: 64 20 66 72 61 67 6d 65 6e 74 73 20 24 63 75 72  d fragments $cur
1d50: 72 65 6e 74 0a 0a 09 09 20 20 20 20 6c 6f 67 20  rent....    log 
1d60: 77 72 69 74 65 20 36 20 63 73 65 74 73 20 22 4e  write 6 csets "N
1d70: 6f 20 62 72 65 61 6b 73 2c 20 66 69 6e 61 6c 22  o breaks, final"
1d80: 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20  ...} else {...  
1d90: 20 20 23 20 53 70 6c 69 74 20 74 68 65 20 72 61    # Split the ra
1da0: 6e 67 65 20 61 6e 64 20 73 63 68 65 64 75 6c 65  nge and schedule
1db0: 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 0a 09   the resulting..
1dc0: 09 20 20 20 20 23 20 66 72 61 67 6d 65 6e 74 73  .    # fragments
1dd0: 20 66 6f 72 20 66 75 72 74 68 65 72 20 69 6e 73   for further ins
1de0: 70 65 63 74 69 6f 6e 2e 20 52 65 6d 65 6d 62 65  pection. Remembe
1df0: 72 20 74 68 65 0a 09 09 20 20 20 20 23 20 6e 75  r the...    # nu
1e00: 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 65 6e  mber of dependen
1e10: 63 69 65 73 20 63 75 74 20 62 65 66 6f 72 65 20  cies cut before 
1e20: 77 65 20 72 65 6d 6f 76 65 20 74 68 65 6d 0a 09  we remove them..
1e30: 09 20 20 20 20 23 20 66 72 6f 6d 20 63 6f 6e 73  .    # from cons
1e40: 69 64 65 72 61 74 69 6f 6e 2c 20 66 6f 72 20 64  ideration, for d
1e50: 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 6c 61 74  ocumentation lat
1e60: 65 72 2e 0a 0a 09 09 20 20 20 20 73 65 74 20 62  er.....    set b
1e70: 72 65 61 6b 73 28 24 62 65 73 74 29 20 24 63 72  reaks($best) $cr
1e80: 6f 73 73 28 24 62 65 73 74 29 0a 0a 09 09 20 20  oss($best)....  
1e90: 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73    log write 6 cs
1ea0: 65 74 73 20 22 42 65 73 74 20 62 72 65 61 6b 20  ets "Best break 
1eb0: 40 20 24 62 65 73 74 2c 20 63 75 74 74 69 6e 67  @ $best, cutting
1ec0: 20 5b 6e 73 70 20 24 63 72 6f 73 73 28 24 62 65   [nsp $cross($be
1ed0: 73 74 29 20 64 65 70 65 6e 64 65 6e 63 79 20 64  st) dependency d
1ee0: 65 70 65 6e 64 65 6e 63 69 65 73 5d 22 0a 0a 09  ependencies]"...
1ef0: 09 20 20 20 20 23 20 4e 6f 74 65 3a 20 54 68 65  .    # Note: The
1f00: 20 76 61 6c 75 65 20 6f 66 20 62 65 73 74 20 69   value of best i
1f10: 73 20 61 6e 20 61 62 6f 6c 75 74 65 20 6c 6f 63  s an abolute loc
1f20: 61 74 69 6f 6e 0a 09 09 20 20 20 20 23 20 69 6e  ation...    # in
1f30: 20 6d 79 69 74 65 6d 73 2e 20 55 73 65 20 74 68   myitems. Use th
1f40: 65 20 73 74 61 72 74 20 6f 66 20 63 75 72 72 65  e start of curre
1f50: 6e 74 20 74 6f 20 6d 61 6b 65 20 69 74 0a 09 09  nt to make it...
1f60: 20 20 20 20 23 20 61 6e 20 69 6e 64 65 78 20 61      # an index a
1f70: 62 73 6f 6c 75 74 65 20 74 6f 20 63 75 72 72 65  bsolute to curre
1f80: 6e 74 2e 0a 0a 09 09 20 20 20 20 73 65 74 20 62  nt.....    set b
1f90: 72 65 6c 20 5b 65 78 70 72 20 7b 24 62 65 73 74  rel [expr {$best
1fa0: 20 2d 20 5b 6c 69 6e 64 65 78 20 24 63 75 72 72   - [lindex $curr
1fb0: 65 6e 74 20 30 5d 7d 5d 0a 09 09 20 20 20 20 73  ent 0]}]...    s
1fc0: 65 74 20 62 6e 65 78 74 20 24 62 72 65 6c 20 3b  et bnext $brel ;
1fd0: 20 69 6e 63 72 20 62 6e 65 78 74 0a 09 09 20 20   incr bnext...  
1fe0: 20 20 73 65 74 20 66 72 61 67 62 65 66 6f 72 65    set fragbefore
1ff0: 20 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 6e   [lrange $curren
2000: 74 20 30 20 24 62 72 65 6c 5d 0a 09 09 20 20 20  t 0 $brel]...   
2010: 20 73 65 74 20 66 72 61 67 61 66 74 65 72 20 20   set fragafter  
2020: 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 6e 74  [lrange $current
2030: 20 24 62 6e 65 78 74 20 65 6e 64 5d 0a 0a 09 09   $bnext end]....
2040: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20      log write 6 
2050: 63 73 65 74 73 20 22 4e 65 77 20 70 69 65 63 65  csets "New piece
2060: 73 20 20 5b 50 52 20 24 66 72 61 67 62 65 66 6f  s  [PR $fragbefo
2070: 72 65 5d 20 5b 50 52 20 24 66 72 61 67 61 66 74  re] [PR $fragaft
2080: 65 72 5d 22 0a 0a 09 09 20 20 20 20 69 6e 74 65  er]"....    inte
2090: 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 5b 6c  grity assert {[l
20a0: 6c 65 6e 67 74 68 20 24 66 72 61 67 62 65 66 6f  length $fragbefo
20b0: 72 65 5d 7d 20 7b 46 6f 75 6e 64 20 7a 65 72 6f  re]} {Found zero
20c0: 2d 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 6e 74  -length fragment
20d0: 20 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e   at the beginnin
20e0: 67 7d 0a 09 09 20 20 20 20 69 6e 74 65 67 72 69  g}...    integri
20f0: 74 79 20 61 73 73 65 72 74 20 7b 5b 6c 6c 65 6e  ty assert {[llen
2100: 67 74 68 20 24 66 72 61 67 61 66 74 65 72 5d 7d  gth $fragafter]}
2110: 20 20 7b 46 6f 75 6e 64 20 7a 65 72 6f 2d 6c 65    {Found zero-le
2120: 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 20 61 74  ngth fragment at
2130: 20 74 68 65 20 65 6e 64 7d 0a 0a 09 09 20 20 20   the end}....   
2140: 20 6c 61 70 70 65 6e 64 20 6e 65 77 20 24 66 72   lappend new $fr
2150: 61 67 62 65 66 6f 72 65 20 24 66 72 61 67 61 66  agbefore $fragaf
2160: 74 65 72 0a 09 09 20 20 20 20 43 75 74 41 74 20  ter...    CutAt 
2170: 24 62 65 73 74 0a 09 09 7d 0a 0a 09 09 69 6e 63  $best...}....inc
2180: 72 20 61 74 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  r at..    }..}..
2190: 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65  .log write 6 cse
21a0: 74 73 20 22 2e 20 2e 20 2e 2e 20 2e 2e 2e 20 2e  ts ". . .. ... .
21b0: 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e 2e  .... ........ ..
21c0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 22 0a 0a 09 23  ..........."...#
21d0: 20 28 2a 29 20 57 65 20 63 6c 65 61 72 20 6f 75   (*) We clear ou
21e0: 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65 64  t the associated
21f0: 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d 79 69   part of the myi
2200: 74 65 6d 6d 61 70 0a 09 23 20 69 6e 2d 6d 65 6d  temmap..# in-mem
2210: 6f 72 79 20 69 6e 64 65 78 20 69 6e 20 70 72 65  ory index in pre
2220: 70 61 72 61 74 69 6f 6e 20 66 6f 72 20 6e 65 77  paration for new
2230: 20 64 61 74 61 2e 20 41 20 73 69 6d 70 6c 65 20   data. A simple 
2240: 75 6e 73 65 74 0a 09 23 20 69 73 20 65 6e 6f 75  unset..# is enou
2250: 67 68 2c 20 77 65 20 68 61 76 65 20 6e 6f 20 73  gh, we have no s
2260: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73  ymbol changesets
2270: 20 61 74 20 74 68 69 73 20 74 69 6d 65 2c 20 61   at this time, a
2280: 6e 64 0a 09 23 20 74 68 75 73 20 6e 65 76 65 72  nd..# thus never
2290: 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20 72   more than one r
22a0: 65 66 65 72 65 6e 63 65 20 69 6e 20 74 68 65 20  eference in the 
22b0: 6c 69 73 74 2e 0a 0a 09 66 6f 72 65 61 63 68 20  list....foreach 
22c0: 69 69 64 20 24 6d 79 69 74 65 6d 73 20 7b 0a 09  iid $myitems {..
22d0: 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c 69 73      set key [lis
22e0: 74 20 24 6d 79 74 79 70 65 20 24 69 69 64 5d 0a  t $mytype $iid].
22f0: 09 20 20 20 20 75 6e 73 65 74 20 6d 79 69 74 65  .    unset myite
2300: 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20 20 20 20  mmap($key)..    
2310: 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74  log write 8 cset
2320: 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20 3c 24 6b  s {MAP- item <$k
2330: 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73 65  ey> $self = [$se
2340: 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 0a 09 23 20  lf str]}..}...# 
2350: 43 72 65 61 74 65 20 63 68 61 6e 67 65 73 65 74  Create changeset
2360: 73 20 66 6f 72 20 74 68 65 20 66 72 61 67 6d 65  s for the fragme
2370: 6e 74 73 2c 20 72 65 75 73 69 6e 67 20 74 68 65  nts, reusing the
2380: 20 63 75 72 72 65 6e 74 20 6f 6e 65 0a 09 23 20   current one..# 
2390: 66 6f 72 20 74 68 65 20 66 69 72 73 74 20 66 72  for the first fr
23a0: 61 67 6d 65 6e 74 2e 20 57 65 20 73 6f 72 74 20  agment. We sort 
23b0: 74 68 65 6d 20 69 6e 20 6f 72 64 65 72 20 74 6f  them in order to
23c0: 20 61 6c 6c 6f 77 0a 09 23 20 63 68 65 63 6b 69   allow..# checki
23d0: 6e 67 20 66 6f 72 20 67 61 70 73 20 61 6e 64 20  ng for gaps and 
23e0: 6e 69 63 65 20 6d 65 73 73 61 67 65 73 2e 0a 0a  nice messages...
23f0: 09 73 65 74 20 66 72 61 67 6d 65 6e 74 73 20 5b  .set fragments [
2400: 6c 73 6f 72 74 20 2d 69 6e 64 65 78 20 30 20 2d  lsort -index 0 -
2410: 69 6e 74 65 67 65 72 20 24 66 72 61 67 6d 65 6e  integer $fragmen
2420: 74 73 5d 0a 0a 09 23 70 75 74 73 20 5c 74 2e 5b  ts]...#puts \t.[
2430: 6a 6f 69 6e 20 5b 50 52 73 20 24 66 72 61 67 6d  join [PRs $fragm
2440: 65 6e 74 73 5d 20 2e 5c 6e 5c 74 2e 5d 2e 0a 0a  ents] .\n\t.]...
2450: 09 42 6f 72 64 65 72 20 5b 6c 69 6e 64 65 78 20  .Border [lindex 
2460: 24 66 72 61 67 6d 65 6e 74 73 20 30 5d 20 66 69  $fragments 0] fi
2470: 72 73 74 73 20 66 69 72 73 74 65 0a 0a 09 69 6e  rsts firste...in
2480: 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b  tegrity assert {
2490: 24 66 69 72 73 74 73 20 3d 3d 20 30 7d 20 7b 42  $firsts == 0} {B
24a0: 61 64 20 66 72 61 67 6d 65 6e 74 20 73 74 61 72  ad fragment star
24b0: 74 20 40 20 24 66 69 72 73 74 73 2c 20 67 61 70  t @ $firsts, gap
24c0: 2c 20 6f 72 20 62 65 66 6f 72 65 20 62 65 67 69  , or before begi
24d0: 6e 6e 69 6e 67 20 6f 66 20 74 68 65 20 72 61 6e  nning of the ran
24e0: 67 65 7d 0a 0a 09 73 65 74 20 6c 61 73 74 65 20  ge}...set laste 
24f0: 24 66 69 72 73 74 65 0a 09 66 6f 72 65 61 63 68  $firste..foreach
2500: 20 66 72 61 67 6d 65 6e 74 20 5b 6c 72 61 6e 67   fragment [lrang
2510: 65 20 24 66 72 61 67 6d 65 6e 74 73 20 31 20 65  e $fragments 1 e
2520: 6e 64 5d 20 7b 0a 09 20 20 20 20 42 6f 72 64 65  nd] {..    Borde
2530: 72 20 24 66 72 61 67 6d 65 6e 74 20 73 20 65 0a  r $fragment s e.
2540: 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61  .    integrity a
2550: 73 73 65 72 74 20 7b 24 6c 61 73 74 65 20 3d 3d  ssert {$laste ==
2560: 20 28 24 73 20 2d 20 31 29 7d 20 7b 42 61 64 20   ($s - 1)} {Bad 
2570: 66 72 61 67 6d 65 6e 74 20 62 6f 72 64 65 72 20  fragment border 
2580: 3c 24 6c 61 73 74 65 20 7c 20 24 73 3e 2c 20 67  <$laste | $s>, g
2590: 61 70 20 6f 72 20 6f 76 65 72 6c 61 70 7d 0a 0a  ap or overlap}..
25a0: 09 20 20 20 20 73 65 74 20 6e 65 77 20 5b 24 74  .    set new [$t
25b0: 79 70 65 20 25 41 55 54 4f 25 20 24 6d 79 70 72  ype %AUTO% $mypr
25c0: 6f 6a 65 63 74 20 24 6d 79 74 79 70 65 20 24 6d  oject $mytype $m
25d0: 79 73 72 63 69 64 20 5b 6c 72 61 6e 67 65 20 24  ysrcid [lrange $
25e0: 6d 79 69 74 65 6d 73 20 24 73 20 24 65 5d 5d 0a  myitems $s $e]].
25f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c 6f 67  .            log
2600: 20 77 72 69 74 65 20 34 20 63 73 65 74 73 20 22   write 4 csets "
2610: 42 72 65 61 6b 69 6e 67 20 5b 24 73 65 6c 66 20  Breaking [$self 
2620: 73 74 72 20 5d 20 40 20 24 6c 61 73 74 65 2c 20  str ] @ $laste, 
2630: 6e 65 77 20 5b 24 6e 65 77 20 73 74 72 5d 2c 20  new [$new str], 
2640: 63 75 74 74 69 6e 67 20 24 62 72 65 61 6b 73 28  cutting $breaks(
2650: 24 6c 61 73 74 65 29 22 0a 0a 09 20 20 20 20 73  $laste)"...    s
2660: 65 74 20 6c 61 73 74 65 20 24 65 0a 09 7d 0a 0a  et laste $e..}..
2670: 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72  .integrity asser
2680: 74 20 7b 0a 09 20 20 20 20 24 6c 61 73 74 65 20  t {..    $laste 
2690: 3d 3d 20 28 5b 6c 6c 65 6e 67 74 68 20 24 6d 79  == ([llength $my
26a0: 69 74 65 6d 73 5d 2d 31 29 0a 09 7d 20 7b 42 61  items]-1)..} {Ba
26b0: 64 20 66 72 61 67 6d 65 6e 74 20 65 6e 64 20 40  d fragment end @
26c0: 20 24 6c 61 73 74 65 2c 20 67 61 70 2c 20 6f 72   $laste, gap, or
26d0: 20 62 65 79 6f 6e 64 20 65 6e 64 20 6f 66 20 74   beyond end of t
26e0: 68 65 20 72 61 6e 67 65 7d 0a 0a 09 23 20 50 75  he range}...# Pu
26f0: 74 20 74 68 65 20 66 69 72 73 74 20 66 72 61 67  t the first frag
2700: 6d 65 6e 74 20 69 6e 74 6f 20 74 68 65 20 63 75  ment into the cu
2710: 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2c  rrent changeset,
2720: 20 61 6e 64 0a 09 23 20 75 70 64 61 74 65 20 74   and..# update t
2730: 68 65 20 69 6e 2d 6d 65 6d 6f 72 79 20 69 6e 64  he in-memory ind
2740: 65 78 2e 20 57 65 20 63 61 6e 20 73 69 6d 70 6c  ex. We can simpl
2750: 79 20 28 72 65 29 61 64 64 20 74 68 65 20 69 74  y (re)add the it
2760: 65 6d 73 0a 09 23 20 62 65 63 61 75 73 65 20 77  ems..# because w
2770: 65 20 63 6c 65 61 72 65 64 20 74 68 65 20 70 72  e cleared the pr
2780: 65 76 69 6f 75 73 6c 79 20 65 78 69 73 74 69 6e  eviously existin
2790: 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20 73  g information, s
27a0: 65 65 0a 09 23 20 28 2a 29 20 61 62 6f 76 65 2e  ee..# (*) above.
27b0: 20 50 65 72 73 69 73 74 65 6e 63 65 20 64 6f 65   Persistence doe
27c0: 73 20 6e 6f 74 20 6d 61 74 74 65 72 20 68 65 72  s not matter her
27d0: 65 2c 20 6e 6f 6e 65 20 6f 66 20 74 68 65 0a 09  e, none of the..
27e0: 23 20 63 68 61 6e 67 65 73 65 74 73 20 68 61 73  # changesets has
27f0: 20 62 65 65 6e 20 73 61 76 65 64 20 74 6f 20 74   been saved to t
2800: 68 65 20 70 65 72 73 69 73 74 65 6e 74 20 73 74  he persistent st
2810: 61 74 65 20 79 65 74 2e 0a 0a 09 73 65 74 20 6d  ate yet....set m
2820: 79 69 74 65 6d 73 20 20 5b 6c 72 61 6e 67 65 20  yitems  [lrange 
2830: 24 6d 79 69 74 65 6d 73 20 20 30 20 24 66 69 72  $myitems  0 $fir
2840: 73 74 65 5d 0a 09 73 65 74 20 6d 79 74 69 74 65  ste]..set mytite
2850: 6d 73 20 5b 6c 72 61 6e 67 65 20 24 6d 79 74 69  ms [lrange $myti
2860: 74 65 6d 73 20 30 20 24 66 69 72 73 74 65 5d 0a  tems 0 $firste].
2870: 09 66 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79  .foreach iid $my
2880: 69 74 65 6d 73 20 7b 0a 09 20 20 20 20 73 65 74  items {..    set
2890: 20 6b 65 79 20 5b 6c 69 73 74 20 24 6d 79 74 79   key [list $myty
28a0: 70 65 20 24 69 69 64 5d 0a 09 20 20 20 20 73 65  pe $iid]..    se
28b0: 74 20 6d 79 69 74 65 6d 6d 61 70 28 24 6b 65 79  t myitemmap($key
28c0: 29 20 24 73 65 6c 66 0a 09 20 20 20 20 6c 6f 67  ) $self..    log
28d0: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b   write 8 csets {
28e0: 4d 41 50 2b 20 69 74 65 6d 20 3c 24 6b 65 79 3e  MAP+ item <$key>
28f0: 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c 66 20   $self = [$self 
2900: 73 74 72 5d 7d 0a 09 7d 0a 0a 09 72 65 74 75 72  str]}..}...retur
2910: 6e 20 31 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d  n 1.    }..    m
2920: 65 74 68 6f 64 20 70 65 72 73 69 73 74 20 7b 7d  ethod persist {}
2930: 20 7b 0a 09 73 65 74 20 74 69 64 20 24 6d 79 63   {..set tid $myc
2940: 73 74 79 70 65 28 24 6d 79 74 79 70 65 29 0a 09  stype($mytype)..
2950: 73 65 74 20 70 69 64 20 5b 24 6d 79 70 72 6f 6a  set pid [$myproj
2960: 65 63 74 20 69 64 5d 0a 09 73 65 74 20 70 6f 73  ect id]..set pos
2970: 20 30 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73   0...state trans
2980: 61 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74  action {..    st
2990: 61 74 65 20 72 75 6e 20 7b 0a 09 09 49 4e 53 45  ate run {...INSE
29a0: 52 54 20 49 4e 54 4f 20 63 68 61 6e 67 65 73 65  RT INTO changese
29b0: 74 20 28 63 69 64 2c 20 20 20 70 69 64 2c 20 20  t (cid,   pid,  
29c0: 74 79 70 65 2c 20 73 72 63 29 0a 09 09 56 41 4c  type, src)...VAL
29d0: 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20  UES             
29e0: 20 20 20 28 24 6d 79 69 64 2c 20 24 70 69 64 2c     ($myid, $pid,
29f0: 20 24 74 69 64 2c 20 24 6d 79 73 72 63 69 64 29   $tid, $mysrcid)
2a00: 3b 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20 66  ;..    }...    f
2a10: 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79 69 74  oreach iid $myit
2a20: 65 6d 73 20 7b 0a 09 09 73 74 61 74 65 20 72 75  ems {...state ru
2a30: 6e 20 7b 0a 09 09 20 20 20 20 49 4e 53 45 52 54  n {...    INSERT
2a40: 20 49 4e 54 4f 20 63 73 69 74 65 6d 20 28 63 69   INTO csitem (ci
2a50: 64 2c 20 20 20 70 6f 73 2c 20 20 69 69 64 29 0a  d,   pos,  iid).
2a60: 09 09 20 20 20 20 56 41 4c 55 45 53 20 20 20 20  ..    VALUES    
2a70: 20 20 20 20 20 20 20 20 20 28 24 6d 79 69 64 2c           ($myid,
2a80: 20 24 70 6f 73 2c 20 24 69 69 64 29 3b 0a 09 09   $pos, $iid);...
2a90: 7d 0a 09 09 69 6e 63 72 20 70 6f 73 0a 09 20 20  }...incr pos..  
2aa0: 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20    }..}..return. 
2ab0: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64     }..    method
2ac0: 20 74 69 6d 65 72 61 6e 67 65 20 7b 7d 20 7b 20   timerange {} { 
2ad0: 72 65 74 75 72 6e 20 5b 24 6d 79 74 79 70 65 6f  return [$mytypeo
2ae0: 62 6a 20 74 69 6d 65 72 61 6e 67 65 20 24 6d 79  bj timerange $my
2af0: 69 74 65 6d 73 5d 20 7d 0a 0a 20 20 20 20 6d 65  items] }..    me
2b00: 74 68 6f 64 20 6c 69 6d 69 74 73 20 7b 7d 20 7b  thod limits {} {
2b10: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61  ..struct::list a
2b20: 73 73 69 67 6e 20 5b 24 6d 79 74 79 70 65 6f 62  ssign [$mytypeob
2b30: 6a 20 6c 69 6d 69 74 73 20 24 6d 79 69 74 65 6d  j limits $myitem
2b40: 73 5d 20 6d 61 78 70 20 6d 69 6e 73 0a 09 72 65  s] maxp mins..re
2b50: 74 75 72 6e 20 5b 6c 69 73 74 20 5b 54 61 67 49  turn [list [TagI
2b60: 74 65 6d 44 69 63 74 20 24 6d 61 78 70 20 24 6d  temDict $maxp $m
2b70: 79 74 79 70 65 5d 20 5b 54 61 67 49 74 65 6d 44  ytype] [TagItemD
2b80: 69 63 74 20 24 6d 69 6e 73 20 24 6d 79 74 79 70  ict $mins $mytyp
2b90: 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d  e]].    }..    m
2ba0: 65 74 68 6f 64 20 64 72 6f 70 20 7b 7d 20 7b 0a  ethod drop {} {.
2bb0: 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65  .log write 8 cse
2bc0: 74 73 20 7b 44 72 6f 70 70 69 6e 67 20 24 73 65  ts {Dropping $se
2bd0: 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d  lf = [$self str]
2be0: 7d 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73 61  }...state transa
2bf0: 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74 61  ction {..    sta
2c00: 74 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54  te run {...DELET
2c10: 45 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65 74  E FROM changeset
2c20: 20 20 20 57 48 45 52 45 20 63 69 64 20 3d 20 24     WHERE cid = $
2c30: 6d 79 69 64 3b 0a 09 09 44 45 4c 45 54 45 20 46  myid;...DELETE F
2c40: 52 4f 4d 20 63 73 69 74 65 6d 20 20 20 20 20 20  ROM csitem      
2c50: 57 48 45 52 45 20 63 69 64 20 3d 20 24 6d 79 69  WHERE cid = $myi
2c60: 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f 4d  d;...DELETE FROM
2c70: 20 63 73 73 75 63 63 65 73 73 6f 72 20 57 48 45   cssuccessor WHE
2c80: 52 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b 0a  RE cid = $myid;.
2c90: 09 20 20 20 20 7d 0a 09 7d 0a 09 66 6f 72 65 61  .    }..}..forea
2ca0: 63 68 20 69 69 64 20 24 6d 79 69 74 65 6d 73 20  ch iid $myitems 
2cb0: 7b 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b  {..    set key [
2cc0: 6c 69 73 74 20 24 6d 79 74 79 70 65 20 24 69 69  list $mytype $ii
2cd0: 64 5d 0a 09 20 20 20 20 75 6e 73 65 74 20 6d 79  d]..    unset my
2ce0: 69 74 65 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20  itemmap($key).. 
2cf0: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63     log write 8 c
2d00: 73 65 74 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20  sets {MAP- item 
2d10: 3c 24 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b  <$key> $self = [
2d20: 24 73 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 09  $self str]}..}..
2d30: 73 65 74 20 70 6f 73 20 20 20 20 20 20 20 20 20  set pos         
2d40: 20 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 63 74   [lsearch -exact
2d50: 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20 24   $mychangesets $
2d60: 73 65 6c 66 5d 0a 09 73 65 74 20 6d 79 63 68 61  self]..set mycha
2d70: 6e 67 65 73 65 74 73 20 5b 6c 72 65 70 6c 61 63  ngesets [lreplac
2d80: 65 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20  e $mychangesets 
2d90: 24 70 6f 73 20 24 70 6f 73 5d 0a 09 73 65 74 20  $pos $pos]..set 
2da0: 70 6f 73 20 20 20 20 20 20 20 20 20 20 20 20 20  pos             
2db0: 20 20 20 20 20 20 20 5b 6c 73 65 61 72 63 68 20         [lsearch 
2dc0: 2d 65 78 61 63 74 20 24 6d 79 74 63 68 61 6e 67  -exact $mytchang
2dd0: 65 73 65 74 73 28 24 6d 79 74 79 70 65 29 20 24  esets($mytype) $
2de0: 73 65 6c 66 5d 0a 09 73 65 74 20 6d 79 74 63 68  self]..set mytch
2df0: 61 6e 67 65 73 65 74 73 28 24 6d 79 74 79 70 65  angesets($mytype
2e00: 29 20 5b 6c 72 65 70 6c 61 63 65 20 24 6d 79 74  ) [lreplace $myt
2e10: 63 68 61 6e 67 65 73 65 74 73 28 24 6d 79 74 79  changesets($myty
2e20: 70 65 29 20 24 70 6f 73 20 24 70 6f 73 5d 0a 0a  pe) $pos $pos]..
2e30: 09 23 20 52 65 74 75 72 6e 20 74 68 65 20 6c 69  .# Return the li
2e40: 73 74 20 6f 66 20 70 72 65 64 65 63 65 73 73 6f  st of predecesso
2e50: 72 73 20 73 6f 20 74 68 61 74 20 74 68 65 79 20  rs so that they 
2e60: 63 61 6e 20 62 65 20 61 64 6a 75 73 74 65 64 2e  can be adjusted.
2e70: 0a 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74  ..return [struct
2e80: 3a 3a 6c 69 73 74 20 6d 61 70 20 5b 73 74 61 74  ::list map [stat
2e90: 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c  e run {..    SEL
2ea0: 45 43 54 20 63 69 64 0a 09 20 20 20 20 46 52 4f  ECT cid..    FRO
2eb0: 4d 20 20 20 63 73 73 75 63 63 65 73 73 6f 72 0a  M   cssuccessor.
2ec0: 09 20 20 20 20 57 48 45 52 45 20 20 6e 69 64 20  .    WHERE  nid 
2ed0: 3d 20 24 6d 79 69 64 0a 09 7d 5d 20 5b 6d 79 74  = $myid..}] [myt
2ee0: 79 70 65 6d 65 74 68 6f 64 20 6f 66 5d 5d 0a 20  ypemethod of]]. 
2ef0: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64     }..    method
2f00: 20 72 65 70 6f 72 74 6c 6f 6f 70 20 7b 7b 6b 69   reportloop {{ki
2f10: 6c 6c 20 31 7d 7d 20 7b 0a 09 23 20 57 65 20 70  ll 1}} {..# We p
2f20: 72 69 6e 74 20 74 68 65 20 69 74 65 6d 73 20 77  rint the items w
2f30: 68 69 63 68 20 61 72 65 20 70 72 6f 64 75 63 69  hich are produci
2f40: 6e 67 20 74 68 65 20 6c 6f 6f 70 2c 20 61 6e 64  ng the loop, and
2f50: 20 68 6f 77 2e 0a 0a 09 73 65 74 20 68 64 72 20   how....set hdr 
2f60: 22 53 65 6c 66 2d 72 65 66 65 72 65 6e 74 69 61  "Self-referentia
2f70: 6c 20 63 68 61 6e 67 65 73 65 74 20 5b 24 73 65  l changeset [$se
2f80: 6c 66 20 73 74 72 5d 20 5f 5f 5f 5f 5f 5f 5f 5f  lf str] ________
2f90: 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 22 0a 09 73 65 74  __________"..set
2fa0: 20 66 74 72 20 5b 72 65 67 73 75 62 20 2d 61 6c   ftr [regsub -al
2fb0: 6c 20 7b 5b 5e 20 09 5d 7d 20 24 68 64 72 20 7b  l {[^ .]} $hdr {
2fc0: 5f 7d 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  _}]...log write 
2fd0: 30 20 63 73 65 74 73 20 24 68 64 72 0a 09 66 6f  0 csets $hdr..fo
2fe0: 72 65 61 63 68 20 7b 69 74 65 6d 20 6e 65 78 74  reach {item next
2ff0: 69 74 65 6d 7d 20 5b 24 6d 79 74 79 70 65 6f 62  item} [$mytypeob
3000: 6a 20 6c 6f 6f 70 73 20 24 6d 79 69 74 65 6d 73  j loops $myitems
3010: 5d 20 7b 0a 09 20 20 20 20 23 20 43 72 65 61 74  ] {..    # Creat
3020: 65 20 74 61 67 67 65 64 20 69 74 65 6d 73 20 66  e tagged items f
3030: 72 6f 6d 20 74 68 65 20 69 64 20 61 6e 64 20 6f  rom the id and o
3040: 75 72 20 74 79 70 65 2e 0a 09 20 20 20 20 73 65  ur type...    se
3050: 74 20 69 74 65 6d 20 20 20 20 20 5b 6c 69 73 74  t item     [list
3060: 20 24 6d 79 74 79 70 65 20 20 24 69 74 65 6d 5d   $mytype  $item]
3070: 0a 09 20 20 20 20 73 65 74 20 6e 65 78 74 69 74  ..    set nextit
3080: 65 6d 20 5b 6c 69 73 74 20 24 6d 79 74 79 70 65  em [list $mytype
3090: 20 24 6e 65 78 74 69 74 65 6d 5d 0a 09 20 20 20   $nextitem]..   
30a0: 20 23 20 50 72 69 6e 74 61 62 6c 65 20 6c 61 62   # Printable lab
30b0: 65 6c 73 2e 0a 09 20 20 20 20 73 65 74 20 69 20  els...    set i 
30c0: 20 22 3c 5b 24 74 79 70 65 20 69 74 65 6d 73 74   "<[$type itemst
30d0: 72 20 24 69 74 65 6d 5d 3e 22 0a 09 20 20 20 20  r $item]>"..    
30e0: 73 65 74 20 6e 20 20 22 3c 5b 24 74 79 70 65 20  set n  "<[$type 
30f0: 69 74 65 6d 73 74 72 20 24 6e 65 78 74 69 74 65  itemstr $nextite
3100: 6d 5d 3e 22 0a 09 20 20 20 20 73 65 74 20 6e 63  m]>"..    set nc
3110: 73 20 24 6d 79 69 74 65 6d 6d 61 70 28 24 6e 65  s $myitemmap($ne
3120: 78 74 69 74 65 6d 29 0a 09 20 20 20 20 23 20 50  xtitem)..    # P
3130: 72 69 6e 74 0a 09 20 20 20 20 6c 6f 67 20 77 72  rint..    log wr
3140: 69 74 65 20 30 20 63 73 65 74 73 20 7b 2a 20 24  ite 0 csets {* $
3150: 69 20 2d 2d 3e 20 24 6e 20 2d 2d 3e 20 63 73 20  i --> $n --> cs 
3160: 5b 24 6e 63 73 20 73 74 72 5d 7d 0a 09 7d 0a 09  [$ncs str]}..}..
3170: 6c 6f 67 20 77 72 69 74 65 20 30 20 63 73 65 74  log write 0 cset
3180: 73 20 24 66 74 72 0a 0a 09 69 66 20 7b 21 24 6b  s $ftr...if {!$k
3190: 69 6c 6c 7d 20 72 65 74 75 72 6e 0a 09 74 72 6f  ill} return..tro
31a0: 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 22 5b  uble internal "[
31b0: 24 73 65 6c 66 20 73 74 72 5d 20 64 65 70 65 6e  $self str] depen
31c0: 64 73 20 6f 6e 20 69 74 73 65 6c 66 22 0a 09 72  ds on itself"..r
31d0: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
31e0: 20 6d 65 74 68 6f 64 20 70 75 73 68 74 6f 20 7b   method pushto {
31f0: 73 76 20 72 65 70 6f 73 69 74 6f 72 79 20 64 61  sv repository da
3200: 74 65 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24  te} {..upvar 1 $
3210: 73 76 20 73 74 61 74 65 0a 0a 09 23 20 47 65 6e  sv state...# Gen
3220: 65 72 61 74 65 20 61 6e 64 20 69 6d 70 6f 72 74  erate and import
3230: 20 74 68 65 20 6d 61 6e 69 66 65 73 74 20 66 6f   the manifest fo
3240: 72 20 74 68 69 73 20 63 68 61 6e 67 65 73 65 74  r this changeset
3250: 2e 0a 09 23 0a 09 23 20 44 61 74 61 20 6e 65 65  ...#..# Data nee
3260: 64 65 64 3a 0a 09 23 20 2d 20 43 6f 6d 6d 69 74  ded:..# - Commit
3270: 20 6d 65 73 73 61 67 65 20 20 20 20 20 20 20 20   message        
3280: 20 20 20 20 20 20 20 28 2d 2d 20 6d 79 73 72 63         (-- mysrc
3290: 69 64 20 2d 3e 20 72 65 70 6f 73 69 74 6f 72 79  id -> repository
32a0: 20 6d 65 74 61 29 0a 09 23 20 2d 20 55 73 65 72   meta)..# - User
32b0: 20 64 6f 69 6e 67 20 74 68 65 20 63 6f 6d 6d 69   doing the commi
32c0: 74 20 20 20 20 20 20 20 20 28 73 2e 61 2e 29 0a  t        (s.a.).
32d0: 09 23 0a 09 23 20 2d 20 54 69 6d 65 73 74 61 6d  .#..# - Timestam
32e0: 70 20 6f 66 20 77 68 65 6e 20 63 6f 6d 6d 69 74  p of when commit
32f0: 74 65 64 20 20 28 63 6f 6d 6d 61 6e 64 20 61 72  ted  (command ar
3300: 67 75 6d 65 6e 74 29 0a 09 23 0a 09 23 20 2d 20  gument)..#..# - 
3310: 54 68 65 20 70 61 72 65 6e 74 20 63 68 61 6e 67  The parent chang
3320: 65 73 65 74 2c 20 69 66 20 61 6e 79 2e 20 49 66  eset, if any. If
3330: 20 74 68 65 72 65 20 69 73 20 6e 6f 20 70 61 72   there is no par
3340: 65 6e 74 20 66 6f 73 73 69 6c 0a 09 23 20 20 20  ent fossil..#   
3350: 77 69 6c 6c 20 75 73 65 20 74 68 65 20 65 6d 70  will use the emp
3360: 74 79 20 62 61 73 65 20 72 65 76 69 73 69 6f 6e  ty base revision
3370: 20 61 73 20 70 61 72 65 6e 74 2e 0a 09 23 0a 09   as parent...#..
3380: 23 20 2d 20 4c 69 73 74 20 6f 66 20 74 68 65 20  # - List of the 
3390: 66 69 6c 65 20 72 65 76 69 73 69 6f 6e 73 20 69  file revisions i
33a0: 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2e  n the changeset.
33b0: 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  ...struct::list 
33c0: 61 73 73 69 67 6e 20 5b 24 6d 79 70 72 6f 6a 65  assign [$myproje
33d0: 63 74 20 67 65 74 6d 65 74 61 20 24 6d 79 73 72  ct getmeta $mysr
33e0: 63 69 64 5d 20 5f 5f 20 62 72 61 6e 63 68 20 75  cid] __ branch u
33f0: 73 65 72 20 6d 65 73 73 61 67 65 0a 09 73 74 72  ser message..str
3400: 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e  uct::list assign
3410: 20 24 62 72 61 6e 63 68 20 5f 5f 20 6c 6f 64 6e   $branch __ lodn
3420: 61 6d 65 0a 0a 09 23 20 50 65 72 66 6f 72 6d 20  ame...# Perform 
3430: 74 68 65 20 69 6d 70 6f 72 74 2e 20 41 73 20 70  the import. As p
3440: 61 72 74 20 6f 66 20 74 68 61 74 20 77 65 20 64  art of that we d
3450: 65 74 65 72 6d 69 6e 65 20 74 68 65 20 70 61 72  etermine the par
3460: 65 6e 74 0a 09 23 20 77 65 20 6e 65 65 64 2c 20  ent..# we need, 
3470: 61 6e 64 20 63 6f 6e 76 65 72 74 20 74 68 65 20  and convert the 
3480: 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20 69 6e  list of items in
3490: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 69   the changeset i
34a0: 6e 74 6f 0a 09 23 20 75 75 69 64 73 20 61 6e 64  nto..# uuids and
34b0: 20 70 72 69 6e 74 61 62 6c 65 20 64 61 74 61 2e   printable data.
34c0: 0a 0a 09 73 65 74 20 75 75 69 64 20 5b 55 70 64  ...set uuid [Upd
34d0: 61 74 65 73 74 61 74 65 20 73 74 61 74 65 20 24  atestate state $
34e0: 6c 6f 64 6e 61 6d 65 20 5c 0a 09 09 20 20 20 20  lodname \...    
34f0: 20 20 5b 24 72 65 70 6f 73 69 74 6f 72 79 20 69    [$repository i
3500: 6d 70 6f 72 74 72 65 76 69 73 69 6f 6e 20 5b 24  mportrevision [$
3510: 73 65 6c 66 20 73 74 72 5d 20 5c 0a 09 09 09 20  self str] \.... 
3520: 20 20 24 75 73 65 72 20 24 6d 65 73 73 61 67 65    $user $message
3530: 20 24 64 61 74 65 20 5c 0a 09 09 09 20 20 20 5b   $date \....   [
3540: 47 65 74 70 61 72 65 6e 74 20 73 74 61 74 65 20  Getparent state 
3550: 24 6c 6f 64 6e 61 6d 65 20 24 6d 79 70 72 6f 6a  $lodname $myproj
3560: 65 63 74 5d 20 5c 0a 09 09 09 20 20 20 5b 47 65  ect] \....   [Ge
3570: 74 72 65 76 69 73 69 6f 6e 69 6e 66 6f 20 24 6d  trevisioninfo $m
3580: 79 69 74 65 6d 73 5d 5d 5d 0a 0a 09 23 20 52 65  yitems]]]...# Re
3590: 6d 65 6d 62 65 72 20 74 68 65 20 77 68 6f 6c 65  member the whole
35a0: 20 63 68 61 6e 67 65 73 65 74 20 2f 20 75 75 69   changeset / uui
35b0: 64 20 6d 61 70 70 69 6e 67 2c 20 66 6f 72 20 74  d mapping, for t
35c0: 68 65 20 74 61 67 73 2e 0a 0a 09 73 74 61 74 65  he tags....state
35d0: 20 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45   run {..    INSE
35e0: 52 54 20 49 4e 54 4f 20 63 73 75 75 69 64 20 28  RT INTO csuuid (
35f0: 63 69 64 2c 20 20 20 75 75 69 64 29 0a 09 20 20  cid,   uuid)..  
3600: 20 20 56 41 4c 55 45 53 20 20 20 20 20 20 20 20    VALUES        
3610: 20 20 20 20 20 28 24 6d 79 69 64 2c 20 24 75 75       ($myid, $uu
3620: 69 64 29 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20  id)..}..return. 
3630: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 47     }..    proc G
3640: 65 74 72 65 76 69 73 69 6f 6e 69 6e 66 6f 20 7b  etrevisioninfo {
3650: 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 73 65  revisions} {..se
3660: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
3670: 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27   $revisions {','
3680: 7d 5d 27 29 0a 09 73 65 74 20 72 65 76 69 73 69  }]')..set revisi
3690: 6f 6e 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20  ons {}..foreach 
36a0: 7b 66 72 69 64 20 70 61 74 68 20 66 6e 61 6d 65  {frid path fname
36b0: 20 72 65 76 6e 72 7d 20 5b 73 74 61 74 65 20 72   revnr} [state r
36c0: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d  un [subst -nocom
36d0: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61  mands -nobacksla
36e0: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45  shes {..    SELE
36f0: 43 54 20 55 2e 75 75 69 64 2c 20 46 2e 76 69 73  CT U.uuid, F.vis
3700: 69 62 6c 65 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e  ible, F.name, R.
3710: 72 65 76 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  rev..    FROM   
3720: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 75  revision R, revu
3730: 75 69 64 20 55 2c 20 66 69 6c 65 20 46 0a 09 20  uid U, file F.. 
3740: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
3750: 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d 20 41  IN $theset  -- A
3760: 6c 6c 20 73 70 65 63 69 66 69 65 64 20 72 65 76  ll specified rev
3770: 69 73 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20  isions..    AND 
3780: 20 20 20 55 2e 72 69 64 20 3d 20 52 2e 72 69 64     U.rid = R.rid
3790: 20 20 20 20 20 2d 2d 20 67 65 74 20 66 6f 73 73       -- get foss
37a0: 69 6c 20 75 75 69 64 20 6f 66 20 72 65 76 69 73  il uuid of revis
37b0: 69 6f 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ion..    AND    
37c0: 46 2e 66 69 64 20 3d 20 52 2e 66 69 64 20 20 20  F.fid = R.fid   
37d0: 20 20 2d 2d 20 67 65 74 20 66 69 6c 65 20 6f 66    -- get file of
37e0: 20 72 65 76 69 73 69 6f 6e 0a 09 7d 5d 5d 20 7b   revision..}]] {
37f0: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 72 65  ..    lappend re
3800: 76 69 73 69 6f 6e 73 20 24 66 72 69 64 20 24 70  visions $frid $p
3810: 61 74 68 20 24 66 6e 61 6d 65 2f 24 72 65 76 6e  ath $fname/$revn
3820: 72 0a 09 7d 0a 09 72 65 74 75 72 6e 20 24 72 65  r..}..return $re
3830: 76 69 73 69 6f 6e 73 0a 20 20 20 20 7d 0a 0a 20  visions.    }.. 
3840: 20 20 20 70 72 6f 63 20 47 65 74 70 61 72 65 6e     proc Getparen
3850: 74 20 7b 73 76 20 6c 6f 64 6e 61 6d 65 20 70 72  t {sv lodname pr
3860: 6f 6a 65 63 74 7d 20 7b 0a 09 75 70 76 61 72 20  oject} {..upvar 
3870: 31 20 24 73 76 20 73 74 61 74 65 0a 0a 09 73 74  1 $sv state...st
3880: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
3890: 6e 20 5b 47 65 74 69 73 64 65 66 61 75 6c 74 20  n [Getisdefault 
38a0: 24 6d 79 69 74 65 6d 73 5d 20 69 73 64 65 66 61  $myitems] isdefa
38b0: 75 6c 74 20 6c 61 73 74 64 65 66 61 75 6c 74 6f  ult lastdefaulto
38c0: 6e 74 72 75 6e 6b 0a 0a 09 23 20 53 65 65 20 28  ntrunk...# See (
38d0: 61 29 20 62 65 6c 6f 77 2c 20 77 65 20 68 61 76  a) below, we hav
38e0: 65 20 74 6f 20 72 65 6d 65 6d 62 65 72 20 69 66  e to remember if
38f0: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 69   the changeset i
3900: 73 20 6c 61 73 74 0a 09 23 20 6f 6e 20 76 65 6e  s last..# on ven
3910: 64 6f 72 20 62 72 61 6e 63 68 20 61 6c 73 6f 20  dor branch also 
3920: 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75  belonging to tru
3930: 6e 6b 20 65 76 65 6e 20 69 66 20 77 65 20 66 69  nk even if we fi
3940: 6e 64 20 61 0a 09 23 20 70 61 72 65 6e 74 20 69  nd a..# parent i
3950: 6e 20 74 68 65 20 73 74 61 74 65 2e 20 54 68 65  n the state. The
3960: 20 63 61 6c 6c 65 72 20 77 69 6c 6c 20 6c 61 74   caller will lat
3970: 65 72 20 28 61 66 74 65 72 20 69 6d 70 6f 72 74  er (after import
3980: 29 0a 09 23 20 6d 61 6b 65 20 75 73 20 74 68 65  )..# make us the
3990: 20 66 69 72 73 74 20 74 72 75 6e 6b 20 63 68 61   first trunk cha
39a0: 6e 67 65 73 65 74 20 69 6e 20 74 68 65 20 73 74  ngeset in the st
39b0: 61 74 65 20 28 53 65 65 20 28 2a 2a 29 29 2e 0a  ate (See (**))..
39c0: 0a 09 69 66 20 7b 24 6c 61 73 74 64 65 66 61 75  ..if {$lastdefau
39d0: 6c 74 6f 6e 74 72 75 6e 6b 7d 20 7b 0a 09 20 20  ltontrunk} {..  
39e0: 20 20 73 65 74 20 73 74 61 74 65 28 3a 76 65 6e    set state(:ven
39f0: 64 6f 72 3a 6c 61 73 74 3a 29 20 2e 0a 09 7d 0a  dor:last:) ...}.
3a00: 0a 09 23 20 54 68 65 20 73 74 61 74 65 20 61 72  ..# The state ar
3a10: 72 61 79 20 68 6f 6c 64 73 20 66 6f 72 20 65 61  ray holds for ea
3a20: 63 68 20 6c 69 6e 65 2d 6f 66 2d 64 65 76 65 6c  ch line-of-devel
3a30: 6f 70 6d 65 6e 74 20 28 4c 4f 44 29 20 74 68 65  opment (LOD) the
3a40: 0a 09 23 20 6c 61 73 74 20 63 6f 6d 6d 69 74 74  ..# last committ
3a50: 65 64 20 63 68 61 6e 67 65 73 65 74 20 62 65 6c  ed changeset bel
3a60: 6f 6e 67 69 6e 67 20 74 6f 20 74 68 61 74 20 4c  onging to that L
3a70: 4f 44 2e 0a 0a 09 23 20 28 2a 29 20 53 74 61 6e  OD....# (*) Stan
3a80: 64 61 72 64 20 68 61 6e 64 6c 69 6e 67 20 69 66  dard handling if
3a90: 20 69 6e 2d 4c 4f 44 20 63 68 61 6e 67 65 73 65   in-LOD changese
3aa0: 74 73 2e 20 49 66 20 74 68 65 20 4c 4f 44 20 6f  ts. If the LOD o
3ab0: 66 0a 09 23 20 20 20 20 20 74 68 65 20 63 75 72  f..#     the cur
3ac0: 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 20 65  rent changeset e
3ad0: 78 69 73 74 73 20 69 6e 20 74 68 65 20 73 74 61  xists in the sta
3ae0: 74 65 20 28 3d 20 68 61 73 20 62 65 65 6e 0a 09  te (= has been..
3af0: 23 20 20 20 20 20 63 6f 6d 6d 69 74 74 65 64 20  #     committed 
3b00: 74 6f 29 20 74 68 65 6e 20 74 68 65 20 73 74 6f  to) then the sto
3b10: 72 65 64 20 63 68 61 6e 67 65 73 65 74 20 69 73  red changeset is
3b20: 20 74 68 65 20 70 61 72 65 6e 74 20 77 65 0a 09   the parent we..
3b30: 23 20 20 20 20 20 61 72 65 20 6c 6f 6f 6b 69 6e  #     are lookin
3b40: 67 20 66 6f 72 2e 0a 0a 09 69 66 20 7b 5b 69 6e  g for....if {[in
3b50: 66 6f 20 65 78 69 73 74 73 20 73 74 61 74 65 28  fo exists state(
3b60: 24 6c 6f 64 6e 61 6d 65 29 5d 7d 20 7b 0a 09 20  $lodname)]} {.. 
3b70: 20 20 20 72 65 74 75 72 6e 20 24 73 74 61 74 65     return $state
3b80: 28 24 6c 6f 64 6e 61 6d 65 29 0a 09 7d 0a 0a 09  ($lodname)..}...
3b90: 23 20 49 66 20 74 68 65 20 4c 4f 44 20 69 73 20  # If the LOD is 
3ba0: 6e 6f 74 20 79 65 74 20 6b 6e 6f 77 6e 20 74 68  not yet known th
3bb0: 65 20 63 75 72 72 65 6e 74 20 63 68 61 6e 67 65  e current change
3bc0: 73 65 74 20 63 61 6e 20 65 69 74 68 65 72 0a 09  set can either..
3bd0: 23 20 62 65 0a 09 23 20 28 61 29 20 74 68 65 20  # be..# (a) the 
3be0: 72 6f 6f 74 20 6f 66 20 61 20 76 65 6e 64 6f 72  root of a vendor
3bf0: 20 62 72 61 6e 63 68 2c 0a 09 23 20 28 62 29 20   branch,..# (b) 
3c00: 74 68 65 20 72 6f 6f 74 20 6f 66 20 74 68 65 20  the root of the 
3c10: 74 72 75 6e 6b 20 4c 4f 44 2c 20 6f 72 0a 09 23  trunk LOD, or..#
3c20: 20 28 63 29 20 74 68 65 20 66 69 72 73 74 20 63   (c) the first c
3c30: 68 61 6e 67 65 73 65 74 20 69 6e 20 61 20 6e 65  hangeset in a ne
3c40: 77 20 4c 4f 44 20 77 68 69 63 68 20 77 61 73 20  w LOD which was 
3c50: 73 70 61 77 6e 65 64 20 66 72 6f 6d 0a 09 23 20  spawned from..# 
3c60: 20 20 20 20 61 6e 20 65 78 69 73 74 69 6e 67 20      an existing 
3c70: 4c 4f 44 2e 0a 0a 09 69 66 20 7b 24 69 73 64 65  LOD....if {$isde
3c80: 66 61 75 6c 74 7d 20 7b 0a 09 20 20 20 20 23 20  fault} {..    # 
3c90: 49 6e 20 63 61 73 65 20 6f 66 20 28 61 29 20 74  In case of (a) t
3ca0: 68 65 20 63 68 61 6e 67 65 73 65 74 20 68 61 73  he changeset has
3cb0: 20 6e 6f 20 70 61 72 65 6e 74 2c 20 73 69 67 6e   no parent, sign
3cc0: 61 6c 65 64 20 62 79 0a 09 20 20 20 20 23 20 74  aled by..    # t
3cd0: 68 65 20 65 6d 70 74 79 20 73 74 72 69 6e 67 2e  he empty string.
3ce0: 20 57 65 20 64 6f 20 72 65 6d 65 6d 62 65 72 20   We do remember 
3cf0: 69 66 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  if the changeset
3d00: 20 69 73 0a 09 20 20 20 20 23 20 6c 61 73 74 20   is..    # last 
3d10: 6f 6e 20 74 68 65 20 76 65 6e 64 6f 72 20 62 72  on the vendor br
3d20: 61 6e 63 68 20 73 74 69 6c 6c 20 62 65 6c 6f 6e  anch still belon
3d30: 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b 2c 20 66  ging to trunk, f
3d40: 6f 72 0a 09 20 20 20 20 23 20 74 68 65 20 74 72  or..    # the tr
3d50: 75 6e 6b 20 72 6f 6f 74 2e 0a 09 20 20 20 20 72  unk root...    r
3d60: 65 74 75 72 6e 20 7b 7d 0a 09 7d 0a 0a 09 69 66  eturn {}..}...if
3d70: 20 7b 24 6c 6f 64 6e 61 6d 65 20 65 71 20 22 3a   {$lodname eq ":
3d80: 74 72 75 6e 6b 3a 22 7d 20 7b 0a 09 20 20 20 20  trunk:"} {..    
3d90: 23 20 54 68 69 73 20 69 73 20 63 61 73 65 20 28  # This is case (
3da0: 62 29 2c 20 61 6e 64 20 77 65 20 61 6c 73 6f 20  b), and we also 
3db0: 63 61 6e 20 62 65 20 73 75 72 65 20 74 68 61 74  can be sure that
3dc0: 20 74 68 65 72 65 20 69 73 0a 09 20 20 20 20 23   there is..    #
3dd0: 20 6e 6f 20 76 65 6e 64 6f 72 20 62 72 61 6e 63   no vendor branc
3de0: 68 20 63 68 61 6e 67 65 73 65 74 20 77 68 69 63  h changeset whic
3df0: 68 20 63 6f 75 6c 64 20 62 65 20 6f 75 72 0a 09  h could be our..
3e00: 20 20 20 20 23 20 70 61 72 65 6e 74 2e 20 54 68      # parent. Th
3e10: 61 74 20 77 61 73 20 61 6c 72 65 61 64 79 20 64  at was already d
3e20: 65 61 6c 74 20 77 69 74 68 20 74 68 72 6f 75 67  ealt with throug
3e30: 68 20 74 68 65 0a 09 20 20 20 20 23 20 3a 76 65  h the..    # :ve
3e40: 6e 64 6f 72 3a 6c 61 73 74 3a 20 73 69 67 6e 61  ndor:last: signa
3e50: 6c 20 61 6e 64 20 63 6f 64 65 20 69 6e 20 74 68  l and code in th
3e60: 65 20 63 61 6c 6c 65 72 20 28 73 65 74 74 69 6e  e caller (settin
3e70: 67 0a 09 20 20 20 20 23 20 73 75 63 68 20 61 20  g..    # such a 
3e80: 63 68 61 6e 67 65 73 65 74 20 75 70 20 61 73 20  changeset up as 
3e90: 70 61 72 65 6e 74 20 69 6e 20 74 68 65 20 73 74  parent in the st
3ea0: 61 74 65 2c 20 63 61 75 73 69 6e 67 20 74 68 65  ate, causing the
3eb0: 0a 09 20 20 20 20 23 20 73 74 61 6e 64 61 72 64  ..    # standard
3ec0: 20 4c 4f 44 20 68 61 6e 64 6c 65 72 20 61 74 20   LOD handler at 
3ed0: 28 2a 29 20 74 6f 20 6b 69 63 6b 20 69 6e 2e 20  (*) to kick in. 
3ee0: 53 6f 2c 20 6e 6f 20 70 61 72 65 6e 74 0a 09 20  So, no parent.. 
3ef0: 20 20 20 23 20 68 65 72 65 20 61 74 20 61 6c 6c     # here at all
3f00: 2e 0a 09 20 20 20 20 72 65 74 75 72 6e 20 7b 7d  ...    return {}
3f10: 0a 09 7d 0a 0a 09 23 20 43 61 73 65 20 28 63 29  ..}...# Case (c)
3f20: 2e 20 57 65 20 66 69 6e 64 20 74 68 65 20 70 61  . We find the pa
3f30: 72 65 6e 74 20 4c 4f 44 20 6f 66 20 6f 75 72 20  rent LOD of our 
3f40: 4c 4f 44 20 61 6e 64 20 74 61 6b 65 20 74 68 65  LOD and take the
3f50: 0a 09 23 20 6c 61 73 74 20 63 68 61 6e 67 65 73  ..# last changes
3f60: 65 74 20 63 6f 6d 6d 69 74 74 65 64 20 74 6f 20  et committed to 
3f70: 74 68 61 74 20 61 73 20 6f 75 72 20 70 61 72 65  that as our pare
3f80: 6e 74 2e 20 49 66 20 74 68 61 74 0a 09 23 20 64  nt. If that..# d
3f90: 6f 65 73 6e 27 74 20 65 78 69 73 74 20 77 65 20  oesn't exist we 
3fa0: 68 61 76 65 20 61 6e 20 65 72 72 6f 72 20 6f 6e  have an error on
3fb0: 20 6f 75 72 20 68 61 6e 64 73 2e 0a 0a 09 73 65   our hands....se
3fc0: 74 20 6c 6f 64 6e 61 6d 65 20 5b 5b 5b 24 70 72  t lodname [[[$pr
3fd0: 6f 6a 65 63 74 20 67 65 74 73 79 6d 62 6f 6c 20  oject getsymbol 
3fe0: 24 6c 6f 64 6e 61 6d 65 5d 20 70 61 72 65 6e 74  $lodname] parent
3ff0: 5d 20 6e 61 6d 65 5d 0a 09 69 66 20 7b 5b 69 6e  ] name]..if {[in
4000: 66 6f 20 65 78 69 73 74 73 20 73 74 61 74 65 28  fo exists state(
4010: 24 6c 6f 64 6e 61 6d 65 29 5d 7d 20 7b 0a 09 20  $lodname)]} {.. 
4020: 20 20 20 72 65 74 75 72 6e 20 24 73 74 61 74 65     return $state
4030: 28 24 6c 6f 64 6e 61 6d 65 29 0a 09 7d 0a 0a 09  ($lodname)..}...
4040: 74 72 6f 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c  trouble internal
4050: 20 7b 55 6e 61 62 6c 65 20 74 6f 20 64 65 74 65   {Unable to dete
4060: 72 6d 69 6e 65 20 63 68 61 6e 67 65 73 65 74 20  rmine changeset 
4070: 70 61 72 65 6e 74 7d 0a 09 72 65 74 75 72 6e 0a  parent}..return.
4080: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20      }..    proc 
4090: 47 65 74 69 73 64 65 66 61 75 6c 74 20 7b 72 65  Getisdefault {re
40a0: 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 73 65 74 20  visions} {..set 
40b0: 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24  theset ('[join $
40c0: 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d  revisions {','}]
40d0: 27 29 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73  ')...struct::lis
40e0: 74 20 61 73 73 69 67 6e 20 5b 73 74 61 74 65 20  t assign [state 
40f0: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
4100: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
4110: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c  ashes {..    SEL
4120: 45 43 54 20 52 2e 69 73 64 65 66 61 75 6c 74 2c  ECT R.isdefault,
4130: 20 52 2e 64 62 63 68 69 6c 64 0a 09 20 20 20 20   R.dbchild..    
4140: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
4150: 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e  R..    WHERE  R.
4160: 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  rid IN $theset  
4170: 2d 2d 20 41 6c 6c 20 73 70 65 63 69 66 69 65 64  -- All specified
4180: 20 72 65 76 69 73 69 6f 6e 73 0a 09 20 20 20 20   revisions..    
4190: 4c 49 4d 49 54 20 31 0a 09 7d 5d 5d 20 64 65 66  LIMIT 1..}]] def
41a0: 20 6c 61 73 74 0a 0a 09 23 20 54 4f 44 4f 2f 43   last...# TODO/C
41b0: 48 45 43 4b 3a 20 6c 6f 6f 6b 20 66 6f 72 20 63  HECK: look for c
41c0: 68 61 6e 67 65 73 65 74 73 20 77 68 65 72 65 20  hangesets where 
41d0: 69 73 64 65 66 61 75 6c 74 2f 64 62 63 68 69 6c  isdefault/dbchil
41e0: 64 20 69 73 0a 09 23 20 61 6d 62 69 67 6f 75 73  d is..# ambigous
41f0: 2e 0a 0a 09 72 65 74 75 72 6e 20 5b 6c 69 73 74  ....return [list
4200: 20 24 64 65 66 20 5b 65 78 70 72 20 7b 24 6c 61   $def [expr {$la
4210: 73 74 20 6e 65 20 22 22 7d 5d 5d 0a 20 20 20 20  st ne ""}]].    
4220: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 55 70 64 61  }..    proc Upda
4230: 74 65 73 74 61 74 65 20 7b 73 76 20 6c 6f 64 6e  testate {sv lodn
4240: 61 6d 65 20 75 75 69 64 7d 20 7b 0a 09 75 70 76  ame uuid} {..upv
4250: 61 72 20 31 20 24 73 76 20 73 74 61 74 65 0a 0a  ar 1 $sv state..
4260: 09 23 20 52 65 6d 65 6d 62 65 72 20 74 68 65 20  .# Remember the 
4270: 69 6d 70 6f 72 74 65 64 20 63 68 61 6e 67 65 73  imported changes
4280: 65 74 20 69 6e 20 74 68 65 20 73 74 61 74 65 2c  et in the state,
4290: 20 75 6e 64 65 72 20 6f 75 72 0a 09 23 20 4c 4f   under our..# LO
42a0: 44 2e 20 28 2a 2a 29 20 41 6e 64 20 69 66 20 74  D. (**) And if t
42b0: 68 65 20 3a 76 65 6e 64 6f 72 3a 6c 61 73 74 3a  he :vendor:last:
42c0: 20 73 69 67 6e 61 6c 20 69 73 20 70 72 65 73 65   signal is prese
42d0: 6e 74 20 74 68 65 6e 0a 09 23 20 74 68 65 20 72  nt then..# the r
42e0: 65 76 69 73 69 6f 6e 20 69 73 20 61 6c 73 6f 20  evision is also 
42f0: 74 68 65 20 61 63 74 75 61 6c 20 72 6f 6f 74 20  the actual root 
4300: 6f 66 20 74 68 65 20 3a 74 72 75 6e 6b 3a 2c 20  of the :trunk:, 
4310: 73 6f 0a 09 23 20 72 65 6d 65 6d 62 65 72 20 69  so..# remember i
4320: 74 20 61 73 20 73 75 63 68 2e 0a 0a 09 73 65 74  t as such....set
4330: 20 73 74 61 74 65 28 24 6c 6f 64 6e 61 6d 65 29   state($lodname)
4340: 20 24 75 75 69 64 0a 09 69 66 20 7b 5b 69 6e 66   $uuid..if {[inf
4350: 6f 20 65 78 69 73 74 73 20 73 74 61 74 65 28 3a  o exists state(:
4360: 76 65 6e 64 6f 72 3a 6c 61 73 74 3a 29 5d 7d 20  vendor:last:)]} 
4370: 7b 0a 09 20 20 20 20 75 6e 73 65 74 20 73 74 61  {..    unset sta
4380: 74 65 28 3a 76 65 6e 64 6f 72 3a 6c 61 73 74 3a  te(:vendor:last:
4390: 29 0a 09 20 20 20 20 73 65 74 20 73 74 61 74 65  )..    set state
43a0: 28 3a 74 72 75 6e 6b 3a 29 20 24 75 75 69 64 0a  (:trunk:) $uuid.
43b0: 09 7d 0a 0a 09 72 65 74 75 72 6e 20 24 75 75 69  .}...return $uui
43c0: 64 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70  d.    }..    typ
43d0: 65 6d 65 74 68 6f 64 20 73 70 6c 69 74 20 7b 63  emethod split {c
43e0: 73 65 74 20 61 72 67 73 7d 20 7b 0a 09 23 20 41  set args} {..# A
43f0: 73 20 70 61 72 74 20 6f 66 20 74 68 65 20 63 72  s part of the cr
4400: 65 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 6e 65  eation of the ne
4410: 77 20 63 68 61 6e 67 65 73 65 74 73 20 73 70 65  w changesets spe
4420: 63 69 66 69 65 64 20 69 6e 0a 09 23 20 41 52 47  cified in..# ARG
4430: 53 20 61 73 20 73 65 74 73 20 6f 66 20 69 74 65  S as sets of ite
4440: 6d 73 2c 20 61 6c 6c 20 73 75 62 73 65 74 73 20  ms, all subsets 
4450: 6f 66 20 43 53 45 54 27 73 20 69 74 65 6d 20 73  of CSET's item s
4460: 65 74 2c 20 43 53 45 54 0a 09 23 20 77 69 6c 6c  et, CSET..# will
4470: 20 62 65 20 64 72 6f 70 70 65 64 20 66 72 6f 6d   be dropped from
4480: 20 61 6c 6c 20 64 61 74 61 62 61 73 65 73 2c 20   all databases, 
4490: 69 6e 20 61 6e 64 20 6f 75 74 20 6f 66 20 6d 65  in and out of me
44a0: 6d 6f 72 79 2c 0a 09 23 20 61 6e 64 20 74 68 65  mory,..# and the
44b0: 6e 20 64 65 73 74 72 6f 79 65 64 2e 0a 09 23 0a  n destroyed...#.
44c0: 09 23 20 4e 6f 74 65 3a 20 54 68 65 20 69 74 65  .# Note: The ite
44d0: 6d 20 6c 69 73 74 73 20 66 6f 75 6e 64 20 69 6e  m lists found in
44e0: 20 61 72 67 73 20 61 72 65 20 74 61 67 67 65 64   args are tagged
44f0: 20 69 74 65 6d 73 2e 20 54 68 65 79 0a 09 23 20   items. They..# 
4500: 68 61 76 65 20 74 6f 20 68 61 76 65 20 74 68 65  have to have the
4510: 20 73 61 6d 65 20 74 79 70 65 20 61 73 20 74 68   same type as th
4520: 65 20 63 68 61 6e 67 65 73 65 74 2c 20 62 65 69  e changeset, bei
4530: 6e 67 20 73 75 62 73 65 74 73 0a 09 23 20 6f 66  ng subsets..# of
4540: 20 69 74 73 20 69 74 65 6d 73 2e 20 54 68 69 73   its items. This
4550: 20 69 73 20 63 68 65 63 6b 65 64 20 69 6e 20 55   is checked in U
4560: 6e 74 61 67 31 2e 0a 0a 09 6c 6f 67 20 77 72 69  ntag1....log wri
4570: 74 65 20 38 20 63 73 65 74 73 20 7b 4f 4c 44 3a  te 8 csets {OLD:
4580: 20 5b 6c 73 6f 72 74 20 5b 24 63 73 65 74 20 69   [lsort [$cset i
4590: 74 65 6d 73 5d 5d 7d 0a 09 56 61 6c 69 64 61 74  tems]]}..Validat
45a0: 65 46 72 61 67 6d 65 6e 74 73 20 24 63 73 65 74  eFragments $cset
45b0: 20 24 61 72 67 73 0a 0a 09 23 20 41 6c 6c 20 63   $args...# All c
45c0: 68 65 63 6b 73 20 70 61 73 73 2c 20 61 63 74 75  hecks pass, actu
45d0: 61 6c 6c 79 20 70 65 72 66 6f 72 6d 20 74 68 65  ally perform the
45e0: 20 73 70 6c 69 74 2e 0a 0a 09 73 74 72 75 63 74   split....struct
45f0: 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 24  ::list assign [$
4600: 63 73 65 74 20 64 61 74 61 5d 20 70 72 6f 6a 65  cset data] proje
4610: 63 74 20 63 73 74 79 70 65 20 63 73 73 72 63 0a  ct cstype cssrc.
4620: 0a 09 73 65 74 20 70 72 65 64 65 63 65 73 73 6f  ..set predecesso
4630: 72 73 20 5b 24 63 73 65 74 20 64 72 6f 70 5d 0a  rs [$cset drop].
4640: 09 24 63 73 65 74 20 64 65 73 74 72 6f 79 0a 0a  .$cset destroy..
4650: 09 73 65 74 20 6e 65 77 63 73 65 74 73 20 7b 7d  .set newcsets {}
4660: 0a 09 66 6f 72 65 61 63 68 20 66 72 61 67 6d 65  ..foreach fragme
4670: 6e 74 69 74 65 6d 73 20 24 61 72 67 73 20 7b 0a  ntitems $args {.
4680: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38  .    log write 8
4690: 20 63 73 65 74 73 20 7b 4d 41 4b 45 3a 20 5b 6c   csets {MAKE: [l
46a0: 73 6f 72 74 20 24 66 72 61 67 6d 65 6e 74 69 74  sort $fragmentit
46b0: 65 6d 73 5d 7d 0a 0a 09 20 20 20 20 73 65 74 20  ems]}...    set 
46c0: 66 72 61 67 6d 65 6e 74 20 5b 24 74 79 70 65 20  fragment [$type 
46d0: 25 41 55 54 4f 25 20 24 70 72 6f 6a 65 63 74 20  %AUTO% $project 
46e0: 24 63 73 74 79 70 65 20 24 63 73 73 72 63 20 5c  $cstype $cssrc \
46f0: 0a 09 09 09 20 20 20 20 20 20 5b 55 6e 74 61 67  ....      [Untag
4700: 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 20   $fragmentitems 
4710: 24 63 73 74 79 70 65 5d 5d 0a 09 20 20 20 20 6c  $cstype]]..    l
4720: 61 70 70 65 6e 64 20 6e 65 77 63 73 65 74 73 20  append newcsets 
4730: 24 66 72 61 67 6d 65 6e 74 0a 0a 09 20 20 20 20  $fragment...    
4740: 24 66 72 61 67 6d 65 6e 74 20 70 65 72 73 69 73  $fragment persis
4750: 74 0a 09 20 20 20 20 24 66 72 61 67 6d 65 6e 74  t..    $fragment
4760: 20 64 65 74 65 72 6d 69 6e 65 73 75 63 63 65 73   determinesucces
4770: 73 6f 72 73 0a 09 7d 0a 0a 09 23 20 54 68 65 20  sors..}...# The 
4780: 70 72 65 64 65 63 65 73 73 6f 72 73 20 68 61 76  predecessors hav
4790: 65 20 74 6f 20 72 65 63 6f 6d 70 75 74 65 20 74  e to recompute t
47a0: 68 65 69 72 20 73 75 63 63 65 73 73 6f 72 73 2c  heir successors,
47b0: 20 69 2e 65 2e 0a 09 23 20 72 65 6d 6f 76 65 20   i.e...# remove 
47c0: 74 68 65 20 64 72 6f 70 70 65 64 20 63 68 61 6e  the dropped chan
47d0: 67 65 73 65 74 20 61 6e 64 20 70 75 74 20 6f 6e  geset and put on
47e0: 65 20 6f 66 20 74 68 65 20 66 72 61 67 6d 65 6e  e of the fragmen
47f0: 74 73 0a 09 23 20 69 6e 74 6f 20 69 74 73 20 70  ts..# into its p
4800: 6c 61 63 65 2e 0a 09 66 6f 72 65 61 63 68 20 70  lace...foreach p
4810: 20 24 70 72 65 64 65 63 65 73 73 6f 72 73 20 7b   $predecessors {
4820: 0a 09 20 20 20 20 24 70 20 64 65 74 65 72 6d 69  ..    $p determi
4830: 6e 65 73 75 63 63 65 73 73 6f 72 73 0a 09 7d 0a  nesuccessors..}.
4840: 0a 09 72 65 74 75 72 6e 20 24 6e 65 77 63 73 65  ..return $newcse
4850: 74 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79  ts.    }..    ty
4860: 70 65 6d 65 74 68 6f 64 20 69 74 65 6d 73 74 72  pemethod itemstr
4870: 20 7b 69 74 65 6d 7d 20 7b 0a 09 73 74 72 75 63   {item} {..struc
4880: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24  t::list assign $
4890: 69 74 65 6d 20 69 74 79 70 65 20 69 69 64 0a 09  item itype iid..
48a0: 72 65 74 75 72 6e 20 5b 24 69 74 79 70 65 20 73  return [$itype s
48b0: 74 72 20 24 69 69 64 5d 0a 20 20 20 20 7d 0a 0a  tr $iid].    }..
48c0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73      typemethod s
48d0: 74 72 6c 69 73 74 20 7b 63 68 61 6e 67 65 73 65  trlist {changese
48e0: 74 73 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 6a  ts} {..return [j
48f0: 6f 69 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69 73  oin [struct::lis
4900: 74 20 6d 61 70 20 24 63 68 61 6e 67 65 73 65 74  t map $changeset
4910: 73 20 5b 6d 79 70 72 6f 63 20 49 44 5d 5d 5d 0a  s [myproc ID]]].
4920: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20      }..    proc 
4930: 49 44 20 7b 63 73 65 74 7d 20 7b 20 24 63 73 65  ID {cset} { $cse
4940: 74 20 73 74 72 20 7d 0a 0a 20 20 20 20 70 72 6f  t str }..    pro
4950: 63 20 55 6e 74 61 67 20 7b 74 61 67 67 65 64 69  c Untag {taggedi
4960: 74 65 6d 73 20 63 73 74 79 70 65 7d 20 7b 0a 09  tems cstype} {..
4970: 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a  return [struct::
4980: 6c 69 73 74 20 6d 61 70 20 24 74 61 67 67 65 64  list map $tagged
4990: 69 74 65 6d 73 20 5b 6d 79 70 72 6f 63 20 55 6e  items [myproc Un
49a0: 74 61 67 31 20 24 63 73 74 79 70 65 5d 5d 0a 20  tag1 $cstype]]. 
49b0: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 55     }..    proc U
49c0: 6e 74 61 67 31 20 7b 63 73 74 79 70 65 20 74 68  ntag1 {cstype th
49d0: 65 69 74 65 6d 7d 20 7b 0a 09 73 74 72 75 63 74  eitem} {..struct
49e0: 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24 74  ::list assign $t
49f0: 68 65 69 74 65 6d 20 74 20 69 0a 09 69 6e 74 65  heitem t i..inte
4a00: 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 24 63  grity assert {$c
4a10: 73 74 79 70 65 20 65 71 20 24 74 7d 20 7b 49 74  stype eq $t} {It
4a20: 65 6d 20 24 69 27 73 20 74 79 70 65 20 69 73 20  em $i's type is 
4a30: 27 24 74 27 2c 20 65 78 70 65 63 74 65 64 20 27  '$t', expected '
4a40: 24 63 73 74 79 70 65 27 7d 0a 09 72 65 74 75 72  $cstype'}..retur
4a50: 6e 20 24 69 0a 20 20 20 20 7d 0a 0a 20 20 20 20  n $i.    }..    
4a60: 70 72 6f 63 20 54 61 67 49 74 65 6d 44 69 63 74  proc TagItemDict
4a70: 20 7b 69 74 65 6d 64 69 63 74 20 63 73 74 79 70   {itemdict cstyp
4a80: 65 7d 20 7b 0a 09 73 65 74 20 72 65 73 20 7b 7d  e} {..set res {}
4a90: 0a 09 66 6f 72 65 61 63 68 20 7b 69 20 76 7d 20  ..foreach {i v} 
4aa0: 24 69 74 65 6d 64 69 63 74 20 7b 20 6c 61 70 70  $itemdict { lapp
4ab0: 65 6e 64 20 72 65 73 20 5b 6c 69 73 74 20 24 63  end res [list $c
4ac0: 73 74 79 70 65 20 24 69 5d 20 24 76 20 7d 0a 09  stype $i] $v }..
4ad0: 72 65 74 75 72 6e 20 24 72 65 73 0a 20 20 20 20  return $res.    
4ae0: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 56 61 6c 69  }..    proc Vali
4af0: 64 61 74 65 46 72 61 67 6d 65 6e 74 73 20 7b 63  dateFragments {c
4b00: 73 65 74 20 66 72 61 67 6d 65 6e 74 73 7d 20 7b  set fragments} {
4b10: 0a 09 23 20 43 68 65 63 6b 20 74 68 65 20 76 61  ..# Check the va
4b20: 72 69 6f 75 73 20 69 6e 74 65 67 72 69 74 79 20  rious integrity 
4b30: 63 6f 6e 73 74 72 61 69 6e 74 73 20 66 6f 72 20  constraints for 
4b40: 74 68 65 20 66 72 61 67 6d 65 6e 74 73 0a 09 23  the fragments..#
4b50: 20 73 70 65 63 69 66 79 69 6e 67 20 68 6f 77 20   specifying how 
4b60: 74 6f 20 73 70 6c 69 74 20 74 68 65 20 63 68 61  to split the cha
4b70: 6e 67 65 73 65 74 3a 0a 09 23 0a 09 23 20 2a 20  ngeset:..#..# * 
4b80: 57 65 20 6d 75 73 74 20 68 61 76 65 20 74 77 6f  We must have two
4b90: 20 6f 72 20 6d 6f 72 65 20 66 72 61 67 6d 65 6e   or more fragmen
4ba0: 74 73 2c 20 61 73 20 73 70 6c 69 74 74 69 6e 67  ts, as splitting
4bb0: 20 61 0a 09 23 20 20 20 63 68 61 6e 67 65 73 65   a..#   changese
4bc0: 74 20 69 6e 74 6f 20 6f 6e 65 20 6d 61 6b 65 73  t into one makes
4bd0: 20 6e 6f 20 73 65 6e 73 65 2e 0a 09 23 20 2a 20   no sense...# * 
4be0: 4e 6f 20 66 72 61 67 6d 65 6e 74 20 6d 61 79 20  No fragment may 
4bf0: 62 65 20 65 6d 70 74 79 2e 0a 09 23 20 2a 20 41  be empty...# * A
4c00: 6c 6c 20 66 72 61 67 6d 65 6e 74 73 20 68 61 76  ll fragments hav
4c10: 65 20 74 6f 20 62 65 20 74 72 75 65 20 73 75 62  e to be true sub
4c20: 73 65 74 73 20 6f 66 20 74 68 65 20 69 74 65 6d  sets of the item
4c30: 73 20 69 6e 20 74 68 65 0a 09 23 20 20 20 63 68  s in the..#   ch
4c40: 61 6e 67 65 73 65 74 20 74 6f 20 73 70 6c 69 74  angeset to split
4c50: 2e 20 54 68 65 20 27 74 72 75 65 27 20 69 73 20  . The 'true' is 
4c60: 69 6d 70 6c 69 65 64 20 62 65 63 61 75 73 65 20  implied because 
4c70: 6e 6f 6e 65 20 61 72 65 0a 09 23 20 20 20 61 6c  none are..#   al
4c80: 6c 6f 77 65 64 20 74 6f 20 62 65 20 65 6d 70 74  lowed to be empt
4c90: 79 2c 20 73 6f 20 65 61 63 68 20 68 61 73 20 74  y, so each has t
4ca0: 6f 20 62 65 20 73 6d 61 6c 6c 65 72 20 74 68 61  o be smaller tha
4cb0: 6e 20 74 68 65 0a 09 23 20 20 20 74 6f 74 61 6c  n the..#   total
4cc0: 2e 0a 09 23 20 2a 20 54 68 65 20 75 6e 69 6f 6e  ...# * The union
4cd0: 20 6f 66 20 74 68 65 20 66 72 61 67 6d 65 6e 74   of the fragment
4ce0: 73 20 68 61 73 20 74 6f 20 62 65 20 74 68 65 20  s has to be the 
4cf0: 69 74 65 6d 20 73 65 74 20 6f 66 20 74 68 65 0a  item set of the.
4d00: 09 23 20 20 20 63 68 61 6e 67 65 73 65 74 2e 0a  .#   changeset..
4d10: 09 23 20 2a 20 54 68 65 20 66 72 61 67 6d 65 6e  .# * The fragmen
4d20: 74 20 6d 75 73 74 20 6e 6f 74 20 6f 76 65 72 6c  t must not overl
4d30: 61 70 2c 20 69 2e 65 2e 20 74 68 65 69 72 20 70  ap, i.e. their p
4d40: 61 69 72 77 69 73 65 0a 09 23 20 20 20 69 6e 74  airwise..#   int
4d50: 65 72 73 65 63 74 69 6f 6e 73 20 68 61 76 65 20  ersections have 
4d60: 74 6f 20 62 65 20 65 6d 70 74 79 2e 0a 0a 09 73  to be empty....s
4d70: 65 74 20 63 6f 76 65 72 20 7b 7d 0a 09 66 6f 72  et cover {}..for
4d80: 65 61 63 68 20 66 72 61 67 6d 65 6e 74 69 74 65  each fragmentite
4d90: 6d 73 20 24 66 72 61 67 6d 65 6e 74 73 20 7b 0a  ms $fragments {.
4da0: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38  .    log write 8
4db0: 20 63 73 65 74 73 20 7b 4e 45 57 3a 20 5b 6c 73   csets {NEW: [ls
4dc0: 6f 72 74 20 24 66 72 61 67 6d 65 6e 74 69 74 65  ort $fragmentite
4dd0: 6d 73 5d 7d 0a 0a 09 20 20 20 20 69 6e 74 65 67  ms]}...    integ
4de0: 72 69 74 79 20 61 73 73 65 72 74 20 7b 0a 09 09  rity assert {...
4df0: 21 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 65 6d  ![struct::set em
4e00: 70 74 79 20 24 66 72 61 67 6d 65 6e 74 69 74 65  pty $fragmentite
4e10: 6d 73 5d 0a 09 20 20 20 20 7d 20 7b 63 68 61 6e  ms]..    } {chan
4e20: 67 65 73 65 74 20 66 72 61 67 6d 65 6e 74 20 69  geset fragment i
4e30: 73 20 65 6d 70 74 79 7d 0a 0a 09 20 20 20 20 69  s empty}...    i
4e40: 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20  ntegrity assert 
4e50: 7b 0a 09 09 5b 73 74 72 75 63 74 3a 3a 73 65 74  {...[struct::set
4e60: 20 73 75 62 73 65 74 6f 66 20 24 66 72 61 67 6d   subsetof $fragm
4e70: 65 6e 74 69 74 65 6d 73 20 5b 24 63 73 65 74 20  entitems [$cset 
4e80: 69 74 65 6d 73 5d 5d 0a 09 20 20 20 20 7d 20 7b  items]]..    } {
4e90: 63 68 61 6e 67 65 73 65 74 20 66 72 61 67 6d 65  changeset fragme
4ea0: 6e 74 20 69 73 20 6e 6f 74 20 61 20 73 75 62 73  nt is not a subs
4eb0: 65 74 7d 0a 09 20 20 20 20 73 74 72 75 63 74 3a  et}..    struct:
4ec0: 3a 73 65 74 20 61 64 64 20 63 6f 76 65 72 20 24  :set add cover $
4ed0: 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 0a 09 7d  fragmentitems..}
4ee0: 0a 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73 73  ...integrity ass
4ef0: 65 72 74 20 7b 0a 09 20 20 20 20 5b 73 74 72 75  ert {..    [stru
4f00: 63 74 3a 3a 73 65 74 20 65 71 75 61 6c 20 24 63  ct::set equal $c
4f10: 6f 76 65 72 20 5b 24 63 73 65 74 20 69 74 65 6d  over [$cset item
4f20: 73 5d 5d 0a 09 20 7d 20 7b 54 68 65 20 66 72 61  s]].. } {The fra
4f30: 67 6d 65 6e 74 73 20 64 6f 20 6e 6f 74 20 63 6f  gments do not co
4f40: 76 65 72 20 74 68 65 20 6f 72 69 67 69 6e 61 6c  ver the original
4f50: 20 63 68 61 6e 67 65 73 65 74 7d 0a 0a 09 73 65   changeset}...se
4f60: 74 20 69 20 31 0a 09 66 6f 72 65 61 63 68 20 66  t i 1..foreach f
4f70: 69 61 20 24 66 72 61 67 6d 65 6e 74 73 20 7b 0a  ia $fragments {.
4f80: 09 20 20 20 20 66 6f 72 65 61 63 68 20 66 69 62  .    foreach fib
4f90: 20 5b 6c 72 61 6e 67 65 20 24 66 72 61 67 6d 65   [lrange $fragme
4fa0: 6e 74 73 20 24 69 20 65 6e 64 5d 20 7b 0a 09 09  nts $i end] {...
4fb0: 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74  integrity assert
4fc0: 20 7b 0a 09 09 20 20 20 20 5b 73 74 72 75 63 74   {...    [struct
4fd0: 3a 3a 73 65 74 20 65 6d 70 74 79 20 5b 73 74 72  ::set empty [str
4fe0: 75 63 74 3a 3a 73 65 74 20 69 6e 74 65 72 73 65  uct::set interse
4ff0: 63 74 20 24 66 69 61 20 24 66 69 62 5d 5d 0a 09  ct $fia $fib]]..
5000: 09 7d 20 7b 54 68 65 20 66 72 61 67 6d 65 6e 74  .} {The fragment
5010: 73 20 3c 24 66 69 61 3e 20 61 6e 64 20 3c 24 66  s <$fia> and <$f
5020: 69 62 3e 20 6f 76 65 72 6c 61 70 7d 0a 09 20 20  ib> overlap}..  
5030: 20 20 7d 0a 09 20 20 20 20 69 6e 63 72 20 69 0a    }..    incr i.
5040: 09 7d 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  .}...return.    
5050: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23  }..    # # ## ##
5060: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
5070: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20   #############. 
5080: 20 20 20 23 23 20 53 74 61 74 65 0a 0a 20 20 20     ## State..   
5090: 20 76 61 72 69 61 62 6c 65 20 6d 79 69 64 20 20   variable myid  
50a0: 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 49 64 20        {} ; # Id 
50b0: 6f 66 20 74 68 65 20 63 73 65 74 20 66 6f 72 20  of the cset for 
50c0: 74 68 65 20 70 65 72 73 69 73 74 65 6e 74 0a 09  the persistent..
50d0: 09 09 20 20 20 20 20 20 23 20 73 74 61 74 65 2e  ..      # state.
50e0: 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79  .    variable my
50f0: 70 72 6f 6a 65 63 74 20 20 20 7b 7d 20 3b 20 23  project   {} ; #
5100: 20 52 65 66 65 72 65 6e 63 65 20 6f 66 20 74 68   Reference of th
5110: 65 20 70 72 6f 6a 65 63 74 20 6f 62 6a 65 63 74  e project object
5120: 20 74 68 65 0a 09 09 09 20 20 20 20 20 20 23 20   the....      # 
5130: 63 68 61 6e 67 65 73 65 74 20 62 65 6c 6f 6e 67  changeset belong
5140: 73 20 74 6f 2e 0a 20 20 20 20 76 61 72 69 61 62  s to..    variab
5150: 6c 65 20 6d 79 74 79 70 65 20 20 20 20 20 20 7b  le mytype      {
5160: 7d 20 3b 20 23 20 57 68 61 74 20 74 68 65 20 63  } ; # What the c
5170: 68 61 6e 67 65 73 65 74 20 69 73 20 62 61 73 65  hangeset is base
5180: 64 20 6f 6e 0a 09 09 09 20 20 20 20 20 20 23 20  d on....      # 
5190: 28 72 65 76 69 73 69 6f 6e 73 2c 20 74 61 67 73  (revisions, tags
51a0: 2c 20 6f 72 20 62 72 61 6e 63 68 65 73 29 2e 0a  , or branches)..
51b0: 09 09 09 20 20 20 20 20 20 23 20 56 61 6c 75 65  ...      # Value
51c0: 73 3a 20 53 65 65 20 6d 79 63 73 74 79 70 65 2e  s: See mycstype.
51d0: 20 4e 6f 74 65 20 74 68 61 74 20 77 65 0a 09 09   Note that we...
51e0: 09 20 20 20 20 20 20 23 20 68 61 76 65 20 74 6f  .      # have to
51f0: 20 6b 65 65 70 20 74 68 65 20 6e 61 6d 65 73 20   keep the names 
5200: 6f 66 20 74 68 65 20 68 65 6c 70 65 72 0a 09 09  of the helper...
5210: 09 20 20 20 20 20 20 23 20 73 69 6e 67 6c 65 74  .      # singlet
5220: 6f 6e 73 20 69 6e 20 73 79 6e 63 20 77 69 74 68  ons in sync with
5230: 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 0a 09 09   the contents...
5240: 09 20 20 20 20 20 20 23 20 6f 66 20 73 74 61 74  .      # of stat
5250: 65 20 74 61 62 6c 65 20 27 63 73 74 79 70 65 27  e table 'cstype'
5260: 2c 20 61 6e 64 20 76 61 72 69 6f 75 73 0a 09 09  , and various...
5270: 09 20 20 20 20 20 20 23 20 6f 74 68 65 72 20 70  .      # other p
5280: 6c 61 63 65 73 20 75 73 69 6e 67 20 74 68 65 6d  laces using them
5290: 20 68 61 72 64 77 69 72 65 64 2e 0a 20 20 20 20   hardwired..    
52a0: 76 61 72 69 61 62 6c 65 20 6d 79 74 79 70 65 6f  variable mytypeo
52b0: 62 6a 20 20 20 7b 7d 20 3b 20 23 20 52 65 66 65  bj   {} ; # Refe
52c0: 72 65 6e 63 65 20 74 6f 20 74 68 65 20 63 6f 6e  rence to the con
52d0: 74 61 69 6e 65 72 20 66 6f 72 20 74 68 65 0a 09  tainer for the..
52e0: 09 09 20 20 20 20 20 20 23 20 74 79 70 65 20 64  ..      # type d
52f0: 65 70 65 6e 64 65 6e 74 20 63 6f 64 65 2e 20 44  ependent code. D
5300: 65 72 69 76 65 64 20 66 72 6f 6d 0a 09 09 09 20  erived from.... 
5310: 20 20 20 20 20 23 20 6d 79 74 79 70 65 2e 0a 20       # mytype.. 
5320: 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 73 72     variable mysr
5330: 63 69 64 20 20 20 20 20 7b 7d 20 3b 20 23 20 49  cid     {} ; # I
5340: 64 20 6f 66 20 74 68 65 20 6d 65 74 61 64 61 74  d of the metadat
5350: 61 20 6f 72 20 73 79 6d 62 6f 6c 20 74 68 65 20  a or symbol the 
5360: 63 73 65 74 0a 09 09 09 20 20 20 20 20 20 23 20  cset....      # 
5370: 69 73 20 62 61 73 65 64 20 6f 6e 2e 0a 20 20 20  is based on..   
5380: 20 76 61 72 69 61 62 6c 65 20 6d 79 69 74 65 6d   variable myitem
5390: 73 20 20 20 20 20 7b 7d 20 3b 20 23 20 4c 69 73  s     {} ; # Lis
53a0: 74 20 6f 66 20 74 68 65 20 66 69 6c 65 20 6c 65  t of the file le
53b0: 76 65 6c 20 72 65 76 69 73 69 6f 6e 73 2c 0a 09  vel revisions,..
53c0: 09 09 20 20 20 20 20 20 23 20 74 61 67 73 2c 20  ..      # tags, 
53d0: 6f 72 20 62 72 61 6e 63 68 65 73 20 69 6e 20 74  or branches in t
53e0: 68 65 20 63 73 65 74 2c 20 61 73 0a 09 09 09 20  he cset, as.... 
53f0: 20 20 20 20 20 23 20 69 64 73 2e 20 4e 6f 74 20       # ids. Not 
5400: 74 61 67 67 65 64 2e 0a 20 20 20 20 76 61 72 69  tagged..    vari
5410: 61 62 6c 65 20 6d 79 74 69 74 65 6d 73 20 20 20  able mytitems   
5420: 20 7b 7d 20 3b 20 23 20 41 73 20 6d 79 69 74 65   {} ; # As myite
5430: 6d 73 2c 20 74 68 65 20 74 61 67 67 65 64 20 66  ms, the tagged f
5440: 6f 72 6d 2e 0a 20 20 20 20 76 61 72 69 61 62 6c  orm..    variabl
5450: 65 20 6d 79 70 6f 73 20 20 20 20 20 20 20 7b 7d  e mypos       {}
5460: 20 3b 20 23 20 43 6f 6d 6d 69 74 20 70 6f 73 69   ; # Commit posi
5470: 74 69 6f 6e 20 6f 66 20 74 68 65 20 63 68 61 6e  tion of the chan
5480: 67 65 73 65 74 2c 20 69 66 0a 09 09 09 20 20 20  geset, if....   
5490: 20 20 20 23 20 6b 6e 6f 77 6e 2e 0a 0a 20 20 20     # known...   
54a0: 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23   # # ## ### ####
54b0: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
54c0: 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20  ########.    ## 
54d0: 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68 6f 64 73  Internal methods
54e0: 0a 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62  ..    typevariab
54f0: 6c 65 20 6d 79 63 6f 75 6e 74 65 72 20 20 20 20  le mycounter    
5500: 20 20 20 20 30 20 3b 20 23 20 49 64 20 63 6f 75      0 ; # Id cou
5510: 6e 74 65 72 20 66 6f 72 20 63 73 65 74 73 2e 20  nter for csets. 
5520: 4c 61 73 74 20 69 64 0a 09 09 09 09 20 20 20 20  Last id.....    
5530: 20 20 23 20 75 73 65 64 2e 0a 20 20 20 20 74 79    # used..    ty
5540: 70 65 76 61 72 69 61 62 6c 65 20 6d 79 63 73 74  pevariable mycst
5550: 79 70 65 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20  ype -array {} ; 
5560: 23 20 4d 61 70 20 63 73 74 79 70 65 73 20 28 6e  # Map cstypes (n
5570: 61 6d 65 73 29 20 74 6f 20 70 65 72 73 69 73 74  ames) to persist
5580: 65 6e 74 0a 09 09 09 09 20 20 20 20 20 20 23 20  ent.....      # 
5590: 69 64 73 2e 20 4e 6f 74 65 20 74 68 61 74 20 77  ids. Note that w
55a0: 65 20 68 61 76 65 20 74 6f 20 6b 65 65 70 0a 09  e have to keep..
55b0: 09 09 09 20 20 20 20 20 20 23 20 74 68 65 20 6e  ...      # the n
55c0: 61 6d 65 73 20 69 6e 20 74 68 65 20 74 61 62 6c  ames in the tabl
55d0: 65 20 27 63 73 74 79 70 65 27 0a 09 09 09 09 20  e 'cstype'..... 
55e0: 20 20 20 20 20 23 20 69 6e 20 73 79 6e 63 20 77       # in sync w
55f0: 69 74 68 20 74 68 65 20 6e 61 6d 65 73 20 6f 66  ith the names of
5600: 20 74 68 65 0a 09 09 09 09 20 20 20 20 20 20 23   the.....      #
5610: 20 68 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f   helper singleto
5620: 6e 73 2e 0a 0a 20 20 20 20 74 79 70 65 6d 65 74  ns...    typemet
5630: 68 6f 64 20 69 6e 6f 72 64 65 72 20 7b 70 72 6f  hod inorder {pro
5640: 6a 65 63 74 69 64 7d 20 7b 0a 09 23 20 52 65 74  jectid} {..# Ret
5650: 75 72 6e 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e  urn all revision
5660: 20 63 68 61 6e 67 65 73 65 74 73 20 66 6f 72 20   changesets for 
5670: 74 68 65 20 73 70 65 63 69 66 69 65 64 20 70 72  the specified pr
5680: 6f 6a 65 63 74 2c 20 69 6e 0a 09 23 20 74 68 65  oject, in..# the
5690: 20 6f 72 64 65 72 20 67 69 76 65 6e 20 74 6f 20   order given to 
56a0: 74 68 65 6d 20 62 79 20 74 68 65 20 73 6f 72 74  them by the sort
56b0: 20 70 61 73 73 65 73 2e 20 42 6f 74 68 20 74 68   passes. Both th
56c0: 65 0a 09 23 20 66 69 6c 74 65 72 69 6e 67 20 62  e..# filtering b
56d0: 79 20 70 72 6f 6a 65 63 74 20 61 6e 64 20 73 6f  y project and so
56e0: 72 74 69 6e 67 20 6d 61 6b 65 20 75 73 65 20 6f  rting make use o
56f0: 66 20 27 70 72 6f 6a 65 63 74 3a 3a 72 65 76 0a  f 'project::rev.
5700: 09 23 20 72 65 76 27 20 69 6d 70 6f 73 73 69 62  .# rev' impossib
5710: 6c 65 2e 0a 0a 09 73 65 74 20 72 65 73 20 7b 7d  le....set res {}
5720: 0a 09 66 6f 72 65 61 63 68 20 7b 63 69 64 20 63  ..foreach {cid c
5730: 64 61 74 65 7d 20 5b 73 74 61 74 65 20 72 75 6e  date} [state run
5740: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43   {..    SELECT C
5750: 2e 63 69 64 2c 20 54 2e 64 61 74 65 0a 09 20 20  .cid, T.date..  
5760: 20 20 46 52 4f 4d 20 20 20 63 68 61 6e 67 65 73    FROM   changes
5770: 65 74 20 43 2c 20 63 73 74 69 6d 65 73 74 61 6d  et C, cstimestam
5780: 70 20 54 0a 09 20 20 20 20 57 48 45 52 45 20 20  p T..    WHERE  
5790: 43 2e 74 79 70 65 20 3d 20 30 20 20 20 20 20 20  C.type = 0      
57a0: 20 20 20 20 2d 2d 20 6c 69 6d 69 74 20 74 6f 20      -- limit to 
57b0: 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73  revision changes
57c0: 65 74 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ets..    AND    
57d0: 43 2e 70 69 64 20 20 3d 20 24 70 72 6f 6a 65 63  C.pid  = $projec
57e0: 74 69 64 20 2d 2d 20 6c 69 6d 69 74 20 74 6f 20  tid -- limit to 
57f0: 63 68 61 6e 67 65 73 65 74 73 20 69 6e 20 70 72  changesets in pr
5800: 6f 6a 65 63 74 0a 09 20 20 20 20 41 4e 44 20 20  oject..    AND  
5810: 20 20 54 2e 63 69 64 20 20 3d 20 43 2e 63 69 64    T.cid  = C.cid
5820: 20 20 20 20 20 20 2d 2d 20 67 65 74 20 6f 72 64        -- get ord
5830: 65 72 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f  ering informatio
5840: 6e 0a 09 20 20 20 20 4f 52 44 45 52 20 42 59 20  n..    ORDER BY 
5850: 54 2e 64 61 74 65 20 20 20 20 20 20 20 20 20 20  T.date          
5860: 20 20 2d 2d 20 73 6f 72 74 20 69 6e 74 6f 20 63    -- sort into c
5870: 6f 6d 6d 69 74 20 6f 72 64 65 72 0a 09 7d 5d 20  ommit order..}] 
5880: 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 72  {..    lappend r
5890: 65 73 20 24 6d 79 69 64 6d 61 70 28 24 63 69 64  es $myidmap($cid
58a0: 29 20 24 63 64 61 74 65 0a 09 7d 0a 09 72 65 74  ) $cdate..}..ret
58b0: 75 72 6e 20 24 72 65 73 0a 20 20 20 20 7d 0a 0a  urn $res.    }..
58c0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 67      typemethod g
58d0: 65 74 63 73 74 79 70 65 73 20 7b 7d 20 7b 0a 09  etcstypes {} {..
58e0: 66 6f 72 65 61 63 68 20 7b 74 69 64 20 6e 61 6d  foreach {tid nam
58f0: 65 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a  e} [state run {.
5900: 09 20 20 20 20 53 45 4c 45 43 54 20 74 69 64 2c  .    SELECT tid,
5910: 20 6e 61 6d 65 20 46 52 4f 4d 20 63 73 74 79 70   name FROM cstyp
5920: 65 3b 0a 09 7d 5d 20 7b 20 73 65 74 20 6d 79 63  e;..}] { set myc
5930: 73 74 79 70 65 28 24 6e 61 6d 65 29 20 24 74 69  stype($name) $ti
5940: 64 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  d }..return.    
5950: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
5960: 64 20 6c 6f 61 64 20 7b 72 65 70 6f 73 69 74 6f  d load {reposito
5970: 72 79 7d 20 7b 0a 09 73 65 74 20 6e 20 30 0a 09  ry} {..set n 0..
5980: 6c 6f 67 20 77 72 69 74 65 20 32 20 63 73 65 74  log write 2 cset
5990: 73 20 7b 4c 6f 61 64 69 6e 67 20 74 68 65 20 63  s {Loading the c
59a0: 68 61 6e 67 65 73 65 74 73 7d 0a 09 66 6f 72 65  hangesets}..fore
59b0: 61 63 68 20 7b 69 64 20 70 69 64 20 63 73 74 79  ach {id pid csty
59c0: 70 65 20 73 72 63 69 64 7d 20 5b 73 74 61 74 65  pe srcid} [state
59d0: 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45   run {..    SELE
59e0: 43 54 20 43 2e 63 69 64 2c 20 43 2e 70 69 64 2c  CT C.cid, C.pid,
59f0: 20 43 53 2e 6e 61 6d 65 2c 20 43 2e 73 72 63 0a   CS.name, C.src.
5a00: 09 20 20 20 20 46 52 4f 4d 20 20 20 63 68 61 6e  .    FROM   chan
5a10: 67 65 73 65 74 20 43 2c 20 63 73 74 79 70 65 20  geset C, cstype 
5a20: 43 53 0a 09 20 20 20 20 57 48 45 52 45 20 20 43  CS..    WHERE  C
5a30: 2e 74 79 70 65 20 3d 20 43 53 2e 74 69 64 0a 09  .type = CS.tid..
5a40: 20 20 20 20 4f 52 44 45 52 20 42 59 20 43 2e 63      ORDER BY C.c
5a50: 69 64 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 6c 6f  id..}] {..    lo
5a60: 67 20 70 72 6f 67 72 65 73 73 20 32 20 63 73 65  g progress 2 cse
5a70: 74 73 20 24 6e 20 7b 7d 0a 09 20 20 20 20 73 65  ts $n {}..    se
5a80: 74 20 72 20 5b 24 74 79 70 65 20 25 41 55 54 4f  t r [$type %AUTO
5a90: 25 20 5b 24 72 65 70 6f 73 69 74 6f 72 79 20 70  % [$repository p
5aa0: 72 6f 6a 65 63 74 6f 66 20 24 70 69 64 5d 20 24  rojectof $pid] $
5ab0: 63 73 74 79 70 65 20 24 73 72 63 69 64 20 5b 73  cstype $srcid [s
5ac0: 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c  tate run {...SEL
5ad0: 45 43 54 20 43 2e 69 69 64 0a 09 09 46 52 4f 4d  ECT C.iid...FROM
5ae0: 20 20 20 63 73 69 74 65 6d 20 43 0a 09 09 57 48     csitem C...WH
5af0: 45 52 45 20 20 43 2e 63 69 64 20 3d 20 24 69 64  ERE  C.cid = $id
5b00: 0a 09 09 4f 52 44 45 52 20 42 59 20 43 2e 70 6f  ...ORDER BY C.po
5b10: 73 0a 09 20 20 20 20 7d 5d 20 24 69 64 5d 0a 09  s..    }] $id]..
5b20: 20 20 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 09 72      incr n..}..r
5b30: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
5b40: 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61 64   typemethod load
5b50: 63 6f 75 6e 74 65 72 20 7b 7d 20 7b 0a 09 23 20  counter {} {..# 
5b60: 49 6e 69 74 69 61 6c 69 7a 65 20 74 68 65 20 63  Initialize the c
5b70: 6f 75 6e 74 65 72 20 66 72 6f 6d 20 74 68 65 20  ounter from the 
5b80: 73 74 61 74 65 0a 09 6c 6f 67 20 77 72 69 74 65  state..log write
5b90: 20 32 20 63 73 65 74 73 20 7b 4c 6f 61 64 69 6e   2 csets {Loadin
5ba0: 67 20 63 68 61 6e 67 65 73 65 74 20 63 6f 75 6e  g changeset coun
5bb0: 74 65 72 7d 0a 09 73 65 74 20 6d 79 63 6f 75 6e  ter}..set mycoun
5bc0: 74 65 72 20 5b 73 74 61 74 65 20 6f 6e 65 20 7b  ter [state one {
5bd0: 20 53 45 4c 45 43 54 20 4d 41 58 28 63 69 64 29   SELECT MAX(cid)
5be0: 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65 74 20   FROM changeset 
5bf0: 7d 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  }]..return.    }
5c00: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
5c10: 20 6e 75 6d 20 7b 7d 20 7b 20 72 65 74 75 72 6e   num {} { return
5c20: 20 24 6d 79 63 6f 75 6e 74 65 72 20 7d 0a 0a 20   $mycounter }.. 
5c30: 20 20 20 70 72 6f 63 20 49 6e 69 74 69 61 6c 69     proc Initiali
5c40: 7a 65 42 72 65 61 6b 53 74 61 74 65 20 7b 72 65  zeBreakState {re
5c50: 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61  visions} {..upva
5c60: 72 20 31 20 70 6f 73 20 70 6f 73 20 63 72 6f 73  r 1 pos pos cros
5c70: 73 20 63 72 6f 73 73 20 72 61 6e 67 65 20 72 61  s cross range ra
5c80: 6e 67 65 20 64 65 70 63 20 64 65 70 63 20 64 65  nge depc depc de
5c90: 6c 74 61 20 64 65 6c 74 61 20 5c 0a 09 20 20 20  lta delta \..   
5ca0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 64 65   dependencies de
5cb0: 70 65 6e 64 65 6e 63 69 65 73 0a 0a 09 23 20 46  pendencies...# F
5cc0: 69 72 73 74 20 77 65 20 63 72 65 61 74 65 20 61  irst we create a
5cd0: 20 6d 61 70 20 6f 66 20 70 6f 73 69 74 69 6f 6e   map of position
5ce0: 73 20 74 6f 20 6d 61 6b 65 20 69 74 20 65 61 73  s to make it eas
5cf0: 69 65 72 20 74 6f 0a 09 23 20 64 65 74 65 72 6d  ier to..# determ
5d00: 69 6e 65 20 77 68 65 74 68 65 72 20 61 20 64 65  ine whether a de
5d10: 70 65 6e 64 65 6e 63 79 20 63 72 6f 73 73 65 73  pendency crosses
5d20: 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 69 6e   a particular in
5d30: 64 65 78 2e 0a 0a 09 61 72 72 61 79 20 73 65 74  dex....array set
5d40: 20 70 6f 73 20 20 20 7b 7d 0a 09 61 72 72 61 79   pos   {}..array
5d50: 20 73 65 74 20 63 72 6f 73 73 20 7b 7d 0a 09 61   set cross {}..a
5d60: 72 72 61 79 20 73 65 74 20 64 65 70 63 20 20 7b  rray set depc  {
5d70: 7d 0a 09 73 65 74 20 72 61 6e 67 65 20 20 20 20  }..set range    
5d80: 20 20 20 7b 7d 0a 09 73 65 74 20 6e 20 30 0a 09     {}..set n 0..
5d90: 66 6f 72 65 61 63 68 20 72 65 76 20 24 72 65 76  foreach rev $rev
5da0: 69 73 69 6f 6e 73 20 7b 0a 09 20 20 20 20 6c 61  isions {..    la
5db0: 70 70 65 6e 64 20 72 61 6e 67 65 20 24 6e 0a 09  ppend range $n..
5dc0: 20 20 20 20 73 65 74 20 70 6f 73 28 24 72 65 76      set pos($rev
5dd0: 29 20 24 6e 0a 09 20 20 20 20 73 65 74 20 63 72  ) $n..    set cr
5de0: 6f 73 73 28 24 6e 29 20 30 0a 09 20 20 20 20 69  oss($n) 0..    i
5df0: 6e 63 72 20 6e 0a 09 7d 0a 0a 09 23 20 53 65 63  ncr n..}...# Sec
5e00: 6f 6e 64 6c 79 20 77 65 20 63 6f 75 6e 74 20 74  ondly we count t
5e10: 68 65 20 63 72 6f 73 73 69 6e 67 73 20 70 65 72  he crossings per
5e20: 20 70 6f 73 69 74 69 6f 6e 2c 20 62 79 20 69 74   position, by it
5e30: 65 72 61 74 69 6e 67 0a 09 23 20 6f 76 65 72 20  erating..# over 
5e40: 74 68 65 20 72 65 63 6f 72 64 65 64 20 69 6e 74  the recorded int
5e50: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
5e60: 65 73 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 49 66  es....# Note: If
5e70: 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20   the timestamps 
5e80: 61 72 65 20 62 61 64 6c 79 20 6f 75 74 20 6f 66  are badly out of
5e90: 20 6f 72 64 65 72 20 69 74 20 69 73 0a 09 23 20   order it is..# 
5ea0: 20 20 20 20 20 20 70 6f 73 73 69 62 6c 65 20 74        possible t
5eb0: 6f 20 68 61 76 65 20 61 20 62 61 63 6b 77 61 72  o have a backwar
5ec0: 64 20 73 75 63 63 65 73 73 6f 72 20 64 65 70 65  d successor depe
5ed0: 6e 64 65 6e 63 79 2c 0a 09 23 20 20 20 20 20 20  ndency,..#      
5ee0: 20 69 2e 65 2e 20 77 69 74 68 20 73 74 61 72 74   i.e. with start
5ef0: 20 3e 20 65 6e 64 2e 20 57 65 20 6d 61 79 20 68   > end. We may h
5f00: 61 76 65 20 74 6f 20 73 77 61 70 20 74 68 65 20  ave to swap the 
5f10: 69 6e 64 69 63 65 73 0a 09 23 20 20 20 20 20 20  indices..#      
5f20: 20 74 6f 20 65 6e 73 75 72 65 20 74 68 61 74 20   to ensure that 
5f30: 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 6c 6f  the following lo
5f40: 6f 70 20 72 75 6e 73 20 63 6f 72 72 65 63 74 6c  op runs correctl
5f50: 79 2e 0a 09 23 0a 09 23 20 4e 6f 74 65 20 32 3a  y...#..# Note 2:
5f60: 20 73 74 61 72 74 20 3d 3d 20 65 6e 64 20 69 73   start == end is
5f70: 20 6e 6f 74 20 70 6f 73 73 69 62 6c 65 2e 20 49   not possible. I
5f80: 74 20 69 6e 64 69 63 61 74 65 73 20 61 0a 09 23  t indicates a..#
5f90: 20 20 20 20 20 20 20 20 20 73 65 6c 66 2d 64 65           self-de
5fa0: 70 65 6e 64 65 6e 63 79 20 64 75 65 20 74 6f 20  pendency due to 
5fb0: 74 68 65 20 75 6e 69 71 75 65 6e 65 73 73 20 6f  the uniqueness o
5fc0: 66 20 70 6f 73 69 74 69 6f 6e 73 2c 0a 09 23 20  f positions,..# 
5fd0: 20 20 20 20 20 20 20 20 61 6e 64 20 74 68 61 74          and that
5fe0: 20 69 73 20 73 6f 6d 65 74 68 69 6e 67 20 77 65   is something we
5ff0: 20 68 61 76 65 20 72 75 6c 65 64 20 6f 75 74 20   have ruled out 
6000: 61 6c 72 65 61 64 79 2c 20 73 65 65 0a 09 23 20  already, see..# 
6010: 20 20 20 20 20 20 20 20 27 72 65 76 20 69 6e 74          'rev int
6020: 65 72 6e 61 6c 73 75 63 63 65 73 73 6f 72 73 27  ernalsuccessors'
6030: 2e 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64  ....foreach {rid
6040: 20 63 68 69 6c 64 72 65 6e 7d 20 5b 61 72 72 61   children} [arra
6050: 79 20 67 65 74 20 64 65 70 65 6e 64 65 6e 63 69  y get dependenci
6060: 65 73 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65 61  es] {..    forea
6070: 63 68 20 63 68 69 6c 64 20 24 63 68 69 6c 64 72  ch child $childr
6080: 65 6e 20 7b 0a 09 09 73 65 74 20 64 6b 65 79 20  en {...set dkey 
6090: 20 20 20 5b 6c 69 73 74 20 24 72 69 64 20 24 63     [list $rid $c
60a0: 68 69 6c 64 5d 0a 09 09 73 65 74 20 73 74 61 72  hild]...set star
60b0: 74 20 20 20 24 70 6f 73 28 24 72 69 64 29 0a 09  t   $pos($rid)..
60c0: 09 73 65 74 20 65 6e 64 20 20 20 20 20 24 70 6f  .set end     $po
60d0: 73 28 24 63 68 69 6c 64 29 0a 09 09 73 65 74 20  s($child)...set 
60e0: 63 72 6f 73 73 65 73 20 7b 7d 0a 0a 09 09 69 66  crosses {}....if
60f0: 20 7b 24 73 74 61 72 74 20 3e 20 24 65 6e 64 7d   {$start > $end}
6100: 20 7b 0a 09 09 20 20 20 20 77 68 69 6c 65 20 7b   {...    while {
6110: 24 65 6e 64 20 3c 20 24 73 74 61 72 74 7d 20 7b  $end < $start} {
6120: 0a 09 09 09 6c 61 70 70 65 6e 64 20 63 72 6f 73  ....lappend cros
6130: 73 65 73 20 24 65 6e 64 0a 09 09 09 69 6e 63 72  ses $end....incr
6140: 20 63 72 6f 73 73 28 24 65 6e 64 29 0a 09 09 09   cross($end)....
6150: 69 6e 63 72 20 65 6e 64 0a 09 09 20 20 20 20 7d  incr end...    }
6160: 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20  ...} else {...  
6170: 20 20 77 68 69 6c 65 20 7b 24 73 74 61 72 74 20    while {$start 
6180: 3c 20 24 65 6e 64 7d 20 7b 0a 09 09 09 6c 61 70  < $end} {....lap
6190: 70 65 6e 64 20 63 72 6f 73 73 65 73 20 24 73 74  pend crosses $st
61a0: 61 72 74 0a 09 09 09 69 6e 63 72 20 63 72 6f 73  art....incr cros
61b0: 73 28 24 73 74 61 72 74 29 0a 09 09 09 69 6e 63  s($start)....inc
61c0: 72 20 73 74 61 72 74 0a 09 09 20 20 20 20 7d 0a  r start...    }.
61d0: 09 09 7d 0a 09 09 73 65 74 20 64 65 70 63 28 24  ..}...set depc($
61e0: 64 6b 65 79 29 20 24 63 72 6f 73 73 65 73 0a 09  dkey) $crosses..
61f0: 20 20 20 20 7d 0a 09 7d 0a 0a 09 49 6e 69 74 69      }..}...Initi
6200: 61 6c 69 7a 65 44 65 6c 74 61 73 20 24 72 65 76  alizeDeltas $rev
6210: 69 73 69 6f 6e 73 0a 09 72 65 74 75 72 6e 0a 20  isions..return. 
6220: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 49     }..    proc I
6230: 6e 69 74 69 61 6c 69 7a 65 44 65 6c 74 61 73 20  nitializeDeltas 
6240: 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75  {revisions} {..u
6250: 70 76 61 72 20 31 20 64 65 6c 74 61 20 64 65 6c  pvar 1 delta del
6260: 74 61 0a 0a 09 23 20 50 75 6c 6c 20 74 68 65 20  ta...# Pull the 
6270: 74 69 6d 65 73 74 61 6d 70 73 20 66 6f 72 20 61  timestamps for a
6280: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 20  ll revisions in 
6290: 74 68 65 20 63 68 61 6e 67 65 73 65 74 73 20 61  the changesets a
62a0: 6e 64 0a 09 23 20 63 6f 6d 70 75 74 65 20 74 68  nd..# compute th
62b0: 65 69 72 20 64 65 6c 74 61 73 20 66 6f 72 20 75  eir deltas for u
62c0: 73 65 20 62 79 20 74 68 65 20 62 72 65 61 6b 20  se by the break 
62d0: 66 69 6e 64 65 72 2e 0a 0a 09 61 72 72 61 79 20  finder....array 
62e0: 73 65 74 20 64 65 6c 74 61 20 7b 7d 0a 09 61 72  set delta {}..ar
62f0: 72 61 79 20 73 65 74 20 73 74 61 6d 70 20 7b 7d  ray set stamp {}
6300: 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27  ...set theset ('
6310: 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73  [join $revisions
6320: 20 7b 27 2c 27 7d 5d 27 29 0a 09 66 6f 72 65 61   {','}]')..forea
6330: 63 68 20 7b 72 69 64 20 74 69 6d 65 7d 20 5b 73  ch {rid time} [s
6340: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
6350: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
6360: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
6370: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20    SELECT R.rid, 
6380: 52 2e 64 61 74 65 0a 09 20 20 20 20 46 52 4f 4d  R.date..    FROM
6390: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20   revision R..   
63a0: 20 57 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20   WHERE R.rid IN 
63b0: 24 74 68 65 73 65 74 0a 09 7d 5d 5d 20 7b 0a 09  $theset..}]] {..
63c0: 20 20 20 20 73 65 74 20 73 74 61 6d 70 28 24 72      set stamp($r
63d0: 69 64 29 20 24 74 69 6d 65 0a 09 7d 0a 0a 09 73  id) $time..}...s
63e0: 65 74 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 20  et n 0..foreach 
63f0: 72 69 64 20 5b 6c 72 61 6e 67 65 20 24 72 65 76  rid [lrange $rev
6400: 69 73 69 6f 6e 73 20 30 20 65 6e 64 2d 31 5d 20  isions 0 end-1] 
6410: 72 6e 65 78 74 20 5b 6c 72 61 6e 67 65 20 24 72  rnext [lrange $r
6420: 65 76 69 73 69 6f 6e 73 20 31 20 65 6e 64 5d 20  evisions 1 end] 
6430: 7b 0a 09 20 20 20 20 73 65 74 20 64 65 6c 74 61  {..    set delta
6440: 28 24 6e 29 20 5b 65 78 70 72 20 7b 24 73 74 61  ($n) [expr {$sta
6450: 6d 70 28 24 72 6e 65 78 74 29 20 2d 20 24 73 74  mp($rnext) - $st
6460: 61 6d 70 28 24 72 69 64 29 7d 5d 0a 09 20 20 20  amp($rid)}]..   
6470: 20 69 6e 63 72 20 6e 0a 09 7d 0a 09 72 65 74 75   incr n..}..retu
6480: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  rn.    }..    pr
6490: 6f 63 20 46 69 6e 64 42 65 73 74 42 72 65 61 6b  oc FindBestBreak
64a0: 20 7b 72 61 6e 67 65 7d 20 7b 0a 09 75 70 76 61   {range} {..upva
64b0: 72 20 31 20 63 72 6f 73 73 20 63 72 6f 73 73 20  r 1 cross cross 
64c0: 64 65 6c 74 61 20 64 65 6c 74 61 0a 0a 09 23 20  delta delta...# 
64d0: 44 65 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65  Determine the be
64e0: 73 74 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f  st break locatio
64f0: 6e 20 69 6e 20 74 68 65 20 67 69 76 65 6e 20 72  n in the given r
6500: 61 6e 67 65 20 6f 66 0a 09 23 20 70 6f 73 69 74  ange of..# posit
6510: 69 6f 6e 73 2e 20 46 69 72 73 74 20 77 65 20 6c  ions. First we l
6520: 6f 6f 6b 20 66 6f 72 20 74 68 65 20 6c 6f 63 61  ook for the loca
6530: 74 69 6f 6e 73 20 77 69 74 68 20 74 68 65 20 6d  tions with the m
6540: 61 78 69 6d 61 6c 0a 09 23 20 6e 75 6d 62 65 72  aximal..# number
6550: 20 6f 66 20 63 72 6f 73 73 69 6e 67 73 2e 20 49   of crossings. I
6560: 66 20 74 68 65 72 65 20 61 72 65 20 73 65 76 65  f there are seve
6570: 72 61 6c 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20  ral we look for 
6580: 74 68 65 0a 09 23 20 73 68 6f 72 74 65 73 74 20  the..# shortest 
6590: 74 69 6d 65 20 69 6e 74 65 72 76 61 6c 20 61 6d  time interval am
65a0: 6f 6e 67 20 74 68 65 6d 2e 20 49 66 20 77 65 20  ong them. If we 
65b0: 73 74 69 6c 6c 20 68 61 76 65 20 6d 75 6c 74 69  still have multi
65c0: 70 6c 65 0a 09 23 20 70 6f 73 73 69 62 69 6c 69  ple..# possibili
65d0: 74 69 65 73 20 61 66 74 65 72 20 74 68 61 74 20  ties after that 
65e0: 77 65 20 73 65 6c 65 63 74 20 74 68 65 20 65 61  we select the ea
65f0: 72 6c 69 65 73 74 20 6c 6f 63 61 74 69 6f 6e 0a  rliest location.
6600: 09 23 20 61 6d 6f 6e 67 20 74 68 65 73 65 2e 0a  .# among these..
6610: 0a 09 23 20 4e 6f 74 65 3a 20 49 66 20 74 68 65  ..# Note: If the
6620: 20 6d 61 78 69 6d 61 6c 20 6e 75 6d 62 65 72 20   maximal number 
6630: 6f 66 20 63 72 6f 73 73 69 6e 67 73 20 69 73 20  of crossings is 
6640: 30 20 74 68 65 6e 20 74 68 65 20 72 61 6e 67 65  0 then the range
6650: 0a 09 23 20 20 20 20 20 20 20 68 61 73 20 6e 6f  ..#       has no
6660: 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64   internal depend
6670: 65 6e 63 69 65 73 2c 20 61 6e 64 20 6e 6f 20 62  encies, and no b
6680: 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 20 61 74  reak location at
6690: 0a 09 23 20 20 20 20 20 20 20 61 6c 6c 2e 20 54  ..#       all. T
66a0: 68 69 73 20 70 6f 73 73 69 62 69 6c 69 74 79 20  his possibility 
66b0: 69 73 20 73 69 67 6e 61 6c 65 64 20 76 69 61 20  is signaled via 
66c0: 72 65 73 75 6c 74 20 2d 31 2e 0a 0a 09 23 20 4e  result -1....# N
66d0: 6f 74 65 3a 20 41 20 72 61 6e 67 65 20 6f 66 20  ote: A range of 
66e0: 6c 65 6e 67 74 68 20 31 20 6f 72 20 6c 65 73 73  length 1 or less
66f0: 20 63 61 6e 6e 6f 74 20 68 61 76 65 20 69 6e 74   cannot have int
6700: 65 72 6e 61 6c 0a 09 23 20 20 20 20 20 20 20 64  ernal..#       d
6710: 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 61 73 20  ependencies, as 
6720: 74 68 61 74 20 6e 65 65 64 73 20 61 74 20 6c 65  that needs at le
6730: 61 73 74 20 74 77 6f 20 72 65 76 69 73 69 6f 6e  ast two revision
6740: 73 20 69 6e 0a 09 23 20 20 20 20 20 20 20 74 68  s in..#       th
6750: 65 20 72 61 6e 67 65 2e 0a 0a 09 69 66 20 7b 5b  e range....if {[
6760: 6c 6c 65 6e 67 74 68 20 24 72 61 6e 67 65 5d 20  llength $range] 
6770: 3c 20 32 7d 20 7b 20 72 65 74 75 72 6e 20 2d 31  < 2} { return -1
6780: 20 7d 0a 0a 09 73 65 74 20 6d 61 78 20 2d 31 0a   }...set max -1.
6790: 09 73 65 74 20 62 65 73 74 20 7b 7d 0a 0a 09 66  .set best {}...f
67a0: 6f 72 65 61 63 68 20 6c 6f 63 61 74 69 6f 6e 20  oreach location 
67b0: 24 72 61 6e 67 65 20 7b 0a 09 20 20 20 20 73 65  $range {..    se
67c0: 74 20 63 72 6f 73 73 69 6e 67 73 20 24 63 72 6f  t crossings $cro
67d0: 73 73 28 24 6c 6f 63 61 74 69 6f 6e 29 0a 09 20  ss($location).. 
67e0: 20 20 20 69 66 20 7b 24 63 72 6f 73 73 69 6e 67     if {$crossing
67f0: 73 20 3e 20 24 6d 61 78 7d 20 7b 0a 09 09 73 65  s > $max} {...se
6800: 74 20 6d 61 78 20 20 24 63 72 6f 73 73 69 6e 67  t max  $crossing
6810: 73 0a 09 09 73 65 74 20 62 65 73 74 20 5b 6c 69  s...set best [li
6820: 73 74 20 24 6c 6f 63 61 74 69 6f 6e 5d 0a 09 09  st $location]...
6830: 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 7d 20  continue..    } 
6840: 65 6c 73 65 69 66 20 7b 24 63 72 6f 73 73 69 6e  elseif {$crossin
6850: 67 73 20 3d 3d 20 24 6d 61 78 7d 20 7b 0a 09 09  gs == $max} {...
6860: 6c 61 70 70 65 6e 64 20 62 65 73 74 20 24 6c 6f  lappend best $lo
6870: 63 61 74 69 6f 6e 0a 09 20 20 20 20 7d 0a 09 7d  cation..    }..}
6880: 0a 0a 09 69 66 20 7b 24 6d 61 78 20 3d 3d 20 30  ...if {$max == 0
6890: 7d 20 20 20 20 20 20 20 20 20 20 20 20 7b 20 72  }            { r
68a0: 65 74 75 72 6e 20 2d 31 20 7d 0a 09 69 66 20 7b  eturn -1 }..if {
68b0: 5b 6c 6c 65 6e 67 74 68 20 24 62 65 73 74 5d 20  [llength $best] 
68c0: 3d 3d 20 31 7d 20 7b 20 72 65 74 75 72 6e 20 5b  == 1} { return [
68d0: 6c 69 6e 64 65 78 20 24 62 65 73 74 20 30 5d 20  lindex $best 0] 
68e0: 7d 0a 0a 09 73 65 74 20 6c 6f 63 61 74 69 6f 6e  }...set location
68f0: 73 20 24 62 65 73 74 0a 09 73 65 74 20 62 65 73  s $best..set bes
6900: 74 20 7b 7d 0a 09 73 65 74 20 6d 69 6e 20 2d 31  t {}..set min -1
6910: 0a 0a 09 66 6f 72 65 61 63 68 20 6c 6f 63 61 74  ...foreach locat
6920: 69 6f 6e 20 24 6c 6f 63 61 74 69 6f 6e 73 20 7b  ion $locations {
6930: 0a 09 20 20 20 20 73 65 74 20 69 6e 74 65 72 76  ..    set interv
6940: 61 6c 20 24 64 65 6c 74 61 28 24 6c 6f 63 61 74  al $delta($locat
6950: 69 6f 6e 29 0a 09 20 20 20 20 69 66 20 7b 28 24  ion)..    if {($
6960: 6d 69 6e 20 3c 20 30 29 20 7c 7c 20 28 24 69 6e  min < 0) || ($in
6970: 74 65 72 76 61 6c 20 3c 20 24 6d 69 6e 29 7d 20  terval < $min)} 
6980: 7b 0a 09 09 73 65 74 20 6d 69 6e 20 20 24 69 6e  {...set min  $in
6990: 74 65 72 76 61 6c 0a 09 09 73 65 74 20 62 65 73  terval...set bes
69a0: 74 20 5b 6c 69 73 74 20 24 6c 6f 63 61 74 69 6f  t [list $locatio
69b0: 6e 5d 0a 09 20 20 20 20 7d 20 65 6c 73 65 69 66  n]..    } elseif
69c0: 20 7b 24 69 6e 74 65 72 76 61 6c 20 3d 3d 20 24   {$interval == $
69d0: 6d 69 6e 7d 20 7b 0a 09 09 6c 61 70 70 65 6e 64  min} {...lappend
69e0: 20 62 65 73 74 20 24 6c 6f 63 61 74 69 6f 6e 0a   best $location.
69f0: 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b  .    }..}...if {
6a00: 5b 6c 6c 65 6e 67 74 68 20 24 62 65 73 74 5d 20  [llength $best] 
6a10: 3d 3d 20 31 7d 20 7b 20 72 65 74 75 72 6e 20 5b  == 1} { return [
6a20: 6c 69 6e 64 65 78 20 24 62 65 73 74 20 30 5d 20  lindex $best 0] 
6a30: 7d 0a 0a 09 72 65 74 75 72 6e 20 5b 6c 69 6e 64  }...return [lind
6a40: 65 78 20 5b 6c 73 6f 72 74 20 2d 69 6e 74 65 67  ex [lsort -integ
6a50: 65 72 20 2d 69 6e 63 72 65 61 73 69 6e 67 20 24  er -increasing $
6a60: 62 65 73 74 5d 20 30 5d 0a 20 20 20 20 7d 0a 0a  best] 0].    }..
6a70: 20 20 20 20 70 72 6f 63 20 43 75 74 41 74 20 7b      proc CutAt {
6a80: 6c 6f 63 61 74 69 6f 6e 7d 20 7b 0a 09 75 70 76  location} {..upv
6a90: 61 72 20 31 20 63 72 6f 73 73 20 63 72 6f 73 73  ar 1 cross cross
6aa0: 20 64 65 70 63 20 64 65 70 63 0a 0a 09 23 20 49   depc depc...# I
6ab0: 74 20 77 61 73 20 64 65 63 69 64 65 64 20 74 6f  t was decided to
6ac0: 20 73 70 6c 69 74 20 74 68 65 20 63 68 61 6e 67   split the chang
6ad0: 65 73 65 74 20 61 74 20 74 68 65 20 67 69 76 65  eset at the give
6ae0: 6e 0a 09 23 20 6c 6f 63 61 74 69 6f 6e 2e 20 54  n..# location. T
6af0: 68 69 73 20 63 75 74 73 20 61 20 6e 75 6d 62 65  his cuts a numbe
6b00: 72 20 6f 66 20 64 65 70 65 6e 64 65 6e 63 69 65  r of dependencie
6b10: 73 2e 20 48 65 72 65 20 77 65 20 75 70 64 61 74  s. Here we updat
6b20: 65 0a 09 23 20 74 68 65 20 63 72 6f 73 73 20 69  e..# the cross i
6b30: 6e 66 6f 72 6d 61 74 69 6f 6e 20 73 6f 20 74 68  nformation so th
6b40: 61 74 20 74 68 65 20 62 72 65 61 6b 20 66 69 6e  at the break fin
6b50: 64 65 72 20 68 61 73 20 61 63 63 75 72 61 74 65  der has accurate
6b60: 0a 09 23 20 64 61 74 61 20 77 68 65 6e 20 77 65  ..# data when we
6b70: 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20 67 65 6e   look at the gen
6b80: 65 72 61 74 65 64 20 66 72 61 67 6d 65 6e 74 73  erated fragments
6b90: 2e 0a 0a 09 73 65 74 20 73 69 78 20 5b 6c 6f 67  ....set six [log
6ba0: 20 76 69 73 69 62 6c 65 3f 20 36 5d 0a 0a 09 66   visible? 6]...f
6bb0: 6f 72 65 61 63 68 20 7b 64 65 70 20 72 61 6e 67  oreach {dep rang
6bc0: 65 7d 20 5b 61 72 72 61 79 20 67 65 74 20 64 65  e} [array get de
6bd0: 70 63 5d 20 7b 0a 09 20 20 20 20 23 20 43 68 65  pc] {..    # Che
6be0: 63 6b 20 61 6c 6c 20 64 65 70 65 6e 64 65 6e 63  ck all dependenc
6bf0: 69 65 73 20 73 74 69 6c 6c 20 6b 6e 6f 77 6e 2c  ies still known,
6c00: 20 74 61 6b 65 20 74 68 65 69 72 20 72 61 6e 67   take their rang
6c10: 65 20 61 6e 64 0a 09 20 20 20 20 23 20 73 65 65  e and..    # see
6c20: 20 69 66 20 74 68 65 20 62 72 65 61 6b 20 6c 6f   if the break lo
6c30: 63 61 74 69 6f 6e 20 66 61 6c 6c 73 20 77 69 74  cation falls wit
6c40: 68 69 6e 2e 0a 0a 09 20 20 20 20 42 6f 72 64 65  hin....    Borde
6c50: 72 20 24 72 61 6e 67 65 20 73 20 65 0a 09 20 20  r $range s e..  
6c60: 20 20 69 66 20 7b 24 6c 6f 63 61 74 69 6f 6e 20    if {$location 
6c70: 3c 20 24 73 7d 20 63 6f 6e 74 69 6e 75 65 20 3b  < $s} continue ;
6c80: 20 23 20 62 72 65 61 6b 20 62 65 66 6f 72 65 20   # break before 
6c90: 72 61 6e 67 65 2c 20 69 67 6e 6f 72 65 0a 09 20  range, ignore.. 
6ca0: 20 20 20 69 66 20 7b 24 6c 6f 63 61 74 69 6f 6e     if {$location
6cb0: 20 3e 20 24 65 7d 20 63 6f 6e 74 69 6e 75 65 20   > $e} continue 
6cc0: 3b 20 23 20 62 72 65 61 6b 20 61 66 74 65 72 20  ; # break after 
6cd0: 72 61 6e 67 65 2c 20 69 67 6e 6f 72 65 2e 0a 0a  range, ignore...
6ce0: 09 20 20 20 20 23 20 54 68 69 73 20 64 65 70 65  .    # This depe
6cf0: 6e 64 65 6e 63 79 20 63 72 6f 73 73 65 73 20 74  ndency crosses t
6d00: 68 65 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f  he break locatio
6d10: 6e 2e 20 57 65 20 72 65 6d 6f 76 65 20 69 74 0a  n. We remove it.
6d20: 09 20 20 20 20 23 20 66 72 6f 6d 20 74 68 65 20  .    # from the 
6d30: 63 72 6f 73 73 69 6e 67 73 20 63 6f 75 6e 74 65  crossings counte
6d40: 72 73 2c 20 61 6e 64 20 74 68 65 6e 20 61 6c 73  rs, and then als
6d50: 6f 20 66 72 6f 6d 20 74 68 65 20 73 65 74 0a 09  o from the set..
6d60: 20 20 20 20 23 20 6f 66 20 6b 6e 6f 77 6e 20 64      # of known d
6d70: 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 61 73 20  ependencies, as 
6d80: 77 65 20 61 72 65 20 64 6f 6e 65 20 77 69 74 68  we are done with
6d90: 20 69 74 2e 0a 0a 09 20 20 20 20 66 6f 72 65 61   it....    forea
6da0: 63 68 20 6c 6f 63 20 24 64 65 70 63 28 24 64 65  ch loc $depc($de
6db0: 70 29 20 7b 20 69 6e 63 72 20 63 72 6f 73 73 28  p) { incr cross(
6dc0: 24 6c 6f 63 29 20 2d 31 20 7d 0a 09 20 20 20 20  $loc) -1 }..    
6dd0: 75 6e 73 65 74 20 64 65 70 63 28 24 64 65 70 29  unset depc($dep)
6de0: 0a 0a 09 20 20 20 20 69 66 20 7b 21 24 73 69 78  ...    if {!$six
6df0: 7d 20 63 6f 6e 74 69 6e 75 65 0a 0a 09 20 20 20  } continue...   
6e00: 20 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73   struct::list as
6e10: 73 69 67 6e 20 24 64 65 70 20 70 61 72 65 6e 74  sign $dep parent
6e20: 20 63 68 69 6c 64 0a 09 20 20 20 20 6c 6f 67 20   child..    log 
6e30: 77 72 69 74 65 20 35 20 63 73 65 74 73 20 22 42  write 5 csets "B
6e40: 72 6f 6b 65 20 64 65 70 65 6e 64 65 6e 63 79 20  roke dependency 
6e50: 5b 50 44 20 24 70 61 72 65 6e 74 5d 20 2d 2d 3e  [PD $parent] -->
6e60: 20 5b 50 44 20 24 63 68 69 6c 64 5d 22 0a 09 7d   [PD $child]"..}
6e70: 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  ...return.    }.
6e80: 0a 20 20 20 20 23 20 50 72 69 6e 74 20 69 64 65  .    # Print ide
6e90: 6e 74 69 66 79 69 6e 67 20 64 61 74 61 20 66 6f  ntifying data fo
6ea0: 72 20 61 20 72 65 76 69 73 69 6f 6e 20 28 70 72  r a revision (pr
6eb0: 6f 6a 65 63 74 2c 20 66 69 6c 65 2c 20 64 6f 74  oject, file, dot
6ec0: 74 65 64 20 72 65 76 0a 20 20 20 20 23 20 6e 75  ted rev.    # nu
6ed0: 6d 62 65 72 29 2c 20 66 6f 72 20 68 69 67 68 20  mber), for high 
6ee0: 76 65 72 62 6f 73 69 74 79 20 6c 6f 67 20 6f 75  verbosity log ou
6ef0: 74 70 75 74 2e 0a 20 20 20 20 23 20 54 4f 44 4f  tput..    # TODO
6f00: 3a 20 52 65 70 6c 61 63 65 20 77 69 74 68 20 63  : Replace with c
6f10: 61 6c 6c 20 74 6f 20 69 74 65 6d 73 74 72 20 28  all to itemstr (
6f20: 6c 69 73 74 20 72 65 76 20 24 69 64 29 0a 0a 20  list rev $id).. 
6f30: 20 20 20 70 72 6f 63 20 50 44 20 7b 69 64 7d 20     proc PD {id} 
6f40: 7b 0a 09 66 6f 72 65 61 63 68 20 7b 70 20 66 20  {..foreach {p f 
6f50: 72 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a  r} [state run {.
6f60: 09 09 53 45 4c 45 43 54 20 50 2e 6e 61 6d 65 20  ..SELECT P.name 
6f70: 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a  , F.name, R.rev.
6f80: 09 09 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20  ..FROM revision 
6f90: 52 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65  R, file F, proje
6fa0: 63 74 20 50 0a 09 09 57 48 45 52 45 20 52 2e 72  ct P...WHERE R.r
6fb0: 69 64 20 3d 20 24 69 64 20 20 20 20 2d 2d 20 46  id = $id    -- F
6fc0: 69 6e 64 20 73 70 65 63 69 66 69 65 64 20 66 69  ind specified fi
6fd0: 6c 65 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e  le revision...AN
6fe0: 44 20 20 20 46 2e 66 69 64 20 3d 20 52 2e 66 69  D   F.fid = R.fi
6ff0: 64 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f  d  -- Get file o
7000: 66 20 74 68 65 20 72 65 76 69 73 69 6f 6e 0a 09  f the revision..
7010: 09 41 4e 44 20 20 20 50 2e 70 69 64 20 3d 20 46  .AND   P.pid = F
7020: 2e 70 69 64 20 20 2d 2d 20 47 65 74 20 70 72 6f  .pid  -- Get pro
7030: 6a 65 63 74 20 6f 66 20 74 68 65 20 66 69 6c 65  ject of the file
7040: 2e 0a 09 7d 5d 20 62 72 65 61 6b 0a 09 72 65 74  ...}] break..ret
7050: 75 72 6e 20 22 27 24 70 20 3a 20 24 66 2f 24 72  urn "'$p : $f/$r
7060: 27 22 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  '".    }..    # 
7070: 50 72 69 6e 74 69 6e 67 20 6f 6e 65 20 6f 72 20  Printing one or 
7080: 6d 6f 72 65 20 72 61 6e 67 65 73 2c 20 66 6f 72  more ranges, for
7090: 6d 61 74 74 65 64 2c 20 61 6e 64 20 6f 6e 6c 79  matted, and only
70a0: 20 74 68 65 69 72 20 62 6f 72 64 65 72 20 74 6f   their border to
70b0: 0a 20 20 20 20 23 20 6b 65 65 70 20 74 68 65 20  .    # keep the 
70c0: 73 74 72 69 6e 67 73 20 73 68 6f 72 74 2e 0a 0a  strings short...
70d0: 20 20 20 20 70 72 6f 63 20 50 52 73 20 7b 72 61      proc PRs {ra
70e0: 6e 67 65 73 7d 20 7b 0a 09 72 65 74 75 72 6e 20  nges} {..return 
70f0: 5b 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61  [struct::list ma
7100: 70 20 24 72 61 6e 67 65 73 20 5b 6d 79 70 72 6f  p $ranges [mypro
7110: 63 20 50 52 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20  c PR]].    }..  
7120: 20 20 70 72 6f 63 20 50 52 20 7b 72 61 6e 67 65    proc PR {range
7130: 7d 20 7b 0a 09 42 6f 72 64 65 72 20 24 72 61 6e  } {..Border $ran
7140: 67 65 20 73 20 65 0a 09 72 65 74 75 72 6e 20 3c  ge s e..return <
7150: 24 7b 73 7d 2e 2e 2e 24 7b 65 7d 3e 0a 20 20 20  ${s}...${e}>.   
7160: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 42 6f 72   }..    proc Bor
7170: 64 65 72 20 7b 72 61 6e 67 65 20 73 76 20 65 76  der {range sv ev
7180: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 73 76  } {..upvar 1 $sv
7190: 20 73 20 24 65 76 20 65 0a 09 73 65 74 20 73 20   s $ev e..set s 
71a0: 5b 6c 69 6e 64 65 78 20 24 72 61 6e 67 65 20 30  [lindex $range 0
71b0: 5d 0a 09 73 65 74 20 65 20 5b 6c 69 6e 64 65 78  ]..set e [lindex
71c0: 20 24 72 61 6e 67 65 20 65 6e 64 5d 0a 09 72 65   $range end]..re
71d0: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
71e0: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
71f0: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
7200: 23 23 23 23 23 23 23 0a 0a 20 20 20 20 74 79 70  #######..    typ
7210: 65 76 61 72 69 61 62 6c 65 20 6d 79 63 68 61 6e  evariable mychan
7220: 67 65 73 65 74 73 20 20 20 20 20 20 20 20 20 7b  gesets         {
7230: 7d 20 3b 20 23 20 4c 69 73 74 20 6f 66 20 61 6c  } ; # List of al
7240: 6c 20 6b 6e 6f 77 6e 0a 09 09 09 09 09 20 20 20  l known......   
7250: 23 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 20 20  # changesets..  
7260: 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d    typevariable m
7270: 79 74 63 68 61 6e 67 65 73 65 74 73 20 2d 61 72  ytchangesets -ar
7280: 72 61 79 20 7b 7d 20 3b 20 23 20 4c 69 73 74 20  ray {} ; # List 
7290: 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 0a 09 09 09  of all known....
72a0: 09 09 20 20 20 23 20 63 68 61 6e 67 65 73 65 74  ..   # changeset
72b0: 73 20 6f 66 20 61 20 74 79 70 65 2e 0a 20 20 20  s of a type..   
72c0: 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79   typevariable my
72d0: 69 74 65 6d 6d 61 70 20 20 20 20 20 2d 61 72 72  itemmap     -arr
72e0: 61 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72  ay {} ; # Map fr
72f0: 6f 6d 20 69 74 65 6d 73 20 28 74 61 67 67 65 64  om items (tagged
7300: 29 0a 09 09 09 09 09 20 20 20 23 20 74 6f 20 74  )......   # to t
7310: 68 65 20 6c 69 73 74 20 6f 66 20 63 68 61 6e 67  he list of chang
7320: 65 73 65 74 73 0a 09 09 09 09 09 20 20 20 23 20  esets......   # 
7330: 63 6f 6e 74 61 69 6e 69 6e 67 20 69 74 2e 20 45  containing it. E
7340: 61 63 68 20 69 74 65 6d 0a 09 09 09 09 09 20 20  ach item......  
7350: 20 23 20 63 61 6e 20 62 65 20 75 73 65 64 20 62   # can be used b
7360: 79 20 6f 6e 6c 79 20 6f 6e 65 0a 09 09 09 09 09  y only one......
7370: 20 20 20 23 20 63 68 61 6e 67 65 73 65 74 2e 0a     # changeset..
7380: 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65      typevariable
7390: 20 6d 79 69 64 6d 61 70 20 20 20 2d 61 72 72 61   myidmap   -arra
73a0: 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f  y {} ; # Map fro
73b0: 6d 20 63 68 61 6e 67 65 73 65 74 20 69 64 20 74  m changeset id t
73c0: 6f 0a 09 09 09 09 20 20 20 20 20 20 20 23 20 63  o.....       # c
73d0: 68 61 6e 67 65 73 65 74 2e 0a 0a 20 20 20 20 74  hangeset...    t
73e0: 79 70 65 6d 65 74 68 6f 64 20 61 6c 6c 20 20 20  ypemethod all   
73f0: 20 7b 7d 20 20 20 20 7b 20 72 65 74 75 72 6e 20   {}    { return 
7400: 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20 7d 0a  $mychangesets }.
7410: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6f      typemethod o
7420: 66 20 20 20 20 20 7b 63 69 64 7d 20 7b 20 72 65  f     {cid} { re
7430: 74 75 72 6e 20 24 6d 79 69 64 6d 61 70 28 24 63  turn $myidmap($c
7440: 69 64 29 20 7d 0a 20 20 20 20 74 79 70 65 6d 65  id) }.    typeme
7450: 74 68 6f 64 20 6f 66 69 74 65 6d 20 7b 69 69 64  thod ofitem {iid
7460: 7d 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 69 74  } { return $myit
7470: 65 6d 6d 61 70 28 24 69 69 64 29 20 7d 0a 0a 20  emmap($iid) }.. 
7480: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 72 65     typemethod re
7490: 76 20 20 20 20 7b 7d 20 20 20 20 7b 20 72 65 74  v    {}    { ret
74a0: 75 72 6e 20 24 6d 79 74 63 68 61 6e 67 65 73 65  urn $mytchangese
74b0: 74 73 28 72 65 76 29 20 7d 0a 20 20 20 20 74 79  ts(rev) }.    ty
74c0: 70 65 6d 65 74 68 6f 64 20 73 79 6d 20 20 20 20  pemethod sym    
74d0: 7b 7d 20 20 20 20 7b 20 72 65 74 75 72 6e 20 5b  {}    { return [
74e0: 63 6f 6e 63 61 74 20 5c 0a 09 09 09 09 09 20 20  concat \......  
74f0: 24 7b 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28  ${mytchangesets(
7500: 73 79 6d 3a 3a 62 72 61 6e 63 68 29 7d 20 5c 0a  sym::branch)} \.
7510: 09 09 09 09 09 20 20 24 7b 6d 79 74 63 68 61 6e  .....  ${mytchan
7520: 67 65 73 65 74 73 28 73 79 6d 3a 3a 74 61 67 29  gesets(sym::tag)
7530: 7d 5d 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23  }] }..    # # ##
7540: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
7550: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
7560: 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75  #.    ## Configu
7570: 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67  ration..    prag
7580: 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20  ma -hastypeinfo 
7590: 20 20 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 74 79     no  ; # no ty
75a0: 70 65 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e  pe introspection
75b0: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73  .    pragma -has
75c0: 69 6e 66 6f 20 20 20 20 20 20 20 20 6e 6f 20 20  info        no  
75d0: 3b 20 23 20 6e 6f 20 6f 62 6a 65 63 74 20 69 6e  ; # no object in
75e0: 74 72 6f 73 70 65 63 74 69 6f 6e 0a 0a 20 20 20  trospection..   
75f0: 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23   # # ## ### ####
7600: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
7610: 23 23 23 23 23 23 23 23 0a 7d 0a 0a 23 23 0a 23  ########.}..##.#
7620: 23 20 4e 4f 54 45 3a 20 54 68 65 20 73 75 63 63  # NOTE: The succ
7630: 65 73 73 6f 72 20 61 6e 64 20 70 72 65 64 65 63  essor and predec
7640: 65 73 73 6f 72 20 6d 65 74 68 6f 64 73 20 64 65  essor methods de
7650: 66 69 6e 65 64 20 62 79 20 74 68 65 20 63 6c 61  fined by the cla
7660: 73 73 65 73 0a 23 23 20 20 20 20 20 20 20 62 65  sses.##       be
7670: 6c 6f 77 20 61 72 65 20 2d 2d 20 62 6f 74 74 6c  low are -- bottl
7680: 65 20 6e 65 63 6b 73 20 2d 2d 2e 20 4c 6f 6f 6b  e necks --. Look
7690: 20 66 6f 72 20 77 61 79 73 20 74 6f 20 6d 61 6b   for ways to mak
76a0: 65 20 74 68 65 20 53 51 4c 0a 23 23 20 20 20 20  e the SQL.##    
76b0: 20 20 20 66 61 73 74 65 72 2e 0a 23 23 0a 0a 23     faster..##..#
76c0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
76d0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
76e0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
76f0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
7700: 48 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e  Helper singleton
7710: 2e 20 43 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 72  . Commands for r
7720: 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65  evision changese
7730: 74 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20  ts...snit::type 
7740: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
7750: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65  port::cvs::proje
7760: 63 74 3a 3a 72 65 76 3a 3a 72 65 76 20 7b 0a 20  ct::rev::rev {. 
7770: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62 79     typemethod by
7780: 72 65 76 69 73 69 6f 6e 20 7b 7d 20 7b 20 72 65  revision {} { re
7790: 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70  turn 1 }.    typ
77a0: 65 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c  emethod bysymbol
77b0: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30     {} { return 0
77c0: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f   }.    typemetho
77d0: 64 20 69 73 74 61 67 20 20 20 20 20 20 7b 7d 20  d istag      {} 
77e0: 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20  { return 0 }.   
77f0: 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 62 72   typemethod isbr
7800: 61 6e 63 68 20 20 20 7b 7d 20 7b 20 72 65 74 75  anch   {} { retu
7810: 72 6e 20 30 20 7d 0a 0a 20 20 20 20 74 79 70 65  rn 0 }..    type
7820: 6d 65 74 68 6f 64 20 73 74 72 20 7b 72 65 76 69  method str {revi
7830: 73 69 6f 6e 7d 20 7b 0a 09 73 74 72 75 63 74 3a  sion} {..struct:
7840: 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 73 74  :list assign [st
7850: 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53  ate run {..    S
7860: 45 4c 45 43 54 20 52 2e 72 65 76 2c 20 46 2e 6e  ELECT R.rev, F.n
7870: 61 6d 65 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20  ame, P.name..   
7880: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
7890: 20 52 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a   R, file F, proj
78a0: 65 63 74 20 50 0a 09 20 20 20 20 57 48 45 52 45  ect P..    WHERE
78b0: 20 20 52 2e 72 69 64 20 3d 20 24 72 65 76 69 73    R.rid = $revis
78c0: 69 6f 6e 20 2d 2d 20 46 69 6e 64 20 73 70 65 63  ion -- Find spec
78d0: 69 66 69 65 64 20 66 69 6c 65 20 72 65 76 69 73  ified file revis
78e0: 69 6f 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ion..    AND    
78f0: 46 2e 66 69 64 20 3d 20 52 2e 66 69 64 20 20 20  F.fid = R.fid   
7900: 20 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66    -- Get file of
7910: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 0a 09 20   the revision.. 
7920: 20 20 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20     AND    P.pid 
7930: 3d 20 46 2e 70 69 64 20 20 20 20 20 2d 2d 20 47  = F.pid     -- G
7940: 65 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 74 68  et project of th
7950: 65 20 66 69 6c 65 2e 0a 09 7d 5d 20 72 65 76 6e  e file...}] revn
7960: 72 20 66 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 72  r fname pname..r
7970: 65 74 75 72 6e 20 22 24 70 6e 61 6d 65 2f 24 7b  eturn "$pname/${
7980: 72 65 76 6e 72 7d 3a 3a 24 66 6e 61 6d 65 22 0a  revnr}::$fname".
7990: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73      }..    # res
79a0: 75 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74  ult = list (mint
79b0: 69 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20  ime, maxtime).  
79c0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 74 69 6d    typemethod tim
79d0: 65 72 61 6e 67 65 20 7b 69 74 65 6d 73 7d 20 7b  erange {items} {
79e0: 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b  ..set theset ('[
79f0: 6a 6f 69 6e 20 24 69 74 65 6d 73 20 7b 27 2c 27  join $items {','
7a00: 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74  }]')..return [st
7a10: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
7a20: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
7a30: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
7a40: 20 53 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64 61   SELECT MIN(R.da
7a50: 74 65 29 2c 20 4d 41 58 28 52 2e 64 61 74 65 29  te), MAX(R.date)
7a60: 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73  ..    FROM revis
7a70: 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45  ion R..    WHERE
7a80: 20 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65   R.rid IN $these
7a90: 74 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f  t -- Restrict to
7aa0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
7ab0: 74 65 72 65 73 74 0a 09 7d 5d 5d 0a 20 20 20 20  terest..}]].    
7ac0: 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 29  }..    # var(dv)
7ad0: 20 3d 20 64 69 63 74 20 28 72 65 76 69 73 69 6f   = dict (revisio
7ae0: 6e 20 2d 3e 20 6c 69 73 74 20 28 72 65 76 69 73  n -> list (revis
7af0: 69 6f 6e 29 29 0a 20 20 20 20 74 79 70 65 6d 65  ion)).    typeme
7b00: 74 68 6f 64 20 69 6e 74 65 72 6e 61 6c 73 75 63  thod internalsuc
7b10: 63 65 73 73 6f 72 73 20 7b 64 76 20 72 65 76 69  cessors {dv revi
7b20: 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20  sions} {..upvar 
7b30: 31 20 24 64 76 20 64 65 70 65 6e 64 65 6e 63 69  1 $dv dependenci
7b40: 65 73 0a 09 73 65 74 20 74 68 65 73 65 74 20 28  es..set theset (
7b50: 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e  '[join $revision
7b60: 73 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 23 20 53  s {','}]')...# S
7b70: 65 65 20 27 73 75 63 63 65 73 73 6f 72 73 27 20  ee 'successors' 
7b80: 62 65 6c 6f 77 20 66 6f 72 20 74 68 65 20 6d 61  below for the ma
7b90: 69 6e 20 65 78 70 6c 61 6e 61 74 69 6f 6e 20 6f  in explanation o
7ba0: 66 0a 09 23 20 74 68 65 20 76 61 72 69 6f 75 73  f..# the various
7bb0: 20 63 61 73 65 73 2e 20 54 68 69 73 20 70 69 65   cases. This pie
7bc0: 63 65 20 69 73 20 73 70 65 63 69 61 6c 20 69 6e  ce is special in
7bd0: 20 74 68 61 74 20 69 74 0a 09 23 20 72 65 73 74   that it..# rest
7be0: 72 69 63 74 73 20 74 68 65 20 73 75 63 63 65 73  ricts the succes
7bf0: 73 6f 72 73 20 77 65 20 6c 6f 6f 6b 20 66 6f 72  sors we look for
7c00: 20 74 6f 20 74 68 65 20 73 61 6d 65 20 73 65 74   to the same set
7c10: 20 6f 66 0a 09 23 20 72 65 76 69 73 69 6f 6e 73   of..# revisions
7c20: 20 77 65 20 73 74 61 72 74 20 66 72 6f 6d 2e 20   we start from. 
7c30: 53 65 6e 73 69 62 6c 65 20 61 73 20 77 65 20 61  Sensible as we a
7c40: 72 65 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72 0a 09  re looking for..
7c50: 23 20 63 68 61 6e 67 65 73 65 74 20 69 6e 74 65  # changeset inte
7c60: 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65  rnal dependencie
7c70: 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20 64  s....array set d
7c80: 65 70 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68 20  ep {}...foreach 
7c90: 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61  {rid child} [sta
7ca0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
7cb0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
7cc0: 6b 73 6c 61 73 68 65 73 20 7b 0a 20 20 20 20 2d  kslashes {.    -
7cd0: 2d 20 28 31 29 20 50 72 69 6d 61 72 79 20 63 68  - (1) Primary ch
7ce0: 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 43 54 20  ild..    SELECT 
7cf0: 52 2e 72 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09  R.rid, R.child..
7d00: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
7d10: 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45  ion R..    WHERE
7d20: 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68    R.rid   IN $th
7d30: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74  eset     -- Rest
7d40: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e  rict to revision
7d50: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
7d60: 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c     AND    R.chil
7d70: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20  d IS NOT NULL   
7d80: 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20   -- Has primary 
7d90: 63 68 69 6c 64 0a 09 20 20 20 20 41 4e 44 20 20  child..    AND  
7da0: 20 20 52 2e 63 68 69 6c 64 20 49 4e 20 24 74 68    R.child IN $th
7db0: 65 73 65 74 20 20 20 20 20 2d 2d 20 57 68 69 63  eset     -- Whic
7dc0: 68 20 69 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74  h is also of int
7dd0: 65 72 65 73 74 0a 20 20 20 20 55 4e 49 4f 4e 0a  erest.    UNION.
7de0: 20 20 20 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e      -- (2) Secon
7df0: 64 61 72 79 20 28 62 72 61 6e 63 68 29 20 63 68  dary (branch) ch
7e00: 69 6c 64 72 65 6e 0a 09 20 20 20 20 53 45 4c 45  ildren..    SELE
7e10: 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 72 69 64  CT R.rid, B.brid
7e20: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76  ..    FROM   rev
7e30: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
7e40: 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20  nbranchchildren 
7e50: 42 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e  B..    WHERE  R.
7e60: 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74  rid   IN $theset
7e70: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
7e80: 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66   to revisions of
7e90: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41   interest..    A
7ea0: 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20 42 2e  ND    R.rid = B.
7eb0: 72 69 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20  rid          -- 
7ec0: 53 65 6c 65 63 74 20 73 75 62 73 65 74 20 6f 66  Select subset of
7ed0: 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e   branch children
7ee0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 62  ..    AND    B.b
7ef0: 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  rid IN $theset  
7f00: 20 20 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20      -- Which is 
7f10: 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74  also of interest
7f20: 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d  .    UNION.    -
7f30: 2d 20 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74  - (4) Child of t
7f40: 72 75 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73  runk root succes
7f50: 73 6f 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42  sor of last NTDB
7f60: 20 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20   on trunk...    
7f70: 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 41  SELECT R.rid, RA
7f80: 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d  .child..    FROM
7f90: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76   revision R, rev
7fa0: 69 73 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48  ision RA..    WH
7fb0: 45 52 45 20 52 2e 72 69 64 20 20 20 49 4e 20 24  ERE R.rid   IN $
7fc0: 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 52  theset      -- R
7fd0: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
7fe0: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
7ff0: 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 69 73  ..    AND   R.is
8000: 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20 20  default         
8010: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
8020: 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e 44  to NTDB..    AND
8030: 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20     R.dbchild IS 
8040: 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e  NOT NULL   -- an
8050: 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65 6c 6f  d last NTDB belo
8060: 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09  nging to trunk..
8070: 20 20 20 20 41 4e 44 20 20 20 52 41 2e 72 69 64      AND   RA.rid
8080: 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 20 20 20   = R.dbchild    
8090: 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 74 6c 79    -- Go directly
80a0: 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09   to trunk root..
80b0: 20 20 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69      AND   RA.chi
80c0: 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20  ld IS NOT NULL  
80d0: 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79    -- Has primary
80e0: 20 63 68 69 6c 64 2e 0a 20 20 20 20 20 20 20 20   child..        
80f0: 20 20 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69      AND   RA.chi
8100: 6c 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20  ld IN $theset   
8110: 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c    -- Which is al
8120: 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  so of interest..
8130: 7d 5d 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e  }]] {..    # Con
8140: 73 69 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69  sider moving thi
8150: 73 20 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69  s to the integri
8160: 74 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20  ty module...    
8170: 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74  integrity assert
8180: 20 7b 24 72 69 64 20 21 3d 20 24 63 68 69 6c 64   {$rid != $child
8190: 7d 20 7b 52 65 76 69 73 69 6f 6e 20 24 72 69 64  } {Revision $rid
81a0: 20 64 65 70 65 6e 64 73 20 6f 6e 20 69 74 73 65   depends on itse
81b0: 6c 66 2e 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e  lf.}..    lappen
81c0: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 24  d dependencies($
81d0: 72 69 64 29 20 24 63 68 69 6c 64 0a 09 20 20 20  rid) $child..   
81e0: 20 73 65 74 20 64 65 70 28 24 72 69 64 2c 24 63   set dep($rid,$c
81f0: 68 69 6c 64 29 20 2e 0a 09 7d 0a 0a 09 23 20 54  hild) ...}...# T
8200: 68 65 20 73 71 6c 20 73 74 61 74 65 6d 65 6e 74  he sql statement
8210: 73 20 61 62 6f 76 65 20 6c 6f 6f 6b 73 20 6f 6e  s above looks on
8220: 6c 79 20 66 6f 72 20 64 69 72 65 63 74 20 64 65  ly for direct de
8230: 70 65 6e 64 65 6e 63 69 65 73 0a 09 23 20 62 65  pendencies..# be
8240: 74 77 65 65 6e 20 72 65 76 69 73 69 6f 6e 20 69  tween revision i
8250: 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2e  n the changeset.
8260: 20 48 6f 77 65 76 65 72 20 64 75 65 20 74 6f 20   However due to 
8270: 74 68 65 0a 09 23 20 76 61 67 61 72 69 65 73 20  the..# vagaries 
8280: 6f 66 20 6d 65 74 61 20 64 61 74 61 20 69 74 20  of meta data it 
8290: 69 73 20 70 6f 73 73 69 62 6c 65 20 66 6f 72 20  is possible for 
82a0: 74 77 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66  two revisions of
82b0: 0a 09 23 20 74 68 65 20 73 61 6d 65 20 66 69 6c  ..# the same fil
82c0: 65 20 74 6f 20 65 6e 64 20 75 70 20 69 6e 20 74  e to end up in t
82d0: 68 65 20 73 61 6d 65 20 63 68 61 6e 67 65 73 65  he same changese
82e0: 74 2c 20 77 69 74 68 6f 75 74 20 61 0a 09 23 20  t, without a..# 
82f0: 64 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63  direct dependenc
8300: 79 20 62 65 74 77 65 65 6e 20 74 68 65 6d 2e 20  y between them. 
8310: 48 6f 77 65 76 65 72 20 77 65 20 6b 6e 6f 77 20  However we know 
8320: 74 68 61 74 20 74 68 65 72 65 0a 09 23 20 68 61  that there..# ha
8330: 73 20 74 6f 20 62 65 20 61 20 61 6e 20 69 6e 64  s to be a an ind
8340: 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63 79  irect dependency
8350: 2c 20 62 65 20 69 74 20 74 68 72 6f 75 67 68 20  , be it through 
8360: 70 72 69 6d 61 72 79 0a 09 23 20 63 68 69 6c 64  primary..# child
8370: 72 65 6e 2c 20 62 72 61 6e 63 68 20 63 68 69 6c  ren, branch chil
8380: 64 72 65 6e 2c 20 6f 72 20 61 20 63 6f 6d 62 69  dren, or a combi
8390: 6e 61 74 69 6f 6e 20 74 68 65 72 65 6f 66 2e 0a  nation thereof..
83a0: 0a 09 23 20 57 65 20 6e 6f 77 20 66 69 6c 6c 20  ..# We now fill 
83b0: 69 6e 20 74 68 65 73 65 20 70 73 65 75 64 6f 2d  in these pseudo-
83c0: 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 69 66  dependencies, if
83d0: 20 6e 6f 20 73 75 63 68 0a 09 23 20 64 65 70 65   no such..# depe
83e0: 6e 64 65 6e 63 79 20 65 78 69 73 74 73 20 61 6c  ndency exists al
83f0: 72 65 61 64 79 2e 20 54 68 65 20 64 69 72 65 63  ready. The direc
8400: 74 69 6f 6e 20 6f 66 20 74 68 65 20 64 65 70 65  tion of the depe
8410: 6e 64 65 6e 63 79 0a 09 23 20 69 73 20 61 63 74  ndency..# is act
8420: 75 61 6c 6c 79 20 69 72 72 65 6c 65 76 61 6e 74  ually irrelevant
8430: 20 66 6f 72 20 74 68 69 73 2e 0a 0a 09 23 20 4e   for this....# N
8440: 4f 54 45 3a 20 54 68 69 73 20 69 73 20 64 69 66  OTE: This is dif
8450: 66 65 72 65 6e 74 20 66 72 6f 6d 20 63 76 73 32  ferent from cvs2
8460: 73 76 6e 2e 20 4f 75 72 20 73 70 69 72 69 74 75  svn. Our spiritu
8470: 61 6c 20 61 6e 63 65 73 74 6f 72 0a 09 23 20 64  al ancestor..# d
8480: 6f 65 73 20 6e 6f 74 20 75 73 65 20 73 75 63 68  oes not use such
8490: 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 6e   pseudo-dependen
84a0: 63 69 65 73 2c 20 68 6f 77 65 76 65 72 20 69 74  cies, however it
84b0: 20 75 73 65 73 20 61 0a 09 23 20 43 4f 4d 4d 49   uses a..# COMMI
84c0: 54 5f 54 48 52 45 53 48 4f 4c 44 2c 20 61 20 74  T_THRESHOLD, a t
84d0: 69 6d 65 20 69 6e 74 65 72 76 61 6c 20 63 6f 6d  ime interval com
84e0: 6d 69 74 73 20 73 68 6f 75 6c 64 20 66 61 6c 6c  mits should fall
84f0: 2e 20 54 68 69 73 0a 09 23 20 77 69 6c 6c 20 67  . This..# will g
8500: 72 65 61 74 6c 79 20 72 65 64 75 63 65 73 20 74  reatly reduces t
8510: 68 65 20 72 69 73 6b 20 6f 66 20 67 65 74 74 69  he risk of getti
8520: 6e 67 20 66 61 72 20 73 65 70 61 72 61 74 65 64  ng far separated
8530: 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 20 6f 66  ..# revisions of
8540: 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 20 69   the same file i
8550: 6e 74 6f 20 6f 6e 65 20 63 68 61 6e 67 65 73 65  nto one changese
8560: 74 2e 0a 0a 09 23 20 57 65 20 61 6c 6c 6f 77 20  t....# We allow 
8570: 72 65 76 69 73 69 6f 6e 73 20 74 6f 20 62 65 20  revisions to be 
8580: 66 61 72 20 61 70 61 72 74 20 69 6e 20 74 69 6d  far apart in tim
8590: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 0a 09 23  e in the same..#
85a0: 20 63 68 61 6e 67 65 73 65 74 2c 20 62 75 74 20   changeset, but 
85b0: 69 6e 20 74 75 72 6e 20 6e 65 65 64 20 74 68 65  in turn need the
85c0: 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 6e   pseudo-dependen
85d0: 63 69 65 73 20 74 6f 0a 09 23 20 68 61 6e 64 6c  cies to..# handl
85e0: 65 20 74 68 69 73 2e 0a 0a 09 61 72 72 61 79 20  e this....array 
85f0: 73 65 74 20 66 69 64 73 20 7b 7d 0a 09 66 6f 72  set fids {}..for
8600: 65 61 63 68 20 7b 72 69 64 20 66 69 64 7d 20 5b  each {rid fid} [
8610: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74  state run [subst
8620: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f   -nocommands -no
8630: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20  backslashes {.. 
8640: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
8650: 20 52 2e 66 69 64 0a 20 20 20 20 20 20 20 20 20   R.fid.         
8660: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69     FROM   revisi
8670: 6f 6e 20 52 0a 20 20 20 20 20 20 20 20 20 20 20  on R.           
8680: 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 49 4e   WHERE  R.rid IN
8690: 20 24 74 68 65 73 65 74 0a 09 7d 5d 5d 20 7b 20   $theset..}]] { 
86a0: 6c 61 70 70 65 6e 64 20 66 69 64 73 28 24 66 69  lappend fids($fi
86b0: 64 29 20 24 72 69 64 20 7d 0a 0a 09 66 6f 72 65  d) $rid }...fore
86c0: 61 63 68 20 7b 66 69 64 20 72 69 64 73 7d 20 5b  ach {fid rids} [
86d0: 61 72 72 61 79 20 67 65 74 20 66 69 64 73 5d 20  array get fids] 
86e0: 7b 0a 09 20 20 20 20 69 66 20 7b 5b 6c 6c 65 6e  {..    if {[llen
86f0: 67 74 68 20 24 72 69 64 73 5d 20 3c 20 32 7d 20  gth $rids] < 2} 
8700: 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 66 6f  continue..    fo
8710: 72 65 61 63 68 20 61 20 24 72 69 64 73 20 7b 0a  reach a $rids {.
8720: 09 09 66 6f 72 65 61 63 68 20 62 20 24 72 69 64  ..foreach b $rid
8730: 73 20 7b 0a 09 09 20 20 20 20 69 66 20 7b 24 61  s {...    if {$a
8740: 20 3d 3d 20 24 62 7d 20 63 6f 6e 74 69 6e 75 65   == $b} continue
8750: 0a 09 09 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f  ...    if {[info
8760: 20 65 78 69 73 74 73 20 64 65 70 28 24 61 2c 24   exists dep($a,$
8770: 62 29 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09  b)]} continue...
8780: 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78      if {[info ex
8790: 69 73 74 73 20 64 65 70 28 24 62 2c 24 61 29 5d  ists dep($b,$a)]
87a0: 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20  } continue...   
87b0: 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65   lappend depende
87c0: 6e 63 69 65 73 28 24 61 29 20 24 62 0a 09 09 20  ncies($a) $b... 
87d0: 20 20 20 73 65 74 20 64 65 70 28 24 61 2c 24 62     set dep($a,$b
87e0: 29 20 2e 0a 09 09 20 20 20 20 73 65 74 20 64 65  ) ....    set de
87f0: 70 28 24 62 2c 24 61 29 20 2e 0a 09 09 7d 0a 09  p($b,$a) ....}..
8800: 20 20 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e      }..}..return
8810: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65  .    }..    # re
8820: 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28 69  sult = 4-list (i
8830: 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 20 6e  temtype itemid n
8840: 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 78 74  extitemtype next
8850: 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 20  itemid ...).    
8860: 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 73  typemethod loops
8870: 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09   {revisions} {..
8880: 23 20 4e 6f 74 65 3a 20 54 61 67 73 20 61 6e 64  # Note: Tags and
8890: 20 62 72 61 6e 63 68 65 73 20 63 61 6e 6e 6f 74   branches cannot
88a0: 20 63 61 75 73 65 20 74 68 65 20 6c 6f 6f 70 2e   cause the loop.
88b0: 20 54 68 65 69 72 20 69 64 27 73 2c 0a 09 23 20   Their id's,..# 
88c0: 62 65 69 6e 67 20 6f 66 20 61 20 66 75 6e 64 61  being of a funda
88d0: 6d 65 6e 74 61 6c 6c 79 20 64 69 66 66 65 72 65  mentally differe
88e0: 6e 74 20 74 79 70 65 20 74 68 61 6e 20 74 68 65  nt type than the
88f0: 20 72 65 76 69 73 69 6f 6e 73 0a 09 23 20 63 6f   revisions..# co
8900: 6d 69 6e 67 20 69 6e 20 63 61 6e 6e 6f 74 20 62  ming in cannot b
8910: 65 20 69 6e 20 74 68 65 20 73 65 74 2e 0a 0a 09  e in the set....
8920: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f  set theset ('[jo
8930: 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27  in $revisions {'
8940: 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b  ,'}]')..return [
8950: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74  state run [subst
8960: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f   -nocommands -no
8970: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20  backslashes {.. 
8980: 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 72     -- (1) Primar
8990: 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53 45 4c  y child..    SEL
89a0: 45 43 54 20 52 2e 72 69 64 2c 20 52 2e 63 68 69  ECT R.rid, R.chi
89b0: 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72  ld..    FROM   r
89c0: 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57  evision R..    W
89d0: 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e  HERE  R.rid   IN
89e0: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
89f0: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
8a00: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
8a10: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
8a20: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
8a30: 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d  L    -- Has prim
8a40: 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 41  ary child..    A
8a50: 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 4e  ND    R.child IN
8a60: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
8a70: 4c 6f 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20  Loop..    --..  
8a80: 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20    UNION..    -- 
8a90: 28 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62  (2) Secondary (b
8aa0: 72 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a  ranch) children.
8ab0: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69  .    SELECT R.ri
8ac0: 64 2c 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46  d, B.brid..    F
8ad0: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
8ae0: 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68  , revisionbranch
8af0: 63 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20  children B..    
8b00: 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49  WHERE  R.rid   I
8b10: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d  N $theset     --
8b20: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76   Restrict to rev
8b30: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65  isions of intere
8b40: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52  st..    AND    R
8b50: 2e 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20  .rid = B.rid    
8b60: 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20        -- Select 
8b70: 73 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68  subset of branch
8b80: 20 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 41   children..    A
8b90: 4e 44 20 20 20 20 42 2e 72 69 64 20 20 20 49 4e  ND    B.rid   IN
8ba0: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
8bb0: 4c 6f 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20  Loop..    --..  
8bc0: 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20    UNION..    -- 
8bd0: 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75  (4) Child of tru
8be0: 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f  nk root successo
8bf0: 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f  r of last NTDB o
8c00: 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45  n trunk...    SE
8c10: 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63  LECT R.rid, RA.c
8c20: 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  hild..    FROM  
8c30: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76   revision R, rev
8c40: 69 73 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48  ision RA..    WH
8c50: 45 52 45 20 20 52 2e 72 69 64 20 20 20 20 49 4e  ERE  R.rid    IN
8c60: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
8c70: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
8c80: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
8c90: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
8ca0: 69 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20  isdefault       
8cb0: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63        -- Restric
8cc0: 74 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41  t to NTDB..    A
8cd0: 4e 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20  ND    R.dbchild 
8ce0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d  IS NOT NULL   --
8cf0: 20 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62   and last NTDB b
8d00: 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e  elonging to trun
8d10: 6b 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41  k..    AND    RA
8d20: 2e 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64  .rid = R.dbchild
8d30: 20 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65        -- Go dire
8d40: 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f  ctly to trunk ro
8d50: 6f 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52  ot..    AND    R
8d60: 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e  A.child IS NOT N
8d70: 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72  ULL    -- Has pr
8d80: 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 20 20  imary child...  
8d90: 20 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c    AND    RA.chil
8da0: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20  d IN $theset    
8db0: 20 2d 2d 20 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20   -- Loop..}]].  
8dc0: 20 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64    }..    # var(d
8dd0: 76 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20  v) = dict (item 
8de0: 2d 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c  -> list (item)),
8df0: 20 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74   item  = list (t
8e00: 79 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 65  ype id).    type
8e10: 6d 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72  method successor
8e20: 73 20 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 7d  s {dv revisions}
8e30: 20 7b 0a 09 75 70 76 61 72 20 31 20 24 64 76 20   {..upvar 1 $dv 
8e40: 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 65  dependencies..se
8e50: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
8e60: 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27   $revisions {','
8e70: 7d 5d 27 29 0a 0a 09 23 20 54 68 65 20 66 6f 6c  }]')...# The fol
8e80: 6c 6f 77 69 6e 67 20 63 61 73 65 73 20 73 70 65  lowing cases spe
8e90: 63 69 66 79 20 77 68 65 6e 20 61 20 72 65 76 69  cify when a revi
8ea0: 73 69 6f 6e 20 53 20 69 73 20 61 20 73 75 63 63  sion S is a succ
8eb0: 65 73 73 6f 72 0a 09 23 20 6f 66 20 61 20 72 65  essor..# of a re
8ec0: 76 69 73 69 6f 6e 20 52 2e 20 45 61 63 68 20 6f  vision R. Each o
8ed0: 66 20 74 68 65 20 63 61 73 65 73 20 74 72 61 6e  f the cases tran
8ee0: 73 6c 61 74 65 73 20 69 6e 74 6f 20 6f 6e 65 20  slates into one 
8ef0: 6f 66 0a 09 23 20 74 68 65 20 62 72 61 6e 63 68  of..# the branch
8f00: 65 73 20 6f 66 20 74 68 65 20 53 51 4c 20 55 4e  es of the SQL UN
8f10: 49 4f 4e 20 63 6f 6d 69 6e 67 20 62 65 6c 6f 77  ION coming below
8f20: 2e 0a 09 23 0a 09 23 20 28 31 29 20 53 20 63 61  ...#..# (1) S ca
8f30: 6e 20 62 65 20 61 20 70 72 69 6d 61 72 79 20 63  n be a primary c
8f40: 68 69 6c 64 20 6f 66 20 52 2c 20 69 2e 65 2e 20  hild of R, i.e. 
8f50: 69 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 2e  in the same LOD.
8f60: 20 52 0a 09 23 20 20 20 20 20 72 65 66 65 72 65   R..#     refere
8f70: 6e 63 65 73 20 53 20 64 69 72 65 63 74 6c 79 2e  nces S directly.
8f80: 20 52 2e 63 68 69 6c 64 20 3d 20 53 28 2e 72 69   R.child = S(.ri
8f90: 64 29 2c 20 69 66 20 69 74 20 65 78 69 73 74 73  d), if it exists
8fa0: 2e 0a 09 23 0a 09 23 20 28 32 29 20 53 20 63 61  ...#..# (2) S ca
8fb0: 6e 20 62 65 20 61 20 73 65 63 6f 6e 64 61 72 79  n be a secondary
8fc0: 2c 20 69 2e 65 2e 20 62 72 61 6e 63 68 2c 20 63  , i.e. branch, c
8fd0: 68 69 6c 64 20 6f 66 20 52 2e 20 48 65 72 65 20  hild of R. Here 
8fe0: 74 68 65 0a 09 23 20 20 20 20 20 6c 69 6e 6b 20  the..#     link 
8ff0: 69 73 20 6d 61 64 65 20 74 68 72 6f 75 67 68 20  is made through 
9000: 74 68 65 20 68 65 6c 70 65 72 20 74 61 62 6c 65  the helper table
9010: 0a 09 23 20 20 20 20 20 52 45 56 49 53 49 4f 4e  ..#     REVISION
9020: 42 52 41 4e 43 48 43 48 49 4c 44 52 45 4e 2e 20  BRANCHCHILDREN. 
9030: 52 2e 72 69 64 20 2d 3e 20 52 42 43 2e 72 69 64  R.rid -> RBC.rid
9040: 2c 20 52 42 43 2e 62 72 69 64 20 3d 0a 09 23 20  , RBC.brid =..# 
9050: 20 20 20 20 53 28 2e 72 69 64 29 0a 09 23 0a 09      S(.rid)..#..
9060: 23 20 28 33 29 20 4f 72 69 67 69 6e 61 6c 6c 79  # (3) Originally
9070: 20 74 68 69 73 20 75 73 65 20 63 61 73 65 20 64   this use case d
9080: 65 66 69 6e 65 64 20 74 68 65 20 72 6f 6f 74 20  efined the root 
9090: 6f 66 20 61 20 64 65 74 61 63 68 65 64 0a 09 23  of a detached..#
90a0: 20 20 20 20 20 4e 54 44 42 20 61 73 20 74 68 65       NTDB as the
90b0: 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 74 68   successor of th
90c0: 65 20 74 72 75 6e 6b 20 72 6f 6f 74 2e 20 54 68  e trunk root. Th
90d0: 69 73 20 6c 65 61 64 73 20 74 6f 20 61 0a 09 23  is leads to a..#
90e0: 20 20 20 20 20 62 61 64 20 74 61 6e 67 6c 65 20       bad tangle 
90f0: 6c 61 74 65 72 20 6f 6e 2e 20 57 69 74 68 20 61  later on. With a
9100: 20 64 65 74 61 63 68 65 64 20 4e 54 44 42 20 74   detached NTDB t
9110: 68 65 20 6f 72 69 67 69 6e 61 6c 0a 09 23 20 20  he original..#  
9120: 20 20 20 74 72 75 6e 6b 20 72 6f 6f 74 20 72 65     trunk root re
9130: 76 69 73 69 6f 6e 20 77 61 73 20 72 65 6d 6f 76  vision was remov
9140: 65 64 20 61 73 20 69 72 72 65 6c 65 76 61 6e 74  ed as irrelevant
9150: 2c 20 61 6c 6c 6f 77 69 6e 67 0a 09 23 20 20 20  , allowing..#   
9160: 20 20 74 68 65 20 6e 6f 6d 69 6e 61 6c 20 72 6f    the nominal ro
9170: 6f 74 20 74 6f 20 62 65 20 6c 61 74 65 72 20 69  ot to be later i
9180: 6e 20 74 69 6d 65 20 74 68 61 6e 20 74 68 65 20  n time than the 
9190: 4e 54 44 42 0a 09 23 20 20 20 20 20 72 6f 6f 74  NTDB..#     root
91a0: 2e 20 4e 6f 77 20 73 65 74 74 69 6e 67 20 74 68  . Now setting th
91b0: 69 73 20 64 65 70 65 6e 64 65 6e 63 79 20 77 69  is dependency wi
91c0: 6c 6c 20 62 65 20 62 61 63 6b 77 61 72 64 20 69  ll be backward i
91d0: 6e 0a 09 23 20 20 20 20 20 74 69 6d 65 2e 20 52  n..#     time. R
91e0: 45 4d 4f 56 45 44 2e 0a 09 23 0a 09 23 20 28 34  EMOVED...#..# (4
91f0: 29 20 49 66 20 52 20 69 73 20 74 68 65 20 6c 61  ) If R is the la
9200: 73 74 20 6f 66 20 74 68 65 20 4e 54 44 42 20 72  st of the NTDB r
9210: 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 62  evisions which b
9220: 65 6c 6f 6e 67 20 74 6f 0a 09 23 20 20 20 20 20  elong to..#     
9230: 74 68 65 20 74 72 75 6e 6b 2c 20 74 68 65 6e 20  the trunk, then 
9240: 74 68 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c  the primary chil
9250: 64 20 6f 66 20 74 68 65 20 74 72 75 6e 6b 20 72  d of the trunk r
9260: 6f 6f 74 20 28 74 68 65 0a 09 23 20 20 20 20 20  oot (the..#     
9270: 27 31 2e 32 27 20 72 65 76 69 73 69 6f 6e 29 20  '1.2' revision) 
9280: 69 73 20 61 20 73 75 63 63 65 73 73 6f 72 2c 20  is a successor, 
9290: 69 66 20 69 74 20 65 78 69 73 74 73 2e 0a 0a 09  if it exists....
92a0: 23 20 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20  # Note that the 
92b0: 62 72 61 6e 63 68 65 73 20 73 70 61 77 6e 65 64  branches spawned
92c0: 20 66 72 6f 6d 20 74 68 65 20 72 65 76 69 73 69   from the revisi
92d0: 6f 6e 73 2c 20 61 6e 64 20 74 68 65 0a 09 23 20  ons, and the..# 
92e0: 74 61 67 73 20 61 73 73 6f 63 69 61 74 65 64 20  tags associated 
92f0: 77 69 74 68 20 74 68 65 6d 20 61 72 65 20 73 75  with them are su
9300: 63 63 65 73 73 6f 72 73 20 61 73 20 77 65 6c 6c  ccessors as well
9310: 2e 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64  ....foreach {rid
9320: 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72   child} [state r
9330: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d  un [subst -nocom
9340: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61  mands -nobacksla
9350: 73 68 65 73 20 7b 0a 20 20 20 20 2d 2d 20 28 31  shes {.    -- (1
9360: 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c 64 0a  ) Primary child.
9370: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69  .    SELECT R.ri
9380: 64 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20 20 20  d, R.child..    
9390: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
93a0: 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e  R..    WHERE  R.
93b0: 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74  rid   IN $theset
93c0: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74       -- Restrict
93d0: 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66   to revisions of
93e0: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41   interest..    A
93f0: 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 53  ND    R.child IS
9400: 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20   NOT NULL    -- 
9410: 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c  Has primary chil
9420: 64 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20  d.    UNION.    
9430: 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61 72 79  -- (2) Secondary
9440: 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c 64 72   (branch) childr
9450: 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52  en..    SELECT R
9460: 2e 72 69 64 2c 20 42 2e 62 72 69 64 0a 09 20 20  .rid, B.brid..  
9470: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f    FROM   revisio
9480: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 62 72 61  n R, revisionbra
9490: 6e 63 68 63 68 69 6c 64 72 65 6e 20 42 0a 09 20  nchchildren B.. 
94a0: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
94b0: 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20    IN $theset    
94c0: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
94d0: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74  revisions of int
94e0: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20  erest..    AND  
94f0: 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 20    R.rid = B.rid 
9500: 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65           -- Sele
9510: 63 74 20 73 75 62 73 65 74 20 6f 66 20 62 72 61  ct subset of bra
9520: 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 20  nch children.   
9530: 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34   UNION.    -- (4
9540: 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b  ) Child of trunk
9550: 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 20   root successor 
9560: 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20  of last NTDB on 
9570: 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45  trunk...    SELE
9580: 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63 68 69  CT R.rid, RA.chi
9590: 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 76  ld..    FROM rev
95a0: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f  ision R, revisio
95b0: 6e 20 52 41 0a 09 20 20 20 20 57 48 45 52 45 20  n RA..    WHERE 
95c0: 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73  R.rid   IN $thes
95d0: 65 74 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72  et      -- Restr
95e0: 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73  ict to revisions
95f0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
9600: 20 20 41 4e 44 20 20 20 52 2e 69 73 64 65 66 61    AND   R.isdefa
9610: 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20  ult             
9620: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e  -- Restrict to N
9630: 54 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 52  TDB..    AND   R
9640: 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20  .dbchild IS NOT 
9650: 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61  NULL   -- and la
9660: 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e  st NTDB belongin
9670: 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20  g to trunk..    
9680: 41 4e 44 20 20 20 52 41 2e 72 69 64 20 3d 20 52  AND   RA.rid = R
9690: 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d 2d  .dbchild      --
96a0: 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f 20   Go directly to 
96b0: 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20  trunk root..    
96c0: 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64 20 49  AND   RA.child I
96d0: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d  S NOT NULL    --
96e0: 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 69   Has primary chi
96f0: 6c 64 2e 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20  ld...}]] {..    
9700: 23 20 43 6f 6e 73 69 64 65 72 20 6d 6f 76 69 6e  # Consider movin
9710: 67 20 74 68 69 73 20 74 6f 20 74 68 65 20 69 6e  g this to the in
9720: 74 65 67 72 69 74 79 20 6d 6f 64 75 6c 65 2e 0a  tegrity module..
9730: 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61  .    integrity a
9740: 73 73 65 72 74 20 7b 24 72 69 64 20 21 3d 20 24  ssert {$rid != $
9750: 63 68 69 6c 64 7d 20 7b 52 65 76 69 73 69 6f 6e  child} {Revision
9760: 20 24 72 69 64 20 64 65 70 65 6e 64 73 20 6f 6e   $rid depends on
9770: 20 69 74 73 65 6c 66 2e 7d 0a 09 20 20 20 20 6c   itself.}..    l
9780: 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63  append dependenc
9790: 69 65 73 28 5b 6c 69 73 74 20 72 65 76 20 24 72  ies([list rev $r
97a0: 69 64 5d 29 20 5b 6c 69 73 74 20 72 65 76 20 24  id]) [list rev $
97b0: 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 61  child]..}..forea
97c0: 63 68 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b  ch {rid child} [
97d0: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74  state run [subst
97e0: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f   -nocommands -no
97f0: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20  backslashes {.. 
9800: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
9810: 20 54 2e 74 69 64 0a 09 20 20 20 20 46 52 4f 4d   T.tid..    FROM
9820: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 74     revision R, t
9830: 61 67 20 54 0a 09 20 20 20 20 57 48 45 52 45 20  ag T..    WHERE 
9840: 20 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65   R.rid IN $these
9850: 74 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72  t       -- Restr
9860: 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73  ict to revisions
9870: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
9880: 20 20 41 4e 44 20 20 20 20 54 2e 72 65 76 20 3d    AND    T.rev =
9890: 20 52 2e 72 69 64 20 20 20 20 20 20 20 20 20 20   R.rid          
98a0: 2d 2d 20 53 65 6c 65 63 74 20 74 61 67 73 20 61  -- Select tags a
98b0: 74 74 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a  ttached to them.
98c0: 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70  .}]] {..    lapp
98d0: 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73  end dependencies
98e0: 28 5b 6c 69 73 74 20 72 65 76 20 24 72 69 64 5d  ([list rev $rid]
98f0: 29 20 5b 6c 69 73 74 20 73 79 6d 3a 3a 74 61 67  ) [list sym::tag
9900: 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72   $child]..}..for
9910: 65 61 63 68 20 7b 72 69 64 20 63 68 69 6c 64 7d  each {rid child}
9920: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62   [state run [sub
9930: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d  st -nocommands -
9940: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a  nobackslashes {.
9950: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69  .    SELECT R.ri
9960: 64 2c 20 42 2e 62 69 64 0a 09 20 20 20 20 46 52  d, B.bid..    FR
9970: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
9980: 20 62 72 61 6e 63 68 20 42 0a 09 20 20 20 20 57   branch B..    W
9990: 48 45 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24  HERE  R.rid IN $
99a0: 74 68 65 73 65 74 20 20 20 20 20 20 20 2d 2d 20  theset       -- 
99b0: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
99c0: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
99d0: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e  t..    AND    B.
99e0: 72 6f 6f 74 20 3d 20 52 2e 72 69 64 20 20 20 20  root = R.rid    
99f0: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 62       -- Select b
9a00: 72 61 6e 63 68 65 73 20 61 74 74 61 63 68 65 64  ranches attached
9a10: 20 74 6f 20 74 68 65 6d 0a 09 7d 5d 5d 20 7b 0a   to them..}]] {.
9a20: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70  .    lappend dep
9a30: 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20  endencies([list 
9a40: 72 65 76 20 24 72 69 64 5d 29 20 5b 6c 69 73 74  rev $rid]) [list
9a50: 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 63 68   sym::branch $ch
9a60: 69 6c 64 5d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a  ild]..}..return.
9a70: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73      }..    # res
9a80: 75 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e  ult = list (chan
9a90: 67 65 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79  geset-id).    ty
9aa0: 70 65 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63  pemethod cs_succ
9ab0: 65 73 73 6f 72 73 20 7b 72 65 76 69 73 69 6f 6e  essors {revision
9ac0: 73 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 20 54  s} {.        # T
9ad0: 68 69 73 20 69 73 20 61 20 76 61 72 69 61 6e 74  his is a variant
9ae0: 20 6f 66 20 27 73 75 63 63 65 73 73 6f 72 73 27   of 'successors'
9af0: 20 77 68 69 63 68 20 6d 61 70 73 20 74 68 65 20   which maps the 
9b00: 6c 6f 77 2d 6c 65 76 65 6c 0a 20 20 20 20 20 20  low-level.      
9b10: 20 20 23 20 64 61 74 61 20 64 69 72 65 63 74 6c    # data directl
9b20: 79 20 74 6f 20 74 68 65 20 61 73 73 6f 63 69 61  y to the associa
9b30: 74 65 64 20 63 68 61 6e 67 65 73 65 74 73 2e 20  ted changesets. 
9b40: 49 2e 65 2e 20 69 6e 73 74 65 61 64 0a 20 20 20  I.e. instead.   
9b50: 20 20 20 20 20 23 20 6d 69 6c 6c 69 6f 6e 73 20       # millions 
9b60: 6f 66 20 64 65 70 65 6e 64 65 6e 63 79 20 70 61  of dependency pa
9b70: 69 72 73 20 28 69 6e 20 65 78 74 72 65 6d 65 20  irs (in extreme 
9b80: 63 61 73 65 73 20 28 45 78 61 6d 70 6c 65 3a 20  cases (Example: 
9b90: 54 63 6c 0a 20 20 20 20 20 20 20 20 23 20 43 56  Tcl.        # CV
9ba0: 53 29 29 20 77 65 20 72 65 74 75 72 6e 20 61 20  S)) we return a 
9bb0: 76 65 72 79 20 73 68 6f 72 74 20 61 6e 64 20 6d  very short and m
9bc0: 75 63 68 20 6d 6f 72 65 20 6d 61 6e 61 67 65 61  uch more managea
9bd0: 62 6c 65 20 6c 69 73 74 0a 20 20 20 20 20 20 20  ble list.       
9be0: 20 23 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73   # of changesets
9bf0: 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28  ....set theset (
9c00: 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e  '[join $revision
9c10: 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75  s {','}]')..retu
9c20: 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73  rn [state run [s
9c30: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73  ubst -nocommands
9c40: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20   -nobackslashes 
9c50: 7b 0a 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69  {.    -- (1) Pri
9c60: 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20  mary child..    
9c70: 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20  SELECT C.cid..  
9c80: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f    FROM   revisio
9c90: 6e 20 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20  n R, csitem CI, 
9ca0: 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20  changeset C..   
9cb0: 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20   WHERE  R.rid   
9cc0: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
9cd0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65  - Restrict to re
9ce0: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72  visions of inter
9cf0: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  est..    AND    
9d00: 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e  R.child IS NOT N
9d10: 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72  ULL    -- Has pr
9d20: 69 6d 61 72 79 20 63 68 69 6c 64 0a 20 20 20 20  imary child.    
9d30: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
9d40: 49 2e 69 69 64 20 3d 20 52 2e 63 68 69 6c 64 20  I.iid = R.child 
9d50: 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20        -- Select 
9d60: 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20  all changesets. 
9d70: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
9d80: 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64    C.cid = CI.cid
9d90: 20 20 20 20 20 20 20 20 20 2d 2d 20 63 6f 6e 74           -- cont
9da0: 61 69 6e 69 6e 67 20 74 68 65 20 70 72 69 6d 61  aining the prima
9db0: 72 79 20 63 68 69 6c 64 0a 20 20 20 20 20 20 20  ry child.       
9dc0: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79       AND    C.ty
9dd0: 70 65 20 3d 20 30 20 20 20 20 20 20 20 20 20 20  pe = 0          
9de0: 20 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20     -- which are 
9df0: 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73  revision changes
9e00: 65 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20  ets.    UNION.  
9e10: 20 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61    -- (2) Seconda
9e20: 72 79 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c  ry (branch) chil
9e30: 64 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54  dren..    SELECT
9e40: 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d   C.cid..    FROM
9e50: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72     revision R, r
9e60: 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69  evisionbranchchi
9e70: 6c 64 72 65 6e 20 42 2c 20 63 73 69 74 65 6d 20  ldren B, csitem 
9e80: 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a  CI, changeset C.
9e90: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
9ea0: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20  d   IN $theset  
9eb0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
9ec0: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
9ed0: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
9ee0: 20 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69      R.rid = B.ri
9ef0: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65  d          -- Se
9f00: 6c 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62  lect subset of b
9f10: 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 20  ranch children. 
9f20: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
9f30: 20 20 43 49 2e 69 69 64 20 3d 20 42 2e 62 72 69    CI.iid = B.bri
9f40: 64 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65  d        -- Sele
9f50: 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74  ct all changeset
9f60: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e  s.            AN
9f70: 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e  D    C.cid = CI.
9f80: 63 69 64 09 20 20 2d 2d 20 63 6f 6e 74 61 69 6e  cid.  -- contain
9f90: 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68 0a 20  ing the branch. 
9fa0: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
9fb0: 20 20 43 2e 74 79 70 65 20 3d 20 30 09 09 20 20    C.type = 0..  
9fc0: 2d 2d 20 77 68 69 63 68 20 61 72 65 20 72 65 76  -- which are rev
9fd0: 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73  ision changesets
9fe0: 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d  .    UNION.    -
9ff0: 2d 20 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74  - (4) Child of t
a000: 72 75 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73  runk root succes
a010: 73 6f 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42  sor of last NTDB
a020: 20 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20   on trunk...    
a030: 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20  SELECT C.cid..  
a040: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f    FROM   revisio
a050: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41  n R, revision RA
a060: 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61  , csitem CI, cha
a070: 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48  ngeset C..    WH
a080: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20  ERE  R.rid   IN 
a090: 24 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20  $theset      -- 
a0a0: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
a0b0: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
a0c0: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
a0d0: 69 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20  isdefault       
a0e0: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63        -- Restric
a0f0: 74 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41  t to NTDB..    A
a100: 4e 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20  ND    R.dbchild 
a110: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d  IS NOT NULL   --
a120: 20 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62   and last NTDB b
a130: 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e  elonging to trun
a140: 6b 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41  k..    AND    RA
a150: 2e 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64  .rid = R.dbchild
a160: 20 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65        -- Go dire
a170: 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f  ctly to trunk ro
a180: 6f 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52  ot..    AND    R
a190: 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e  A.child IS NOT N
a1a0: 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72  ULL    -- Has pr
a1b0: 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 20 20 20  imary child..   
a1c0: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
a1d0: 43 49 2e 69 69 64 20 3d 20 52 41 2e 63 68 69 6c  CI.iid = RA.chil
a1e0: 64 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63  d       -- Selec
a1f0: 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73  t all changesets
a200: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
a210: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63      C.cid = CI.c
a220: 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e  id.   -- contain
a230: 69 6e 67 20 74 68 65 20 70 72 69 6d 61 72 79 20  ing the primary 
a240: 63 68 69 6c 64 0a 20 20 20 20 20 20 20 20 20 20  child.          
a250: 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20    AND    C.type 
a260: 3d 20 30 09 09 20 20 20 2d 2d 20 77 68 69 63 68  = 0..   -- which
a270: 20 61 72 65 20 72 65 76 69 73 69 6f 6e 20 63 68   are revision ch
a280: 61 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49  angesets.    UNI
a290: 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43  ON..    SELECT C
a2a0: 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  .cid..    FROM  
a2b0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 74 61 67   revision R, tag
a2c0: 20 54 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63   T, csitem CI, c
a2d0: 68 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20  hangeset C..    
a2e0: 57 48 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20  WHERE  R.rid in 
a2f0: 24 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d  $theset        -
a300: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65  - Restrict to re
a310: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72  visions of inter
a320: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  est..    AND    
a330: 54 2e 72 65 76 20 3d 20 52 2e 72 69 64 09 20 20  T.rev = R.rid.  
a340: 20 2d 2d 20 53 65 6c 65 63 74 20 74 61 67 73 20   -- Select tags 
a350: 61 74 74 61 63 68 65 64 20 74 6f 20 74 68 65 6d  attached to them
a360: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
a370: 20 20 20 20 43 49 2e 69 69 64 20 3d 20 54 2e 74      CI.iid = T.t
a380: 69 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53  id          -- S
a390: 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65  elect all change
a3a0: 73 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20  sets.           
a3b0: 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20   AND    C.cid = 
a3c0: 43 49 2e 63 69 64 09 20 20 20 2d 2d 20 63 6f 6e  CI.cid.   -- con
a3d0: 74 61 69 6e 69 6e 67 20 74 68 65 20 74 61 67 73  taining the tags
a3e0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
a3f0: 20 20 20 20 43 2e 74 79 70 65 20 3d 20 31 09 09      C.type = 1..
a400: 20 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20     -- which are 
a410: 74 61 67 20 63 68 61 6e 67 65 73 65 74 73 0a 20  tag changesets. 
a420: 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45     UNION..    SE
a430: 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20  LECT C.cid..    
a440: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
a450: 52 2c 20 62 72 61 6e 63 68 20 42 2c 20 63 73 69  R, branch B, csi
a460: 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65  tem CI, changese
a470: 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20  t C..    WHERE  
a480: 52 2e 72 69 64 20 69 6e 20 24 74 68 65 73 65 74  R.rid in $theset
a490: 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72          -- Restr
a4a0: 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73  ict to revisions
a4b0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
a4c0: 20 20 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20    AND    B.root 
a4d0: 3d 20 52 2e 72 69 64 09 20 20 20 2d 2d 20 53 65  = R.rid.   -- Se
a4e0: 6c 65 63 74 20 62 72 61 6e 63 68 65 73 20 61 74  lect branches at
a4f0: 74 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 20  tached to them. 
a500: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
a510: 20 20 43 49 2e 69 69 64 20 3d 20 42 2e 62 69 64    CI.iid = B.bid
a520: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c            -- Sel
a530: 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65  ect all changese
a540: 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41  ts.            A
a550: 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49  ND    C.cid = CI
a560: 2e 63 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61  .cid.   -- conta
a570: 69 6e 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68  ining the branch
a580: 65 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41  es.            A
a590: 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 32  ND    C.type = 2
a5a0: 09 09 20 20 20 2d 2d 20 77 68 69 63 68 20 61 72  ..   -- which ar
a5b0: 65 20 62 72 61 6e 63 68 20 63 68 61 6e 67 65 73  e branch changes
a5c0: 65 74 73 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 7d  ets..}]].    }.}
a5d0: 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
a5e0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
a5f0: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23  ######### ######
a600: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
a610: 23 23 20 48 65 6c 70 65 72 20 73 69 6e 67 6c 65  ## Helper single
a620: 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73 20 66 6f  ton. Commands fo
a630: 72 20 74 61 67 20 73 79 6d 62 6f 6c 20 63 68 61  r tag symbol cha
a640: 6e 67 65 73 65 74 73 2e 0a 0a 73 6e 69 74 3a 3a  ngesets...snit::
a650: 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  type ::vc::fossi
a660: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
a670: 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a 73 79  project::rev::sy
a680: 6d 3a 3a 74 61 67 20 7b 0a 20 20 20 20 74 79 70  m::tag {.    typ
a690: 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 69  emethod byrevisi
a6a0: 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30  on {} { return 0
a6b0: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f   }.    typemetho
a6c0: 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20  d bysymbol   {} 
a6d0: 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20 20 20  { return 1 }.   
a6e0: 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74 61   typemethod ista
a6f0: 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 75  g      {} { retu
a700: 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 65 6d  rn 1 }.    typem
a710: 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20 20  ethod isbranch  
a720: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d   {} { return 0 }
a730: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64  ..    typemethod
a740: 20 73 74 72 20 7b 74 61 67 7d 20 7b 0a 09 73 74   str {tag} {..st
a750: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
a760: 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09  n [state run {..
a770: 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e 61 6d      SELECT S.nam
a780: 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e 61 6d  e, F.name, P.nam
a790: 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 74 61  e..    FROM   ta
a7a0: 67 20 54 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 66  g T, symbol S, f
a7b0: 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50  ile F, project P
a7c0: 0a 09 20 20 20 20 57 48 45 52 45 20 20 54 2e 74  ..    WHERE  T.t
a7d0: 69 64 20 3d 20 24 74 61 67 20 20 20 2d 2d 20 46  id = $tag   -- F
a7e0: 69 6e 64 20 73 70 65 63 69 66 69 65 64 20 74 61  ind specified ta
a7f0: 67 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46 2e  g..    AND    F.
a800: 66 69 64 20 3d 20 54 2e 66 69 64 20 20 2d 2d 20  fid = T.fid  -- 
a810: 47 65 74 20 66 69 6c 65 20 6f 66 20 74 61 67 0a  Get file of tag.
a820: 09 20 20 20 20 41 4e 44 20 20 20 20 50 2e 70 69  .    AND    P.pi
a830: 64 20 3d 20 46 2e 70 69 64 20 20 2d 2d 20 47 65  d = F.pid  -- Ge
a840: 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 66 69 6c  t project of fil
a850: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 53 2e  e..    AND    S.
a860: 73 69 64 20 3d 20 54 2e 73 69 64 20 20 2d 2d 20  sid = T.sid  -- 
a870: 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 74 61  Get symbol of ta
a880: 67 0a 09 7d 5d 20 73 6e 61 6d 65 20 66 6e 61 6d  g..}] sname fnam
a890: 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20  e pname..return 
a8a0: 22 24 70 6e 61 6d 65 2f 54 27 24 7b 73 6e 61 6d  "$pname/T'${snam
a8b0: 65 7d 27 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20  e}'::$fname".   
a8c0: 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74   }..    # result
a8d0: 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65   = list (mintime
a8e0: 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74  , maxtime).    t
a8f0: 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61  ypemethod timera
a900: 6e 67 65 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20  nge {tags} {..# 
a910: 54 68 65 20 72 61 6e 67 65 20 69 73 20 64 65 66  The range is def
a920: 69 6e 65 64 20 61 73 20 74 68 65 20 72 61 6e 67  ined as the rang
a930: 65 20 6f 66 20 74 68 65 20 72 65 76 69 73 69 6f  e of the revisio
a940: 6e 73 20 74 68 65 20 74 61 67 73 0a 09 23 20 61  ns the tags..# a
a950: 72 65 20 61 74 74 61 63 68 65 64 20 74 6f 2e 0a  re attached to..
a960: 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b  ..set theset ('[
a970: 6a 6f 69 6e 20 24 74 61 67 73 20 7b 27 2c 27 7d  join $tags {','}
a980: 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61  ]')..return [sta
a990: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
a9a0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
a9b0: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
a9c0: 53 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64 61 74  SELECT MIN(R.dat
a9d0: 65 29 2c 20 4d 41 58 28 52 2e 64 61 74 65 29 0a  e), MAX(R.date).
a9e0: 09 20 20 20 20 46 52 4f 4d 20 20 20 74 61 67 20  .    FROM   tag 
a9f0: 54 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20  T, revision R.. 
aa00: 20 20 20 57 48 45 52 45 20 20 54 2e 74 69 64 20     WHERE  T.tid 
aa10: 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d 20 52  IN $theset  -- R
aa20: 65 73 74 72 69 63 74 20 74 6f 20 74 61 67 73 20  estrict to tags 
aa30: 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20 20 20  of interest.    
aa40: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 52          AND    R
aa50: 2e 72 69 64 20 3d 20 54 2e 72 65 76 20 20 20 20  .rid = T.rev    
aa60: 20 2d 2d 20 53 65 6c 65 63 74 20 74 61 67 20 70   -- Select tag p
aa70: 61 72 65 6e 74 20 72 65 76 69 73 69 6f 6e 73 0a  arent revisions.
aa80: 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  .}]].    }..    
aa90: 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 63 74  # var(dv) = dict
aaa0: 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28   (item -> list (
aab0: 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 3d 20  item)), item  = 
aac0: 6c 69 73 74 20 28 74 79 70 65 20 69 64 29 0a 20  list (type id). 
aad0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 75     typemethod su
aae0: 63 63 65 73 73 6f 72 73 20 7b 64 76 20 74 61 67  ccessors {dv tag
aaf0: 73 7d 20 7b 0a 09 23 20 54 61 67 73 20 68 61 76  s} {..# Tags hav
ab00: 65 20 6e 6f 20 73 75 63 63 65 73 73 6f 72 73 2e  e no successors.
ab10: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
ab20: 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 34      # result = 4
ab30: 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70 65 20  -list (itemtype 
ab40: 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65 6d 74  itemid nextitemt
ab50: 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64 20 2e  ype nextitemid .
ab60: 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68  ..).    typemeth
ab70: 6f 64 20 6c 6f 6f 70 73 20 7b 74 61 67 73 7d 20  od loops {tags} 
ab80: 7b 0a 09 23 20 54 61 67 73 20 68 61 76 65 20 6e  {..# Tags have n
ab90: 6f 20 73 75 63 63 65 73 73 6f 72 73 2c 20 74 68  o successors, th
aba0: 65 72 65 66 6f 72 65 20 63 61 6e 6e 6f 74 20 63  erefore cannot c
abb0: 61 75 73 65 20 6c 6f 6f 70 73 0a 09 72 65 74 75  ause loops..retu
abc0: 72 6e 20 7b 7d 0a 20 20 20 20 7d 0a 0a 20 20 20  rn {}.    }..   
abd0: 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74   # result = list
abe0: 20 28 63 68 61 6e 67 65 73 65 74 2d 69 64 29 0a   (changeset-id).
abf0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63      typemethod c
ac00: 73 5f 73 75 63 63 65 73 73 6f 72 73 20 7b 74 61  s_successors {ta
ac10: 67 73 7d 20 7b 0a 09 23 20 54 61 67 73 20 68 61  gs} {..# Tags ha
ac20: 76 65 20 6e 6f 20 73 75 63 63 65 73 73 6f 72 73  ve no successors
ac30: 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  ...return.    }.
ac40: 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23  }..# # ## ### ##
ac50: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
ac60: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23  ########## #####
ac70: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
ac80: 0a 23 23 20 48 65 6c 70 65 72 20 73 69 6e 67 6c  .## Helper singl
ac90: 65 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73 20 66  eton. Commands f
aca0: 6f 72 20 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c  or branch symbol
acb0: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e   changesets...sn
acc0: 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66  it::type ::vc::f
acd0: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63  ossil::import::c
ace0: 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76  vs::project::rev
acf0: 3a 3a 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b 0a  ::sym::branch {.
ad00: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62      typemethod b
ad10: 79 72 65 76 69 73 69 6f 6e 20 7b 7d 20 7b 20 72  yrevision {} { r
ad20: 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74 79  eturn 0 }.    ty
ad30: 70 65 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f  pemethod bysymbo
ad40: 6c 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20  l   {} { return 
ad50: 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68  1 }.    typemeth
ad60: 6f 64 20 69 73 74 61 67 20 20 20 20 20 20 7b 7d  od istag      {}
ad70: 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20   { return 0 }.  
ad80: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 62    typemethod isb
ad90: 72 61 6e 63 68 20 20 20 7b 7d 20 7b 20 72 65 74  ranch   {} { ret
ada0: 75 72 6e 20 31 20 7d 0a 0a 20 20 20 20 74 79 70  urn 1 }..    typ
adb0: 65 6d 65 74 68 6f 64 20 73 74 72 20 7b 62 72 61  emethod str {bra
adc0: 6e 63 68 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a  nch} {..struct::
add0: 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 73 74 61  list assign [sta
ade0: 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45  te run {..    SE
adf0: 4c 45 43 54 20 53 2e 6e 61 6d 65 2c 20 46 2e 6e  LECT S.name, F.n
ae00: 61 6d 65 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20  ame, P.name..   
ae10: 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42   FROM   branch B
ae20: 2c 20 73 79 6d 62 6f 6c 20 53 2c 20 66 69 6c 65  , symbol S, file
ae30: 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a 09 20   F, project P.. 
ae40: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20     WHERE  B.bid 
ae50: 3d 20 24 62 72 61 6e 63 68 20 20 2d 2d 20 46 69  = $branch  -- Fi
ae60: 6e 64 20 73 70 65 63 69 66 69 65 64 20 62 72 61  nd specified bra
ae70: 6e 63 68 0a 09 20 20 20 20 41 4e 44 20 20 20 20  nch..    AND    
ae80: 46 2e 66 69 64 20 3d 20 42 2e 66 69 64 20 20 20  F.fid = B.fid   
ae90: 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20   -- Get file of 
aea0: 62 72 61 6e 63 68 0a 09 20 20 20 20 41 4e 44 20  branch..    AND 
aeb0: 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 69 64     P.pid = F.pid
aec0: 20 20 20 20 2d 2d 20 47 65 74 20 70 72 6f 6a 65      -- Get proje
aed0: 63 74 20 6f 66 20 66 69 6c 65 0a 09 20 20 20 20  ct of file..    
aee0: 41 4e 44 20 20 20 20 53 2e 73 69 64 20 3d 20 42  AND    S.sid = B
aef0: 2e 73 69 64 20 20 20 20 2d 2d 20 47 65 74 20 73  .sid    -- Get s
af00: 79 6d 62 6f 6c 20 6f 66 20 62 72 61 6e 63 68 0a  ymbol of branch.
af10: 09 7d 5d 20 73 6e 61 6d 65 20 66 6e 61 6d 65 20  .}] sname fname 
af20: 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20 22 24  pname..return "$
af30: 70 6e 61 6d 65 2f 42 27 24 7b 73 6e 61 6d 65 7d  pname/B'${sname}
af40: 27 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20 20 7d  '::$fname".    }
af50: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d  ..    # result =
af60: 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20   list (mintime, 
af70: 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74 79 70  maxtime).    typ
af80: 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61 6e 67  emethod timerang
af90: 65 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09  e {branches} {..
afa0: 23 20 54 68 65 20 72 61 6e 67 65 20 6f 66 20 61  # The range of a
afb0: 20 62 72 61 6e 63 68 20 69 73 20 64 65 66 69 6e   branch is defin
afc0: 65 64 20 61 73 20 74 68 65 20 72 61 6e 67 65 20  ed as the range 
afd0: 6f 66 20 74 68 65 0a 09 23 20 72 65 76 69 73 69  of the..# revisi
afe0: 6f 6e 73 20 74 68 65 20 62 72 61 6e 63 68 65 73  ons the branches
aff0: 20 61 72 65 20 73 70 61 77 6e 65 64 20 62 79 2e   are spawned by.
b000: 20 4e 4f 54 45 20 68 6f 77 65 76 65 72 20 74 68   NOTE however th
b010: 61 74 20 74 68 65 0a 09 23 20 62 72 61 6e 63 68  at the..# branch
b020: 65 73 20 61 73 73 6f 63 69 61 74 65 64 20 77 69  es associated wi
b030: 74 68 20 61 20 64 65 74 61 63 68 65 64 20 4e 54  th a detached NT
b040: 44 42 20 77 69 6c 6c 20 68 61 76 65 20 6e 6f 20  DB will have no 
b050: 72 6f 6f 74 0a 09 23 20 73 70 61 77 6e 69 6e 67  root..# spawning
b060: 20 74 68 65 6d 2c 20 68 65 6e 63 65 20 74 68 65   them, hence the
b070: 79 20 68 61 76 65 20 6e 6f 20 72 65 61 6c 20 74  y have no real t
b080: 69 6d 65 72 61 6e 67 65 20 61 6e 79 0a 09 23 20  imerange any..# 
b090: 6c 6f 6e 67 65 72 2e 20 42 79 20 75 73 69 6e 67  longer. By using
b0a0: 20 30 20 77 65 20 70 75 74 20 74 68 65 6d 20 69   0 we put them i
b0b0: 6e 20 66 72 6f 6e 74 20 6f 66 20 65 76 65 72 79  n front of every
b0c0: 74 68 69 6e 67 20 65 6c 73 65 2c 0a 09 23 20 61  thing else,..# a
b0d0: 73 20 74 68 65 79 20 6c 6f 67 69 63 61 6c 6c 79  s they logically
b0e0: 20 61 72 65 2e 0a 0a 09 73 65 74 20 74 68 65 73   are....set thes
b0f0: 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e  et ('[join $bran
b100: 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72  ches {','}]')..r
b110: 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e  eturn [state run
b120: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
b130: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
b140: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  es {..    SELECT
b150: 20 49 46 4e 55 4c 4c 28 4d 49 4e 28 52 2e 64 61   IFNULL(MIN(R.da
b160: 74 65 29 2c 30 29 2c 20 49 46 4e 55 4c 4c 28 4d  te),0), IFNULL(M
b170: 41 58 28 52 2e 64 61 74 65 29 2c 30 29 0a 09 20  AX(R.date),0).. 
b180: 20 20 20 46 52 4f 4d 20 20 62 72 61 6e 63 68 20     FROM  branch 
b190: 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20  B, revision R.. 
b1a0: 20 20 20 57 48 45 52 45 20 42 2e 62 69 64 20 49     WHERE B.bid I
b1b0: 4e 20 24 74 68 65 73 65 74 20 20 20 2d 2d 20 52  N $theset   -- R
b1c0: 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63  estrict to branc
b1d0: 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  hes of interest.
b1e0: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20              AND 
b1f0: 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 6f 6f 74    R.rid = B.root
b200: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 62       -- Select b
b210: 72 61 6e 63 68 20 70 61 72 65 6e 74 20 72 65 76  ranch parent rev
b220: 69 73 69 6f 6e 73 0a 09 7d 5d 5d 0a 20 20 20 20  isions..}]].    
b230: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20  }..    # result 
b240: 3d 20 34 2d 6c 69 73 74 20 28 69 74 65 6d 74 79  = 4-list (itemty
b250: 70 65 20 69 74 65 6d 69 64 20 6e 65 78 74 69 74  pe itemid nextit
b260: 65 6d 74 79 70 65 20 6e 65 78 74 69 74 65 6d 69  emtype nextitemi
b270: 64 20 2e 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d  d ...).    typem
b280: 65 74 68 6f 64 20 6c 6f 6f 70 73 20 7b 62 72 61  ethod loops {bra
b290: 6e 63 68 65 73 7d 20 7b 0a 09 23 20 4e 6f 74 65  nches} {..# Note
b2a0: 3a 20 52 65 76 69 73 69 6f 6e 73 20 61 6e 64 20  : Revisions and 
b2b0: 74 61 67 73 20 63 61 6e 6e 6f 74 20 63 61 75 73  tags cannot caus
b2c0: 65 20 74 68 65 20 6c 6f 6f 70 2e 20 42 65 69 6e  e the loop. Bein
b2d0: 67 20 6f 66 20 61 0a 09 23 20 66 75 6e 64 61 6d  g of a..# fundam
b2e0: 65 6e 74 61 6c 6c 79 20 64 69 66 66 65 72 65 6e  entally differen
b2f0: 74 20 74 79 70 65 20 74 68 65 79 20 63 61 6e 6e  t type they cann
b300: 6f 74 20 62 65 20 69 6e 20 74 68 65 20 69 6e 63  ot be in the inc
b310: 6f 6d 69 6e 67 0a 09 23 20 73 65 74 20 6f 66 20  oming..# set of 
b320: 69 64 73 2e 0a 0a 09 73 65 74 20 74 68 65 73 65  ids....set these
b330: 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63  t ('[join $branc
b340: 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65  hes {','}]')..re
b350: 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20  turn [state run 
b360: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e  [subst -nocomman
b370: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65  ds -nobackslashe
b380: 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20  s {..    SELECT 
b390: 42 2e 62 69 64 2c 20 42 58 2e 62 69 64 0a 09 20  B.bid, BX.bid.. 
b3a0: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68     FROM   branch
b3b0: 20 42 2c 20 70 72 65 66 65 72 65 64 70 61 72 65   B, preferedpare
b3c0: 6e 74 20 50 2c 20 62 72 61 6e 63 68 20 42 58 0a  nt P, branch BX.
b3d0: 09 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69  .    WHERE  B.bi
b3e0: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 2d  d IN $theset   -
b3f0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72  - Restrict to br
b400: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65  anches of intere
b410: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  st..    AND    B
b420: 2e 73 69 64 20 3d 20 50 2e 70 69 64 20 20 20 20  .sid = P.pid    
b430: 20 20 2d 2d 20 47 65 74 20 74 68 65 20 70 72 65    -- Get the pre
b440: 66 65 72 65 64 20 62 72 61 6e 63 68 65 73 20 76  fered branches v
b450: 69 61 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  ia..    AND    B
b460: 58 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20  X.sid = P.sid   
b470: 20 20 2d 2d 20 74 68 65 20 62 72 61 6e 63 68 20    -- the branch 
b480: 73 79 6d 62 6f 6c 73 0a 09 20 20 20 20 41 4e 44  symbols..    AND
b490: 20 20 20 20 42 58 2e 62 69 64 20 49 4e 20 24 74      BX.bid IN $t
b4a0: 68 65 73 65 74 20 20 2d 2d 20 4c 6f 6f 70 0a 09  heset  -- Loop..
b4b0: 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23  }]].    }..    #
b4c0: 20 76 61 72 28 64 76 29 20 3d 20 64 69 63 74 20   var(dv) = dict 
b4d0: 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69  (item -> list (i
b4e0: 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 3d 20 6c  tem)), item  = l
b4f0: 69 73 74 20 28 74 79 70 65 20 69 64 29 0a 20 20  ist (type id).  
b500: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 75 63    typemethod suc
b510: 63 65 73 73 6f 72 73 20 7b 64 76 20 62 72 61 6e  cessors {dv bran
b520: 63 68 65 73 7d 20 7b 0a 09 75 70 76 61 72 20 31  ches} {..upvar 1
b530: 20 24 64 76 20 64 65 70 65 6e 64 65 6e 63 69 65   $dv dependencie
b540: 73 0a 09 23 20 54 68 65 20 66 69 72 73 74 20 72  s..# The first r
b550: 65 76 69 73 69 6f 6e 20 63 6f 6d 6d 69 74 74 65  evision committe
b560: 64 20 6f 6e 20 61 20 62 72 61 6e 63 68 2c 20 61  d on a branch, a
b570: 6e 64 20 61 6c 6c 20 62 72 61 6e 63 68 65 73 0a  nd all branches.
b580: 09 23 20 61 6e 64 20 74 61 67 73 20 77 68 69 63  .# and tags whic
b590: 68 20 68 61 76 65 20 69 74 20 61 73 20 74 68 65  h have it as the
b5a0: 69 72 20 70 72 65 66 65 72 65 64 20 70 61 72 65  ir prefered pare
b5b0: 6e 74 20 61 72 65 20 74 68 65 0a 09 23 20 73 75  nt are the..# su
b5c0: 63 63 65 73 73 6f 72 73 20 6f 66 20 61 20 62 72  ccessors of a br
b5d0: 61 6e 63 68 2e 0a 0a 09 73 65 74 20 74 68 65 73  anch....set thes
b5e0: 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e  et ('[join $bran
b5f0: 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 66  ches {','}]')..f
b600: 6f 72 65 61 63 68 20 7b 62 69 64 20 63 68 69 6c  oreach {bid chil
b610: 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73  d} [state run [s
b620: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73  ubst -nocommands
b630: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20   -nobackslashes 
b640: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e  {..    SELECT B.
b650: 62 69 64 2c 20 52 2e 72 69 64 0a 09 20 20 20 20  bid, R.rid..    
b660: 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c  FROM   branch B,
b670: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20   revision R..   
b680: 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e   WHERE  B.bid IN
b690: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
b6a0: 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e  Restrict to bran
b6b0: 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ches of interest
b6c0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 66  ..    AND    B.f
b6d0: 69 72 73 74 20 3d 20 52 2e 72 69 64 20 20 20 20  irst = R.rid    
b6e0: 20 20 2d 2d 20 47 65 74 20 66 69 72 73 74 20 72    -- Get first r
b6f0: 65 76 69 73 69 6f 6e 20 6f 6e 20 74 68 65 20 62  evision on the b
b700: 72 61 6e 63 68 0a 09 7d 5d 5d 20 7b 0a 09 20 20  ranch..}]] {..  
b710: 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64    lappend depend
b720: 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 73 79 6d  encies([list sym
b730: 3a 3a 62 72 61 6e 63 68 20 24 62 69 64 5d 29 20  ::branch $bid]) 
b740: 5b 6c 69 73 74 20 72 65 76 20 24 63 68 69 6c 64  [list rev $child
b750: 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b 62  ]..}..foreach {b
b760: 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65  id child} [state
b770: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63   run [subst -noc
b780: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73  ommands -nobacks
b790: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45  lashes {..    SE
b7a0: 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 58 2e 62  LECT B.bid, BX.b
b7b0: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62  id..    FROM   b
b7c0: 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65  ranch B, prefere
b7d0: 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61 6e 63  dparent P, branc
b7e0: 68 20 42 58 0a 09 20 20 20 20 57 48 45 52 45 20  h BX..    WHERE 
b7f0: 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65   B.bid IN $these
b800: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63  t     -- Restric
b810: 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66  t to branches of
b820: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41   interest..    A
b830: 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e  ND    B.sid = P.
b840: 70 69 64 20 20 20 20 20 20 20 20 2d 2d 20 47 65  pid        -- Ge
b850: 74 20 73 75 62 6f 72 64 69 6e 61 74 65 20 62 72  t subordinate br
b860: 61 6e 63 68 65 73 20 76 69 61 20 74 68 65 0a 09  anches via the..
b870: 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e 73 69      AND    BX.si
b880: 64 20 3d 20 50 2e 73 69 64 20 20 20 20 20 20 20  d = P.sid       
b890: 2d 2d 20 70 72 65 66 65 72 65 64 20 70 61 72 65  -- prefered pare
b8a0: 6e 74 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d  nts of their sym
b8b0: 62 6f 6c 73 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20  bols..}]] {..   
b8c0: 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65   lappend depende
b8d0: 6e 63 69 65 73 28 5b 6c 69 73 74 20 73 79 6d 3a  ncies([list sym:
b8e0: 3a 62 72 61 6e 63 68 20 24 62 69 64 5d 29 20 5b  :branch $bid]) [
b8f0: 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68  list sym::branch
b900: 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72   $child]..}..for
b910: 65 61 63 68 20 7b 62 69 64 20 63 68 69 6c 64 7d  each {bid child}
b920: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62   [state run [sub
b930: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d  st -nocommands -
b940: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a  nobackslashes {.
b950: 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69  .    SELECT B.bi
b960: 64 2c 20 54 2e 74 69 64 0a 09 20 20 20 20 46 52  d, T.tid..    FR
b970: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70  OM   branch B, p
b980: 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c  referedparent P,
b990: 20 74 61 67 20 54 0a 09 20 20 20 20 57 48 45 52   tag T..    WHER
b9a0: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65  E  B.bid IN $the
b9b0: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72  set     -- Restr
b9c0: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20  ict to branches 
b9d0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
b9e0: 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20   AND    B.sid = 
b9f0: 50 2e 70 69 64 20 20 20 20 20 20 20 20 2d 2d 20  P.pid        -- 
ba00: 47 65 74 20 73 75 62 6f 72 64 69 6e 61 74 65 20  Get subordinate 
ba10: 74 61 67 73 20 76 69 61 20 74 68 65 0a 09 20 20  tags via the..  
ba20: 20 20 41 4e 44 20 20 20 20 54 2e 73 69 64 20 3d    AND    T.sid =
ba30: 20 50 2e 73 69 64 20 20 20 20 20 20 20 20 2d 2d   P.sid        --
ba40: 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74   prefered parent
ba50: 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d 62 6f  s of their symbo
ba60: 6c 73 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c  ls..}]] {..    l
ba70: 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63  append dependenc
ba80: 69 65 73 28 5b 6c 69 73 74 20 73 79 6d 3a 3a 62  ies([list sym::b
ba90: 72 61 6e 63 68 20 24 62 69 64 5d 29 20 5b 6c 69  ranch $bid]) [li
baa0: 73 74 20 73 79 6d 3a 3a 74 61 67 20 24 63 68 69  st sym::tag $chi
bab0: 6c 64 5d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20  ld]..}..return. 
bac0: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75     }..    # resu
bad0: 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e 67  lt = list (chang
bae0: 65 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79 70  eset-id).    typ
baf0: 65 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63 65  emethod cs_succe
bb00: 73 73 6f 72 73 20 7b 62 72 61 6e 63 68 65 73 7d  ssors {branches}
bb10: 20 7b 0a 20 20 20 20 20 20 20 20 23 20 54 68 69   {.        # Thi
bb20: 73 20 69 73 20 61 20 76 61 72 69 61 6e 74 20 6f  s is a variant o
bb30: 66 20 27 73 75 63 63 65 73 73 6f 72 73 27 20 77  f 'successors' w
bb40: 68 69 63 68 20 6d 61 70 73 20 74 68 65 20 6c 6f  hich maps the lo
bb50: 77 2d 6c 65 76 65 6c 0a 20 20 20 20 20 20 20 20  w-level.        
bb60: 23 20 64 61 74 61 20 64 69 72 65 63 74 6c 79 20  # data directly 
bb70: 74 6f 20 74 68 65 20 61 73 73 6f 63 69 61 74 65  to the associate
bb80: 64 20 63 68 61 6e 67 65 73 65 74 73 2e 20 49 2e  d changesets. I.
bb90: 65 2e 20 69 6e 73 74 65 61 64 0a 20 20 20 20 20  e. instead.     
bba0: 20 20 20 23 20 6d 69 6c 6c 69 6f 6e 73 20 6f 66     # millions of
bbb0: 20 64 65 70 65 6e 64 65 6e 63 79 20 70 61 69 72   dependency pair
bbc0: 73 20 28 69 6e 20 65 78 74 72 65 6d 65 20 63 61  s (in extreme ca
bbd0: 73 65 73 20 28 45 78 61 6d 70 6c 65 3a 20 54 63  ses (Example: Tc
bbe0: 6c 0a 20 20 20 20 20 20 20 20 23 20 43 56 53 29  l.        # CVS)
bbf0: 29 20 77 65 20 72 65 74 75 72 6e 20 61 20 76 65  ) we return a ve
bc00: 72 79 20 73 68 6f 72 74 20 61 6e 64 20 6d 75 63  ry short and muc
bc10: 68 20 6d 6f 72 65 20 6d 61 6e 61 67 65 61 62 6c  h more manageabl
bc20: 65 20 6c 69 73 74 0a 20 20 20 20 20 20 20 20 23  e list.        #
bc30: 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73 2e 0a   of changesets..
bc40: 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b  ..set theset ('[
bc50: 6a 6f 69 6e 20 24 62 72 61 6e 63 68 65 73 20 7b  join $branches {
bc60: 27 2c 27 7d 5d 27 29 0a 20 20 20 20 20 20 20 20  ','}]').        
bc70: 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75  return [state ru
bc80: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
bc90: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
bca0: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  hes {..    SELEC
bcb0: 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f  T C.cid..    FRO
bcc0: 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 72 65  M   branch B, re
bcd0: 76 69 73 69 6f 6e 20 52 2c 20 63 73 69 74 65 6d  vision R, csitem
bce0: 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43   CI, changeset C
bcf0: 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e 62  ..    WHERE  B.b
bd00: 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20  id IN $theset   
bd10: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
bd20: 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74   branches of int
bd30: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20  erest..    AND  
bd40: 20 20 42 2e 66 69 72 73 74 20 3d 20 52 2e 72 69    B.first = R.ri
bd50: 64 09 2d 2d 20 47 65 74 20 66 69 72 73 74 20 72  d.-- Get first r
bd60: 65 76 69 73 69 6f 6e 20 6f 6e 20 74 68 65 20 62  evision on the b
bd70: 72 61 6e 63 68 0a 20 20 20 20 20 20 20 20 20 20  ranch.          
bd80: 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20    AND    CI.iid 
bd90: 3d 20 52 2e 72 69 64 20 20 20 20 20 20 20 2d 2d  = R.rid       --
bda0: 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e   Select all chan
bdb0: 67 65 73 65 74 73 0a 20 20 20 20 20 20 20 20 20  gesets.         
bdc0: 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20     AND    C.cid 
bdd0: 3d 20 43 49 2e 63 69 64 09 2d 2d 20 63 6f 6e 74  = CI.cid.-- cont
bde0: 61 69 6e 69 6e 67 20 74 68 69 73 20 72 65 76 69  aining this revi
bdf0: 73 69 6f 6e 0a 20 20 20 20 20 20 20 20 20 20 20  sion.           
be00: 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d   AND    C.type =
be10: 20 30 09 09 2d 2d 20 77 68 69 63 68 20 61 72 65   0..-- which are
be20: 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65   revision change
be30: 73 65 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 09  sets.    UNION..
be40: 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64      SELECT C.cid
be50: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61  ..    FROM   bra
be60: 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 70  nch B, preferedp
be70: 61 72 65 6e 74 20 50 2c 20 62 72 61 6e 63 68 20  arent P, branch 
be80: 42 58 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63  BX, csitem CI, c
be90: 68 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20  hangeset C..    
bea0: 57 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20  WHERE  B.bid IN 
beb0: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52  $theset     -- R
bec0: 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63  estrict to branc
bed0: 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  hes of interest.
bee0: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 73 69  .    AND    B.si
bef0: 64 20 3d 20 50 2e 70 69 64 09 2d 2d 20 47 65 74  d = P.pid.-- Get
bf00: 20 73 75 62 6f 72 64 69 6e 61 74 65 20 62 72 61   subordinate bra
bf10: 6e 63 68 65 73 20 76 69 61 20 74 68 65 0a 09 20  nches via the.. 
bf20: 20 20 20 41 4e 44 20 20 20 20 42 58 2e 73 69 64     AND    BX.sid
bf30: 20 3d 20 50 2e 73 69 64 09 2d 2d 20 70 72 65 66   = P.sid.-- pref
bf40: 65 72 65 64 20 70 61 72 65 6e 74 73 20 6f 66 20  ered parents of 
bf50: 74 68 65 69 72 20 73 79 6d 62 6f 6c 73 0a 20 20  their symbols.  
bf60: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
bf70: 20 43 49 2e 69 69 64 20 3d 20 42 58 2e 62 69 64   CI.iid = BX.bid
bf80: 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20        -- Select 
bf90: 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20  all changesets. 
bfa0: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
bfb0: 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64    C.cid = CI.cid
bfc0: 09 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74  .-- containing t
bfd0: 68 65 20 73 75 62 6f 72 64 69 6e 61 74 65 20 62  he subordinate b
bfe0: 72 61 6e 63 68 65 73 0a 20 20 20 20 20 20 20 20  ranches.        
bff0: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70      AND    C.typ
c000: 65 20 3d 20 32 09 09 2d 2d 20 77 68 69 63 68 20  e = 2..-- which 
c010: 61 72 65 20 62 72 61 6e 63 68 20 63 68 61 6e 67  are branch chang
c020: 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a  esets.    UNION.
c030: 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69  .    SELECT C.ci
c040: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72  d..    FROM   br
c050: 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65 64  anch B, prefered
c060: 70 61 72 65 6e 74 20 50 2c 20 74 61 67 20 54 2c  parent P, tag T,
c070: 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e   csitem CI, chan
c080: 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45  geset C..    WHE
c090: 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68  RE  B.bid IN $th
c0a0: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74  eset     -- Rest
c0b0: 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73  rict to branches
c0c0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20   of interest..  
c0d0: 20 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20 3d    AND    B.sid =
c0e0: 20 50 2e 70 69 64 09 2d 2d 20 47 65 74 20 73 75   P.pid.-- Get su
c0f0: 62 6f 72 64 69 6e 61 74 65 20 74 61 67 73 20 76  bordinate tags v
c100: 69 61 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20  ia the..    AND 
c110: 20 20 20 54 2e 73 69 64 20 3d 20 50 2e 73 69 64     T.sid = P.sid
c120: 09 2d 2d 20 70 72 65 66 65 72 65 64 20 70 61 72  .-- prefered par
c130: 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20 73 79  ents of their sy
c140: 6d 62 6f 6c 73 0a 20 20 20 20 20 20 20 20 20 20  mbols.          
c150: 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20    AND    CI.iid 
c160: 3d 20 54 2e 74 69 64 20 20 20 20 20 20 20 2d 2d  = T.tid       --
c170: 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e   Select all chan
c180: 67 65 73 65 74 73 0a 20 20 20 20 20 20 20 20 20  gesets.         
c190: 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20     AND    C.cid 
c1a0: 3d 20 43 49 2e 63 69 64 09 2d 2d 20 63 6f 6e 74  = CI.cid.-- cont
c1b0: 61 69 6e 69 6e 67 20 74 68 65 20 73 75 62 6f 72  aining the subor
c1c0: 64 69 6e 61 74 65 20 74 61 67 73 0a 20 20 20 20  dinate tags.    
c1d0: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
c1e0: 2e 74 79 70 65 20 3d 20 31 09 09 2d 2d 20 77 68  .type = 1..-- wh
c1f0: 69 63 68 20 61 72 65 20 74 61 67 20 63 68 61 6e  ich are tag chan
c200: 67 65 73 65 74 73 0a 09 7d 5d 5d 0a 09 72 65 74  gesets..}]]..ret
c210: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74  urn.    }..    t
c220: 79 70 65 6d 65 74 68 6f 64 20 6c 69 6d 69 74 73  ypemethod limits
c230: 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 23   {branches} {..#
c240: 20 4e 6f 74 65 73 2e 20 54 68 69 73 20 6d 65 74   Notes. This met
c250: 68 6f 64 20 65 78 69 73 74 73 20 6f 6e 6c 79 20  hod exists only 
c260: 66 6f 72 20 62 72 61 6e 63 68 65 73 2e 20 49 74  for branches. It
c270: 20 69 73 20 6e 65 65 64 65 64 20 74 6f 0a 09 23   is needed to..#
c280: 20 67 65 74 20 64 65 74 61 69 6c 65 64 20 69 6e   get detailed in
c290: 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 20  formation about 
c2a0: 61 20 62 61 63 6b 77 61 72 64 20 62 72 61 6e 63  a backward branc
c2b0: 68 2e 20 49 74 20 64 6f 65 73 0a 09 23 20 6e 6f  h. It does..# no
c2c0: 74 20 61 70 70 6c 79 20 74 6f 20 74 61 67 73 2c  t apply to tags,
c2d0: 20 6e 6f 72 20 72 65 76 69 73 69 6f 6e 73 2e 20   nor revisions. 
c2e0: 54 68 65 20 71 75 65 72 69 65 73 20 63 61 6e 20  The queries can 
c2f0: 61 6c 73 6f 0a 09 23 20 72 65 73 74 72 69 63 74  also..# restrict
c300: 20 74 68 65 6d 73 65 6c 76 65 73 20 74 6f 20 74   themselves to t
c310: 68 65 20 72 65 76 69 73 69 6f 6e 20 73 75 63 65  he revision suce
c320: 73 73 6f 72 73 2f 70 72 65 64 65 63 65 73 73 6f  ssors/predecesso
c330: 72 73 0a 09 23 20 6f 66 20 62 72 61 6e 63 68 65  rs..# of branche
c340: 73 2c 20 61 73 20 6f 6e 6c 79 20 74 68 65 79 20  s, as only they 
c350: 68 61 76 65 20 6f 72 64 65 72 69 6e 67 20 64 61  have ordering da
c360: 74 61 20 61 6e 64 20 74 68 75 73 20 63 61 6e 0a  ta and thus can.
c370: 09 23 20 63 61 75 73 65 20 74 68 65 20 62 61 63  .# cause the bac
c380: 6b 77 61 72 64 6e 65 73 73 2e 0a 0a 09 73 65 74  kwardness....set
c390: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20   theset ('[join 
c3a0: 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d  $branches {','}]
c3b0: 27 29 0a 0a 09 73 65 74 20 6d 61 78 70 20 5b 73  ')...set maxp [s
c3c0: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
c3d0: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
c3e0: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
c3f0: 20 20 2d 2d 20 6d 61 78 69 6d 61 6c 20 70 72 65    -- maximal pre
c400: 64 65 63 65 73 73 6f 72 20 70 6f 73 69 74 69 6f  decessor positio
c410: 6e 20 70 65 72 20 62 72 61 6e 63 68 0a 09 20 20  n per branch..  
c420: 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20    SELECT B.bid, 
c430: 4d 41 58 20 28 43 4f 2e 70 6f 73 29 0a 09 20 20  MAX (CO.pos)..  
c440: 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20    FROM   branch 
c450: 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 63  B, revision R, c
c460: 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65  sitem CI, change
c470: 73 65 74 20 43 2c 20 63 73 6f 72 64 65 72 20 43  set C, csorder C
c480: 4f 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e  O..    WHERE  B.
c490: 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  bid IN $theset  
c4a0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
c4b0: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e  o branches of in
c4c0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
c4d0: 20 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69     B.root = R.ri
c4e0: 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 62  d       -- Get b
c4f0: 72 61 6e 63 68 20 72 6f 6f 74 20 72 65 76 69 73  ranch root revis
c500: 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20 20 20  ions..    AND   
c510: 20 43 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 20   CI.iid = R.rid 
c520: 20 20 20 20 20 20 2d 2d 20 47 65 74 20 63 68 61        -- Get cha
c530: 6e 67 65 73 65 74 73 20 63 6f 6e 74 61 69 6e 69  ngesets containi
c540: 6e 67 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20  ng the..    AND 
c550: 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69     C.cid = CI.ci
c560: 64 20 20 20 20 20 20 20 2d 2d 20 72 6f 6f 74 20  d       -- root 
c570: 72 65 76 69 73 69 6f 6e 73 2c 20 77 68 69 63 68  revisions, which
c580: 20 61 72 65 0a 09 20 20 20 20 41 4e 44 20 20 20   are..    AND   
c590: 20 43 2e 74 79 70 65 20 3d 20 30 20 20 20 20 20   C.type = 0     
c5a0: 20 20 20 20 20 20 2d 2d 20 72 65 76 69 73 69 6f        -- revisio
c5b0: 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 09 20 20  n changesets..  
c5c0: 20 20 41 4e 44 20 20 20 20 43 4f 2e 63 69 64 20    AND    CO.cid 
c5d0: 3d 20 43 2e 63 69 64 20 20 20 20 20 20 20 2d 2d  = C.cid       --
c5e0: 20 47 65 74 20 74 68 65 69 72 20 74 6f 70 6f 6c   Get their topol
c5f0: 6f 67 69 63 61 6c 20 6f 72 64 65 72 69 6e 67 0a  ogical ordering.
c600: 09 20 20 20 20 47 52 4f 55 50 20 42 59 20 42 2e  .    GROUP BY B.
c610: 62 69 64 0a 09 7d 5d 5d 0a 0a 09 73 65 74 20 6d  bid..}]]...set m
c620: 69 6e 73 20 5b 73 74 61 74 65 20 72 75 6e 20 5b  ins [state run [
c630: 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64  subst -nocommand
c640: 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73  s -nobackslashes
c650: 20 7b 0a 09 20 20 20 20 2d 2d 20 6d 69 6e 69 6d   {..    -- minim
c660: 61 6c 20 73 75 63 63 65 73 73 6f 72 20 70 6f 73  al successor pos
c670: 69 74 69 6f 6e 20 70 65 72 20 62 72 61 6e 63 68  ition per branch
c680: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62  ..    SELECT B.b
c690: 69 64 2c 20 4d 49 4e 20 28 43 4f 2e 70 6f 73 29  id, MIN (CO.pos)
c6a0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61  ..    FROM   bra
c6b0: 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20  nch B, revision 
c6c0: 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68  R, csitem CI, ch
c6d0: 61 6e 67 65 73 65 74 20 43 2c 20 63 73 6f 72 64  angeset C, csord
c6e0: 65 72 20 43 4f 0a 09 20 20 20 20 57 48 45 52 45  er CO..    WHERE
c6f0: 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73    B.bid IN $thes
c700: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  et     -- Restri
c710: 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f  ct to branches o
c720: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20  f interest..    
c730: 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20 3d  AND    B.first =
c740: 20 52 2e 72 69 64 20 20 20 20 20 20 2d 2d 20 47   R.rid      -- G
c750: 65 74 20 74 68 65 20 66 69 72 73 74 20 72 65 76  et the first rev
c760: 69 73 69 6f 6e 73 20 6f 6e 20 74 68 65 20 62 72  isions on the br
c770: 61 6e 63 68 65 73 0a 09 20 20 20 20 41 4e 44 20  anches..    AND 
c780: 20 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 72 69     CI.iid = R.ri
c790: 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 63  d       -- Get c
c7a0: 68 61 6e 67 65 73 65 74 73 20 63 6f 6e 74 61 69  hangesets contai
c7b0: 6e 69 6e 67 20 74 68 65 0a 09 20 20 20 20 41 4e  ning the..    AN
c7c0: 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e  D    C.cid = CI.
c7d0: 63 69 64 09 2d 2d 20 66 69 72 73 74 20 72 65 76  cid.-- first rev
c7e0: 69 73 69 6f 6e 73 2c 20 77 68 69 63 68 20 61 72  isions, which ar
c7f0: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 2e  e..    AND    C.
c800: 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 72 65 76  type = 0..-- rev
c810: 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73  ision changesets
c820: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 4f 2e  ..    AND    CO.
c830: 63 69 64 20 3d 20 43 2e 63 69 64 09 2d 2d 20 47  cid = C.cid.-- G
c840: 65 74 20 74 68 65 69 72 20 74 6f 70 6f 6c 6f 67  et their topolog
c850: 69 63 61 6c 20 6f 72 64 65 72 69 6e 67 0a 09 20  ical ordering.. 
c860: 20 20 20 47 52 4f 55 50 20 42 59 20 42 2e 62 69     GROUP BY B.bi
c870: 64 0a 09 7d 5d 5d 0a 0a 20 20 20 20 20 20 20 20  d..}]]..        
c880: 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24 6d 61  return [list $ma
c890: 78 70 20 24 6d 69 6e 73 5d 0a 20 20 20 20 7d 0a  xp $mins].    }.
c8a0: 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20  .    # # ## ### 
c8b0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
c8c0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20  ############.   
c8d0: 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74 69 6f   ## Configuratio
c8e0: 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68  n..    pragma -h
c8f0: 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20 6e 6f  asinstances   no
c900: 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e 0a 20   ; # singleton. 
c910: 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79     pragma -hasty
c920: 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b 20 23  peinfo    no ; #
c930: 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74 69 6f   no introspectio
c940: 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61  n.    pragma -ha
c950: 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e 6f 20  stypedestroy no 
c960: 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 7d 0a 0a  ; # immortal.}..
c970: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
c980: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
c990: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
c9a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23  #############.##
c9b0: 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c  ..namespace eval
c9c0: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
c9d0: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a  mport::cvs::proj
c9e0: 65 63 74 20 7b 0a 20 20 20 20 6e 61 6d 65 73 70  ect {.    namesp
c9f0: 61 63 65 20 65 78 70 6f 72 74 20 72 65 76 0a 20  ace export rev. 
ca00: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61     namespace eva
ca10: 6c 20 72 65 76 20 7b 0a 09 6e 61 6d 65 73 70 61  l rev {..namespa
ca20: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
ca30: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
ca40: 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65  cvs::state..name
ca50: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
ca60: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
ca70: 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74  t::cvs::integrit
ca80: 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70  y..namespace imp
ca90: 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a  ort ::vc::tools:
caa0: 3a 6d 69 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73 70  :misc::*..namesp
cab0: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
cac0: 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 0a  :tools::trouble.
cad0: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
cae0: 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c  t ::vc::tools::l
caf0: 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65 72  og..log register
cb00: 20 63 73 65 74 73 0a 0a 09 23 20 53 65 74 20 75   csets...# Set u
cb10: 70 20 74 68 65 20 68 65 6c 70 65 72 20 73 69 6e  p the helper sin
cb20: 67 6c 65 74 6f 6e 73 0a 09 6e 61 6d 65 73 70 61  gletons..namespa
cb30: 63 65 20 65 76 61 6c 20 72 65 76 20 7b 0a 09 20  ce eval rev {.. 
cb40: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70     namespace imp
cb50: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
cb60: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73  ::import::cvs::s
cb70: 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 70  tate..    namesp
cb80: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
cb90: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
cba0: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a  :cvs::integrity.
cbb0: 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76  .}..namespace ev
cbc0: 61 6c 20 73 79 6d 3a 3a 74 61 67 20 7b 0a 09 20  al sym::tag {.. 
cbd0: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70     namespace imp
cbe0: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ort ::vc::fossil
cbf0: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73  ::import::cvs::s
cc00: 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 70  tate..    namesp
cc10: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
cc20: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
cc30: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a  :cvs::integrity.
cc40: 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76  .}..namespace ev
cc50: 61 6c 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b  al sym::branch {
cc60: 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20  ..    namespace 
cc70: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73  import ::vc::fos
cc80: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
cc90: 3a 3a 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d  ::state..    nam
cca0: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
ccb0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
ccc0: 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69  rt::cvs::integri
ccd0: 74 79 0a 09 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 23  ty..}.    }.}..#
cce0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
ccf0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
cd00: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
cd10: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
cd20: 52 65 61 64 79 0a 0a 70 61 63 6b 61 67 65 20 70  Ready..package p
cd30: 72 6f 76 69 64 65 20 76 63 3a 3a 66 6f 73 73 69  rovide vc::fossi
cd40: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
cd50: 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20 31 2e 30  project::rev 1.0
cd60: 0a 72 65 74 75 72 6e 0a                          .return.