Hex Artifact Content
Not logged in

Artifact dd4e59c472e0c8a22480a13029f9f3987b1ec98a:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [27b15b7095] - This commit starts a series of incremental changes not quite completely overhauling the handling of changesets, i.e. of project-level revisions. Actually this series of changes already started with 8ce7ffff21 as the bug it fixes was found when the first parts of the overhaul tripped the new integrity conditions for the modified changesets.

Background: In the last few days I repeatedly ran against the wall of an assertion in pass 9, last of the cycle breakers, with the revision changesets coming in out of order when the symbols were added to the dependency graph.

While walking to the office, and later re-reading the relevant parts of cvs2svn again I had several insights. Trigger was the realization that giving the tag changesets successor dependencies was wrong. Tags describe a state, they have no successors. This caused the re-read, and I recognized that my handling of the symbol changesets was completely wrong, that with using revisions as their data. It should have been the tags and branches. From there their actual dependencies (versus my reuse of revision dependencies) fell out naturally.

I have decided to commit my rewrite of the internals incrementally to make it easier to follow them, despite leaving the sourcebase in an unusable state during the series. One big commit would be much more difficult to understand.

The central change is to the changeset class, which becomes a trinity, holding either revisions, tags, or branches, with type-dependent code to retrieve their dependencies. The remainder of the changes are 'just' adaptions of the users to the changed API.

First change: Add outline of the helper classes, singletons actually, to hold the type-dependent functionality.

