Hex Artifact Content
Not logged in

Artifact 21310ece5288f2e488d96fca2746723a008a1ce7:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [911d56a8c8] - Changesets, extended human readable representation, and tweaking of log output. by aku on 2007-11-27 09:03:07.

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 76 63 3a 3a 74 6f 6f 6c 73  equire vc::tools
0380: 3a 3a 6d 69 73 63 20 20 20 20 20 20 20 20 20 20  ::misc          
0390: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23               ; #
03a0: 20 54 65 78 74 20 66 6f 72 6d 61 74 74 69 6e 67   Text formatting
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 74 72 6f 75   vc::tools::trou
03d0: 62 6c 65 20 20 20 20 20 20 20 20 20 20 20 20 20  ble             
03e0: 20 20 20 20 20 20 20 3b 20 23 20 45 72 72 6f 72         ; # Error
03f0: 20 72 65 70 6f 72 74 69 6e 67 2e 0a 70 61 63 6b   reporting..pack
0400: 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a  age require vc::
0410: 74 6f 6f 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20  tools::log      
0420: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0430: 20 20 3b 20 23 20 55 73 65 72 20 66 65 65 64 62    ; # User feedb
0440: 61 63 6b 2e 0a 70 61 63 6b 61 67 65 20 72 65 71  ack..package req
0450: 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a  uire vc::fossil:
0460: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74  :import::cvs::st
0470: 61 74 65 20 20 20 20 20 20 20 20 3b 20 23 20 53  ate        ; # S
0480: 74 61 74 65 20 73 74 6f 72 61 67 65 2e 0a 70 61  tate storage..pa
0490: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
04a0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
04b0: 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a  ::cvs::project::
04c0: 73 79 6d 20 3b 20 23 20 50 72 6f 6a 65 63 74 20  sym ; # Project 
04d0: 6c 65 76 65 6c 20 73 79 6d 62 6f 6c 73 0a 0a 23  level symbols..#
04e0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
04f0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0500: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
0510: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 0a  ############.##.
0520: 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63  .snit::type ::vc
0530: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
0540: 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a  ::cvs::project::
0550: 72 65 76 20 7b 0a 20 20 20 20 23 20 23 20 23 23  rev {.    # # ##
0560: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
0570: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
0580: 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69 63 20  #.    ## Public 
0590: 41 50 49 0a 0a 20 20 20 20 63 6f 6e 73 74 72 75  API..    constru
05a0: 63 74 6f 72 20 7b 70 72 6f 6a 65 63 74 20 63 73  ctor {project cs
05b0: 74 79 70 65 20 73 72 63 69 64 20 72 65 76 69 73  type srcid revis
05c0: 69 6f 6e 73 20 7b 74 68 65 69 64 20 7b 7d 7d 7d  ions {theid {}}}
05d0: 20 7b 0a 09 69 66 20 7b 24 74 68 65 69 64 20 6e   {..if {$theid n
05e0: 65 20 22 22 7d 20 7b 0a 09 20 20 20 20 73 65 74  e ""} {..    set
05f0: 20 6d 79 69 64 20 24 74 68 65 69 64 0a 09 7d 20   myid $theid..} 
0600: 65 6c 73 65 20 7b 0a 09 20 20 20 20 73 65 74 20  else {..    set 
0610: 6d 79 69 64 20 5b 69 6e 63 72 20 6d 79 63 6f 75  myid [incr mycou
0620: 6e 74 65 72 5d 0a 09 7d 0a 0a 09 73 65 74 20 6d  nter]..}...set m
0630: 79 70 72 6f 6a 65 63 74 20 20 20 24 70 72 6f 6a  yproject   $proj
0640: 65 63 74 0a 09 73 65 74 20 6d 79 74 79 70 65 20  ect..set mytype 
0650: 20 20 20 20 20 24 63 73 74 79 70 65 0a 09 73 65       $cstype..se
0660: 74 20 6d 79 73 72 63 69 64 09 24 73 72 63 69 64  t mysrcid.$srcid
0670: 0a 09 73 65 74 20 6d 79 72 65 76 69 73 69 6f 6e  ..set myrevision
0680: 73 20 24 72 65 76 69 73 69 6f 6e 73 0a 09 73 65  s $revisions..se
0690: 74 20 6d 79 70 6f 73 20 20 20 20 20 20 20 7b 7d  t mypos       {}
06a0: 20 3b 20 23 20 43 6f 6d 6d 69 74 20 6c 6f 63 61   ; # Commit loca
06b0: 74 69 6f 6e 20 69 73 20 6e 6f 74 20 6b 6e 6f 77  tion is not know
06c0: 6e 20 79 65 74 2e 0a 0a 09 23 20 4b 65 65 70 20  n yet....# Keep 
06d0: 74 72 61 63 6b 20 6f 66 20 74 68 65 20 67 65 6e  track of the gen
06e0: 65 72 61 74 65 64 20 63 68 61 6e 67 65 73 65 74  erated changeset
06f0: 73 20 61 6e 64 20 6f 66 20 74 68 65 20 69 6e 76  s and of the inv
0700: 65 72 73 65 0a 09 23 20 6d 61 70 70 69 6e 67 20  erse..# mapping 
0710: 66 72 6f 6d 20 72 65 76 69 73 69 6f 6e 73 20 74  from revisions t
0720: 6f 20 74 68 65 6d 2e 0a 09 6c 61 70 70 65 6e 64  o them...lappend
0730: 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20 20   mychangesets   
0740: 24 73 65 6c 66 0a 09 73 65 74 20 20 20 20 20 6d  $self..set     m
0750: 79 69 64 6d 61 70 28 24 6d 79 69 64 29 20 24 73  yidmap($myid) $s
0760: 65 6c 66 0a 09 66 6f 72 65 61 63 68 20 72 20 24  elf..foreach r $
0770: 72 65 76 69 73 69 6f 6e 73 20 7b 20 6c 61 70 70  revisions { lapp
0780: 65 6e 64 20 6d 79 72 65 76 6d 61 70 28 24 72 29  end myrevmap($r)
0790: 20 24 73 65 6c 66 20 7d 0a 09 72 65 74 75 72 6e   $self }..return
07a0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68  .    }..    meth
07b0: 6f 64 20 73 74 72 20 7b 7d 20 7b 0a 09 73 65 74  od str {} {..set
07c0: 20 73 74 72 20 20 20 20 22 3c 22 0a 09 73 65 74   str    "<"..set
07d0: 20 64 65 74 61 69 6c 20 22 22 0a 09 69 66 20 7b   detail ""..if {
07e0: 24 6d 79 74 79 70 65 20 65 71 20 22 73 79 6d 22  $mytype eq "sym"
07f0: 7d 20 7b 0a 09 20 20 20 20 73 74 72 75 63 74 3a  } {..    struct:
0800: 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 73 74  :list assign [st
0810: 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c 45  ate run {...SELE
0820: 43 54 20 54 2e 6e 61 6d 65 2c 20 53 2e 6e 61 6d  CT T.name, S.nam
0830: 65 0a 09 09 46 52 4f 4d 20 20 20 73 79 6d 74 79  e...FROM   symty
0840: 70 65 20 54 2c 20 73 79 6d 62 6f 6c 20 53 0a 09  pe T, symbol S..
0850: 09 57 48 45 52 45 20 20 53 2e 73 69 64 20 3d 20  .WHERE  S.sid = 
0860: 24 6d 79 73 72 63 69 64 0a 09 09 41 4e 44 20 20  $mysrcid...AND  
0870: 20 20 54 2e 74 69 64 20 3d 20 53 2e 74 79 70 65    T.tid = S.type
0880: 0a 09 20 20 20 20 7d 5d 20 73 74 79 70 65 20 64  ..    }] stype d
0890: 65 74 61 69 6c 0a 09 20 20 20 20 61 70 70 65 6e  etail..    appen
08a0: 64 20 73 74 72 20 24 73 74 79 70 65 20 22 20 22  d str $stype " "
08b0: 0a 09 20 20 20 20 73 65 74 20 64 65 74 61 69 6c  ..    set detail
08c0: 20 22 20 27 24 64 65 74 61 69 6c 27 22 0a 09 7d   " '$detail'"..}
08d0: 0a 09 61 70 70 65 6e 64 20 73 74 72 20 22 24 6d  ..append str "$m
08e0: 79 74 79 70 65 20 24 7b 6d 79 69 64 7d 24 7b 64  ytype ${myid}${d
08f0: 65 74 61 69 6c 7d 3e 22 0a 09 72 65 74 75 72 6e  etail}>"..return
0900: 20 24 73 74 72 0a 20 20 20 20 7d 0a 0a 20 20 20   $str.    }..   
0910: 20 6d 65 74 68 6f 64 20 69 64 20 20 20 20 20 20   method id      
0920: 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 24 6d    {} { return $m
0930: 79 69 64 20 7d 0a 20 20 20 20 6d 65 74 68 6f 64  yid }.    method
0940: 20 72 65 76 69 73 69 6f 6e 73 20 7b 7d 20 7b 20   revisions {} { 
0950: 72 65 74 75 72 6e 20 24 6d 79 72 65 76 69 73 69  return $myrevisi
0960: 6f 6e 73 20 7d 0a 20 20 20 20 6d 65 74 68 6f 64  ons }.    method
0970: 20 64 61 74 61 20 20 20 20 20 20 7b 7d 20 7b 20   data      {} { 
0980: 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24 6d 79  return [list $my
0990: 70 72 6f 6a 65 63 74 20 24 6d 79 74 79 70 65 20  project $mytype 
09a0: 24 6d 79 73 72 63 69 64 5d 20 7d 0a 0a 20 20 20  $mysrcid] }..   
09b0: 20 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c   method bysymbol
09c0: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5b     {} { return [
09d0: 65 78 70 72 20 7b 24 6d 79 74 79 70 65 20 65 71  expr {$mytype eq
09e0: 20 22 73 79 6d 22 7d 5d 20 7d 0a 20 20 20 20 6d   "sym"}] }.    m
09f0: 65 74 68 6f 64 20 62 79 72 65 76 69 73 69 6f 6e  ethod byrevision
0a00: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5b 65 78   {} { return [ex
0a10: 70 72 20 7b 24 6d 79 74 79 70 65 20 65 71 20 22  pr {$mytype eq "
0a20: 72 65 76 22 7d 5d 20 7d 0a 0a 20 20 20 20 6d 65  rev"}] }..    me
0a30: 74 68 6f 64 20 73 65 74 70 6f 73 20 7b 70 7d 20  thod setpos {p} 
0a40: 7b 20 73 65 74 20 6d 79 70 6f 73 20 24 70 20 3b  { set mypos $p ;
0a50: 20 72 65 74 75 72 6e 20 7d 0a 20 20 20 20 6d 65   return }.    me
0a60: 74 68 6f 64 20 70 6f 73 20 20 20 20 7b 7d 20 20  thod pos    {}  
0a70: 7b 20 72 65 74 75 72 6e 20 24 6d 79 70 6f 73 20  { return $mypos 
0a80: 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 69 73  }..    method is
0a90: 62 72 61 6e 63 68 20 7b 7d 20 7b 0a 09 65 72 72  branch {} {..err
0aa0: 6f 72 20 4e 4f 54 2d 55 53 45 44 0a 09 72 65 74  or NOT-USED..ret
0ab0: 75 72 6e 20 5b 65 78 70 72 20 7b 28 24 6d 79 74  urn [expr {($myt
0ac0: 79 70 65 20 65 71 20 22 73 79 6d 22 29 20 26 26  ype eq "sym") &&
0ad0: 0a 09 09 20 20 20 20 20 20 28 24 6d 79 62 72 61  ...      ($mybra
0ae0: 6e 63 68 63 6f 64 65 20 3d 3d 20 5b 73 74 61 74  nchcode == [stat
0af0: 65 20 6f 6e 65 20 7b 0a 09 09 09 20 20 53 45 4c  e one {....  SEL
0b00: 45 43 54 20 74 79 70 65 20 46 52 4f 4d 20 73 79  ECT type FROM sy
0b10: 6d 62 6f 6c 20 57 48 45 52 45 20 73 69 64 20 3d  mbol WHERE sid =
0b20: 20 24 6d 79 73 72 63 69 64 0a 09 09 20 20 20 20   $mysrcid...    
0b30: 20 20 7d 5d 29 7d 5d 0a 20 20 20 20 7d 0a 0a 20    }])}].    }.. 
0b40: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 64 69     # result = di
0b50: 63 74 20 28 72 65 76 69 73 69 6f 6e 20 2d 3e 20  ct (revision -> 
0b60: 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65 74 29  list (changeset)
0b70: 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 73 75 63  ).    method suc
0b80: 63 65 73 73 6f 72 6d 61 70 20 7b 7d 20 7b 0a 09  cessormap {} {..
0b90: 23 20 4e 4f 54 45 20 2f 20 46 55 54 55 52 45 3a  # NOTE / FUTURE:
0ba0: 20 50 6f 73 73 69 62 6c 65 20 62 6f 74 74 6c 65   Possible bottle
0bb0: 6e 65 63 6b 2e 0a 09 61 72 72 61 79 20 73 65 74  neck...array set
0bc0: 20 74 6d 70 20 7b 7d 0a 09 66 6f 72 65 61 63 68   tmp {}..foreach
0bd0: 20 7b 72 65 76 20 63 68 69 6c 64 72 65 6e 7d 20   {rev children} 
0be0: 5b 24 73 65 6c 66 20 6e 65 78 74 6d 61 70 5d 20  [$self nextmap] 
0bf0: 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20 63  {..    foreach c
0c00: 68 69 6c 64 20 24 63 68 69 6c 64 72 65 6e 20 7b  hild $children {
0c10: 0a 09 09 23 20 38 2e 35 20 6c 61 70 70 65 6e 64  ...# 8.5 lappend
0c20: 20 74 6d 70 28 24 72 65 76 29 20 7b 2a 7d 24 6d   tmp($rev) {*}$m
0c30: 79 72 65 76 6d 61 70 28 24 63 68 69 6c 64 29 0a  yrevmap($child).
0c40: 09 09 66 6f 72 65 61 63 68 20 63 73 65 74 20 24  ..foreach cset $
0c50: 6d 79 72 65 76 6d 61 70 28 24 63 68 69 6c 64 29  myrevmap($child)
0c60: 20 7b 0a 09 09 20 20 20 20 6c 61 70 70 65 6e 64   {...    lappend
0c70: 20 74 6d 70 28 24 72 65 76 29 20 24 63 73 65 74   tmp($rev) $cset
0c80: 0a 09 09 7d 0a 09 20 20 20 20 7d 0a 09 20 20 20  ...}..    }..   
0c90: 20 73 65 74 20 74 6d 70 28 24 72 65 76 29 20 5b   set tmp($rev) [
0ca0: 6c 73 6f 72 74 20 2d 75 6e 69 71 75 65 20 24 74  lsort -unique $t
0cb0: 6d 70 28 24 72 65 76 29 5d 0a 09 7d 0a 09 72 65  mp($rev)]..}..re
0cc0: 74 75 72 6e 20 5b 61 72 72 61 79 20 67 65 74 20  turn [array get 
0cd0: 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  tmp].    }..    
0ce0: 6d 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72  method successor
0cf0: 73 20 7b 7d 20 7b 0a 09 23 20 4e 4f 54 45 20 2f  s {} {..# NOTE /
0d00: 20 46 55 54 55 52 45 3a 20 50 6f 73 73 69 62 6c   FUTURE: Possibl
0d10: 65 20 62 6f 74 74 6c 65 6e 65 63 6b 2e 0a 09 73  e bottleneck...s
0d20: 65 74 20 63 73 65 74 73 20 7b 7d 0a 09 66 6f 72  et csets {}..for
0d30: 65 61 63 68 20 7b 5f 20 63 68 69 6c 64 72 65 6e  each {_ children
0d40: 7d 20 5b 24 73 65 6c 66 20 6e 65 78 74 6d 61 70  } [$self nextmap
0d50: 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68  ] {..    foreach
0d60: 20 63 68 69 6c 64 20 24 63 68 69 6c 64 72 65 6e   child $children
0d70: 20 7b 0a 09 09 23 20 38 2e 35 20 6c 61 70 70 65   {...# 8.5 lappe
0d80: 6e 64 20 63 73 65 74 73 20 7b 2a 7d 24 6d 79 72  nd csets {*}$myr
0d90: 65 76 6d 61 70 28 24 63 68 69 6c 64 29 0a 09 09  evmap($child)...
0da0: 66 6f 72 65 61 63 68 20 63 73 65 74 20 24 6d 79  foreach cset $my
0db0: 72 65 76 6d 61 70 28 24 63 68 69 6c 64 29 20 7b  revmap($child) {
0dc0: 0a 09 09 20 20 20 20 6c 61 70 70 65 6e 64 20 63  ...    lappend c
0dd0: 73 65 74 73 20 24 63 73 65 74 0a 09 09 7d 0a 09  sets $cset...}..
0de0: 20 20 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e      }..}..return
0df0: 20 5b 6c 73 6f 72 74 20 2d 75 6e 69 71 75 65 20   [lsort -unique 
0e00: 24 63 73 65 74 73 5d 0a 20 20 20 20 7d 0a 0a 20  $csets].    }.. 
0e10: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 64 69     # result = di
0e20: 63 74 20 28 72 65 76 69 73 69 6f 6e 20 2d 3e 20  ct (revision -> 
0e30: 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65 74 29  list (changeset)
0e40: 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 70 72 65  ).    method pre
0e50: 64 65 63 65 73 73 6f 72 6d 61 70 20 7b 7d 20 7b  decessormap {} {
0e60: 0a 09 23 20 4e 4f 54 45 20 2f 20 46 55 54 55 52  ..# NOTE / FUTUR
0e70: 45 3a 20 50 6f 73 73 69 62 6c 65 20 62 6f 74 74  E: Possible bott
0e80: 6c 65 6e 65 63 6b 2e 0a 09 61 72 72 61 79 20 73  leneck...array s
0e90: 65 74 20 74 6d 70 20 7b 7d 0a 09 66 6f 72 65 61  et tmp {}..forea
0ea0: 63 68 20 7b 72 65 76 20 63 68 69 6c 64 72 65 6e  ch {rev children
0eb0: 7d 20 5b 24 73 65 6c 66 20 70 72 65 6d 61 70 5d  } [$self premap]
0ec0: 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20   {..    foreach 
0ed0: 63 68 69 6c 64 20 24 63 68 69 6c 64 72 65 6e 20  child $children 
0ee0: 7b 0a 09 09 23 20 38 2e 35 20 6c 61 70 70 65 6e  {...# 8.5 lappen
0ef0: 64 20 74 6d 70 28 24 72 65 76 29 20 7b 2a 7d 24  d tmp($rev) {*}$
0f00: 6d 79 72 65 76 6d 61 70 28 24 63 68 69 6c 64 29  myrevmap($child)
0f10: 0a 09 09 66 6f 72 65 61 63 68 20 63 73 65 74 20  ...foreach cset 
0f20: 24 6d 79 72 65 76 6d 61 70 28 24 63 68 69 6c 64  $myrevmap($child
0f30: 29 20 7b 0a 09 09 20 20 20 20 6c 61 70 70 65 6e  ) {...    lappen
0f40: 64 20 74 6d 70 28 24 72 65 76 29 20 24 63 73 65  d tmp($rev) $cse
0f50: 74 0a 09 09 7d 0a 09 20 20 20 20 7d 0a 09 20 20  t...}..    }..  
0f60: 20 20 73 65 74 20 74 6d 70 28 24 72 65 76 29 20    set tmp($rev) 
0f70: 5b 6c 73 6f 72 74 20 2d 75 6e 69 71 75 65 20 24  [lsort -unique $
0f80: 74 6d 70 28 24 72 65 76 29 5d 0a 09 7d 0a 09 72  tmp($rev)]..}..r
0f90: 65 74 75 72 6e 20 5b 61 72 72 61 79 20 67 65 74  eturn [array get
0fa0: 20 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20 20 20   tmp].    }..   
0fb0: 20 23 20 72 65 76 69 73 69 6f 6e 20 2d 3e 20 6c   # revision -> l
0fc0: 69 73 74 20 28 72 65 76 69 73 69 6f 6e 29 0a 20  ist (revision). 
0fd0: 20 20 20 6d 65 74 68 6f 64 20 6e 65 78 74 6d 61     method nextma
0fe0: 70 20 7b 7d 20 7b 0a 09 69 66 20 7b 5b 6c 6c 65  p {} {..if {[lle
0ff0: 6e 67 74 68 20 24 6d 79 6e 65 78 74 6d 61 70 5d  ngth $mynextmap]
1000: 7d 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 6e 65  } { return $myne
1010: 78 74 6d 61 70 20 7d 0a 09 50 75 6c 6c 53 75 63  xtmap }..PullSuc
1020: 63 65 73 73 6f 72 52 65 76 69 73 69 6f 6e 73 20  cessorRevisions 
1030: 74 6d 70 20 24 6d 79 72 65 76 69 73 69 6f 6e 73  tmp $myrevisions
1040: 0a 09 73 65 74 20 6d 79 6e 65 78 74 6d 61 70 20  ..set mynextmap 
1050: 5b 61 72 72 61 79 20 67 65 74 20 74 6d 70 5d 0a  [array get tmp].
1060: 09 72 65 74 75 72 6e 20 24 6d 79 6e 65 78 74 6d  .return $mynextm
1070: 61 70 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  ap.    }..    # 
1080: 72 65 76 69 73 69 6f 6e 20 2d 3e 20 6c 69 73 74  revision -> list
1090: 20 28 72 65 76 69 73 69 6f 6e 29 0a 20 20 20 20   (revision).    
10a0: 6d 65 74 68 6f 64 20 70 72 65 6d 61 70 20 7b 7d  method premap {}
10b0: 20 7b 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68   {..if {[llength
10c0: 20 24 6d 79 70 72 65 6d 61 70 5d 7d 20 7b 20 72   $mypremap]} { r
10d0: 65 74 75 72 6e 20 24 6d 79 70 72 65 6d 61 70 20  eturn $mypremap 
10e0: 7d 0a 09 50 75 6c 6c 50 72 65 64 65 63 65 73 73  }..PullPredecess
10f0: 6f 72 52 65 76 69 73 69 6f 6e 73 20 74 6d 70 20  orRevisions tmp 
1100: 24 6d 79 72 65 76 69 73 69 6f 6e 73 0a 09 73 65  $myrevisions..se
1110: 74 20 6d 79 70 72 65 6d 61 70 20 5b 61 72 72 61  t mypremap [arra
1120: 79 20 67 65 74 20 74 6d 70 5d 0a 09 72 65 74 75  y get tmp]..retu
1130: 72 6e 20 24 6d 79 70 72 65 6d 61 70 0a 20 20 20  rn $mypremap.   
1140: 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 62   }..    method b
1150: 72 65 61 6b 69 6e 74 65 72 6e 61 6c 64 65 70 65  reakinternaldepe
1160: 6e 64 65 6e 63 69 65 73 20 7b 7d 20 7b 0a 09 23  ndencies {} {..#
1170: 20 54 68 69 73 20 6d 65 74 68 6f 64 20 69 6e 73   This method ins
1180: 70 65 63 74 73 20 74 68 65 20 63 68 61 6e 67 65  pects the change
1190: 73 65 74 73 20 66 6f 72 20 69 6e 74 65 72 6e 61  sets for interna
11a0: 6c 0a 09 23 20 64 65 70 65 6e 64 65 6e 63 69 65  l..# dependencie
11b0: 73 2e 20 4e 6f 74 68 69 6e 67 20 69 73 20 64 6f  s. Nothing is do
11c0: 6e 65 20 69 66 20 74 68 65 72 65 20 61 72 65 20  ne if there are 
11d0: 6e 6f 0a 09 23 20 73 75 63 68 2e 20 4f 74 68 65  no..# such. Othe
11e0: 72 77 69 73 65 20 74 68 65 20 63 68 61 6e 67 65  rwise the change
11f0: 73 65 74 20 69 73 20 73 70 6c 69 74 20 69 6e 74  set is split int
1200: 6f 20 61 20 73 65 74 20 6f 66 0a 09 23 20 66 72  o a set of..# fr
1210: 61 67 6d 65 6e 74 73 20 77 69 74 68 6f 75 74 20  agments without 
1220: 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65  internal depende
1230: 6e 63 69 65 73 2c 20 74 72 61 6e 73 66 6f 72 6d  ncies, transform
1240: 69 6e 67 20 74 68 65 0a 09 23 20 69 6e 74 65 72  ing the..# inter
1250: 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73  nal dependencies
1260: 20 69 6e 74 6f 20 65 78 74 65 72 6e 61 6c 20 6f   into external o
1270: 6e 65 73 2e 20 54 68 65 20 6e 65 77 20 63 68 61  nes. The new cha
1280: 6e 67 65 73 65 74 73 0a 09 23 20 61 72 65 20 61  ngesets..# are a
1290: 64 64 65 64 20 74 6f 20 74 68 65 20 6c 69 73 74  dded to the list
12a0: 20 6f 66 20 61 6c 6c 20 63 68 61 6e 67 65 73 65   of all changese
12b0: 74 73 2e 0a 0a 09 23 20 57 65 20 70 65 72 66 6f  ts....# We perfo
12c0: 72 6d 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79  rm all necessary
12d0: 20 73 70 6c 69 74 73 20 69 6e 20 6f 6e 65 20 67   splits in one g
12e0: 6f 2c 20 69 6e 73 74 65 61 64 20 6f 66 20 6f 6e  o, instead of on
12f0: 6c 79 0a 09 23 20 6f 6e 65 2e 20 54 68 65 20 70  ly..# one. The p
1300: 72 65 76 69 6f 75 73 20 61 6c 67 6f 72 69 74 68  revious algorith
1310: 6d 2c 20 61 64 61 70 74 65 64 20 66 72 6f 6d 20  m, adapted from 
1320: 63 76 73 32 73 76 6e 2c 20 63 6f 6d 70 75 74 65  cvs2svn, compute
1330: 64 0a 09 23 20 61 20 6c 6f 74 20 6f 66 20 73 74  d..# a lot of st
1340: 61 74 65 20 77 68 69 63 68 20 77 61 73 20 74 68  ate which was th
1350: 72 6f 77 6e 20 61 77 61 79 20 61 6e 64 20 74 68  rown away and th
1360: 65 6e 20 63 6f 6d 70 75 74 65 64 20 61 67 61 69  en computed agai
1370: 6e 0a 09 23 20 66 6f 72 20 65 61 63 68 20 6f 66  n..# for each of
1380: 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73 2e 20   the fragments. 
1390: 49 74 20 73 68 6f 75 6c 64 20 62 65 20 65 61 73  It should be eas
13a0: 69 65 72 20 74 6f 20 75 70 64 61 74 65 20 61 6e  ier to update an
13b0: 64 0a 09 23 20 72 65 75 73 65 20 74 68 61 74 20  d..# reuse that 
13c0: 73 74 61 74 65 2e 0a 0a 09 23 20 54 68 65 20 63  state....# The c
13d0: 6f 64 65 20 63 68 65 63 6b 73 20 6f 6e 6c 79 20  ode checks only 
13e0: 73 75 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65  sucessor depende
13f0: 6e 63 69 65 73 2c 20 61 73 20 74 68 69 73 0a 09  ncies, as this..
1400: 23 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20  # automatically 
1410: 63 6f 76 65 72 73 20 74 68 65 20 70 72 65 64 65  covers the prede
1420: 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63  cessor dependenc
1430: 69 65 73 20 61 73 20 77 65 6c 6c 20 28 41 0a 09  ies as well (A..
1440: 23 20 73 75 63 63 65 73 73 6f 72 20 64 65 70 65  # successor depe
1450: 6e 64 65 6e 63 79 20 61 20 2d 3e 20 62 20 69 73  ndency a -> b is
1460: 20 61 6c 73 6f 20 61 20 70 72 65 64 65 63 65 73   also a predeces
1470: 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 79 0a 09  sor dependency..
1480: 23 20 62 20 2d 3e 20 61 29 2e 0a 0a 09 23 20 41  # b -> a)....# A
1490: 72 72 61 79 20 6f 66 20 64 65 70 65 6e 64 65 6e  rray of dependen
14a0: 63 69 65 73 20 28 70 61 72 65 6e 74 20 2d 3e 20  cies (parent -> 
14b0: 63 68 69 6c 64 29 2e 20 54 68 69 73 20 69 73 20  child). This is 
14c0: 70 75 6c 6c 65 64 20 66 72 6f 6d 0a 09 23 20 74  pulled from..# t
14d0: 68 65 20 73 74 61 74 65 2c 20 61 6e 64 20 6c 69  he state, and li
14e0: 6d 69 74 65 64 20 74 6f 20 73 75 63 63 65 73 73  mited to success
14f0: 6f 72 73 20 77 69 74 68 69 6e 20 74 68 65 20 63  ors within the c
1500: 68 61 6e 67 65 73 65 74 2e 0a 0a 09 61 72 72 61  hangeset....arra
1510: 79 20 73 65 74 20 64 65 70 65 6e 64 65 6e 63 69  y set dependenci
1520: 65 73 20 7b 7d 0a 09 50 75 6c 6c 49 6e 74 65 72  es {}..PullInter
1530: 6e 61 6c 53 75 63 63 65 73 73 6f 72 52 65 76 69  nalSuccessorRevi
1540: 73 69 6f 6e 73 20 64 65 70 65 6e 64 65 6e 63 69  sions dependenci
1550: 65 73 20 24 6d 79 72 65 76 69 73 69 6f 6e 73 0a  es $myrevisions.
1560: 09 69 66 20 7b 21 5b 61 72 72 61 79 20 73 69 7a  .if {![array siz
1570: 65 20 64 65 70 65 6e 64 65 6e 63 69 65 73 5d 7d  e dependencies]}
1580: 20 7b 72 65 74 75 72 6e 20 30 7d 20 3b 20 23 20   {return 0} ; # 
1590: 4e 6f 74 68 69 6e 67 20 74 6f 20 62 72 65 61 6b  Nothing to break
15a0: 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 35 20  ....log write 5 
15b0: 63 73 65 74 73 20 2e 2e 2e 5b 24 73 65 6c 66 20  csets ...[$self 
15c0: 73 74 72 5d 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  str]............
15d0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
15e0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
15f0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 09 23 20  ..............# 
1600: 57 65 20 68 61 76 65 20 69 6e 74 65 72 6e 61 6c  We have internal
1610: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 74 6f   dependencies to
1620: 20 62 72 65 61 6b 2e 20 57 65 20 6e 6f 77 20 69   break. We now i
1630: 74 65 72 61 74 65 20 6f 76 65 72 0a 09 23 20 61  terate over..# a
1640: 6c 6c 20 70 6f 73 69 74 69 6f 6e 73 20 69 6e 20  ll positions in 
1650: 74 68 65 20 6c 69 73 74 20 28 77 68 69 63 68 20  the list (which 
1660: 69 73 20 63 68 72 6f 6e 6f 6c 6f 67 69 63 61 6c  is chronological
1670: 2c 20 61 74 20 6c 65 61 73 74 0a 09 23 20 61 73  , at least..# as
1680: 20 66 61 72 20 61 73 20 74 68 65 20 74 69 6d 65   far as the time
1690: 73 74 61 6d 70 73 20 61 72 65 20 63 6f 72 72 65  stamps are corre
16a0: 63 74 20 61 6e 64 20 75 6e 69 71 75 65 29 20 61  ct and unique) a
16b0: 6e 64 0a 09 23 20 64 65 74 65 72 6d 69 6e 65 20  nd..# determine 
16c0: 74 68 65 20 62 65 73 74 20 70 6f 73 69 74 69 6f  the best positio
16d0: 6e 20 66 6f 72 20 74 68 65 20 62 72 65 61 6b 2c  n for the break,
16e0: 20 62 79 20 74 72 79 69 6e 67 20 74 6f 0a 09 23   by trying to..#
16f0: 20 62 72 65 61 6b 20 61 73 20 6d 61 6e 79 20 64   break as many d
1700: 65 70 65 6e 64 65 6e 63 69 65 73 20 61 73 20 70  ependencies as p
1710: 6f 73 73 69 62 6c 65 20 69 6e 20 6f 6e 65 20 67  ossible in one g
1720: 6f 2e 20 57 68 65 6e 20 61 0a 09 23 20 62 72 65  o. When a..# bre
1730: 61 6b 20 77 61 73 20 66 6f 75 6e 64 20 74 68 69  ak was found thi
1740: 73 20 69 73 20 72 65 64 6f 6e 65 20 66 6f 72 20  s is redone for 
1750: 74 68 65 20 66 72 61 67 6d 65 6e 74 73 20 63 6f  the fragments co
1760: 6d 69 6e 67 20 61 6e 64 0a 09 23 20 61 66 74 65  ming and..# afte
1770: 72 2c 20 61 66 74 65 72 20 75 70 64 69 6e 67 20  r, after upding 
1780: 74 68 65 20 63 72 6f 73 73 69 6e 67 20 69 6e 66  the crossing inf
1790: 6f 72 6d 61 74 69 6f 6e 2e 0a 0a 09 23 20 44 61  ormation....# Da
17a0: 74 61 20 73 74 72 75 63 74 75 72 65 73 3a 0a 09  ta structures:..
17b0: 23 20 4d 61 70 3a 20 20 50 4f 53 20 20 20 72 65  # Map:  POS   re
17c0: 76 69 73 69 6f 6e 20 69 64 20 20 20 20 20 20 2d  vision id      -
17d0: 3e 20 70 6f 73 69 74 69 6f 6e 20 69 6e 20 6c 69  > position in li
17e0: 73 74 2e 0a 09 23 20 20 20 20 20 20 20 43 52 4f  st...#       CRO
17f0: 53 53 20 70 6f 73 69 74 69 6f 6e 20 69 6e 20 6c  SS position in l
1800: 69 73 74 20 2d 3e 20 6e 75 6d 62 65 72 20 6f 66  ist -> number of
1810: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 63 72   dependencies cr
1820: 6f 73 73 69 6e 67 20 69 74 0a 09 23 20 20 20 20  ossing it..#    
1830: 20 20 20 44 45 50 43 20 20 64 65 70 65 6e 64 65     DEPC  depende
1840: 6e 63 79 20 20 20 20 20 20 20 2d 3e 20 70 6f 73  ncy       -> pos
1850: 69 74 69 6f 6e 73 20 69 74 20 63 72 6f 73 73 65  itions it crosse
1860: 73 0a 09 23 20 4c 69 73 74 3a 20 52 41 4e 47 45  s..# List: RANGE
1870: 20 4f 66 20 74 68 65 20 70 6f 73 69 74 69 6f 6e   Of the position
1880: 73 20 69 74 73 65 6c 66 2e 0a 09 23 20 41 20 64  s itself...# A d
1890: 65 70 65 6e 64 65 6e 63 79 20 69 73 20 61 20 73  ependency is a s
18a0: 69 6e 67 6c 65 2d 65 6c 65 6d 65 6e 74 20 6d 61  ingle-element ma
18b0: 70 20 70 61 72 65 6e 74 20 2d 3e 20 63 68 69 6c  p parent -> chil
18c0: 64 0a 0a 09 49 6e 69 74 69 61 6c 69 7a 65 42 72  d...InitializeBr
18d0: 65 61 6b 53 74 61 74 65 20 24 6d 79 72 65 76 69  eakState $myrevi
18e0: 73 69 6f 6e 73 0a 0a 09 73 65 74 20 66 72 61 67  sions...set frag
18f0: 6d 65 6e 74 73 20 7b 7d 0a 09 73 65 74 20 70 65  ments {}..set pe
1900: 6e 64 69 6e 67 20 20 20 5b 6c 69 73 74 20 24 72  nding   [list $r
1910: 61 6e 67 65 5d 0a 09 73 65 74 20 61 74 20 20 20  ange]..set at   
1920: 20 20 20 20 20 30 0a 09 61 72 72 61 79 20 73 65       0..array se
1930: 74 20 62 72 65 61 6b 73 20 7b 7d 0a 0a 09 77 68  t breaks {}...wh
1940: 69 6c 65 20 7b 24 61 74 20 3c 20 5b 6c 6c 65 6e  ile {$at < [llen
1950: 67 74 68 20 24 70 65 6e 64 69 6e 67 5d 7d 20 7b  gth $pending]} {
1960: 0a 09 20 20 20 20 73 65 74 20 63 75 72 72 65 6e  ..    set curren
1970: 74 20 5b 6c 69 6e 64 65 78 20 24 70 65 6e 64 69  t [lindex $pendi
1980: 6e 67 20 24 61 74 5d 0a 0a 09 20 20 20 20 6c 6f  ng $at]...    lo
1990: 67 20 77 72 69 74 65 20 36 20 63 73 65 74 73 20  g write 6 csets 
19a0: 22 2e 20 2e 20 2e 2e 20 2e 2e 2e 20 2e 2e 2e 2e  ". . .. ... ....
19b0: 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e  . ........ .....
19c0: 2e 2e 2e 2e 2e 2e 2e 2e 22 0a 09 20 20 20 20 6c  ........"..    l
19d0: 6f 67 20 77 72 69 74 65 20 36 20 63 73 65 74 73  og write 6 csets
19e0: 20 22 53 63 68 65 64 75 6c 65 64 20 20 20 5b 6a   "Scheduled   [j
19f0: 6f 69 6e 20 5b 50 52 73 20 5b 6c 72 61 6e 67 65  oin [PRs [lrange
1a00: 20 24 70 65 6e 64 69 6e 67 20 24 61 74 20 65 6e   $pending $at en
1a10: 64 5d 5d 20 7b 20 7d 5d 22 0a 09 20 20 20 20 6c  d]] { }]"..    l
1a20: 6f 67 20 77 72 69 74 65 20 36 20 63 73 65 74 73  og write 6 csets
1a30: 20 22 43 6f 6e 73 69 64 65 72 69 6e 67 20 5b 50   "Considering [P
1a40: 52 20 24 63 75 72 72 65 6e 74 5d 20 5c 5b 24 61  R $current] \[$a
1a50: 74 2f 5b 6c 6c 65 6e 67 74 68 20 24 70 65 6e 64  t/[llength $pend
1a60: 69 6e 67 5d 5c 5d 22 0a 0a 09 20 20 20 20 73 65  ing]\]"...    se
1a70: 74 20 62 65 73 74 20 5b 46 69 6e 64 42 65 73 74  t best [FindBest
1a80: 42 72 65 61 6b 20 24 63 75 72 72 65 6e 74 5d 0a  Break $current].
1a90: 0a 09 20 20 20 20 69 66 20 7b 24 62 65 73 74 20  ..    if {$best 
1aa0: 3c 20 30 7d 20 7b 0a 09 09 23 20 54 68 65 20 69  < 0} {...# The i
1ab0: 6e 73 70 65 63 74 65 64 20 72 61 6e 67 65 20 68  nspected range h
1ac0: 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61 6c 0a 09  as no internal..
1ad0: 09 23 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e  .# dependencies.
1ae0: 20 54 68 69 73 20 69 73 20 61 20 63 6f 6d 70 6c   This is a compl
1af0: 65 74 65 20 66 72 61 67 6d 65 6e 74 2e 0a 09 09  ete fragment....
1b00: 6c 61 70 70 65 6e 64 20 66 72 61 67 6d 65 6e 74  lappend fragment
1b10: 73 20 24 63 75 72 72 65 6e 74 0a 0a 09 09 6c 6f  s $current....lo
1b20: 67 20 77 72 69 74 65 20 36 20 63 73 65 74 73 20  g write 6 csets 
1b30: 22 4e 6f 20 62 72 65 61 6b 73 2c 20 66 69 6e 61  "No breaks, fina
1b40: 6c 22 0a 09 20 20 20 20 7d 20 65 6c 73 65 20 7b  l"..    } else {
1b50: 0a 09 09 23 20 53 70 6c 69 74 20 74 68 65 20 72  ...# Split the r
1b60: 61 6e 67 65 20 61 6e 64 20 73 63 68 65 64 75 6c  ange and schedul
1b70: 65 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 20  e the resulting 
1b80: 66 72 61 67 6d 65 6e 74 73 0a 09 09 23 20 66 6f  fragments...# fo
1b90: 72 20 66 75 72 74 68 65 72 20 69 6e 73 70 65 63  r further inspec
1ba0: 74 69 6f 6e 2e 20 52 65 6d 65 6d 62 65 72 20 74  tion. Remember t
1bb0: 68 65 20 6e 75 6d 62 65 72 20 6f 66 0a 09 09 23  he number of...#
1bc0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 63 75   dependencies cu
1bd0: 74 20 62 65 66 6f 72 65 20 77 65 20 72 65 6d 6f  t before we remo
1be0: 76 65 20 74 68 65 6d 20 66 72 6f 6d 0a 09 09 23  ve them from...#
1bf0: 20 63 6f 6e 73 69 64 65 72 61 74 69 6f 6e 2c 20   consideration, 
1c00: 66 6f 72 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f  for documentatio
1c10: 6e 20 6c 61 74 65 72 2e 0a 0a 09 09 73 65 74 20  n later.....set 
1c20: 62 72 65 61 6b 73 28 24 62 65 73 74 29 20 24 63  breaks($best) $c
1c30: 72 6f 73 73 28 24 62 65 73 74 29 0a 0a 09 09 6c  ross($best)....l
1c40: 6f 67 20 77 72 69 74 65 20 36 20 63 73 65 74 73  og write 6 csets
1c50: 20 22 42 65 73 74 20 62 72 65 61 6b 20 40 20 24   "Best break @ $
1c60: 62 65 73 74 2c 20 63 75 74 74 69 6e 67 20 5b 6e  best, cutting [n
1c70: 73 70 20 24 63 72 6f 73 73 28 24 62 65 73 74 29  sp $cross($best)
1c80: 20 64 65 70 65 6e 64 65 6e 63 79 20 64 65 70 65   dependency depe
1c90: 6e 64 65 6e 63 69 65 73 5d 22 0a 0a 09 09 23 20  ndencies]"....# 
1ca0: 4e 6f 74 65 3a 20 54 68 65 20 76 61 6c 75 65 20  Note: The value 
1cb0: 6f 66 20 62 65 73 74 20 69 73 20 61 6e 20 61 62  of best is an ab
1cc0: 6f 6c 75 74 65 20 6c 6f 63 61 74 69 6f 6e 20 69  olute location i
1cd0: 6e 0a 09 09 23 20 6d 79 72 65 76 69 73 69 6f 6e  n...# myrevision
1ce0: 73 2e 20 55 73 65 20 74 68 65 20 73 74 61 72 74  s. Use the start
1cf0: 20 6f 66 20 63 75 72 72 65 6e 74 20 74 6f 20 6d   of current to m
1d00: 61 6b 65 20 69 74 20 61 6e 0a 09 09 23 20 69 6e  ake it an...# in
1d10: 64 65 78 20 61 62 73 6f 6c 75 74 65 20 74 6f 20  dex absolute to 
1d20: 63 75 72 72 65 6e 74 2e 0a 0a 09 09 73 65 74 20  current.....set 
1d30: 62 72 65 6c 20 5b 65 78 70 72 20 7b 24 62 65 73  brel [expr {$bes
1d40: 74 20 2d 20 5b 6c 69 6e 64 65 78 20 24 63 75 72  t - [lindex $cur
1d50: 72 65 6e 74 20 30 5d 7d 5d 0a 09 09 73 65 74 20  rent 0]}]...set 
1d60: 62 6e 65 78 74 20 24 62 72 65 6c 20 3b 20 69 6e  bnext $brel ; in
1d70: 63 72 20 62 6e 65 78 74 0a 09 09 73 65 74 20 66  cr bnext...set f
1d80: 72 61 67 62 65 66 6f 72 65 20 5b 6c 72 61 6e 67  ragbefore [lrang
1d90: 65 20 24 63 75 72 72 65 6e 74 20 30 20 24 62 72  e $current 0 $br
1da0: 65 6c 5d 0a 09 09 73 65 74 20 66 72 61 67 61 66  el]...set fragaf
1db0: 74 65 72 20 20 5b 6c 72 61 6e 67 65 20 24 63 75  ter  [lrange $cu
1dc0: 72 72 65 6e 74 20 24 62 6e 65 78 74 20 65 6e 64  rrent $bnext end
1dd0: 5d 0a 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 36  ]....log write 6
1de0: 20 63 73 65 74 73 20 22 4e 65 77 20 70 69 65 63   csets "New piec
1df0: 65 73 20 20 5b 50 52 20 24 66 72 61 67 62 65 66  es  [PR $fragbef
1e00: 6f 72 65 5d 20 5b 50 52 20 24 66 72 61 67 61 66  ore] [PR $fragaf
1e10: 74 65 72 5d 22 0a 0a 09 09 69 66 20 7b 21 5b 6c  ter]"....if {![l
1e20: 6c 65 6e 67 74 68 20 24 66 72 61 67 62 65 66 6f  length $fragbefo
1e30: 72 65 5d 7d 20 7b 0a 09 09 20 20 20 20 74 72 6f  re]} {...    tro
1e40: 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 22 54  uble internal "T
1e50: 72 69 65 64 20 74 6f 20 73 70 6c 69 74 20 6f 66  ried to split of
1e60: 66 20 61 20 7a 65 72 6f 2d 6c 65 6e 67 74 68 20  f a zero-length 
1e70: 66 72 61 67 6d 65 6e 74 20 61 74 20 74 68 65 20  fragment at the 
1e80: 62 65 67 69 6e 6e 69 6e 67 22 0a 09 09 7d 0a 09  beginning"...}..
1e90: 09 69 66 20 7b 21 5b 6c 6c 65 6e 67 74 68 20 24  .if {![llength $
1ea0: 66 72 61 67 61 66 74 65 72 5d 7d 20 7b 0a 09 09  fragafter]} {...
1eb0: 20 20 20 20 74 72 6f 75 62 6c 65 20 69 6e 74 65      trouble inte
1ec0: 72 6e 61 6c 20 22 54 72 69 65 64 20 74 6f 20 73  rnal "Tried to s
1ed0: 70 6c 69 74 20 6f 66 66 20 61 20 7a 65 72 6f 2d  plit off a zero-
1ee0: 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 20  length fragment 
1ef0: 61 74 20 74 68 65 20 65 6e 64 22 0a 09 09 7d 0a  at the end"...}.
1f00: 0a 09 09 6c 61 70 70 65 6e 64 20 70 65 6e 64 69  ...lappend pendi
1f10: 6e 67 20 24 66 72 61 67 62 65 66 6f 72 65 20 24  ng $fragbefore $
1f20: 66 72 61 67 61 66 74 65 72 0a 09 09 43 75 74 41  fragafter...CutA
1f30: 74 20 24 62 65 73 74 0a 09 20 20 20 20 7d 0a 0a  t $best..    }..
1f40: 09 20 20 20 20 69 6e 63 72 20 61 74 0a 09 7d 0a  .    incr at..}.
1f50: 0a 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73  ..log write 6 cs
1f60: 65 74 73 20 22 2e 20 2e 20 2e 2e 20 2e 2e 2e 20  ets ". . .. ... 
1f70: 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e  ..... ........ .
1f80: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 22 0a 0a 09  ............"...
1f90: 23 20 28 2a 29 20 57 65 20 63 6c 65 61 72 20 6f  # (*) We clear o
1fa0: 75 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65  ut the associate
1fb0: 64 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d 79  d part of the my
1fc0: 72 65 76 6d 61 70 0a 09 23 20 69 6e 2d 6d 65 6d  revmap..# in-mem
1fd0: 6f 72 79 20 69 6e 64 65 78 20 69 6e 20 70 72 65  ory index in pre
1fe0: 70 61 72 61 74 69 6f 6e 20 66 6f 72 20 6e 65 77  paration for new
1ff0: 20 64 61 74 61 2e 20 41 20 73 69 6d 70 6c 65 20   data. A simple 
2000: 75 6e 73 65 74 0a 09 23 20 69 73 20 65 6e 6f 75  unset..# is enou
2010: 67 68 2c 20 77 65 20 68 61 76 65 20 6e 6f 20 73  gh, we have no s
2020: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73  ymbol changesets
2030: 20 61 74 20 74 68 69 73 20 74 69 6d 65 2c 20 61   at this time, a
2040: 6e 64 0a 09 23 20 74 68 75 73 20 6e 65 76 65 72  nd..# thus never
2050: 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20 72   more than one r
2060: 65 66 65 72 65 6e 63 65 20 69 6e 20 74 68 65 20  eference in the 
2070: 6c 69 73 74 2e 0a 0a 09 66 6f 72 65 61 63 68 20  list....foreach 
2080: 72 20 24 6d 79 72 65 76 69 73 69 6f 6e 73 20 7b  r $myrevisions {
2090: 20 75 6e 73 65 74 20 6d 79 72 65 76 6d 61 70 28   unset myrevmap(
20a0: 24 72 29 20 7d 0a 0a 09 23 20 43 72 65 61 74 65  $r) }...# Create
20b0: 20 63 68 61 6e 67 65 73 65 74 73 20 66 6f 72 20   changesets for 
20c0: 74 68 65 20 66 72 61 67 6d 65 6e 74 73 2c 20 72  the fragments, r
20d0: 65 75 73 69 6e 67 20 74 68 65 20 63 75 72 72 65  eusing the curre
20e0: 6e 74 20 6f 6e 65 0a 09 23 20 66 6f 72 20 74 68  nt one..# for th
20f0: 65 20 66 69 72 73 74 20 66 72 61 67 6d 65 6e 74  e first fragment
2100: 2e 20 57 65 20 73 6f 72 74 20 74 68 65 6d 20 69  . We sort them i
2110: 6e 20 6f 72 64 65 72 20 74 6f 20 61 6c 6c 6f 77  n order to allow
2120: 0a 09 23 20 63 68 65 63 6b 69 6e 67 20 66 6f 72  ..# checking for
2130: 20 67 61 70 73 20 61 6e 64 20 6e 69 63 65 20 6d   gaps and nice m
2140: 65 73 73 61 67 65 73 2e 0a 0a 09 73 65 74 20 66  essages....set f
2150: 72 61 67 6d 65 6e 74 73 20 5b 6c 73 6f 72 74 20  ragments [lsort 
2160: 2d 69 6e 64 65 78 20 30 20 2d 69 6e 74 65 67 65  -index 0 -intege
2170: 72 20 24 66 72 61 67 6d 65 6e 74 73 5d 0a 0a 09  r $fragments]...
2180: 23 70 75 74 73 20 5c 74 2e 5b 6a 6f 69 6e 20 5b  #puts \t.[join [
2190: 50 52 73 20 24 66 72 61 67 6d 65 6e 74 73 5d 20  PRs $fragments] 
21a0: 2e 5c 6e 5c 74 2e 5d 2e 0a 0a 09 42 6f 72 64 65  .\n\t.]....Borde
21b0: 72 20 5b 6c 69 6e 64 65 78 20 24 66 72 61 67 6d  r [lindex $fragm
21c0: 65 6e 74 73 20 30 5d 20 66 69 72 73 74 73 20 66  ents 0] firsts f
21d0: 69 72 73 74 65 0a 0a 09 69 66 20 7b 24 66 69 72  irste...if {$fir
21e0: 73 74 73 20 21 3d 20 30 7d 20 7b 0a 09 20 20 20  sts != 0} {..   
21f0: 20 74 72 6f 75 62 6c 65 20 69 6e 74 65 72 6e 61   trouble interna
2200: 6c 20 22 42 61 64 20 66 72 61 67 6d 65 6e 74 20  l "Bad fragment 
2210: 73 74 61 72 74 20 40 20 24 66 69 72 73 74 73 2c  start @ $firsts,
2220: 20 67 61 70 2c 20 6f 72 20 62 65 66 6f 72 65 20   gap, or before 
2230: 62 65 67 69 6e 6e 69 6e 67 20 6f 66 20 74 68 65  beginning of the
2240: 20 72 61 6e 67 65 22 0a 09 7d 0a 0a 09 73 65 74   range"..}...set
2250: 20 6c 61 73 74 65 20 24 66 69 72 73 74 65 0a 09   laste $firste..
2260: 66 6f 72 65 61 63 68 20 66 72 61 67 6d 65 6e 74  foreach fragment
2270: 20 5b 6c 72 61 6e 67 65 20 24 66 72 61 67 6d 65   [lrange $fragme
2280: 6e 74 73 20 31 20 65 6e 64 5d 20 7b 0a 09 20 20  nts 1 end] {..  
2290: 20 20 42 6f 72 64 65 72 20 24 66 72 61 67 6d 65    Border $fragme
22a0: 6e 74 20 73 20 65 0a 09 20 20 20 20 69 66 20 7b  nt s e..    if {
22b0: 24 6c 61 73 74 65 20 21 3d 20 28 24 73 20 2d 20  $laste != ($s - 
22c0: 31 29 7d 20 7b 0a 09 09 74 72 6f 75 62 6c 65 20  1)} {...trouble 
22d0: 69 6e 74 65 72 6e 61 6c 20 22 42 61 64 20 66 72  internal "Bad fr
22e0: 61 67 6d 65 6e 74 20 62 6f 72 64 65 72 20 3c 24  agment border <$
22f0: 6c 61 73 74 65 20 7c 20 24 73 3e 2c 20 67 61 70  laste | $s>, gap
2300: 20 6f 72 20 6f 76 65 72 6c 61 70 22 0a 09 20 20   or overlap"..  
2310: 20 20 7d 0a 0a 09 20 20 20 20 73 65 74 20 6e 65    }...    set ne
2320: 77 20 5b 24 74 79 70 65 20 25 41 55 54 4f 25 20  w [$type %AUTO% 
2330: 24 6d 79 70 72 6f 6a 65 63 74 20 24 6d 79 74 79  $myproject $myty
2340: 70 65 20 24 6d 79 73 72 63 69 64 20 5b 6c 72 61  pe $mysrcid [lra
2350: 6e 67 65 20 24 6d 79 72 65 76 69 73 69 6f 6e 73  nge $myrevisions
2360: 20 24 73 20 24 65 5d 5d 0a 0a 20 20 20 20 20 20   $s $e]]..      
2370: 20 20 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20        log write 
2380: 34 20 63 73 65 74 73 20 22 42 72 65 61 6b 69 6e  4 csets "Breakin
2390: 67 20 5b 24 73 65 6c 66 20 73 74 72 20 5d 20 40  g [$self str ] @
23a0: 20 24 6c 61 73 74 65 2c 20 6e 65 77 20 5b 24 6e   $laste, new [$n
23b0: 65 77 20 73 74 72 5d 2c 20 63 75 74 74 69 6e 67  ew str], cutting
23c0: 20 24 62 72 65 61 6b 73 28 24 6c 61 73 74 65 29   $breaks($laste)
23d0: 22 0a 0a 09 20 20 20 20 73 65 74 20 6c 61 73 74  "...    set last
23e0: 65 20 24 65 0a 09 7d 0a 0a 09 69 66 20 7b 24 6c  e $e..}...if {$l
23f0: 61 73 74 65 20 21 3d 20 28 5b 6c 6c 65 6e 67 74  aste != ([llengt
2400: 68 20 24 6d 79 72 65 76 69 73 69 6f 6e 73 5d 2d  h $myrevisions]-
2410: 31 29 7d 20 7b 0a 09 20 20 20 20 74 72 6f 75 62  1)} {..    troub
2420: 6c 65 20 69 6e 74 65 72 6e 61 6c 20 22 42 61 64  le internal "Bad
2430: 20 66 72 61 67 6d 65 6e 74 20 65 6e 64 20 40 20   fragment end @ 
2440: 24 6c 61 73 74 65 2c 20 67 61 70 2c 20 6f 72 20  $laste, gap, or 
2450: 62 65 79 6f 6e 64 20 65 6e 64 20 6f 66 20 74 68  beyond end of th
2460: 65 20 72 61 6e 67 65 22 0a 09 7d 0a 0a 09 23 20  e range"..}...# 
2470: 50 75 74 20 74 68 65 20 66 69 72 73 74 20 66 72  Put the first fr
2480: 61 67 6d 65 6e 74 20 69 6e 74 6f 20 74 68 65 20  agment into the 
2490: 63 75 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65  current changese
24a0: 74 2c 20 61 6e 64 0a 09 23 20 75 70 64 61 74 65  t, and..# update
24b0: 20 74 68 65 20 69 6e 2d 6d 65 6d 6f 72 79 20 69   the in-memory i
24c0: 6e 64 65 78 2e 20 57 65 20 63 61 6e 20 73 69 6d  ndex. We can sim
24d0: 70 6c 79 20 28 72 65 29 61 64 64 20 74 68 65 0a  ply (re)add the.
24e0: 09 23 20 72 65 76 69 73 69 6f 6e 73 20 62 65 63  .# revisions bec
24f0: 61 75 73 65 20 77 65 20 63 6c 65 61 72 65 64 20  ause we cleared 
2500: 74 68 65 20 70 72 65 76 69 6f 75 73 6c 79 20 65  the previously e
2510: 78 69 73 74 69 6e 67 0a 09 23 20 69 6e 66 6f 72  xisting..# infor
2520: 6d 61 74 69 6f 6e 2c 20 73 65 65 20 28 2a 29 20  mation, see (*) 
2530: 61 62 6f 76 65 2e 20 50 65 72 73 69 73 74 65 6e  above. Persisten
2540: 63 65 20 64 6f 65 73 20 6e 6f 74 20 6d 61 74 74  ce does not matt
2550: 65 72 0a 09 23 20 68 65 72 65 2c 20 6e 6f 6e 65  er..# here, none
2560: 20 6f 66 20 74 68 65 20 63 68 61 6e 67 65 73 65   of the changese
2570: 74 73 20 68 61 73 20 62 65 65 6e 20 73 61 76 65  ts has been save
2580: 64 20 74 6f 20 74 68 65 0a 09 23 20 70 65 72 73  d to the..# pers
2590: 69 73 74 65 6e 74 20 73 74 61 74 65 20 79 65 74  istent state yet
25a0: 2e 0a 0a 09 73 65 74 20 6d 79 72 65 76 69 73 69  ....set myrevisi
25b0: 6f 6e 73 20 5b 6c 72 61 6e 67 65 20 24 6d 79 72  ons [lrange $myr
25c0: 65 76 69 73 69 6f 6e 73 20 30 20 24 66 69 72 73  evisions 0 $firs
25d0: 74 65 5d 0a 09 66 6f 72 65 61 63 68 20 72 20 24  te]..foreach r $
25e0: 6d 79 72 65 76 69 73 69 6f 6e 73 20 7b 20 6c 61  myrevisions { la
25f0: 70 70 65 6e 64 20 6d 79 72 65 76 6d 61 70 28 24  ppend myrevmap($
2600: 72 29 20 24 73 65 6c 66 20 7d 0a 0a 09 72 65 74  r) $self }...ret
2610: 75 72 6e 20 31 0a 20 20 20 20 7d 0a 0a 20 20 20  urn 1.    }..   
2620: 20 6d 65 74 68 6f 64 20 70 65 72 73 69 73 74 20   method persist 
2630: 7b 7d 20 7b 0a 09 73 65 74 20 74 69 64 20 24 6d  {} {..set tid $m
2640: 79 63 73 74 79 70 65 28 24 6d 79 74 79 70 65 29  ycstype($mytype)
2650: 0a 09 73 65 74 20 70 69 64 20 5b 24 6d 79 70 72  ..set pid [$mypr
2660: 6f 6a 65 63 74 20 69 64 5d 0a 09 73 65 74 20 70  oject id]..set p
2670: 6f 73 20 30 0a 0a 09 73 74 61 74 65 20 74 72 61  os 0...state tra
2680: 6e 73 61 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20  nsaction {..    
2690: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 49 4e  state run {...IN
26a0: 53 45 52 54 20 49 4e 54 4f 20 63 68 61 6e 67 65  SERT INTO change
26b0: 73 65 74 20 28 63 69 64 2c 20 20 20 70 69 64 2c  set (cid,   pid,
26c0: 20 20 74 79 70 65 2c 20 73 72 63 29 0a 09 09 56    type, src)...V
26d0: 41 4c 55 45 53 20 20 20 20 20 20 20 20 20 20 20  ALUES           
26e0: 20 20 20 20 20 28 24 6d 79 69 64 2c 20 24 70 69       ($myid, $pi
26f0: 64 2c 20 24 74 69 64 2c 20 24 6d 79 73 72 63 69  d, $tid, $mysrci
2700: 64 29 3b 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20  d);..    }...   
2710: 20 66 6f 72 65 61 63 68 20 72 69 64 20 24 6d 79   foreach rid $my
2720: 72 65 76 69 73 69 6f 6e 73 20 7b 0a 09 09 73 74  revisions {...st
2730: 61 74 65 20 72 75 6e 20 7b 0a 09 09 20 20 20 20  ate run {...    
2740: 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 73 72 65  INSERT INTO csre
2750: 76 69 73 69 6f 6e 20 28 63 69 64 2c 20 20 20 70  vision (cid,   p
2760: 6f 73 2c 20 20 72 69 64 29 0a 09 09 20 20 20 20  os,  rid)...    
2770: 56 41 4c 55 45 53 20 20 20 20 20 20 20 20 20 20  VALUES          
2780: 20 20 20 20 20 20 20 28 24 6d 79 69 64 2c 20 24         ($myid, $
2790: 70 6f 73 2c 20 24 72 69 64 29 3b 0a 09 09 7d 0a  pos, $rid);...}.
27a0: 09 09 69 6e 63 72 20 70 6f 73 0a 09 20 20 20 20  ..incr pos..    
27b0: 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20  }..}..return.   
27c0: 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 74   }..    method t
27d0: 69 6d 65 72 61 6e 67 65 20 7b 7d 20 7b 0a 09 73  imerange {} {..s
27e0: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69  et theset ('[joi
27f0: 6e 20 24 6d 79 72 65 76 69 73 69 6f 6e 73 20 7b  n $myrevisions {
2800: 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20  ','}]')..return 
2810: 5b 73 74 61 74 65 20 72 75 6e 20 22 0a 09 20 20  [state run "..  
2820: 20 20 53 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64    SELECT MIN(R.d
2830: 61 74 65 29 2c 20 4d 41 58 28 52 2e 64 61 74 65  ate), MAX(R.date
2840: 29 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69  )..    FROM revi
2850: 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52  sion R..    WHER
2860: 45 20 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73  E R.rid IN $thes
2870: 65 74 0a 09 22 5d 0a 20 20 20 20 7d 0a 0a 20 20  et.."].    }..  
2880: 20 20 6d 65 74 68 6f 64 20 64 72 6f 70 20 7b 7d    method drop {}
2890: 20 7b 0a 09 73 74 61 74 65 20 74 72 61 6e 73 61   {..state transa
28a0: 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74 61  ction {..    sta
28b0: 74 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54  te run {...DELET
28c0: 45 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65 74  E FROM changeset
28d0: 20 20 57 48 45 52 45 20 63 69 64 20 3d 20 24 6d    WHERE cid = $m
28e0: 79 69 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 52  yid;...DELETE FR
28f0: 4f 4d 20 63 73 72 65 76 69 73 69 6f 6e 20 57 48  OM csrevision WH
2900: 45 52 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b  ERE cid = $myid;
2910: 0a 09 20 20 20 20 7d 0a 09 7d 0a 09 66 6f 72 65  ..    }..}..fore
2920: 61 63 68 20 72 20 24 6d 79 72 65 76 69 73 69 6f  ach r $myrevisio
2930: 6e 73 20 7b 0a 09 20 20 20 20 69 66 20 7b 5b 6c  ns {..    if {[l
2940: 6c 65 6e 67 74 68 20 24 6d 79 72 65 76 6d 61 70  length $myrevmap
2950: 28 24 72 29 5d 20 3d 3d 20 31 7d 20 7b 0a 09 09  ($r)] == 1} {...
2960: 75 6e 73 65 74 20 6d 79 72 65 76 6d 61 70 28 24  unset myrevmap($
2970: 72 29 0a 09 20 20 20 20 7d 20 65 6c 73 65 20 7b  r)..    } else {
2980: 0a 09 09 73 65 74 20 70 6f 73 20 5b 6c 73 65 61  ...set pos [lsea
2990: 72 63 68 20 2d 65 78 61 63 74 20 24 6d 79 72 65  rch -exact $myre
29a0: 76 6d 61 70 28 24 72 29 20 24 73 65 6c 66 5d 0a  vmap($r) $self].
29b0: 09 09 73 65 74 20 6d 79 72 65 76 6d 61 70 28 24  ..set myrevmap($
29c0: 72 29 20 5b 6c 72 65 70 6c 61 63 65 20 24 6d 79  r) [lreplace $my
29d0: 72 65 76 6d 61 70 28 24 72 29 20 24 70 6f 73 20  revmap($r) $pos 
29e0: 24 70 6f 73 5d 0a 09 20 20 20 20 7d 0a 09 7d 0a  $pos]..    }..}.
29f0: 09 73 65 74 20 70 6f 73 20 20 20 20 20 20 20 20  .set pos        
2a00: 20 20 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 63    [lsearch -exac
2a10: 74 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20  t $mychangesets 
2a20: 24 73 65 6c 66 5d 0a 09 73 65 74 20 6d 79 63 68  $self]..set mych
2a30: 61 6e 67 65 73 65 74 73 20 5b 6c 72 65 70 6c 61  angesets [lrepla
2a40: 63 65 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73  ce $mychangesets
2a50: 20 24 70 6f 73 20 24 70 6f 73 5d 0a 09 72 65 74   $pos $pos]..ret
2a60: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74  urn.    }..    t
2a70: 79 70 65 6d 65 74 68 6f 64 20 73 70 6c 69 74 20  ypemethod split 
2a80: 7b 63 73 65 74 20 61 72 67 73 7d 20 7b 0a 09 23  {cset args} {..#
2a90: 20 41 73 20 70 61 72 74 20 6f 66 20 74 68 65 20   As part of the 
2aa0: 63 72 65 61 74 69 6f 6e 20 6f 66 20 74 68 65 20  creation of the 
2ab0: 6e 65 77 20 63 68 61 6e 67 65 73 65 74 73 20 73  new changesets s
2ac0: 70 65 63 69 66 69 65 64 20 69 6e 0a 09 23 20 41  pecified in..# A
2ad0: 52 47 53 20 61 73 20 73 65 74 73 20 6f 66 20 72  RGS as sets of r
2ae0: 65 76 69 73 69 6f 6e 73 2c 20 61 6c 6c 20 73 75  evisions, all su
2af0: 62 73 65 74 73 20 6f 66 20 43 53 45 54 27 73 20  bsets of CSET's 
2b00: 72 65 76 69 73 69 6f 6e 0a 09 23 20 73 65 74 2c  revision..# set,
2b10: 20 43 53 45 54 20 77 69 6c 6c 20 62 65 20 64 72   CSET will be dr
2b20: 6f 70 70 65 64 20 66 72 6f 6d 20 61 6c 6c 20 64  opped from all d
2b30: 61 74 61 62 61 73 65 73 2c 20 69 6e 20 61 6e 64  atabases, in and
2b40: 20 6f 75 74 20 6f 66 0a 09 23 20 6d 65 6d 6f 72   out of..# memor
2b50: 79 2c 20 61 6e 64 20 74 68 65 6e 20 64 65 73 74  y, and then dest
2b60: 72 6f 79 65 64 2e 0a 0a 09 73 74 72 75 63 74 3a  royed....struct:
2b70: 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b 24 63  :list assign [$c
2b80: 73 65 74 20 64 61 74 61 5d 20 70 72 6f 6a 65 63  set data] projec
2b90: 74 20 63 73 74 79 70 65 20 63 73 73 72 63 0a 0a  t cstype cssrc..
2ba0: 09 24 63 73 65 74 20 64 72 6f 70 0a 09 24 63 73  .$cset drop..$cs
2bb0: 65 74 20 64 65 73 74 72 6f 79 0a 0a 09 73 65 74  et destroy...set
2bc0: 20 6e 65 77 63 73 65 74 73 20 7b 7d 0a 09 66 6f   newcsets {}..fo
2bd0: 72 65 61 63 68 20 66 72 61 67 6d 65 6e 74 72 65  reach fragmentre
2be0: 76 69 73 69 6f 6e 73 20 24 61 72 67 73 20 7b 0a  visions $args {.
2bf0: 09 20 20 20 20 69 66 20 7b 21 5b 6c 6c 65 6e 67  .    if {![lleng
2c00: 74 68 20 24 66 72 61 67 6d 65 6e 74 72 65 76 69  th $fragmentrevi
2c10: 73 69 6f 6e 73 5d 7d 20 7b 0a 09 09 74 72 6f 75  sions]} {...trou
2c20: 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 22 41 74  ble internal "At
2c30: 74 65 6d 70 74 65 64 20 74 6f 20 63 72 65 61 74  tempted to creat
2c40: 65 20 61 6e 20 65 6d 70 74 79 20 63 68 61 6e 67  e an empty chang
2c50: 65 73 65 74 2c 20 69 2e 65 2e 20 77 69 74 68 6f  eset, i.e. witho
2c60: 75 74 20 72 65 76 69 73 69 6f 6e 73 22 0a 09 20  ut revisions".. 
2c70: 20 20 20 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e     }..    lappen
2c80: 64 20 6e 65 77 63 73 65 74 73 20 5b 24 74 79 70  d newcsets [$typ
2c90: 65 20 25 41 55 54 4f 25 20 24 70 72 6f 6a 65 63  e %AUTO% $projec
2ca0: 74 20 24 63 73 74 79 70 65 20 24 63 73 73 72 63  t $cstype $cssrc
2cb0: 20 24 66 72 61 67 6d 65 6e 74 72 65 76 69 73 69   $fragmentrevisi
2cc0: 6f 6e 73 5d 0a 09 7d 0a 0a 09 66 6f 72 65 61 63  ons]..}...foreac
2cd0: 68 20 63 20 24 6e 65 77 63 73 65 74 73 20 7b 20  h c $newcsets { 
2ce0: 24 63 20 70 65 72 73 69 73 74 20 7d 0a 09 72 65  $c persist }..re
2cf0: 74 75 72 6e 20 24 6e 65 77 63 73 65 74 73 0a 20  turn $newcsets. 
2d00: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65     }..    typeme
2d10: 74 68 6f 64 20 73 74 72 6c 69 73 74 20 7b 63 68  thod strlist {ch
2d20: 61 6e 67 65 73 65 74 73 7d 20 7b 0a 09 72 65 74  angesets} {..ret
2d30: 75 72 6e 20 5b 6a 6f 69 6e 20 5b 73 74 72 75 63  urn [join [struc
2d40: 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 63 68 61  t::list map $cha
2d50: 6e 67 65 73 65 74 73 20 5b 6d 79 70 72 6f 63 20  ngesets [myproc 
2d60: 49 44 5d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20  ID]]].    }..   
2d70: 20 70 72 6f 63 20 49 44 20 7b 63 73 65 74 7d 20   proc ID {cset} 
2d80: 7b 20 24 63 73 65 74 20 73 74 72 20 7d 0a 0a 20  { $cset str }.. 
2d90: 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23     # # ## ### ##
2da0: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23  ### ######## ###
2db0: 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23  ##########.    #
2dc0: 23 20 53 74 61 74 65 0a 0a 20 20 20 20 76 61 72  # State..    var
2dd0: 69 61 62 6c 65 20 6d 79 69 64 20 20 20 20 20 20  iable myid      
2de0: 20 20 7b 7d 20 3b 20 23 20 49 64 20 6f 66 20 74    {} ; # Id of t
2df0: 68 65 20 63 73 65 74 20 66 6f 72 20 74 68 65 20  he cset for the 
2e00: 70 65 72 73 69 73 74 65 6e 74 0a 09 09 09 20 20  persistent....  
2e10: 20 20 20 20 23 20 73 74 61 74 65 2e 0a 20 20 20      # state..   
2e20: 20 76 61 72 69 61 62 6c 65 20 6d 79 70 72 6f 6a   variable myproj
2e30: 65 63 74 20 20 20 7b 7d 20 3b 20 23 20 52 65 66  ect   {} ; # Ref
2e40: 65 72 65 6e 63 65 20 6f 66 20 74 68 65 20 70 72  erence of the pr
2e50: 6f 6a 65 63 74 20 6f 62 6a 65 63 74 20 74 68 65  oject object the
2e60: 0a 09 09 09 20 20 20 20 20 20 23 20 63 68 61 6e  ....      # chan
2e70: 67 65 73 65 74 20 62 65 6c 6f 6e 67 73 20 74 6f  geset belongs to
2e80: 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d  ..    variable m
2e90: 79 74 79 70 65 20 20 20 20 20 20 7b 7d 20 3b 20  ytype      {} ; 
2ea0: 23 20 72 65 76 20 6f 72 20 73 79 6d 2c 20 77 68  # rev or sym, wh
2eb0: 65 72 65 20 74 68 65 20 63 73 65 74 20 6f 72 69  ere the cset ori
2ec0: 67 69 6e 61 74 65 64 0a 09 09 09 20 20 20 20 20  ginated....     
2ed0: 20 23 20 66 72 6f 6d 2e 0a 20 20 20 20 76 61 72   # from..    var
2ee0: 69 61 62 6c 65 20 6d 79 73 72 63 69 64 20 20 20  iable mysrcid   
2ef0: 20 20 7b 7d 20 3b 20 23 20 49 64 20 6f 66 20 74    {} ; # Id of t
2f00: 68 65 20 6d 65 74 61 64 61 74 61 20 6f 72 20 73  he metadata or s
2f10: 79 6d 62 6f 6c 20 74 68 65 20 63 73 65 74 0a 09  ymbol the cset..
2f20: 09 09 20 20 20 20 20 20 23 20 69 73 20 62 61 73  ..      # is bas
2f30: 65 64 20 6f 6e 2e 0a 20 20 20 20 76 61 72 69 61  ed on..    varia
2f40: 62 6c 65 20 6d 79 72 65 76 69 73 69 6f 6e 73 20  ble myrevisions 
2f50: 7b 7d 20 3b 20 23 20 4c 69 73 74 20 6f 66 20 74  {} ; # List of t
2f60: 68 65 20 66 69 6c 65 20 6c 65 76 65 6c 20 72 65  he file level re
2f70: 76 69 73 69 6f 6e 73 20 69 6e 0a 09 09 09 20 20  visions in....  
2f80: 20 20 20 20 23 20 74 68 65 20 63 73 65 74 2e 0a      # the cset..
2f90: 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 70      variable myp
2fa0: 72 65 6d 61 70 20 20 20 20 7b 7d 20 3b 20 23 20  remap    {} ; # 
2fb0: 44 69 63 74 69 6f 6e 61 72 79 20 6d 61 70 70 69  Dictionary mappi
2fc0: 6e 67 20 66 72 6f 6d 20 74 68 65 20 72 65 76 69  ng from the revi
2fd0: 73 69 6f 6e 73 0a 09 09 09 20 20 20 20 20 20 23  sions....      #
2fe0: 20 74 6f 20 74 68 65 69 72 20 70 72 65 64 65 63   to their predec
2ff0: 65 73 73 6f 72 73 2e 20 43 61 63 68 65 20 74 6f  essors. Cache to
3000: 20 61 76 6f 69 64 0a 09 09 09 20 20 20 20 20 20   avoid....      
3010: 23 20 6c 6f 61 64 69 6e 67 20 74 68 69 73 20 66  # loading this f
3020: 72 6f 6d 20 74 68 65 20 73 74 61 74 65 20 6d 6f  rom the state mo
3030: 72 65 20 74 68 61 6e 0a 09 09 09 20 20 20 20 20  re than....     
3040: 20 23 20 6f 6e 63 65 2e 0a 20 20 20 20 76 61 72   # once..    var
3050: 69 61 62 6c 65 20 6d 79 6e 65 78 74 6d 61 70 20  iable mynextmap 
3060: 20 20 7b 7d 20 3b 20 23 20 44 69 63 74 69 6f 6e    {} ; # Diction
3070: 61 72 79 20 6d 61 70 70 69 6e 67 20 66 72 6f 6d  ary mapping from
3080: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 0a 09   the revisions..
3090: 09 09 20 20 20 20 20 20 23 20 74 6f 20 74 68 65  ..      # to the
30a0: 69 72 20 73 75 63 63 65 73 73 6f 72 73 2e 20 43  ir successors. C
30b0: 61 63 68 65 20 74 6f 20 61 76 6f 69 64 0a 09 09  ache to avoid...
30c0: 09 20 20 20 20 20 20 23 20 6c 6f 61 64 69 6e 67  .      # loading
30d0: 20 74 68 69 73 20 66 72 6f 6d 20 74 68 65 20 73   this from the s
30e0: 74 61 74 65 20 6d 6f 72 65 20 74 68 61 6e 0a 09  tate more than..
30f0: 09 09 20 20 20 20 20 20 23 20 6f 6e 63 65 2e 0a  ..      # once..
3100: 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 70      variable myp
3110: 6f 73 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20  os       {} ; # 
3120: 43 6f 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e 20  Commit position 
3130: 6f 66 20 74 68 65 20 63 68 61 6e 67 65 73 65 74  of the changeset
3140: 2c 20 69 66 0a 09 09 09 20 20 20 20 20 20 23 20  , if....      # 
3150: 6b 6e 6f 77 6e 2e 0a 0a 20 20 20 20 23 20 23 20  known...    # # 
3160: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
3170: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
3180: 23 23 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72  ###.    ## Inter
3190: 6e 61 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20  nal methods..   
31a0: 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79   typevariable my
31b0: 63 6f 75 6e 74 65 72 20 20 20 20 20 20 20 20 30  counter        0
31c0: 20 3b 20 23 20 49 64 20 63 6f 75 6e 74 65 72 20   ; # Id counter 
31d0: 66 6f 72 20 63 73 65 74 73 2e 20 4c 61 73 74 20  for csets. Last 
31e0: 69 64 20 75 73 65 64 2e 0a 20 20 20 20 74 79 70  id used..    typ
31f0: 65 76 61 72 69 61 62 6c 65 20 6d 79 63 73 74 79  evariable mycsty
3200: 70 65 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23  pe -array {} ; #
3210: 20 4d 61 70 20 63 73 74 79 70 65 73 20 74 6f 20   Map cstypes to 
3220: 70 65 72 73 69 73 74 65 6e 74 20 69 64 73 2e 0a  persistent ids..
3230: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
3240: 67 65 74 63 73 74 79 70 65 73 20 7b 7d 20 7b 0a  getcstypes {} {.
3250: 09 66 6f 72 65 61 63 68 20 7b 74 69 64 20 6e 61  .foreach {tid na
3260: 6d 65 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b  me} [state run {
3270: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 74 69 64  ..    SELECT tid
3280: 2c 20 6e 61 6d 65 20 46 52 4f 4d 20 63 73 74 79  , name FROM csty
3290: 70 65 3b 0a 09 7d 5d 20 7b 20 73 65 74 20 6d 79  pe;..}] { set my
32a0: 63 73 74 79 70 65 28 24 6e 61 6d 65 29 20 24 74  cstype($name) $t
32b0: 69 64 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20  id }..return.   
32c0: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68   }..    typemeth
32d0: 6f 64 20 6c 6f 61 64 63 6f 75 6e 74 65 72 20 7b  od loadcounter {
32e0: 7d 20 7b 0a 09 23 20 49 6e 69 74 69 61 6c 69 7a  } {..# Initializ
32f0: 65 20 74 68 65 20 63 6f 75 6e 74 65 72 20 66 72  e the counter fr
3300: 6f 6d 20 74 68 65 20 73 74 61 74 65 0a 09 73 65  om the state..se
3310: 74 20 6d 79 63 6f 75 6e 74 65 72 20 5b 73 74 61  t mycounter [sta
3320: 74 65 20 6f 6e 65 20 7b 20 53 45 4c 45 43 54 20  te one { SELECT 
3330: 4d 41 58 28 63 69 64 29 20 46 52 4f 4d 20 63 68  MAX(cid) FROM ch
3340: 61 6e 67 65 73 65 74 20 7d 5d 0a 09 72 65 74 75  angeset }]..retu
3350: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79  rn.    }..    ty
3360: 70 65 6d 65 74 68 6f 64 20 6e 75 6d 20 7b 7d 20  pemethod num {} 
3370: 7b 20 72 65 74 75 72 6e 20 24 6d 79 63 6f 75 6e  { return $mycoun
3380: 74 65 72 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20  ter }..    proc 
3390: 50 75 6c 6c 49 6e 74 65 72 6e 61 6c 53 75 63 63  PullInternalSucc
33a0: 65 73 73 6f 72 52 65 76 69 73 69 6f 6e 73 20 7b  essorRevisions {
33b0: 64 76 20 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a  dv revisions} {.
33c0: 09 75 70 76 61 72 20 31 20 24 64 76 20 64 65 70  .upvar 1 $dv dep
33d0: 65 6e 64 65 6e 63 69 65 73 0a 09 73 65 74 20 74  endencies..set t
33e0: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72  heset ('[join $r
33f0: 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27  evisions {','}]'
3400: 29 0a 0a 09 23 20 53 65 65 20 50 75 6c 6c 53 75  )...# See PullSu
3410: 63 63 65 73 73 6f 72 52 65 76 69 73 69 6f 6e 73  ccessorRevisions
3420: 20 62 65 6c 6f 77 20 66 6f 72 20 74 68 65 20 6d   below for the m
3430: 61 69 6e 20 65 78 70 6c 61 6e 61 74 69 6f 6e 20  ain explanation 
3440: 6f 66 0a 09 23 20 74 68 65 20 76 61 72 69 6f 75  of..# the variou
3450: 73 20 63 61 73 65 73 2e 20 54 68 69 73 20 70 69  s cases. This pi
3460: 65 63 65 20 69 73 20 73 70 65 63 69 61 6c 20 69  ece is special i
3470: 6e 20 74 68 61 74 20 69 74 0a 09 23 20 72 65 73  n that it..# res
3480: 74 72 69 63 74 73 20 74 68 65 20 73 75 63 63 65  tricts the succe
3490: 73 73 6f 72 73 20 77 65 20 6c 6f 6f 6b 20 66 6f  ssors we look fo
34a0: 72 20 74 6f 20 74 68 65 20 73 61 6d 65 20 73 65  r to the same se
34b0: 74 20 6f 66 0a 09 23 20 72 65 76 69 73 69 6f 6e  t of..# revision
34c0: 73 20 77 65 20 73 74 61 72 74 20 66 72 6f 6d 2e  s we start from.
34d0: 20 53 65 6e 73 69 62 6c 65 20 61 73 20 77 65 20   Sensible as we 
34e0: 61 72 65 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72 0a  are looking for.
34f0: 09 23 20 63 68 61 6e 67 65 73 65 74 20 69 6e 74  .# changeset int
3500: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
3510: 65 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20  es....array set 
3520: 64 65 70 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68  dep {}...foreach
3530: 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74   {rid child} [st
3540: 61 74 65 20 72 75 6e 20 22 0a 20 20 20 2d 2d 20  ate run ".   -- 
3550: 28 31 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c  (1) Primary chil
3560: 64 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e  d..    SELECT R.
3570: 72 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20  rid, R.child..  
3580: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f    FROM   revisio
3590: 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20  n R..    WHERE  
35a0: 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73  R.rid   IN $thes
35b0: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69  et     -- Restri
35c0: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20  ct to revisions 
35d0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20  of interest..   
35e0: 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20   AND    R.child 
35f0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d  IS NOT NULL    -
3600: 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68  - Has primary ch
3610: 69 6c 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20  ild..    AND    
3620: 52 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73  R.child IN $thes
3630: 65 74 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20  et     -- Which 
3640: 69 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72  is also of inter
3650: 65 73 74 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20  est.    UNION.  
3660: 20 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61    -- (2) Seconda
3670: 72 79 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c  ry (branch) chil
3680: 64 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54  dren..    SELECT
3690: 20 52 2e 72 69 64 2c 20 42 2e 62 72 69 64 0a 09   R.rid, B.brid..
36a0: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73      FROM   revis
36b0: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 62  ion R, revisionb
36c0: 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20 42 0a  ranchchildren B.
36d0: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
36e0: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20  d   IN $theset  
36f0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
3700: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
3710: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
3720: 20 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69      R.rid = B.ri
3730: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65  d          -- Se
3740: 6c 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62  lect subset of b
3750: 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 09  ranch children..
3760: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 62 72 69      AND    B.bri
3770: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20  d IN $theset    
3780: 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c    -- Which is al
3790: 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20  so of interest. 
37a0: 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20     UNION.    -- 
37b0: 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75  (4) Child of tru
37c0: 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f  nk root successo
37d0: 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f  r of last NTDB o
37e0: 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45  n trunk...    SE
37f0: 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63  LECT R.rid, RA.c
3800: 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 72  hild..    FROM r
3810: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73  evision R, revis
3820: 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 45 52  ion RA..    WHER
3830: 45 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68  E R.rid   IN $th
3840: 65 73 65 74 20 20 20 20 20 20 2d 2d 20 52 65 73  eset      -- Res
3850: 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f  trict to revisio
3860: 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09  ns of interest..
3870: 20 20 20 20 41 4e 44 20 20 20 52 2e 69 73 64 65      AND   R.isde
3880: 66 61 75 6c 74 20 20 20 20 20 20 20 20 20 20 20  fault           
3890: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
38a0: 20 4e 54 44 42 0a 09 20 20 20 20 41 4e 44 20 20   NTDB..    AND  
38b0: 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f   R.dbchild IS NO
38c0: 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20  T NULL   -- and 
38d0: 6c 61 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67  last NTDB belong
38e0: 69 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20  ing to trunk..  
38f0: 20 20 41 4e 44 20 20 20 52 41 2e 72 69 64 20 3d    AND   RA.rid =
3900: 20 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20   R.dbchild      
3910: 2d 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74  -- Go directly t
3920: 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20  o trunk root..  
3930: 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64    AND   RA.child
3940: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20   IS NOT NULL    
3950: 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63  -- Has primary c
3960: 68 69 6c 64 2e 0a 20 20 20 20 20 20 20 20 20 20  hild..          
3970: 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64    AND   RA.child
3980: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
3990: 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c 73 6f  -- Which is also
39a0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 22 5d   of interest.."]
39b0: 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73 69 64   {..    # Consid
39c0: 65 72 20 6d 6f 76 69 6e 67 20 74 68 69 73 20 74  er moving this t
39d0: 6f 20 74 68 65 20 69 6e 74 65 67 72 69 74 79 20  o the integrity 
39e0: 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69 66 20  module...    if 
39f0: 7b 24 72 69 64 20 3d 3d 20 24 63 68 69 6c 64 7d  {$rid == $child}
3a00: 20 7b 0a 09 09 74 72 6f 75 62 6c 65 20 69 6e 74   {...trouble int
3a10: 65 72 6e 61 6c 20 22 52 65 76 69 73 69 6f 6e 20  ernal "Revision 
3a20: 24 72 69 64 20 64 65 70 65 6e 64 73 20 6f 6e 20  $rid depends on 
3a30: 69 74 73 65 6c 66 2e 22 0a 09 20 20 20 20 7d 0a  itself."..    }.
3a40: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70  .    lappend dep
3a50: 65 6e 64 65 6e 63 69 65 73 28 24 72 69 64 29 20  endencies($rid) 
3a60: 24 63 68 69 6c 64 0a 09 20 20 20 20 73 65 74 20  $child..    set 
3a70: 64 65 70 28 24 72 69 64 2c 24 63 68 69 6c 64 29  dep($rid,$child)
3a80: 20 2e 0a 09 7d 0a 0a 09 23 20 54 68 65 20 73 71   ...}...# The sq
3a90: 6c 20 73 74 61 74 65 6d 65 6e 74 73 20 61 62 6f  l statements abo
3aa0: 76 65 20 6c 6f 6f 6b 73 20 6f 6e 6c 79 20 66 6f  ve looks only fo
3ab0: 72 20 64 69 72 65 63 74 20 64 65 70 65 6e 64 65  r direct depende
3ac0: 6e 63 69 65 73 0a 09 23 20 62 65 74 77 65 65 6e  ncies..# between
3ad0: 20 72 65 76 69 73 69 6f 6e 20 69 6e 20 74 68 65   revision in the
3ae0: 20 63 68 61 6e 67 65 73 65 74 2e 20 48 6f 77 65   changeset. Howe
3af0: 76 65 72 20 64 75 65 20 74 6f 20 74 68 65 0a 09  ver due to the..
3b00: 23 20 76 61 67 61 72 69 65 73 20 6f 66 20 6d 65  # vagaries of me
3b10: 74 61 20 64 61 74 61 20 69 74 20 69 73 20 70 6f  ta data it is po
3b20: 73 73 69 62 6c 65 20 66 6f 72 20 74 77 6f 20 72  ssible for two r
3b30: 65 76 69 73 69 6f 6e 73 20 6f 66 0a 09 23 20 74  evisions of..# t
3b40: 68 65 20 73 61 6d 65 20 66 69 6c 65 20 74 6f 20  he same file to 
3b50: 65 6e 64 20 75 70 20 69 6e 20 74 68 65 20 73 61  end up in the sa
3b60: 6d 65 20 63 68 61 6e 67 65 73 65 74 2c 20 77 69  me changeset, wi
3b70: 74 68 6f 75 74 20 61 0a 09 23 20 64 69 72 65 63  thout a..# direc
3b80: 74 20 64 65 70 65 6e 64 65 6e 63 79 20 62 65 74  t dependency bet
3b90: 77 65 65 6e 20 74 68 65 6d 2e 20 48 6f 77 65 76  ween them. Howev
3ba0: 65 72 20 77 65 20 6b 6e 6f 77 20 74 68 61 74 20  er we know that 
3bb0: 74 68 65 72 65 0a 09 23 20 68 61 73 20 74 6f 20  there..# has to 
3bc0: 62 65 20 61 20 61 6e 20 69 6e 64 69 72 65 63 74  be a an indirect
3bd0: 20 64 65 70 65 6e 64 65 6e 63 79 2c 20 62 65 20   dependency, be 
3be0: 69 74 20 74 68 72 6f 75 67 68 20 70 72 69 6d 61  it through prima
3bf0: 72 79 0a 09 23 20 63 68 69 6c 64 72 65 6e 2c 20  ry..# children, 
3c00: 62 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 2c  branch children,
3c10: 20 6f 72 20 61 20 63 6f 6d 62 69 6e 61 74 69 6f   or a combinatio
3c20: 6e 20 74 68 65 72 65 6f 66 2e 0a 0a 09 23 20 57  n thereof....# W
3c30: 65 20 6e 6f 77 20 66 69 6c 6c 20 69 6e 20 74 68  e now fill in th
3c40: 65 73 65 20 70 73 65 75 64 6f 2d 64 65 70 65 6e  ese pseudo-depen
3c50: 64 65 6e 63 69 65 73 2c 20 69 66 20 6e 6f 20 73  dencies, if no s
3c60: 75 63 68 0a 09 23 20 64 65 70 65 6e 64 65 6e 63  uch..# dependenc
3c70: 79 20 65 78 69 73 74 73 20 61 6c 72 65 61 64 79  y exists already
3c80: 2e 20 54 68 65 20 64 69 72 65 63 74 69 6f 6e 20  . The direction 
3c90: 6f 66 20 74 68 65 20 64 65 70 65 6e 64 65 6e 63  of the dependenc
3ca0: 79 0a 09 23 20 69 73 20 61 63 74 75 61 6c 6c 79  y..# is actually
3cb0: 20 69 72 72 65 6c 65 76 61 6e 74 20 66 6f 72 20   irrelevant for 
3cc0: 74 68 69 73 2e 0a 0a 09 23 20 4e 4f 54 45 3a 20  this....# NOTE: 
3cd0: 54 68 69 73 20 69 73 20 64 69 66 66 65 72 65 6e  This is differen
3ce0: 74 20 66 72 6f 6d 20 63 76 73 32 73 76 6e 2e 20  t from cvs2svn. 
3cf0: 4f 75 72 20 73 70 69 72 69 74 75 61 6c 20 61 6e  Our spiritual an
3d00: 63 65 73 74 6f 72 0a 09 23 20 64 6f 65 73 20 6e  cestor..# does n
3d10: 6f 74 20 75 73 65 20 73 75 63 68 20 70 73 65 75  ot use such pseu
3d20: 64 6f 2d 64 65 70 65 6e 64 65 6e 63 69 65 73 2c  do-dependencies,
3d30: 20 68 6f 77 65 76 65 72 20 69 74 20 75 73 65 73   however it uses
3d40: 20 61 0a 09 23 20 43 4f 4d 4d 49 54 5f 54 48 52   a..# COMMIT_THR
3d50: 45 53 48 4f 4c 44 2c 20 61 20 74 69 6d 65 20 69  ESHOLD, a time i
3d60: 6e 74 65 72 76 61 6c 20 63 6f 6d 6d 69 74 73 20  nterval commits 
3d70: 73 68 6f 75 6c 64 20 66 61 6c 6c 2e 20 54 68 69  should fall. Thi
3d80: 73 0a 09 23 20 77 69 6c 6c 20 67 72 65 61 74 6c  s..# will greatl
3d90: 79 20 72 65 64 75 63 65 73 20 74 68 65 20 72 69  y reduces the ri
3da0: 73 6b 20 6f 66 20 67 65 74 74 69 6e 67 20 66 61  sk of getting fa
3db0: 72 20 73 65 70 61 72 61 74 65 64 0a 09 23 20 72  r separated..# r
3dc0: 65 76 69 73 69 6f 6e 73 20 6f 66 20 74 68 65 20  evisions of the 
3dd0: 73 61 6d 65 20 66 69 6c 65 20 69 6e 74 6f 20 6f  same file into o
3de0: 6e 65 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09  ne changeset....
3df0: 23 20 57 65 20 61 6c 6c 6f 77 20 72 65 76 69 73  # We allow revis
3e00: 69 6f 6e 73 20 74 6f 20 62 65 20 66 61 72 20 61  ions to be far a
3e10: 70 61 72 74 20 69 6e 20 74 69 6d 65 20 69 6e 20  part in time in 
3e20: 74 68 65 20 73 61 6d 65 0a 09 23 20 63 68 61 6e  the same..# chan
3e30: 67 65 73 65 74 2c 20 62 75 74 20 6e 65 65 64 20  geset, but need 
3e40: 74 68 65 20 70 73 65 75 64 6f 2d 64 65 70 65 6e  the pseudo-depen
3e50: 64 65 6e 63 69 65 73 20 66 6f 72 20 74 68 69 73  dencies for this
3e60: 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20 66 69  ....array set fi
3e70: 64 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b  ds {}..foreach {
3e80: 72 69 64 20 66 69 64 7d 20 5b 73 74 61 74 65 20  rid fid} [state 
3e90: 72 75 6e 20 22 0a 09 20 20 20 20 53 45 4c 45 43  run "..    SELEC
3ea0: 54 20 52 2e 72 69 64 2c 20 52 2e 66 69 64 20 46  T R.rid, R.fid F
3eb0: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 20 57  ROM revision R W
3ec0: 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20 24 74  HERE R.rid IN $t
3ed0: 68 65 73 65 74 0a 09 22 5d 20 7b 20 6c 61 70 70  heset.."] { lapp
3ee0: 65 6e 64 20 66 69 64 73 28 24 66 69 64 29 20 24  end fids($fid) $
3ef0: 72 69 64 20 7d 0a 0a 09 66 6f 72 65 61 63 68 20  rid }...foreach 
3f00: 7b 66 69 64 20 72 69 64 73 7d 20 5b 61 72 72 61  {fid rids} [arra
3f10: 79 20 67 65 74 20 66 69 64 73 5d 20 7b 0a 09 20  y get fids] {.. 
3f20: 20 20 20 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20     if {[llength 
3f30: 24 72 69 64 73 5d 20 3c 20 32 7d 20 63 6f 6e 74  $rids] < 2} cont
3f40: 69 6e 75 65 0a 09 20 20 20 20 66 6f 72 65 61 63  inue..    foreac
3f50: 68 20 61 20 24 72 69 64 73 20 7b 0a 09 09 66 6f  h a $rids {...fo
3f60: 72 65 61 63 68 20 62 20 24 72 69 64 73 20 7b 0a  reach b $rids {.
3f70: 09 09 20 20 20 20 69 66 20 7b 24 61 20 3d 3d 20  ..    if {$a == 
3f80: 24 62 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20  $b} continue... 
3f90: 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69     if {[info exi
3fa0: 73 74 73 20 64 65 70 28 24 61 2c 24 62 29 5d 7d  sts dep($a,$b)]}
3fb0: 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20 20   continue...    
3fc0: 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 73  if {[info exists
3fd0: 20 64 65 70 28 24 62 2c 24 61 29 5d 7d 20 63 6f   dep($b,$a)]} co
3fe0: 6e 74 69 6e 75 65 0a 09 09 20 20 20 20 6c 61 70  ntinue...    lap
3ff0: 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65  pend dependencie
4000: 73 28 24 61 29 20 24 62 0a 09 09 20 20 20 20 73  s($a) $b...    s
4010: 65 74 20 64 65 70 28 24 61 2c 24 62 29 20 2e 0a  et dep($a,$b) ..
4020: 09 09 20 20 20 20 73 65 74 20 64 65 70 28 24 62  ..    set dep($b
4030: 2c 24 61 29 20 2e 0a 09 09 7d 0a 09 20 20 20 20  ,$a) ....}..    
4040: 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20  }..}..return.   
4050: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 75 6c   }..    proc Pul
4060: 6c 53 75 63 63 65 73 73 6f 72 52 65 76 69 73 69  lSuccessorRevisi
4070: 6f 6e 73 20 7b 64 76 20 72 65 76 69 73 69 6f 6e  ons {dv revision
4080: 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 64  s} {..upvar 1 $d
4090: 76 20 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 09  v dependencies..
40a0: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f  set theset ('[jo
40b0: 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27  in $revisions {'
40c0: 2c 27 7d 5d 27 29 0a 0a 09 23 20 54 68 65 20 66  ,'}]')...# The f
40d0: 6f 6c 6c 6f 77 69 6e 67 20 63 61 73 65 73 20 73  ollowing cases s
40e0: 70 65 63 69 66 79 20 77 68 65 6e 20 61 20 72 65  pecify when a re
40f0: 76 69 73 69 6f 6e 20 53 20 69 73 20 61 20 73 75  vision S is a su
4100: 63 63 65 73 73 6f 72 0a 09 23 20 6f 66 20 61 20  ccessor..# of a 
4110: 72 65 76 69 73 69 6f 6e 20 52 2e 20 45 61 63 68  revision R. Each
4120: 20 6f 66 20 74 68 65 20 63 61 73 65 73 20 74 72   of the cases tr
4130: 61 6e 73 6c 61 74 65 73 20 69 6e 74 6f 20 6f 6e  anslates into on
4140: 65 20 6f 66 0a 09 23 20 74 68 65 20 62 72 61 6e  e of..# the bran
4150: 63 68 65 73 20 6f 66 20 74 68 65 20 53 51 4c 20  ches of the SQL 
4160: 55 4e 49 4f 4e 20 63 6f 6d 69 6e 67 20 62 65 6c  UNION coming bel
4170: 6f 77 2e 0a 09 23 0a 09 23 20 28 31 29 20 53 20  ow...#..# (1) S 
4180: 63 61 6e 20 62 65 20 61 20 70 72 69 6d 61 72 79  can be a primary
4190: 20 63 68 69 6c 64 20 6f 66 20 52 2c 20 69 2e 65   child of R, i.e
41a0: 2e 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f  . in the same LO
41b0: 44 2e 20 52 0a 09 23 20 20 20 20 20 72 65 66 65  D. R..#     refe
41c0: 72 65 6e 63 65 73 20 53 20 64 69 72 65 63 74 6c  rences S directl
41d0: 79 2e 20 52 2e 63 68 69 6c 64 20 3d 20 53 28 2e  y. R.child = S(.
41e0: 72 69 64 29 2c 20 69 66 20 69 74 20 65 78 69 73  rid), if it exis
41f0: 74 73 2e 0a 09 23 0a 09 23 20 28 32 29 20 53 20  ts...#..# (2) S 
4200: 63 61 6e 20 62 65 20 61 20 73 65 63 6f 6e 64 61  can be a seconda
4210: 72 79 2c 20 69 2e 65 2e 20 62 72 61 6e 63 68 2c  ry, i.e. branch,
4220: 20 63 68 69 6c 64 20 6f 66 20 52 2e 20 48 65 72   child of R. Her
4230: 65 20 74 68 65 0a 09 23 20 20 20 20 20 6c 69 6e  e the..#     lin
4240: 6b 20 69 73 20 6d 61 64 65 20 74 68 72 6f 75 67  k is made throug
4250: 68 20 74 68 65 20 68 65 6c 70 65 72 20 74 61 62  h the helper tab
4260: 6c 65 0a 09 23 20 20 20 20 20 52 45 56 49 53 49  le..#     REVISI
4270: 4f 4e 42 52 41 4e 43 48 43 48 49 4c 44 52 45 4e  ONBRANCHCHILDREN
4280: 2e 20 52 2e 72 69 64 20 2d 3e 20 52 42 43 2e 72  . R.rid -> RBC.r
4290: 69 64 2c 20 52 42 43 2e 62 72 69 64 20 3d 0a 09  id, RBC.brid =..
42a0: 23 20 20 20 20 20 53 28 2e 72 69 64 29 0a 09 23  #     S(.rid)..#
42b0: 0a 09 23 20 28 33 29 20 4f 72 69 67 69 6e 61 6c  ..# (3) Original
42c0: 6c 79 20 74 68 69 73 20 75 73 65 20 63 61 73 65  ly this use case
42d0: 20 64 65 66 69 6e 65 64 20 74 68 65 20 72 6f 6f   defined the roo
42e0: 74 20 6f 66 20 61 20 64 65 74 61 63 68 65 64 0a  t of a detached.
42f0: 09 23 20 20 20 20 20 4e 54 44 42 20 61 73 20 74  .#     NTDB as t
4300: 68 65 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20  he successor of 
4310: 74 68 65 20 74 72 75 6e 6b 20 72 6f 6f 74 2e 20  the trunk root. 
4320: 54 68 69 73 20 6c 65 61 64 73 20 74 6f 20 61 0a  This leads to a.
4330: 09 23 20 20 20 20 20 62 61 64 20 74 61 6e 67 6c  .#     bad tangl
4340: 65 20 6c 61 74 65 72 20 6f 6e 2e 20 57 69 74 68  e later on. With
4350: 20 61 20 64 65 74 61 63 68 65 64 20 4e 54 44 42   a detached NTDB
4360: 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 0a 09 23   the original..#
4370: 20 20 20 20 20 74 72 75 6e 6b 20 72 6f 6f 74 20       trunk root 
4380: 72 65 76 69 73 69 6f 6e 20 77 61 73 20 72 65 6d  revision was rem
4390: 6f 76 65 64 20 61 73 20 69 72 72 65 6c 65 76 61  oved as irreleva
43a0: 6e 74 2c 20 61 6c 6c 6f 77 69 6e 67 0a 09 23 20  nt, allowing..# 
43b0: 20 20 20 20 74 68 65 20 6e 6f 6d 69 6e 61 6c 20      the nominal 
43c0: 72 6f 6f 74 20 74 6f 20 62 65 20 6c 61 74 65 72  root to be later
43d0: 20 69 6e 20 74 69 6d 65 20 74 68 61 6e 20 74 68   in time than th
43e0: 65 20 4e 54 44 42 0a 09 23 20 20 20 20 20 72 6f  e NTDB..#     ro
43f0: 6f 74 2e 20 4e 6f 77 20 73 65 74 74 69 6e 67 20  ot. Now setting 
4400: 74 68 69 73 20 64 65 70 65 6e 64 65 6e 63 79 20  this dependency 
4410: 77 69 6c 6c 20 62 65 20 62 61 63 6b 77 61 72 64  will be backward
4420: 20 69 6e 0a 09 23 20 20 20 20 20 74 69 6d 65 2e   in..#     time.
4430: 20 52 45 4d 4f 56 45 44 2e 0a 09 23 0a 09 23 20   REMOVED...#..# 
4440: 28 34 29 20 49 66 20 52 20 69 73 20 74 68 65 20  (4) If R is the 
4450: 6c 61 73 74 20 6f 66 20 74 68 65 20 4e 54 44 42  last of the NTDB
4460: 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63 68   revisions which
4470: 20 62 65 6c 6f 6e 67 20 74 6f 0a 09 23 20 20 20   belong to..#   
4480: 20 20 74 68 65 20 74 72 75 6e 6b 2c 20 74 68 65    the trunk, the
4490: 6e 20 74 68 65 20 70 72 69 6d 61 72 79 20 63 68  n the primary ch
44a0: 69 6c 64 20 6f 66 20 74 68 65 20 74 72 75 6e 6b  ild of the trunk
44b0: 20 72 6f 6f 74 20 28 74 68 65 0a 09 23 20 20 20   root (the..#   
44c0: 20 20 27 31 2e 32 27 20 72 65 76 69 73 69 6f 6e    '1.2' revision
44d0: 29 20 69 73 20 61 20 73 75 63 63 65 73 73 6f 72  ) is a successor
44e0: 2c 20 69 66 20 69 74 20 65 78 69 73 74 73 2e 0a  , if it exists..
44f0: 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 63  ..foreach {rid c
4500: 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75 6e  hild} [state run
4510: 20 22 0a 20 20 20 2d 2d 20 28 31 29 20 50 72 69   ".   -- (1) Pri
4520: 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20  mary child..    
4530: 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 2e  SELECT R.rid, R.
4540: 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20  child..    FROM 
4550: 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20    revision R..  
4560: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20    WHERE  R.rid  
4570: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
4580: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72  -- Restrict to r
4590: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65  evisions of inte
45a0: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rest..    AND   
45b0: 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20   R.child IS NOT 
45c0: 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70  NULL    -- Has p
45d0: 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 20 20 20  rimary child.   
45e0: 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 32   UNION.    -- (2
45f0: 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72 61  ) Secondary (bra
4600: 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 20  nch) children.. 
4610: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c     SELECT R.rid,
4620: 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46 52 4f   B.brid..    FRO
4630: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20  M   revision R, 
4640: 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68  revisionbranchch
4650: 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 57 48  ildren B..    WH
4660: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20  ERE  R.rid   IN 
4670: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52  $theset     -- R
4680: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73  estrict to revis
4690: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74  ions of interest
46a0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72  ..    AND    R.r
46b0: 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20 20  id = B.rid      
46c0: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73 75      -- Select su
46d0: 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20 63  bset of branch c
46e0: 68 69 6c 64 72 65 6e 0a 20 20 20 20 55 4e 49 4f  hildren.    UNIO
46f0: 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20 43 68 69  N.    -- (4) Chi
4700: 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74  ld of trunk root
4710: 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 6c 61   successor of la
4720: 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b  st NTDB on trunk
4730: 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e  ...    SELECT R.
4740: 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09 20  rid, RA.child.. 
4750: 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e     FROM revision
4760: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 0a   R, revision RA.
4770: 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64  .    WHERE R.rid
4780: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20     IN $theset   
4790: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
47a0: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
47b0: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
47c0: 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74 20 20     R.isdefault  
47d0: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65             -- Re
47e0: 73 74 72 69 63 74 20 74 6f 20 4e 54 44 42 0a 09  strict to NTDB..
47f0: 20 20 20 20 41 4e 44 20 20 20 52 2e 64 62 63 68      AND   R.dbch
4800: 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20  ild IS NOT NULL 
4810: 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74 20 4e 54    -- and last NT
4820: 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20  DB belonging to 
4830: 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e 44 20 20  trunk..    AND  
4840: 20 52 41 2e 72 69 64 20 3d 20 52 2e 64 62 63 68   RA.rid = R.dbch
4850: 69 6c 64 20 20 20 20 20 20 2d 2d 20 47 6f 20 64  ild      -- Go d
4860: 69 72 65 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b  irectly to trunk
4870: 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e 44 20 20   root..    AND  
4880: 20 52 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54   RA.child IS NOT
4890: 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20   NULL    -- Has 
48a0: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09  primary child...
48b0: 22 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73  "] {..    # Cons
48c0: 69 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69 73  ider moving this
48d0: 20 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69 74   to the integrit
48e0: 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69  y module...    i
48f0: 66 20 7b 24 72 69 64 20 3d 3d 20 24 63 68 69 6c  f {$rid == $chil
4900: 64 7d 20 7b 0a 09 09 74 72 6f 75 62 6c 65 20 69  d} {...trouble i
4910: 6e 74 65 72 6e 61 6c 20 22 52 65 76 69 73 69 6f  nternal "Revisio
4920: 6e 20 24 72 69 64 20 64 65 70 65 6e 64 73 20 6f  n $rid depends o
4930: 6e 20 69 74 73 65 6c 66 2e 22 0a 09 20 20 20 20  n itself."..    
4940: 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64  }..    lappend d
4950: 65 70 65 6e 64 65 6e 63 69 65 73 28 24 72 69 64  ependencies($rid
4960: 29 20 24 63 68 69 6c 64 0a 09 7d 0a 09 72 65 74  ) $child..}..ret
4970: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70  urn.    }..    p
4980: 72 6f 63 20 50 75 6c 6c 50 72 65 64 65 63 65 73  roc PullPredeces
4990: 73 6f 72 52 65 76 69 73 69 6f 6e 73 20 7b 64 76  sorRevisions {dv
49a0: 20 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75   revisions} {..u
49b0: 70 76 61 72 20 31 20 24 64 76 20 64 65 70 65 6e  pvar 1 $dv depen
49c0: 64 65 6e 63 69 65 73 0a 09 73 65 74 20 74 68 65  dencies..set the
49d0: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76  set ('[join $rev
49e0: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a  isions {','}]').
49f0: 0a 09 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e  ..# The followin
4a00: 67 20 63 61 73 65 73 20 73 70 65 63 69 66 79 20  g cases specify 
4a10: 77 68 65 6e 20 61 20 72 65 76 69 73 69 6f 6e 20  when a revision 
4a20: 50 20 69 73 20 61 0a 09 23 20 70 72 65 64 65 63  P is a..# predec
4a30: 65 73 73 6f 72 20 6f 66 20 61 20 72 65 76 69 73  essor of a revis
4a40: 69 6f 6e 20 52 2e 20 45 61 63 68 20 6f 66 20 74  ion R. Each of t
4a50: 68 65 20 63 61 73 65 73 20 74 72 61 6e 73 6c 61  he cases transla
4a60: 74 65 73 0a 09 23 20 69 6e 74 6f 20 6f 6e 65 20  tes..# into one 
4a70: 6f 66 20 74 68 65 20 62 72 61 6e 63 68 65 73 20  of the branches 
4a80: 6f 66 20 74 68 65 20 53 51 4c 20 55 4e 49 4f 4e  of the SQL UNION
4a90: 20 63 6f 6d 69 6e 67 20 62 65 6c 6f 77 2e 0a 09   coming below...
4aa0: 23 0a 09 23 20 28 31 29 20 54 68 65 20 69 6d 6d  #..# (1) The imm
4ab0: 65 64 69 61 74 65 20 70 61 72 65 6e 74 20 52 2e  ediate parent R.
4ac0: 70 61 72 65 6e 74 20 6f 66 20 52 20 69 73 20 61  parent of R is a
4ad0: 20 70 72 65 64 65 63 65 73 73 6f 72 20 6f 66 0a   predecessor of.
4ae0: 09 23 20 20 20 20 20 52 2e 20 4e 4f 54 45 3a 20  .#     R. NOTE: 
4af0: 54 68 69 73 20 69 73 20 74 72 75 65 20 66 6f 72  This is true for
4b00: 20 52 20 65 69 74 68 65 72 20 70 72 69 6d 61 72   R either primar
4b10: 79 20 6f 72 20 73 65 63 6f 6e 64 61 72 79 0a 09  y or secondary..
4b20: 23 20 20 20 20 20 63 68 69 6c 64 20 6f 66 20 50  #     child of P
4b30: 2e 20 49 74 20 6e 6f 74 20 6e 65 63 65 73 73 61  . It not necessa
4b40: 72 79 20 74 6f 20 64 69 73 74 69 6e 67 75 69 73  ry to distinguis
4b50: 68 20 74 68 65 20 74 77 6f 0a 09 23 20 20 20 20  h the two..#    
4b60: 20 63 61 73 65 73 2c 20 69 6e 20 63 6f 6e 74 72   cases, in contr
4b70: 61 73 74 20 74 6f 20 74 68 65 20 63 6f 64 65 20  ast to the code 
4b80: 72 65 74 72 69 65 76 69 6e 67 20 74 68 65 20 73  retrieving the s
4b90: 75 63 63 65 73 73 6f 72 0a 09 23 20 20 20 20 20  uccessor..#     
4ba0: 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e 0a 09 23 0a  information...#.
4bb0: 09 23 20 28 32 29 20 54 68 65 20 63 6f 6d 70 6c  .# (2) The compl
4bc0: 65 6d 65 6e 74 20 6f 66 20 73 75 63 63 65 73 73  ement of success
4bd0: 6f 72 20 63 61 73 65 20 28 33 29 2e 20 54 68 65  or case (3). The
4be0: 20 74 72 75 6e 6b 20 72 6f 6f 74 20 69 73 0a 09   trunk root is..
4bf0: 23 20 20 20 20 20 61 20 70 72 65 64 65 63 65 73  #     a predeces
4c00: 73 6f 72 20 6f 66 20 61 20 4e 54 44 42 20 72 6f  sor of a NTDB ro
4c10: 6f 74 2e 20 52 45 4d 4f 56 45 44 2e 20 53 65 65  ot. REMOVED. See
4c20: 0a 09 23 20 20 20 20 20 50 75 6c 6c 53 75 63 63  ..#     PullSucc
4c30: 65 73 73 6f 72 52 65 76 69 73 69 6f 6e 73 20 66  essorRevisions f
4c40: 6f 72 20 74 68 65 20 65 78 70 6c 61 6e 61 74 69  or the explanati
4c50: 6f 6e 2e 0a 09 23 0a 09 23 20 28 33 29 20 54 68  on...#..# (3) Th
4c60: 65 20 63 6f 6d 70 6c 65 6d 65 6e 74 20 6f 66 20  e complement of 
4c70: 73 75 63 63 65 73 73 6f 72 20 63 61 73 65 20 28  successor case (
4c80: 34 29 2e 20 54 68 65 20 6c 61 73 74 20 4e 54 44  4). The last NTD
4c90: 42 0a 09 23 20 20 20 20 20 72 65 76 69 73 69 6f  B..#     revisio
4ca0: 6e 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74  n belonging to t
4cb0: 68 65 20 74 72 75 6e 6b 20 69 73 20 61 20 70 72  he trunk is a pr
4cc0: 65 64 65 63 65 73 73 6f 72 20 6f 66 20 74 68 65  edecessor of the
4cd0: 0a 09 23 20 20 20 20 20 70 72 69 6d 61 72 79 20  ..#     primary 
4ce0: 63 68 69 6c 64 20 6f 66 20 74 68 65 20 74 72 75  child of the tru
4cf0: 6e 6b 20 72 6f 6f 74 20 28 54 68 65 20 27 31 2e  nk root (The '1.
4d00: 32 27 20 72 65 76 69 73 69 6f 6e 29 2e 0a 0a 09  2' revision)....
4d10: 66 6f 72 65 61 63 68 20 7b 72 69 64 20 70 61 72  foreach {rid par
4d20: 65 6e 74 7d 20 5b 73 74 61 74 65 20 72 75 6e 20  ent} [state run 
4d30: 22 0a 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d  ".   -- (1) Prim
4d40: 61 72 79 20 70 61 72 65 6e 74 2c 20 63 61 6e 20  ary parent, can 
4d50: 62 65 20 69 6e 20 64 69 66 66 65 72 65 6e 74 20  be in different 
4d60: 4c 4f 44 20 66 6f 72 20 66 69 72 73 74 20 69 6e  LOD for first in
4d70: 20 61 20 62 72 61 6e 63 68 0a 09 20 20 20 20 53   a branch..    S
4d80: 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 2e 70  ELECT R.rid, R.p
4d90: 61 72 65 6e 74 0a 09 20 20 20 20 46 52 4f 4d 20  arent..    FROM 
4da0: 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20    revision R..  
4db0: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20    WHERE  R.rid  
4dc0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
4dd0: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72  -- Restrict to r
4de0: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65  evisions of inte
4df0: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20  rest..    AND   
4e00: 20 52 2e 70 61 72 65 6e 74 20 49 53 20 4e 4f 54   R.parent IS NOT
4e10: 20 4e 55 4c 4c 20 20 20 2d 2d 20 48 61 73 20 70   NULL   -- Has p
4e20: 72 69 6d 61 72 79 20 70 61 72 65 6e 74 0a 20 20  rimary parent.  
4e30: 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28    UNION.    -- (
4e40: 33 29 20 4c 61 73 74 20 4e 54 44 42 20 6f 6e 20  3) Last NTDB on 
4e50: 74 72 75 6e 6b 20 69 73 20 70 72 65 64 65 63 65  trunk is predece
4e60: 73 73 6f 72 20 6f 66 20 63 68 69 6c 64 20 6f 66  ssor of child of
4e70: 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20   trunk root..   
4e80: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52   SELECT R.rid, R
4e90: 41 2e 64 62 70 61 72 65 6e 74 0a 09 20 20 20 20  A.dbparent..    
4ea0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c  FROM revision R,
4eb0: 20 72 65 76 69 73 69 6f 6e 20 52 41 0a 09 20 20   revision RA..  
4ec0: 20 20 57 48 45 52 45 20 52 2e 72 69 64 20 49 4e    WHERE R.rid IN
4ed0: 20 24 74 68 65 73 65 74 20 20 20 20 20 20 20 2d   $theset       -
4ee0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65  - Restrict to re
4ef0: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72  visions of inter
4f00: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 4e 4f 54  est..    AND NOT
4f10: 20 52 2e 69 73 64 65 66 61 75 6c 74 20 20 20 20   R.isdefault    
4f20: 20 20 20 20 20 20 2d 2d 20 6e 6f 74 20 6f 6e 20        -- not on 
4f30: 4e 54 44 42 0a 09 20 20 20 20 41 4e 44 20 52 2e  NTDB..    AND R.
4f40: 70 61 72 65 6e 74 20 49 53 20 4e 4f 54 20 4e 55  parent IS NOT NU
4f50: 4c 4c 20 20 20 20 20 2d 2d 20 77 68 69 63 68 20  LL     -- which 
4f60: 61 72 65 20 6e 6f 74 20 72 6f 6f 74 0a 09 20 20  are not root..  
4f70: 20 20 41 4e 44 20 52 41 2e 72 69 64 20 3d 20 52    AND RA.rid = R
4f80: 2e 70 61 72 65 6e 74 20 20 20 20 20 20 20 20 2d  .parent        -
4f90: 2d 20 67 6f 20 74 6f 20 74 68 65 69 72 20 70 61  - go to their pa
4fa0: 72 65 6e 74 0a 09 20 20 20 20 41 4e 44 20 52 41  rent..    AND RA
4fb0: 2e 64 62 70 61 72 65 6e 74 20 49 53 20 4e 4f 54  .dbparent IS NOT
4fc0: 20 4e 55 4c 4c 20 20 2d 2d 20 77 68 69 63 68 20   NULL  -- which 
4fd0: 68 61 73 20 74 6f 20 72 65 66 65 72 20 74 6f 20  has to refer to 
4fe0: 4e 54 44 42 27 73 20 72 6f 6f 74 0a 09 22 5d 20  NTDB's root.."] 
4ff0: 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73 69 64 65  {..    # Conside
5000: 72 20 6d 6f 76 69 6e 67 20 74 68 69 73 20 74 6f  r moving this to
5010: 20 74 68 65 20 69 6e 74 65 67 72 69 74 79 20 6d   the integrity m
5020: 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69 66 20 7b  odule...    if {
5030: 24 72 69 64 20 3d 3d 20 24 70 61 72 65 6e 74 7d  $rid == $parent}
5040: 20 7b 0a 09 09 74 72 6f 75 62 6c 65 20 69 6e 74   {...trouble int
5050: 65 72 6e 61 6c 20 22 52 65 76 69 73 69 6f 6e 20  ernal "Revision 
5060: 24 72 69 64 20 64 65 70 65 6e 64 73 20 6f 6e 20  $rid depends on 
5070: 69 74 73 65 6c 66 2e 22 0a 09 20 20 20 20 7d 0a  itself."..    }.
5080: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70  .    lappend dep
5090: 65 6e 64 65 6e 63 69 65 73 28 24 72 69 64 29 20  endencies($rid) 
50a0: 24 70 61 72 65 6e 74 0a 09 7d 0a 09 72 65 74 75  $parent..}..retu
50b0: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72  rn.    }..    pr
50c0: 6f 63 20 49 6e 69 74 69 61 6c 69 7a 65 42 72 65  oc InitializeBre
50d0: 61 6b 53 74 61 74 65 20 7b 72 65 76 69 73 69 6f  akState {revisio
50e0: 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 70  ns} {..upvar 1 p
50f0: 6f 73 20 70 6f 73 20 63 72 6f 73 73 20 63 72 6f  os pos cross cro
5100: 73 73 20 72 61 6e 67 65 20 72 61 6e 67 65 20 64  ss range range d
5110: 65 70 63 20 64 65 70 63 20 64 65 6c 74 61 20 64  epc depc delta d
5120: 65 6c 74 61 20 5c 0a 09 20 20 20 20 64 65 70 65  elta \..    depe
5130: 6e 64 65 6e 63 69 65 73 20 64 65 70 65 6e 64 65  ndencies depende
5140: 6e 63 69 65 73 0a 0a 09 23 20 46 69 72 73 74 20  ncies...# First 
5150: 77 65 20 63 72 65 61 74 65 20 61 20 6d 61 70 20  we create a map 
5160: 6f 66 20 70 6f 73 69 74 69 6f 6e 73 20 74 6f 20  of positions to 
5170: 6d 61 6b 65 20 69 74 20 65 61 73 69 65 72 20 74  make it easier t
5180: 6f 0a 09 23 20 64 65 74 65 72 6d 69 6e 65 20 77  o..# determine w
5190: 68 65 74 68 65 72 20 61 20 64 65 70 65 6e 64 65  hether a depende
51a0: 6e 63 79 20 63 72 6f 73 73 65 73 20 61 20 70 61  ncy crosses a pa
51b0: 72 74 69 63 75 6c 61 72 20 69 6e 64 65 78 2e 0a  rticular index..
51c0: 0a 09 61 72 72 61 79 20 73 65 74 20 70 6f 73 20  ..array set pos 
51d0: 20 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 20    {}..array set 
51e0: 63 72 6f 73 73 20 7b 7d 0a 09 61 72 72 61 79 20  cross {}..array 
51f0: 73 65 74 20 64 65 70 63 20 20 7b 7d 0a 09 73 65  set depc  {}..se
5200: 74 20 72 61 6e 67 65 20 20 20 20 20 20 20 7b 7d  t range       {}
5210: 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 65 61  ..set n 0..forea
5220: 63 68 20 72 65 76 20 24 72 65 76 69 73 69 6f 6e  ch rev $revision
5230: 73 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64  s {..    lappend
5240: 20 72 61 6e 67 65 20 24 6e 0a 09 20 20 20 20 73   range $n..    s
5250: 65 74 20 70 6f 73 28 24 72 65 76 29 20 24 6e 0a  et pos($rev) $n.
5260: 09 20 20 20 20 73 65 74 20 63 72 6f 73 73 28 24  .    set cross($
5270: 6e 29 20 30 0a 09 20 20 20 20 69 6e 63 72 20 6e  n) 0..    incr n
5280: 0a 09 7d 0a 0a 09 23 20 53 65 63 6f 6e 64 6c 79  ..}...# Secondly
5290: 20 77 65 20 63 6f 75 6e 74 20 74 68 65 20 63 72   we count the cr
52a0: 6f 73 73 69 6e 67 73 20 70 65 72 20 70 6f 73 69  ossings per posi
52b0: 74 69 6f 6e 2c 20 62 79 20 69 74 65 72 61 74 69  tion, by iterati
52c0: 6e 67 0a 09 23 20 6f 76 65 72 20 74 68 65 20 72  ng..# over the r
52d0: 65 63 6f 72 64 65 64 20 69 6e 74 65 72 6e 61 6c  ecorded internal
52e0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 0a 0a   dependencies...
52f0: 09 23 20 4e 6f 74 65 3a 20 49 66 20 74 68 65 20  .# Note: If the 
5300: 74 69 6d 65 73 74 61 6d 70 73 20 61 72 65 20 62  timestamps are b
5310: 61 64 6c 79 20 6f 75 74 20 6f 66 20 6f 72 64 65  adly out of orde
5320: 72 20 69 74 20 69 73 0a 09 23 20 20 20 20 20 20  r it is..#      
5330: 20 70 6f 73 73 69 62 6c 65 20 74 6f 20 68 61 76   possible to hav
5340: 65 20 61 20 62 61 63 6b 77 61 72 64 20 73 75 63  e a backward suc
5350: 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63  cessor dependenc
5360: 79 2c 0a 09 23 20 20 20 20 20 20 20 69 2e 65 2e  y,..#       i.e.
5370: 20 77 69 74 68 20 73 74 61 72 74 20 3e 20 65 6e   with start > en
5380: 64 2e 20 57 65 20 6d 61 79 20 68 61 76 65 20 74  d. We may have t
5390: 6f 20 73 77 61 70 20 74 68 65 20 69 6e 64 69 63  o swap the indic
53a0: 65 73 0a 09 23 20 20 20 20 20 20 20 74 6f 20 65  es..#       to e
53b0: 6e 73 75 72 65 20 74 68 61 74 20 74 68 65 20 66  nsure that the f
53c0: 6f 6c 6c 6f 77 69 6e 67 20 6c 6f 6f 70 20 72 75  ollowing loop ru
53d0: 6e 73 20 63 6f 72 72 65 63 74 6c 79 2e 0a 09 23  ns correctly...#
53e0: 0a 09 23 20 4e 6f 74 65 20 32 3a 20 73 74 61 72  ..# Note 2: star
53f0: 74 20 3d 3d 20 65 6e 64 20 69 73 20 6e 6f 74 20  t == end is not 
5400: 70 6f 73 73 69 62 6c 65 2e 20 49 74 20 69 6e 64  possible. It ind
5410: 69 63 61 74 65 73 20 61 0a 09 23 20 20 20 20 20  icates a..#     
5420: 20 20 20 20 73 65 6c 66 2d 64 65 70 65 6e 64 65      self-depende
5430: 6e 63 79 20 64 75 65 20 74 6f 20 74 68 65 20 75  ncy due to the u
5440: 6e 69 71 75 65 6e 65 73 73 20 6f 66 20 70 6f 73  niqueness of pos
5450: 69 74 69 6f 6e 73 2c 0a 09 23 20 20 20 20 20 20  itions,..#      
5460: 20 20 20 61 6e 64 20 74 68 61 74 20 69 73 20 73     and that is s
5470: 6f 6d 65 74 68 69 6e 67 20 77 65 20 68 61 76 65  omething we have
5480: 20 72 75 6c 65 64 20 6f 75 74 20 61 6c 72 65 61   ruled out alrea
5490: 64 79 2c 20 73 65 65 0a 09 23 20 20 20 20 20 20  dy, see..#      
54a0: 20 20 20 50 75 6c 6c 49 6e 74 65 72 6e 61 6c 53     PullInternalS
54b0: 75 63 63 65 73 73 6f 72 52 65 76 69 73 69 6f 6e  uccessorRevision
54c0: 73 2e 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69  s....foreach {ri
54d0: 64 20 63 68 69 6c 64 72 65 6e 7d 20 5b 61 72 72  d children} [arr
54e0: 61 79 20 67 65 74 20 64 65 70 65 6e 64 65 6e 63  ay get dependenc
54f0: 69 65 73 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65  ies] {..    fore
5500: 61 63 68 20 63 68 69 6c 64 20 24 63 68 69 6c 64  ach child $child
5510: 72 65 6e 20 7b 0a 09 09 73 65 74 20 64 6b 65 79  ren {...set dkey
5520: 20 20 20 20 5b 6c 69 73 74 20 24 72 69 64 20 24      [list $rid $
5530: 63 68 69 6c 64 5d 0a 09 09 73 65 74 20 73 74 61  child]...set sta
5540: 72 74 20 20 20 24 70 6f 73 28 24 72 69 64 29 0a  rt   $pos($rid).
5550: 09 09 73 65 74 20 65 6e 64 20 20 20 20 20 24 70  ..set end     $p
5560: 6f 73 28 24 63 68 69 6c 64 29 0a 09 09 73 65 74  os($child)...set
5570: 20 63 72 6f 73 73 65 73 20 7b 7d 0a 0a 09 09 69   crosses {}....i
5580: 66 20 7b 24 73 74 61 72 74 20 3e 20 24 65 6e 64  f {$start > $end
5590: 7d 20 7b 0a 09 09 20 20 20 20 77 68 69 6c 65 20  } {...    while 
55a0: 7b 24 65 6e 64 20 3c 20 24 73 74 61 72 74 7d 20  {$end < $start} 
55b0: 7b 0a 09 09 09 6c 61 70 70 65 6e 64 20 63 72 6f  {....lappend cro
55c0: 73 73 65 73 20 24 65 6e 64 0a 09 09 09 69 6e 63  sses $end....inc
55d0: 72 20 63 72 6f 73 73 28 24 65 6e 64 29 0a 09 09  r cross($end)...
55e0: 09 69 6e 63 72 20 65 6e 64 0a 09 09 20 20 20 20  .incr end...    
55f0: 7d 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20  }...} else {... 
5600: 20 20 20 77 68 69 6c 65 20 7b 24 73 74 61 72 74     while {$start
5610: 20 3c 20 24 65 6e 64 7d 20 7b 0a 09 09 09 6c 61   < $end} {....la
5620: 70 70 65 6e 64 20 63 72 6f 73 73 65 73 20 24 73  ppend crosses $s
5630: 74 61 72 74 0a 09 09 09 69 6e 63 72 20 63 72 6f  tart....incr cro
5640: 73 73 28 24 73 74 61 72 74 29 0a 09 09 09 69 6e  ss($start)....in
5650: 63 72 20 73 74 61 72 74 0a 09 09 20 20 20 20 7d  cr start...    }
5660: 0a 09 09 7d 0a 09 09 73 65 74 20 64 65 70 63 28  ...}...set depc(
5670: 24 64 6b 65 79 29 20 24 63 72 6f 73 73 65 73 0a  $dkey) $crosses.
5680: 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 49 6e 69 74  .    }..}...Init
5690: 69 61 6c 69 7a 65 44 65 6c 74 61 73 20 24 72 65  ializeDeltas $re
56a0: 76 69 73 69 6f 6e 73 0a 09 72 65 74 75 72 6e 0a  visions..return.
56b0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20      }..    proc 
56c0: 49 6e 69 74 69 61 6c 69 7a 65 44 65 6c 74 61 73  InitializeDeltas
56d0: 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09   {revisions} {..
56e0: 75 70 76 61 72 20 31 20 64 65 6c 74 61 20 64 65  upvar 1 delta de
56f0: 6c 74 61 0a 0a 09 23 20 50 75 6c 6c 20 74 68 65  lta...# Pull the
5700: 20 74 69 6d 65 73 74 61 6d 70 73 20 66 6f 72 20   timestamps for 
5710: 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 69 6e  all revisions in
5720: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 73 20   the changesets 
5730: 61 6e 64 0a 09 23 20 63 6f 6d 70 75 74 65 20 74  and..# compute t
5740: 68 65 69 72 20 64 65 6c 74 61 73 20 66 6f 72 20  heir deltas for 
5750: 75 73 65 20 62 79 20 74 68 65 20 62 72 65 61 6b  use by the break
5760: 20 66 69 6e 64 65 72 2e 0a 0a 09 61 72 72 61 79   finder....array
5770: 20 73 65 74 20 64 65 6c 74 61 20 7b 7d 0a 09 61   set delta {}..a
5780: 72 72 61 79 20 73 65 74 20 73 74 61 6d 70 20 7b  rray set stamp {
5790: 7d 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28  }...set theset (
57a0: 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e  '[join $revision
57b0: 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 66 6f 72 65  s {','}]')..fore
57c0: 61 63 68 20 7b 72 69 64 20 74 69 6d 65 7d 20 5b  ach {rid time} [
57d0: 73 74 61 74 65 20 72 75 6e 20 22 0a 09 20 20 20  state run "..   
57e0: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52   SELECT R.rid, R
57f0: 2e 64 61 74 65 0a 09 20 20 20 20 46 52 4f 4d 20  .date..    FROM 
5800: 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20  revision R..    
5810: 57 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20 24  WHERE R.rid IN $
5820: 74 68 65 73 65 74 0a 09 22 5d 20 7b 0a 09 20 20  theset.."] {..  
5830: 20 20 73 65 74 20 73 74 61 6d 70 28 24 72 69 64    set stamp($rid
5840: 29 20 24 74 69 6d 65 0a 09 7d 0a 0a 09 73 65 74  ) $time..}...set
5850: 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 20 72 69   n 0..foreach ri
5860: 64 20 5b 6c 72 61 6e 67 65 20 24 72 65 76 69 73  d [lrange $revis
5870: 69 6f 6e 73 20 30 20 65 6e 64 2d 31 5d 20 72 6e  ions 0 end-1] rn
5880: 65 78 74 20 5b 6c 72 61 6e 67 65 20 24 72 65 76  ext [lrange $rev
5890: 69 73 69 6f 6e 73 20 31 20 65 6e 64 5d 20 7b 0a  isions 1 end] {.
58a0: 09 20 20 20 20 73 65 74 20 64 65 6c 74 61 28 24  .    set delta($
58b0: 6e 29 20 5b 65 78 70 72 20 7b 24 73 74 61 6d 70  n) [expr {$stamp
58c0: 28 24 72 6e 65 78 74 29 20 2d 20 24 73 74 61 6d  ($rnext) - $stam
58d0: 70 28 24 72 69 64 29 7d 5d 0a 09 20 20 20 20 69  p($rid)}]..    i
58e0: 6e 63 72 20 6e 0a 09 7d 0a 09 72 65 74 75 72 6e  ncr n..}..return
58f0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63  .    }..    proc
5900: 20 46 69 6e 64 42 65 73 74 42 72 65 61 6b 20 7b   FindBestBreak {
5910: 72 61 6e 67 65 7d 20 7b 0a 09 75 70 76 61 72 20  range} {..upvar 
5920: 31 20 63 72 6f 73 73 20 63 72 6f 73 73 20 64 65  1 cross cross de
5930: 6c 74 61 20 64 65 6c 74 61 0a 0a 09 23 20 44 65  lta delta...# De
5940: 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65 73 74  termine the best
5950: 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 20   break location 
5960: 69 6e 20 74 68 65 20 67 69 76 65 6e 20 72 61 6e  in the given ran
5970: 67 65 20 6f 66 0a 09 23 20 70 6f 73 69 74 69 6f  ge of..# positio
5980: 6e 73 2e 20 46 69 72 73 74 20 77 65 20 6c 6f 6f  ns. First we loo
5990: 6b 20 66 6f 72 20 74 68 65 20 6c 6f 63 61 74 69  k for the locati
59a0: 6f 6e 73 20 77 69 74 68 20 74 68 65 20 6d 61 78  ons with the max
59b0: 69 6d 61 6c 0a 09 23 20 6e 75 6d 62 65 72 20 6f  imal..# number o
59c0: 66 20 63 72 6f 73 73 69 6e 67 73 2e 20 49 66 20  f crossings. If 
59d0: 74 68 65 72 65 20 61 72 65 20 73 65 76 65 72 61  there are severa
59e0: 6c 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20 74 68  l we look for th
59f0: 65 0a 09 23 20 73 68 6f 72 74 65 73 74 20 74 69  e..# shortest ti
5a00: 6d 65 20 69 6e 74 65 72 76 61 6c 20 61 6d 6f 6e  me interval amon
5a10: 67 20 74 68 65 6d 2e 20 49 66 20 77 65 20 73 74  g them. If we st
5a20: 69 6c 6c 20 68 61 76 65 20 6d 75 6c 74 69 70 6c  ill have multipl
5a30: 65 0a 09 23 20 70 6f 73 73 69 62 69 6c 69 74 69  e..# possibiliti
5a40: 65 73 20 61 66 74 65 72 20 74 68 61 74 20 77 65  es after that we
5a50: 20 73 65 6c 65 63 74 20 74 68 65 20 65 61 72 6c   select the earl
5a60: 69 65 73 74 20 6c 6f 63 61 74 69 6f 6e 0a 09 23  iest location..#
5a70: 20 61 6d 6f 6e 67 20 74 68 65 73 65 2e 0a 0a 09   among these....
5a80: 23 20 4e 6f 74 65 3a 20 49 66 20 74 68 65 20 6d  # Note: If the m
5a90: 61 78 69 6d 61 6c 20 6e 75 6d 62 65 72 20 6f 66  aximal number of
5aa0: 20 63 72 6f 73 73 69 6e 67 73 20 69 73 20 30 20   crossings is 0 
5ab0: 74 68 65 6e 20 74 68 65 20 72 61 6e 67 65 0a 09  then the range..
5ac0: 23 20 20 20 20 20 20 20 68 61 73 20 6e 6f 20 69  #       has no i
5ad0: 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e  nternal dependen
5ae0: 63 69 65 73 2c 20 61 6e 64 20 6e 6f 20 62 72 65  cies, and no bre
5af0: 61 6b 20 6c 6f 63 61 74 69 6f 6e 20 61 74 0a 09  ak location at..
5b00: 23 20 20 20 20 20 20 20 61 6c 6c 2e 20 54 68 69  #       all. Thi
5b10: 73 20 70 6f 73 73 69 62 69 6c 69 74 79 20 69 73  s possibility is
5b20: 20 73 69 67 6e 61 6c 65 64 20 76 69 61 20 72 65   signaled via re
5b30: 73 75 6c 74 20 2d 31 2e 0a 0a 09 23 20 4e 6f 74  sult -1....# Not
5b40: 65 3a 20 41 20 72 61 6e 67 65 20 6f 66 20 6c 65  e: A range of le
5b50: 6e 67 74 68 20 31 20 6f 72 20 6c 65 73 73 20 63  ngth 1 or less c
5b60: 61 6e 6e 6f 74 20 68 61 76 65 20 69 6e 74 65 72  annot have inter
5b70: 6e 61 6c 0a 09 23 20 20 20 20 20 20 20 64 65 70  nal..#       dep
5b80: 65 6e 64 65 6e 63 69 65 73 2c 20 61 73 20 74 68  endencies, as th
5b90: 61 74 20 6e 65 65 64 73 20 61 74 20 6c 65 61 73  at needs at leas
5ba0: 74 20 74 77 6f 20 72 65 76 69 73 69 6f 6e 73 20  t two revisions 
5bb0: 69 6e 0a 09 23 20 20 20 20 20 20 20 74 68 65 20  in..#       the 
5bc0: 72 61 6e 67 65 2e 0a 0a 09 69 66 20 7b 5b 6c 6c  range....if {[ll
5bd0: 65 6e 67 74 68 20 24 72 61 6e 67 65 5d 20 3c 20  ength $range] < 
5be0: 32 7d 20 7b 20 72 65 74 75 72 6e 20 2d 31 20 7d  2} { return -1 }
5bf0: 0a 0a 09 73 65 74 20 6d 61 78 20 2d 31 0a 09 73  ...set max -1..s
5c00: 65 74 20 62 65 73 74 20 7b 7d 0a 0a 09 66 6f 72  et best {}...for
5c10: 65 61 63 68 20 6c 6f 63 61 74 69 6f 6e 20 24 72  each location $r
5c20: 61 6e 67 65 20 7b 0a 09 20 20 20 20 73 65 74 20  ange {..    set 
5c30: 63 72 6f 73 73 69 6e 67 73 20 24 63 72 6f 73 73  crossings $cross
5c40: 28 24 6c 6f 63 61 74 69 6f 6e 29 0a 09 20 20 20  ($location)..   
5c50: 20 69 66 20 7b 24 63 72 6f 73 73 69 6e 67 73 20   if {$crossings 
5c60: 3e 20 24 6d 61 78 7d 20 7b 0a 09 09 73 65 74 20  > $max} {...set 
5c70: 6d 61 78 20 20 24 63 72 6f 73 73 69 6e 67 73 0a  max  $crossings.
5c80: 09 09 73 65 74 20 62 65 73 74 20 5b 6c 69 73 74  ..set best [list
5c90: 20 24 6c 6f 63 61 74 69 6f 6e 5d 0a 09 09 63 6f   $location]...co
5ca0: 6e 74 69 6e 75 65 0a 09 20 20 20 20 7d 20 65 6c  ntinue..    } el
5cb0: 73 65 69 66 20 7b 24 63 72 6f 73 73 69 6e 67 73  seif {$crossings
5cc0: 20 3d 3d 20 24 6d 61 78 7d 20 7b 0a 09 09 6c 61   == $max} {...la
5cd0: 70 70 65 6e 64 20 62 65 73 74 20 24 6c 6f 63 61  ppend best $loca
5ce0: 74 69 6f 6e 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  tion..    }..}..
5cf0: 09 69 66 20 7b 24 6d 61 78 20 3d 3d 20 30 7d 20  .if {$max == 0} 
5d00: 20 20 20 20 20 20 20 20 20 20 20 7b 20 72 65 74             { ret
5d10: 75 72 6e 20 2d 31 20 7d 0a 09 69 66 20 7b 5b 6c  urn -1 }..if {[l
5d20: 6c 65 6e 67 74 68 20 24 62 65 73 74 5d 20 3d 3d  length $best] ==
5d30: 20 31 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69   1} { return [li
5d40: 6e 64 65 78 20 24 62 65 73 74 20 30 5d 20 7d 0a  ndex $best 0] }.
5d50: 0a 09 73 65 74 20 6c 6f 63 61 74 69 6f 6e 73 20  ..set locations 
5d60: 24 62 65 73 74 0a 09 73 65 74 20 62 65 73 74 20  $best..set best 
5d70: 7b 7d 0a 09 73 65 74 20 6d 69 6e 20 2d 31 0a 0a  {}..set min -1..
5d80: 09 66 6f 72 65 61 63 68 20 6c 6f 63 61 74 69 6f  .foreach locatio
5d90: 6e 20 24 6c 6f 63 61 74 69 6f 6e 73 20 7b 0a 09  n $locations {..
5da0: 20 20 20 20 73 65 74 20 69 6e 74 65 72 76 61 6c      set interval
5db0: 20 24 64 65 6c 74 61 28 24 6c 6f 63 61 74 69 6f   $delta($locatio
5dc0: 6e 29 0a 09 20 20 20 20 69 66 20 7b 28 24 6d 69  n)..    if {($mi
5dd0: 6e 20 3c 20 30 29 20 7c 7c 20 28 24 69 6e 74 65  n < 0) || ($inte
5de0: 72 76 61 6c 20 3c 20 24 6d 69 6e 29 7d 20 7b 0a  rval < $min)} {.
5df0: 09 09 73 65 74 20 6d 69 6e 20 20 24 69 6e 74 65  ..set min  $inte
5e00: 72 76 61 6c 0a 09 09 73 65 74 20 62 65 73 74 20  rval...set best 
5e10: 5b 6c 69 73 74 20 24 6c 6f 63 61 74 69 6f 6e 5d  [list $location]
5e20: 0a 09 20 20 20 20 7d 20 65 6c 73 65 69 66 20 7b  ..    } elseif {
5e30: 24 69 6e 74 65 72 76 61 6c 20 3d 3d 20 24 6d 69  $interval == $mi
5e40: 6e 7d 20 7b 0a 09 09 6c 61 70 70 65 6e 64 20 62  n} {...lappend b
5e50: 65 73 74 20 24 6c 6f 63 61 74 69 6f 6e 0a 09 20  est $location.. 
5e60: 20 20 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b 5b 6c     }..}...if {[l
5e70: 6c 65 6e 67 74 68 20 24 62 65 73 74 5d 20 3d 3d  length $best] ==
5e80: 20 31 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69   1} { return [li
5e90: 6e 64 65 78 20 24 62 65 73 74 20 30 5d 20 7d 0a  ndex $best 0] }.
5ea0: 0a 09 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78  ..return [lindex
5eb0: 20 5b 6c 73 6f 72 74 20 2d 69 6e 74 65 67 65 72   [lsort -integer
5ec0: 20 2d 69 6e 63 72 65 61 73 69 6e 67 20 24 62 65   -increasing $be
5ed0: 73 74 5d 20 30 5d 0a 20 20 20 20 7d 0a 0a 20 20  st] 0].    }..  
5ee0: 20 20 70 72 6f 63 20 43 75 74 41 74 20 7b 6c 6f    proc CutAt {lo
5ef0: 63 61 74 69 6f 6e 7d 20 7b 0a 09 75 70 76 61 72  cation} {..upvar
5f00: 20 31 20 63 72 6f 73 73 20 63 72 6f 73 73 20 64   1 cross cross d
5f10: 65 70 63 20 64 65 70 63 0a 0a 09 23 20 49 74 20  epc depc...# It 
5f20: 77 61 73 20 64 65 63 69 64 65 64 20 74 6f 20 73  was decided to s
5f30: 70 6c 69 74 20 74 68 65 20 63 68 61 6e 67 65 73  plit the changes
5f40: 65 74 20 61 74 20 74 68 65 20 67 69 76 65 6e 0a  et at the given.
5f50: 09 23 20 6c 6f 63 61 74 69 6f 6e 2e 20 54 68 69  .# location. Thi
5f60: 73 20 63 75 74 73 20 61 20 6e 75 6d 62 65 72 20  s cuts a number 
5f70: 6f 66 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e  of dependencies.
5f80: 20 48 65 72 65 20 77 65 20 75 70 64 61 74 65 0a   Here we update.
5f90: 09 23 20 74 68 65 20 63 72 6f 73 73 20 69 6e 66  .# the cross inf
5fa0: 6f 72 6d 61 74 69 6f 6e 20 73 6f 20 74 68 61 74  ormation so that
5fb0: 20 74 68 65 20 62 72 65 61 6b 20 66 69 6e 64 65   the break finde
5fc0: 72 20 68 61 73 20 61 63 63 75 72 61 74 65 0a 09  r has accurate..
5fd0: 23 20 64 61 74 61 20 77 68 65 6e 20 77 65 20 6c  # data when we l
5fe0: 6f 6f 6b 20 61 74 20 74 68 65 20 67 65 6e 65 72  ook at the gener
5ff0: 61 74 65 64 20 66 72 61 67 6d 65 6e 74 73 2e 0a  ated fragments..
6000: 0a 09 73 65 74 20 73 69 78 20 5b 6c 6f 67 20 76  ..set six [log v
6010: 69 73 69 62 6c 65 3f 20 36 5d 0a 0a 09 66 6f 72  isible? 6]...for
6020: 65 61 63 68 20 7b 64 65 70 20 72 61 6e 67 65 7d  each {dep range}
6030: 20 5b 61 72 72 61 79 20 67 65 74 20 64 65 70 63   [array get depc
6040: 5d 20 7b 0a 09 20 20 20 20 23 20 43 68 65 63 6b  ] {..    # Check
6050: 20 61 6c 6c 20 64 65 70 65 6e 64 65 6e 63 69 65   all dependencie
6060: 73 20 73 74 69 6c 6c 20 6b 6e 6f 77 6e 2c 20 74  s still known, t
6070: 61 6b 65 20 74 68 65 69 72 20 72 61 6e 67 65 20  ake their range 
6080: 61 6e 64 0a 09 20 20 20 20 23 20 73 65 65 20 69  and..    # see i
6090: 66 20 74 68 65 20 62 72 65 61 6b 20 6c 6f 63 61  f the break loca
60a0: 74 69 6f 6e 20 66 61 6c 6c 73 20 77 69 74 68 69  tion falls withi
60b0: 6e 2e 0a 0a 09 20 20 20 20 42 6f 72 64 65 72 20  n....    Border 
60c0: 24 72 61 6e 67 65 20 73 20 65 0a 09 20 20 20 20  $range s e..    
60d0: 69 66 20 7b 24 6c 6f 63 61 74 69 6f 6e 20 3c 20  if {$location < 
60e0: 24 73 7d 20 63 6f 6e 74 69 6e 75 65 20 3b 20 23  $s} continue ; #
60f0: 20 62 72 65 61 6b 20 62 65 66 6f 72 65 20 72 61   break before ra
6100: 6e 67 65 2c 20 69 67 6e 6f 72 65 0a 09 20 20 20  nge, ignore..   
6110: 20 69 66 20 7b 24 6c 6f 63 61 74 69 6f 6e 20 3e   if {$location >
6120: 20 24 65 7d 20 63 6f 6e 74 69 6e 75 65 20 3b 20   $e} continue ; 
6130: 23 20 62 72 65 61 6b 20 61 66 74 65 72 20 72 61  # break after ra
6140: 6e 67 65 2c 20 69 67 6e 6f 72 65 2e 0a 0a 09 20  nge, ignore.... 
6150: 20 20 20 23 20 54 68 69 73 20 64 65 70 65 6e 64     # This depend
6160: 65 6e 63 79 20 63 72 6f 73 73 65 73 20 74 68 65  ency crosses the
6170: 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 2e   break location.
6180: 20 57 65 20 72 65 6d 6f 76 65 20 69 74 0a 09 20   We remove it.. 
6190: 20 20 20 23 20 66 72 6f 6d 20 74 68 65 20 63 72     # from the cr
61a0: 6f 73 73 69 6e 67 73 20 63 6f 75 6e 74 65 72 73  ossings counters
61b0: 2c 20 61 6e 64 20 74 68 65 6e 20 61 6c 73 6f 20  , and then also 
61c0: 66 72 6f 6d 20 74 68 65 20 73 65 74 0a 09 20 20  from the set..  
61d0: 20 20 23 20 6f 66 20 6b 6e 6f 77 6e 20 64 65 70    # of known dep
61e0: 65 6e 64 65 6e 63 69 65 73 2c 20 61 73 20 77 65  endencies, as we
61f0: 20 61 72 65 20 64 6f 6e 65 20 77 69 74 68 20 69   are done with i
6200: 74 2e 0a 0a 09 20 20 20 20 66 6f 72 65 61 63 68  t....    foreach
6210: 20 6c 6f 63 20 24 64 65 70 63 28 24 64 65 70 29   loc $depc($dep)
6220: 20 7b 20 69 6e 63 72 20 63 72 6f 73 73 28 24 6c   { incr cross($l
6230: 6f 63 29 20 2d 31 20 7d 0a 09 20 20 20 20 75 6e  oc) -1 }..    un
6240: 73 65 74 20 64 65 70 63 28 24 64 65 70 29 0a 0a  set depc($dep)..
6250: 09 20 20 20 20 69 66 20 7b 21 24 73 69 78 7d 20  .    if {!$six} 
6260: 63 6f 6e 74 69 6e 75 65 0a 0a 09 20 20 20 20 73  continue...    s
6270: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69  truct::list assi
6280: 67 6e 20 24 64 65 70 20 70 61 72 65 6e 74 20 63  gn $dep parent c
6290: 68 69 6c 64 0a 09 20 20 20 20 6c 6f 67 20 77 72  hild..    log wr
62a0: 69 74 65 20 35 20 63 73 65 74 73 20 22 42 72 6f  ite 5 csets "Bro
62b0: 6b 65 20 64 65 70 65 6e 64 65 6e 63 79 20 5b 50  ke dependency [P
62c0: 44 20 24 70 61 72 65 6e 74 5d 20 2d 2d 3e 20 5b  D $parent] --> [
62d0: 50 44 20 24 63 68 69 6c 64 5d 22 0a 09 7d 0a 0a  PD $child]"..}..
62e0: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
62f0: 20 20 20 23 20 50 72 69 6e 74 20 69 64 65 6e 74     # Print ident
6300: 69 66 79 69 6e 67 20 64 61 74 61 20 66 6f 72 20  ifying data for 
6310: 61 20 72 65 76 69 73 69 6f 6e 20 28 70 72 6f 6a  a revision (proj
6320: 65 63 74 2c 20 66 69 6c 65 2c 20 64 6f 74 74 65  ect, file, dotte
6330: 64 20 72 65 76 0a 20 20 20 20 23 20 6e 75 6d 62  d rev.    # numb
6340: 65 72 29 2c 20 66 6f 72 20 68 69 67 68 20 76 65  er), for high ve
6350: 72 62 6f 73 69 74 79 20 6c 6f 67 20 6f 75 74 70  rbosity log outp
6360: 75 74 2e 0a 0a 20 20 20 20 70 72 6f 63 20 50 44  ut...    proc PD
6370: 20 7b 69 64 7d 20 7b 0a 09 66 6f 72 65 61 63 68   {id} {..foreach
6380: 20 7b 70 20 66 20 72 7d 20 5b 73 74 61 74 65 20   {p f r} [state 
6390: 72 75 6e 20 7b 0a 09 09 53 45 4c 45 43 54 20 50  run {...SELECT P
63a0: 2e 6e 61 6d 65 20 2c 20 46 2e 6e 61 6d 65 2c 20  .name , F.name, 
63b0: 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 72 65 76  R.rev...FROM rev
63c0: 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c  ision R, file F,
63d0: 20 70 72 6f 6a 65 63 74 20 50 0a 09 09 57 48 45   project P...WHE
63e0: 52 45 20 52 2e 72 69 64 20 3d 20 24 69 64 0a 09  RE R.rid = $id..
63f0: 09 41 4e 44 20 20 20 52 2e 66 69 64 20 3d 20 46  .AND   R.fid = F
6400: 2e 66 69 64 0a 09 09 41 4e 44 20 20 20 46 2e 70  .fid...AND   F.p
6410: 69 64 20 3d 20 50 2e 70 69 64 0a 09 7d 5d 20 62  id = P.pid..}] b
6420: 72 65 61 6b 0a 09 72 65 74 75 72 6e 20 22 27 24  reak..return "'$
6430: 70 20 3a 20 24 66 2f 24 72 27 22 0a 20 20 20 20  p : $f/$r'".    
6440: 7d 0a 0a 20 20 20 20 23 20 50 72 69 6e 74 69 6e  }..    # Printin
6450: 67 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 72 61  g one or more ra
6460: 6e 67 65 73 2c 20 66 6f 72 6d 61 74 74 65 64 2c  nges, formatted,
6470: 20 61 6e 64 20 6f 6e 6c 79 20 74 68 65 69 72 20   and only their 
6480: 62 6f 72 64 65 72 20 74 6f 0a 20 20 20 20 23 20  border to.    # 
6490: 6b 65 65 70 20 74 68 65 20 73 74 72 69 6e 67 73  keep the strings
64a0: 20 73 68 6f 72 74 2e 0a 0a 20 20 20 20 70 72 6f   short...    pro
64b0: 63 20 50 52 73 20 7b 72 61 6e 67 65 73 7d 20 7b  c PRs {ranges} {
64c0: 0a 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74  ..return [struct
64d0: 3a 3a 6c 69 73 74 20 6d 61 70 20 24 72 61 6e 67  ::list map $rang
64e0: 65 73 20 5b 6d 79 70 72 6f 63 20 50 52 5d 5d 0a  es [myproc PR]].
64f0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20      }..    proc 
6500: 50 52 20 7b 72 61 6e 67 65 7d 20 7b 0a 09 42 6f  PR {range} {..Bo
6510: 72 64 65 72 20 24 72 61 6e 67 65 20 73 20 65 0a  rder $range s e.
6520: 09 72 65 74 75 72 6e 20 3c 24 7b 73 7d 2e 2e 2e  .return <${s}...
6530: 24 7b 65 7d 3e 0a 20 20 20 20 7d 0a 0a 20 20 20  ${e}>.    }..   
6540: 20 70 72 6f 63 20 42 6f 72 64 65 72 20 7b 72 61   proc Border {ra
6550: 6e 67 65 20 73 76 20 65 76 7d 20 7b 0a 09 75 70  nge sv ev} {..up
6560: 76 61 72 20 31 20 24 73 76 20 73 20 24 65 76 20  var 1 $sv s $ev 
6570: 65 0a 09 73 65 74 20 73 20 5b 6c 69 6e 64 65 78  e..set s [lindex
6580: 20 24 72 61 6e 67 65 20 30 5d 0a 09 73 65 74 20   $range 0]..set 
6590: 65 20 5b 6c 69 6e 64 65 78 20 24 72 61 6e 67 65  e [lindex $range
65a0: 20 65 6e 64 5d 0a 09 72 65 74 75 72 6e 0a 20 20   end]..return.  
65b0: 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20    }..    # # ## 
65c0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
65d0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
65e0: 0a 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62  ..    typevariab
65f0: 6c 65 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20  le mychangesets 
6600: 20 20 20 7b 7d 20 3b 20 23 20 4c 69 73 74 20 6f     {} ; # List o
6610: 66 20 61 6c 6c 20 6b 6e 6f 77 6e 20 63 68 61 6e  f all known chan
6620: 67 65 73 65 74 73 2e 0a 20 20 20 20 74 79 70 65  gesets..    type
6630: 76 61 72 69 61 62 6c 65 20 6d 79 72 65 76 6d 61  variable myrevma
6640: 70 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23 20  p -array {} ; # 
6650: 4d 61 70 20 66 72 6f 6d 20 72 65 76 69 73 69 6f  Map from revisio
6660: 6e 73 20 74 6f 20 74 68 65 20 6c 69 73 74 0a 09  ns to the list..
6670: 09 09 09 20 20 20 20 20 20 23 20 6f 66 20 63 68  ...      # of ch
6680: 61 6e 67 65 73 65 74 73 20 63 6f 6e 74 61 69 6e  angesets contain
6690: 69 6e 67 0a 09 09 09 09 20 20 20 20 20 20 23 20  ing.....      # 
66a0: 69 74 2e 20 4e 4f 54 45 3a 20 57 68 69 6c 65 20  it. NOTE: While 
66b0: 6f 6e 6c 79 20 6f 6e 65 0a 09 09 09 09 20 20 20  only one.....   
66c0: 20 20 20 23 20 72 65 76 69 73 69 6f 6e 20 63 68     # revision ch
66d0: 61 6e 67 65 73 65 74 20 63 61 6e 20 63 6f 6e 74  angeset can cont
66e0: 61 69 6e 0a 09 09 09 09 20 20 20 20 20 20 23 20  ain.....      # 
66f0: 74 68 65 20 72 65 76 69 73 69 6f 6e 2c 20 74 68  the revision, th
6700: 65 72 65 20 63 61 6e 0a 09 09 09 09 20 20 20 20  ere can.....    
6710: 20 20 23 20 68 6f 77 65 76 65 72 20 61 6c 73 6f    # however also
6720: 20 62 65 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 0a   be one or more.
6730: 09 09 09 09 20 20 20 20 20 20 23 20 61 64 64 69  ....      # addi
6740: 74 69 6f 6e 61 6c 20 73 79 6d 62 6f 6c 20 63 68  tional symbol ch
6750: 61 6e 67 65 73 65 74 73 0a 09 09 09 09 20 20 20  angesets.....   
6760: 20 20 20 23 20 77 68 69 63 68 20 75 73 65 20 69     # which use i
6770: 74 2c 20 68 65 6e 63 65 20 61 20 6c 69 73 74 2e  t, hence a list.
6780: 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c  .    typevariabl
6790: 65 20 6d 79 69 64 6d 61 70 20 20 2d 61 72 72 61  e myidmap  -arra
67a0: 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f  y {} ; # Map fro
67b0: 6d 20 63 68 61 6e 67 65 73 65 74 20 69 64 20 74  m changeset id t
67c0: 6f 20 63 68 61 6e 67 65 73 65 74 2e 0a 20 20 20  o changeset..   
67d0: 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79   typevariable my
67e0: 62 72 61 6e 63 68 63 6f 64 65 20 20 20 20 7b 7d  branchcode    {}
67f0: 20 3b 20 23 20 4c 6f 63 61 6c 20 63 6f 70 79 20   ; # Local copy 
6800: 6f 66 20 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 2f  of project::sym/
6810: 6d 79 62 72 61 6e 63 68 2e 0a 0a 20 20 20 20 74  mybranch...    t
6820: 79 70 65 6d 65 74 68 6f 64 20 61 6c 6c 20 20 20  ypemethod all   
6830: 7b 7d 20 20 20 7b 20 72 65 74 75 72 6e 20 24 6d  {}   { return $m
6840: 79 63 68 61 6e 67 65 73 65 74 73 20 7d 0a 20 20  ychangesets }.  
6850: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6f 66 20    typemethod of 
6860: 20 20 20 7b 69 64 7d 20 7b 20 72 65 74 75 72 6e     {id} { return
6870: 20 24 6d 79 69 64 6d 61 70 28 24 69 64 29 20 7d   $myidmap($id) }
6880: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
6890: 6f 66 72 65 76 20 7b 69 64 7d 20 7b 20 72 65 74  ofrev {id} { ret
68a0: 75 72 6e 20 24 6d 79 72 65 76 6d 61 70 28 24 69  urn $myrevmap($i
68b0: 64 29 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23  d) }..    # # ##
68c0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
68d0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
68e0: 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75  #.    ## Configu
68f0: 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67  ration..    prag
6900: 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20  ma -hastypeinfo 
6910: 20 20 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 74 79     no  ; # no ty
6920: 70 65 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e  pe introspection
6930: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73  .    pragma -has
6940: 69 6e 66 6f 20 20 20 20 20 20 20 20 6e 6f 20 20  info        no  
6950: 3b 20 23 20 6e 6f 20 6f 62 6a 65 63 74 20 69 6e  ; # no object in
6960: 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20  trospection.    
6970: 70 72 61 67 6d 61 20 2d 73 69 6d 70 6c 65 64 69  pragma -simpledi
6980: 73 70 61 74 63 68 20 79 65 73 20 3b 20 23 20 73  spatch yes ; # s
6990: 69 6d 70 6c 65 20 66 61 73 74 20 64 69 73 70 61  imple fast dispa
69a0: 74 63 68 0a 0a 20 20 20 20 23 20 23 20 23 23 20  tch..    # # ## 
69b0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
69c0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
69d0: 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76  .}..namespace ev
69e0: 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  al ::vc::fossil:
69f0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72  :import::cvs::pr
6a00: 6f 6a 65 63 74 20 7b 0a 20 20 20 20 6e 61 6d 65  oject {.    name
6a10: 73 70 61 63 65 20 65 78 70 6f 72 74 20 72 65 76  space export rev
6a20: 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65  .    namespace e
6a30: 76 61 6c 20 72 65 76 20 7b 0a 09 6e 61 6d 65 73  val rev {..names
6a40: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63  pace import ::vc
6a50: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74  ::fossil::import
6a60: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61  ::cvs::state..na
6a70: 6d 65 73 70 61 63 65 20 65 76 61 6c 20 70 72 6f  mespace eval pro
6a80: 6a 65 63 74 20 7b 0a 09 20 20 20 20 6e 61 6d 65  ject {..    name
6a90: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
6aa0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
6ab0: 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a  t::cvs::project:
6ac0: 3a 73 79 6d 0a 09 7d 0a 09 3a 3a 76 61 72 69 61  :sym..}..::varia
6ad0: 62 6c 65 20 6d 79 62 72 61 6e 63 68 63 6f 64 65  ble mybranchcode
6ae0: 20 5b 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 20 62   [project::sym b
6af0: 72 61 6e 63 68 5d 0a 09 6e 61 6d 65 73 70 61 63  ranch]..namespac
6b00: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74  e import ::vc::t
6b10: 6f 6f 6c 73 3a 3a 6d 69 73 63 3a 3a 2a 0a 09 6e  ools::misc::*..n
6b20: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
6b30: 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f  ::vc::tools::tro
6b40: 75 62 6c 65 0a 09 6e 61 6d 65 73 70 61 63 65 20  uble..namespace 
6b50: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f  import ::vc::too
6b60: 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65 67  ls::log..log reg
6b70: 69 73 74 65 72 20 63 73 65 74 73 0a 20 20 20 20  ister csets.    
6b80: 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20  }.}..# # ## ### 
6b90: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
6ba0: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23  ############ ###
6bb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
6bc0: 23 23 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 63  ##.## Ready..pac
6bd0: 6b 61 67 65 20 70 72 6f 76 69 64 65 20 76 63 3a  kage provide vc:
6be0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
6bf0: 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72  :cvs::project::r
6c00: 65 76 20 31 2e 30 0a 72 65 74 75 72 6e 0a        ev 1.0.return.