Hex Artifact Content
Not logged in

Artifact 3b42fd437ed34cffd6791a91aa0894e7a3024aca:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [0d13da3018] - Get the line of development for changesets directly from the items and their lod references. The in-memory data from the meta table is out-of-date since the adjustment of parents in pass 'FilterSymbols'. Print the LOD information when sorting the changesets. by aku on 2008-02-06 04:55:34.

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 6c 6f 64  ..    method lod
0a30: 20 7b 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 24   {} {..return [$
0a40: 6d 79 74 79 70 65 6f 62 6a 20 63 73 5f 6c 6f 64  mytypeobj cs_lod
0a50: 20 24 6d 79 69 74 65 6d 73 5d 0a 20 20 20 20 7d   $myitems].    }
0a60: 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 69 64 20  ..    method id 
0a70: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 24     {} { return $
0a80: 6d 79 69 64 20 7d 0a 20 20 20 20 6d 65 74 68 6f  myid }.    metho
0a90: 64 20 69 74 65 6d 73 20 7b 7d 20 7b 20 72 65 74  d items {} { ret
0aa0: 75 72 6e 20 24 6d 79 74 69 74 65 6d 73 20 7d 0a  urn $mytitems }.
0ab0: 20 20 20 20 6d 65 74 68 6f 64 20 64 61 74 61 20      method data 
0ac0: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69   {} { return [li
0ad0: 73 74 20 24 6d 79 70 72 6f 6a 65 63 74 20 24 6d  st $myproject $m
0ae0: 79 74 79 70 65 20 24 6d 79 73 72 63 69 64 5d 20  ytype $mysrcid] 
0af0: 7d 0a 0a 20 20 20 20 64 65 6c 65 67 61 74 65 20  }..    delegate 
0b00: 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20  method bysymbol 
0b10: 20 20 74 6f 20 6d 79 74 79 70 65 6f 62 6a 0a 20    to mytypeobj. 
0b20: 20 20 20 64 65 6c 65 67 61 74 65 20 6d 65 74 68     delegate meth
0b30: 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20 74 6f  od byrevision to
0b40: 20 6d 79 74 79 70 65 6f 62 6a 0a 20 20 20 20 64   mytypeobj.    d
0b50: 65 6c 65 67 61 74 65 20 6d 65 74 68 6f 64 20 69  elegate method i
0b60: 73 62 72 61 6e 63 68 20 20 20 74 6f 20 6d 79 74  sbranch   to myt
0b70: 79 70 65 6f 62 6a 0a 20 20 20 20 64 65 6c 65 67  ypeobj.    deleg
0b80: 61 74 65 20 6d 65 74 68 6f 64 20 69 73 74 61 67  ate method istag
0b90: 20 20 20 20 20 20 74 6f 20 6d 79 74 79 70 65 6f        to mytypeo
0ba0: 62 6a 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 73  bj..    method s
0bb0: 65 74 70 6f 73 20 7b 70 7d 20 7b 20 73 65 74 20  etpos {p} { set 
0bc0: 6d 79 70 6f 73 20 24 70 20 3b 20 72 65 74 75 72  mypos $p ; retur
0bd0: 6e 20 7d 0a 20 20 20 20 6d 65 74 68 6f 64 20 70  n }.    method p
0be0: 6f 73 20 20 20 20 7b 7d 20 20 7b 20 72 65 74 75  os    {}  { retu
0bf0: 72 6e 20 24 6d 79 70 6f 73 20 7d 0a 0a 20 20 20  rn $mypos }..   
0c00: 20 6d 65 74 68 6f 64 20 64 65 74 65 72 6d 69 6e   method determin
0c10: 65 73 75 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b  esuccessors {} {
0c20: 0a 09 23 20 50 61 73 73 20 36 20 6f 70 65 72 61  ..# Pass 6 opera
0c30: 74 69 6f 6e 2e 20 43 6f 6d 70 75 74 65 20 70 72  tion. Compute pr
0c40: 6f 6a 65 63 74 2d 6c 65 76 65 6c 20 64 65 70 65  oject-level depe
0c50: 6e 64 65 6e 63 69 65 73 20 66 72 6f 6d 0a 09 23  ndencies from..#
0c60: 20 74 68 65 20 66 69 6c 65 2d 6c 65 76 65 6c 20   the file-level 
0c70: 64 61 74 61 20 61 6e 64 20 73 61 76 65 20 69 74  data and save it
0c80: 20 62 61 63 6b 20 74 6f 20 74 68 65 20 73 74 61   back to the sta
0c90: 74 65 2e 20 54 68 69 73 20 6d 61 79 0a 09 23 20  te. This may..# 
0ca0: 62 65 20 63 61 6c 6c 65 64 20 64 75 72 69 6e 67  be called during
0cb0: 20 74 68 65 20 63 79 63 6c 65 20 62 72 65 61 6b   the cycle break
0cc0: 65 72 20 70 61 73 73 65 73 20 61 73 20 77 65 6c  er passes as wel
0cd0: 6c 2c 20 74 6f 20 61 64 6a 75 73 74 0a 09 23 20  l, to adjust..# 
0ce0: 74 68 65 20 73 75 63 63 65 73 73 6f 72 20 69 6e  the successor in
0cf0: 66 6f 72 6d 61 74 69 6f 6e 20 6f 66 20 63 68 61  formation of cha
0d00: 6e 67 65 73 65 74 73 20 77 68 69 63 68 20 61 72  ngesets which ar
0d10: 65 20 74 68 65 0a 09 23 20 70 72 65 64 65 63 65  e the..# predece
0d20: 73 73 6f 72 73 20 6f 66 20 64 72 6f 70 70 65 64  ssors of dropped
0d30: 20 63 68 61 6e 67 65 73 65 74 73 2e 20 46 6f 72   changesets. For
0d40: 20 74 68 65 6d 20 77 65 20 68 61 76 65 20 74 6f   them we have to
0d50: 0a 09 23 20 72 65 6d 6f 76 65 20 74 68 65 69 72  ..# remove their
0d60: 20 65 78 69 73 74 69 6e 67 20 69 6e 66 6f 72 6d   existing inform
0d70: 61 74 69 6f 6e 20 66 69 72 73 74 20 62 65 66 6f  ation first befo
0d80: 72 65 20 69 6e 73 65 72 74 69 6e 67 20 74 68 65  re inserting the
0d90: 0a 09 23 20 6e 65 77 20 64 61 74 61 2e 0a 09 73  ..# new data...s
0da0: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20  tate run {..    
0db0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 63 73 73 75  DELETE FROM cssu
0dc0: 63 63 65 73 73 6f 72 20 57 48 45 52 45 20 63 69  ccessor WHERE ci
0dd0: 64 20 3d 20 24 6d 79 69 64 3b 0a 09 7d 0a 09 73  d = $myid;..}..s
0de0: 65 74 20 6c 6f 6f 70 20 30 0a 09 66 6f 72 65 61  et loop 0..forea
0df0: 63 68 20 6e 69 64 20 5b 24 6d 79 74 79 70 65 6f  ch nid [$mytypeo
0e00: 62 6a 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73  bj cs_successors
0e10: 20 24 6d 79 69 74 65 6d 73 5d 20 7b 0a 09 20 20   $myitems] {..  
0e20: 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09    state run {...
0e30: 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 73 73 75  INSERT INTO cssu
0e40: 63 63 65 73 73 6f 72 20 28 63 69 64 2c 20 20 6e  ccessor (cid,  n
0e50: 69 64 29 0a 09 09 56 41 4c 55 45 53 20 20 20 20  id)...VALUES    
0e60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 24                ($
0e70: 6d 79 69 64 2c 24 6e 69 64 29 0a 09 20 20 20 20  myid,$nid)..    
0e80: 7d 0a 09 20 20 20 20 69 66 20 7b 24 6e 69 64 20  }..    if {$nid 
0e90: 3d 3d 20 24 6d 79 69 64 7d 20 7b 20 73 65 74 20  == $myid} { set 
0ea0: 6c 6f 6f 70 20 31 20 7d 0a 09 7d 0a 09 23 20 52  loop 1 }..}..# R
0eb0: 65 70 6f 72 74 20 61 66 74 65 72 20 74 68 65 20  eport after the 
0ec0: 63 6f 6d 70 6c 65 74 65 20 73 74 72 75 63 74 75  complete structu
0ed0: 72 65 20 68 61 73 20 62 65 65 6e 20 73 61 76 65  re has been save
0ee0: 64 2e 0a 09 69 66 20 7b 24 6c 6f 6f 70 7d 20 7b  d...if {$loop} {
0ef0: 20 24 73 65 6c 66 20 72 65 70 6f 72 74 6c 6f 6f   $self reportloo
0f00: 70 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  p }..return.    
0f10: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20  }..    # result 
0f20: 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65  = list (changese
0f30: 74 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 73 75  t).    method su
0f40: 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b 0a 09 23  ccessors {} {..#
0f50: 20 55 73 65 20 74 68 65 20 64 61 74 61 20 73 61   Use the data sa
0f60: 76 65 64 20 62 79 20 70 61 73 73 20 36 2e 0a 09  ved by pass 6...
0f70: 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a  return [struct::
0f80: 6c 69 73 74 20 6d 61 70 20 5b 73 74 61 74 65 20  list map [state 
0f90: 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  run {..    SELEC
0fa0: 54 20 53 2e 6e 69 64 0a 09 20 20 20 20 46 52 4f  T S.nid..    FRO
0fb0: 4d 20 20 20 63 73 73 75 63 63 65 73 73 6f 72 20  M   cssuccessor 
0fc0: 53 0a 09 20 20 20 20 57 48 45 52 45 20 20 53 2e  S..    WHERE  S.
0fd0: 63 69 64 20 3d 20 24 6d 79 69 64 0a 09 7d 5d 20  cid = $myid..}] 
0fe0: 5b 6d 79 74 79 70 65 6d 65 74 68 6f 64 20 6f 66  [mytypemethod of
0ff0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  ]].    }..    # 
1000: 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69 74  item -> list (it
1010: 65 6d 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 6e  em).    method n
1020: 65 78 74 6d 61 70 20 7b 7d 20 7b 0a 09 24 6d 79  extmap {} {..$my
1030: 74 79 70 65 6f 62 6a 20 73 75 63 63 65 73 73 6f  typeobj successo
1040: 72 73 20 74 6d 70 20 24 6d 79 69 74 65 6d 73 0a  rs tmp $myitems.
1050: 09 72 65 74 75 72 6e 20 5b 61 72 72 61 79 20 67  .return [array g
1060: 65 74 20 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20  et tmp].    }.. 
1070: 20 20 20 6d 65 74 68 6f 64 20 62 72 65 61 6b 69     method breaki
1080: 6e 74 65 72 6e 61 6c 64 65 70 65 6e 64 65 6e 63  nternaldependenc
1090: 69 65 73 20 7b 7d 20 7b 0a 0a 09 23 23 0a 09 23  ies {} {...##..#
10a0: 23 20 4e 4f 54 45 3a 20 54 68 69 73 20 6d 65 74  # NOTE: This met
10b0: 68 6f 64 2c 20 6d 61 79 62 65 20 69 6e 20 63 6f  hod, maybe in co
10c0: 6e 6a 75 6e 63 74 69 6f 6e 20 77 69 74 68 20 69  njunction with i
10d0: 74 73 20 63 61 6c 6c 65 72 0a 09 23 23 20 20 20  ts caller..##   
10e0: 20 20 20 20 73 65 65 6d 73 20 74 6f 20 62 65 20      seems to be 
10f0: 61 20 6d 65 6d 6f 72 79 20 68 6f 67 2c 20 65 73  a memory hog, es
1100: 70 65 63 69 61 6c 6c 79 20 66 6f 72 20 6c 61 72  pecially for lar
1110: 67 65 0a 09 23 23 20 20 20 20 20 20 20 63 68 61  ge..##       cha
1120: 6e 67 65 73 65 74 73 2c 20 77 69 74 68 20 27 6c  ngesets, with 'l
1130: 61 72 67 65 27 20 6d 65 61 6e 69 6e 67 20 74 6f  arge' meaning to
1140: 20 68 61 76 65 20 61 20 27 6c 6f 6e 67 20 6c 69   have a 'long li
1150: 73 74 0a 09 23 23 20 20 20 20 20 20 20 6f 66 20  st..##       of 
1160: 69 74 65 6d 73 2c 20 73 65 76 65 72 61 6c 20 74  items, several t
1170: 68 6f 75 73 61 6e 64 27 2e 20 49 6e 76 65 73 74  housand'. Invest
1180: 69 67 61 74 65 20 77 68 65 72 65 20 74 68 65 0a  igate where the.
1190: 09 23 23 20 20 20 20 20 20 20 6d 65 6d 6f 72 79  .##       memory
11a0: 20 69 73 20 73 70 65 6e 74 20 61 6e 64 20 74 68   is spent and th
11b0: 65 6e 20 6c 6f 6f 6b 20 66 6f 72 20 77 61 79 73  en look for ways
11c0: 20 6f 66 20 72 65 63 74 69 66 79 69 6e 67 0a 09   of rectifying..
11d0: 23 23 20 20 20 20 20 20 20 74 68 65 20 70 72 6f  ##       the pro
11e0: 62 6c 65 6d 2e 0a 09 23 23 0a 0a 09 23 20 54 68  blem...##...# Th
11f0: 69 73 20 6d 65 74 68 6f 64 20 69 6e 73 70 65 63  is method inspec
1200: 74 73 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  ts the changeset
1210: 73 20 66 6f 72 20 69 6e 74 65 72 6e 61 6c 0a 09  s for internal..
1220: 23 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 20  # dependencies. 
1230: 4e 6f 74 68 69 6e 67 20 69 73 20 64 6f 6e 65 20  Nothing is done 
1240: 69 66 20 74 68 65 72 65 20 61 72 65 20 6e 6f 0a  if there are no.
1250: 09 23 20 73 75 63 68 2e 20 4f 74 68 65 72 77 69  .# such. Otherwi
1260: 73 65 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  se the changeset
1270: 20 69 73 20 73 70 6c 69 74 20 69 6e 74 6f 20 61   is split into a
1280: 20 73 65 74 20 6f 66 0a 09 23 20 66 72 61 67 6d   set of..# fragm
1290: 65 6e 74 73 20 77 69 74 68 6f 75 74 20 69 6e 74  ents without int
12a0: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
12b0: 65 73 2c 20 74 72 61 6e 73 66 6f 72 6d 69 6e 67  es, transforming
12c0: 20 74 68 65 0a 09 23 20 69 6e 74 65 72 6e 61 6c   the..# internal
12d0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 69 6e   dependencies in
12e0: 74 6f 20 65 78 74 65 72 6e 61 6c 20 6f 6e 65 73  to external ones
12f0: 2e 20 54 68 65 20 6e 65 77 20 63 68 61 6e 67 65  . The new change
1300: 73 65 74 73 0a 09 23 20 61 72 65 20 61 64 64 65  sets..# are adde
1310: 64 20 74 6f 20 74 68 65 20 6c 69 73 74 20 6f 66  d to the list of
1320: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 2e   all changesets.
1330: 0a 0a 09 23 20 57 65 20 70 65 72 66 6f 72 6d 20  ...# We perform 
1340: 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20 73 70  all necessary sp
1350: 6c 69 74 73 20 69 6e 20 6f 6e 65 20 67 6f 2c 20  lits in one go, 
1360: 69 6e 73 74 65 61 64 20 6f 66 20 6f 6e 6c 79 0a  instead of only.
1370: 09 23 20 6f 6e 65 2e 20 54 68 65 20 70 72 65 76  .# one. The prev
1380: 69 6f 75 73 20 61 6c 67 6f 72 69 74 68 6d 2c 20  ious algorithm, 
1390: 61 64 61 70 74 65 64 20 66 72 6f 6d 20 63 76 73  adapted from cvs
13a0: 32 73 76 6e 2c 20 63 6f 6d 70 75 74 65 64 0a 09  2svn, computed..
13b0: 23 20 61 20 6c 6f 74 20 6f 66 20 73 74 61 74 65  # a lot of state
13c0: 20 77 68 69 63 68 20 77 61 73 20 74 68 72 6f 77   which was throw
13d0: 6e 20 61 77 61 79 20 61 6e 64 20 74 68 65 6e 20  n away and then 
13e0: 63 6f 6d 70 75 74 65 64 20 61 67 61 69 6e 0a 09  computed again..
13f0: 23 20 66 6f 72 20 65 61 63 68 20 6f 66 20 74 68  # for each of th
1400: 65 20 66 72 61 67 6d 65 6e 74 73 2e 20 49 74 20  e fragments. It 
1410: 73 68 6f 75 6c 64 20 62 65 20 65 61 73 69 65 72  should be easier
1420: 20 74 6f 20 75 70 64 61 74 65 20 61 6e 64 0a 09   to update and..
1430: 23 20 72 65 75 73 65 20 74 68 61 74 20 73 74 61  # reuse that sta
1440: 74 65 2e 0a 0a 09 23 20 54 68 65 20 63 6f 64 65  te....# The code
1450: 20 63 68 65 63 6b 73 20 6f 6e 6c 79 20 73 75 63   checks only suc
1460: 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63  cessor dependenc
1470: 69 65 73 2c 20 61 73 20 74 68 69 73 0a 09 23 20  ies, as this..# 
1480: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 63 6f  automatically co
1490: 76 65 72 73 20 74 68 65 20 70 72 65 64 65 63 65  vers the predece
14a0: 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 69 65  ssor dependencie
14b0: 73 20 61 73 20 77 65 6c 6c 20 28 41 0a 09 23 20  s as well (A..# 
14c0: 73 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e 64  successor depend
14d0: 65 6e 63 79 20 61 20 2d 3e 20 62 20 69 73 20 61  ency a -> b is a
14e0: 6c 73 6f 20 61 20 70 72 65 64 65 63 65 73 73 6f  lso a predecesso
14f0: 72 20 64 65 70 65 6e 64 65 6e 63 79 0a 09 23 20  r dependency..# 
1500: 62 20 2d 3e 20 61 29 2e 0a 0a 09 23 20 41 72 72  b -> a)....# Arr
1510: 61 79 20 6f 66 20 64 65 70 65 6e 64 65 6e 63 69  ay of dependenci
1520: 65 73 20 28 70 61 72 65 6e 74 20 2d 3e 20 63 68  es (parent -> ch
1530: 69 6c 64 29 2e 20 54 68 69 73 20 69 73 20 70 75  ild). This is pu
1540: 6c 6c 65 64 20 66 72 6f 6d 0a 09 23 20 74 68 65  lled from..# the
1550: 20 73 74 61 74 65 2c 20 61 6e 64 20 6c 69 6d 69   state, and limi
1560: 74 65 64 20 74 6f 20 73 75 63 63 65 73 73 6f 72  ted to successor
1570: 73 20 77 69 74 68 69 6e 20 74 68 65 20 63 68 61  s within the cha
1580: 6e 67 65 73 65 74 2e 0a 0a 09 61 72 72 61 79 20  ngeset....array 
1590: 73 65 74 20 64 65 70 65 6e 64 65 6e 63 69 65 73  set dependencies
15a0: 20 7b 7d 0a 09 24 6d 79 74 79 70 65 6f 62 6a 20   {}..$mytypeobj 
15b0: 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f  internalsuccesso
15c0: 72 73 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  rs dependencies 
15d0: 24 6d 79 69 74 65 6d 73 0a 09 69 66 20 7b 21 5b  $myitems..if {![
15e0: 61 72 72 61 79 20 73 69 7a 65 20 64 65 70 65 6e  array size depen
15f0: 64 65 6e 63 69 65 73 5d 7d 20 7b 72 65 74 75 72  dencies]} {retur
1600: 6e 20 30 7d 20 3b 20 23 20 4e 6f 74 68 69 6e 67  n 0} ; # Nothing
1610: 20 74 6f 20 62 72 65 61 6b 2e 0a 0a 09 6c 6f 67   to break....log
1620: 20 77 72 69 74 65 20 35 20 63 73 65 74 73 20 2e   write 5 csets .
1630: 2e 2e 5b 24 73 65 6c 66 20 73 74 72 5d 2e 2e 2e  ..[$self str]...
1640: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1650: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1660: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1670: 2e 2e 2e 2e 0a 0a 09 23 20 57 65 20 68 61 76 65  .......# We have
1680: 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64   internal depend
1690: 65 6e 63 69 65 73 20 74 6f 20 62 72 65 61 6b 2e  encies to break.
16a0: 20 57 65 20 6e 6f 77 20 69 74 65 72 61 74 65 20   We now iterate 
16b0: 6f 76 65 72 0a 09 23 20 61 6c 6c 20 70 6f 73 69  over..# all posi
16c0: 74 69 6f 6e 73 20 69 6e 20 74 68 65 20 6c 69 73  tions in the lis
16d0: 74 20 28 77 68 69 63 68 20 69 73 20 63 68 72 6f  t (which is chro
16e0: 6e 6f 6c 6f 67 69 63 61 6c 2c 20 61 74 20 6c 65  nological, at le
16f0: 61 73 74 0a 09 23 20 61 73 20 66 61 72 20 61 73  ast..# as far as
1700: 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20   the timestamps 
1710: 61 72 65 20 63 6f 72 72 65 63 74 20 61 6e 64 20  are correct and 
1720: 75 6e 69 71 75 65 29 20 61 6e 64 0a 09 23 20 64  unique) and..# d
1730: 65 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65 73  etermine the bes
1740: 74 20 70 6f 73 69 74 69 6f 6e 20 66 6f 72 20 74  t position for t
1750: 68 65 20 62 72 65 61 6b 2c 20 62 79 20 74 72 79  he break, by try
1760: 69 6e 67 20 74 6f 0a 09 23 20 62 72 65 61 6b 20  ing to..# break 
1770: 61 73 20 6d 61 6e 79 20 64 65 70 65 6e 64 65 6e  as many dependen
1780: 63 69 65 73 20 61 73 20 70 6f 73 73 69 62 6c 65  cies as possible
1790: 20 69 6e 20 6f 6e 65 20 67 6f 2e 20 57 68 65 6e   in one go. When
17a0: 20 61 0a 09 23 20 62 72 65 61 6b 20 77 61 73 20   a..# break was 
17b0: 66 6f 75 6e 64 20 74 68 69 73 20 69 73 20 72 65  found this is re
17c0: 64 6f 6e 65 20 66 6f 72 20 74 68 65 20 66 72 61  done for the fra
17d0: 67 6d 65 6e 74 73 20 63 6f 6d 69 6e 67 20 61 6e  gments coming an
17e0: 64 0a 09 23 20 61 66 74 65 72 2c 20 61 66 74 65  d..# after, afte
17f0: 72 20 75 70 64 69 6e 67 20 74 68 65 20 63 72 6f  r upding the cro
1800: 73 73 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f  ssing informatio
1810: 6e 2e 0a 0a 09 23 20 44 61 74 61 20 73 74 72 75  n....# Data stru
1820: 63 74 75 72 65 73 3a 0a 09 23 20 4d 61 70 3a 20  ctures:..# Map: 
1830: 20 50 4f 53 20 20 20 72 65 76 69 73 69 6f 6e 20   POS   revision 
1840: 69 64 20 20 20 20 20 20 2d 3e 20 70 6f 73 69 74  id      -> posit
1850: 69 6f 6e 20 69 6e 20 6c 69 73 74 2e 0a 09 23 20  ion in list...# 
1860: 20 20 20 20 20 20 43 52 4f 53 53 20 70 6f 73 69        CROSS posi
1870: 74 69 6f 6e 20 69 6e 20 6c 69 73 74 20 2d 3e 20  tion in list -> 
1880: 6e 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64  number of depend
1890: 65 6e 63 69 65 73 20 63 72 6f 73 73 69 6e 67 20  encies crossing 
18a0: 69 74 0a 09 23 20 20 20 20 20 20 20 44 45 50 43  it..#       DEPC
18b0: 20 20 64 65 70 65 6e 64 65 6e 63 79 20 20 20 20    dependency    
18c0: 20 20 20 2d 3e 20 70 6f 73 69 74 69 6f 6e 73 20     -> positions 
18d0: 69 74 20 63 72 6f 73 73 65 73 0a 09 23 20 4c 69  it crosses..# Li
18e0: 73 74 3a 20 52 41 4e 47 45 20 4f 66 20 74 68 65  st: RANGE Of the
18f0: 20 70 6f 73 69 74 69 6f 6e 73 20 69 74 73 65 6c   positions itsel
1900: 66 2e 0a 09 23 20 41 20 64 65 70 65 6e 64 65 6e  f...# A dependen
1910: 63 79 20 69 73 20 61 20 73 69 6e 67 6c 65 2d 65  cy is a single-e
1920: 6c 65 6d 65 6e 74 20 6d 61 70 20 70 61 72 65 6e  lement map paren
1930: 74 20 2d 3e 20 63 68 69 6c 64 0a 0a 09 49 6e 69  t -> child...Ini
1940: 74 69 61 6c 69 7a 65 42 72 65 61 6b 53 74 61 74  tializeBreakStat
1950: 65 20 24 6d 79 69 74 65 6d 73 0a 0a 09 73 65 74  e $myitems...set
1960: 20 66 72 61 67 6d 65 6e 74 73 20 7b 7d 0a 09 73   fragments {}..s
1970: 65 74 20 6e 65 77 20 20 20 20 20 20 20 5b 6c 69  et new       [li
1980: 73 74 20 24 72 61 6e 67 65 5d 0a 09 61 72 72 61  st $range]..arra
1990: 79 20 73 65 74 20 62 72 65 61 6b 73 20 7b 7d 0a  y set breaks {}.
19a0: 0a 09 23 20 49 6e 73 74 65 61 64 20 6f 66 20 6f  ..# Instead of o
19b0: 6e 65 20 6c 69 73 74 20 68 6f 6c 64 69 6e 67 20  ne list holding 
19c0: 62 6f 74 68 20 70 72 6f 63 65 73 73 65 64 20 61  both processed a
19d0: 6e 64 20 70 65 6e 64 69 6e 67 0a 09 23 20 66 72  nd pending..# fr
19e0: 61 67 6d 65 6e 74 73 20 77 65 20 75 73 65 20 74  agments we use t
19f0: 77 6f 2c 20 6f 6e 65 20 66 6f 72 20 74 68 65 20  wo, one for the 
1a00: 66 72 61 6d 65 6e 74 73 20 74 6f 20 70 72 6f 63  framents to proc
1a10: 65 73 73 2c 20 6f 6e 65 0a 09 23 20 74 6f 20 68  ess, one..# to h
1a20: 6f 6c 64 20 74 68 65 20 6e 65 77 20 66 72 61 67  old the new frag
1a30: 6d 65 6e 74 73 2c 20 61 6e 64 20 74 68 65 20 6c  ments, and the l
1a40: 61 74 74 65 72 20 69 73 20 63 6f 70 69 65 64 20  atter is copied 
1a50: 74 6f 20 74 68 65 0a 09 23 20 66 6f 72 6d 65 72  to the..# former
1a60: 20 77 68 65 6e 20 74 68 65 79 20 72 75 6e 20 6f   when they run o
1a70: 75 74 2e 20 54 68 69 73 20 6b 65 65 70 73 20 74  ut. This keeps t
1a80: 68 65 20 6c 69 73 74 20 6f 66 20 70 65 6e 64 69  he list of pendi
1a90: 6e 67 0a 09 23 20 66 72 61 67 6d 65 6e 74 73 20  ng..# fragments 
1aa0: 73 68 6f 72 74 20 77 69 74 68 6f 75 74 20 73 61  short without sa
1ab0: 63 72 69 66 69 63 69 6e 67 20 73 70 65 65 64 20  crificing speed 
1ac0: 62 79 20 73 68 69 66 74 69 6e 67 20 73 74 75 66  by shifting stuf
1ad0: 66 0a 09 23 20 64 6f 77 6e 2e 20 57 65 20 65 73  f..# down. We es
1ae0: 70 65 63 69 61 6c 6c 79 20 64 72 6f 70 20 74 68  pecially drop th
1af0: 65 20 6d 65 6d 6f 72 79 20 6f 66 20 66 72 61 67  e memory of frag
1b00: 6d 65 6e 74 73 20 62 72 6f 6b 65 6e 0a 09 23 20  ments broken..# 
1b10: 64 75 72 69 6e 67 20 70 72 6f 63 65 73 73 69 6e  during processin
1b20: 67 20 61 66 74 65 72 20 61 20 73 68 6f 72 74 20  g after a short 
1b30: 74 69 6d 65 2c 20 69 6e 73 74 65 61 64 20 6f 66  time, instead of
1b40: 20 6c 65 74 74 69 6e 67 20 69 74 0a 09 23 20 63   letting it..# c
1b50: 6f 6e 73 75 6d 65 20 6d 65 6d 6f 72 79 2e 0a 0a  onsume memory...
1b60: 09 77 68 69 6c 65 20 7b 5b 6c 6c 65 6e 67 74 68  .while {[llength
1b70: 20 24 6e 65 77 5d 7d 20 7b 0a 0a 09 20 20 20 20   $new]} {...    
1b80: 73 65 74 20 70 65 6e 64 69 6e 67 20 24 6e 65 77  set pending $new
1b90: 0a 09 20 20 20 20 73 65 74 20 6e 65 77 20 20 20  ..    set new   
1ba0: 20 20 7b 7d 0a 09 20 20 20 20 73 65 74 20 61 74    {}..    set at
1bb0: 20 20 20 20 20 20 30 0a 0a 09 20 20 20 20 77 68        0...    wh
1bc0: 69 6c 65 20 7b 24 61 74 20 3c 20 5b 6c 6c 65 6e  ile {$at < [llen
1bd0: 67 74 68 20 24 70 65 6e 64 69 6e 67 5d 7d 20 7b  gth $pending]} {
1be0: 0a 09 09 73 65 74 20 63 75 72 72 65 6e 74 20 5b  ...set current [
1bf0: 6c 69 6e 64 65 78 20 24 70 65 6e 64 69 6e 67 20  lindex $pending 
1c00: 24 61 74 5d 0a 0a 09 09 6c 6f 67 20 77 72 69 74  $at]....log writ
1c10: 65 20 36 20 63 73 65 74 73 20 7b 2e 20 2e 20 2e  e 6 csets {. . .
1c20: 2e 20 2e 2e 2e 20 2e 2e 2e 2e 2e 20 2e 2e 2e 2e  . ... ..... ....
1c30: 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  .... ...........
1c40: 2e 2e 7d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20  ..}...log write 
1c50: 36 20 63 73 65 74 73 20 7b 53 63 68 65 64 75 6c  6 csets {Schedul
1c60: 65 64 20 20 20 5b 6a 6f 69 6e 20 5b 50 52 73 20  ed   [join [PRs 
1c70: 5b 6c 72 61 6e 67 65 20 24 70 65 6e 64 69 6e 67  [lrange $pending
1c80: 20 24 61 74 20 65 6e 64 5d 5d 20 7b 20 7d 5d 7d   $at end]] { }]}
1c90: 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63  ...log write 6 c
1ca0: 73 65 74 73 20 7b 43 6f 6e 73 69 64 65 72 69 6e  sets {Considerin
1cb0: 67 20 5b 50 52 20 24 63 75 72 72 65 6e 74 5d 20  g [PR $current] 
1cc0: 5c 5b 24 61 74 2f 5b 6c 6c 65 6e 67 74 68 20 24  \[$at/[llength $
1cd0: 70 65 6e 64 69 6e 67 5d 5c 5d 7d 0a 0a 09 09 73  pending]\]}....s
1ce0: 65 74 20 62 65 73 74 20 5b 46 69 6e 64 42 65 73  et best [FindBes
1cf0: 74 42 72 65 61 6b 20 24 63 75 72 72 65 6e 74 5d  tBreak $current]
1d00: 0a 0a 09 09 69 66 20 7b 24 62 65 73 74 20 3c 20  ....if {$best < 
1d10: 30 7d 20 7b 0a 09 09 20 20 20 20 23 20 54 68 65  0} {...    # The
1d20: 20 69 6e 73 70 65 63 74 65 64 20 72 61 6e 67 65   inspected range
1d30: 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61 6c   has no internal
1d40: 0a 09 09 20 20 20 20 23 20 64 65 70 65 6e 64 65  ...    # depende
1d50: 6e 63 69 65 73 2e 20 54 68 69 73 20 69 73 20 61  ncies. This is a
1d60: 20 63 6f 6d 70 6c 65 74 65 20 66 72 61 67 6d 65   complete fragme
1d70: 6e 74 2e 0a 09 09 20 20 20 20 6c 61 70 70 65 6e  nt....    lappen
1d80: 64 20 66 72 61 67 6d 65 6e 74 73 20 24 63 75 72  d fragments $cur
1d90: 72 65 6e 74 0a 0a 09 09 20 20 20 20 6c 6f 67 20  rent....    log 
1da0: 77 72 69 74 65 20 36 20 63 73 65 74 73 20 22 4e  write 6 csets "N
1db0: 6f 20 62 72 65 61 6b 73 2c 20 66 69 6e 61 6c 22  o breaks, final"
1dc0: 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20  ...} else {...  
1dd0: 20 20 23 20 53 70 6c 69 74 20 74 68 65 20 72 61    # Split the ra
1de0: 6e 67 65 20 61 6e 64 20 73 63 68 65 64 75 6c 65  nge and schedule
1df0: 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 0a 09   the resulting..
1e00: 09 20 20 20 20 23 20 66 72 61 67 6d 65 6e 74 73  .    # fragments
1e10: 20 66 6f 72 20 66 75 72 74 68 65 72 20 69 6e 73   for further ins
1e20: 70 65 63 74 69 6f 6e 2e 20 52 65 6d 65 6d 62 65  pection. Remembe
1e30: 72 20 74 68 65 0a 09 09 20 20 20 20 23 20 6e 75  r the...    # nu
1e40: 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 65 6e  mber of dependen
1e50: 63 69 65 73 20 63 75 74 20 62 65 66 6f 72 65 20  cies cut before 
1e60: 77 65 20 72 65 6d 6f 76 65 20 74 68 65 6d 0a 09  we remove them..
1e70: 09 20 20 20 20 23 20 66 72 6f 6d 20 63 6f 6e 73  .    # from cons
1e80: 69 64 65 72 61 74 69 6f 6e 2c 20 66 6f 72 20 64  ideration, for d
1e90: 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 6c 61 74  ocumentation lat
1ea0: 65 72 2e 0a 0a 09 09 20 20 20 20 73 65 74 20 62  er.....    set b
1eb0: 72 65 61 6b 73 28 24 62 65 73 74 29 20 24 63 72  reaks($best) $cr
1ec0: 6f 73 73 28 24 62 65 73 74 29 0a 0a 09 09 20 20  oss($best)....  
1ed0: 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73    log write 6 cs
1ee0: 65 74 73 20 22 42 65 73 74 20 62 72 65 61 6b 20  ets "Best break 
1ef0: 40 20 24 62 65 73 74 2c 20 63 75 74 74 69 6e 67  @ $best, cutting
1f00: 20 5b 6e 73 70 20 24 63 72 6f 73 73 28 24 62 65   [nsp $cross($be
1f10: 73 74 29 20 64 65 70 65 6e 64 65 6e 63 79 20 64  st) dependency d
1f20: 65 70 65 6e 64 65 6e 63 69 65 73 5d 22 0a 0a 09  ependencies]"...
1f30: 09 20 20 20 20 23 20 4e 6f 74 65 3a 20 54 68 65  .    # Note: The
1f40: 20 76 61 6c 75 65 20 6f 66 20 62 65 73 74 20 69   value of best i
1f50: 73 20 61 6e 20 61 62 6f 6c 75 74 65 20 6c 6f 63  s an abolute loc
1f60: 61 74 69 6f 6e 0a 09 09 20 20 20 20 23 20 69 6e  ation...    # in
1f70: 20 6d 79 69 74 65 6d 73 2e 20 55 73 65 20 74 68   myitems. Use th
1f80: 65 20 73 74 61 72 74 20 6f 66 20 63 75 72 72 65  e start of curre
1f90: 6e 74 20 74 6f 20 6d 61 6b 65 20 69 74 0a 09 09  nt to make it...
1fa0: 20 20 20 20 23 20 61 6e 20 69 6e 64 65 78 20 61      # an index a
1fb0: 62 73 6f 6c 75 74 65 20 74 6f 20 63 75 72 72 65  bsolute to curre
1fc0: 6e 74 2e 0a 0a 09 09 20 20 20 20 73 65 74 20 62  nt.....    set b
1fd0: 72 65 6c 20 5b 65 78 70 72 20 7b 24 62 65 73 74  rel [expr {$best
1fe0: 20 2d 20 5b 6c 69 6e 64 65 78 20 24 63 75 72 72   - [lindex $curr
1ff0: 65 6e 74 20 30 5d 7d 5d 0a 09 09 20 20 20 20 73  ent 0]}]...    s
2000: 65 74 20 62 6e 65 78 74 20 24 62 72 65 6c 20 3b  et bnext $brel ;
2010: 20 69 6e 63 72 20 62 6e 65 78 74 0a 09 09 20 20   incr bnext...  
2020: 20 20 73 65 74 20 66 72 61 67 62 65 66 6f 72 65    set fragbefore
2030: 20 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 6e   [lrange $curren
2040: 74 20 30 20 24 62 72 65 6c 5d 0a 09 09 20 20 20  t 0 $brel]...   
2050: 20 73 65 74 20 66 72 61 67 61 66 74 65 72 20 20   set fragafter  
2060: 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 6e 74  [lrange $current
2070: 20 24 62 6e 65 78 74 20 65 6e 64 5d 0a 0a 09 09   $bnext end]....
2080: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20      log write 6 
2090: 63 73 65 74 73 20 22 4e 65 77 20 70 69 65 63 65  csets "New piece
20a0: 73 20 20 5b 50 52 20 24 66 72 61 67 62 65 66 6f  s  [PR $fragbefo
20b0: 72 65 5d 20 5b 50 52 20 24 66 72 61 67 61 66 74  re] [PR $fragaft
20c0: 65 72 5d 22 0a 0a 09 09 20 20 20 20 69 6e 74 65  er]"....    inte
20d0: 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 5b 6c  grity assert {[l
20e0: 6c 65 6e 67 74 68 20 24 66 72 61 67 62 65 66 6f  length $fragbefo
20f0: 72 65 5d 7d 20 7b 46 6f 75 6e 64 20 7a 65 72 6f  re]} {Found zero
2100: 2d 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 6e 74  -length fragment
2110: 20 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e   at the beginnin
2120: 67 7d 0a 09 09 20 20 20 20 69 6e 74 65 67 72 69  g}...    integri
2130: 74 79 20 61 73 73 65 72 74 20 7b 5b 6c 6c 65 6e  ty assert {[llen
2140: 67 74 68 20 24 66 72 61 67 61 66 74 65 72 5d 7d  gth $fragafter]}
2150: 20 20 7b 46 6f 75 6e 64 20 7a 65 72 6f 2d 6c 65    {Found zero-le
2160: 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 20 61 74  ngth fragment at
2170: 20 74 68 65 20 65 6e 64 7d 0a 0a 09 09 20 20 20   the end}....   
2180: 20 6c 61 70 70 65 6e 64 20 6e 65 77 20 24 66 72   lappend new $fr
2190: 61 67 62 65 66 6f 72 65 20 24 66 72 61 67 61 66  agbefore $fragaf
21a0: 74 65 72 0a 09 09 20 20 20 20 43 75 74 41 74 20  ter...    CutAt 
21b0: 24 62 65 73 74 0a 09 09 7d 0a 0a 09 09 69 6e 63  $best...}....inc
21c0: 72 20 61 74 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  r at..    }..}..
21d0: 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65  .log write 6 cse
21e0: 74 73 20 22 2e 20 2e 20 2e 2e 20 2e 2e 2e 20 2e  ts ". . .. ... .
21f0: 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e 2e  .... ........ ..
2200: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 22 0a 0a 09 23  ..........."...#
2210: 20 28 2a 29 20 57 65 20 63 6c 65 61 72 20 6f 75   (*) We clear ou
2220: 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65 64  t the associated
2230: 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d 79 69   part of the myi
2240: 74 65 6d 6d 61 70 0a 09 23 20 69 6e 2d 6d 65 6d  temmap..# in-mem
2250: 6f 72 79 20 69 6e 64 65 78 20 69 6e 20 70 72 65  ory index in pre
2260: 70 61 72 61 74 69 6f 6e 20 66 6f 72 20 6e 65 77  paration for new
2270: 20 64 61 74 61 2e 20 41 20 73 69 6d 70 6c 65 20   data. A simple 
2280: 75 6e 73 65 74 0a 09 23 20 69 73 20 65 6e 6f 75  unset..# is enou
2290: 67 68 2c 20 77 65 20 68 61 76 65 20 6e 6f 20 73  gh, we have no s
22a0: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73  ymbol changesets
22b0: 20 61 74 20 74 68 69 73 20 74 69 6d 65 2c 20 61   at this time, a
22c0: 6e 64 0a 09 23 20 74 68 75 73 20 6e 65 76 65 72  nd..# thus never
22d0: 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20 72   more than one r
22e0: 65 66 65 72 65 6e 63 65 20 69 6e 20 74 68 65 20  eference in the 
22f0: 6c 69 73 74 2e 0a 0a 09 66 6f 72 65 61 63 68 20  list....foreach 
2300: 69 69 64 20 24 6d 79 69 74 65 6d 73 20 7b 0a 09  iid $myitems {..
2310: 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c 69 73      set key [lis
2320: 74 20 24 6d 79 74 79 70 65 20 24 69 69 64 5d 0a  t $mytype $iid].
2330: 09 20 20 20 20 75 6e 73 65 74 20 6d 79 69 74 65  .    unset myite
2340: 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20 20 20 20  mmap($key)..    
2350: 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74  log write 8 cset
2360: 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20 3c 24 6b  s {MAP- item <$k
2370: 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73 65  ey> $self = [$se
2380: 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 0a 09 23 20  lf str]}..}...# 
2390: 43 72 65 61 74 65 20 63 68 61 6e 67 65 73 65 74  Create changeset
23a0: 73 20 66 6f 72 20 74 68 65 20 66 72 61 67 6d 65  s for the fragme
23b0: 6e 74 73 2c 20 72 65 75 73 69 6e 67 20 74 68 65  nts, reusing the
23c0: 20 63 75 72 72 65 6e 74 20 6f 6e 65 0a 09 23 20   current one..# 
23d0: 66 6f 72 20 74 68 65 20 66 69 72 73 74 20 66 72  for the first fr
23e0: 61 67 6d 65 6e 74 2e 20 57 65 20 73 6f 72 74 20  agment. We sort 
23f0: 74 68 65 6d 20 69 6e 20 6f 72 64 65 72 20 74 6f  them in order to
2400: 20 61 6c 6c 6f 77 0a 09 23 20 63 68 65 63 6b 69   allow..# checki
2410: 6e 67 20 66 6f 72 20 67 61 70 73 20 61 6e 64 20  ng for gaps and 
2420: 6e 69 63 65 20 6d 65 73 73 61 67 65 73 2e 0a 0a  nice messages...
2430: 09 73 65 74 20 66 72 61 67 6d 65 6e 74 73 20 5b  .set fragments [
2440: 6c 73 6f 72 74 20 2d 69 6e 64 65 78 20 30 20 2d  lsort -index 0 -
2450: 69 6e 74 65 67 65 72 20 24 66 72 61 67 6d 65 6e  integer $fragmen
2460: 74 73 5d 0a 0a 09 23 70 75 74 73 20 5c 74 2e 5b  ts]...#puts \t.[
2470: 6a 6f 69 6e 20 5b 50 52 73 20 24 66 72 61 67 6d  join [PRs $fragm
2480: 65 6e 74 73 5d 20 2e 5c 6e 5c 74 2e 5d 2e 0a 0a  ents] .\n\t.]...
2490: 09 42 6f 72 64 65 72 20 5b 6c 69 6e 64 65 78 20  .Border [lindex 
24a0: 24 66 72 61 67 6d 65 6e 74 73 20 30 5d 20 66 69  $fragments 0] fi
24b0: 72 73 74 73 20 66 69 72 73 74 65 0a 0a 09 69 6e  rsts firste...in
24c0: 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b  tegrity assert {
24d0: 24 66 69 72 73 74 73 20 3d 3d 20 30 7d 20 7b 42  $firsts == 0} {B
24e0: 61 64 20 66 72 61 67 6d 65 6e 74 20 73 74 61 72  ad fragment star
24f0: 74 20 40 20 24 66 69 72 73 74 73 2c 20 67 61 70  t @ $firsts, gap
2500: 2c 20 6f 72 20 62 65 66 6f 72 65 20 62 65 67 69  , or before begi
2510: 6e 6e 69 6e 67 20 6f 66 20 74 68 65 20 72 61 6e  nning of the ran
2520: 67 65 7d 0a 0a 09 73 65 74 20 6c 61 73 74 65 20  ge}...set laste 
2530: 24 66 69 72 73 74 65 0a 09 66 6f 72 65 61 63 68  $firste..foreach
2540: 20 66 72 61 67 6d 65 6e 74 20 5b 6c 72 61 6e 67   fragment [lrang
2550: 65 20 24 66 72 61 67 6d 65 6e 74 73 20 31 20 65  e $fragments 1 e
2560: 6e 64 5d 20 7b 0a 09 20 20 20 20 42 6f 72 64 65  nd] {..    Borde
2570: 72 20 24 66 72 61 67 6d 65 6e 74 20 73 20 65 0a  r $fragment s e.
2580: 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61  .    integrity a
2590: 73 73 65 72 74 20 7b 24 6c 61 73 74 65 20 3d 3d  ssert {$laste ==
25a0: 20 28 24 73 20 2d 20 31 29 7d 20 7b 42 61 64 20   ($s - 1)} {Bad 
25b0: 66 72 61 67 6d 65 6e 74 20 62 6f 72 64 65 72 20  fragment border 
25c0: 3c 24 6c 61 73 74 65 20 7c 20 24 73 3e 2c 20 67  <$laste | $s>, g
25d0: 61 70 20 6f 72 20 6f 76 65 72 6c 61 70 7d 0a 0a  ap or overlap}..
25e0: 09 20 20 20 20 73 65 74 20 6e 65 77 20 5b 24 74  .    set new [$t
25f0: 79 70 65 20 25 41 55 54 4f 25 20 24 6d 79 70 72  ype %AUTO% $mypr
2600: 6f 6a 65 63 74 20 24 6d 79 74 79 70 65 20 24 6d  oject $mytype $m
2610: 79 73 72 63 69 64 20 5b 6c 72 61 6e 67 65 20 24  ysrcid [lrange $
2620: 6d 79 69 74 65 6d 73 20 24 73 20 24 65 5d 5d 0a  myitems $s $e]].
2630: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c 6f 67  .            log
2640: 20 77 72 69 74 65 20 34 20 63 73 65 74 73 20 22   write 4 csets "
2650: 42 72 65 61 6b 69 6e 67 20 5b 24 73 65 6c 66 20  Breaking [$self 
2660: 73 74 72 20 5d 20 40 20 24 6c 61 73 74 65 2c 20  str ] @ $laste, 
2670: 6e 65 77 20 5b 24 6e 65 77 20 73 74 72 5d 2c 20  new [$new str], 
2680: 63 75 74 74 69 6e 67 20 24 62 72 65 61 6b 73 28  cutting $breaks(
2690: 24 6c 61 73 74 65 29 22 0a 0a 09 20 20 20 20 73  $laste)"...    s
26a0: 65 74 20 6c 61 73 74 65 20 24 65 0a 09 7d 0a 0a  et laste $e..}..
26b0: 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72  .integrity asser
26c0: 74 20 7b 0a 09 20 20 20 20 24 6c 61 73 74 65 20  t {..    $laste 
26d0: 3d 3d 20 28 5b 6c 6c 65 6e 67 74 68 20 24 6d 79  == ([llength $my
26e0: 69 74 65 6d 73 5d 2d 31 29 0a 09 7d 20 7b 42 61  items]-1)..} {Ba
26f0: 64 20 66 72 61 67 6d 65 6e 74 20 65 6e 64 20 40  d fragment end @
2700: 20 24 6c 61 73 74 65 2c 20 67 61 70 2c 20 6f 72   $laste, gap, or
2710: 20 62 65 79 6f 6e 64 20 65 6e 64 20 6f 66 20 74   beyond end of t
2720: 68 65 20 72 61 6e 67 65 7d 0a 0a 09 23 20 50 75  he range}...# Pu
2730: 74 20 74 68 65 20 66 69 72 73 74 20 66 72 61 67  t the first frag
2740: 6d 65 6e 74 20 69 6e 74 6f 20 74 68 65 20 63 75  ment into the cu
2750: 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2c  rrent changeset,
2760: 20 61 6e 64 0a 09 23 20 75 70 64 61 74 65 20 74   and..# update t
2770: 68 65 20 69 6e 2d 6d 65 6d 6f 72 79 20 69 6e 64  he in-memory ind
2780: 65 78 2e 20 57 65 20 63 61 6e 20 73 69 6d 70 6c  ex. We can simpl
2790: 79 20 28 72 65 29 61 64 64 20 74 68 65 20 69 74  y (re)add the it
27a0: 65 6d 73 0a 09 23 20 62 65 63 61 75 73 65 20 77  ems..# because w
27b0: 65 20 63 6c 65 61 72 65 64 20 74 68 65 20 70 72  e cleared the pr
27c0: 65 76 69 6f 75 73 6c 79 20 65 78 69 73 74 69 6e  eviously existin
27d0: 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20 73  g information, s
27e0: 65 65 0a 09 23 20 28 2a 29 20 61 62 6f 76 65 2e  ee..# (*) above.
27f0: 20 50 65 72 73 69 73 74 65 6e 63 65 20 64 6f 65   Persistence doe
2800: 73 20 6e 6f 74 20 6d 61 74 74 65 72 20 68 65 72  s not matter her
2810: 65 2c 20 6e 6f 6e 65 20 6f 66 20 74 68 65 0a 09  e, none of the..
2820: 23 20 63 68 61 6e 67 65 73 65 74 73 20 68 61 73  # changesets has
2830: 20 62 65 65 6e 20 73 61 76 65 64 20 74 6f 20 74   been saved to t
2840: 68 65 20 70 65 72 73 69 73 74 65 6e 74 20 73 74  he persistent st
2850: 61 74 65 20 79 65 74 2e 0a 0a 09 73 65 74 20 6d  ate yet....set m
2860: 79 69 74 65 6d 73 20 20 5b 6c 72 61 6e 67 65 20  yitems  [lrange 
2870: 24 6d 79 69 74 65 6d 73 20 20 30 20 24 66 69 72  $myitems  0 $fir
2880: 73 74 65 5d 0a 09 73 65 74 20 6d 79 74 69 74 65  ste]..set mytite
2890: 6d 73 20 5b 6c 72 61 6e 67 65 20 24 6d 79 74 69  ms [lrange $myti
28a0: 74 65 6d 73 20 30 20 24 66 69 72 73 74 65 5d 0a  tems 0 $firste].
28b0: 09 66 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79  .foreach iid $my
28c0: 69 74 65 6d 73 20 7b 0a 09 20 20 20 20 73 65 74  items {..    set
28d0: 20 6b 65 79 20 5b 6c 69 73 74 20 24 6d 79 74 79   key [list $myty
28e0: 70 65 20 24 69 69 64 5d 0a 09 20 20 20 20 73 65  pe $iid]..    se
28f0: 74 20 6d 79 69 74 65 6d 6d 61 70 28 24 6b 65 79  t myitemmap($key
2900: 29 20 24 73 65 6c 66 0a 09 20 20 20 20 6c 6f 67  ) $self..    log
2910: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b   write 8 csets {
2920: 4d 41 50 2b 20 69 74 65 6d 20 3c 24 6b 65 79 3e  MAP+ item <$key>
2930: 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c 66 20   $self = [$self 
2940: 73 74 72 5d 7d 0a 09 7d 0a 0a 09 72 65 74 75 72  str]}..}...retur
2950: 6e 20 31 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d  n 1.    }..    m
2960: 65 74 68 6f 64 20 70 65 72 73 69 73 74 20 7b 7d  ethod persist {}
2970: 20 7b 0a 09 73 65 74 20 74 69 64 20 24 6d 79 63   {..set tid $myc
2980: 73 74 79 70 65 28 24 6d 79 74 79 70 65 29 0a 09  stype($mytype)..
2990: 73 65 74 20 70 69 64 20 5b 24 6d 79 70 72 6f 6a  set pid [$myproj
29a0: 65 63 74 20 69 64 5d 0a 09 73 65 74 20 70 6f 73  ect id]..set pos
29b0: 20 30 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73   0...state trans
29c0: 61 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74  action {..    st
29d0: 61 74 65 20 72 75 6e 20 7b 0a 09 09 49 4e 53 45  ate run {...INSE
29e0: 52 54 20 49 4e 54 4f 20 63 68 61 6e 67 65 73 65  RT INTO changese
29f0: 74 20 28 63 69 64 2c 20 20 20 70 69 64 2c 20 20  t (cid,   pid,  
2a00: 74 79 70 65 2c 20 73 72 63 29 0a 09 09 56 41 4c  type, src)...VAL
2a10: 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20  UES             
2a20: 20 20 20 28 24 6d 79 69 64 2c 20 24 70 69 64 2c     ($myid, $pid,
2a30: 20 24 74 69 64 2c 20 24 6d 79 73 72 63 69 64 29   $tid, $mysrcid)
2a40: 3b 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20 66  ;..    }...    f
2a50: 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79 69 74  oreach iid $myit
2a60: 65 6d 73 20 7b 0a 09 09 73 74 61 74 65 20 72 75  ems {...state ru
2a70: 6e 20 7b 0a 09 09 20 20 20 20 49 4e 53 45 52 54  n {...    INSERT
2a80: 20 49 4e 54 4f 20 63 73 69 74 65 6d 20 28 63 69   INTO csitem (ci
2a90: 64 2c 20 20 20 70 6f 73 2c 20 20 69 69 64 29 0a  d,   pos,  iid).
2aa0: 09 09 20 20 20 20 56 41 4c 55 45 53 20 20 20 20  ..    VALUES    
2ab0: 20 20 20 20 20 20 20 20 20 28 24 6d 79 69 64 2c           ($myid,
2ac0: 20 24 70 6f 73 2c 20 24 69 69 64 29 3b 0a 09 09   $pos, $iid);...
2ad0: 7d 0a 09 09 69 6e 63 72 20 70 6f 73 0a 09 20 20  }...incr pos..  
2ae0: 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20    }..}..return. 
2af0: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64     }..    method
2b00: 20 74 69 6d 65 72 61 6e 67 65 20 7b 7d 20 7b 20   timerange {} { 
2b10: 72 65 74 75 72 6e 20 5b 24 6d 79 74 79 70 65 6f  return [$mytypeo
2b20: 62 6a 20 74 69 6d 65 72 61 6e 67 65 20 24 6d 79  bj timerange $my
2b30: 69 74 65 6d 73 5d 20 7d 0a 0a 20 20 20 20 6d 65  items] }..    me
2b40: 74 68 6f 64 20 6c 69 6d 69 74 73 20 7b 7d 20 7b  thod limits {} {
2b50: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61  ..struct::list a
2b60: 73 73 69 67 6e 20 5b 24 6d 79 74 79 70 65 6f 62  ssign [$mytypeob
2b70: 6a 20 6c 69 6d 69 74 73 20 24 6d 79 69 74 65 6d  j limits $myitem
2b80: 73 5d 20 6d 61 78 70 20 6d 69 6e 73 0a 09 72 65  s] maxp mins..re
2b90: 74 75 72 6e 20 5b 6c 69 73 74 20 5b 54 61 67 49  turn [list [TagI
2ba0: 74 65 6d 44 69 63 74 20 24 6d 61 78 70 20 24 6d  temDict $maxp $m
2bb0: 79 74 79 70 65 5d 20 5b 54 61 67 49 74 65 6d 44  ytype] [TagItemD
2bc0: 69 63 74 20 24 6d 69 6e 73 20 24 6d 79 74 79 70  ict $mins $mytyp
2bd0: 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d  e]].    }..    m
2be0: 65 74 68 6f 64 20 64 72 6f 70 20 7b 7d 20 7b 0a  ethod drop {} {.
2bf0: 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65  .log write 8 cse
2c00: 74 73 20 7b 44 72 6f 70 70 69 6e 67 20 24 73 65  ts {Dropping $se
2c10: 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d  lf = [$self str]
2c20: 7d 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73 61  }...state transa
2c30: 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74 61  ction {..    sta
2c40: 74 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54  te run {...DELET
2c50: 45 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65 74  E FROM changeset
2c60: 20 20 20 57 48 45 52 45 20 63 69 64 20 3d 20 24     WHERE cid = $
2c70: 6d 79 69 64 3b 0a 09 09 44 45 4c 45 54 45 20 46  myid;...DELETE F
2c80: 52 4f 4d 20 63 73 69 74 65 6d 20 20 20 20 20 20  ROM csitem      
2c90: 57 48 45 52 45 20 63 69 64 20 3d 20 24 6d 79 69  WHERE cid = $myi
2ca0: 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f 4d  d;...DELETE FROM
2cb0: 20 63 73 73 75 63 63 65 73 73 6f 72 20 57 48 45   cssuccessor WHE
2cc0: 52 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b 0a  RE cid = $myid;.
2cd0: 09 20 20 20 20 7d 0a 09 7d 0a 09 66 6f 72 65 61  .    }..}..forea
2ce0: 63 68 20 69 69 64 20 24 6d 79 69 74 65 6d 73 20  ch iid $myitems 
2cf0: 7b 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b  {..    set key [
2d00: 6c 69 73 74 20 24 6d 79 74 79 70 65 20 24 69 69  list $mytype $ii
2d10: 64 5d 0a 09 20 20 20 20 75 6e 73 65 74 20 6d 79  d]..    unset my
2d20: 69 74 65 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20  itemmap($key).. 
2d30: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63     log write 8 c
2d40: 73 65 74 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20  sets {MAP- item 
2d50: 3c 24 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b  <$key> $self = [
2d60: 24 73 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 09  $self str]}..}..
2d70: 73 65 74 20 70 6f 73 20 20 20 20 20 20 20 20 20  set pos         
2d80: 20 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 63 74   [lsearch -exact
2d90: 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20 24   $mychangesets $
2da0: 73 65 6c 66 5d 0a 09 73 65 74 20 6d 79 63 68 61  self]..set mycha
2db0: 6e 67 65 73 65 74 73 20 5b 6c 72 65 70 6c 61 63  ngesets [lreplac
2dc0: 65 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20  e $mychangesets 
2dd0: 24 70 6f 73 20 24 70 6f 73 5d 0a 09 73 65 74 20  $pos $pos]..set 
2de0: 70 6f 73 20 20 20 20 20 20 20 20 20 20 20 20 20  pos             
2df0: 20 20 20 20 20 20 20 5b 6c 73 65 61 72 63 68 20         [lsearch 
2e00: 2d 65 78 61 63 74 20 24 6d 79 74 63 68 61 6e 67  -exact $mytchang
2e10: 65 73 65 74 73 28 24 6d 79 74 79 70 65 29 20 24  esets($mytype) $
2e20: 73 65 6c 66 5d 0a 09 73 65 74 20 6d 79 74 63 68  self]..set mytch
2e30: 61 6e 67 65 73 65 74 73 28 24 6d 79 74 79 70 65  angesets($mytype
2e40: 29 20 5b 6c 72 65 70 6c 61 63 65 20 24 6d 79 74  ) [lreplace $myt
2e50: 63 68 61 6e 67 65 73 65 74 73 28 24 6d 79 74 79  changesets($myty
2e60: 70 65 29 20 24 70 6f 73 20 24 70 6f 73 5d 0a 0a  pe) $pos $pos]..
2e70: 09 23 20 52 65 74 75 72 6e 20 74 68 65 20 6c 69  .# Return the li
2e80: 73 74 20 6f 66 20 70 72 65 64 65 63 65 73 73 6f  st of predecesso
2e90: 72 73 20 73 6f 20 74 68 61 74 20 74 68 65 79 20  rs so that they 
2ea0: 63 61 6e 20 62 65 20 61 64 6a 75 73 74 65 64 2e  can be adjusted.
2eb0: 0a 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74  ..return [struct
2ec0: 3a 3a 6c 69 73 74 20 6d 61 70 20 5b 73 74 61 74  ::list map [stat
2ed0: 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c  e run {..    SEL
2ee0: 45 43 54 20 63 69 64 0a 09 20 20 20 20 46 52 4f  ECT cid..    FRO
2ef0: 4d 20 20 20 63 73 73 75 63 63 65 73 73 6f 72 0a  M   cssuccessor.
2f00: 09 20 20 20 20 57 48 45 52 45 20 20 6e 69 64 20  .    WHERE  nid 
2f10: 3d 20 24 6d 79 69 64 0a 09 7d 5d 20 5b 6d 79 74  = $myid..}] [myt
2f20: 79 70 65 6d 65 74 68 6f 64 20 6f 66 5d 5d 0a 20  ypemethod of]]. 
2f30: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64     }..    method
2f40: 20 72 65 70 6f 72 74 6c 6f 6f 70 20 7b 7b 6b 69   reportloop {{ki
2f50: 6c 6c 20 31 7d 7d 20 7b 0a 09 23 20 57 65 20 70  ll 1}} {..# We p
2f60: 72 69 6e 74 20 74 68 65 20 69 74 65 6d 73 20 77  rint the items w
2f70: 68 69 63 68 20 61 72 65 20 70 72 6f 64 75 63 69  hich are produci
2f80: 6e 67 20 74 68 65 20 6c 6f 6f 70 2c 20 61 6e 64  ng the loop, and
2f90: 20 68 6f 77 2e 0a 0a 09 73 65 74 20 68 64 72 20   how....set hdr 
2fa0: 22 53 65 6c 66 2d 72 65 66 65 72 65 6e 74 69 61  "Self-referentia
2fb0: 6c 20 63 68 61 6e 67 65 73 65 74 20 5b 24 73 65  l changeset [$se
2fc0: 6c 66 20 73 74 72 5d 20 5f 5f 5f 5f 5f 5f 5f 5f  lf str] ________
2fd0: 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 22 0a 09 73 65 74  __________"..set
2fe0: 20 66 74 72 20 5b 72 65 67 73 75 62 20 2d 61 6c   ftr [regsub -al
2ff0: 6c 20 7b 5b 5e 20 09 5d 7d 20 24 68 64 72 20 7b  l {[^ .]} $hdr {
3000: 5f 7d 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  _}]...log write 
3010: 30 20 63 73 65 74 73 20 24 68 64 72 0a 09 66 6f  0 csets $hdr..fo
3020: 72 65 61 63 68 20 7b 69 74 65 6d 20 6e 65 78 74  reach {item next
3030: 69 74 65 6d 7d 20 5b 24 6d 79 74 79 70 65 6f 62  item} [$mytypeob
3040: 6a 20 6c 6f 6f 70 73 20 24 6d 79 69 74 65 6d 73  j loops $myitems
3050: 5d 20 7b 0a 09 20 20 20 20 23 20 43 72 65 61 74  ] {..    # Creat
3060: 65 20 74 61 67 67 65 64 20 69 74 65 6d 73 20 66  e tagged items f
3070: 72 6f 6d 20 74 68 65 20 69 64 20 61 6e 64 20 6f  rom the id and o
3080: 75 72 20 74 79 70 65 2e 0a 09 20 20 20 20 73 65  ur type...    se
3090: 74 20 69 74 65 6d 20 20 20 20 20 5b 6c 69 73 74  t item     [list
30a0: 20 24 6d 79 74 79 70 65 20 20 24 69 74 65 6d 5d   $mytype  $item]
30b0: 0a 09 20 20 20 20 73 65 74 20 6e 65 78 74 69 74  ..    set nextit
30c0: 65 6d 20 5b 6c 69 73 74 20 24 6d 79 74 79 70 65  em [list $mytype
30d0: 20 24 6e 65 78 74 69 74 65 6d 5d 0a 09 20 20 20   $nextitem]..   
30e0: 20 23 20 50 72 69 6e 74 61 62 6c 65 20 6c 61 62   # Printable lab
30f0: 65 6c 73 2e 0a 09 20 20 20 20 73 65 74 20 69 20  els...    set i 
3100: 20 22 3c 5b 24 74 79 70 65 20 69 74 65 6d 73 74   "<[$type itemst
3110: 72 20 24 69 74 65 6d 5d 3e 22 0a 09 20 20 20 20  r $item]>"..    
3120: 73 65 74 20 6e 20 20 22 3c 5b 24 74 79 70 65 20  set n  "<[$type 
3130: 69 74 65 6d 73 74 72 20 24 6e 65 78 74 69 74 65  itemstr $nextite
3140: 6d 5d 3e 22 0a 09 20 20 20 20 73 65 74 20 6e 63  m]>"..    set nc
3150: 73 20 24 6d 79 69 74 65 6d 6d 61 70 28 24 6e 65  s $myitemmap($ne
3160: 78 74 69 74 65 6d 29 0a 09 20 20 20 20 23 20 50  xtitem)..    # P
3170: 72 69 6e 74 0a 09 20 20 20 20 6c 6f 67 20 77 72  rint..    log wr
3180: 69 74 65 20 30 20 63 73 65 74 73 20 7b 2a 20 24  ite 0 csets {* $
3190: 69 20 2d 2d 3e 20 24 6e 20 2d 2d 3e 20 63 73 20  i --> $n --> cs 
31a0: 5b 24 6e 63 73 20 73 74 72 5d 7d 0a 09 7d 0a 09  [$ncs str]}..}..
31b0: 6c 6f 67 20 77 72 69 74 65 20 30 20 63 73 65 74  log write 0 cset
31c0: 73 20 24 66 74 72 0a 0a 09 69 66 20 7b 21 24 6b  s $ftr...if {!$k
31d0: 69 6c 6c 7d 20 72 65 74 75 72 6e 0a 09 74 72 6f  ill} return..tro
31e0: 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 22 5b  uble internal "[
31f0: 24 73 65 6c 66 20 73 74 72 5d 20 64 65 70 65 6e  $self str] depen
3200: 64 73 20 6f 6e 20 69 74 73 65 6c 66 22 0a 09 72  ds on itself"..r
3210: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
3220: 20 6d 65 74 68 6f 64 20 70 75 73 68 74 6f 20 7b   method pushto {
3230: 72 65 70 6f 73 69 74 6f 72 79 20 64 61 74 65 20  repository date 
3240: 72 73 74 61 74 65 7d 20 7b 0a 09 23 20 47 65 6e  rstate} {..# Gen
3250: 65 72 61 74 65 20 61 6e 64 20 69 6d 70 6f 72 74  erate and import
3260: 20 74 68 65 20 6d 61 6e 69 66 65 73 74 20 66 6f   the manifest fo
3270: 72 20 74 68 69 73 20 63 68 61 6e 67 65 73 65 74  r this changeset
3280: 2e 0a 09 23 0a 09 23 20 44 61 74 61 20 6e 65 65  ...#..# Data nee
3290: 64 65 64 3a 0a 09 23 20 2d 20 43 6f 6d 6d 69 74  ded:..# - Commit
32a0: 20 6d 65 73 73 61 67 65 20 20 20 20 20 20 20 20   message        
32b0: 20 20 20 20 20 20 20 28 2d 2d 20 6d 79 73 72 63         (-- mysrc
32c0: 69 64 20 2d 3e 20 72 65 70 6f 73 69 74 6f 72 79  id -> repository
32d0: 20 6d 65 74 61 29 0a 09 23 20 2d 20 55 73 65 72   meta)..# - User
32e0: 20 64 6f 69 6e 67 20 74 68 65 20 63 6f 6d 6d 69   doing the commi
32f0: 74 20 20 20 20 20 20 20 20 28 73 2e 61 2e 29 0a  t        (s.a.).
3300: 09 23 0a 09 23 20 2d 20 54 69 6d 65 73 74 61 6d  .#..# - Timestam
3310: 70 20 6f 66 20 77 68 65 6e 20 63 6f 6d 6d 69 74  p of when commit
3320: 74 65 64 20 20 28 63 6f 6d 6d 61 6e 64 20 61 72  ted  (command ar
3330: 67 75 6d 65 6e 74 29 0a 09 23 0a 09 23 20 2d 20  gument)..#..# - 
3340: 54 68 65 20 70 61 72 65 6e 74 20 63 68 61 6e 67  The parent chang
3350: 65 73 65 74 2c 20 69 66 20 61 6e 79 2e 20 49 66  eset, if any. If
3360: 20 74 68 65 72 65 20 69 73 20 6e 6f 20 70 61 72   there is no par
3370: 65 6e 74 20 66 6f 73 73 69 6c 0a 09 23 20 20 20  ent fossil..#   
3380: 77 69 6c 6c 20 75 73 65 20 74 68 65 20 65 6d 70  will use the emp
3390: 74 79 20 62 61 73 65 20 72 65 76 69 73 69 6f 6e  ty base revision
33a0: 20 61 73 20 70 61 72 65 6e 74 2e 0a 09 23 0a 09   as parent...#..
33b0: 23 20 2d 20 4c 69 73 74 20 6f 66 20 74 68 65 20  # - List of the 
33c0: 66 69 6c 65 20 72 65 76 69 73 69 6f 6e 73 20 69  file revisions i
33d0: 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2e  n the changeset.
33e0: 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  ...struct::list 
33f0: 61 73 73 69 67 6e 20 5b 24 6d 79 70 72 6f 6a 65  assign [$myproje
3400: 63 74 20 67 65 74 6d 65 74 61 20 24 6d 79 73 72  ct getmeta $mysr
3410: 63 69 64 5d 20 5f 5f 20 5f 5f 20 75 73 65 72 20  cid] __ __ user 
3420: 6d 65 73 73 61 67 65 0a 0a 09 23 20 57 65 20 64  message...# We d
3430: 65 72 69 76 65 20 74 68 65 20 6c 6f 64 20 69 6e  erive the lod in
3440: 66 6f 72 6d 61 74 69 6f 6e 20 64 69 72 65 63 74  formation direct
3450: 6c 79 20 66 72 6f 6d 20 74 68 65 20 72 65 76 69  ly from the revi
3460: 73 69 6f 6e 73 20 6f 66 0a 09 23 20 74 68 65 20  sions of..# the 
3470: 63 68 61 6e 67 65 73 65 74 2c 20 61 73 20 74 68  changeset, as th
3480: 65 20 62 72 61 6e 63 68 20 70 61 72 74 20 6f 66  e branch part of
3490: 20 74 68 65 20 6d 65 74 61 20 64 61 74 61 20 28   the meta data (
34a0: 73 2e 61 2e 29 20 69 73 0a 09 23 20 6f 75 74 64  s.a.) is..# outd
34b0: 61 74 65 64 20 73 69 6e 63 65 20 70 61 73 73 20  ated since pass 
34c0: 46 69 6c 74 65 72 53 79 6d 62 6f 6c 73 2e 0a 0a  FilterSymbols...
34d0: 09 73 65 74 20 6c 6f 64 6e 61 6d 65 20 5b 24 73  .set lodname [$s
34e0: 65 6c 66 20 6c 6f 64 5d 0a 0a 09 6c 6f 67 20 77  elf lod]...log w
34f0: 72 69 74 65 20 32 20 63 73 65 74 73 20 7b 49 6d  rite 2 csets {Im
3500: 70 6f 72 74 69 6e 67 20 72 65 76 69 73 69 6f 6e  porting revision
3510: 20 5b 24 73 65 6c 66 20 73 74 72 5d 20 6f 6e 20   [$self str] on 
3520: 24 6c 6f 64 6e 61 6d 65 7d 0a 0a 09 23 20 50 65  $lodname}...# Pe
3530: 72 66 6f 72 6d 20 74 68 65 20 69 6d 70 6f 72 74  rform the import
3540: 2e 20 41 73 20 70 61 72 74 20 6f 66 20 74 68 61  . As part of tha
3550: 74 20 77 65 20 64 65 74 65 72 6d 69 6e 65 20 74  t we determine t
3560: 68 65 20 70 61 72 65 6e 74 0a 09 23 20 77 65 20  he parent..# we 
3570: 6e 65 65 64 2c 20 61 6e 64 20 63 6f 6e 76 65 72  need, and conver
3580: 74 20 74 68 65 20 6c 69 73 74 20 6f 66 20 69 74  t the list of it
3590: 65 6d 73 20 69 6e 20 74 68 65 20 63 68 61 6e 67  ems in the chang
35a0: 65 73 65 74 20 69 6e 74 6f 0a 09 23 20 75 75 69  eset into..# uui
35b0: 64 73 20 61 6e 64 20 70 72 69 6e 74 61 62 6c 65  ds and printable
35c0: 20 64 61 74 61 2e 0a 0a 09 73 74 72 75 63 74 3a   data....struct:
35d0: 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 47 65  :list assign [Ge
35e0: 74 69 73 64 65 66 61 75 6c 74 20 24 6d 79 69 74  tisdefault $myit
35f0: 65 6d 73 5d 20 69 73 64 65 66 61 75 6c 74 20 6c  ems] isdefault l
3600: 61 73 74 64 65 66 61 75 6c 74 6f 6e 74 72 75 6e  astdefaultontrun
3610: 6b 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 38 20  k...log write 8 
3620: 63 73 65 74 73 20 7b 4c 4f 44 20 20 20 20 27 24  csets {LOD    '$
3630: 6c 6f 64 6e 61 6d 65 27 7d 0a 09 6c 6f 67 20 77  lodname'}..log w
3640: 72 69 74 65 20 38 20 63 73 65 74 73 20 7b 20 64  rite 8 csets { d
3650: 65 66 3f 20 20 24 69 73 64 65 66 61 75 6c 74 7d  ef?  $isdefault}
3660: 0a 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73  ..log write 8 cs
3670: 65 74 73 20 7b 20 6c 61 73 74 3f 20 24 6c 61 73  ets { last? $las
3680: 74 64 65 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 7d  tdefaultontrunk}
3690: 0a 0a 09 73 65 74 20 6c 77 73 20 20 5b 47 65 74  ...set lws  [Get
36a0: 77 6f 72 6b 73 70 61 63 65 20 20 20 20 24 72 73  workspace    $rs
36b0: 74 61 74 65 20 24 6c 6f 64 6e 61 6d 65 20 24 6d  tate $lodname $m
36c0: 79 70 72 6f 6a 65 63 74 20 24 69 73 64 65 66 61  yproject $isdefa
36d0: 75 6c 74 5d 0a 09 24 6c 77 73 20 61 64 64 20 5b  ult]..$lws add [
36e0: 47 65 74 72 65 76 69 73 69 6f 6e 69 6e 66 6f 20  Getrevisioninfo 
36f0: 24 6d 79 69 74 65 6d 73 5d 0a 0a 09 73 65 74 20  $myitems]...set 
3700: 75 75 69 64 20 5b 24 72 65 70 6f 73 69 74 6f 72  uuid [$repositor
3710: 79 20 69 6d 70 6f 72 74 72 65 76 69 73 69 6f 6e  y importrevision
3720: 20 5b 24 73 65 6c 66 20 73 74 72 5d 20 5c 0a 09   [$self str] \..
3730: 09 20 20 20 20 20 20 24 75 73 65 72 20 24 6d 65  .      $user $me
3740: 73 73 61 67 65 20 24 64 61 74 65 20 5c 0a 09 09  ssage $date \...
3750: 20 20 20 20 20 20 5b 24 6c 77 73 20 67 65 74 69        [$lws geti
3760: 64 5d 20 5b 24 6c 77 73 20 67 65 74 5d 5d 0a 0a  d] [$lws get]]..
3770: 09 23 20 52 65 6d 65 6d 62 65 72 20 74 68 65 20  .# Remember the 
3780: 69 6d 70 6f 72 74 65 64 20 63 68 61 6e 67 65 73  imported changes
3790: 65 74 20 69 6e 20 74 68 65 20 73 74 61 74 65 2c  et in the state,
37a0: 20 75 6e 64 65 72 20 6f 75 72 0a 09 23 20 4c 4f   under our..# LO
37b0: 44 2e 20 41 6e 64 20 69 66 20 69 74 20 69 73 20  D. And if it is 
37c0: 74 68 65 20 6c 61 73 74 20 74 72 75 6e 6b 20 63  the last trunk c
37d0: 68 61 6e 67 65 73 65 74 20 6f 6e 20 74 68 65 20  hangeset on the 
37e0: 76 65 6e 64 6f 72 0a 09 23 20 62 72 61 6e 63 68  vendor..# branch
37f0: 20 74 68 65 6e 20 74 68 65 20 72 65 76 69 73 69   then the revisi
3800: 6f 6e 20 69 73 20 61 6c 73 6f 20 74 68 65 20 61  on is also the a
3810: 63 74 75 61 6c 20 72 6f 6f 74 20 6f 66 20 74 68  ctual root of th
3820: 65 0a 09 23 20 3a 74 72 75 6e 6b 3a 2c 20 73 6f  e..# :trunk:, so
3830: 20 77 65 20 72 65 6d 65 6d 62 65 72 20 69 74 20   we remember it 
3840: 61 73 20 73 75 63 68 20 69 6e 20 74 68 65 20 73  as such in the s
3850: 74 61 74 65 2e 20 48 6f 77 65 76 65 72 20 69 66  tate. However if
3860: 0a 09 23 20 74 68 65 20 74 72 75 6e 6b 20 61 6c  ..# the trunk al
3870: 72 65 61 64 79 20 65 78 69 73 74 73 20 74 68 65  ready exists the
3880: 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20  n the changeset 
3890: 63 61 6e 6e 6f 74 20 62 65 20 6f 6e 20 69 74 0a  cannot be on it.
38a0: 09 23 20 61 6e 79 20 6d 6f 72 65 2e 20 54 68 69  .# any more. Thi
38b0: 73 20 69 6e 64 69 63 61 74 65 73 20 77 65 69 72  s indicates weir
38c0: 64 6e 65 73 73 20 69 6e 20 74 68 65 20 73 65 74  dness in the set
38d0: 75 70 20 6f 66 20 74 68 65 0a 09 23 20 76 65 6e  up of the..# ven
38e0: 64 6f 72 20 62 72 61 6e 63 68 2c 20 62 75 74 20  dor branch, but 
38f0: 6f 6e 65 20 77 65 20 63 61 6e 20 77 6f 72 6b 20  one we can work 
3900: 61 72 6f 75 6e 64 2e 0a 0a 09 24 6c 77 73 20 64  around....$lws d
3910: 65 66 69 64 20 24 75 75 69 64 0a 09 69 66 20 7b  efid $uuid..if {
3920: 24 6c 61 73 74 64 65 66 61 75 6c 74 6f 6e 74 72  $lastdefaultontr
3930: 75 6e 6b 7d 20 7b 0a 09 20 20 20 20 69 66 20 7b  unk} {..    if {
3940: 5b 24 72 73 74 61 74 65 20 68 61 73 20 3a 74 72  [$rstate has :tr
3950: 75 6e 6b 3a 5d 7d 20 7b 0a 09 09 6c 6f 67 20 77  unk:]} {...log w
3960: 72 69 74 65 20 32 20 63 73 65 74 73 20 7b 4d 75  rite 2 csets {Mu
3970: 6c 74 69 70 6c 65 20 63 68 61 6e 67 65 73 65 74  ltiple changeset
3980: 73 20 64 65 63 6c 61 72 65 64 20 74 6f 20 62 65  s declared to be
3990: 20 74 68 65 20 6c 61 73 74 20 74 72 75 6e 6b 20   the last trunk 
39a0: 63 68 61 6e 67 65 73 65 74 20 6f 6e 20 74 68 65  changeset on the
39b0: 20 76 65 6e 64 6f 72 2d 62 72 61 6e 63 68 7d 0a   vendor-branch}.
39c0: 09 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 09 09  .    } else {...
39d0: 24 72 73 74 61 74 65 20 6e 65 77 20 3a 74 72 75  $rstate new :tru
39e0: 6e 6b 3a 20 5b 24 6c 77 73 20 6e 61 6d 65 5d 0a  nk: [$lws name].
39f0: 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 23 20 52 65  .    }..}...# Re
3a00: 6d 65 6d 62 65 72 20 74 68 65 20 77 68 6f 6c 65  member the whole
3a10: 20 63 68 61 6e 67 65 73 65 74 20 2f 20 75 75 69   changeset / uui
3a20: 64 20 6d 61 70 70 69 6e 67 2c 20 66 6f 72 20 74  d mapping, for t
3a30: 68 65 20 74 61 67 73 2e 0a 0a 09 73 74 61 74 65  he tags....state
3a40: 20 72 75 6e 20 7b 0a 09 20 20 20 20 49 4e 53 45   run {..    INSE
3a50: 52 54 20 49 4e 54 4f 20 63 73 75 75 69 64 20 28  RT INTO csuuid (
3a60: 63 69 64 2c 20 20 20 75 75 69 64 29 0a 09 20 20  cid,   uuid)..  
3a70: 20 20 56 41 4c 55 45 53 20 20 20 20 20 20 20 20    VALUES        
3a80: 20 20 20 20 20 28 24 6d 79 69 64 2c 20 24 75 75       ($myid, $uu
3a90: 69 64 29 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20  id)..}..return. 
3aa0: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 47     }..    proc G
3ab0: 65 74 72 65 76 69 73 69 6f 6e 69 6e 66 6f 20 7b  etrevisioninfo {
3ac0: 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 73 65  revisions} {..se
3ad0: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
3ae0: 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27   $revisions {','
3af0: 7d 5d 27 29 0a 09 73 65 74 20 72 65 76 69 73 69  }]')..set revisi
3b00: 6f 6e 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20  ons {}..foreach 
3b10: 7b 66 72 69 64 20 70 61 74 68 20 66 6e 61 6d 65  {frid path fname
3b20: 20 72 65 76 6e 72 20 72 6f 70 7d 20 5b 73 74 61   revnr rop} [sta
3b30: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
3b40: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
3b50: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
3b60: 53 45 4c 45 43 54 20 55 2e 75 75 69 64 2c 20 46  SELECT U.uuid, F
3b70: 2e 76 69 73 69 62 6c 65 2c 20 46 2e 6e 61 6d 65  .visible, F.name
3b80: 2c 20 52 2e 72 65 76 2c 20 52 2e 6f 70 0a 09 20  , R.rev, R.op.. 
3b90: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69     FROM   revisi
3ba0: 6f 6e 20 52 2c 20 72 65 76 75 75 69 64 20 55 2c  on R, revuuid U,
3bb0: 20 66 69 6c 65 20 46 0a 09 20 20 20 20 57 48 45   file F..    WHE
3bc0: 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24 74 68  RE  R.rid IN $th
3bd0: 65 73 65 74 20 20 2d 2d 20 41 6c 6c 20 73 70 65  eset  -- All spe
3be0: 63 69 66 69 65 64 20 72 65 76 69 73 69 6f 6e 73  cified revisions
3bf0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 55 2e 72  ..    AND    U.r
3c00: 69 64 20 3d 20 52 2e 72 69 64 20 20 20 20 20 2d  id = R.rid     -
3c10: 2d 20 67 65 74 20 66 6f 73 73 69 6c 20 75 75 69  - get fossil uui
3c20: 64 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a 09 20  d of revision.. 
3c30: 20 20 20 41 4e 44 20 20 20 20 46 2e 66 69 64 20     AND    F.fid 
3c40: 3d 20 52 2e 66 69 64 20 20 20 20 20 2d 2d 20 67  = R.fid     -- g
3c50: 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76 69 73  et file of revis
3c60: 69 6f 6e 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20  ion..}]] {..    
3c70: 6c 61 70 70 65 6e 64 20 72 65 76 69 73 69 6f 6e  lappend revision
3c80: 73 20 24 66 72 69 64 20 24 70 61 74 68 20 24 66  s $frid $path $f
3c90: 6e 61 6d 65 2f 24 72 65 76 6e 72 20 24 72 6f 70  name/$revnr $rop
3ca0: 0a 09 7d 0a 09 72 65 74 75 72 6e 20 24 72 65 76  ..}..return $rev
3cb0: 69 73 69 6f 6e 73 0a 20 20 20 20 7d 0a 0a 20 20  isions.    }..  
3cc0: 20 20 70 72 6f 63 20 47 65 74 77 6f 72 6b 73 70    proc Getworksp
3cd0: 61 63 65 20 7b 72 73 74 61 74 65 20 6c 6f 64 6e  ace {rstate lodn
3ce0: 61 6d 65 20 70 72 6f 6a 65 63 74 20 69 73 64 65  ame project isde
3cf0: 66 61 75 6c 74 7d 20 7b 0a 0a 09 23 20 54 68 65  fault} {...# The
3d00: 20 73 74 61 74 65 20 6f 62 6a 65 63 74 20 68 6f   state object ho
3d10: 6c 64 73 20 74 68 65 20 77 6f 72 6b 73 70 61 63  lds the workspac
3d20: 65 20 73 74 61 74 65 20 6f 66 20 65 61 63 68 20  e state of each 
3d30: 6b 6e 6f 77 6e 0a 09 23 20 6c 69 6e 65 2d 6f 66  known..# line-of
3d40: 2d 64 65 76 65 6c 6f 70 6d 65 6e 74 20 28 4c 4f  -development (LO
3d50: 44 29 2c 20 75 70 20 74 6f 20 74 68 65 20 6c 61  D), up to the la
3d60: 73 74 20 63 6f 6d 6d 69 74 74 65 64 0a 09 23 20  st committed..# 
3d70: 63 68 61 6e 67 65 73 65 74 20 62 65 6c 6f 6e 67  changeset belong
3d80: 69 6e 67 20 74 6f 20 74 68 61 74 20 4c 4f 44 2e  ing to that LOD.
3d90: 0a 0a 09 23 20 28 2a 29 20 53 74 61 6e 64 61 72  ...# (*) Standar
3da0: 64 20 68 61 6e 64 6c 69 6e 67 20 69 66 20 69 6e  d handling if in
3db0: 2d 4c 4f 44 20 63 68 61 6e 67 65 73 65 74 73 2e  -LOD changesets.
3dc0: 20 49 66 20 74 68 65 20 4c 4f 44 20 6f 66 0a 09   If the LOD of..
3dd0: 23 20 20 20 20 20 74 68 65 20 63 75 72 72 65 6e  #     the curren
3de0: 74 20 63 68 61 6e 67 65 73 65 74 20 65 78 69 73  t changeset exis
3df0: 74 73 20 69 6e 20 74 68 65 20 73 74 61 74 65 20  ts in the state 
3e00: 28 3d 20 68 61 73 20 62 65 65 6e 0a 09 23 20 20  (= has been..#  
3e10: 20 20 20 63 6f 6d 6d 69 74 74 65 64 20 74 6f 29     committed to)
3e20: 20 74 68 65 6e 20 74 68 69 73 20 69 74 20 68 61   then this it ha
3e30: 73 20 74 68 65 20 77 6f 72 6b 73 70 61 63 65 20  s the workspace 
3e40: 77 65 20 61 72 65 0a 09 23 20 20 20 20 20 6c 6f  we are..#     lo
3e50: 6f 6b 69 6e 67 20 66 6f 72 2e 0a 0a 09 69 66 20  oking for....if 
3e60: 7b 5b 24 72 73 74 61 74 65 20 68 61 73 20 24 6c  {[$rstate has $l
3e70: 6f 64 6e 61 6d 65 5d 7d 20 7b 0a 09 20 20 20 20  odname]} {..    
3e80: 72 65 74 75 72 6e 20 5b 24 72 73 74 61 74 65 20  return [$rstate 
3e90: 67 65 74 20 24 6c 6f 64 6e 61 6d 65 5d 0a 09 7d  get $lodname]..}
3ea0: 0a 0a 09 23 20 49 66 20 74 68 65 20 4c 4f 44 20  ...# If the LOD 
3eb0: 69 73 20 68 6f 77 65 76 65 72 20 6e 6f 74 20 79  is however not y
3ec0: 65 74 20 6b 6e 6f 77 6e 2c 20 74 68 65 6e 20 74  et known, then t
3ed0: 68 65 20 63 75 72 72 65 6e 74 0a 09 23 20 63 68  he current..# ch
3ee0: 61 6e 67 65 73 65 74 20 63 61 6e 20 62 65 20 65  angeset can be e
3ef0: 69 74 68 65 72 20 6f 66 0a 09 23 20 28 61 29 20  ither of..# (a) 
3f00: 72 6f 6f 74 20 6f 66 20 61 20 76 65 6e 64 6f 72  root of a vendor
3f10: 20 62 72 61 6e 63 68 2c 0a 09 23 20 28 62 29 20   branch,..# (b) 
3f20: 72 6f 6f 74 20 6f 66 20 74 68 65 20 74 72 75 6e  root of the trun
3f30: 6b 20 4c 4f 44 2c 20 6f 72 0a 09 23 20 28 63 29  k LOD, or..# (c)
3f40: 20 74 68 65 20 66 69 72 73 74 20 63 68 61 6e 67   the first chang
3f50: 65 73 65 74 20 69 6e 20 61 20 6e 65 77 20 4c 4f  eset in a new LO
3f60: 44 20 77 68 69 63 68 20 77 61 73 20 73 70 61 77  D which was spaw
3f70: 6e 65 64 20 66 72 6f 6d 0a 09 23 20 20 20 20 20  ned from..#     
3f80: 61 6e 20 65 78 69 73 74 69 6e 67 20 4c 4f 44 2e  an existing LOD.
3f90: 0a 0a 09 69 66 20 7b 24 69 73 64 65 66 61 75 6c  ...if {$isdefaul
3fa0: 74 20 7c 7c 20 28 24 6c 6f 64 6e 61 6d 65 20 65  t || ($lodname e
3fb0: 71 20 22 3a 74 72 75 6e 6b 3a 22 29 7d 20 7b 0a  q ":trunk:")} {.
3fc0: 09 20 20 20 20 23 20 46 6f 72 20 62 6f 74 68 20  .    # For both 
3fd0: 28 61 29 20 61 6e 64 20 28 62 29 20 77 65 20 68  (a) and (b) we h
3fe0: 61 76 65 20 74 6f 20 63 72 65 61 74 65 20 61 20  ave to create a 
3ff0: 6e 65 77 20 77 6f 72 6b 73 70 61 63 65 0a 09 20  new workspace.. 
4000: 20 20 20 23 20 66 6f 72 20 74 68 65 20 6c 6f 64     # for the lod
4010: 2c 20 61 6e 64 20 69 74 20 64 6f 65 73 6e 27 74  , and it doesn't
4020: 20 69 6e 68 65 72 69 74 20 66 72 6f 6d 20 61 6e   inherit from an
4030: 79 74 68 69 6e 67 2e 0a 0a 09 20 20 20 20 23 20  ything....    # 
4040: 4e 6f 74 65 20 74 68 61 74 20 63 61 73 65 20 28  Note that case (
4050: 62 29 20 6d 61 79 20 6e 65 76 65 72 20 6f 63 63  b) may never occ
4060: 75 72 2e 20 53 65 65 20 74 68 65 20 76 61 72 69  ur. See the vari
4070: 61 62 6c 65 0a 09 20 20 20 20 23 20 27 6c 61 73  able..    # 'las
4080: 74 64 65 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 27  tdefaultontrunk'
4090: 20 69 6e 20 74 68 65 20 63 61 6c 6c 65 72 20 28   in the caller (
40a0: 6d 65 74 68 6f 64 20 70 75 73 68 74 6f 29 2e 20  method pushto). 
40b0: 54 68 69 73 0a 09 20 20 20 20 23 20 66 6c 61 67  This..    # flag
40c0: 20 63 61 6e 20 74 68 65 20 67 65 6e 65 72 61 74   can the generat
40d0: 69 6f 6e 20 6f 66 20 74 68 65 20 77 6f 72 6b 73  ion of the works
40e0: 70 61 63 65 20 66 6f 72 20 74 68 65 20 3a 74 72  pace for the :tr
40f0: 75 6e 6b 3a 0a 09 20 20 20 20 23 20 4c 4f 44 20  unk:..    # LOD 
4100: 61 73 20 77 65 6c 6c 2c 20 6d 61 6b 69 6e 67 20  as well, making 
4110: 69 74 20 69 6e 68 65 72 69 74 20 74 68 65 20 73  it inherit the s
4120: 74 61 74 65 20 6f 66 20 74 68 65 20 6c 61 73 74  tate of the last
4130: 0a 09 20 20 20 20 23 20 74 72 75 6e 6b 2d 63 68  ..    # trunk-ch
4140: 61 6e 67 65 73 65 74 20 6f 6e 20 74 68 65 20 76  angeset on the v
4150: 65 6e 64 6f 72 2d 62 72 61 6e 63 68 2e 0a 0a 09  endor-branch....
4160: 20 20 20 20 72 65 74 75 72 6e 20 5b 24 72 73 74      return [$rst
4170: 61 74 65 20 6e 65 77 20 24 6c 6f 64 6e 61 6d 65  ate new $lodname
4180: 5d 0a 09 7d 0a 0a 09 23 20 43 61 73 65 20 28 63  ]..}...# Case (c
4190: 29 2e 20 57 65 20 66 69 6e 64 20 74 68 65 20 70  ). We find the p
41a0: 61 72 65 6e 74 20 4c 4f 44 20 6f 66 20 6f 75 72  arent LOD of our
41b0: 20 4c 4f 44 20 61 6e 64 20 6c 65 74 20 74 68 65   LOD and let the
41c0: 20 6e 65 77 0a 09 23 20 77 6f 72 6b 73 70 61 63   new..# workspac
41d0: 65 20 69 6e 68 65 72 69 74 20 66 72 6f 6d 20 74  e inherit from t
41e0: 68 65 20 70 61 72 65 6e 74 27 73 20 77 6f 72 6b  he parent's work
41f0: 73 70 61 63 65 2e 0a 0a 09 73 65 74 20 70 6c 6f  space....set plo
4200: 64 6e 61 6d 65 20 5b 5b 5b 24 70 72 6f 6a 65 63  dname [[[$projec
4210: 74 20 67 65 74 73 79 6d 62 6f 6c 20 24 6c 6f 64  t getsymbol $lod
4220: 6e 61 6d 65 5d 20 70 61 72 65 6e 74 5d 20 6e 61  name] parent] na
4230: 6d 65 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  me]...log write 
4240: 38 20 63 73 65 74 73 20 7b 70 4c 4f 44 20 20 20  8 csets {pLOD   
4250: 27 24 70 6c 6f 64 6e 61 6d 65 27 7d 0a 0a 09 69  '$plodname'}...i
4260: 66 20 7b 5b 24 72 73 74 61 74 65 20 68 61 73 20  f {[$rstate has 
4270: 24 70 6c 6f 64 6e 61 6d 65 5d 7d 20 7b 0a 09 20  $plodname]} {.. 
4280: 20 20 20 72 65 74 75 72 6e 20 5b 24 72 73 74 61     return [$rsta
4290: 74 65 20 6e 65 77 20 24 6c 6f 64 6e 61 6d 65 20  te new $lodname 
42a0: 24 70 6c 6f 64 6e 61 6d 65 5d 0a 09 7d 0a 0a 09  $plodname]..}...
42b0: 66 6f 72 65 61 63 68 20 6b 20 5b 6c 73 6f 72 74  foreach k [lsort
42c0: 20 5b 24 72 73 74 61 74 65 20 6e 61 6d 65 73 5d   [$rstate names]
42d0: 5d 20 7b 0a 09 20 20 20 20 6c 6f 67 20 77 72 69  ] {..    log wri
42e0: 74 65 20 38 20 63 73 65 74 73 20 7b 20 20 20 20  te 8 csets {    
42f0: 24 6b 20 3d 20 5b 5b 24 72 73 74 61 74 65 20 67  $k = [[$rstate g
4300: 65 74 20 24 6b 5d 20 67 65 74 69 64 5d 7d 0a 09  et $k] getid]}..
4310: 7d 0a 0a 09 74 72 6f 75 62 6c 65 20 69 6e 74 65  }...trouble inte
4320: 72 6e 61 6c 20 7b 55 6e 61 62 6c 65 20 74 6f 20  rnal {Unable to 
4330: 64 65 74 65 72 6d 69 6e 65 20 63 68 61 6e 67 65  determine change
4340: 73 65 74 20 70 61 72 65 6e 74 7d 0a 09 72 65 74  set parent}..ret
4350: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70  urn.    }..    p
4360: 72 6f 63 20 47 65 74 69 73 64 65 66 61 75 6c 74  roc Getisdefault
4370: 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09   {revisions} {..
4380: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f  set theset ('[jo
4390: 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27  in $revisions {'
43a0: 2c 27 7d 5d 27 29 0a 0a 09 73 74 72 75 63 74 3a  ,'}]')...struct:
43b0: 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 73 74  :list assign [st
43c0: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
43d0: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
43e0: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
43f0: 20 53 45 4c 45 43 54 20 52 2e 69 73 64 65 66 61   SELECT R.isdefa
4400: 75 6c 74 2c 20 52 2e 64 62 63 68 69 6c 64 0a 09  ult, R.dbchild..
4410: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
4420: 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45  ion R..    WHERE
4430: 20 20 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73    R.rid IN $thes
4440: 65 74 20 20 2d 2d 20 41 6c 6c 20 73 70 65 63 69  et  -- All speci
4450: 66 69 65 64 20 72 65 76 69 73 69 6f 6e 73 0a 09  fied revisions..
4460: 20 20 20 20 4c 49 4d 49 54 20 31 0a 09 7d 5d 5d      LIMIT 1..}]]
4470: 20 64 65 66 20 6c 61 73 74 0a 0a 09 23 20 54 4f   def last...# TO
4480: 44 4f 2f 43 48 45 43 4b 3a 20 6c 6f 6f 6b 20 66  DO/CHECK: look f
4490: 6f 72 20 63 68 61 6e 67 65 73 65 74 73 20 77 68  or changesets wh
44a0: 65 72 65 20 69 73 64 65 66 61 75 6c 74 2f 64 62  ere isdefault/db
44b0: 63 68 69 6c 64 20 69 73 0a 09 23 20 61 6d 62 69  child is..# ambi
44c0: 67 6f 75 73 2e 0a 0a 09 72 65 74 75 72 6e 20 5b  gous....return [
44d0: 6c 69 73 74 20 24 64 65 66 20 5b 65 78 70 72 20  list $def [expr 
44e0: 7b 24 6c 61 73 74 20 6e 65 20 22 22 7d 5d 5d 0a  {$last ne ""}]].
44f0: 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d      }..    typem
4500: 65 74 68 6f 64 20 73 70 6c 69 74 20 7b 63 73 65  ethod split {cse
4510: 74 20 61 72 67 73 7d 20 7b 0a 09 23 20 41 73 20  t args} {..# As 
4520: 70 61 72 74 20 6f 66 20 74 68 65 20 63 72 65 61  part of the crea
4530: 74 69 6f 6e 20 6f 66 20 74 68 65 20 6e 65 77 20  tion of the new 
4540: 63 68 61 6e 67 65 73 65 74 73 20 73 70 65 63 69  changesets speci
4550: 66 69 65 64 20 69 6e 0a 09 23 20 41 52 47 53 20  fied in..# ARGS 
4560: 61 73 20 73 65 74 73 20 6f 66 20 69 74 65 6d 73  as sets of items
4570: 2c 20 61 6c 6c 20 73 75 62 73 65 74 73 20 6f 66  , all subsets of
4580: 20 43 53 45 54 27 73 20 69 74 65 6d 20 73 65 74   CSET's item set
4590: 2c 20 43 53 45 54 0a 09 23 20 77 69 6c 6c 20 62  , CSET..# will b
45a0: 65 20 64 72 6f 70 70 65 64 20 66 72 6f 6d 20 61  e dropped from a
45b0: 6c 6c 20 64 61 74 61 62 61 73 65 73 2c 20 69 6e  ll databases, in
45c0: 20 61 6e 64 20 6f 75 74 20 6f 66 20 6d 65 6d 6f   and out of memo
45d0: 72 79 2c 0a 09 23 20 61 6e 64 20 74 68 65 6e 20  ry,..# and then 
45e0: 64 65 73 74 72 6f 79 65 64 2e 0a 09 23 0a 09 23  destroyed...#..#
45f0: 20 4e 6f 74 65 3a 20 54 68 65 20 69 74 65 6d 20   Note: The item 
4600: 6c 69 73 74 73 20 66 6f 75 6e 64 20 69 6e 20 61  lists found in a
4610: 72 67 73 20 61 72 65 20 74 61 67 67 65 64 20 69  rgs are tagged i
4620: 74 65 6d 73 2e 20 54 68 65 79 0a 09 23 20 68 61  tems. They..# ha
4630: 76 65 20 74 6f 20 68 61 76 65 20 74 68 65 20 73  ve to have the s
4640: 61 6d 65 20 74 79 70 65 20 61 73 20 74 68 65 20  ame type as the 
4650: 63 68 61 6e 67 65 73 65 74 2c 20 62 65 69 6e 67  changeset, being
4660: 20 73 75 62 73 65 74 73 0a 09 23 20 6f 66 20 69   subsets..# of i
4670: 74 73 20 69 74 65 6d 73 2e 20 54 68 69 73 20 69  ts items. This i
4680: 73 20 63 68 65 63 6b 65 64 20 69 6e 20 55 6e 74  s checked in Unt
4690: 61 67 31 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65  ag1....log write
46a0: 20 38 20 63 73 65 74 73 20 7b 4f 4c 44 3a 20 5b   8 csets {OLD: [
46b0: 6c 73 6f 72 74 20 5b 24 63 73 65 74 20 69 74 65  lsort [$cset ite
46c0: 6d 73 5d 5d 7d 0a 09 56 61 6c 69 64 61 74 65 46  ms]]}..ValidateF
46d0: 72 61 67 6d 65 6e 74 73 20 24 63 73 65 74 20 24  ragments $cset $
46e0: 61 72 67 73 0a 0a 09 23 20 41 6c 6c 20 63 68 65  args...# All che
46f0: 63 6b 73 20 70 61 73 73 2c 20 61 63 74 75 61 6c  cks pass, actual
4700: 6c 79 20 70 65 72 66 6f 72 6d 20 74 68 65 20 73  ly perform the s
4710: 70 6c 69 74 2e 0a 0a 09 73 74 72 75 63 74 3a 3a  plit....struct::
4720: 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 24 63 73  list assign [$cs
4730: 65 74 20 64 61 74 61 5d 20 70 72 6f 6a 65 63 74  et data] project
4740: 20 63 73 74 79 70 65 20 63 73 73 72 63 0a 0a 09   cstype cssrc...
4750: 73 65 74 20 70 72 65 64 65 63 65 73 73 6f 72 73  set predecessors
4760: 20 5b 24 63 73 65 74 20 64 72 6f 70 5d 0a 09 24   [$cset drop]..$
4770: 63 73 65 74 20 64 65 73 74 72 6f 79 0a 0a 09 73  cset destroy...s
4780: 65 74 20 6e 65 77 63 73 65 74 73 20 7b 7d 0a 09  et newcsets {}..
4790: 66 6f 72 65 61 63 68 20 66 72 61 67 6d 65 6e 74  foreach fragment
47a0: 69 74 65 6d 73 20 24 61 72 67 73 20 7b 0a 09 20  items $args {.. 
47b0: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63     log write 8 c
47c0: 73 65 74 73 20 7b 4d 41 4b 45 3a 20 5b 6c 73 6f  sets {MAKE: [lso
47d0: 72 74 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d  rt $fragmentitem
47e0: 73 5d 7d 0a 0a 09 20 20 20 20 73 65 74 20 66 72  s]}...    set fr
47f0: 61 67 6d 65 6e 74 20 5b 24 74 79 70 65 20 25 41  agment [$type %A
4800: 55 54 4f 25 20 24 70 72 6f 6a 65 63 74 20 24 63  UTO% $project $c
4810: 73 74 79 70 65 20 24 63 73 73 72 63 20 5c 0a 09  stype $cssrc \..
4820: 09 09 20 20 20 20 20 20 5b 55 6e 74 61 67 20 24  ..      [Untag $
4830: 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 20 24 63  fragmentitems $c
4840: 73 74 79 70 65 5d 5d 0a 09 20 20 20 20 6c 61 70  stype]]..    lap
4850: 70 65 6e 64 20 6e 65 77 63 73 65 74 73 20 24 66  pend newcsets $f
4860: 72 61 67 6d 65 6e 74 0a 0a 09 20 20 20 20 24 66  ragment...    $f
4870: 72 61 67 6d 65 6e 74 20 70 65 72 73 69 73 74 0a  ragment persist.
4880: 09 20 20 20 20 24 66 72 61 67 6d 65 6e 74 20 64  .    $fragment d
4890: 65 74 65 72 6d 69 6e 65 73 75 63 63 65 73 73 6f  eterminesuccesso
48a0: 72 73 0a 09 7d 0a 0a 09 23 20 54 68 65 20 70 72  rs..}...# The pr
48b0: 65 64 65 63 65 73 73 6f 72 73 20 68 61 76 65 20  edecessors have 
48c0: 74 6f 20 72 65 63 6f 6d 70 75 74 65 20 74 68 65  to recompute the
48d0: 69 72 20 73 75 63 63 65 73 73 6f 72 73 2c 20 69  ir successors, i
48e0: 2e 65 2e 0a 09 23 20 72 65 6d 6f 76 65 20 74 68  .e...# remove th
48f0: 65 20 64 72 6f 70 70 65 64 20 63 68 61 6e 67 65  e dropped change
4900: 73 65 74 20 61 6e 64 20 70 75 74 20 6f 6e 65 20  set and put one 
4910: 6f 66 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73  of the fragments
4920: 0a 09 23 20 69 6e 74 6f 20 69 74 73 20 70 6c 61  ..# into its pla
4930: 63 65 2e 0a 09 66 6f 72 65 61 63 68 20 70 20 24  ce...foreach p $
4940: 70 72 65 64 65 63 65 73 73 6f 72 73 20 7b 0a 09  predecessors {..
4950: 20 20 20 20 24 70 20 64 65 74 65 72 6d 69 6e 65      $p determine
4960: 73 75 63 63 65 73 73 6f 72 73 0a 09 7d 0a 0a 09  successors..}...
4970: 72 65 74 75 72 6e 20 24 6e 65 77 63 73 65 74 73  return $newcsets
4980: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65  .    }..    type
4990: 6d 65 74 68 6f 64 20 69 74 65 6d 73 74 72 20 7b  method itemstr {
49a0: 69 74 65 6d 7d 20 7b 0a 09 73 74 72 75 63 74 3a  item} {..struct:
49b0: 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24 69 74  :list assign $it
49c0: 65 6d 20 69 74 79 70 65 20 69 69 64 0a 09 72 65  em itype iid..re
49d0: 74 75 72 6e 20 5b 24 69 74 79 70 65 20 73 74 72  turn [$itype str
49e0: 20 24 69 69 64 5d 0a 20 20 20 20 7d 0a 0a 20 20   $iid].    }..  
49f0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 74 72    typemethod str
4a00: 6c 69 73 74 20 7b 63 68 61 6e 67 65 73 65 74 73  list {changesets
4a10: 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 6a 6f 69  } {..return [joi
4a20: 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69 73 74 20  n [struct::list 
4a30: 6d 61 70 20 24 63 68 61 6e 67 65 73 65 74 73 20  map $changesets 
4a40: 5b 6d 79 70 72 6f 63 20 49 44 5d 5d 5d 0a 20 20  [myproc ID]]].  
4a50: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 49 44    }..    proc ID
4a60: 20 7b 63 73 65 74 7d 20 7b 20 24 63 73 65 74 20   {cset} { $cset 
4a70: 73 74 72 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20  str }..    proc 
4a80: 55 6e 74 61 67 20 7b 74 61 67 67 65 64 69 74 65  Untag {taggedite
4a90: 6d 73 20 63 73 74 79 70 65 7d 20 7b 0a 09 72 65  ms cstype} {..re
4aa0: 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69  turn [struct::li
4ab0: 73 74 20 6d 61 70 20 24 74 61 67 67 65 64 69 74  st map $taggedit
4ac0: 65 6d 73 20 5b 6d 79 70 72 6f 63 20 55 6e 74 61  ems [myproc Unta
4ad0: 67 31 20 24 63 73 74 79 70 65 5d 5d 0a 20 20 20  g1 $cstype]].   
4ae0: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 55 6e 74   }..    proc Unt
4af0: 61 67 31 20 7b 63 73 74 79 70 65 20 74 68 65 69  ag1 {cstype thei
4b00: 74 65 6d 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a  tem} {..struct::
4b10: 6c 69 73 74 20 61 73 73 69 67 6e 20 24 74 68 65  list assign $the
4b20: 69 74 65 6d 20 74 20 69 0a 09 69 6e 74 65 67 72  item t i..integr
4b30: 69 74 79 20 61 73 73 65 72 74 20 7b 24 63 73 74  ity assert {$cst
4b40: 79 70 65 20 65 71 20 24 74 7d 20 7b 49 74 65 6d  ype eq $t} {Item
4b50: 20 24 69 27 73 20 74 79 70 65 20 69 73 20 27 24   $i's type is '$
4b60: 74 27 2c 20 65 78 70 65 63 74 65 64 20 27 24 63  t', expected '$c
4b70: 73 74 79 70 65 27 7d 0a 09 72 65 74 75 72 6e 20  stype'}..return 
4b80: 24 69 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  $i.    }..    pr
4b90: 6f 63 20 54 61 67 49 74 65 6d 44 69 63 74 20 7b  oc TagItemDict {
4ba0: 69 74 65 6d 64 69 63 74 20 63 73 74 79 70 65 7d  itemdict cstype}
4bb0: 20 7b 0a 09 73 65 74 20 72 65 73 20 7b 7d 0a 09   {..set res {}..
4bc0: 66 6f 72 65 61 63 68 20 7b 69 20 76 7d 20 24 69  foreach {i v} $i
4bd0: 74 65 6d 64 69 63 74 20 7b 20 6c 61 70 70 65 6e  temdict { lappen
4be0: 64 20 72 65 73 20 5b 6c 69 73 74 20 24 63 73 74  d res [list $cst
4bf0: 79 70 65 20 24 69 5d 20 24 76 20 7d 0a 09 72 65  ype $i] $v }..re
4c00: 74 75 72 6e 20 24 72 65 73 0a 20 20 20 20 7d 0a  turn $res.    }.
4c10: 0a 20 20 20 20 70 72 6f 63 20 56 61 6c 69 64 61  .    proc Valida
4c20: 74 65 46 72 61 67 6d 65 6e 74 73 20 7b 63 73 65  teFragments {cse
4c30: 74 20 66 72 61 67 6d 65 6e 74 73 7d 20 7b 0a 09  t fragments} {..
4c40: 23 20 43 68 65 63 6b 20 74 68 65 20 76 61 72 69  # Check the vari
4c50: 6f 75 73 20 69 6e 74 65 67 72 69 74 79 20 63 6f  ous integrity co
4c60: 6e 73 74 72 61 69 6e 74 73 20 66 6f 72 20 74 68  nstraints for th
4c70: 65 20 66 72 61 67 6d 65 6e 74 73 0a 09 23 20 73  e fragments..# s
4c80: 70 65 63 69 66 79 69 6e 67 20 68 6f 77 20 74 6f  pecifying how to
4c90: 20 73 70 6c 69 74 20 74 68 65 20 63 68 61 6e 67   split the chang
4ca0: 65 73 65 74 3a 0a 09 23 0a 09 23 20 2a 20 57 65  eset:..#..# * We
4cb0: 20 6d 75 73 74 20 68 61 76 65 20 74 77 6f 20 6f   must have two o
4cc0: 72 20 6d 6f 72 65 20 66 72 61 67 6d 65 6e 74 73  r more fragments
4cd0: 2c 20 61 73 20 73 70 6c 69 74 74 69 6e 67 20 61  , as splitting a
4ce0: 0a 09 23 20 20 20 63 68 61 6e 67 65 73 65 74 20  ..#   changeset 
4cf0: 69 6e 74 6f 20 6f 6e 65 20 6d 61 6b 65 73 20 6e  into one makes n
4d00: 6f 20 73 65 6e 73 65 2e 0a 09 23 20 2a 20 4e 6f  o sense...# * No
4d10: 20 66 72 61 67 6d 65 6e 74 20 6d 61 79 20 62 65   fragment may be
4d20: 20 65 6d 70 74 79 2e 0a 09 23 20 2a 20 41 6c 6c   empty...# * All
4d30: 20 66 72 61 67 6d 65 6e 74 73 20 68 61 76 65 20   fragments have 
4d40: 74 6f 20 62 65 20 74 72 75 65 20 73 75 62 73 65  to be true subse
4d50: 74 73 20 6f 66 20 74 68 65 20 69 74 65 6d 73 20  ts of the items 
4d60: 69 6e 20 74 68 65 0a 09 23 20 20 20 63 68 61 6e  in the..#   chan
4d70: 67 65 73 65 74 20 74 6f 20 73 70 6c 69 74 2e 20  geset to split. 
4d80: 54 68 65 20 27 74 72 75 65 27 20 69 73 20 69 6d  The 'true' is im
4d90: 70 6c 69 65 64 20 62 65 63 61 75 73 65 20 6e 6f  plied because no
4da0: 6e 65 20 61 72 65 0a 09 23 20 20 20 61 6c 6c 6f  ne are..#   allo
4db0: 77 65 64 20 74 6f 20 62 65 20 65 6d 70 74 79 2c  wed to be empty,
4dc0: 20 73 6f 20 65 61 63 68 20 68 61 73 20 74 6f 20   so each has to 
4dd0: 62 65 20 73 6d 61 6c 6c 65 72 20 74 68 61 6e 20  be smaller than 
4de0: 74 68 65 0a 09 23 20 20 20 74 6f 74 61 6c 2e 0a  the..#   total..
4df0: 09 23 20 2a 20 54 68 65 20 75 6e 69 6f 6e 20 6f  .# * The union o
4e00: 66 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73 20  f the fragments 
4e10: 68 61 73 20 74 6f 20 62 65 20 74 68 65 20 69 74  has to be the it
4e20: 65 6d 20 73 65 74 20 6f 66 20 74 68 65 0a 09 23  em set of the..#
4e30: 20 20 20 63 68 61 6e 67 65 73 65 74 2e 0a 09 23     changeset...#
4e40: 20 2a 20 54 68 65 20 66 72 61 67 6d 65 6e 74 20   * The fragment 
4e50: 6d 75 73 74 20 6e 6f 74 20 6f 76 65 72 6c 61 70  must not overlap
4e60: 2c 20 69 2e 65 2e 20 74 68 65 69 72 20 70 61 69  , i.e. their pai
4e70: 72 77 69 73 65 0a 09 23 20 20 20 69 6e 74 65 72  rwise..#   inter
4e80: 73 65 63 74 69 6f 6e 73 20 68 61 76 65 20 74 6f  sections have to
4e90: 20 62 65 20 65 6d 70 74 79 2e 0a 0a 09 73 65 74   be empty....set
4ea0: 20 63 6f 76 65 72 20 7b 7d 0a 09 66 6f 72 65 61   cover {}..forea
4eb0: 63 68 20 66 72 61 67 6d 65 6e 74 69 74 65 6d 73  ch fragmentitems
4ec0: 20 24 66 72 61 67 6d 65 6e 74 73 20 7b 0a 09 20   $fragments {.. 
4ed0: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63     log write 8 c
4ee0: 73 65 74 73 20 7b 4e 45 57 3a 20 5b 6c 73 6f 72  sets {NEW: [lsor
4ef0: 74 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d 73  t $fragmentitems
4f00: 5d 7d 0a 0a 09 20 20 20 20 69 6e 74 65 67 72 69  ]}...    integri
4f10: 74 79 20 61 73 73 65 72 74 20 7b 0a 09 09 21 5b  ty assert {...![
4f20: 73 74 72 75 63 74 3a 3a 73 65 74 20 65 6d 70 74  struct::set empt
4f30: 79 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d 73  y $fragmentitems
4f40: 5d 0a 09 20 20 20 20 7d 20 7b 63 68 61 6e 67 65  ]..    } {change
4f50: 73 65 74 20 66 72 61 67 6d 65 6e 74 20 69 73 20  set fragment is 
4f60: 65 6d 70 74 79 7d 0a 0a 09 20 20 20 20 69 6e 74  empty}...    int
4f70: 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 0a  egrity assert {.
4f80: 09 09 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 73  ..[struct::set s
4f90: 75 62 73 65 74 6f 66 20 24 66 72 61 67 6d 65 6e  ubsetof $fragmen
4fa0: 74 69 74 65 6d 73 20 5b 24 63 73 65 74 20 69 74  titems [$cset it
4fb0: 65 6d 73 5d 5d 0a 09 20 20 20 20 7d 20 7b 63 68  ems]]..    } {ch
4fc0: 61 6e 67 65 73 65 74 20 66 72 61 67 6d 65 6e 74  angeset fragment
4fd0: 20 69 73 20 6e 6f 74 20 61 20 73 75 62 73 65 74   is not a subset
4fe0: 7d 0a 09 20 20 20 20 73 74 72 75 63 74 3a 3a 73  }..    struct::s
4ff0: 65 74 20 61 64 64 20 63 6f 76 65 72 20 24 66 72  et add cover $fr
5000: 61 67 6d 65 6e 74 69 74 65 6d 73 0a 09 7d 0a 0a  agmentitems..}..
5010: 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72  .integrity asser
5020: 74 20 7b 0a 09 20 20 20 20 5b 73 74 72 75 63 74  t {..    [struct
5030: 3a 3a 73 65 74 20 65 71 75 61 6c 20 24 63 6f 76  ::set equal $cov
5040: 65 72 20 5b 24 63 73 65 74 20 69 74 65 6d 73 5d  er [$cset items]
5050: 5d 0a 09 20 7d 20 7b 54 68 65 20 66 72 61 67 6d  ].. } {The fragm
5060: 65 6e 74 73 20 64 6f 20 6e 6f 74 20 63 6f 76 65  ents do not cove
5070: 72 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 20 63  r the original c
5080: 68 61 6e 67 65 73 65 74 7d 0a 0a 09 73 65 74 20  hangeset}...set 
5090: 69 20 31 0a 09 66 6f 72 65 61 63 68 20 66 69 61  i 1..foreach fia
50a0: 20 24 66 72 61 67 6d 65 6e 74 73 20 7b 0a 09 20   $fragments {.. 
50b0: 20 20 20 66 6f 72 65 61 63 68 20 66 69 62 20 5b     foreach fib [
50c0: 6c 72 61 6e 67 65 20 24 66 72 61 67 6d 65 6e 74  lrange $fragment
50d0: 73 20 24 69 20 65 6e 64 5d 20 7b 0a 09 09 69 6e  s $i end] {...in
50e0: 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b  tegrity assert {
50f0: 0a 09 09 20 20 20 20 5b 73 74 72 75 63 74 3a 3a  ...    [struct::
5100: 73 65 74 20 65 6d 70 74 79 20 5b 73 74 72 75 63  set empty [struc
5110: 74 3a 3a 73 65 74 20 69 6e 74 65 72 73 65 63 74  t::set intersect
5120: 20 24 66 69 61 20 24 66 69 62 5d 5d 0a 09 09 7d   $fia $fib]]...}
5130: 20 7b 54 68 65 20 66 72 61 67 6d 65 6e 74 73 20   {The fragments 
5140: 3c 24 66 69 61 3e 20 61 6e 64 20 3c 24 66 69 62  <$fia> and <$fib
5150: 3e 20 6f 76 65 72 6c 61 70 7d 0a 09 20 20 20 20  > overlap}..    
5160: 7d 0a 09 20 20 20 20 69 6e 63 72 20 69 0a 09 7d  }..    incr i..}
5170: 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  ...return.    }.
5180: 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20  .    # # ## ### 
5190: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
51a0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20  ############.   
51b0: 20 23 23 20 53 74 61 74 65 0a 0a 20 20 20 20 76   ## State..    v
51c0: 61 72 69 61 62 6c 65 20 6d 79 69 64 20 20 20 20  ariable myid    
51d0: 20 20 20 20 7b 7d 20 3b 20 23 20 49 64 20 6f 66      {} ; # Id of
51e0: 20 74 68 65 20 63 73 65 74 20 66 6f 72 20 74 68   the cset for th
51f0: 65 20 70 65 72 73 69 73 74 65 6e 74 0a 09 09 09  e persistent....
5200: 20 20 20 20 20 20 23 20 73 74 61 74 65 2e 0a 20        # state.. 
5210: 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 70 72     variable mypr
5220: 6f 6a 65 63 74 20 20 20 7b 7d 20 3b 20 23 20 52  oject   {} ; # R
5230: 65 66 65 72 65 6e 63 65 20 6f 66 20 74 68 65 20  eference of the 
5240: 70 72 6f 6a 65 63 74 20 6f 62 6a 65 63 74 20 74  project object t
5250: 68 65 0a 09 09 09 20 20 20 20 20 20 23 20 63 68  he....      # ch
5260: 61 6e 67 65 73 65 74 20 62 65 6c 6f 6e 67 73 20  angeset belongs 
5270: 74 6f 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65  to..    variable
5280: 20 6d 79 74 79 70 65 20 20 20 20 20 20 7b 7d 20   mytype      {} 
5290: 3b 20 23 20 57 68 61 74 20 74 68 65 20 63 68 61  ; # What the cha
52a0: 6e 67 65 73 65 74 20 69 73 20 62 61 73 65 64 20  ngeset is based 
52b0: 6f 6e 0a 09 09 09 20 20 20 20 20 20 23 20 28 72  on....      # (r
52c0: 65 76 69 73 69 6f 6e 73 2c 20 74 61 67 73 2c 20  evisions, tags, 
52d0: 6f 72 20 62 72 61 6e 63 68 65 73 29 2e 0a 09 09  or branches)....
52e0: 09 20 20 20 20 20 20 23 20 56 61 6c 75 65 73 3a  .      # Values:
52f0: 20 53 65 65 20 6d 79 63 73 74 79 70 65 2e 20 4e   See mycstype. N
5300: 6f 74 65 20 74 68 61 74 20 77 65 0a 09 09 09 20  ote that we.... 
5310: 20 20 20 20 20 23 20 68 61 76 65 20 74 6f 20 6b       # have to k
5320: 65 65 70 20 74 68 65 20 6e 61 6d 65 73 20 6f 66  eep the names of
5330: 20 74 68 65 20 68 65 6c 70 65 72 0a 09 09 09 20   the helper.... 
5340: 20 20 20 20 20 23 20 73 69 6e 67 6c 65 74 6f 6e       # singleton
5350: 73 20 69 6e 20 73 79 6e 63 20 77 69 74 68 20 74  s in sync with t
5360: 68 65 20 63 6f 6e 74 65 6e 74 73 0a 09 09 09 20  he contents.... 
5370: 20 20 20 20 20 23 20 6f 66 20 73 74 61 74 65 20       # of state 
5380: 74 61 62 6c 65 20 27 63 73 74 79 70 65 27 2c 20  table 'cstype', 
5390: 61 6e 64 20 76 61 72 69 6f 75 73 0a 09 09 09 20  and various.... 
53a0: 20 20 20 20 20 23 20 6f 74 68 65 72 20 70 6c 61       # other pla
53b0: 63 65 73 20 75 73 69 6e 67 20 74 68 65 6d 20 68  ces using them h
53c0: 61 72 64 77 69 72 65 64 2e 0a 20 20 20 20 76 61  ardwired..    va
53d0: 72 69 61 62 6c 65 20 6d 79 74 79 70 65 6f 62 6a  riable mytypeobj
53e0: 20 20 20 7b 7d 20 3b 20 23 20 52 65 66 65 72 65     {} ; # Refere
53f0: 6e 63 65 20 74 6f 20 74 68 65 20 63 6f 6e 74 61  nce to the conta
5400: 69 6e 65 72 20 66 6f 72 20 74 68 65 0a 09 09 09  iner for the....
5410: 20 20 20 20 20 20 23 20 74 79 70 65 20 64 65 70        # type dep
5420: 65 6e 64 65 6e 74 20 63 6f 64 65 2e 20 44 65 72  endent code. Der
5430: 69 76 65 64 20 66 72 6f 6d 0a 09 09 09 20 20 20  ived from....   
5440: 20 20 20 23 20 6d 79 74 79 70 65 2e 0a 20 20 20     # mytype..   
5450: 20 76 61 72 69 61 62 6c 65 20 6d 79 73 72 63 69   variable mysrci
5460: 64 20 20 20 20 20 7b 7d 20 3b 20 23 20 49 64 20  d     {} ; # Id 
5470: 6f 66 20 74 68 65 20 6d 65 74 61 64 61 74 61 20  of the metadata 
5480: 6f 72 20 73 79 6d 62 6f 6c 20 74 68 65 20 63 73  or symbol the cs
5490: 65 74 0a 09 09 09 20 20 20 20 20 20 23 20 69 73  et....      # is
54a0: 20 62 61 73 65 64 20 6f 6e 2e 0a 20 20 20 20 76   based on..    v
54b0: 61 72 69 61 62 6c 65 20 6d 79 69 74 65 6d 73 20  ariable myitems 
54c0: 20 20 20 20 7b 7d 20 3b 20 23 20 4c 69 73 74 20      {} ; # List 
54d0: 6f 66 20 74 68 65 20 66 69 6c 65 20 6c 65 76 65  of the file leve
54e0: 6c 20 72 65 76 69 73 69 6f 6e 73 2c 0a 09 09 09  l revisions,....
54f0: 20 20 20 20 20 20 23 20 74 61 67 73 2c 20 6f 72        # tags, or
5500: 20 62 72 61 6e 63 68 65 73 20 69 6e 20 74 68 65   branches in the
5510: 20 63 73 65 74 2c 20 61 73 0a 09 09 09 20 20 20   cset, as....   
5520: 20 20 20 23 20 69 64 73 2e 20 4e 6f 74 20 74 61     # ids. Not ta
5530: 67 67 65 64 2e 0a 20 20 20 20 76 61 72 69 61 62  gged..    variab
5540: 6c 65 20 6d 79 74 69 74 65 6d 73 20 20 20 20 7b  le mytitems    {
5550: 7d 20 3b 20 23 20 41 73 20 6d 79 69 74 65 6d 73  } ; # As myitems
5560: 2c 20 74 68 65 20 74 61 67 67 65 64 20 66 6f 72  , the tagged for
5570: 6d 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20  m..    variable 
5580: 6d 79 70 6f 73 20 20 20 20 20 20 20 7b 7d 20 3b  mypos       {} ;
5590: 20 23 20 43 6f 6d 6d 69 74 20 70 6f 73 69 74 69   # Commit positi
55a0: 6f 6e 20 6f 66 20 74 68 65 20 63 68 61 6e 67 65  on of the change
55b0: 73 65 74 2c 20 69 66 0a 09 09 09 20 20 20 20 20  set, if....     
55c0: 20 23 20 6b 6e 6f 77 6e 2e 0a 0a 20 20 20 20 23   # known...    #
55d0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
55e0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
55f0: 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 49 6e  ######.    ## In
5600: 74 65 72 6e 61 6c 20 6d 65 74 68 6f 64 73 0a 0a  ternal methods..
5610: 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65      typevariable
5620: 20 6d 79 63 6f 75 6e 74 65 72 20 20 20 20 20 20   mycounter      
5630: 20 20 30 20 3b 20 23 20 49 64 20 63 6f 75 6e 74    0 ; # Id count
5640: 65 72 20 66 6f 72 20 63 73 65 74 73 2e 20 4c 61  er for csets. La
5650: 73 74 20 69 64 0a 09 09 09 09 20 20 20 20 20 20  st id.....      
5660: 23 20 75 73 65 64 2e 0a 20 20 20 20 74 79 70 65  # used..    type
5670: 76 61 72 69 61 62 6c 65 20 6d 79 63 73 74 79 70  variable mycstyp
5680: 65 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23 20  e -array {} ; # 
5690: 4d 61 70 20 63 73 74 79 70 65 73 20 28 6e 61 6d  Map cstypes (nam
56a0: 65 73 29 20 74 6f 20 70 65 72 73 69 73 74 65 6e  es) to persisten
56b0: 74 0a 09 09 09 09 20 20 20 20 20 20 23 20 69 64  t.....      # id
56c0: 73 2e 20 4e 6f 74 65 20 74 68 61 74 20 77 65 20  s. Note that we 
56d0: 68 61 76 65 20 74 6f 20 6b 65 65 70 0a 09 09 09  have to keep....
56e0: 09 20 20 20 20 20 20 23 20 74 68 65 20 6e 61 6d  .      # the nam
56f0: 65 73 20 69 6e 20 74 68 65 20 74 61 62 6c 65 20  es in the table 
5700: 27 63 73 74 79 70 65 27 0a 09 09 09 09 20 20 20  'cstype'.....   
5710: 20 20 20 23 20 69 6e 20 73 79 6e 63 20 77 69 74     # in sync wit
5720: 68 20 74 68 65 20 6e 61 6d 65 73 20 6f 66 20 74  h the names of t
5730: 68 65 0a 09 09 09 09 20 20 20 20 20 20 23 20 68  he.....      # h
5740: 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 73  elper singletons
5750: 2e 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  ...    typemetho
5760: 64 20 69 6e 6f 72 64 65 72 20 7b 70 72 6f 6a 65  d inorder {proje
5770: 63 74 69 64 7d 20 7b 0a 09 23 20 52 65 74 75 72  ctid} {..# Retur
5780: 6e 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 20 63  n all revision c
5790: 68 61 6e 67 65 73 65 74 73 20 66 6f 72 20 74 68  hangesets for th
57a0: 65 20 73 70 65 63 69 66 69 65 64 20 70 72 6f 6a  e specified proj
57b0: 65 63 74 2c 20 69 6e 0a 09 23 20 74 68 65 20 6f  ect, in..# the o
57c0: 72 64 65 72 20 67 69 76 65 6e 20 74 6f 20 74 68  rder given to th
57d0: 65 6d 20 62 79 20 74 68 65 20 73 6f 72 74 20 70  em by the sort p
57e0: 61 73 73 65 73 2e 20 42 6f 74 68 20 74 68 65 0a  asses. Both the.
57f0: 09 23 20 66 69 6c 74 65 72 69 6e 67 20 62 79 20  .# filtering by 
5800: 70 72 6f 6a 65 63 74 20 61 6e 64 20 73 6f 72 74  project and sort
5810: 69 6e 67 20 6d 61 6b 65 20 75 73 65 20 6f 66 20  ing make use of 
5820: 27 70 72 6f 6a 65 63 74 3a 3a 72 65 76 0a 09 23  'project::rev..#
5830: 20 72 65 76 27 20 69 6d 70 6f 73 73 69 62 6c 65   rev' impossible
5840: 2e 0a 0a 09 73 65 74 20 72 65 73 20 7b 7d 0a 09  ....set res {}..
5850: 66 6f 72 65 61 63 68 20 7b 63 69 64 20 63 64 61  foreach {cid cda
5860: 74 65 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b  te} [state run {
5870: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63  ..    SELECT C.c
5880: 69 64 2c 20 54 2e 64 61 74 65 0a 09 20 20 20 20  id, T.date..    
5890: 46 52 4f 4d 20 20 20 63 68 61 6e 67 65 73 65 74  FROM   changeset
58a0: 20 43 2c 20 63 73 74 69 6d 65 73 74 61 6d 70 20   C, cstimestamp 
58b0: 54 0a 09 20 20 20 20 57 48 45 52 45 20 20 43 2e  T..    WHERE  C.
58c0: 74 79 70 65 20 3d 20 30 20 20 20 20 20 20 20 20  type = 0        
58d0: 20 20 2d 2d 20 6c 69 6d 69 74 20 74 6f 20 72 65    -- limit to re
58e0: 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74  vision changeset
58f0: 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 2e  s..    AND    C.
5900: 70 69 64 20 20 3d 20 24 70 72 6f 6a 65 63 74 69  pid  = $projecti
5910: 64 20 2d 2d 20 6c 69 6d 69 74 20 74 6f 20 63 68  d -- limit to ch
5920: 61 6e 67 65 73 65 74 73 20 69 6e 20 70 72 6f 6a  angesets in proj
5930: 65 63 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ect..    AND    
5940: 54 2e 63 69 64 20 20 3d 20 43 2e 63 69 64 20 20  T.cid  = C.cid  
5950: 20 20 20 20 2d 2d 20 67 65 74 20 6f 72 64 65 72      -- get order
5960: 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 0a  ing information.
5970: 09 20 20 20 20 4f 52 44 45 52 20 42 59 20 54 2e  .    ORDER BY T.
5980: 64 61 74 65 20 20 20 20 20 20 20 20 20 20 20 20  date            
5990: 2d 2d 20 73 6f 72 74 20 69 6e 74 6f 20 63 6f 6d  -- sort into com
59a0: 6d 69 74 20 6f 72 64 65 72 0a 09 7d 5d 20 7b 0a  mit order..}] {.
59b0: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 72 65 73  .    lappend res
59c0: 20 24 6d 79 69 64 6d 61 70 28 24 63 69 64 29 20   $myidmap($cid) 
59d0: 24 63 64 61 74 65 0a 09 7d 0a 09 72 65 74 75 72  $cdate..}..retur
59e0: 6e 20 24 72 65 73 0a 20 20 20 20 7d 0a 0a 20 20  n $res.    }..  
59f0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 67 65 74    typemethod get
5a00: 63 73 74 79 70 65 73 20 7b 7d 20 7b 0a 09 66 6f  cstypes {} {..fo
5a10: 72 65 61 63 68 20 7b 74 69 64 20 6e 61 6d 65 7d  reach {tid name}
5a20: 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20   [state run {.. 
5a30: 20 20 20 53 45 4c 45 43 54 20 74 69 64 2c 20 6e     SELECT tid, n
5a40: 61 6d 65 20 46 52 4f 4d 20 63 73 74 79 70 65 3b  ame FROM cstype;
5a50: 0a 09 7d 5d 20 7b 20 73 65 74 20 6d 79 63 73 74  ..}] { set mycst
5a60: 79 70 65 28 24 6e 61 6d 65 29 20 24 74 69 64 20  ype($name) $tid 
5a70: 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  }..return.    }.
5a80: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
5a90: 6c 6f 61 64 20 7b 72 65 70 6f 73 69 74 6f 72 79  load {repository
5aa0: 7d 20 7b 0a 09 73 65 74 20 6e 20 30 0a 09 6c 6f  } {..set n 0..lo
5ab0: 67 20 77 72 69 74 65 20 32 20 63 73 65 74 73 20  g write 2 csets 
5ac0: 7b 4c 6f 61 64 69 6e 67 20 74 68 65 20 63 68 61  {Loading the cha
5ad0: 6e 67 65 73 65 74 73 7d 0a 09 66 6f 72 65 61 63  ngesets}..foreac
5ae0: 68 20 7b 69 64 20 70 69 64 20 63 73 74 79 70 65  h {id pid cstype
5af0: 20 73 72 63 69 64 7d 20 5b 73 74 61 74 65 20 72   srcid} [state r
5b00: 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54  un {..    SELECT
5b10: 20 43 2e 63 69 64 2c 20 43 2e 70 69 64 2c 20 43   C.cid, C.pid, C
5b20: 53 2e 6e 61 6d 65 2c 20 43 2e 73 72 63 0a 09 20  S.name, C.src.. 
5b30: 20 20 20 46 52 4f 4d 20 20 20 63 68 61 6e 67 65     FROM   change
5b40: 73 65 74 20 43 2c 20 63 73 74 79 70 65 20 43 53  set C, cstype CS
5b50: 0a 09 20 20 20 20 57 48 45 52 45 20 20 43 2e 74  ..    WHERE  C.t
5b60: 79 70 65 20 3d 20 43 53 2e 74 69 64 0a 09 20 20  ype = CS.tid..  
5b70: 20 20 4f 52 44 45 52 20 42 59 20 43 2e 63 69 64    ORDER BY C.cid
5b80: 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 6c 6f 67 20  ..}] {..    log 
5b90: 70 72 6f 67 72 65 73 73 20 32 20 63 73 65 74 73  progress 2 csets
5ba0: 20 24 6e 20 7b 7d 0a 09 20 20 20 20 73 65 74 20   $n {}..    set 
5bb0: 72 20 5b 24 74 79 70 65 20 25 41 55 54 4f 25 20  r [$type %AUTO% 
5bc0: 5b 24 72 65 70 6f 73 69 74 6f 72 79 20 70 72 6f  [$repository pro
5bd0: 6a 65 63 74 6f 66 20 24 70 69 64 5d 20 24 63 73  jectof $pid] $cs
5be0: 74 79 70 65 20 24 73 72 63 69 64 20 5b 73 74 61  type $srcid [sta
5bf0: 74 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c 45 43  te run {...SELEC
5c00: 54 20 43 2e 69 69 64 0a 09 09 46 52 4f 4d 20 20  T C.iid...FROM  
5c10: 20 63 73 69 74 65 6d 20 43 0a 09 09 57 48 45 52   csitem C...WHER
5c20: 45 20 20 43 2e 63 69 64 20 3d 20 24 69 64 0a 09  E  C.cid = $id..
5c30: 09 4f 52 44 45 52 20 42 59 20 43 2e 70 6f 73 0a  .ORDER BY C.pos.
5c40: 09 20 20 20 20 7d 5d 20 24 69 64 5d 0a 09 20 20  .    }] $id]..  
5c50: 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 09 72 65 74    incr n..}..ret
5c60: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74  urn.    }..    t
5c70: 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61 64 63 6f  ypemethod loadco
5c80: 75 6e 74 65 72 20 7b 7d 20 7b 0a 09 23 20 49 6e  unter {} {..# In
5c90: 69 74 69 61 6c 69 7a 65 20 74 68 65 20 63 6f 75  itialize the cou
5ca0: 6e 74 65 72 20 66 72 6f 6d 20 74 68 65 20 73 74  nter from the st
5cb0: 61 74 65 0a 09 6c 6f 67 20 77 72 69 74 65 20 32  ate..log write 2
5cc0: 20 63 73 65 74 73 20 7b 4c 6f 61 64 69 6e 67 20   csets {Loading 
5cd0: 63 68 61 6e 67 65 73 65 74 20 63 6f 75 6e 74 65  changeset counte
5ce0: 72 7d 0a 09 73 65 74 20 6d 79 63 6f 75 6e 74 65  r}..set mycounte
5cf0: 72 20 5b 73 74 61 74 65 20 6f 6e 65 20 7b 20 53  r [state one { S
5d00: 45 4c 45 43 54 20 4d 41 58 28 63 69 64 29 20 46  ELECT MAX(cid) F
5d10: 52 4f 4d 20 63 68 61 6e 67 65 73 65 74 20 7d 5d  ROM changeset }]
5d20: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
5d30: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6e      typemethod n
5d40: 75 6d 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 24  um {} { return $
5d50: 6d 79 63 6f 75 6e 74 65 72 20 7d 0a 0a 20 20 20  mycounter }..   
5d60: 20 70 72 6f 63 20 49 6e 69 74 69 61 6c 69 7a 65   proc Initialize
5d70: 42 72 65 61 6b 53 74 61 74 65 20 7b 72 65 76 69  BreakState {revi
5d80: 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20  sions} {..upvar 
5d90: 31 20 70 6f 73 20 70 6f 73 20 63 72 6f 73 73 20  1 pos pos cross 
5da0: 63 72 6f 73 73 20 72 61 6e 67 65 20 72 61 6e 67  cross range rang
5db0: 65 20 64 65 70 63 20 64 65 70 63 20 64 65 6c 74  e depc depc delt
5dc0: 61 20 64 65 6c 74 61 20 5c 0a 09 20 20 20 20 64  a delta \..    d
5dd0: 65 70 65 6e 64 65 6e 63 69 65 73 20 64 65 70 65  ependencies depe
5de0: 6e 64 65 6e 63 69 65 73 0a 0a 09 23 20 46 69 72  ndencies...# Fir
5df0: 73 74 20 77 65 20 63 72 65 61 74 65 20 61 20 6d  st we create a m
5e00: 61 70 20 6f 66 20 70 6f 73 69 74 69 6f 6e 73 20  ap of positions 
5e10: 74 6f 20 6d 61 6b 65 20 69 74 20 65 61 73 69 65  to make it easie
5e20: 72 20 74 6f 0a 09 23 20 64 65 74 65 72 6d 69 6e  r to..# determin
5e30: 65 20 77 68 65 74 68 65 72 20 61 20 64 65 70 65  e whether a depe
5e40: 6e 64 65 6e 63 79 20 63 72 6f 73 73 65 73 20 61  ndency crosses a
5e50: 20 70 61 72 74 69 63 75 6c 61 72 20 69 6e 64 65   particular inde
5e60: 78 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20 70  x....array set p
5e70: 6f 73 20 20 20 7b 7d 0a 09 61 72 72 61 79 20 73  os   {}..array s
5e80: 65 74 20 63 72 6f 73 73 20 7b 7d 0a 09 61 72 72  et cross {}..arr
5e90: 61 79 20 73 65 74 20 64 65 70 63 20 20 7b 7d 0a  ay set depc  {}.
5ea0: 09 73 65 74 20 72 61 6e 67 65 20 20 20 20 20 20  .set range      
5eb0: 20 7b 7d 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f   {}..set n 0..fo
5ec0: 72 65 61 63 68 20 72 65 76 20 24 72 65 76 69 73  reach rev $revis
5ed0: 69 6f 6e 73 20 7b 0a 09 20 20 20 20 6c 61 70 70  ions {..    lapp
5ee0: 65 6e 64 20 72 61 6e 67 65 20 24 6e 0a 09 20 20  end range $n..  
5ef0: 20 20 73 65 74 20 70 6f 73 28 24 72 65 76 29 20    set pos($rev) 
5f00: 24 6e 0a 09 20 20 20 20 73 65 74 20 63 72 6f 73  $n..    set cros
5f10: 73 28 24 6e 29 20 30 0a 09 20 20 20 20 69 6e 63  s($n) 0..    inc
5f20: 72 20 6e 0a 09 7d 0a 0a 09 23 20 53 65 63 6f 6e  r n..}...# Secon
5f30: 64 6c 79 20 77 65 20 63 6f 75 6e 74 20 74 68 65  dly we count the
5f40: 20 63 72 6f 73 73 69 6e 67 73 20 70 65 72 20 70   crossings per p
5f50: 6f 73 69 74 69 6f 6e 2c 20 62 79 20 69 74 65 72  osition, by iter
5f60: 61 74 69 6e 67 0a 09 23 20 6f 76 65 72 20 74 68  ating..# over th
5f70: 65 20 72 65 63 6f 72 64 65 64 20 69 6e 74 65 72  e recorded inter
5f80: 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73  nal dependencies
5f90: 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 49 66 20 74  ....# Note: If t
5fa0: 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20 61 72  he timestamps ar
5fb0: 65 20 62 61 64 6c 79 20 6f 75 74 20 6f 66 20 6f  e badly out of o
5fc0: 72 64 65 72 20 69 74 20 69 73 0a 09 23 20 20 20  rder it is..#   
5fd0: 20 20 20 20 70 6f 73 73 69 62 6c 65 20 74 6f 20      possible to 
5fe0: 68 61 76 65 20 61 20 62 61 63 6b 77 61 72 64 20  have a backward 
5ff0: 73 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e 64  successor depend
6000: 65 6e 63 79 2c 0a 09 23 20 20 20 20 20 20 20 69  ency,..#       i
6010: 2e 65 2e 20 77 69 74 68 20 73 74 61 72 74 20 3e  .e. with start >
6020: 20 65 6e 64 2e 20 57 65 20 6d 61 79 20 68 61 76   end. We may hav
6030: 65 20 74 6f 20 73 77 61 70 20 74 68 65 20 69 6e  e to swap the in
6040: 64 69 63 65 73 0a 09 23 20 20 20 20 20 20 20 74  dices..#       t
6050: 6f 20 65 6e 73 75 72 65 20 74 68 61 74 20 74 68  o ensure that th
6060: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 6c 6f 6f 70  e following loop
6070: 20 72 75 6e 73 20 63 6f 72 72 65 63 74 6c 79 2e   runs correctly.
6080: 0a 09 23 0a 09 23 20 4e 6f 74 65 20 32 3a 20 73  ..#..# Note 2: s
6090: 74 61 72 74 20 3d 3d 20 65 6e 64 20 69 73 20 6e  tart == end is n
60a0: 6f 74 20 70 6f 73 73 69 62 6c 65 2e 20 49 74 20  ot possible. It 
60b0: 69 6e 64 69 63 61 74 65 73 20 61 0a 09 23 20 20  indicates a..#  
60c0: 20 20 20 20 20 20 20 73 65 6c 66 2d 64 65 70 65         self-depe
60d0: 6e 64 65 6e 63 79 20 64 75 65 20 74 6f 20 74 68  ndency due to th
60e0: 65 20 75 6e 69 71 75 65 6e 65 73 73 20 6f 66 20  e uniqueness of 
60f0: 70 6f 73 69 74 69 6f 6e 73 2c 0a 09 23 20 20 20  positions,..#   
6100: 20 20 20 20 20 20 61 6e 64 20 74 68 61 74 20 69        and that i
6110: 73 20 73 6f 6d 65 74 68 69 6e 67 20 77 65 20 68  s something we h
6120: 61 76 65 20 72 75 6c 65 64 20 6f 75 74 20 61 6c  ave ruled out al
6130: 72 65 61 64 79 2c 20 73 65 65 0a 09 23 20 20 20  ready, see..#   
6140: 20 20 20 20 20 20 27 72 65 76 20 69 6e 74 65 72        'rev inter
6150: 6e 61 6c 73 75 63 63 65 73 73 6f 72 73 27 2e 0a  nalsuccessors'..
6160: 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 63  ..foreach {rid c
6170: 68 69 6c 64 72 65 6e 7d 20 5b 61 72 72 61 79 20  hildren} [array 
6180: 67 65 74 20 64 65 70 65 6e 64 65 6e 63 69 65 73  get dependencies
6190: 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68  ] {..    foreach
61a0: 20 63 68 69 6c 64 20 24 63 68 69 6c 64 72 65 6e   child $children
61b0: 20 7b 0a 09 09 73 65 74 20 64 6b 65 79 20 20 20   {...set dkey   
61c0: 20 5b 6c 69 73 74 20 24 72 69 64 20 24 63 68 69   [list $rid $chi
61d0: 6c 64 5d 0a 09 09 73 65 74 20 73 74 61 72 74 20  ld]...set start 
61e0: 20 20 24 70 6f 73 28 24 72 69 64 29 0a 09 09 73    $pos($rid)...s
61f0: 65 74 20 65 6e 64 20 20 20 20 20 24 70 6f 73 28  et end     $pos(
6200: 24 63 68 69 6c 64 29 0a 09 09 73 65 74 20 63 72  $child)...set cr
6210: 6f 73 73 65 73 20 7b 7d 0a 0a 09 09 69 66 20 7b  osses {}....if {
6220: 24 73 74 61 72 74 20 3e 20 24 65 6e 64 7d 20 7b  $start > $end} {
6230: 0a 09 09 20 20 20 20 77 68 69 6c 65 20 7b 24 65  ...    while {$e
6240: 6e 64 20 3c 20 24 73 74 61 72 74 7d 20 7b 0a 09  nd < $start} {..
6250: 09 09 6c 61 70 70 65 6e 64 20 63 72 6f 73 73 65  ..lappend crosse
6260: 73 20 24 65 6e 64 0a 09 09 09 69 6e 63 72 20 63  s $end....incr c
6270: 72 6f 73 73 28 24 65 6e 64 29 0a 09 09 09 69 6e  ross($end)....in
6280: 63 72 20 65 6e 64 0a 09 09 20 20 20 20 7d 0a 09  cr end...    }..
6290: 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20 20 20  .} else {...    
62a0: 77 68 69 6c 65 20 7b 24 73 74 61 72 74 20 3c 20  while {$start < 
62b0: 24 65 6e 64 7d 20 7b 0a 09 09 09 6c 61 70 70 65  $end} {....lappe
62c0: 6e 64 20 63 72 6f 73 73 65 73 20 24 73 74 61 72  nd crosses $star
62d0: 74 0a 09 09 09 69 6e 63 72 20 63 72 6f 73 73 28  t....incr cross(
62e0: 24 73 74 61 72 74 29 0a 09 09 09 69 6e 63 72 20  $start)....incr 
62f0: 73 74 61 72 74 0a 09 09 20 20 20 20 7d 0a 09 09  start...    }...
6300: 7d 0a 09 09 73 65 74 20 64 65 70 63 28 24 64 6b  }...set depc($dk
6310: 65 79 29 20 24 63 72 6f 73 73 65 73 0a 09 20 20  ey) $crosses..  
6320: 20 20 7d 0a 09 7d 0a 0a 09 49 6e 69 74 69 61 6c    }..}...Initial
6330: 69 7a 65 44 65 6c 74 61 73 20 24 72 65 76 69 73  izeDeltas $revis
6340: 69 6f 6e 73 0a 09 72 65 74 75 72 6e 0a 20 20 20  ions..return.   
6350: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 49 6e 69   }..    proc Ini
6360: 74 69 61 6c 69 7a 65 44 65 6c 74 61 73 20 7b 72  tializeDeltas {r
6370: 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76  evisions} {..upv
6380: 61 72 20 31 20 64 65 6c 74 61 20 64 65 6c 74 61  ar 1 delta delta
6390: 0a 0a 09 23 20 50 75 6c 6c 20 74 68 65 20 74 69  ...# Pull the ti
63a0: 6d 65 73 74 61 6d 70 73 20 66 6f 72 20 61 6c 6c  mestamps for all
63b0: 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 74 68   revisions in th
63c0: 65 20 63 68 61 6e 67 65 73 65 74 73 20 61 6e 64  e changesets and
63d0: 0a 09 23 20 63 6f 6d 70 75 74 65 20 74 68 65 69  ..# compute thei
63e0: 72 20 64 65 6c 74 61 73 20 66 6f 72 20 75 73 65  r deltas for use
63f0: 20 62 79 20 74 68 65 20 62 72 65 61 6b 20 66 69   by the break fi
6400: 6e 64 65 72 2e 0a 0a 09 61 72 72 61 79 20 73 65  nder....array se
6410: 74 20 64 65 6c 74 61 20 7b 7d 0a 09 61 72 72 61  t delta {}..arra
6420: 79 20 73 65 74 20 73 74 61 6d 70 20 7b 7d 0a 0a  y set stamp {}..
6430: 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a  .set theset ('[j
6440: 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b  oin $revisions {
6450: 27 2c 27 7d 5d 27 29 0a 09 66 6f 72 65 61 63 68  ','}]')..foreach
6460: 20 7b 72 69 64 20 74 69 6d 65 7d 20 5b 73 74 61   {rid time} [sta
6470: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
6480: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
6490: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
64a0: 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 2e  SELECT R.rid, R.
64b0: 64 61 74 65 0a 09 20 20 20 20 46 52 4f 4d 20 72  date..    FROM r
64c0: 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57  evision R..    W
64d0: 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20 24 74  HERE R.rid IN $t
64e0: 68 65 73 65 74 0a 09 7d 5d 5d 20 7b 0a 09 20 20  heset..}]] {..  
64f0: 20 20 73 65 74 20 73 74 61 6d 70 28 24 72 69 64    set stamp($rid
6500: 29 20 24 74 69 6d 65 0a 09 7d 0a 0a 09 73 65 74  ) $time..}...set
6510: 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 20 72 69   n 0..foreach ri
6520: 64 20 5b 6c 72 61 6e 67 65 20 24 72 65 76 69 73  d [lrange $revis
6530: 69 6f 6e 73 20 30 20 65 6e 64 2d 31 5d 20 72 6e  ions 0 end-1] rn
6540: 65 78 74 20 5b 6c 72 61 6e 67 65 20 24 72 65 76  ext [lrange $rev
6550: 69 73 69 6f 6e 73 20 31 20 65 6e 64 5d 20 7b 0a  isions 1 end] {.
6560: 09 20 20 20 20 73 65 74 20 64 65 6c 74 61 28 24  .    set delta($
6570: 6e 29 20 5b 65 78 70 72 20 7b 24 73 74 61 6d 70  n) [expr {$stamp
6580: 28 24 72 6e 65 78 74 29 20 2d 20 24 73 74 61 6d  ($rnext) - $stam
6590: 70 28 24 72 69 64 29 7d 5d 0a 09 20 20 20 20 69  p($rid)}]..    i
65a0: 6e 63 72 20 6e 0a 09 7d 0a 09 72 65 74 75 72 6e  ncr n..}..return
65b0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63  .    }..    proc
65c0: 20 46 69 6e 64 42 65 73 74 42 72 65 61 6b 20 7b   FindBestBreak {
65d0: 72 61 6e 67 65 7d 20 7b 0a 09 75 70 76 61 72 20  range} {..upvar 
65e0: 31 20 63 72 6f 73 73 20 63 72 6f 73 73 20 64 65  1 cross cross de
65f0: 6c 74 61 20 64 65 6c 74 61 0a 0a 09 23 20 44 65  lta delta...# De
6600: 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65 73 74  termine the best
6610: 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 20   break location 
6620: 69 6e 20 74 68 65 20 67 69 76 65 6e 20 72 61 6e  in the given ran
6630: 67 65 20 6f 66 0a 09 23 20 70 6f 73 69 74 69 6f  ge of..# positio
6640: 6e 73 2e 20 46 69 72 73 74 20 77 65 20 6c 6f 6f  ns. First we loo
6650: 6b 20 66 6f 72 20 74 68 65 20 6c 6f 63 61 74 69  k for the locati
6660: 6f 6e 73 20 77 69 74 68 20 74 68 65 20 6d 61 78  ons with the max
6670: 69 6d 61 6c 0a 09 23 20 6e 75 6d 62 65 72 20 6f  imal..# number o
6680: 66 20 63 72 6f 73 73 69 6e 67 73 2e 20 49 66 20  f crossings. If 
6690: 74 68 65 72 65 20 61 72 65 20 73 65 76 65 72 61  there are severa
66a0: 6c 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20 74 68  l we look for th
66b0: 65 0a 09 23 20 73 68 6f 72 74 65 73 74 20 74 69  e..# shortest ti
66c0: 6d 65 20 69 6e 74 65 72 76 61 6c 20 61 6d 6f 6e  me interval amon
66d0: 67 20 74 68 65 6d 2e 20 49 66 20 77 65 20 73 74  g them. If we st
66e0: 69 6c 6c 20 68 61 76 65 20 6d 75 6c 74 69 70 6c  ill have multipl
66f0: 65 0a 09 23 20 70 6f 73 73 69 62 69 6c 69 74 69  e..# possibiliti
6700: 65 73 20 61 66 74 65 72 20 74 68 61 74 20 77 65  es after that we
6710: 20 73 65 6c 65 63 74 20 74 68 65 20 65 61 72 6c   select the earl
6720: 69 65 73 74 20 6c 6f 63 61 74 69 6f 6e 0a 09 23  iest location..#
6730: 20 61 6d 6f 6e 67 20 74 68 65 73 65 2e 0a 0a 09   among these....
6740: 23 20 4e 6f 74 65 3a 20 49 66 20 74 68 65 20 6d  # Note: If the m
6750: 61 78 69 6d 61 6c 20 6e 75 6d 62 65 72 20 6f 66  aximal number of
6760: 20 63 72 6f 73 73 69 6e 67 73 20 69 73 20 30 20   crossings is 0 
6770: 74 68 65 6e 20 74 68 65 20 72 61 6e 67 65 0a 09  then the range..
6780: 23 20 20 20 20 20 20 20 68 61 73 20 6e 6f 20 69  #       has no i
6790: 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e  nternal dependen
67a0: 63 69 65 73 2c 20 61 6e 64 20 6e 6f 20 62 72 65  cies, and no bre
67b0: 61 6b 20 6c 6f 63 61 74 69 6f 6e 20 61 74 0a 09  ak location at..
67c0: 23 20 20 20 20 20 20 20 61 6c 6c 2e 20 54 68 69  #       all. Thi
67d0: 73 20 70 6f 73 73 69 62 69 6c 69 74 79 20 69 73  s possibility is
67e0: 20 73 69 67 6e 61 6c 65 64 20 76 69 61 20 72 65   signaled via re
67f0: 73 75 6c 74 20 2d 31 2e 0a 0a 09 23 20 4e 6f 74  sult -1....# Not
6800: 65 3a 20 41 20 72 61 6e 67 65 20 6f 66 20 6c 65  e: A range of le
6810: 6e 67 74 68 20 31 20 6f 72 20 6c 65 73 73 20 63  ngth 1 or less c
6820: 61 6e 6e 6f 74 20 68 61 76 65 20 69 6e 74 65 72  annot have inter
6830: 6e 61 6c 0a 09 23 20 20 20 20 20 20 20 64 65 70  nal..#       dep
6840: 65 6e 64 65 6e 63 69 65 73 2c 20 61 73 20 74 68  endencies, as th
6850: 61 74 20 6e 65 65 64 73 20 61 74 20 6c 65 61 73  at needs at leas
6860: 74 20 74 77 6f 20 72 65 76 69 73 69 6f 6e 73 20  t two revisions 
6870: 69 6e 0a 09 23 20 20 20 20 20 20 20 74 68 65 20  in..#       the 
6880: 72 61 6e 67 65 2e 0a 0a 09 69 66 20 7b 5b 6c 6c  range....if {[ll
6890: 65 6e 67 74 68 20 24 72 61 6e 67 65 5d 20 3c 20  ength $range] < 
68a0: 32 7d 20 7b 20 72 65 74 75 72 6e 20 2d 31 20 7d  2} { return -1 }
68b0: 0a 0a 09 73 65 74 20 6d 61 78 20 2d 31 0a 09 73  ...set max -1..s
68c0: 65 74 20 62 65 73 74 20 7b 7d 0a 0a 09 66 6f 72  et best {}...for
68d0: 65 61 63 68 20 6c 6f 63 61 74 69 6f 6e 20 24 72  each location $r
68e0: 61 6e 67 65 20 7b 0a 09 20 20 20 20 73 65 74 20  ange {..    set 
68f0: 63 72 6f 73 73 69 6e 67 73 20 24 63 72 6f 73 73  crossings $cross
6900: 28 24 6c 6f 63 61 74 69 6f 6e 29 0a 09 20 20 20  ($location)..   
6910: 20 69 66 20 7b 24 63 72 6f 73 73 69 6e 67 73 20   if {$crossings 
6920: 3e 20 24 6d 61 78 7d 20 7b 0a 09 09 73 65 74 20  > $max} {...set 
6930: 6d 61 78 20 20 24 63 72 6f 73 73 69 6e 67 73 0a  max  $crossings.
6940: 09 09 73 65 74 20 62 65 73 74 20 5b 6c 69 73 74  ..set best [list
6950: 20 24 6c 6f 63 61 74 69 6f 6e 5d 0a 09 09 63 6f   $location]...co
6960: 6e 74 69 6e 75 65 0a 09 20 20 20 20 7d 20 65 6c  ntinue..    } el
6970: 73 65 69 66 20 7b 24 63 72 6f 73 73 69 6e 67 73  seif {$crossings
6980: 20 3d 3d 20 24 6d 61 78 7d 20 7b 0a 09 09 6c 61   == $max} {...la
6990: 70 70 65 6e 64 20 62 65 73 74 20 24 6c 6f 63 61  ppend best $loca
69a0: 74 69 6f 6e 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  tion..    }..}..
69b0: 09 69 66 20 7b 24 6d 61 78 20 3d 3d 20 30 7d 20  .if {$max == 0} 
69c0: 20 20 20 20 20 20 20 20 20 20 20 7b 20 72 65 74             { ret
69d0: 75 72 6e 20 2d 31 20 7d 0a 09 69 66 20 7b 5b 6c  urn -1 }..if {[l
69e0: 6c 65 6e 67 74 68 20 24 62 65 73 74 5d 20 3d 3d  length $best] ==
69f0: 20 31 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69   1} { return [li
6a00: 6e 64 65 78 20 24 62 65 73 74 20 30 5d 20 7d 0a  ndex $best 0] }.
6a10: 0a 09 73 65 74 20 6c 6f 63 61 74 69 6f 6e 73 20  ..set locations 
6a20: 24 62 65 73 74 0a 09 73 65 74 20 62 65 73 74 20  $best..set best 
6a30: 7b 7d 0a 09 73 65 74 20 6d 69 6e 20 2d 31 0a 0a  {}..set min -1..
6a40: 09 66 6f 72 65 61 63 68 20 6c 6f 63 61 74 69 6f  .foreach locatio
6a50: 6e 20 24 6c 6f 63 61 74 69 6f 6e 73 20 7b 0a 09  n $locations {..
6a60: 20 20 20 20 73 65 74 20 69 6e 74 65 72 76 61 6c      set interval
6a70: 20 24 64 65 6c 74 61 28 24 6c 6f 63 61 74 69 6f   $delta($locatio
6a80: 6e 29 0a 09 20 20 20 20 69 66 20 7b 28 24 6d 69  n)..    if {($mi
6a90: 6e 20 3c 20 30 29 20 7c 7c 20 28 24 69 6e 74 65  n < 0) || ($inte
6aa0: 72 76 61 6c 20 3c 20 24 6d 69 6e 29 7d 20 7b 0a  rval < $min)} {.
6ab0: 09 09 73 65 74 20 6d 69 6e 20 20 24 69 6e 74 65  ..set min  $inte
6ac0: 72 76 61 6c 0a 09 09 73 65 74 20 62 65 73 74 20  rval...set best 
6ad0: 5b 6c 69 73 74 20 24 6c 6f 63 61 74 69 6f 6e 5d  [list $location]
6ae0: 0a 09 20 20 20 20 7d 20 65 6c 73 65 69 66 20 7b  ..    } elseif {
6af0: 24 69 6e 74 65 72 76 61 6c 20 3d 3d 20 24 6d 69  $interval == $mi
6b00: 6e 7d 20 7b 0a 09 09 6c 61 70 70 65 6e 64 20 62  n} {...lappend b
6b10: 65 73 74 20 24 6c 6f 63 61 74 69 6f 6e 0a 09 20  est $location.. 
6b20: 20 20 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b 5b 6c     }..}...if {[l
6b30: 6c 65 6e 67 74 68 20 24 62 65 73 74 5d 20 3d 3d  length $best] ==
6b40: 20 31 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69   1} { return [li
6b50: 6e 64 65 78 20 24 62 65 73 74 20 30 5d 20 7d 0a  ndex $best 0] }.
6b60: 0a 09 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78  ..return [lindex
6b70: 20 5b 6c 73 6f 72 74 20 2d 69 6e 74 65 67 65 72   [lsort -integer
6b80: 20 2d 69 6e 63 72 65 61 73 69 6e 67 20 24 62 65   -increasing $be
6b90: 73 74 5d 20 30 5d 0a 20 20 20 20 7d 0a 0a 20 20  st] 0].    }..  
6ba0: 20 20 70 72 6f 63 20 43 75 74 41 74 20 7b 6c 6f    proc CutAt {lo
6bb0: 63 61 74 69 6f 6e 7d 20 7b 0a 09 75 70 76 61 72  cation} {..upvar
6bc0: 20 31 20 63 72 6f 73 73 20 63 72 6f 73 73 20 64   1 cross cross d
6bd0: 65 70 63 20 64 65 70 63 0a 0a 09 23 20 49 74 20  epc depc...# It 
6be0: 77 61 73 20 64 65 63 69 64 65 64 20 74 6f 20 73  was decided to s
6bf0: 70 6c 69 74 20 74 68 65 20 63 68 61 6e 67 65 73  plit the changes
6c00: 65 74 20 61 74 20 74 68 65 20 67 69 76 65 6e 0a  et at the given.
6c10: 09 23 20 6c 6f 63 61 74 69 6f 6e 2e 20 54 68 69  .# location. Thi
6c20: 73 20 63 75 74 73 20 61 20 6e 75 6d 62 65 72 20  s cuts a number 
6c30: 6f 66 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e  of dependencies.
6c40: 20 48 65 72 65 20 77 65 20 75 70 64 61 74 65 0a   Here we update.
6c50: 09 23 20 74 68 65 20 63 72 6f 73 73 20 69 6e 66  .# the cross inf
6c60: 6f 72 6d 61 74 69 6f 6e 20 73 6f 20 74 68 61 74  ormation so that
6c70: 20 74 68 65 20 62 72 65 61 6b 20 66 69 6e 64 65   the break finde
6c80: 72 20 68 61 73 20 61 63 63 75 72 61 74 65 0a 09  r has accurate..
6c90: 23 20 64 61 74 61 20 77 68 65 6e 20 77 65 20 6c  # data when we l
6ca0: 6f 6f 6b 20 61 74 20 74 68 65 20 67 65 6e 65 72  ook at the gener
6cb0: 61 74 65 64 20 66 72 61 67 6d 65 6e 74 73 2e 0a  ated fragments..
6cc0: 0a 09 73 65 74 20 73 69 78 20 5b 6c 6f 67 20 76  ..set six [log v
6cd0: 69 73 69 62 6c 65 3f 20 36 5d 0a 0a 09 66 6f 72  isible? 6]...for
6ce0: 65 61 63 68 20 7b 64 65 70 20 72 61 6e 67 65 7d  each {dep range}
6cf0: 20 5b 61 72 72 61 79 20 67 65 74 20 64 65 70 63   [array get depc
6d00: 5d 20 7b 0a 09 20 20 20 20 23 20 43 68 65 63 6b  ] {..    # Check
6d10: 20 61 6c 6c 20 64 65 70 65 6e 64 65 6e 63 69 65   all dependencie
6d20: 73 20 73 74 69 6c 6c 20 6b 6e 6f 77 6e 2c 20 74  s still known, t
6d30: 61 6b 65 20 74 68 65 69 72 20 72 61 6e 67 65 20  ake their range 
6d40: 61 6e 64 0a 09 20 20 20 20 23 20 73 65 65 20 69  and..    # see i
6d50: 66 20 74 68 65 20 62 72 65 61 6b 20 6c 6f 63 61  f the break loca
6d60: 74 69 6f 6e 20 66 61 6c 6c 73 20 77 69 74 68 69  tion falls withi
6d70: 6e 2e 0a 0a 09 20 20 20 20 42 6f 72 64 65 72 20  n....    Border 
6d80: 24 72 61 6e 67 65 20 73 20 65 0a 09 20 20 20 20  $range s e..    
6d90: 69 66 20 7b 24 6c 6f 63 61 74 69 6f 6e 20 3c 20  if {$location < 
6da0: 24 73 7d 20 63 6f 6e 74 69 6e 75 65 20 3b 20 23  $s} continue ; #
6db0: 20 62 72 65 61 6b 20 62 65 66 6f 72 65 20 72 61   break before ra
6dc0: 6e 67 65 2c 20 69 67 6e 6f 72 65 0a 09 20 20 20  nge, ignore..   
6dd0: 20 69 66 20 7b 24 6c 6f 63 61 74 69 6f 6e 20 3e   if {$location >
6de0: 20 24 65 7d 20 63 6f 6e 74 69 6e 75 65 20 3b 20   $e} continue ; 
6df0: 23 20 62 72 65 61 6b 20 61 66 74 65 72 20 72 61  # break after ra
6e00: 6e 67 65 2c 20 69 67 6e 6f 72 65 2e 0a 0a 09 20  nge, ignore.... 
6e10: 20 20 20 23 20 54 68 69 73 20 64 65 70 65 6e 64     # This depend
6e20: 65 6e 63 79 20 63 72 6f 73 73 65 73 20 74 68 65  ency crosses the
6e30: 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 2e   break location.
6e40: 20 57 65 20 72 65 6d 6f 76 65 20 69 74 0a 09 20   We remove it.. 
6e50: 20 20 20 23 20 66 72 6f 6d 20 74 68 65 20 63 72     # from the cr
6e60: 6f 73 73 69 6e 67 73 20 63 6f 75 6e 74 65 72 73  ossings counters
6e70: 2c 20 61 6e 64 20 74 68 65 6e 20 61 6c 73 6f 20  , and then also 
6e80: 66 72 6f 6d 20 74 68 65 20 73 65 74 0a 09 20 20  from the set..  
6e90: 20 20 23 20 6f 66 20 6b 6e 6f 77 6e 20 64 65 70    # of known dep
6ea0: 65 6e 64 65 6e 63 69 65 73 2c 20 61 73 20 77 65  endencies, as we
6eb0: 20 61 72 65 20 64 6f 6e 65 20 77 69 74 68 20 69   are done with i
6ec0: 74 2e 0a 0a 09 20 20 20 20 66 6f 72 65 61 63 68  t....    foreach
6ed0: 20 6c 6f 63 20 24 64 65 70 63 28 24 64 65 70 29   loc $depc($dep)
6ee0: 20 7b 20 69 6e 63 72 20 63 72 6f 73 73 28 24 6c   { incr cross($l
6ef0: 6f 63 29 20 2d 31 20 7d 0a 09 20 20 20 20 75 6e  oc) -1 }..    un
6f00: 73 65 74 20 64 65 70 63 28 24 64 65 70 29 0a 0a  set depc($dep)..
6f10: 09 20 20 20 20 69 66 20 7b 21 24 73 69 78 7d 20  .    if {!$six} 
6f20: 63 6f 6e 74 69 6e 75 65 0a 0a 09 20 20 20 20 73  continue...    s
6f30: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69  truct::list assi
6f40: 67 6e 20 24 64 65 70 20 70 61 72 65 6e 74 20 63  gn $dep parent c
6f50: 68 69 6c 64 0a 09 20 20 20 20 6c 6f 67 20 77 72  hild..    log wr
6f60: 69 74 65 20 35 20 63 73 65 74 73 20 22 42 72 6f  ite 5 csets "Bro
6f70: 6b 65 20 64 65 70 65 6e 64 65 6e 63 79 20 5b 50  ke dependency [P
6f80: 44 20 24 70 61 72 65 6e 74 5d 20 2d 2d 3e 20 5b  D $parent] --> [
6f90: 50 44 20 24 63 68 69 6c 64 5d 22 0a 09 7d 0a 0a  PD $child]"..}..
6fa0: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
6fb0: 20 20 20 23 20 50 72 69 6e 74 20 69 64 65 6e 74     # Print ident
6fc0: 69 66 79 69 6e 67 20 64 61 74 61 20 66 6f 72 20  ifying data for 
6fd0: 61 20 72 65 76 69 73 69 6f 6e 20 28 70 72 6f 6a  a revision (proj
6fe0: 65 63 74 2c 20 66 69 6c 65 2c 20 64 6f 74 74 65  ect, file, dotte
6ff0: 64 20 72 65 76 0a 20 20 20 20 23 20 6e 75 6d 62  d rev.    # numb
7000: 65 72 29 2c 20 66 6f 72 20 68 69 67 68 20 76 65  er), for high ve
7010: 72 62 6f 73 69 74 79 20 6c 6f 67 20 6f 75 74 70  rbosity log outp
7020: 75 74 2e 0a 20 20 20 20 23 20 54 4f 44 4f 3a 20  ut..    # TODO: 
7030: 52 65 70 6c 61 63 65 20 77 69 74 68 20 63 61 6c  Replace with cal
7040: 6c 20 74 6f 20 69 74 65 6d 73 74 72 20 28 6c 69  l to itemstr (li
7050: 73 74 20 72 65 76 20 24 69 64 29 0a 0a 20 20 20  st rev $id)..   
7060: 20 70 72 6f 63 20 50 44 20 7b 69 64 7d 20 7b 0a   proc PD {id} {.
7070: 09 66 6f 72 65 61 63 68 20 7b 70 20 66 20 72 7d  .foreach {p f r}
7080: 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09   [state run {...
7090: 53 45 4c 45 43 54 20 50 2e 6e 61 6d 65 20 2c 20  SELECT P.name , 
70a0: 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09  F.name, R.rev...
70b0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
70c0: 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74   file F, project
70d0: 20 50 0a 09 09 57 48 45 52 45 20 52 2e 72 69 64   P...WHERE R.rid
70e0: 20 3d 20 24 69 64 20 20 20 20 2d 2d 20 46 69 6e   = $id    -- Fin
70f0: 64 20 73 70 65 63 69 66 69 65 64 20 66 69 6c 65  d specified file
7100: 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20   revision...AND 
7110: 20 20 46 2e 66 69 64 20 3d 20 52 2e 66 69 64 20    F.fid = R.fid 
7120: 20 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20   -- Get file of 
7130: 74 68 65 20 72 65 76 69 73 69 6f 6e 0a 09 09 41  the revision...A
7140: 4e 44 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70  ND   P.pid = F.p
7150: 69 64 20 20 2d 2d 20 47 65 74 20 70 72 6f 6a 65  id  -- Get proje
7160: 63 74 20 6f 66 20 74 68 65 20 66 69 6c 65 2e 0a  ct of the file..
7170: 09 7d 5d 20 62 72 65 61 6b 0a 09 72 65 74 75 72  .}] break..retur
7180: 6e 20 22 27 24 70 20 3a 20 24 66 2f 24 72 27 22  n "'$p : $f/$r'"
7190: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 50 72  .    }..    # Pr
71a0: 69 6e 74 69 6e 67 20 6f 6e 65 20 6f 72 20 6d 6f  inting one or mo
71b0: 72 65 20 72 61 6e 67 65 73 2c 20 66 6f 72 6d 61  re ranges, forma
71c0: 74 74 65 64 2c 20 61 6e 64 20 6f 6e 6c 79 20 74  tted, and only t
71d0: 68 65 69 72 20 62 6f 72 64 65 72 20 74 6f 0a 20  heir border to. 
71e0: 20 20 20 23 20 6b 65 65 70 20 74 68 65 20 73 74     # keep the st
71f0: 72 69 6e 67 73 20 73 68 6f 72 74 2e 0a 0a 20 20  rings short...  
7200: 20 20 70 72 6f 63 20 50 52 73 20 7b 72 61 6e 67    proc PRs {rang
7210: 65 73 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 73  es} {..return [s
7220: 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20  truct::list map 
7230: 24 72 61 6e 67 65 73 20 5b 6d 79 70 72 6f 63 20  $ranges [myproc 
7240: 50 52 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  PR]].    }..    
7250: 70 72 6f 63 20 50 52 20 7b 72 61 6e 67 65 7d 20  proc PR {range} 
7260: 7b 0a 09 42 6f 72 64 65 72 20 24 72 61 6e 67 65  {..Border $range
7270: 20 73 20 65 0a 09 72 65 74 75 72 6e 20 3c 24 7b   s e..return <${
7280: 73 7d 2e 2e 2e 24 7b 65 7d 3e 0a 20 20 20 20 7d  s}...${e}>.    }
7290: 0a 0a 20 20 20 20 70 72 6f 63 20 42 6f 72 64 65  ..    proc Borde
72a0: 72 20 7b 72 61 6e 67 65 20 73 76 20 65 76 7d 20  r {range sv ev} 
72b0: 7b 0a 09 75 70 76 61 72 20 31 20 24 73 76 20 73  {..upvar 1 $sv s
72c0: 20 24 65 76 20 65 0a 09 73 65 74 20 73 20 5b 6c   $ev e..set s [l
72d0: 69 6e 64 65 78 20 24 72 61 6e 67 65 20 30 5d 0a  index $range 0].
72e0: 09 73 65 74 20 65 20 5b 6c 69 6e 64 65 78 20 24  .set e [lindex $
72f0: 72 61 6e 67 65 20 65 6e 64 5d 0a 09 72 65 74 75  range end]..retu
7300: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  rn.    }..    # 
7310: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
7320: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
7330: 23 23 23 23 23 0a 0a 20 20 20 20 74 79 70 65 76  #####..    typev
7340: 61 72 69 61 62 6c 65 20 6d 79 63 68 61 6e 67 65  ariable mychange
7350: 73 65 74 73 20 20 20 20 20 20 20 20 20 7b 7d 20  sets         {} 
7360: 3b 20 23 20 4c 69 73 74 20 6f 66 20 61 6c 6c 20  ; # List of all 
7370: 6b 6e 6f 77 6e 0a 09 09 09 09 09 20 20 20 23 20  known......   # 
7380: 63 68 61 6e 67 65 73 65 74 73 2e 0a 20 20 20 20  changesets..    
7390: 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 74  typevariable myt
73a0: 63 68 61 6e 67 65 73 65 74 73 20 2d 61 72 72 61  changesets -arra
73b0: 79 20 7b 7d 20 3b 20 23 20 4c 69 73 74 20 6f 66  y {} ; # List of
73c0: 20 61 6c 6c 20 6b 6e 6f 77 6e 0a 09 09 09 09 09   all known......
73d0: 20 20 20 23 20 63 68 61 6e 67 65 73 65 74 73 20     # changesets 
73e0: 6f 66 20 61 20 74 79 70 65 2e 0a 20 20 20 20 74  of a type..    t
73f0: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 69 74  ypevariable myit
7400: 65 6d 6d 61 70 20 20 20 20 20 2d 61 72 72 61 79  emmap     -array
7410: 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d   {} ; # Map from
7420: 20 69 74 65 6d 73 20 28 74 61 67 67 65 64 29 0a   items (tagged).
7430: 09 09 09 09 09 20 20 20 23 20 74 6f 20 74 68 65  .....   # to the
7440: 20 6c 69 73 74 20 6f 66 20 63 68 61 6e 67 65 73   list of changes
7450: 65 74 73 0a 09 09 09 09 09 20 20 20 23 20 63 6f  ets......   # co
7460: 6e 74 61 69 6e 69 6e 67 20 69 74 2e 20 45 61 63  ntaining it. Eac
7470: 68 20 69 74 65 6d 0a 09 09 09 09 09 20 20 20 23  h item......   #
7480: 20 63 61 6e 20 62 65 20 75 73 65 64 20 62 79 20   can be used by 
7490: 6f 6e 6c 79 20 6f 6e 65 0a 09 09 09 09 09 20 20  only one......  
74a0: 20 23 20 63 68 61 6e 67 65 73 65 74 2e 0a 20 20   # changeset..  
74b0: 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d    typevariable m
74c0: 79 69 64 6d 61 70 20 20 20 2d 61 72 72 61 79 20  yidmap   -array 
74d0: 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d 20  {} ; # Map from 
74e0: 63 68 61 6e 67 65 73 65 74 20 69 64 20 74 6f 0a  changeset id to.
74f0: 09 09 09 09 20 20 20 20 20 20 20 23 20 63 68 61  ....       # cha
7500: 6e 67 65 73 65 74 2e 0a 0a 20 20 20 20 74 79 70  ngeset...    typ
7510: 65 6d 65 74 68 6f 64 20 61 6c 6c 20 20 20 20 7b  emethod all    {
7520: 7d 20 20 20 20 7b 20 72 65 74 75 72 6e 20 24 6d  }    { return $m
7530: 79 63 68 61 6e 67 65 73 65 74 73 20 7d 0a 20 20  ychangesets }.  
7540: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6f 66 20    typemethod of 
7550: 20 20 20 20 7b 63 69 64 7d 20 7b 20 72 65 74 75      {cid} { retu
7560: 72 6e 20 24 6d 79 69 64 6d 61 70 28 24 63 69 64  rn $myidmap($cid
7570: 29 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68  ) }.    typemeth
7580: 6f 64 20 6f 66 69 74 65 6d 20 7b 69 69 64 7d 20  od ofitem {iid} 
7590: 7b 20 72 65 74 75 72 6e 20 24 6d 79 69 74 65 6d  { return $myitem
75a0: 6d 61 70 28 24 69 69 64 29 20 7d 0a 0a 20 20 20  map($iid) }..   
75b0: 20 74 79 70 65 6d 65 74 68 6f 64 20 72 65 76 20   typemethod rev 
75c0: 20 20 20 7b 7d 20 20 20 20 7b 20 72 65 74 75 72     {}    { retur
75d0: 6e 20 24 6d 79 74 63 68 61 6e 67 65 73 65 74 73  n $mytchangesets
75e0: 28 72 65 76 29 20 7d 0a 20 20 20 20 74 79 70 65  (rev) }.    type
75f0: 6d 65 74 68 6f 64 20 73 79 6d 20 20 20 20 7b 7d  method sym    {}
7600: 20 20 20 20 7b 20 72 65 74 75 72 6e 20 5b 63 6f      { return [co
7610: 6e 63 61 74 20 5c 0a 09 09 09 09 09 20 20 24 7b  ncat \......  ${
7620: 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 73 79  mytchangesets(sy
7630: 6d 3a 3a 62 72 61 6e 63 68 29 7d 20 5c 0a 09 09  m::branch)} \...
7640: 09 09 09 20 20 24 7b 6d 79 74 63 68 61 6e 67 65  ...  ${mytchange
7650: 73 65 74 73 28 73 79 6d 3a 3a 74 61 67 29 7d 5d  sets(sym::tag)}]
7660: 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23   }..    # # ## #
7670: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
7680: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  # #############.
7690: 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61      ## Configura
76a0: 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61  tion..    pragma
76b0: 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20   -hastypeinfo   
76c0: 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 74 79 70 65   no  ; # no type
76d0: 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20   introspection. 
76e0: 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69 6e     pragma -hasin
76f0: 66 6f 20 20 20 20 20 20 20 20 6e 6f 20 20 3b 20  fo        no  ; 
7700: 23 20 6e 6f 20 6f 62 6a 65 63 74 20 69 6e 74 72  # no object intr
7710: 6f 73 70 65 63 74 69 6f 6e 0a 0a 20 20 20 20 23  ospection..    #
7720: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
7730: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
7740: 23 23 23 23 23 23 0a 7d 0a 0a 23 23 0a 23 23 20  ######.}..##.## 
7750: 4e 4f 54 45 3a 20 54 68 65 20 73 75 63 63 65 73  NOTE: The succes
7760: 73 6f 72 20 61 6e 64 20 70 72 65 64 65 63 65 73  sor and predeces
7770: 73 6f 72 20 6d 65 74 68 6f 64 73 20 64 65 66 69  sor methods defi
7780: 6e 65 64 20 62 79 20 74 68 65 20 63 6c 61 73 73  ned by the class
7790: 65 73 0a 23 23 20 20 20 20 20 20 20 62 65 6c 6f  es.##       belo
77a0: 77 20 61 72 65 20 2d 2d 20 62 6f 74 74 6c 65 20  w are -- bottle 
77b0: 6e 65 63 6b 73 20 2d 2d 2e 20 4c 6f 6f 6b 20 66  necks --. Look f
77c0: 6f 72 20 77 61 79 73 20 74 6f 20 6d 61 6b 65 20  or ways to make 
77d0: 74 68 65 20 53 51 4c 0a 23 23 20 20 20 20 20 20  the SQL.##      
77e0: 20 66 61 73 74 65 72 2e 0a 23 23 0a 0a 23 20 23   faster..##..# #
77f0: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
7800: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
7810: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
7820: 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 48 65  ##########.## He
7830: 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20  lper singleton. 
7840: 43 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 72 65 76  Commands for rev
7850: 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73  ision changesets
7860: 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a  ...snit::type ::
7870: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
7880: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74  rt::cvs::project
7890: 3a 3a 72 65 76 3a 3a 72 65 76 20 7b 0a 20 20 20  ::rev::rev {.   
78a0: 20 74 79 70 65 6d 65 74 68 6f 64 20 62 79 72 65   typemethod byre
78b0: 76 69 73 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75  vision {} { retu
78c0: 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 65 6d  rn 1 }.    typem
78d0: 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20  ethod bysymbol  
78e0: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d   {} { return 0 }
78f0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
7900: 69 73 74 61 67 20 20 20 20 20 20 7b 7d 20 7b 20  istag      {} { 
7910: 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74  return 0 }.    t
7920: 79 70 65 6d 65 74 68 6f 64 20 69 73 62 72 61 6e  ypemethod isbran
7930: 63 68 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e  ch   {} { return
7940: 20 30 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65   0 }..    typeme
7950: 74 68 6f 64 20 73 74 72 20 7b 72 65 76 69 73 69  thod str {revisi
7960: 6f 6e 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c  on} {..struct::l
7970: 69 73 74 20 61 73 73 69 67 6e 20 5b 73 74 61 74  ist assign [stat
7980: 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c  e run {..    SEL
7990: 45 43 54 20 52 2e 72 65 76 2c 20 46 2e 6e 61 6d  ECT R.rev, F.nam
79a0: 65 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20 20 46  e, P.name..    F
79b0: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52  ROM   revision R
79c0: 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63  , file F, projec
79d0: 74 20 50 0a 09 20 20 20 20 57 48 45 52 45 20 20  t P..    WHERE  
79e0: 52 2e 72 69 64 20 3d 20 24 72 65 76 69 73 69 6f  R.rid = $revisio
79f0: 6e 20 2d 2d 20 46 69 6e 64 20 73 70 65 63 69 66  n -- Find specif
7a00: 69 65 64 20 66 69 6c 65 20 72 65 76 69 73 69 6f  ied file revisio
7a10: 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46 2e  n..    AND    F.
7a20: 66 69 64 20 3d 20 52 2e 66 69 64 20 20 20 20 20  fid = R.fid     
7a30: 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 74  -- Get file of t
7a40: 68 65 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 20  he revision..   
7a50: 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20 3d 20   AND    P.pid = 
7a60: 46 2e 70 69 64 20 20 20 20 20 2d 2d 20 47 65 74  F.pid     -- Get
7a70: 20 70 72 6f 6a 65 63 74 20 6f 66 20 74 68 65 20   project of the 
7a80: 66 69 6c 65 2e 0a 09 7d 5d 20 72 65 76 6e 72 20  file...}] revnr 
7a90: 66 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65 74  fname pname..ret
7aa0: 75 72 6e 20 22 24 70 6e 61 6d 65 2f 24 7b 72 65  urn "$pname/${re
7ab0: 76 6e 72 7d 3a 3a 24 66 6e 61 6d 65 22 0a 20 20  vnr}::$fname".  
7ac0: 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c    }..    # resul
7ad0: 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d  t = list (mintim
7ae0: 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20 20  e, maxtime).    
7af0: 74 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65 72  typemethod timer
7b00: 61 6e 67 65 20 7b 69 74 65 6d 73 7d 20 7b 0a 09  ange {items} {..
7b10: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f  set theset ('[jo
7b20: 69 6e 20 24 69 74 65 6d 73 20 7b 27 2c 27 7d 5d  in $items {','}]
7b30: 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74  ')..return [stat
7b40: 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f  e run [subst -no
7b50: 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b  commands -noback
7b60: 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53  slashes {..    S
7b70: 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64 61 74 65  ELECT MIN(R.date
7b80: 29 2c 20 4d 41 58 28 52 2e 64 61 74 65 29 0a 09  ), MAX(R.date)..
7b90: 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f      FROM revisio
7ba0: 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 52  n R..    WHERE R
7bb0: 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .rid IN $theset 
7bc0: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72  -- Restrict to r
7bd0: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65  evisions of inte
7be0: 72 65 73 74 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a  rest..}]].    }.
7bf0: 0a 20 20 20 20 23 20 76 61 72 28 64 76 29 20 3d  .    # var(dv) =
7c00: 20 64 69 63 74 20 28 72 65 76 69 73 69 6f 6e 20   dict (revision 
7c10: 2d 3e 20 6c 69 73 74 20 28 72 65 76 69 73 69 6f  -> list (revisio
7c20: 6e 29 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68  n)).    typemeth
7c30: 6f 64 20 69 6e 74 65 72 6e 61 6c 73 75 63 63 65  od internalsucce
7c40: 73 73 6f 72 73 20 7b 64 76 20 72 65 76 69 73 69  ssors {dv revisi
7c50: 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20  ons} {..upvar 1 
7c60: 24 64 76 20 64 65 70 65 6e 64 65 6e 63 69 65 73  $dv dependencies
7c70: 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b  ..set theset ('[
7c80: 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20  join $revisions 
7c90: 7b 27 2c 27 7d 5d 27 29 0a 0a 09 23 20 53 65 65  {','}]')...# See
7ca0: 20 27 73 75 63 63 65 73 73 6f 72 73 27 20 62 65   'successors' be
7cb0: 6c 6f 77 20 66 6f 72 20 74 68 65 20 6d 61 69 6e  low for the main
7cc0: 20 65 78 70 6c 61 6e 61 74 69 6f 6e 20 6f 66 0a   explanation of.
7cd0: 09 23 20 74 68 65 20 76 61 72 69 6f 75 73 20 63  .# the various c
7ce0: 61 73 65 73 2e 20 54 68 69 73 20 70 69 65 63 65  ases. This piece
7cf0: 20 69 73 20 73 70 65 63 69 61 6c 20 69 6e 20 74   is special in t
7d00: 68 61 74 20 69 74 0a 09 23 20 72 65 73 74 72 69  hat it..# restri
7d10: 63 74 73 20 74 68 65 20 73 75 63 63 65 73 73 6f  cts the successo
7d20: 72 73 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20 74  rs we look for t
7d30: 6f 20 74 68 65 20 73 61 6d 65 20 73 65 74 20 6f  o the same set o
7d40: 66 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 20 77  f..# revisions w
7d50: 65 20 73 74 61 72 74 20 66 72 6f 6d 2e 20 53 65  e start from. Se
7d60: 6e 73 69 62 6c 65 20 61 73 20 77 65 20 61 72 65  nsible as we are
7d70: 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72 0a 09 23 20   looking for..# 
7d80: 63 68 61 6e 67 65 73 65 74 20 69 6e 74 65 72 6e  changeset intern
7d90: 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e  al dependencies.
7da0: 0a 0a 09 61 72 72 61 79 20 73 65 74 20 64 65 70  ...array set dep
7db0: 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72   {}...foreach {r
7dc0: 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65  id child} [state
7dd0: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63   run [subst -noc
7de0: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73  ommands -nobacks
7df0: 6c 61 73 68 65 73 20 7b 0a 20 20 20 20 2d 2d 20  lashes {.    -- 
7e00: 28 31 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c  (1) Primary chil
7e10: 64 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e  d..    SELECT R.
7e20: 72 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20  rid, R.child..  
7e30: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f    FROM   revisio
7e40: 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20  n R..    WHERE  
7e50: 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73  R.rid   IN $thes
7e60: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  et     -- Restri
7e70: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
7e80: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
7e90: 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20   AND    R.child 
7ea0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d  IS NOT NULL    -
7eb0: 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68  - Has primary ch
7ec0: 69 6c 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ild..    AND    
7ed0: 52 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73  R.child IN $thes
7ee0: 65 74 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20  et     -- Which 
7ef0: 69 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72  is also of inter
7f00: 65 73 74 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20  est.    UNION.  
7f10: 20 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61    -- (2) Seconda
7f20: 72 79 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c  ry (branch) chil
7f30: 64 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54  dren..    SELECT
7f40: 20 52 2e 72 69 64 2c 20 42 2e 62 72 69 64 0a 09   R.rid, B.brid..
7f50: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
7f60: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 62  ion R, revisionb
7f70: 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20 42 0a  ranchchildren B.
7f80: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
7f90: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20  d   IN $theset  
7fa0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
7fb0: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
7fc0: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
7fd0: 20 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69      R.rid = B.ri
7fe0: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65  d          -- Se
7ff0: 6c 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62  lect subset of b
8000: 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 09  ranch children..
8010: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 62 72 69      AND    B.bri
8020: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20  d IN $theset    
8030: 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c    -- Which is al
8040: 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20  so of interest. 
8050: 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20     UNION.    -- 
8060: 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75  (4) Child of tru
8070: 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f  nk root successo
8080: 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f  r of last NTDB o
8090: 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45  n trunk...    SE
80a0: 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63  LECT R.rid, RA.c
80b0: 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 72  hild..    FROM r
80c0: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73  evision R, revis
80d0: 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 45 52  ion RA..    WHER
80e0: 45 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68  E R.rid   IN $th
80f0: 65 73 65 74 20 20 20 20 20 20 2d 2d 20 52 65 73  eset      -- Res
8100: 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f  trict to revisio
8110: 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  ns of interest..
8120: 20 20 20 20 41 4e 44 20 20 20 52 2e 69 73 64 65      AND   R.isde
8130: 66 61 75 6c 74 20 20 20 20 20 20 20 20 20 20 20  fault           
8140: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
8150: 20 4e 54 44 42 0a 09 20 20 20 20 41 4e 44 20 20   NTDB..    AND  
8160: 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f   R.dbchild IS NO
8170: 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20  T NULL   -- and 
8180: 6c 61 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67  last NTDB belong
8190: 69 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20  ing to trunk..  
81a0: 20 20 41 4e 44 20 20 20 52 41 2e 72 69 64 20 3d    AND   RA.rid =
81b0: 20 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20   R.dbchild      
81c0: 2d 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74  -- Go directly t
81d0: 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20  o trunk root..  
81e0: 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64    AND   RA.child
81f0: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20   IS NOT NULL    
8200: 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63  -- Has primary c
8210: 68 69 6c 64 2e 0a 20 20 20 20 20 20 20 20 20 20  hild..          
8220: 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64    AND   RA.child
8230: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
8240: 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c 73 6f  -- Which is also
8250: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 7d 5d   of interest..}]
8260: 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73 69  ] {..    # Consi
8270: 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69 73 20  der moving this 
8280: 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69 74 79  to the integrity
8290: 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69 6e   module...    in
82a0: 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b  tegrity assert {
82b0: 24 72 69 64 20 21 3d 20 24 63 68 69 6c 64 7d 20  $rid != $child} 
82c0: 7b 52 65 76 69 73 69 6f 6e 20 24 72 69 64 20 64  {Revision $rid d
82d0: 65 70 65 6e 64 73 20 6f 6e 20 69 74 73 65 6c 66  epends on itself
82e0: 2e 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20  .}..    lappend 
82f0: 64 65 70 65 6e 64 65 6e 63 69 65 73 28 24 72 69  dependencies($ri
8300: 64 29 20 24 63 68 69 6c 64 0a 09 20 20 20 20 73  d) $child..    s
8310: 65 74 20 64 65 70 28 24 72 69 64 2c 24 63 68 69  et dep($rid,$chi
8320: 6c 64 29 20 2e 0a 09 7d 0a 0a 09 23 20 54 68 65  ld) ...}...# The
8330: 20 73 71 6c 20 73 74 61 74 65 6d 65 6e 74 73 20   sql statements 
8340: 61 62 6f 76 65 20 6c 6f 6f 6b 73 20 6f 6e 6c 79  above looks only
8350: 20 66 6f 72 20 64 69 72 65 63 74 20 64 65 70 65   for direct depe
8360: 6e 64 65 6e 63 69 65 73 0a 09 23 20 62 65 74 77  ndencies..# betw
8370: 65 65 6e 20 72 65 76 69 73 69 6f 6e 20 69 6e 20  een revision in 
8380: 74 68 65 20 63 68 61 6e 67 65 73 65 74 2e 20 48  the changeset. H
8390: 6f 77 65 76 65 72 20 64 75 65 20 74 6f 20 74 68  owever due to th
83a0: 65 0a 09 23 20 76 61 67 61 72 69 65 73 20 6f 66  e..# vagaries of
83b0: 20 6d 65 74 61 20 64 61 74 61 20 69 74 20 69 73   meta data it is
83c0: 20 70 6f 73 73 69 62 6c 65 20 66 6f 72 20 74 77   possible for tw
83d0: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 0a 09  o revisions of..
83e0: 23 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 20  # the same file 
83f0: 74 6f 20 65 6e 64 20 75 70 20 69 6e 20 74 68 65  to end up in the
8400: 20 73 61 6d 65 20 63 68 61 6e 67 65 73 65 74 2c   same changeset,
8410: 20 77 69 74 68 6f 75 74 20 61 0a 09 23 20 64 69   without a..# di
8420: 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63 79 20  rect dependency 
8430: 62 65 74 77 65 65 6e 20 74 68 65 6d 2e 20 48 6f  between them. Ho
8440: 77 65 76 65 72 20 77 65 20 6b 6e 6f 77 20 74 68  wever we know th
8450: 61 74 20 74 68 65 72 65 0a 09 23 20 68 61 73 20  at there..# has 
8460: 74 6f 20 62 65 20 61 20 61 6e 20 69 6e 64 69 72  to be a an indir
8470: 65 63 74 20 64 65 70 65 6e 64 65 6e 63 79 2c 20  ect dependency, 
8480: 62 65 20 69 74 20 74 68 72 6f 75 67 68 20 70 72  be it through pr
8490: 69 6d 61 72 79 0a 09 23 20 63 68 69 6c 64 72 65  imary..# childre
84a0: 6e 2c 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72  n, branch childr
84b0: 65 6e 2c 20 6f 72 20 61 20 63 6f 6d 62 69 6e 61  en, or a combina
84c0: 74 69 6f 6e 20 74 68 65 72 65 6f 66 2e 0a 0a 09  tion thereof....
84d0: 23 20 57 65 20 6e 6f 77 20 66 69 6c 6c 20 69 6e  # We now fill in
84e0: 20 74 68 65 73 65 20 70 73 65 75 64 6f 2d 64 65   these pseudo-de
84f0: 70 65 6e 64 65 6e 63 69 65 73 2c 20 69 66 20 6e  pendencies, if n
8500: 6f 20 73 75 63 68 0a 09 23 20 64 65 70 65 6e 64  o such..# depend
8510: 65 6e 63 79 20 65 78 69 73 74 73 20 61 6c 72 65  ency exists alre
8520: 61 64 79 2e 20 54 68 65 20 64 69 72 65 63 74 69  ady. The directi
8530: 6f 6e 20 6f 66 20 74 68 65 20 64 65 70 65 6e 64  on of the depend
8540: 65 6e 63 79 0a 09 23 20 69 73 20 61 63 74 75 61  ency..# is actua
8550: 6c 6c 79 20 69 72 72 65 6c 65 76 61 6e 74 20 66  lly irrelevant f
8560: 6f 72 20 74 68 69 73 2e 0a 0a 09 23 20 4e 4f 54  or this....# NOT
8570: 45 3a 20 54 68 69 73 20 69 73 20 64 69 66 66 65  E: This is diffe
8580: 72 65 6e 74 20 66 72 6f 6d 20 63 76 73 32 73 76  rent from cvs2sv
8590: 6e 2e 20 4f 75 72 20 73 70 69 72 69 74 75 61 6c  n. Our spiritual
85a0: 20 61 6e 63 65 73 74 6f 72 0a 09 23 20 64 6f 65   ancestor..# doe
85b0: 73 20 6e 6f 74 20 75 73 65 20 73 75 63 68 20 70  s not use such p
85c0: 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 6e 63 69  seudo-dependenci
85d0: 65 73 2c 20 68 6f 77 65 76 65 72 20 69 74 20 75  es, however it u
85e0: 73 65 73 20 61 0a 09 23 20 43 4f 4d 4d 49 54 5f  ses a..# COMMIT_
85f0: 54 48 52 45 53 48 4f 4c 44 2c 20 61 20 74 69 6d  THRESHOLD, a tim
8600: 65 20 69 6e 74 65 72 76 61 6c 20 63 6f 6d 6d 69  e interval commi
8610: 74 73 20 73 68 6f 75 6c 64 20 66 61 6c 6c 2e 20  ts should fall. 
8620: 54 68 69 73 0a 09 23 20 77 69 6c 6c 20 67 72 65  This..# will gre
8630: 61 74 6c 79 20 72 65 64 75 63 65 73 20 74 68 65  atly reduces the
8640: 20 72 69 73 6b 20 6f 66 20 67 65 74 74 69 6e 67   risk of getting
8650: 20 66 61 72 20 73 65 70 61 72 61 74 65 64 0a 09   far separated..
8660: 23 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 74  # revisions of t
8670: 68 65 20 73 61 6d 65 20 66 69 6c 65 20 69 6e 74  he same file int
8680: 6f 20 6f 6e 65 20 63 68 61 6e 67 65 73 65 74 2e  o one changeset.
8690: 0a 0a 09 23 20 57 65 20 61 6c 6c 6f 77 20 72 65  ...# We allow re
86a0: 76 69 73 69 6f 6e 73 20 74 6f 20 62 65 20 66 61  visions to be fa
86b0: 72 20 61 70 61 72 74 20 69 6e 20 74 69 6d 65 20  r apart in time 
86c0: 69 6e 20 74 68 65 20 73 61 6d 65 0a 09 23 20 63  in the same..# c
86d0: 68 61 6e 67 65 73 65 74 2c 20 62 75 74 20 69 6e  hangeset, but in
86e0: 20 74 75 72 6e 20 6e 65 65 64 20 74 68 65 20 70   turn need the p
86f0: 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 6e 63 69  seudo-dependenci
8700: 65 73 20 74 6f 0a 09 23 20 68 61 6e 64 6c 65 20  es to..# handle 
8710: 74 68 69 73 2e 0a 0a 09 61 72 72 61 79 20 73 65  this....array se
8720: 74 20 66 69 64 73 20 7b 7d 0a 09 66 6f 72 65 61  t fids {}..forea
8730: 63 68 20 7b 72 69 64 20 66 69 64 7d 20 5b 73 74  ch {rid fid} [st
8740: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
8750: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
8760: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
8770: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52   SELECT R.rid, R
8780: 2e 66 69 64 0a 20 20 20 20 20 20 20 20 20 20 20  .fid.           
8790: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
87a0: 20 52 0a 20 20 20 20 20 20 20 20 20 20 20 20 57   R.            W
87b0: 48 45 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24  HERE  R.rid IN $
87c0: 74 68 65 73 65 74 0a 09 7d 5d 5d 20 7b 20 6c 61  theset..}]] { la
87d0: 70 70 65 6e 64 20 66 69 64 73 28 24 66 69 64 29  ppend fids($fid)
87e0: 20 24 72 69 64 20 7d 0a 0a 09 66 6f 72 65 61 63   $rid }...foreac
87f0: 68 20 7b 66 69 64 20 72 69 64 73 7d 20 5b 61 72  h {fid rids} [ar
8800: 72 61 79 20 67 65 74 20 66 69 64 73 5d 20 7b 0a  ray get fids] {.
8810: 09 20 20 20 20 69 66 20 7b 5b 6c 6c 65 6e 67 74  .    if {[llengt
8820: 68 20 24 72 69 64 73 5d 20 3c 20 32 7d 20 63 6f  h $rids] < 2} co
8830: 6e 74 69 6e 75 65 0a 09 20 20 20 20 66 6f 72 65  ntinue..    fore
8840: 61 63 68 20 61 20 24 72 69 64 73 20 7b 0a 09 09  ach a $rids {...
8850: 66 6f 72 65 61 63 68 20 62 20 24 72 69 64 73 20  foreach b $rids 
8860: 7b 0a 09 09 20 20 20 20 69 66 20 7b 24 61 20 3d  {...    if {$a =
8870: 3d 20 24 62 7d 20 63 6f 6e 74 69 6e 75 65 0a 09  = $b} continue..
8880: 09 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65  .    if {[info e
8890: 78 69 73 74 73 20 64 65 70 28 24 61 2c 24 62 29  xists dep($a,$b)
88a0: 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20  ]} continue...  
88b0: 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73    if {[info exis
88c0: 74 73 20 64 65 70 28 24 62 2c 24 61 29 5d 7d 20  ts dep($b,$a)]} 
88d0: 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20 20 6c  continue...    l
88e0: 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63  append dependenc
88f0: 69 65 73 28 24 61 29 20 24 62 0a 09 09 20 20 20  ies($a) $b...   
8900: 20 73 65 74 20 64 65 70 28 24 61 2c 24 62 29 20   set dep($a,$b) 
8910: 2e 0a 09 09 20 20 20 20 73 65 74 20 64 65 70 28  ....    set dep(
8920: 24 62 2c 24 61 29 20 2e 0a 09 09 7d 0a 09 20 20  $b,$a) ....}..  
8930: 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20    }..}..return. 
8940: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75     }..    # resu
8950: 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28 69 74 65  lt = 4-list (ite
8960: 6d 74 79 70 65 20 69 74 65 6d 69 64 20 6e 65 78  mtype itemid nex
8970: 74 69 74 65 6d 74 79 70 65 20 6e 65 78 74 69 74  titemtype nextit
8980: 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 20 74 79  emid ...).    ty
8990: 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 73 20 7b  pemethod loops {
89a0: 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 23 20  revisions} {..# 
89b0: 4e 6f 74 65 3a 20 54 61 67 73 20 61 6e 64 20 62  Note: Tags and b
89c0: 72 61 6e 63 68 65 73 20 63 61 6e 6e 6f 74 20 63  ranches cannot c
89d0: 61 75 73 65 20 74 68 65 20 6c 6f 6f 70 2e 20 54  ause the loop. T
89e0: 68 65 69 72 20 69 64 27 73 2c 0a 09 23 20 62 65  heir id's,..# be
89f0: 69 6e 67 20 6f 66 20 61 20 66 75 6e 64 61 6d 65  ing of a fundame
8a00: 6e 74 61 6c 6c 79 20 64 69 66 66 65 72 65 6e 74  ntally different
8a10: 20 74 79 70 65 20 74 68 61 6e 20 74 68 65 20 72   type than the r
8a20: 65 76 69 73 69 6f 6e 73 0a 09 23 20 63 6f 6d 69  evisions..# comi
8a30: 6e 67 20 69 6e 20 63 61 6e 6e 6f 74 20 62 65 20  ng in cannot be 
8a40: 69 6e 20 74 68 65 20 73 65 74 2e 0a 0a 09 73 65  in the set....se
8a50: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
8a60: 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27   $revisions {','
8a70: 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74  }]')..return [st
8a80: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
8a90: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
8aa0: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
8ab0: 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 72 79 20   -- (1) Primary 
8ac0: 63 68 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 43  child..    SELEC
8ad0: 54 20 52 2e 72 69 64 2c 20 52 2e 63 68 69 6c 64  T R.rid, R.child
8ae0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76  ..    FROM   rev
8af0: 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45  ision R..    WHE
8b00: 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24  RE  R.rid   IN $
8b10: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65  theset     -- Re
8b20: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
8b30: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  ons of interest.
8b40: 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68  .    AND    R.ch
8b50: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ild IS NOT NULL 
8b60: 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72     -- Has primar
8b70: 79 20 63 68 69 6c 64 0a 09 20 20 20 20 41 4e 44  y child..    AND
8b80: 20 20 20 20 52 2e 63 68 69 6c 64 20 49 4e 20 24      R.child IN $
8b90: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c 6f  theset     -- Lo
8ba0: 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 20  op..    --..    
8bb0: 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20 28 32  UNION..    -- (2
8bc0: 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72 61  ) Secondary (bra
8bd0: 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 20  nch) children.. 
8be0: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
8bf0: 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46 52 4f   B.brid..    FRO
8c00: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
8c10: 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68  revisionbranchch
8c20: 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 57 48  ildren B..    WH
8c30: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20  ERE  R.rid   IN 
8c40: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52  $theset     -- R
8c50: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
8c60: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
8c70: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72  ..    AND    R.r
8c80: 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20 20  id = B.rid      
8c90: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73 75      -- Select su
8ca0: 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20 63  bset of branch c
8cb0: 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 41 4e 44  hildren..    AND
8cc0: 20 20 20 20 42 2e 72 69 64 20 20 20 49 4e 20 24      B.rid   IN $
8cd0: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c 6f  theset     -- Lo
8ce0: 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 20  op..    --..    
8cf0: 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20 28 34  UNION..    -- (4
8d00: 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b  ) Child of trunk
8d10: 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 20   root successor 
8d20: 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20  of last NTDB on 
8d30: 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45  trunk...    SELE
8d40: 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63 68 69  CT R.rid, RA.chi
8d50: 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72  ld..    FROM   r
8d60: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73  evision R, revis
8d70: 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 45 52  ion RA..    WHER
8d80: 45 20 20 52 2e 72 69 64 20 20 20 20 49 4e 20 24  E  R.rid    IN $
8d90: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65  theset     -- Re
8da0: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
8db0: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  ons of interest.
8dc0: 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 69 73  .    AND    R.is
8dd0: 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20 20  default         
8de0: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
8df0: 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e 44  to NTDB..    AND
8e00: 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53      R.dbchild IS
8e10: 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 61   NOT NULL   -- a
8e20: 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65 6c  nd last NTDB bel
8e30: 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b 0a  onging to trunk.
8e40: 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e 72  .    AND    RA.r
8e50: 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 20  id = R.dbchild  
8e60: 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 74      -- Go direct
8e70: 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f 74  ly to trunk root
8e80: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e  ..    AND    RA.
8e90: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
8ea0: 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d  L    -- Has prim
8eb0: 61 72 79 20 63 68 69 6c 64 2e 0a 09 20 20 20 20  ary child...    
8ec0: 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c 64 20  AND    RA.child 
8ed0: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
8ee0: 2d 20 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20 20 20  - Loop..}]].    
8ef0: 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 29  }..    # var(dv)
8f00: 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d 3e   = dict (item ->
8f10: 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20 69   list (item)), i
8f20: 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79 70  tem  = list (typ
8f30: 65 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65  e id).    typeme
8f40: 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73 20  thod successors 
8f50: 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 7d 20 7b  {dv revisions} {
8f60: 0a 09 75 70 76 61 72 20 31 20 24 64 76 20 64 65  ..upvar 1 $dv de
8f70: 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 65 74 20  pendencies..set 
8f80: 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24  theset ('[join $
8f90: 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d  revisions {','}]
8fa0: 27 29 0a 0a 09 23 20 54 68 65 20 66 6f 6c 6c 6f  ')...# The follo
8fb0: 77 69 6e 67 20 63 61 73 65 73 20 73 70 65 63 69  wing cases speci
8fc0: 66 79 20 77 68 65 6e 20 61 20 72 65 76 69 73 69  fy when a revisi
8fd0: 6f 6e 20 53 20 69 73 20 61 20 73 75 63 63 65 73  on S is a succes
8fe0: 73 6f 72 0a 09 23 20 6f 66 20 61 20 72 65 76 69  sor..# of a revi
8ff0: 73 69 6f 6e 20 52 2e 20 45 61 63 68 20 6f 66 20  sion R. Each of 
9000: 74 68 65 20 63 61 73 65 73 20 74 72 61 6e 73 6c  the cases transl
9010: 61 74 65 73 20 69 6e 74 6f 20 6f 6e 65 20 6f 66  ates into one of
9020: 0a 09 23 20 74 68 65 20 62 72 61 6e 63 68 65 73  ..# the branches
9030: 20 6f 66 20 74 68 65 20 53 51 4c 20 55 4e 49 4f   of the SQL UNIO
9040: 4e 20 63 6f 6d 69 6e 67 20 62 65 6c 6f 77 2e 0a  N coming below..
9050: 09 23 0a 09 23 20 28 31 29 20 53 20 63 61 6e 20  .#..# (1) S can 
9060: 62 65 20 61 20 70 72 69 6d 61 72 79 20 63 68 69  be a primary chi
9070: 6c 64 20 6f 66 20 52 2c 20 69 2e 65 2e 20 69 6e  ld of R, i.e. in
9080: 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 2e 20 52   the same LOD. R
9090: 0a 09 23 20 20 20 20 20 72 65 66 65 72 65 6e 63  ..#     referenc
90a0: 65 73 20 53 20 64 69 72 65 63 74 6c 79 2e 20 52  es S directly. R
90b0: 2e 63 68 69 6c 64 20 3d 20 53 28 2e 72 69 64 29  .child = S(.rid)
90c0: 2c 20 69 66 20 69 74 20 65 78 69 73 74 73 2e 0a  , if it exists..
90d0: 09 23 0a 09 23 20 28 32 29 20 53 20 63 61 6e 20  .#..# (2) S can 
90e0: 62 65 20 61 20 73 65 63 6f 6e 64 61 72 79 2c 20  be a secondary, 
90f0: 69 2e 65 2e 20 62 72 61 6e 63 68 2c 20 63 68 69  i.e. branch, chi
9100: 6c 64 20 6f 66 20 52 2e 20 48 65 72 65 20 74 68  ld of R. Here th
9110: 65 0a 09 23 20 20 20 20 20 6c 69 6e 6b 20 69 73  e..#     link is
9120: 20 6d 61 64 65 20 74 68 72 6f 75 67 68 20 74 68   made through th
9130: 65 20 68 65 6c 70 65 72 20 74 61 62 6c 65 0a 09  e helper table..
9140: 23 20 20 20 20 20 52 45 56 49 53 49 4f 4e 42 52  #     REVISIONBR
9150: 41 4e 43 48 43 48 49 4c 44 52 45 4e 2e 20 52 2e  ANCHCHILDREN. R.
9160: 72 69 64 20 2d 3e 20 52 42 43 2e 72 69 64 2c 20  rid -> RBC.rid, 
9170: 52 42 43 2e 62 72 69 64 20 3d 0a 09 23 20 20 20  RBC.brid =..#   
9180: 20 20 53 28 2e 72 69 64 29 0a 09 23 0a 09 23 20    S(.rid)..#..# 
9190: 28 33 29 20 4f 72 69 67 69 6e 61 6c 6c 79 20 74  (3) Originally t
91a0: 68 69 73 20 75 73 65 20 63 61 73 65 20 64 65 66  his use case def
91b0: 69 6e 65 64 20 74 68 65 20 72 6f 6f 74 20 6f 66  ined the root of
91c0: 20 61 20 64 65 74 61 63 68 65 64 0a 09 23 20 20   a detached..#  
91d0: 20 20 20 4e 54 44 42 20 61 73 20 74 68 65 20 73     NTDB as the s
91e0: 75 63 63 65 73 73 6f 72 20 6f 66 20 74 68 65 20  uccessor of the 
91f0: 74 72 75 6e 6b 20 72 6f 6f 74 2e 20 54 68 69 73  trunk root. This
9200: 20 6c 65 61 64 73 20 74 6f 20 61 0a 09 23 20 20   leads to a..#  
9210: 20 20 20 62 61 64 20 74 61 6e 67 6c 65 20 6c 61     bad tangle la
9220: 74 65 72 20 6f 6e 2e 20 57 69 74 68 20 61 20 64  ter on. With a d
9230: 65 74 61 63 68 65 64 20 4e 54 44 42 20 74 68 65  etached NTDB the
9240: 20 6f 72 69 67 69 6e 61 6c 0a 09 23 20 20 20 20   original..#    
9250: 20 74 72 75 6e 6b 20 72 6f 6f 74 20 72 65 76 69   trunk root revi
9260: 73 69 6f 6e 20 77 61 73 20 72 65 6d 6f 76 65 64  sion was removed
9270: 20 61 73 20 69 72 72 65 6c 65 76 61 6e 74 2c 20   as irrelevant, 
9280: 61 6c 6c 6f 77 69 6e 67 0a 09 23 20 20 20 20 20  allowing..#     
9290: 74 68 65 20 6e 6f 6d 69 6e 61 6c 20 72 6f 6f 74  the nominal root
92a0: 20 74 6f 20 62 65 20 6c 61 74 65 72 20 69 6e 20   to be later in 
92b0: 74 69 6d 65 20 74 68 61 6e 20 74 68 65 20 4e 54  time than the NT
92c0: 44 42 0a 09 23 20 20 20 20 20 72 6f 6f 74 2e 20  DB..#     root. 
92d0: 4e 6f 77 20 73 65 74 74 69 6e 67 20 74 68 69 73  Now setting this
92e0: 20 64 65 70 65 6e 64 65 6e 63 79 20 77 69 6c 6c   dependency will
92f0: 20 62 65 20 62 61 63 6b 77 61 72 64 20 69 6e 0a   be backward in.
9300: 09 23 20 20 20 20 20 74 69 6d 65 2e 20 52 45 4d  .#     time. REM
9310: 4f 56 45 44 2e 0a 09 23 0a 09 23 20 28 34 29 20  OVED...#..# (4) 
9320: 49 66 20 52 20 69 73 20 74 68 65 20 6c 61 73 74  If R is the last
9330: 20 6f 66 20 74 68 65 20 4e 54 44 42 20 72 65 76   of the NTDB rev
9340: 69 73 69 6f 6e 73 20 77 68 69 63 68 20 62 65 6c  isions which bel
9350: 6f 6e 67 20 74 6f 0a 09 23 20 20 20 20 20 74 68  ong to..#     th
9360: 65 20 74 72 75 6e 6b 2c 20 74 68 65 6e 20 74 68  e trunk, then th
9370: 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20  e primary child 
9380: 6f 66 20 74 68 65 20 74 72 75 6e 6b 20 72 6f 6f  of the trunk roo
9390: 74 20 28 74 68 65 0a 09 23 20 20 20 20 20 27 31  t (the..#     '1
93a0: 2e 32 27 20 72 65 76 69 73 69 6f 6e 29 20 69 73  .2' revision) is
93b0: 20 61 20 73 75 63 63 65 73 73 6f 72 2c 20 69 66   a successor, if
93c0: 20 69 74 20 65 78 69 73 74 73 2e 0a 0a 09 23 20   it exists....# 
93d0: 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20 62 72  Note that the br
93e0: 61 6e 63 68 65 73 20 73 70 61 77 6e 65 64 20 66  anches spawned f
93f0: 72 6f 6d 20 74 68 65 20 72 65 76 69 73 69 6f 6e  rom the revision
9400: 73 2c 20 61 6e 64 20 74 68 65 0a 09 23 20 74 61  s, and the..# ta
9410: 67 73 20 61 73 73 6f 63 69 61 74 65 64 20 77 69  gs associated wi
9420: 74 68 20 74 68 65 6d 20 61 72 65 20 73 75 63 63  th them are succ
9430: 65 73 73 6f 72 73 20 61 73 20 77 65 6c 6c 2e 0a  essors as well..
9440: 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 63  ..foreach {rid c
9450: 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75 6e  hild} [state run
9460: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61   [subst -nocomma
9470: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68  nds -nobackslash
9480: 65 73 20 7b 0a 20 20 20 20 2d 2d 20 28 31 29 20  es {.    -- (1) 
9490: 50 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 20  Primary child.. 
94a0: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
94b0: 20 52 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52   R.child..    FR
94c0: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a  OM   revision R.
94d0: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
94e0: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20  d   IN $theset  
94f0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
9500: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
9510: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
9520: 20 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e      R.child IS N
9530: 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61  OT NULL    -- Ha
9540: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a  s primary child.
9550: 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d      UNION.    --
9560: 20 28 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28   (2) Secondary (
9570: 62 72 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e  branch) children
9580: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72  ..    SELECT R.r
9590: 69 64 2c 20 42 2e 62 72 69 64 0a 09 20 20 20 20  id, B.brid..    
95a0: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
95b0: 52 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63  R, revisionbranc
95c0: 68 63 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20  hchildren B..   
95d0: 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20   WHERE  R.rid   
95e0: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
95f0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65  - Restrict to re
9600: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72  visions of inter
9610: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20  est..    AND    
9620: 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20  R.rid = B.rid   
9630: 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74         -- Select
9640: 20 73 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63   subset of branc
9650: 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 20 20 55  h children.    U
9660: 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20  NION.    -- (4) 
9670: 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72  Child of trunk r
9680: 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66  oot successor of
9690: 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72   last NTDB on tr
96a0: 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54  unk...    SELECT
96b0: 20 52 2e 72 69 64 2c 20 52 41 2e 63 68 69 6c 64   R.rid, RA.child
96c0: 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73  ..    FROM revis
96d0: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20  ion R, revision 
96e0: 52 41 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e  RA..    WHERE R.
96f0: 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74  rid   IN $theset
9700: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63        -- Restric
9710: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f  t to revisions o
9720: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20  f interest..    
9730: 41 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75 6c  AND   R.isdefaul
9740: 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d  t             --
9750: 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 44   Restrict to NTD
9760: 42 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 64  B..    AND   R.d
9770: 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55  bchild IS NOT NU
9780: 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74  LL   -- and last
9790: 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20   NTDB belonging 
97a0: 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e  to trunk..    AN
97b0: 44 20 20 20 52 41 2e 72 69 64 20 3d 20 52 2e 64  D   RA.rid = R.d
97c0: 62 63 68 69 6c 64 20 20 20 20 20 20 2d 2d 20 47  bchild      -- G
97d0: 6f 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 72  o directly to tr
97e0: 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e  unk root..    AN
97f0: 44 20 20 20 52 41 2e 63 68 69 6c 64 20 49 53 20  D   RA.child IS 
9800: 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48  NOT NULL    -- H
9810: 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64  as primary child
9820: 2e 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 23 20  ...}]] {..    # 
9830: 43 6f 6e 73 69 64 65 72 20 6d 6f 76 69 6e 67 20  Consider moving 
9840: 74 68 69 73 20 74 6f 20 74 68 65 20 69 6e 74 65  this to the inte
9850: 67 72 69 74 79 20 6d 6f 64 75 6c 65 2e 0a 09 20  grity module... 
9860: 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73     integrity ass
9870: 65 72 74 20 7b 24 72 69 64 20 21 3d 20 24 63 68  ert {$rid != $ch
9880: 69 6c 64 7d 20 7b 52 65 76 69 73 69 6f 6e 20 24  ild} {Revision $
9890: 72 69 64 20 64 65 70 65 6e 64 73 20 6f 6e 20 69  rid depends on i
98a0: 74 73 65 6c 66 2e 7d 0a 09 20 20 20 20 6c 61 70  tself.}..    lap
98b0: 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65  pend dependencie
98c0: 73 28 5b 6c 69 73 74 20 72 65 76 20 24 72 69 64  s([list rev $rid
98d0: 5d 29 20 5b 6c 69 73 74 20 72 65 76 20 24 63 68  ]) [list rev $ch
98e0: 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68  ild]..}..foreach
98f0: 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74   {rid child} [st
9900: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
9910: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
9920: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
9930: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 54   SELECT R.rid, T
9940: 2e 74 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  .tid..    FROM  
9950: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 74 61 67   revision R, tag
9960: 20 54 0a 09 20 20 20 20 57 48 45 52 45 20 20 52   T..    WHERE  R
9970: 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .rid IN $theset 
9980: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63        -- Restric
9990: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f  t to revisions o
99a0: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20  f interest..    
99b0: 41 4e 44 20 20 20 20 54 2e 72 65 76 20 3d 20 52  AND    T.rev = R
99c0: 2e 72 69 64 20 20 20 20 20 20 20 20 20 20 2d 2d  .rid          --
99d0: 20 53 65 6c 65 63 74 20 74 61 67 73 20 61 74 74   Select tags att
99e0: 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 09 7d  ached to them..}
99f0: 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e  ]] {..    lappen
9a00: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b  d dependencies([
9a10: 6c 69 73 74 20 72 65 76 20 24 72 69 64 5d 29 20  list rev $rid]) 
9a20: 5b 6c 69 73 74 20 73 79 6d 3a 3a 74 61 67 20 24  [list sym::tag $
9a30: 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 61  child]..}..forea
9a40: 63 68 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b  ch {rid child} [
9a50: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74  state run [subst
9a60: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f   -nocommands -no
9a70: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20  backslashes {.. 
9a80: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
9a90: 20 42 2e 62 69 64 0a 09 20 20 20 20 46 52 4f 4d   B.bid..    FROM
9aa0: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 62     revision R, b
9ab0: 72 61 6e 63 68 20 42 0a 09 20 20 20 20 57 48 45  ranch B..    WHE
9ac0: 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24 74 68  RE  R.rid IN $th
9ad0: 65 73 65 74 20 20 20 20 20 20 20 2d 2d 20 52 65  eset       -- Re
9ae0: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
9af0: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  ons of interest.
9b00: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 6f  .    AND    B.ro
9b10: 6f 74 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20  ot = R.rid      
9b20: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 62 72 61     -- Select bra
9b30: 6e 63 68 65 73 20 61 74 74 61 63 68 65 64 20 74  nches attached t
9b40: 6f 20 74 68 65 6d 0a 09 7d 5d 5d 20 7b 0a 09 20  o them..}]] {.. 
9b50: 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e     lappend depen
9b60: 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 72 65  dencies([list re
9b70: 76 20 24 72 69 64 5d 29 20 5b 6c 69 73 74 20 73  v $rid]) [list s
9b80: 79 6d 3a 3a 62 72 61 6e 63 68 20 24 63 68 69 6c  ym::branch $chil
9b90: 64 5d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20  d]..}..return.  
9ba0: 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c    }..    # resul
9bb0: 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65  t = list (change
9bc0: 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79 70 65  set-id).    type
9bd0: 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63 65 73  method cs_succes
9be0: 73 6f 72 73 20 7b 72 65 76 69 73 69 6f 6e 73 7d  sors {revisions}
9bf0: 20 7b 0a 20 20 20 20 20 20 20 20 23 20 54 68 69   {.        # Thi
9c00: 73 20 69 73 20 61 20 76 61 72 69 61 6e 74 20 6f  s is a variant o
9c10: 66 20 27 73 75 63 63 65 73 73 6f 72 73 27 20 77  f 'successors' w
9c20: 68 69 63 68 20 6d 61 70 73 20 74 68 65 20 6c 6f  hich maps the lo
9c30: 77 2d 6c 65 76 65 6c 0a 20 20 20 20 20 20 20 20  w-level.        
9c40: 23 20 64 61 74 61 20 64 69 72 65 63 74 6c 79 20  # data directly 
9c50: 74 6f 20 74 68 65 20 61 73 73 6f 63 69 61 74 65  to the associate
9c60: 64 20 63 68 61 6e 67 65 73 65 74 73 2e 20 49 2e  d changesets. I.
9c70: 65 2e 20 69 6e 73 74 65 61 64 0a 20 20 20 20 20  e. instead.     
9c80: 20 20 20 23 20 6d 69 6c 6c 69 6f 6e 73 20 6f 66     # millions of
9c90: 20 64 65 70 65 6e 64 65 6e 63 79 20 70 61 69 72   dependency pair
9ca0: 73 20 28 69 6e 20 65 78 74 72 65 6d 65 20 63 61  s (in extreme ca
9cb0: 73 65 73 20 28 45 78 61 6d 70 6c 65 3a 20 54 63  ses (Example: Tc
9cc0: 6c 0a 20 20 20 20 20 20 20 20 23 20 43 56 53 29  l.        # CVS)
9cd0: 29 20 77 65 20 72 65 74 75 72 6e 20 61 20 76 65  ) we return a ve
9ce0: 72 79 20 73 68 6f 72 74 20 61 6e 64 20 6d 75 63  ry short and muc
9cf0: 68 20 6d 6f 72 65 20 6d 61 6e 61 67 65 61 62 6c  h more manageabl
9d00: 65 20 6c 69 73 74 0a 20 20 20 20 20 20 20 20 23  e list.        #
9d10: 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73 2e 0a   of changesets..
9d20: 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b  ..set theset ('[
9d30: 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20  join $revisions 
9d40: 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e  {','}]')..return
9d50: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62   [state run [sub
9d60: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d  st -nocommands -
9d70: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a  nobackslashes {.
9d80: 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d 61      -- (1) Prima
9d90: 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53 45  ry child..    SE
9da0: 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20  LECT C.cid..    
9db0: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
9dc0: 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68  R, csitem CI, ch
9dd0: 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57  angeset C..    W
9de0: 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e  HERE  R.rid   IN
9df0: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
9e00: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
9e10: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
9e20: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
9e30: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
9e40: 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d  L    -- Has prim
9e50: 61 72 79 20 63 68 69 6c 64 0a 20 20 20 20 20 20  ary child.      
9e60: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e        AND    CI.
9e70: 69 69 64 20 3d 20 52 2e 63 68 69 6c 64 20 20 20  iid = R.child   
9e80: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c      -- Select al
9e90: 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20  l changesets.   
9ea0: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
9eb0: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 20 20  C.cid = CI.cid  
9ec0: 20 20 20 20 20 20 20 2d 2d 20 63 6f 6e 74 61 69         -- contai
9ed0: 6e 69 6e 67 20 74 68 65 20 70 72 69 6d 61 72 79  ning the primary
9ee0: 20 63 68 69 6c 64 0a 20 20 20 20 20 20 20 20 20   child.         
9ef0: 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65     AND    C.type
9f00: 20 3d 20 30 20 20 20 20 20 20 20 20 20 20 20 20   = 0            
9f10: 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 72 65   -- which are re
9f20: 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74  vision changeset
9f30: 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20  s.    UNION.    
9f40: 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61 72 79  -- (2) Secondary
9f50: 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c 64 72   (branch) childr
9f60: 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43  en..    SELECT C
9f70: 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20  .cid..    FROM  
9f80: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76   revision R, rev
9f90: 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64  isionbranchchild
9fa0: 72 65 6e 20 42 2c 20 63 73 69 74 65 6d 20 43 49  ren B, csitem CI
9fb0: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20  , changeset C.. 
9fc0: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
9fd0: 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20    IN $theset    
9fe0: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
9ff0: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74  revisions of int
a000: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20  erest..    AND  
a010: 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 20    R.rid = B.rid 
a020: 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65           -- Sele
a030: 63 74 20 73 75 62 73 65 74 20 6f 66 20 62 72 61  ct subset of bra
a040: 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 20  nch children.   
a050: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
a060: 43 49 2e 69 69 64 20 3d 20 42 2e 62 72 69 64 20  CI.iid = B.brid 
a070: 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74         -- Select
a080: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a   all changesets.
a090: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20              AND 
a0a0: 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69     C.cid = CI.ci
a0b0: 64 09 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e  d.  -- containin
a0c0: 67 20 74 68 65 20 62 72 61 6e 63 68 0a 20 20 20  g the branch.   
a0d0: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
a0e0: 43 2e 74 79 70 65 20 3d 20 30 09 09 20 20 2d 2d  C.type = 0..  --
a0f0: 20 77 68 69 63 68 20 61 72 65 20 72 65 76 69 73   which are revis
a100: 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 20  ion changesets. 
a110: 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20     UNION.    -- 
a120: 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75  (4) Child of tru
a130: 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f  nk root successo
a140: 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f  r of last NTDB o
a150: 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45  n trunk...    SE
a160: 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20  LECT C.cid..    
a170: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20  FROM   revision 
a180: 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 2c 20  R, revision RA, 
a190: 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67  csitem CI, chang
a1a0: 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45 52  eset C..    WHER
a1b0: 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74  E  R.rid   IN $t
a1c0: 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 52 65  heset      -- Re
a1d0: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69  strict to revisi
a1e0: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  ons of interest.
a1f0: 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 69 73  .    AND    R.is
a200: 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20 20  default         
a210: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
a220: 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e 44  to NTDB..    AND
a230: 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53      R.dbchild IS
a240: 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 61   NOT NULL   -- a
a250: 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65 6c  nd last NTDB bel
a260: 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b 0a  onging to trunk.
a270: 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e 72  .    AND    RA.r
a280: 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 20  id = R.dbchild  
a290: 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 74      -- Go direct
a2a0: 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f 74  ly to trunk root
a2b0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e  ..    AND    RA.
a2c0: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c  child IS NOT NUL
a2d0: 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d  L    -- Has prim
a2e0: 61 72 79 20 63 68 69 6c 64 2e 0a 20 20 20 20 20  ary child..     
a2f0: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49         AND    CI
a300: 2e 69 69 64 20 3d 20 52 41 2e 63 68 69 6c 64 20  .iid = RA.child 
a310: 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20        -- Select 
a320: 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20  all changesets. 
a330: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
a340: 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64    C.cid = CI.cid
a350: 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e  .   -- containin
a360: 67 20 74 68 65 20 70 72 69 6d 61 72 79 20 63 68  g the primary ch
a370: 69 6c 64 0a 20 20 20 20 20 20 20 20 20 20 20 20  ild.            
a380: 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20  AND    C.type = 
a390: 30 09 09 20 20 20 2d 2d 20 77 68 69 63 68 20 61  0..   -- which a
a3a0: 72 65 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e  re revision chan
a3b0: 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f 4e  gesets.    UNION
a3c0: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63  ..    SELECT C.c
a3d0: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72  id..    FROM   r
a3e0: 65 76 69 73 69 6f 6e 20 52 2c 20 74 61 67 20 54  evision R, tag T
a3f0: 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61  , csitem CI, cha
a400: 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48  ngeset C..    WH
a410: 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20 24 74  ERE  R.rid in $t
a420: 68 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d 20  heset        -- 
a430: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
a440: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
a450: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 54 2e  t..    AND    T.
a460: 72 65 76 20 3d 20 52 2e 72 69 64 09 20 20 20 2d  rev = R.rid.   -
a470: 2d 20 53 65 6c 65 63 74 20 74 61 67 73 20 61 74  - Select tags at
a480: 74 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 20  tached to them. 
a490: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
a4a0: 20 20 43 49 2e 69 69 64 20 3d 20 54 2e 74 69 64    CI.iid = T.tid
a4b0: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c            -- Sel
a4c0: 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65  ect all changese
a4d0: 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41  ts.            A
a4e0: 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49  ND    C.cid = CI
a4f0: 2e 63 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61  .cid.   -- conta
a500: 69 6e 69 6e 67 20 74 68 65 20 74 61 67 73 0a 20  ining the tags. 
a510: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20             AND  
a520: 20 20 43 2e 74 79 70 65 20 3d 20 31 09 09 20 20    C.type = 1..  
a530: 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 74 61   -- which are ta
a540: 67 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20  g changesets.   
a550: 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45   UNION..    SELE
a560: 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52  CT C.cid..    FR
a570: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
a580: 20 62 72 61 6e 63 68 20 42 2c 20 63 73 69 74 65   branch B, csite
a590: 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20  m CI, changeset 
a5a0: 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e  C..    WHERE  R.
a5b0: 72 69 64 20 69 6e 20 24 74 68 65 73 65 74 20 20  rid in $theset  
a5c0: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63        -- Restric
a5d0: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f  t to revisions o
a5e0: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20  f interest..    
a5f0: 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20  AND    B.root = 
a600: 52 2e 72 69 64 09 20 20 20 2d 2d 20 53 65 6c 65  R.rid.   -- Sele
a610: 63 74 20 62 72 61 6e 63 68 65 73 20 61 74 74 61  ct branches atta
a620: 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 20 20 20  ched to them.   
a630: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
a640: 43 49 2e 69 69 64 20 3d 20 42 2e 62 69 64 20 20  CI.iid = B.bid  
a650: 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63          -- Selec
a660: 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73  t all changesets
a670: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
a680: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63      C.cid = CI.c
a690: 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e  id.   -- contain
a6a0: 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68 65 73  ing the branches
a6b0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44  .            AND
a6c0: 20 20 20 20 43 2e 74 79 70 65 20 3d 20 32 09 09      C.type = 2..
a6d0: 20 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20     -- which are 
a6e0: 62 72 61 6e 63 68 20 63 68 61 6e 67 65 73 65 74  branch changeset
a6f0: 73 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20  s..}]].    }..  
a700: 20 20 23 20 72 65 73 75 6c 74 20 3d 20 73 79 6d    # result = sym
a710: 62 6f 6c 20 6e 61 6d 65 0a 20 20 20 20 74 79 70  bol name.    typ
a720: 65 6d 65 74 68 6f 64 20 63 73 5f 6c 6f 64 20 7b  emethod cs_lod {
a730: 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 23 20  revisions} {..# 
a740: 44 65 74 65 72 6d 69 6e 65 73 20 74 68 65 20 6e  Determines the n
a750: 61 6d 65 20 6f 66 20 74 68 65 20 73 79 6d 62 6f  ame of the symbo
a760: 6c 20 77 68 69 63 68 20 69 73 20 74 68 65 20 6c  l which is the l
a770: 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c 6f  ine of..# develo
a780: 70 6d 65 6e 74 20 66 6f 72 20 74 68 65 20 72 65  pment for the re
a790: 76 69 73 69 6f 6e 73 20 69 6e 20 61 20 63 68 61  visions in a cha
a7a0: 6e 67 65 73 65 74 2e 0a 0a 09 73 65 74 20 74 68  ngeset....set th
a7b0: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65  eset ('[join $re
a7c0: 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29  visions {','}]')
a7d0: 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20  ..return [state 
a7e0: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
a7f0: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
a800: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c  ashes {..    SEL
a810: 45 43 54 0a 09 20 20 20 20 44 49 53 54 49 4e 43  ECT..    DISTINC
a820: 54 20 4c 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52  T L.name..    FR
a830: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
a840: 20 73 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20 57   symbol L..    W
a850: 48 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20 24  HERE  R.rid in $
a860: 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d  theset        --
a870: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76   Restrict to rev
a880: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65  isions of intere
a890: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 4c  st..    AND    L
a8a0: 2e 73 69 64 20 3d 20 52 2e 6c 6f 64 20 20 20 20  .sid = R.lod    
a8b0: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 6c 6f         -- Get lo
a8c0: 64 20 73 79 6d 62 6f 6c 20 6f 66 20 72 65 76 69  d symbol of revi
a8d0: 73 69 6f 6e 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a  sion..}]].    }.
a8e0: 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23  }..# # ## ### ##
a8f0: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
a900: 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23  ########## #####
a910: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
a920: 0a 23 23 20 48 65 6c 70 65 72 20 73 69 6e 67 6c  .## Helper singl
a930: 65 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73 20 66  eton. Commands f
a940: 6f 72 20 74 61 67 20 73 79 6d 62 6f 6c 20 63 68  or tag symbol ch
a950: 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e 69 74 3a  angesets...snit:
a960: 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73  :type ::vc::foss
a970: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
a980: 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a 73  :project::rev::s
a990: 79 6d 3a 3a 74 61 67 20 7b 0a 20 20 20 20 74 79  ym::tag {.    ty
a9a0: 70 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73  pemethod byrevis
a9b0: 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20  ion {} { return 
a9c0: 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68  0 }.    typemeth
a9d0: 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d  od bysymbol   {}
a9e0: 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20 20   { return 1 }.  
a9f0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74    typemethod ist
aa00: 61 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74  ag      {} { ret
aa10: 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 65  urn 1 }.    type
aa20: 6d 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20  method isbranch 
aa30: 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20    {} { return 0 
aa40: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
aa50: 64 20 73 74 72 20 7b 74 61 67 7d 20 7b 0a 09 73  d str {tag} {..s
aa60: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69  truct::list assi
aa70: 67 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a  gn [state run {.
aa80: 09 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e 61  .    SELECT S.na
aa90: 6d 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e 61  me, F.name, P.na
aaa0: 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 74  me..    FROM   t
aab0: 61 67 20 54 2c 20 73 79 6d 62 6f 6c 20 53 2c 20  ag T, symbol S, 
aac0: 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20  file F, project 
aad0: 50 0a 09 20 20 20 20 57 48 45 52 45 20 20 54 2e  P..    WHERE  T.
aae0: 74 69 64 20 3d 20 24 74 61 67 20 20 20 2d 2d 20  tid = $tag   -- 
aaf0: 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 20 74  Find specified t
ab00: 61 67 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46  ag..    AND    F
ab10: 2e 66 69 64 20 3d 20 54 2e 66 69 64 20 20 2d 2d  .fid = T.fid  --
ab20: 20 47 65 74 20 66 69 6c 65 20 6f 66 20 74 61 67   Get file of tag
ab30: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 50 2e 70  ..    AND    P.p
ab40: 69 64 20 3d 20 46 2e 70 69 64 20 20 2d 2d 20 47  id = F.pid  -- G
ab50: 65 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 66 69  et project of fi
ab60: 6c 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 53  le..    AND    S
ab70: 2e 73 69 64 20 3d 20 54 2e 73 69 64 20 20 2d 2d  .sid = T.sid  --
ab80: 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 74   Get symbol of t
ab90: 61 67 0a 09 7d 5d 20 73 6e 61 6d 65 20 66 6e 61  ag..}] sname fna
aba0: 6d 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e  me pname..return
abb0: 20 22 24 70 6e 61 6d 65 2f 54 27 24 7b 73 6e 61   "$pname/T'${sna
abc0: 6d 65 7d 27 3a 3a 24 66 6e 61 6d 65 22 0a 20 20  me}'::$fname".  
abd0: 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c    }..    # resul
abe0: 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d  t = list (mintim
abf0: 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20 20  e, maxtime).    
ac00: 74 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65 72  typemethod timer
ac10: 61 6e 67 65 20 7b 74 61 67 73 7d 20 7b 0a 09 23  ange {tags} {..#
ac20: 20 54 68 65 20 72 61 6e 67 65 20 69 73 20 64 65   The range is de
ac30: 66 69 6e 65 64 20 61 73 20 74 68 65 20 72 61 6e  fined as the ran
ac40: 67 65 20 6f 66 20 74 68 65 20 72 65 76 69 73 69  ge of the revisi
ac50: 6f 6e 73 20 74 68 65 20 74 61 67 73 0a 09 23 20  ons the tags..# 
ac60: 61 72 65 20 61 74 74 61 63 68 65 64 20 74 6f 2e  are attached to.
ac70: 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27  ...set theset ('
ac80: 5b 6a 6f 69 6e 20 24 74 61 67 73 20 7b 27 2c 27  [join $tags {','
ac90: 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74  }]')..return [st
aca0: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
acb0: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
acc0: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
acd0: 20 53 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64 61   SELECT MIN(R.da
ace0: 74 65 29 2c 20 4d 41 58 28 52 2e 64 61 74 65 29  te), MAX(R.date)
acf0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 74 61 67  ..    FROM   tag
ad00: 20 54 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a 09   T, revision R..
ad10: 20 20 20 20 57 48 45 52 45 20 20 54 2e 74 69 64      WHERE  T.tid
ad20: 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d 20   IN $theset  -- 
ad30: 52 65 73 74 72 69 63 74 20 74 6f 20 74 61 67 73  Restrict to tags
ad40: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20 20   of interest.   
ad50: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
ad60: 52 2e 72 69 64 20 3d 20 54 2e 72 65 76 20 20 20  R.rid = T.rev   
ad70: 20 20 2d 2d 20 53 65 6c 65 63 74 20 74 61 67 20    -- Select tag 
ad80: 70 61 72 65 6e 74 20 72 65 76 69 73 69 6f 6e 73  parent revisions
ad90: 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20  ..}]].    }..   
ada0: 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 63   # var(dv) = dic
adb0: 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20  t (item -> list 
adc0: 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 3d  (item)), item  =
add0: 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29 0a   list (type id).
ade0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73      typemethod s
adf0: 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20 74 61  uccessors {dv ta
ae00: 67 73 7d 20 7b 0a 09 23 20 54 61 67 73 20 68 61  gs} {..# Tags ha
ae10: 76 65 20 6e 6f 20 73 75 63 63 65 73 73 6f 72 73  ve no successors
ae20: 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  ...return.    }.
ae30: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20  .    # result = 
ae40: 34 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70 65  4-list (itemtype
ae50: 20 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65 6d   itemid nextitem
ae60: 74 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64 20  type nextitemid 
ae70: 2e 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65 74  ...).    typemet
ae80: 68 6f 64 20 6c 6f 6f 70 73 20 7b 74 61 67 73 7d  hod loops {tags}
ae90: 20 7b 0a 09 23 20 54 61 67 73 20 68 61 76 65 20   {..# Tags have 
aea0: 6e 6f 20 73 75 63 63 65 73 73 6f 72 73 2c 20 74  no successors, t
aeb0: 68 65 72 65 66 6f 72 65 20 63 61 6e 6e 6f 74 20  herefore cannot 
aec0: 63 61 75 73 65 20 6c 6f 6f 70 73 0a 09 72 65 74  cause loops..ret
aed0: 75 72 6e 20 7b 7d 0a 20 20 20 20 7d 0a 0a 20 20  urn {}.    }..  
aee0: 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73    # result = lis
aef0: 74 20 28 63 68 61 6e 67 65 73 65 74 2d 69 64 29  t (changeset-id)
af00: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
af10: 63 73 5f 73 75 63 63 65 73 73 6f 72 73 20 7b 74  cs_successors {t
af20: 61 67 73 7d 20 7b 0a 09 23 20 54 61 67 73 20 68  ags} {..# Tags h
af30: 61 76 65 20 6e 6f 20 73 75 63 63 65 73 73 6f 72  ave no successor
af40: 73 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  s...return.    }
af50: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d  ..    # result =
af60: 20 73 79 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20 20   symbol name.   
af70: 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f 6c   typemethod cs_l
af80: 6f 64 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20 44  od {tags} {..# D
af90: 65 74 65 72 6d 69 6e 65 73 20 74 68 65 20 6e 61  etermines the na
afa0: 6d 65 20 6f 66 20 74 68 65 20 73 79 6d 62 6f 6c  me of the symbol
afb0: 20 77 68 69 63 68 20 69 73 20 74 68 65 20 6c 69   which is the li
afc0: 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c 6f 70  ne of..# develop
afd0: 6d 65 6e 74 20 66 6f 72 20 74 68 65 20 74 61 67  ment for the tag
afe0: 73 20 69 6e 20 61 20 63 68 61 6e 67 65 73 65 74  s in a changeset
aff0: 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28  ....set theset (
b000: 27 5b 6a 6f 69 6e 20 24 74 61 67 73 20 7b 27 2c  '[join $tags {',
b010: 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73  '}]')..return [s
b020: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20  tate run [subst 
b030: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62  -nocommands -nob
b040: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20  ackslashes {..  
b050: 20 20 53 45 4c 45 43 54 0a 09 20 20 20 20 44 49    SELECT..    DI
b060: 53 54 49 4e 43 54 20 4c 2e 6e 61 6d 65 0a 09 20  STINCT L.name.. 
b070: 20 20 20 46 52 4f 4d 20 20 20 74 61 67 20 54 2c     FROM   tag T,
b080: 20 73 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20 57   symbol L..    W
b090: 48 45 52 45 20 20 54 2e 74 69 64 20 69 6e 20 24  HERE  T.tid in $
b0a0: 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d  theset        --
b0b0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 74 61 67   Restrict to tag
b0c0: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
b0d0: 20 20 20 41 4e 44 20 20 20 20 4c 2e 73 69 64 20     AND    L.sid 
b0e0: 3d 20 54 2e 6c 6f 64 20 20 20 20 20 20 20 20 20  = T.lod         
b0f0: 20 20 2d 2d 20 47 65 74 20 6c 6f 64 20 73 79 6d    -- Get lod sym
b100: 62 6f 6c 20 6f 66 20 74 61 67 0a 09 7d 5d 5d 0a  bol of tag..}]].
b110: 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20      }.}..# # ## 
b120: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
b130: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
b140: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23   ###############
b150: 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65 72  ######.## Helper
b160: 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d 6d   singleton. Comm
b170: 61 6e 64 73 20 66 6f 72 20 62 72 61 6e 63 68 20  ands for branch 
b180: 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74  symbol changeset
b190: 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a  s...snit::type :
b1a0: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
b1b0: 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63  ort::cvs::projec
b1c0: 74 3a 3a 72 65 76 3a 3a 73 79 6d 3a 3a 62 72 61  t::rev::sym::bra
b1d0: 6e 63 68 20 7b 0a 20 20 20 20 74 79 70 65 6d 65  nch {.    typeme
b1e0: 74 68 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20  thod byrevision 
b1f0: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a  {} { return 0 }.
b200: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62      typemethod b
b210: 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 7b 20 72  ysymbol   {} { r
b220: 65 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79  eturn 1 }.    ty
b230: 70 65 6d 65 74 68 6f 64 20 69 73 74 61 67 20 20  pemethod istag  
b240: 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20      {} { return 
b250: 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68  0 }.    typemeth
b260: 6f 64 20 69 73 62 72 61 6e 63 68 20 20 20 7b 7d  od isbranch   {}
b270: 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 0a 20   { return 1 }.. 
b280: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 74     typemethod st
b290: 72 20 7b 62 72 61 6e 63 68 7d 20 7b 0a 09 73 74  r {branch} {..st
b2a0: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
b2b0: 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09  n [state run {..
b2c0: 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e 61 6d      SELECT S.nam
b2d0: 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e 61 6d  e, F.name, P.nam
b2e0: 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72  e..    FROM   br
b2f0: 61 6e 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20 53  anch B, symbol S
b300: 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63  , file F, projec
b310: 74 20 50 0a 09 20 20 20 20 57 48 45 52 45 20 20  t P..    WHERE  
b320: 42 2e 62 69 64 20 3d 20 24 62 72 61 6e 63 68 20  B.bid = $branch 
b330: 20 2d 2d 20 46 69 6e 64 20 73 70 65 63 69 66 69   -- Find specifi
b340: 65 64 20 62 72 61 6e 63 68 0a 09 20 20 20 20 41  ed branch..    A
b350: 4e 44 20 20 20 20 46 2e 66 69 64 20 3d 20 42 2e  ND    F.fid = B.
b360: 66 69 64 20 20 20 20 2d 2d 20 47 65 74 20 66 69  fid    -- Get fi
b370: 6c 65 20 6f 66 20 62 72 61 6e 63 68 0a 09 20 20  le of branch..  
b380: 20 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20 3d    AND    P.pid =
b390: 20 46 2e 70 69 64 20 20 20 20 2d 2d 20 47 65 74   F.pid    -- Get
b3a0: 20 70 72 6f 6a 65 63 74 20 6f 66 20 66 69 6c 65   project of file
b3b0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 53 2e 73  ..    AND    S.s
b3c0: 69 64 20 3d 20 42 2e 73 69 64 20 20 20 20 2d 2d  id = B.sid    --
b3d0: 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 62   Get symbol of b
b3e0: 72 61 6e 63 68 0a 09 7d 5d 20 73 6e 61 6d 65 20  ranch..}] sname 
b3f0: 66 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65 74  fname pname..ret
b400: 75 72 6e 20 22 24 70 6e 61 6d 65 2f 42 27 24 7b  urn "$pname/B'${
b410: 73 6e 61 6d 65 7d 27 3a 3a 24 66 6e 61 6d 65 22  sname}'::$fname"
b420: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65  .    }..    # re
b430: 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e  sult = list (min
b440: 74 69 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20  time, maxtime). 
b450: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 74 69     typemethod ti
b460: 6d 65 72 61 6e 67 65 20 7b 62 72 61 6e 63 68 65  merange {branche
b470: 73 7d 20 7b 0a 09 23 20 54 68 65 20 72 61 6e 67  s} {..# The rang
b480: 65 20 6f 66 20 61 20 62 72 61 6e 63 68 20 69 73  e of a branch is
b490: 20 64 65 66 69 6e 65 64 20 61 73 20 74 68 65 20   defined as the 
b4a0: 72 61 6e 67 65 20 6f 66 20 74 68 65 0a 09 23 20  range of the..# 
b4b0: 72 65 76 69 73 69 6f 6e 73 20 74 68 65 20 62 72  revisions the br
b4c0: 61 6e 63 68 65 73 20 61 72 65 20 73 70 61 77 6e  anches are spawn
b4d0: 65 64 20 62 79 2e 20 4e 4f 54 45 20 68 6f 77 65  ed by. NOTE howe
b4e0: 76 65 72 20 74 68 61 74 20 74 68 65 0a 09 23 20  ver that the..# 
b4f0: 62 72 61 6e 63 68 65 73 20 61 73 73 6f 63 69 61  branches associa
b500: 74 65 64 20 77 69 74 68 20 61 20 64 65 74 61 63  ted with a detac
b510: 68 65 64 20 4e 54 44 42 20 77 69 6c 6c 20 68 61  hed NTDB will ha
b520: 76 65 20 6e 6f 20 72 6f 6f 74 0a 09 23 20 73 70  ve no root..# sp
b530: 61 77 6e 69 6e 67 20 74 68 65 6d 2c 20 68 65 6e  awning them, hen
b540: 63 65 20 74 68 65 79 20 68 61 76 65 20 6e 6f 20  ce they have no 
b550: 72 65 61 6c 20 74 69 6d 65 72 61 6e 67 65 20 61  real timerange a
b560: 6e 79 0a 09 23 20 6c 6f 6e 67 65 72 2e 20 42 79  ny..# longer. By
b570: 20 75 73 69 6e 67 20 30 20 77 65 20 70 75 74 20   using 0 we put 
b580: 74 68 65 6d 20 69 6e 20 66 72 6f 6e 74 20 6f 66  them in front of
b590: 20 65 76 65 72 79 74 68 69 6e 67 20 65 6c 73 65   everything else
b5a0: 2c 0a 09 23 20 61 73 20 74 68 65 79 20 6c 6f 67  ,..# as they log
b5b0: 69 63 61 6c 6c 79 20 61 72 65 2e 0a 0a 09 73 65  ically are....se
b5c0: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
b5d0: 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d   $branches {','}
b5e0: 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61  ]')..return [sta
b5f0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e  te run [subst -n
b600: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63  ocommands -nobac
b610: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20  kslashes {..    
b620: 53 45 4c 45 43 54 20 49 46 4e 55 4c 4c 28 4d 49  SELECT IFNULL(MI
b630: 4e 28 52 2e 64 61 74 65 29 2c 30 29 2c 20 49 46  N(R.date),0), IF
b640: 4e 55 4c 4c 28 4d 41 58 28 52 2e 64 61 74 65 29  NULL(MAX(R.date)
b650: 2c 30 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 62  ,0)..    FROM  b
b660: 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f  ranch B, revisio
b670: 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 42  n R..    WHERE B
b680: 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .bid IN $theset 
b690: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
b6a0: 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74   branches of int
b6b0: 65 72 65 73 74 0a 20 20 20 20 20 20 20 20 20 20  erest.          
b6c0: 20 20 41 4e 44 20 20 20 52 2e 72 69 64 20 3d 20    AND   R.rid = 
b6d0: 42 2e 72 6f 6f 74 20 20 20 20 20 2d 2d 20 53 65  B.root     -- Se
b6e0: 6c 65 63 74 20 62 72 61 6e 63 68 20 70 61 72 65  lect branch pare
b6f0: 6e 74 20 72 65 76 69 73 69 6f 6e 73 0a 09 7d 5d  nt revisions..}]
b700: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72  ].    }..    # r
b710: 65 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28  esult = 4-list (
b720: 69 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 20  itemtype itemid 
b730: 6e 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 78  nextitemtype nex
b740: 74 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20  titemid ...).   
b750: 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70   typemethod loop
b760: 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09  s {branches} {..
b770: 23 20 4e 6f 74 65 3a 20 52 65 76 69 73 69 6f 6e  # Note: Revision
b780: 73 20 61 6e 64 20 74 61 67 73 20 63 61 6e 6e 6f  s and tags canno
b790: 74 20 63 61 75 73 65 20 74 68 65 20 6c 6f 6f 70  t cause the loop
b7a0: 2e 20 42 65 69 6e 67 20 6f 66 20 61 0a 09 23 20  . Being of a..# 
b7b0: 66 75 6e 64 61 6d 65 6e 74 61 6c 6c 79 20 64 69  fundamentally di
b7c0: 66 66 65 72 65 6e 74 20 74 79 70 65 20 74 68 65  fferent type the
b7d0: 79 20 63 61 6e 6e 6f 74 20 62 65 20 69 6e 20 74  y cannot be in t
b7e0: 68 65 20 69 6e 63 6f 6d 69 6e 67 0a 09 23 20 73  he incoming..# s
b7f0: 65 74 20 6f 66 20 69 64 73 2e 0a 0a 09 73 65 74  et of ids....set
b800: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20   theset ('[join 
b810: 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d  $branches {','}]
b820: 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74  ')..return [stat
b830: 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f  e run [subst -no
b840: 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b  commands -noback
b850: 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53  slashes {..    S
b860: 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 58 2e  ELECT B.bid, BX.
b870: 62 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20  bid..    FROM   
b880: 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72  branch B, prefer
b890: 65 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61 6e  edparent P, bran
b8a0: 63 68 20 42 58 0a 09 20 20 20 20 57 48 45 52 45  ch BX..    WHERE
b8b0: 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73    B.bid IN $thes
b8c0: 65 74 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74  et   -- Restrict
b8d0: 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20   to branches of 
b8e0: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e  interest..    AN
b8f0: 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e 70  D    B.sid = P.p
b900: 69 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20 74  id      -- Get t
b910: 68 65 20 70 72 65 66 65 72 65 64 20 62 72 61 6e  he prefered bran
b920: 63 68 65 73 20 76 69 61 0a 09 20 20 20 20 41 4e  ches via..    AN
b930: 44 20 20 20 20 42 58 2e 73 69 64 20 3d 20 50 2e  D    BX.sid = P.
b940: 73 69 64 20 20 20 20 20 2d 2d 20 74 68 65 20 62  sid     -- the b
b950: 72 61 6e 63 68 20 73 79 6d 62 6f 6c 73 0a 09 20  ranch symbols.. 
b960: 20 20 20 41 4e 44 20 20 20 20 42 58 2e 62 69 64     AND    BX.bid
b970: 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d 20   IN $theset  -- 
b980: 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a  Loop..}]].    }.
b990: 0a 20 20 20 20 23 20 76 61 72 28 64 76 29 20 3d  .    # var(dv) =
b9a0: 20 64 69 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c   dict (item -> l
b9b0: 69 73 74 20 28 69 74 65 6d 29 29 2c 20 69 74 65  ist (item)), ite
b9c0: 6d 20 20 3d 20 6c 69 73 74 20 28 74 79 70 65 20  m  = list (type 
b9d0: 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68  id).    typemeth
b9e0: 6f 64 20 73 75 63 63 65 73 73 6f 72 73 20 7b 64  od successors {d
b9f0: 76 20 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 75  v branches} {..u
ba00: 70 76 61 72 20 31 20 24 64 76 20 64 65 70 65 6e  pvar 1 $dv depen
ba10: 64 65 6e 63 69 65 73 0a 09 23 20 54 68 65 20 66  dencies..# The f
ba20: 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 63 6f  irst revision co
ba30: 6d 6d 69 74 74 65 64 20 6f 6e 20 61 20 62 72 61  mmitted on a bra
ba40: 6e 63 68 2c 20 61 6e 64 20 61 6c 6c 20 62 72 61  nch, and all bra
ba50: 6e 63 68 65 73 0a 09 23 20 61 6e 64 20 74 61 67  nches..# and tag
ba60: 73 20 77 68 69 63 68 20 68 61 76 65 20 69 74 20  s which have it 
ba70: 61 73 20 74 68 65 69 72 20 70 72 65 66 65 72 65  as their prefere
ba80: 64 20 70 61 72 65 6e 74 20 61 72 65 20 74 68 65  d parent are the
ba90: 0a 09 23 20 73 75 63 63 65 73 73 6f 72 73 20 6f  ..# successors o
baa0: 66 20 61 20 62 72 61 6e 63 68 2e 0a 0a 09 73 65  f a branch....se
bab0: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
bac0: 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d   $branches {','}
bad0: 5d 27 29 0a 09 66 6f 72 65 61 63 68 20 7b 62 69  ]')..foreach {bi
bae0: 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20  d child} [state 
baf0: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
bb00: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
bb10: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c  ashes {..    SEL
bb20: 45 43 54 20 42 2e 62 69 64 2c 20 52 2e 72 69 64  ECT B.bid, R.rid
bb30: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61  ..    FROM   bra
bb40: 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20  nch B, revision 
bb50: 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e  R..    WHERE  B.
bb60: 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20  bid IN $theset  
bb70: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
bb80: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e  o branches of in
bb90: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
bba0: 20 20 20 42 2e 66 69 72 73 74 20 3d 20 52 2e 72     B.first = R.r
bbb0: 69 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20 66  id      -- Get f
bbc0: 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 6f 6e  irst revision on
bbd0: 20 74 68 65 20 62 72 61 6e 63 68 0a 09 7d 5d 5d   the branch..}]]
bbe0: 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20   {..    lappend 
bbf0: 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69  dependencies([li
bc00: 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24  st sym::branch $
bc10: 62 69 64 5d 29 20 5b 6c 69 73 74 20 72 65 76 20  bid]) [list rev 
bc20: 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65  $child]..}..fore
bc30: 61 63 68 20 7b 62 69 64 20 63 68 69 6c 64 7d 20  ach {bid child} 
bc40: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73  [state run [subs
bc50: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e  t -nocommands -n
bc60: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09  obackslashes {..
bc70: 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64      SELECT B.bid
bc80: 2c 20 42 58 2e 62 69 64 0a 09 20 20 20 20 46 52  , BX.bid..    FR
bc90: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70  OM   branch B, p
bca0: 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c  referedparent P,
bcb0: 20 62 72 61 6e 63 68 20 42 58 0a 09 20 20 20 20   branch BX..    
bcc0: 57 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20  WHERE  B.bid IN 
bcd0: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52  $theset     -- R
bce0: 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63  estrict to branc
bcf0: 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  hes of interest.
bd00: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 73 69  .    AND    B.si
bd10: 64 20 3d 20 50 2e 70 69 64 20 20 20 20 20 20 20  d = P.pid       
bd20: 20 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 69 6e   -- Get subordin
bd30: 61 74 65 20 62 72 61 6e 63 68 65 73 20 76 69 61  ate branches via
bd40: 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20   the..    AND   
bd50: 20 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 64 20   BX.sid = P.sid 
bd60: 20 20 20 20 20 20 2d 2d 20 70 72 65 66 65 72 65        -- prefere
bd70: 64 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68 65  d parents of the
bd80: 69 72 20 73 79 6d 62 6f 6c 73 0a 09 7d 5d 5d 20  ir symbols..}]] 
bd90: 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64  {..    lappend d
bda0: 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73  ependencies([lis
bdb0: 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 62  t sym::branch $b
bdc0: 69 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d 3a 3a  id]) [list sym::
bdd0: 62 72 61 6e 63 68 20 24 63 68 69 6c 64 5d 0a 09  branch $child]..
bde0: 7d 0a 09 66 6f 72 65 61 63 68 20 7b 62 69 64 20  }..foreach {bid 
bdf0: 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75  child} [state ru
be00: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d  n [subst -nocomm
be10: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73  ands -nobackslas
be20: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43  hes {..    SELEC
be30: 54 20 42 2e 62 69 64 2c 20 54 2e 74 69 64 0a 09  T B.bid, T.tid..
be40: 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63      FROM   branc
be50: 68 20 42 2c 20 70 72 65 66 65 72 65 64 70 61 72  h B, preferedpar
be60: 65 6e 74 20 50 2c 20 74 61 67 20 54 0a 09 20 20  ent P, tag T..  
be70: 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 49    WHERE  B.bid I
be80: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d  N $theset     --
be90: 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 61   Restrict to bra
bea0: 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73  nches of interes
beb0: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e  t..    AND    B.
bec0: 73 69 64 20 3d 20 50 2e 70 69 64 20 20 20 20 20  sid = P.pid     
bed0: 20 20 20 2d 2d 20 47 65 74 20 73 75 62 6f 72 64     -- Get subord
bee0: 69 6e 61 74 65 20 74 61 67 73 20 76 69 61 20 74  inate tags via t
bef0: 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 54  he..    AND    T
bf00: 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20 20  .sid = P.sid    
bf10: 20 20 20 20 2d 2d 20 70 72 65 66 65 72 65 64 20      -- prefered 
bf20: 70 61 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72  parents of their
bf30: 20 73 79 6d 62 6f 6c 73 0a 09 7d 5d 5d 20 7b 0a   symbols..}]] {.
bf40: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70  .    lappend dep
bf50: 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20  endencies([list 
bf60: 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 62 69 64  sym::branch $bid
bf70: 5d 29 20 5b 6c 69 73 74 20 73 79 6d 3a 3a 74 61  ]) [list sym::ta
bf80: 67 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 72 65  g $child]..}..re
bf90: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
bfa0: 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20  # result = list 
bfb0: 28 63 68 61 6e 67 65 73 65 74 2d 69 64 29 0a 20  (changeset-id). 
bfc0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73     typemethod cs
bfd0: 5f 73 75 63 63 65 73 73 6f 72 73 20 7b 62 72 61  _successors {bra
bfe0: 6e 63 68 65 73 7d 20 7b 0a 20 20 20 20 20 20 20  nches} {.       
bff0: 20 23 20 54 68 69 73 20 69 73 20 61 20 76 61 72   # This is a var
c000: 69 61 6e 74 20 6f 66 20 27 73 75 63 63 65 73 73  iant of 'success
c010: 6f 72 73 27 20 77 68 69 63 68 20 6d 61 70 73 20  ors' which maps 
c020: 74 68 65 20 6c 6f 77 2d 6c 65 76 65 6c 0a 20 20  the low-level.  
c030: 20 20 20 20 20 20 23 20 64 61 74 61 20 64 69 72        # data dir
c040: 65 63 74 6c 79 20 74 6f 20 74 68 65 20 61 73 73  ectly to the ass
c050: 6f 63 69 61 74 65 64 20 63 68 61 6e 67 65 73 65  ociated changese
c060: 74 73 2e 20 49 2e 65 2e 20 69 6e 73 74 65 61 64  ts. I.e. instead
c070: 0a 20 20 20 20 20 20 20 20 23 20 6d 69 6c 6c 69  .        # milli
c080: 6f 6e 73 20 6f 66 20 64 65 70 65 6e 64 65 6e 63  ons of dependenc
c090: 79 20 70 61 69 72 73 20 28 69 6e 20 65 78 74 72  y pairs (in extr
c0a0: 65 6d 65 20 63 61 73 65 73 20 28 45 78 61 6d 70  eme cases (Examp
c0b0: 6c 65 3a 20 54 63 6c 0a 20 20 20 20 20 20 20 20  le: Tcl.        
c0c0: 23 20 43 56 53 29 29 20 77 65 20 72 65 74 75 72  # CVS)) we retur
c0d0: 6e 20 61 20 76 65 72 79 20 73 68 6f 72 74 20 61  n a very short a
c0e0: 6e 64 20 6d 75 63 68 20 6d 6f 72 65 20 6d 61 6e  nd much more man
c0f0: 61 67 65 61 62 6c 65 20 6c 69 73 74 0a 20 20 20  ageable list.   
c100: 20 20 20 20 20 23 20 6f 66 20 63 68 61 6e 67 65       # of change
c110: 73 65 74 73 2e 0a 0a 09 73 65 74 20 74 68 65 73  sets....set thes
c120: 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e  et ('[join $bran
c130: 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 20 20  ches {','}]').  
c140: 20 20 20 20 20 20 72 65 74 75 72 6e 20 5b 73 74        return [st
c150: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d  ate run [subst -
c160: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61  nocommands -noba
c170: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20  ckslashes {..   
c180: 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20   SELECT C.cid.. 
c190: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68     FROM   branch
c1a0: 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c 20   B, revision R, 
c1b0: 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67  csitem CI, chang
c1c0: 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45 52  eset C..    WHER
c1d0: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65  E  B.bid IN $the
c1e0: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72  set     -- Restr
c1f0: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20  ict to branches 
c200: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
c210: 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20   AND    B.first 
c220: 3d 20 52 2e 72 69 64 09 2d 2d 20 47 65 74 20 66  = R.rid.-- Get f
c230: 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 6f 6e  irst revision on
c240: 20 74 68 65 20 62 72 61 6e 63 68 0a 20 20 20 20   the branch.    
c250: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
c260: 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 20 20 20  I.iid = R.rid   
c270: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c      -- Select al
c280: 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20  l changesets.   
c290: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
c2a0: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 2d  C.cid = CI.cid.-
c2b0: 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 69  - containing thi
c2c0: 73 20 72 65 76 69 73 69 6f 6e 0a 20 20 20 20 20  s revision.     
c2d0: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e         AND    C.
c2e0: 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 77 68 69  type = 0..-- whi
c2f0: 63 68 20 61 72 65 20 72 65 76 69 73 69 6f 6e 20  ch are revision 
c300: 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 55  changesets.    U
c310: 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43 54  NION..    SELECT
c320: 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d   C.cid..    FROM
c330: 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65     branch B, pre
c340: 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20 62  feredparent P, b
c350: 72 61 6e 63 68 20 42 58 2c 20 63 73 69 74 65 6d  ranch BX, csitem
c360: 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43   CI, changeset C
c370: 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e 62  ..    WHERE  B.b
c380: 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20  id IN $theset   
c390: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
c3a0: 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74   branches of int
c3b0: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20  erest..    AND  
c3c0: 20 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 64 09    B.sid = P.pid.
c3d0: 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 69 6e 61  -- Get subordina
c3e0: 74 65 20 62 72 61 6e 63 68 65 73 20 76 69 61 20  te branches via 
c3f0: 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20  the..    AND    
c400: 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 64 09 2d  BX.sid = P.sid.-
c410: 2d 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e  - prefered paren
c420: 74 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d 62  ts of their symb
c430: 6f 6c 73 0a 20 20 20 20 20 20 20 20 20 20 20 20  ols.            
c440: 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20  AND    CI.iid = 
c450: 42 58 2e 62 69 64 20 20 20 20 20 20 2d 2d 20 53  BX.bid      -- S
c460: 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65  elect all change
c470: 73 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20  sets.           
c480: 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20   AND    C.cid = 
c490: 43 49 2e 63 69 64 09 2d 2d 20 63 6f 6e 74 61 69  CI.cid.-- contai
c4a0: 6e 69 6e 67 20 74 68 65 20 73 75 62 6f 72 64 69  ning the subordi
c4b0: 6e 61 74 65 20 62 72 61 6e 63 68 65 73 0a 20 20  nate branches.  
c4c0: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20            AND   
c4d0: 20 43 2e 74 79 70 65 20 3d 20 32 09 09 2d 2d 20   C.type = 2..-- 
c4e0: 77 68 69 63 68 20 61 72 65 20 62 72 61 6e 63 68  which are branch
c4f0: 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20   changesets.    
c500: 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43  UNION..    SELEC
c510: 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f  T C.cid..    FRO
c520: 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70 72  M   branch B, pr
c530: 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20  eferedparent P, 
c540: 74 61 67 20 54 2c 20 63 73 69 74 65 6d 20 43 49  tag T, csitem CI
c550: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20  , changeset C.. 
c560: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20     WHERE  B.bid 
c570: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
c580: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72  - Restrict to br
c590: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65  anches of intere
c5a0: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42  st..    AND    B
c5b0: 2e 73 69 64 20 3d 20 50 2e 70 69 64 09 2d 2d 20  .sid = P.pid.-- 
c5c0: 47 65 74 20 73 75 62 6f 72 64 69 6e 61 74 65 20  Get subordinate 
c5d0: 74 61 67 73 20 76 69 61 20 74 68 65 0a 09 20 20  tags via the..  
c5e0: 20 20 41 4e 44 20 20 20 20 54 2e 73 69 64 20 3d    AND    T.sid =
c5f0: 20 50 2e 73 69 64 09 2d 2d 20 70 72 65 66 65 72   P.sid.-- prefer
c600: 65 64 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68  ed parents of th
c610: 65 69 72 20 73 79 6d 62 6f 6c 73 0a 20 20 20 20  eir symbols.    
c620: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43          AND    C
c630: 49 2e 69 69 64 20 3d 20 54 2e 74 69 64 20 20 20  I.iid = T.tid   
c640: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c      -- Select al
c650: 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20  l changesets.   
c660: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20           AND    
c670: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 2d  C.cid = CI.cid.-
c680: 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65  - containing the
c690: 20 73 75 62 6f 72 64 69 6e 61 74 65 20 74 61 67   subordinate tag
c6a0: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e  s.            AN
c6b0: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 31 09  D    C.type = 1.
c6c0: 09 2d 2d 20 77 68 69 63 68 20 61 72 65 20 74 61  .-- which are ta
c6d0: 67 20 63 68 61 6e 67 65 73 65 74 73 0a 09 7d 5d  g changesets..}]
c6e0: 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  ]..return.    }.
c6f0: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20  .    # result = 
c700: 73 79 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20 20 20  symbol name.    
c710: 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f 6c 6f  typemethod cs_lo
c720: 64 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09  d {branches} {..
c730: 23 20 44 65 74 65 72 6d 69 6e 65 73 20 74 68 65  # Determines the
c740: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 79 6d   name of the sym
c750: 62 6f 6c 20 77 68 69 63 68 20 69 73 20 74 68 65  bol which is the
c760: 20 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65   line of..# deve
c770: 6c 6f 70 6d 65 6e 74 20 66 6f 72 20 74 68 65 20  lopment for the 
c780: 62 72 61 6e 63 68 65 73 20 69 6e 20 61 20 63 68  branches in a ch
c790: 61 6e 67 65 73 65 74 2e 0a 0a 09 73 65 74 20 74  angeset....set t
c7a0: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62  heset ('[join $b
c7b0: 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29  ranches {','}]')
c7c0: 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20  ..return [state 
c7d0: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f  run [subst -noco
c7e0: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c  mmands -nobacksl
c7f0: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c  ashes {..    SEL
c800: 45 43 54 0a 09 20 20 20 20 44 49 53 54 49 4e 43  ECT..    DISTINC
c810: 54 20 4c 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52  T L.name..    FR
c820: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 73  OM   branch B, s
c830: 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20 57 48 45  ymbol L..    WHE
c840: 52 45 20 20 42 2e 62 69 64 20 69 6e 20 24 74 68  RE  B.bid in $th
c850: 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d 20 52  eset        -- R
c860: 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63  estrict to branc
c870: 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a  hes of interest.
c880: 09 20 20 20 20 41 4e 44 20 20 20 20 4c 2e 73 69  .    AND    L.si
c890: 64 20 3d 20 42 2e 6c 6f 64 20 20 20 20 20 20 20  d = B.lod       
c8a0: 20 20 20 20 2d 2d 20 47 65 74 20 6c 6f 64 20 73      -- Get lod s
c8b0: 79 6d 62 6f 6c 20 6f 66 20 62 72 61 6e 63 68 0a  ymbol of branch.
c8c0: 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  .}]].    }..    
c8d0: 74 79 70 65 6d 65 74 68 6f 64 20 6c 69 6d 69 74  typemethod limit
c8e0: 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09  s {branches} {..
c8f0: 23 20 4e 6f 74 65 73 2e 20 54 68 69 73 20 6d 65  # Notes. This me
c900: 74 68 6f 64 20 65 78 69 73 74 73 20 6f 6e 6c 79  thod exists only
c910: 20 66 6f 72 20 62 72 61 6e 63 68 65 73 2e 20 49   for branches. I
c920: 74 20 69 73 20 6e 65 65 64 65 64 20 74 6f 0a 09  t is needed to..
c930: 23 20 67 65 74 20 64 65 74 61 69 6c 65 64 20 69  # get detailed i
c940: 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74  nformation about
c950: 20 61 20 62 61 63 6b 77 61 72 64 20 62 72 61 6e   a backward bran
c960: 63 68 2e 20 49 74 20 64 6f 65 73 0a 09 23 20 6e  ch. It does..# n
c970: 6f 74 20 61 70 70 6c 79 20 74 6f 20 74 61 67 73  ot apply to tags
c980: 2c 20 6e 6f 72 20 72 65 76 69 73 69 6f 6e 73 2e  , nor revisions.
c990: 20 54 68 65 20 71 75 65 72 69 65 73 20 63 61 6e   The queries can
c9a0: 20 61 6c 73 6f 0a 09 23 20 72 65 73 74 72 69 63   also..# restric
c9b0: 74 20 74 68 65 6d 73 65 6c 76 65 73 20 74 6f 20  t themselves to 
c9c0: 74 68 65 20 72 65 76 69 73 69 6f 6e 20 73 75 63  the revision suc
c9d0: 65 73 73 6f 72 73 2f 70 72 65 64 65 63 65 73 73  essors/predecess
c9e0: 6f 72 73 0a 09 23 20 6f 66 20 62 72 61 6e 63 68  ors..# of branch
c9f0: 65 73 2c 20 61 73 20 6f 6e 6c 79 20 74 68 65 79  es, as only they
ca00: 20 68 61 76 65 20 6f 72 64 65 72 69 6e 67 20 64   have ordering d
ca10: 61 74 61 20 61 6e 64 20 74 68 75 73 20 63 61 6e  ata and thus can
ca20: 0a 09 23 20 63 61 75 73 65 20 74 68 65 20 62 61  ..# cause the ba
ca30: 63 6b 77 61 72 64 6e 65 73 73 2e 0a 0a 09 73 65  ckwardness....se
ca40: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e  t theset ('[join
ca50: 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d   $branches {','}
ca60: 5d 27 29 0a 0a 09 73 65 74 20 6d 61 78 70 20 5b  ]')...set maxp [
ca70: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74  state run [subst
ca80: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f   -nocommands -no
ca90: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20  backslashes {.. 
caa0: 20 20 20 2d 2d 20 6d 61 78 69 6d 61 6c 20 70 72     -- maximal pr
cab0: 65 64 65 63 65 73 73 6f 72 20 70 6f 73 69 74 69  edecessor positi
cac0: 6f 6e 20 70 65 72 20 62 72 61 6e 63 68 0a 09 20  on per branch.. 
cad0: 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c     SELECT B.bid,
cae0: 20 4d 41 58 20 28 43 4f 2e 70 6f 73 29 0a 09 20   MAX (CO.pos).. 
caf0: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68     FROM   branch
cb00: 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c 20   B, revision R, 
cb10: 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67  csitem CI, chang
cb20: 65 73 65 74 20 43 2c 20 63 73 6f 72 64 65 72 20  eset C, csorder 
cb30: 43 4f 0a 09 20 20 20 20 57 48 45 52 45 20 20 42  CO..    WHERE  B
cb40: 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20  .bid IN $theset 
cb50: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
cb60: 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69  to branches of i
cb70: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
cb80: 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72      B.root = R.r
cb90: 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20  id       -- Get 
cba0: 62 72 61 6e 63 68 20 72 6f 6f 74 20 72 65 76 69  branch root revi
cbb0: 73 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20 20  sions..    AND  
cbc0: 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 72 69 64    CI.iid = R.rid
cbd0: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 63 68         -- Get ch
cbe0: 61 6e 67 65 73 65 74 73 20 63 6f 6e 74 61 69 6e  angesets contain
cbf0: 69 6e 67 20 74 68 65 0a 09 20 20 20 20 41 4e 44  ing the..    AND
cc00: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63      C.cid = CI.c
cc10: 69 64 20 20 20 20 20 20 20 2d 2d 20 72 6f 6f 74  id       -- root
cc20: 20 72 65 76 69 73 69 6f 6e 73 2c 20 77 68 69 63   revisions, whic
cc30: 68 20 61 72 65 0a 09 20 20 20 20 41 4e 44 20 20  h are..    AND  
cc40: 20 20 43 2e 74 79 70 65 20 3d 20 30 20 20 20 20    C.type = 0    
cc50: 20 20 20 20 20 20 20 2d 2d 20 72 65 76 69 73 69         -- revisi
cc60: 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 09 20  on changesets.. 
cc70: 20 20 20 41 4e 44 20 20 20 20 43 4f 2e 63 69 64     AND    CO.cid
cc80: 20 3d 20 43 2e 63 69 64 20 20 20 20 20 20 20 2d   = C.cid       -
cc90: 2d 20 47 65 74 20 74 68 65 69 72 20 74 6f 70 6f  - Get their topo
cca0: 6c 6f 67 69 63 61 6c 20 6f 72 64 65 72 69 6e 67  logical ordering
ccb0: 0a 09 20 20 20 20 47 52 4f 55 50 20 42 59 20 42  ..    GROUP BY B
ccc0: 2e 62 69 64 0a 09 7d 5d 5d 0a 0a 09 73 65 74 20  .bid..}]]...set 
ccd0: 6d 69 6e 73 20 5b 73 74 61 74 65 20 72 75 6e 20  mins [state run 
cce0: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e  [subst -nocomman
ccf0: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65  ds -nobackslashe
cd00: 73 20 7b 0a 09 20 20 20 20 2d 2d 20 6d 69 6e 69  s {..    -- mini
cd10: 6d 61 6c 20 73 75 63 63 65 73 73 6f 72 20 70 6f  mal successor po
cd20: 73 69 74 69 6f 6e 20 70 65 72 20 62 72 61 6e 63  sition per branc
cd30: 68 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e  h..    SELECT B.
cd40: 62 69 64 2c 20 4d 49 4e 20 28 43 4f 2e 70 6f 73  bid, MIN (CO.pos
cd50: 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72  )..    FROM   br
cd60: 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e  anch B, revision
cd70: 20 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63   R, csitem CI, c
cd80: 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 6f 72  hangeset C, csor
cd90: 64 65 72 20 43 4f 0a 09 20 20 20 20 57 48 45 52  der CO..    WHER
cda0: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65  E  B.bid IN $the
cdb0: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72  set     -- Restr
cdc0: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20  ict to branches 
cdd0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
cde0: 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20   AND    B.first 
cdf0: 3d 20 52 2e 72 69 64 20 20 20 20 20 20 2d 2d 20  = R.rid      -- 
ce00: 47 65 74 20 74 68 65 20 66 69 72 73 74 20 72 65  Get the first re
ce10: 76 69 73 69 6f 6e 73 20 6f 6e 20 74 68 65 20 62  visions on the b
ce20: 72 61 6e 63 68 65 73 0a 09 20 20 20 20 41 4e 44  ranches..    AND
ce30: 20 20 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 72      CI.iid = R.r
ce40: 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20  id       -- Get 
ce50: 63 68 61 6e 67 65 73 65 74 73 20 63 6f 6e 74 61  changesets conta
ce60: 69 6e 69 6e 67 20 74 68 65 0a 09 20 20 20 20 41  ining the..    A
ce70: 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49  ND    C.cid = CI
ce80: 2e 63 69 64 09 2d 2d 20 66 69 72 73 74 20 72 65  .cid.-- first re
ce90: 76 69 73 69 6f 6e 73 2c 20 77 68 69 63 68 20 61  visions, which a
cea0: 72 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43  re..    AND    C
ceb0: 2e 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 72 65  .type = 0..-- re
cec0: 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74  vision changeset
ced0: 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 4f  s..    AND    CO
cee0: 2e 63 69 64 20 3d 20 43 2e 63 69 64 09 2d 2d 20  .cid = C.cid.-- 
cef0: 47 65 74 20 74 68 65 69 72 20 74 6f 70 6f 6c 6f  Get their topolo
cf00: 67 69 63 61 6c 20 6f 72 64 65 72 69 6e 67 0a 09  gical ordering..
cf10: 20 20 20 20 47 52 4f 55 50 20 42 59 20 42 2e 62      GROUP BY B.b
cf20: 69 64 0a 09 7d 5d 5d 0a 0a 20 20 20 20 20 20 20  id..}]]..       
cf30: 20 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24 6d   return [list $m
cf40: 61 78 70 20 24 6d 69 6e 73 5d 0a 20 20 20 20 7d  axp $mins].    }
cf50: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
cf60: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
cf70: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20  #############.  
cf80: 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74 69    ## Configurati
cf90: 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20 2d  on..    pragma -
cfa0: 68 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20 6e  hasinstances   n
cfb0: 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e 0a  o ; # singleton.
cfc0: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74      pragma -hast
cfd0: 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b 20  ypeinfo    no ; 
cfe0: 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74 69  # no introspecti
cff0: 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68  on.    pragma -h
d000: 61 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e 6f  astypedestroy no
d010: 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 7d 0a   ; # immortal.}.
d020: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23  .# # ## ### ####
d030: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
d040: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
d050: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23  ##############.#
d060: 23 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61  #..namespace eva
d070: 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  l ::vc::fossil::
d080: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f  import::cvs::pro
d090: 6a 65 63 74 20 7b 0a 20 20 20 20 6e 61 6d 65 73  ject {.    names
d0a0: 70 61 63 65 20 65 78 70 6f 72 74 20 72 65 76 0a  pace export rev.
d0b0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76      namespace ev
d0c0: 61 6c 20 72 65 76 20 7b 0a 09 6e 61 6d 65 73 70  al rev {..namesp
d0d0: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
d0e0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
d0f0: 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d  :cvs::state..nam
d100: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
d110: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
d120: 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69  rt::cvs::integri
d130: 74 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d  ty..namespace im
d140: 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73  port ::vc::tools
d150: 3a 3a 6d 69 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73  ::misc::*..names
d160: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
d170: 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65  ::tools::trouble
d180: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
d190: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  rt ::vc::tools::
d1a0: 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65  log..log registe
d1b0: 72 20 63 73 65 74 73 0a 0a 09 23 20 53 65 74 20  r csets...# Set 
d1c0: 75 70 20 74 68 65 20 68 65 6c 70 65 72 20 73 69  up the helper si
d1d0: 6e 67 6c 65 74 6f 6e 73 0a 09 6e 61 6d 65 73 70  ngletons..namesp
d1e0: 61 63 65 20 65 76 61 6c 20 72 65 76 20 7b 0a 09  ace eval rev {..
d1f0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d      namespace im
d200: 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  port ::vc::fossi
d210: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
d220: 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73  state..    names
d230: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
d240: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
d250: 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79  ::cvs::integrity
d260: 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65  ..}..namespace e
d270: 76 61 6c 20 73 79 6d 3a 3a 74 61 67 20 7b 0a 09  val sym::tag {..
d280: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d      namespace im
d290: 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  port ::vc::fossi
d2a0: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
d2b0: 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73  state..    names
d2c0: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
d2d0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
d2e0: 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79  ::cvs::integrity
d2f0: 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65  ..}..namespace e
d300: 76 61 6c 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20  val sym::branch 
d310: 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65  {..    namespace
d320: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f   import ::vc::fo
d330: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
d340: 73 3a 3a 73 74 61 74 65 0a 09 20 20 20 20 6e 61  s::state..    na
d350: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
d360: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
d370: 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72  ort::cvs::integr
d380: 69 74 79 0a 09 7d 0a 20 20 20 20 7d 0a 7d 0a 0a  ity..}.    }.}..
d390: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23  # # ## ### #####
d3a0: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23   ######## ######
d3b0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
d3c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23  #############.##
d3d0: 20 52 65 61 64 79 0a 0a 70 61 63 6b 61 67 65 20   Ready..package 
d3e0: 70 72 6f 76 69 64 65 20 76 63 3a 3a 66 6f 73 73  provide vc::foss
d3f0: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
d400: 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20 31 2e  :project::rev 1.
d410: 30 0a 72 65 74 75 72 6e 0a                       0.return.