by aku on 2007-11-29 05:58:53.

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 69 6e 74 65 67 72 69 74 79  ::cvs::integrity
04c0: 20 20 20 20 3b 20 23 20 53 74 61 74 65 20 69 6e      ; # State in
04d0: 74 65 67 72 69 74 79 20 63 68 65 63 6b 73 2e 0a  tegrity checks..
04e0: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20  package require 
04f0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
0500: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74  rt::cvs::project
0510: 3a 3a 73 79 6d 20 3b 20 23 20 50 72 6f 6a 65 63  ::sym ; # Projec
0520: 74 20 6c 65 76 65 6c 20 73 79 6d 62 6f 6c 73 0a  t level symbols.
0530: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23  .# # ## ### ####
0540: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23  # ######## #####
0550: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0560: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23  ##############.#
0570: 23 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a  #..snit::type ::
0580: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
0590: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74  rt::cvs::project
05a0: 3a 3a 72 65 76 20 7b 0a 20 20 20 20 23 20 23 20  ::rev {.    # # 
05b0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
05c0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
05d0: 23 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69  ###.    ## Publi
05e0: 63 20 41 50 49 0a 0a 20 20 20 20 63 6f 6e 73 74  c API..    const
05f0: 72 75 63 74 6f 72 20 7b 70 72 6f 6a 65 63 74 20  ructor {project 
0600: 63 73 74 79 70 65 20 73 72 63 69 64 20 72 65 76  cstype srcid rev
0610: 69 73 69 6f 6e 73 20 7b 74 68 65 69 64 20 7b 7d  isions {theid {}
0620: 7d 7d 20 7b 0a 09 69 66 20 7b 24 74 68 65 69 64  }} {..if {$theid
0630: 20 6e 65 20 22 22 7d 20 7b 0a 09 20 20 20 20 73   ne ""} {..    s
0640: 65 74 20 6d 79 69 64 20 24 74 68 65 69 64 0a 09  et myid $theid..
0650: 7d 20 65 6c 73 65 20 7b 0a 09 20 20 20 20 73 65  } else {..    se
0660: 74 20 6d 79 69 64 20 5b 69 6e 63 72 20 6d 79 63  t myid [incr myc
0670: 6f 75 6e 74 65 72 5d 0a 09 7d 0a 0a 09 73 65 74  ounter]..}...set
0680: 20 6d 79 70 72 6f 6a 65 63 74 20 20 20 24 70 72   myproject   $pr
0690: 6f 6a 65 63 74 0a 09 73 65 74 20 6d 79 74 79 70  oject..set mytyp
06a0: 65 20 20 20 20 20 20 24 63 73 74 79 70 65 0a 09  e      $cstype..
06b0: 73 65 74 20 6d 79 73 72 63 69 64 09 24 73 72 63  set mysrcid.$src
06c0: 69 64 0a 09 73 65 74 20 6d 79 72 65 76 69 73 69  id..set myrevisi
06d0: 6f 6e 73 20 24 72 65 76 69 73 69 6f 6e 73 0a 09  ons $revisions..
06e0: 73 65 74 20 6d 79 70 6f 73 20 20 20 20 20 20 20  set mypos       
06f0: 7b 7d 20 3b 20 23 20 43 6f 6d 6d 69 74 20 6c 6f  {} ; # Commit lo
0700: 63 61 74 69 6f 6e 20 69 73 20 6e 6f 74 20 6b 6e  cation is not kn
0710: 6f 77 6e 20 79 65 74 2e 0a 0a 09 23 20 4b 65 65  own yet....# Kee
0720: 70 20 74 72 61 63 6b 20 6f 66 20 74 68 65 20 67  p track of the g
0730: 65 6e 65 72 61 74 65 64 20 63 68 61 6e 67 65 73  enerated changes
0740: 65 74 73 20 61 6e 64 20 6f 66 20 74 68 65 20 69  ets and of the i
0750: 6e 76 65 72 73 65 0a 09 23 20 6d 61 70 70 69 6e  nverse..# mappin
0760: 67 20 66 72 6f 6d 20 72 65 76 69 73 69 6f 6e 73  g from revisions
0770: 20 74 6f 20 74 68 65 6d 2e 0a 09 6c 61 70 70 65   to them...lappe
0780: 6e 64 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20  nd mychangesets 
0790: 20 20 24 73 65 6c 66 0a 09 73 65 74 20 20 20 20    $self..set    
07a0: 20 6d 79 69 64 6d 61 70 28 24 6d 79 69 64 29 20   myidmap($myid) 
07b0: 24 73 65 6c 66 0a 09 66 6f 72 65 61 63 68 20 72  $self..foreach r
07c0: 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 20 6c 61   $revisions { la
07d0: 70 70 65 6e 64 20 6d 79 72 65 76 6d 61 70 28 24  ppend myrevmap($
07e0: 72 29 20 24 73 65 6c 66 20 7d 0a 09 72 65 74 75  r) $self }..retu
07f0: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65  rn.    }..    me
0800: 74 68 6f 64 20 73 74 72 20 7b 7d 20 7b 0a 09 73  thod str {} {..s
0810: 65 74 20 73 74 72 20 20 20 20 22 3c 22 0a 09 73  et str    "<"..s
0820: 65 74 20 64 65 74 61 69 6c 20 22 22 0a 09 69 66  et detail ""..if
0830: 20 7b 24 6d 79 74 79 70 65 20 65 71 20 22 73 79   {$mytype eq "sy
0840: 6d 22 7d 20 7b 0a 09 20 20 20 20 73 74 72 75 63  m"} {..    struc
0850: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b  t::list assign [
0860: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 45  state run {...SE
0870: 4c 45 43 54 20 54 2e 6e 61 6d 65 2c 20 53 2e 6e  LECT T.name, S.n
0880: 61 6d 65 0a 09 09 46 52 4f 4d 20 20 20 73 79 6d  ame...FROM   sym
0890: 74 79 70 65 20 54 2c 20 73 79 6d 62 6f 6c 20 53  type T, symbol S
08a0: 0a 09 09 57 48 45 52 45 20 20 53 2e 73 69 64 20  ...WHERE  S.sid 
08b0: 3d 20 24 6d 79 73 72 63 69 64 0a 09 09 41 4e 44  = $mysrcid...AND
08c0: 20 20 20 20 54 2e 74 69 64 20 3d 20 53 2e 74 79      T.tid = S.ty
08d0: 70 65 0a 09 20 20 20 20 7d 5d 20 73 74 79 70 65  pe..    }] stype
08e0: 20 64 65 74 61 69 6c 0a 09 20 20 20 20 61 70 70   detail..    app
08f0: 65 6e 64 20 73 74 72 20 24 73 74 79 70 65 20 22  end str $stype "
0900: 20 22 0a 09 20 20 20 20 73 65 74 20 64 65 74 61   "..    set deta
0910: 69 6c 20 22 20 27 24 64 65 74 61 69 6c 27 22 0a  il " '$detail'".
0920: 09 7d 0a 09 61 70 70 65 6e 64 20 73 74 72 20 22  .}..append str "
0930: 24 6d 79 74 79 70 65 20 24 7b 6d 79 69 64 7d 24  $mytype ${myid}$
0940: 7b 64 65 74 61 69 6c 7d 3e 22 0a 09 72 65 74 75  {detail}>"..retu
0950: 72 6e 20 24 73 74 72 0a 20 20 20 20 7d 0a 0a 20  rn $str.    }.. 
0960: 20 20 20 6d 65 74 68 6f 64 20 69 64 20 20 20 20     method id    
0970: 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20      {} { return 
0980: 24 6d 79 69 64 20 7d 0a 20 20 20 20 6d 65 74 68  $myid }.    meth
0990: 6f 64 20 72 65 76 69 73 69 6f 6e 73 20 7b 7d 20  od revisions {} 
09a0: 7b 20 72 65 74 75 72 6e 20 24 6d 79 72 65 76 69  { return $myrevi
09b0: 73 69 6f 6e 73 20 7d 0a 20 20 20 20 6d 65 74 68  sions }.    meth
09c0: 6f 64 20 64 61 74 61 20 20 20 20 20 20 7b 7d 20  od data      {} 
09d0: 7b 20 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24  { return [list $
09e0: 6d 79 70 72 6f 6a 65 63 74 20 24 6d 79 74 79 70  myproject $mytyp
09f0: 65 20 24 6d 79 73 72 63 69 64 5d 20 7d 0a 0a 20  e $mysrcid] }.. 
0a00: 20 20 20 6d 65 74 68 6f 64 20 62 79 73 79 6d 62     method bysymb
0a10: 6f 6c 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e  ol   {} { return
0a20: 20 5b 65 78 70 72 20 7b 24 6d 79 74 79 70 65 20   [expr {$mytype 
0a30: 65 71 20 22 73 79 6d 22 7d 5d 20 7d 0a 20 20 20  eq "sym"}] }.   
0a40: 20 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 69   method byrevisi
0a50: 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5b  on {} { return [
0a60: 65 78 70 72 20 7b 24 6d 79 74 79 70 65 20 65 71  expr {$mytype eq
0a70: 20 22 72 65 76 22 7d 5d 20 7d 0a 0a 20 20 20 20   "rev"}] }..    
0a80: 6d 65 74 68 6f 64 20 73 65 74 70 6f 73 20 7b 70  method setpos {p
0a90: 7d 20 7b 20 73 65 74 20 6d 79 70 6f 73 20 24 70  } { set mypos $p
0aa0: 20 3b 20 72 65 74 75 72 6e 20 7d 0a 20 20 20 20   ; return }.    
0ab0: 6d 65 74 68 6f 64 20 70 6f 73 20 20 20 20 7b 7d  method pos    {}
0ac0: 20 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 70 6f    { return $mypo
0ad0: 73 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20  s }..    method 
0ae0: 69 73 62 72 61 6e 63 68 20 7b 7d 20 7b 0a 09 65  isbranch {} {..e
0af0: 72 72 6f 72 20 4e 4f 54 2d 55 53 45 44 0a 09 72  rror NOT-USED..r
0b00: 65 74 75 72 6e 20 5b 65 78 70 72 20 7b 28 24 6d  eturn [expr {($m
0b10: 79 74 79 70 65 20 65 71 20 22 73 79 6d 22 29 20  ytype eq "sym") 
0b20: 26 26 0a 09 09 20 20 20 20 20 20 28 24 6d 79 62  &&...      ($myb
0b30: 72 61 6e 63 68 63 6f 64 65 20 3d 3d 20 5b 73 74  ranchcode == [st
0b40: 61 74 65 20 6f 6e 65 20 7b 0a 09 09 09 20 20 53  ate one {....  S
0b50: 45 4c 45 43 54 20 74 79 70 65 20 46 52 4f 4d 20  ELECT type FROM 
0b60: 73 79 6d 62 6f 6c 20 57 48 45 52 45 20 73 69 64  symbol WHERE sid
0b70: 20 3d 20 24 6d 79 73 72 63 69 64 0a 09 09 20 20   = $mysrcid...  
0b80: 20 20 20 20 7d 5d 29 7d 5d 0a 20 20 20 20 7d 0a      }])}].    }.
0b90: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20  .    # result = 
0ba0: 64 69 63 74 20 28 72 65 76 69 73 69 6f 6e 20 2d  dict (revision -
0bb0: 3e 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65  > list (changese
0bc0: 74 29 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 73  t)).    method s
0bd0: 75 63 63 65 73 73 6f 72 6d 61 70 20 7b 7d 20 7b  uccessormap {} {
0be0: 0a 09 23 20 4e 4f 54 45 20 2f 20 46 55 54 55 52  ..# NOTE / FUTUR
0bf0: 45 3a 20 50 6f 73 73 69 62 6c 65 20 62 6f 74 74  E: Possible bott
0c00: 6c 65 6e 65 63 6b 2e 0a 09 61 72 72 61 79 20 73  leneck...array s
0c10: 65 74 20 74 6d 70 20 7b 7d 0a 09 66 6f 72 65 61  et tmp {}..forea
0c20: 63 68 20 7b 72 65 76 20 63 68 69 6c 64 72 65 6e  ch {rev children
0c30: 7d 20 5b 24 73 65 6c 66 20 6e 65 78 74 6d 61 70  } [$self nextmap
0c40: 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68  ] {..    foreach
0c50: 20 63 68 69 6c 64 20 24 63 68 69 6c 64 72 65 6e   child $children
0c60: 20 7b 0a 09 09 23 20 38 2e 35 20 6c 61 70 70 65   {...# 8.5 lappe
0c70: 6e 64 20 74 6d 70 28 24 72 65 76 29 20 7b 2a 7d  nd tmp($rev) {*}
0c80: 24 6d 79 72 65 76 6d 61 70 28 24 63 68 69 6c 64  $myrevmap($child
0c90: 29 0a 09 09 66 6f 72 65 61 63 68 20 63 73 65 74  )...foreach cset
0ca0: 20 24 6d 79 72 65 76 6d 61 70 28 24 63 68 69 6c   $myrevmap($chil
0cb0: 64 29 20 7b 0a 09 09 20 20 20 20 6c 61 70 70 65  d) {...    lappe
0cc0: 6e 64 20 74 6d 70 28 24 72 65 76 29 20 24 63 73  nd tmp($rev) $cs
0cd0: 65 74 0a 09 09 7d 0a 09 20 20 20 20 7d 0a 09 20  et...}..    }.. 
0ce0: 20 20 20 73 65 74 20 74 6d 70 28 24 72 65 76 29     set tmp($rev)
0cf0: 20 5b 6c 73 6f 72 74 20 2d 75 6e 69 71 75 65 20   [lsort -unique 
0d00: 24 74 6d 70 28 24 72 65 76 29 5d 0a 09 7d 0a 09  $tmp($rev)]..}..
0d10: 72 65 74 75 72 6e 20 5b 61 72 72 61 79 20 67 65  return [array ge
0d20: 74 20 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20 20  t tmp].    }..  
0d30: 20 20 6d 65 74 68 6f 64 20 73 75 63 63 65 73 73    method success
0d40: 6f 72 73 20 7b 7d 20 7b 0a 09 23 20 4e 4f 54 45  ors {} {..# NOTE
0d50: 20 2f 20 46 55 54 55 52 45 3a 20 50 6f 73 73 69   / FUTURE: Possi
0d60: 62 6c 65 20 62 6f 74 74 6c 65 6e 65 63 6b 2e 0a  ble bottleneck..
0d70: 09 73 65 74 20 63 73 65 74 73 20 7b 7d 0a 09 66  .set csets {}..f
0d80: 6f 72 65 61 63 68 20 7b 5f 20 63 68 69 6c 64 72  oreach {_ childr
0d90: 65 6e 7d 20 5b 24 73 65 6c 66 20 6e 65 78 74 6d  en} [$self nextm
0da0: 61 70 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65 61  ap] {..    forea
0db0: 63 68 20 63 68 69 6c 64 20 24 63 68 69 6c 64 72  ch child $childr
0dc0: 65 6e 20 7b 0a 09 09 23 20 38 2e 35 20 6c 61 70  en {...# 8.5 lap
0dd0: 70 65 6e 64 20 63 73 65 74 73 20 7b 2a 7d 24 6d  pend csets {*}$m
0de0: 79 72 65 76 6d 61 70 28 24 63 68 69 6c 64 29 0a  yrevmap($child).
0df0: 09 09 66 6f 72 65 61 63 68 20 63 73 65 74 20 24  ..foreach cset $
0e00: 6d 79 72 65 76 6d 61 70 28 24 63 68 69 6c 64 29  myrevmap($child)
0e10: 20 7b 0a 09 09 20 20 20 20 6c 61 70 70 65 6e 64   {...    lappend
0e20: 20 63 73 65 74 73 20 24 63 73 65 74 0a 09 09 7d   csets $cset...}
0e30: 0a 09 20 20 20 20 7d 0a 09 7d 0a 09 72 65 74 75  ..    }..}..retu
0e40: 72 6e 20 5b 6c 73 6f 72 74 20 2d 75 6e 69 71 75  rn [lsort -uniqu
0e50: 65 20 24 63 73 65 74 73 5d 0a 20 20 20 20 7d 0a  e $csets].    }.
0e60: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20  .    # result = 
0e70: 64 69 63 74 20 28 72 65 76 69 73 69 6f 6e 20 2d  dict (revision -
0e80: 3e 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65  > list (changese
0e90: 74 29 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 70  t)).    method p
0ea0: 72 65 64 65 63 65 73 73 6f 72 6d 61 70 20 7b 7d  redecessormap {}
0eb0: 20 7b 0a 09 23 20 4e 4f 54 45 20 2f 20 46 55 54   {..# NOTE / FUT
0ec0: 55 52 45 3a 20 50 6f 73 73 69 62 6c 65 20 62 6f  URE: Possible bo
0ed0: 74 74 6c 65 6e 65 63 6b 2e 0a 09 61 72 72 61 79  ttleneck...array
0ee0: 20 73 65 74 20 74 6d 70 20 7b 7d 0a 09 66 6f 72   set tmp {}..for
0ef0: 65 61 63 68 20 7b 72 65 76 20 63 68 69 6c 64 72  each {rev childr
0f00: 65 6e 7d 20 5b 24 73 65 6c 66 20 70 72 65 6d 61  en} [$self prema
0f10: 70 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63  p] {..    foreac
0f20: 68 20 63 68 69 6c 64 20 24 63 68 69 6c 64 72 65  h child $childre
0f30: 6e 20 7b 0a 09 09 23 20 38 2e 35 20 6c 61 70 70  n {...# 8.5 lapp
0f40: 65 6e 64 20 74 6d 70 28 24 72 65 76 29 20 7b 2a  end tmp($rev) {*
0f50: 7d 24 6d 79 72 65 76 6d 61 70 28 24 63 68 69 6c  }$myrevmap($chil
0f60: 64 29 0a 09 09 66 6f 72 65 61 63 68 20 63 73 65  d)...foreach cse
0f70: 74 20 24 6d 79 72 65 76 6d 61 70 28 24 63 68 69  t $myrevmap($chi
0f80: 6c 64 29 20 7b 0a 09 09 20 20 20 20 6c 61 70 70  ld) {...    lapp
0f90: 65 6e 64 20 74 6d 70 28 24 72 65 76 29 20 24 63  end tmp($rev) $c
0fa0: 73 65 74 0a 09 09 7d 0a 09 20 20 20 20 7d 0a 09  set...}..    }..
0fb0: 20 20 20 20 73 65 74 20 74 6d 70 28 24 72 65 76      set tmp($rev
0fc0: 29 20 5b 6c 73 6f 72 74 20 2d 75 6e 69 71 75 65  ) [lsort -unique
0fd0: 20 24 74 6d 70 28 24 72 65 76 29 5d 0a 09 7d 0a   $tmp($rev)]..}.
0fe0: 09 72 65 74 75 72 6e 20 5b 61 72 72 61 79 20 67  .return [array g
0ff0: 65 74 20 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20  et tmp].    }.. 
1000: 20 20 20 23 20 72 65 76 69 73 69 6f 6e 20 2d 3e     # revision ->
1010: 20 6c 69 73 74 20 28 72 65 76 69 73 69 6f 6e 29   list (revision)
1020: 0a 20 20 20 20 6d 65 74 68 6f 64 20 6e 65 78 74  .    method next
1030: 6d 61 70 20 7b 7d 20 7b 0a 09 69 66 20 7b 5b 6c  map {} {..if {[l
1040: 6c 65 6e 67 74 68 20 24 6d 79 6e 65 78 74 6d 61  length $mynextma
1050: 70 5d 7d 20 7b 20 72 65 74 75 72 6e 20 24 6d 79  p]} { return $my
1060: 6e 65 78 74 6d 61 70 20 7d 0a 09 50 75 6c 6c 53  nextmap }..PullS
1070: 75 63 63 65 73 73 6f 72 52 65 76 69 73 69 6f 6e  uccessorRevision
1080: 73 20 74 6d 70 20 24 6d 79 72 65 76 69 73 69 6f  s tmp $myrevisio
1090: 6e 73 0a 09 73 65 74 20 6d 79 6e 65 78 74 6d 61  ns..set mynextma
10a0: 70 20 5b 61 72 72 61 79 20 67 65 74 20 74 6d 70  p [array get tmp
10b0: 5d 0a 09 72 65 74 75 72 6e 20 24 6d 79 6e 65 78  ]..return $mynex
10c0: 74 6d 61 70 0a 20 20 20 20 7d 0a 0a 20 20 20 20  tmap.    }..    
10d0: 23 20 72 65 76 69 73 69 6f 6e 20 2d 3e 20 6c 69  # revision -> li
10e0: 73 74 20 28 72 65 76 69 73 69 6f 6e 29 0a 20 20  st (revision).  
10f0: 20 20 6d 65 74 68 6f 64 20 70 72 65 6d 61 70 20    method premap 
1100: 7b 7d 20 7b 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67  {} {..if {[lleng
1110: 74 68 20 24 6d 79 70 72 65 6d 61 70 5d 7d 20 7b  th $mypremap]} {
1120: 20 72 65 74 75 72 6e 20 24 6d 79 70 72 65 6d 61   return $myprema
1130: 70 20 7d 0a 09 50 75 6c 6c 50 72 65 64 65 63 65  p }..PullPredece
1140: 73 73 6f 72 52 65 76 69 73 69 6f 6e 73 20 74 6d  ssorRevisions tm
1150: 70 20 24 6d 79 72 65 76 69 73 69 6f 6e 73 0a 09  p $myrevisions..
1160: 73 65 74 20 6d 79 70 72 65 6d 61 70 20 5b 61 72  set mypremap [ar
1170: 72 61 79 20 67 65 74 20 74 6d 70 5d 0a 09 72 65  ray get tmp]..re
1180: 74 75 72 6e 20 24 6d 79 70 72 65 6d 61 70 0a 20  turn $mypremap. 
1190: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64     }..    method
11a0: 20 62 72 65 61 6b 69 6e 74 65 72 6e 61 6c 64 65   breakinternalde
11b0: 70 65 6e 64 65 6e 63 69 65 73 20 7b 7d 20 7b 0a  pendencies {} {.
11c0: 09 23 20 54 68 69 73 20 6d 65 74 68 6f 64 20 69  .# This method i
11d0: 6e 73 70 65 63 74 73 20 74 68 65 20 63 68 61 6e  nspects the chan
11e0: 67 65 73 65 74 73 20 66 6f 72 20 69 6e 74 65 72  gesets for inter
11f0: 6e 61 6c 0a 09 23 20 64 65 70 65 6e 64 65 6e 63  nal..# dependenc
1200: 69 65 73 2e 20 4e 6f 74 68 69 6e 67 20 69 73 20  ies. Nothing is 
1210: 64 6f 6e 65 20 69 66 20 74 68 65 72 65 20 61 72  done if there ar
1220: 65 20 6e 6f 0a 09 23 20 73 75 63 68 2e 20 4f 74  e no..# such. Ot
1230: 68 65 72 77 69 73 65 20 74 68 65 20 63 68 61 6e  herwise the chan
1240: 67 65 73 65 74 20 69 73 20 73 70 6c 69 74 20 69  geset is split i
1250: 6e 74 6f 20 61 20 73 65 74 20 6f 66 0a 09 23 20  nto a set of..# 
1260: 66 72 61 67 6d 65 6e 74 73 20 77 69 74 68 6f 75  fragments withou
1270: 74 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e  t internal depen
1280: 64 65 6e 63 69 65 73 2c 20 74 72 61 6e 73 66 6f  dencies, transfo
1290: 72 6d 69 6e 67 20 74 68 65 0a 09 23 20 69 6e 74  rming the..# int
12a0: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
12b0: 65 73 20 69 6e 74 6f 20 65 78 74 65 72 6e 61 6c  es into external
12c0: 20 6f 6e 65 73 2e 20 54 68 65 20 6e 65 77 20 63   ones. The new c
12d0: 68 61 6e 67 65 73 65 74 73 0a 09 23 20 61 72 65  hangesets..# are
12e0: 20 61 64 64 65 64 20 74 6f 20 74 68 65 20 6c 69   added to the li
12f0: 73 74 20 6f 66 20 61 6c 6c 20 63 68 61 6e 67 65  st of all change
1300: 73 65 74 73 2e 0a 0a 09 23 20 57 65 20 70 65 72  sets....# We per
1310: 66 6f 72 6d 20 61 6c 6c 20 6e 65 63 65 73 73 61  form all necessa
1320: 72 79 20 73 70 6c 69 74 73 20 69 6e 20 6f 6e 65  ry splits in one
1330: 20 67 6f 2c 20 69 6e 73 74 65 61 64 20 6f 66 20   go, instead of 
1340: 6f 6e 6c 79 0a 09 23 20 6f 6e 65 2e 20 54 68 65  only..# one. The
1350: 20 70 72 65 76 69 6f 75 73 20 61 6c 67 6f 72 69   previous algori
1360: 74 68 6d 2c 20 61 64 61 70 74 65 64 20 66 72 6f  thm, adapted fro
1370: 6d 20 63 76 73 32 73 76 6e 2c 20 63 6f 6d 70 75  m cvs2svn, compu
1380: 74 65 64 0a 09 23 20 61 20 6c 6f 74 20 6f 66 20  ted..# a lot of 
1390: 73 74 61 74 65 20 77 68 69 63 68 20 77 61 73 20  state which was 
13a0: 74 68 72 6f 77 6e 20 61 77 61 79 20 61 6e 64 20  thrown away and 
13b0: 74 68 65 6e 20 63 6f 6d 70 75 74 65 64 20 61 67  then computed ag
13c0: 61 69 6e 0a 09 23 20 66 6f 72 20 65 61 63 68 20  ain..# for each 
13d0: 6f 66 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73  of the fragments
13e0: 2e 20 49 74 20 73 68 6f 75 6c 64 20 62 65 20 65  . It should be e
13f0: 61 73 69 65 72 20 74 6f 20 75 70 64 61 74 65 20  asier to update 
1400: 61 6e 64 0a 09 23 20 72 65 75 73 65 20 74 68 61  and..# reuse tha
1410: 74 20 73 74 61 74 65 2e 0a 0a 09 23 20 54 68 65  t state....# The
1420: 20 63 6f 64 65 20 63 68 65 63 6b 73 20 6f 6e 6c   code checks onl
1430: 79 20 73 75 63 65 73 73 6f 72 20 64 65 70 65 6e  y sucessor depen
1440: 64 65 6e 63 69 65 73 2c 20 61 73 20 74 68 69 73  dencies, as this
1450: 0a 09 23 20 61 75 74 6f 6d 61 74 69 63 61 6c 6c  ..# automaticall
1460: 79 20 63 6f 76 65 72 73 20 74 68 65 20 70 72 65  y covers the pre
1470: 64 65 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65  decessor depende
1480: 6e 63 69 65 73 20 61 73 20 77 65 6c 6c 20 28 41  ncies as well (A
1490: 0a 09 23 20 73 75 63 63 65 73 73 6f 72 20 64 65  ..# successor de
14a0: 70 65 6e 64 65 6e 63 79 20 61 20 2d 3e 20 62 20  pendency a -> b 
14b0: 69 73 20 61 6c 73 6f 20 61 20 70 72 65 64 65 63  is also a predec
14c0: 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 79  essor dependency
14d0: 0a 09 23 20 62 20 2d 3e 20 61 29 2e 0a 0a 09 23  ..# b -> a)....#
14e0: 20 41 72 72 61 79 20 6f 66 20 64 65 70 65 6e 64   Array of depend
14f0: 65 6e 63 69 65 73 20 28 70 61 72 65 6e 74 20 2d  encies (parent -
1500: 3e 20 63 68 69 6c 64 29 2e 20 54 68 69 73 20 69  > child). This i
1510: 73 20 70 75 6c 6c 65 64 20 66 72 6f 6d 0a 09 23  s pulled from..#
1520: 20 74 68 65 20 73 74 61 74 65 2c 20 61 6e 64 20   the state, and 
1530: 6c 69 6d 69 74 65 64 20 74 6f 20 73 75 63 63 65  limited to succe
1540: 73 73 6f 72 73 20 77 69 74 68 69 6e 20 74 68 65  ssors within the
1550: 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 61 72   changeset....ar
1560: 72 61 79 20 73 65 74 20 64 65 70 65 6e 64 65 6e  ray set dependen
1570: 63 69 65 73 20 7b 7d 0a 09 50 75 6c 6c 49 6e 74  cies {}..PullInt
1580: 65 72 6e 61 6c 53 75 63 63 65 73 73 6f 72 52 65  ernalSuccessorRe
1590: 76 69 73 69 6f 6e 73 20 64 65 70 65 6e 64 65 6e  visions dependen
15a0: 63 69 65 73 20 24 6d 79 72 65 76 69 73 69 6f 6e  cies $myrevision
15b0: 73 0a 09 69 66 20 7b 21 5b 61 72 72 61 79 20 73  s..if {![array s
15c0: 69 7a 65 20 64 65 70 65 6e 64 65 6e 63 69 65 73  ize dependencies
15d0: 5d 7d 20 7b 72 65 74 75 72 6e 20 30 7d 20 3b 20  ]} {return 0} ; 
15e0: 23 20 4e 6f 74 68 69 6e 67 20 74 6f 20 62 72 65  # Nothing to bre
15f0: 61 6b 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20  ak....log write 
1600: 35 20 63 73 65 74 73 20 2e 2e 2e 5b 24 73 65 6c  5 csets ...[$sel
1610: 66 20 73 74 72 5d 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  f str]..........
1620: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1630: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ................
1640: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 0a 0a 09  ................
1650: 23 20 57 65 20 68 61 76 65 20 69 6e 74 65 72 6e  # We have intern
1660: 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  al dependencies 
1670: 74 6f 20 62 72 65 61 6b 2e 20 57 65 20 6e 6f 77  to break. We now
1680: 20 69 74 65 72 61 74 65 20 6f 76 65 72 0a 09 23   iterate over..#
1690: 20 61 6c 6c 20 70 6f 73 69 74 69 6f 6e 73 20 69   all positions i
16a0: 6e 20 74 68 65 20 6c 69 73 74 20 28 77 68 69 63  n the list (whic
16b0: 68 20 69 73 20 63 68 72 6f 6e 6f 6c 6f 67 69 63  h is chronologic
16c0: 61 6c 2c 20 61 74 20 6c 65 61 73 74 0a 09 23 20  al, at least..# 
16d0: 61 73 20 66 61 72 20 61 73 20 74 68 65 20 74 69  as far as the ti
16e0: 6d 65 73 74 61 6d 70 73 20 61 72 65 20 63 6f 72  mestamps are cor
16f0: 72 65 63 74 20 61 6e 64 20 75 6e 69 71 75 65 29  rect and unique)
1700: 20 61 6e 64 0a 09 23 20 64 65 74 65 72 6d 69 6e   and..# determin
1710: 65 20 74 68 65 20 62 65 73 74 20 70 6f 73 69 74  e the best posit
1720: 69 6f 6e 20 66 6f 72 20 74 68 65 20 62 72 65 61  ion for the brea
1730: 6b 2c 20 62 79 20 74 72 79 69 6e 67 20 74 6f 0a  k, by trying to.
1740: 09 23 20 62 72 65 61 6b 20 61 73 20 6d 61 6e 79  .# break as many
1750: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 61 73   dependencies as
1760: 20 70 6f 73 73 69 62 6c 65 20 69 6e 20 6f 6e 65   possible in one
1770: 20 67 6f 2e 20 57 68 65 6e 20 61 0a 09 23 20 62   go. When a..# b
1780: 72 65 61 6b 20 77 61 73 20 66 6f 75 6e 64 20 74  reak was found t
1790: 68 69 73 20 69 73 20 72 65 64 6f 6e 65 20 66 6f  his is redone fo
17a0: 72 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73 20  r the fragments 
17b0: 63 6f 6d 69 6e 67 20 61 6e 64 0a 09 23 20 61 66  coming and..# af
17c0: 74 65 72 2c 20 61 66 74 65 72 20 75 70 64 69 6e  ter, after updin
17d0: 67 20 74 68 65 20 63 72 6f 73 73 69 6e 67 20 69  g the crossing i
17e0: 6e 66 6f 72 6d 61 74 69 6f 6e 2e 0a 0a 09 23 20  nformation....# 
17f0: 44 61 74 61 20 73 74 72 75 63 74 75 72 65 73 3a  Data structures:
1800: 0a 09 23 20 4d 61 70 3a 20 20 50 4f 53 20 20 20  ..# Map:  POS   
1810: 72 65 76 69 73 69 6f 6e 20 69 64 20 20 20 20 20  revision id     
1820: 20 2d 3e 20 70 6f 73 69 74 69 6f 6e 20 69 6e 20   -> position in 
1830: 6c 69 73 74 2e 0a 09 23 20 20 20 20 20 20 20 43  list...#       C
1840: 52 4f 53 53 20 70 6f 73 69 74 69 6f 6e 20 69 6e  ROSS position in
1850: 20 6c 69 73 74 20 2d 3e 20 6e 75 6d 62 65 72 20   list -> number 
1860: 6f 66 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  of dependencies 
1870: 63 72 6f 73 73 69 6e 67 20 69 74 0a 09 23 20 20  crossing it..#  
1880: 20 20 20 20 20 44 45 50 43 20 20 64 65 70 65 6e       DEPC  depen
1890: 64 65 6e 63 79 20 20 20 20 20 20 20 2d 3e 20 70  dency       -> p
18a0: 6f 73 69 74 69 6f 6e 73 20 69 74 20 63 72 6f 73  ositions it cros
18b0: 73 65 73 0a 09 23 20 4c 69 73 74 3a 20 52 41 4e  ses..# List: RAN
18c0: 47 45 20 4f 66 20 74 68 65 20 70 6f 73 69 74 69  GE Of the positi
18d0: 6f 6e 73 20 69 74 73 65 6c 66 2e 0a 09 23 20 41  ons itself...# A
18e0: 20 64 65 70 65 6e 64 65 6e 63 79 20 69 73 20 61   dependency is a
18f0: 20 73 69 6e 67 6c 65 2d 65 6c 65 6d 65 6e 74 20   single-element 
1900: 6d 61 70 20 70 61 72 65 6e 74 20 2d 3e 20 63 68  map parent -> ch
1910: 69 6c 64 0a 0a 09 49 6e 69 74 69 61 6c 69 7a 65  ild...Initialize
1920: 42 72 65 61 6b 53 74 61 74 65 20 24 6d 79 72 65  BreakState $myre
1930: 76 69 73 69 6f 6e 73 0a 0a 09 73 65 74 20 66 72  visions...set fr
1940: 61 67 6d 65 6e 74 73 20 7b 7d 0a 09 73 65 74 20  agments {}..set 
1950: 70 65 6e 64 69 6e 67 20 20 20 5b 6c 69 73 74 20  pending   [list 
1960: 24 72 61 6e 67 65 5d 0a 09 73 65 74 20 61 74 20  $range]..set at 
1970: 20 20 20 20 20 20 20 30 0a 09 61 72 72 61 79 20         0..array 
1980: 73 65 74 20 62 72 65 61 6b 73 20 7b 7d 0a 0a 09  set breaks {}...
1990: 77 68 69 6c 65 20 7b 24 61 74 20 3c 20 5b 6c 6c  while {$at < [ll
19a0: 65 6e 67 74 68 20 24 70 65 6e 64 69 6e 67 5d 7d  ength $pending]}
19b0: 20 7b 0a 09 20 20 20 20 73 65 74 20 63 75 72 72   {..    set curr
19c0: 65 6e 74 20 5b 6c 69 6e 64 65 78 20 24 70 65 6e  ent [lindex $pen
19d0: 64 69 6e 67 20 24 61 74 5d 0a 0a 09 20 20 20 20  ding $at]...    
19e0: 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65 74  log write 6 cset
19f0: 73 20 7b 2e 20 2e 20 2e 2e 20 2e 2e 2e 20 2e 2e  s {. . .. ... ..
1a00: 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e 2e 2e  ... ........ ...
1a10: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 7d 0a 09 20 20 20  ..........}..   
1a20: 20 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65   log write 6 cse
1a30: 74 73 20 7b 53 63 68 65 64 75 6c 65 64 20 20 20  ts {Scheduled   
1a40: 5b 6a 6f 69 6e 20 5b 50 52 73 20 5b 6c 72 61 6e  [join [PRs [lran
1a50: 67 65 20 24 70 65 6e 64 69 6e 67 20 24 61 74 20  ge $pending $at 
1a60: 65 6e 64 5d 5d 20 7b 20 7d 5d 7d 0a 09 20 20 20  end]] { }]}..   
1a70: 20 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65   log write 6 cse
1a80: 74 73 20 7b 43 6f 6e 73 69 64 65 72 69 6e 67 20  ts {Considering 
1a90: 5b 50 52 20 24 63 75 72 72 65 6e 74 5d 20 5c 5b  [PR $current] \[
1aa0: 24 61 74 2f 5b 6c 6c 65 6e 67 74 68 20 24 70 65  $at/[llength $pe
1ab0: 6e 64 69 6e 67 5d 5c 5d 7d 0a 0a 09 20 20 20 20  nding]\]}...    
1ac0: 73 65 74 20 62 65 73 74 20 5b 46 69 6e 64 42 65  set best [FindBe
1ad0: 73 74 42 72 65 61 6b 20 24 63 75 72 72 65 6e 74  stBreak $current
1ae0: 5d 0a 0a 09 20 20 20 20 69 66 20 7b 24 62 65 73  ]...    if {$bes
1af0: 74 20 3c 20 30 7d 20 7b 0a 09 09 23 20 54 68 65  t < 0} {...# The
1b00: 20 69 6e 73 70 65 63 74 65 64 20 72 61 6e 67 65   inspected range
1b10: 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61 6c   has no internal
1b20: 0a 09 09 23 20 64 65 70 65 6e 64 65 6e 63 69 65  ...# dependencie
1b30: 73 2e 20 54 68 69 73 20 69 73 20 61 20 63 6f 6d  s. This is a com
1b40: 70 6c 65 74 65 20 66 72 61 67 6d 65 6e 74 2e 0a  plete fragment..
1b50: 09 09 6c 61 70 70 65 6e 64 20 66 72 61 67 6d 65  ..lappend fragme
1b60: 6e 74 73 20 24 63 75 72 72 65 6e 74 0a 0a 09 09  nts $current....
1b70: 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65 74  log write 6 cset
1b80: 73 20 22 4e 6f 20 62 72 65 61 6b 73 2c 20 66 69  s "No breaks, fi
1b90: 6e 61 6c 22 0a 09 20 20 20 20 7d 20 65 6c 73 65  nal"..    } else
1ba0: 20 7b 0a 09 09 23 20 53 70 6c 69 74 20 74 68 65   {...# Split the
1bb0: 20 72 61 6e 67 65 20 61 6e 64 20 73 63 68 65 64   range and sched
1bc0: 75 6c 65 20 74 68 65 20 72 65 73 75 6c 74 69 6e  ule the resultin
1bd0: 67 20 66 72 61 67 6d 65 6e 74 73 0a 09 09 23 20  g fragments...# 
1be0: 66 6f 72 20 66 75 72 74 68 65 72 20 69 6e 73 70  for further insp
1bf0: 65 63 74 69 6f 6e 2e 20 52 65 6d 65 6d 62 65 72  ection. Remember
1c00: 20 74 68 65 20 6e 75 6d 62 65 72 20 6f 66 0a 09   the number of..
1c10: 09 23 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  .# dependencies 
1c20: 63 75 74 20 62 65 66 6f 72 65 20 77 65 20 72 65  cut before we re
1c30: 6d 6f 76 65 20 74 68 65 6d 20 66 72 6f 6d 0a 09  move them from..
1c40: 09 23 20 63 6f 6e 73 69 64 65 72 61 74 69 6f 6e  .# consideration
1c50: 2c 20 66 6f 72 20 64 6f 63 75 6d 65 6e 74 61 74  , for documentat
1c60: 69 6f 6e 20 6c 61 74 65 72 2e 0a 0a 09 09 73 65  ion later.....se
1c70: 74 20 62 72 65 61 6b 73 28 24 62 65 73 74 29 20  t breaks($best) 
1c80: 24 63 72 6f 73 73 28 24 62 65 73 74 29 0a 0a 09  $cross($best)...
1c90: 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65  .log write 6 cse
1ca0: 74 73 20 22 42 65 73 74 20 62 72 65 61 6b 20 40  ts "Best break @
1cb0: 20 24 62 65 73 74 2c 20 63 75 74 74 69 6e 67 20   $best, cutting 
1cc0: 5b 6e 73 70 20 24 63 72 6f 73 73 28 24 62 65 73  [nsp $cross($bes
1cd0: 74 29 20 64 65 70 65 6e 64 65 6e 63 79 20 64 65  t) dependency de
1ce0: 70 65 6e 64 65 6e 63 69 65 73 5d 22 0a 0a 09 09  pendencies]"....
1cf0: 23 20 4e 6f 74 65 3a 20 54 68 65 20 76 61 6c 75  # Note: The valu
1d00: 65 20 6f 66 20 62 65 73 74 20 69 73 20 61 6e 20  e of best is an 
1d10: 61 62 6f 6c 75 74 65 20 6c 6f 63 61 74 69 6f 6e  abolute location
1d20: 20 69 6e 0a 09 09 23 20 6d 79 72 65 76 69 73 69   in...# myrevisi
1d30: 6f 6e 73 2e 20 55 73 65 20 74 68 65 20 73 74 61  ons. Use the sta
1d40: 72 74 20 6f 66 20 63 75 72 72 65 6e 74 20 74 6f  rt of current to
1d50: 20 6d 61 6b 65 20 69 74 20 61 6e 0a 09 09 23 20   make it an...# 
1d60: 69 6e 64 65 78 20 61 62 73 6f 6c 75 74 65 20 74  index absolute t
1d70: 6f 20 63 75 72 72 65 6e 74 2e 0a 0a 09 09 73 65  o current.....se
1d80: 74 20 62 72 65 6c 20 5b 65 78 70 72 20 7b 24 62  t brel [expr {$b
1d90: 65 73 74 20 2d 20 5b 6c 69 6e 64 65 78 20 24 63  est - [lindex $c
1da0: 75 72 72 65 6e 74 20 30 5d 7d 5d 0a 09 09 73 65  urrent 0]}]...se
1db0: 74 20 62 6e 65 78 74 20 24 62 72 65 6c 20 3b 20  t bnext $brel ; 
1dc0: 69 6e 63 72 20 62 6e 65 78 74 0a 09 09 73 65 74  incr bnext...set
1dd0: 20 66 72 61 67 62 65 66 6f 72 65 20 5b 6c 72 61   fragbefore [lra
1de0: 6e 67 65 20 24 63 75 72 72 65 6e 74 20 30 20 24  nge $current 0 $
1df0: 62 72 65 6c 5d 0a 09 09 73 65 74 20 66 72 61 67  brel]...set frag
1e00: 61 66 74 65 72 20 20 5b 6c 72 61 6e 67 65 20 24  after  [lrange $
1e10: 63 75 72 72 65 6e 74 20 24 62 6e 65 78 74 20 65  current $bnext e
1e20: 6e 64 5d 0a 0a 09 09 6c 6f 67 20 77 72 69 74 65  nd]....log write
1e30: 20 36 20 63 73 65 74 73 20 22 4e 65 77 20 70 69   6 csets "New pi
1e40: 65 63 65 73 20 20 5b 50 52 20 24 66 72 61 67 62  eces  [PR $fragb
1e50: 65 66 6f 72 65 5d 20 5b 50 52 20 24 66 72 61 67  efore] [PR $frag
1e60: 61 66 74 65 72 5d 22 0a 0a 09 09 69 6e 74 65 67  after]"....integ
1e70: 72 69 74 79 20 61 73 73 65 72 74 20 7b 5b 6c 6c  rity assert {[ll
1e80: 65 6e 67 74 68 20 24 66 72 61 67 62 65 66 6f 72  ength $fragbefor
1e90: 65 5d 7d 20 7b 46 6f 75 6e 64 20 7a 65 72 6f 2d  e]} {Found zero-
1ea0: 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 20  length fragment 
1eb0: 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67  at the beginning
1ec0: 7d 0a 09 09 69 6e 74 65 67 72 69 74 79 20 61 73  }...integrity as
1ed0: 73 65 72 74 20 7b 5b 6c 6c 65 6e 67 74 68 20 24  sert {[llength $
1ee0: 66 72 61 67 61 66 74 65 72 5d 7d 20 20 7b 46 6f  fragafter]}  {Fo
1ef0: 75 6e 64 20 7a 65 72 6f 2d 6c 65 6e 67 74 68 20  und zero-length 
1f00: 66 72 61 67 6d 65 6e 74 20 61 74 20 74 68 65 20  fragment at the 
1f10: 65 6e 64 7d 0a 0a 09 09 6c 61 70 70 65 6e 64 20  end}....lappend 
1f20: 70 65 6e 64 69 6e 67 20 24 66 72 61 67 62 65 66  pending $fragbef
1f30: 6f 72 65 20 24 66 72 61 67 61 66 74 65 72 0a 09  ore $fragafter..
1f40: 09 43 75 74 41 74 20 24 62 65 73 74 0a 09 20 20  .CutAt $best..  
1f50: 20 20 7d 0a 0a 09 20 20 20 20 69 6e 63 72 20 61    }...    incr a
1f60: 74 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65  t..}...log write
1f70: 20 36 20 63 73 65 74 73 20 22 2e 20 2e 20 2e 2e   6 csets ". . ..
1f80: 20 2e 2e 2e 20 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e   ... ..... .....
1f90: 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e  ... ............
1fa0: 2e 22 0a 0a 09 23 20 28 2a 29 20 57 65 20 63 6c  ."...# (*) We cl
1fb0: 65 61 72 20 6f 75 74 20 74 68 65 20 61 73 73 6f  ear out the asso
1fc0: 63 69 61 74 65 64 20 70 61 72 74 20 6f 66 20 74  ciated part of t
1fd0: 68 65 20 6d 79 72 65 76 6d 61 70 0a 09 23 20 69  he myrevmap..# i
1fe0: 6e 2d 6d 65 6d 6f 72 79 20 69 6e 64 65 78 20 69  n-memory index i
1ff0: 6e 20 70 72 65 70 61 72 61 74 69 6f 6e 20 66 6f  n preparation fo
2000: 72 20 6e 65 77 20 64 61 74 61 2e 20 41 20 73 69  r new data. A si
2010: 6d 70 6c 65 20 75 6e 73 65 74 0a 09 23 20 69 73  mple unset..# is
2020: 20 65 6e 6f 75 67 68 2c 20 77 65 20 68 61 76 65   enough, we have
2030: 20 6e 6f 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67   no symbol chang
2040: 65 73 65 74 73 20 61 74 20 74 68 69 73 20 74 69  esets at this ti
2050: 6d 65 2c 20 61 6e 64 0a 09 23 20 74 68 75 73 20  me, and..# thus 
2060: 6e 65 76 65 72 20 6d 6f 72 65 20 74 68 61 6e 20  never more than 
2070: 6f 6e 65 20 72 65 66 65 72 65 6e 63 65 20 69 6e  one reference in
2080: 20 74 68 65 20 6c 69 73 74 2e 0a 0a 09 66 6f 72   the list....for
2090: 65 61 63 68 20 72 20 24 6d 79 72 65 76 69 73 69  each r $myrevisi
20a0: 6f 6e 73 20 7b 20 75 6e 73 65 74 20 6d 79 72 65  ons { unset myre
20b0: 76 6d 61 70 28 24 72 29 20 7d 0a 0a 09 23 20 43  vmap($r) }...# C
20c0: 72 65 61 74 65 20 63 68 61 6e 67 65 73 65 74 73  reate changesets
20d0: 20 66 6f 72 20 74 68 65 20 66 72 61 67 6d 65 6e   for the fragmen
20e0: 74 73 2c 20 72 65 75 73 69 6e 67 20 74 68 65 20  ts, reusing the 
20f0: 63 75 72 72 65 6e 74 20 6f 6e 65 0a 09 23 20 66  current one..# f
2100: 6f 72 20 74 68 65 20 66 69 72 73 74 20 66 72 61  or the first fra
2110: 67 6d 65 6e 74 2e 20 57 65 20 73 6f 72 74 20 74  gment. We sort t
2120: 68 65 6d 20 69 6e 20 6f 72 64 65 72 20 74 6f 20  hem in order to 
2130: 61 6c 6c 6f 77 0a 09 23 20 63 68 65 63 6b 69 6e  allow..# checkin
2140: 67 20 66 6f 72 20 67 61 70 73 20 61 6e 64 20 6e  g for gaps and n
2150: 69 63 65 20 6d 65 73 73 61 67 65 73 2e 0a 0a 09  ice messages....
2160: 73 65 74 20 66 72 61 67 6d 65 6e 74 73 20 5b 6c  set fragments [l
2170: 73 6f 72 74 20 2d 69 6e 64 65 78 20 30 20 2d 69  sort -index 0 -i
2180: 6e 74 65 67 65 72 20 24 66 72 61 67 6d 65 6e 74  nteger $fragment
2190: 73 5d 0a 0a 09 23 70 75 74 73 20 5c 74 2e 5b 6a  s]...#puts \t.[j
21a0: 6f 69 6e 20 5b 50 52 73 20 24 66 72 61 67 6d 65  oin [PRs $fragme
21b0: 6e 74 73 5d 20 2e 5c 6e 5c 74 2e 5d 2e 0a 0a 09  nts] .\n\t.]....
21c0: 42 6f 72 64 65 72 20 5b 6c 69 6e 64 65 78 20 24  Border [lindex $
21d0: 66 72 61 67 6d 65 6e 74 73 20 30 5d 20 66 69 72  fragments 0] fir
21e0: 73 74 73 20 66 69 72 73 74 65 0a 0a 09 69 6e 74  sts firste...int
21f0: 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 24  egrity assert {$
2200: 66 69 72 73 74 73 20 3d 3d 20 30 7d 20 7b 42 61  firsts == 0} {Ba
2210: 64 20 66 72 61 67 6d 65 6e 74 20 73 74 61 72 74  d fragment start
2220: 20 40 20 24 66 69 72 73 74 73 2c 20 67 61 70 2c   @ $firsts, gap,
2230: 20 6f 72 20 62 65 66 6f 72 65 20 62 65 67 69 6e   or before begin
2240: 6e 69 6e 67 20 6f 66 20 74 68 65 20 72 61 6e 67  ning of the rang
2250: 65 7d 0a 0a 09 73 65 74 20 6c 61 73 74 65 20 24  e}...set laste $
2260: 66 69 72 73 74 65 0a 09 66 6f 72 65 61 63 68 20  firste..foreach 
2270: 66 72 61 67 6d 65 6e 74 20 5b 6c 72 61 6e 67 65  fragment [lrange
2280: 20 24 66 72 61 67 6d 65 6e 74 73 20 31 20 65 6e   $fragments 1 en
2290: 64 5d 20 7b 0a 09 20 20 20 20 42 6f 72 64 65 72  d] {..    Border
22a0: 20 24 66 72 61 67 6d 65 6e 74 20 73 20 65 0a 09   $fragment s e..
22b0: 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73      integrity as
22c0: 73 65 72 74 20 7b 24 6c 61 73 74 65 20 3d 3d 20  sert {$laste == 
22d0: 28 24 73 20 2d 20 31 29 7d 20 7b 42 61 64 20 66  ($s - 1)} {Bad f
22e0: 72 61 67 6d 65 6e 74 20 62 6f 72 64 65 72 20 3c  ragment border <
22f0: 24 6c 61 73 74 65 20 7c 20 24 73 3e 2c 20 67 61  $laste | $s>, ga
2300: 70 20 6f 72 20 6f 76 65 72 6c 61 70 7d 0a 0a 09  p or overlap}...
2310: 20 20 20 20 73 65 74 20 6e 65 77 20 5b 24 74 79      set new [$ty
2320: 70 65 20 25 41 55 54 4f 25 20 24 6d 79 70 72 6f  pe %AUTO% $mypro
2330: 6a 65 63 74 20 24 6d 79 74 79 70 65 20 24 6d 79  ject $mytype $my
2340: 73 72 63 69 64 20 5b 6c 72 61 6e 67 65 20 24 6d  srcid [lrange $m
2350: 79 72 65 76 69 73 69 6f 6e 73 20 24 73 20 24 65  yrevisions $s $e
2360: 5d 5d 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20  ]]..            
2370: 6c 6f 67 20 77 72 69 74 65 20 34 20 63 73 65 74  log write 4 cset
2380: 73 20 22 42 72 65 61 6b 69 6e 67 20 5b 24 73 65  s "Breaking [$se
2390: 6c 66 20 73 74 72 20 5d 20 40 20 24 6c 61 73 74  lf str ] @ $last
23a0: 65 2c 20 6e 65 77 20 5b 24 6e 65 77 20 73 74 72  e, new [$new str
23b0: 5d 2c 20 63 75 74 74 69 6e 67 20 24 62 72 65 61  ], cutting $brea
23c0: 6b 73 28 24 6c 61 73 74 65 29 22 0a 0a 09 20 20  ks($laste)"...  
23d0: 20 20 73 65 74 20 6c 61 73 74 65 20 24 65 0a 09    set laste $e..
23e0: 7d 0a 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73  }...integrity as
23f0: 73 65 72 74 20 7b 0a 09 20 20 20 20 24 6c 61 73  sert {..    $las
2400: 74 65 20 3d 3d 20 28 5b 6c 6c 65 6e 67 74 68 20  te == ([llength 
2410: 24 6d 79 72 65 76 69 73 69 6f 6e 73 5d 2d 31 29  $myrevisions]-1)
2420: 0a 09 7d 20 7b 42 61 64 20 66 72 61 67 6d 65 6e  ..} {Bad fragmen
2430: 74 20 65 6e 64 20 40 20 24 6c 61 73 74 65 2c 20  t end @ $laste, 
2440: 67 61 70 2c 20 6f 72 20 62 65 79 6f 6e 64 20 65  gap, or beyond e
2450: 6e 64 20 6f 66 20 74 68 65 20 72 61 6e 67 65 7d  nd of the range}
2460: 0a 0a 09 23 20 50 75 74 20 74 68 65 20 66 69 72  ...# Put the fir
2470: 73 74 20 66 72 61 67 6d 65 6e 74 20 69 6e 74 6f  st fragment into
2480: 20 74 68 65 20 63 75 72 72 65 6e 74 20 63 68 61   the current cha
2490: 6e 67 65 73 65 74 2c 20 61 6e 64 0a 09 23 20 75  ngeset, and..# u
24a0: 70 64 61 74 65 20 74 68 65 20 69 6e 2d 6d 65 6d  pdate the in-mem
24b0: 6f 72 79 20 69 6e 64 65 78 2e 20 57 65 20 63 61  ory index. We ca
24c0: 6e 20 73 69 6d 70 6c 79 20 28 72 65 29 61 64 64  n simply (re)add
24d0: 20 74 68 65 0a 09 23 20 72 65 76 69 73 69 6f 6e   the..# revision
24e0: 73 20 62 65 63 61 75 73 65 20 77 65 20 63 6c 65  s because we cle
24f0: 61 72 65 64 20 74 68 65 20 70 72 65 76 69 6f 75  ared the previou
2500: 73 6c 79 20 65 78 69 73 74 69 6e 67 0a 09 23 20  sly existing..# 
2510: 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20 73 65 65  information, see
2520: 20 28 2a 29 20 61 62 6f 76 65 2e 20 50 65 72 73   (*) above. Pers
2530: 69 73 74 65 6e 63 65 20 64 6f 65 73 20 6e 6f 74  istence does not
2540: 20 6d 61 74 74 65 72 0a 09 23 20 68 65 72 65 2c   matter..# here,
2550: 20 6e 6f 6e 65 20 6f 66 20 74 68 65 20 63 68 61   none of the cha
2560: 6e 67 65 73 65 74 73 20 68 61 73 20 62 65 65 6e  ngesets has been
2570: 20 73 61 76 65 64 20 74 6f 20 74 68 65 0a 09 23   saved to the..#
2580: 20 70 65 72 73 69 73 74 65 6e 74 20 73 74 61 74   persistent stat
2590: 65 20 79 65 74 2e 0a 0a 09 73 65 74 20 6d 79 72  e yet....set myr
25a0: 65 76 69 73 69 6f 6e 73 20 5b 6c 72 61 6e 67 65  evisions [lrange
25b0: 20 24 6d 79 72 65 76 69 73 69 6f 6e 73 20 30 20   $myrevisions 0 
25c0: 24 66 69 72 73 74 65 5d 0a 09 66 6f 72 65 61 63  $firste]..foreac
25d0: 68 20 72 20 24 6d 79 72 65 76 69 73 69 6f 6e 73  h r $myrevisions
25e0: 20 7b 20 6c 61 70 70 65 6e 64 20 6d 79 72 65 76   { lappend myrev
25f0: 6d 61 70 28 24 72 29 20 24 73 65 6c 66 20 7d 0a  map($r) $self }.
2600: 0a 09 72 65 74 75 72 6e 20 31 0a 20 20 20 20 7d  ..return 1.    }
2610: 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 70 65 72  ..    method per
2620: 73 69 73 74 20 7b 7d 20 7b 0a 09 73 65 74 20 74  sist {} {..set t
2630: 69 64 20 24 6d 79 63 73 74 79 70 65 28 24 6d 79  id $mycstype($my
2640: 74 79 70 65 29 0a 09 73 65 74 20 70 69 64 20 5b  type)..set pid [
2650: 24 6d 79 70 72 6f 6a 65 63 74 20 69 64 5d 0a 09  $myproject id]..
2660: 73 65 74 20 70 6f 73 20 30 0a 0a 09 73 74 61 74  set pos 0...stat
2670: 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 7b 0a  e transaction {.
2680: 09 20 20 20 20 73 74 61 74 65 20 72 75 6e 20 7b  .    state run {
2690: 0a 09 09 49 4e 53 45 52 54 20 49 4e 54 4f 20 63  ...INSERT INTO c
26a0: 68 61 6e 67 65 73 65 74 20 28 63 69 64 2c 20 20  hangeset (cid,  
26b0: 20 70 69 64 2c 20 20 74 79 70 65 2c 20 73 72 63   pid,  type, src
26c0: 29 0a 09 09 56 41 4c 55 45 53 20 20 20 20 20 20  )...VALUES      
26d0: 20 20 20 20 20 20 20 20 20 20 28 24 6d 79 69 64            ($myid
26e0: 2c 20 24 70 69 64 2c 20 24 74 69 64 2c 20 24 6d  , $pid, $tid, $m
26f0: 79 73 72 63 69 64 29 3b 0a 09 20 20 20 20 7d 0a  ysrcid);..    }.
2700: 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20 72 69  ..    foreach ri
2710: 64 20 24 6d 79 72 65 76 69 73 69 6f 6e 73 20 7b  d $myrevisions {
2720: 0a 09 09 73 74 61 74 65 20 72 75 6e 20 7b 0a 09  ...state run {..
2730: 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e 54 4f  .    INSERT INTO
2740: 20 63 73 72 65 76 69 73 69 6f 6e 20 28 63 69 64   csrevision (cid
2750: 2c 20 20 20 70 6f 73 2c 20 20 72 69 64 29 0a 09  ,   pos,  rid)..
2760: 09 20 20 20 20 56 41 4c 55 45 53 20 20 20 20 20  .    VALUES     
2770: 20 20 20 20 20 20 20 20 20 20 20 20 28 24 6d 79              ($my
2780: 69 64 2c 20 24 70 6f 73 2c 20 24 72 69 64 29 3b  id, $pos, $rid);
2790: 0a 09 09 7d 0a 09 09 69 6e 63 72 20 70 6f 73 0a  ...}...incr pos.
27a0: 09 20 20 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72  .    }..}..retur
27b0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74  n.    }..    met
27c0: 68 6f 64 20 74 69 6d 65 72 61 6e 67 65 20 7b 7d  hod timerange {}
27d0: 20 7b 0a 09 73 65 74 20 74 68 65 73 65 74 20 28   {..set theset (
27e0: 27 5b 6a 6f 69 6e 20 24 6d 79 72 65 76 69 73 69  '[join $myrevisi
27f0: 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65  ons {','}]')..re
2800: 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20  turn [state run 
2810: 22 0a 09 20 20 20 20 53 45 4c 45 43 54 20 4d 49  "..    SELECT MI
2820: 4e 28 52 2e 64 61 74 65 29 2c 20 4d 41 58 28 52  N(R.date), MAX(R
2830: 2e 64 61 74 65 29 0a 09 20 20 20 20 46 52 4f 4d  .date)..    FROM
2840: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20   revision R..   
2850: 20 57 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20   WHERE R.rid IN 
2860: 24 74 68 65 73 65 74 0a 09 22 5d 0a 20 20 20 20  $theset.."].    
2870: 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 64 72  }..    method dr
2880: 6f 70 20 7b 7d 20 7b 0a 09 73 74 61 74 65 20 74  op {} {..state t
2890: 72 61 6e 73 61 63 74 69 6f 6e 20 7b 0a 09 20 20  ransaction {..  
28a0: 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09    state run {...
28b0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 63 68 61 6e  DELETE FROM chan
28c0: 67 65 73 65 74 20 20 57 48 45 52 45 20 63 69 64  geset  WHERE cid
28d0: 20 3d 20 24 6d 79 69 64 3b 0a 09 09 44 45 4c 45   = $myid;...DELE
28e0: 54 45 20 46 52 4f 4d 20 63 73 72 65 76 69 73 69  TE FROM csrevisi
28f0: 6f 6e 20 57 48 45 52 45 20 63 69 64 20 3d 20 24  on WHERE cid = $
2900: 6d 79 69 64 3b 0a 09 20 20 20 20 7d 0a 09 7d 0a  myid;..    }..}.
2910: 09 66 6f 72 65 61 63 68 20 72 20 24 6d 79 72 65  .foreach r $myre
2920: 76 69 73 69 6f 6e 73 20 7b 0a 09 20 20 20 20 69  visions {..    i
2930: 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 6d 79 72  f {[llength $myr
2940: 65 76 6d 61 70 28 24 72 29 5d 20 3d 3d 20 31 7d  evmap($r)] == 1}
2950: 20 7b 0a 09 09 75 6e 73 65 74 20 6d 79 72 65 76   {...unset myrev
2960: 6d 61 70 28 24 72 29 0a 09 20 20 20 20 7d 20 65  map($r)..    } e
2970: 6c 73 65 20 7b 0a 09 09 73 65 74 20 70 6f 73 20  lse {...set pos 
2980: 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 63 74 20  [lsearch -exact 
2990: 24 6d 79 72 65 76 6d 61 70 28 24 72 29 20 24 73  $myrevmap($r) $s
29a0: 65 6c 66 5d 0a 09 09 73 65 74 20 6d 79 72 65 76  elf]...set myrev
29b0: 6d 61 70 28 24 72 29 20 5b 6c 72 65 70 6c 61 63  map($r) [lreplac
29c0: 65 20 24 6d 79 72 65 76 6d 61 70 28 24 72 29 20  e $myrevmap($r) 
29d0: 24 70 6f 73 20 24 70 6f 73 5d 0a 09 20 20 20 20  $pos $pos]..    
29e0: 7d 0a 09 7d 0a 09 73 65 74 20 70 6f 73 20 20 20  }..}..set pos   
29f0: 20 20 20 20 20 20 20 5b 6c 73 65 61 72 63 68 20         [lsearch 
2a00: 2d 65 78 61 63 74 20 24 6d 79 63 68 61 6e 67 65  -exact $mychange
2a10: 73 65 74 73 20 24 73 65 6c 66 5d 0a 09 73 65 74  sets $self]..set
2a20: 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 5b 6c   mychangesets [l
2a30: 72 65 70 6c 61 63 65 20 24 6d 79 63 68 61 6e 67  replace $mychang
2a40: 65 73 65 74 73 20 24 70 6f 73 20 24 70 6f 73 5d  esets $pos $pos]
2a50: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
2a60: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73      typemethod s
2a70: 70 6c 69 74 20 7b 63 73 65 74 20 61 72 67 73 7d  plit {cset args}
2a80: 20 7b 0a 09 23 20 41 73 20 70 61 72 74 20 6f 66   {..# As part of
2a90: 20 74 68 65 20 63 72 65 61 74 69 6f 6e 20 6f 66   the creation of
2aa0: 20 74 68 65 20 6e 65 77 20 63 68 61 6e 67 65 73   the new changes
2ab0: 65 74 73 20 73 70 65 63 69 66 69 65 64 20 69 6e  ets specified in
2ac0: 0a 09 23 20 41 52 47 53 20 61 73 20 73 65 74 73  ..# ARGS as sets
2ad0: 20 6f 66 20 72 65 76 69 73 69 6f 6e 73 2c 20 61   of revisions, a
2ae0: 6c 6c 20 73 75 62 73 65 74 73 20 6f 66 20 43 53  ll subsets of CS
2af0: 45 54 27 73 20 72 65 76 69 73 69 6f 6e 0a 09 23  ET's revision..#
2b00: 20 73 65 74 2c 20 43 53 45 54 20 77 69 6c 6c 20   set, CSET will 
2b10: 62 65 20 64 72 6f 70 70 65 64 20 66 72 6f 6d 20  be dropped from 
2b20: 61 6c 6c 20 64 61 74 61 62 61 73 65 73 2c 20 69  all databases, i
2b30: 6e 20 61 6e 64 20 6f 75 74 20 6f 66 0a 09 23 20  n and out of..# 
2b40: 6d 65 6d 6f 72 79 2c 20 61 6e 64 20 74 68 65 6e  memory, and then
2b50: 20 64 65 73 74 72 6f 79 65 64 2e 0a 0a 09 73 74   destroyed....st
2b60: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
2b70: 6e 20 5b 24 63 73 65 74 20 64 61 74 61 5d 20 70  n [$cset data] p
2b80: 72 6f 6a 65 63 74 20 63 73 74 79 70 65 20 63 73  roject cstype cs
2b90: 73 72 63 0a 0a 09 24 63 73 65 74 20 64 72 6f 70  src...$cset drop
2ba0: 0a 09 24 63 73 65 74 20 64 65 73 74 72 6f 79 0a  ..$cset destroy.
2bb0: 0a 09 73 65 74 20 6e 65 77 63 73 65 74 73 20 7b  ..set newcsets {
2bc0: 7d 0a 09 66 6f 72 65 61 63 68 20 66 72 61 67 6d  }..foreach fragm
2bd0: 65 6e 74 72 65 76 69 73 69 6f 6e 73 20 24 61 72  entrevisions $ar
2be0: 67 73 20 7b 0a 09 20 20 20 20 69 6e 74 65 67 72  gs {..    integr
2bf0: 69 74 79 20 61 73 73 65 72 74 20 7b 0a 09 09 5b  ity assert {...[
2c00: 6c 6c 65 6e 67 74 68 20 24 66 72 61 67 6d 65 6e  llength $fragmen
2c10: 74 72 65 76 69 73 69 6f 6e 73 5d 0a 09 20 20 20  trevisions]..   
2c20: 20 7d 20 7b 41 74 74 65 6d 70 74 65 64 20 74 6f   } {Attempted to
2c30: 20 63 72 65 61 74 65 20 61 6e 20 65 6d 70 74 79   create an empty
2c40: 20 63 68 61 6e 67 65 73 65 74 2c 20 69 2e 65 2e   changeset, i.e.
2c50: 20 77 69 74 68 6f 75 74 20 72 65 76 69 73 69 6f   without revisio
2c60: 6e 73 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64  ns}..    lappend
2c70: 20 6e 65 77 63 73 65 74 73 20 5b 24 74 79 70 65   newcsets [$type
2c80: 20 25 41 55 54 4f 25 20 24 70 72 6f 6a 65 63 74   %AUTO% $project
2c90: 20 24 63 73 74 79 70 65 20 24 63 73 73 72 63 20   $cstype $cssrc 
2ca0: 24 66 72 61 67 6d 65 6e 74 72 65 76 69 73 69 6f  $fragmentrevisio
2cb0: 6e 73 5d 0a 09 7d 0a 0a 09 66 6f 72 65 61 63 68  ns]..}...foreach
2cc0: 20 63 20 24 6e 65 77 63 73 65 74 73 20 7b 20 24   c $newcsets { $
2cd0: 63 20 70 65 72 73 69 73 74 20 7d 0a 09 72 65 74  c persist }..ret
2ce0: 75 72 6e 20 24 6e 65 77 63 73 65 74 73 0a 20 20  urn $newcsets.  
2cf0: 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74    }..    typemet
2d00: 68 6f 64 20 73 74 72 6c 69 73 74 20 7b 63 68 61  hod strlist {cha
2d10: 6e 67 65 73 65 74 73 7d 20 7b 0a 09 72 65 74 75  ngesets} {..retu
2d20: 72 6e 20 5b 6a 6f 69 6e 20 5b 73 74 72 75 63 74  rn [join [struct
2d30: 3a 3a 6c 69 73 74 20 6d 61 70 20 24 63 68 61 6e  ::list map $chan
2d40: 67 65 73 65 74 73 20 5b 6d 79 70 72 6f 63 20 49  gesets [myproc I
2d50: 44 5d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  D]]].    }..    
2d60: 70 72 6f 63 20 49 44 20 7b 63 73 65 74 7d 20 7b  proc ID {cset} {
2d70: 20 24 63 73 65 74 20 73 74 72 20 7d 0a 0a 20 20   $cset str }..  
2d80: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
2d90: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
2da0: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
2db0: 20 53 74 61 74 65 0a 0a 20 20 20 20 76 61 72 69   State..    vari
2dc0: 61 62 6c 65 20 6d 79 69 64 20 20 20 20 20 20 20  able myid       
2dd0: 20 7b 7d 20 3b 20 23 20 49 64 20 6f 66 20 74 68   {} ; # Id of th
2de0: 65 20 63 73 65 74 20 66 6f 72 20 74 68 65 20 70  e cset for the p
2df0: 65 72 73 69 73 74 65 6e 74 0a 09 09 09 20 20 20  ersistent....   
2e00: 20 20 20 23 20 73 74 61 74 65 2e 0a 20 20 20 20     # state..    
2e10: 76 61 72 69 61 62 6c 65 20 6d 79 70 72 6f 6a 65  variable myproje
2e20: 63 74 20 20 20 7b 7d 20 3b 20 23 20 52 65 66 65  ct   {} ; # Refe
2e30: 72 65 6e 63 65 20 6f 66 20 74 68 65 20 70 72 6f  rence of the pro
2e40: 6a 65 63 74 20 6f 62 6a 65 63 74 20 74 68 65 0a  ject object the.
2e50: 09 09 09 20 20 20 20 20 20 23 20 63 68 61 6e 67  ...      # chang
2e60: 65 73 65 74 20 62 65 6c 6f 6e 67 73 20 74 6f 2e  eset belongs to.
2e70: 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79  .    variable my
2e80: 74 79 70 65 20 20 20 20 20 20 7b 7d 20 3b 20 23  type      {} ; #
2e90: 20 72 65 76 20 6f 72 20 73 79 6d 2c 20 77 68 65   rev or sym, whe
2ea0: 72 65 20 74 68 65 20 63 73 65 74 20 6f 72 69 67  re the cset orig
2eb0: 69 6e 61 74 65 64 0a 09 09 09 20 20 20 20 20 20  inated....      
2ec0: 23 20 66 72 6f 6d 2e 0a 20 20 20 20 76 61 72 69  # from..    vari
2ed0: 61 62 6c 65 20 6d 79 73 72 63 69 64 20 20 20 20  able mysrcid    
2ee0: 20 7b 7d 20 3b 20 23 20 49 64 20 6f 66 20 74 68   {} ; # Id of th
2ef0: 65 20 6d 65 74 61 64 61 74 61 20 6f 72 20 73 79  e metadata or sy
2f00: 6d 62 6f 6c 20 74 68 65 20 63 73 65 74 0a 09 09  mbol the cset...
2f10: 09 20 20 20 20 20 20 23 20 69 73 20 62 61 73 65  .      # is base
2f20: 64 20 6f 6e 2e 0a 20 20 20 20 76 61 72 69 61 62  d on..    variab
2f30: 6c 65 20 6d 79 72 65 76 69 73 69 6f 6e 73 20 7b  le myrevisions {
2f40: 7d 20 3b 20 23 20 4c 69 73 74 20 6f 66 20 74 68  } ; # List of th
2f50: 65 20 66 69 6c 65 20 6c 65 76 65 6c 20 72 65 76  e file level rev
2f60: 69 73 69 6f 6e 73 20 69 6e 0a 09 09 09 20 20 20  isions in....   
2f70: 20 20 20 23 20 74 68 65 20 63 73 65 74 2e 0a 20     # the cset.. 
2f80: 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 70 72     variable mypr
2f90: 65 6d 61 70 20 20 20 20 7b 7d 20 3b 20 23 20 44  emap    {} ; # D
2fa0: 69 63 74 69 6f 6e 61 72 79 20 6d 61 70 70 69 6e  ictionary mappin
2fb0: 67 20 66 72 6f 6d 20 74 68 65 20 72 65 76 69 73  g from the revis
2fc0: 69 6f 6e 73 0a 09 09 09 20 20 20 20 20 20 23 20  ions....      # 
2fd0: 74 6f 20 74 68 65 69 72 20 70 72 65 64 65 63 65  to their predece
2fe0: 73 73 6f 72 73 2e 20 43 61 63 68 65 20 74 6f 20  ssors. Cache to 
2ff0: 61 76 6f 69 64 0a 09 09 09 20 20 20 20 20 20 23  avoid....      #
3000: 20 6c 6f 61 64 69 6e 67 20 74 68 69 73 20 66 72   loading this fr
3010: 6f 6d 20 74 68 65 20 73 74 61 74 65 20 6d 6f 72  om the state mor
3020: 65 20 74 68 61 6e 0a 09 09 09 20 20 20 20 20 20  e than....      
3030: 23 20 6f 6e 63 65 2e 0a 20 20 20 20 76 61 72 69  # once..    vari
3040: 61 62 6c 65 20 6d 79 6e 65 78 74 6d 61 70 20 20  able mynextmap  
3050: 20 7b 7d 20 3b 20 23 20 44 69 63 74 69 6f 6e 61   {} ; # Dictiona
3060: 72 79 20 6d 61 70 70 69 6e 67 20 66 72 6f 6d 20  ry mapping from 
3070: 74 68 65 20 72 65 76 69 73 69 6f 6e 73 0a 09 09  the revisions...
3080: 09 20 20 20 20 20 20 23 20 74 6f 20 74 68 65 69  .      # to thei
3090: 72 20 73 75 63 63 65 73 73 6f 72 73 2e 20 43 61  r successors. Ca
30a0: 63 68 65 20 74 6f 20 61 76 6f 69 64 0a 09 09 09  che to avoid....
30b0: 20 20 20 20 20 20 23 20 6c 6f 61 64 69 6e 67 20        # loading 
30c0: 74 68 69 73 20 66 72 6f 6d 20 74 68 65 20 73 74  this from the st
30d0: 61 74 65 20 6d 6f 72 65 20 74 68 61 6e 0a 09 09  ate more than...
30e0: 09 20 20 20 20 20 20 23 20 6f 6e 63 65 2e 0a 20  .      # once.. 
30f0: 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 70 6f     variable mypo
3100: 73 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 43  s       {} ; # C
3110: 6f 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e 20 6f  ommit position o
3120: 66 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2c  f the changeset,
3130: 20 69 66 0a 09 09 09 20 20 20 20 20 20 23 20 6b   if....      # k
3140: 6e 6f 77 6e 2e 0a 0a 20 20 20 20 23 20 23 20 23  nown...    # # #
3150: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
3160: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
3170: 23 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72 6e  ##.    ## Intern
3180: 61 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20 20  al methods..    
3190: 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 63  typevariable myc
31a0: 6f 75 6e 74 65 72 20 20 20 20 20 20 20 20 30 20  ounter        0 
31b0: 3b 20 23 20 49 64 20 63 6f 75 6e 74 65 72 20 66  ; # Id counter f
31c0: 6f 72 20 63 73 65 74 73 2e 20 4c 61 73 74 20 69  or csets. Last i
31d0: 64 20 75 73 65 64 2e 0a 20 20 20 20 74 79 70 65  d used..    type
31e0: 76 61 72 69 61 62 6c 65 20 6d 79 63 73 74 79 70  variable mycstyp
31f0: 65 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23 20  e -array {} ; # 
3200: 4d 61 70 20 63 73 74 79 70 65 73 20 74 6f 20 70  Map cstypes to p
3210: 65 72 73 69 73 74 65 6e 74 20 69 64 73 2e 0a 0a  ersistent ids...
3220: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 67      typemethod g
3230: 65 74 63 73 74 79 70 65 73 20 7b 7d 20 7b 0a 09  etcstypes {} {..
3240: 66 6f 72 65 61 63 68 20 7b 74 69 64 20 6e 61 6d  foreach {tid nam
3250: 65 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a  e} [state run {.
3260: 09 20 20 20 20 53 45 4c 45 43 54 20 74 69 64 2c  .    SELECT tid,
3270: 20 6e 61 6d 65 20 46 52 4f 4d 20 63 73 74 79 70   name FROM cstyp
3280: 65 3b 0a 09 7d 5d 20 7b 20 73 65 74 20 6d 79 63  e;..}] { set myc
3290: 73 74 79 70 65 28 24 6e 61 6d 65 29 20 24 74 69  stype($name) $ti
32a0: 64 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  d }..return.    
32b0: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
32c0: 64 20 6c 6f 61 64 63 6f 75 6e 74 65 72 20 7b 7d  d loadcounter {}
32d0: 20 7b 0a 09 23 20 49 6e 69 74 69 61 6c 69 7a 65   {..# Initialize
32e0: 20 74 68 65 20 63 6f 75 6e 74 65 72 20 66 72 6f   the counter fro
32f0: 6d 20 74 68 65 20 73 74 61 74 65 0a 09 73 65 74  m the state..set
3300: 20 6d 79 63 6f 75 6e 74 65 72 20 5b 73 74 61 74   mycounter [stat
3310: 65 20 6f 6e 65 20 7b 20 53 45 4c 45 43 54 20 4d  e one { SELECT M
3320: 41 58 28 63 69 64 29 20 46 52 4f 4d 20 63 68 61  AX(cid) FROM cha
3330: 6e 67 65 73 65 74 20 7d 5d 0a 09 72 65 74 75 72  ngeset }]..retur
3340: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70  n.    }..    typ
3350: 65 6d 65 74 68 6f 64 20 6e 75 6d 20 7b 7d 20 7b  emethod num {} {
3360: 20 72 65 74 75 72 6e 20 24 6d 79 63 6f 75 6e 74   return $mycount
3370: 65 72 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50  er }..    proc P
3380: 75 6c 6c 49 6e 74 65 72 6e 61 6c 53 75 63 63 65  ullInternalSucce
3390: 73 73 6f 72 52 65 76 69 73 69 6f 6e 73 20 7b 64  ssorRevisions {d
33a0: 76 20 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09  v revisions} {..
33b0: 75 70 76 61 72 20 31 20 24 64 76 20 64 65 70 65  upvar 1 $dv depe
33c0: 6e 64 65 6e 63 69 65 73 0a 09 73 65 74 20 74 68  ndencies..set th
33d0: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65  eset ('[join $re
33e0: 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29  visions {','}]')
33f0: 0a 0a 09 23 20 53 65 65 20 50 75 6c 6c 53 75 63  ...# See PullSuc
3400: 63 65 73 73 6f 72 52 65 76 69 73 69 6f 6e 73 20  cessorRevisions 
3410: 62 65 6c 6f 77 20 66 6f 72 20 74 68 65 20 6d 61  below for the ma
3420: 69 6e 20 65 78 70 6c 61 6e 61 74 69 6f 6e 20 6f  in explanation o
3430: 66 0a 09 23 20 74 68 65 20 76 61 72 69 6f 75 73  f..# the various
3440: 20 63 61 73 65 73 2e 20 54 68 69 73 20 70 69 65   cases. This pie
3450: 63 65 20 69 73 20 73 70 65 63 69 61 6c 20 69 6e  ce is special in
3460: 20 74 68 61 74 20 69 74 0a 09 23 20 72 65 73 74   that it..# rest
3470: 72 69 63 74 73 20 74 68 65 20 73 75 63 63 65 73  ricts the succes
3480: 73 6f 72 73 20 77 65 20 6c 6f 6f 6b 20 66 6f 72  sors we look for
3490: 20 74 6f 20 74 68 65 20 73 61 6d 65 20 73 65 74   to the same set
34a0: 20 6f 66 0a 09 23 20 72 65 76 69 73 69 6f 6e 73   of..# revisions
34b0: 20 77 65 20 73 74 61 72 74 20 66 72 6f 6d 2e 20   we start from. 
34c0: 53 65 6e 73 69 62 6c 65 20 61 73 20 77 65 20 61  Sensible as we a
34d0: 72 65 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72 0a 09  re looking for..
34e0: 23 20 63 68 61 6e 67 65 73 65 74 20 69 6e 74 65  # changeset inte
34f0: 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65  rnal dependencie
3500: 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20 64  s....array set d
3510: 65 70 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68 20  ep {}...foreach 
3520: 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61  {rid child} [sta
3530: 74 65 20 72 75 6e 20 22 0a 20 20 20 2d 2d 20 28  te run ".   -- (
3540: 31 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c 64  1) Primary child
3550: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72  ..    SELECT R.r
3560: 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20 20  id, R.child..   
3570: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e   FROM   revision
3580: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 52   R..    WHERE  R
3590: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65  .rid   IN $these
35a0: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63  t     -- Restric
35b0: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f  t to revisions o
35c0: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20  f interest..    
35d0: 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49  AND    R.child I
35e0: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d  S NOT NULL    --
35f0: 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 69   Has primary chi
3600: 6c 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52  ld..    AND    R
3610: 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73 65  .child IN $these
3620: 74 20 20 20 20 20 2d 2d 20 57 68 69 63 68 20 69  t     -- Which i
3630: 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72 65  s also of intere
3640: 73 74 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20  st.    UNION.   
3650: 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61 72   -- (2) Secondar
3660: 79 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c 64  y (branch) child
3670: 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54 20  ren..    SELECT 
3680: 52 2e 72 69 64 2c 20 42 2e 62 72 69 64 0a 09 20  R.rid, B.brid.. 
3690: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69     FROM   revisi
36a0: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 62 72  on R, revisionbr
36b0: 61 6e 63 68 63 68 69 6c 64 72 65 6e 20 42 0a 09  anchchildren B..
36c0: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64      WHERE  R.rid
36d0: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20     IN $theset   
36e0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
36f0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
3700: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
3710: 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64     R.rid = B.rid
3720: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c            -- Sel
3730: 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62 72  ect subset of br
3740: 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 09 20  anch children.. 
3750: 20 20 20 41 4e 44 20 20 20 20 42 2e 62 72 69 64     AND    B.brid
3760: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
3770: 20 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c 73   -- Which is als
3780: 6f 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20  o of interest.  
3790: 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28    UNION.    -- (
37a0: 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75 6e  4) Child of trun
37b0: 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f 72  k root successor
37c0: 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e   of last NTDB on
37d0: 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c   trunk...    SEL
37e0: 45 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63 68  ECT R.rid, RA.ch
37f0: 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 72 65  ild..    FROM re
3800: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69  vision R, revisi
3810: 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 45 52 45  on RA..    WHERE
3820: 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65   R.rid   IN $the
3830: 73 65 74 20 20 20 20 20 20 2d 2d 20 52 65 73 74  set      -- Rest
3840: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e  rict to revision
3850: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20  s of interest.. 
3860: 20 20 20 41 4e 44 20 20 20 52 2e 69 73 64 65 66     AND   R.isdef
3870: 61 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20  ault            
3880: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
3890: 4e 54 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20  NTDB..    AND   
38a0: 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54  R.dbchild IS NOT
38b0: 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c   NULL   -- and l
38c0: 61 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69  ast NTDB belongi
38d0: 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20  ng to trunk..   
38e0: 20 41 4e 44 20 20 20 52 41 2e 72 69 64 20 3d 20   AND   RA.rid = 
38f0: 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d  R.dbchild      -
3900: 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f  - Go directly to
3910: 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20   trunk root..   
3920: 20 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64 20   AND   RA.child 
3930: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d  IS NOT NULL    -
3940: 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68  - Has primary ch
3950: 69 6c 64 2e 0a 20 20 20 20 20 20 20 20 20 20 20  ild..           
3960: 20 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64 20   AND   RA.child 
3970: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d  IN $theset     -
3980: 2d 20 57 68 69 63 68 20 69 73 20 61 6c 73 6f 20  - Which is also 
3990: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 22 5d 20  of interest.."] 
39a0: 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73 69 64 65  {..    # Conside
39b0: 72 20 6d 6f 76 69 6e 67 20 74 68 69 73 20 74 6f  r moving this to
39c0: 20 74 68 65 20 69 6e 74 65 67 72 69 74 79 20 6d   the integrity m
39d0: 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69 6e 74 65  odule...    inte
39e0: 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 24 72  grity assert {$r
39f0: 69 64 20 21 3d 20 24 63 68 69 6c 64 7d 20 7b 52  id != $child} {R
3a00: 65 76 69 73 69 6f 6e 20 24 72 69 64 20 64 65 70  evision $rid dep
3a10: 65 6e 64 73 20 6f 6e 20 69 74 73 65 6c 66 2e 7d  ends on itself.}
3a20: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65  ..    lappend de
3a30: 70 65 6e 64 65 6e 63 69 65 73 28 24 72 69 64 29  pendencies($rid)
3a40: 20 24 63 68 69 6c 64 0a 09 20 20 20 20 73 65 74   $child..    set
3a50: 20 64 65 70 28 24 72 69 64 2c 24 63 68 69 6c 64   dep($rid,$child
3a60: 29 20 2e 0a 09 7d 0a 0a 09 23 20 54 68 65 20 73  ) ...}...# The s
3a70: 71 6c 20 73 74 61 74 65 6d 65 6e 74 73 20 61 62  ql statements ab
3a80: 6f 76 65 20 6c 6f 6f 6b 73 20 6f 6e 6c 79 20 66  ove looks only f
3a90: 6f 72 20 64 69 72 65 63 74 20 64 65 70 65 6e 64  or direct depend
3aa0: 65 6e 63 69 65 73 0a 09 23 20 62 65 74 77 65 65  encies..# betwee
3ab0: 6e 20 72 65 76 69 73 69 6f 6e 20 69 6e 20 74 68  n revision in th
3ac0: 65 20 63 68 61 6e 67 65 73 65 74 2e 20 48 6f 77  e changeset. How
3ad0: 65 76 65 72 20 64 75 65 20 74 6f 20 74 68 65 0a  ever due to the.
3ae0: 09 23 20 76 61 67 61 72 69 65 73 20 6f 66 20 6d  .# vagaries of m
3af0: 65 74 61 20 64 61 74 61 20 69 74 20 69 73 20 70  eta data it is p
3b00: 6f 73 73 69 62 6c 65 20 66 6f 72 20 74 77 6f 20  ossible for two 
3b10: 72 65 76 69 73 69 6f 6e 73 20 6f 66 0a 09 23 20  revisions of..# 
3b20: 74 68 65 20 73 61 6d 65 20 66 69 6c 65 20 74 6f  the same file to
3b30: 20 65 6e 64 20 75 70 20 69 6e 20 74 68 65 20 73   end up in the s
3b40: 61 6d 65 20 63 68 61 6e 67 65 73 65 74 2c 20 77  ame changeset, w
3b50: 69 74 68 6f 75 74 20 61 0a 09 23 20 64 69 72 65  ithout a..# dire
3b60: 63 74 20 64 65 70 65 6e 64 65 6e 63 79 20 62 65  ct dependency be
3b70: 74 77 65 65 6e 20 74 68 65 6d 2e 20 48 6f 77 65  tween them. Howe
3b80: 76 65 72 20 77 65 20 6b 6e 6f 77 20 74 68 61 74  ver we know that
3b90: 20 74 68 65 72 65 0a 09 23 20 68 61 73 20 74 6f   there..# has to
3ba0: 20 62 65 20 61 20 61 6e 20 69 6e 64 69 72 65 63   be a an indirec
3bb0: 74 20 64 65 70 65 6e 64 65 6e 63 79 2c 20 62 65  t dependency, be
3bc0: 20 69 74 20 74 68 72 6f 75 67 68 20 70 72 69 6d   it through prim
3bd0: 61 72 79 0a 09 23 20 63 68 69 6c 64 72 65 6e 2c  ary..# children,
3be0: 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e   branch children
3bf0: 2c 20 6f 72 20 61 20 63 6f 6d 62 69 6e 61 74 69  , or a combinati
3c00: 6f 6e 20 74 68 65 72 65 6f 66 2e 0a 0a 09 23 20  on thereof....# 
3c10: 57 65 20 6e 6f 77 20 66 69 6c 6c 20 69 6e 20 74  We now fill in t
3c20: 68 65 73 65 20 70 73 65 75 64 6f 2d 64 65 70 65  hese pseudo-depe
3c30: 6e 64 65 6e 63 69 65 73 2c 20 69 66 20 6e 6f 20  ndencies, if no 
3c40: 73 75 63 68 0a 09 23 20 64 65 70 65 6e 64 65 6e  such..# dependen
3c50: 63 79 20 65 78 69 73 74 73 20 61 6c 72 65 61 64  cy exists alread
3c60: 79 2e 20 54 68 65 20 64 69 72 65 63 74 69 6f 6e  y. The direction
3c70: 20 6f 66 20 74 68 65 20 64 65 70 65 6e 64 65 6e   of the dependen
3c80: 63 79 0a 09 23 20 69 73 20 61 63 74 75 61 6c 6c  cy..# is actuall
3c90: 79 20 69 72 72 65 6c 65 76 61 6e 74 20 66 6f 72  y irrelevant for
3ca0: 20 74 68 69 73 2e 0a 0a 09 23 20 4e 4f 54 45 3a   this....# NOTE:
3cb0: 20 54 68 69 73 20 69 73 20 64 69 66 66 65 72 65   This is differe
3cc0: 6e 74 20 66 72 6f 6d 20 63 76 73 32 73 76 6e 2e  nt from cvs2svn.
3cd0: 20 4f 75 72 20 73 70 69 72 69 74 75 61 6c 20 61   Our spiritual a
3ce0: 6e 63 65 73 74 6f 72 0a 09 23 20 64 6f 65 73 20  ncestor..# does 
3cf0: 6e 6f 74 20 75 73 65 20 73 75 63 68 20 70 73 65  not use such pse
3d00: 75 64 6f 2d 64 65 70 65 6e 64 65 6e 63 69 65 73  udo-dependencies
3d10: 2c 20 68 6f 77 65 76 65 72 20 69 74 20 75 73 65  , however it use
3d20: 73 20 61 0a 09 23 20 43 4f 4d 4d 49 54 5f 54 48  s a..# COMMIT_TH
3d30: 52 45 53 48 4f 4c 44 2c 20 61 20 74 69 6d 65 20  RESHOLD, a time 
3d40: 69 6e 74 65 72 76 61 6c 20 63 6f 6d 6d 69 74 73  interval commits
3d50: 20 73 68 6f 75 6c 64 20 66 61 6c 6c 2e 20 54 68   should fall. Th
3d60: 69 73 0a 09 23 20 77 69 6c 6c 20 67 72 65 61 74  is..# will great
3d70: 6c 79 20 72 65 64 75 63 65 73 20 74 68 65 20 72  ly reduces the r
3d80: 69 73 6b 20 6f 66 20 67 65 74 74 69 6e 67 20 66  isk of getting f
3d90: 61 72 20 73 65 70 61 72 61 74 65 64 0a 09 23 20  ar separated..# 
3da0: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 74 68 65  revisions of the
3db0: 20 73 61 6d 65 20 66 69 6c 65 20 69 6e 74 6f 20   same file into 
3dc0: 6f 6e 65 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a  one changeset...
3dd0: 09 23 20 57 65 20 61 6c 6c 6f 77 20 72 65 76 69  .# We allow revi
3de0: 73 69 6f 6e 73 20 74 6f 20 62 65 20 66 61 72 20  sions to be far 
3df0: 61 70 61 72 74 20 69 6e 20 74 69 6d 65 20 69 6e  apart in time in
3e00: 20 74 68 65 20 73 61 6d 65 0a 09 23 20 63 68 61   the same..# cha
3e10: 6e 67 65 73 65 74 2c 20 62 75 74 20 6e 65 65 64  ngeset, but need
3e20: 20 74 68 65 20 70 73 65 75 64 6f 2d 64 65 70 65   the pseudo-depe
3e30: 6e 64 65 6e 63 69 65 73 20 66 6f 72 20 74 68 69  ndencies for thi
3e40: 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20 66  s....array set f
3e50: 69 64 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20  ids {}..foreach 
3e60: 7b 72 69 64 20 66 69 64 7d 20 5b 73 74 61 74 65  {rid fid} [state
3e70: 20 72 75 6e 20 22 0a 09 20 20 20 20 53 45 4c 45   run "..    SELE
3e80: 43 54 20 52 2e 72 69 64 2c 20 52 2e 66 69 64 20  CT R.rid, R.fid 
3e90: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 20  FROM revision R 
3ea0: 57 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20 24  WHERE R.rid IN $
3eb0: 74 68 65 73 65 74 0a 09 22 5d 20 7b 20 6c 61 70  theset.."] { lap
3ec0: 70 65 6e 64 20 66 69 64 73 28 24 66 69 64 29 20  pend fids($fid) 
3ed0: 24 72 69 64 20 7d 0a 0a 09 66 6f 72 65 61 63 68  $rid }...foreach
3ee0: 20 7b 66 69 64 20 72 69 64 73 7d 20 5b 61 72 72   {fid rids} [arr
3ef0: 61 79 20 67 65 74 20 66 69 64 73 5d 20 7b 0a 09  ay get fids] {..
3f00: 20 20 20 20 69 66 20 7b 5b 6c 6c 65 6e 67 74 68      if {[llength
3f10: 20 24 72 69 64 73 5d 20 3c 20 32 7d 20 63 6f 6e   $rids] < 2} con
3f20: 74 69 6e 75 65 0a 09 20 20 20 20 66 6f 72 65 61  tinue..    forea
3f30: 63 68 20 61 20 24 72 69 64 73 20 7b 0a 09 09 66  ch a $rids {...f
3f40: 6f 72 65 61 63 68 20 62 20 24 72 69 64 73 20 7b  oreach b $rids {
3f50: 0a 09 09 20 20 20 20 69 66 20 7b 24 61 20 3d 3d  ...    if {$a ==
3f60: 20 24 62 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09   $b} continue...
3f70: 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78      if {[info ex
3f80: 69 73 74 73 20 64 65 70 28 24 61 2c 24 62 29 5d  ists dep($a,$b)]
3f90: 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20  } continue...   
3fa0: 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74   if {[info exist
3fb0: 73 20 64 65 70 28 24 62 2c 24 61 29 5d 7d 20 63  s dep($b,$a)]} c
3fc0: 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20 20 6c 61  ontinue...    la
3fd0: 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69  ppend dependenci
3fe0: 65 73 28 24 61 29 20 24 62 0a 09 09 20 20 20 20  es($a) $b...    
3ff0: 73 65 74 20 64 65 70 28 24 61 2c 24 62 29 20 2e  set dep($a,$b) .
4000: 0a 09 09 20 20 20 20 73 65 74 20 64 65 70 28 24  ...    set dep($
4010: 62 2c 24 61 29 20 2e 0a 09 09 7d 0a 09 20 20 20  b,$a) ....}..   
4020: 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20   }..}..return.  
4030: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 75    }..    proc Pu
4040: 6c 6c 53 75 63 63 65 73 73 6f 72 52 65 76 69 73  llSuccessorRevis
4050: 69 6f 6e 73 20 7b 64 76 20 72 65 76 69 73 69 6f  ions {dv revisio
4060: 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24  ns} {..upvar 1 $
4070: 64 76 20 64 65 70 65 6e 64 65 6e 63 69 65 73 0a  dv dependencies.
4080: 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a  .set theset ('[j
4090: 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b  oin $revisions {
40a0: 27 2c 27 7d 5d 27 29 0a 0a 09 23 20 54 68 65 20  ','}]')...# The 
40b0: 66 6f 6c 6c 6f 77 69 6e 67 20 63 61 73 65 73 20  following cases 
40c0: 73 70 65 63 69 66 79 20 77 68 65 6e 20 61 20 72  specify when a r
40d0: 65 76 69 73 69 6f 6e 20 53 20 69 73 20 61 20 73  evision S is a s
40e0: 75 63 63 65 73 73 6f 72 0a 09 23 20 6f 66 20 61  uccessor..# of a
40f0: 20 72 65 76 69 73 69 6f 6e 20 52 2e 20 45 61 63   revision R. Eac
4100: 68 20 6f 66 20 74 68 65 20 63 61 73 65 73 20 74  h of the cases t
4110: 72 61 6e 73 6c 61 74 65 73 20 69 6e 74 6f 20 6f  ranslates into o
4120: 6e 65 20 6f 66 0a 09 23 20 74 68 65 20 62 72 61  ne of..# the bra
4130: 6e 63 68 65 73 20 6f 66 20 74 68 65 20 53 51 4c  nches of the SQL
4140: 20 55 4e 49 4f 4e 20 63 6f 6d 69 6e 67 20 62 65   UNION coming be
4150: 6c 6f 77 2e 0a 09 23 0a 09 23 20 28 31 29 20 53  low...#..# (1) S
4160: 20 63 61 6e 20 62 65 20 61 20 70 72 69 6d 61 72   can be a primar
4170: 79 20 63 68 69 6c 64 20 6f 66 20 52 2c 20 69 2e  y child of R, i.
4180: 65 2e 20 69 6e 20 74 68 65 20 73 61 6d 65 20 4c  e. in the same L
4190: 4f 44 2e 20 52 0a 09 23 20 20 20 20 20 72 65 66  OD. R..#     ref
41a0: 65 72 65 6e 63 65 73 20 53 20 64 69 72 65 63 74  erences S direct
41b0: 6c 79 2e 20 52 2e 63 68 69 6c 64 20 3d 20 53 28  ly. R.child = S(
41c0: 2e 72 69 64 29 2c 20 69 66 20 69 74 20 65 78 69  .rid), if it exi
41d0: 73 74 73 2e 0a 09 23 0a 09 23 20 28 32 29 20 53  sts...#..# (2) S
41e0: 20 63 61 6e 20 62 65 20 61 20 73 65 63 6f 6e 64   can be a second
41f0: 61 72 79 2c 20 69 2e 65 2e 20 62 72 61 6e 63 68  ary, i.e. branch
4200: 2c 20 63 68 69 6c 64 20 6f 66 20 52 2e 20 48 65  , child of R. He
4210: 72 65 20 74 68 65 0a 09 23 20 20 20 20 20 6c 69  re the..#     li
4220: 6e 6b 20 69 73 20 6d 61 64 65 20 74 68 72 6f 75  nk is made throu
4230: 67 68 20 74 68 65 20 68 65 6c 70 65 72 20 74 61  gh the helper ta
4240: 62 6c 65 0a 09 23 20 20 20 20 20 52 45 56 49 53  ble..#     REVIS
4250: 49 4f 4e 42 52 41 4e 43 48 43 48 49 4c 44 52 45  IONBRANCHCHILDRE
4260: 4e 2e 20 52 2e 72 69 64 20 2d 3e 20 52 42 43 2e  N. R.rid -> RBC.
4270: 72 69 64 2c 20 52 42 43 2e 62 72 69 64 20 3d 0a  rid, RBC.brid =.
4280: 09 23 20 20 20 20 20 53 28 2e 72 69 64 29 0a 09  .#     S(.rid)..
4290: 23 0a 09 23 20 28 33 29 20 4f 72 69 67 69 6e 61  #..# (3) Origina
42a0: 6c 6c 79 20 74 68 69 73 20 75 73 65 20 63 61 73  lly this use cas
42b0: 65 20 64 65 66 69 6e 65 64 20 74 68 65 20 72 6f  e defined the ro
42c0: 6f 74 20 6f 66 20 61 20 64 65 74 61 63 68 65 64  ot of a detached
42d0: 0a 09 23 20 20 20 20 20 4e 54 44 42 20 61 73 20  ..#     NTDB as 
42e0: 74 68 65 20 73 75 63 63 65 73 73 6f 72 20 6f 66  the successor of
42f0: 20 74 68 65 20 74 72 75 6e 6b 20 72 6f 6f 74 2e   the trunk root.
4300: 20 54 68 69 73 20 6c 65 61 64 73 20 74 6f 20 61   This leads to a
4310: 0a 09 23 20 20 20 20 20 62 61 64 20 74 61 6e 67  ..#     bad tang
4320: 6c 65 20 6c 61 74 65 72 20 6f 6e 2e 20 57 69 74  le later on. Wit
4330: 68 20 61 20 64 65 74 61 63 68 65 64 20 4e 54 44  h a detached NTD
4340: 42 20 74 68 65 20 6f 72 69 67 69 6e 61 6c 0a 09  B the original..
4350: 23 20 20 20 20 20 74 72 75 6e 6b 20 72 6f 6f 74  #     trunk root
4360: 20 72 65 76 69 73 69 6f 6e 20 77 61 73 20 72 65   revision was re
4370: 6d 6f 76 65 64 20 61 73 20 69 72 72 65 6c 65 76  moved as irrelev
4380: 61 6e 74 2c 20 61 6c 6c 6f 77 69 6e 67 0a 09 23  ant, allowing..#
4390: 20 20 20 20 20 74 68 65 20 6e 6f 6d 69 6e 61 6c       the nominal
43a0: 20 72 6f 6f 74 20 74 6f 20 62 65 20 6c 61 74 65   root to be late
43b0: 72 20 69 6e 20 74 69 6d 65 20 74 68 61 6e 20 74  r in time than t
43c0: 68 65 20 4e 54 44 42 0a 09 23 20 20 20 20 20 72  he NTDB..#     r
43d0: 6f 6f 74 2e 20 4e 6f 77 20 73 65 74 74 69 6e 67  oot. Now setting
43e0: 20 74 68 69 73 20 64 65 70 65 6e 64 65 6e 63 79   this dependency
43f0: 20 77 69 6c 6c 20 62 65 20 62 61 63 6b 77 61 72   will be backwar
4400: 64 20 69 6e 0a 09 23 20 20 20 20 20 74 69 6d 65  d in..#     time
4410: 2e 20 52 45 4d 4f 56 45 44 2e 0a 09 23 0a 09 23  . REMOVED...#..#
4420: 20 28 34 29 20 49 66 20 52 20 69 73 20 74 68 65   (4) If R is the
4430: 20 6c 61 73 74 20 6f 66 20 74 68 65 20 4e 54 44   last of the NTD
4440: 42 20 72 65 76 69 73 69 6f 6e 73 20 77 68 69 63  B revisions whic
4450: 68 20 62 65 6c 6f 6e 67 20 74 6f 0a 09 23 20 20  h belong to..#  
4460: 20 20 20 74 68 65 20 74 72 75 6e 6b 2c 20 74 68     the trunk, th
4470: 65 6e 20 74 68 65 20 70 72 69 6d 61 72 79 20 63  en the primary c
4480: 68 69 6c 64 20 6f 66 20 74 68 65 20 74 72 75 6e  hild of the trun
4490: 6b 20 72 6f 6f 74 20 28 74 68 65 0a 09 23 20 20  k root (the..#  
44a0: 20 20 20 27 31 2e 32 27 20 72 65 76 69 73 69 6f     '1.2' revisio
44b0: 6e 29 20 69 73 20 61 20 73 75 63 63 65 73 73 6f  n) is a successo
44c0: 72 2c 20 69 66 20 69 74 20 65 78 69 73 74 73 2e  r, if it exists.
44d0: 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20  ...foreach {rid 
44e0: 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75  child} [state ru
44f0: 6e 20 22 0a 20 20 20 2d 2d 20 28 31 29 20 50 72  n ".   -- (1) Pr
4500: 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20  imary child..   
4510: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52   SELECT R.rid, R
4520: 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d  .child..    FROM
4530: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20     revision R.. 
4540: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20     WHERE  R.rid 
4550: 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20    IN $theset    
4560: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20   -- Restrict to 
4570: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74  revisions of int
4580: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20  erest..    AND  
4590: 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54    R.child IS NOT
45a0: 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20   NULL    -- Has 
45b0: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 20 20  primary child.  
45c0: 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28    UNION.    -- (
45d0: 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72  2) Secondary (br
45e0: 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09  anch) children..
45f0: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64      SELECT R.rid
4600: 2c 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46 52  , B.brid..    FR
4610: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c  OM   revision R,
4620: 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63   revisionbranchc
4630: 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 57  hildren B..    W
4640: 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e  HERE  R.rid   IN
4650: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20   $theset     -- 
4660: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69  Restrict to revi
4670: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73  sions of interes
4680: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e  t..    AND    R.
4690: 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20  rid = B.rid     
46a0: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73       -- Select s
46b0: 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20  ubset of branch 
46c0: 63 68 69 6c 64 72 65 6e 0a 20 20 20 20 55 4e 49  children.    UNI
46d0: 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20 43 68  ON.    -- (4) Ch
46e0: 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f  ild of trunk roo
46f0: 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 6c  t successor of l
4700: 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e  ast NTDB on trun
4710: 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52  k...    SELECT R
4720: 2e 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09  .rid, RA.child..
4730: 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f      FROM revisio
4740: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41  n R, revision RA
4750: 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69  ..    WHERE R.ri
4760: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20  d   IN $theset  
4770: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20      -- Restrict 
4780: 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20  to revisions of 
4790: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e  interest..    AN
47a0: 44 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74 20  D   R.isdefault 
47b0: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 52              -- R
47c0: 65 73 74 72 69 63 74 20 74 6f 20 4e 54 44 42 0a  estrict to NTDB.
47d0: 09 20 20 20 20 41 4e 44 20 20 20 52 2e 64 62 63  .    AND   R.dbc
47e0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c  hild IS NOT NULL
47f0: 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74 20 4e     -- and last N
4800: 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f  TDB belonging to
4810: 20 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e 44 20   trunk..    AND 
4820: 20 20 52 41 2e 72 69 64 20 3d 20 52 2e 64 62 63    RA.rid = R.dbc
4830: 68 69 6c 64 20 20 20 20 20 20 2d 2d 20 47 6f 20  hild      -- Go 
4840: 64 69 72 65 63 74 6c 79 20 74 6f 20 74 72 75 6e  directly to trun
4850: 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e 44 20  k root..    AND 
4860: 20 20 52 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f    RA.child IS NO
4870: 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73  T NULL    -- Has
4880: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a   primary child..
4890: 09 22 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e  ."] {..    # Con
48a0: 73 69 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69  sider moving thi
48b0: 73 20 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69  s to the integri
48c0: 74 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20  ty module...    
48d0: 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74  integrity assert
48e0: 20 7b 24 72 69 64 20 21 3d 20 24 63 68 69 6c 64   {$rid != $child
48f0: 7d 20 7b 52 65 76 69 73 69 6f 6e 20 24 72 69 64  } {Revision $rid
4900: 20 64 65 70 65 6e 64 73 20 6f 6e 20 69 74 73 65   depends on itse
4910: 6c 66 2e 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e  lf.}..    lappen
4920: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 24  d dependencies($
4930: 72 69 64 29 20 24 63 68 69 6c 64 0a 09 7d 0a 09  rid) $child..}..
4940: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
4950: 20 20 70 72 6f 63 20 50 75 6c 6c 50 72 65 64 65    proc PullPrede
4960: 63 65 73 73 6f 72 52 65 76 69 73 69 6f 6e 73 20  cessorRevisions 
4970: 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 7d 20 7b  {dv revisions} {
4980: 0a 09 75 70 76 61 72 20 31 20 24 64 76 20 64 65  ..upvar 1 $dv de
4990: 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 65 74 20  pendencies..set 
49a0: 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24  theset ('[join $
49b0: 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d  revisions {','}]
49c0: 27 29 0a 0a 09 23 20 54 68 65 20 66 6f 6c 6c 6f  ')...# The follo
49d0: 77 69 6e 67 20 63 61 73 65 73 20 73 70 65 63 69  wing cases speci
49e0: 66 79 20 77 68 65 6e 20 61 20 72 65 76 69 73 69  fy when a revisi
49f0: 6f 6e 20 50 20 69 73 20 61 0a 09 23 20 70 72 65  on P is a..# pre
4a00: 64 65 63 65 73 73 6f 72 20 6f 66 20 61 20 72 65  decessor of a re
4a10: 76 69 73 69 6f 6e 20 52 2e 20 45 61 63 68 20 6f  vision R. Each o
4a20: 66 20 74 68 65 20 63 61 73 65 73 20 74 72 61 6e  f the cases tran
4a30: 73 6c 61 74 65 73 0a 09 23 20 69 6e 74 6f 20 6f  slates..# into o
4a40: 6e 65 20 6f 66 20 74 68 65 20 62 72 61 6e 63 68  ne of the branch
4a50: 65 73 20 6f 66 20 74 68 65 20 53 51 4c 20 55 4e  es of the SQL UN
4a60: 49 4f 4e 20 63 6f 6d 69 6e 67 20 62 65 6c 6f 77  ION coming below
4a70: 2e 0a 09 23 0a 09 23 20 28 31 29 20 54 68 65 20  ...#..# (1) The 
4a80: 69 6d 6d 65 64 69 61 74 65 20 70 61 72 65 6e 74  immediate parent
4a90: 20 52 2e 70 61 72 65 6e 74 20 6f 66 20 52 20 69   R.parent of R i
4aa0: 73 20 61 20 70 72 65 64 65 63 65 73 73 6f 72 20  s a predecessor 
4ab0: 6f 66 0a 09 23 20 20 20 20 20 52 2e 20 4e 4f 54  of..#     R. NOT
4ac0: 45 3a 20 54 68 69 73 20 69 73 20 74 72 75 65 20  E: This is true 
4ad0: 66 6f 72 20 52 20 65 69 74 68 65 72 20 70 72 69  for R either pri
4ae0: 6d 61 72 79 20 6f 72 20 73 65 63 6f 6e 64 61 72  mary or secondar
4af0: 79 0a 09 23 20 20 20 20 20 63 68 69 6c 64 20 6f  y..#     child o
4b00: 66 20 50 2e 20 49 74 20 6e 6f 74 20 6e 65 63 65  f P. It not nece
4b10: 73 73 61 72 79 20 74 6f 20 64 69 73 74 69 6e 67  ssary to disting
4b20: 75 69 73 68 20 74 68 65 20 74 77 6f 0a 09 23 20  uish the two..# 
4b30: 20 20 20 20 63 61 73 65 73 2c 20 69 6e 20 63 6f      cases, in co
4b40: 6e 74 72 61 73 74 20 74 6f 20 74 68 65 20 63 6f  ntrast to the co
4b50: 64 65 20 72 65 74 72 69 65 76 69 6e 67 20 74 68  de retrieving th
4b60: 65 20 73 75 63 63 65 73 73 6f 72 0a 09 23 20 20  e successor..#  
4b70: 20 20 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2e 0a     information..
4b80: 09 23 0a 09 23 20 28 32 29 20 54 68 65 20 63 6f  .#..# (2) The co
4b90: 6d 70 6c 65 6d 65 6e 74 20 6f 66 20 73 75 63 63  mplement of succ
4ba0: 65 73 73 6f 72 20 63 61 73 65 20 28 33 29 2e 20  essor case (3). 
4bb0: 54 68 65 20 74 72 75 6e 6b 20 72 6f 6f 74 20 69  The trunk root i
4bc0: 73 0a 09 23 20 20 20 20 20 61 20 70 72 65 64 65  s..#     a prede
4bd0: 63 65 73 73 6f 72 20 6f 66 20 61 20 4e 54 44 42  cessor of a NTDB
4be0: 20 72 6f 6f 74 2e 20 52 45 4d 4f 56 45 44 2e 20   root. REMOVED. 
4bf0: 53 65 65 0a 09 23 20 20 20 20 20 50 75 6c 6c 53  See..#     PullS
4c00: 75 63 63 65 73 73 6f 72 52 65 76 69 73 69 6f 6e  uccessorRevision
4c10: 73 20 66 6f 72 20 74 68 65 20 65 78 70 6c 61 6e  s for the explan
4c20: 61 74 69 6f 6e 2e 0a 09 23 0a 09 23 20 28 33 29  ation...#..# (3)
4c30: 20 54 68 65 20 63 6f 6d 70 6c 65 6d 65 6e 74 20   The complement 
4c40: 6f 66 20 73 75 63 63 65 73 73 6f 72 20 63 61 73  of successor cas
4c50: 65 20 28 34 29 2e 20 54 68 65 20 6c 61 73 74 20  e (4). The last 
4c60: 4e 54 44 42 0a 09 23 20 20 20 20 20 72 65 76 69  NTDB..#     revi
4c70: 73 69 6f 6e 20 62 65 6c 6f 6e 67 69 6e 67 20 74  sion belonging t
4c80: 6f 20 74 68 65 20 74 72 75 6e 6b 20 69 73 20 61  o the trunk is a
4c90: 20 70 72 65 64 65 63 65 73 73 6f 72 20 6f 66 20   predecessor of 
4ca0: 74 68 65 0a 09 23 20 20 20 20 20 70 72 69 6d 61  the..#     prima
4cb0: 72 79 20 63 68 69 6c 64 20 6f 66 20 74 68 65 20  ry child of the 
4cc0: 74 72 75 6e 6b 20 72 6f 6f 74 20 28 54 68 65 20  trunk root (The 
4cd0: 27 31 2e 32 27 20 72 65 76 69 73 69 6f 6e 29 2e  '1.2' revision).
4ce0: 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20  ...foreach {rid 
4cf0: 70 61 72 65 6e 74 7d 20 5b 73 74 61 74 65 20 72  parent} [state r
4d00: 75 6e 20 22 0a 20 20 20 2d 2d 20 28 31 29 20 50  un ".   -- (1) P
4d10: 72 69 6d 61 72 79 20 70 61 72 65 6e 74 2c 20 63  rimary parent, c
4d20: 61 6e 20 62 65 20 69 6e 20 64 69 66 66 65 72 65  an be in differe
4d30: 6e 74 20 4c 4f 44 20 66 6f 72 20 66 69 72 73 74  nt LOD for first
4d40: 20 69 6e 20 61 20 62 72 61 6e 63 68 0a 09 20 20   in a branch..  
4d50: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20    SELECT R.rid, 
4d60: 52 2e 70 61 72 65 6e 74 0a 09 20 20 20 20 46 52  R.parent..    FR
4d70: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a  OM   revision R.
4d80: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69  .    WHERE  R.ri
4d90: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20  d   IN $theset  
4da0: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74     -- Restrict t
4db0: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69  o revisions of i
4dc0: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44  nterest..    AND
4dd0: 20 20 20 20 52 2e 70 61 72 65 6e 74 20 49 53 20      R.parent IS 
4de0: 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 48 61  NOT NULL   -- Ha
4df0: 73 20 70 72 69 6d 61 72 79 20 70 61 72 65 6e 74  s primary parent
4e00: 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d  .    UNION.    -
4e10: 2d 20 28 33 29 20 4c 61 73 74 20 4e 54 44 42 20  - (3) Last NTDB 
4e20: 6f 6e 20 74 72 75 6e 6b 20 69 73 20 70 72 65 64  on trunk is pred
4e30: 65 63 65 73 73 6f 72 20 6f 66 20 63 68 69 6c 64  ecessor of child
4e40: 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09   of trunk root..
4e50: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64      SELECT R.rid
4e60: 2c 20 52 41 2e 64 62 70 61 72 65 6e 74 0a 09 20  , RA.dbparent.. 
4e70: 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e     FROM revision
4e80: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 0a   R, revision RA.
4e90: 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64  .    WHERE R.rid
4ea0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20   IN $theset     
4eb0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f    -- Restrict to
4ec0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e   revisions of in
4ed0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20  terest..    AND 
4ee0: 4e 4f 54 20 52 2e 69 73 64 65 66 61 75 6c 74 20  NOT R.isdefault 
4ef0: 20 20 20 20 20 20 20 20 20 2d 2d 20 6e 6f 74 20           -- not 
4f00: 6f 6e 20 4e 54 44 42 0a 09 20 20 20 20 41 4e 44  on NTDB..    AND
4f10: 20 52 2e 70 61 72 65 6e 74 20 49 53 20 4e 4f 54   R.parent IS NOT
4f20: 20 4e 55 4c 4c 20 20 20 20 20 2d 2d 20 77 68 69   NULL     -- whi
4f30: 63 68 20 61 72 65 20 6e 6f 74 20 72 6f 6f 74 0a  ch are not root.
4f40: 09 20 20 20 20 41 4e 44 20 52 41 2e 72 69 64 20  .    AND RA.rid 
4f50: 3d 20 52 2e 70 61 72 65 6e 74 20 20 20 20 20 20  = R.parent      
4f60: 20 20 2d 2d 20 67 6f 20 74 6f 20 74 68 65 69 72    -- go to their
4f70: 20 70 61 72 65 6e 74 0a 09 20 20 20 20 41 4e 44   parent..    AND
4f80: 20 52 41 2e 64 62 70 61 72 65 6e 74 20 49 53 20   RA.dbparent IS 
4f90: 4e 4f 54 20 4e 55 4c 4c 20 20 2d 2d 20 77 68 69  NOT NULL  -- whi
4fa0: 63 68 20 68 61 73 20 74 6f 20 72 65 66 65 72 20  ch has to refer 
4fb0: 74 6f 20 4e 54 44 42 27 73 20 72 6f 6f 74 0a 09  to NTDB's root..
4fc0: 22 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73  "] {..    # Cons
4fd0: 69 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69 73  ider moving this
4fe0: 20 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69 74   to the integrit
4ff0: 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69  y module...    i
5000: 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20  ntegrity assert 
5010: 7b 24 72 69 64 20 21 3d 20 24 70 61 72 65 6e 74  {$rid != $parent
5020: 7d 20 7b 52 65 76 69 73 69 6f 6e 20 24 72 69 64  } {Revision $rid
5030: 20 64 65 70 65 6e 64 73 20 6f 6e 20 69 74 73 65   depends on itse
5040: 6c 66 2e 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e  lf.}..    lappen
5050: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 24  d dependencies($
5060: 72 69 64 29 20 24 70 61 72 65 6e 74 0a 09 7d 0a  rid) $parent..}.
5070: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
5080: 20 20 20 70 72 6f 63 20 49 6e 69 74 69 61 6c 69     proc Initiali
5090: 7a 65 42 72 65 61 6b 53 74 61 74 65 20 7b 72 65  zeBreakState {re
50a0: 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61  visions} {..upva
50b0: 72 20 31 20 70 6f 73 20 70 6f 73 20 63 72 6f 73  r 1 pos pos cros
50c0: 73 20 63 72 6f 73 73 20 72 61 6e 67 65 20 72 61  s cross range ra
50d0: 6e 67 65 20 64 65 70 63 20 64 65 70 63 20 64 65  nge depc depc de
50e0: 6c 74 61 20 64 65 6c 74 61 20 5c 0a 09 20 20 20  lta delta \..   
50f0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 64 65   dependencies de
5100: 70 65 6e 64 65 6e 63 69 65 73 0a 0a 09 23 20 46  pendencies...# F
5110: 69 72 73 74 20 77 65 20 63 72 65 61 74 65 20 61  irst we create a
5120: 20 6d 61 70 20 6f 66 20 70 6f 73 69 74 69 6f 6e   map of position
5130: 73 20 74 6f 20 6d 61 6b 65 20 69 74 20 65 61 73  s to make it eas
5140: 69 65 72 20 74 6f 0a 09 23 20 64 65 74 65 72 6d  ier to..# determ
5150: 69 6e 65 20 77 68 65 74 68 65 72 20 61 20 64 65  ine whether a de
5160: 70 65 6e 64 65 6e 63 79 20 63 72 6f 73 73 65 73  pendency crosses
5170: 20 61 20 70 61 72 74 69 63 75 6c 61 72 20 69 6e   a particular in
5180: 64 65 78 2e 0a 0a 09 61 72 72 61 79 20 73 65 74  dex....array set
5190: 20 70 6f 73 20 20 20 7b 7d 0a 09 61 72 72 61 79   pos   {}..array
51a0: 20 73 65 74 20 63 72 6f 73 73 20 7b 7d 0a 09 61   set cross {}..a
51b0: 72 72 61 79 20 73 65 74 20 64 65 70 63 20 20 7b  rray set depc  {
51c0: 7d 0a 09 73 65 74 20 72 61 6e 67 65 20 20 20 20  }..set range    
51d0: 20 20 20 7b 7d 0a 09 73 65 74 20 6e 20 30 0a 09     {}..set n 0..
51e0: 66 6f 72 65 61 63 68 20 72 65 76 20 24 72 65 76  foreach rev $rev
51f0: 69 73 69 6f 6e 73 20 7b 0a 09 20 20 20 20 6c 61  isions {..    la
5200: 70 70 65 6e 64 20 72 61 6e 67 65 20 24 6e 0a 09  ppend range $n..
5210: 20 20 20 20 73 65 74 20 70 6f 73 28 24 72 65 76      set pos($rev
5220: 29 20 24 6e 0a 09 20 20 20 20 73 65 74 20 63 72  ) $n..    set cr
5230: 6f 73 73 28 24 6e 29 20 30 0a 09 20 20 20 20 69  oss($n) 0..    i
5240: 6e 63 72 20 6e 0a 09 7d 0a 0a 09 23 20 53 65 63  ncr n..}...# Sec
5250: 6f 6e 64 6c 79 20 77 65 20 63 6f 75 6e 74 20 74  ondly we count t
5260: 68 65 20 63 72 6f 73 73 69 6e 67 73 20 70 65 72  he crossings per
5270: 20 70 6f 73 69 74 69 6f 6e 2c 20 62 79 20 69 74   position, by it
5280: 65 72 61 74 69 6e 67 0a 09 23 20 6f 76 65 72 20  erating..# over 
5290: 74 68 65 20 72 65 63 6f 72 64 65 64 20 69 6e 74  the recorded int
52a0: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69  ernal dependenci
52b0: 65 73 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 49 66  es....# Note: If
52c0: 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20   the timestamps 
52d0: 61 72 65 20 62 61 64 6c 79 20 6f 75 74 20 6f 66  are badly out of
52e0: 20 6f 72 64 65 72 20 69 74 20 69 73 0a 09 23 20   order it is..# 
52f0: 20 20 20 20 20 20 70 6f 73 73 69 62 6c 65 20 74        possible t
5300: 6f 20 68 61 76 65 20 61 20 62 61 63 6b 77 61 72  o have a backwar
5310: 64 20 73 75 63 63 65 73 73 6f 72 20 64 65 70 65  d successor depe
5320: 6e 64 65 6e 63 79 2c 0a 09 23 20 20 20 20 20 20  ndency,..#      
5330: 20 69 2e 65 2e 20 77 69 74 68 20 73 74 61 72 74   i.e. with start
5340: 20 3e 20 65 6e 64 2e 20 57 65 20 6d 61 79 20 68   > end. We may h
5350: 61 76 65 20 74 6f 20 73 77 61 70 20 74 68 65 20  ave to swap the 
5360: 69 6e 64 69 63 65 73 0a 09 23 20 20 20 20 20 20  indices..#      
5370: 20 74 6f 20 65 6e 73 75 72 65 20 74 68 61 74 20   to ensure that 
5380: 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 6c 6f  the following lo
5390: 6f 70 20 72 75 6e 73 20 63 6f 72 72 65 63 74 6c  op runs correctl
53a0: 79 2e 0a 09 23 0a 09 23 20 4e 6f 74 65 20 32 3a  y...#..# Note 2:
53b0: 20 73 74 61 72 74 20 3d 3d 20 65 6e 64 20 69 73   start == end is
53c0: 20 6e 6f 74 20 70 6f 73 73 69 62 6c 65 2e 20 49   not possible. I
53d0: 74 20 69 6e 64 69 63 61 74 65 73 20 61 0a 09 23  t indicates a..#
53e0: 20 20 20 20 20 20 20 20 20 73 65 6c 66 2d 64 65           self-de
53f0: 70 65 6e 64 65 6e 63 79 20 64 75 65 20 74 6f 20  pendency due to 
5400: 74 68 65 20 75 6e 69 71 75 65 6e 65 73 73 20 6f  the uniqueness o
5410: 66 20 70 6f 73 69 74 69 6f 6e 73 2c 0a 09 23 20  f positions,..# 
5420: 20 20 20 20 20 20 20 20 61 6e 64 20 74 68 61 74          and that
5430: 20 69 73 20 73 6f 6d 65 74 68 69 6e 67 20 77 65   is something we
5440: 20 68 61 76 65 20 72 75 6c 65 64 20 6f 75 74 20   have ruled out 
5450: 61 6c 72 65 61 64 79 2c 20 73 65 65 0a 09 23 20  already, see..# 
5460: 20 20 20 20 20 20 20 20 50 75 6c 6c 49 6e 74 65          PullInte
5470: 72 6e 61 6c 53 75 63 63 65 73 73 6f 72 52 65 76  rnalSuccessorRev
5480: 69 73 69 6f 6e 73 2e 0a 0a 09 66 6f 72 65 61 63  isions....foreac
5490: 68 20 7b 72 69 64 20 63 68 69 6c 64 72 65 6e 7d  h {rid children}
54a0: 20 5b 61 72 72 61 79 20 67 65 74 20 64 65 70 65   [array get depe
54b0: 6e 64 65 6e 63 69 65 73 5d 20 7b 0a 09 20 20 20  ndencies] {..   
54c0: 20 66 6f 72 65 61 63 68 20 63 68 69 6c 64 20 24   foreach child $
54d0: 63 68 69 6c 64 72 65 6e 20 7b 0a 09 09 73 65 74  children {...set
54e0: 20 64 6b 65 79 20 20 20 20 5b 6c 69 73 74 20 24   dkey    [list $
54f0: 72 69 64 20 24 63 68 69 6c 64 5d 0a 09 09 73 65  rid $child]...se
5500: 74 20 73 74 61 72 74 20 20 20 24 70 6f 73 28 24  t start   $pos($
5510: 72 69 64 29 0a 09 09 73 65 74 20 65 6e 64 20 20  rid)...set end  
5520: 20 20 20 24 70 6f 73 28 24 63 68 69 6c 64 29 0a     $pos($child).
5530: 09 09 73 65 74 20 63 72 6f 73 73 65 73 20 7b 7d  ..set crosses {}
5540: 0a 0a 09 09 69 66 20 7b 24 73 74 61 72 74 20 3e  ....if {$start >
5550: 20 24 65 6e 64 7d 20 7b 0a 09 09 20 20 20 20 77   $end} {...    w
5560: 68 69 6c 65 20 7b 24 65 6e 64 20 3c 20 24 73 74  hile {$end < $st
5570: 61 72 74 7d 20 7b 0a 09 09 09 6c 61 70 70 65 6e  art} {....lappen
5580: 64 20 63 72 6f 73 73 65 73 20 24 65 6e 64 0a 09  d crosses $end..
5590: 09 09 69 6e 63 72 20 63 72 6f 73 73 28 24 65 6e  ..incr cross($en
55a0: 64 29 0a 09 09 09 69 6e 63 72 20 65 6e 64 0a 09  d)....incr end..
55b0: 09 20 20 20 20 7d 0a 09 09 7d 20 65 6c 73 65 20  .    }...} else 
55c0: 7b 0a 09 09 20 20 20 20 77 68 69 6c 65 20 7b 24  {...    while {$
55d0: 73 74 61 72 74 20 3c 20 24 65 6e 64 7d 20 7b 0a  start < $end} {.
55e0: 09 09 09 6c 61 70 70 65 6e 64 20 63 72 6f 73 73  ...lappend cross
55f0: 65 73 20 24 73 74 61 72 74 0a 09 09 09 69 6e 63  es $start....inc
5600: 72 20 63 72 6f 73 73 28 24 73 74 61 72 74 29 0a  r cross($start).
5610: 09 09 09 69 6e 63 72 20 73 74 61 72 74 0a 09 09  ...incr start...
5620: 20 20 20 20 7d 0a 09 09 7d 0a 09 09 73 65 74 20      }...}...set 
5630: 64 65 70 63 28 24 64 6b 65 79 29 20 24 63 72 6f  depc($dkey) $cro
5640: 73 73 65 73 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a  sses..    }..}..
5650: 09 49 6e 69 74 69 61 6c 69 7a 65 44 65 6c 74 61  .InitializeDelta
5660: 73 20 24 72 65 76 69 73 69 6f 6e 73 0a 09 72 65  s $revisions..re
5670: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
5680: 70 72 6f 63 20 49 6e 69 74 69 61 6c 69 7a 65 44  proc InitializeD
5690: 65 6c 74 61 73 20 7b 72 65 76 69 73 69 6f 6e 73  eltas {revisions
56a0: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 64 65 6c  } {..upvar 1 del
56b0: 74 61 20 64 65 6c 74 61 0a 0a 09 23 20 50 75 6c  ta delta...# Pul
56c0: 6c 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73  l the timestamps
56d0: 20 66 6f 72 20 61 6c 6c 20 72 65 76 69 73 69 6f   for all revisio
56e0: 6e 73 20 69 6e 20 74 68 65 20 63 68 61 6e 67 65  ns in the change
56f0: 73 65 74 73 20 61 6e 64 0a 09 23 20 63 6f 6d 70  sets and..# comp
5700: 75 74 65 20 74 68 65 69 72 20 64 65 6c 74 61 73  ute their deltas
5710: 20 66 6f 72 20 75 73 65 20 62 79 20 74 68 65 20   for use by the 
5720: 62 72 65 61 6b 20 66 69 6e 64 65 72 2e 0a 0a 09  break finder....
5730: 61 72 72 61 79 20 73 65 74 20 64 65 6c 74 61 20  array set delta 
5740: 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 20 73 74  {}..array set st
5750: 61 6d 70 20 7b 7d 0a 0a 09 73 65 74 20 74 68 65  amp {}...set the
5760: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76  set ('[join $rev
5770: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a  isions {','}]').
5780: 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 74 69  .foreach {rid ti
5790: 6d 65 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 22  me} [state run "
57a0: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72  ..    SELECT R.r
57b0: 69 64 2c 20 52 2e 64 61 74 65 0a 09 20 20 20 20  id, R.date..    
57c0: 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 0a  FROM revision R.
57d0: 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64  .    WHERE R.rid
57e0: 20 49 4e 20 24 74 68 65 73 65 74 0a 09 22 5d 20   IN $theset.."] 
57f0: 7b 0a 09 20 20 20 20 73 65 74 20 73 74 61 6d 70  {..    set stamp
5800: 28 24 72 69 64 29 20 24 74 69 6d 65 0a 09 7d 0a  ($rid) $time..}.
5810: 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 65 61  ..set n 0..forea
5820: 63 68 20 72 69 64 20 5b 6c 72 61 6e 67 65 20 24  ch rid [lrange $
5830: 72 65 76 69 73 69 6f 6e 73 20 30 20 65 6e 64 2d  revisions 0 end-
5840: 31 5d 20 72 6e 65 78 74 20 5b 6c 72 61 6e 67 65  1] rnext [lrange
5850: 20 24 72 65 76 69 73 69 6f 6e 73 20 31 20 65 6e   $revisions 1 en
5860: 64 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 64 65  d] {..    set de
5870: 6c 74 61 28 24 6e 29 20 5b 65 78 70 72 20 7b 24  lta($n) [expr {$
5880: 73 74 61 6d 70 28 24 72 6e 65 78 74 29 20 2d 20  stamp($rnext) - 
5890: 24 73 74 61 6d 70 28 24 72 69 64 29 7d 5d 0a 09  $stamp($rid)}]..
58a0: 20 20 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 09 72      incr n..}..r
58b0: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
58c0: 20 70 72 6f 63 20 46 69 6e 64 42 65 73 74 42 72   proc FindBestBr
58d0: 65 61 6b 20 7b 72 61 6e 67 65 7d 20 7b 0a 09 75  eak {range} {..u
58e0: 70 76 61 72 20 31 20 63 72 6f 73 73 20 63 72 6f  pvar 1 cross cro
58f0: 73 73 20 64 65 6c 74 61 20 64 65 6c 74 61 0a 0a  ss delta delta..
5900: 09 23 20 44 65 74 65 72 6d 69 6e 65 20 74 68 65  .# Determine the
5910: 20 62 65 73 74 20 62 72 65 61 6b 20 6c 6f 63 61   best break loca
5920: 74 69 6f 6e 20 69 6e 20 74 68 65 20 67 69 76 65  tion in the give
5930: 6e 20 72 61 6e 67 65 20 6f 66 0a 09 23 20 70 6f  n range of..# po
5940: 73 69 74 69 6f 6e 73 2e 20 46 69 72 73 74 20 77  sitions. First w
5950: 65 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 20 6c  e look for the l
5960: 6f 63 61 74 69 6f 6e 73 20 77 69 74 68 20 74 68  ocations with th
5970: 65 20 6d 61 78 69 6d 61 6c 0a 09 23 20 6e 75 6d  e maximal..# num
5980: 62 65 72 20 6f 66 20 63 72 6f 73 73 69 6e 67 73  ber of crossings
5990: 2e 20 49 66 20 74 68 65 72 65 20 61 72 65 20 73  . If there are s
59a0: 65 76 65 72 61 6c 20 77 65 20 6c 6f 6f 6b 20 66  everal we look f
59b0: 6f 72 20 74 68 65 0a 09 23 20 73 68 6f 72 74 65  or the..# shorte
59c0: 73 74 20 74 69 6d 65 20 69 6e 74 65 72 76 61 6c  st time interval
59d0: 20 61 6d 6f 6e 67 20 74 68 65 6d 2e 20 49 66 20   among them. If 
59e0: 77 65 20 73 74 69 6c 6c 20 68 61 76 65 20 6d 75  we still have mu
59f0: 6c 74 69 70 6c 65 0a 09 23 20 70 6f 73 73 69 62  ltiple..# possib
5a00: 69 6c 69 74 69 65 73 20 61 66 74 65 72 20 74 68  ilities after th
5a10: 61 74 20 77 65 20 73 65 6c 65 63 74 20 74 68 65  at we select the
5a20: 20 65 61 72 6c 69 65 73 74 20 6c 6f 63 61 74 69   earliest locati
5a30: 6f 6e 0a 09 23 20 61 6d 6f 6e 67 20 74 68 65 73  on..# among thes
5a40: 65 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 49 66 20  e....# Note: If 
5a50: 74 68 65 20 6d 61 78 69 6d 61 6c 20 6e 75 6d 62  the maximal numb
5a60: 65 72 20 6f 66 20 63 72 6f 73 73 69 6e 67 73 20  er of crossings 
5a70: 69 73 20 30 20 74 68 65 6e 20 74 68 65 20 72 61  is 0 then the ra
5a80: 6e 67 65 0a 09 23 20 20 20 20 20 20 20 68 61 73  nge..#       has
5a90: 20 6e 6f 20 69 6e 74 65 72 6e 61 6c 20 64 65 70   no internal dep
5aa0: 65 6e 64 65 6e 63 69 65 73 2c 20 61 6e 64 20 6e  endencies, and n
5ab0: 6f 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e  o break location
5ac0: 20 61 74 0a 09 23 20 20 20 20 20 20 20 61 6c 6c   at..#       all
5ad0: 2e 20 54 68 69 73 20 70 6f 73 73 69 62 69 6c 69  . This possibili
5ae0: 74 79 20 69 73 20 73 69 67 6e 61 6c 65 64 20 76  ty is signaled v
5af0: 69 61 20 72 65 73 75 6c 74 20 2d 31 2e 0a 0a 09  ia result -1....
5b00: 23 20 4e 6f 74 65 3a 20 41 20 72 61 6e 67 65 20  # Note: A range 
5b10: 6f 66 20 6c 65 6e 67 74 68 20 31 20 6f 72 20 6c  of length 1 or l
5b20: 65 73 73 20 63 61 6e 6e 6f 74 20 68 61 76 65 20  ess cannot have 
5b30: 69 6e 74 65 72 6e 61 6c 0a 09 23 20 20 20 20 20  internal..#     
5b40: 20 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20    dependencies, 
5b50: 61 73 20 74 68 61 74 20 6e 65 65 64 73 20 61 74  as that needs at
5b60: 20 6c 65 61 73 74 20 74 77 6f 20 72 65 76 69 73   least two revis
5b70: 69 6f 6e 73 20 69 6e 0a 09 23 20 20 20 20 20 20  ions in..#      
5b80: 20 74 68 65 20 72 61 6e 67 65 2e 0a 0a 09 69 66   the range....if
5b90: 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 72 61 6e 67   {[llength $rang
5ba0: 65 5d 20 3c 20 32 7d 20 7b 20 72 65 74 75 72 6e  e] < 2} { return
5bb0: 20 2d 31 20 7d 0a 0a 09 73 65 74 20 6d 61 78 20   -1 }...set max 
5bc0: 2d 31 0a 09 73 65 74 20 62 65 73 74 20 7b 7d 0a  -1..set best {}.
5bd0: 0a 09 66 6f 72 65 61 63 68 20 6c 6f 63 61 74 69  ..foreach locati
5be0: 6f 6e 20 24 72 61 6e 67 65 20 7b 0a 09 20 20 20  on $range {..   
5bf0: 20 73 65 74 20 63 72 6f 73 73 69 6e 67 73 20 24   set crossings $
5c00: 63 72 6f 73 73 28 24 6c 6f 63 61 74 69 6f 6e 29  cross($location)
5c10: 0a 09 20 20 20 20 69 66 20 7b 24 63 72 6f 73 73  ..    if {$cross
5c20: 69 6e 67 73 20 3e 20 24 6d 61 78 7d 20 7b 0a 09  ings > $max} {..
5c30: 09 73 65 74 20 6d 61 78 20 20 24 63 72 6f 73 73  .set max  $cross
5c40: 69 6e 67 73 0a 09 09 73 65 74 20 62 65 73 74 20  ings...set best 
5c50: 5b 6c 69 73 74 20 24 6c 6f 63 61 74 69 6f 6e 5d  [list $location]
5c60: 0a 09 09 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20  ...continue..   
5c70: 20 7d 20 65 6c 73 65 69 66 20 7b 24 63 72 6f 73   } elseif {$cros
5c80: 73 69 6e 67 73 20 3d 3d 20 24 6d 61 78 7d 20 7b  sings == $max} {
5c90: 0a 09 09 6c 61 70 70 65 6e 64 20 62 65 73 74 20  ...lappend best 
5ca0: 24 6c 6f 63 61 74 69 6f 6e 0a 09 20 20 20 20 7d  $location..    }
5cb0: 0a 09 7d 0a 0a 09 69 66 20 7b 24 6d 61 78 20 3d  ..}...if {$max =
5cc0: 3d 20 30 7d 20 20 20 20 20 20 20 20 20 20 20 20  = 0}            
5cd0: 7b 20 72 65 74 75 72 6e 20 2d 31 20 7d 0a 09 69  { return -1 }..i
5ce0: 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 62 65 73  f {[llength $bes
5cf0: 74 5d 20 3d 3d 20 31 7d 20 7b 20 72 65 74 75 72  t] == 1} { retur
5d00: 6e 20 5b 6c 69 6e 64 65 78 20 24 62 65 73 74 20  n [lindex $best 
5d10: 30 5d 20 7d 0a 0a 09 73 65 74 20 6c 6f 63 61 74  0] }...set locat
5d20: 69 6f 6e 73 20 24 62 65 73 74 0a 09 73 65 74 20  ions $best..set 
5d30: 62 65 73 74 20 7b 7d 0a 09 73 65 74 20 6d 69 6e  best {}..set min
5d40: 20 2d 31 0a 0a 09 66 6f 72 65 61 63 68 20 6c 6f   -1...foreach lo
5d50: 63 61 74 69 6f 6e 20 24 6c 6f 63 61 74 69 6f 6e  cation $location
5d60: 73 20 7b 0a 09 20 20 20 20 73 65 74 20 69 6e 74  s {..    set int
5d70: 65 72 76 61 6c 20 24 64 65 6c 74 61 28 24 6c 6f  erval $delta($lo
5d80: 63 61 74 69 6f 6e 29 0a 09 20 20 20 20 69 66 20  cation)..    if 
5d90: 7b 28 24 6d 69 6e 20 3c 20 30 29 20 7c 7c 20 28  {($min < 0) || (
5da0: 24 69 6e 74 65 72 76 61 6c 20 3c 20 24 6d 69 6e  $interval < $min
5db0: 29 7d 20 7b 0a 09 09 73 65 74 20 6d 69 6e 20 20  )} {...set min  
5dc0: 24 69 6e 74 65 72 76 61 6c 0a 09 09 73 65 74 20  $interval...set 
5dd0: 62 65 73 74 20 5b 6c 69 73 74 20 24 6c 6f 63 61  best [list $loca
5de0: 74 69 6f 6e 5d 0a 09 20 20 20 20 7d 20 65 6c 73  tion]..    } els
5df0: 65 69 66 20 7b 24 69 6e 74 65 72 76 61 6c 20 3d  eif {$interval =
5e00: 3d 20 24 6d 69 6e 7d 20 7b 0a 09 09 6c 61 70 70  = $min} {...lapp
5e10: 65 6e 64 20 62 65 73 74 20 24 6c 6f 63 61 74 69  end best $locati
5e20: 6f 6e 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69  on..    }..}...i
5e30: 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 62 65 73  f {[llength $bes
5e40: 74 5d 20 3d 3d 20 31 7d 20 7b 20 72 65 74 75 72  t] == 1} { retur
5e50: 6e 20 5b 6c 69 6e 64 65 78 20 24 62 65 73 74 20  n [lindex $best 
5e60: 30 5d 20 7d 0a 0a 09 72 65 74 75 72 6e 20 5b 6c  0] }...return [l
5e70: 69 6e 64 65 78 20 5b 6c 73 6f 72 74 20 2d 69 6e  index [lsort -in
5e80: 74 65 67 65 72 20 2d 69 6e 63 72 65 61 73 69 6e  teger -increasin
5e90: 67 20 24 62 65 73 74 5d 20 30 5d 0a 20 20 20 20  g $best] 0].    
5ea0: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 43 75 74 41  }..    proc CutA
5eb0: 74 20 7b 6c 6f 63 61 74 69 6f 6e 7d 20 7b 0a 09  t {location} {..
5ec0: 75 70 76 61 72 20 31 20 63 72 6f 73 73 20 63 72  upvar 1 cross cr
5ed0: 6f 73 73 20 64 65 70 63 20 64 65 70 63 0a 0a 09  oss depc depc...
5ee0: 23 20 49 74 20 77 61 73 20 64 65 63 69 64 65 64  # It was decided
5ef0: 20 74 6f 20 73 70 6c 69 74 20 74 68 65 20 63 68   to split the ch
5f00: 61 6e 67 65 73 65 74 20 61 74 20 74 68 65 20 67  angeset at the g
5f10: 69 76 65 6e 0a 09 23 20 6c 6f 63 61 74 69 6f 6e  iven..# location
5f20: 2e 20 54 68 69 73 20 63 75 74 73 20 61 20 6e 75  . This cuts a nu
5f30: 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 65 6e  mber of dependen
5f40: 63 69 65 73 2e 20 48 65 72 65 20 77 65 20 75 70  cies. Here we up
5f50: 64 61 74 65 0a 09 23 20 74 68 65 20 63 72 6f 73  date..# the cros
5f60: 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 73 6f  s information so
5f70: 20 74 68 61 74 20 74 68 65 20 62 72 65 61 6b 20   that the break 
5f80: 66 69 6e 64 65 72 20 68 61 73 20 61 63 63 75 72  finder has accur
5f90: 61 74 65 0a 09 23 20 64 61 74 61 20 77 68 65 6e  ate..# data when
5fa0: 20 77 65 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20   we look at the 
5fb0: 67 65 6e 65 72 61 74 65 64 20 66 72 61 67 6d 65  generated fragme
5fc0: 6e 74 73 2e 0a 0a 09 73 65 74 20 73 69 78 20 5b  nts....set six [
5fd0: 6c 6f 67 20 76 69 73 69 62 6c 65 3f 20 36 5d 0a  log visible? 6].
5fe0: 0a 09 66 6f 72 65 61 63 68 20 7b 64 65 70 20 72  ..foreach {dep r
5ff0: 61 6e 67 65 7d 20 5b 61 72 72 61 79 20 67 65 74  ange} [array get
6000: 20 64 65 70 63 5d 20 7b 0a 09 20 20 20 20 23 20   depc] {..    # 
6010: 43 68 65 63 6b 20 61 6c 6c 20 64 65 70 65 6e 64  Check all depend
6020: 65 6e 63 69 65 73 20 73 74 69 6c 6c 20 6b 6e 6f  encies still kno
6030: 77 6e 2c 20 74 61 6b 65 20 74 68 65 69 72 20 72  wn, take their r
6040: 61 6e 67 65 20 61 6e 64 0a 09 20 20 20 20 23 20  ange and..    # 
6050: 73 65 65 20 69 66 20 74 68 65 20 62 72 65 61 6b  see if the break
6060: 20 6c 6f 63 61 74 69 6f 6e 20 66 61 6c 6c 73 20   location falls 
6070: 77 69 74 68 69 6e 2e 0a 0a 09 20 20 20 20 42 6f  within....    Bo
6080: 72 64 65 72 20 24 72 61 6e 67 65 20 73 20 65 0a  rder $range s e.
6090: 09 20 20 20 20 69 66 20 7b 24 6c 6f 63 61 74 69  .    if {$locati
60a0: 6f 6e 20 3c 20 24 73 7d 20 63 6f 6e 74 69 6e 75  on < $s} continu
60b0: 65 20 3b 20 23 20 62 72 65 61 6b 20 62 65 66 6f  e ; # break befo
60c0: 72 65 20 72 61 6e 67 65 2c 20 69 67 6e 6f 72 65  re range, ignore
60d0: 0a 09 20 20 20 20 69 66 20 7b 24 6c 6f 63 61 74  ..    if {$locat
60e0: 69 6f 6e 20 3e 20 24 65 7d 20 63 6f 6e 74 69 6e  ion > $e} contin
60f0: 75 65 20 3b 20 23 20 62 72 65 61 6b 20 61 66 74  ue ; # break aft
6100: 65 72 20 72 61 6e 67 65 2c 20 69 67 6e 6f 72 65  er range, ignore
6110: 2e 0a 0a 09 20 20 20 20 23 20 54 68 69 73 20 64  ....    # This d
6120: 65 70 65 6e 64 65 6e 63 79 20 63 72 6f 73 73 65  ependency crosse
6130: 73 20 74 68 65 20 62 72 65 61 6b 20 6c 6f 63 61  s the break loca
6140: 74 69 6f 6e 2e 20 57 65 20 72 65 6d 6f 76 65 20  tion. We remove 
6150: 69 74 0a 09 20 20 20 20 23 20 66 72 6f 6d 20 74  it..    # from t
6160: 68 65 20 63 72 6f 73 73 69 6e 67 73 20 63 6f 75  he crossings cou
6170: 6e 74 65 72 73 2c 20 61 6e 64 20 74 68 65 6e 20  nters, and then 
6180: 61 6c 73 6f 20 66 72 6f 6d 20 74 68 65 20 73 65  also from the se
6190: 74 0a 09 20 20 20 20 23 20 6f 66 20 6b 6e 6f 77  t..    # of know
61a0: 6e 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20  n dependencies, 
61b0: 61 73 20 77 65 20 61 72 65 20 64 6f 6e 65 20 77  as we are done w
61c0: 69 74 68 20 69 74 2e 0a 0a 09 20 20 20 20 66 6f  ith it....    fo
61d0: 72 65 61 63 68 20 6c 6f 63 20 24 64 65 70 63 28  reach loc $depc(
61e0: 24 64 65 70 29 20 7b 20 69 6e 63 72 20 63 72 6f  $dep) { incr cro
61f0: 73 73 28 24 6c 6f 63 29 20 2d 31 20 7d 0a 09 20  ss($loc) -1 }.. 
6200: 20 20 20 75 6e 73 65 74 20 64 65 70 63 28 24 64     unset depc($d
6210: 65 70 29 0a 0a 09 20 20 20 20 69 66 20 7b 21 24  ep)...    if {!$
6220: 73 69 78 7d 20 63 6f 6e 74 69 6e 75 65 0a 0a 09  six} continue...
6230: 20 20 20 20 73 74 72 75 63 74 3a 3a 6c 69 73 74      struct::list
6240: 20 61 73 73 69 67 6e 20 24 64 65 70 20 70 61 72   assign $dep par
6250: 65 6e 74 20 63 68 69 6c 64 0a 09 20 20 20 20 6c  ent child..    l
6260: 6f 67 20 77 72 69 74 65 20 35 20 63 73 65 74 73  og write 5 csets
6270: 20 22 42 72 6f 6b 65 20 64 65 70 65 6e 64 65 6e   "Broke dependen
6280: 63 79 20 5b 50 44 20 24 70 61 72 65 6e 74 5d 20  cy [PD $parent] 
6290: 2d 2d 3e 20 5b 50 44 20 24 63 68 69 6c 64 5d 22  --> [PD $child]"
62a0: 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20  ..}...return.   
62b0: 20 7d 0a 0a 20 20 20 20 23 20 50 72 69 6e 74 20   }..    # Print 
62c0: 69 64 65 6e 74 69 66 79 69 6e 67 20 64 61 74 61  identifying data
62d0: 20 66 6f 72 20 61 20 72 65 76 69 73 69 6f 6e 20   for a revision 
62e0: 28 70 72 6f 6a 65 63 74 2c 20 66 69 6c 65 2c 20  (project, file, 
62f0: 64 6f 74 74 65 64 20 72 65 76 0a 20 20 20 20 23  dotted rev.    #
6300: 20 6e 75 6d 62 65 72 29 2c 20 66 6f 72 20 68 69   number), for hi
6310: 67 68 20 76 65 72 62 6f 73 69 74 79 20 6c 6f 67  gh verbosity log
6320: 20 6f 75 74 70 75 74 2e 0a 0a 20 20 20 20 70 72   output...    pr
6330: 6f 63 20 50 44 20 7b 69 64 7d 20 7b 0a 09 66 6f  oc PD {id} {..fo
6340: 72 65 61 63 68 20 7b 70 20 66 20 72 7d 20 5b 73  reach {p f r} [s
6350: 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c  tate run {...SEL
6360: 45 43 54 20 50 2e 6e 61 6d 65 20 2c 20 46 2e 6e  ECT P.name , F.n
6370: 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f  ame, R.rev...FRO
6380: 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69  M revision R, fi
6390: 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a  le F, project P.
63a0: 09 09 57 48 45 52 45 20 52 2e 72 69 64 20 3d 20  ..WHERE R.rid = 
63b0: 24 69 64 0a 09 09 41 4e 44 20 20 20 52 2e 66 69  $id...AND   R.fi
63c0: 64 20 3d 20 46 2e 66 69 64 0a 09 09 41 4e 44 20  d = F.fid...AND 
63d0: 20 20 46 2e 70 69 64 20 3d 20 50 2e 70 69 64 0a    F.pid = P.pid.
63e0: 09 7d 5d 20 62 72 65 61 6b 0a 09 72 65 74 75 72  .}] break..retur
63f0: 6e 20 22 27 24 70 20 3a 20 24 66 2f 24 72 27 22  n "'$p : $f/$r'"
6400: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 50 72  .    }..    # Pr
6410: 69 6e 74 69 6e 67 20 6f 6e 65 20 6f 72 20 6d 6f  inting one or mo
6420: 72 65 20 72 61 6e 67 65 73 2c 20 66 6f 72 6d 61  re ranges, forma
6430: 74 74 65 64 2c 20 61 6e 64 20 6f 6e 6c 79 20 74  tted, and only t
6440: 68 65 69 72 20 62 6f 72 64 65 72 20 74 6f 0a 20  heir border to. 
6450: 20 20 20 23 20 6b 65 65 70 20 74 68 65 20 73 74     # keep the st
6460: 72 69 6e 67 73 20 73 68 6f 72 74 2e 0a 0a 20 20  rings short...  
6470: 20 20 70 72 6f 63 20 50 52 73 20 7b 72 61 6e 67    proc PRs {rang
6480: 65 73 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 73  es} {..return [s
6490: 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20  truct::list map 
64a0: 24 72 61 6e 67 65 73 20 5b 6d 79 70 72 6f 63 20  $ranges [myproc 
64b0: 50 52 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20  PR]].    }..    
64c0: 70 72 6f 63 20 50 52 20 7b 72 61 6e 67 65 7d 20  proc PR {range} 
64d0: 7b 0a 09 42 6f 72 64 65 72 20 24 72 61 6e 67 65  {..Border $range
64e0: 20 73 20 65 0a 09 72 65 74 75 72 6e 20 3c 24 7b   s e..return <${
64f0: 73 7d 2e 2e 2e 24 7b 65 7d 3e 0a 20 20 20 20 7d  s}...${e}>.    }
6500: 0a 0a 20 20 20 20 70 72 6f 63 20 42 6f 72 64 65  ..    proc Borde
6510: 72 20 7b 72 61 6e 67 65 20 73 76 20 65 76 7d 20  r {range sv ev} 
6520: 7b 0a 09 75 70 76 61 72 20 31 20 24 73 76 20 73  {..upvar 1 $sv s
6530: 20 24 65 76 20 65 0a 09 73 65 74 20 73 20 5b 6c   $ev e..set s [l
6540: 69 6e 64 65 78 20 24 72 61 6e 67 65 20 30 5d 0a  index $range 0].
6550: 09 73 65 74 20 65 20 5b 6c 69 6e 64 65 78 20 24  .set e [lindex $
6560: 72 61 6e 67 65 20 65 6e 64 5d 0a 09 72 65 74 75  range end]..retu
6570: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20  rn.    }..    # 
6580: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
6590: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
65a0: 23 23 23 23 23 0a 0a 20 20 20 20 74 79 70 65 76  #####..    typev
65b0: 61 72 69 61 62 6c 65 20 6d 79 63 68 61 6e 67 65  ariable mychange
65c0: 73 65 74 73 20 20 20 20 7b 7d 20 3b 20 23 20 4c  sets    {} ; # L
65d0: 69 73 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e  ist of all known
65e0: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 20 20 20   changesets..   
65f0: 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79   typevariable my
6600: 72 65 76 6d 61 70 20 2d 61 72 72 61 79 20 7b 7d  revmap -array {}
6610: 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d 20 72 65   ; # Map from re
6620: 76 69 73 69 6f 6e 73 20 74 6f 20 74 68 65 20 6c  visions to the l
6630: 69 73 74 0a 09 09 09 09 20 20 20 20 20 20 23 20  ist.....      # 
6640: 6f 66 20 63 68 61 6e 67 65 73 65 74 73 20 63 6f  of changesets co
6650: 6e 74 61 69 6e 69 6e 67 0a 09 09 09 09 20 20 20  ntaining.....   
6660: 20 20 20 23 20 69 74 2e 20 4e 4f 54 45 3a 20 57     # it. NOTE: W
6670: 68 69 6c 65 20 6f 6e 6c 79 20 6f 6e 65 0a 09 09  hile only one...
6680: 09 09 20 20 20 20 20 20 23 20 72 65 76 69 73 69  ..      # revisi
6690: 6f 6e 20 63 68 61 6e 67 65 73 65 74 20 63 61 6e  on changeset can
66a0: 20 63 6f 6e 74 61 69 6e 0a 09 09 09 09 20 20 20   contain.....   
66b0: 20 20 20 23 20 74 68 65 20 72 65 76 69 73 69 6f     # the revisio
66c0: 6e 2c 20 74 68 65 72 65 20 63 61 6e 0a 09 09 09  n, there can....
66d0: 09 20 20 20 20 20 20 23 20 68 6f 77 65 76 65 72  .      # however
66e0: 20 61 6c 73 6f 20 62 65 20 6f 6e 65 20 6f 72 20   also be one or 
66f0: 6d 6f 72 65 0a 09 09 09 09 20 20 20 20 20 20 23  more.....      #
6700: 20 61 64 64 69 74 69 6f 6e 61 6c 20 73 79 6d 62   additional symb
6710: 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 09 09  ol changesets...
6720: 09 09 20 20 20 20 20 20 23 20 77 68 69 63 68 20  ..      # which 
6730: 75 73 65 20 69 74 2c 20 68 65 6e 63 65 20 61 20  use it, hence a 
6740: 6c 69 73 74 2e 0a 20 20 20 20 74 79 70 65 76 61  list..    typeva
6750: 72 69 61 62 6c 65 20 6d 79 69 64 6d 61 70 20 20  riable myidmap  
6760: 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23 20 4d 61  -array {} ; # Ma
6770: 70 20 66 72 6f 6d 20 63 68 61 6e 67 65 73 65 74  p from changeset
6780: 20 69 64 20 74 6f 20 63 68 61 6e 67 65 73 65 74   id to changeset
6790: 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62  ..    typevariab
67a0: 6c 65 20 6d 79 62 72 61 6e 63 68 63 6f 64 65 20  le mybranchcode 
67b0: 20 20 20 7b 7d 20 3b 20 23 20 4c 6f 63 61 6c 20     {} ; # Local 
67c0: 63 6f 70 79 20 6f 66 20 70 72 6f 6a 65 63 74 3a  copy of project:
67d0: 3a 73 79 6d 2f 6d 79 62 72 61 6e 63 68 2e 0a 0a  :sym/mybranch...
67e0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 61      typemethod a
67f0: 6c 6c 20 20 20 7b 7d 20 20 20 7b 20 72 65 74 75  ll   {}   { retu
6800: 72 6e 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73  rn $mychangesets
6810: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f   }.    typemetho
6820: 64 20 6f 66 20 20 20 20 7b 69 64 7d 20 7b 20 72  d of    {id} { r
6830: 65 74 75 72 6e 20 24 6d 79 69 64 6d 61 70 28 24  eturn $myidmap($
6840: 69 64 29 20 7d 0a 20 20 20 20 74 79 70 65 6d 65  id) }.    typeme
6850: 74 68 6f 64 20 6f 66 72 65 76 20 7b 69 64 7d 20  thod ofrev {id} 
6860: 7b 20 72 65 74 75 72 6e 20 24 6d 79 72 65 76 6d  { return $myrevm
6870: 61 70 28 24 69 64 29 20 7d 0a 0a 20 20 20 20 23  ap($id) }..    #
6880: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
6890: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
68a0: 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 43 6f  ######.    ## Co
68b0: 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20  nfiguration..   
68c0: 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65   pragma -hastype
68d0: 69 6e 66 6f 20 20 20 20 6e 6f 20 20 3b 20 23 20  info    no  ; # 
68e0: 6e 6f 20 74 79 70 65 20 69 6e 74 72 6f 73 70 65  no type introspe
68f0: 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61  ction.    pragma
6900: 20 2d 68 61 73 69 6e 66 6f 20 20 20 20 20 20 20   -hasinfo       
6910: 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 6f 62 6a 65   no  ; # no obje
6920: 63 74 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e  ct introspection
6930: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 73 69 6d  .    pragma -sim
6940: 70 6c 65 64 69 73 70 61 74 63 68 20 79 65 73 20  pledispatch yes 
6950: 3b 20 23 20 73 69 6d 70 6c 65 20 66 61 73 74 20  ; # simple fast 
6960: 64 69 73 70 61 74 63 68 0a 0a 20 20 20 20 23 20  dispatch..    # 
6970: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
6980: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
6990: 23 23 23 23 23 0a 7d 0a 0a 23 20 23 20 23 23 20  #####.}..# # ## 
69a0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
69b0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
69c0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23   ###############
69d0: 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65 72  ######.## Helper
69e0: 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d 6d   singleton. Comm
69f0: 61 6e 64 73 20 66 6f 72 20 72 65 76 69 73 69 6f  ands for revisio
6a00: 6e 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 73  n changesets...s
6a10: 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a  nit::type ::vc::
6a20: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
6a30: 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65  cvs::project::re
6a40: 76 3a 3a 72 65 76 20 7b 0a 20 20 20 20 74 79 70  v::rev {.    typ
6a50: 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 69  emethod byrevisi
6a60: 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31  on {} { return 1
6a70: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f   }.    typemetho
6a80: 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20  d bysymbol   {} 
6a90: 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20  { return 0 }.   
6aa0: 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74 61   typemethod ista
6ab0: 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 75  g      {} { retu
6ac0: 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d  rn 0 }.    typem
6ad0: 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20 20  ethod isbranch  
6ae0: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d   {} { return 0 }
6af0: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d  ..    # result =
6b00: 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20   list (mintime, 
6b10: 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74 79 70  maxtime).    typ
6b20: 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61 6e 67  emethod timerang
6b30: 65 20 7b 69 74 65 6d 73 7d 20 7b 0a 20 20 20 20  e {items} {.    
6b40: 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 29  }..    # var(dv)
6b50: 20 3d 20 64 69 63 74 20 28 72 65 76 69 73 69 6f   = dict (revisio
6b60: 6e 20 2d 3e 20 6c 69 73 74 20 28 72 65 76 69 73  n -> list (revis
6b70: 69 6f 6e 29 29 0a 20 20 20 20 74 79 70 65 6d 65  ion)).    typeme
6b80: 74 68 6f 64 20 69 6e 74 65 72 6e 61 6c 73 75 63  thod internalsuc
6b90: 63 65 73 73 6f 72 73 20 7b 64 76 20 72 65 76 69  cessors {dv revi
6ba0: 73 69 6f 6e 73 7d 20 7b 0a 20 20 20 20 7d 0a 0a  sions} {.    }..
6bb0: 20 20 20 20 23 20 76 61 72 28 64 76 29 20 3d 20      # var(dv) = 
6bc0: 64 69 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69  dict (item -> li
6bd0: 73 74 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d  st (item)), item
6be0: 20 20 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69    = list (type i
6bf0: 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  d).    typemetho
6c00: 64 20 73 75 63 63 65 73 73 6f 72 73 20 7b 64 76  d successors {dv
6c10: 20 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 20 20   revisions} {.  
6c20: 20 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64    }..    # var(d
6c30: 76 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20  v) = dict (item 
6c40: 2d 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c  -> list (item)),
6c50: 20 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74   item  = list (t
6c60: 79 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 65  ype id).    type
6c70: 6d 65 74 68 6f 64 20 70 72 65 64 65 63 65 73 73  method predecess
6c80: 6f 72 73 20 7b 64 76 20 72 65 76 69 73 69 6f 6e  ors {dv revision
6c90: 73 7d 20 7b 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20  s} {.    }.}..# 
6ca0: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
6cb0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
6cc0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
6cd0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 48  ###########.## H
6ce0: 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 2e  elper singleton.
6cf0: 20 43 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 74 61   Commands for ta
6d00: 67 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73  g symbol changes
6d10: 65 74 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65  ets...snit::type
6d20: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69   ::vc::fossil::i
6d30: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a  mport::cvs::proj
6d40: 65 63 74 3a 3a 72 65 76 3a 3a 73 79 6d 3a 3a 74  ect::rev::sym::t
6d50: 61 67 20 7b 0a 20 20 20 20 74 79 70 65 6d 65 74  ag {.    typemet
6d60: 68 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20 7b  hod byrevision {
6d70: 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 20  } { return 0 }. 
6d80: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62 79     typemethod by
6d90: 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 7b 20 72 65  symbol   {} { re
6da0: 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70  turn 1 }.    typ
6db0: 65 6d 65 74 68 6f 64 20 69 73 74 61 67 20 20 20  emethod istag   
6dc0: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31     {} { return 1
6dd0: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f   }.    typemetho
6de0: 64 20 69 73 62 72 61 6e 63 68 20 20 20 7b 7d 20  d isbranch   {} 
6df0: 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 0a 20 20  { return 0 }..  
6e00: 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73    # result = lis
6e10: 74 20 28 6d 69 6e 74 69 6d 65 2c 20 6d 61 78 74  t (mintime, maxt
6e20: 69 6d 65 29 0a 20 20 20 20 74 79 70 65 6d 65 74  ime).    typemet
6e30: 68 6f 64 20 74 69 6d 65 72 61 6e 67 65 20 7b 74  hod timerange {t
6e40: 61 67 73 7d 20 7b 0a 20 20 20 20 7d 0a 0a 20 20  ags} {.    }..  
6e50: 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69    # var(dv) = di
6e60: 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74  ct (item -> list
6e70: 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20   (item)), item  
6e80: 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29  = list (type id)
6e90: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
6ea0: 73 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20 74  successors {dv t
6eb0: 61 67 73 7d 20 7b 0a 20 20 20 20 7d 0a 0a 20 20  ags} {.    }..  
6ec0: 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69    # var(dv) = di
6ed0: 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74  ct (item -> list
6ee0: 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20   (item)), item  
6ef0: 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29  = list (type id)
6f00: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20  .    typemethod 
6f10: 70 72 65 64 65 63 65 73 73 6f 72 73 20 7b 64 76  predecessors {dv
6f20: 20 74 61 67 73 7d 20 7b 0a 20 20 20 20 7d 0a 7d   tags} {.    }.}
6f30: 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
6f40: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
6f50: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23  ######### ######
6f60: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
6f70: 23 23 20 48 65 6c 70 65 72 20 73 69 6e 67 6c 65  ## Helper single
6f80: 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73 20 66 6f  ton. Commands fo
6f90: 72 20 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 20  r branch symbol 
6fa0: 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e 69  changesets...sni
6fb0: 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f  t::type ::vc::fo
6fc0: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
6fd0: 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a  s::project::rev:
6fe0: 3a 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b 0a 20  :sym::branch {. 
6ff0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62 79     typemethod by
7000: 72 65 76 69 73 69 6f 6e 20 7b 7d 20 7b 20 72 65  revision {} { re
7010: 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70  turn 0 }.    typ
7020: 65 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c  emethod bysymbol
7030: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31     {} { return 1
7040: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f   }.    typemetho
7050: 64 20 69 73 74 61 67 20 20 20 20 20 20 7b 7d 20  d istag      {} 
7060: 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20  { return 0 }.   
7070: 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 62 72   typemethod isbr
7080: 61 6e 63 68 20 20 20 7b 7d 20 7b 20 72 65 74 75  anch   {} { retu
7090: 72 6e 20 31 20 7d 0a 0a 20 20 20 20 23 20 72 65  rn 1 }..    # re
70a0: 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e  sult = list (min
70b0: 74 69 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20  time, maxtime). 
70c0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 74 69     typemethod ti
70d0: 6d 65 72 61 6e 67 65 20 7b 62 72 61 6e 63 68 65  merange {branche
70e0: 73 7d 20 7b 0a 20 20 20 20 7d 0a 0a 20 20 20 20  s} {.    }..    
70f0: 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 63 74  # var(dv) = dict
7100: 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28   (item -> list (
7110: 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 3d 20  item)), item  = 
7120: 6c 69 73 74 20 28 74 79 70 65 20 69 64 29 0a 20  list (type id). 
7130: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 75     typemethod su
7140: 63 63 65 73 73 6f 72 73 20 7b 64 76 20 62 72 61  ccessors {dv bra
7150: 6e 63 68 65 73 7d 20 7b 0a 20 20 20 20 7d 0a 0a  nches} {.    }..
7160: 20 20 20 20 23 20 76 61 72 28 64 76 29 20 3d 20      # var(dv) = 
7170: 64 69 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69  dict (item -> li
7180: 73 74 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d  st (item)), item
7190: 20 20 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69    = list (type i
71a0: 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  d).    typemetho
71b0: 64 20 70 72 65 64 65 63 65 73 73 6f 72 73 20 7b  d predecessors {
71c0: 64 76 20 62 72 61 6e 63 68 65 73 7d 20 7b 0a 20  dv branches} {. 
71d0: 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23     }..    # # ##
71e0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
71f0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
7200: 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75  #.    ## Configu
7210: 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67  ration..    prag
7220: 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 65 73  ma -hasinstances
7230: 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65     no ; # single
7240: 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d  ton.    pragma -
7250: 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20 6e  hastypeinfo    n
7260: 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70  o ; # no introsp
7270: 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d  ection.    pragm
7280: 61 20 2d 68 61 73 74 79 70 65 64 65 73 74 72 6f  a -hastypedestro
7290: 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61  y no ; # immorta
72a0: 6c 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20  l.}..# # ## ### 
72b0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23  ##### ######## #
72c0: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23  ############ ###
72d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
72e0: 23 23 0a 23 23 0a 0a 6e 61 6d 65 73 70 61 63 65  ##.##..namespace
72f0: 20 65 76 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73   eval ::vc::foss
7300: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
7310: 3a 70 72 6f 6a 65 63 74 20 7b 0a 20 20 20 20 6e  :project {.    n
7320: 61 6d 65 73 70 61 63 65 20 65 78 70 6f 72 74 20  amespace export 
7330: 72 65 76 0a 20 20 20 20 6e 61 6d 65 73 70 61 63  rev.    namespac
7340: 65 20 65 76 61 6c 20 72 65 76 20 7b 0a 09 6e 61  e eval rev {..na
7350: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
7360: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
7370: 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a  ort::cvs::state.
7380: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
7390: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
73a0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74  import::cvs::int
73b0: 65 67 72 69 74 79 0a 09 6e 61 6d 65 73 70 61 63  egrity..namespac
73c0: 65 20 65 76 61 6c 20 70 72 6f 6a 65 63 74 20 7b  e eval project {
73d0: 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20  ..    namespace 
73e0: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73  import ::vc::fos
73f0: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
7400: 3a 3a 70 72 6f 6a 65 63 74 3a 3a 73 79 6d 0a 09  ::project::sym..
7410: 7d 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79  }..::variable my
7420: 62 72 61 6e 63 68 63 6f 64 65 20 5b 70 72 6f 6a  branchcode [proj
7430: 65 63 74 3a 3a 73 79 6d 20 62 72 61 6e 63 68 5d  ect::sym branch]
7440: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f  ..namespace impo
7450: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a  rt ::vc::tools::
7460: 6d 69 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73 70 61  misc::*..namespa
7470: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
7480: 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 0a 09  tools::trouble..
7490: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74  namespace import
74a0: 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f   ::vc::tools::lo
74b0: 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65 72 20  g..log register 
74c0: 63 73 65 74 73 0a 0a 09 23 20 53 65 74 20 75 70  csets...# Set up
74d0: 20 74 68 65 20 68 65 6c 70 65 72 20 73 69 6e 67   the helper sing
74e0: 6c 65 74 6f 6e 73 0a 09 6e 61 6d 65 73 70 61 63  letons..namespac
74f0: 65 20 65 76 61 6c 20 72 65 76 20 7b 0a 09 20 20  e eval rev {..  
7500: 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f    namespace impo
7510: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  rt ::vc::fossil:
7520: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74  :import::cvs::st
7530: 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 61  ate..    namespa
7540: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
7550: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
7560: 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09  cvs::integrity..
7570: 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61  }..namespace eva
7580: 6c 20 73 79 6d 3a 3a 74 61 67 20 7b 0a 09 20 20  l sym::tag {..  
7590: 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f    namespace impo
75a0: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a  rt ::vc::fossil:
75b0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74  :import::cvs::st
75c0: 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 61  ate..    namespa
75d0: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
75e0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
75f0: 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09  cvs::integrity..
7600: 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61  }..namespace eva
7610: 6c 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b 0a  l sym::branch {.
7620: 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69  .    namespace i
7630: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73  mport ::vc::foss
7640: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a  il::import::cvs:
7650: 3a 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65  :state..    name
7660: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
7670: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
7680: 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74  t::cvs::integrit
7690: 79 0a 09 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20  y..}.    }.}..# 
76a0: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
76b0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
76c0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
76d0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52  ###########.## R
76e0: 65 61 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72  eady..package pr
76f0: 6f 76 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c  ovide vc::fossil
7700: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70  ::import::cvs::p
7710: 72 6f 6a 65 63 74 3a 3a 72 65 76 20 31 2e 30 0a  roject::rev 1.0.
7720: 72 65 74 75 72 6e 0a                             return.