Artifact 10b6b95ceb723019aeba896310332236d33cfe92:
File
tools/cvs2fossil/lib/c2f_cyclebreaker.tcl
part of check-in
[b42cff97e3]
- Replaced the checks for self-referential changesets in the cycle breaker with a scheme in the changeset class doing checks when splitting a changeset, which is also called by the general changeset integrity code, after each pass. Extended log output at high verbosity levels. Thorough checking of the fragments a changeset is to be split into.
by
aku on
2007-11-30 03:57:19.
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 74 ire vc::tools::t
04d0: 72 6f 75 62 6c 65 20 20 20 20 20 20 20 20 20 20 rouble
04e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 ;
04f0: 23 20 45 72 72 6f 72 20 72 65 70 6f 72 74 69 6e # Error reportin
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 74 6f 6f 6c 73 3a 3a 6d 69 re vc::tools::mi
0520: 73 63 20 20 20 20 20 20 20 20 20 20 20 20 20 20 sc
0530: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 ; #
0540: 20 54 65 78 74 20 66 6f 72 6d 61 74 74 69 6e 67 Text formatting
0550: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 ..package requir
0560: 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d e vc::fossil::im
0570: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 port::cvs::proje
0580: 63 74 3a 3a 72 65 76 20 20 20 20 20 3b 20 23 20 ct::rev ; #
0590: 50 72 6f 6a 65 63 74 20 6c 65 76 65 6c 20 63 68 Project level ch
05a0: 61 6e 67 65 73 65 74 73 0a 70 61 63 6b 61 67 65 angesets.package
05b0: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 require vc::fos
05c0: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 sil::import::cvs
05d0: 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 6c 69 ::project::revli
05e0: 6e 6b 20 3b 20 23 20 43 79 63 6c 65 20 6c 69 6e nk ; # Cycle lin
05f0: 6b 73 2e 0a 0a 23 20 23 20 23 23 20 23 23 23 20 ks...# # ## ###
0600: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 ##### ######## #
0610: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 ############ ###
0620: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0630: 23 23 0a 23 23 0a 0a 73 6e 69 74 3a 3a 74 79 70 ##.##..snit::typ
0640: 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a e ::vc::fossil::
0650: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 63 79 63 import::cvs::cyc
0660: 6c 65 62 72 65 61 6b 65 72 20 7b 0a 20 20 20 20 lebreaker {.
0670: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 # # ## ### #####
0680: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 ######## ######
0690: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 50 #######. ## P
06a0: 75 62 6c 69 63 20 41 50 49 0a 0a 20 20 20 20 74 ublic API.. t
06b0: 79 70 65 6d 65 74 68 6f 64 20 70 72 65 63 6d 64 ypemethod precmd
06c0: 20 7b 63 6d 64 7d 20 7b 0a 09 3a 3a 76 61 72 69 {cmd} {..::vari
06d0: 61 62 6c 65 20 6d 79 70 72 65 63 6d 64 20 24 63 able myprecmd $c
06e0: 6d 64 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d md..return. }
06f0: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 .. typemethod
0700: 20 73 61 76 65 63 6d 64 20 7b 63 6d 64 7d 20 7b savecmd {cmd} {
0710: 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 73 ..::variable mys
0720: 61 76 65 63 6d 64 20 24 63 6d 64 0a 09 72 65 74 avecmd $cmd..ret
0730: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 urn. }.. t
0740: 79 70 65 6d 65 74 68 6f 64 20 62 72 65 61 6b 63 ypemethod breakc
0750: 6d 64 20 7b 63 6d 64 7d 20 7b 0a 09 3a 3a 76 61 md {cmd} {..::va
0760: 72 69 61 62 6c 65 20 6d 79 62 72 65 61 6b 63 6d riable mybreakcm
0770: 64 20 24 63 6d 64 0a 09 72 65 74 75 72 6e 0a 20 d $cmd..return.
0780: 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 }.. # # ##
0790: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
07a0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
07b0: 23 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f #.. typemetho
07c0: 64 20 64 6f 74 73 74 6f 20 7b 70 61 74 68 7d 20 d dotsto {path}
07d0: 7b 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 {..::variable my
07e0: 64 6f 74 64 65 73 74 69 6e 61 74 69 6f 6e 20 24 dotdestination $
07f0: 70 61 74 68 0a 09 72 65 74 75 72 6e 0a 20 20 20 path..return.
0800: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 }.. typemeth
0810: 6f 64 20 77 61 74 63 68 20 7b 69 64 7d 20 7b 0a od watch {id} {.
0820: 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 77 61 .::variable mywa
0830: 74 63 68 69 64 73 0a 09 6c 61 70 70 65 6e 64 20 tchids..lappend
0840: 6d 79 77 61 74 63 68 69 64 73 20 24 69 64 0a 20 mywatchids $id.
0850: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 }.. typeme
0860: 74 68 6f 64 20 64 6f 74 20 7b 6c 61 62 65 6c 20 thod dot {label
0870: 63 68 61 6e 67 65 73 65 74 73 7d 20 7b 0a 09 3a changesets} {..:
0880: 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 70 :variable mydotp
0890: 72 65 66 69 78 20 24 6c 61 62 65 6c 0a 09 3a 3a refix $label..::
08a0: 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 69 64 variable mydotid
08b0: 20 20 20 20 20 30 0a 0a 09 73 65 74 20 64 67 20 0...set dg
08c0: 5b 53 65 74 75 70 20 24 63 68 61 6e 67 65 73 65 [Setup $changese
08d0: 74 73 20 30 5d 0a 09 4d 61 72 6b 20 24 64 67 0a ts 0]..Mark $dg.
08e0: 09 24 64 67 20 64 65 73 74 72 6f 79 0a 09 72 65 .$dg destroy..re
08f0: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
0900: 74 79 70 65 6d 65 74 68 6f 64 20 6d 61 72 6b 20 typemethod mark
0910: 7b 67 72 61 70 68 20 73 75 66 66 69 78 20 7b 73 {graph suffix {s
0920: 75 62 67 72 61 70 68 20 7b 7d 7d 7d 20 7b 0a 09 ubgraph {}}} {..
0930: 4d 61 72 6b 20 24 67 72 61 70 68 20 24 73 75 66 Mark $graph $suf
0940: 66 69 78 20 24 73 75 62 67 72 61 70 68 0a 09 72 fix $subgraph..r
0950: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
0960: 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 # # ## ### ####
0970: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 # ######## #####
0980: 23 23 23 23 23 23 23 23 0a 0a 20 20 20 20 74 79 ########.. ty
0990: 70 65 6d 65 74 68 6f 64 20 72 75 6e 20 7b 6c 61 pemethod run {la
09a0: 62 65 6c 20 63 68 61 6e 67 65 73 65 74 63 6d 64 bel changesetcmd
09b0: 7d 20 7b 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20 } {..::variable
09c0: 6d 79 61 74 20 20 20 20 20 20 20 20 30 0a 09 3a myat 0..:
09d0: 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 70 :variable mydotp
09e0: 72 65 66 69 78 20 24 6c 61 62 65 6c 0a 09 3a 3a refix $label..::
09f0: 76 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 69 64 variable mydotid
0a00: 20 20 20 20 20 30 0a 0a 09 23 20 57 65 20 63 72 0...# We cr
0a10: 65 61 74 65 20 61 20 67 72 61 70 68 20 6f 66 20 eate a graph of
0a20: 74 68 65 20 72 65 76 69 73 69 6f 6e 20 63 68 61 the revision cha
0a30: 6e 67 65 73 65 74 73 2c 20 75 73 69 6e 67 20 74 ngesets, using t
0a40: 68 65 20 66 69 6c 65 0a 09 23 20 6c 65 76 65 6c he file..# level
0a50: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 74 6f dependencies to
0a60: 20 63 6f 6e 73 74 72 75 63 74 20 61 20 66 69 72 construct a fir
0a70: 73 74 20 61 70 70 72 6f 78 69 6d 61 74 69 6f 6e st approximation
0a80: 20 6f 66 20 74 68 65 0a 09 23 20 64 65 70 65 6e of the..# depen
0a90: 64 65 6e 63 69 65 73 20 61 74 20 74 68 65 20 70 dencies at the p
0aa0: 72 6f 6a 65 63 74 20 6c 65 76 65 6c 2e 20 54 68 roject level. Th
0ab0: 65 6e 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20 63 en we look for c
0ac0: 79 63 6c 65 73 0a 09 23 20 69 6e 20 74 68 61 74 ycles..# in that
0ad0: 20 67 72 61 70 68 20 61 6e 64 20 62 72 65 61 6b graph and break
0ae0: 20 74 68 65 6d 2e 0a 0a 09 23 20 31 2e 20 43 72 them....# 1. Cr
0af0: 65 61 74 65 20 6e 6f 64 65 73 20 66 6f 72 20 61 eate nodes for a
0b00: 6c 6c 20 72 65 6c 65 76 61 6e 74 20 63 68 61 6e ll relevant chan
0b10: 67 65 73 65 74 73 20 61 6e 64 20 61 20 6d 61 70 gesets and a map
0b20: 70 69 6e 67 0a 09 23 20 20 20 20 66 72 6f 6d 20 ping..# from
0b30: 74 68 65 20 72 65 76 69 73 69 6f 6e 73 20 74 6f the revisions to
0b40: 20 74 68 65 69 72 20 63 68 61 6e 67 65 73 65 74 their changeset
0b50: 73 2f 6e 6f 64 65 73 2e 0a 0a 09 73 65 74 20 63 s/nodes....set c
0b60: 68 61 6e 67 65 73 65 74 73 20 5b 75 70 6c 65 76 hangesets [uplev
0b70: 65 6c 20 23 30 20 24 63 68 61 6e 67 65 73 65 74 el #0 $changeset
0b80: 63 6d 64 5d 0a 09 73 65 74 20 64 67 20 5b 53 65 cmd]..set dg [Se
0b90: 74 75 70 20 24 63 68 61 6e 67 65 73 65 74 73 5d tup $changesets]
0ba0: 0a 0a 09 23 20 33 2e 20 4c 61 73 74 6c 79 20 77 ...# 3. Lastly w
0bb0: 65 20 69 74 65 72 61 74 65 20 74 68 65 20 67 72 e iterate the gr
0bc0: 61 70 68 20 74 6f 70 6f 6c 6f 67 69 63 61 6c 6c aph topologicall
0bd0: 79 2e 20 57 65 20 6d 61 72 6b 20 6f 66 66 0a 09 y. We mark off..
0be0: 23 20 20 20 20 74 68 65 20 6e 6f 64 65 73 20 77 # the nodes w
0bf0: 68 69 63 68 20 68 61 76 65 20 6e 6f 20 70 72 65 hich have no pre
0c00: 64 65 63 65 73 73 6f 72 73 2c 20 69 6e 20 6f 72 decessors, in or
0c10: 64 65 72 20 66 72 6f 6d 0a 09 23 20 20 20 20 6f der from..# o
0c20: 6c 64 65 73 74 20 74 6f 20 79 6f 75 6e 67 65 73 ldest to younges
0c30: 74 2c 20 73 61 76 69 6e 67 20 61 6e 64 20 72 65 t, saving and re
0c40: 6d 6f 76 69 6e 67 20 64 65 70 65 6e 64 65 6e 63 moving dependenc
0c50: 69 65 73 2e 20 49 66 0a 09 23 20 20 20 20 77 65 ies. If..# we
0c60: 20 66 69 6e 64 20 6e 6f 20 6e 6f 64 65 73 20 77 find no nodes w
0c70: 69 74 68 6f 75 74 20 70 72 65 64 65 63 65 73 73 ithout predecess
0c80: 6f 72 73 20 77 65 20 68 61 76 65 20 61 20 63 79 ors we have a cy
0c90: 63 6c 65 2c 0a 09 23 20 20 20 20 61 6e 64 20 77 cle,..# and w
0ca0: 6f 72 6b 20 6f 6e 20 62 72 65 61 6b 69 6e 67 20 ork on breaking
0cb0: 69 74 2e 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 it....log write
0cc0: 33 20 63 79 63 6c 65 62 72 65 61 6b 65 72 20 7b 3 cyclebreaker {
0cd0: 54 72 61 76 65 72 73 65 20 63 68 61 6e 67 65 73 Traverse changes
0ce0: 65 74 73 7d 0a 0a 09 49 6e 69 74 69 61 6c 69 7a ets}...Initializ
0cf0: 65 43 61 6e 64 69 64 61 74 65 73 20 24 64 67 0a eCandidates $dg.
0d00: 09 77 68 69 6c 65 20 7b 31 7d 20 7b 0a 09 20 20 .while {1} {..
0d10: 20 20 77 68 69 6c 65 20 7b 5b 57 69 74 68 6f 75 while {[Withou
0d20: 74 50 72 65 64 65 63 65 73 73 6f 72 20 24 64 67 tPredecessor $dg
0d30: 20 6e 5d 7d 20 7b 0a 09 09 4d 61 72 6b 57 61 74 n]} {...MarkWat
0d40: 63 68 20 24 64 67 0a 09 09 50 72 6f 63 65 73 73 ch $dg...Process
0d50: 65 64 48 6f 6f 6b 20 24 64 67 20 24 6e 20 24 6d edHook $dg $n $m
0d60: 79 61 74 0a 09 09 24 64 67 20 6e 6f 64 65 20 64 yat...$dg node d
0d70: 65 6c 65 74 65 20 24 6e 0a 09 09 69 6e 63 72 20 elete $n...incr
0d80: 6d 79 61 74 0a 09 09 53 68 6f 77 50 65 6e 64 69 myat...ShowPendi
0d90: 6e 67 4e 6f 64 65 73 0a 09 20 20 20 20 7d 0a 0a ngNodes.. }..
0da0: 09 20 20 20 20 69 66 20 7b 21 5b 6c 6c 65 6e 67 . if {![lleng
0db0: 74 68 20 5b 64 67 20 6e 6f 64 65 73 5d 5d 7d 20 th [dg nodes]]}
0dc0: 62 72 65 61 6b 0a 0a 09 20 20 20 20 42 72 65 61 break... Brea
0dd0: 6b 43 79 63 6c 65 48 6f 6f 6b 20 20 20 20 20 20 kCycleHook
0de0: 20 24 64 67 0a 09 20 20 20 20 49 6e 69 74 69 61 $dg.. Initia
0df0: 6c 69 7a 65 43 61 6e 64 69 64 61 74 65 73 20 24 lizeCandidates $
0e00: 64 67 0a 09 20 20 20 20 4d 61 72 6b 57 61 74 63 dg.. MarkWatc
0e10: 68 20 20 20 20 20 20 20 20 20 20 20 20 24 64 67 h $dg
0e20: 0a 09 7d 0a 0a 09 24 64 67 20 64 65 73 74 72 6f ..}...$dg destro
0e30: 79 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 33 20 y...log write 3
0e40: 63 79 63 6c 65 62 72 65 61 6b 65 72 20 44 6f 6e cyclebreaker Don
0e50: 65 2e 0a 09 43 6c 65 61 72 48 6f 6f 6b 73 0a 0a e...ClearHooks..
0e60: 09 23 20 52 65 72 65 61 64 20 74 68 65 20 67 72 .# Reread the gr
0e70: 61 70 68 20 61 6e 64 20 64 75 6d 70 20 69 74 73 aph and dump its
0e80: 20 66 69 6e 61 6c 20 66 6f 72 6d 2c 20 69 66 20 final form, if
0e90: 67 72 61 70 68 20 65 78 70 6f 72 74 0a 09 23 20 graph export..#
0ea0: 77 61 73 20 61 63 74 69 76 61 74 65 64 2e 0a 0a was activated...
0eb0: 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 64 6f .::variable mydo
0ec0: 74 64 65 73 74 69 6e 61 74 69 6f 6e 0a 09 69 66 tdestination..if
0ed0: 20 7b 24 6d 79 64 6f 74 64 65 73 74 69 6e 61 74 {$mydotdestinat
0ee0: 69 6f 6e 20 65 71 20 22 22 7d 20 72 65 74 75 72 ion eq ""} retur
0ef0: 6e 0a 0a 09 73 65 74 20 20 20 64 67 20 5b 53 65 n...set dg [Se
0f00: 74 75 70 20 5b 75 70 6c 65 76 65 6c 20 23 30 20 tup [uplevel #0
0f10: 24 63 68 61 6e 67 65 73 65 74 63 6d 64 5d 20 30 $changesetcmd] 0
0f20: 5d 0a 09 4d 61 72 6b 20 24 64 67 20 2d 64 6f 6e ]..Mark $dg -don
0f30: 65 0a 09 24 64 67 20 64 65 73 74 72 6f 79 0a 09 e..$dg destroy..
0f40: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 return. }..
0f50: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 # # ## ### ###
0f60: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 ## ######## ####
0f70: 23 23 23 23 23 23 23 23 23 0a 0a 20 20 20 20 74 #########.. t
0f80: 79 70 65 6d 65 74 68 6f 64 20 62 72 65 61 6b 2d ypemethod break-
0f90: 73 65 67 6d 65 6e 74 20 7b 67 72 61 70 68 7d 20 segment {graph}
0fa0: 7b 0a 09 42 72 65 61 6b 53 65 67 6d 65 6e 74 20 {..BreakSegment
0fb0: 24 67 72 61 70 68 20 24 70 61 74 68 20 22 73 65 $graph $path "se
0fc0: 67 6d 65 6e 74 20 28 5b 70 72 6f 6a 65 63 74 3a gment ([project:
0fd0: 3a 72 65 76 20 73 74 72 6c 69 73 74 20 24 70 61 :rev strlist $pa
0fe0: 74 68 5d 29 22 0a 09 72 65 74 75 72 6e 0a 20 20 th])"..return.
0ff0: 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 }.. typemet
1000: 68 6f 64 20 62 72 65 61 6b 20 7b 67 72 61 70 68 hod break {graph
1010: 7d 20 7b 0a 09 73 65 74 20 63 79 63 6c 65 20 5b } {..set cycle [
1020: 46 69 6e 64 43 79 63 6c 65 20 24 67 72 61 70 68 FindCycle $graph
1030: 5d 0a 09 73 65 74 20 6c 61 62 65 6c 20 22 63 79 ]..set label "cy
1040: 63 6c 65 20 28 5b 70 72 6f 6a 65 63 74 3a 3a 72 cle ([project::r
1050: 65 76 20 73 74 72 6c 69 73 74 20 24 63 79 63 6c ev strlist $cycl
1060: 65 5d 29 22 0a 0a 09 23 20 4e 4f 54 45 3a 20 63 e])"...# NOTE: c
1070: 76 73 32 73 76 6e 20 75 73 65 73 20 74 68 65 20 vs2svn uses the
1080: 73 65 71 75 65 6e 63 65 20 22 65 6e 64 2d 31 2c sequence "end-1,
1090: 20 63 79 63 6c 65 2c 20 30 22 20 74 6f 20 63 72 cycle, 0" to cr
10a0: 65 61 74 65 0a 09 23 20 20 20 20 20 20 20 74 68 eate..# th
10b0: 65 20 70 61 74 68 20 66 72 6f 6d 20 74 68 65 20 e path from the
10c0: 63 79 63 6c 65 2e 20 54 68 65 20 6f 6e 6c 79 20 cycle. The only
10d0: 65 66 66 65 63 74 20 49 20 63 61 6e 20 73 65 65 effect I can see
10e0: 20 69 73 0a 09 23 20 20 20 20 20 20 20 74 68 61 is..# tha
10f0: 74 20 74 68 69 73 20 63 61 75 73 65 73 20 74 68 t this causes th
1100: 65 20 6c 69 6e 6b 2d 74 72 69 70 6c 65 73 20 74 e link-triples t
1110: 6f 20 62 65 20 67 65 6e 65 72 61 74 65 64 20 69 o be generated i
1120: 6e 20 61 0a 09 23 20 20 20 20 20 20 20 73 69 67 n a..# sig
1130: 68 74 6c 79 20 64 69 66 66 65 72 65 6e 74 20 6f htly different o
1140: 72 64 65 72 2c 20 69 2e 65 2e 20 6f 6e 65 20 6c rder, i.e. one l
1150: 69 6e 6b 20 72 6f 74 61 74 65 64 20 74 6f 20 74 ink rotated to t
1160: 68 65 0a 09 23 20 20 20 20 20 20 20 72 69 67 68 he..# righ
1170: 74 2e 20 54 68 69 73 20 73 68 6f 75 6c 64 20 68 t. This should h
1180: 61 76 65 20 6e 6f 20 65 66 66 65 63 74 20 6f 6e ave no effect on
1190: 20 74 68 65 20 73 65 61 72 63 68 20 66 6f 72 0a the search for.
11a0: 09 23 20 20 20 20 20 20 20 74 68 65 20 62 65 73 .# the bes
11b0: 74 20 6f 66 20 61 6c 6c 2e 0a 0a 09 6c 61 70 70 t of all....lapp
11c0: 65 6e 64 20 63 79 63 6c 65 20 5b 6c 69 6e 64 65 end cycle [linde
11d0: 78 20 24 63 79 63 6c 65 20 30 5d 20 5b 6c 69 6e x $cycle 0] [lin
11e0: 64 65 78 20 24 63 79 63 6c 65 20 31 5d 0a 09 42 dex $cycle 1]..B
11f0: 72 65 61 6b 53 65 67 6d 65 6e 74 20 24 67 72 61 reakSegment $gra
1200: 70 68 20 24 63 79 63 6c 65 20 24 6c 61 62 65 6c ph $cycle $label
1210: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a ..return. }..
1220: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 72 typemethod r
1230: 65 70 6c 61 63 65 20 7b 67 72 61 70 68 20 6e 20 eplace {graph n
1240: 72 65 70 6c 61 63 65 6d 65 6e 74 73 7d 20 7b 0a replacements} {.
1250: 09 52 65 70 6c 61 63 65 20 24 67 72 61 70 68 20 .Replace $graph
1260: 24 6e 20 24 72 65 70 6c 61 63 65 6d 65 6e 74 73 $n $replacements
1270: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a ..return. }..
1280: 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 # # ## ### #
1290: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 #### ######## ##
12a0: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 ###########.
12b0: 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68 ## Internal meth
12c0: 6f 64 73 0a 0a 20 20 20 20 70 72 6f 63 20 53 65 ods.. proc Se
12d0: 74 75 70 20 7b 63 68 61 6e 67 65 73 65 74 73 20 tup {changesets
12e0: 7b 6c 6f 67 20 31 7d 7d 20 7b 0a 09 69 66 20 7b {log 1}} {..if {
12f0: 24 6c 6f 67 7d 20 7b 0a 09 20 20 20 20 6c 6f 67 $log} {.. log
1300: 20 77 72 69 74 65 20 33 20 63 79 63 6c 65 62 72 write 3 cyclebr
1310: 65 61 6b 65 72 20 22 43 72 65 61 74 69 6e 67 20 eaker "Creating
1320: 67 72 61 70 68 20 6f 66 20 63 68 61 6e 67 65 73 graph of changes
1330: 65 74 73 22 0a 09 7d 0a 0a 09 73 65 74 20 64 67 ets"..}...set dg
1340: 20 5b 73 74 72 75 63 74 3a 3a 67 72 61 70 68 20 [struct::graph
1350: 64 67 5d 0a 0a 09 66 6f 72 65 61 63 68 20 63 73 dg]...foreach cs
1360: 65 74 20 24 63 68 61 6e 67 65 73 65 74 73 20 7b et $changesets {
1370: 0a 09 20 20 20 20 73 65 74 20 74 72 20 5b 24 63 .. set tr [$c
1380: 73 65 74 20 74 69 6d 65 72 61 6e 67 65 5d 0a 09 set timerange]..
1390: 20 20 20 20 24 64 67 20 6e 6f 64 65 20 69 6e 73 $dg node ins
13a0: 65 72 74 20 24 63 73 65 74 0a 09 20 20 20 20 24 ert $cset.. $
13b0: 64 67 20 6e 6f 64 65 20 73 65 74 20 20 20 20 24 dg node set $
13c0: 63 73 65 74 20 74 69 6d 65 72 61 6e 67 65 20 24 cset timerange $
13d0: 74 72 0a 09 20 20 20 20 24 64 67 20 6e 6f 64 65 tr.. $dg node
13e0: 20 73 65 74 20 20 20 20 24 63 73 65 74 20 6c 61 set $cset la
13f0: 62 65 6c 20 20 20 20 20 22 5b 24 63 73 65 74 20 bel "[$cset
1400: 73 74 72 5d 5c 5c 6e 5b 6a 6f 69 6e 20 5b 73 74 str]\\n[join [st
1410: 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 ruct::list map $
1420: 74 72 20 7b 3a 3a 63 6c 6f 63 6b 20 66 6f 72 6d tr {::clock form
1430: 61 74 7d 5d 20 22 5c 5c 6e 22 5d 22 0a 09 20 20 at}] "\\n"]"..
1440: 20 20 24 64 67 20 6e 6f 64 65 20 73 65 74 20 20 $dg node set
1450: 20 20 24 63 73 65 74 20 5f 5f 69 64 5f 5f 20 20 $cset __id__
1460: 20 20 5b 24 63 73 65 74 20 69 64 5d 0a 09 20 20 [$cset id]..
1470: 20 20 24 64 67 20 6e 6f 64 65 20 73 65 74 20 20 $dg node set
1480: 20 20 24 63 73 65 74 20 73 68 61 70 65 20 20 20 $cset shape
1490: 20 20 5b 65 78 70 72 20 7b 5b 24 63 73 65 74 20 [expr {[$cset
14a0: 62 79 73 79 6d 62 6f 6c 5d 0a 09 09 09 09 09 09 bysymbol].......
14b0: 20 20 20 3f 20 22 65 6c 6c 69 70 73 65 22 0a 09 ? "ellipse"..
14c0: 09 09 09 09 09 20 20 20 3a 20 22 62 6f 78 22 7d ..... : "box"}
14d0: 5d 0a 09 7d 0a 0a 09 69 66 20 7b 24 6c 6f 67 7d ]..}...if {$log}
14e0: 20 7b 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 {.. log writ
14f0: 65 20 33 20 63 79 63 6c 65 62 72 65 61 6b 65 72 e 3 cyclebreaker
1500: 20 22 48 61 73 20 5b 6e 73 70 20 5b 6c 6c 65 6e "Has [nsp [llen
1510: 67 74 68 20 24 63 68 61 6e 67 65 73 65 74 73 5d gth $changesets]
1520: 20 63 68 61 6e 67 65 73 65 74 5d 22 0a 09 7d 0a changeset]"..}.
1530: 0a 09 23 20 32 2e 20 46 69 6e 64 20 66 6f 72 20 ..# 2. Find for
1540: 61 6c 6c 20 72 65 6c 65 76 61 6e 74 20 63 68 61 all relevant cha
1550: 6e 67 65 73 65 74 20 74 68 65 69 72 20 72 65 76 ngeset their rev
1560: 69 73 69 6f 6e 73 20 61 6e 64 20 74 68 65 69 72 isions and their
1570: 0a 09 23 20 20 20 20 64 65 70 65 6e 64 65 6e 63 ..# dependenc
1580: 69 65 73 2e 20 4d 61 70 20 74 68 65 20 6c 61 74 ies. Map the lat
1590: 74 65 72 20 62 61 63 6b 20 74 6f 20 63 68 61 6e ter back to chan
15a0: 67 65 73 65 74 73 20 61 6e 64 0a 09 23 20 20 20 gesets and..#
15b0: 20 63 6f 6e 73 74 72 75 63 74 20 74 68 65 20 63 construct the c
15c0: 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20 61 72 63 orresponding arc
15d0: 73 2e 0a 0a 09 66 6f 72 65 61 63 68 20 63 73 65 s....foreach cse
15e0: 74 20 24 63 68 61 6e 67 65 73 65 74 73 20 7b 0a t $changesets {.
15f0: 09 20 20 20 20 66 6f 72 65 61 63 68 20 73 75 63 . foreach suc
1600: 63 20 5b 24 63 73 65 74 20 73 75 63 63 65 73 73 c [$cset success
1610: 6f 72 73 5d 20 7b 0a 09 09 23 20 43 68 61 6e 67 ors] {...# Chang
1620: 65 73 65 74 73 20 6d 61 79 20 68 61 76 65 20 64 esets may have d
1630: 65 70 65 6e 64 65 6e 63 69 65 73 20 6f 75 74 73 ependencies outs
1640: 69 64 65 20 6f 66 20 74 68 65 0a 09 09 23 20 63 ide of the...# c
1650: 68 6f 73 65 6e 20 73 65 74 2e 20 54 68 65 73 65 hosen set. These
1660: 20 61 72 65 20 69 67 6e 6f 72 65 64 0a 09 09 69 are ignored...i
1670: 66 20 7b 21 5b 24 64 67 20 6e 6f 64 65 20 65 78 f {![$dg node ex
1680: 69 73 74 73 20 24 73 75 63 63 5d 7d 20 63 6f 6e ists $succ]} con
1690: 74 69 6e 75 65 0a 09 09 24 64 67 20 61 72 63 20 tinue...$dg arc
16a0: 69 6e 73 65 72 74 20 24 63 73 65 74 20 24 73 75 insert $cset $su
16b0: 63 63 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69 cc.. }..}...i
16c0: 66 20 7b 24 6c 6f 67 7d 20 7b 0a 09 20 20 20 20 f {$log} {..
16d0: 6c 6f 67 20 77 72 69 74 65 20 33 20 63 79 63 6c log write 3 cycl
16e0: 65 62 72 65 61 6b 65 72 20 22 48 61 73 20 5b 6e ebreaker "Has [n
16f0: 73 70 20 5b 6c 6c 65 6e 67 74 68 20 5b 24 64 67 sp [llength [$dg
1700: 20 61 72 63 73 5d 5d 20 64 65 70 65 6e 64 65 6e arcs]] dependen
1710: 63 79 20 64 65 70 65 6e 64 65 6e 63 69 65 73 5d cy dependencies]
1720: 22 0a 09 7d 0a 0a 09 23 20 52 75 6e 20 74 68 65 "..}...# Run the
1730: 20 75 73 65 72 20 68 6f 6f 6b 20 74 6f 20 6d 61 user hook to ma
1740: 6e 69 70 75 6c 61 74 65 20 74 68 65 20 67 72 61 nipulate the gra
1750: 70 68 20 62 65 66 6f 72 65 0a 09 23 20 63 6f 6e ph before..# con
1760: 73 75 6d 6d 61 74 69 6f 6e 2e 0a 0a 09 69 66 20 summation....if
1770: 7b 24 6c 6f 67 7d 20 7b 20 4d 61 72 6b 20 24 64 {$log} { Mark $d
1780: 67 20 2d 73 74 61 72 74 20 7d 0a 09 4d 61 72 6b g -start }..Mark
1790: 57 61 74 63 68 20 24 64 67 0a 09 50 72 65 48 6f Watch $dg..PreHo
17a0: 6f 6b 20 20 20 24 64 67 0a 09 4d 61 72 6b 57 61 ok $dg..MarkWa
17b0: 74 63 68 20 24 64 67 0a 09 72 65 74 75 72 6e 20 tch $dg..return
17c0: 20 24 64 67 0a 20 20 20 20 7d 0a 0a 20 20 20 20 $dg. }..
17d0: 23 20 49 6e 73 74 65 61 64 20 6f 66 20 73 65 61 # Instead of sea
17e0: 72 63 68 69 6e 67 20 74 68 65 20 77 68 6f 6c 65 rching the whole
17f0: 20 67 72 61 70 68 20 66 6f 72 20 74 68 65 20 64 graph for the d
1800: 65 67 72 65 65 2d 30 20 6e 6f 64 65 73 20 69 6e egree-0 nodes in
1810: 0a 20 20 20 20 23 20 65 61 63 68 20 69 74 65 72 . # each iter
1820: 61 74 69 6f 6e 20 77 65 20 63 6f 6d 70 75 74 65 ation we compute
1830: 20 74 68 65 20 6c 69 73 74 20 6f 6e 63 65 20 74 the list once t
1840: 6f 20 73 74 61 72 74 2c 20 61 6e 64 20 74 68 65 o start, and the
1850: 6e 20 6f 6e 6c 79 0a 20 20 20 20 23 20 75 70 64 n only. # upd
1860: 61 74 65 20 69 74 20 69 6e 63 72 65 6d 65 6e 74 ate it increment
1870: 61 6c 6c 79 20 62 61 73 65 64 20 6f 6e 20 74 68 ally based on th
1880: 65 20 6f 75 74 67 6f 69 6e 67 20 6e 65 69 67 68 e outgoing neigh
1890: 62 6f 75 72 73 20 6f 66 20 74 68 65 0a 20 20 20 bours of the.
18a0: 20 23 20 6e 6f 64 65 20 63 68 6f 73 65 6e 20 66 # node chosen f
18b0: 6f 72 20 63 6f 6d 6d 69 74 2e 0a 0a 20 20 20 20 or commit...
18c0: 70 72 6f 63 20 49 6e 69 74 69 61 6c 69 7a 65 43 proc InitializeC
18d0: 61 6e 64 69 64 61 74 65 73 20 7b 64 67 7d 20 7b andidates {dg} {
18e0: 0a 09 23 20 62 6f 74 74 6f 6d 20 3d 20 6c 69 73 ..# bottom = lis
18f0: 74 20 28 6c 69 73 74 20 28 6e 6f 64 65 2c 20 72 t (list (node, r
1900: 61 6e 67 65 20 6d 69 6e 2c 20 72 61 6e 67 65 20 ange min, range
1910: 6d 61 78 29 29 0a 09 3a 3a 76 61 72 69 61 62 6c max))..::variabl
1920: 65 20 6d 79 62 6f 74 74 6f 6d 0a 09 66 6f 72 65 e mybottom..fore
1930: 61 63 68 20 6e 20 5b 24 64 67 20 6e 6f 64 65 73 ach n [$dg nodes
1940: 5d 20 7b 0a 09 20 20 20 20 69 66 20 7b 5b 24 64 ] {.. if {[$d
1950: 67 20 6e 6f 64 65 20 64 65 67 72 65 65 20 2d 69 g node degree -i
1960: 6e 20 24 6e 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a n $n]} continue.
1970: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 6d 79 62 . lappend myb
1980: 6f 74 74 6f 6d 20 5b 6c 69 6e 73 65 72 74 20 5b ottom [linsert [
1990: 24 64 67 20 6e 6f 64 65 20 67 65 74 20 24 6e 20 $dg node get $n
19a0: 74 69 6d 65 72 61 6e 67 65 5d 20 30 20 24 6e 5d timerange] 0 $n]
19b0: 0a 09 7d 0a 09 53 63 68 65 64 75 6c 65 43 61 6e ..}..ScheduleCan
19c0: 64 69 64 61 74 65 73 0a 09 53 68 6f 77 50 65 6e didates..ShowPen
19d0: 64 69 6e 67 4e 6f 64 65 73 0a 09 72 65 74 75 72 dingNodes..retur
19e0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f n. }.. pro
19f0: 63 20 57 69 74 68 6f 75 74 50 72 65 64 65 63 65 c WithoutPredece
1a00: 73 73 6f 72 20 7b 64 67 20 6e 76 7d 20 7b 0a 09 ssor {dg nv} {..
1a10: 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 62 6f 74 ::variable mybot
1a20: 74 6f 6d 0a 0a 09 75 70 76 61 72 20 31 20 24 6e tom...upvar 1 $n
1a30: 76 20 6e 0a 09 69 66 20 7b 21 5b 6c 6c 65 6e 67 v n..if {![lleng
1a40: 74 68 20 24 6d 79 62 6f 74 74 6f 6d 5d 7d 20 7b th $mybottom]} {
1a50: 20 72 65 74 75 72 6e 20 30 20 7d 0a 0a 09 73 65 return 0 }...se
1a60: 74 20 6e 20 5b 6c 69 6e 64 65 78 20 5b 6c 69 6e t n [lindex [lin
1a70: 64 65 78 20 24 6d 79 62 6f 74 74 6f 6d 20 30 5d dex $mybottom 0]
1a80: 20 30 5d 0a 09 73 65 74 20 6d 79 62 6f 74 74 6f 0]..set mybotto
1a90: 6d 20 5b 6c 72 61 6e 67 65 20 24 6d 79 62 6f 74 m [lrange $mybot
1aa0: 74 6f 6d 20 31 20 65 6e 64 5d 0a 09 73 65 74 20 tom 1 end]..set
1ab0: 63 68 61 6e 67 65 64 20 30 0a 0a 09 23 20 55 70 changed 0...# Up
1ac0: 64 61 74 65 20 6c 69 73 74 20 6f 66 20 6e 6f 64 date list of nod
1ad0: 65 73 20 77 69 74 68 6f 75 74 20 70 72 65 64 65 es without prede
1ae0: 63 65 73 73 6f 72 2c 20 62 61 73 65 64 20 6f 6e cessor, based on
1af0: 20 74 68 65 0a 09 23 20 6f 75 74 67 6f 69 6e 67 the..# outgoing
1b00: 20 6e 65 69 67 68 62 6f 75 72 73 20 6f 66 20 74 neighbours of t
1b10: 68 65 20 63 68 6f 73 65 6e 20 6e 6f 64 65 2e 20 he chosen node.
1b20: 54 68 69 73 20 73 68 6f 75 6c 64 20 62 65 0a 09 This should be..
1b30: 23 20 66 61 73 74 65 72 20 74 68 61 6e 20 69 74 # faster than it
1b40: 65 72 61 74 69 6e 67 20 6f 66 20 74 68 65 20 77 erating of the w
1b50: 68 6f 6c 65 20 73 65 74 20 6f 66 20 6e 6f 64 65 hole set of node
1b60: 73 2c 20 66 69 6e 64 69 6e 67 20 61 6c 6c 0a 09 s, finding all..
1b70: 23 20 77 69 74 68 6f 75 74 20 70 72 65 64 65 63 # without predec
1b80: 65 73 73 6f 72 73 2c 20 73 6f 72 74 69 6e 67 20 essors, sorting
1b90: 74 68 65 6d 20 62 79 20 74 69 6d 65 2c 20 65 74 them by time, et
1ba0: 63 2e 20 70 70 2e 0a 09 66 6f 72 65 61 63 68 20 c. pp...foreach
1bb0: 6f 75 74 20 5b 24 64 67 20 6e 6f 64 65 73 20 2d out [$dg nodes -
1bc0: 6f 75 74 20 24 6e 5d 20 7b 0a 09 20 20 20 20 69 out $n] {.. i
1bd0: 66 20 7b 5b 24 64 67 20 6e 6f 64 65 20 64 65 67 f {[$dg node deg
1be0: 72 65 65 20 2d 69 6e 20 24 6f 75 74 5d 20 3e 20 ree -in $out] >
1bf0: 31 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 1} continue..
1c00: 20 23 20 44 65 67 72 65 65 2d 31 20 6e 65 69 67 # Degree-1 neig
1c10: 68 62 6f 75 72 2c 20 77 69 6c 6c 20 68 61 76 65 hbour, will have
1c20: 20 6e 6f 20 70 72 65 64 65 63 65 73 73 6f 72 73 no predecessors
1c30: 20 61 66 74 65 72 20 74 68 65 0a 09 20 20 20 20 after the..
1c40: 23 20 72 65 6d 6f 76 61 6c 20 6f 66 20 6e 2e 20 # removal of n.
1c50: 50 75 74 20 6f 6e 20 74 68 65 20 6c 69 73 74 2e Put on the list.
1c60: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 6d 79 .. lappend my
1c70: 62 6f 74 74 6f 6d 20 5b 6c 69 6e 73 65 72 74 20 bottom [linsert
1c80: 5b 24 64 67 20 6e 6f 64 65 20 67 65 74 20 24 6f [$dg node get $o
1c90: 75 74 20 74 69 6d 65 72 61 6e 67 65 5d 20 30 20 ut timerange] 0
1ca0: 24 6f 75 74 5d 0a 09 20 20 20 20 73 65 74 20 63 $out].. set c
1cb0: 68 61 6e 67 65 64 20 31 0a 09 7d 0a 09 69 66 20 hanged 1..}..if
1cc0: 7b 24 63 68 61 6e 67 65 64 7d 20 7b 0a 09 20 20 {$changed} {..
1cd0: 20 20 53 63 68 65 64 75 6c 65 43 61 6e 64 69 64 ScheduleCandid
1ce0: 61 74 65 73 0a 09 7d 0a 0a 09 23 20 57 65 20 64 ates..}...# We d
1cf0: 6f 20 6e 6f 74 20 64 65 6c 65 74 65 20 74 68 65 o not delete the
1d00: 20 6e 6f 64 65 20 69 6d 6d 65 64 69 61 74 65 6c node immediatel
1d10: 79 2c 20 74 6f 20 61 6c 6c 6f 77 20 74 68 65 20 y, to allow the
1d20: 53 61 76 65 0a 09 23 20 70 72 6f 63 65 64 75 72 Save..# procedur
1d30: 65 20 74 6f 20 73 61 76 65 20 74 68 65 20 64 65 e to save the de
1d40: 70 65 6e 64 65 6e 63 69 65 73 20 61 73 20 77 65 pendencies as we
1d50: 6c 6c 20 28 65 6e 63 6f 64 65 64 20 69 6e 20 74 ll (encoded in t
1d60: 68 65 0a 09 23 20 61 72 63 73 29 2e 0a 09 72 65 he..# arcs)...re
1d70: 74 75 72 6e 20 31 0a 20 20 20 20 7d 0a 0a 20 20 turn 1. }..
1d80: 20 20 70 72 6f 63 20 53 63 68 65 64 75 6c 65 43 proc ScheduleC
1d90: 61 6e 64 69 64 61 74 65 73 20 7b 7d 20 7b 0a 09 andidates {} {..
1da0: 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 62 6f 74 ::variable mybot
1db0: 74 6f 6d 0a 09 23 20 53 6f 72 74 20 62 79 20 63 tom..# Sort by c
1dc0: 73 65 74 20 6f 62 6a 65 63 74 20 6e 61 6d 65 2c set object name,
1dd0: 20 6c 6f 77 65 72 20 62 6f 72 64 65 72 20 6f 66 lower border of
1de0: 20 74 69 6d 65 72 61 6e 67 65 2c 20 61 74 20 6c timerange, at l
1df0: 61 73 74 0a 09 23 20 62 79 20 74 68 65 20 75 70 ast..# by the up
1e00: 70 65 72 20 62 6f 72 64 65 72 2e 0a 09 73 65 74 per border...set
1e10: 20 6d 79 62 6f 74 74 6f 6d 20 5b 6c 73 6f 72 74 mybottom [lsort
1e20: 20 2d 69 6e 64 65 78 20 32 20 2d 69 6e 74 65 67 -index 2 -integ
1e30: 65 72 20 5b 6c 73 6f 72 74 20 2d 69 6e 64 65 78 er [lsort -index
1e40: 20 31 20 2d 69 6e 74 65 67 65 72 20 5b 6c 73 6f 1 -integer [lso
1e50: 72 74 20 2d 69 6e 64 65 78 20 30 20 2d 64 69 63 rt -index 0 -dic
1e60: 74 20 24 6d 79 62 6f 74 74 6f 6d 5d 5d 5d 0a 09 t $mybottom]]]..
1e70: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 return. }..
1e80: 20 20 70 72 6f 63 20 53 68 6f 77 50 65 6e 64 69 proc ShowPendi
1e90: 6e 67 4e 6f 64 65 73 20 7b 7d 20 7b 0a 09 69 66 ngNodes {} {..if
1ea0: 20 7b 5b 6c 6f 67 20 76 65 72 62 6f 73 69 74 79 {[log verbosity
1eb0: 3f 5d 20 3c 20 31 30 7d 20 72 65 74 75 72 6e 0a ?] < 10} return.
1ec0: 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 62 6f .::variable mybo
1ed0: 74 74 6f 6d 0a 09 6c 6f 67 20 77 72 69 74 65 20 ttom..log write
1ee0: 31 30 20 63 79 63 6c 65 62 72 65 61 6b 65 72 20 10 cyclebreaker
1ef0: 22 50 65 6e 64 69 6e 67 2e 2e 2e 2e 2e 2e 2e 2e "Pending........
1f00: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e ................
1f10: 2e 2e 2e 2e 2e 2e 2e 22 0a 09 66 6f 72 65 61 63 ......."..foreac
1f20: 68 20 69 74 65 6d 20 5b 73 74 72 75 63 74 3a 3a h item [struct::
1f30: 6c 69 73 74 20 6d 61 70 20 24 6d 79 62 6f 74 74 list map $mybott
1f40: 6f 6d 20 5b 6d 79 70 72 6f 63 20 46 6f 72 6d 61 om [myproc Forma
1f50: 74 50 65 6e 64 69 6e 67 49 74 65 6d 5d 5d 20 7b tPendingItem]] {
1f60: 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 .. log write
1f70: 31 30 20 63 79 63 6c 65 62 72 65 61 6b 65 72 20 10 cyclebreaker
1f80: 22 50 65 6e 64 69 6e 67 3a 20 20 20 20 20 24 69 "Pending: $i
1f90: 74 65 6d 22 0a 09 7d 0a 09 72 65 74 75 72 6e 0a tem"..}..return.
1fa0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
1fb0: 46 6f 72 6d 61 74 50 65 6e 64 69 6e 67 49 74 65 FormatPendingIte
1fc0: 6d 20 7b 69 74 65 6d 7d 20 7b 0a 09 6a 6f 69 6e m {item} {..join
1fd0: 20 5b 6c 69 73 74 20 5b 5b 6c 69 6e 64 65 78 20 [list [[lindex
1fe0: 24 69 74 65 6d 20 30 5d 20 73 74 72 5d 20 5b 63 $item 0] str] [c
1ff0: 6c 6f 63 6b 20 66 6f 72 6d 61 74 20 5b 6c 69 6e lock format [lin
2000: 64 65 78 20 24 69 74 65 6d 20 31 5d 5d 20 5b 63 dex $item 1]] [c
2010: 6c 6f 63 6b 20 66 6f 72 6d 61 74 20 5b 6c 69 6e lock format [lin
2020: 64 65 78 20 24 69 74 65 6d 20 32 5d 5d 5d 0a 20 dex $item 2]]].
2030: 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 46 }.. proc F
2040: 69 6e 64 43 79 63 6c 65 20 7b 64 67 7d 20 7b 0a indCycle {dg} {.
2050: 09 23 20 54 68 69 73 20 70 72 6f 63 65 64 75 72 .# This procedur
2060: 65 20 69 73 20 72 75 6e 20 69 66 20 61 6e 64 20 e is run if and
2070: 6f 6e 6c 79 20 74 68 65 20 67 72 61 70 68 20 69 only the graph i
2080: 73 20 6e 6f 74 20 65 6d 70 74 79 20 61 6e 64 0a s not empty and.
2090: 09 23 20 61 6c 6c 20 6e 6f 64 65 73 20 68 61 76 .# all nodes hav
20a0: 65 20 70 72 65 64 65 63 65 73 73 6f 72 73 2e 20 e predecessors.
20b0: 54 68 69 73 20 6d 65 61 6e 73 20 74 68 61 74 20 This means that
20c0: 65 61 63 68 20 6e 6f 64 65 20 69 73 0a 09 23 20 each node is..#
20d0: 65 69 74 68 65 72 20 70 61 72 74 20 6f 66 20 61 either part of a
20e0: 20 63 79 63 6c 65 20 6f 72 20 28 69 6e 64 69 72 cycle or (indir
20f0: 65 63 74 6c 79 29 20 64 65 70 65 6e 64 69 6e 67 ectly) depending
2100: 20 6f 6e 20 61 20 6e 6f 64 65 0a 09 23 20 69 6e on a node..# in
2110: 20 61 20 63 79 63 6c 65 2e 20 57 65 20 63 61 6e a cycle. We can
2120: 20 73 74 61 72 74 20 61 74 20 61 6e 20 61 72 62 start at an arb
2130: 69 74 72 61 72 79 20 6e 6f 64 65 2c 20 66 6f 6c itrary node, fol
2140: 6c 6f 77 20 69 74 73 0a 09 23 20 69 6e 63 6f 6d low its..# incom
2150: 69 6e 67 20 65 64 67 65 73 20 74 6f 20 69 74 73 ing edges to its
2160: 20 70 72 65 64 65 63 65 73 73 6f 72 73 20 75 6e predecessors un
2170: 74 69 6c 20 77 65 20 73 65 65 20 61 20 6e 6f 64 til we see a nod
2180: 65 20 61 0a 09 23 20 73 65 63 6f 6e 64 20 74 69 e a..# second ti
2190: 6d 65 2e 20 54 68 61 74 20 6e 6f 64 65 20 63 6c me. That node cl
21a0: 6f 73 65 73 20 74 68 65 20 63 79 63 6c 65 20 61 oses the cycle a
21b0: 6e 64 20 74 68 65 20 62 65 67 69 6e 6e 69 6e 67 nd the beginning
21c0: 20 69 73 0a 09 23 20 69 74 73 20 66 69 72 73 74 is..# its first
21d0: 20 6f 63 63 75 72 65 6e 63 65 2e 20 4e 6f 74 65 occurence. Note
21e0: 20 74 68 61 74 20 77 65 20 63 61 6e 20 63 68 6f that we can cho
21f0: 6f 73 65 20 61 6e 20 61 72 62 69 74 72 61 72 79 ose an arbitrary
2200: 0a 09 23 20 70 72 65 64 65 63 65 73 73 6f 72 20 ..# predecessor
2210: 6f 66 20 65 61 63 68 20 6e 6f 64 65 20 61 73 20 of each node as
2220: 77 65 6c 6c 2c 20 77 65 20 64 6f 20 6e 6f 74 20 well, we do not
2230: 68 61 76 65 20 74 6f 20 73 65 61 72 63 68 2e 0a have to search..
2240: 0a 09 23 20 57 65 20 72 65 63 6f 72 64 20 66 6f ..# We record fo
2250: 72 20 65 61 63 68 20 6e 6f 64 65 20 74 68 65 20 r each node the
2260: 69 6e 64 65 78 20 6f 66 20 74 68 65 20 66 69 72 index of the fir
2270: 73 74 20 61 70 70 65 61 72 61 6e 63 65 20 69 6e st appearance in
2280: 0a 09 23 20 74 68 65 20 70 61 74 68 2c 20 6d 61 ..# the path, ma
2290: 6b 69 6e 67 20 69 74 20 65 61 73 79 20 61 74 20 king it easy at
22a0: 74 68 65 20 65 6e 64 20 74 6f 20 63 75 74 20 74 the end to cut t
22b0: 68 65 20 63 79 63 6c 65 20 66 72 6f 6d 0a 09 23 he cycle from..#
22c0: 20 69 74 2e 0a 0a 09 23 20 43 68 6f 6f 73 65 20 it....# Choose
22d0: 61 72 62 69 74 72 61 72 79 20 6e 6f 64 65 20 74 arbitrary node t
22e0: 6f 20 73 74 61 72 74 20 6f 75 72 20 73 65 61 72 o start our sear
22f0: 63 68 20 61 74 2e 0a 09 73 65 74 20 73 74 61 72 ch at...set star
2300: 74 20 5b 6c 69 6e 64 65 78 20 5b 24 64 67 20 6e t [lindex [$dg n
2310: 6f 64 65 73 5d 20 30 5d 0a 0a 09 23 20 49 6e 69 odes] 0]...# Ini
2320: 74 69 61 6c 69 7a 65 20 73 74 61 74 65 2c 20 70 tialize state, p
2330: 61 74 68 20 6f 66 20 73 65 65 6e 20 6e 6f 64 65 ath of seen node
2340: 73 2c 20 61 6e 64 20 77 68 65 6e 20 73 65 65 6e s, and when seen
2350: 2e 0a 09 73 65 74 20 20 20 20 20 20 20 70 61 74 ...set pat
2360: 68 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 20 h {}..array set
2370: 73 65 65 6e 20 7b 7d 0a 0a 09 77 68 69 6c 65 20 seen {}...while
2380: 7b 31 7d 20 7b 0a 09 20 20 20 20 23 20 53 74 6f {1} {.. # Sto
2390: 70 20 73 65 61 72 63 68 69 6e 67 20 77 68 65 6e p searching when
23a0: 20 77 65 20 68 61 76 65 20 73 65 65 6e 20 74 68 we have seen th
23b0: 65 20 63 75 72 72 65 6e 74 20 6e 6f 64 65 0a 09 e current node..
23c0: 20 20 20 20 23 20 61 6c 72 65 61 64 79 2c 20 74 # already, t
23d0: 68 65 20 63 69 72 63 6c 65 20 68 61 73 20 62 65 he circle has be
23e0: 65 6e 20 63 6c 6f 73 65 64 2e 0a 09 20 20 20 20 en closed...
23f0: 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 73 if {[info exists
2400: 20 73 65 65 6e 28 24 73 74 61 72 74 29 5d 7d 20 seen($start)]}
2410: 62 72 65 61 6b 0a 09 20 20 20 20 6c 61 70 70 65 break.. lappe
2420: 6e 64 20 70 61 74 68 20 24 73 74 61 72 74 0a 09 nd path $start..
2430: 20 20 20 20 73 65 74 20 73 65 65 6e 28 24 73 74 set seen($st
2440: 61 72 74 29 20 5b 65 78 70 72 20 7b 5b 6c 6c 65 art) [expr {[lle
2450: 6e 67 74 68 20 24 70 61 74 68 5d 2d 31 7d 5d 0a ngth $path]-1}].
2460: 09 20 20 20 20 23 20 43 68 6f 6f 73 65 20 61 72 . # Choose ar
2470: 62 69 74 72 61 72 79 20 70 72 65 64 65 63 65 73 bitrary predeces
2480: 73 6f 72 0a 09 20 20 20 20 73 65 74 20 73 74 61 sor.. set sta
2490: 72 74 20 5b 6c 69 6e 64 65 78 20 5b 24 64 67 20 rt [lindex [$dg
24a0: 6e 6f 64 65 73 20 2d 69 6e 20 24 73 74 61 72 74 nodes -in $start
24b0: 5d 20 30 5d 0a 09 7d 0a 0a 09 72 65 74 75 72 6e ] 0]..}...return
24c0: 20 5b 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 72 [struct::list r
24d0: 65 76 65 72 73 65 20 5b 6c 72 61 6e 67 65 20 24 everse [lrange $
24e0: 70 61 74 68 20 24 73 65 65 6e 28 24 73 74 61 72 path $seen($star
24f0: 74 29 20 65 6e 64 5d 5d 0a 20 20 20 20 7d 0a 0a t) end]]. }..
2500: 20 20 20 20 70 72 6f 63 20 42 72 65 61 6b 53 65 proc BreakSe
2510: 67 6d 65 6e 74 20 7b 64 67 20 70 61 74 68 20 6c gment {dg path l
2520: 61 62 65 6c 7d 20 7b 0a 09 23 20 54 68 65 20 70 abel} {..# The p
2530: 61 74 68 2c 20 75 73 75 61 6c 6c 79 20 61 20 63 ath, usually a c
2540: 79 63 6c 65 2c 20 77 65 20 68 61 76 65 20 67 6f ycle, we have go
2550: 74 74 65 6e 20 69 73 20 62 72 6f 6b 65 6e 20 62 tten is broken b
2560: 79 0a 09 23 20 62 72 65 61 6b 69 6e 67 20 61 70 y..# breaking ap
2570: 61 72 74 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 art one or more
2580: 6f 66 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 of the changeset
2590: 73 20 69 6e 20 74 68 65 0a 09 23 20 63 79 63 6c s in the..# cycl
25a0: 65 2e 20 54 68 69 73 20 63 61 75 73 65 73 20 75 e. This causes u
25b0: 73 20 74 6f 20 63 72 65 61 74 65 20 6f 6e 65 20 s to create one
25c0: 6f 72 20 6d 6f 72 65 20 63 68 61 6e 67 65 73 65 or more changese
25d0: 74 73 20 77 68 69 63 68 0a 09 23 20 61 72 65 20 ts which..# are
25e0: 74 6f 20 62 65 20 63 6f 6d 6d 69 74 74 65 64 2c to be committed,
25f0: 20 61 64 64 65 64 20 74 6f 20 74 68 65 20 67 72 added to the gr
2600: 61 70 68 2c 20 65 74 63 2e 20 70 70 2e 0a 0a 09 aph, etc. pp....
2610: 73 65 74 20 62 65 73 74 6c 69 6e 6b 20 7b 7d 0a set bestlink {}.
2620: 09 73 65 74 20 62 65 73 74 6e 6f 64 65 20 7b 7d .set bestnode {}
2630: 0a 0a 09 66 6f 72 65 61 63 68 20 5c 0a 09 20 20 ...foreach \..
2640: 20 20 70 72 65 76 20 5b 6c 72 61 6e 67 65 20 24 prev [lrange $
2650: 70 61 74 68 20 30 20 65 6e 64 2d 32 5d 20 5c 0a path 0 end-2] \.
2660: 09 20 20 20 20 63 73 65 74 20 5b 6c 72 61 6e 67 . cset [lrang
2670: 65 20 24 70 61 74 68 20 31 20 65 6e 64 2d 31 5d e $path 1 end-1]
2680: 20 5c 0a 09 20 20 20 20 6e 65 78 74 20 5b 6c 72 \.. next [lr
2690: 61 6e 67 65 20 24 70 61 74 68 20 32 20 65 6e 64 ange $path 2 end
26a0: 5d 20 7b 0a 0a 09 09 23 20 45 61 63 68 20 74 72 ] {....# Each tr
26b0: 69 70 6c 65 20 50 52 45 56 20 2d 3e 20 43 53 45 iple PREV -> CSE
26c0: 54 20 2d 3e 20 4e 45 58 54 20 6f 66 20 63 68 61 T -> NEXT of cha
26d0: 6e 67 65 73 65 74 73 2c 20 61 0a 09 09 23 20 27 ngesets, a...# '
26e0: 6c 69 6e 6b 27 20 69 6e 20 74 68 65 20 63 79 63 link' in the cyc
26f0: 6c 65 2c 20 69 73 20 61 6e 61 6c 79 73 65 64 20 le, is analysed
2700: 61 6e 64 20 74 68 65 20 62 65 73 74 0a 09 09 23 and the best...#
2710: 20 6c 6f 63 61 74 69 6f 6e 20 77 68 65 72 65 20 location where
2720: 74 6f 20 61 74 20 6c 65 61 73 74 20 77 65 61 6b to at least weak
2730: 65 6e 20 74 68 65 20 63 79 63 6c 65 20 69 73 0a en the cycle is.
2740: 09 09 23 20 63 68 6f 73 65 6e 20 66 6f 72 20 66 ..# chosen for f
2750: 75 72 74 68 65 72 20 70 72 6f 63 65 73 73 69 6e urther processin
2760: 67 2e 0a 0a 09 09 73 65 74 20 6c 69 6e 6b 20 5b g.....set link [
2770: 70 72 6f 6a 65 63 74 3a 3a 72 65 76 6c 69 6e 6b project::revlink
2780: 20 25 41 55 54 4f 25 20 24 70 72 65 76 20 24 63 %AUTO% $prev $c
2790: 73 65 74 20 24 6e 65 78 74 5d 0a 09 09 69 66 20 set $next]...if
27a0: 7b 24 62 65 73 74 6c 69 6e 6b 20 65 71 20 22 22 {$bestlink eq ""
27b0: 7d 20 7b 0a 09 09 20 20 20 20 73 65 74 20 62 65 } {... set be
27c0: 73 74 6c 69 6e 6b 20 24 6c 69 6e 6b 0a 09 09 20 stlink $link...
27d0: 20 20 20 73 65 74 20 62 65 73 74 6e 6f 64 65 20 set bestnode
27e0: 24 63 73 65 74 0a 09 09 7d 20 65 6c 73 65 69 66 $cset...} elseif
27f0: 20 7b 5b 24 6c 69 6e 6b 20 62 65 74 74 65 72 74 {[$link bettert
2800: 68 61 6e 20 24 62 65 73 74 6c 69 6e 6b 5d 7d 20 han $bestlink]}
2810: 7b 0a 09 09 20 20 20 20 24 62 65 73 74 6c 69 6e {... $bestlin
2820: 6b 20 64 65 73 74 72 6f 79 0a 09 09 20 20 20 20 k destroy...
2830: 73 65 74 20 62 65 73 74 6c 69 6e 6b 20 24 6c 69 set bestlink $li
2840: 6e 6b 0a 09 09 20 20 20 20 73 65 74 20 62 65 73 nk... set bes
2850: 74 6e 6f 64 65 20 24 63 73 65 74 0a 09 09 7d 20 tnode $cset...}
2860: 65 6c 73 65 20 7b 0a 09 09 20 20 20 20 24 6c 69 else {... $li
2870: 6e 6b 20 64 65 73 74 72 6f 79 0a 09 09 7d 0a 09 nk destroy...}..
2880: 20 20 20 20 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 }...log writ
2890: 65 20 35 20 63 79 63 6c 65 62 72 65 61 6b 65 72 e 5 cyclebreaker
28a0: 20 22 42 72 65 61 6b 69 6e 67 20 24 6c 61 62 65 "Breaking $labe
28b0: 6c 20 62 79 20 73 70 6c 69 74 74 69 6e 67 20 63 l by splitting c
28c0: 68 61 6e 67 65 73 65 74 20 5b 24 62 65 73 74 6e hangeset [$bestn
28d0: 6f 64 65 20 73 74 72 5d 22 0a 09 73 65 74 20 49 ode str]"..set I
28e0: 44 20 5b 24 62 65 73 74 6e 6f 64 65 20 69 64 5d D [$bestnode id]
28f0: 0a 09 4d 61 72 6b 20 24 64 67 20 2d 24 7b 49 44 ..Mark $dg -${ID
2900: 7d 2d 62 65 66 6f 72 65 0a 0a 09 73 65 74 20 6e }-before...set n
2910: 65 77 63 73 65 74 73 20 5b 24 62 65 73 74 6c 69 ewcsets [$bestli
2920: 6e 6b 20 62 72 65 61 6b 5d 0a 09 24 62 65 73 74 nk break]..$best
2930: 6c 69 6e 6b 20 64 65 73 74 72 6f 79 0a 0a 20 20 link destroy..
2940: 20 20 20 20 20 20 23 20 41 74 20 74 68 69 73 20 # At this
2950: 70 6f 69 6e 74 20 74 68 65 20 6f 6c 64 20 63 68 point the old ch
2960: 61 6e 67 65 73 65 74 20 28 42 45 53 54 4e 4f 44 angeset (BESTNOD
2970: 45 29 20 69 73 20 67 6f 6e 65 0a 20 20 20 20 20 E) is gone.
2980: 20 20 20 23 20 61 6c 72 65 61 64 79 2e 20 57 65 # already. We
2990: 20 72 65 6d 6f 76 65 20 69 74 20 66 72 6f 6d 20 remove it from
29a0: 74 68 65 20 67 72 61 70 68 20 61 73 20 77 65 6c the graph as wel
29b0: 6c 20 61 6e 64 20 74 68 65 6e 20 65 6e 74 65 72 l and then enter
29c0: 0a 20 20 20 20 20 20 20 20 23 20 74 68 65 20 66 . # the f
29d0: 72 61 67 6d 65 6e 74 73 20 67 65 6e 65 72 61 74 ragments generat
29e0: 65 64 20 66 6f 72 20 69 74 2e 0a 0a 09 52 65 70 ed for it....Rep
29f0: 6c 61 63 65 20 24 64 67 20 24 62 65 73 74 6e 6f lace $dg $bestno
2a00: 64 65 20 24 6e 65 77 63 73 65 74 73 0a 0a 09 4d de $newcsets...M
2a10: 61 72 6b 20 24 64 67 20 2d 24 7b 49 44 7d 2d 61 ark $dg -${ID}-a
2a20: 66 74 65 72 0a 09 72 65 74 75 72 6e 0a 20 20 20 fter..return.
2a30: 20 7d 0a 0a 20 20 20 20 23 20 54 4f 44 4f 3a 20 }.. # TODO:
2a40: 54 68 69 73 20 73 68 6f 75 6c 64 20 62 65 20 61 This should be a
2a50: 20 67 72 61 70 68 20 6d 65 74 68 6f 64 2e 0a 20 graph method..
2a60: 20 20 20 70 72 6f 63 20 48 61 73 41 72 63 20 7b proc HasArc {
2a70: 64 67 20 61 20 62 7d 20 7b 0a 09 23 38 2e 35 3a dg a b} {..#8.5:
2a80: 20 72 65 74 75 72 6e 20 5b 65 78 70 72 20 7b 24 return [expr {$
2a90: 62 20 69 6e 20 5b 24 64 67 20 6e 6f 64 65 73 20 b in [$dg nodes
2aa0: 2d 6f 75 74 20 24 61 5d 7d 5d 0a 09 69 66 20 7b -out $a]}]..if {
2ab0: 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 63 74 20 [lsearch -exact
2ac0: 5b 24 64 67 20 6e 6f 64 65 73 20 2d 6f 75 74 20 [$dg nodes -out
2ad0: 24 61 5d 20 24 62 5d 20 3c 20 30 7d 20 7b 20 72 $a] $b] < 0} { r
2ae0: 65 74 75 72 6e 20 30 20 7d 0a 09 72 65 74 75 72 eturn 0 }..retur
2af0: 6e 20 31 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 n 1. }.. p
2b00: 72 6f 63 20 4d 61 72 6b 20 7b 64 67 20 7b 73 75 roc Mark {dg {su
2b10: 66 66 69 78 20 7b 7d 7d 20 7b 73 75 62 67 72 61 ffix {}} {subgra
2b20: 70 68 20 7b 7d 7d 7d 20 7b 0a 09 3a 3a 76 61 72 ph {}}} {..::var
2b30: 69 61 62 6c 65 20 6d 79 64 6f 74 64 65 73 74 69 iable mydotdesti
2b40: 6e 61 74 69 6f 6e 0a 09 69 66 20 7b 24 6d 79 64 nation..if {$myd
2b50: 6f 74 64 65 73 74 69 6e 61 74 69 6f 6e 20 65 71 otdestination eq
2b60: 20 22 22 7d 20 72 65 74 75 72 6e 0a 09 3a 3a 76 ""} return..::v
2b70: 61 72 69 61 62 6c 65 20 6d 79 64 6f 74 70 72 65 ariable mydotpre
2b80: 66 69 78 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20 fix..::variable
2b90: 6d 79 64 6f 74 69 64 0a 09 73 65 74 20 66 6e 61 mydotid..set fna
2ba0: 6d 65 20 24 6d 79 64 6f 74 64 65 73 74 69 6e 61 me $mydotdestina
2bb0: 74 69 6f 6e 2f 24 7b 6d 79 64 6f 74 70 72 65 66 tion/${mydotpref
2bc0: 69 78 7d 24 7b 6d 79 64 6f 74 69 64 7d 24 7b 73 ix}${mydotid}${s
2bd0: 75 66 66 69 78 7d 2e 64 6f 74 0a 09 66 69 6c 65 uffix}.dot..file
2be0: 20 6d 6b 64 69 72 20 5b 66 69 6c 65 20 64 69 72 mkdir [file dir
2bf0: 6e 61 6d 65 20 24 66 6e 61 6d 65 5d 0a 09 64 6f name $fname]..do
2c00: 74 20 77 72 69 74 65 20 24 64 67 20 24 6d 79 64 t write $dg $myd
2c10: 6f 74 70 72 65 66 69 78 24 73 75 66 66 69 78 20 otprefix$suffix
2c20: 24 66 6e 61 6d 65 20 24 73 75 62 67 72 61 70 68 $fname $subgraph
2c30: 0a 09 69 6e 63 72 20 6d 79 64 6f 74 69 64 0a 0a ..incr mydotid..
2c40: 09 6c 6f 67 20 77 72 69 74 65 20 35 20 63 79 63 .log write 5 cyc
2c50: 6c 65 62 72 65 61 6b 65 72 20 22 2e 64 6f 74 20 lebreaker ".dot
2c60: 65 78 70 6f 72 74 20 24 66 6e 61 6d 65 22 0a 09 export $fname"..
2c70: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 return. }..
2c80: 20 20 70 72 6f 63 20 52 65 70 6c 61 63 65 20 7b proc Replace {
2c90: 64 67 20 6e 20 72 65 70 6c 61 63 65 6d 65 6e 74 dg n replacement
2ca0: 73 7d 20 7b 0a 09 23 20 4e 4f 54 45 2e 20 57 65 s} {..# NOTE. We
2cb0: 20 68 61 76 65 20 74 6f 20 67 65 74 20 74 68 65 have to get the
2cc0: 20 6c 69 73 74 20 6f 66 20 69 6e 63 6f 6d 69 6e list of incomin
2cd0: 67 20 6e 65 69 67 68 62 6f 75 72 73 20 61 6e 64 g neighbours and
2ce0: 0a 09 23 20 72 65 63 6f 6d 70 75 74 65 20 74 68 ..# recompute th
2cf0: 65 69 72 20 73 75 63 63 65 73 73 6f 72 73 20 61 eir successors a
2d00: 66 74 65 72 20 74 68 65 20 6e 65 77 20 6e 6f 64 fter the new nod
2d10: 65 73 20 68 61 76 65 20 62 65 65 6e 0a 09 23 20 es have been..#
2d20: 69 6e 73 65 72 74 65 64 2e 20 54 68 65 69 72 20 inserted. Their
2d30: 6f 75 74 67 6f 69 6e 67 20 61 72 63 73 20 77 69 outgoing arcs wi
2d40: 6c 6c 20 6e 6f 77 20 67 6f 20 74 6f 20 6f 6e 65 ll now go to one
2d50: 20 6f 72 20 62 6f 74 68 20 6f 66 0a 09 23 20 74 or both of..# t
2d60: 68 65 20 6e 65 77 20 6e 6f 64 65 73 2c 20 61 6e he new nodes, an
2d70: 64 20 6e 6f 74 20 72 65 64 6f 69 6e 67 20 74 68 d not redoing th
2d80: 65 6d 20 6d 61 79 20 63 61 75 73 65 20 75 73 20 em may cause us
2d90: 74 6f 20 66 6f 72 67 65 74 0a 09 23 20 63 69 72 to forget..# cir
2da0: 63 6c 65 73 2c 20 6c 65 61 76 69 6e 67 20 74 68 cles, leaving th
2db0: 65 6d 20 69 6e 2c 20 75 6e 62 72 6f 6b 65 6e 2e em in, unbroken.
2dc0: 0a 0a 09 73 65 74 20 70 72 65 20 5b 24 64 67 20 ...set pre [$dg
2dd0: 6e 6f 64 65 73 20 2d 69 6e 20 24 6e 5d 0a 0a 20 nodes -in $n]..
2de0: 20 20 20 20 20 20 20 24 64 67 20 6e 6f 64 65 20 $dg node
2df0: 64 65 6c 65 74 65 20 24 6e 0a 0a 09 66 6f 72 65 delete $n...fore
2e00: 61 63 68 20 63 73 65 74 20 24 72 65 70 6c 61 63 ach cset $replac
2e10: 65 6d 65 6e 74 73 20 7b 0a 09 20 20 20 20 73 65 ements {.. se
2e20: 74 20 74 72 20 5b 24 63 73 65 74 20 74 69 6d 65 t tr [$cset time
2e30: 72 61 6e 67 65 5d 0a 09 20 20 20 20 24 64 67 20 range].. $dg
2e40: 6e 6f 64 65 20 69 6e 73 65 72 74 20 24 63 73 65 node insert $cse
2e50: 74 0a 09 20 20 20 20 24 64 67 20 6e 6f 64 65 20 t.. $dg node
2e60: 73 65 74 20 20 20 20 24 63 73 65 74 20 74 69 6d set $cset tim
2e70: 65 72 61 6e 67 65 20 24 74 72 0a 09 20 20 20 20 erange $tr..
2e80: 24 64 67 20 6e 6f 64 65 20 73 65 74 20 20 20 20 $dg node set
2e90: 24 63 73 65 74 20 6c 61 62 65 6c 20 20 20 20 20 $cset label
2ea0: 22 5b 24 63 73 65 74 20 73 74 72 5d 5c 5c 6e 5b "[$cset str]\\n[
2eb0: 6a 6f 69 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69 join [struct::li
2ec0: 73 74 20 6d 61 70 20 24 74 72 20 7b 3a 3a 63 6c st map $tr {::cl
2ed0: 6f 63 6b 20 66 6f 72 6d 61 74 7d 5d 20 22 5c 5c ock format}] "\\
2ee0: 6e 22 5d 22 0a 09 20 20 20 20 24 64 67 20 6e 6f n"]".. $dg no
2ef0: 64 65 20 73 65 74 20 20 20 20 24 63 73 65 74 20 de set $cset
2f00: 5f 5f 69 64 5f 5f 20 20 20 20 5b 24 63 73 65 74 __id__ [$cset
2f10: 20 69 64 5d 0a 09 20 20 20 20 24 64 67 20 6e 6f id].. $dg no
2f20: 64 65 20 73 65 74 20 20 20 20 24 63 73 65 74 20 de set $cset
2f30: 73 68 61 70 65 20 20 20 20 20 5b 65 78 70 72 20 shape [expr
2f40: 7b 5b 24 63 73 65 74 20 62 79 73 79 6d 62 6f 6c {[$cset bysymbol
2f50: 5d 0a 09 09 09 09 09 09 20 20 20 3f 20 22 65 6c ]....... ? "el
2f60: 6c 69 70 73 65 22 0a 09 09 09 09 09 09 20 20 20 lipse".......
2f70: 3a 20 22 62 6f 78 22 7d 5d 0a 09 7d 0a 0a 09 66 : "box"}]..}...f
2f80: 6f 72 65 61 63 68 20 63 73 65 74 20 24 72 65 70 oreach cset $rep
2f90: 6c 61 63 65 6d 65 6e 74 73 20 7b 0a 09 20 20 20 lacements {..
2fa0: 20 66 6f 72 65 61 63 68 20 73 75 63 63 20 5b 24 foreach succ [$
2fb0: 63 73 65 74 20 73 75 63 63 65 73 73 6f 72 73 5d cset successors]
2fc0: 20 7b 0a 09 09 23 20 54 68 65 20 6e 65 77 20 63 {...# The new c
2fd0: 68 61 6e 67 65 73 65 74 73 20 6d 61 79 20 68 61 hangesets may ha
2fe0: 76 65 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 ve dependencies
2ff0: 6f 75 74 73 69 64 65 20 6f 66 0a 09 09 23 20 74 outside of...# t
3000: 68 65 20 63 68 6f 73 65 6e 20 73 65 74 2e 20 54 he chosen set. T
3010: 68 65 73 65 20 61 72 65 20 69 67 6e 6f 72 65 64 hese are ignored
3020: 0a 09 09 69 66 20 7b 21 5b 24 64 67 20 6e 6f 64 ...if {![$dg nod
3030: 65 20 65 78 69 73 74 73 20 24 73 75 63 63 5d 7d e exists $succ]}
3040: 20 63 6f 6e 74 69 6e 75 65 0a 09 09 24 64 67 20 continue...$dg
3050: 61 72 63 20 69 6e 73 65 72 74 20 24 63 73 65 74 arc insert $cset
3060: 20 24 73 75 63 63 0a 09 20 20 20 20 7d 0a 09 7d $succ.. }..}
3070: 0a 09 66 6f 72 65 61 63 68 20 63 73 65 74 20 24 ..foreach cset $
3080: 70 72 65 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 pre {.. forea
3090: 63 68 20 73 75 63 63 20 5b 24 63 73 65 74 20 73 ch succ [$cset s
30a0: 75 63 63 65 73 73 6f 72 73 5d 20 7b 0a 09 09 23 uccessors] {...#
30b0: 20 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20 61 Note that the a
30c0: 72 63 20 6d 61 79 20 61 6c 72 65 61 64 79 20 65 rc may already e
30d0: 78 69 73 74 20 69 6e 20 74 68 65 20 67 72 61 70 xist in the grap
30e0: 68 2e 20 49 66 0a 09 09 23 20 73 6f 20 69 67 6e h. If...# so ign
30f0: 6f 72 65 20 69 74 2e 20 54 68 65 20 6e 65 77 20 ore it. The new
3100: 63 68 61 6e 67 65 73 65 74 73 20 6d 61 79 20 68 changesets may h
3110: 61 76 65 0a 09 09 23 20 64 65 70 65 6e 64 65 6e ave...# dependen
3120: 63 69 65 73 20 6f 75 74 73 69 64 65 20 6f 66 20 cies outside of
3130: 74 68 65 20 63 68 6f 73 65 6e 20 73 65 74 2e 20 the chosen set.
3140: 54 68 65 73 65 20 61 72 65 0a 09 09 23 20 69 67 These are...# ig
3150: 6e 6f 72 65 64 0a 09 09 69 66 20 7b 21 5b 24 64 nored...if {![$d
3160: 67 20 6e 6f 64 65 20 65 78 69 73 74 73 20 24 73 g node exists $s
3170: 75 63 63 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 ucc]} continue..
3180: 09 69 66 20 7b 5b 48 61 73 41 72 63 20 24 64 67 .if {[HasArc $dg
3190: 20 24 63 73 65 74 20 24 73 75 63 63 5d 7d 20 63 $cset $succ]} c
31a0: 6f 6e 74 69 6e 75 65 3b 23 20 54 4f 44 4f 20 73 ontinue;# TODO s
31b0: 68 6f 75 6c 64 20 62 65 20 67 72 61 70 68 20 6d hould be graph m
31c0: 65 74 68 6f 64 2e 0a 09 09 24 64 67 20 61 72 63 ethod....$dg arc
31d0: 20 69 6e 73 65 72 74 20 24 63 73 65 74 20 24 73 insert $cset $s
31e0: 75 63 63 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 ucc.. }..}...
31f0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 return. }..
3200: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 # # ## ### ###
3210: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 ## ######## ####
3220: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 #########. ##
3230: 20 43 61 6c 6c 62 61 63 6b 20 69 6e 76 6f 6b 61 Callback invoka
3240: 74 69 6f 6e 20 2e 2e 2e 0a 0a 20 20 20 20 70 72 tion ..... pr
3250: 6f 63 20 50 72 65 48 6f 6f 6b 20 7b 67 72 61 70 oc PreHook {grap
3260: 68 7d 20 7b 0a 09 23 20 47 69 76 65 20 74 68 65 h} {..# Give the
3270: 20 75 73 65 72 20 6f 66 20 74 68 65 20 63 79 63 user of the cyc
3280: 6c 65 20 62 72 65 61 6b 65 72 20 74 68 65 20 6f le breaker the o
3290: 70 70 6f 72 74 75 6e 69 74 79 20 74 6f 20 77 6f pportunity to wo
32a0: 72 6b 0a 09 23 20 77 69 74 68 20 74 68 65 20 67 rk..# with the g
32b0: 72 61 70 68 20 62 65 74 77 65 65 6e 20 73 65 74 raph between set
32c0: 75 70 20 61 6e 64 20 63 6f 6e 73 75 6d 6d 61 74 up and consummat
32d0: 69 6f 6e 2e 0a 0a 09 3a 3a 76 61 72 69 61 62 6c ion....::variabl
32e0: 65 20 6d 79 70 72 65 63 6d 64 0a 09 69 66 20 7b e myprecmd..if {
32f0: 21 5b 6c 6c 65 6e 67 74 68 20 24 6d 79 70 72 65 ![llength $mypre
3300: 63 6d 64 5d 7d 20 72 65 74 75 72 6e 0a 0a 09 75 cmd]} return...u
3310: 70 6c 65 76 65 6c 20 23 30 20 5b 6c 69 6e 73 65 plevel #0 [linse
3320: 72 74 20 24 6d 79 70 72 65 63 6d 64 20 65 6e 64 rt $myprecmd end
3330: 20 24 67 72 61 70 68 5d 0a 09 4d 61 72 6b 20 24 $graph]..Mark $
3340: 67 72 61 70 68 20 2d 70 72 65 2d 64 6f 6e 65 0a graph -pre-done.
3350: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 .return. }..
3360: 20 20 20 70 72 6f 63 20 50 72 6f 63 65 73 73 65 proc Processe
3370: 64 48 6f 6f 6b 20 7b 64 67 20 63 73 65 74 20 70 dHook {dg cset p
3380: 6f 73 7d 20 7b 0a 09 23 20 47 69 76 65 20 74 68 os} {..# Give th
3390: 65 20 75 73 65 72 20 6f 66 20 74 68 65 20 63 79 e user of the cy
33a0: 63 6c 65 20 62 72 65 61 6b 65 72 20 74 68 65 20 cle breaker the
33b0: 6f 70 70 6f 72 74 75 6e 69 74 79 20 74 6f 20 77 opportunity to w
33c0: 6f 72 6b 0a 09 23 20 77 69 74 68 20 74 68 65 20 ork..# with the
33d0: 63 68 61 6e 67 65 73 65 74 20 62 65 66 6f 72 65 changeset before
33e0: 20 69 74 20 69 73 20 72 65 6d 6f 76 65 64 20 66 it is removed f
33f0: 72 6f 6d 20 74 68 65 20 67 72 61 70 68 2e 0a 0a rom the graph...
3400: 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 73 61 .::variable mysa
3410: 76 65 63 6d 64 0a 09 69 66 20 7b 21 5b 6c 6c 65 vecmd..if {![lle
3420: 6e 67 74 68 20 24 6d 79 73 61 76 65 63 6d 64 5d ngth $mysavecmd]
3430: 7d 20 72 65 74 75 72 6e 0a 0a 09 75 70 6c 65 76 } return...uplev
3440: 65 6c 20 23 30 20 5b 6c 69 6e 73 65 72 74 20 24 el #0 [linsert $
3450: 6d 79 73 61 76 65 63 6d 64 20 65 6e 64 20 24 64 mysavecmd end $d
3460: 67 20 24 70 6f 73 20 24 63 73 65 74 5d 0a 09 72 g $pos $cset]..r
3470: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
3480: 20 70 72 6f 63 20 42 72 65 61 6b 43 79 63 6c 65 proc BreakCycle
3490: 48 6f 6f 6b 20 7b 67 72 61 70 68 7d 20 7b 0a 09 Hook {graph} {..
34a0: 23 20 43 61 6c 6c 20 6f 75 74 20 74 6f 20 74 68 # Call out to th
34b0: 65 20 63 68 6f 73 65 6e 20 61 6c 67 6f 72 69 74 e chosen algorit
34c0: 68 6d 20 66 6f 72 20 63 79 63 6c 65 20 62 72 65 hm for cycle bre
34d0: 61 6b 69 6e 67 2e 20 46 69 6e 64 69 6e 67 0a 09 aking. Finding..
34e0: 23 20 61 20 63 79 63 6c 65 20 69 66 20 6e 6f 20 # a cycle if no
34f0: 62 72 65 61 6b 65 72 20 77 61 73 20 63 68 6f 73 breaker was chos
3500: 65 6e 20 69 73 20 61 6e 20 65 72 72 6f 72 2e 0a en is an error..
3510: 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 62 ..::variable myb
3520: 72 65 61 6b 63 6d 64 0a 09 69 66 20 7b 21 5b 6c reakcmd..if {![l
3530: 6c 65 6e 67 74 68 20 24 6d 79 62 72 65 61 6b 63 length $mybreakc
3540: 6d 64 5d 7d 20 7b 0a 09 20 20 20 20 74 72 6f 75 md]} {.. trou
3550: 62 6c 65 20 66 61 74 61 6c 20 22 46 6f 75 6e 64 ble fatal "Found
3560: 20 61 20 63 79 63 6c 65 2c 20 65 78 70 65 63 74 a cycle, expect
3570: 69 6e 67 20 6e 6f 6e 65 2e 22 0a 09 20 20 20 20 ing none."..
3580: 65 78 69 74 20 31 0a 09 7d 0a 0a 09 75 70 6c 65 exit 1..}...uple
3590: 76 65 6c 20 23 30 20 5b 6c 69 6e 73 65 72 74 20 vel #0 [linsert
35a0: 24 6d 79 62 72 65 61 6b 63 6d 64 20 65 6e 64 20 $mybreakcmd end
35b0: 24 67 72 61 70 68 5d 0a 09 72 65 74 75 72 6e 0a $graph]..return.
35c0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
35d0: 43 6c 65 61 72 48 6f 6f 6b 73 20 7b 7d 20 7b 0a ClearHooks {} {.
35e0: 09 3a 3a 76 61 72 69 61 62 6c 65 20 6d 79 70 72 .::variable mypr
35f0: 65 63 6d 64 20 20 20 7b 7d 0a 09 3a 3a 76 61 72 ecmd {}..::var
3600: 69 61 62 6c 65 20 6d 79 73 61 76 65 63 6d 64 20 iable mysavecmd
3610: 20 7b 7d 0a 09 3a 3a 76 61 72 69 61 62 6c 65 20 {}..::variable
3620: 6d 79 62 72 65 61 6b 63 6d 64 20 7b 7d 0a 09 72 mybreakcmd {}..r
3630: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
3640: 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 # # ## ### ####
3650: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 # ######## #####
3660: 23 23 23 23 23 23 23 23 0a 0a 20 20 20 20 70 72 ########.. pr
3670: 6f 63 20 4d 61 72 6b 57 61 74 63 68 20 7b 67 72 oc MarkWatch {gr
3680: 61 70 68 7d 20 7b 0a 09 3a 3a 76 61 72 69 61 62 aph} {..::variab
3690: 6c 65 20 6d 79 77 61 74 63 68 69 64 73 0a 09 73 le mywatchids..s
36a0: 65 74 20 77 61 74 63 68 65 64 20 5b 57 61 74 63 et watched [Watc
36b0: 68 65 64 20 24 67 72 61 70 68 20 24 6d 79 77 61 hed $graph $mywa
36c0: 74 63 68 69 64 73 5d 0a 09 69 66 20 7b 21 5b 6c tchids]..if {![l
36d0: 6c 65 6e 67 74 68 20 24 77 61 74 63 68 65 64 5d length $watched]
36e0: 7d 20 72 65 74 75 72 6e 0a 09 73 65 74 20 6e 65 } return..set ne
36f0: 69 67 68 62 6f 75 72 73 20 5b 65 76 61 6c 20 5b ighbours [eval [
3700: 6c 69 6e 73 65 72 74 20 24 77 61 74 63 68 65 64 linsert $watched
3710: 20 30 20 24 67 72 61 70 68 20 6e 6f 64 65 73 20 0 $graph nodes
3720: 2d 61 64 6a 5d 5d 0a 09 23 66 6f 72 65 61 63 68 -adj]]..#foreach
3730: 20 6e 20 24 6e 65 69 67 68 62 6f 75 72 73 20 7b n $neighbours {
3740: 20 6c 6f 67 20 77 72 69 74 65 20 36 20 63 79 63 log write 6 cyc
3750: 6c 65 62 72 65 61 6b 65 72 20 22 4e 65 69 67 68 lebreaker "Neigh
3760: 62 6f 72 20 5b 24 6e 20 69 64 5d 20 3d 3e 20 24 bor [$n id] => $
3770: 6e 22 20 7d 0a 09 4d 61 72 6b 20 24 67 72 61 70 n" }..Mark $grap
3780: 68 20 77 61 74 63 68 65 64 20 5b 63 6f 6e 63 61 h watched [conca
3790: 74 20 24 77 61 74 63 68 65 64 20 24 6e 65 69 67 t $watched $neig
37a0: 68 62 6f 75 72 73 5d 0a 09 72 65 74 75 72 6e 0a hbours]..return.
37b0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
37c0: 57 61 74 63 68 65 64 20 7b 67 72 61 70 68 20 77 Watched {graph w
37d0: 61 74 63 68 69 64 73 7d 20 7b 0a 09 73 65 74 20 atchids} {..set
37e0: 72 65 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 res {}..foreach
37f0: 69 64 20 24 77 61 74 63 68 69 64 73 20 7b 0a 09 id $watchids {..
3800: 20 20 20 20 73 65 74 20 6e 6c 20 5b 24 67 72 61 set nl [$gra
3810: 70 68 20 6e 6f 64 65 73 20 2d 6b 65 79 20 5f 5f ph nodes -key __
3820: 69 64 5f 5f 20 2d 76 61 6c 75 65 20 24 69 64 5d id__ -value $id]
3830: 0a 09 20 20 20 20 69 66 20 7b 21 5b 6c 6c 65 6e .. if {![llen
3840: 67 74 68 20 24 6e 6c 5d 7d 20 63 6f 6e 74 69 6e gth $nl]} contin
3850: 75 65 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 ue.. lappend
3860: 72 65 73 20 24 6e 6c 0a 09 20 20 20 20 23 6c 6f res $nl.. #lo
3870: 67 20 77 72 69 74 65 20 36 20 62 72 65 61 6b 72 g write 6 breakr
3880: 63 79 63 6c 65 20 22 57 61 74 63 68 69 6e 67 20 cycle "Watching
3890: 24 69 64 20 3d 3e 20 24 6e 6c 22 0a 09 20 20 20 $id => $nl"..
38a0: 20 24 67 72 61 70 68 20 6e 6f 64 65 20 73 65 74 $graph node set
38b0: 20 24 6e 6c 20 66 6f 6e 74 63 6f 6c 6f 72 20 72 $nl fontcolor r
38c0: 65 64 0a 09 7d 0a 09 72 65 74 75 72 6e 20 24 72 ed..}..return $r
38d0: 65 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 es. }.. #
38e0: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 # ## ### ##### #
38f0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 ####### ########
3900: 23 23 23 23 23 0a 0a 0a 20 20 20 20 74 79 70 65 #####... type
3910: 76 61 72 69 61 62 6c 65 20 6d 79 61 74 20 20 20 variable myat
3920: 20 20 20 30 20 3b 20 23 20 43 6f 75 6e 74 65 72 0 ; # Counter
3930: 20 66 6f 72 20 63 6f 6d 6d 69 74 20 69 64 73 20 for commit ids
3940: 66 6f 72 20 74 68 65 0a 09 09 09 20 20 20 20 20 for the....
3950: 20 20 23 20 63 68 61 6e 67 65 73 65 74 73 2e 0a # changesets..
3960: 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 typevariable
3970: 20 6d 79 62 6f 74 74 6f 6d 20 7b 7d 20 3b 20 23 mybottom {} ; #
3980: 20 4c 69 73 74 20 6f 66 20 74 68 65 20 63 61 6e List of the can
3990: 64 69 64 61 74 65 20 6e 6f 64 65 73 20 66 6f 72 didate nodes for
39a0: 0a 09 09 09 20 20 20 20 20 20 20 23 20 63 6f 6d .... # com
39b0: 6d 69 74 74 69 6e 67 2e 0a 0a 20 20 20 20 74 79 mitting... ty
39c0: 70 65 76 61 72 69 61 62 6c 65 20 6d 79 70 72 65 pevariable mypre
39d0: 63 6d 64 20 20 20 7b 7d 20 3b 20 23 20 43 61 6c cmd {} ; # Cal
39e0: 6c 62 61 63 6b 2c 20 63 68 61 6e 67 65 20 67 72 lback, change gr
39f0: 61 70 68 20 62 65 66 6f 72 65 20 77 61 6c 6b 2e aph before walk.
3a00: 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c . typevariabl
3a10: 65 20 6d 79 73 61 76 65 63 6d 64 20 20 7b 7d 20 e mysavecmd {}
3a20: 3b 20 23 20 43 61 6c 6c 62 61 63 6b 2c 20 66 6f ; # Callback, fo
3a30: 72 20 65 61 63 68 20 70 72 6f 63 65 73 73 65 64 r each processed
3a40: 20 6e 6f 64 65 2e 0a 20 20 20 20 74 79 70 65 76 node.. typev
3a50: 61 72 69 61 62 6c 65 20 6d 79 62 72 65 61 6b 63 ariable mybreakc
3a60: 6d 64 20 7b 7d 20 3b 20 23 20 43 61 6c 6c 62 61 md {} ; # Callba
3a70: 63 6b 2c 20 66 6f 72 20 65 61 63 68 20 66 6f 75 ck, for each fou
3a80: 6e 64 20 63 79 63 6c 65 2e 0a 0a 20 20 20 20 74 nd cycle... t
3a90: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 64 6f ypevariable mydo
3aa0: 74 64 65 73 74 69 6e 61 74 69 6f 6e 20 7b 7d 20 tdestination {}
3ab0: 3b 20 23 20 44 65 73 74 69 6e 61 74 69 6f 6e 20 ; # Destination
3ac0: 64 69 72 65 63 74 6f 72 79 20 66 6f 72 20 74 68 directory for th
3ad0: 65 0a 09 09 09 09 20 20 20 20 20 20 20 23 20 67 e..... # g
3ae0: 65 6e 65 72 61 74 65 64 20 2e 64 6f 74 20 66 69 enerated .dot fi
3af0: 6c 65 73 2e 0a 20 20 20 20 74 79 70 65 76 61 72 les.. typevar
3b00: 69 61 62 6c 65 20 6d 79 64 6f 74 70 72 65 66 69 iable mydotprefi
3b10: 78 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 50 72 x {} ; # Pr
3b20: 65 66 69 78 20 66 6f 72 20 64 6f 74 20 66 69 6c efix for dot fil
3b30: 65 73 20 77 68 65 6e 0a 09 09 09 09 20 20 20 20 es when.....
3b40: 20 20 20 23 20 65 78 70 6f 72 74 69 6e 67 20 74 # exporting t
3b50: 68 65 20 67 72 61 70 68 73 2e 0a 20 20 20 20 74 he graphs.. t
3b60: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 64 6f ypevariable mydo
3b70: 74 69 64 20 20 20 20 20 20 20 20 20 20 20 30 20 tid 0
3b80: 3b 20 23 20 43 6f 75 6e 74 65 72 20 66 6f 72 20 ; # Counter for
3b90: 64 6f 74 20 66 69 6c 65 20 6e 61 6d 65 0a 09 09 dot file name...
3ba0: 09 09 20 20 20 20 20 20 20 23 20 67 65 6e 65 72 .. # gener
3bb0: 61 74 69 6f 6e 2e 0a 20 20 20 20 74 79 70 65 76 ation.. typev
3bc0: 61 72 69 61 62 6c 65 20 6d 79 77 61 74 63 68 69 ariable mywatchi
3bd0: 64 73 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 ds {} ; #
3be0: 43 68 61 6e 67 65 73 65 74 73 20 74 6f 20 77 61 Changesets to wa
3bf0: 74 63 68 20 74 68 65 0a 09 09 09 09 20 20 20 20 tch the.....
3c00: 20 20 20 23 20 6e 65 69 67 68 62 6f 75 72 68 6f # neighbourho
3c10: 6f 64 20 6f 66 2e 0a 0a 20 20 20 20 23 20 23 20 od of... # #
3c20: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
3c30: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
3c40: 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 ###. ## Confi
3c50: 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 guration.. pr
3c60: 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e 63 agma -hasinstanc
3c70: 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e 67 es no ; # sing
3c80: 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 leton. pragma
3c90: 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 20 -hastypeinfo
3ca0: 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 6f no ; # no intro
3cb0: 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 spection. pra
3cc0: 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73 74 gma -hastypedest
3cd0: 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f 72 roy no ; # immor
3ce0: 74 61 6c 0a 0a 20 20 20 20 23 20 23 20 23 23 20 tal.. # # ##
3cf0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 ### ##### ######
3d00: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
3d10: 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 .}..namespace ev
3d20: 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a al ::vc::fossil:
3d30: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 20 7b 0a 20 :import::cvs {.
3d40: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 70 namespace exp
3d50: 6f 72 74 20 63 79 63 6c 65 62 72 65 61 6b 65 72 ort cyclebreaker
3d60: 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 . namespace e
3d70: 76 61 6c 20 63 79 63 6c 65 62 72 65 61 6b 65 72 val cyclebreaker
3d80: 20 7b 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 {..namespace ev
3d90: 61 6c 20 70 72 6f 6a 65 63 74 20 7b 0a 09 20 20 al project {..
3da0: 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f namespace impo
3db0: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a rt ::vc::fossil:
3dc0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 :import::cvs::pr
3dd0: 6f 6a 65 63 74 3a 3a 72 65 76 0a 09 20 20 20 20 oject::rev..
3de0: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 namespace import
3df0: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 ::vc::fossil::i
3e00: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a mport::cvs::proj
3e10: 65 63 74 3a 3a 72 65 76 6c 69 6e 6b 0a 09 7d 0a ect::revlink..}.
3e20: 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 .namespace impor
3e30: 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d t ::vc::tools::m
3e40: 69 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73 70 61 63 isc::*..namespac
3e50: 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 e import ::vc::t
3e60: 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6e 61 6d 65 73 ools::log..names
3e70: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 pace import ::vc
3e80: 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 ::tools::trouble
3e90: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f ..namespace impo
3ea0: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a rt ::vc::tools::
3eb0: 64 6f 74 0a 09 6c 6f 67 20 72 65 67 69 73 74 65 dot..log registe
3ec0: 72 20 63 79 63 6c 65 62 72 65 61 6b 65 72 0a 20 r cyclebreaker.
3ed0: 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 }.}..# # ## #
3ee0: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 ## ##### #######
3ef0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 # #############
3f00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3f10: 23 23 23 23 23 0a 23 23 20 52 65 61 64 79 0a 0a #####.## Ready..
3f20: 70 61 63 6b 61 67 65 20 70 72 6f 76 69 64 65 20 package provide
3f30: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f vc::fossil::impo
3f40: 72 74 3a 3a 63 76 73 3a 3a 63 79 63 6c 65 62 72 rt::cvs::cyclebr
3f50: 65 61 6b 65 72 20 31 2e 30 0a 72 65 74 75 72 6e eaker 1.0.return
3f60: 0a .