Hex Artifact Content
Not logged in

Artifact f65b1a93225c7fb72288255df98d0065b6caf652:

File tools/cvs2fossil/lib/c2f_pbreakacycle.tcl part of check-in [a437da486d] - Added progress output to the breaking of backward branches. by aku on 2007-12-02 06:58:49.

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 50 61 73  ########..## Pas
0200: 73 20 49 58 2e 20 54 68 69 73 20 69 73 20 74 68  s IX. This is th
0210: 65 20 66 69 6e 61 6c 20 70 61 73 73 20 66 6f 72  e final pass for
0220: 20 62 72 65 61 6b 69 6e 67 20 63 68 61 6e 67 65   breaking change
0230: 73 65 74 20 64 65 70 65 6e 64 65 6e 63 79 0a 23  set dependency.#
0240: 23 20 63 79 63 6c 65 73 2e 20 54 68 65 20 70 72  # cycles. The pr
0250: 65 76 69 6f 75 73 20 62 72 65 61 6b 65 72 20 70  evious breaker p
0260: 61 73 73 65 73 20 28 36 20 61 6e 64 20 38 29 20  asses (6 and 8) 
0270: 62 72 6f 6b 65 20 63 79 63 6c 65 73 20 63 6f 76  broke cycles cov
0280: 65 72 69 6e 67 0a 23 23 20 72 65 76 69 73 69 6f  ering.## revisio
0290: 6e 20 61 6e 64 20 73 79 6d 62 6f 6c 20 63 68 61  n and symbol cha
02a0: 6e 67 65 73 65 74 73 2c 20 72 65 73 70 65 63 74  ngesets, respect
02b0: 69 76 65 6c 79 2e 20 54 68 69 73 20 70 61 73 73  ively. This pass
02c0: 20 6e 6f 77 20 62 72 65 61 6b 73 0a 23 23 20 61   now breaks.## a
02d0: 6e 79 20 72 65 6d 61 69 6e 69 6e 67 20 63 79 63  ny remaining cyc
02e0: 6c 65 73 2c 20 65 61 63 68 20 6f 66 20 77 68 69  les, each of whi
02f0: 63 68 20 68 61 73 20 74 6f 20 63 6f 6e 74 61 69  ch has to contai
0300: 6e 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 0a 23  n at least one.#
0310: 23 20 72 65 76 69 73 69 6f 6e 20 61 6e 64 20 61  # revision and a
0320: 74 20 6c 65 61 73 74 20 6f 6e 65 20 73 79 6d 62  t least one symb
0330: 6f 6c 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 23  ol changeset...#
0340: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
0350: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0360: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
0370: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
0380: 52 65 71 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61  Requirements..pa
0390: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 54 63  ckage require Tc
03a0: 6c 20 38 2e 34 20 20 20 20 20 20 20 20 20 20 20  l 8.4           
03b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03c0: 20 20 20 20 20 20 20 20 3b 20 23 20 52 65 71 75          ; # Requ
03d0: 69 72 65 64 20 72 75 6e 74 69 6d 65 2e 0a 70 61  ired runtime..pa
03e0: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 73 6e  ckage require sn
03f0: 69 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20  it              
0400: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0410: 20 20 20 20 20 20 20 20 3b 20 23 20 4f 4f 20 73          ; # OO s
0420: 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67 65 20 72  ystem..package r
0430: 65 71 75 69 72 65 20 73 74 72 75 63 74 3a 3a 6c  equire struct::l
0440: 69 73 74 20 20 20 20 20 20 20 20 20 20 20 20 20  ist             
0450: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0460: 20 3b 20 23 20 48 69 67 68 65 72 20 6f 72 64 65   ; # Higher orde
0470: 72 20 6c 69 73 74 20 6f 70 65 72 61 74 69 6f 6e  r list operation
0480: 73 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69  s..package requi
0490: 72 65 20 73 74 72 75 63 74 3a 3a 73 65 74 20 20  re struct::set  
04a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
04b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23               ; #
04c0: 20 53 65 74 20 6f 70 65 72 61 74 69 6f 6e 73 2e   Set operations.
04d0: 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65  .package require
04e0: 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63   vc::tools::misc
04f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0500: 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 4d             ; # M
0510: 69 6e 2c 20 6d 61 78 2e 0a 70 61 63 6b 61 67 65  in, max..package
0520: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f   require vc::too
0530: 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20 20 20 20  ls::log         
0540: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0550: 20 20 20 3b 20 23 20 55 73 65 72 20 66 65 65 64     ; # User feed
0560: 62 61 63 6b 2e 0a 70 61 63 6b 61 67 65 20 72 65  back..package re
0570: 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a  quire vc::tools:
0580: 3a 74 72 6f 75 62 6c 65 20 20 20 20 20 20 20 20  :trouble        
0590: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
05a0: 3b 20 23 20 45 72 72 6f 72 20 72 65 70 6f 72 74  ; # Error report
05b0: 69 6e 67 2e 0a 70 61 63 6b 61 67 65 20 72 65 71  ing..package req
05c0: 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a  uire vc::fossil:
05d0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65  :import::cvs::re
05e0: 70 6f 73 69 74 6f 72 79 20 20 20 20 20 20 20 3b  pository       ;
05f0: 20 23 20 52 65 70 6f 73 69 74 6f 72 79 20 6d 61   # Repository ma
0600: 6e 61 67 65 6d 65 6e 74 2e 0a 70 61 63 6b 61 67  nagement..packag
0610: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f  e require vc::fo
0620: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
0630: 73 3a 3a 63 79 63 6c 65 62 72 65 61 6b 65 72 20  s::cyclebreaker 
0640: 20 20 20 20 3b 20 23 20 42 72 65 61 6b 69 6e 67      ; # Breaking
0650: 20 64 65 70 65 6e 64 65 6e 63 79 20 63 79 63 6c   dependency cycl
0660: 65 73 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75  es..package requ
0670: 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  ire vc::fossil::
0680: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61  import::cvs::sta
0690: 74 65 20 20 20 20 20 20 20 20 20 20 20 20 3b 20  te            ; 
06a0: 23 20 53 74 61 74 65 20 73 74 6f 72 61 67 65 2e  # State storage.
06b0: 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65  .package require
06c0: 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70   vc::fossil::imp
06d0: 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72  ort::cvs::integr
06e0: 69 74 79 20 20 20 20 20 20 20 20 3b 20 23 20 53  ity        ; # S
06f0: 74 61 74 65 20 69 6e 74 65 67 72 69 74 79 20 63  tate integrity c
0700: 68 65 63 6b 73 2e 0a 70 61 63 6b 61 67 65 20 72  hecks..package r
0710: 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69  equire vc::fossi
0720: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
0730: 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20 20 20 20  project::rev    
0740: 20 3b 20 23 20 50 72 6f 6a 65 63 74 20 6c 65 76   ; # Project lev
0750: 65 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 0a 23  el changesets..#
0760: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
0770: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0780: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
0790: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20  ############.## 
07a0: 52 65 67 69 73 74 65 72 20 74 68 65 20 70 61 73  Register the pas
07b0: 73 20 77 69 74 68 20 74 68 65 20 6d 61 6e 61 67  s with the manag
07c0: 65 6d 65 6e 74 0a 0a 76 63 3a 3a 66 6f 73 73 69  ement..vc::fossi
07d0: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
07e0: 70 61 73 73 20 64 65 66 69 6e 65 20 5c 0a 20 20  pass define \.  
07f0: 20 20 42 72 65 61 6b 41 6c 6c 43 73 65 74 43 79    BreakAllCsetCy
0800: 63 6c 65 73 20 5c 0a 20 20 20 20 7b 42 72 65 61  cles \.    {Brea
0810: 6b 20 52 65 6d 61 69 6e 69 6e 67 20 43 68 61 6e  k Remaining Chan
0820: 67 65 53 65 74 20 44 65 70 65 6e 64 65 6e 63 79  geSet Dependency
0830: 20 43 79 63 6c 65 73 7d 20 5c 0a 20 20 20 20 3a   Cycles} \.    :
0840: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70  :vc::fossil::imp
0850: 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a  ort::cvs::pass::
0860: 62 72 65 61 6b 61 63 79 63 6c 65 0a 0a 23 20 23  breakacycle..# #
0870: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
0880: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
0890: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
08a0: 23 23 23 23 23 23 23 23 23 23 0a 23 23 0a 0a 73  ##########.##..s
08b0: 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a  nit::type ::vc::
08c0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
08d0: 63 76 73 3a 3a 70 61 73 73 3a 3a 62 72 65 61 6b  cvs::pass::break
08e0: 61 63 79 63 6c 65 20 7b 0a 20 20 20 20 23 20 23  acycle {.    # #
08f0: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
0900: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
0910: 23 23 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c  ####.    ## Publ
0920: 69 63 20 41 50 49 0a 0a 20 20 20 20 74 79 70 65  ic API..    type
0930: 6d 65 74 68 6f 64 20 73 65 74 75 70 20 7b 7d 20  method setup {} 
0940: 7b 0a 09 23 20 44 65 66 69 6e 65 20 74 68 65 20  {..# Define the 
0950: 6e 61 6d 65 73 20 61 6e 64 20 73 74 72 75 63 74  names and struct
0960: 75 72 65 20 6f 66 20 74 68 65 20 70 65 72 73 69  ure of the persi
0970: 73 74 65 6e 74 20 73 74 61 74 65 20 6f 66 0a 09  stent state of..
0980: 23 20 74 68 69 73 20 70 61 73 73 2e 0a 0a 09 73  # this pass....s
0990: 74 61 74 65 20 72 65 61 64 69 6e 67 20 63 68 61  tate reading cha
09a0: 6e 67 65 73 65 74 0a 09 73 74 61 74 65 20 72 65  ngeset..state re
09b0: 61 64 69 6e 67 20 63 73 69 74 65 6d 0a 09 73 74  ading csitem..st
09c0: 61 74 65 20 72 65 61 64 69 6e 67 20 63 73 6f 72  ate reading csor
09d0: 64 65 72 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  der..return.    
09e0: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
09f0: 64 20 6c 6f 61 64 20 7b 7d 20 7b 0a 09 23 20 50  d load {} {..# P
0a00: 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65  ass manager inte
0a10: 72 66 61 63 65 2e 20 45 78 65 63 75 74 65 64 20  rface. Executed 
0a20: 74 6f 20 6c 6f 61 64 20 64 61 74 61 20 63 6f 6d  to load data com
0a30: 70 75 74 65 64 20 62 79 0a 09 23 20 74 68 69 73  puted by..# this
0a40: 20 70 61 73 73 20 69 6e 74 6f 20 6d 65 6d 6f 72   pass into memor
0a50: 79 20 77 68 65 6e 20 74 68 69 73 20 70 61 73 73  y when this pass
0a60: 20 69 73 20 73 6b 69 70 70 65 64 20 69 6e 73 74   is skipped inst
0a70: 65 61 64 20 6f 66 0a 09 23 20 65 78 65 63 75 74  ead of..# execut
0a80: 65 64 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ed...return.    
0a90: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f  }..    typemetho
0aa0: 64 20 72 75 6e 20 7b 7d 20 7b 0a 09 23 20 50 61  d run {} {..# Pa
0ab0: 73 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65 72  ss manager inter
0ac0: 66 61 63 65 2e 20 45 78 65 63 75 74 65 64 20 74  face. Executed t
0ad0: 6f 20 70 65 72 66 6f 72 6d 20 74 68 65 0a 09 23  o perform the..#
0ae0: 20 66 75 6e 63 74 69 6f 6e 61 6c 69 74 79 20 6f   functionality o
0af0: 66 20 74 68 65 20 70 61 73 73 2e 0a 0a 09 73 65  f the pass....se
0b00: 74 20 6c 65 6e 20 5b 73 74 72 69 6e 67 20 6c 65  t len [string le
0b10: 6e 67 74 68 20 5b 70 72 6f 6a 65 63 74 3a 3a 72  ngth [project::r
0b20: 65 76 20 6e 75 6d 5d 5d 0a 09 73 65 74 20 6d 79  ev num]]..set my
0b30: 61 74 66 6d 74 20 25 24 7b 6c 65 6e 7d 73 0a 09  atfmt %${len}s..
0b40: 69 6e 63 72 20 6c 65 6e 20 31 32 0a 09 73 65 74  incr len 12..set
0b50: 20 6d 79 63 73 66 6d 74 20 25 24 7b 6c 65 6e 7d   mycsfmt %${len}
0b60: 73 0a 0a 09 63 79 63 6c 65 62 72 65 61 6b 65 72  s...cyclebreaker
0b70: 20 70 72 65 63 6d 64 20 20 20 5b 6d 79 70 72 6f   precmd   [mypro
0b80: 63 20 42 72 65 61 6b 42 61 63 6b 77 61 72 64 5d  c BreakBackward]
0b90: 0a 09 63 79 63 6c 65 62 72 65 61 6b 65 72 20 73  ..cyclebreaker s
0ba0: 61 76 65 63 6d 64 20 20 5b 6d 79 70 72 6f 63 20  avecmd  [myproc 
0bb0: 4b 65 65 70 4f 72 64 65 72 5d 0a 0a 09 73 74 61  KeepOrder]...sta
0bc0: 74 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 7b  te transaction {
0bd0: 0a 09 20 20 20 20 4c 6f 61 64 43 6f 6d 6d 69 74  ..    LoadCommit
0be0: 4f 72 64 65 72 0a 09 20 20 20 20 63 79 63 6c 65  Order..    cycle
0bf0: 62 72 65 61 6b 65 72 20 72 75 6e 20 62 72 65 61  breaker run brea
0c00: 6b 2d 61 6c 6c 20 5b 6d 79 70 72 6f 63 20 43 68  k-all [myproc Ch
0c10: 61 6e 67 65 73 65 74 73 5d 0a 09 7d 0a 0a 09 72  angesets]..}...r
0c20: 65 70 6f 73 69 74 6f 72 79 20 70 72 69 6e 74 63  epository printc
0c30: 73 65 74 73 74 61 74 69 73 74 69 63 73 0a 09 69  setstatistics..i
0c40: 6e 74 65 67 72 69 74 79 20 63 68 61 6e 67 65 73  ntegrity changes
0c50: 65 74 73 20 5b 70 72 6f 6a 65 63 74 3a 3a 72 65  ets [project::re
0c60: 76 20 61 6c 6c 5d 0a 09 72 65 74 75 72 6e 0a 20  v all]..return. 
0c70: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65     }..    typeme
0c80: 74 68 6f 64 20 64 69 73 63 61 72 64 20 7b 7d 20  thod discard {} 
0c90: 7b 0a 09 23 20 50 61 73 73 20 6d 61 6e 61 67 65  {..# Pass manage
0ca0: 72 20 69 6e 74 65 72 66 61 63 65 2e 20 45 78 65  r interface. Exe
0cb0: 63 75 74 65 64 20 66 6f 72 20 61 6c 6c 20 70 61  cuted for all pa
0cc0: 73 73 65 73 20 61 66 74 65 72 20 74 68 65 0a 09  sses after the..
0cd0: 23 20 72 75 6e 20 70 61 73 73 65 73 2c 20 74 6f  # run passes, to
0ce0: 20 72 65 6d 6f 76 65 20 61 6c 6c 20 64 61 74 61   remove all data
0cf0: 20 6f 66 20 74 68 69 73 20 70 61 73 73 20 66 72   of this pass fr
0d00: 6f 6d 20 74 68 65 20 73 74 61 74 65 2c 0a 09 23  om the state,..#
0d10: 20 61 73 20 62 65 69 6e 67 20 6f 75 74 20 6f 66   as being out of
0d20: 20 64 61 74 65 2e 0a 09 72 65 74 75 72 6e 0a 20   date...return. 
0d30: 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23     }..    # # ##
0d40: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
0d50: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
0d60: 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72 6e 61  #.    ## Interna
0d70: 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20 20 70  l methods..    p
0d80: 72 6f 63 20 43 68 61 6e 67 65 73 65 74 73 20 7b  roc Changesets {
0d90: 7d 20 7b 20 70 72 6f 6a 65 63 74 3a 3a 72 65 76  } { project::rev
0da0: 20 61 6c 6c 20 7d 0a 0a 20 20 20 20 70 72 6f 63   all }..    proc
0db0: 20 4c 6f 61 64 43 6f 6d 6d 69 74 4f 72 64 65 72   LoadCommitOrder
0dc0: 20 7b 7d 20 7b 0a 09 3a 3a 76 61 72 69 61 62 6c   {} {..::variabl
0dd0: 65 20 6d 79 63 73 65 74 0a 09 3a 3a 76 61 72 69  e mycset..::vari
0de0: 61 62 6c 65 20 6d 79 72 65 76 69 73 69 6f 6e 63  able myrevisionc
0df0: 68 61 6e 67 65 73 65 74 73 0a 0a 09 73 74 61 74  hangesets...stat
0e00: 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 7b 0a  e transaction {.
0e10: 09 20 20 20 20 66 6f 72 65 61 63 68 20 7b 63 69  .    foreach {ci
0e20: 64 20 70 6f 73 7d 20 5b 73 74 61 74 65 20 72 75  d pos} [state ru
0e30: 6e 20 7b 20 53 45 4c 45 43 54 20 63 69 64 2c 20  n { SELECT cid, 
0e40: 70 6f 73 20 46 52 4f 4d 20 63 73 6f 72 64 65 72  pos FROM csorder
0e50: 20 7d 5d 20 7b 0a 09 09 73 65 74 20 63 73 65 74   }] {...set cset
0e60: 20 5b 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20 6f   [project::rev o
0e70: 66 20 24 63 69 64 5d 0a 09 09 24 63 73 65 74 20  f $cid]...$cset 
0e80: 73 65 74 70 6f 73 20 24 70 6f 73 0a 09 09 73 65  setpos $pos...se
0e90: 74 20 6d 79 63 73 65 74 28 24 70 6f 73 29 20 24  t mycset($pos) $
0ea0: 63 73 65 74 0a 09 09 6c 61 70 70 65 6e 64 20 6d  cset...lappend m
0eb0: 79 72 65 76 69 73 69 6f 6e 63 68 61 6e 67 65 73  yrevisionchanges
0ec0: 65 74 73 20 24 63 73 65 74 0a 09 20 20 20 20 7d  ets $cset..    }
0ed0: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ..}..return.    
0ee0: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23  }..    # # ## ##
0ef0: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23  # ##### ########
0f00: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a   #############..
0f10: 20 20 20 20 70 72 6f 63 20 42 72 65 61 6b 42 61      proc BreakBa
0f20: 63 6b 77 61 72 64 20 7b 67 72 61 70 68 7d 20 7b  ckward {graph} {
0f30: 0a 09 23 20 57 65 20 67 6f 20 6f 76 65 72 20 61  ..# We go over a
0f40: 6c 6c 20 62 72 61 6e 63 68 20 63 68 61 6e 67 65  ll branch change
0f50: 73 65 74 73 2c 20 69 2e 65 2e 20 74 68 65 20 63  sets, i.e. the c
0f60: 68 61 6e 67 65 73 65 74 73 0a 09 23 20 63 72 65  hangesets..# cre
0f70: 61 74 65 64 20 62 79 20 74 68 65 20 73 79 6d 62  ated by the symb
0f80: 6f 6c 73 20 77 68 69 63 68 20 61 72 65 20 74 72  ols which are tr
0f90: 61 6e 73 6c 61 74 65 64 20 61 73 20 62 72 61 6e  anslated as bran
0fa0: 63 68 65 73 2c 20 61 6e 64 0a 09 23 20 62 72 65  ches, and..# bre
0fb0: 61 6b 20 61 6e 79 20 77 68 69 63 68 20 61 72 65  ak any which are
0fc0: 20 27 62 61 63 6b 77 61 72 64 27 2c 20 77 68 69   'backward', whi
0fd0: 63 68 20 6d 65 61 6e 73 20 74 68 61 74 20 74 68  ch means that th
0fe0: 65 79 20 68 61 76 65 0a 09 23 20 61 74 20 6c 65  ey have..# at le
0ff0: 61 73 74 20 6f 6e 65 20 69 6e 63 6f 6d 69 6e 67  ast one incoming
1000: 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65   revision change
1010: 73 65 74 20 77 68 69 63 68 20 69 73 20 63 6f 6d  set which is com
1020: 6d 69 74 74 65 64 0a 09 23 20 61 66 74 65 72 20  mitted..# after 
1030: 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 6f 66 20  at least one of 
1040: 74 68 65 20 6f 75 74 67 6f 69 6e 67 20 72 65 76  the outgoing rev
1050: 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73  ision changesets
1060: 2c 20 70 65 72 0a 09 23 20 74 68 65 20 6f 72 64  , per..# the ord
1070: 65 72 20 63 6f 6d 70 75 74 65 64 20 69 6e 20 70  er computed in p
1080: 61 73 73 20 36 2e 20 49 6e 20 22 63 76 73 32 73  ass 6. In "cvs2s
1090: 76 6e 22 20 74 68 69 73 20 69 73 20 63 61 6c 6c  vn" this is call
10a0: 65 64 0a 09 23 20 22 72 65 74 72 6f 67 72 61 64  ed..# "retrograd
10b0: 65 22 2e 0a 0a 09 73 65 74 20 6e 20 30 0a 09 73  e"....set n 0..s
10c0: 65 74 20 6d 61 78 20 5b 6c 6c 65 6e 67 74 68 20  et max [llength 
10d0: 5b 24 67 72 61 70 68 20 6e 6f 64 65 73 5d 5d 0a  [$graph nodes]].
10e0: 09 66 6f 72 65 61 63 68 20 63 73 65 74 20 5b 24  .foreach cset [$
10f0: 67 72 61 70 68 20 6e 6f 64 65 73 5d 20 7b 0a 09  graph nodes] {..
1100: 20 20 20 20 6c 6f 67 20 70 72 6f 67 72 65 73 73      log progress
1110: 20 32 20 62 72 65 61 6b 61 63 79 63 6c 65 20 24   2 breakacycle $
1120: 6e 20 24 6d 61 78 20 3b 20 69 6e 63 72 20 6e 0a  n $max ; incr n.
1130: 09 20 20 20 20 69 66 20 7b 21 5b 24 63 73 65 74  .    if {![$cset
1140: 20 69 73 62 72 61 6e 63 68 5d 7d 20 63 6f 6e 74   isbranch]} cont
1150: 69 6e 75 65 0a 09 20 20 20 20 43 68 65 63 6b 41  inue..    CheckA
1160: 6e 64 42 72 65 61 6b 42 61 63 6b 77 61 72 64 20  ndBreakBackward 
1170: 24 67 72 61 70 68 20 24 63 73 65 74 0a 09 7d 0a  $graph $cset..}.
1180: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
1190: 20 20 20 70 72 6f 63 20 43 68 65 63 6b 41 6e 64     proc CheckAnd
11a0: 42 72 65 61 6b 42 61 63 6b 77 61 72 64 20 7b 67  BreakBackward {g
11b0: 72 61 70 68 20 63 73 65 74 7d 20 7b 0a 09 77 68  raph cset} {..wh
11c0: 69 6c 65 20 7b 5b 49 73 42 61 63 6b 77 61 72 64  ile {[IsBackward
11d0: 20 24 67 72 61 70 68 20 24 63 73 65 74 5d 7d 20   $graph $cset]} 
11e0: 7b 0a 09 20 20 20 20 23 20 4b 6e 6f 77 69 6e 67  {..    # Knowing
11f0: 20 74 68 61 74 20 74 68 65 20 62 72 61 6e 63 68   that the branch
1200: 20 63 68 61 6e 67 65 73 65 74 20 69 73 20 62 61   changeset is ba
1210: 63 6b 77 61 72 64 20 77 65 20 6e 6f 77 0a 09 20  ckward we now.. 
1220: 20 20 20 23 20 6c 6f 6f 6b 20 61 74 20 74 68 65     # look at the
1230: 20 69 6e 64 69 76 69 64 75 61 6c 20 62 72 61 6e   individual bran
1240: 63 68 65 73 20 69 6e 20 74 68 65 20 63 68 61 6e  ches in the chan
1250: 67 65 73 65 74 20 61 6e 64 0a 09 20 20 20 20 23  geset and..    #
1260: 20 64 65 74 65 72 6d 69 6e 65 20 77 68 69 63 68   determine which
1270: 20 6f 66 20 74 68 65 6d 20 61 72 65 20 72 65 73   of them are res
1280: 70 6f 6e 73 69 62 6c 65 20 66 6f 72 20 74 68 65  ponsible for the
1290: 0a 09 20 20 20 20 23 20 6f 76 65 72 6c 61 70 2e  ..    # overlap.
12a0: 20 54 68 69 73 20 61 6c 6c 6f 77 73 20 75 73 20   This allows us 
12b0: 74 6f 20 73 70 6c 69 74 20 74 68 65 6d 20 69 6e  to split them in
12c0: 74 6f 20 74 77 6f 20 73 65 74 73 2c 20 6f 6e 65  to two sets, one
12d0: 0a 09 20 20 20 20 23 20 6f 66 20 6e 6f 6e 2d 6f  ..    # of non-o
12e0: 76 65 72 6c 61 70 70 69 6e 67 20 62 72 61 6e 63  verlapping branc
12f0: 68 65 73 2c 20 61 6e 64 20 6f 66 20 6f 76 65 72  hes, and of over
1300: 6c 61 70 70 69 6e 67 0a 09 20 20 20 20 23 20 6f  lapping..    # o
1310: 6e 65 73 2e 20 45 61 63 68 20 73 65 74 20 69 6e  nes. Each set in
1320: 64 75 63 65 73 20 61 20 6e 65 77 20 63 68 61 6e  duces a new chan
1330: 67 65 73 65 74 2c 20 61 6e 64 20 74 68 65 20 73  geset, and the s
1340: 65 63 6f 6e 64 0a 09 20 20 20 20 23 20 6f 6e 65  econd..    # one
1350: 20 6d 61 79 20 73 74 69 6c 6c 20 62 65 20 62 61   may still be ba
1360: 63 6b 77 61 72 64 20 61 6e 64 20 69 6e 20 6e 65  ckward and in ne
1370: 65 64 20 6f 66 20 66 75 72 74 68 65 72 0a 09 20  ed of further.. 
1380: 20 20 20 23 20 73 70 6c 69 74 74 69 6e 67 2e 20     # splitting. 
1390: 48 65 6e 63 65 20 74 68 65 20 6c 6f 6f 70 69 6e  Hence the loopin
13a0: 67 2e 0a 09 20 20 20 20 23 0a 09 20 20 20 20 23  g...    #..    #
13b0: 20 54 68 65 20 62 6f 72 64 65 72 20 75 73 65 64   The border used
13c0: 20 66 6f 72 20 74 68 65 20 73 70 6c 69 74 20 69   for the split i
13d0: 73 20 74 68 65 20 6d 69 6e 69 6d 61 6c 20 63 6f  s the minimal co
13e0: 6d 6d 69 74 0a 09 20 20 20 20 23 20 70 6f 73 69  mmit..    # posi
13f0: 74 69 6f 6e 20 61 6d 6f 6e 67 20 74 68 65 20 6d  tion among the m
1400: 69 6e 69 6d 61 6c 20 73 75 63 65 73 73 6f 72 20  inimal sucessor 
1410: 63 6f 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e 73  commit positions
1420: 20 66 6f 72 0a 09 20 20 20 20 23 20 74 68 65 20   for..    # the 
1430: 62 72 61 6e 63 68 65 73 20 69 6e 20 74 68 65 20  branches in the 
1440: 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 20 20 20  changeset....   
1450: 20 23 20 4e 6f 74 65 20 74 68 61 74 20 69 6e 64   # Note that ind
1460: 69 76 69 64 75 61 6c 20 62 72 61 6e 63 68 65 73  ividual branches
1470: 20 6d 61 79 20 6e 6f 74 20 68 61 76 65 20 63 68   may not have ch
1480: 61 6e 67 65 73 65 74 73 0a 09 20 20 20 20 23 20  angesets..    # 
1490: 77 68 69 63 68 20 61 72 65 20 74 68 65 69 72 20  which are their 
14a0: 70 72 65 64 65 63 65 73 73 6f 72 73 20 61 6e 64  predecessors and
14b0: 2f 6f 72 20 73 75 63 63 65 73 73 6f 72 73 2c 20  /or successors, 
14c0: 6c 65 61 76 69 6e 67 0a 09 20 20 20 20 23 20 74  leaving..    # t
14d0: 68 65 20 6c 69 6d 69 74 73 20 70 61 72 74 69 61  he limits partia
14e0: 6c 6c 79 20 6f 72 20 63 6f 6d 70 6c 65 74 65 6c  lly or completel
14f0: 79 20 75 6e 64 65 66 69 6e 65 64 2e 0a 0a 09 20  y undefined.... 
1500: 20 20 20 23 20 6c 69 6d 69 74 73 20 3a 20 64 69     # limits : di
1510: 63 74 20 28 72 65 76 69 73 69 6f 6e 20 2d 3e 20  ct (revision -> 
1520: 6c 69 73 74 20 28 6d 61 78 20 70 72 65 64 65 63  list (max predec
1530: 65 73 73 6f 72 20 63 6f 6d 6d 69 74 2c 20 6d 69  essor commit, mi
1540: 6e 20 73 75 63 65 73 73 6f 72 20 63 6f 6d 6d 69  n sucessor commi
1550: 74 29 29 0a 0a 09 20 20 20 20 43 6f 6d 70 75 74  t))...    Comput
1560: 65 4c 69 6d 69 74 73 20 24 63 73 65 74 20 6c 69  eLimits $cset li
1570: 6d 69 74 73 20 62 6f 72 64 65 72 0a 0a 09 20 20  mits border...  
1580: 20 20 6c 6f 67 20 77 72 69 74 65 20 35 20 62 72    log write 5 br
1590: 65 61 6b 61 63 79 63 6c 65 20 22 42 72 65 61 6b  eakacycle "Break
15a0: 69 6e 67 20 62 61 63 6b 77 61 72 64 20 63 68 61  ing backward cha
15b0: 6e 67 65 73 65 74 20 5b 24 63 73 65 74 20 73 74  ngeset [$cset st
15c0: 72 5d 20 77 69 74 68 20 63 6f 6d 6d 69 74 20 70  r] with commit p
15d0: 6f 73 69 74 69 6f 6e 20 24 62 6f 72 64 65 72 20  osition $border 
15e0: 61 73 20 62 6f 72 64 65 72 22 0a 0a 09 20 20 20  as border"...   
15f0: 20 23 20 53 65 63 6f 6e 64 6c 79 20 77 65 20 73   # Secondly we s
1600: 6f 72 74 20 74 68 65 20 66 69 6c 65 20 6c 65 76  ort the file lev
1610: 65 6c 20 69 74 65 6d 73 20 62 61 73 65 64 20 6f  el items based o
1620: 6e 20 74 68 65 72 65 0a 09 20 20 20 20 23 20 74  n there..    # t
1630: 68 65 79 20 73 69 74 20 72 65 6c 61 74 69 76 65  hey sit relative
1640: 20 74 6f 20 74 68 65 20 62 6f 72 64 65 72 20 69   to the border i
1650: 6e 74 6f 20 62 65 66 6f 72 65 20 61 6e 64 20 61  nto before and a
1660: 66 74 65 72 0a 09 20 20 20 20 23 20 74 68 65 20  fter..    # the 
1670: 62 6f 72 64 65 72 2e 0a 0a 09 20 20 20 20 53 70  border....    Sp
1680: 6c 69 74 49 74 65 6d 73 20 24 6c 69 6d 69 74 73  litItems $limits
1690: 20 24 62 6f 72 64 65 72 20 6e 6f 72 6d 61 6c 69   $border normali
16a0: 74 65 6d 73 20 62 61 63 6b 77 61 72 64 69 74 65  tems backwardite
16b0: 6d 73 0a 0a 09 20 20 20 20 73 65 74 20 72 65 70  ms...    set rep
16c0: 6c 61 63 65 6d 65 6e 74 73 20 5b 70 72 6f 6a 65  lacements [proje
16d0: 63 74 3a 3a 72 65 76 20 73 70 6c 69 74 20 24 63  ct::rev split $c
16e0: 73 65 74 20 24 6e 6f 72 6d 61 6c 69 74 65 6d 73  set $normalitems
16f0: 20 24 62 61 63 6b 77 61 72 64 69 74 65 6d 73 5d   $backwarditems]
1700: 0a 09 20 20 20 20 63 79 63 6c 65 62 72 65 61 6b  ..    cyclebreak
1710: 65 72 20 72 65 70 6c 61 63 65 20 24 67 72 61 70  er replace $grap
1720: 68 20 24 63 73 65 74 20 24 72 65 70 6c 61 63 65  h $cset $replace
1730: 6d 65 6e 74 73 0a 0a 09 20 20 20 20 23 20 41 74  ments...    # At
1740: 20 6c 61 73 74 20 63 68 65 63 6b 20 74 68 61 74   last check that
1750: 20 74 68 65 20 6e 6f 72 6d 61 6c 20 66 72 61 6d   the normal fram
1760: 65 6e 74 20 69 73 20 69 6e 64 65 65 64 20 6e 6f  ent is indeed no
1770: 74 0a 09 20 20 20 20 23 20 62 61 63 6b 77 61 72  t..    # backwar
1780: 64 2c 20 61 6e 64 20 69 74 65 72 61 74 65 20 6f  d, and iterate o
1790: 76 65 72 20 74 68 65 20 70 6f 73 73 69 62 6c 79  ver the possibly
17a0: 20 73 74 69 6c 6c 20 62 61 63 6b 77 61 72 64 0a   still backward.
17b0: 09 20 20 20 20 23 20 73 65 63 6f 6e 64 20 66 72  .    # second fr
17c0: 61 67 6d 65 6e 74 2e 0a 0a 09 20 20 20 20 73 74  agment....    st
17d0: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
17e0: 6e 20 24 72 65 70 6c 61 63 65 6d 65 6e 74 73 20  n $replacements 
17f0: 6e 6f 72 6d 61 6c 20 62 61 63 6b 77 61 72 64 0a  normal backward.
1800: 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61  .    integrity a
1810: 73 73 65 72 74 20 7b 0a 09 09 21 5b 49 73 42 61  ssert {...![IsBa
1820: 63 6b 77 61 72 64 20 24 67 72 61 70 68 20 24 6e  ckward $graph $n
1830: 6f 72 6d 61 6c 5d 0a 09 20 20 20 20 7d 20 7b 54  ormal]..    } {T
1840: 68 65 20 6e 6f 72 6d 61 6c 20 66 72 61 67 6d 65  he normal fragme
1850: 6e 74 20 69 73 20 75 6e 65 78 70 65 63 74 65 64  nt is unexpected
1860: 6c 79 20 62 61 63 6b 77 61 72 64 7d 0a 0a 09 20  ly backward}... 
1870: 20 20 20 73 65 74 20 63 73 65 74 20 24 62 61 63     set cset $bac
1880: 6b 77 61 72 64 0a 09 7d 0a 09 72 65 74 75 72 6e  kward..}..return
1890: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63  .    }..    proc
18a0: 20 49 73 42 61 63 6b 77 61 72 64 20 7b 64 67 20   IsBackward {dg 
18b0: 63 73 65 74 7d 20 7b 0a 09 23 20 41 20 62 72 61  cset} {..# A bra
18c0: 6e 63 68 20 69 73 20 22 62 61 63 6b 77 61 72 64  nch is "backward
18d0: 22 20 69 66 20 69 74 20 68 61 73 20 61 74 20 6c  " if it has at l
18e0: 65 61 73 74 20 6f 6e 65 20 69 6e 63 6f 6d 69 6e  east one incomin
18f0: 67 0a 09 23 20 72 65 76 69 73 69 6f 6e 20 63 68  g..# revision ch
1900: 61 6e 67 65 73 65 74 20 77 68 69 63 68 20 69 73  angeset which is
1910: 20 63 6f 6d 6d 69 74 74 65 64 20 61 66 74 65 72   committed after
1920: 20 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 6f 66   at least one of
1930: 0a 09 23 20 74 68 65 20 6f 75 74 67 6f 69 6e 67  ..# the outgoing
1940: 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65   revision change
1950: 73 65 74 73 2c 20 70 65 72 20 74 68 65 20 6f 72  sets, per the or
1960: 64 65 72 20 63 6f 6d 70 75 74 65 64 20 62 79 0a  der computed by.
1970: 09 23 20 70 61 73 73 20 36 2e 0a 0a 09 23 20 52  .# pass 6....# R
1980: 65 70 68 72 61 73 65 64 2c 20 74 68 65 20 6d 61  ephrased, the ma
1990: 78 69 6d 61 6c 20 63 6f 6d 6d 69 74 20 70 6f 73  ximal commit pos
19a0: 69 74 69 6f 6e 20 66 6f 75 6e 64 20 61 6d 6f 6e  ition found amon
19b0: 67 20 74 68 65 0a 09 23 20 69 6e 63 6f 6d 69 6e  g the..# incomin
19c0: 67 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67  g revision chang
19d0: 65 73 65 74 73 20 69 73 20 6c 61 72 67 65 72 20  esets is larger 
19e0: 74 68 61 6e 20 74 68 65 20 6d 69 6e 69 6d 61 6c  than the minimal
19f0: 0a 09 23 20 63 6f 6d 6d 69 74 20 70 6f 73 69 74  ..# commit posit
1a00: 69 6f 6e 20 66 6f 75 6e 64 20 61 6d 6f 6e 67 20  ion found among 
1a10: 74 68 65 20 6f 75 74 67 6f 69 6e 67 20 72 65 76  the outgoing rev
1a20: 69 73 69 6f 6e 0a 09 23 20 63 68 61 6e 67 65 73  ision..# changes
1a30: 65 74 73 2e 20 41 73 73 75 6d 69 6e 67 20 74 68  ets. Assuming th
1a40: 61 74 20 77 65 20 68 61 76 65 20 62 6f 74 68 20  at we have both 
1a50: 69 6e 63 6f 6d 69 6e 67 20 61 6e 64 20 6f 75 74  incoming and out
1a60: 67 6f 69 6e 67 0a 09 23 20 72 65 76 69 73 69 6f  going..# revisio
1a70: 6e 20 63 68 61 6e 67 65 73 65 74 73 20 66 6f 72  n changesets for
1a80: 20 74 68 65 20 62 72 61 6e 63 68 2e 0a 0a 09 23   the branch....#
1a90: 20 54 68 65 20 68 65 6c 70 65 72 20 22 50 6f 73   The helper "Pos
1aa0: 69 74 69 6f 6e 73 22 20 63 6f 6d 70 75 74 65 73  itions" computes
1ab0: 20 74 68 65 20 73 65 74 20 6f 66 20 63 6f 6d 6d   the set of comm
1ac0: 69 74 20 70 6f 73 69 74 69 6f 6e 73 0a 09 23 20  it positions..# 
1ad0: 66 6f 72 20 61 20 73 65 74 20 6f 66 20 63 68 61  for a set of cha
1ae0: 6e 67 65 73 65 74 73 2c 20 77 68 69 63 68 20 63  ngesets, which c
1af0: 61 6e 20 62 65 20 61 20 6d 69 78 20 6f 66 20 72  an be a mix of r
1b00: 65 76 69 73 69 6f 6e 20 61 6e 64 0a 09 23 20 73  evision and..# s
1b10: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73  ymbol changesets
1b20: 2e 0a 0a 09 73 65 74 20 70 72 65 64 65 63 65 73  ....set predeces
1b30: 73 6f 72 73 20 5b 50 6f 73 69 74 69 6f 6e 73 20  sors [Positions 
1b40: 5b 24 64 67 20 6e 6f 64 65 73 20 2d 69 6e 20 20  [$dg nodes -in  
1b50: 24 63 73 65 74 5d 5d 0a 09 73 65 74 20 73 75 63  $cset]]..set suc
1b60: 63 65 73 73 6f 72 73 20 20 20 5b 50 6f 73 69 74  cessors   [Posit
1b70: 69 6f 6e 73 20 5b 24 64 67 20 6e 6f 64 65 73 20  ions [$dg nodes 
1b80: 2d 6f 75 74 20 24 63 73 65 74 5d 5d 0a 0a 09 72  -out $cset]]...r
1b90: 65 74 75 72 6e 20 5b 65 78 70 72 20 7b 0a 09 09  eturn [expr {...
1ba0: 20 20 20 20 20 20 5b 6c 6c 65 6e 67 74 68 20 24        [llength $
1bb0: 70 72 65 64 65 63 65 73 73 6f 72 73 5d 20 26 26  predecessors] &&
1bc0: 0a 09 09 20 20 20 20 20 20 5b 6c 6c 65 6e 67 74  ...      [llengt
1bd0: 68 20 24 73 75 63 63 65 73 73 6f 72 73 5d 20 20  h $successors]  
1be0: 20 26 26 0a 09 09 20 20 20 20 20 20 28 5b 6d 61   &&...      ([ma
1bf0: 78 20 24 70 72 65 64 65 63 65 73 73 6f 72 73 5d  x $predecessors]
1c00: 20 3e 3d 20 5b 6d 69 6e 20 24 73 75 63 63 65 73   >= [min $succes
1c10: 73 6f 72 73 5d 29 0a 09 09 20 20 7d 5d 0a 20 20  sors])...  }].  
1c20: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 6f    }..    proc Po
1c30: 73 69 74 69 6f 6e 73 20 7b 63 68 61 6e 67 65 73  sitions {changes
1c40: 65 74 73 7d 20 7b 0a 09 23 20 54 6f 20 63 6f 6d  ets} {..# To com
1c50: 70 75 74 65 20 74 68 65 20 73 65 74 20 6f 66 20  pute the set of 
1c60: 63 6f 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e 73  commit positions
1c70: 20 66 72 6f 6d 20 74 68 65 20 73 65 74 20 6f 66   from the set of
1c80: 0a 09 23 20 63 68 61 6e 67 65 73 65 74 73 20 77  ..# changesets w
1c90: 65 20 66 69 72 73 74 20 6d 61 70 20 65 61 63 68  e first map each
1ca0: 20 63 68 61 6e 67 65 73 65 74 20 74 6f 20 69 74   changeset to it
1cb0: 73 20 70 6f 73 69 74 69 6f 6e 20 28 2a 29 0a 09  s position (*)..
1cc0: 23 20 61 6e 64 20 74 68 65 6e 20 66 69 6c 74 65  # and then filte
1cd0: 72 20 6f 75 74 20 74 68 65 20 69 6e 76 61 6c 69  r out the invali
1ce0: 64 20 72 65 73 70 6f 6e 73 65 73 20 28 74 68 65  d responses (the
1cf0: 20 65 6d 70 74 79 20 73 74 72 69 6e 67 29 0a 09   empty string)..
1d00: 23 20 72 65 74 75 72 6e 65 64 20 62 79 20 74 68  # returned by th
1d10: 65 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73  e symbol changes
1d20: 65 74 73 2e 0a 09 23 0a 09 23 20 28 2a 29 20 54  ets...#..# (*) T
1d30: 68 69 73 20 64 61 74 61 20 77 61 73 20 6c 6f 61  his data was loa
1d40: 64 65 64 20 69 6e 74 6f 20 6d 65 6d 6f 72 79 20  ded into memory 
1d50: 65 61 72 6c 69 72 20 69 6e 20 74 68 65 20 70 61  earlir in the pa
1d60: 73 73 2c 20 62 79 0a 09 23 20 20 20 20 20 4c 6f  ss, by..#     Lo
1d70: 61 64 43 6f 6d 6d 69 74 4f 72 64 65 72 2e 0a 0a  adCommitOrder...
1d80: 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a  .return [struct:
1d90: 3a 6c 69 73 74 20 66 69 6c 74 65 72 20 5b 73 74  :list filter [st
1da0: 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24  ruct::list map $
1db0: 63 68 61 6e 67 65 73 65 74 73 20 5c 0a 09 09 09  changesets \....
1dc0: 09 09 20 5b 6d 79 70 72 6f 63 20 54 6f 50 6f 73  .. [myproc ToPos
1dd0: 69 74 69 6f 6e 5d 5d 20 5c 0a 09 09 20 20 20 20  ition]] \...    
1de0: 5b 6d 79 70 72 6f 63 20 56 61 6c 69 64 50 6f 73  [myproc ValidPos
1df0: 69 74 69 6f 6e 5d 5d 0a 20 20 20 20 7d 0a 0a 20  ition]].    }.. 
1e00: 20 20 20 70 72 6f 63 20 54 6f 50 6f 73 69 74 69     proc ToPositi
1e10: 6f 6e 20 20 20 20 7b 63 73 65 74 7d 20 7b 20 24  on    {cset} { $
1e20: 63 73 65 74 20 70 6f 73 20 7d 0a 20 20 20 20 70  cset pos }.    p
1e30: 72 6f 63 20 56 61 6c 69 64 50 6f 73 69 74 69 6f  roc ValidPositio
1e40: 6e 20 7b 70 6f 73 7d 20 20 7b 20 65 78 70 72 20  n {pos}  { expr 
1e50: 7b 24 70 6f 73 20 6e 65 20 22 22 7d 20 7d 0a 0a  {$pos ne ""} }..
1e60: 20 20 20 20 70 72 6f 63 20 43 6f 6d 70 75 74 65      proc Compute
1e70: 4c 69 6d 69 74 73 20 7b 63 73 65 74 20 6c 76 20  Limits {cset lv 
1e80: 62 76 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24  bv} {..upvar 1 $
1e90: 6c 76 20 74 68 65 6c 69 6d 69 74 73 20 24 62 76  lv thelimits $bv
1ea0: 20 62 6f 72 64 65 72 0a 0a 09 23 20 49 6e 69 74   border...# Init
1eb0: 69 61 6c 69 7a 65 20 74 68 65 20 62 6f 75 6e 64  ialize the bound
1ec0: 61 72 69 65 73 20 66 6f 72 20 61 6c 6c 20 69 74  aries for all it
1ed0: 65 6d 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 74  ems....array set
1ee0: 20 6c 69 6d 69 74 73 20 7b 7d 0a 09 66 6f 72 65   limits {}..fore
1ef0: 61 63 68 20 72 65 76 69 73 69 6f 6e 20 5b 24 63  ach revision [$c
1f00: 73 65 74 20 69 74 65 6d 73 5d 20 7b 0a 09 20 20  set items] {..  
1f10: 20 20 73 65 74 20 6c 69 6d 69 74 73 28 24 72 65    set limits($re
1f20: 76 69 73 69 6f 6e 29 20 7b 30 20 7b 7d 7d 0a 09  vision) {0 {}}..
1f30: 7d 0a 0a 09 23 20 43 6f 6d 70 75 74 65 20 61 6e  }...# Compute an
1f40: 64 20 73 74 6f 72 65 20 74 68 65 20 6d 61 78 69  d store the maxi
1f50: 6d 61 6c 20 70 72 65 64 65 63 65 73 73 6f 72 73  mal predecessors
1f60: 20 70 65 72 20 69 74 65 6d 20 28 62 72 61 6e 63   per item (branc
1f70: 68 29 0a 0a 09 66 6f 72 65 61 63 68 20 7b 69 74  h)...foreach {it
1f80: 65 6d 20 63 73 65 74 73 7d 20 5b 24 63 73 65 74  em csets} [$cset
1f90: 20 70 72 65 64 65 63 65 73 73 6f 72 6d 61 70 5d   predecessormap]
1fa0: 20 7b 0a 09 20 20 20 20 73 65 74 20 73 20 5b 50   {..    set s [P
1fb0: 6f 73 69 74 69 6f 6e 73 20 24 63 73 65 74 73 5d  ositions $csets]
1fc0: 0a 09 20 20 20 20 69 66 20 7b 21 5b 6c 6c 65 6e  ..    if {![llen
1fd0: 67 74 68 20 24 73 5d 7d 20 63 6f 6e 74 69 6e 75  gth $s]} continu
1fe0: 65 0a 09 20 20 20 20 73 65 74 20 6c 69 6d 69 74  e..    set limit
1ff0: 73 28 24 69 74 65 6d 29 20 5b 6c 72 65 70 6c 61  s($item) [lrepla
2000: 63 65 20 24 6c 69 6d 69 74 73 28 24 69 74 65 6d  ce $limits($item
2010: 29 20 30 20 30 20 5b 6d 61 78 20 24 73 5d 5d 0a  ) 0 0 [max $s]].
2020: 09 7d 0a 0a 09 23 20 43 6f 6d 70 75 74 65 20 61  .}...# Compute a
2030: 6e 64 20 73 74 6f 72 65 20 74 68 65 20 6d 69 6e  nd store the min
2040: 69 6d 61 6c 20 73 75 63 63 65 73 73 6f 72 73 20  imal successors 
2050: 70 65 72 20 69 74 65 6d 20 28 62 72 61 6e 63 68  per item (branch
2060: 29 0a 0a 09 66 6f 72 65 61 63 68 20 7b 69 74 65  )...foreach {ite
2070: 6d 20 63 73 65 74 73 7d 20 5b 24 63 73 65 74 20  m csets} [$cset 
2080: 73 75 63 63 65 73 73 6f 72 6d 61 70 5d 20 7b 0a  successormap] {.
2090: 09 20 20 20 20 73 65 74 20 73 20 5b 50 6f 73 69  .    set s [Posi
20a0: 74 69 6f 6e 73 20 24 63 73 65 74 73 5d 0a 09 20  tions $csets].. 
20b0: 20 20 20 69 66 20 7b 21 5b 6c 6c 65 6e 67 74 68     if {![llength
20c0: 20 24 73 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09   $s]} continue..
20d0: 20 20 20 20 73 65 74 20 6c 69 6d 69 74 73 28 24      set limits($
20e0: 69 74 65 6d 29 20 5b 6c 72 65 70 6c 61 63 65 20  item) [lreplace 
20f0: 24 6c 69 6d 69 74 73 28 24 69 74 65 6d 29 20 31  $limits($item) 1
2100: 20 31 20 5b 6d 69 6e 20 24 73 5d 5d 0a 09 7d 0a   1 [min $s]]..}.
2110: 0a 09 23 20 43 68 65 63 6b 20 74 68 61 74 20 74  ..# Check that t
2120: 68 65 20 6f 72 64 65 72 69 6e 67 20 61 74 20 74  he ordering at t
2130: 68 65 20 66 69 6c 65 20 6c 65 76 65 6c 20 69 73  he file level is
2140: 20 63 6f 72 72 65 63 74 2e 20 57 65 0a 09 23 20   correct. We..# 
2150: 63 61 6e 6e 6f 74 20 68 61 76 65 20 62 61 63 6b  cannot have back
2160: 77 61 72 64 20 6f 72 64 65 72 69 6e 67 20 70 65  ward ordering pe
2170: 72 20 62 72 61 6e 63 68 2c 20 6f 72 20 73 6f 6d  r branch, or som
2180: 65 74 68 69 6e 67 20 69 73 0a 09 23 20 77 72 6f  ething is..# wro
2190: 6e 67 2e 0a 0a 09 66 6f 72 65 61 63 68 20 69 74  ng....foreach it
21a0: 65 6d 20 5b 61 72 72 61 79 20 6e 61 6d 65 73 20  em [array names 
21b0: 6c 69 6d 69 74 73 5d 20 7b 0a 09 20 20 20 20 73  limits] {..    s
21c0: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69  truct::list assi
21d0: 67 6e 20 24 6c 69 6d 69 74 73 28 24 69 74 65 6d  gn $limits($item
21e0: 29 20 6d 61 78 70 20 6d 69 6e 73 0a 09 20 20 20  ) maxp mins..   
21f0: 20 23 20 48 61 6e 64 6c 65 20 6d 69 6e 20 73 75   # Handle min su
2200: 63 63 65 73 73 6f 72 20 70 6f 73 69 74 69 6f 6e  ccessor position
2210: 20 22 22 20 61 73 20 72 65 70 72 65 73 65 6e 74   "" as represent
2220: 69 6e 67 20 69 6e 66 69 6e 69 74 79 0a 09 20 20  ing infinity..  
2230: 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73 65    integrity asse
2240: 72 74 20 7b 0a 09 09 28 24 6d 69 6e 73 20 65 71  rt {...($mins eq
2250: 20 22 22 29 20 7c 7c 20 28 24 6d 61 78 70 20 3c   "") || ($maxp <
2260: 20 24 6d 69 6e 73 29 20 0a 09 20 20 20 20 7d 20   $mins) ..    } 
2270: 7b 49 74 65 6d 20 3c 24 69 74 65 6d 3e 20 69 73  {Item <$item> is
2280: 20 62 61 63 6b 77 61 72 64 20 61 74 20 66 69 6c   backward at fil
2290: 65 20 6c 65 76 65 6c 20 28 24 6d 61 78 70 20 3e  e level ($maxp >
22a0: 3d 20 24 6d 69 6e 73 29 7d 0a 09 7d 0a 0a 09 23  = $mins)}..}...#
22b0: 20 53 61 76 65 20 74 68 65 20 6c 69 6d 69 74 73   Save the limits
22c0: 20 66 6f 72 20 74 68 65 20 73 70 6c 69 74 74 65   for the splitte
22d0: 72 2c 20 61 6e 64 20 63 6f 6d 70 75 74 65 20 74  r, and compute t
22e0: 68 65 20 62 6f 72 64 65 72 20 61 74 0a 09 23 20  he border at..# 
22f0: 77 68 69 63 68 20 74 6f 20 73 70 6c 69 74 20 61  which to split a
2300: 73 20 74 68 65 20 6d 69 6e 69 6d 75 6d 20 6f 66  s the minimum of
2310: 20 61 6c 6c 20 6d 69 6e 69 6d 61 6c 20 73 75 63   all minimal suc
2320: 63 65 73 73 6f 72 0a 09 23 20 70 6f 73 69 74 69  cessor..# positi
2330: 6f 6e 73 2e 0a 0a 09 73 65 74 20 74 68 65 6c 69  ons....set theli
2340: 6d 69 74 73 20 5b 61 72 72 61 79 20 67 65 74 20  mits [array get 
2350: 6c 69 6d 69 74 73 5d 0a 09 73 65 74 20 62 6f 72  limits]..set bor
2360: 64 65 72 20 5b 6d 69 6e 20 5b 73 74 72 75 63 74  der [min [struct
2370: 3a 3a 6c 69 73 74 20 66 69 6c 74 65 72 20 5b 73  ::list filter [s
2380: 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20  truct::list map 
2390: 5b 56 61 6c 75 65 73 20 24 74 68 65 6c 69 6d 69  [Values $thelimi
23a0: 74 73 5d 20 5c 0a 09 09 09 09 09 09 20 20 5b 6d  ts] \.......  [m
23b0: 79 70 72 6f 63 20 4d 69 6e 53 75 63 63 65 73 73  yproc MinSuccess
23c0: 6f 72 50 6f 73 69 74 69 6f 6e 5d 5d 20 5c 0a 09  orPosition]] \..
23d0: 09 09 20 20 20 20 20 5b 6d 79 70 72 6f 63 20 56  ..     [myproc V
23e0: 61 6c 69 64 50 6f 73 69 74 69 6f 6e 5d 5d 5d 0a  alidPosition]]].
23f0: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20  .return.    }.. 
2400: 20 20 20 70 72 6f 63 20 56 61 6c 75 65 73 20 7b     proc Values {
2410: 64 69 63 74 7d 20 7b 0a 09 73 65 74 20 72 65 73  dict} {..set res
2420: 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b 6b 20   {}..foreach {k 
2430: 76 7d 20 24 64 69 63 74 20 7b 20 6c 61 70 70 65  v} $dict { lappe
2440: 6e 64 20 72 65 73 20 24 76 20 7d 0a 09 72 65 74  nd res $v }..ret
2450: 75 72 6e 20 24 72 65 73 0a 20 20 20 20 7d 0a 0a  urn $res.    }..
2460: 20 20 20 20 70 72 6f 63 20 4d 69 6e 53 75 63 63      proc MinSucc
2470: 65 73 73 6f 72 50 6f 73 69 74 69 6f 6e 20 7b 69  essorPosition {i
2480: 74 65 6d 7d 20 7b 20 6c 69 6e 64 65 78 20 24 69  tem} { lindex $i
2490: 74 65 6d 20 31 20 7d 0a 0a 20 20 20 20 70 72 6f  tem 1 }..    pro
24a0: 63 20 53 70 6c 69 74 49 74 65 6d 73 20 7b 6c 69  c SplitItems {li
24b0: 6d 69 74 73 20 62 6f 72 64 65 72 20 6e 76 20 62  mits border nv b
24c0: 76 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 6e  v} {..upvar 1 $n
24d0: 76 20 6e 6f 72 6d 61 6c 69 74 65 6d 73 20 24 62  v normalitems $b
24e0: 76 20 62 61 63 6b 77 61 72 64 69 74 65 6d 73 0a  v backwarditems.
24f0: 0a 09 73 65 74 20 6e 6f 72 6d 61 6c 69 74 65 6d  ..set normalitem
2500: 73 20 20 20 7b 7d 0a 09 73 65 74 20 62 61 63 6b  s   {}..set back
2510: 77 61 72 64 69 74 65 6d 73 20 7b 7d 0a 0a 09 66  warditems {}...f
2520: 6f 72 65 61 63 68 20 7b 72 65 76 20 76 7d 20 24  oreach {rev v} $
2530: 6c 69 6d 69 74 73 20 7b 0a 09 20 20 20 20 73 74  limits {..    st
2540: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67  ruct::list assig
2550: 6e 20 24 76 20 6d 61 78 70 20 6d 69 6e 73 0a 09  n $v maxp mins..
2560: 20 20 20 20 69 66 20 7b 24 6d 61 78 70 20 3e 3d      if {$maxp >=
2570: 20 24 62 6f 72 64 65 72 7d 20 7b 0a 09 09 6c 61   $border} {...la
2580: 70 70 65 6e 64 20 62 61 63 6b 77 61 72 64 69 74  ppend backwardit
2590: 65 6d 73 20 20 24 72 65 76 0a 09 20 20 20 20 7d  ems  $rev..    }
25a0: 20 65 6c 73 65 20 7b 0a 09 09 6c 61 70 70 65 6e   else {...lappen
25b0: 64 20 6e 6f 72 6d 61 6c 69 74 65 6d 73 20 24 72  d normalitems $r
25c0: 65 76 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69  ev..    }..}...i
25d0: 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20  ntegrity assert 
25e0: 7b 5b 6c 6c 65 6e 67 74 68 20 24 6e 6f 72 6d 61  {[llength $norma
25f0: 6c 69 74 65 6d 73 5d 7d 20 20 20 7b 53 65 74 20  litems]}   {Set 
2600: 6f 66 20 6e 6f 72 6d 61 6c 20 69 74 65 6d 73 20  of normal items 
2610: 69 73 20 65 6d 70 74 79 7d 0a 09 69 6e 74 65 67  is empty}..integ
2620: 72 69 74 79 20 61 73 73 65 72 74 20 7b 5b 6c 6c  rity assert {[ll
2630: 65 6e 67 74 68 20 24 62 61 63 6b 77 61 72 64 69  ength $backwardi
2640: 74 65 6d 73 5d 7d 20 7b 53 65 74 20 6f 66 20 62  tems]} {Set of b
2650: 61 63 6b 77 61 72 64 20 69 74 65 6d 73 20 69 73  ackward items is
2660: 20 65 6d 70 74 79 7d 0a 09 72 65 74 75 72 6e 0a   empty}..return.
2670: 20 20 20 20 7d 0a 0a 0a 20 20 20 20 23 20 23 20      }...    # # 
2680: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
2690: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
26a0: 23 23 23 0a 0a 20 20 20 20 70 72 6f 63 20 4b 65  ###..    proc Ke
26b0: 65 70 4f 72 64 65 72 20 7b 67 72 61 70 68 20 61  epOrder {graph a
26c0: 74 20 63 73 65 74 7d 20 7b 0a 09 3a 3a 76 61 72  t cset} {..::var
26d0: 69 61 62 6c 65 20 6d 79 61 74 66 6d 74 0a 09 3a  iable myatfmt..:
26e0: 3a 76 61 72 69 61 62 6c 65 20 6d 79 63 73 66 6d  :variable mycsfm
26f0: 74 0a 0a 09 73 65 74 20 63 69 64 20 5b 24 63 73  t...set cid [$cs
2700: 65 74 20 69 64 5d 0a 0a 09 6c 6f 67 20 77 72 69  et id]...log wri
2710: 74 65 20 38 20 62 72 65 61 6b 61 63 79 63 6c 65  te 8 breakacycle
2720: 20 22 43 68 61 6e 67 65 73 65 74 20 40 20 5b 66   "Changeset @ [f
2730: 6f 72 6d 61 74 20 24 6d 79 61 74 66 6d 74 20 24  ormat $myatfmt $
2740: 61 74 5d 3a 20 5b 66 6f 72 6d 61 74 20 24 6d 79  at]: [format $my
2750: 63 73 66 6d 74 20 5b 24 63 73 65 74 20 73 74 72  csfmt [$cset str
2760: 5d 5d 20 3c 3c 5b 46 6f 72 6d 61 74 54 52 20 24  ]] <<[FormatTR $
2770: 67 72 61 70 68 20 24 63 73 65 74 5d 3e 3e 22 0a  graph $cset]>>".
2780: 0a 09 23 20 57 65 20 73 65 65 20 68 65 72 65 20  ..# We see here 
2790: 61 20 6d 69 78 74 75 72 65 20 6f 66 20 73 79 6d  a mixture of sym
27a0: 62 6f 6c 20 61 6e 64 20 72 65 76 69 73 69 6f 6e  bol and revision
27b0: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 09 23 20   changesets...# 
27c0: 54 68 65 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67  The symbol chang
27d0: 65 73 65 74 73 20 61 72 65 20 69 67 6e 6f 72 65  esets are ignore
27e0: 64 20 61 73 20 69 72 72 65 6c 65 76 61 6e 74 2e  d as irrelevant.
27f0: 0a 0a 09 69 66 20 7b 5b 24 63 73 65 74 20 70 6f  ...if {[$cset po
2800: 73 5d 20 65 71 20 22 22 7d 20 72 65 74 75 72 6e  s] eq ""} return
2810: 0a 0a 09 23 20 46 6f 72 20 74 68 65 20 72 65 76  ...# For the rev
2820: 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73  ision changesets
2830: 20 77 65 20 61 72 65 20 73 75 72 65 20 74 68 61   we are sure tha
2840: 74 20 74 68 65 79 20 61 72 65 0a 09 23 20 63 6f  t they are..# co
2850: 6e 73 75 6d 65 64 20 69 6e 20 74 68 65 20 73 61  nsumed in the sa
2860: 6d 65 20 6f 72 64 65 72 20 61 73 20 67 65 6e 65  me order as gene
2870: 72 61 74 65 64 20 62 79 20 70 61 73 73 20 37 0a  rated by pass 7.
2880: 09 23 20 28 52 65 76 54 6f 70 6f 6c 6f 67 69 63  .# (RevTopologic
2890: 61 6c 53 6f 72 74 29 2e 20 50 65 72 20 74 68 65  alSort). Per the
28a0: 20 63 6f 64 65 20 69 6e 20 63 76 73 32 73 76 6e   code in cvs2svn
28b0: 2e 0a 0a 09 23 20 54 68 69 73 20 77 6f 72 6b 73  ....# This works
28c0: 20 69 66 20 61 6e 64 20 6f 6e 6c 79 20 69 66 20   if and only if 
28d0: 6e 6f 6e 65 20 6f 66 20 74 68 65 20 73 79 6d 62  none of the symb
28e0: 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 20 61 72  ol changesets ar
28f0: 65 0a 09 23 20 22 62 61 63 6b 77 61 72 64 73 22  e..# "backwards"
2900: 2c 20 68 65 6e 63 65 20 6f 75 72 20 62 72 65 61  , hence our brea
2910: 6b 69 6e 67 20 6f 66 20 74 68 65 20 62 61 63 6b  king of the back
2920: 77 61 72 64 20 63 68 61 6e 67 65 73 65 74 73 0a  ward changesets.
2930: 09 23 20 66 69 72 73 74 2c 20 69 6e 20 74 68 65  .# first, in the
2940: 20 70 72 65 2d 68 6f 6f 6b 2e 0a 0a 09 23 20 4e   pre-hook....# N
2950: 6f 74 65 20 74 68 61 74 20 74 61 68 20 63 68 61  ote that tah cha
2960: 6e 67 65 73 65 74 73 20 63 61 6e 6e 6f 74 20 62  ngesets cannot b
2970: 65 20 62 61 63 6b 77 61 72 64 20 61 73 20 74 68  e backward as th
2980: 65 79 20 64 6f 6e 27 74 0a 09 23 20 68 61 76 65  ey don't..# have
2990: 20 73 75 63 63 65 73 73 6f 72 73 20 61 74 20 61   successors at a
29a0: 6c 6c 2e 0a 0a 09 23 20 41 6e 20 69 6e 74 65 72  ll....# An inter
29b0: 65 73 74 69 6e 67 20 74 68 69 6e 67 20 49 4d 48  esting thing IMH
29c0: 4f 2c 20 69 73 20 74 68 61 74 20 61 66 74 65 72  O, is that after
29d0: 20 62 72 65 61 6b 69 6e 67 20 74 68 65 0a 09 23   breaking the..#
29e0: 20 62 61 63 6b 77 61 72 64 20 73 79 6d 62 6f 6c   backward symbol
29f0: 20 63 68 61 6e 67 65 73 65 74 73 20 77 65 20 73   changesets we s
2a00: 68 6f 75 6c 64 20 6e 6f 74 20 68 61 76 65 20 61  hould not have a
2a10: 6e 79 20 63 69 72 63 6c 65 73 0a 09 23 20 61 6e  ny circles..# an
2a20: 79 20 6c 6f 6e 67 65 72 2e 20 45 61 63 68 20 63  y longer. Each c
2a30: 69 72 63 6c 65 20 77 68 69 63 68 20 77 6f 75 6c  ircle which woul
2a40: 64 20 73 74 69 6c 6c 20 62 65 20 70 72 65 73 65  d still be prese
2a50: 6e 74 20 68 61 73 20 74 6f 0a 09 23 20 69 6e 76  nt has to..# inv
2a60: 6f 6c 76 65 20 61 20 62 61 63 6b 77 61 72 64 20  olve a backward 
2a70: 73 79 6d 62 6f 6c 2c 20 61 6e 64 20 77 65 20 73  symbol, and we s
2a80: 70 6c 69 74 20 74 68 65 6d 20 61 6c 6c 2c 20 73  plit them all, s
2a90: 6f 20 74 68 65 72 65 0a 09 23 20 63 61 6e 27 74  o there..# can't
2aa0: 20 62 65 20 61 20 63 69 72 63 6c 65 2e 2e 0a 0a   be a circle....
2ab0: 09 23 20 50 72 6f 6f 66 3a 0a 09 23 20 4c 65 74  .# Proof:..# Let
2ac0: 20 75 73 20 61 73 73 75 6d 65 20 77 65 20 74 68   us assume we th
2ad0: 61 74 20 68 61 76 65 20 61 20 63 69 72 63 6c 65  at have a circle
2ae0: 0a 09 23 20 09 43 3a 20 52 31 20 2d 3e 20 2e 2e  ..# .C: R1 -> ..
2af0: 2e 20 2d 3e 20 52 78 20 2d 3e 20 53 20 2d 3e 20  . -> Rx -> S -> 
2b00: 52 79 20 2d 3e 20 2e 2e 2e 20 2d 3e 20 52 6e 20  Ry -> ... -> Rn 
2b10: 2d 3e 20 52 31 0a 09 23 20 4c 65 74 20 75 73 20  -> R1..# Let us 
2b20: 66 75 72 74 68 65 72 20 61 73 73 75 6d 65 20 74  further assume t
2b30: 68 61 74 20 74 68 65 20 73 79 6d 62 6f 6c 20 63  hat the symbol c
2b40: 68 61 6e 67 65 73 65 74 20 53 20 69 6e 20 74 68  hangeset S in th
2b50: 61 74 0a 09 23 20 63 69 72 63 6c 65 20 69 73 20  at..# circle is 
2b60: 6e 6f 74 20 62 61 63 6b 77 61 72 64 2e 20 54 68  not backward. Th
2b70: 61 74 20 6d 65 61 6e 73 20 4f 52 44 28 52 78 29  at means ORD(Rx)
2b80: 20 3c 20 4f 52 44 28 52 79 29 2e 20 20 54 68 65   < ORD(Ry).  The
2b90: 0a 09 23 20 65 61 72 6c 69 65 72 20 74 6f 70 6f  ..# earlier topo
2ba0: 6c 6f 67 69 63 61 6c 20 73 6f 72 74 69 6e 67 20  logical sorting 
2bb0: 77 69 74 68 6f 75 74 20 73 79 6d 62 6f 6c 73 20  without symbols 
2bc0: 6e 6f 77 20 66 6f 72 63 65 73 20 74 68 69 73 0a  now forces this.
2bd0: 09 23 20 72 65 6c 61 74 69 6f 6e 73 68 69 70 20  .# relationship 
2be0: 74 68 72 6f 75 67 68 20 74 6f 20 62 65 20 4f 52  through to be OR
2bf0: 44 28 52 78 29 20 3c 20 4f 52 44 28 52 31 29 20  D(Rx) < ORD(R1) 
2c00: 3c 20 4f 52 44 28 52 78 29 2e 20 20 57 65 0a 09  < ORD(Rx).  We..
2c10: 23 20 68 61 76 65 20 72 65 61 63 68 65 64 20 61  # have reached a
2c20: 6e 20 69 6d 70 6f 73 73 69 62 69 6c 69 74 79 2c  n impossibility,
2c30: 20 61 20 70 61 72 61 64 6f 78 2e 20 4f 75 72 20   a paradox. Our 
2c40: 69 6e 69 74 69 61 6c 0a 09 23 20 61 73 73 75 6d  initial..# assum
2c50: 70 74 69 6f 6e 20 6f 66 20 53 20 6e 6f 74 20 62  ption of S not b
2c60: 65 69 6e 67 20 62 61 63 6b 77 61 72 64 20 63 61  eing backward ca
2c70: 6e 6e 6f 74 20 68 6f 6c 64 2e 0a 09 23 0a 09 23  nnot hold...#..#
2c80: 20 41 6c 74 65 72 6e 61 74 65 2c 20 64 69 72 65   Alternate, dire
2c90: 63 74 2c 20 72 65 61 73 6f 6e 69 6e 67 3a 20 57  ct, reasoning: W
2ca0: 69 74 68 6f 75 74 20 53 20 74 68 65 20 63 68 61  ithout S the cha
2cb0: 69 6e 20 6f 66 0a 09 23 20 64 65 70 65 6e 64 65  in of..# depende
2cc0: 6e 63 69 65 73 20 69 73 20 52 79 20 2d 3e 20 2e  ncies is Ry -> .
2cd0: 2e 20 2d 3e 20 52 31 20 2d 3e 20 2e 2e 20 2d 3e  . -> R1 -> .. ->
2ce0: 20 52 78 2c 20 74 68 65 72 65 66 6f 72 65 0a 09   Rx, therefore..
2cf0: 23 20 4f 52 44 28 52 79 29 20 3c 20 4f 52 44 28  # ORD(Ry) < ORD(
2d00: 52 78 29 20 68 6f 6c 64 73 2c 20 61 6e 64 20 74  Rx) holds, and t
2d10: 68 69 73 20 6d 65 61 6e 73 20 53 20 69 73 20 62  his means S is b
2d20: 61 63 6b 77 61 72 64 2e 0a 0a 09 73 74 72 75 63  ackward....struc
2d30: 74 3a 3a 73 65 74 20 65 78 63 6c 75 64 65 20 6d  t::set exclude m
2d40: 79 72 65 76 69 73 69 6f 6e 63 68 61 6e 67 65 73  yrevisionchanges
2d50: 65 74 73 20 24 63 73 65 74 0a 0a 09 3a 3a 76 61  ets $cset...::va
2d60: 72 69 61 62 6c 65 20 6d 79 6c 61 73 74 70 6f 73  riable mylastpos
2d70: 0a 09 73 65 74 20 6e 65 77 20 5b 24 63 73 65 74  ..set new [$cset
2d80: 20 70 6f 73 5d 0a 0a 09 69 66 20 7b 24 6e 65 77   pos]...if {$new
2d90: 20 21 3d 20 28 24 6d 79 6c 61 73 74 70 6f 73 20   != ($mylastpos 
2da0: 2b 20 31 29 7d 20 7b 0a 09 20 20 20 20 69 66 20  + 1)} {..    if 
2db0: 7b 24 6d 79 6c 61 73 74 70 6f 73 20 3c 20 30 7d  {$mylastpos < 0}
2dc0: 20 7b 0a 09 09 73 65 74 20 6f 6c 64 20 22 3c 4e   {...set old "<N
2dd0: 4f 4e 45 3e 22 0a 09 20 20 20 20 7d 20 65 6c 73  ONE>"..    } els
2de0: 65 20 7b 0a 09 09 3a 3a 76 61 72 69 61 62 6c 65  e {...::variable
2df0: 20 6d 79 63 73 65 74 0a 09 09 73 65 74 20 6f 6c   mycset...set ol
2e00: 64 20 5b 24 6d 79 63 73 65 74 28 24 6d 79 6c 61  d [$mycset($myla
2e10: 73 74 70 6f 73 29 20 73 74 72 5d 40 24 6d 79 6c  stpos) str]@$myl
2e20: 61 73 74 70 6f 73 0a 09 20 20 20 20 7d 0a 0a 09  astpos..    }...
2e30: 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73      integrity as
2e40: 73 65 72 74 20 30 20 7b 4f 72 64 65 72 69 6e 67  sert 0 {Ordering
2e50: 20 6f 66 20 72 65 76 69 73 69 6f 6e 20 63 68 61   of revision cha
2e60: 6e 67 65 73 65 74 73 20 76 69 6f 6c 61 74 65 64  ngesets violated
2e70: 2c 20 5b 24 63 73 65 74 20 73 74 72 5d 40 24 6e  , [$cset str]@$n
2e80: 65 77 20 69 73 20 6e 6f 74 20 69 6d 6d 65 64 69  ew is not immedi
2e90: 61 74 65 6c 79 20 61 66 74 65 72 20 24 6f 6c 64  ately after $old
2ea0: 7d 0a 09 7d 0a 0a 09 73 65 74 20 6d 79 6c 61 73  }..}...set mylas
2eb0: 74 70 6f 73 20 24 6e 65 77 0a 09 72 65 74 75 72  tpos $new..retur
2ec0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f  n.    }..    pro
2ed0: 63 20 46 6f 72 6d 61 74 54 52 20 7b 67 72 61 70  c FormatTR {grap
2ee0: 68 20 63 73 65 74 7d 20 7b 0a 09 72 65 74 75 72  h cset} {..retur
2ef0: 6e 20 5b 6a 6f 69 6e 20 5b 73 74 72 75 63 74 3a  n [join [struct:
2f00: 3a 6c 69 73 74 20 6d 61 70 20 5b 24 67 72 61 70  :list map [$grap
2f10: 68 20 6e 6f 64 65 20 73 65 74 20 24 63 73 65 74  h node set $cset
2f20: 20 74 69 6d 65 72 61 6e 67 65 5d 20 7b 63 6c 6f   timerange] {clo
2f30: 63 6b 20 66 6f 72 6d 61 74 7d 5d 20 7b 20 2d 2d  ck format}] { --
2f40: 20 7d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74   }].    }..    t
2f50: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 6c 61  ypevariable myla
2f60: 73 74 70 6f 73 20 20 20 20 20 20 20 20 20 20 20  stpos           
2f70: 20 2d 31 20 3b 20 23 20 50 6f 73 69 74 69 6f 6e   -1 ; # Position
2f80: 20 6f 66 20 6c 61 73 74 20 72 65 76 69 73 69 6f   of last revisio
2f90: 6e 20 63 68 61 6e 67 65 73 65 74 20 73 61 76 65  n changeset save
2fa0: 64 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 61  d..    typevaria
2fb0: 62 6c 65 20 6d 79 72 65 76 69 73 69 6f 6e 63 68  ble myrevisionch
2fc0: 61 6e 67 65 73 65 74 73 20 7b 7d 20 3b 20 23 20  angesets {} ; # 
2fd0: 53 65 74 20 6f 66 20 72 65 76 69 73 69 6f 6e 20  Set of revision 
2fe0: 63 68 61 6e 67 65 73 65 74 73 0a 0a 20 20 20 20  changesets..    
2ff0: 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 61  typevariable mya
3000: 74 66 6d 74 20 3b 20 23 20 46 6f 72 6d 61 74 20  tfmt ; # Format 
3010: 66 6f 72 20 6c 6f 67 20 6f 75 74 70 75 74 20 74  for log output t
3020: 6f 20 67 61 69 6e 20 62 65 74 74 65 72 20 61 6c  o gain better al
3030: 69 67 6e 6d 65 6e 74 20 6f 66 20 74 68 65 20 76  ignment of the v
3040: 61 72 69 6f 75 73 20 63 6f 6c 75 6d 6e 73 2e 0a  arious columns..
3050: 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65      typevariable
3060: 20 6d 79 63 73 66 6d 74 20 3b 20 23 20 44 69 74   mycsfmt ; # Dit
3070: 74 6f 20 66 6f 72 20 74 68 65 20 63 68 61 6e 67  to for the chang
3080: 65 73 65 74 73 2e 0a 0a 20 20 20 20 23 20 23 20  esets...    # # 
3090: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
30a0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
30b0: 23 23 23 0a 0a 20 20 20 20 74 79 70 65 76 61 72  ###..    typevar
30c0: 69 61 62 6c 65 20 6d 79 63 73 65 74 20 2d 61 72  iable mycset -ar
30d0: 72 61 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66  ray {} ; # Map f
30e0: 72 6f 6d 20 63 6f 6d 6d 69 74 20 70 6f 73 69 74  rom commit posit
30f0: 69 6f 6e 73 20 74 6f 20 74 68 65 0a 09 09 09 09  ions to the.....
3100: 20 20 20 20 23 20 63 68 61 6e 67 65 73 65 74 20      # changeset 
3110: 28 6f 62 6a 65 63 74 20 72 65 66 29 20 61 74 20  (object ref) at 
3120: 74 68 61 74 0a 09 09 09 09 20 20 20 20 23 20 70  that.....    # p
3130: 6f 73 69 74 69 6f 6e 2e 0a 0a 20 20 20 20 23 20  osition...    # 
3140: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
3150: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
3160: 23 23 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e  #####.    ## Con
3170: 66 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20  figuration..    
3180: 70 72 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61  pragma -hasinsta
3190: 6e 63 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69  nces   no ; # si
31a0: 6e 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67  ngleton.    prag
31b0: 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20  ma -hastypeinfo 
31c0: 20 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74     no ; # no int
31d0: 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70  rospection.    p
31e0: 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65  ragma -hastypede
31f0: 73 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d  stroy no ; # imm
3200: 6f 72 74 61 6c 0a 0a 20 20 20 20 23 20 23 20 23  ortal..    # # #
3210: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
3220: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
3230: 23 23 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20  ##.}..namespace 
3240: 65 76 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  eval ::vc::fossi
3250: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
3260: 70 61 73 73 20 7b 0a 20 20 20 20 6e 61 6d 65 73  pass {.    names
3270: 70 61 63 65 20 65 78 70 6f 72 74 20 62 72 65 61  pace export brea
3280: 6b 61 63 79 63 6c 65 0a 20 20 20 20 6e 61 6d 65  kacycle.    name
3290: 73 70 61 63 65 20 65 76 61 6c 20 62 72 65 61 6b  space eval break
32a0: 61 63 79 63 6c 65 20 7b 0a 09 6e 61 6d 65 73 70  acycle {..namesp
32b0: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
32c0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
32d0: 3a 63 76 73 3a 3a 63 79 63 6c 65 62 72 65 61 6b  :cvs::cyclebreak
32e0: 65 72 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d  er..namespace im
32f0: 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  port ::vc::fossi
3300: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
3310: 72 65 70 6f 73 69 74 6f 72 79 0a 09 6e 61 6d 65  repository..name
3320: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76  space import ::v
3330: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
3340: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e  t::cvs::state..n
3350: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
3360: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
3370: 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67  port::cvs::integ
3380: 72 69 74 79 0a 09 6e 61 6d 65 73 70 61 63 65 20  rity..namespace 
3390: 65 76 61 6c 20 70 72 6f 6a 65 63 74 20 7b 0a 09  eval project {..
33a0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d      namespace im
33b0: 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69  port ::vc::fossi
33c0: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a  l::import::cvs::
33d0: 70 72 6f 6a 65 63 74 3a 3a 72 65 76 0a 09 7d 0a  project::rev..}.
33e0: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
33f0: 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d  t ::vc::tools::m
3400: 69 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73 70 61 63  isc::*..namespac
3410: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74  e import ::vc::t
3420: 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 0a 09 6e  ools::trouble..n
3430: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
3440: 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67  ::vc::tools::log
3450: 0a 09 6c 6f 67 20 72 65 67 69 73 74 65 72 20 62  ..log register b
3460: 72 65 61 6b 61 63 79 63 6c 65 0a 20 20 20 20 7d  reakacycle.    }
3470: 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23  .}..# # ## ### #
3480: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23  #### ######## ##
3490: 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23  ########### ####
34a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
34b0: 23 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 63 6b  #.## Ready..pack
34c0: 61 67 65 20 70 72 6f 76 69 64 65 20 76 63 3a 3a  age provide vc::
34d0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
34e0: 63 76 73 3a 3a 70 61 73 73 3a 3a 62 72 65 61 6b  cvs::pass::break
34f0: 61 63 79 63 6c 65 20 31 2e 30 0a 72 65 74 75 72  acycle 1.0.retur
3500: 6e 0a                                            n.