Hex Artifact Content
Not logged in

Artifact ba2a0b846b278c8ee3e28c28461c369ea2a0eb51:

File tools/cvs2fossil/lib/c2f_pbreakacycle.tcl part of check-in [7ed2f29d7a] - Updated passes 6 and 8 for to the changtes in the cycle breaker API (changed signature of save callback). by aku on 2007-11-24 03:56:46.

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 56 49 49 49 2e 20 54 68 69 73 20 69 73 20  s VIII. This is 
0210: 74 68 65 20 66 69 6e 61 6c 20 70 61 73 73 20 66  the final pass f
0220: 6f 72 20 62 72 65 61 6b 69 6e 67 20 63 68 61 6e  or breaking chan
0230: 67 65 73 65 74 20 64 65 70 65 6e 64 65 6e 63 79  geset dependency
0240: 0a 23 23 20 63 79 63 6c 65 73 2e 20 54 68 65 20  .## cycles. The 
0250: 74 77 6f 20 70 72 65 76 69 6f 75 73 20 70 61 73  two previous pas
0260: 73 65 73 20 62 72 6f 6b 65 20 63 79 63 6c 65 73  ses broke cycles
0270: 20 63 6f 76 65 72 69 6e 67 20 72 65 76 69 73 69   covering revisi
0280: 6f 6e 20 61 6e 64 0a 23 23 20 73 79 6d 62 6f 6c  on and.## symbol
0290: 20 63 68 61 6e 67 65 73 65 74 73 2c 20 72 65 73   changesets, res
02a0: 70 65 63 74 69 76 65 6c 79 2e 20 54 68 69 73 20  pectively. This 
02b0: 70 61 73 73 20 6e 6f 77 20 62 72 65 61 6b 73 20  pass now breaks 
02c0: 61 6e 79 20 72 65 6d 61 69 6e 69 6e 67 0a 23 23  any remaining.##
02d0: 20 63 79 63 6c 65 73 20 65 61 63 68 20 6f 66 20   cycles each of 
02e0: 77 68 69 63 68 20 68 61 73 20 74 6f 20 63 6f 6e  which has to con
02f0: 74 61 69 6e 20 61 74 20 6c 65 61 73 74 20 6f 6e  tain at least on
0300: 65 20 72 65 76 69 73 69 6f 6e 20 61 6e 64 20 61  e revision and a
0310: 74 0a 23 23 20 6c 65 61 73 74 20 6f 6e 65 20 73  t.## least one s
0320: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 2e  ymbol changeset.
0330: 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23  ..# # ## ### ###
0340: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
0350: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23  ######### ######
0360: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  ###############.
0370: 23 23 20 52 65 71 75 69 72 65 6d 65 6e 74 73 0a  ## Requirements.
0380: 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65  .package require
0390: 20 54 63 6c 20 38 2e 34 20 20 20 20 20 20 20 20   Tcl 8.4        
03a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03b0: 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 52             ; # R
03c0: 65 71 75 69 72 65 64 20 72 75 6e 74 69 6d 65 2e  equired runtime.
03d0: 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65  .package require
03e0: 20 73 6e 69 74 20 20 20 20 20 20 20 20 20 20 20   snit           
03f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0400: 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 4f             ; # O
0410: 4f 20 73 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67  O system..packag
0420: 65 20 72 65 71 75 69 72 65 20 73 74 72 75 63 74  e require struct
0430: 3a 3a 6c 69 73 74 20 20 20 20 20 20 20 20 20 20  ::list          
0440: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0450: 20 20 20 20 3b 20 23 20 48 69 67 68 65 72 20 6f      ; # Higher o
0460: 72 64 65 72 20 6c 69 73 74 20 6f 70 65 72 61 74  rder list operat
0470: 69 6f 6e 73 2e 0a 70 61 63 6b 61 67 65 20 72 65  ions..package re
0480: 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a  quire vc::tools:
0490: 3a 6d 69 73 63 20 20 20 20 20 20 20 20 20 20 20  :misc           
04a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
04b0: 3b 20 23 20 4d 69 6e 2c 20 6d 61 78 2e 0a 70 61  ; # Min, max..pa
04c0: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
04d0: 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 20 20 20 20  ::tools::log    
04e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
04f0: 20 20 20 20 20 20 20 20 3b 20 23 20 55 73 65 72          ; # User
0500: 20 66 65 65 64 62 61 63 6b 2e 0a 70 61 63 6b 61   feedback..packa
0510: 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74  ge require vc::t
0520: 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 20 20 20  ools::trouble   
0530: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0540: 20 20 20 20 20 3b 20 23 20 45 72 72 6f 72 20 72       ; # Error r
0550: 65 70 6f 72 74 69 6e 67 2e 0a 70 61 63 6b 61 67  eporting..packag
0560: 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f  e require vc::fo
0570: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
0580: 73 3a 3a 72 65 70 6f 73 69 74 6f 72 79 20 20 20  s::repository   
0590: 20 20 20 20 3b 20 23 20 52 65 70 6f 73 69 74 6f      ; # Reposito
05a0: 72 79 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a 70  ry management..p
05b0: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76  ackage require v
05c0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72  c::fossil::impor
05d0: 74 3a 3a 63 76 73 3a 3a 63 79 63 6c 65 62 72 65  t::cvs::cyclebre
05e0: 61 6b 65 72 20 20 20 20 20 3b 20 23 20 42 72 65  aker     ; # Bre
05f0: 61 6b 69 6e 67 20 64 65 70 65 6e 64 65 6e 63 79  aking dependency
0600: 20 63 79 63 6c 65 73 2e 0a 70 61 63 6b 61 67 65   cycles..package
0610: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73   require vc::fos
0620: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73  sil::import::cvs
0630: 3a 3a 73 74 61 74 65 20 20 20 20 20 20 20 20 20  ::state         
0640: 20 20 20 3b 20 23 20 53 74 61 74 65 20 73 74 6f     ; # State sto
0650: 72 61 67 65 2e 0a 70 61 63 6b 61 67 65 20 72 65  rage..package re
0660: 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c  quire vc::fossil
0670: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70  ::import::cvs::p
0680: 72 6f 6a 65 63 74 3a 3a 72 65 76 20 20 20 20 20  roject::rev     
0690: 3b 20 23 20 50 72 6f 6a 65 63 74 20 6c 65 76 65  ; # Project leve
06a0: 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 0a 23 20  l changesets..# 
06b0: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
06c0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
06d0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
06e0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52  ###########.## R
06f0: 65 67 69 73 74 65 72 20 74 68 65 20 70 61 73 73  egister the pass
0700: 20 77 69 74 68 20 74 68 65 20 6d 61 6e 61 67 65   with the manage
0710: 6d 65 6e 74 0a 0a 76 63 3a 3a 66 6f 73 73 69 6c  ment..vc::fossil
0720: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70  ::import::cvs::p
0730: 61 73 73 20 64 65 66 69 6e 65 20 5c 0a 20 20 20  ass define \.   
0740: 20 42 72 65 61 6b 41 6c 6c 43 73 65 74 43 79 63   BreakAllCsetCyc
0750: 6c 65 73 20 5c 0a 20 20 20 20 7b 42 72 65 61 6b  les \.    {Break
0760: 20 52 65 6d 61 69 6e 69 6e 67 20 43 68 61 6e 67   Remaining Chang
0770: 65 53 65 74 20 44 65 70 65 6e 64 65 6e 63 79 20  eSet Dependency 
0780: 43 79 63 6c 65 73 7d 20 5c 0a 20 20 20 20 3a 3a  Cycles} \.    ::
0790: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
07a0: 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a 3a 62  rt::cvs::pass::b
07b0: 72 65 61 6b 61 63 79 63 6c 65 0a 0a 23 20 23 20  reakacycle..# # 
07c0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
07d0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
07e0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
07f0: 23 23 23 23 23 23 23 23 23 0a 23 23 20 0a 0a 73  #########.## ..s
0800: 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a  nit::type ::vc::
0810: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
0820: 63 76 73 3a 3a 70 61 73 73 3a 3a 62 72 65 61 6b  cvs::pass::break
0830: 61 63 79 63 6c 65 20 7b 0a 20 20 20 20 23 20 23  acycle {.    # #
0840: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23   ## ### ##### ##
0850: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23  ###### #########
0860: 23 23 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c  ####.    ## Publ
0870: 69 63 20 41 50 49 0a 0a 20 20 20 20 74 79 70 65  ic API..    type
0880: 6d 65 74 68 6f 64 20 73 65 74 75 70 20 7b 7d 20  method setup {} 
0890: 7b 0a 09 23 20 44 65 66 69 6e 65 20 74 68 65 20  {..# Define the 
08a0: 6e 61 6d 65 73 20 61 6e 64 20 73 74 72 75 63 74  names and struct
08b0: 75 72 65 20 6f 66 20 74 68 65 20 70 65 72 73 69  ure of the persi
08c0: 73 74 65 6e 74 20 73 74 61 74 65 20 6f 66 0a 09  stent state of..
08d0: 23 20 74 68 69 73 20 70 61 73 73 2e 0a 0a 09 73  # this pass....s
08e0: 74 61 74 65 20 72 65 61 64 69 6e 67 20 63 73 6f  tate reading cso
08f0: 72 64 65 72 0a 09 72 65 74 75 72 6e 0a 20 20 20  rder..return.   
0900: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68   }..    typemeth
0910: 6f 64 20 6c 6f 61 64 20 7b 7d 20 7b 0a 09 23 20  od load {} {..# 
0920: 50 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e 74  Pass manager int
0930: 65 72 66 61 63 65 2e 20 45 78 65 63 75 74 65 64  erface. Executed
0940: 20 74 6f 20 6c 6f 61 64 20 64 61 74 61 20 63 6f   to load data co
0950: 6d 70 75 74 65 64 20 62 79 0a 09 23 20 74 68 69  mputed by..# thi
0960: 73 20 70 61 73 73 20 69 6e 74 6f 20 6d 65 6d 6f  s pass into memo
0970: 72 79 20 77 68 65 6e 20 74 68 69 73 20 70 61 73  ry when this pas
0980: 73 20 69 73 20 73 6b 69 70 70 65 64 20 69 6e 73  s is skipped ins
0990: 74 65 61 64 20 6f 66 0a 09 23 20 65 78 65 63 75  tead of..# execu
09a0: 74 65 64 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20  ted...return.   
09b0: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68   }..    typemeth
09c0: 6f 64 20 72 75 6e 20 7b 7d 20 7b 0a 09 23 20 50  od run {} {..# P
09d0: 61 73 73 20 6d 61 6e 61 67 65 72 20 69 6e 74 65  ass manager inte
09e0: 72 66 61 63 65 2e 20 45 78 65 63 75 74 65 64 20  rface. Executed 
09f0: 74 6f 20 70 65 72 66 6f 72 6d 20 74 68 65 0a 09  to perform the..
0a00: 23 20 66 75 6e 63 74 69 6f 6e 61 6c 69 74 79 20  # functionality 
0a10: 6f 66 20 74 68 65 20 70 61 73 73 2e 0a 0a 09 63  of the pass....c
0a20: 79 63 6c 65 62 72 65 61 6b 65 72 20 70 72 65 63  yclebreaker prec
0a30: 6d 64 20 20 20 5b 6d 79 70 72 6f 63 20 42 72 65  md   [myproc Bre
0a40: 61 6b 42 61 63 6b 77 61 72 64 42 72 61 6e 63 68  akBackwardBranch
0a50: 65 73 5d 0a 09 63 79 63 6c 65 62 72 65 61 6b 65  es]..cyclebreake
0a60: 72 20 73 61 76 65 63 6d 64 20 20 5b 6d 79 70 72  r savecmd  [mypr
0a70: 6f 63 20 53 61 76 65 4f 72 64 65 72 5d 0a 09 63  oc SaveOrder]..c
0a80: 79 63 6c 65 62 72 65 61 6b 65 72 20 62 72 65 61  yclebreaker brea
0a90: 6b 63 6d 64 20 5b 6d 79 70 72 6f 63 20 42 72 65  kcmd [myproc Bre
0aa0: 61 6b 43 79 63 6c 65 5d 0a 0a 09 73 74 61 74 65  akCycle]...state
0ab0: 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 7b 0a 09   transaction {..
0ac0: 20 20 20 20 4c 6f 61 64 43 6f 6d 6d 69 74 4f 72      LoadCommitOr
0ad0: 64 65 72 0a 09 20 20 20 20 63 79 63 6c 65 62 72  der..    cyclebr
0ae0: 65 61 6b 65 72 20 72 75 6e 20 62 72 65 61 6b 2d  eaker run break-
0af0: 61 6c 6c 20 5b 6d 79 70 72 6f 63 20 43 68 61 6e  all [myproc Chan
0b00: 67 65 73 65 74 73 5d 0a 09 7d 0a 0a 09 72 65 70  gesets]..}...rep
0b10: 6f 73 69 74 6f 72 79 20 70 72 69 6e 74 63 73 65  ository printcse
0b20: 74 73 74 61 74 69 73 74 69 63 73 0a 09 72 65 74  tstatistics..ret
0b30: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74  urn.    }..    t
0b40: 79 70 65 6d 65 74 68 6f 64 20 64 69 73 63 61 72  ypemethod discar
0b50: 64 20 7b 7d 20 7b 0a 09 23 20 50 61 73 73 20 6d  d {} {..# Pass m
0b60: 61 6e 61 67 65 72 20 69 6e 74 65 72 66 61 63 65  anager interface
0b70: 2e 20 45 78 65 63 75 74 65 64 20 66 6f 72 20 61  . Executed for a
0b80: 6c 6c 20 70 61 73 73 65 73 20 61 66 74 65 72 20  ll passes after 
0b90: 74 68 65 0a 09 23 20 72 75 6e 20 70 61 73 73 65  the..# run passe
0ba0: 73 2c 20 74 6f 20 72 65 6d 6f 76 65 20 61 6c 6c  s, to remove all
0bb0: 20 64 61 74 61 20 6f 66 20 74 68 69 73 20 70 61   data of this pa
0bc0: 73 73 20 66 72 6f 6d 20 74 68 65 20 73 74 61 74  ss from the stat
0bd0: 65 2c 0a 09 23 20 61 73 20 62 65 69 6e 67 20 6f  e,..# as being o
0be0: 75 74 20 6f 66 20 64 61 74 65 2e 0a 09 72 65 74  ut of date...ret
0bf0: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23  urn.    }..    #
0c00: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20   # ## ### ##### 
0c10: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23  ######## #######
0c20: 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 49 6e  ######.    ## In
0c30: 74 65 72 6e 61 6c 20 6d 65 74 68 6f 64 73 0a 0a  ternal methods..
0c40: 20 20 20 20 70 72 6f 63 20 43 68 61 6e 67 65 73      proc Changes
0c50: 65 74 73 20 7b 7d 20 7b 20 70 72 6f 6a 65 63 74  ets {} { project
0c60: 3a 3a 72 65 76 20 61 6c 6c 20 7d 0a 0a 20 20 20  ::rev all }..   
0c70: 20 70 72 6f 63 20 4c 6f 61 64 43 6f 6d 6d 69 74   proc LoadCommit
0c80: 4f 72 64 65 72 20 7b 7d 20 7b 0a 09 3a 3a 76 61  Order {} {..::va
0c90: 72 69 61 62 6c 65 20 6d 79 63 73 65 74 0a 0a 09  riable mycset...
0ca0: 73 74 61 74 65 20 74 72 61 6e 73 61 63 74 69 6f  state transactio
0cb0: 6e 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68  n {..    foreach
0cc0: 20 7b 63 69 64 20 70 6f 73 7d 20 5b 73 74 61 74   {cid pos} [stat
0cd0: 65 20 72 75 6e 20 7b 20 53 45 4c 45 43 54 20 63  e run { SELECT c
0ce0: 69 64 2c 20 70 6f 73 20 46 52 4f 4d 20 63 73 6f  id, pos FROM cso
0cf0: 72 64 65 72 20 7d 5d 20 7b 0a 09 09 73 65 74 20  rder }] {...set 
0d00: 63 73 65 74 20 5b 70 72 6f 6a 65 63 74 3a 3a 72  cset [project::r
0d10: 65 76 20 6f 66 20 24 63 69 64 5d 0a 09 09 24 63  ev of $cid]...$c
0d20: 73 65 74 20 73 65 74 70 6f 73 20 24 70 6f 73 0a  set setpos $pos.
0d30: 09 09 73 65 74 20 6d 79 63 73 65 74 28 24 70 6f  ..set mycset($po
0d40: 73 29 20 24 63 73 65 74 0a 09 20 20 20 20 7d 0a  s) $cset..    }.
0d50: 09 20 20 20 20 23 20 52 65 6d 6f 76 65 20 74 68  .    # Remove th
0d60: 65 20 6f 72 64 65 72 20 69 6e 66 6f 72 6d 61 74  e order informat
0d70: 69 6f 6e 20 6e 6f 77 20 74 68 61 74 20 77 65 20  ion now that we 
0d80: 68 61 76 65 20 69 74 20 69 6e 0a 09 20 20 20 20  have it in..    
0d90: 23 20 6d 65 6d 6f 72 79 2c 20 73 6f 20 74 68 61  # memory, so tha
0da0: 74 20 77 65 20 63 61 6e 20 73 61 76 65 20 69 74  t we can save it
0db0: 20 6f 6e 63 65 20 6d 6f 72 65 2c 20 66 6f 72 20   once more, for 
0dc0: 61 6c 6c 0a 09 20 20 20 20 23 20 63 68 61 6e 67  all..    # chang
0dd0: 65 73 65 74 73 2c 20 77 68 69 6c 65 20 62 72 65  esets, while bre
0de0: 61 6b 69 6e 67 20 74 68 65 20 72 65 6d 61 69 6e  aking the remain
0df0: 69 6e 67 20 63 79 63 6c 65 73 2e 0a 09 20 20 20  ing cycles...   
0e00: 20 73 74 61 74 65 20 72 75 6e 20 7b 20 44 45 4c   state run { DEL
0e10: 45 54 45 20 46 52 4f 4d 20 63 73 6f 72 64 65 72  ETE FROM csorder
0e20: 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20   }..}..return.  
0e30: 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20    }..    # # ## 
0e40: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
0e50: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
0e60: 0a 0a 20 20 20 20 70 72 6f 63 20 42 72 65 61 6b  ..    proc Break
0e70: 42 61 63 6b 77 61 72 64 42 72 61 6e 63 68 65 73  BackwardBranches
0e80: 20 7b 67 72 61 70 68 7d 20 7b 0a 09 23 20 57 65   {graph} {..# We
0e90: 20 67 6f 20 6f 76 65 72 20 61 6c 6c 20 62 72 61   go over all bra
0ea0: 6e 63 68 20 63 68 61 6e 67 65 73 65 74 73 2c 20  nch changesets, 
0eb0: 69 2e 65 2e 20 74 68 65 20 63 68 61 6e 67 65 73  i.e. the changes
0ec0: 65 74 73 0a 09 23 20 63 72 65 61 74 65 64 20 62  ets..# created b
0ed0: 79 20 74 68 65 20 73 79 6d 62 6f 6c 73 20 77 68  y the symbols wh
0ee0: 69 63 68 20 61 72 65 20 74 72 61 6e 73 6c 61 74  ich are translat
0ef0: 65 64 20 61 73 20 62 72 61 6e 63 68 65 73 2c 20  ed as branches, 
0f00: 61 6e 64 0a 09 23 20 62 72 65 61 6b 20 61 6e 79  and..# break any
0f10: 20 77 68 69 63 68 20 61 72 65 20 27 62 61 63 6b   which are 'back
0f20: 77 61 72 64 27 2c 20 77 68 69 63 68 20 6d 65 61  ward', which mea
0f30: 6e 73 20 74 68 61 74 20 74 68 65 79 20 68 61 76  ns that they hav
0f40: 65 0a 09 23 20 61 74 20 6c 65 61 73 74 20 6f 6e  e..# at least on
0f50: 65 20 69 6e 63 6f 6d 69 6e 67 20 72 65 76 69 73  e incoming revis
0f60: 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 20 77 68  ion changeset wh
0f70: 69 63 68 20 69 73 20 63 6f 6d 6d 69 74 74 65 64  ich is committed
0f80: 0a 09 23 20 61 66 74 65 72 20 61 74 20 6c 65 61  ..# after at lea
0f90: 73 74 20 6f 6e 65 20 6f 66 20 74 68 65 20 6f 75  st one of the ou
0fa0: 74 67 6f 69 6e 67 20 72 65 76 69 73 69 6f 6e 20  tgoing revision 
0fb0: 63 68 61 6e 67 65 73 65 74 73 2c 20 70 65 72 0a  changesets, per.
0fc0: 09 23 20 74 68 65 20 6f 72 64 65 72 20 63 6f 6d  .# the order com
0fd0: 70 75 74 65 64 20 69 6e 20 70 61 73 73 20 36 2e  puted in pass 6.
0fe0: 20 49 6e 20 22 63 76 73 32 73 76 6e 22 20 74 68   In "cvs2svn" th
0ff0: 69 73 20 69 73 20 63 61 6c 6c 65 64 0a 09 23 20  is is called..# 
1000: 22 72 65 74 72 6f 67 72 61 64 65 22 2e 0a 0a 09  "retrograde"....
1010: 23 20 4e 4f 54 45 3a 20 57 65 20 6d 69 67 68 74  # NOTE: We might
1020: 20 62 65 20 61 62 6c 65 20 74 6f 20 75 73 65 20   be able to use 
1030: 6f 75 72 20 6b 6e 6f 77 6c 65 64 67 65 20 74 68  our knowledge th
1040: 61 74 20 77 65 20 61 72 65 0a 09 23 20 6c 6f 6f  at we are..# loo
1050: 6b 69 6e 67 20 61 74 20 61 6c 6c 20 63 68 61 6e  king at all chan
1060: 67 65 73 65 74 73 20 74 6f 20 63 72 65 61 74 65  gesets to create
1070: 20 61 20 73 71 6c 20 77 68 69 63 68 20 73 65 6c   a sql which sel
1080: 65 63 74 73 20 61 6c 6c 0a 09 23 20 74 68 65 20  ects all..# the 
1090: 62 72 61 6e 63 68 20 63 68 61 6e 67 65 73 65 74  branch changeset
10a0: 73 20 66 72 6f 6d 20 74 68 65 20 73 74 61 74 65  s from the state
10b0: 20 69 6e 20 6f 6e 65 20 67 6f 20 69 6e 73 74 65   in one go inste
10c0: 61 64 20 6f 66 0a 09 23 20 68 61 76 69 6e 67 20  ad of..# having 
10d0: 74 6f 20 63 68 65 63 6b 20 65 61 63 68 20 63 68  to check each ch
10e0: 61 6e 67 65 73 65 74 20 73 65 70 61 72 61 74 65  angeset separate
10f0: 6c 79 2e 20 43 6f 6e 73 69 64 65 72 20 74 68 69  ly. Consider thi
1100: 73 0a 09 23 20 6c 61 74 65 72 2c 20 67 65 74 20  s..# later, get 
1110: 74 68 65 20 70 61 73 73 20 77 6f 72 6b 69 6e 67  the pass working
1120: 20 66 69 72 73 74 2e 0a 09 23 0a 09 23 20 4e 4f   first...#..# NO
1130: 54 45 20 32 3a 20 4d 69 67 68 74 20 77 65 20 65  TE 2: Might we e
1140: 76 65 6e 20 62 65 20 61 62 6c 65 20 74 6f 20 73  ven be able to s
1150: 65 6c 65 63 74 20 74 68 65 20 62 61 63 6b 77 61  elect the backwa
1160: 72 64 20 62 72 61 6e 63 68 0a 09 23 20 63 68 61  rd branch..# cha
1170: 6e 67 65 73 65 74 73 20 74 6f 6f 20 3f 0a 0a 09  ngesets too ?...
1180: 66 6f 72 65 61 63 68 20 63 73 65 74 20 5b 24 67  foreach cset [$g
1190: 72 61 70 68 20 6e 6f 64 65 73 5d 20 7b 0a 09 20  raph nodes] {.. 
11a0: 20 20 20 69 66 20 7b 21 5b 24 63 73 65 74 20 69     if {![$cset i
11b0: 73 62 72 61 6e 63 68 5d 7d 20 63 6f 6e 74 69 6e  sbranch]} contin
11c0: 75 65 0a 09 20 20 20 20 43 68 65 63 6b 41 6e 64  ue..    CheckAnd
11d0: 42 72 65 61 6b 42 61 63 6b 77 61 72 64 42 72 61  BreakBackwardBra
11e0: 6e 63 68 20 24 67 72 61 70 68 20 24 63 73 65 74  nch $graph $cset
11f0: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20  ..}..return.    
1200: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 43 68 65 63  }..    proc Chec
1210: 6b 41 6e 64 42 72 65 61 6b 42 61 63 6b 77 61 72  kAndBreakBackwar
1220: 64 42 72 61 6e 63 68 20 7b 67 72 61 70 68 20 63  dBranch {graph c
1230: 73 65 74 7d 20 7b 0a 09 77 68 69 6c 65 20 7b 5b  set} {..while {[
1240: 49 73 41 42 61 63 6b 77 61 72 64 42 72 61 6e 63  IsABackwardBranc
1250: 68 20 24 67 72 61 70 68 20 24 63 73 65 74 5d 7d  h $graph $cset]}
1260: 20 7b 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74   {..    log writ
1270: 65 20 35 20 62 72 65 61 6b 61 63 79 63 6c 65 20  e 5 breakacycle 
1280: 22 42 72 65 61 6b 69 6e 67 20 62 61 63 6b 77 61  "Breaking backwa
1290: 72 64 20 62 72 61 6e 63 68 20 63 68 61 6e 67 65  rd branch change
12a0: 73 65 74 20 3c 5b 24 63 73 65 74 20 69 64 5d 3e  set <[$cset id]>
12b0: 22 0a 0a 09 20 20 20 20 23 20 4b 6e 6f 77 69 6e  "...    # Knowin
12c0: 67 20 74 68 61 74 20 74 68 65 20 62 72 61 6e 63  g that the branc
12d0: 68 20 69 73 20 62 61 63 6b 77 61 72 64 20 77 65  h is backward we
12e0: 20 6e 6f 77 20 6c 6f 6f 6b 20 61 74 20 74 68 65   now look at the
12f0: 0a 09 20 20 20 20 23 20 69 6e 64 69 76 69 64 75  ..    # individu
1300: 61 6c 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 20  al revisions in 
1310: 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 61 6e  the changeset an
1320: 64 20 64 65 74 65 72 6d 69 6e 65 0a 09 20 20 20  d determine..   
1330: 20 23 20 77 68 69 63 68 20 6f 66 20 74 68 65 6d   # which of them
1340: 20 61 72 65 20 72 65 73 70 6f 6e 73 69 62 6c 65   are responsible
1350: 20 66 6f 72 20 74 68 65 20 6f 76 65 72 6c 61 70   for the overlap
1360: 2e 20 54 68 69 73 0a 09 20 20 20 20 23 20 61 6c  . This..    # al
1370: 6c 6f 77 73 20 75 73 20 74 6f 20 73 70 6c 69 74  lows us to split
1380: 20 74 68 65 6d 20 69 6e 74 6f 20 74 77 6f 20 73   them into two s
1390: 65 74 73 2c 20 6f 6e 65 20 6f 66 0a 09 20 20 20  ets, one of..   
13a0: 20 23 20 6e 6f 6e 2d 6f 76 65 72 6c 61 70 70 69   # non-overlappi
13b0: 6e 67 20 72 65 76 69 73 69 6f 6e 73 2c 20 61 6e  ng revisions, an
13c0: 64 20 6f 66 20 6f 76 65 72 6c 61 70 70 69 6e 67  d of overlapping
13d0: 20 6f 6e 65 73 2e 20 45 61 63 68 0a 09 20 20 20   ones. Each..   
13e0: 20 23 20 69 6e 64 75 63 65 73 20 61 20 6e 65 77   # induces a new
13f0: 20 63 68 61 6e 67 65 73 65 74 2c 20 61 6e 64 20   changeset, and 
1400: 74 68 65 20 73 65 63 6f 6e 64 20 6d 61 79 20 73  the second may s
1410: 74 69 6c 6c 20 62 65 0a 09 20 20 20 20 23 20 62  till be..    # b
1420: 61 63 6b 77 61 72 64 20 61 6e 64 20 6e 65 65 64  ackward and need
1430: 20 66 75 72 74 68 65 72 20 73 70 6c 69 74 74 69   further splitti
1440: 6e 67 2e 20 48 65 6e 63 65 20 74 68 65 20 6c 6f  ng. Hence the lo
1450: 6f 70 69 6e 67 2e 0a 09 20 20 20 20 23 0a 09 20  oping...    #.. 
1460: 20 20 20 23 20 54 68 65 20 62 6f 72 64 65 72 20     # The border 
1470: 75 73 65 64 20 66 6f 72 20 74 68 65 20 73 70 6c  used for the spl
1480: 69 74 20 69 73 20 74 68 65 20 6d 69 6e 69 6d 61  it is the minima
1490: 6c 20 63 6f 6d 6d 69 74 0a 09 20 20 20 20 23 20  l commit..    # 
14a0: 70 6f 73 69 74 69 6f 6e 20 61 6d 6f 6e 67 20 74  position among t
14b0: 68 65 20 6d 69 6e 69 6d 61 6c 20 73 75 63 65 73  he minimal suces
14c0: 73 6f 72 20 63 6f 6d 6d 69 74 20 70 6f 73 69 74  sor commit posit
14d0: 69 6f 6e 73 20 66 6f 72 0a 09 20 20 20 20 23 20  ions for..    # 
14e0: 74 68 65 20 72 65 76 69 73 69 6f 6e 73 20 69 6e  the revisions in
14f0: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2e 0a   the changeset..
1500: 0a 09 20 20 20 20 23 20 4e 6f 74 65 20 74 68 61  ..    # Note tha
1510: 74 20 69 6e 64 69 76 69 64 75 61 6c 20 72 65 76  t individual rev
1520: 69 73 69 6f 6e 73 20 6d 61 79 20 6e 6f 74 20 68  isions may not h
1530: 61 76 65 20 72 65 76 69 73 69 6f 6e 0a 09 20 20  ave revision..  
1540: 20 20 23 20 63 68 61 6e 67 65 73 65 74 73 20 61    # changesets a
1550: 72 65 20 70 72 65 64 65 63 65 73 73 6f 72 73 20  re predecessors 
1560: 61 6e 64 2f 6f 72 20 73 75 63 63 65 73 73 6f 72  and/or successor
1570: 73 2c 20 6c 65 61 76 69 6e 67 0a 09 20 20 20 20  s, leaving..    
1580: 23 20 74 68 65 20 6c 69 6d 69 74 73 20 70 61 72  # the limits par
1590: 74 69 61 6c 6c 79 20 6f 72 20 63 6f 6d 70 6c 65  tially or comple
15a0: 74 65 6c 79 20 75 6e 64 65 66 69 6e 65 64 2e 0a  tely undefined..
15b0: 0a 09 20 20 20 20 23 20 6c 69 6d 69 74 73 20 3a  ..    # limits :
15c0: 20 64 69 63 74 20 28 72 65 76 69 73 69 6f 6e 20   dict (revision 
15d0: 2d 3e 20 6c 69 73 74 20 28 6d 61 78 20 70 72 65  -> list (max pre
15e0: 64 65 63 65 73 73 6f 72 20 63 6f 6d 6d 69 74 2c  decessor commit,
15f0: 20 6d 69 6e 20 73 75 63 65 73 73 6f 72 20 63 6f   min sucessor co
1600: 6d 6d 69 74 29 29 0a 0a 09 20 20 20 20 43 6f 6d  mmit))...    Com
1610: 70 75 74 65 4c 69 6d 69 74 73 20 24 63 73 65 74  puteLimits $cset
1620: 20 6c 69 6d 69 74 73 20 62 6f 72 64 65 72 0a 0a   limits border..
1630: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36  .    log write 6
1640: 20 62 72 65 61 6b 61 63 79 63 6c 65 20 22 41 74   breakacycle "At
1650: 20 63 6f 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e   commit position
1660: 20 62 6f 72 64 65 72 20 24 62 6f 72 64 65 72 22   border $border"
1670: 0a 0a 09 20 20 20 20 23 20 54 68 65 6e 20 77 65  ...    # Then we
1680: 20 73 6f 72 74 20 74 68 65 20 66 69 6c 65 20 6c   sort the file l
1690: 65 76 65 6c 20 69 74 65 6d 73 20 62 61 73 65 64  evel items based
16a0: 20 6f 6e 20 74 68 65 72 65 20 74 68 65 79 0a 09   on there they..
16b0: 20 20 20 20 23 20 73 69 74 20 72 65 6c 61 74 69      # sit relati
16c0: 76 65 20 74 6f 20 74 68 65 20 62 6f 72 64 65 72  ve to the border
16d0: 20 69 6e 74 6f 20 62 65 66 6f 72 65 20 61 6e 64   into before and
16e0: 20 61 66 74 65 72 20 74 68 65 0a 09 20 20 20 20   after the..    
16f0: 23 20 62 6f 72 64 65 72 2e 0a 0a 09 20 20 20 20  # border....    
1700: 53 70 6c 69 74 52 65 76 69 73 69 6f 6e 73 20 24  SplitRevisions $
1710: 6c 69 6d 69 74 73 20 6e 6f 72 6d 61 6c 72 65 76  limits normalrev
1720: 69 73 69 6f 6e 73 20 62 61 63 6b 77 61 72 64 72  isions backwardr
1730: 65 76 69 73 69 6f 6e 73 0a 0a 09 20 20 20 20 73  evisions...    s
1740: 65 74 20 72 65 70 6c 61 63 65 6d 65 6e 74 73 20  et replacements 
1750: 5b 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20 73 70  [project::rev sp
1760: 6c 69 74 20 24 63 73 65 74 20 24 6e 6f 72 6d 61  lit $cset $norma
1770: 6c 72 65 76 69 73 69 6f 6e 73 20 24 62 61 63 6b  lrevisions $back
1780: 77 61 72 64 72 65 76 69 73 69 6f 6e 73 5d 0a 09  wardrevisions]..
1790: 20 20 20 20 63 79 63 6c 65 62 72 65 61 6b 65 72      cyclebreaker
17a0: 20 72 65 70 6c 61 63 65 20 24 67 72 61 70 68 20   replace $graph 
17b0: 24 63 73 65 74 20 24 72 65 70 6c 61 63 65 6d 65  $cset $replaceme
17c0: 6e 74 73 0a 0a 09 20 20 20 20 23 20 41 74 20 6c  nts...    # At l
17d0: 61 73 74 20 63 68 65 63 6b 20 74 68 61 74 20 74  ast check that t
17e0: 68 65 20 6e 6f 72 6d 61 6c 20 66 72 61 6d 65 6e  he normal framen
17f0: 74 20 69 73 20 69 6e 64 65 65 64 20 6e 6f 74 0a  t is indeed not.
1800: 09 20 20 20 20 23 20 62 61 63 6b 77 61 72 64 2c  .    # backward,
1810: 20 61 6e 64 20 69 74 65 72 61 74 65 20 6f 76 65   and iterate ove
1820: 72 20 74 68 65 20 70 6f 73 73 69 62 6c 79 20 73  r the possibly s
1830: 74 69 6c 6c 20 62 61 63 6b 77 61 72 64 0a 09 20  till backward.. 
1840: 20 20 20 23 20 73 65 63 6f 6e 64 20 66 72 61 67     # second frag
1850: 6d 65 6e 74 2e 0a 0a 09 20 20 20 20 73 74 72 75  ment....    stru
1860: 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20  ct::list assign 
1870: 24 72 65 70 6c 61 63 65 6d 65 6e 74 73 20 6e 6f  $replacements no
1880: 72 6d 61 6c 20 62 61 63 6b 77 61 72 64 0a 09 20  rmal backward.. 
1890: 20 20 20 69 66 20 7b 5b 49 73 41 42 61 63 6b 77     if {[IsABackw
18a0: 61 72 64 42 72 61 6e 63 68 20 24 64 67 20 24 6e  ardBranch $dg $n
18b0: 6f 72 6d 61 6c 5d 7d 20 7b 20 74 72 6f 75 62 6c  ormal]} { troubl
18c0: 65 20 69 6e 74 65 72 6e 61 6c 20 22 54 68 65 20  e internal "The 
18d0: 6e 6f 72 6d 61 6c 20 66 72 61 67 6d 65 6e 74 20  normal fragment 
18e0: 69 73 20 75 6e 65 78 70 65 63 74 65 64 6c 79 20  is unexpectedly 
18f0: 61 20 62 61 63 6b 77 61 72 64 20 62 72 61 6e 63  a backward branc
1900: 68 22 20 7d 0a 0a 09 20 20 20 20 73 65 74 20 63  h" }...    set c
1910: 73 65 74 20 24 62 61 63 6b 77 61 72 64 0a 09 7d  set $backward..}
1920: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
1930: 20 20 20 20 70 72 6f 63 20 49 73 41 42 61 63 6b      proc IsABack
1940: 77 61 72 64 42 72 61 6e 63 68 20 7b 64 67 20 63  wardBranch {dg c
1950: 73 65 74 7d 20 7b 0a 09 23 20 41 20 62 72 61 6e  set} {..# A bran
1960: 63 68 20 69 73 20 22 62 61 63 6b 77 61 72 64 22  ch is "backward"
1970: 20 69 66 20 69 74 20 68 61 73 20 61 74 20 6c 65   if it has at le
1980: 61 73 74 20 6f 6e 65 20 69 6e 63 6f 6d 69 6e 67  ast one incoming
1990: 0a 09 23 20 72 65 76 69 73 69 6f 6e 20 63 68 61  ..# revision cha
19a0: 6e 67 65 73 65 74 20 77 68 69 63 68 20 69 73 20  ngeset which is 
19b0: 63 6f 6d 6d 69 74 74 65 64 20 61 66 74 65 72 20  committed after 
19c0: 61 74 20 6c 65 61 73 74 20 6f 6e 65 20 6f 66 0a  at least one of.
19d0: 09 23 20 74 68 65 20 6f 75 74 67 6f 69 6e 67 20  .# the outgoing 
19e0: 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73  revision changes
19f0: 65 74 73 2c 20 70 65 72 20 74 68 65 20 6f 72 64  ets, per the ord
1a00: 65 72 20 63 6f 6d 70 75 74 65 64 20 69 6e 0a 09  er computed in..
1a10: 23 20 70 61 73 73 20 36 2e 0a 0a 09 23 20 52 65  # pass 6....# Re
1a20: 70 68 72 61 73 65 64 2c 20 74 68 65 20 6d 61 78  phrased, the max
1a30: 69 6d 61 6c 20 63 6f 6d 6d 69 74 20 70 6f 73 69  imal commit posi
1a40: 74 69 6f 6e 20 66 6f 75 6e 64 20 61 6d 6f 6e 67  tion found among
1a50: 20 74 68 65 0a 09 23 20 69 6e 63 6f 6d 69 6e 67   the..# incoming
1a60: 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65   revision change
1a70: 73 65 74 73 20 69 73 20 6c 61 72 67 65 72 20 74  sets is larger t
1a80: 68 61 6e 20 74 68 65 20 6d 69 6e 69 6d 61 6c 0a  han the minimal.
1a90: 09 23 20 63 6f 6d 6d 69 74 20 70 6f 73 69 74 69  .# commit positi
1aa0: 6f 6e 20 66 6f 75 6e 64 20 61 6d 6f 6e 67 20 74  on found among t
1ab0: 68 65 20 6f 75 74 67 6f 69 6e 67 20 72 65 76 69  he outgoing revi
1ac0: 73 69 6f 6e 0a 09 23 20 63 68 61 6e 67 65 73 65  sion..# changese
1ad0: 74 73 2e 20 41 73 73 75 6d 69 6e 67 20 74 68 61  ts. Assuming tha
1ae0: 74 20 77 65 20 68 61 76 65 20 62 6f 74 68 20 69  t we have both i
1af0: 6e 63 6f 6d 69 6e 67 20 61 6e 64 20 6f 75 74 67  ncoming and outg
1b00: 6f 69 6e 67 0a 09 23 20 72 65 76 69 73 69 6f 6e  oing..# revision
1b10: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09 23   changesets....#
1b20: 20 54 68 65 20 68 65 6c 70 65 72 20 22 50 6f 73   The helper "Pos
1b30: 69 74 69 6f 6e 73 22 20 63 6f 6d 70 75 74 65 73  itions" computes
1b40: 20 74 68 65 20 73 65 74 20 6f 66 20 63 6f 6d 6d   the set of comm
1b50: 69 74 20 70 6f 73 69 74 69 6f 6e 73 0a 09 23 20  it positions..# 
1b60: 66 6f 72 20 61 20 73 65 74 20 6f 66 20 63 68 61  for a set of cha
1b70: 6e 67 65 73 65 74 73 2c 20 77 68 69 63 68 20 63  ngesets, which c
1b80: 61 6e 20 62 65 20 61 20 6d 69 78 20 6f 66 20 72  an be a mix of r
1b90: 65 76 69 73 69 6f 6e 20 61 6e 64 0a 09 23 20 73  evision and..# s
1ba0: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73  ymbol changesets
1bb0: 2e 0a 0a 09 73 65 74 20 70 72 65 64 65 63 65 73  ....set predeces
1bc0: 73 6f 72 73 20 5b 50 6f 73 69 74 69 6f 6e 73 20  sors [Positions 
1bd0: 5b 24 64 67 20 6e 6f 64 65 73 20 2d 69 6e 20 20  [$dg nodes -in  
1be0: 24 63 73 65 74 5d 5d 0a 09 73 65 74 20 73 75 63  $cset]]..set suc
1bf0: 63 65 73 73 6f 72 73 20 20 20 5b 50 6f 73 69 74  cessors   [Posit
1c00: 69 6f 6e 73 20 5b 24 64 67 20 6e 6f 64 65 73 20  ions [$dg nodes 
1c10: 2d 6f 75 74 20 24 63 73 65 74 5d 5d 0a 0a 09 72  -out $cset]]...r
1c20: 65 74 75 72 6e 20 5b 65 78 70 72 20 7b 0a 09 09  eturn [expr {...
1c30: 20 20 20 20 20 20 5b 6c 6c 65 6e 67 74 68 20 24        [llength $
1c40: 70 72 65 64 65 63 65 73 73 6f 72 73 5d 20 26 26  predecessors] &&
1c50: 0a 09 09 20 20 20 20 20 20 5b 6c 6c 65 6e 67 74  ...      [llengt
1c60: 68 20 24 73 75 63 63 65 73 73 6f 72 73 5d 20 20  h $successors]  
1c70: 20 26 26 0a 09 09 20 20 20 20 20 20 28 5b 6d 61   &&...      ([ma
1c80: 78 20 24 70 72 65 64 65 63 65 73 73 6f 72 73 5d  x $predecessors]
1c90: 20 3e 3d 20 5b 6d 69 6e 20 24 73 75 63 63 65 73   >= [min $succes
1ca0: 73 6f 72 73 5d 29 0a 09 09 20 20 7d 5d 0a 20 20  sors])...  }].  
1cb0: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 6f    }..    proc Po
1cc0: 73 69 74 69 6f 6e 73 20 7b 63 68 61 6e 67 65 73  sitions {changes
1cd0: 65 74 73 7d 20 7b 0a 09 23 20 54 6f 20 63 6f 6d  ets} {..# To com
1ce0: 70 75 74 65 20 74 68 65 20 73 65 74 20 6f 66 20  pute the set of 
1cf0: 63 6f 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e 73  commit positions
1d00: 20 66 72 6f 6d 20 74 68 65 20 73 65 74 20 6f 66   from the set of
1d10: 0a 09 23 20 63 68 61 6e 67 65 73 65 74 73 20 77  ..# changesets w
1d20: 65 20 66 69 72 73 74 20 6d 61 70 20 65 61 63 68  e first map each
1d30: 20 63 68 61 6e 67 65 73 65 74 20 74 6f 20 69 74   changeset to it
1d40: 73 20 70 6f 73 69 74 69 6f 6e 20 28 2a 29 0a 09  s position (*)..
1d50: 23 20 61 6e 64 20 74 68 65 6e 20 66 69 6c 74 65  # and then filte
1d60: 72 20 6f 75 74 20 74 68 65 20 69 6e 76 61 6c 69  r out the invali
1d70: 64 20 72 65 73 70 6f 6e 73 65 73 20 28 74 68 65  d responses (the
1d80: 20 65 6d 70 74 79 20 73 74 72 69 6e 67 29 0a 09   empty string)..
1d90: 23 20 72 65 74 75 72 6e 65 64 20 62 79 20 74 68  # returned by th
1da0: 65 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73  e symbol changes
1db0: 65 74 73 2e 0a 09 23 0a 09 23 20 28 2a 29 20 54  ets...#..# (*) T
1dc0: 68 69 73 20 64 61 74 61 20 77 61 73 20 6c 6f 61  his data was loa
1dd0: 64 65 64 20 69 6e 74 6f 20 6d 65 6d 6f 72 79 20  ded into memory 
1de0: 65 61 72 6c 69 72 20 69 6e 20 74 68 65 20 70 61  earlir in the pa
1df0: 73 73 2c 20 62 79 0a 09 23 20 20 20 20 20 4c 6f  ss, by..#     Lo
1e00: 61 64 43 6f 6d 6d 69 74 4f 72 64 65 72 2e 0a 0a  adCommitOrder...
1e10: 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a  .return [struct:
1e20: 3a 6c 69 73 74 20 66 69 6c 74 65 72 20 5b 73 74  :list filter [st
1e30: 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24  ruct::list map $
1e40: 63 68 61 6e 67 65 73 65 74 73 20 5c 0a 09 09 09  changesets \....
1e50: 09 09 20 5b 6d 79 70 72 6f 63 20 54 6f 50 6f 73  .. [myproc ToPos
1e60: 69 74 69 6f 6e 5d 5d 20 5c 0a 09 09 20 20 20 20  ition]] \...    
1e70: 5b 6d 79 70 72 6f 63 20 56 61 6c 69 64 50 6f 73  [myproc ValidPos
1e80: 69 74 69 6f 6e 5d 5d 0a 20 20 20 20 7d 0a 0a 20  ition]].    }.. 
1e90: 20 20 20 70 72 6f 63 20 54 6f 50 6f 73 69 74 69     proc ToPositi
1ea0: 6f 6e 20 20 20 20 7b 63 73 65 74 7d 20 7b 20 24  on    {cset} { $
1eb0: 63 73 65 74 20 70 6f 73 20 7d 0a 20 20 20 20 70  cset pos }.    p
1ec0: 72 6f 63 20 56 61 6c 69 64 50 6f 73 69 74 69 6f  roc ValidPositio
1ed0: 6e 20 7b 70 6f 73 7d 20 20 7b 20 65 78 70 72 20  n {pos}  { expr 
1ee0: 7b 24 70 6f 73 20 6e 65 20 22 22 7d 20 7d 0a 0a  {$pos ne ""} }..
1ef0: 20 20 20 20 70 72 6f 63 20 43 6f 6d 70 75 74 65      proc Compute
1f00: 4c 69 6d 69 74 73 20 7b 63 73 65 74 20 6c 76 20  Limits {cset lv 
1f10: 62 76 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24  bv} {..upvar 1 $
1f20: 6c 76 20 74 68 65 6c 69 6d 69 74 73 20 24 62 76  lv thelimits $bv
1f30: 20 62 6f 72 64 65 72 0a 0a 09 23 20 49 6e 69 74   border...# Init
1f40: 69 61 6c 69 7a 65 20 74 68 65 20 62 6f 75 6e 64  ialize the bound
1f50: 61 72 69 65 73 20 66 6f 72 20 61 6c 6c 20 72 65  aries for all re
1f60: 76 69 73 69 6f 6e 73 2e 0a 0a 09 61 72 72 61 79  visions....array
1f70: 20 73 65 74 20 6c 69 6d 69 74 73 20 7b 7d 0a 09   set limits {}..
1f80: 66 6f 72 65 61 63 68 20 72 65 76 69 73 69 6f 6e  foreach revision
1f90: 20 5b 24 63 73 65 74 20 72 65 76 69 73 69 6f 6e   [$cset revision
1fa0: 73 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 6c 69  s] {..    set li
1fb0: 6d 69 74 73 28 24 72 65 76 69 73 69 6f 6e 29 20  mits($revision) 
1fc0: 7b 30 20 7b 7d 7d 0a 09 7d 0a 0a 09 23 20 43 6f  {0 {}}..}...# Co
1fd0: 6d 70 75 74 65 20 61 6e 64 20 73 74 6f 72 65 20  mpute and store 
1fe0: 74 68 65 20 6d 61 78 69 6d 61 6c 20 70 72 65 64  the maximal pred
1ff0: 65 63 65 73 73 6f 72 73 20 70 65 72 20 72 65 76  ecessors per rev
2000: 69 73 69 6f 6e 0a 0a 09 66 6f 72 65 61 63 68 20  ision...foreach 
2010: 7b 72 65 76 69 73 69 6f 6e 20 63 73 65 74 73 7d  {revision csets}
2020: 20 5b 24 63 73 65 74 20 70 72 65 64 65 63 65 73   [$cset predeces
2030: 73 6f 72 6d 61 70 5d 20 7b 0a 09 20 20 20 20 73  sormap] {..    s
2040: 65 74 20 73 20 5b 50 6f 73 69 74 69 6f 6e 73 20  et s [Positions 
2050: 24 63 73 65 74 73 5d 0a 09 20 20 20 20 69 66 20  $csets]..    if 
2060: 7b 21 5b 6c 6c 65 6e 67 74 68 20 24 73 5d 7d 20  {![llength $s]} 
2070: 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 73 65  continue..    se
2080: 74 20 6c 69 6d 69 74 73 28 24 72 65 76 69 73 69  t limits($revisi
2090: 6f 6e 29 20 5b 6c 72 65 70 6c 61 63 65 20 24 6c  on) [lreplace $l
20a0: 69 6d 69 74 73 28 24 72 65 76 69 73 69 6f 6e 29  imits($revision)
20b0: 20 30 20 30 20 5b 6d 61 78 20 24 73 5d 5d 0a 09   0 0 [max $s]]..
20c0: 7d 0a 0a 09 23 20 43 6f 6d 70 75 74 65 20 61 6e  }...# Compute an
20d0: 64 20 73 74 6f 72 65 20 74 68 65 20 6d 69 6e 69  d store the mini
20e0: 6d 61 6c 20 73 75 63 63 65 73 73 6f 72 73 20 70  mal successors p
20f0: 65 72 20 72 65 76 69 73 69 6f 6e 0a 0a 09 66 6f  er revision...fo
2100: 72 65 61 63 68 20 7b 72 65 76 69 73 69 6f 6e 20  reach {revision 
2110: 63 73 65 74 73 7d 20 5b 24 63 73 65 74 20 73 75  csets} [$cset su
2120: 63 63 65 73 73 6f 72 6d 61 70 5d 20 7b 0a 09 20  ccessormap] {.. 
2130: 20 20 20 73 65 74 20 73 20 5b 50 6f 73 69 74 69     set s [Positi
2140: 6f 6e 73 20 24 63 73 65 74 73 5d 0a 09 20 20 20  ons $csets]..   
2150: 20 69 66 20 7b 21 5b 6c 6c 65 6e 67 74 68 20 24   if {![llength $
2160: 73 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 20 20  s]} continue..  
2170: 20 20 73 65 74 20 6c 69 6d 69 74 73 28 24 72 65    set limits($re
2180: 76 69 73 69 6f 6e 29 20 5b 6c 72 65 70 6c 61 63  vision) [lreplac
2190: 65 20 24 6c 69 6d 69 74 73 28 24 72 65 76 69 73  e $limits($revis
21a0: 69 6f 6e 29 20 31 20 31 20 5b 6d 69 6e 20 24 73  ion) 1 1 [min $s
21b0: 5d 5d 0a 09 7d 0a 0a 09 23 20 43 68 65 63 6b 20  ]]..}...# Check 
21c0: 74 68 61 74 20 74 68 65 20 6f 72 64 65 72 69 6e  that the orderin
21d0: 67 20 61 74 20 74 68 65 20 66 69 6c 65 20 6c 65  g at the file le
21e0: 76 65 6c 20 69 73 20 63 6f 72 72 65 63 74 2e 20  vel is correct. 
21f0: 57 65 0a 09 23 20 63 61 6e 6e 6f 74 20 68 61 76  We..# cannot hav
2200: 65 20 62 61 63 6b 77 61 72 64 20 6f 72 64 65 72  e backward order
2210: 69 6e 67 20 70 65 72 20 72 65 76 69 73 69 6f 6e  ing per revision
2220: 2c 20 6f 72 20 73 6f 6d 65 74 68 69 6e 67 20 69  , or something i
2230: 73 0a 09 23 20 77 72 6f 6e 67 2e 0a 0a 09 66 6f  s..# wrong....fo
2240: 72 65 61 63 68 20 72 65 76 69 73 69 6f 6e 20 5b  reach revision [
2250: 61 72 72 61 79 20 6e 61 6d 65 73 20 6c 69 6d 69  array names limi
2260: 74 73 5d 20 7b 0a 09 20 20 20 20 73 74 72 75 63  ts] {..    struc
2270: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24  t::list assign $
2280: 6c 69 6d 69 74 73 28 24 72 65 76 69 73 69 6f 6e  limits($revision
2290: 29 20 6d 61 78 70 20 6d 69 6e 73 0a 09 20 20 20  ) maxp mins..   
22a0: 20 23 20 48 61 6e 64 6c 65 20 6d 69 6e 20 73 75   # Handle min su
22b0: 63 63 65 73 73 6f 72 20 70 6f 73 69 74 69 6f 6e  ccessor position
22c0: 20 22 22 20 61 73 20 72 65 70 72 65 73 65 6e 74   "" as represent
22d0: 69 6e 67 20 69 6e 66 69 6e 69 74 79 0a 09 20 20  ing infinity..  
22e0: 20 20 69 66 20 7b 24 6d 69 6e 73 20 65 71 20 22    if {$mins eq "
22f0: 22 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20  "} continue..   
2300: 20 69 66 20 7b 24 6d 61 78 70 20 3c 20 24 6d 69   if {$maxp < $mi
2310: 6e 73 7d 20 63 6f 6e 74 69 6e 75 65 0a 0a 09 20  ns} continue... 
2320: 20 20 20 74 72 6f 75 62 6c 65 20 69 6e 74 65 72     trouble inter
2330: 6e 61 6c 20 22 42 72 61 6e 63 68 20 72 65 76 69  nal "Branch revi
2340: 73 69 6f 6e 20 24 72 65 76 69 73 69 6f 6e 20 69  sion $revision i
2350: 73 20 62 61 63 6b 77 61 72 64 20 61 74 20 66 69  s backward at fi
2360: 6c 65 20 6c 65 76 65 6c 20 28 24 6d 61 78 70 20  le level ($maxp 
2370: 3e 3d 20 24 6d 69 6e 73 29 22 0a 09 7d 0a 0a 09  >= $mins)"..}...
2380: 23 20 53 61 76 65 20 74 68 65 20 6c 69 6d 69 74  # Save the limit
2390: 73 20 66 6f 72 20 74 68 65 20 73 70 6c 69 74 74  s for the splitt
23a0: 65 72 2c 20 61 6e 64 20 63 6f 6d 70 75 74 65 20  er, and compute 
23b0: 74 68 65 20 62 6f 72 64 65 72 20 61 74 0a 09 23  the border at..#
23c0: 20 77 68 69 63 68 20 74 6f 20 73 70 6c 69 74 20   which to split 
23d0: 61 73 20 74 68 65 20 6d 69 6e 69 6d 75 6d 20 6f  as the minimum o
23e0: 66 20 61 6c 6c 20 6d 69 6e 69 6d 61 6c 20 73 75  f all minimal su
23f0: 63 63 65 73 73 6f 72 0a 09 23 20 70 6f 73 69 74  ccessor..# posit
2400: 69 6f 6e 73 2e 0a 0a 09 73 65 74 20 74 68 65 6c  ions....set thel
2410: 69 6d 69 74 73 20 5b 61 72 72 61 79 20 67 65 74  imits [array get
2420: 20 6c 69 6d 69 74 73 5d 0a 09 73 65 74 20 62 6f   limits]..set bo
2430: 72 64 65 72 20 5b 6d 69 6e 20 5b 73 74 72 75 63  rder [min [struc
2440: 74 3a 3a 6c 69 73 74 20 66 69 6c 74 65 72 20 5b  t::list filter [
2450: 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70  struct::list map
2460: 20 5b 56 61 6c 75 65 73 20 24 74 68 65 6c 69 6d   [Values $thelim
2470: 69 74 73 5d 20 5c 0a 09 09 09 09 09 09 20 20 5b  its] \.......  [
2480: 6d 79 70 72 6f 63 20 4d 69 6e 53 75 63 63 65 73  myproc MinSucces
2490: 73 6f 72 50 6f 73 69 74 69 6f 6e 5d 5d 20 5c 0a  sorPosition]] \.
24a0: 09 09 09 20 20 20 20 20 5b 6d 79 70 72 6f 63 20  ...     [myproc 
24b0: 56 61 6c 69 64 50 6f 73 69 74 69 6f 6e 5d 5d 5d  ValidPosition]]]
24c0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a  ..return.    }..
24d0: 20 20 20 20 70 72 6f 63 20 56 61 6c 75 65 73 20      proc Values 
24e0: 7b 64 69 63 74 7d 20 7b 0a 09 73 65 74 20 72 65  {dict} {..set re
24f0: 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b 6b  s {}..foreach {k
2500: 20 76 7d 20 24 64 69 63 74 20 7b 20 6c 61 70 70   v} $dict { lapp
2510: 65 6e 64 20 72 65 73 20 24 76 20 7d 0a 09 72 65  end res $v }..re
2520: 74 75 72 6e 20 24 72 65 73 0a 20 20 20 20 7d 0a  turn $res.    }.
2530: 0a 20 20 20 20 70 72 6f 63 20 4d 69 6e 53 75 63  .    proc MinSuc
2540: 63 65 73 73 6f 72 50 6f 73 69 74 69 6f 6e 20 7b  cessorPosition {
2550: 69 74 65 6d 7d 20 7b 20 6c 69 6e 64 65 78 20 24  item} { lindex $
2560: 69 74 65 6d 20 31 20 7d 0a 0a 20 20 20 20 70 72  item 1 }..    pr
2570: 6f 63 20 53 70 6c 69 74 52 65 76 69 73 69 6f 6e  oc SplitRevision
2580: 73 20 7b 6c 69 6d 69 74 73 20 6e 76 20 62 76 7d  s {limits nv bv}
2590: 20 7b 0a 09 75 70 76 61 72 20 31 20 24 6e 76 20   {..upvar 1 $nv 
25a0: 6e 6f 72 6d 61 6c 72 65 76 69 73 69 6f 6e 73 20  normalrevisions 
25b0: 24 62 76 20 62 61 63 6b 77 61 72 64 72 65 76 69  $bv backwardrevi
25c0: 73 69 6f 6e 73 0a 0a 09 73 65 74 20 6e 6f 72 6d  sions...set norm
25d0: 61 6c 72 65 76 69 73 69 6f 6e 73 20 20 20 7b 7d  alrevisions   {}
25e0: 0a 09 73 65 74 20 62 61 63 6b 77 61 72 64 72 65  ..set backwardre
25f0: 76 69 73 69 6f 6e 73 20 7b 7d 0a 0a 09 66 6f 72  visions {}...for
2600: 65 61 63 68 20 7b 72 65 76 20 76 7d 20 24 6c 69  each {rev v} $li
2610: 6d 69 74 73 20 7b 0a 09 20 20 20 20 73 74 72 75  mits {..    stru
2620: 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20  ct::list assign 
2630: 24 76 20 6d 61 78 70 20 6d 69 6e 73 0a 09 20 20  $v maxp mins..  
2640: 20 20 69 66 20 7b 24 6d 61 78 70 20 3e 3d 20 24    if {$maxp >= $
2650: 62 6f 72 64 65 72 7d 20 7b 0a 09 09 6c 61 70 70  border} {...lapp
2660: 65 6e 64 20 62 61 63 6b 77 61 72 64 72 65 76 69  end backwardrevi
2670: 73 69 6f 6e 73 20 20 24 72 65 76 0a 09 20 20 20  sions  $rev..   
2680: 20 7d 20 65 6c 73 65 20 7b 0a 09 09 6c 61 70 70   } else {...lapp
2690: 65 6e 64 20 6e 6f 72 6d 61 6c 72 65 76 69 73 69  end normalrevisi
26a0: 6f 6e 73 20 24 72 65 76 0a 09 20 20 20 20 7d 0a  ons $rev..    }.
26b0: 09 7d 0a 0a 09 69 66 20 7b 21 5b 6c 6c 65 6e 67  .}...if {![lleng
26c0: 74 68 20 24 6e 6f 72 6d 61 6c 72 65 76 69 73 69  th $normalrevisi
26d0: 6f 6e 73 5d 7d 20 20 20 7b 20 74 72 6f 75 62 6c  ons]}   { troubl
26e0: 65 20 69 6e 74 65 72 6e 61 6c 20 22 53 65 74 20  e internal "Set 
26f0: 6f 66 20 6e 6f 72 6d 61 6c 20 72 65 76 69 73 69  of normal revisi
2700: 6f 6e 73 20 69 73 20 65 6d 70 74 79 22 20 7d 0a  ons is empty" }.
2710: 09 69 66 20 7b 21 5b 6c 6c 65 6e 67 74 68 20 24  .if {![llength $
2720: 62 61 63 6b 77 61 72 64 72 65 76 69 73 69 6f 6e  backwardrevision
2730: 73 5d 7d 20 7b 20 74 72 6f 75 62 6c 65 20 69 6e  s]} { trouble in
2740: 74 65 72 6e 61 6c 20 22 53 65 74 20 6f 66 20 62  ternal "Set of b
2750: 61 63 6b 77 61 72 64 20 72 65 76 69 73 69 6f 6e  ackward revision
2760: 73 20 69 73 20 65 6d 70 74 79 22 20 7d 0a 09 72  s is empty" }..r
2770: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 0a 20 20  eturn.    }...  
2780: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
2790: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
27a0: 23 23 23 23 23 23 23 23 23 0a 0a 20 20 20 20 70  #########..    p
27b0: 72 6f 63 20 53 61 76 65 4f 72 64 65 72 20 7b 67  roc SaveOrder {g
27c0: 72 61 70 68 20 63 73 65 74 20 70 6f 73 7d 20 7b  raph cset pos} {
27d0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20  .    }..    # # 
27e0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
27f0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
2800: 23 23 23 0a 0a 20 20 20 20 70 72 6f 63 20 42 72  ###..    proc Br
2810: 65 61 6b 43 79 63 6c 65 20 7b 67 72 61 70 68 7d  eakCycle {graph}
2820: 20 7b 0a 09 63 79 63 6c 65 62 72 65 61 6b 65 72   {..cyclebreaker
2830: 20 62 72 65 61 6b 20 24 67 72 61 70 68 0a 20 20   break $graph.  
2840: 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20    }..    # # ## 
2850: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
2860: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
2870: 0a 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62  ..    typevariab
2880: 6c 65 20 6d 79 63 73 65 74 20 2d 61 72 72 61 79  le mycset -array
2890: 20 7b 7d 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d   {} ; # Map from
28a0: 20 63 6f 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e   commit position
28b0: 73 20 74 6f 20 74 68 65 0a 09 09 09 09 20 20 20  s to the.....   
28c0: 20 23 20 63 68 61 6e 67 65 73 65 74 20 28 6f 62   # changeset (ob
28d0: 6a 65 63 74 20 72 65 66 29 20 61 74 20 74 68 61  ject ref) at tha
28e0: 74 0a 09 09 09 09 20 20 20 20 23 20 70 6f 73 69  t.....    # posi
28f0: 74 69 6f 6e 2e 0a 0a 20 20 20 20 23 20 23 20 23  tion...    # # #
2900: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23  # ### ##### ####
2910: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23  #### ###########
2920: 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67  ##.    ## Config
2930: 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61  uration..    pra
2940: 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 65  gma -hasinstance
2950: 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c  s   no ; # singl
2960: 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20  eton.    pragma 
2970: 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20  -hastypeinfo    
2980: 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73  no ; # no intros
2990: 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67  pection.    prag
29a0: 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73 74 72  ma -hastypedestr
29b0: 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74  oy no ; # immort
29c0: 61 6c 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23  al..    # # ## #
29d0: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23  ## ##### #######
29e0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a  # #############.
29f0: 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61  }..namespace eva
2a00: 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  l ::vc::fossil::
2a10: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73  import::cvs::pas
2a20: 73 20 7b 0a 20 20 20 20 6e 61 6d 65 73 70 61 63  s {.    namespac
2a30: 65 20 65 78 70 6f 72 74 20 62 72 65 61 6b 61 63  e export breakac
2a40: 79 63 6c 65 0a 20 20 20 20 6e 61 6d 65 73 70 61  ycle.    namespa
2a50: 63 65 20 65 76 61 6c 20 62 72 65 61 6b 61 63 79  ce eval breakacy
2a60: 63 6c 65 20 7b 0a 09 6e 61 6d 65 73 70 61 63 65  cle {..namespace
2a70: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f   import ::vc::fo
2a80: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76  ssil::import::cv
2a90: 73 3a 3a 63 79 63 6c 65 62 72 65 61 6b 65 72 0a  s::cyclebreaker.
2aa0: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72  .namespace impor
2ab0: 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a  t ::vc::fossil::
2ac0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 72 65 70  import::cvs::rep
2ad0: 6f 73 69 74 6f 72 79 0a 09 6e 61 6d 65 73 70 61  ository..namespa
2ae0: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a  ce import ::vc::
2af0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a  fossil::import::
2b00: 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65  cvs::state..name
2b10: 73 70 61 63 65 20 65 76 61 6c 20 70 72 6f 6a 65  space eval proje
2b20: 63 74 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73 70  ct {..    namesp
2b30: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a  ace import ::vc:
2b40: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a  :fossil::import:
2b50: 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72  :cvs::project::r
2b60: 65 76 0a 09 7d 0a 09 6e 61 6d 65 73 70 61 63 65  ev..}..namespace
2b70: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f   import ::vc::to
2b80: 6f 6c 73 3a 3a 6d 69 73 63 3a 3a 2a 0a 09 6e 61  ols::misc::*..na
2b90: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
2ba0: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75  :vc::tools::trou
2bb0: 62 6c 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ble..namespace i
2bc0: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c  mport ::vc::tool
2bd0: 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69  s::log..log regi
2be0: 73 74 65 72 20 62 72 65 61 6b 61 63 79 63 6c 65  ster breakacycle
2bf0: 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23  .    }.}..# # ##
2c00: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23   ### ##### #####
2c10: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
2c20: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23  # ##############
2c30: 23 23 23 23 23 23 23 0a 23 23 20 52 65 61 64 79  #######.## Ready
2c40: 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 69 64  ..package provid
2c50: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  e vc::fossil::im
2c60: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 61 73 73 3a  port::cvs::pass:
2c70: 3a 62 72 65 61 6b 61 63 79 63 6c 65 20 31 2e 30  :breakacycle 1.0
2c80: 0a 72 65 74 75 72 6e 0a                          .return.