Hex Artifact Content
Not logged in

Artifact 9c7c517526cfe7a5703f61f4ffe509e67100655e:

File tools/cvs2fossil/lib/c2f_cyclebreaker.tcl part of check-in [d58423cdc4] - API change cycle breaker. The save callback command is now specified through a separate configuration command. Moved callback invokation to helper command. Updated pass 6. Moved changeset selection to helper command. by aku on 2007-11-21 03:46:22.

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 54 68 69  ########..## Thi
0200: 73 20 66 69 6c 65 20 70 72 6f 76 69 64 65 73 20  s file provides 
0210: 61 20 68 65 6c 70 65 72 20 70 61 63 6b 61 67 65  a helper package
0220: 20 66 6f 72 20 74 68 65 20 70 61 73 73 65 73 20   for the passes 
0230: 36 20 61 6e 64 20 37 20 77 68 69 63 68 0a 23 23  6 and 7 which.##
0240: 20 63 6f 6e 74 61 69 6e 73 20 74 68 65 20 63 6f   contains the co
0250: 6d 6d 6f 6e 20 63 6f 64 65 20 6f 66 20 74 68 65  mmon code of the
0260: 20 63 79 63 6c 65 20 62 72 65 61 6b 69 6e 67 20   cycle breaking 
0270: 61 6c 67 6f 72 69 74 68 6d 2e 0a 0a 23 20 23 20  algorithm...# # 
0280: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
0290: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
02a0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23  ### ############
02b0: 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 71  #########.## Req
02c0: 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61 63 6b 61  uirements..packa
02d0: 67 65 20 72 65 71 75 69 72 65 20 54 63 6c 20 38  ge require Tcl 8
02e0: 2e 34 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .4              
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0300: 20 20 20 20 20 3b 20 23 20 52 65 71 75 69 72 65       ; # Require
0310: 64 20 72 75 6e 74 69 6d 65 2e 0a 70 61 63 6b 61  d runtime..packa
0320: 67 65 20 72 65 71 75 69 72 65 20 73 6e 69 74 20  ge require snit 
0330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0340: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0350: 20 20 20 20 20 3b 20 23 20 4f 4f 20 73 79 73 74       ; # OO syst
0360: 65 6d 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75  em..package requ
0370: 69 72 65 20 73 74 72 75 63 74 3a 3a 67 72 61 70  ire struct::grap
0380: 68 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  h               
0390: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20                ; 
03a0: 23 20 47 72 61 70 68 20 68 61 6e 64 6c 69 6e 67  # Graph handling
03b0: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72  ..package requir
03c0: 65 20 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 20  e struct::list  
03d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
03e0: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20              ; # 
03f0: 48 69 67 68 65 72 20 6f 72 64 65 72 20 6c 69 73  Higher order lis
0400: 74 20 6f 70 65 72 61 74 69 6f 6e 73 2e 0a 70 61  t operations..pa
0410: 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63  ckage require vc
0420: 3a 3a 74 6f 6f 6c 73 3a 3a 64 6f 74 20 20 20 20  ::tools::dot    
0430: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0440: 20 20 20 20 20 20 20 20 3b 20 23 20 55 73 65 72          ; # User
0450: 20 66 65 65 64 62 61 63 6b 2e 20 44 4f 54 20 65   feedback. DOT e
0460: 78 70 6f 72 74 2e 0a 70 61 63 6b 61 67 65 20 72  xport..package r
0470: 65 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73  equire vc::tools
0480: 3a 3a 6c 6f 67 20 20 20 20 20 20 20 20 20 20 20  ::log           
0490: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
04a0: 20 3b 20 23 20 55 73 65 72 20 66 65 65 64 62 61   ; # User feedba
04b0: 63 6b 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75  ck..package requ
04c0: 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d  ire vc::tools::m
04d0: 69 73 63 20 20 20 20 20 20 20 20 20 20 20 20 20  isc             
04e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20                ; 
04f0: 23 20 54 65 78 74 20 66 6f 72 6d 61 74 74 69 6e  # Text formattin
0500: 67 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69  g..package requi
0510: 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69  re vc::fossil::i
0520: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a  mport::cvs::proj
0530: 65 63 74 3a 3a 72 65 76 20 20 20 20 20 3b 20 23  ect::rev     ; #
0540: 20 50 72 6f 6a 65 63 74 20 6c 65 76 65 6c 20 63   Project level c
0550: 68 61 6e 67 65 73 65 74 73 0a 70 61 63 6b 61 67  hangesets.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 70 72 6f 6a 65 63 74 3a 3a 72 65 76 6c  s::project::revl
0590: 69 6e 6b 20 3b 20 23 20 43 79 63 6c 65 20 6c 69  ink ; # Cycle li
05a0: 6e 6b 73 2e 0a 0a 23 20 23 20 23 23 20 23 23 23  nks...# # ## ###
05b0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
05c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23  ############# ##
05d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
05e0: 23 23 23 0a 23 23 20 0a 0a 73 6e 69 74 3a 3a 74  ###.## ..snit::t
05f0: 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c  ype ::vc::fossil
0600: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 63  ::import::cvs::c
0610: 79 63 6c 65 62 72 65 61 6b 65 72 20 7b 0a 20 20  yclebreaker {.  
0620: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
0630: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
0640: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
0650: 20 50 75 62 6c 69 63 20 41 50 49 0a 0a 20 20 20   Public API..   
0660: 20 74 79 70 65 6d 65 74 68 6f 64 20 73 61 76 65   typemethod save
0670: 63 6d 64 20 7b 63 6d 64 7d 20 7b 0a 09 3a 3a 76  cmd {cmd} {..::v
0680: 61 72 69 61 62 6c 65 20 6d 79 73 61 76 65 63 6d  ariable mysavecm
0690: 64 20 24 63 6d 64 0a 09 72 65 74 75 72 6e 0a 20  d $cmd..return. 
06a0: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65     }..    typeme
06b0: 74 68 6f 64 20 64 6f 74 73 74 6f 20 7b 70 61 74  thod dotsto {pat
06c0: 68 7d 20 7b 0a 09 3a 3a 76 61 72 69 61 62 6c 65  h} {..::variable
06d0: 20 6d 79 64 6f 74 64 65 73 74 69 6e 61 74 69 6f   mydotdestinatio
06e0: 6e 20 24 70 61 74 68 0a 09 72 65 74 75 72 6e 0a  n $path..return.
06f0: 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d      }..    typem
0700: 65 74 68 6f 64 20 64 6f 74 20 7b 6c 61 62 65 6c  ethod dot {label
0710: 20 63 68 61 6e 67 65 73 65 74 73 7d 20 7b 0a 09   changesets} {..
0720: 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74  ::variable mydot
0730: 70 72 65 66 69 78 20 24 6c 61 62 65 6c 0a 09 3a  prefix $label..:
0740: 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 69  :variable mydoti
0750: 64 20 20 20 20 20 30 0a 0a 09 73 65 74 20 64 67  d     0...set dg
0760: 20 5b 53 65 74 75 70 20 24 63 68 61 6e 67 65 73   [Setup $changes
0770: 65 74 73 20 30 5d 0a 09 4d 61 72 6b 20 24 64 67  ets 0]..Mark $dg
0780: 0a 09 24 64 67 20 64 65 73 74 72 6f 79 0a 09 72  ..$dg destroy..r
0790: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20  eturn.    }..   
07a0: 20 74 79 70 65 6d 65 74 68 6f 64 20 72 75 6e 20   typemethod run 
07b0: 7b 6c 61 62 65 6c 20 63 68 61 6e 67 65 73 65 74  {label changeset
07c0: 73 7d 20 7b 0a 09 3a 3a 76 61 72 69 61 62 6c 65  s} {..::variable
07d0: 20 6d 79 61 74 20 20 20 20 20 20 20 20 30 0a 09   myat        0..
07e0: 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74  ::variable mydot
07f0: 70 72 65 66 69 78 20 24 6c 61 62 65 6c 0a 09 3a  prefix $label..:
0800: 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 69  :variable mydoti
0810: 64 20 20 20 20 20 30 0a 0a 09 23 20 57 65 20 63  d     0...# We c
0820: 72 65 61 74 65 20 61 20 67 72 61 70 68 20 6f 66  reate a graph of
0830: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 63 68   the revision ch
0840: 61 6e 67 65 73 65 74 73 2c 20 75 73 69 6e 67 20  angesets, using 
0850: 74 68 65 20 66 69 6c 65 0a 09 23 20 6c 65 76 65  the file..# leve
0860: 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 74  l dependencies t
0870: 6f 20 63 6f 6e 73 74 72 75 63 74 20 61 20 66 69  o construct a fi
0880: 72 73 74 20 61 70 70 72 6f 78 69 6d 61 74 69 6f  rst approximatio
0890: 6e 20 6f 66 20 74 68 65 0a 09 23 20 64 65 70 65  n of the..# depe
08a0: 6e 64 65 6e 63 69 65 73 20 61 74 20 74 68 65 20  ndencies at the 
08b0: 70 72 6f 6a 65 63 74 20 6c 65 76 65 6c 2e 20 54  project level. T
08c0: 68 65 6e 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20  hen we look for 
08d0: 63 79 63 6c 65 73 0a 09 23 20 69 6e 20 74 68 61  cycles..# in tha
08e0: 74 20 67 72 61 70 68 20 61 6e 64 20 62 72 65 61  t graph and brea
08f0: 6b 20 74 68 65 6d 2e 0a 0a 09 23 20 31 2e 20 43  k them....# 1. C
0900: 72 65 61 74 65 20 6e 6f 64 65 73 20 66 6f 72 20  reate nodes for 
0910: 61 6c 6c 20 72 65 6c 65 76 61 6e 74 20 63 68 61  all relevant cha
0920: 6e 67 65 73 65 74 73 20 61 6e 64 20 61 20 6d 61  ngesets and a ma
0930: 70 70 69 6e 67 0a 09 23 20 20 20 20 66 72 6f 6d  pping..#    from
0940: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 20 74   the revisions t
0950: 6f 20 74 68 65 69 72 20 63 68 61 6e 67 65 73 65  o their changese
0960: 74 73 2f 6e 6f 64 65 73 2e 0a 0a 09 73 65 74 20  ts/nodes....set 
0970: 64 67 20 5b 53 65 74 75 70 20 24 63 68 61 6e 67  dg [Setup $chang
0980: 65 73 65 74 73 5d 0a 0a 09 23 20 33 2e 20 4c 61  esets]...# 3. La
0990: 73 74 6c 79 20 77 65 20 69 74 65 72 61 74 65 20  stly we iterate 
09a0: 74 68 65 20 67 72 61 70 68 20 74 6f 70 6f 6c 6f  the graph topolo
09b0: 67 69 63 61 6c 6c 79 2e 20 57 65 20 6d 61 72 6b  gically. We mark
09c0: 20 6f 66 66 0a 09 23 20 20 20 20 74 68 65 20 6e   off..#    the n
09d0: 6f 64 65 73 20 77 68 69 63 68 20 68 61 76 65 20  odes which have 
09e0: 6e 6f 20 70 72 65 64 65 63 65 73 73 6f 72 73 2c  no predecessors,
09f0: 20 69 6e 20 6f 72 64 65 72 20 66 72 6f 6d 0a 09   in order from..
0a00: 23 20 20 20 20 6f 6c 64 65 73 74 20 74 6f 20 79  #    oldest to y
0a10: 6f 75 6e 67 65 73 74 2c 20 73 61 76 69 6e 67 20  oungest, saving 
0a20: 61 6e 64 20 72 65 6d 6f 76 69 6e 67 20 64 65 70  and removing dep
0a30: 65 6e 64 65 6e 63 69 65 73 2e 20 49 66 0a 09 23  endencies. If..#
0a40: 20 20 20 20 77 65 20 66 69 6e 64 20 6e 6f 20 6e      we find no n
0a50: 6f 64 65 73 20 77 69 74 68 6f 75 74 20 70 72 65  odes without pre
0a60: 64 65 63 65 73 73 6f 72 73 20 77 65 20 68 61 76  decessors we hav
0a70: 65 20 61 20 63 79 63 6c 65 2c 0a 09 23 20 20 20  e a cycle,..#   
0a80: 20 61 6e 64 20 77 6f 72 6b 20 6f 6e 20 62 72 65   and work on bre
0a90: 61 6b 69 6e 67 20 69 74 2e 0a 0a 09 6c 6f 67 20  aking it....log 
0aa0: 77 72 69 74 65 20 33 20 63 79 63 6c 65 62 72 65  write 3 cyclebre
0ab0: 61 6b 65 72 20 7b 4e 6f 77 20 73 6f 72 74 69 6e  aker {Now sortin
0ac0: 67 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 73  g the changesets
0ad0: 2c 20 62 72 65 61 6b 69 6e 67 20 63 79 63 6c 65  , breaking cycle
0ae0: 73 7d 0a 0a 09 49 6e 69 74 69 61 6c 69 7a 65 43  s}...InitializeC
0af0: 61 6e 64 69 64 61 74 65 73 20 24 64 67 0a 09 77  andidates $dg..w
0b00: 68 69 6c 65 20 7b 31 7d 20 7b 0a 09 20 20 20 20  hile {1} {..    
0b10: 77 68 69 6c 65 20 7b 5b 57 69 74 68 6f 75 74 50  while {[WithoutP
0b20: 72 65 64 65 63 65 73 73 6f 72 20 24 64 67 20 6e  redecessor $dg n
0b30: 5d 7d 20 7b 0a 09 09 53 61 76 65 41 6e 64 52 65  ]} {...SaveAndRe
0b40: 6d 6f 76 65 20 24 64 67 20 24 6e 0a 09 20 20 20  move $dg $n..   
0b50: 20 7d 0a 09 20 20 20 20 69 66 20 7b 21 5b 6c 6c   }..    if {![ll
0b60: 65 6e 67 74 68 20 5b 64 67 20 6e 6f 64 65 73 5d  ength [dg nodes]
0b70: 5d 7d 20 62 72 65 61 6b 0a 09 20 20 20 20 42 72  ]} break..    Br
0b80: 65 61 6b 43 79 63 6c 65 20 24 64 67 20 5b 46 69  eakCycle $dg [Fi
0b90: 6e 64 43 79 63 6c 65 20 24 64 67 5d 0a 09 20 20  ndCycle $dg]..  
0ba0: 20 20 49 6e 69 74 69 61 6c 69 7a 65 43 61 6e 64    InitializeCand
0bb0: 69 64 61 74 65 73 20 24 64 67 0a 09 7d 0a 0a 09  idates $dg..}...
0bc0: 64 67 20 64 65 73 74 72 6f 79 0a 0a 09 6c 6f 67  dg destroy...log
0bd0: 20 77 72 69 74 65 20 33 20 63 79 63 6c 65 62 72   write 3 cyclebr
0be0: 65 61 6b 65 72 20 44 6f 6e 65 2e 0a 0a 09 43 6c  eaker Done....Cl
0bf0: 65 61 72 48 6f 6f 6b 73 0a 09 72 65 74 75 72 6e  earHooks..return
0c00: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20  .    }..    # # 
0c10: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23  ## ### ##### ###
0c20: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
0c30: 23 23 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72  ###.    ## Inter
0c40: 6e 61 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20  nal methods..   
0c50: 20 70 72 6f 63 20 53 65 74 75 70 20 7b 63 68 61   proc Setup {cha
0c60: 6e 67 65 73 65 74 73 20 7b 6c 6f 67 20 31 7d 7d  ngesets {log 1}}
0c70: 20 7b 0a 09 69 66 20 7b 24 6c 6f 67 7d 20 7b 0a   {..if {$log} {.
0c80: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 33  .    log write 3
0c90: 20 63 79 63 6c 65 62 72 65 61 6b 65 72 20 22 43   cyclebreaker "C
0ca0: 72 65 61 74 69 6e 67 20 63 68 61 6e 67 65 73 65  reating changese
0cb0: 74 20 67 72 61 70 68 2c 20 66 69 6c 6c 69 6e 67  t graph, filling
0cc0: 20 77 69 74 68 20 6e 6f 64 65 73 22 0a 09 20 20   with nodes"..  
0cd0: 20 20 6c 6f 67 20 77 72 69 74 65 20 33 20 63 79    log write 3 cy
0ce0: 63 6c 65 62 72 65 61 6b 65 72 20 22 41 64 64 69  clebreaker "Addi
0cf0: 6e 67 20 5b 6e 73 70 20 5b 6c 6c 65 6e 67 74 68  ng [nsp [llength
0d00: 20 24 63 68 61 6e 67 65 73 65 74 73 5d 20 6e 6f   $changesets] no
0d10: 64 65 5d 22 0a 09 7d 0a 0a 09 73 65 74 20 64 67  de]"..}...set dg
0d20: 20 5b 73 74 72 75 63 74 3a 3a 67 72 61 70 68 20   [struct::graph 
0d30: 64 67 5d 0a 0a 09 66 6f 72 65 61 63 68 20 63 73  dg]...foreach cs
0d40: 65 74 20 24 63 68 61 6e 67 65 73 65 74 73 20 7b  et $changesets {
0d50: 0a 09 20 20 20 20 24 64 67 20 6e 6f 64 65 20 69  ..    $dg node i
0d60: 6e 73 65 72 74 20 24 63 73 65 74 0a 09 20 20 20  nsert $cset..   
0d70: 20 24 64 67 20 6e 6f 64 65 20 73 65 74 20 20 20   $dg node set   
0d80: 20 24 63 73 65 74 20 74 69 6d 65 72 61 6e 67 65   $cset timerange
0d90: 20 5b 24 63 73 65 74 20 74 69 6d 65 72 61 6e 67   [$cset timerang
0da0: 65 5d 0a 09 7d 0a 0a 09 23 20 32 2e 20 46 69 6e  e]..}...# 2. Fin
0db0: 64 20 66 6f 72 20 61 6c 6c 20 72 65 6c 65 76 61  d for all releva
0dc0: 6e 74 20 63 68 61 6e 67 65 73 65 74 20 74 68 65  nt changeset the
0dd0: 69 72 20 72 65 76 69 73 69 6f 6e 73 20 61 6e 64  ir revisions and
0de0: 20 74 68 65 69 72 0a 09 23 20 20 20 20 64 65 70   their..#    dep
0df0: 65 6e 64 65 6e 63 69 65 73 2e 20 4d 61 70 20 74  endencies. Map t
0e00: 68 65 20 6c 61 74 74 65 72 20 62 61 63 6b 20 74  he latter back t
0e10: 6f 20 63 68 61 6e 67 65 73 65 74 73 20 61 6e 64  o changesets and
0e20: 0a 09 23 20 20 20 20 63 6f 6e 73 74 72 75 63 74  ..#    construct
0e30: 20 74 68 65 20 63 6f 72 72 65 73 70 6f 6e 64 69   the correspondi
0e40: 6e 67 20 61 72 63 73 2e 0a 0a 09 69 66 20 7b 24  ng arcs....if {$
0e50: 6c 6f 67 7d 20 7b 0a 09 20 20 20 20 6c 6f 67 20  log} {..    log 
0e60: 77 72 69 74 65 20 33 20 63 79 63 6c 65 62 72 65  write 3 cyclebre
0e70: 61 6b 65 72 20 7b 53 65 74 74 69 6e 67 20 75 70  aker {Setting up
0e80: 20 6e 6f 64 65 20 64 65 70 65 6e 64 65 6e 63 69   node dependenci
0e90: 65 73 7d 0a 09 7d 0a 0a 09 66 6f 72 65 61 63 68  es}..}...foreach
0ea0: 20 63 73 65 74 20 24 63 68 61 6e 67 65 73 65 74   cset $changeset
0eb0: 73 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68  s {..    foreach
0ec0: 20 73 75 63 63 20 5b 24 63 73 65 74 20 73 75 63   succ [$cset suc
0ed0: 63 65 73 73 6f 72 73 5d 20 7b 0a 09 09 23 20 43  cessors] {...# C
0ee0: 68 61 6e 67 65 73 65 74 73 20 6d 61 79 20 68 61  hangesets may ha
0ef0: 76 65 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20  ve dependencies 
0f00: 6f 75 74 73 69 64 65 20 6f 66 20 74 68 65 0a 09  outside of the..
0f10: 09 23 20 63 68 6f 73 65 6e 20 73 65 74 2e 20 54  .# chosen set. T
0f20: 68 65 73 65 20 61 72 65 20 69 67 6e 6f 72 65 64  hese are ignored
0f30: 0a 09 09 69 66 20 7b 21 5b 24 64 67 20 6e 6f 64  ...if {![$dg nod
0f40: 65 20 65 78 69 73 74 73 20 24 73 75 63 63 5d 7d  e exists $succ]}
0f50: 20 63 6f 6e 74 69 6e 75 65 0a 09 09 24 64 67 20   continue...$dg 
0f60: 61 72 63 20 69 6e 73 65 72 74 20 24 63 73 65 74  arc insert $cset
0f70: 20 24 73 75 63 63 0a 09 20 20 20 20 7d 0a 09 7d   $succ..    }..}
0f80: 0a 0a 09 72 65 74 75 72 6e 20 24 64 67 0a 20 20  ...return $dg.  
0f90: 20 20 7d 0a 0a 20 20 20 20 23 20 49 6e 73 74 65    }..    # Inste
0fa0: 61 64 20 6f 66 20 73 65 61 72 63 68 69 6e 67 20  ad of searching 
0fb0: 74 68 65 20 77 68 6f 6c 65 20 67 72 61 70 68 20  the whole graph 
0fc0: 66 6f 72 20 74 68 65 20 64 65 67 72 65 65 2d 30  for the degree-0
0fd0: 20 6e 6f 64 65 73 20 69 6e 0a 20 20 20 20 23 20   nodes in.    # 
0fe0: 65 61 63 68 20 69 74 65 72 61 74 69 6f 6e 20 77  each iteration w
0ff0: 65 20 63 6f 6d 70 75 74 65 20 74 68 65 20 6c 69  e compute the li
1000: 73 74 20 6f 6e 63 65 20 74 6f 20 73 74 61 72 74  st once to start
1010: 2c 20 61 6e 64 20 74 68 65 6e 20 6f 6e 6c 79 0a  , and then only.
1020: 20 20 20 20 23 20 75 70 64 61 74 65 20 69 74 20      # update it 
1030: 69 6e 63 72 65 6d 65 6e 74 61 6c 6c 79 20 62 61  incrementally ba
1040: 73 65 64 20 6f 6e 20 74 68 65 20 6f 75 74 67 6f  sed on the outgo
1050: 69 6e 67 20 6e 65 69 67 68 62 6f 75 72 73 20 6f  ing neighbours o
1060: 66 20 74 68 65 0a 20 20 20 20 23 20 6e 6f 64 65  f the.    # node
1070: 20 63 68 6f 73 65 6e 20 66 6f 72 20 63 6f 6d 6d   chosen for comm
1080: 69 74 2e 0a 0a 20 20 20 20 70 72 6f 63 20 49 6e  it...    proc In
1090: 69 74 69 61 6c 69 7a 65 43 61 6e 64 69 64 61 74  itializeCandidat
10a0: 65 73 20 7b 64 67 7d 20 7b 0a 09 23 20 62 6f 74  es {dg} {..# bot
10b0: 74 6f 6d 20 3d 20 6c 69 73 74 20 28 6c 69 73 74  tom = list (list
10c0: 20 28 6e 6f 64 65 2c 20 72 61 6e 67 65 20 6d 69   (node, range mi
10d0: 6e 2c 20 72 61 6e 67 65 20 6d 61 78 29 29 0a 09  n, range max))..
10e0: 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 62 6f 74  ::variable mybot
10f0: 74 6f 6d 0a 09 66 6f 72 65 61 63 68 20 6e 20 5b  tom..foreach n [
1100: 24 64 67 20 6e 6f 64 65 73 5d 20 7b 0a 09 20 20  $dg nodes] {..  
1110: 20 20 69 66 20 7b 5b 24 64 67 20 6e 6f 64 65 20    if {[$dg node 
1120: 64 65 67 72 65 65 20 2d 69 6e 20 24 6e 5d 7d 20  degree -in $n]} 
1130: 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 6c 61  continue..    la
1140: 70 70 65 6e 64 20 6d 79 62 6f 74 74 6f 6d 20 5b  ppend mybottom [
1150: 6c 69 6e 73 65 72 74 20 5b 24 64 67 20 6e 6f 64  linsert [$dg nod
1160: 65 20 67 65 74 20 24 6e 20 74 69 6d 65 72 61 6e  e get $n timeran
1170: 67 65 5d 20 30 20 24 6e 5d 0a 09 7d 0a 09 73 65  ge] 0 $n]..}..se
1180: 74 20 6d 79 62 6f 74 74 6f 6d 20 5b 6c 73 6f 72  t mybottom [lsor
1190: 74 20 2d 69 6e 64 65 78 20 31 20 2d 69 6e 74 65  t -index 1 -inte
11a0: 67 65 72 20 5b 6c 73 6f 72 74 20 2d 69 6e 64 65  ger [lsort -inde
11b0: 78 20 32 20 2d 69 6e 74 65 67 65 72 20 24 6d 79  x 2 -integer $my
11c0: 62 6f 74 74 6f 6d 5d 5d 0a 09 72 65 74 75 72 6e  bottom]]..return
11d0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63  .    }..    proc
11e0: 20 57 69 74 68 6f 75 74 50 72 65 64 65 63 65 73   WithoutPredeces
11f0: 73 6f 72 20 7b 64 67 20 6e 76 7d 20 7b 0a 09 3a  sor {dg nv} {..:
1200: 3a 76 61 72 69 61 62 6c 65 20 6d 79 62 6f 74 74  :variable mybott
1210: 6f 6d 0a 0a 09 75 70 76 61 72 20 31 20 24 6e 76  om...upvar 1 $nv
1220: 20 6e 0a 09 69 66 20 7b 21 5b 6c 6c 65 6e 67 74   n..if {![llengt
1230: 68 20 24 6d 79 62 6f 74 74 6f 6d 5d 7d 20 7b 20  h $mybottom]} { 
1240: 72 65 74 75 72 6e 20 30 20 7d 0a 0a 09 73 65 74  return 0 }...set
1250: 20 6e 20 5b 6c 69 6e 64 65 78 20 5b 6c 69 6e 64   n [lindex [lind
1260: 65 78 20 24 6d 79 62 6f 74 74 6f 6d 20 30 5d 20  ex $mybottom 0] 
1270: 30 5d 0a 09 73 65 74 20 6d 79 62 6f 74 74 6f 6d  0]..set mybottom
1280: 20 5b 6c 72 61 6e 67 65 20 24 6d 79 62 6f 74 74   [lrange $mybott
1290: 6f 6d 20 31 20 65 6e 64 5d 0a 09 73 65 74 20 63  om 1 end]..set c
12a0: 68 61 6e 67 65 64 20 30 0a 0a 09 23 20 55 70 64  hanged 0...# Upd
12b0: 61 74 65 20 6c 69 73 74 20 6f 66 20 6e 6f 64 65  ate list of node
12c0: 73 20 77 69 74 68 6f 75 74 20 70 72 65 64 65 63  s without predec
12d0: 65 73 73 6f 72 2c 20 62 61 73 65 64 20 6f 6e 20  essor, based on 
12e0: 74 68 65 0a 09 23 20 6f 75 74 67 6f 69 6e 67 20  the..# outgoing 
12f0: 6e 65 69 67 68 62 6f 75 72 73 20 6f 66 20 74 68  neighbours of th
1300: 65 20 63 68 6f 73 65 6e 20 6e 6f 64 65 2e 20 54  e chosen node. T
1310: 68 69 73 20 73 68 6f 75 6c 64 20 62 65 0a 09 23  his should be..#
1320: 20 66 61 73 74 65 72 20 74 68 61 6e 20 69 74 65   faster than ite
1330: 72 61 74 69 6e 67 20 6f 66 20 74 68 65 20 77 68  rating of the wh
1340: 6f 6c 65 20 73 65 74 20 6f 66 20 6e 6f 64 65 73  ole set of nodes
1350: 2c 20 66 69 6e 64 69 6e 67 20 61 6c 6c 0a 09 23  , finding all..#
1360: 20 77 69 74 68 6f 75 74 20 70 72 65 64 65 63 65   without predece
1370: 73 73 6f 72 73 2c 20 73 6f 72 74 69 6e 67 20 74  ssors, sorting t
1380: 68 65 6d 20 62 79 20 74 69 6d 65 2c 20 65 74 63  hem by time, etc
1390: 2e 20 70 70 2e 0a 09 66 6f 72 65 61 63 68 20 6f  . pp...foreach o
13a0: 75 74 20 5b 24 64 67 20 6e 6f 64 65 73 20 2d 6f  ut [$dg nodes -o
13b0: 75 74 20 24 6e 5d 20 7b 0a 09 20 20 20 20 69 66  ut $n] {..    if
13c0: 20 7b 5b 24 64 67 20 6e 6f 64 65 20 64 65 67 72   {[$dg node degr
13d0: 65 65 20 2d 69 6e 20 24 6f 75 74 5d 20 3e 20 31  ee -in $out] > 1
13e0: 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20  } continue..    
13f0: 23 20 44 65 67 72 65 65 2d 31 20 6e 65 69 67 68  # Degree-1 neigh
1400: 62 6f 75 72 2c 20 77 69 6c 6c 20 68 61 76 65 20  bour, will have 
1410: 6e 6f 20 70 72 65 64 65 63 65 73 73 6f 72 73 20  no predecessors 
1420: 61 66 74 65 72 20 74 68 65 0a 09 20 20 20 20 23  after the..    #
1430: 20 72 65 6d 6f 76 61 6c 20 6f 66 20 6e 2e 20 50   removal of n. P
1440: 75 74 20 6f 6e 20 74 68 65 20 6c 69 73 74 2e 0a  ut on the list..
1450: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 6d 79 62  .    lappend myb
1460: 6f 74 74 6f 6d 20 5b 6c 69 6e 73 65 72 74 20 5b  ottom [linsert [
1470: 24 64 67 20 6e 6f 64 65 20 67 65 74 20 24 6f 75  $dg node get $ou
1480: 74 20 74 69 6d 65 72 61 6e 67 65 5d 20 30 20 24  t timerange] 0 $
1490: 6f 75 74 5d 0a 09 20 20 20 20 73 65 74 20 63 68  out]..    set ch
14a0: 61 6e 67 65 64 20 31 0a 09 7d 0a 09 69 66 20 7b  anged 1..}..if {
14b0: 24 63 68 61 6e 67 65 64 7d 20 7b 0a 09 20 20 20  $changed} {..   
14c0: 20 73 65 74 20 6d 79 62 6f 74 74 6f 6d 20 5b 6c   set mybottom [l
14d0: 73 6f 72 74 20 2d 69 6e 64 65 78 20 31 20 2d 69  sort -index 1 -i
14e0: 6e 74 65 67 65 72 20 5b 6c 73 6f 72 74 20 2d 69  nteger [lsort -i
14f0: 6e 64 65 78 20 32 20 2d 69 6e 74 65 67 65 72 20  ndex 2 -integer 
1500: 24 6d 79 62 6f 74 74 6f 6d 5d 5d 0a 09 7d 0a 0a  $mybottom]]..}..
1510: 09 23 20 57 65 20 64 6f 20 6e 6f 74 20 64 65 6c  .# We do not del
1520: 65 74 65 20 74 68 65 20 6e 6f 64 65 20 69 6d 6d  ete the node imm
1530: 65 64 69 61 74 65 6c 79 2c 20 74 6f 20 61 6c 6c  ediately, to all
1540: 6f 77 20 74 68 65 20 53 61 76 65 0a 09 23 20 70  ow the Save..# p
1550: 72 6f 63 65 64 75 72 65 20 74 6f 20 73 61 76 65  rocedure to save
1560: 20 74 68 65 20 64 65 70 65 6e 64 65 6e 63 69 65   the dependencie
1570: 73 20 61 73 20 77 65 6c 6c 20 28 65 6e 63 6f 64  s as well (encod
1580: 65 64 20 69 6e 20 74 68 65 0a 09 23 20 61 72 63  ed in the..# arc
1590: 73 29 2e 0a 09 72 65 74 75 72 6e 20 31 0a 20 20  s)...return 1.  
15a0: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 53 61    }..    proc Sa
15b0: 76 65 41 6e 64 52 65 6d 6f 76 65 20 7b 64 67 20  veAndRemove {dg 
15c0: 6e 7d 20 7b 0a 09 3a 3a 76 61 72 69 61 62 6c 65  n} {..::variable
15d0: 20 6d 79 61 74 0a 09 50 72 6f 63 65 73 73 65 64   myat..Processed
15e0: 48 6f 6f 6b 20 24 6e 20 24 6d 79 61 74 0a 09 24  Hook $n $myat..$
15f0: 64 67 20 6e 6f 64 65 20 64 65 6c 65 74 65 20 24  dg node delete $
1600: 6e 0a 09 69 6e 63 72 20 6d 79 61 74 0a 09 72 65  n..incr myat..re
1610: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
1620: 70 72 6f 63 20 46 69 6e 64 43 79 63 6c 65 20 7b  proc FindCycle {
1630: 64 67 7d 20 7b 0a 09 23 20 54 68 69 73 20 70 72  dg} {..# This pr
1640: 6f 63 65 64 75 72 65 20 69 73 20 72 75 6e 20 69  ocedure is run i
1650: 66 20 61 6e 64 20 6f 6e 6c 79 20 74 68 65 20 67  f and only the g
1660: 72 61 70 68 20 69 73 20 6e 6f 74 20 65 6d 70 74  raph is not empt
1670: 79 20 61 6e 64 0a 09 23 20 61 6c 6c 20 6e 6f 64  y and..# all nod
1680: 65 73 20 68 61 76 65 20 70 72 65 64 65 63 65 73  es have predeces
1690: 73 6f 72 73 2e 20 54 68 69 73 20 6d 65 61 6e 73  sors. This means
16a0: 20 74 68 61 74 20 65 61 63 68 20 6e 6f 64 65 20   that each node 
16b0: 69 73 0a 09 23 20 65 69 74 68 65 72 20 70 61 72  is..# either par
16c0: 74 20 6f 66 20 61 20 63 79 63 6c 65 20 6f 72 20  t of a cycle or 
16d0: 28 69 6e 64 69 72 65 63 74 6c 79 29 20 64 65 70  (indirectly) dep
16e0: 65 6e 64 69 6e 67 20 6f 6e 20 61 20 6e 6f 64 65  ending on a node
16f0: 0a 09 23 20 69 6e 20 61 20 63 79 63 6c 65 2e 20  ..# in a cycle. 
1700: 57 65 20 63 61 6e 20 73 74 61 72 74 20 61 74 20  We can start at 
1710: 61 6e 20 61 72 62 69 74 72 61 72 79 20 6e 6f 64  an arbitrary nod
1720: 65 2c 20 66 6f 6c 6c 6f 77 20 69 74 73 0a 09 23  e, follow its..#
1730: 20 69 6e 63 6f 6d 69 6e 67 20 65 64 67 65 73 20   incoming edges 
1740: 74 6f 20 69 74 73 20 70 72 65 64 65 63 65 73 73  to its predecess
1750: 6f 72 73 20 75 6e 74 69 6c 20 77 65 20 73 65 65  ors until we see
1760: 20 61 20 6e 6f 64 65 20 61 0a 09 23 20 73 65 63   a node a..# sec
1770: 6f 6e 64 20 74 69 6d 65 2e 20 54 68 61 74 20 6e  ond time. That n
1780: 6f 64 65 20 63 6c 6f 73 65 73 20 74 68 65 20 63  ode closes the c
1790: 79 63 6c 65 20 61 6e 64 20 74 68 65 20 62 65 67  ycle and the beg
17a0: 69 6e 6e 69 6e 67 20 69 73 0a 09 23 20 69 74 73  inning is..# its
17b0: 20 66 69 72 73 74 20 6f 63 63 75 72 65 6e 63 65   first occurence
17c0: 2e 20 4e 6f 74 65 20 74 68 61 74 20 77 65 20 63  . Note that we c
17d0: 61 6e 20 63 68 6f 6f 73 65 20 61 6e 20 61 72 62  an choose an arb
17e0: 69 74 72 61 72 79 0a 09 23 20 70 72 65 64 65 63  itrary..# predec
17f0: 65 73 73 6f 72 20 6f 66 20 65 61 63 68 20 6e 6f  essor of each no
1800: 64 65 20 61 73 20 77 65 6c 6c 2c 20 77 65 20 64  de as well, we d
1810: 6f 20 6e 6f 74 20 68 61 76 65 20 74 6f 20 73 65  o not have to se
1820: 61 72 63 68 2e 0a 0a 09 23 20 57 65 20 72 65 63  arch....# We rec
1830: 6f 72 64 20 66 6f 72 20 65 61 63 68 20 6e 6f 64  ord for each nod
1840: 65 20 74 68 65 20 69 6e 64 65 78 20 6f 66 20 74  e the index of t
1850: 68 65 20 66 69 72 73 74 20 61 70 70 65 61 72 61  he first appeara
1860: 6e 63 65 20 69 6e 0a 09 23 20 74 68 65 20 70 61  nce in..# the pa
1870: 74 68 2c 20 6d 61 6b 69 6e 67 20 69 74 20 65 61  th, making it ea
1880: 73 79 20 61 74 20 74 68 65 20 65 6e 64 20 74 6f  sy at the end to
1890: 20 63 75 74 20 74 68 65 20 63 79 63 6c 65 20 66   cut the cycle f
18a0: 72 6f 6d 0a 09 23 20 69 74 2e 0a 0a 09 23 20 43  rom..# it....# C
18b0: 68 6f 6f 73 65 20 61 72 62 69 74 72 61 72 79 20  hoose arbitrary 
18c0: 6e 6f 64 65 20 74 6f 20 73 74 61 72 74 20 6f 75  node to start ou
18d0: 72 20 73 65 61 72 63 68 20 61 74 2e 0a 09 73 65  r search at...se
18e0: 74 20 73 74 61 72 74 20 5b 6c 69 6e 64 65 78 20  t start [lindex 
18f0: 5b 24 64 67 20 6e 6f 64 65 73 5d 20 30 5d 0a 0a  [$dg nodes] 0]..
1900: 09 23 20 49 6e 69 74 69 61 6c 69 7a 65 20 73 74  .# Initialize st
1910: 61 74 65 2c 20 70 61 74 68 20 6f 66 20 73 65 65  ate, path of see
1920: 6e 20 6e 6f 64 65 73 2c 20 61 6e 64 20 77 68 65  n nodes, and whe
1930: 6e 20 73 65 65 6e 2e 0a 09 73 65 74 20 20 20 20  n seen...set    
1940: 20 20 20 70 61 74 68 20 7b 7d 0a 09 61 72 72 61     path {}..arra
1950: 79 20 73 65 74 20 73 65 65 6e 20 7b 7d 0a 0a 09  y set seen {}...
1960: 77 68 69 6c 65 20 7b 31 7d 20 7b 0a 09 20 20 20  while {1} {..   
1970: 20 23 20 53 74 6f 70 20 73 65 61 72 63 68 69 6e   # Stop searchin
1980: 67 20 77 68 65 6e 20 77 65 20 68 61 76 65 20 73  g when we have s
1990: 65 65 6e 20 74 68 65 20 63 75 72 72 65 6e 74 20  een the current 
19a0: 6e 6f 64 65 0a 09 20 20 20 20 23 20 61 6c 72 65  node..    # alre
19b0: 61 64 79 2c 20 74 68 65 20 63 69 72 63 6c 65 20  ady, the circle 
19c0: 68 61 73 20 62 65 65 6e 20 63 6c 6f 73 65 64 2e  has been closed.
19d0: 0a 09 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20  ..    if {[info 
19e0: 65 78 69 73 74 73 20 73 65 65 6e 28 24 73 74 61  exists seen($sta
19f0: 72 74 29 5d 7d 20 62 72 65 61 6b 0a 09 20 20 20  rt)]} break..   
1a00: 20 6c 61 70 70 65 6e 64 20 70 61 74 68 20 24 73   lappend path $s
1a10: 74 61 72 74 0a 09 20 20 20 20 73 65 74 20 73 65  tart..    set se
1a20: 65 6e 28 24 73 74 61 72 74 29 20 5b 65 78 70 72  en($start) [expr
1a30: 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 70 61 74 68   {[llength $path
1a40: 5d 2d 31 7d 5d 0a 09 20 20 20 20 23 20 43 68 6f  ]-1}]..    # Cho
1a50: 6f 73 65 20 61 72 62 69 74 72 61 72 79 20 70 72  ose arbitrary pr
1a60: 65 64 65 63 65 73 73 6f 72 0a 09 20 20 20 20 73  edecessor..    s
1a70: 65 74 20 73 74 61 72 74 20 5b 6c 69 6e 64 65 78  et start [lindex
1a80: 20 5b 24 64 67 20 6e 6f 64 65 73 20 2d 69 6e 20   [$dg nodes -in 
1a90: 24 73 74 61 72 74 5d 20 30 5d 0a 09 7d 0a 0a 09  $start] 0]..}...
1aa0: 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a  return [struct::
1ab0: 6c 69 73 74 20 72 65 76 65 72 73 65 20 5b 6c 72  list reverse [lr
1ac0: 61 6e 67 65 20 24 70 61 74 68 20 24 73 65 65 6e  ange $path $seen
1ad0: 28 24 73 74 61 72 74 29 20 65 6e 64 5d 5d 0a 20  ($start) end]]. 
1ae0: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 49     }..    proc I
1af0: 44 20 7b 63 73 65 74 7d 20 7b 20 72 65 74 75 72  D {cset} { retur
1b00: 6e 20 22 3c 5b 24 63 73 65 74 20 69 64 5d 3e 22  n "<[$cset id]>"
1b10: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 42 72 65   }..    proc Bre
1b20: 61 6b 43 79 63 6c 65 20 7b 64 67 20 63 79 63 6c  akCycle {dg cycl
1b30: 65 7d 20 7b 0a 09 23 20 54 68 65 20 63 79 63 6c  e} {..# The cycl
1b40: 65 20 77 65 20 68 61 76 65 20 67 6f 74 74 65 6e  e we have gotten
1b50: 20 69 73 20 62 72 6f 6b 65 6e 20 62 79 20 62 72   is broken by br
1b60: 65 61 6b 69 6e 67 20 61 70 61 72 74 20 6f 6e 65  eaking apart one
1b70: 20 6f 72 0a 09 23 20 6d 6f 72 65 20 6f 66 20 74   or..# more of t
1b80: 68 65 20 63 68 61 6e 67 65 73 65 74 73 20 69 6e  he changesets in
1b90: 20 74 68 65 20 63 79 63 6c 65 2e 20 54 68 69 73   the cycle. This
1ba0: 20 63 61 75 73 65 73 20 75 73 20 74 6f 0a 09 23   causes us to..#
1bb0: 20 63 72 65 61 74 65 20 6f 6e 65 20 6f 72 20 6d   create one or m
1bc0: 6f 72 65 20 63 68 61 6e 67 65 73 65 74 73 20 77  ore changesets w
1bd0: 68 69 63 68 20 61 72 65 20 74 6f 20 62 65 20 63  hich are to be c
1be0: 6f 6d 6d 69 74 74 65 64 2c 0a 09 23 20 61 64 64  ommitted,..# add
1bf0: 65 64 20 74 6f 20 74 68 65 20 67 72 61 70 68 2c  ed to the graph,
1c00: 20 65 74 63 2e 20 70 70 2e 0a 0a 09 73 65 74 20   etc. pp....set 
1c10: 63 70 72 69 6e 74 20 5b 6a 6f 69 6e 20 5b 73 74  cprint [join [st
1c20: 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24  ruct::list map $
1c30: 63 79 63 6c 65 20 5b 6d 79 70 72 6f 63 20 49 44  cycle [myproc ID
1c40: 5d 5d 20 7b 20 7d 5d 0a 0a 09 6c 61 70 70 65 6e  ]] { }]...lappen
1c50: 64 20 63 79 63 6c 65 20 5b 6c 69 6e 64 65 78 20  d cycle [lindex 
1c60: 24 63 79 63 6c 65 20 30 5d 20 5b 6c 69 6e 64 65  $cycle 0] [linde
1c70: 78 20 24 63 79 63 6c 65 20 31 5d 0a 09 73 65 74  x $cycle 1]..set
1c80: 20 62 65 73 74 6c 69 6e 6b 20 7b 7d 0a 09 73 65   bestlink {}..se
1c90: 74 20 62 65 73 74 6e 6f 64 65 20 7b 7d 0a 0a 09  t bestnode {}...
1ca0: 66 6f 72 65 61 63 68 20 5c 0a 09 20 20 20 20 70  foreach \..    p
1cb0: 72 65 76 20 5b 6c 72 61 6e 67 65 20 24 63 79 63  rev [lrange $cyc
1cc0: 6c 65 20 30 20 65 6e 64 2d 32 5d 20 5c 0a 09 20  le 0 end-2] \.. 
1cd0: 20 20 20 63 73 65 74 20 5b 6c 72 61 6e 67 65 20     cset [lrange 
1ce0: 24 63 79 63 6c 65 20 31 20 65 6e 64 2d 31 5d 20  $cycle 1 end-1] 
1cf0: 5c 0a 09 20 20 20 20 6e 65 78 74 20 5b 6c 72 61  \..    next [lra
1d00: 6e 67 65 20 24 63 79 63 6c 65 20 32 20 65 6e 64  nge $cycle 2 end
1d10: 5d 20 7b 0a 0a 09 09 23 20 45 61 63 68 20 74 72  ] {....# Each tr
1d20: 69 70 6c 65 20 50 52 45 56 20 2d 3e 20 43 53 45  iple PREV -> CSE
1d30: 54 20 2d 3e 20 4e 45 58 54 20 6f 66 20 63 68 61  T -> NEXT of cha
1d40: 6e 67 65 73 65 74 73 2c 20 61 0a 09 09 23 20 27  ngesets, a...# '
1d50: 6c 69 6e 6b 27 20 69 6e 20 74 68 65 20 63 79 63  link' in the cyc
1d60: 6c 65 2c 20 69 73 20 61 6e 61 6c 79 73 65 64 20  le, is analysed 
1d70: 61 6e 64 20 74 68 65 20 62 65 73 74 0a 09 09 23  and the best...#
1d80: 20 6c 6f 63 61 74 69 6f 6e 20 77 68 65 72 65 20   location where 
1d90: 74 6f 20 61 74 20 6c 65 61 73 74 20 77 65 61 6b  to at least weak
1da0: 65 6e 20 74 68 65 20 63 79 63 6c 65 20 69 73 0a  en the cycle is.
1db0: 09 09 23 20 63 68 6f 73 65 6e 20 66 6f 72 20 66  ..# chosen for f
1dc0: 75 72 74 68 65 72 20 70 72 6f 63 65 73 73 69 6e  urther processin
1dd0: 67 2e 0a 0a 09 09 73 65 74 20 6c 69 6e 6b 20 5b  g.....set link [
1de0: 70 72 6f 6a 65 63 74 3a 3a 72 65 76 6c 69 6e 6b  project::revlink
1df0: 20 25 41 55 54 4f 25 20 24 70 72 65 76 20 24 63   %AUTO% $prev $c
1e00: 73 65 74 20 24 6e 65 78 74 5d 0a 09 09 69 66 20  set $next]...if 
1e10: 7b 24 62 65 73 74 6c 69 6e 6b 20 65 71 20 22 22  {$bestlink eq ""
1e20: 7d 20 7b 0a 09 09 20 20 20 20 73 65 74 20 62 65  } {...    set be
1e30: 73 74 6c 69 6e 6b 20 24 6c 69 6e 6b 0a 09 09 20  stlink $link... 
1e40: 20 20 20 73 65 74 20 62 65 73 74 6e 6f 64 65 20     set bestnode 
1e50: 24 63 73 65 74 0a 09 09 7d 20 65 6c 73 65 69 66  $cset...} elseif
1e60: 20 7b 5b 24 6c 69 6e 6b 20 62 65 74 74 65 72 74   {[$link bettert
1e70: 68 61 6e 20 24 62 65 73 74 6c 69 6e 6b 5d 7d 20  han $bestlink]} 
1e80: 7b 0a 09 09 20 20 20 20 24 62 65 73 74 6c 69 6e  {...    $bestlin
1e90: 6b 20 64 65 73 74 72 6f 79 0a 09 09 20 20 20 20  k destroy...    
1ea0: 73 65 74 20 62 65 73 74 6c 69 6e 6b 20 24 6c 69  set bestlink $li
1eb0: 6e 6b 0a 09 09 20 20 20 20 73 65 74 20 62 65 73  nk...    set bes
1ec0: 74 6e 6f 64 65 20 24 63 73 65 74 0a 09 09 7d 20  tnode $cset...} 
1ed0: 65 6c 73 65 20 7b 0a 09 09 20 20 20 20 24 6c 69  else {...    $li
1ee0: 6e 6b 20 64 65 73 74 72 6f 79 0a 09 09 7d 0a 09  nk destroy...}..
1ef0: 20 20 20 20 7d 0a 0a 09 6c 6f 67 20 77 72 69 74      }...log writ
1f00: 65 20 35 20 62 72 65 61 6b 72 63 79 63 6c 65 20  e 5 breakrcycle 
1f10: 22 42 72 65 61 6b 69 6e 67 20 63 79 63 6c 65 20  "Breaking cycle 
1f20: 28 24 63 70 72 69 6e 74 29 20 62 79 20 73 70 6c  ($cprint) by spl
1f30: 69 74 74 69 6e 67 20 63 68 61 6e 67 65 73 65 74  itting changeset
1f40: 20 3c 5b 24 62 65 73 74 6e 6f 64 65 20 69 64 5d   <[$bestnode id]
1f50: 3e 22 0a 09 73 65 74 20 49 44 20 5b 24 62 65 73  >"..set ID [$bes
1f60: 74 6e 6f 64 65 20 69 64 5d 0a 09 4d 61 72 6b 20  tnode id]..Mark 
1f70: 24 64 67 20 2d 24 7b 49 44 7d 2d 62 65 66 6f 72  $dg -${ID}-befor
1f80: 65 0a 0a 09 73 65 74 20 6e 65 77 63 73 65 74 73  e...set newcsets
1f90: 20 5b 24 62 65 73 74 6c 69 6e 6b 20 62 72 65 61   [$bestlink brea
1fa0: 6b 5d 0a 09 24 62 65 73 74 6c 69 6e 6b 20 64 65  k]..$bestlink de
1fb0: 73 74 72 6f 79 0a 0a 20 20 20 20 20 20 20 20 23  stroy..        #
1fc0: 20 41 74 20 74 68 69 73 20 70 6f 69 6e 74 20 74   At this point t
1fd0: 68 65 20 6f 6c 64 20 63 68 61 6e 67 65 73 65 74  he old changeset
1fe0: 20 28 42 45 53 54 4e 4f 44 45 29 20 69 73 20 67   (BESTNODE) is g
1ff0: 6f 6e 65 0a 20 20 20 20 20 20 20 20 23 20 61 6c  one.        # al
2000: 72 65 61 64 79 2e 20 57 65 20 72 65 6d 6f 76 65  ready. We remove
2010: 20 69 74 20 66 72 6f 6d 20 74 68 65 20 67 72 61   it from the gra
2020: 70 68 20 61 73 20 77 65 6c 6c 20 61 6e 64 20 74  ph as well and t
2030: 68 65 6e 20 65 6e 74 65 72 0a 20 20 20 20 20 20  hen enter.      
2040: 20 20 23 20 74 68 65 20 66 72 61 67 6d 65 6e 74    # the fragment
2050: 73 20 67 65 6e 65 72 61 74 65 64 20 66 6f 72 20  s generated for 
2060: 69 74 2e 0a 0a 09 23 20 4e 4f 54 45 2e 20 57 65  it....# NOTE. We
2070: 20 68 61 76 65 20 74 6f 20 67 65 74 20 74 68 65   have to get the
2080: 20 6c 69 73 74 20 6f 66 20 69 6e 63 6f 6d 69 6e   list of incomin
2090: 67 20 6e 65 69 67 68 62 6f 75 72 73 20 61 6e 64  g neighbours and
20a0: 0a 09 23 20 72 65 63 6f 6d 70 75 74 65 20 74 68  ..# recompute th
20b0: 65 69 72 20 73 75 63 63 65 73 73 6f 72 73 20 61  eir successors a
20c0: 66 74 65 72 20 74 68 65 20 6e 65 77 20 6e 6f 64  fter the new nod
20d0: 65 73 20 68 61 76 65 20 62 65 65 6e 0a 09 23 20  es have been..# 
20e0: 69 6e 73 65 72 74 65 64 2e 20 54 68 65 69 72 20  inserted. Their 
20f0: 6f 75 74 67 6f 69 6e 67 20 61 72 63 73 20 77 69  outgoing arcs wi
2100: 6c 6c 20 6e 6f 77 20 67 6f 20 74 6f 20 6f 6e 65  ll now go to one
2110: 20 6f 72 20 62 6f 74 68 20 6f 66 0a 09 23 20 74   or both of..# t
2120: 68 65 20 6e 65 77 20 6e 6f 64 65 73 2c 20 61 6e  he new nodes, an
2130: 64 20 6e 6f 74 20 72 65 64 6f 69 6e 67 20 74 68  d not redoing th
2140: 65 6d 20 6d 61 79 20 63 61 75 73 65 20 75 73 20  em may cause us 
2150: 74 6f 20 66 6f 72 67 65 74 0a 09 23 20 63 69 72  to forget..# cir
2160: 63 6c 65 73 2c 20 6c 65 61 76 69 6e 67 20 74 68  cles, leaving th
2170: 65 6d 20 69 6e 2c 20 75 6e 62 72 6f 6b 65 6e 2e  em in, unbroken.
2180: 0a 0a 09 73 65 74 20 70 72 65 20 5b 24 64 67 20  ...set pre [$dg 
2190: 6e 6f 64 65 73 20 2d 69 6e 20 24 62 65 73 74 6e  nodes -in $bestn
21a0: 6f 64 65 5d 0a 0a 20 20 20 20 20 20 20 20 24 64  ode]..        $d
21b0: 67 20 6e 6f 64 65 20 64 65 6c 65 74 65 20 24 62  g node delete $b
21c0: 65 73 74 6e 6f 64 65 0a 0a 09 66 6f 72 65 61 63  estnode...foreac
21d0: 68 20 63 73 65 74 20 24 6e 65 77 63 73 65 74 73  h cset $newcsets
21e0: 20 7b 0a 09 20 20 20 20 24 64 67 20 6e 6f 64 65   {..    $dg node
21f0: 20 69 6e 73 65 72 74 20 24 63 73 65 74 0a 09 20   insert $cset.. 
2200: 20 20 20 24 64 67 20 6e 6f 64 65 20 73 65 74 20     $dg node set 
2210: 20 20 20 24 63 73 65 74 20 74 69 6d 65 72 61 6e     $cset timeran
2220: 67 65 20 5b 24 63 73 65 74 20 74 69 6d 65 72 61  ge [$cset timera
2230: 6e 67 65 5d 0a 09 7d 0a 0a 09 66 6f 72 65 61 63  nge]..}...foreac
2240: 68 20 63 73 65 74 20 24 6e 65 77 63 73 65 74 73  h cset $newcsets
2250: 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20   {..    foreach 
2260: 73 75 63 63 20 5b 24 63 73 65 74 20 73 75 63 63  succ [$cset succ
2270: 65 73 73 6f 72 73 5d 20 7b 0a 09 09 23 20 54 68  essors] {...# Th
2280: 65 20 6e 65 77 20 63 68 61 6e 67 65 73 65 74 73  e new changesets
2290: 20 6d 61 79 20 68 61 76 65 20 64 65 70 65 6e 64   may have depend
22a0: 65 6e 63 69 65 73 20 6f 75 74 73 69 64 65 20 6f  encies outside o
22b0: 66 0a 09 09 23 20 74 68 65 20 63 68 6f 73 65 6e  f...# the chosen
22c0: 20 73 65 74 2e 20 54 68 65 73 65 20 61 72 65 20   set. These are 
22d0: 69 67 6e 6f 72 65 64 0a 09 09 69 66 20 7b 21 5b  ignored...if {![
22e0: 24 64 67 20 6e 6f 64 65 20 65 78 69 73 74 73 20  $dg node exists 
22f0: 24 73 75 63 63 5d 7d 20 63 6f 6e 74 69 6e 75 65  $succ]} continue
2300: 0a 09 09 24 64 67 20 61 72 63 20 69 6e 73 65 72  ...$dg arc inser
2310: 74 20 24 63 73 65 74 20 24 73 75 63 63 0a 09 20  t $cset $succ.. 
2320: 20 20 20 7d 0a 09 7d 0a 09 66 6f 72 65 61 63 68     }..}..foreach
2330: 20 63 73 65 74 20 24 70 72 65 20 7b 0a 09 20 20   cset $pre {..  
2340: 20 20 66 6f 72 65 61 63 68 20 73 75 63 63 20 5b    foreach succ [
2350: 24 63 73 65 74 20 73 75 63 63 65 73 73 6f 72 73  $cset successors
2360: 5d 20 7b 0a 09 09 23 20 4e 6f 74 65 20 74 68 61  ] {...# Note tha
2370: 74 20 74 68 65 20 61 72 63 20 6d 61 79 20 61 6c  t the arc may al
2380: 72 65 61 64 79 20 65 78 69 73 74 20 69 6e 20 74  ready exist in t
2390: 68 65 20 67 72 61 70 68 2e 20 49 66 0a 09 09 23  he graph. If...#
23a0: 20 73 6f 20 69 67 6e 6f 72 65 20 69 74 2e 20 54   so ignore it. T
23b0: 68 65 20 6e 65 77 20 63 68 61 6e 67 65 73 65 74  he new changeset
23c0: 73 20 6d 61 79 20 68 61 76 65 0a 09 09 23 20 64  s may have...# d
23d0: 65 70 65 6e 64 65 6e 63 69 65 73 20 6f 75 74 73  ependencies outs
23e0: 69 64 65 20 6f 66 20 74 68 65 20 63 68 6f 73 65  ide of the chose
23f0: 6e 20 73 65 74 2e 20 54 68 65 73 65 20 61 72 65  n set. These are
2400: 0a 09 09 23 20 69 67 6e 6f 72 65 64 0a 09 09 69  ...# ignored...i
2410: 66 20 7b 21 5b 24 64 67 20 6e 6f 64 65 20 65 78  f {![$dg node ex
2420: 69 73 74 73 20 24 73 75 63 63 5d 7d 20 63 6f 6e  ists $succ]} con
2430: 74 69 6e 75 65 0a 09 09 69 66 20 7b 5b 48 61 73  tinue...if {[Has
2440: 41 72 63 20 24 64 67 20 24 63 73 65 74 20 24 73  Arc $dg $cset $s
2450: 75 63 63 5d 7d 20 63 6f 6e 74 69 6e 75 65 3b 23  ucc]} continue;#
2460: 20 54 4f 44 4f 20 73 68 6f 75 6c 64 20 62 65 20   TODO should be 
2470: 67 72 61 70 68 20 6d 65 74 68 6f 64 2e 0a 09 09  graph method....
2480: 24 64 67 20 61 72 63 20 69 6e 73 65 72 74 20 24  $dg arc insert $
2490: 63 73 65 74 20 24 73 75 63 63 0a 09 20 20 20 20  cset $succ..    
24a0: 7d 0a 09 7d 0a 0a 09 4d 61 72 6b 20 24 64 67 20  }..}...Mark $dg 
24b0: 2d 24 7b 49 44 7d 2d 61 66 74 65 72 0a 09 72 65  -${ID}-after..re
24c0: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20  turn.    }..    
24d0: 23 20 54 4f 44 4f 3a 20 54 68 69 73 20 73 68 6f  # TODO: This sho
24e0: 75 6c 64 20 62 65 20 61 20 67 72 61 70 68 20 6d  uld be a graph m
24f0: 65 74 68 6f 64 2e 0a 20 20 20 20 70 72 6f 63 20  ethod..    proc 
2500: 48 61 73 41 72 63 20 7b 64 67 20 61 20 62 7d 20  HasArc {dg a b} 
2510: 7b 0a 09 23 38 2e 35 3a 20 72 65 74 75 72 6e 20  {..#8.5: return 
2520: 5b 65 78 70 72 20 7b 24 62 20 69 6e 20 5b 24 64  [expr {$b in [$d
2530: 67 20 6e 6f 64 65 73 20 2d 6f 75 74 20 24 61 5d  g nodes -out $a]
2540: 7d 5d 0a 09 69 66 20 7b 5b 6c 73 65 61 72 63 68  }]..if {[lsearch
2550: 20 2d 65 78 61 63 74 20 5b 24 64 67 20 6e 6f 64   -exact [$dg nod
2560: 65 73 20 2d 6f 75 74 20 24 61 5d 20 24 62 5d 20  es -out $a] $b] 
2570: 3c 20 30 7d 20 7b 20 72 65 74 75 72 6e 20 30 20  < 0} { return 0 
2580: 7d 0a 09 72 65 74 75 72 6e 20 31 0a 20 20 20 20  }..return 1.    
2590: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 4d 61 72 6b  }..    proc Mark
25a0: 20 7b 64 67 20 7b 73 75 66 66 69 78 20 7b 7d 7d   {dg {suffix {}}
25b0: 7d 20 7b 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20  } {..::variable 
25c0: 6d 79 64 6f 74 64 65 73 74 69 6e 61 74 69 6f 6e  mydotdestination
25d0: 0a 09 69 66 20 7b 24 6d 79 64 6f 74 64 65 73 74  ..if {$mydotdest
25e0: 69 6e 61 74 69 6f 6e 20 65 71 20 22 22 7d 20 72  ination eq ""} r
25f0: 65 74 75 72 6e 0a 09 3a 3a 76 61 72 69 61 62 6c  eturn..::variabl
2600: 65 20 6d 79 64 6f 74 70 72 65 66 69 78 0a 09 3a  e mydotprefix..:
2610: 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 69  :variable mydoti
2620: 64 0a 09 73 65 74 20 66 6e 61 6d 65 20 24 6d 79  d..set fname $my
2630: 64 6f 74 64 65 73 74 69 6e 61 74 69 6f 6e 2f 24  dotdestination/$
2640: 7b 6d 79 64 6f 74 70 72 65 66 69 78 7d 24 7b 6d  {mydotprefix}${m
2650: 79 64 6f 74 69 64 7d 24 7b 73 75 66 66 69 78 7d  ydotid}${suffix}
2660: 2e 64 6f 74 0a 09 66 69 6c 65 20 6d 6b 64 69 72  .dot..file mkdir
2670: 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 24   [file dirname $
2680: 66 6e 61 6d 65 5d 0a 09 64 6f 74 20 77 72 69 74  fname]..dot writ
2690: 65 20 24 64 67 20 24 6d 79 64 6f 74 70 72 65 66  e $dg $mydotpref
26a0: 69 78 24 73 75 66 66 69 78 20 24 66 6e 61 6d 65  ix$suffix $fname
26b0: 0a 09 69 6e 63 72 20 6d 79 64 6f 74 69 64 0a 0a  ..incr mydotid..
26c0: 09 6c 6f 67 20 77 72 69 74 65 20 35 20 63 79 63  .log write 5 cyc
26d0: 6c 65 62 72 65 61 6b 65 72 20 22 2e 64 6f 74 20  lebreaker ".dot 
26e0: 65 78 70 6f 72 74 20 24 66 6e 61 6d 65 22 0a 09  export $fname"..
26f0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20  return.    }..  
2700: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23    # # ## ### ###
2710: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23  ## ######## ####
2720: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23  #########.    ##
2730: 20 43 61 6c 6c 62 61 63 6b 20 69 6e 76 6f 6b 61   Callback invoka
2740: 74 69 6f 6e 20 2e 2e 2e 0a 0a 20 20 20 20 70 72  tion .....    pr
2750: 6f 63 20 50 72 6f 63 65 73 73 65 64 48 6f 6f 6b  oc ProcessedHook
2760: 20 7b 63 73 65 74 20 70 6f 73 7d 20 7b 0a 09 23   {cset pos} {..#
2770: 20 47 69 76 65 20 74 68 65 20 75 73 65 72 20 6f   Give the user o
2780: 66 20 74 68 65 20 63 79 63 6c 65 20 62 72 65 61  f the cycle brea
2790: 6b 65 72 20 74 68 65 20 6f 70 70 6f 72 74 75 6e  ker the opportun
27a0: 69 74 79 20 74 6f 20 77 6f 72 6b 0a 09 23 20 77  ity to work..# w
27b0: 69 74 68 20 74 68 65 20 63 68 61 6e 67 65 73 65  ith the changese
27c0: 74 20 62 65 66 6f 72 65 20 69 74 20 69 73 20 72  t before it is r
27d0: 65 6d 6f 76 65 64 20 66 72 6f 6d 20 74 68 65 20  emoved from the 
27e0: 67 72 61 70 68 2e 0a 0a 09 3a 3a 76 61 72 69 61  graph....::varia
27f0: 62 6c 65 20 6d 79 73 61 76 65 63 6d 64 0a 09 69  ble mysavecmd..i
2800: 66 20 7b 21 5b 6c 6c 65 6e 67 74 68 20 24 6d 79  f {![llength $my
2810: 73 61 76 65 63 6d 64 5d 7d 20 72 65 74 75 72 6e  savecmd]} return
2820: 0a 0a 09 75 70 6c 65 76 65 6c 20 23 30 20 5b 6c  ...uplevel #0 [l
2830: 69 6e 73 65 72 74 20 24 6d 79 73 61 76 65 63 6d  insert $mysavecm
2840: 64 20 65 6e 64 20 24 70 6f 73 20 24 63 73 65 74  d end $pos $cset
2850: 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a  ]..return.    }.
2860: 0a 20 20 20 20 70 72 6f 63 20 43 6c 65 61 72 48  .    proc ClearH
2870: 6f 6f 6b 73 20 7b 7d 20 7b 0a 09 3a 3a 76 61 72  ooks {} {..::var
2880: 69 61 62 6c 65 20 6d 79 73 61 76 65 63 6d 64 20  iable mysavecmd 
2890: 7b 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d  {}..return.    }
28a0: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
28b0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
28c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a 20  #############.. 
28d0: 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 20     typevariable 
28e0: 6d 79 61 74 20 20 20 20 20 20 30 20 3b 20 23 20  myat      0 ; # 
28f0: 43 6f 75 6e 74 65 72 20 66 6f 72 20 63 6f 6d 6d  Counter for comm
2900: 69 74 20 69 64 73 20 66 6f 72 20 74 68 65 0a 09  it ids for the..
2910: 09 09 20 20 20 20 20 20 20 23 20 63 68 61 6e 67  ..       # chang
2920: 65 73 65 74 73 2e 0a 20 20 20 20 74 79 70 65 76  esets..    typev
2930: 61 72 69 61 62 6c 65 20 6d 79 62 6f 74 74 6f 6d  ariable mybottom
2940: 20 7b 7d 20 3b 20 23 20 4c 69 73 74 20 6f 66 20   {} ; # List of 
2950: 74 68 65 20 63 61 6e 64 69 64 61 74 65 20 6e 6f  the candidate no
2960: 64 65 73 20 66 6f 72 0a 09 09 09 20 20 20 20 20  des for....     
2970: 20 20 23 20 63 6f 6d 6d 69 74 74 69 6e 67 2e 0a    # committing..
2980: 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c  .    typevariabl
2990: 65 20 6d 79 73 61 76 65 63 6d 64 20 20 7b 7d 20  e mysavecmd  {} 
29a0: 3b 20 23 20 43 61 6c 6c 62 61 63 6b 2c 20 66 6f  ; # Callback, fo
29b0: 72 20 65 61 63 68 20 70 72 6f 63 65 73 73 65 64  r each processed
29c0: 20 6e 6f 64 65 2e 0a 0a 20 20 20 20 74 79 70 65   node...    type
29d0: 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 64 65  variable mydotde
29e0: 73 74 69 6e 61 74 69 6f 6e 20 7b 7d 20 3b 20 23  stination {} ; #
29f0: 20 44 65 73 74 69 6e 61 74 69 6f 6e 20 64 69 72   Destination dir
2a00: 65 63 74 6f 72 79 20 66 6f 72 20 74 68 65 0a 09  ectory for the..
2a10: 09 09 09 20 20 20 20 20 20 20 23 20 67 65 6e 65  ...       # gene
2a20: 72 61 74 65 64 20 2e 64 6f 74 20 66 69 6c 65 73  rated .dot files
2a30: 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62  ..    typevariab
2a40: 6c 65 20 6d 79 64 6f 74 70 72 65 66 69 78 20 20  le mydotprefix  
2a50: 20 20 20 20 7b 7d 20 3b 20 23 20 50 72 65 66 69      {} ; # Prefi
2a60: 78 20 66 6f 72 20 64 6f 74 20 66 69 6c 65 73 20  x for dot files 
2a70: 77 68 65 6e 0a 09 09 09 09 20 20 20 20 20 20 20  when.....       
2a80: 23 20 65 78 70 6f 72 74 69 6e 67 20 74 68 65 20  # exporting the 
2a90: 67 72 61 70 68 73 2e 0a 20 20 20 20 74 79 70 65  graphs..    type
2aa0: 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 69 64  variable mydotid
2ab0: 20 20 20 20 20 20 20 20 20 20 20 30 20 3b 20 23             0 ; #
2ac0: 20 43 6f 75 6e 74 65 72 20 66 6f 72 20 64 6f 74   Counter for dot
2ad0: 20 66 69 6c 65 20 6e 61 6d 65 0a 09 09 09 09 20   file name..... 
2ae0: 20 20 20 20 20 20 23 20 67 65 6e 65 72 61 74 69        # generati
2af0: 6f 6e 2e 0a 0a 20 20 20 20 23 20 23 20 23 23 20  on...    # # ## 
2b00: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23  ### ##### ######
2b10: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23  ## #############
2b20: 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75 72  .    ## Configur
2b30: 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d  ation..    pragm
2b40: 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 65 73 20  a -hasinstances 
2b50: 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74    no ; # singlet
2b60: 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68  on.    pragma -h
2b70: 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f  astypeinfo    no
2b80: 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65   ; # no introspe
2b90: 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61  ction.    pragma
2ba0: 20 2d 68 61 73 74 79 70 65 64 65 73 74 72 6f 79   -hastypedestroy
2bb0: 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c   no ; # immortal
2bc0: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23  ..    # # ## ###
2bd0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20   ##### ######## 
2be0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 7d 0a  #############.}.
2bf0: 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
2c00: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
2c10: 70 6f 72 74 3a 3a 63 76 73 20 7b 0a 20 20 20 20  port::cvs {.    
2c20: 6e 61 6d 65 73 70 61 63 65 20 65 78 70 6f 72 74  namespace export
2c30: 20 63 79 63 6c 65 62 72 65 61 6b 65 72 0a 20 20   cyclebreaker.  
2c40: 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c    namespace eval
2c50: 20 63 79 63 6c 65 62 72 65 61 6b 65 72 20 7b 0a   cyclebreaker {.
2c60: 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20  .namespace eval 
2c70: 70 72 6f 6a 65 63 74 20 7b 0a 09 20 20 20 20 6e  project {..    n
2c80: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20  amespace import 
2c90: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d  ::vc::fossil::im
2ca0: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65  port::cvs::proje
2cb0: 63 74 3a 3a 72 65 76 0a 09 20 20 20 20 6e 61 6d  ct::rev..    nam
2cc0: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a  espace import ::
2cd0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f  vc::fossil::impo
2ce0: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74  rt::cvs::project
2cf0: 3a 3a 72 65 76 6c 69 6e 6b 0a 09 7d 0a 09 6e 61  ::revlink..}..na
2d00: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a  mespace import :
2d10: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63  :vc::tools::misc
2d20: 3a 3a 2a 0a 09 6e 61 6d 65 73 70 61 63 65 20 69  ::*..namespace i
2d30: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c  mport ::vc::tool
2d40: 73 3a 3a 6c 6f 67 0a 09 6e 61 6d 65 73 70 61 63  s::log..namespac
2d50: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74  e import ::vc::t
2d60: 6f 6f 6c 73 3a 3a 64 6f 74 0a 09 6c 6f 67 20 72  ools::dot..log r
2d70: 65 67 69 73 74 65 72 20 63 79 63 6c 65 62 72 65  egister cyclebre
2d80: 61 6b 65 72 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20  aker.    }.}..# 
2d90: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23  # ## ### ##### #
2da0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23  ####### ########
2db0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23  ##### ##########
2dc0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52  ###########.## R
2dd0: 65 61 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72  eady..package pr
2de0: 6f 76 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c  ovide vc::fossil
2df0: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 63  ::import::cvs::c
2e00: 79 63 6c 65 62 72 65 61 6b 65 72 20 31 2e 30 0a  yclebreaker 1.0.
2e10: 72 65 74 75 72 6e 0a                             return.