0000: 23 23 20 2d 2a 2d 20 74 63 6c 20 2d 2a 2d 0a 23 ## -*- tcl -*-.#
0010: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 # ## ### #####
0020: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 ######## #######
0030: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
0040: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 ############.##
0050: 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 32 30 Copyright (c) 20
0060: 30 37 20 41 6e 64 72 65 61 73 20 4b 75 70 72 69 07 Andreas Kupri
0070: 65 73 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 es..#.# This sof
0080: 74 77 61 72 65 20 69 73 20 6c 69 63 65 6e 73 65 tware is license
0090: 64 20 61 73 20 64 65 73 63 72 69 62 65 64 20 69 d as described i
00a0: 6e 20 74 68 65 20 66 69 6c 65 20 4c 49 43 45 4e n the file LICEN
00b0: 53 45 2c 20 77 68 69 63 68 0a 23 20 79 6f 75 20 SE, which.# you
00c0: 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65 should have rece
00d0: 69 76 65 64 20 61 73 20 70 61 72 74 20 6f 66 20 ived as part of
00e0: 74 68 69 73 20 64 69 73 74 72 69 62 75 74 69 6f this distributio
00f0: 6e 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 74 n..#.# This soft
0100: 77 61 72 65 20 63 6f 6e 73 69 73 74 73 20 6f 66 ware consists of
0110: 20 76 6f 6c 75 6e 74 61 72 79 20 63 6f 6e 74 72 voluntary contr
0120: 69 62 75 74 69 6f 6e 73 20 6d 61 64 65 20 62 79 ibutions made by
0130: 20 6d 61 6e 79 0a 23 20 69 6e 64 69 76 69 64 75 many.# individu
0140: 61 6c 73 2e 20 20 46 6f 72 20 65 78 61 63 74 20 als. For exact
0150: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 20 68 69 73 contribution his
0160: 74 6f 72 79 2c 20 73 65 65 20 74 68 65 20 72 65 tory, see the re
0170: 76 69 73 69 6f 6e 0a 23 20 68 69 73 74 6f 72 79 vision.# history
0180: 20 61 6e 64 20 6c 6f 67 73 2c 20 61 76 61 69 6c and logs, avail
0190: 61 62 6c 65 20 61 74 20 68 74 74 70 3a 2f 2f 66 able at http://f
01a0: 6f 73 73 69 6c 2d 73 63 6d 2e 68 77 61 63 69 2e ossil-scm.hwaci.
01b0: 63 6f 6d 2f 66 6f 73 73 69 6c 0a 23 20 23 20 23 com/fossil.# # #
01c0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
01d0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
01e0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
01f0: 23 23 23 23 23 23 23 23 0a 0a 23 23 20 52 65 76 ########..## Rev
0200: 69 73 69 6f 6e 73 20 70 65 72 20 70 72 6f 6a 65 isions per proje
0210: 63 74 2c 20 61 6b 61 20 43 68 61 6e 67 65 73 65 ct, aka Changese
0220: 74 73 2e 20 54 68 65 73 65 20 6f 62 6a 65 63 74 ts. These object
0230: 73 20 61 72 65 20 66 69 72 73 74 20 75 73 65 64 s are first used
0240: 0a 23 23 20 69 6e 20 70 61 73 73 20 35 2c 20 77 .## in pass 5, w
0250: 68 69 63 68 20 63 72 65 61 74 65 73 20 74 68 65 hich creates the
0260: 20 69 6e 69 74 69 61 6c 20 73 65 74 20 63 6f 76 initial set cov
0270: 65 72 69 6e 67 20 74 68 65 20 72 65 70 6f 73 69 ering the reposi
0280: 74 6f 72 79 2e 0a 0a 23 20 23 20 23 23 20 23 23 tory...# # ## ##
0290: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 # ##### ########
02a0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 ############# #
02b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
02c0: 23 23 23 23 0a 23 23 20 52 65 71 75 69 72 65 6d ####.## Requirem
02d0: 65 6e 74 73 0a 0a 70 61 63 6b 61 67 65 20 72 65 ents..package re
02e0: 71 75 69 72 65 20 54 63 6c 20 38 2e 34 20 20 20 quire Tcl 8.4
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0300: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 ; #
0310: 52 65 71 75 69 72 65 64 20 72 75 6e 74 69 6d 65 Required runtime
0320: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 ..package requir
0330: 65 20 73 6e 69 74 20 20 20 20 20 20 20 20 20 20 e snit
0340: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0350: 20 20 20 20 20 20 20 20 3b 20 23 20 4f 4f 20 73 ; # OO s
0360: 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67 65 20 72 ystem..package r
0370: 65 71 75 69 72 65 20 73 74 72 75 63 74 3a 3a 73 equire struct::s
0380: 65 74 20 20 20 20 20 20 20 20 20 20 20 20 20 20 et
0390: 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 ; #
03a0: 20 53 65 74 20 6f 70 65 72 61 74 69 6f 6e 73 2e Set operations.
03b0: 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 .package require
03c0: 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63 vc::tools::misc
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 3b 20 23 20 54 65 78 74 20 ; # Text
03f0: 66 6f 72 6d 61 74 74 69 6e 67 0a 70 61 63 6b 61 formatting.packa
0400: 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 ge require vc::t
0410: 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 20 20 20 ools::trouble
0420: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0430: 20 3b 20 23 20 45 72 72 6f 72 20 72 65 70 6f 72 ; # Error repor
0440: 74 69 6e 67 2e 0a 70 61 63 6b 61 67 65 20 72 65 ting..package re
0450: 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a quire vc::tools:
0460: 3a 6c 6f 67 20 20 20 20 20 20 20 20 20 20 20 20 :log
0470: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 ; #
0480: 55 73 65 72 20 66 65 65 64 62 61 63 6b 2e 0a 70 User feedback..p
0490: 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 ackage require v
04a0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 c::fossil::impor
04b0: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 20 20 20 t::cvs::state
04c0: 20 20 20 20 20 3b 20 23 20 53 74 61 74 65 20 73 ; # State s
04d0: 74 6f 72 61 67 65 2e 0a 70 61 63 6b 61 67 65 20 torage..package
04e0: 72 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 require vc::foss
04f0: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a il::import::cvs:
0500: 3a 69 6e 74 65 67 72 69 74 79 20 20 20 20 3b 20 :integrity ;
0510: 23 20 53 74 61 74 65 20 69 6e 74 65 67 72 69 74 # State integrit
0520: 79 20 63 68 65 63 6b 73 2e 0a 0a 23 20 23 20 23 y checks...# # #
0530: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
0540: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
0550: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
0560: 23 23 23 23 23 23 23 23 0a 23 23 0a 0a 73 6e 69 ########.##..sni
0570: 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f t::type ::vc::fo
0580: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 ssil::import::cv
0590: 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 20 s::project::rev
05a0: 7b 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 {. # # ## ###
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 0a 20 20 #############.
05d0: 20 20 23 23 20 50 75 62 6c 69 63 20 41 50 49 0a ## Public API.
05e0: 0a 20 20 20 20 63 6f 6e 73 74 72 75 63 74 6f 72 . constructor
05f0: 20 7b 70 72 6f 6a 65 63 74 20 63 73 74 79 70 65 {project cstype
0600: 20 73 72 63 69 64 20 69 74 65 6d 73 20 7b 74 68 srcid items {th
0610: 65 69 64 20 7b 7d 7d 7d 20 7b 0a 09 69 66 20 7b eid {}}} {..if {
0620: 24 74 68 65 69 64 20 6e 65 20 22 22 7d 20 7b 0a $theid ne ""} {.
0630: 09 20 20 20 20 73 65 74 20 6d 79 69 64 20 24 74 . set myid $t
0640: 68 65 69 64 0a 09 7d 20 65 6c 73 65 20 7b 0a 09 heid..} else {..
0650: 20 20 20 20 73 65 74 20 6d 79 69 64 20 5b 69 6e set myid [in
0660: 63 72 20 6d 79 63 6f 75 6e 74 65 72 5d 0a 09 7d cr mycounter]..}
0670: 0a 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 ...integrity ass
0680: 65 72 74 20 7b 0a 09 20 20 20 20 5b 69 6e 66 6f ert {.. [info
0690: 20 65 78 69 73 74 73 20 6d 79 63 73 74 79 70 65 exists mycstype
06a0: 28 24 63 73 74 79 70 65 29 5d 0a 09 7d 20 7b 42 ($cstype)]..} {B
06b0: 61 64 20 63 68 61 6e 67 65 73 65 74 20 74 79 70 ad changeset typ
06c0: 65 20 27 24 63 73 74 79 70 65 27 2e 7d 0a 0a 09 e '$cstype'.}...
06d0: 73 65 74 20 6d 79 70 72 6f 6a 65 63 74 20 20 20 set myproject
06e0: 24 70 72 6f 6a 65 63 74 0a 09 73 65 74 20 6d 79 $project..set my
06f0: 74 79 70 65 20 20 20 20 20 20 24 63 73 74 79 70 type $cstyp
0700: 65 0a 09 73 65 74 20 6d 79 74 79 70 65 6f 62 6a e..set mytypeobj
0710: 20 20 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a ::vc::fossil:
0720: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 :import::cvs::pr
0730: 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a 24 7b 63 73 oject::rev::${cs
0740: 74 79 70 65 7d 0a 09 73 65 74 20 6d 79 73 72 63 type}..set mysrc
0750: 69 64 09 24 73 72 63 69 64 0a 09 73 65 74 20 6d id.$srcid..set m
0760: 79 69 74 65 6d 73 20 20 20 20 20 24 69 74 65 6d yitems $item
0770: 73 0a 09 73 65 74 20 6d 79 70 6f 73 20 20 20 20 s..set mypos
0780: 20 20 20 7b 7d 20 3b 20 23 20 43 6f 6d 6d 69 74 {} ; # Commit
0790: 20 6c 6f 63 61 74 69 6f 6e 20 69 73 20 6e 6f 74 location is not
07a0: 20 6b 6e 6f 77 6e 20 79 65 74 2e 0a 0a 09 23 20 known yet....#
07b0: 4b 65 65 70 20 74 72 61 63 6b 20 6f 66 20 74 68 Keep track of th
07c0: 65 20 67 65 6e 65 72 61 74 65 64 20 63 68 61 6e e generated chan
07d0: 67 65 73 65 74 73 20 61 6e 64 20 6f 66 20 74 68 gesets and of th
07e0: 65 20 69 6e 76 65 72 73 65 0a 09 23 20 6d 61 70 e inverse..# map
07f0: 70 69 6e 67 20 66 72 6f 6d 20 69 74 65 6d 73 20 ping from items
0800: 74 6f 20 74 68 65 6d 2e 0a 09 6c 61 70 70 65 6e to them...lappen
0810: 64 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20 d mychangesets
0820: 20 24 73 65 6c 66 0a 09 6c 61 70 70 65 6e 64 20 $self..lappend
0830: 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 24 63 mytchangesets($c
0840: 73 74 79 70 65 29 20 24 73 65 6c 66 0a 09 73 65 stype) $self..se
0850: 74 20 20 20 20 20 6d 79 69 64 6d 61 70 28 24 6d t myidmap($m
0860: 79 69 64 29 20 24 73 65 6c 66 0a 09 66 6f 72 65 yid) $self..fore
0870: 61 63 68 20 69 69 64 20 24 69 74 65 6d 73 20 7b ach iid $items {
0880: 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c .. set key [l
0890: 69 73 74 20 24 63 73 74 79 70 65 20 24 69 69 64 ist $cstype $iid
08a0: 5d 0a 09 20 20 20 20 73 65 74 20 6d 79 69 74 65 ].. set myite
08b0: 6d 6d 61 70 28 24 6b 65 79 29 20 24 73 65 6c 66 mmap($key) $self
08c0: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 6d 79 .. lappend my
08d0: 74 69 74 65 6d 73 20 24 6b 65 79 0a 09 20 20 20 titems $key..
08e0: 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 log write 8 cse
08f0: 74 73 20 7b 4d 41 50 2b 20 69 74 65 6d 20 3c 24 ts {MAP+ item <$
0900: 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73 key> $self = [$s
0910: 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 09 72 65 elf str]}..}..re
0920: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
0930: 6d 65 74 68 6f 64 20 73 74 72 20 7b 7d 20 7b 0a method str {} {.
0940: 09 73 65 74 20 73 74 72 20 20 20 20 22 3c 22 0a .set str "<".
0950: 09 73 65 74 20 64 65 74 61 69 6c 20 22 22 0a 09 .set detail ""..
0960: 69 66 20 7b 5b 24 6d 79 74 79 70 65 6f 62 6a 20 if {[$mytypeobj
0970: 62 79 73 79 6d 62 6f 6c 5d 7d 20 7b 0a 09 20 20 bysymbol]} {..
0980: 20 20 73 65 74 20 64 65 74 61 69 6c 20 22 20 27 set detail " '
0990: 5b 73 74 61 74 65 20 6f 6e 65 20 7b 0a 09 09 53 [state one {...S
09a0: 45 4c 45 43 54 20 53 2e 6e 61 6d 65 0a 09 09 46 ELECT S.name...F
09b0: 52 4f 4d 20 20 20 73 79 6d 62 6f 6c 20 53 0a 09 ROM symbol S..
09c0: 09 57 48 45 52 45 20 20 53 2e 73 69 64 20 3d 20 .WHERE S.sid =
09d0: 24 6d 79 73 72 63 69 64 0a 09 20 20 20 20 7d 5d $mysrcid.. }]
09e0: 27 22 0a 09 7d 0a 09 61 70 70 65 6e 64 20 73 74 '"..}..append st
09f0: 72 20 22 24 6d 79 74 79 70 65 20 24 7b 6d 79 69 r "$mytype ${myi
0a00: 64 7d 24 7b 64 65 74 61 69 6c 7d 3e 22 0a 09 72 d}${detail}>"..r
0a10: 65 74 75 72 6e 20 24 73 74 72 0a 20 20 20 20 7d eturn $str. }
0a20: 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 69 64 20 .. method id
0a30: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 24 {} { return $
0a40: 6d 79 69 64 20 7d 0a 20 20 20 20 6d 65 74 68 6f myid }. metho
0a50: 64 20 69 74 65 6d 73 20 7b 7d 20 7b 20 72 65 74 d items {} { ret
0a60: 75 72 6e 20 24 6d 79 74 69 74 65 6d 73 20 7d 0a urn $mytitems }.
0a70: 20 20 20 20 6d 65 74 68 6f 64 20 64 61 74 61 20 method data
0a80: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5b 6c 69 {} { return [li
0a90: 73 74 20 24 6d 79 70 72 6f 6a 65 63 74 20 24 6d st $myproject $m
0aa0: 79 74 79 70 65 20 24 6d 79 73 72 63 69 64 5d 20 ytype $mysrcid]
0ab0: 7d 0a 0a 20 20 20 20 64 65 6c 65 67 61 74 65 20 }.. delegate
0ac0: 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20 method bysymbol
0ad0: 20 20 74 6f 20 6d 79 74 79 70 65 6f 62 6a 0a 20 to mytypeobj.
0ae0: 20 20 20 64 65 6c 65 67 61 74 65 20 6d 65 74 68 delegate meth
0af0: 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20 74 6f od byrevision to
0b00: 20 6d 79 74 79 70 65 6f 62 6a 0a 20 20 20 20 64 mytypeobj. d
0b10: 65 6c 65 67 61 74 65 20 6d 65 74 68 6f 64 20 69 elegate method i
0b20: 73 62 72 61 6e 63 68 20 20 20 74 6f 20 6d 79 74 sbranch to myt
0b30: 79 70 65 6f 62 6a 0a 20 20 20 20 64 65 6c 65 67 ypeobj. deleg
0b40: 61 74 65 20 6d 65 74 68 6f 64 20 69 73 74 61 67 ate method istag
0b50: 20 20 20 20 20 20 74 6f 20 6d 79 74 79 70 65 6f to mytypeo
0b60: 62 6a 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 73 bj.. method s
0b70: 65 74 70 6f 73 20 7b 70 7d 20 7b 20 73 65 74 20 etpos {p} { set
0b80: 6d 79 70 6f 73 20 24 70 20 3b 20 72 65 74 75 72 mypos $p ; retur
0b90: 6e 20 7d 0a 20 20 20 20 6d 65 74 68 6f 64 20 70 n }. method p
0ba0: 6f 73 20 20 20 20 7b 7d 20 20 7b 20 72 65 74 75 os {} { retu
0bb0: 72 6e 20 24 6d 79 70 6f 73 20 7d 0a 0a 20 20 20 rn $mypos }..
0bc0: 20 6d 65 74 68 6f 64 20 64 65 74 65 72 6d 69 6e method determin
0bd0: 65 73 75 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b esuccessors {} {
0be0: 0a 09 23 20 50 61 73 73 20 36 20 6f 70 65 72 61 ..# Pass 6 opera
0bf0: 74 69 6f 6e 2e 20 43 6f 6d 70 75 74 65 20 70 72 tion. Compute pr
0c00: 6f 6a 65 63 74 2d 6c 65 76 65 6c 20 64 65 70 65 oject-level depe
0c10: 6e 64 65 6e 63 69 65 73 20 66 72 6f 6d 0a 09 23 ndencies from..#
0c20: 20 74 68 65 20 66 69 6c 65 2d 6c 65 76 65 6c 20 the file-level
0c30: 64 61 74 61 20 61 6e 64 20 73 61 76 65 20 69 74 data and save it
0c40: 20 62 61 63 6b 20 74 6f 20 74 68 65 20 73 74 61 back to the sta
0c50: 74 65 2e 20 54 68 69 73 20 6d 61 79 0a 09 23 20 te. This may..#
0c60: 62 65 20 63 61 6c 6c 65 64 20 64 75 72 69 6e 67 be called during
0c70: 20 74 68 65 20 63 79 63 6c 65 20 62 72 65 61 6b the cycle break
0c80: 65 72 20 70 61 73 73 65 73 20 61 73 20 77 65 6c er passes as wel
0c90: 6c 2c 20 74 6f 20 61 64 6a 75 73 74 0a 09 23 20 l, to adjust..#
0ca0: 74 68 65 20 73 75 63 63 65 73 73 6f 72 20 69 6e the successor in
0cb0: 66 6f 72 6d 61 74 69 6f 6e 20 6f 66 20 63 68 61 formation of cha
0cc0: 6e 67 65 73 65 74 73 20 77 68 69 63 68 20 61 72 ngesets which ar
0cd0: 65 20 74 68 65 0a 09 23 20 70 72 65 64 65 63 65 e the..# predece
0ce0: 73 73 6f 72 73 20 6f 66 20 64 72 6f 70 70 65 64 ssors of dropped
0cf0: 20 63 68 61 6e 67 65 73 65 74 73 2e 20 46 6f 72 changesets. For
0d00: 20 74 68 65 6d 20 77 65 20 68 61 76 65 20 74 6f them we have to
0d10: 0a 09 23 20 72 65 6d 6f 76 65 20 74 68 65 69 72 ..# remove their
0d20: 20 65 78 69 73 74 69 6e 67 20 69 6e 66 6f 72 6d existing inform
0d30: 61 74 69 6f 6e 20 66 69 72 73 74 20 62 65 66 6f ation first befo
0d40: 72 65 20 69 6e 73 65 72 74 69 6e 67 20 74 68 65 re inserting the
0d50: 0a 09 23 20 6e 65 77 20 64 61 74 61 2e 0a 09 73 ..# new data...s
0d60: 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 tate run {..
0d70: 44 45 4c 45 54 45 20 46 52 4f 4d 20 63 73 73 75 DELETE FROM cssu
0d80: 63 63 65 73 73 6f 72 20 57 48 45 52 45 20 63 69 ccessor WHERE ci
0d90: 64 20 3d 20 24 6d 79 69 64 3b 0a 09 7d 0a 09 73 d = $myid;..}..s
0da0: 65 74 20 6c 6f 6f 70 20 30 0a 09 66 6f 72 65 61 et loop 0..forea
0db0: 63 68 20 6e 69 64 20 5b 24 6d 79 74 79 70 65 6f ch nid [$mytypeo
0dc0: 62 6a 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73 bj cs_successors
0dd0: 20 24 6d 79 69 74 65 6d 73 5d 20 7b 0a 09 20 20 $myitems] {..
0de0: 20 20 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 state run {...
0df0: 49 4e 53 45 52 54 20 49 4e 54 4f 20 63 73 73 75 INSERT INTO cssu
0e00: 63 63 65 73 73 6f 72 20 28 63 69 64 2c 20 20 6e ccessor (cid, n
0e10: 69 64 29 0a 09 09 56 41 4c 55 45 53 20 20 20 20 id)...VALUES
0e20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 24 ($
0e30: 6d 79 69 64 2c 24 6e 69 64 29 0a 09 20 20 20 20 myid,$nid)..
0e40: 7d 0a 09 20 20 20 20 69 66 20 7b 24 6e 69 64 20 }.. if {$nid
0e50: 3d 3d 20 24 6d 79 69 64 7d 20 7b 20 73 65 74 20 == $myid} { set
0e60: 6c 6f 6f 70 20 31 20 7d 0a 09 7d 0a 09 23 20 52 loop 1 }..}..# R
0e70: 65 70 6f 72 74 20 61 66 74 65 72 20 74 68 65 20 eport after the
0e80: 63 6f 6d 70 6c 65 74 65 20 73 74 72 75 63 74 75 complete structu
0e90: 72 65 20 68 61 73 20 62 65 65 6e 20 73 61 76 65 re has been save
0ea0: 64 2e 0a 09 69 66 20 7b 24 6c 6f 6f 70 7d 20 7b d...if {$loop} {
0eb0: 20 24 73 65 6c 66 20 72 65 70 6f 72 74 6c 6f 6f $self reportloo
0ec0: 70 20 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 p }..return.
0ed0: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 }.. # result
0ee0: 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65 = list (changese
0ef0: 74 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 73 75 t). method su
0f00: 63 63 65 73 73 6f 72 73 20 7b 7d 20 7b 0a 09 23 ccessors {} {..#
0f10: 20 55 73 65 20 74 68 65 20 64 61 74 61 20 73 61 Use the data sa
0f20: 76 65 64 20 62 79 20 70 61 73 73 20 36 2e 0a 09 ved by pass 6...
0f30: 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a return [struct::
0f40: 6c 69 73 74 20 6d 61 70 20 5b 73 74 61 74 65 20 list map [state
0f50: 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 run {.. SELEC
0f60: 54 20 53 2e 6e 69 64 0a 09 20 20 20 20 46 52 4f T S.nid.. FRO
0f70: 4d 20 20 20 63 73 73 75 63 63 65 73 73 6f 72 20 M cssuccessor
0f80: 53 0a 09 20 20 20 20 57 48 45 52 45 20 20 53 2e S.. WHERE S.
0f90: 63 69 64 20 3d 20 24 6d 79 69 64 0a 09 7d 5d 20 cid = $myid..}]
0fa0: 5b 6d 79 74 79 70 65 6d 65 74 68 6f 64 20 6f 66 [mytypemethod of
0fb0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 ]]. }.. #
0fc0: 69 74 65 6d 20 2d 3e 20 6c 69 73 74 20 28 69 74 item -> list (it
0fd0: 65 6d 29 0a 20 20 20 20 6d 65 74 68 6f 64 20 6e em). method n
0fe0: 65 78 74 6d 61 70 20 7b 7d 20 7b 0a 09 24 6d 79 extmap {} {..$my
0ff0: 74 79 70 65 6f 62 6a 20 73 75 63 63 65 73 73 6f typeobj successo
1000: 72 73 20 74 6d 70 20 24 6d 79 69 74 65 6d 73 0a rs tmp $myitems.
1010: 09 72 65 74 75 72 6e 20 5b 61 72 72 61 79 20 67 .return [array g
1020: 65 74 20 74 6d 70 5d 0a 20 20 20 20 7d 0a 0a 20 et tmp]. }..
1030: 20 20 20 6d 65 74 68 6f 64 20 62 72 65 61 6b 69 method breaki
1040: 6e 74 65 72 6e 61 6c 64 65 70 65 6e 64 65 6e 63 nternaldependenc
1050: 69 65 73 20 7b 7d 20 7b 0a 0a 09 23 23 0a 09 23 ies {} {...##..#
1060: 23 20 4e 4f 54 45 3a 20 54 68 69 73 20 6d 65 74 # NOTE: This met
1070: 68 6f 64 2c 20 6d 61 79 62 65 20 69 6e 20 63 6f hod, maybe in co
1080: 6e 6a 75 6e 63 74 69 6f 6e 20 77 69 74 68 20 69 njunction with i
1090: 74 73 20 63 61 6c 6c 65 72 0a 09 23 23 20 20 20 ts caller..##
10a0: 20 20 20 20 73 65 65 6d 73 20 74 6f 20 62 65 20 seems to be
10b0: 61 20 6d 65 6d 6f 72 79 20 68 6f 67 2c 20 65 73 a memory hog, es
10c0: 70 65 63 69 61 6c 6c 79 20 66 6f 72 20 6c 61 72 pecially for lar
10d0: 67 65 0a 09 23 23 20 20 20 20 20 20 20 63 68 61 ge..## cha
10e0: 6e 67 65 73 65 74 73 2c 20 77 69 74 68 20 27 6c ngesets, with 'l
10f0: 61 72 67 65 27 20 6d 65 61 6e 69 6e 67 20 74 6f arge' meaning to
1100: 20 68 61 76 65 20 61 20 27 6c 6f 6e 67 20 6c 69 have a 'long li
1110: 73 74 0a 09 23 23 20 20 20 20 20 20 20 6f 66 20 st..## of
1120: 69 74 65 6d 73 2c 20 73 65 76 65 72 61 6c 20 74 items, several t
1130: 68 6f 75 73 61 6e 64 27 2e 20 49 6e 76 65 73 74 housand'. Invest
1140: 69 67 61 74 65 20 77 68 65 72 65 20 74 68 65 0a igate where the.
1150: 09 23 23 20 20 20 20 20 20 20 6d 65 6d 6f 72 79 .## memory
1160: 20 69 73 20 73 70 65 6e 74 20 61 6e 64 20 74 68 is spent and th
1170: 65 6e 20 6c 6f 6f 6b 20 66 6f 72 20 77 61 79 73 en look for ways
1180: 20 6f 66 20 72 65 63 74 69 66 79 69 6e 67 0a 09 of rectifying..
1190: 23 23 20 20 20 20 20 20 20 74 68 65 20 70 72 6f ## the pro
11a0: 62 6c 65 6d 2e 0a 09 23 23 0a 0a 09 23 20 54 68 blem...##...# Th
11b0: 69 73 20 6d 65 74 68 6f 64 20 69 6e 73 70 65 63 is method inspec
11c0: 74 73 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 ts the changeset
11d0: 73 20 66 6f 72 20 69 6e 74 65 72 6e 61 6c 0a 09 s for internal..
11e0: 23 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 20 # dependencies.
11f0: 4e 6f 74 68 69 6e 67 20 69 73 20 64 6f 6e 65 20 Nothing is done
1200: 69 66 20 74 68 65 72 65 20 61 72 65 20 6e 6f 0a if there are no.
1210: 09 23 20 73 75 63 68 2e 20 4f 74 68 65 72 77 69 .# such. Otherwi
1220: 73 65 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 se the changeset
1230: 20 69 73 20 73 70 6c 69 74 20 69 6e 74 6f 20 61 is split into a
1240: 20 73 65 74 20 6f 66 0a 09 23 20 66 72 61 67 6d set of..# fragm
1250: 65 6e 74 73 20 77 69 74 68 6f 75 74 20 69 6e 74 ents without int
1260: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 ernal dependenci
1270: 65 73 2c 20 74 72 61 6e 73 66 6f 72 6d 69 6e 67 es, transforming
1280: 20 74 68 65 0a 09 23 20 69 6e 74 65 72 6e 61 6c the..# internal
1290: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 69 6e dependencies in
12a0: 74 6f 20 65 78 74 65 72 6e 61 6c 20 6f 6e 65 73 to external ones
12b0: 2e 20 54 68 65 20 6e 65 77 20 63 68 61 6e 67 65 . The new change
12c0: 73 65 74 73 0a 09 23 20 61 72 65 20 61 64 64 65 sets..# are adde
12d0: 64 20 74 6f 20 74 68 65 20 6c 69 73 74 20 6f 66 d to the list of
12e0: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 2e all changesets.
12f0: 0a 0a 09 23 20 57 65 20 70 65 72 66 6f 72 6d 20 ...# We perform
1300: 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 20 73 70 all necessary sp
1310: 6c 69 74 73 20 69 6e 20 6f 6e 65 20 67 6f 2c 20 lits in one go,
1320: 69 6e 73 74 65 61 64 20 6f 66 20 6f 6e 6c 79 0a instead of only.
1330: 09 23 20 6f 6e 65 2e 20 54 68 65 20 70 72 65 76 .# one. The prev
1340: 69 6f 75 73 20 61 6c 67 6f 72 69 74 68 6d 2c 20 ious algorithm,
1350: 61 64 61 70 74 65 64 20 66 72 6f 6d 20 63 76 73 adapted from cvs
1360: 32 73 76 6e 2c 20 63 6f 6d 70 75 74 65 64 0a 09 2svn, computed..
1370: 23 20 61 20 6c 6f 74 20 6f 66 20 73 74 61 74 65 # a lot of state
1380: 20 77 68 69 63 68 20 77 61 73 20 74 68 72 6f 77 which was throw
1390: 6e 20 61 77 61 79 20 61 6e 64 20 74 68 65 6e 20 n away and then
13a0: 63 6f 6d 70 75 74 65 64 20 61 67 61 69 6e 0a 09 computed again..
13b0: 23 20 66 6f 72 20 65 61 63 68 20 6f 66 20 74 68 # for each of th
13c0: 65 20 66 72 61 67 6d 65 6e 74 73 2e 20 49 74 20 e fragments. It
13d0: 73 68 6f 75 6c 64 20 62 65 20 65 61 73 69 65 72 should be easier
13e0: 20 74 6f 20 75 70 64 61 74 65 20 61 6e 64 0a 09 to update and..
13f0: 23 20 72 65 75 73 65 20 74 68 61 74 20 73 74 61 # reuse that sta
1400: 74 65 2e 0a 0a 09 23 20 54 68 65 20 63 6f 64 65 te....# The code
1410: 20 63 68 65 63 6b 73 20 6f 6e 6c 79 20 73 75 63 checks only suc
1420: 63 65 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 cessor dependenc
1430: 69 65 73 2c 20 61 73 20 74 68 69 73 0a 09 23 20 ies, as this..#
1440: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 63 6f automatically co
1450: 76 65 72 73 20 74 68 65 20 70 72 65 64 65 63 65 vers the predece
1460: 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 69 65 ssor dependencie
1470: 73 20 61 73 20 77 65 6c 6c 20 28 41 0a 09 23 20 s as well (A..#
1480: 73 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e 64 successor depend
1490: 65 6e 63 79 20 61 20 2d 3e 20 62 20 69 73 20 61 ency a -> b is a
14a0: 6c 73 6f 20 61 20 70 72 65 64 65 63 65 73 73 6f lso a predecesso
14b0: 72 20 64 65 70 65 6e 64 65 6e 63 79 0a 09 23 20 r dependency..#
14c0: 62 20 2d 3e 20 61 29 2e 0a 0a 09 23 20 41 72 72 b -> a)....# Arr
14d0: 61 79 20 6f 66 20 64 65 70 65 6e 64 65 6e 63 69 ay of dependenci
14e0: 65 73 20 28 70 61 72 65 6e 74 20 2d 3e 20 63 68 es (parent -> ch
14f0: 69 6c 64 29 2e 20 54 68 69 73 20 69 73 20 70 75 ild). This is pu
1500: 6c 6c 65 64 20 66 72 6f 6d 0a 09 23 20 74 68 65 lled from..# the
1510: 20 73 74 61 74 65 2c 20 61 6e 64 20 6c 69 6d 69 state, and limi
1520: 74 65 64 20 74 6f 20 73 75 63 63 65 73 73 6f 72 ted to successor
1530: 73 20 77 69 74 68 69 6e 20 74 68 65 20 63 68 61 s within the cha
1540: 6e 67 65 73 65 74 2e 0a 0a 09 61 72 72 61 79 20 ngeset....array
1550: 73 65 74 20 64 65 70 65 6e 64 65 6e 63 69 65 73 set dependencies
1560: 20 7b 7d 0a 09 24 6d 79 74 79 70 65 6f 62 6a 20 {}..$mytypeobj
1570: 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f internalsuccesso
1580: 72 73 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 rs dependencies
1590: 24 6d 79 69 74 65 6d 73 0a 09 69 66 20 7b 21 5b $myitems..if {![
15a0: 61 72 72 61 79 20 73 69 7a 65 20 64 65 70 65 6e array size depen
15b0: 64 65 6e 63 69 65 73 5d 7d 20 7b 72 65 74 75 72 dencies]} {retur
15c0: 6e 20 30 7d 20 3b 20 23 20 4e 6f 74 68 69 6e 67 n 0} ; # Nothing
15d0: 20 74 6f 20 62 72 65 61 6b 2e 0a 0a 09 6c 6f 67 to break....log
15e0: 20 77 72 69 74 65 20 35 20 63 73 65 74 73 20 2e write 5 csets .
15f0: 2e 2e 5b 24 73 65 6c 66 20 73 74 72 5d 2e 2e 2e ..[$self str]...
1600: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e ................
1610: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e ................
1620: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e ................
1630: 2e 2e 2e 2e 0a 0a 09 23 20 57 65 20 68 61 76 65 .......# We have
1640: 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 internal depend
1650: 65 6e 63 69 65 73 20 74 6f 20 62 72 65 61 6b 2e encies to break.
1660: 20 57 65 20 6e 6f 77 20 69 74 65 72 61 74 65 20 We now iterate
1670: 6f 76 65 72 0a 09 23 20 61 6c 6c 20 70 6f 73 69 over..# all posi
1680: 74 69 6f 6e 73 20 69 6e 20 74 68 65 20 6c 69 73 tions in the lis
1690: 74 20 28 77 68 69 63 68 20 69 73 20 63 68 72 6f t (which is chro
16a0: 6e 6f 6c 6f 67 69 63 61 6c 2c 20 61 74 20 6c 65 nological, at le
16b0: 61 73 74 0a 09 23 20 61 73 20 66 61 72 20 61 73 ast..# as far as
16c0: 20 74 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20 the timestamps
16d0: 61 72 65 20 63 6f 72 72 65 63 74 20 61 6e 64 20 are correct and
16e0: 75 6e 69 71 75 65 29 20 61 6e 64 0a 09 23 20 64 unique) and..# d
16f0: 65 74 65 72 6d 69 6e 65 20 74 68 65 20 62 65 73 etermine the bes
1700: 74 20 70 6f 73 69 74 69 6f 6e 20 66 6f 72 20 74 t position for t
1710: 68 65 20 62 72 65 61 6b 2c 20 62 79 20 74 72 79 he break, by try
1720: 69 6e 67 20 74 6f 0a 09 23 20 62 72 65 61 6b 20 ing to..# break
1730: 61 73 20 6d 61 6e 79 20 64 65 70 65 6e 64 65 6e as many dependen
1740: 63 69 65 73 20 61 73 20 70 6f 73 73 69 62 6c 65 cies as possible
1750: 20 69 6e 20 6f 6e 65 20 67 6f 2e 20 57 68 65 6e in one go. When
1760: 20 61 0a 09 23 20 62 72 65 61 6b 20 77 61 73 20 a..# break was
1770: 66 6f 75 6e 64 20 74 68 69 73 20 69 73 20 72 65 found this is re
1780: 64 6f 6e 65 20 66 6f 72 20 74 68 65 20 66 72 61 done for the fra
1790: 67 6d 65 6e 74 73 20 63 6f 6d 69 6e 67 20 61 6e gments coming an
17a0: 64 0a 09 23 20 61 66 74 65 72 2c 20 61 66 74 65 d..# after, afte
17b0: 72 20 75 70 64 69 6e 67 20 74 68 65 20 63 72 6f r upding the cro
17c0: 73 73 69 6e 67 20 69 6e 66 6f 72 6d 61 74 69 6f ssing informatio
17d0: 6e 2e 0a 0a 09 23 20 44 61 74 61 20 73 74 72 75 n....# Data stru
17e0: 63 74 75 72 65 73 3a 0a 09 23 20 4d 61 70 3a 20 ctures:..# Map:
17f0: 20 50 4f 53 20 20 20 72 65 76 69 73 69 6f 6e 20 POS revision
1800: 69 64 20 20 20 20 20 20 2d 3e 20 70 6f 73 69 74 id -> posit
1810: 69 6f 6e 20 69 6e 20 6c 69 73 74 2e 0a 09 23 20 ion in list...#
1820: 20 20 20 20 20 20 43 52 4f 53 53 20 70 6f 73 69 CROSS posi
1830: 74 69 6f 6e 20 69 6e 20 6c 69 73 74 20 2d 3e 20 tion in list ->
1840: 6e 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 number of depend
1850: 65 6e 63 69 65 73 20 63 72 6f 73 73 69 6e 67 20 encies crossing
1860: 69 74 0a 09 23 20 20 20 20 20 20 20 44 45 50 43 it..# DEPC
1870: 20 20 64 65 70 65 6e 64 65 6e 63 79 20 20 20 20 dependency
1880: 20 20 20 2d 3e 20 70 6f 73 69 74 69 6f 6e 73 20 -> positions
1890: 69 74 20 63 72 6f 73 73 65 73 0a 09 23 20 4c 69 it crosses..# Li
18a0: 73 74 3a 20 52 41 4e 47 45 20 4f 66 20 74 68 65 st: RANGE Of the
18b0: 20 70 6f 73 69 74 69 6f 6e 73 20 69 74 73 65 6c positions itsel
18c0: 66 2e 0a 09 23 20 41 20 64 65 70 65 6e 64 65 6e f...# A dependen
18d0: 63 79 20 69 73 20 61 20 73 69 6e 67 6c 65 2d 65 cy is a single-e
18e0: 6c 65 6d 65 6e 74 20 6d 61 70 20 70 61 72 65 6e lement map paren
18f0: 74 20 2d 3e 20 63 68 69 6c 64 0a 0a 09 49 6e 69 t -> child...Ini
1900: 74 69 61 6c 69 7a 65 42 72 65 61 6b 53 74 61 74 tializeBreakStat
1910: 65 20 24 6d 79 69 74 65 6d 73 0a 0a 09 73 65 74 e $myitems...set
1920: 20 66 72 61 67 6d 65 6e 74 73 20 7b 7d 0a 09 73 fragments {}..s
1930: 65 74 20 6e 65 77 20 20 20 20 20 20 20 5b 6c 69 et new [li
1940: 73 74 20 24 72 61 6e 67 65 5d 0a 09 61 72 72 61 st $range]..arra
1950: 79 20 73 65 74 20 62 72 65 61 6b 73 20 7b 7d 0a y set breaks {}.
1960: 0a 09 23 20 49 6e 73 74 65 61 64 20 6f 66 20 6f ..# Instead of o
1970: 6e 65 20 6c 69 73 74 20 68 6f 6c 64 69 6e 67 20 ne list holding
1980: 62 6f 74 68 20 70 72 6f 63 65 73 73 65 64 20 61 both processed a
1990: 6e 64 20 70 65 6e 64 69 6e 67 0a 09 23 20 66 72 nd pending..# fr
19a0: 61 67 6d 65 6e 74 73 20 77 65 20 75 73 65 20 74 agments we use t
19b0: 77 6f 2c 20 6f 6e 65 20 66 6f 72 20 74 68 65 20 wo, one for the
19c0: 66 72 61 6d 65 6e 74 73 20 74 6f 20 70 72 6f 63 framents to proc
19d0: 65 73 73 2c 20 6f 6e 65 0a 09 23 20 74 6f 20 68 ess, one..# to h
19e0: 6f 6c 64 20 74 68 65 20 6e 65 77 20 66 72 61 67 old the new frag
19f0: 6d 65 6e 74 73 2c 20 61 6e 64 20 74 68 65 20 6c ments, and the l
1a00: 61 74 74 65 72 20 69 73 20 63 6f 70 69 65 64 20 atter is copied
1a10: 74 6f 20 74 68 65 0a 09 23 20 66 6f 72 6d 65 72 to the..# former
1a20: 20 77 68 65 6e 20 74 68 65 79 20 72 75 6e 20 6f when they run o
1a30: 75 74 2e 20 54 68 69 73 20 6b 65 65 70 73 20 74 ut. This keeps t
1a40: 68 65 20 6c 69 73 74 20 6f 66 20 70 65 6e 64 69 he list of pendi
1a50: 6e 67 0a 09 23 20 66 72 61 67 6d 65 6e 74 73 20 ng..# fragments
1a60: 73 68 6f 72 74 20 77 69 74 68 6f 75 74 20 73 61 short without sa
1a70: 63 72 69 66 69 63 69 6e 67 20 73 70 65 65 64 20 crificing speed
1a80: 62 79 20 73 68 69 66 74 69 6e 67 20 73 74 75 66 by shifting stuf
1a90: 66 0a 09 23 20 64 6f 77 6e 2e 20 57 65 20 65 73 f..# down. We es
1aa0: 70 65 63 69 61 6c 6c 79 20 64 72 6f 70 20 74 68 pecially drop th
1ab0: 65 20 6d 65 6d 6f 72 79 20 6f 66 20 66 72 61 67 e memory of frag
1ac0: 6d 65 6e 74 73 20 62 72 6f 6b 65 6e 0a 09 23 20 ments broken..#
1ad0: 64 75 72 69 6e 67 20 70 72 6f 63 65 73 73 69 6e during processin
1ae0: 67 20 61 66 74 65 72 20 61 20 73 68 6f 72 74 20 g after a short
1af0: 74 69 6d 65 2c 20 69 6e 73 74 65 61 64 20 6f 66 time, instead of
1b00: 20 6c 65 74 74 69 6e 67 20 69 74 0a 09 23 20 63 letting it..# c
1b10: 6f 6e 73 75 6d 65 20 6d 65 6d 6f 72 79 2e 0a 0a onsume memory...
1b20: 09 77 68 69 6c 65 20 7b 5b 6c 6c 65 6e 67 74 68 .while {[llength
1b30: 20 24 6e 65 77 5d 7d 20 7b 0a 0a 09 20 20 20 20 $new]} {...
1b40: 73 65 74 20 70 65 6e 64 69 6e 67 20 24 6e 65 77 set pending $new
1b50: 0a 09 20 20 20 20 73 65 74 20 6e 65 77 20 20 20 .. set new
1b60: 20 20 7b 7d 0a 09 20 20 20 20 73 65 74 20 61 74 {}.. set at
1b70: 20 20 20 20 20 20 30 0a 0a 09 20 20 20 20 77 68 0... wh
1b80: 69 6c 65 20 7b 24 61 74 20 3c 20 5b 6c 6c 65 6e ile {$at < [llen
1b90: 67 74 68 20 24 70 65 6e 64 69 6e 67 5d 7d 20 7b gth $pending]} {
1ba0: 0a 09 09 73 65 74 20 63 75 72 72 65 6e 74 20 5b ...set current [
1bb0: 6c 69 6e 64 65 78 20 24 70 65 6e 64 69 6e 67 20 lindex $pending
1bc0: 24 61 74 5d 0a 0a 09 09 6c 6f 67 20 77 72 69 74 $at]....log writ
1bd0: 65 20 36 20 63 73 65 74 73 20 7b 2e 20 2e 20 2e e 6 csets {. . .
1be0: 2e 20 2e 2e 2e 20 2e 2e 2e 2e 2e 20 2e 2e 2e 2e . ... ..... ....
1bf0: 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e .... ...........
1c00: 2e 2e 7d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 ..}...log write
1c10: 36 20 63 73 65 74 73 20 7b 53 63 68 65 64 75 6c 6 csets {Schedul
1c20: 65 64 20 20 20 5b 6a 6f 69 6e 20 5b 50 52 73 20 ed [join [PRs
1c30: 5b 6c 72 61 6e 67 65 20 24 70 65 6e 64 69 6e 67 [lrange $pending
1c40: 20 24 61 74 20 65 6e 64 5d 5d 20 7b 20 7d 5d 7d $at end]] { }]}
1c50: 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 ...log write 6 c
1c60: 73 65 74 73 20 7b 43 6f 6e 73 69 64 65 72 69 6e sets {Considerin
1c70: 67 20 5b 50 52 20 24 63 75 72 72 65 6e 74 5d 20 g [PR $current]
1c80: 5c 5b 24 61 74 2f 5b 6c 6c 65 6e 67 74 68 20 24 \[$at/[llength $
1c90: 70 65 6e 64 69 6e 67 5d 5c 5d 7d 0a 0a 09 09 73 pending]\]}....s
1ca0: 65 74 20 62 65 73 74 20 5b 46 69 6e 64 42 65 73 et best [FindBes
1cb0: 74 42 72 65 61 6b 20 24 63 75 72 72 65 6e 74 5d tBreak $current]
1cc0: 0a 0a 09 09 69 66 20 7b 24 62 65 73 74 20 3c 20 ....if {$best <
1cd0: 30 7d 20 7b 0a 09 09 20 20 20 20 23 20 54 68 65 0} {... # The
1ce0: 20 69 6e 73 70 65 63 74 65 64 20 72 61 6e 67 65 inspected range
1cf0: 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61 6c has no internal
1d00: 0a 09 09 20 20 20 20 23 20 64 65 70 65 6e 64 65 ... # depende
1d10: 6e 63 69 65 73 2e 20 54 68 69 73 20 69 73 20 61 ncies. This is a
1d20: 20 63 6f 6d 70 6c 65 74 65 20 66 72 61 67 6d 65 complete fragme
1d30: 6e 74 2e 0a 09 09 20 20 20 20 6c 61 70 70 65 6e nt.... lappen
1d40: 64 20 66 72 61 67 6d 65 6e 74 73 20 24 63 75 72 d fragments $cur
1d50: 72 65 6e 74 0a 0a 09 09 20 20 20 20 6c 6f 67 20 rent.... log
1d60: 77 72 69 74 65 20 36 20 63 73 65 74 73 20 22 4e write 6 csets "N
1d70: 6f 20 62 72 65 61 6b 73 2c 20 66 69 6e 61 6c 22 o breaks, final"
1d80: 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 20 20 ...} else {...
1d90: 20 20 23 20 53 70 6c 69 74 20 74 68 65 20 72 61 # Split the ra
1da0: 6e 67 65 20 61 6e 64 20 73 63 68 65 64 75 6c 65 nge and schedule
1db0: 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 0a 09 the resulting..
1dc0: 09 20 20 20 20 23 20 66 72 61 67 6d 65 6e 74 73 . # fragments
1dd0: 20 66 6f 72 20 66 75 72 74 68 65 72 20 69 6e 73 for further ins
1de0: 70 65 63 74 69 6f 6e 2e 20 52 65 6d 65 6d 62 65 pection. Remembe
1df0: 72 20 74 68 65 0a 09 09 20 20 20 20 23 20 6e 75 r the... # nu
1e00: 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 65 6e mber of dependen
1e10: 63 69 65 73 20 63 75 74 20 62 65 66 6f 72 65 20 cies cut before
1e20: 77 65 20 72 65 6d 6f 76 65 20 74 68 65 6d 0a 09 we remove them..
1e30: 09 20 20 20 20 23 20 66 72 6f 6d 20 63 6f 6e 73 . # from cons
1e40: 69 64 65 72 61 74 69 6f 6e 2c 20 66 6f 72 20 64 ideration, for d
1e50: 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 6c 61 74 ocumentation lat
1e60: 65 72 2e 0a 0a 09 09 20 20 20 20 73 65 74 20 62 er..... set b
1e70: 72 65 61 6b 73 28 24 62 65 73 74 29 20 24 63 72 reaks($best) $cr
1e80: 6f 73 73 28 24 62 65 73 74 29 0a 0a 09 09 20 20 oss($best)....
1e90: 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 log write 6 cs
1ea0: 65 74 73 20 22 42 65 73 74 20 62 72 65 61 6b 20 ets "Best break
1eb0: 40 20 24 62 65 73 74 2c 20 63 75 74 74 69 6e 67 @ $best, cutting
1ec0: 20 5b 6e 73 70 20 24 63 72 6f 73 73 28 24 62 65 [nsp $cross($be
1ed0: 73 74 29 20 64 65 70 65 6e 64 65 6e 63 79 20 64 st) dependency d
1ee0: 65 70 65 6e 64 65 6e 63 69 65 73 5d 22 0a 0a 09 ependencies]"...
1ef0: 09 20 20 20 20 23 20 4e 6f 74 65 3a 20 54 68 65 . # Note: The
1f00: 20 76 61 6c 75 65 20 6f 66 20 62 65 73 74 20 69 value of best i
1f10: 73 20 61 6e 20 61 62 6f 6c 75 74 65 20 6c 6f 63 s an abolute loc
1f20: 61 74 69 6f 6e 0a 09 09 20 20 20 20 23 20 69 6e ation... # in
1f30: 20 6d 79 69 74 65 6d 73 2e 20 55 73 65 20 74 68 myitems. Use th
1f40: 65 20 73 74 61 72 74 20 6f 66 20 63 75 72 72 65 e start of curre
1f50: 6e 74 20 74 6f 20 6d 61 6b 65 20 69 74 0a 09 09 nt to make it...
1f60: 20 20 20 20 23 20 61 6e 20 69 6e 64 65 78 20 61 # an index a
1f70: 62 73 6f 6c 75 74 65 20 74 6f 20 63 75 72 72 65 bsolute to curre
1f80: 6e 74 2e 0a 0a 09 09 20 20 20 20 73 65 74 20 62 nt..... set b
1f90: 72 65 6c 20 5b 65 78 70 72 20 7b 24 62 65 73 74 rel [expr {$best
1fa0: 20 2d 20 5b 6c 69 6e 64 65 78 20 24 63 75 72 72 - [lindex $curr
1fb0: 65 6e 74 20 30 5d 7d 5d 0a 09 09 20 20 20 20 73 ent 0]}]... s
1fc0: 65 74 20 62 6e 65 78 74 20 24 62 72 65 6c 20 3b et bnext $brel ;
1fd0: 20 69 6e 63 72 20 62 6e 65 78 74 0a 09 09 20 20 incr bnext...
1fe0: 20 20 73 65 74 20 66 72 61 67 62 65 66 6f 72 65 set fragbefore
1ff0: 20 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 6e [lrange $curren
2000: 74 20 30 20 24 62 72 65 6c 5d 0a 09 09 20 20 20 t 0 $brel]...
2010: 20 73 65 74 20 66 72 61 67 61 66 74 65 72 20 20 set fragafter
2020: 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 6e 74 [lrange $current
2030: 20 24 62 6e 65 78 74 20 65 6e 64 5d 0a 0a 09 09 $bnext end]....
2040: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20 log write 6
2050: 63 73 65 74 73 20 22 4e 65 77 20 70 69 65 63 65 csets "New piece
2060: 73 20 20 5b 50 52 20 24 66 72 61 67 62 65 66 6f s [PR $fragbefo
2070: 72 65 5d 20 5b 50 52 20 24 66 72 61 67 61 66 74 re] [PR $fragaft
2080: 65 72 5d 22 0a 0a 09 09 20 20 20 20 69 6e 74 65 er]".... inte
2090: 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 5b 6c grity assert {[l
20a0: 6c 65 6e 67 74 68 20 24 66 72 61 67 62 65 66 6f length $fragbefo
20b0: 72 65 5d 7d 20 7b 46 6f 75 6e 64 20 7a 65 72 6f re]} {Found zero
20c0: 2d 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 -length fragment
20d0: 20 61 74 20 74 68 65 20 62 65 67 69 6e 6e 69 6e at the beginnin
20e0: 67 7d 0a 09 09 20 20 20 20 69 6e 74 65 67 72 69 g}... integri
20f0: 74 79 20 61 73 73 65 72 74 20 7b 5b 6c 6c 65 6e ty assert {[llen
2100: 67 74 68 20 24 66 72 61 67 61 66 74 65 72 5d 7d gth $fragafter]}
2110: 20 20 7b 46 6f 75 6e 64 20 7a 65 72 6f 2d 6c 65 {Found zero-le
2120: 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 20 61 74 ngth fragment at
2130: 20 74 68 65 20 65 6e 64 7d 0a 0a 09 09 20 20 20 the end}....
2140: 20 6c 61 70 70 65 6e 64 20 6e 65 77 20 24 66 72 lappend new $fr
2150: 61 67 62 65 66 6f 72 65 20 24 66 72 61 67 61 66 agbefore $fragaf
2160: 74 65 72 0a 09 09 20 20 20 20 43 75 74 41 74 20 ter... CutAt
2170: 24 62 65 73 74 0a 09 09 7d 0a 0a 09 09 69 6e 63 $best...}....inc
2180: 72 20 61 74 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a r at.. }..}..
2190: 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 73 65 .log write 6 cse
21a0: 74 73 20 22 2e 20 2e 20 2e 2e 20 2e 2e 2e 20 2e ts ". . .. ... .
21b0: 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 2e 2e .... ........ ..
21c0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 22 0a 0a 09 23 ..........."...#
21d0: 20 28 2a 29 20 57 65 20 63 6c 65 61 72 20 6f 75 (*) We clear ou
21e0: 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65 64 t the associated
21f0: 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d 79 69 part of the myi
2200: 74 65 6d 6d 61 70 0a 09 23 20 69 6e 2d 6d 65 6d temmap..# in-mem
2210: 6f 72 79 20 69 6e 64 65 78 20 69 6e 20 70 72 65 ory index in pre
2220: 70 61 72 61 74 69 6f 6e 20 66 6f 72 20 6e 65 77 paration for new
2230: 20 64 61 74 61 2e 20 41 20 73 69 6d 70 6c 65 20 data. A simple
2240: 75 6e 73 65 74 0a 09 23 20 69 73 20 65 6e 6f 75 unset..# is enou
2250: 67 68 2c 20 77 65 20 68 61 76 65 20 6e 6f 20 73 gh, we have no s
2260: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 ymbol changesets
2270: 20 61 74 20 74 68 69 73 20 74 69 6d 65 2c 20 61 at this time, a
2280: 6e 64 0a 09 23 20 74 68 75 73 20 6e 65 76 65 72 nd..# thus never
2290: 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e 65 20 72 more than one r
22a0: 65 66 65 72 65 6e 63 65 20 69 6e 20 74 68 65 20 eference in the
22b0: 6c 69 73 74 2e 0a 0a 09 66 6f 72 65 61 63 68 20 list....foreach
22c0: 69 69 64 20 24 6d 79 69 74 65 6d 73 20 7b 0a 09 iid $myitems {..
22d0: 20 20 20 20 73 65 74 20 6b 65 79 20 5b 6c 69 73 set key [lis
22e0: 74 20 24 6d 79 74 79 70 65 20 24 69 69 64 5d 0a t $mytype $iid].
22f0: 09 20 20 20 20 75 6e 73 65 74 20 6d 79 69 74 65 . unset myite
2300: 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20 20 20 20 mmap($key)..
2310: 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74 log write 8 cset
2320: 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20 3c 24 6b s {MAP- item <$k
2330: 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 ey> $self = [$se
2340: 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 0a 09 23 20 lf str]}..}...#
2350: 43 72 65 61 74 65 20 63 68 61 6e 67 65 73 65 74 Create changeset
2360: 73 20 66 6f 72 20 74 68 65 20 66 72 61 67 6d 65 s for the fragme
2370: 6e 74 73 2c 20 72 65 75 73 69 6e 67 20 74 68 65 nts, reusing the
2380: 20 63 75 72 72 65 6e 74 20 6f 6e 65 0a 09 23 20 current one..#
2390: 66 6f 72 20 74 68 65 20 66 69 72 73 74 20 66 72 for the first fr
23a0: 61 67 6d 65 6e 74 2e 20 57 65 20 73 6f 72 74 20 agment. We sort
23b0: 74 68 65 6d 20 69 6e 20 6f 72 64 65 72 20 74 6f them in order to
23c0: 20 61 6c 6c 6f 77 0a 09 23 20 63 68 65 63 6b 69 allow..# checki
23d0: 6e 67 20 66 6f 72 20 67 61 70 73 20 61 6e 64 20 ng for gaps and
23e0: 6e 69 63 65 20 6d 65 73 73 61 67 65 73 2e 0a 0a nice messages...
23f0: 09 73 65 74 20 66 72 61 67 6d 65 6e 74 73 20 5b .set fragments [
2400: 6c 73 6f 72 74 20 2d 69 6e 64 65 78 20 30 20 2d lsort -index 0 -
2410: 69 6e 74 65 67 65 72 20 24 66 72 61 67 6d 65 6e integer $fragmen
2420: 74 73 5d 0a 0a 09 23 70 75 74 73 20 5c 74 2e 5b ts]...#puts \t.[
2430: 6a 6f 69 6e 20 5b 50 52 73 20 24 66 72 61 67 6d join [PRs $fragm
2440: 65 6e 74 73 5d 20 2e 5c 6e 5c 74 2e 5d 2e 0a 0a ents] .\n\t.]...
2450: 09 42 6f 72 64 65 72 20 5b 6c 69 6e 64 65 78 20 .Border [lindex
2460: 24 66 72 61 67 6d 65 6e 74 73 20 30 5d 20 66 69 $fragments 0] fi
2470: 72 73 74 73 20 66 69 72 73 74 65 0a 0a 09 69 6e rsts firste...in
2480: 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b tegrity assert {
2490: 24 66 69 72 73 74 73 20 3d 3d 20 30 7d 20 7b 42 $firsts == 0} {B
24a0: 61 64 20 66 72 61 67 6d 65 6e 74 20 73 74 61 72 ad fragment star
24b0: 74 20 40 20 24 66 69 72 73 74 73 2c 20 67 61 70 t @ $firsts, gap
24c0: 2c 20 6f 72 20 62 65 66 6f 72 65 20 62 65 67 69 , or before begi
24d0: 6e 6e 69 6e 67 20 6f 66 20 74 68 65 20 72 61 6e nning of the ran
24e0: 67 65 7d 0a 0a 09 73 65 74 20 6c 61 73 74 65 20 ge}...set laste
24f0: 24 66 69 72 73 74 65 0a 09 66 6f 72 65 61 63 68 $firste..foreach
2500: 20 66 72 61 67 6d 65 6e 74 20 5b 6c 72 61 6e 67 fragment [lrang
2510: 65 20 24 66 72 61 67 6d 65 6e 74 73 20 31 20 65 e $fragments 1 e
2520: 6e 64 5d 20 7b 0a 09 20 20 20 20 42 6f 72 64 65 nd] {.. Borde
2530: 72 20 24 66 72 61 67 6d 65 6e 74 20 73 20 65 0a r $fragment s e.
2540: 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 . integrity a
2550: 73 73 65 72 74 20 7b 24 6c 61 73 74 65 20 3d 3d ssert {$laste ==
2560: 20 28 24 73 20 2d 20 31 29 7d 20 7b 42 61 64 20 ($s - 1)} {Bad
2570: 66 72 61 67 6d 65 6e 74 20 62 6f 72 64 65 72 20 fragment border
2580: 3c 24 6c 61 73 74 65 20 7c 20 24 73 3e 2c 20 67 <$laste | $s>, g
2590: 61 70 20 6f 72 20 6f 76 65 72 6c 61 70 7d 0a 0a ap or overlap}..
25a0: 09 20 20 20 20 73 65 74 20 6e 65 77 20 5b 24 74 . set new [$t
25b0: 79 70 65 20 25 41 55 54 4f 25 20 24 6d 79 70 72 ype %AUTO% $mypr
25c0: 6f 6a 65 63 74 20 24 6d 79 74 79 70 65 20 24 6d oject $mytype $m
25d0: 79 73 72 63 69 64 20 5b 6c 72 61 6e 67 65 20 24 ysrcid [lrange $
25e0: 6d 79 69 74 65 6d 73 20 24 73 20 24 65 5d 5d 0a myitems $s $e]].
25f0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c 6f 67 . log
2600: 20 77 72 69 74 65 20 34 20 63 73 65 74 73 20 22 write 4 csets "
2610: 42 72 65 61 6b 69 6e 67 20 5b 24 73 65 6c 66 20 Breaking [$self
2620: 73 74 72 20 5d 20 40 20 24 6c 61 73 74 65 2c 20 str ] @ $laste,
2630: 6e 65 77 20 5b 24 6e 65 77 20 73 74 72 5d 2c 20 new [$new str],
2640: 63 75 74 74 69 6e 67 20 24 62 72 65 61 6b 73 28 cutting $breaks(
2650: 24 6c 61 73 74 65 29 22 0a 0a 09 20 20 20 20 73 $laste)"... s
2660: 65 74 20 6c 61 73 74 65 20 24 65 0a 09 7d 0a 0a et laste $e..}..
2670: 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 .integrity asser
2680: 74 20 7b 0a 09 20 20 20 20 24 6c 61 73 74 65 20 t {.. $laste
2690: 3d 3d 20 28 5b 6c 6c 65 6e 67 74 68 20 24 6d 79 == ([llength $my
26a0: 69 74 65 6d 73 5d 2d 31 29 0a 09 7d 20 7b 42 61 items]-1)..} {Ba
26b0: 64 20 66 72 61 67 6d 65 6e 74 20 65 6e 64 20 40 d fragment end @
26c0: 20 24 6c 61 73 74 65 2c 20 67 61 70 2c 20 6f 72 $laste, gap, or
26d0: 20 62 65 79 6f 6e 64 20 65 6e 64 20 6f 66 20 74 beyond end of t
26e0: 68 65 20 72 61 6e 67 65 7d 0a 0a 09 23 20 50 75 he range}...# Pu
26f0: 74 20 74 68 65 20 66 69 72 73 74 20 66 72 61 67 t the first frag
2700: 6d 65 6e 74 20 69 6e 74 6f 20 74 68 65 20 63 75 ment into the cu
2710: 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2c rrent changeset,
2720: 20 61 6e 64 0a 09 23 20 75 70 64 61 74 65 20 74 and..# update t
2730: 68 65 20 69 6e 2d 6d 65 6d 6f 72 79 20 69 6e 64 he in-memory ind
2740: 65 78 2e 20 57 65 20 63 61 6e 20 73 69 6d 70 6c ex. We can simpl
2750: 79 20 28 72 65 29 61 64 64 20 74 68 65 20 69 74 y (re)add the it
2760: 65 6d 73 0a 09 23 20 62 65 63 61 75 73 65 20 77 ems..# because w
2770: 65 20 63 6c 65 61 72 65 64 20 74 68 65 20 70 72 e cleared the pr
2780: 65 76 69 6f 75 73 6c 79 20 65 78 69 73 74 69 6e eviously existin
2790: 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20 73 g information, s
27a0: 65 65 0a 09 23 20 28 2a 29 20 61 62 6f 76 65 2e ee..# (*) above.
27b0: 20 50 65 72 73 69 73 74 65 6e 63 65 20 64 6f 65 Persistence doe
27c0: 73 20 6e 6f 74 20 6d 61 74 74 65 72 20 68 65 72 s not matter her
27d0: 65 2c 20 6e 6f 6e 65 20 6f 66 20 74 68 65 0a 09 e, none of the..
27e0: 23 20 63 68 61 6e 67 65 73 65 74 73 20 68 61 73 # changesets has
27f0: 20 62 65 65 6e 20 73 61 76 65 64 20 74 6f 20 74 been saved to t
2800: 68 65 20 70 65 72 73 69 73 74 65 6e 74 20 73 74 he persistent st
2810: 61 74 65 20 79 65 74 2e 0a 0a 09 73 65 74 20 6d ate yet....set m
2820: 79 69 74 65 6d 73 20 20 5b 6c 72 61 6e 67 65 20 yitems [lrange
2830: 24 6d 79 69 74 65 6d 73 20 20 30 20 24 66 69 72 $myitems 0 $fir
2840: 73 74 65 5d 0a 09 73 65 74 20 6d 79 74 69 74 65 ste]..set mytite
2850: 6d 73 20 5b 6c 72 61 6e 67 65 20 24 6d 79 74 69 ms [lrange $myti
2860: 74 65 6d 73 20 30 20 24 66 69 72 73 74 65 5d 0a tems 0 $firste].
2870: 09 66 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79 .foreach iid $my
2880: 69 74 65 6d 73 20 7b 0a 09 20 20 20 20 73 65 74 items {.. set
2890: 20 6b 65 79 20 5b 6c 69 73 74 20 24 6d 79 74 79 key [list $myty
28a0: 70 65 20 24 69 69 64 5d 0a 09 20 20 20 20 73 65 pe $iid].. se
28b0: 74 20 6d 79 69 74 65 6d 6d 61 70 28 24 6b 65 79 t myitemmap($key
28c0: 29 20 24 73 65 6c 66 0a 09 20 20 20 20 6c 6f 67 ) $self.. log
28d0: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b write 8 csets {
28e0: 4d 41 50 2b 20 69 74 65 6d 20 3c 24 6b 65 79 3e MAP+ item <$key>
28f0: 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c 66 20 $self = [$self
2900: 73 74 72 5d 7d 0a 09 7d 0a 0a 09 72 65 74 75 72 str]}..}...retur
2910: 6e 20 31 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d n 1. }.. m
2920: 65 74 68 6f 64 20 70 65 72 73 69 73 74 20 7b 7d ethod persist {}
2930: 20 7b 0a 09 73 65 74 20 74 69 64 20 24 6d 79 63 {..set tid $myc
2940: 73 74 79 70 65 28 24 6d 79 74 79 70 65 29 0a 09 stype($mytype)..
2950: 73 65 74 20 70 69 64 20 5b 24 6d 79 70 72 6f 6a set pid [$myproj
2960: 65 63 74 20 69 64 5d 0a 09 73 65 74 20 70 6f 73 ect id]..set pos
2970: 20 30 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73 0...state trans
2980: 61 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74 action {.. st
2990: 61 74 65 20 72 75 6e 20 7b 0a 09 09 49 4e 53 45 ate run {...INSE
29a0: 52 54 20 49 4e 54 4f 20 63 68 61 6e 67 65 73 65 RT INTO changese
29b0: 74 20 28 63 69 64 2c 20 20 20 70 69 64 2c 20 20 t (cid, pid,
29c0: 74 79 70 65 2c 20 73 72 63 29 0a 09 09 56 41 4c type, src)...VAL
29d0: 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20 UES
29e0: 20 20 20 28 24 6d 79 69 64 2c 20 24 70 69 64 2c ($myid, $pid,
29f0: 20 24 74 69 64 2c 20 24 6d 79 73 72 63 69 64 29 $tid, $mysrcid)
2a00: 3b 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20 66 ;.. }... f
2a10: 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79 69 74 oreach iid $myit
2a20: 65 6d 73 20 7b 0a 09 09 73 74 61 74 65 20 72 75 ems {...state ru
2a30: 6e 20 7b 0a 09 09 20 20 20 20 49 4e 53 45 52 54 n {... INSERT
2a40: 20 49 4e 54 4f 20 63 73 69 74 65 6d 20 28 63 69 INTO csitem (ci
2a50: 64 2c 20 20 20 70 6f 73 2c 20 20 69 69 64 29 0a d, pos, iid).
2a60: 09 09 20 20 20 20 56 41 4c 55 45 53 20 20 20 20 .. VALUES
2a70: 20 20 20 20 20 20 20 20 20 28 24 6d 79 69 64 2c ($myid,
2a80: 20 24 70 6f 73 2c 20 24 69 69 64 29 3b 0a 09 09 $pos, $iid);...
2a90: 7d 0a 09 09 69 6e 63 72 20 70 6f 73 0a 09 20 20 }...incr pos..
2aa0: 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 }..}..return.
2ab0: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 }.. method
2ac0: 20 74 69 6d 65 72 61 6e 67 65 20 7b 7d 20 7b 20 timerange {} {
2ad0: 72 65 74 75 72 6e 20 5b 24 6d 79 74 79 70 65 6f return [$mytypeo
2ae0: 62 6a 20 74 69 6d 65 72 61 6e 67 65 20 24 6d 79 bj timerange $my
2af0: 69 74 65 6d 73 5d 20 7d 0a 0a 20 20 20 20 6d 65 items] }.. me
2b00: 74 68 6f 64 20 6c 69 6d 69 74 73 20 7b 7d 20 7b thod limits {} {
2b10: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 ..struct::list a
2b20: 73 73 69 67 6e 20 5b 24 6d 79 74 79 70 65 6f 62 ssign [$mytypeob
2b30: 6a 20 6c 69 6d 69 74 73 20 24 6d 79 69 74 65 6d j limits $myitem
2b40: 73 5d 20 6d 61 78 70 20 6d 69 6e 73 0a 09 72 65 s] maxp mins..re
2b50: 74 75 72 6e 20 5b 6c 69 73 74 20 5b 54 61 67 49 turn [list [TagI
2b60: 74 65 6d 44 69 63 74 20 24 6d 61 78 70 20 24 6d temDict $maxp $m
2b70: 79 74 79 70 65 5d 20 5b 54 61 67 49 74 65 6d 44 ytype] [TagItemD
2b80: 69 63 74 20 24 6d 69 6e 73 20 24 6d 79 74 79 70 ict $mins $mytyp
2b90: 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d e]]. }.. m
2ba0: 65 74 68 6f 64 20 64 72 6f 70 20 7b 7d 20 7b 0a ethod drop {} {.
2bb0: 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 .log write 8 cse
2bc0: 74 73 20 7b 44 72 6f 70 70 69 6e 67 20 24 73 65 ts {Dropping $se
2bd0: 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d lf = [$self str]
2be0: 7d 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73 61 }...state transa
2bf0: 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74 61 ction {.. sta
2c00: 74 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54 te run {...DELET
2c10: 45 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65 74 E FROM changeset
2c20: 20 20 20 57 48 45 52 45 20 63 69 64 20 3d 20 24 WHERE cid = $
2c30: 6d 79 69 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 myid;...DELETE F
2c40: 52 4f 4d 20 63 73 69 74 65 6d 20 20 20 20 20 20 ROM csitem
2c50: 57 48 45 52 45 20 63 69 64 20 3d 20 24 6d 79 69 WHERE cid = $myi
2c60: 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f 4d d;...DELETE FROM
2c70: 20 63 73 73 75 63 63 65 73 73 6f 72 20 57 48 45 cssuccessor WHE
2c80: 52 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b 0a RE cid = $myid;.
2c90: 09 20 20 20 20 7d 0a 09 7d 0a 09 66 6f 72 65 61 . }..}..forea
2ca0: 63 68 20 69 69 64 20 24 6d 79 69 74 65 6d 73 20 ch iid $myitems
2cb0: 7b 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b {.. set key [
2cc0: 6c 69 73 74 20 24 6d 79 74 79 70 65 20 24 69 69 list $mytype $ii
2cd0: 64 5d 0a 09 20 20 20 20 75 6e 73 65 74 20 6d 79 d].. unset my
2ce0: 69 74 65 6d 6d 61 70 28 24 6b 65 79 29 0a 09 20 itemmap($key)..
2cf0: 20 20 20 6c 6f 67 20 77 72 69 74 65 20 38 20 63 log write 8 c
2d00: 73 65 74 73 20 7b 4d 41 50 2d 20 69 74 65 6d 20 sets {MAP- item
2d10: 3c 24 6b 65 79 3e 20 24 73 65 6c 66 20 3d 20 5b <$key> $self = [
2d20: 24 73 65 6c 66 20 73 74 72 5d 7d 0a 09 7d 0a 09 $self str]}..}..
2d30: 73 65 74 20 70 6f 73 20 20 20 20 20 20 20 20 20 set pos
2d40: 20 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 63 74 [lsearch -exact
2d50: 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20 24 $mychangesets $
2d60: 73 65 6c 66 5d 0a 09 73 65 74 20 6d 79 63 68 61 self]..set mycha
2d70: 6e 67 65 73 65 74 73 20 5b 6c 72 65 70 6c 61 63 ngesets [lreplac
2d80: 65 20 24 6d 79 63 68 61 6e 67 65 73 65 74 73 20 e $mychangesets
2d90: 24 70 6f 73 20 24 70 6f 73 5d 0a 09 73 65 74 20 $pos $pos]..set
2da0: 70 6f 73 20 20 20 20 20 20 20 20 20 20 20 20 20 pos
2db0: 20 20 20 20 20 20 20 5b 6c 73 65 61 72 63 68 20 [lsearch
2dc0: 2d 65 78 61 63 74 20 24 6d 79 74 63 68 61 6e 67 -exact $mytchang
2dd0: 65 73 65 74 73 28 24 6d 79 74 79 70 65 29 20 24 esets($mytype) $
2de0: 73 65 6c 66 5d 0a 09 73 65 74 20 6d 79 74 63 68 self]..set mytch
2df0: 61 6e 67 65 73 65 74 73 28 24 6d 79 74 79 70 65 angesets($mytype
2e00: 29 20 5b 6c 72 65 70 6c 61 63 65 20 24 6d 79 74 ) [lreplace $myt
2e10: 63 68 61 6e 67 65 73 65 74 73 28 24 6d 79 74 79 changesets($myty
2e20: 70 65 29 20 24 70 6f 73 20 24 70 6f 73 5d 0a 0a pe) $pos $pos]..
2e30: 09 23 20 52 65 74 75 72 6e 20 74 68 65 20 6c 69 .# Return the li
2e40: 73 74 20 6f 66 20 70 72 65 64 65 63 65 73 73 6f st of predecesso
2e50: 72 73 20 73 6f 20 74 68 61 74 20 74 68 65 79 20 rs so that they
2e60: 63 61 6e 20 62 65 20 61 64 6a 75 73 74 65 64 2e can be adjusted.
2e70: 0a 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 ..return [struct
2e80: 3a 3a 6c 69 73 74 20 6d 61 70 20 5b 73 74 61 74 ::list map [stat
2e90: 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c e run {.. SEL
2ea0: 45 43 54 20 63 69 64 0a 09 20 20 20 20 46 52 4f ECT cid.. FRO
2eb0: 4d 20 20 20 63 73 73 75 63 63 65 73 73 6f 72 0a M cssuccessor.
2ec0: 09 20 20 20 20 57 48 45 52 45 20 20 6e 69 64 20 . WHERE nid
2ed0: 3d 20 24 6d 79 69 64 0a 09 7d 5d 20 5b 6d 79 74 = $myid..}] [myt
2ee0: 79 70 65 6d 65 74 68 6f 64 20 6f 66 5d 5d 0a 20 ypemethod of]].
2ef0: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 }.. method
2f00: 20 72 65 70 6f 72 74 6c 6f 6f 70 20 7b 7b 6b 69 reportloop {{ki
2f10: 6c 6c 20 31 7d 7d 20 7b 0a 09 23 20 57 65 20 70 ll 1}} {..# We p
2f20: 72 69 6e 74 20 74 68 65 20 69 74 65 6d 73 20 77 rint the items w
2f30: 68 69 63 68 20 61 72 65 20 70 72 6f 64 75 63 69 hich are produci
2f40: 6e 67 20 74 68 65 20 6c 6f 6f 70 2c 20 61 6e 64 ng the loop, and
2f50: 20 68 6f 77 2e 0a 0a 09 73 65 74 20 68 64 72 20 how....set hdr
2f60: 22 53 65 6c 66 2d 72 65 66 65 72 65 6e 74 69 61 "Self-referentia
2f70: 6c 20 63 68 61 6e 67 65 73 65 74 20 5b 24 73 65 l changeset [$se
2f80: 6c 66 20 73 74 72 5d 20 5f 5f 5f 5f 5f 5f 5f 5f lf str] ________
2f90: 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 22 0a 09 73 65 74 __________"..set
2fa0: 20 66 74 72 20 5b 72 65 67 73 75 62 20 2d 61 6c ftr [regsub -al
2fb0: 6c 20 7b 5b 5e 20 09 5d 7d 20 24 68 64 72 20 7b l {[^ .]} $hdr {
2fc0: 5f 7d 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 _}]...log write
2fd0: 30 20 63 73 65 74 73 20 24 68 64 72 0a 09 66 6f 0 csets $hdr..fo
2fe0: 72 65 61 63 68 20 7b 69 74 65 6d 20 6e 65 78 74 reach {item next
2ff0: 69 74 65 6d 7d 20 5b 24 6d 79 74 79 70 65 6f 62 item} [$mytypeob
3000: 6a 20 6c 6f 6f 70 73 20 24 6d 79 69 74 65 6d 73 j loops $myitems
3010: 5d 20 7b 0a 09 20 20 20 20 23 20 43 72 65 61 74 ] {.. # Creat
3020: 65 20 74 61 67 67 65 64 20 69 74 65 6d 73 20 66 e tagged items f
3030: 72 6f 6d 20 74 68 65 20 69 64 20 61 6e 64 20 6f rom the id and o
3040: 75 72 20 74 79 70 65 2e 0a 09 20 20 20 20 73 65 ur type... se
3050: 74 20 69 74 65 6d 20 20 20 20 20 5b 6c 69 73 74 t item [list
3060: 20 24 6d 79 74 79 70 65 20 20 24 69 74 65 6d 5d $mytype $item]
3070: 0a 09 20 20 20 20 73 65 74 20 6e 65 78 74 69 74 .. set nextit
3080: 65 6d 20 5b 6c 69 73 74 20 24 6d 79 74 79 70 65 em [list $mytype
3090: 20 24 6e 65 78 74 69 74 65 6d 5d 0a 09 20 20 20 $nextitem]..
30a0: 20 23 20 50 72 69 6e 74 61 62 6c 65 20 6c 61 62 # Printable lab
30b0: 65 6c 73 2e 0a 09 20 20 20 20 73 65 74 20 69 20 els... set i
30c0: 20 22 3c 5b 24 74 79 70 65 20 69 74 65 6d 73 74 "<[$type itemst
30d0: 72 20 24 69 74 65 6d 5d 3e 22 0a 09 20 20 20 20 r $item]>"..
30e0: 73 65 74 20 6e 20 20 22 3c 5b 24 74 79 70 65 20 set n "<[$type
30f0: 69 74 65 6d 73 74 72 20 24 6e 65 78 74 69 74 65 itemstr $nextite
3100: 6d 5d 3e 22 0a 09 20 20 20 20 73 65 74 20 6e 63 m]>".. set nc
3110: 73 20 24 6d 79 69 74 65 6d 6d 61 70 28 24 6e 65 s $myitemmap($ne
3120: 78 74 69 74 65 6d 29 0a 09 20 20 20 20 23 20 50 xtitem).. # P
3130: 72 69 6e 74 0a 09 20 20 20 20 6c 6f 67 20 77 72 rint.. log wr
3140: 69 74 65 20 30 20 63 73 65 74 73 20 7b 2a 20 24 ite 0 csets {* $
3150: 69 20 2d 2d 3e 20 24 6e 20 2d 2d 3e 20 63 73 20 i --> $n --> cs
3160: 5b 24 6e 63 73 20 73 74 72 5d 7d 0a 09 7d 0a 09 [$ncs str]}..}..
3170: 6c 6f 67 20 77 72 69 74 65 20 30 20 63 73 65 74 log write 0 cset
3180: 73 20 24 66 74 72 0a 0a 09 69 66 20 7b 21 24 6b s $ftr...if {!$k
3190: 69 6c 6c 7d 20 72 65 74 75 72 6e 0a 09 74 72 6f ill} return..tro
31a0: 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 20 22 5b uble internal "[
31b0: 24 73 65 6c 66 20 73 74 72 5d 20 64 65 70 65 6e $self str] depen
31c0: 64 73 20 6f 6e 20 69 74 73 65 6c 66 22 0a 09 72 ds on itself"..r
31d0: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
31e0: 20 74 79 70 65 6d 65 74 68 6f 64 20 73 70 6c 69 typemethod spli
31f0: 74 20 7b 63 73 65 74 20 61 72 67 73 7d 20 7b 0a t {cset args} {.
3200: 09 23 20 41 73 20 70 61 72 74 20 6f 66 20 74 68 .# As part of th
3210: 65 20 63 72 65 61 74 69 6f 6e 20 6f 66 20 74 68 e creation of th
3220: 65 20 6e 65 77 20 63 68 61 6e 67 65 73 65 74 73 e new changesets
3230: 20 73 70 65 63 69 66 69 65 64 20 69 6e 0a 09 23 specified in..#
3240: 20 41 52 47 53 20 61 73 20 73 65 74 73 20 6f 66 ARGS as sets of
3250: 20 69 74 65 6d 73 2c 20 61 6c 6c 20 73 75 62 73 items, all subs
3260: 65 74 73 20 6f 66 20 43 53 45 54 27 73 20 69 74 ets of CSET's it
3270: 65 6d 20 73 65 74 2c 20 43 53 45 54 0a 09 23 20 em set, CSET..#
3280: 77 69 6c 6c 20 62 65 20 64 72 6f 70 70 65 64 20 will be dropped
3290: 66 72 6f 6d 20 61 6c 6c 20 64 61 74 61 62 61 73 from all databas
32a0: 65 73 2c 20 69 6e 20 61 6e 64 20 6f 75 74 20 6f es, in and out o
32b0: 66 20 6d 65 6d 6f 72 79 2c 0a 09 23 20 61 6e 64 f memory,..# and
32c0: 20 74 68 65 6e 20 64 65 73 74 72 6f 79 65 64 2e then destroyed.
32d0: 0a 09 23 0a 09 23 20 4e 6f 74 65 3a 20 54 68 65 ..#..# Note: The
32e0: 20 69 74 65 6d 20 6c 69 73 74 73 20 66 6f 75 6e item lists foun
32f0: 64 20 69 6e 20 61 72 67 73 20 61 72 65 20 74 61 d in args are ta
3300: 67 67 65 64 20 69 74 65 6d 73 2e 20 54 68 65 79 gged items. They
3310: 0a 09 23 20 68 61 76 65 20 74 6f 20 68 61 76 65 ..# have to have
3320: 20 74 68 65 20 73 61 6d 65 20 74 79 70 65 20 61 the same type a
3330: 73 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2c s the changeset,
3340: 20 62 65 69 6e 67 20 73 75 62 73 65 74 73 0a 09 being subsets..
3350: 23 20 6f 66 20 69 74 73 20 69 74 65 6d 73 2e 20 # of its items.
3360: 54 68 69 73 20 69 73 20 63 68 65 63 6b 65 64 20 This is checked
3370: 69 6e 20 55 6e 74 61 67 31 2e 0a 0a 09 6c 6f 67 in Untag1....log
3380: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b write 8 csets {
3390: 4f 4c 44 3a 20 5b 6c 73 6f 72 74 20 5b 24 63 73 OLD: [lsort [$cs
33a0: 65 74 20 69 74 65 6d 73 5d 5d 7d 0a 09 56 61 6c et items]]}..Val
33b0: 69 64 61 74 65 46 72 61 67 6d 65 6e 74 73 20 24 idateFragments $
33c0: 63 73 65 74 20 24 61 72 67 73 0a 0a 09 23 20 41 cset $args...# A
33d0: 6c 6c 20 63 68 65 63 6b 73 20 70 61 73 73 2c 20 ll checks pass,
33e0: 61 63 74 75 61 6c 6c 79 20 70 65 72 66 6f 72 6d actually perform
33f0: 20 74 68 65 20 73 70 6c 69 74 2e 0a 0a 09 73 74 the split....st
3400: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 ruct::list assig
3410: 6e 20 5b 24 63 73 65 74 20 64 61 74 61 5d 20 70 n [$cset data] p
3420: 72 6f 6a 65 63 74 20 63 73 74 79 70 65 20 63 73 roject cstype cs
3430: 73 72 63 0a 0a 09 73 65 74 20 70 72 65 64 65 63 src...set predec
3440: 65 73 73 6f 72 73 20 5b 24 63 73 65 74 20 64 72 essors [$cset dr
3450: 6f 70 5d 0a 09 24 63 73 65 74 20 64 65 73 74 72 op]..$cset destr
3460: 6f 79 0a 0a 09 73 65 74 20 6e 65 77 63 73 65 74 oy...set newcset
3470: 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 66 72 s {}..foreach fr
3480: 61 67 6d 65 6e 74 69 74 65 6d 73 20 24 61 72 67 agmentitems $arg
3490: 73 20 7b 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 s {.. log wri
34a0: 74 65 20 38 20 63 73 65 74 73 20 7b 4d 41 4b 45 te 8 csets {MAKE
34b0: 3a 20 5b 6c 73 6f 72 74 20 24 66 72 61 67 6d 65 : [lsort $fragme
34c0: 6e 74 69 74 65 6d 73 5d 7d 0a 0a 09 20 20 20 20 ntitems]}...
34d0: 73 65 74 20 66 72 61 67 6d 65 6e 74 20 5b 24 74 set fragment [$t
34e0: 79 70 65 20 25 41 55 54 4f 25 20 24 70 72 6f 6a ype %AUTO% $proj
34f0: 65 63 74 20 24 63 73 74 79 70 65 20 24 63 73 73 ect $cstype $css
3500: 72 63 20 5c 0a 09 09 09 20 20 20 20 20 20 5b 55 rc \.... [U
3510: 6e 74 61 67 20 24 66 72 61 67 6d 65 6e 74 69 74 ntag $fragmentit
3520: 65 6d 73 20 24 63 73 74 79 70 65 5d 5d 0a 09 20 ems $cstype]]..
3530: 20 20 20 6c 61 70 70 65 6e 64 20 6e 65 77 63 73 lappend newcs
3540: 65 74 73 20 24 66 72 61 67 6d 65 6e 74 0a 0a 09 ets $fragment...
3550: 20 20 20 20 24 66 72 61 67 6d 65 6e 74 20 70 65 $fragment pe
3560: 72 73 69 73 74 0a 09 20 20 20 20 24 66 72 61 67 rsist.. $frag
3570: 6d 65 6e 74 20 64 65 74 65 72 6d 69 6e 65 73 75 ment determinesu
3580: 63 63 65 73 73 6f 72 73 0a 09 7d 0a 0a 09 23 20 ccessors..}...#
3590: 54 68 65 20 70 72 65 64 65 63 65 73 73 6f 72 73 The predecessors
35a0: 20 68 61 76 65 20 74 6f 20 72 65 63 6f 6d 70 75 have to recompu
35b0: 74 65 20 74 68 65 69 72 20 73 75 63 63 65 73 73 te their success
35c0: 6f 72 73 2c 20 69 2e 65 2e 0a 09 23 20 72 65 6d ors, i.e...# rem
35d0: 6f 76 65 20 74 68 65 20 64 72 6f 70 70 65 64 20 ove the dropped
35e0: 63 68 61 6e 67 65 73 65 74 20 61 6e 64 20 70 75 changeset and pu
35f0: 74 20 6f 6e 65 20 6f 66 20 74 68 65 20 66 72 61 t one of the fra
3600: 67 6d 65 6e 74 73 0a 09 23 20 69 6e 74 6f 20 69 gments..# into i
3610: 74 73 20 70 6c 61 63 65 2e 0a 09 66 6f 72 65 61 ts place...forea
3620: 63 68 20 70 20 24 70 72 65 64 65 63 65 73 73 6f ch p $predecesso
3630: 72 73 20 7b 0a 09 20 20 20 20 24 70 20 64 65 74 rs {.. $p det
3640: 65 72 6d 69 6e 65 73 75 63 63 65 73 73 6f 72 73 erminesuccessors
3650: 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 20 24 6e 65 ..}...return $ne
3660: 77 63 73 65 74 73 0a 20 20 20 20 7d 0a 0a 20 20 wcsets. }..
3670: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 74 65 typemethod ite
3680: 6d 73 74 72 20 7b 69 74 65 6d 7d 20 7b 0a 09 73 mstr {item} {..s
3690: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 truct::list assi
36a0: 67 6e 20 24 69 74 65 6d 20 69 74 79 70 65 20 69 gn $item itype i
36b0: 69 64 0a 09 72 65 74 75 72 6e 20 5b 24 69 74 79 id..return [$ity
36c0: 70 65 20 73 74 72 20 24 69 69 64 5d 0a 20 20 20 pe str $iid].
36d0: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 }.. typemeth
36e0: 6f 64 20 73 74 72 6c 69 73 74 20 7b 63 68 61 6e od strlist {chan
36f0: 67 65 73 65 74 73 7d 20 7b 0a 09 72 65 74 75 72 gesets} {..retur
3700: 6e 20 5b 6a 6f 69 6e 20 5b 73 74 72 75 63 74 3a n [join [struct:
3710: 3a 6c 69 73 74 20 6d 61 70 20 24 63 68 61 6e 67 :list map $chang
3720: 65 73 65 74 73 20 5b 6d 79 70 72 6f 63 20 49 44 esets [myproc ID
3730: 5d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 ]]]. }.. p
3740: 72 6f 63 20 49 44 20 7b 63 73 65 74 7d 20 7b 20 roc ID {cset} {
3750: 24 63 73 65 74 20 73 74 72 20 7d 0a 0a 20 20 20 $cset str }..
3760: 20 70 72 6f 63 20 55 6e 74 61 67 20 7b 74 61 67 proc Untag {tag
3770: 67 65 64 69 74 65 6d 73 20 63 73 74 79 70 65 7d geditems cstype}
3780: 20 7b 0a 09 72 65 74 75 72 6e 20 5b 73 74 72 75 {..return [stru
3790: 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 74 61 ct::list map $ta
37a0: 67 67 65 64 69 74 65 6d 73 20 5b 6d 79 70 72 6f ggeditems [mypro
37b0: 63 20 55 6e 74 61 67 31 20 24 63 73 74 79 70 65 c Untag1 $cstype
37c0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 ]]. }.. pr
37d0: 6f 63 20 55 6e 74 61 67 31 20 7b 63 73 74 79 70 oc Untag1 {cstyp
37e0: 65 20 74 68 65 69 74 65 6d 7d 20 7b 0a 09 73 74 e theitem} {..st
37f0: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 ruct::list assig
3800: 6e 20 24 74 68 65 69 74 65 6d 20 74 20 69 0a 09 n $theitem t i..
3810: 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 integrity assert
3820: 20 7b 24 63 73 74 79 70 65 20 65 71 20 24 74 7d {$cstype eq $t}
3830: 20 7b 49 74 65 6d 20 24 69 27 73 20 74 79 70 65 {Item $i's type
3840: 20 69 73 20 27 24 74 27 2c 20 65 78 70 65 63 74 is '$t', expect
3850: 65 64 20 27 24 63 73 74 79 70 65 27 7d 0a 09 72 ed '$cstype'}..r
3860: 65 74 75 72 6e 20 24 69 0a 20 20 20 20 7d 0a 0a eturn $i. }..
3870: 20 20 20 20 70 72 6f 63 20 54 61 67 49 74 65 6d proc TagItem
3880: 44 69 63 74 20 7b 69 74 65 6d 64 69 63 74 20 63 Dict {itemdict c
3890: 73 74 79 70 65 7d 20 7b 0a 09 73 65 74 20 72 65 stype} {..set re
38a0: 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b 69 s {}..foreach {i
38b0: 20 76 7d 20 24 69 74 65 6d 64 69 63 74 20 7b 20 v} $itemdict {
38c0: 6c 61 70 70 65 6e 64 20 72 65 73 20 5b 6c 69 73 lappend res [lis
38d0: 74 20 24 63 73 74 79 70 65 20 24 69 5d 20 24 76 t $cstype $i] $v
38e0: 20 7d 0a 09 72 65 74 75 72 6e 20 24 72 65 73 0a }..return $res.
38f0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
3900: 56 61 6c 69 64 61 74 65 46 72 61 67 6d 65 6e 74 ValidateFragment
3910: 73 20 7b 63 73 65 74 20 66 72 61 67 6d 65 6e 74 s {cset fragment
3920: 73 7d 20 7b 0a 09 23 20 43 68 65 63 6b 20 74 68 s} {..# Check th
3930: 65 20 76 61 72 69 6f 75 73 20 69 6e 74 65 67 72 e various integr
3940: 69 74 79 20 63 6f 6e 73 74 72 61 69 6e 74 73 20 ity constraints
3950: 66 6f 72 20 74 68 65 20 66 72 61 67 6d 65 6e 74 for the fragment
3960: 73 0a 09 23 20 73 70 65 63 69 66 79 69 6e 67 20 s..# specifying
3970: 68 6f 77 20 74 6f 20 73 70 6c 69 74 20 74 68 65 how to split the
3980: 20 63 68 61 6e 67 65 73 65 74 3a 0a 09 23 0a 09 changeset:..#..
3990: 23 20 2a 20 57 65 20 6d 75 73 74 20 68 61 76 65 # * We must have
39a0: 20 74 77 6f 20 6f 72 20 6d 6f 72 65 20 66 72 61 two or more fra
39b0: 67 6d 65 6e 74 73 2c 20 61 73 20 73 70 6c 69 74 gments, as split
39c0: 74 69 6e 67 20 61 0a 09 23 20 20 20 63 68 61 6e ting a..# chan
39d0: 67 65 73 65 74 20 69 6e 74 6f 20 6f 6e 65 20 6d geset into one m
39e0: 61 6b 65 73 20 6e 6f 20 73 65 6e 73 65 2e 0a 09 akes no sense...
39f0: 23 20 2a 20 4e 6f 20 66 72 61 67 6d 65 6e 74 20 # * No fragment
3a00: 6d 61 79 20 62 65 20 65 6d 70 74 79 2e 0a 09 23 may be empty...#
3a10: 20 2a 20 41 6c 6c 20 66 72 61 67 6d 65 6e 74 73 * All fragments
3a20: 20 68 61 76 65 20 74 6f 20 62 65 20 74 72 75 65 have to be true
3a30: 20 73 75 62 73 65 74 73 20 6f 66 20 74 68 65 20 subsets of the
3a40: 69 74 65 6d 73 20 69 6e 20 74 68 65 0a 09 23 20 items in the..#
3a50: 20 20 63 68 61 6e 67 65 73 65 74 20 74 6f 20 73 changeset to s
3a60: 70 6c 69 74 2e 20 54 68 65 20 27 74 72 75 65 27 plit. The 'true'
3a70: 20 69 73 20 69 6d 70 6c 69 65 64 20 62 65 63 61 is implied beca
3a80: 75 73 65 20 6e 6f 6e 65 20 61 72 65 0a 09 23 20 use none are..#
3a90: 20 20 61 6c 6c 6f 77 65 64 20 74 6f 20 62 65 20 allowed to be
3aa0: 65 6d 70 74 79 2c 20 73 6f 20 65 61 63 68 20 68 empty, so each h
3ab0: 61 73 20 74 6f 20 62 65 20 73 6d 61 6c 6c 65 72 as to be smaller
3ac0: 20 74 68 61 6e 20 74 68 65 0a 09 23 20 20 20 74 than the..# t
3ad0: 6f 74 61 6c 2e 0a 09 23 20 2a 20 54 68 65 20 75 otal...# * The u
3ae0: 6e 69 6f 6e 20 6f 66 20 74 68 65 20 66 72 61 67 nion of the frag
3af0: 6d 65 6e 74 73 20 68 61 73 20 74 6f 20 62 65 20 ments has to be
3b00: 74 68 65 20 69 74 65 6d 20 73 65 74 20 6f 66 20 the item set of
3b10: 74 68 65 0a 09 23 20 20 20 63 68 61 6e 67 65 73 the..# changes
3b20: 65 74 2e 0a 09 23 20 2a 20 54 68 65 20 66 72 61 et...# * The fra
3b30: 67 6d 65 6e 74 20 6d 75 73 74 20 6e 6f 74 20 6f gment must not o
3b40: 76 65 72 6c 61 70 2c 20 69 2e 65 2e 20 74 68 65 verlap, i.e. the
3b50: 69 72 20 70 61 69 72 77 69 73 65 0a 09 23 20 20 ir pairwise..#
3b60: 20 69 6e 74 65 72 73 65 63 74 69 6f 6e 73 20 68 intersections h
3b70: 61 76 65 20 74 6f 20 62 65 20 65 6d 70 74 79 2e ave to be empty.
3b80: 0a 0a 09 73 65 74 20 63 6f 76 65 72 20 7b 7d 0a ...set cover {}.
3b90: 09 66 6f 72 65 61 63 68 20 66 72 61 67 6d 65 6e .foreach fragmen
3ba0: 74 69 74 65 6d 73 20 24 66 72 61 67 6d 65 6e 74 titems $fragment
3bb0: 73 20 7b 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 s {.. log wri
3bc0: 74 65 20 38 20 63 73 65 74 73 20 7b 4e 45 57 3a te 8 csets {NEW:
3bd0: 20 5b 6c 73 6f 72 74 20 24 66 72 61 67 6d 65 6e [lsort $fragmen
3be0: 74 69 74 65 6d 73 5d 7d 0a 0a 09 20 20 20 20 69 titems]}... i
3bf0: 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 ntegrity assert
3c00: 7b 0a 09 09 21 5b 73 74 72 75 63 74 3a 3a 73 65 {...![struct::se
3c10: 74 20 65 6d 70 74 79 20 24 66 72 61 67 6d 65 6e t empty $fragmen
3c20: 74 69 74 65 6d 73 5d 0a 09 20 20 20 20 7d 20 7b titems].. } {
3c30: 63 68 61 6e 67 65 73 65 74 20 66 72 61 67 6d 65 changeset fragme
3c40: 6e 74 20 69 73 20 65 6d 70 74 79 7d 0a 0a 09 20 nt is empty}...
3c50: 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73 integrity ass
3c60: 65 72 74 20 7b 0a 09 09 5b 73 74 72 75 63 74 3a ert {...[struct:
3c70: 3a 73 65 74 20 73 75 62 73 65 74 6f 66 20 24 66 :set subsetof $f
3c80: 72 61 67 6d 65 6e 74 69 74 65 6d 73 20 5b 24 63 ragmentitems [$c
3c90: 73 65 74 20 69 74 65 6d 73 5d 5d 0a 09 20 20 20 set items]]..
3ca0: 20 7d 20 7b 63 68 61 6e 67 65 73 65 74 20 66 72 } {changeset fr
3cb0: 61 67 6d 65 6e 74 20 69 73 20 6e 6f 74 20 61 20 agment is not a
3cc0: 73 75 62 73 65 74 7d 0a 09 20 20 20 20 73 74 72 subset}.. str
3cd0: 75 63 74 3a 3a 73 65 74 20 61 64 64 20 63 6f 76 uct::set add cov
3ce0: 65 72 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d er $fragmentitem
3cf0: 73 0a 09 7d 0a 0a 09 69 6e 74 65 67 72 69 74 79 s..}...integrity
3d00: 20 61 73 73 65 72 74 20 7b 0a 09 20 20 20 20 5b assert {.. [
3d10: 73 74 72 75 63 74 3a 3a 73 65 74 20 65 71 75 61 struct::set equa
3d20: 6c 20 24 63 6f 76 65 72 20 5b 24 63 73 65 74 20 l $cover [$cset
3d30: 69 74 65 6d 73 5d 5d 0a 09 20 7d 20 7b 54 68 65 items]].. } {The
3d40: 20 66 72 61 67 6d 65 6e 74 73 20 64 6f 20 6e 6f fragments do no
3d50: 74 20 63 6f 76 65 72 20 74 68 65 20 6f 72 69 67 t cover the orig
3d60: 69 6e 61 6c 20 63 68 61 6e 67 65 73 65 74 7d 0a inal changeset}.
3d70: 0a 09 73 65 74 20 69 20 31 0a 09 66 6f 72 65 61 ..set i 1..forea
3d80: 63 68 20 66 69 61 20 24 66 72 61 67 6d 65 6e 74 ch fia $fragment
3d90: 73 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 68 s {.. foreach
3da0: 20 66 69 62 20 5b 6c 72 61 6e 67 65 20 24 66 72 fib [lrange $fr
3db0: 61 67 6d 65 6e 74 73 20 24 69 20 65 6e 64 5d 20 agments $i end]
3dc0: 7b 0a 09 09 69 6e 74 65 67 72 69 74 79 20 61 73 {...integrity as
3dd0: 73 65 72 74 20 7b 0a 09 09 20 20 20 20 5b 73 74 sert {... [st
3de0: 72 75 63 74 3a 3a 73 65 74 20 65 6d 70 74 79 20 ruct::set empty
3df0: 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 69 6e 74 [struct::set int
3e00: 65 72 73 65 63 74 20 24 66 69 61 20 24 66 69 62 ersect $fia $fib
3e10: 5d 5d 0a 09 09 7d 20 7b 54 68 65 20 66 72 61 67 ]]...} {The frag
3e20: 6d 65 6e 74 73 20 3c 24 66 69 61 3e 20 61 6e 64 ments <$fia> and
3e30: 20 3c 24 66 69 62 3e 20 6f 76 65 72 6c 61 70 7d <$fib> overlap}
3e40: 0a 09 20 20 20 20 7d 0a 09 20 20 20 20 69 6e 63 .. }.. inc
3e50: 72 20 69 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 0a r i..}...return.
3e60: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 }.. # # #
3e70: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
3e80: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
3e90: 23 23 0a 20 20 20 20 23 23 20 53 74 61 74 65 0a ##. ## State.
3ea0: 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 . variable my
3eb0: 69 64 20 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 id {} ; #
3ec0: 20 49 64 20 6f 66 20 74 68 65 20 63 73 65 74 20 Id of the cset
3ed0: 66 6f 72 20 74 68 65 20 70 65 72 73 69 73 74 65 for the persiste
3ee0: 6e 74 0a 09 09 09 20 20 20 20 20 20 23 20 73 74 nt.... # st
3ef0: 61 74 65 2e 0a 20 20 20 20 76 61 72 69 61 62 6c ate.. variabl
3f00: 65 20 6d 79 70 72 6f 6a 65 63 74 20 20 20 7b 7d e myproject {}
3f10: 20 3b 20 23 20 52 65 66 65 72 65 6e 63 65 20 6f ; # Reference o
3f20: 66 20 74 68 65 20 70 72 6f 6a 65 63 74 20 6f 62 f the project ob
3f30: 6a 65 63 74 20 74 68 65 0a 09 09 09 20 20 20 20 ject the....
3f40: 20 20 23 20 63 68 61 6e 67 65 73 65 74 20 62 65 # changeset be
3f50: 6c 6f 6e 67 73 20 74 6f 2e 0a 20 20 20 20 76 61 longs to.. va
3f60: 72 69 61 62 6c 65 20 6d 79 74 79 70 65 20 20 20 riable mytype
3f70: 20 20 20 7b 7d 20 3b 20 23 20 57 68 61 74 20 74 {} ; # What t
3f80: 68 65 20 63 68 61 6e 67 65 73 65 74 20 69 73 20 he changeset is
3f90: 62 61 73 65 64 20 6f 6e 0a 09 09 09 20 20 20 20 based on....
3fa0: 20 20 23 20 28 72 65 76 69 73 69 6f 6e 73 2c 20 # (revisions,
3fb0: 74 61 67 73 2c 20 6f 72 20 62 72 61 6e 63 68 65 tags, or branche
3fc0: 73 29 2e 0a 09 09 09 20 20 20 20 20 20 23 20 56 s)..... # V
3fd0: 61 6c 75 65 73 3a 20 53 65 65 20 6d 79 63 73 74 alues: See mycst
3fe0: 79 70 65 2e 20 4e 6f 74 65 20 74 68 61 74 20 77 ype. Note that w
3ff0: 65 0a 09 09 09 20 20 20 20 20 20 23 20 68 61 76 e.... # hav
4000: 65 20 74 6f 20 6b 65 65 70 20 74 68 65 20 6e 61 e to keep the na
4010: 6d 65 73 20 6f 66 20 74 68 65 20 68 65 6c 70 65 mes of the helpe
4020: 72 0a 09 09 09 20 20 20 20 20 20 23 20 73 69 6e r.... # sin
4030: 67 6c 65 74 6f 6e 73 20 69 6e 20 73 79 6e 63 20 gletons in sync
4040: 77 69 74 68 20 74 68 65 20 63 6f 6e 74 65 6e 74 with the content
4050: 73 0a 09 09 09 20 20 20 20 20 20 23 20 6f 66 20 s.... # of
4060: 73 74 61 74 65 20 74 61 62 6c 65 20 27 63 73 74 state table 'cst
4070: 79 70 65 27 2c 20 61 6e 64 20 76 61 72 69 6f 75 ype', and variou
4080: 73 0a 09 09 09 20 20 20 20 20 20 23 20 6f 74 68 s.... # oth
4090: 65 72 20 70 6c 61 63 65 73 20 75 73 69 6e 67 20 er places using
40a0: 74 68 65 6d 20 68 61 72 64 77 69 72 65 64 2e 0a them hardwired..
40b0: 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 74 variable myt
40c0: 79 70 65 6f 62 6a 20 20 20 7b 7d 20 3b 20 23 20 ypeobj {} ; #
40d0: 52 65 66 65 72 65 6e 63 65 20 74 6f 20 74 68 65 Reference to the
40e0: 20 63 6f 6e 74 61 69 6e 65 72 20 66 6f 72 20 74 container for t
40f0: 68 65 0a 09 09 09 20 20 20 20 20 20 23 20 74 79 he.... # ty
4100: 70 65 20 64 65 70 65 6e 64 65 6e 74 20 63 6f 64 pe dependent cod
4110: 65 2e 20 44 65 72 69 76 65 64 20 66 72 6f 6d 0a e. Derived from.
4120: 09 09 09 20 20 20 20 20 20 23 20 6d 79 74 79 70 ... # mytyp
4130: 65 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 e.. variable
4140: 6d 79 73 72 63 69 64 20 20 20 20 20 7b 7d 20 3b mysrcid {} ;
4150: 20 23 20 49 64 20 6f 66 20 74 68 65 20 6d 65 74 # Id of the met
4160: 61 64 61 74 61 20 6f 72 20 73 79 6d 62 6f 6c 20 adata or symbol
4170: 74 68 65 20 63 73 65 74 0a 09 09 09 20 20 20 20 the cset....
4180: 20 20 23 20 69 73 20 62 61 73 65 64 20 6f 6e 2e # is based on.
4190: 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 . variable my
41a0: 69 74 65 6d 73 20 20 20 20 20 7b 7d 20 3b 20 23 items {} ; #
41b0: 20 4c 69 73 74 20 6f 66 20 74 68 65 20 66 69 6c List of the fil
41c0: 65 20 6c 65 76 65 6c 20 72 65 76 69 73 69 6f 6e e level revision
41d0: 73 2c 0a 09 09 09 20 20 20 20 20 20 23 20 74 61 s,.... # ta
41e0: 67 73 2c 20 6f 72 20 62 72 61 6e 63 68 65 73 20 gs, or branches
41f0: 69 6e 20 74 68 65 20 63 73 65 74 2c 20 61 73 0a in the cset, as.
4200: 09 09 09 20 20 20 20 20 20 23 20 69 64 73 2e 20 ... # ids.
4210: 4e 6f 74 20 74 61 67 67 65 64 2e 0a 20 20 20 20 Not tagged..
4220: 76 61 72 69 61 62 6c 65 20 6d 79 74 69 74 65 6d variable mytitem
4230: 73 20 20 20 20 7b 7d 20 3b 20 23 20 41 73 20 6d s {} ; # As m
4240: 79 69 74 65 6d 73 2c 20 74 68 65 20 74 61 67 67 yitems, the tagg
4250: 65 64 20 66 6f 72 6d 2e 0a 20 20 20 20 76 61 72 ed form.. var
4260: 69 61 62 6c 65 20 6d 79 70 6f 73 20 20 20 20 20 iable mypos
4270: 20 20 7b 7d 20 3b 20 23 20 43 6f 6d 6d 69 74 20 {} ; # Commit
4280: 70 6f 73 69 74 69 6f 6e 20 6f 66 20 74 68 65 20 position of the
4290: 63 68 61 6e 67 65 73 65 74 2c 20 69 66 0a 09 09 changeset, if...
42a0: 09 20 20 20 20 20 20 23 20 6b 6e 6f 77 6e 2e 0a . # known..
42b0: 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 . # # ## ###
42c0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 ##### ######## #
42d0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 ############.
42e0: 20 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 ## Internal met
42f0: 68 6f 64 73 0a 0a 20 20 20 20 74 79 70 65 76 61 hods.. typeva
4300: 72 69 61 62 6c 65 20 6d 79 63 6f 75 6e 74 65 72 riable mycounter
4310: 20 20 20 20 20 20 20 20 30 20 3b 20 23 20 49 64 0 ; # Id
4320: 20 63 6f 75 6e 74 65 72 20 66 6f 72 20 63 73 65 counter for cse
4330: 74 73 2e 20 4c 61 73 74 20 69 64 0a 09 09 09 09 ts. Last id.....
4340: 20 20 20 20 20 20 23 20 75 73 65 64 2e 0a 20 20 # used..
4350: 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d typevariable m
4360: 79 63 73 74 79 70 65 20 2d 61 72 72 61 79 20 7b ycstype -array {
4370: 7d 20 3b 20 23 20 4d 61 70 20 63 73 74 79 70 65 } ; # Map cstype
4380: 73 20 28 6e 61 6d 65 73 29 20 74 6f 20 70 65 72 s (names) to per
4390: 73 69 73 74 65 6e 74 0a 09 09 09 09 20 20 20 20 sistent.....
43a0: 20 20 23 20 69 64 73 2e 20 4e 6f 74 65 20 74 68 # ids. Note th
43b0: 61 74 20 77 65 20 68 61 76 65 20 74 6f 20 6b 65 at we have to ke
43c0: 65 70 0a 09 09 09 09 20 20 20 20 20 20 23 20 74 ep..... # t
43d0: 68 65 20 6e 61 6d 65 73 20 69 6e 20 74 68 65 20 he names in the
43e0: 74 61 62 6c 65 20 27 63 73 74 79 70 65 27 0a 09 table 'cstype'..
43f0: 09 09 09 20 20 20 20 20 20 23 20 69 6e 20 73 79 ... # in sy
4400: 6e 63 20 77 69 74 68 20 74 68 65 20 6e 61 6d 65 nc with the name
4410: 73 20 6f 66 20 74 68 65 0a 09 09 09 09 20 20 20 s of the.....
4420: 20 20 20 23 20 68 65 6c 70 65 72 20 73 69 6e 67 # helper sing
4430: 6c 65 74 6f 6e 73 2e 0a 0a 20 20 20 20 74 79 70 letons... typ
4440: 65 6d 65 74 68 6f 64 20 67 65 74 63 73 74 79 70 emethod getcstyp
4450: 65 73 20 7b 7d 20 7b 0a 09 66 6f 72 65 61 63 68 es {} {..foreach
4460: 20 7b 74 69 64 20 6e 61 6d 65 7d 20 5b 73 74 61 {tid name} [sta
4470: 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 te run {.. SE
4480: 4c 45 43 54 20 74 69 64 2c 20 6e 61 6d 65 20 46 LECT tid, name F
4490: 52 4f 4d 20 63 73 74 79 70 65 3b 0a 09 7d 5d 20 ROM cstype;..}]
44a0: 7b 20 73 65 74 20 6d 79 63 73 74 79 70 65 28 24 { set mycstype($
44b0: 6e 61 6d 65 29 20 24 74 69 64 20 7d 0a 09 72 65 name) $tid }..re
44c0: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
44d0: 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61 64 63 typemethod loadc
44e0: 6f 75 6e 74 65 72 20 7b 7d 20 7b 0a 09 23 20 49 ounter {} {..# I
44f0: 6e 69 74 69 61 6c 69 7a 65 20 74 68 65 20 63 6f nitialize the co
4500: 75 6e 74 65 72 20 66 72 6f 6d 20 74 68 65 20 73 unter from the s
4510: 74 61 74 65 0a 09 6c 6f 67 20 77 72 69 74 65 20 tate..log write
4520: 32 20 69 6e 69 74 63 73 65 74 73 20 7b 4c 6f 61 2 initcsets {Loa
4530: 64 69 6e 67 20 63 68 61 6e 67 65 73 65 74 20 63 ding changeset c
4540: 6f 75 6e 74 65 72 7d 0a 09 73 65 74 20 6d 79 63 ounter}..set myc
4550: 6f 75 6e 74 65 72 20 5b 73 74 61 74 65 20 6f 6e ounter [state on
4560: 65 20 7b 20 53 45 4c 45 43 54 20 4d 41 58 28 63 e { SELECT MAX(c
4570: 69 64 29 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 id) FROM changes
4580: 65 74 20 7d 5d 0a 09 72 65 74 75 72 6e 0a 20 20 et }]..return.
4590: 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 }.. typemet
45a0: 68 6f 64 20 6e 75 6d 20 7b 7d 20 7b 20 72 65 74 hod num {} { ret
45b0: 75 72 6e 20 24 6d 79 63 6f 75 6e 74 65 72 20 7d urn $mycounter }
45c0: 0a 0a 20 20 20 20 70 72 6f 63 20 49 6e 69 74 69 .. proc Initi
45d0: 61 6c 69 7a 65 42 72 65 61 6b 53 74 61 74 65 20 alizeBreakState
45e0: 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 {revisions} {..u
45f0: 70 76 61 72 20 31 20 70 6f 73 20 70 6f 73 20 63 pvar 1 pos pos c
4600: 72 6f 73 73 20 63 72 6f 73 73 20 72 61 6e 67 65 ross cross range
4610: 20 72 61 6e 67 65 20 64 65 70 63 20 64 65 70 63 range depc depc
4620: 20 64 65 6c 74 61 20 64 65 6c 74 61 20 5c 0a 09 delta delta \..
4630: 20 20 20 20 64 65 70 65 6e 64 65 6e 63 69 65 73 dependencies
4640: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 0a 09 dependencies...
4650: 23 20 46 69 72 73 74 20 77 65 20 63 72 65 61 74 # First we creat
4660: 65 20 61 20 6d 61 70 20 6f 66 20 70 6f 73 69 74 e a map of posit
4670: 69 6f 6e 73 20 74 6f 20 6d 61 6b 65 20 69 74 20 ions to make it
4680: 65 61 73 69 65 72 20 74 6f 0a 09 23 20 64 65 74 easier to..# det
4690: 65 72 6d 69 6e 65 20 77 68 65 74 68 65 72 20 61 ermine whether a
46a0: 20 64 65 70 65 6e 64 65 6e 63 79 20 63 72 6f 73 dependency cros
46b0: 73 65 73 20 61 20 70 61 72 74 69 63 75 6c 61 72 ses a particular
46c0: 20 69 6e 64 65 78 2e 0a 0a 09 61 72 72 61 79 20 index....array
46d0: 73 65 74 20 70 6f 73 20 20 20 7b 7d 0a 09 61 72 set pos {}..ar
46e0: 72 61 79 20 73 65 74 20 63 72 6f 73 73 20 7b 7d ray set cross {}
46f0: 0a 09 61 72 72 61 79 20 73 65 74 20 64 65 70 63 ..array set depc
4700: 20 20 7b 7d 0a 09 73 65 74 20 72 61 6e 67 65 20 {}..set range
4710: 20 20 20 20 20 20 7b 7d 0a 09 73 65 74 20 6e 20 {}..set n
4720: 30 0a 09 66 6f 72 65 61 63 68 20 72 65 76 20 24 0..foreach rev $
4730: 72 65 76 69 73 69 6f 6e 73 20 7b 0a 09 20 20 20 revisions {..
4740: 20 6c 61 70 70 65 6e 64 20 72 61 6e 67 65 20 24 lappend range $
4750: 6e 0a 09 20 20 20 20 73 65 74 20 70 6f 73 28 24 n.. set pos($
4760: 72 65 76 29 20 24 6e 0a 09 20 20 20 20 73 65 74 rev) $n.. set
4770: 20 63 72 6f 73 73 28 24 6e 29 20 30 0a 09 20 20 cross($n) 0..
4780: 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 0a 09 23 20 incr n..}...#
4790: 53 65 63 6f 6e 64 6c 79 20 77 65 20 63 6f 75 6e Secondly we coun
47a0: 74 20 74 68 65 20 63 72 6f 73 73 69 6e 67 73 20 t the crossings
47b0: 70 65 72 20 70 6f 73 69 74 69 6f 6e 2c 20 62 79 per position, by
47c0: 20 69 74 65 72 61 74 69 6e 67 0a 09 23 20 6f 76 iterating..# ov
47d0: 65 72 20 74 68 65 20 72 65 63 6f 72 64 65 64 20 er the recorded
47e0: 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 internal depende
47f0: 6e 63 69 65 73 2e 0a 0a 09 23 20 4e 6f 74 65 3a ncies....# Note:
4800: 20 49 66 20 74 68 65 20 74 69 6d 65 73 74 61 6d If the timestam
4810: 70 73 20 61 72 65 20 62 61 64 6c 79 20 6f 75 74 ps are badly out
4820: 20 6f 66 20 6f 72 64 65 72 20 69 74 20 69 73 0a of order it is.
4830: 09 23 20 20 20 20 20 20 20 70 6f 73 73 69 62 6c .# possibl
4840: 65 20 74 6f 20 68 61 76 65 20 61 20 62 61 63 6b e to have a back
4850: 77 61 72 64 20 73 75 63 63 65 73 73 6f 72 20 64 ward successor d
4860: 65 70 65 6e 64 65 6e 63 79 2c 0a 09 23 20 20 20 ependency,..#
4870: 20 20 20 20 69 2e 65 2e 20 77 69 74 68 20 73 74 i.e. with st
4880: 61 72 74 20 3e 20 65 6e 64 2e 20 57 65 20 6d 61 art > end. We ma
4890: 79 20 68 61 76 65 20 74 6f 20 73 77 61 70 20 74 y have to swap t
48a0: 68 65 20 69 6e 64 69 63 65 73 0a 09 23 20 20 20 he indices..#
48b0: 20 20 20 20 74 6f 20 65 6e 73 75 72 65 20 74 68 to ensure th
48c0: 61 74 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 at the following
48d0: 20 6c 6f 6f 70 20 72 75 6e 73 20 63 6f 72 72 65 loop runs corre
48e0: 63 74 6c 79 2e 0a 09 23 0a 09 23 20 4e 6f 74 65 ctly...#..# Note
48f0: 20 32 3a 20 73 74 61 72 74 20 3d 3d 20 65 6e 64 2: start == end
4900: 20 69 73 20 6e 6f 74 20 70 6f 73 73 69 62 6c 65 is not possible
4910: 2e 20 49 74 20 69 6e 64 69 63 61 74 65 73 20 61 . It indicates a
4920: 0a 09 23 20 20 20 20 20 20 20 20 20 73 65 6c 66 ..# self
4930: 2d 64 65 70 65 6e 64 65 6e 63 79 20 64 75 65 20 -dependency due
4940: 74 6f 20 74 68 65 20 75 6e 69 71 75 65 6e 65 73 to the uniquenes
4950: 73 20 6f 66 20 70 6f 73 69 74 69 6f 6e 73 2c 0a s of positions,.
4960: 09 23 20 20 20 20 20 20 20 20 20 61 6e 64 20 74 .# and t
4970: 68 61 74 20 69 73 20 73 6f 6d 65 74 68 69 6e 67 hat is something
4980: 20 77 65 20 68 61 76 65 20 72 75 6c 65 64 20 6f we have ruled o
4990: 75 74 20 61 6c 72 65 61 64 79 2c 20 73 65 65 0a ut already, see.
49a0: 09 23 20 20 20 20 20 20 20 20 20 27 72 65 76 20 .# 'rev
49b0: 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f internalsuccesso
49c0: 72 73 27 2e 0a 0a 09 66 6f 72 65 61 63 68 20 7b rs'....foreach {
49d0: 72 69 64 20 63 68 69 6c 64 72 65 6e 7d 20 5b 61 rid children} [a
49e0: 72 72 61 79 20 67 65 74 20 64 65 70 65 6e 64 65 rray get depende
49f0: 6e 63 69 65 73 5d 20 7b 0a 09 20 20 20 20 66 6f ncies] {.. fo
4a00: 72 65 61 63 68 20 63 68 69 6c 64 20 24 63 68 69 reach child $chi
4a10: 6c 64 72 65 6e 20 7b 0a 09 09 73 65 74 20 64 6b ldren {...set dk
4a20: 65 79 20 20 20 20 5b 6c 69 73 74 20 24 72 69 64 ey [list $rid
4a30: 20 24 63 68 69 6c 64 5d 0a 09 09 73 65 74 20 73 $child]...set s
4a40: 74 61 72 74 20 20 20 24 70 6f 73 28 24 72 69 64 tart $pos($rid
4a50: 29 0a 09 09 73 65 74 20 65 6e 64 20 20 20 20 20 )...set end
4a60: 24 70 6f 73 28 24 63 68 69 6c 64 29 0a 09 09 73 $pos($child)...s
4a70: 65 74 20 63 72 6f 73 73 65 73 20 7b 7d 0a 0a 09 et crosses {}...
4a80: 09 69 66 20 7b 24 73 74 61 72 74 20 3e 20 24 65 .if {$start > $e
4a90: 6e 64 7d 20 7b 0a 09 09 20 20 20 20 77 68 69 6c nd} {... whil
4aa0: 65 20 7b 24 65 6e 64 20 3c 20 24 73 74 61 72 74 e {$end < $start
4ab0: 7d 20 7b 0a 09 09 09 6c 61 70 70 65 6e 64 20 63 } {....lappend c
4ac0: 72 6f 73 73 65 73 20 24 65 6e 64 0a 09 09 09 69 rosses $end....i
4ad0: 6e 63 72 20 63 72 6f 73 73 28 24 65 6e 64 29 0a ncr cross($end).
4ae0: 09 09 09 69 6e 63 72 20 65 6e 64 0a 09 09 20 20 ...incr end...
4af0: 20 20 7d 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 }...} else {..
4b00: 09 20 20 20 20 77 68 69 6c 65 20 7b 24 73 74 61 . while {$sta
4b10: 72 74 20 3c 20 24 65 6e 64 7d 20 7b 0a 09 09 09 rt < $end} {....
4b20: 6c 61 70 70 65 6e 64 20 63 72 6f 73 73 65 73 20 lappend crosses
4b30: 24 73 74 61 72 74 0a 09 09 09 69 6e 63 72 20 63 $start....incr c
4b40: 72 6f 73 73 28 24 73 74 61 72 74 29 0a 09 09 09 ross($start)....
4b50: 69 6e 63 72 20 73 74 61 72 74 0a 09 09 20 20 20 incr start...
4b60: 20 7d 0a 09 09 7d 0a 09 09 73 65 74 20 64 65 70 }...}...set dep
4b70: 63 28 24 64 6b 65 79 29 20 24 63 72 6f 73 73 65 c($dkey) $crosse
4b80: 73 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 49 6e s.. }..}...In
4b90: 69 74 69 61 6c 69 7a 65 44 65 6c 74 61 73 20 24 itializeDeltas $
4ba0: 72 65 76 69 73 69 6f 6e 73 0a 09 72 65 74 75 72 revisions..retur
4bb0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f n. }.. pro
4bc0: 63 20 49 6e 69 74 69 61 6c 69 7a 65 44 65 6c 74 c InitializeDelt
4bd0: 61 73 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b as {revisions} {
4be0: 0a 09 75 70 76 61 72 20 31 20 64 65 6c 74 61 20 ..upvar 1 delta
4bf0: 64 65 6c 74 61 0a 0a 09 23 20 50 75 6c 6c 20 74 delta...# Pull t
4c00: 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20 66 6f he timestamps fo
4c10: 72 20 61 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 r all revisions
4c20: 69 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 in the changeset
4c30: 73 20 61 6e 64 0a 09 23 20 63 6f 6d 70 75 74 65 s and..# compute
4c40: 20 74 68 65 69 72 20 64 65 6c 74 61 73 20 66 6f their deltas fo
4c50: 72 20 75 73 65 20 62 79 20 74 68 65 20 62 72 65 r use by the bre
4c60: 61 6b 20 66 69 6e 64 65 72 2e 0a 0a 09 61 72 72 ak finder....arr
4c70: 61 79 20 73 65 74 20 64 65 6c 74 61 20 7b 7d 0a ay set delta {}.
4c80: 09 61 72 72 61 79 20 73 65 74 20 73 74 61 6d 70 .array set stamp
4c90: 20 7b 7d 0a 0a 09 73 65 74 20 74 68 65 73 65 74 {}...set theset
4ca0: 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 ('[join $revisi
4cb0: 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 66 6f ons {','}]')..fo
4cc0: 72 65 61 63 68 20 7b 72 69 64 20 74 69 6d 65 7d reach {rid time}
4cd0: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 [state run [sub
4ce0: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d st -nocommands -
4cf0: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a nobackslashes {.
4d00: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 . SELECT R.ri
4d10: 64 2c 20 52 2e 64 61 74 65 0a 09 20 20 20 20 46 d, R.date.. F
4d20: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 ROM revision R..
4d30: 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64 20 WHERE R.rid
4d40: 49 4e 20 24 74 68 65 73 65 74 0a 09 7d 5d 5d 20 IN $theset..}]]
4d50: 7b 0a 09 20 20 20 20 73 65 74 20 73 74 61 6d 70 {.. set stamp
4d60: 28 24 72 69 64 29 20 24 74 69 6d 65 0a 09 7d 0a ($rid) $time..}.
4d70: 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 65 61 ..set n 0..forea
4d80: 63 68 20 72 69 64 20 5b 6c 72 61 6e 67 65 20 24 ch rid [lrange $
4d90: 72 65 76 69 73 69 6f 6e 73 20 30 20 65 6e 64 2d revisions 0 end-
4da0: 31 5d 20 72 6e 65 78 74 20 5b 6c 72 61 6e 67 65 1] rnext [lrange
4db0: 20 24 72 65 76 69 73 69 6f 6e 73 20 31 20 65 6e $revisions 1 en
4dc0: 64 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 64 65 d] {.. set de
4dd0: 6c 74 61 28 24 6e 29 20 5b 65 78 70 72 20 7b 24 lta($n) [expr {$
4de0: 73 74 61 6d 70 28 24 72 6e 65 78 74 29 20 2d 20 stamp($rnext) -
4df0: 24 73 74 61 6d 70 28 24 72 69 64 29 7d 5d 0a 09 $stamp($rid)}]..
4e00: 20 20 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 09 72 incr n..}..r
4e10: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
4e20: 20 70 72 6f 63 20 46 69 6e 64 42 65 73 74 42 72 proc FindBestBr
4e30: 65 61 6b 20 7b 72 61 6e 67 65 7d 20 7b 0a 09 75 eak {range} {..u
4e40: 70 76 61 72 20 31 20 63 72 6f 73 73 20 63 72 6f pvar 1 cross cro
4e50: 73 73 20 64 65 6c 74 61 20 64 65 6c 74 61 0a 0a ss delta delta..
4e60: 09 23 20 44 65 74 65 72 6d 69 6e 65 20 74 68 65 .# Determine the
4e70: 20 62 65 73 74 20 62 72 65 61 6b 20 6c 6f 63 61 best break loca
4e80: 74 69 6f 6e 20 69 6e 20 74 68 65 20 67 69 76 65 tion in the give
4e90: 6e 20 72 61 6e 67 65 20 6f 66 0a 09 23 20 70 6f n range of..# po
4ea0: 73 69 74 69 6f 6e 73 2e 20 46 69 72 73 74 20 77 sitions. First w
4eb0: 65 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 20 6c e look for the l
4ec0: 6f 63 61 74 69 6f 6e 73 20 77 69 74 68 20 74 68 ocations with th
4ed0: 65 20 6d 61 78 69 6d 61 6c 0a 09 23 20 6e 75 6d e maximal..# num
4ee0: 62 65 72 20 6f 66 20 63 72 6f 73 73 69 6e 67 73 ber of crossings
4ef0: 2e 20 49 66 20 74 68 65 72 65 20 61 72 65 20 73 . If there are s
4f00: 65 76 65 72 61 6c 20 77 65 20 6c 6f 6f 6b 20 66 everal we look f
4f10: 6f 72 20 74 68 65 0a 09 23 20 73 68 6f 72 74 65 or the..# shorte
4f20: 73 74 20 74 69 6d 65 20 69 6e 74 65 72 76 61 6c st time interval
4f30: 20 61 6d 6f 6e 67 20 74 68 65 6d 2e 20 49 66 20 among them. If
4f40: 77 65 20 73 74 69 6c 6c 20 68 61 76 65 20 6d 75 we still have mu
4f50: 6c 74 69 70 6c 65 0a 09 23 20 70 6f 73 73 69 62 ltiple..# possib
4f60: 69 6c 69 74 69 65 73 20 61 66 74 65 72 20 74 68 ilities after th
4f70: 61 74 20 77 65 20 73 65 6c 65 63 74 20 74 68 65 at we select the
4f80: 20 65 61 72 6c 69 65 73 74 20 6c 6f 63 61 74 69 earliest locati
4f90: 6f 6e 0a 09 23 20 61 6d 6f 6e 67 20 74 68 65 73 on..# among thes
4fa0: 65 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 49 66 20 e....# Note: If
4fb0: 74 68 65 20 6d 61 78 69 6d 61 6c 20 6e 75 6d 62 the maximal numb
4fc0: 65 72 20 6f 66 20 63 72 6f 73 73 69 6e 67 73 20 er of crossings
4fd0: 69 73 20 30 20 74 68 65 6e 20 74 68 65 20 72 61 is 0 then the ra
4fe0: 6e 67 65 0a 09 23 20 20 20 20 20 20 20 68 61 73 nge..# has
4ff0: 20 6e 6f 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 no internal dep
5000: 65 6e 64 65 6e 63 69 65 73 2c 20 61 6e 64 20 6e endencies, and n
5010: 6f 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e o break location
5020: 20 61 74 0a 09 23 20 20 20 20 20 20 20 61 6c 6c at..# all
5030: 2e 20 54 68 69 73 20 70 6f 73 73 69 62 69 6c 69 . This possibili
5040: 74 79 20 69 73 20 73 69 67 6e 61 6c 65 64 20 76 ty is signaled v
5050: 69 61 20 72 65 73 75 6c 74 20 2d 31 2e 0a 0a 09 ia result -1....
5060: 23 20 4e 6f 74 65 3a 20 41 20 72 61 6e 67 65 20 # Note: A range
5070: 6f 66 20 6c 65 6e 67 74 68 20 31 20 6f 72 20 6c of length 1 or l
5080: 65 73 73 20 63 61 6e 6e 6f 74 20 68 61 76 65 20 ess cannot have
5090: 69 6e 74 65 72 6e 61 6c 0a 09 23 20 20 20 20 20 internal..#
50a0: 20 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 dependencies,
50b0: 61 73 20 74 68 61 74 20 6e 65 65 64 73 20 61 74 as that needs at
50c0: 20 6c 65 61 73 74 20 74 77 6f 20 72 65 76 69 73 least two revis
50d0: 69 6f 6e 73 20 69 6e 0a 09 23 20 20 20 20 20 20 ions in..#
50e0: 20 74 68 65 20 72 61 6e 67 65 2e 0a 0a 09 69 66 the range....if
50f0: 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 72 61 6e 67 {[llength $rang
5100: 65 5d 20 3c 20 32 7d 20 7b 20 72 65 74 75 72 6e e] < 2} { return
5110: 20 2d 31 20 7d 0a 0a 09 73 65 74 20 6d 61 78 20 -1 }...set max
5120: 2d 31 0a 09 73 65 74 20 62 65 73 74 20 7b 7d 0a -1..set best {}.
5130: 0a 09 66 6f 72 65 61 63 68 20 6c 6f 63 61 74 69 ..foreach locati
5140: 6f 6e 20 24 72 61 6e 67 65 20 7b 0a 09 20 20 20 on $range {..
5150: 20 73 65 74 20 63 72 6f 73 73 69 6e 67 73 20 24 set crossings $
5160: 63 72 6f 73 73 28 24 6c 6f 63 61 74 69 6f 6e 29 cross($location)
5170: 0a 09 20 20 20 20 69 66 20 7b 24 63 72 6f 73 73 .. if {$cross
5180: 69 6e 67 73 20 3e 20 24 6d 61 78 7d 20 7b 0a 09 ings > $max} {..
5190: 09 73 65 74 20 6d 61 78 20 20 24 63 72 6f 73 73 .set max $cross
51a0: 69 6e 67 73 0a 09 09 73 65 74 20 62 65 73 74 20 ings...set best
51b0: 5b 6c 69 73 74 20 24 6c 6f 63 61 74 69 6f 6e 5d [list $location]
51c0: 0a 09 09 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 ...continue..
51d0: 20 7d 20 65 6c 73 65 69 66 20 7b 24 63 72 6f 73 } elseif {$cros
51e0: 73 69 6e 67 73 20 3d 3d 20 24 6d 61 78 7d 20 7b sings == $max} {
51f0: 0a 09 09 6c 61 70 70 65 6e 64 20 62 65 73 74 20 ...lappend best
5200: 24 6c 6f 63 61 74 69 6f 6e 0a 09 20 20 20 20 7d $location.. }
5210: 0a 09 7d 0a 0a 09 69 66 20 7b 24 6d 61 78 20 3d ..}...if {$max =
5220: 3d 20 30 7d 20 20 20 20 20 20 20 20 20 20 20 20 = 0}
5230: 7b 20 72 65 74 75 72 6e 20 2d 31 20 7d 0a 09 69 { return -1 }..i
5240: 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 62 65 73 f {[llength $bes
5250: 74 5d 20 3d 3d 20 31 7d 20 7b 20 72 65 74 75 72 t] == 1} { retur
5260: 6e 20 5b 6c 69 6e 64 65 78 20 24 62 65 73 74 20 n [lindex $best
5270: 30 5d 20 7d 0a 0a 09 73 65 74 20 6c 6f 63 61 74 0] }...set locat
5280: 69 6f 6e 73 20 24 62 65 73 74 0a 09 73 65 74 20 ions $best..set
5290: 62 65 73 74 20 7b 7d 0a 09 73 65 74 20 6d 69 6e best {}..set min
52a0: 20 2d 31 0a 0a 09 66 6f 72 65 61 63 68 20 6c 6f -1...foreach lo
52b0: 63 61 74 69 6f 6e 20 24 6c 6f 63 61 74 69 6f 6e cation $location
52c0: 73 20 7b 0a 09 20 20 20 20 73 65 74 20 69 6e 74 s {.. set int
52d0: 65 72 76 61 6c 20 24 64 65 6c 74 61 28 24 6c 6f erval $delta($lo
52e0: 63 61 74 69 6f 6e 29 0a 09 20 20 20 20 69 66 20 cation).. if
52f0: 7b 28 24 6d 69 6e 20 3c 20 30 29 20 7c 7c 20 28 {($min < 0) || (
5300: 24 69 6e 74 65 72 76 61 6c 20 3c 20 24 6d 69 6e $interval < $min
5310: 29 7d 20 7b 0a 09 09 73 65 74 20 6d 69 6e 20 20 )} {...set min
5320: 24 69 6e 74 65 72 76 61 6c 0a 09 09 73 65 74 20 $interval...set
5330: 62 65 73 74 20 5b 6c 69 73 74 20 24 6c 6f 63 61 best [list $loca
5340: 74 69 6f 6e 5d 0a 09 20 20 20 20 7d 20 65 6c 73 tion].. } els
5350: 65 69 66 20 7b 24 69 6e 74 65 72 76 61 6c 20 3d eif {$interval =
5360: 3d 20 24 6d 69 6e 7d 20 7b 0a 09 09 6c 61 70 70 = $min} {...lapp
5370: 65 6e 64 20 62 65 73 74 20 24 6c 6f 63 61 74 69 end best $locati
5380: 6f 6e 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69 on.. }..}...i
5390: 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 62 65 73 f {[llength $bes
53a0: 74 5d 20 3d 3d 20 31 7d 20 7b 20 72 65 74 75 72 t] == 1} { retur
53b0: 6e 20 5b 6c 69 6e 64 65 78 20 24 62 65 73 74 20 n [lindex $best
53c0: 30 5d 20 7d 0a 0a 09 72 65 74 75 72 6e 20 5b 6c 0] }...return [l
53d0: 69 6e 64 65 78 20 5b 6c 73 6f 72 74 20 2d 69 6e index [lsort -in
53e0: 74 65 67 65 72 20 2d 69 6e 63 72 65 61 73 69 6e teger -increasin
53f0: 67 20 24 62 65 73 74 5d 20 30 5d 0a 20 20 20 20 g $best] 0].
5400: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 43 75 74 41 }.. proc CutA
5410: 74 20 7b 6c 6f 63 61 74 69 6f 6e 7d 20 7b 0a 09 t {location} {..
5420: 75 70 76 61 72 20 31 20 63 72 6f 73 73 20 63 72 upvar 1 cross cr
5430: 6f 73 73 20 64 65 70 63 20 64 65 70 63 0a 0a 09 oss depc depc...
5440: 23 20 49 74 20 77 61 73 20 64 65 63 69 64 65 64 # It was decided
5450: 20 74 6f 20 73 70 6c 69 74 20 74 68 65 20 63 68 to split the ch
5460: 61 6e 67 65 73 65 74 20 61 74 20 74 68 65 20 67 angeset at the g
5470: 69 76 65 6e 0a 09 23 20 6c 6f 63 61 74 69 6f 6e iven..# location
5480: 2e 20 54 68 69 73 20 63 75 74 73 20 61 20 6e 75 . This cuts a nu
5490: 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 65 6e mber of dependen
54a0: 63 69 65 73 2e 20 48 65 72 65 20 77 65 20 75 70 cies. Here we up
54b0: 64 61 74 65 0a 09 23 20 74 68 65 20 63 72 6f 73 date..# the cros
54c0: 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 73 6f s information so
54d0: 20 74 68 61 74 20 74 68 65 20 62 72 65 61 6b 20 that the break
54e0: 66 69 6e 64 65 72 20 68 61 73 20 61 63 63 75 72 finder has accur
54f0: 61 74 65 0a 09 23 20 64 61 74 61 20 77 68 65 6e ate..# data when
5500: 20 77 65 20 6c 6f 6f 6b 20 61 74 20 74 68 65 20 we look at the
5510: 67 65 6e 65 72 61 74 65 64 20 66 72 61 67 6d 65 generated fragme
5520: 6e 74 73 2e 0a 0a 09 73 65 74 20 73 69 78 20 5b nts....set six [
5530: 6c 6f 67 20 76 69 73 69 62 6c 65 3f 20 36 5d 0a log visible? 6].
5540: 0a 09 66 6f 72 65 61 63 68 20 7b 64 65 70 20 72 ..foreach {dep r
5550: 61 6e 67 65 7d 20 5b 61 72 72 61 79 20 67 65 74 ange} [array get
5560: 20 64 65 70 63 5d 20 7b 0a 09 20 20 20 20 23 20 depc] {.. #
5570: 43 68 65 63 6b 20 61 6c 6c 20 64 65 70 65 6e 64 Check all depend
5580: 65 6e 63 69 65 73 20 73 74 69 6c 6c 20 6b 6e 6f encies still kno
5590: 77 6e 2c 20 74 61 6b 65 20 74 68 65 69 72 20 72 wn, take their r
55a0: 61 6e 67 65 20 61 6e 64 0a 09 20 20 20 20 23 20 ange and.. #
55b0: 73 65 65 20 69 66 20 74 68 65 20 62 72 65 61 6b see if the break
55c0: 20 6c 6f 63 61 74 69 6f 6e 20 66 61 6c 6c 73 20 location falls
55d0: 77 69 74 68 69 6e 2e 0a 0a 09 20 20 20 20 42 6f within.... Bo
55e0: 72 64 65 72 20 24 72 61 6e 67 65 20 73 20 65 0a rder $range s e.
55f0: 09 20 20 20 20 69 66 20 7b 24 6c 6f 63 61 74 69 . if {$locati
5600: 6f 6e 20 3c 20 24 73 7d 20 63 6f 6e 74 69 6e 75 on < $s} continu
5610: 65 20 3b 20 23 20 62 72 65 61 6b 20 62 65 66 6f e ; # break befo
5620: 72 65 20 72 61 6e 67 65 2c 20 69 67 6e 6f 72 65 re range, ignore
5630: 0a 09 20 20 20 20 69 66 20 7b 24 6c 6f 63 61 74 .. if {$locat
5640: 69 6f 6e 20 3e 20 24 65 7d 20 63 6f 6e 74 69 6e ion > $e} contin
5650: 75 65 20 3b 20 23 20 62 72 65 61 6b 20 61 66 74 ue ; # break aft
5660: 65 72 20 72 61 6e 67 65 2c 20 69 67 6e 6f 72 65 er range, ignore
5670: 2e 0a 0a 09 20 20 20 20 23 20 54 68 69 73 20 64 .... # This d
5680: 65 70 65 6e 64 65 6e 63 79 20 63 72 6f 73 73 65 ependency crosse
5690: 73 20 74 68 65 20 62 72 65 61 6b 20 6c 6f 63 61 s the break loca
56a0: 74 69 6f 6e 2e 20 57 65 20 72 65 6d 6f 76 65 20 tion. We remove
56b0: 69 74 0a 09 20 20 20 20 23 20 66 72 6f 6d 20 74 it.. # from t
56c0: 68 65 20 63 72 6f 73 73 69 6e 67 73 20 63 6f 75 he crossings cou
56d0: 6e 74 65 72 73 2c 20 61 6e 64 20 74 68 65 6e 20 nters, and then
56e0: 61 6c 73 6f 20 66 72 6f 6d 20 74 68 65 20 73 65 also from the se
56f0: 74 0a 09 20 20 20 20 23 20 6f 66 20 6b 6e 6f 77 t.. # of know
5700: 6e 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 n dependencies,
5710: 61 73 20 77 65 20 61 72 65 20 64 6f 6e 65 20 77 as we are done w
5720: 69 74 68 20 69 74 2e 0a 0a 09 20 20 20 20 66 6f ith it.... fo
5730: 72 65 61 63 68 20 6c 6f 63 20 24 64 65 70 63 28 reach loc $depc(
5740: 24 64 65 70 29 20 7b 20 69 6e 63 72 20 63 72 6f $dep) { incr cro
5750: 73 73 28 24 6c 6f 63 29 20 2d 31 20 7d 0a 09 20 ss($loc) -1 }..
5760: 20 20 20 75 6e 73 65 74 20 64 65 70 63 28 24 64 unset depc($d
5770: 65 70 29 0a 0a 09 20 20 20 20 69 66 20 7b 21 24 ep)... if {!$
5780: 73 69 78 7d 20 63 6f 6e 74 69 6e 75 65 0a 0a 09 six} continue...
5790: 20 20 20 20 73 74 72 75 63 74 3a 3a 6c 69 73 74 struct::list
57a0: 20 61 73 73 69 67 6e 20 24 64 65 70 20 70 61 72 assign $dep par
57b0: 65 6e 74 20 63 68 69 6c 64 0a 09 20 20 20 20 6c ent child.. l
57c0: 6f 67 20 77 72 69 74 65 20 35 20 63 73 65 74 73 og write 5 csets
57d0: 20 22 42 72 6f 6b 65 20 64 65 70 65 6e 64 65 6e "Broke dependen
57e0: 63 79 20 5b 50 44 20 24 70 61 72 65 6e 74 5d 20 cy [PD $parent]
57f0: 2d 2d 3e 20 5b 50 44 20 24 63 68 69 6c 64 5d 22 --> [PD $child]"
5800: 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20 ..}...return.
5810: 20 7d 0a 0a 20 20 20 20 23 20 50 72 69 6e 74 20 }.. # Print
5820: 69 64 65 6e 74 69 66 79 69 6e 67 20 64 61 74 61 identifying data
5830: 20 66 6f 72 20 61 20 72 65 76 69 73 69 6f 6e 20 for a revision
5840: 28 70 72 6f 6a 65 63 74 2c 20 66 69 6c 65 2c 20 (project, file,
5850: 64 6f 74 74 65 64 20 72 65 76 0a 20 20 20 20 23 dotted rev. #
5860: 20 6e 75 6d 62 65 72 29 2c 20 66 6f 72 20 68 69 number), for hi
5870: 67 68 20 76 65 72 62 6f 73 69 74 79 20 6c 6f 67 gh verbosity log
5880: 20 6f 75 74 70 75 74 2e 0a 20 20 20 20 23 20 54 output.. # T
5890: 4f 44 4f 3a 20 52 65 70 6c 61 63 65 20 77 69 74 ODO: Replace wit
58a0: 68 20 63 61 6c 6c 20 74 6f 20 69 74 65 6d 73 74 h call to itemst
58b0: 72 20 28 6c 69 73 74 20 72 65 76 20 24 69 64 29 r (list rev $id)
58c0: 0a 0a 20 20 20 20 70 72 6f 63 20 50 44 20 7b 69 .. proc PD {i
58d0: 64 7d 20 7b 0a 09 66 6f 72 65 61 63 68 20 7b 70 d} {..foreach {p
58e0: 20 66 20 72 7d 20 5b 73 74 61 74 65 20 72 75 6e f r} [state run
58f0: 20 7b 0a 09 09 53 45 4c 45 43 54 20 50 2e 6e 61 {...SELECT P.na
5900: 6d 65 20 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 me , F.name, R.r
5910: 65 76 0a 09 09 46 52 4f 4d 20 72 65 76 69 73 69 ev...FROM revisi
5920: 6f 6e 20 52 2c 20 66 69 6c 65 20 46 2c 20 70 72 on R, file F, pr
5930: 6f 6a 65 63 74 20 50 0a 09 09 57 48 45 52 45 20 oject P...WHERE
5940: 52 2e 72 69 64 20 3d 20 24 69 64 0a 09 09 41 4e R.rid = $id...AN
5950: 44 20 20 20 46 2e 66 69 64 20 3d 20 52 2e 66 69 D F.fid = R.fi
5960: 64 0a 09 09 41 4e 44 20 20 20 50 2e 70 69 64 20 d...AND P.pid
5970: 3d 20 46 2e 70 69 64 0a 09 7d 5d 20 62 72 65 61 = F.pid..}] brea
5980: 6b 0a 09 72 65 74 75 72 6e 20 22 27 24 70 20 3a k..return "'$p :
5990: 20 24 66 2f 24 72 27 22 0a 20 20 20 20 7d 0a 0a $f/$r'". }..
59a0: 20 20 20 20 23 20 50 72 69 6e 74 69 6e 67 20 6f # Printing o
59b0: 6e 65 20 6f 72 20 6d 6f 72 65 20 72 61 6e 67 65 ne or more range
59c0: 73 2c 20 66 6f 72 6d 61 74 74 65 64 2c 20 61 6e s, formatted, an
59d0: 64 20 6f 6e 6c 79 20 74 68 65 69 72 20 62 6f 72 d only their bor
59e0: 64 65 72 20 74 6f 0a 20 20 20 20 23 20 6b 65 65 der to. # kee
59f0: 70 20 74 68 65 20 73 74 72 69 6e 67 73 20 73 68 p the strings sh
5a00: 6f 72 74 2e 0a 0a 20 20 20 20 70 72 6f 63 20 50 ort... proc P
5a10: 52 73 20 7b 72 61 6e 67 65 73 7d 20 7b 0a 09 72 Rs {ranges} {..r
5a20: 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a 6c eturn [struct::l
5a30: 69 73 74 20 6d 61 70 20 24 72 61 6e 67 65 73 20 ist map $ranges
5a40: 5b 6d 79 70 72 6f 63 20 50 52 5d 5d 0a 20 20 20 [myproc PR]].
5a50: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 50 52 20 }.. proc PR
5a60: 7b 72 61 6e 67 65 7d 20 7b 0a 09 42 6f 72 64 65 {range} {..Borde
5a70: 72 20 24 72 61 6e 67 65 20 73 20 65 0a 09 72 65 r $range s e..re
5a80: 74 75 72 6e 20 3c 24 7b 73 7d 2e 2e 2e 24 7b 65 turn <${s}...${e
5a90: 7d 3e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 }>. }.. pr
5aa0: 6f 63 20 42 6f 72 64 65 72 20 7b 72 61 6e 67 65 oc Border {range
5ab0: 20 73 76 20 65 76 7d 20 7b 0a 09 75 70 76 61 72 sv ev} {..upvar
5ac0: 20 31 20 24 73 76 20 73 20 24 65 76 20 65 0a 09 1 $sv s $ev e..
5ad0: 73 65 74 20 73 20 5b 6c 69 6e 64 65 78 20 24 72 set s [lindex $r
5ae0: 61 6e 67 65 20 30 5d 0a 09 73 65 74 20 65 20 5b ange 0]..set e [
5af0: 6c 69 6e 64 65 78 20 24 72 61 6e 67 65 20 65 6e lindex $range en
5b00: 64 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d d]..return. }
5b10: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 .. # # ## ###
5b20: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 ##### ########
5b30: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a 20 #############..
5b40: 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 typevariable
5b50: 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20 20 20 mychangesets
5b60: 20 20 20 20 20 7b 7d 20 3b 20 23 20 4c 69 73 74 {} ; # List
5b70: 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 0a 09 09 of all known...
5b80: 09 09 09 20 20 20 23 20 63 68 61 6e 67 65 73 65 ... # changese
5b90: 74 73 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 ts.. typevari
5ba0: 61 62 6c 65 20 6d 79 74 63 68 61 6e 67 65 73 65 able mytchangese
5bb0: 74 73 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23 ts -array {} ; #
5bc0: 20 4c 69 73 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f List of all kno
5bd0: 77 6e 0a 09 09 09 09 09 20 20 20 23 20 63 68 61 wn...... # cha
5be0: 6e 67 65 73 65 74 73 20 6f 66 20 61 20 74 79 70 ngesets of a typ
5bf0: 65 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 e.. typevaria
5c00: 62 6c 65 20 6d 79 69 74 65 6d 6d 61 70 20 20 20 ble myitemmap
5c10: 20 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23 20 -array {} ; #
5c20: 4d 61 70 20 66 72 6f 6d 20 69 74 65 6d 73 20 28 Map from items (
5c30: 74 61 67 67 65 64 29 0a 09 09 09 09 09 20 20 20 tagged)......
5c40: 23 20 74 6f 20 74 68 65 20 6c 69 73 74 20 6f 66 # to the list of
5c50: 20 63 68 61 6e 67 65 73 65 74 73 0a 09 09 09 09 changesets.....
5c60: 09 20 20 20 23 20 63 6f 6e 74 61 69 6e 69 6e 67 . # containing
5c70: 20 69 74 2e 20 45 61 63 68 20 69 74 65 6d 0a 09 it. Each item..
5c80: 09 09 09 09 20 20 20 23 20 63 61 6e 20 62 65 20 .... # can be
5c90: 75 73 65 64 20 62 79 20 6f 6e 6c 79 20 6f 6e 65 used by only one
5ca0: 0a 09 09 09 09 09 20 20 20 23 20 63 68 61 6e 67 ...... # chang
5cb0: 65 73 65 74 2e 0a 20 20 20 20 74 79 70 65 76 61 eset.. typeva
5cc0: 72 69 61 62 6c 65 20 6d 79 69 64 6d 61 70 20 20 riable myidmap
5cd0: 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 23 20 4d -array {} ; # M
5ce0: 61 70 20 66 72 6f 6d 20 63 68 61 6e 67 65 73 65 ap from changese
5cf0: 74 20 69 64 20 74 6f 0a 09 09 09 09 20 20 20 20 t id to.....
5d00: 20 20 20 23 20 63 68 61 6e 67 65 73 65 74 2e 0a # changeset..
5d10: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
5d20: 61 6c 6c 20 20 20 20 7b 7d 20 20 20 20 7b 20 72 all {} { r
5d30: 65 74 75 72 6e 20 24 6d 79 63 68 61 6e 67 65 73 eturn $mychanges
5d40: 65 74 73 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 ets }. typeme
5d50: 74 68 6f 64 20 6f 66 20 20 20 20 20 7b 63 69 64 thod of {cid
5d60: 7d 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 69 64 } { return $myid
5d70: 6d 61 70 28 24 63 69 64 29 20 7d 0a 20 20 20 20 map($cid) }.
5d80: 74 79 70 65 6d 65 74 68 6f 64 20 6f 66 69 74 65 typemethod ofite
5d90: 6d 20 7b 69 69 64 7d 20 7b 20 72 65 74 75 72 6e m {iid} { return
5da0: 20 24 6d 79 69 74 65 6d 6d 61 70 28 24 69 69 64 $myitemmap($iid
5db0: 29 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 ) }.. typemet
5dc0: 68 6f 64 20 72 65 76 20 20 20 20 7b 7d 20 20 20 hod rev {}
5dd0: 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 74 63 68 { return $mytch
5de0: 61 6e 67 65 73 65 74 73 28 72 65 76 29 20 7d 0a angesets(rev) }.
5df0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 typemethod s
5e00: 79 6d 20 20 20 20 7b 7d 20 20 20 20 7b 20 72 65 ym {} { re
5e10: 74 75 72 6e 20 5b 63 6f 6e 63 61 74 20 5c 0a 09 turn [concat \..
5e20: 09 09 09 09 20 20 24 7b 6d 79 74 63 68 61 6e 67 .... ${mytchang
5e30: 65 73 65 74 73 28 73 79 6d 3a 3a 62 72 61 6e 63 esets(sym::branc
5e40: 68 29 7d 20 5c 0a 09 09 09 09 09 20 20 24 7b 6d h)} \...... ${m
5e50: 79 74 63 68 61 6e 67 65 73 65 74 73 28 73 79 6d ytchangesets(sym
5e60: 3a 3a 74 61 67 29 7d 5d 20 7d 0a 0a 20 20 20 20 ::tag)}] }..
5e70: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 # # ## ### #####
5e80: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 ######## ######
5e90: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 43 #######. ## C
5ea0: 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 onfiguration..
5eb0: 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 pragma -hastyp
5ec0: 65 69 6e 66 6f 20 20 20 20 6e 6f 20 20 3b 20 23 einfo no ; #
5ed0: 20 6e 6f 20 74 79 70 65 20 69 6e 74 72 6f 73 70 no type introsp
5ee0: 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 61 67 6d ection. pragm
5ef0: 61 20 2d 68 61 73 69 6e 66 6f 20 20 20 20 20 20 a -hasinfo
5f00: 20 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 6f 62 6a no ; # no obj
5f10: 65 63 74 20 69 6e 74 72 6f 73 70 65 63 74 69 6f ect introspectio
5f20: 6e 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 n.. # # ## ##
5f30: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 # ##### ########
5f40: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 7d #############.}
5f50: 0a 0a 23 23 0a 23 23 20 4e 4f 54 45 3a 20 54 68 ..##.## NOTE: Th
5f60: 65 20 73 75 63 63 65 73 73 6f 72 20 61 6e 64 20 e successor and
5f70: 70 72 65 64 65 63 65 73 73 6f 72 20 6d 65 74 68 predecessor meth
5f80: 6f 64 73 20 64 65 66 69 6e 65 64 20 62 79 20 74 ods defined by t
5f90: 68 65 20 63 6c 61 73 73 65 73 0a 23 23 20 20 20 he classes.##
5fa0: 20 20 20 20 62 65 6c 6f 77 20 61 72 65 20 2d 2d below are --
5fb0: 20 62 6f 74 74 6c 65 20 6e 65 63 6b 73 20 2d 2d bottle necks --
5fc0: 2e 20 4c 6f 6f 6b 20 66 6f 72 20 77 61 79 73 20 . Look for ways
5fd0: 74 6f 20 6d 61 6b 65 20 74 68 65 20 53 51 4c 0a to make the SQL.
5fe0: 23 23 20 20 20 20 20 20 20 66 61 73 74 65 72 2e ## faster.
5ff0: 0a 23 23 0a 0a 23 20 23 20 23 23 20 23 23 23 20 .##..# # ## ###
6000: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 ##### ######## #
6010: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 ############ ###
6020: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6030: 23 23 0a 23 23 20 48 65 6c 70 65 72 20 73 69 6e ##.## Helper sin
6040: 67 6c 65 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73 gleton. Commands
6050: 20 66 6f 72 20 72 65 76 69 73 69 6f 6e 20 63 68 for revision ch
6060: 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e 69 74 3a angesets...snit:
6070: 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 :type ::vc::foss
6080: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a il::import::cvs:
6090: 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a 72 :project::rev::r
60a0: 65 76 20 7b 0a 20 20 20 20 74 79 70 65 6d 65 74 ev {. typemet
60b0: 68 6f 64 20 62 79 72 65 76 69 73 69 6f 6e 20 7b hod byrevision {
60c0: 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20 } { return 1 }.
60d0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 62 79 typemethod by
60e0: 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 7b 20 72 65 symbol {} { re
60f0: 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 turn 0 }. typ
6100: 65 6d 65 74 68 6f 64 20 69 73 74 61 67 20 20 20 emethod istag
6110: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 {} { return 0
6120: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f }. typemetho
6130: 64 20 69 73 62 72 61 6e 63 68 20 20 20 7b 7d 20 d isbranch {}
6140: 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 0a 20 20 { return 0 }..
6150: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 74 72 typemethod str
6160: 20 7b 72 65 76 69 73 69 6f 6e 7d 20 7b 0a 09 73 {revision} {..s
6170: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 truct::list assi
6180: 67 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a gn [state run {.
6190: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 65 . SELECT R.re
61a0: 76 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e 61 6d v, F.name, P.nam
61b0: 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 e.. FROM re
61c0: 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 20 46 vision R, file F
61d0: 2c 20 70 72 6f 6a 65 63 74 20 50 0a 09 20 20 20 , project P..
61e0: 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 3d 20 WHERE R.rid =
61f0: 24 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 41 $revision.. A
6200: 4e 44 20 20 20 20 46 2e 66 69 64 20 3d 20 52 2e ND F.fid = R.
6210: 66 69 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20 fid.. AND
6220: 50 2e 70 69 64 20 3d 20 46 2e 70 69 64 0a 09 7d P.pid = F.pid..}
6230: 5d 20 72 65 76 6e 72 20 66 6e 61 6d 65 20 70 6e ] revnr fname pn
6240: 61 6d 65 0a 09 72 65 74 75 72 6e 20 22 24 70 6e ame..return "$pn
6250: 61 6d 65 2f 24 7b 72 65 76 6e 72 7d 3a 3a 24 66 ame/${revnr}::$f
6260: 6e 61 6d 65 22 0a 20 20 20 20 7d 0a 0a 20 20 20 name". }..
6270: 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 # result = list
6280: 20 28 6d 69 6e 74 69 6d 65 2c 20 6d 61 78 74 69 (mintime, maxti
6290: 6d 65 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 me). typemeth
62a0: 6f 64 20 74 69 6d 65 72 61 6e 67 65 20 7b 69 74 od timerange {it
62b0: 65 6d 73 7d 20 7b 0a 09 73 65 74 20 74 68 65 73 ems} {..set thes
62c0: 65 74 20 28 27 5b 6a 6f 69 6e 20 24 69 74 65 6d et ('[join $item
62d0: 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 s {','}]')..retu
62e0: 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 rn [state run [s
62f0: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 ubst -nocommands
6300: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 -nobackslashes
6310: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 4d 49 {.. SELECT MI
6320: 4e 28 52 2e 64 61 74 65 29 2c 20 4d 41 58 28 52 N(R.date), MAX(R
6330: 2e 64 61 74 65 29 0a 09 20 20 20 20 46 52 4f 4d .date).. FROM
6340: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 revision R..
6350: 20 57 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20 WHERE R.rid IN
6360: 24 74 68 65 73 65 74 0a 09 7d 5d 5d 0a 20 20 20 $theset..}]].
6370: 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 }.. # var(dv
6380: 29 20 3d 20 64 69 63 74 20 28 72 65 76 69 73 69 ) = dict (revisi
6390: 6f 6e 20 2d 3e 20 6c 69 73 74 20 28 72 65 76 69 on -> list (revi
63a0: 73 69 6f 6e 29 29 0a 20 20 20 20 74 79 70 65 6d sion)). typem
63b0: 65 74 68 6f 64 20 69 6e 74 65 72 6e 61 6c 73 75 ethod internalsu
63c0: 63 63 65 73 73 6f 72 73 20 7b 64 76 20 72 65 76 ccessors {dv rev
63d0: 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 72 isions} {..upvar
63e0: 20 31 20 24 64 76 20 64 65 70 65 6e 64 65 6e 63 1 $dv dependenc
63f0: 69 65 73 0a 09 73 65 74 20 74 68 65 73 65 74 20 ies..set theset
6400: 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f ('[join $revisio
6410: 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 23 20 ns {','}]')...#
6420: 53 65 65 20 27 73 75 63 63 65 73 73 6f 72 73 27 See 'successors'
6430: 20 62 65 6c 6f 77 20 66 6f 72 20 74 68 65 20 6d below for the m
6440: 61 69 6e 20 65 78 70 6c 61 6e 61 74 69 6f 6e 20 ain explanation
6450: 6f 66 0a 09 23 20 74 68 65 20 76 61 72 69 6f 75 of..# the variou
6460: 73 20 63 61 73 65 73 2e 20 54 68 69 73 20 70 69 s cases. This pi
6470: 65 63 65 20 69 73 20 73 70 65 63 69 61 6c 20 69 ece is special i
6480: 6e 20 74 68 61 74 20 69 74 0a 09 23 20 72 65 73 n that it..# res
6490: 74 72 69 63 74 73 20 74 68 65 20 73 75 63 63 65 tricts the succe
64a0: 73 73 6f 72 73 20 77 65 20 6c 6f 6f 6b 20 66 6f ssors we look fo
64b0: 72 20 74 6f 20 74 68 65 20 73 61 6d 65 20 73 65 r to the same se
64c0: 74 20 6f 66 0a 09 23 20 72 65 76 69 73 69 6f 6e t of..# revision
64d0: 73 20 77 65 20 73 74 61 72 74 20 66 72 6f 6d 2e s we start from.
64e0: 20 53 65 6e 73 69 62 6c 65 20 61 73 20 77 65 20 Sensible as we
64f0: 61 72 65 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72 0a are looking for.
6500: 09 23 20 63 68 61 6e 67 65 73 65 74 20 69 6e 74 .# changeset int
6510: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 ernal dependenci
6520: 65 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 20 es....array set
6530: 64 65 70 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68 dep {}...foreach
6540: 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 {rid child} [st
6550: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d ate run [subst -
6560: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 nocommands -noba
6570: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 20 20 20 2d ckslashes {. -
6580: 2d 20 28 31 29 20 50 72 69 6d 61 72 79 20 63 68 - (1) Primary ch
6590: 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 43 54 20 ild.. SELECT
65a0: 52 2e 72 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09 R.rid, R.child..
65b0: 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 FROM revis
65c0: 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 ion R.. WHERE
65d0: 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 R.rid IN $th
65e0: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 eset -- Rest
65f0: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e rict to revision
6600: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 s of interest..
6610: 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c AND R.chil
6620: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 d IS NOT NULL
6630: 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 -- Has primary
6640: 63 68 69 6c 64 0a 09 20 20 20 20 41 4e 44 20 20 child.. AND
6650: 20 20 52 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 R.child IN $th
6660: 65 73 65 74 20 20 20 20 20 2d 2d 20 57 68 69 63 eset -- Whic
6670: 68 20 69 73 20 61 6c 73 6f 20 6f 66 20 69 6e 74 h is also of int
6680: 65 72 65 73 74 0a 20 20 20 20 55 4e 49 4f 4e 0a erest. UNION.
6690: 20 20 20 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e -- (2) Secon
66a0: 64 61 72 79 20 28 62 72 61 6e 63 68 29 20 63 68 dary (branch) ch
66b0: 69 6c 64 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 ildren.. SELE
66c0: 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 72 69 64 CT R.rid, B.brid
66d0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 .. FROM rev
66e0: 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f ision R, revisio
66f0: 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20 nbranchchildren
6700: 42 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e B.. WHERE R.
6710: 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 rid IN $theset
6720: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 -- Restrict
6730: 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 to revisions of
6740: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 interest.. A
6750: 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20 42 2e ND R.rid = B.
6760: 72 69 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 rid --
6770: 53 65 6c 65 63 74 20 73 75 62 73 65 74 20 6f 66 Select subset of
6780: 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72 65 6e branch children
6790: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 62 .. AND B.b
67a0: 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 rid IN $theset
67b0: 20 20 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20 -- Which is
67c0: 61 6c 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74 also of interest
67d0: 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d . UNION. -
67e0: 2d 20 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74 - (4) Child of t
67f0: 72 75 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 runk root succes
6800: 73 6f 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 sor of last NTDB
6810: 20 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 on trunk...
6820: 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 41 SELECT R.rid, RA
6830: 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d .child.. FROM
6840: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 revision R, rev
6850: 69 73 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 ision RA.. WH
6860: 45 52 45 20 52 2e 72 69 64 20 20 20 49 4e 20 24 ERE R.rid IN $
6870: 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 52 theset -- R
6880: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 estrict to revis
6890: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 ions of interest
68a0: 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 69 73 .. AND R.is
68b0: 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20 20 default
68c0: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 -- Restrict
68d0: 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e 44 to NTDB.. AND
68e0: 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 53 20 R.dbchild IS
68f0: 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e NOT NULL -- an
6900: 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65 6c 6f d last NTDB belo
6910: 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09 nging to trunk..
6920: 20 20 20 20 41 4e 44 20 20 20 52 41 2e 72 69 64 AND RA.rid
6930: 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 20 20 20 = R.dbchild
6940: 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 -- Go directly
6950: 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 to trunk root..
6960: 20 20 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69 AND RA.chi
6970: 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 ld IS NOT NULL
6980: 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 -- Has primary
6990: 20 63 68 69 6c 64 2e 0a 20 20 20 20 20 20 20 20 child..
69a0: 20 20 20 20 41 4e 44 20 20 20 52 41 2e 63 68 69 AND RA.chi
69b0: 6c 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 ld IN $theset
69c0: 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c -- Which is al
69d0: 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 so of interest..
69e0: 7d 5d 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e }]] {.. # Con
69f0: 73 69 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69 sider moving thi
6a00: 73 20 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69 s to the integri
6a10: 74 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20 ty module...
6a20: 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 integrity assert
6a30: 20 7b 24 72 69 64 20 21 3d 20 24 63 68 69 6c 64 {$rid != $child
6a40: 7d 20 7b 52 65 76 69 73 69 6f 6e 20 24 72 69 64 } {Revision $rid
6a50: 20 64 65 70 65 6e 64 73 20 6f 6e 20 69 74 73 65 depends on itse
6a60: 6c 66 2e 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e lf.}.. lappen
6a70: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 24 d dependencies($
6a80: 72 69 64 29 20 24 63 68 69 6c 64 0a 09 20 20 20 rid) $child..
6a90: 20 73 65 74 20 64 65 70 28 24 72 69 64 2c 24 63 set dep($rid,$c
6aa0: 68 69 6c 64 29 20 2e 0a 09 7d 0a 0a 09 23 20 54 hild) ...}...# T
6ab0: 68 65 20 73 71 6c 20 73 74 61 74 65 6d 65 6e 74 he sql statement
6ac0: 73 20 61 62 6f 76 65 20 6c 6f 6f 6b 73 20 6f 6e s above looks on
6ad0: 6c 79 20 66 6f 72 20 64 69 72 65 63 74 20 64 65 ly for direct de
6ae0: 70 65 6e 64 65 6e 63 69 65 73 0a 09 23 20 62 65 pendencies..# be
6af0: 74 77 65 65 6e 20 72 65 76 69 73 69 6f 6e 20 69 tween revision i
6b00: 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2e n the changeset.
6b10: 20 48 6f 77 65 76 65 72 20 64 75 65 20 74 6f 20 However due to
6b20: 74 68 65 0a 09 23 20 76 61 67 61 72 69 65 73 20 the..# vagaries
6b30: 6f 66 20 6d 65 74 61 20 64 61 74 61 20 69 74 20 of meta data it
6b40: 69 73 20 70 6f 73 73 69 62 6c 65 20 66 6f 72 20 is possible for
6b50: 74 77 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 two revisions of
6b60: 0a 09 23 20 74 68 65 20 73 61 6d 65 20 66 69 6c ..# the same fil
6b70: 65 20 74 6f 20 65 6e 64 20 75 70 20 69 6e 20 74 e to end up in t
6b80: 68 65 20 73 61 6d 65 20 63 68 61 6e 67 65 73 65 he same changese
6b90: 74 2c 20 77 69 74 68 6f 75 74 20 61 0a 09 23 20 t, without a..#
6ba0: 64 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63 direct dependenc
6bb0: 79 20 62 65 74 77 65 65 6e 20 74 68 65 6d 2e 20 y between them.
6bc0: 48 6f 77 65 76 65 72 20 77 65 20 6b 6e 6f 77 20 However we know
6bd0: 74 68 61 74 20 74 68 65 72 65 0a 09 23 20 68 61 that there..# ha
6be0: 73 20 74 6f 20 62 65 20 61 20 61 6e 20 69 6e 64 s to be a an ind
6bf0: 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63 79 irect dependency
6c00: 2c 20 62 65 20 69 74 20 74 68 72 6f 75 67 68 20 , be it through
6c10: 70 72 69 6d 61 72 79 0a 09 23 20 63 68 69 6c 64 primary..# child
6c20: 72 65 6e 2c 20 62 72 61 6e 63 68 20 63 68 69 6c ren, branch chil
6c30: 64 72 65 6e 2c 20 6f 72 20 61 20 63 6f 6d 62 69 dren, or a combi
6c40: 6e 61 74 69 6f 6e 20 74 68 65 72 65 6f 66 2e 0a nation thereof..
6c50: 0a 09 23 20 57 65 20 6e 6f 77 20 66 69 6c 6c 20 ..# We now fill
6c60: 69 6e 20 74 68 65 73 65 20 70 73 65 75 64 6f 2d in these pseudo-
6c70: 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 69 66 dependencies, if
6c80: 20 6e 6f 20 73 75 63 68 0a 09 23 20 64 65 70 65 no such..# depe
6c90: 6e 64 65 6e 63 79 20 65 78 69 73 74 73 20 61 6c ndency exists al
6ca0: 72 65 61 64 79 2e 20 54 68 65 20 64 69 72 65 63 ready. The direc
6cb0: 74 69 6f 6e 20 6f 66 20 74 68 65 20 64 65 70 65 tion of the depe
6cc0: 6e 64 65 6e 63 79 0a 09 23 20 69 73 20 61 63 74 ndency..# is act
6cd0: 75 61 6c 6c 79 20 69 72 72 65 6c 65 76 61 6e 74 ually irrelevant
6ce0: 20 66 6f 72 20 74 68 69 73 2e 0a 0a 09 23 20 4e for this....# N
6cf0: 4f 54 45 3a 20 54 68 69 73 20 69 73 20 64 69 66 OTE: This is dif
6d00: 66 65 72 65 6e 74 20 66 72 6f 6d 20 63 76 73 32 ferent from cvs2
6d10: 73 76 6e 2e 20 4f 75 72 20 73 70 69 72 69 74 75 svn. Our spiritu
6d20: 61 6c 20 61 6e 63 65 73 74 6f 72 0a 09 23 20 64 al ancestor..# d
6d30: 6f 65 73 20 6e 6f 74 20 75 73 65 20 73 75 63 68 oes not use such
6d40: 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 6e pseudo-dependen
6d50: 63 69 65 73 2c 20 68 6f 77 65 76 65 72 20 69 74 cies, however it
6d60: 20 75 73 65 73 20 61 0a 09 23 20 43 4f 4d 4d 49 uses a..# COMMI
6d70: 54 5f 54 48 52 45 53 48 4f 4c 44 2c 20 61 20 74 T_THRESHOLD, a t
6d80: 69 6d 65 20 69 6e 74 65 72 76 61 6c 20 63 6f 6d ime interval com
6d90: 6d 69 74 73 20 73 68 6f 75 6c 64 20 66 61 6c 6c mits should fall
6da0: 2e 20 54 68 69 73 0a 09 23 20 77 69 6c 6c 20 67 . This..# will g
6db0: 72 65 61 74 6c 79 20 72 65 64 75 63 65 73 20 74 reatly reduces t
6dc0: 68 65 20 72 69 73 6b 20 6f 66 20 67 65 74 74 69 he risk of getti
6dd0: 6e 67 20 66 61 72 20 73 65 70 61 72 61 74 65 64 ng far separated
6de0: 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 ..# revisions of
6df0: 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 20 69 the same file i
6e00: 6e 74 6f 20 6f 6e 65 20 63 68 61 6e 67 65 73 65 nto one changese
6e10: 74 2e 0a 0a 09 23 20 57 65 20 61 6c 6c 6f 77 20 t....# We allow
6e20: 72 65 76 69 73 69 6f 6e 73 20 74 6f 20 62 65 20 revisions to be
6e30: 66 61 72 20 61 70 61 72 74 20 69 6e 20 74 69 6d far apart in tim
6e40: 65 20 69 6e 20 74 68 65 20 73 61 6d 65 0a 09 23 e in the same..#
6e50: 20 63 68 61 6e 67 65 73 65 74 2c 20 62 75 74 20 changeset, but
6e60: 69 6e 20 74 75 72 6e 20 6e 65 65 64 20 74 68 65 in turn need the
6e70: 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 6e pseudo-dependen
6e80: 63 69 65 73 20 74 6f 0a 09 23 20 68 61 6e 64 6c cies to..# handl
6e90: 65 20 74 68 69 73 2e 0a 0a 09 61 72 72 61 79 20 e this....array
6ea0: 73 65 74 20 66 69 64 73 20 7b 7d 0a 09 66 6f 72 set fids {}..for
6eb0: 65 61 63 68 20 7b 72 69 64 20 66 69 64 7d 20 5b each {rid fid} [
6ec0: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 state run [subst
6ed0: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f -nocommands -no
6ee0: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 backslashes {..
6ef0: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c SELECT R.rid,
6f00: 20 52 2e 66 69 64 0a 20 20 20 20 20 20 20 20 20 R.fid.
6f10: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 FROM revisi
6f20: 6f 6e 20 52 0a 20 20 20 20 20 20 20 20 20 20 20 on R.
6f30: 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 49 4e WHERE R.rid IN
6f40: 20 24 74 68 65 73 65 74 0a 09 7d 5d 5d 20 7b 20 $theset..}]] {
6f50: 6c 61 70 70 65 6e 64 20 66 69 64 73 28 24 66 69 lappend fids($fi
6f60: 64 29 20 24 72 69 64 20 7d 0a 0a 09 66 6f 72 65 d) $rid }...fore
6f70: 61 63 68 20 7b 66 69 64 20 72 69 64 73 7d 20 5b ach {fid rids} [
6f80: 61 72 72 61 79 20 67 65 74 20 66 69 64 73 5d 20 array get fids]
6f90: 7b 0a 09 20 20 20 20 69 66 20 7b 5b 6c 6c 65 6e {.. if {[llen
6fa0: 67 74 68 20 24 72 69 64 73 5d 20 3c 20 32 7d 20 gth $rids] < 2}
6fb0: 63 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 66 6f continue.. fo
6fc0: 72 65 61 63 68 20 61 20 24 72 69 64 73 20 7b 0a reach a $rids {.
6fd0: 09 09 66 6f 72 65 61 63 68 20 62 20 24 72 69 64 ..foreach b $rid
6fe0: 73 20 7b 0a 09 09 20 20 20 20 69 66 20 7b 24 61 s {... if {$a
6ff0: 20 3d 3d 20 24 62 7d 20 63 6f 6e 74 69 6e 75 65 == $b} continue
7000: 0a 09 09 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f ... if {[info
7010: 20 65 78 69 73 74 73 20 64 65 70 28 24 61 2c 24 exists dep($a,$
7020: 62 29 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 b)]} continue...
7030: 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78 if {[info ex
7040: 69 73 74 73 20 64 65 70 28 24 62 2c 24 61 29 5d ists dep($b,$a)]
7050: 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20 } continue...
7060: 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 lappend depende
7070: 6e 63 69 65 73 28 24 61 29 20 24 62 0a 09 09 20 ncies($a) $b...
7080: 20 20 20 73 65 74 20 64 65 70 28 24 61 2c 24 62 set dep($a,$b
7090: 29 20 2e 0a 09 09 20 20 20 20 73 65 74 20 64 65 ) .... set de
70a0: 70 28 24 62 2c 24 61 29 20 2e 0a 09 09 7d 0a 09 p($b,$a) ....}..
70b0: 20 20 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e }..}..return
70c0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 . }.. # re
70d0: 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28 69 sult = 4-list (i
70e0: 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 20 6e temtype itemid n
70f0: 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 78 74 extitemtype next
7100: 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 20 itemid ...).
7110: 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 73 typemethod loops
7120: 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 {revisions} {..
7130: 23 20 4e 6f 74 65 3a 20 54 61 67 73 20 61 6e 64 # Note: Tags and
7140: 20 62 72 61 6e 63 68 65 73 20 63 61 6e 6e 6f 74 branches cannot
7150: 20 63 61 75 73 65 20 74 68 65 20 6c 6f 6f 70 2e cause the loop.
7160: 20 54 68 65 69 72 20 69 64 27 73 2c 0a 09 23 20 Their id's,..#
7170: 62 65 69 6e 20 6f 66 20 61 20 66 75 6e 64 61 6d bein of a fundam
7180: 65 6e 74 61 6c 6c 79 20 64 69 66 66 65 72 65 6e entally differen
7190: 74 20 74 79 70 65 20 74 68 61 6e 20 74 68 65 20 t type than the
71a0: 72 65 76 69 73 69 6f 6e 73 0a 09 23 20 63 6f 6d revisions..# com
71b0: 69 6e 67 20 69 6e 20 63 61 6e 6e 6f 74 20 62 65 ing in cannot be
71c0: 20 69 6e 20 74 68 65 20 73 65 74 2e 0a 0a 09 73 in the set....s
71d0: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 et theset ('[joi
71e0: 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c n $revisions {',
71f0: 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 '}]')..return [s
7200: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 tate run [subst
7210: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 -nocommands -nob
7220: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 ackslashes {..
7230: 20 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 72 79 -- (1) Primary
7240: 20 63 68 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 child.. SELE
7250: 43 54 20 52 2e 72 69 64 2c 20 52 2e 63 68 69 6c CT R.rid, R.chil
7260: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 d.. FROM re
7270: 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 vision R.. WH
7280: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 ERE R.rid IN
7290: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 $theset -- R
72a0: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 estrict to revis
72b0: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 ions of interest
72c0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 63 .. AND R.c
72d0: 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c hild IS NOT NULL
72e0: 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 -- Has prima
72f0: 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 41 4e ry child.. AN
7300: 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 4e 20 D R.child IN
7310: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c $theset -- L
7320: 6f 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 oop.. --..
7330: 20 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20 28 UNION.. -- (
7340: 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72 2) Secondary (br
7350: 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 anch) children..
7360: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 SELECT R.rid
7370: 2c 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46 52 , B.brid.. FR
7380: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c OM revision R,
7390: 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 revisionbranchc
73a0: 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 57 hildren B.. W
73b0: 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e HERE R.rid IN
73c0: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 $theset --
73d0: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 Restrict to revi
73e0: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 sions of interes
73f0: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e t.. AND R.
7400: 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20 rid = B.rid
7410: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73 -- Select s
7420: 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20 ubset of branch
7430: 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 41 4e children.. AN
7440: 44 20 20 20 20 42 2e 72 69 64 20 20 20 49 4e 20 D B.rid IN
7450: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c $theset -- L
7460: 6f 6f 70 0a 09 20 20 20 20 2d 2d 0a 09 20 20 20 oop.. --..
7470: 20 55 4e 49 4f 4e 0a 09 20 20 20 20 2d 2d 20 28 UNION.. -- (
7480: 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 4) Child of trun
7490: 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 k root successor
74a0: 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e of last NTDB on
74b0: 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c trunk... SEL
74c0: 45 43 54 20 52 2e 72 69 64 2c 20 52 41 2e 63 68 ECT R.rid, RA.ch
74d0: 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 ild.. FROM
74e0: 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 revision R, revi
74f0: 73 69 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 45 sion RA.. WHE
7500: 52 45 20 20 52 2e 72 69 64 20 20 20 20 49 4e 20 RE R.rid IN
7510: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 $theset -- R
7520: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 estrict to revis
7530: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 ions of interest
7540: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 69 .. AND R.i
7550: 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20 sdefault
7560: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 -- Restrict
7570: 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e to NTDB.. AN
7580: 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 D R.dbchild I
7590: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 S NOT NULL --
75a0: 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65 and last NTDB be
75b0: 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b longing to trunk
75c0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e .. AND RA.
75d0: 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 rid = R.dbchild
75e0: 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 -- Go direc
75f0: 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f tly to trunk roo
7600: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 t.. AND RA
7610: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 .child IS NOT NU
7620: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 LL -- Has pri
7630: 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 20 20 20 mary child...
7640: 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c 64 AND RA.child
7650: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 IN $theset
7660: 2d 2d 20 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20 20 -- Loop..}]].
7670: 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 }.. # var(dv
7680: 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d ) = dict (item -
7690: 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20 > list (item)),
76a0: 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79 item = list (ty
76b0: 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d pe id). typem
76c0: 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73 ethod successors
76d0: 20 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 7d 20 {dv revisions}
76e0: 7b 0a 09 75 70 76 61 72 20 31 20 24 64 76 20 64 {..upvar 1 $dv d
76f0: 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 65 74 ependencies..set
7700: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 theset ('[join
7710: 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d $revisions {','}
7720: 5d 27 29 0a 0a 09 23 20 54 68 65 20 66 6f 6c 6c ]')...# The foll
7730: 6f 77 69 6e 67 20 63 61 73 65 73 20 73 70 65 63 owing cases spec
7740: 69 66 79 20 77 68 65 6e 20 61 20 72 65 76 69 73 ify when a revis
7750: 69 6f 6e 20 53 20 69 73 20 61 20 73 75 63 63 65 ion S is a succe
7760: 73 73 6f 72 0a 09 23 20 6f 66 20 61 20 72 65 76 ssor..# of a rev
7770: 69 73 69 6f 6e 20 52 2e 20 45 61 63 68 20 6f 66 ision R. Each of
7780: 20 74 68 65 20 63 61 73 65 73 20 74 72 61 6e 73 the cases trans
7790: 6c 61 74 65 73 20 69 6e 74 6f 20 6f 6e 65 20 6f lates into one o
77a0: 66 0a 09 23 20 74 68 65 20 62 72 61 6e 63 68 65 f..# the branche
77b0: 73 20 6f 66 20 74 68 65 20 53 51 4c 20 55 4e 49 s of the SQL UNI
77c0: 4f 4e 20 63 6f 6d 69 6e 67 20 62 65 6c 6f 77 2e ON coming below.
77d0: 0a 09 23 0a 09 23 20 28 31 29 20 53 20 63 61 6e ..#..# (1) S can
77e0: 20 62 65 20 61 20 70 72 69 6d 61 72 79 20 63 68 be a primary ch
77f0: 69 6c 64 20 6f 66 20 52 2c 20 69 2e 65 2e 20 69 ild of R, i.e. i
7800: 6e 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 2e 20 n the same LOD.
7810: 52 0a 09 23 20 20 20 20 20 72 65 66 65 72 65 6e R..# referen
7820: 63 65 73 20 53 20 64 69 72 65 63 74 6c 79 2e 20 ces S directly.
7830: 52 2e 63 68 69 6c 64 20 3d 20 53 28 2e 72 69 64 R.child = S(.rid
7840: 29 2c 20 69 66 20 69 74 20 65 78 69 73 74 73 2e ), if it exists.
7850: 0a 09 23 0a 09 23 20 28 32 29 20 53 20 63 61 6e ..#..# (2) S can
7860: 20 62 65 20 61 20 73 65 63 6f 6e 64 61 72 79 2c be a secondary,
7870: 20 69 2e 65 2e 20 62 72 61 6e 63 68 2c 20 63 68 i.e. branch, ch
7880: 69 6c 64 20 6f 66 20 52 2e 20 48 65 72 65 20 74 ild of R. Here t
7890: 68 65 0a 09 23 20 20 20 20 20 6c 69 6e 6b 20 69 he..# link i
78a0: 73 20 6d 61 64 65 20 74 68 72 6f 75 67 68 20 74 s made through t
78b0: 68 65 20 68 65 6c 70 65 72 20 74 61 62 6c 65 0a he helper table.
78c0: 09 23 20 20 20 20 20 52 45 56 49 53 49 4f 4e 42 .# REVISIONB
78d0: 52 41 4e 43 48 43 48 49 4c 44 52 45 4e 2e 20 52 RANCHCHILDREN. R
78e0: 2e 72 69 64 20 2d 3e 20 52 42 43 2e 72 69 64 2c .rid -> RBC.rid,
78f0: 20 52 42 43 2e 62 72 69 64 20 3d 0a 09 23 20 20 RBC.brid =..#
7900: 20 20 20 53 28 2e 72 69 64 29 0a 09 23 0a 09 23 S(.rid)..#..#
7910: 20 28 33 29 20 4f 72 69 67 69 6e 61 6c 6c 79 20 (3) Originally
7920: 74 68 69 73 20 75 73 65 20 63 61 73 65 20 64 65 this use case de
7930: 66 69 6e 65 64 20 74 68 65 20 72 6f 6f 74 20 6f fined the root o
7940: 66 20 61 20 64 65 74 61 63 68 65 64 0a 09 23 20 f a detached..#
7950: 20 20 20 20 4e 54 44 42 20 61 73 20 74 68 65 20 NTDB as the
7960: 73 75 63 63 65 73 73 6f 72 20 6f 66 20 74 68 65 successor of the
7970: 20 74 72 75 6e 6b 20 72 6f 6f 74 2e 20 54 68 69 trunk root. Thi
7980: 73 20 6c 65 61 64 73 20 74 6f 20 61 0a 09 23 20 s leads to a..#
7990: 20 20 20 20 62 61 64 20 74 61 6e 67 6c 65 20 6c bad tangle l
79a0: 61 74 65 72 20 6f 6e 2e 20 57 69 74 68 20 61 20 ater on. With a
79b0: 64 65 74 61 63 68 65 64 20 4e 54 44 42 20 74 68 detached NTDB th
79c0: 65 20 6f 72 69 67 69 6e 61 6c 0a 09 23 20 20 20 e original..#
79d0: 20 20 74 72 75 6e 6b 20 72 6f 6f 74 20 72 65 76 trunk root rev
79e0: 69 73 69 6f 6e 20 77 61 73 20 72 65 6d 6f 76 65 ision was remove
79f0: 64 20 61 73 20 69 72 72 65 6c 65 76 61 6e 74 2c d as irrelevant,
7a00: 20 61 6c 6c 6f 77 69 6e 67 0a 09 23 20 20 20 20 allowing..#
7a10: 20 74 68 65 20 6e 6f 6d 69 6e 61 6c 20 72 6f 6f the nominal roo
7a20: 74 20 74 6f 20 62 65 20 6c 61 74 65 72 20 69 6e t to be later in
7a30: 20 74 69 6d 65 20 74 68 61 6e 20 74 68 65 20 4e time than the N
7a40: 54 44 42 0a 09 23 20 20 20 20 20 72 6f 6f 74 2e TDB..# root.
7a50: 20 4e 6f 77 20 73 65 74 74 69 6e 67 20 74 68 69 Now setting thi
7a60: 73 20 64 65 70 65 6e 64 65 6e 63 79 20 77 69 6c s dependency wil
7a70: 6c 20 62 65 20 62 61 63 6b 77 61 72 64 20 69 6e l be backward in
7a80: 0a 09 23 20 20 20 20 20 74 69 6d 65 2e 20 52 45 ..# time. RE
7a90: 4d 4f 56 45 44 2e 0a 09 23 0a 09 23 20 28 34 29 MOVED...#..# (4)
7aa0: 20 49 66 20 52 20 69 73 20 74 68 65 20 6c 61 73 If R is the las
7ab0: 74 20 6f 66 20 74 68 65 20 4e 54 44 42 20 72 65 t of the NTDB re
7ac0: 76 69 73 69 6f 6e 73 20 77 68 69 63 68 20 62 65 visions which be
7ad0: 6c 6f 6e 67 20 74 6f 0a 09 23 20 20 20 20 20 74 long to..# t
7ae0: 68 65 20 74 72 75 6e 6b 2c 20 74 68 65 6e 20 74 he trunk, then t
7af0: 68 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 he primary child
7b00: 20 6f 66 20 74 68 65 20 74 72 75 6e 6b 20 72 6f of the trunk ro
7b10: 6f 74 20 28 74 68 65 0a 09 23 20 20 20 20 20 27 ot (the..# '
7b20: 31 2e 32 27 20 72 65 76 69 73 69 6f 6e 29 20 69 1.2' revision) i
7b30: 73 20 61 20 73 75 63 63 65 73 73 6f 72 2c 20 69 s a successor, i
7b40: 66 20 69 74 20 65 78 69 73 74 73 2e 0a 0a 09 23 f it exists....#
7b50: 20 4e 6f 74 65 20 74 68 61 74 20 74 68 65 20 62 Note that the b
7b60: 72 61 6e 63 68 65 73 20 73 70 61 77 6e 65 64 20 ranches spawned
7b70: 66 72 6f 6d 20 74 68 65 20 72 65 76 69 73 69 6f from the revisio
7b80: 6e 73 2c 20 61 6e 64 20 74 68 65 0a 09 23 20 74 ns, and the..# t
7b90: 61 67 73 20 61 73 73 6f 63 69 61 74 65 64 20 77 ags associated w
7ba0: 69 74 68 20 74 68 65 6d 20 61 72 65 20 73 75 63 ith them are suc
7bb0: 63 65 73 73 6f 72 73 20 61 73 20 77 65 6c 6c 2e cessors as well.
7bc0: 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 ...foreach {rid
7bd0: 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75 child} [state ru
7be0: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d n [subst -nocomm
7bf0: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 ands -nobackslas
7c00: 68 65 73 20 7b 0a 20 20 20 2d 2d 20 28 31 29 20 hes {. -- (1)
7c10: 50 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 Primary child..
7c20: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c SELECT R.rid,
7c30: 20 52 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52 R.child.. FR
7c40: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a OM revision R.
7c50: 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 . WHERE R.ri
7c60: 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 d IN $theset
7c70: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 -- Restrict t
7c80: 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 o revisions of i
7c90: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 nterest.. AND
7ca0: 20 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e R.child IS N
7cb0: 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 OT NULL -- Ha
7cc0: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a s primary child.
7cd0: 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d UNION. --
7ce0: 20 28 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 (2) Secondary (
7cf0: 62 72 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e branch) children
7d00: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 .. SELECT R.r
7d10: 69 64 2c 20 42 2e 62 72 69 64 0a 09 20 20 20 20 id, B.brid..
7d20: 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 FROM revision
7d30: 52 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 R, revisionbranc
7d40: 68 63 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 hchildren B..
7d50: 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 WHERE R.rid
7d60: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d IN $theset -
7d70: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 - Restrict to re
7d80: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 visions of inter
7d90: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 est.. AND
7da0: 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 R.rid = B.rid
7db0: 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 -- Select
7dc0: 20 73 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 subset of branc
7dd0: 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 20 20 55 h children. U
7de0: 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20 NION. -- (4)
7df0: 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 Child of trunk r
7e00: 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66 oot successor of
7e10: 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 last NTDB on tr
7e20: 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 unk... SELECT
7e30: 20 52 2e 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 R.rid, RA.child
7e40: 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73 .. FROM revis
7e50: 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 ion R, revision
7e60: 52 41 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e RA.. WHERE R.
7e70: 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 rid IN $theset
7e80: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 -- Restric
7e90: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f t to revisions o
7ea0: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 f interest..
7eb0: 41 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75 6c AND R.isdefaul
7ec0: 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d t --
7ed0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 44 Restrict to NTD
7ee0: 42 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 64 B.. AND R.d
7ef0: 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 bchild IS NOT NU
7f00: 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74 LL -- and last
7f10: 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20 NTDB belonging
7f20: 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e to trunk.. AN
7f30: 44 20 20 20 52 41 2e 72 69 64 20 3d 20 52 2e 64 D RA.rid = R.d
7f40: 62 63 68 69 6c 64 20 20 20 20 20 20 2d 2d 20 47 bchild -- G
7f50: 6f 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 72 o directly to tr
7f60: 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e unk root.. AN
7f70: 44 20 20 20 52 41 2e 63 68 69 6c 64 20 49 53 20 D RA.child IS
7f80: 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 NOT NULL -- H
7f90: 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 as primary child
7fa0: 2e 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 23 20 ...}]] {.. #
7fb0: 43 6f 6e 73 69 64 65 72 20 6d 6f 76 69 6e 67 20 Consider moving
7fc0: 74 68 69 73 20 74 6f 20 74 68 65 20 69 6e 74 65 this to the inte
7fd0: 67 72 69 74 79 20 6d 6f 64 75 6c 65 2e 0a 09 20 grity module...
7fe0: 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 73 integrity ass
7ff0: 65 72 74 20 7b 24 72 69 64 20 21 3d 20 24 63 68 ert {$rid != $ch
8000: 69 6c 64 7d 20 7b 52 65 76 69 73 69 6f 6e 20 24 ild} {Revision $
8010: 72 69 64 20 64 65 70 65 6e 64 73 20 6f 6e 20 69 rid depends on i
8020: 74 73 65 6c 66 2e 7d 0a 09 20 20 20 20 6c 61 70 tself.}.. lap
8030: 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 pend dependencie
8040: 73 28 5b 6c 69 73 74 20 72 65 76 20 24 72 69 64 s([list rev $rid
8050: 5d 29 20 5b 6c 69 73 74 20 72 65 76 20 24 63 68 ]) [list rev $ch
8060: 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68 ild]..}..foreach
8070: 20 7b 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 {rid child} [st
8080: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d ate run [subst -
8090: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 nocommands -noba
80a0: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 ckslashes {..
80b0: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 54 SELECT R.rid, T
80c0: 2e 74 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 .tid.. FROM
80d0: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 74 61 67 revision R, tag
80e0: 20 54 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 T.. WHERE R
80f0: 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 0a .rid IN $theset.
8100: 09 20 20 20 20 41 4e 44 20 20 20 20 54 2e 72 65 . AND T.re
8110: 76 20 3d 20 52 2e 72 69 64 0a 09 7d 5d 5d 20 7b v = R.rid..}]] {
8120: 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 .. lappend de
8130: 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 pendencies([list
8140: 20 72 65 76 20 24 72 69 64 5d 29 20 5b 6c 69 73 rev $rid]) [lis
8150: 74 20 73 79 6d 3a 3a 74 61 67 20 24 63 68 69 6c t sym::tag $chil
8160: 64 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b d]..}..foreach {
8170: 72 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 rid child} [stat
8180: 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f e run [subst -no
8190: 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b commands -noback
81a0: 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 slashes {.. S
81b0: 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 ELECT R.rid, B.b
81c0: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 id.. FROM r
81d0: 65 76 69 73 69 6f 6e 20 52 2c 20 62 72 61 6e 63 evision R, branc
81e0: 68 20 42 0a 09 20 20 20 20 57 48 45 52 45 20 20 h B.. WHERE
81f0: 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 R.rid IN $theset
8200: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 .. AND B.r
8210: 6f 6f 74 20 3d 20 52 2e 72 69 64 0a 09 7d 5d 5d oot = R.rid..}]]
8220: 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 {.. lappend
8230: 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 dependencies([li
8240: 73 74 20 72 65 76 20 24 72 69 64 5d 29 20 5b 6c st rev $rid]) [l
8250: 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 ist sym::branch
8260: 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 72 65 74 75 $child]..}..retu
8270: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 rn. }.. #
8280: 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 63 result = list (c
8290: 68 61 6e 67 65 73 65 74 2d 69 64 29 0a 20 20 20 hangeset-id).
82a0: 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f 73 typemethod cs_s
82b0: 75 63 63 65 73 73 6f 72 73 20 7b 72 65 76 69 73 uccessors {revis
82c0: 69 6f 6e 73 7d 20 7b 0a 20 20 20 20 20 20 20 20 ions} {.
82d0: 23 20 54 68 69 73 20 69 73 20 61 20 76 61 72 69 # This is a vari
82e0: 61 6e 74 20 6f 66 20 27 73 75 63 63 65 73 73 6f ant of 'successo
82f0: 72 73 27 20 77 68 69 63 68 20 6d 61 70 73 20 74 rs' which maps t
8300: 68 65 20 6c 6f 77 2d 6c 65 76 65 6c 0a 20 20 20 he low-level.
8310: 20 20 20 20 20 23 20 64 61 74 61 20 64 69 72 65 # data dire
8320: 63 74 6c 79 20 74 6f 20 74 68 65 20 61 73 73 6f ctly to the asso
8330: 63 69 61 74 65 64 20 63 68 61 6e 67 65 73 65 74 ciated changeset
8340: 73 2e 20 49 2e 65 2e 20 69 6e 73 74 65 61 64 0a s. I.e. instead.
8350: 20 20 20 20 20 20 20 20 23 20 6d 69 6c 6c 69 6f # millio
8360: 6e 73 20 6f 66 20 64 65 70 65 6e 64 65 6e 63 79 ns of dependency
8370: 20 70 61 69 72 73 20 28 69 6e 20 65 78 74 72 65 pairs (in extre
8380: 6d 65 20 63 61 73 65 73 20 28 45 78 61 6d 70 6c me cases (Exampl
8390: 65 3a 20 54 63 6c 0a 20 20 20 20 20 20 20 20 23 e: Tcl. #
83a0: 20 43 56 53 29 29 20 77 65 20 72 65 74 75 72 6e CVS)) we return
83b0: 20 61 20 76 65 72 79 20 73 68 6f 72 74 20 61 6e a very short an
83c0: 64 20 6d 75 63 68 20 6d 6f 72 65 20 6d 61 6e 61 d much more mana
83d0: 67 65 61 62 6c 65 20 6c 69 73 74 0a 20 20 20 20 geable list.
83e0: 20 20 20 20 23 20 6f 66 20 63 68 61 6e 67 65 73 # of changes
83f0: 65 74 73 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 ets....set these
8400: 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 t ('[join $revis
8410: 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 ions {','}]')..r
8420: 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e eturn [state run
8430: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 [subst -nocomma
8440: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 nds -nobackslash
8450: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 es {.. SELECT
8460: 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d C.cid.. FROM
8470: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 63 revision R, c
8480: 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 sitem CI, change
8490: 73 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 set C.. WHERE
84a0: 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 R.rid IN $th
84b0: 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 eset -- Rest
84c0: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e rict to revision
84d0: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 s of interest..
84e0: 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c AND R.chil
84f0: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 d IS NOT NULL
8500: 20 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 -- Has primary
8510: 63 68 69 6c 64 0a 20 20 20 20 20 20 20 20 20 20 child.
8520: 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 AND CI.iid
8530: 3d 20 52 2e 63 68 69 6c 64 0a 20 20 20 20 20 20 = R.child.
8540: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 AND C.c
8550: 69 64 20 3d 20 43 49 2e 63 69 64 0a 20 20 20 20 id = CI.cid.
8560: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 AND C
8570: 2e 74 79 70 65 20 3d 20 30 0a 20 20 20 20 55 4e .type = 0. UN
8580: 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 ION.. SELECT
8590: 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 C.cid.. FROM
85a0: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 revision R, re
85b0: 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c visionbranchchil
85c0: 64 72 65 6e 20 42 2c 20 63 73 69 74 65 6d 20 43 dren B, csitem C
85d0: 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 I, changeset C..
85e0: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 WHERE R.rid
85f0: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 IN $theset
8600: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f -- Restrict to
8610: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e revisions of in
8620: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 terest.. AND
8630: 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 R.rid = B.rid
8640: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c -- Sel
8650: 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62 72 ect subset of br
8660: 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 anch children.
8670: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
8680: 20 43 49 2e 69 69 64 20 3d 20 42 2e 62 72 69 64 CI.iid = B.brid
8690: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 . AND
86a0: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 C.cid = CI.c
86b0: 69 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 id. A
86c0: 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30 ND C.type = 0
86d0: 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 . UNION..
86e0: 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 SELECT C.cid..
86f0: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f FROM revisio
8700: 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 n R, revision RA
8710: 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 , csitem CI, cha
8720: 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 ngeset C.. WH
8730: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 ERE R.rid IN
8740: 24 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 $theset --
8750: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 Restrict to revi
8760: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 sions of interes
8770: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e t.. AND R.
8780: 69 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 isdefault
8790: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 -- Restric
87a0: 74 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 t to NTDB.. A
87b0: 4e 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 ND R.dbchild
87c0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d IS NOT NULL --
87d0: 20 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 and last NTDB b
87e0: 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e elonging to trun
87f0: 6b 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 k.. AND RA
8800: 2e 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 .rid = R.dbchild
8810: 20 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 -- Go dire
8820: 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f ctly to trunk ro
8830: 6f 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 ot.. AND R
8840: 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e A.child IS NOT N
8850: 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 ULL -- Has pr
8860: 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 20 20 20 imary child..
8870: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 AND
8880: 43 49 2e 69 69 64 20 3d 20 52 41 2e 63 68 69 6c CI.iid = RA.chil
8890: 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e d. AN
88a0: 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e D C.cid = CI.
88b0: 63 69 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 cid.
88c0: 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 AND C.type =
88d0: 30 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 0. UNION..
88e0: 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 SELECT C.cid..
88f0: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 FROM revisi
8900: 6f 6e 20 52 2c 20 74 61 67 20 54 2c 20 63 73 69 on R, tag T, csi
8910: 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 tem CI, changese
8920: 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 t C.. WHERE
8930: 52 2e 72 69 64 20 69 6e 20 24 74 68 65 73 65 74 R.rid in $theset
8940: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 54 2e 72 .. AND T.r
8950: 65 76 20 3d 20 52 2e 72 69 64 0a 20 20 20 20 20 ev = R.rid.
8960: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49 AND CI
8970: 2e 69 69 64 20 3d 20 54 2e 74 69 64 0a 20 20 20 .iid = T.tid.
8980: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 AND
8990: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 0a 20 C.cid = CI.cid.
89a0: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 AND
89b0: 20 20 43 2e 74 79 70 65 20 3d 20 31 0a 20 20 20 C.type = 1.
89c0: 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 UNION.. SELE
89d0: 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 CT C.cid.. FR
89e0: 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c OM revision R,
89f0: 20 62 72 61 6e 63 68 20 42 2c 20 63 73 69 74 65 branch B, csite
8a00: 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 m CI, changeset
8a10: 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e C.. WHERE R.
8a20: 72 69 64 20 69 6e 20 24 74 68 65 73 65 74 0a 09 rid in $theset..
8a30: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 6f 6f AND B.roo
8a40: 74 20 3d 20 52 2e 72 69 64 0a 20 20 20 20 20 20 t = R.rid.
8a50: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e AND CI.
8a60: 69 69 64 20 3d 20 42 2e 62 69 64 0a 20 20 20 20 iid = B.bid.
8a70: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 AND C
8a80: 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 0a 20 20 .cid = CI.cid.
8a90: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
8aa0: 20 43 2e 74 79 70 65 20 3d 20 32 0a 09 7d 5d 5d C.type = 2..}]]
8ab0: 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 . }.}..# # ##
8ac0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
8ad0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
8ae0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 # ##############
8af0: 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65 #######.## Helpe
8b00: 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d r singleton. Com
8b10: 6d 61 6e 64 73 20 66 6f 72 20 74 61 67 20 73 79 mands for tag sy
8b20: 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 2e mbol changesets.
8b30: 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 ..snit::type ::v
8b40: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 c::fossil::impor
8b50: 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a t::cvs::project:
8b60: 3a 72 65 76 3a 3a 73 79 6d 3a 3a 74 61 67 20 7b :rev::sym::tag {
8b70: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
8b80: 62 79 72 65 76 69 73 69 6f 6e 20 7b 7d 20 7b 20 byrevision {} {
8b90: 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 74 return 0 }. t
8ba0: 79 70 65 6d 65 74 68 6f 64 20 62 79 73 79 6d 62 ypemethod bysymb
8bb0: 6f 6c 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e ol {} { return
8bc0: 20 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 1 }. typemet
8bd0: 68 6f 64 20 69 73 74 61 67 20 20 20 20 20 20 7b hod istag {
8be0: 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20 } { return 1 }.
8bf0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 typemethod is
8c00: 62 72 61 6e 63 68 20 20 20 7b 7d 20 7b 20 72 65 branch {} { re
8c10: 74 75 72 6e 20 30 20 7d 0a 0a 20 20 20 20 74 79 turn 0 }.. ty
8c20: 70 65 6d 65 74 68 6f 64 20 73 74 72 20 7b 74 61 pemethod str {ta
8c30: 67 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 g} {..struct::li
8c40: 73 74 20 61 73 73 69 67 6e 20 5b 73 74 61 74 65 st assign [state
8c50: 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 run {.. SELE
8c60: 43 54 20 53 2e 6e 61 6d 65 2c 20 46 2e 6e 61 6d CT S.name, F.nam
8c70: 65 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20 20 46 e, P.name.. F
8c80: 52 4f 4d 20 20 20 74 61 67 20 54 2c 20 73 79 6d ROM tag T, sym
8c90: 62 6f 6c 20 53 2c 20 66 69 6c 65 20 46 2c 20 70 bol S, file F, p
8ca0: 72 6f 6a 65 63 74 20 50 0a 09 20 20 20 20 57 48 roject P.. WH
8cb0: 45 52 45 20 20 54 2e 74 69 64 20 3d 20 24 74 61 ERE T.tid = $ta
8cc0: 67 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46 2e g.. AND F.
8cd0: 66 69 64 20 3d 20 54 2e 66 69 64 0a 09 20 20 20 fid = T.fid..
8ce0: 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20 3d 20 AND P.pid =
8cf0: 46 2e 70 69 64 0a 09 20 20 20 20 41 4e 44 20 20 F.pid.. AND
8d00: 20 20 53 2e 73 69 64 20 3d 20 54 2e 73 69 64 0a S.sid = T.sid.
8d10: 09 7d 5d 20 73 6e 61 6d 65 20 66 6e 61 6d 65 20 .}] sname fname
8d20: 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20 22 24 pname..return "$
8d30: 70 6e 61 6d 65 2f 54 27 24 7b 73 6e 61 6d 65 7d pname/T'${sname}
8d40: 27 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20 20 7d '::$fname". }
8d50: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d .. # result =
8d60: 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20 list (mintime,
8d70: 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74 79 70 maxtime). typ
8d80: 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61 6e 67 emethod timerang
8d90: 65 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20 54 68 e {tags} {..# Th
8da0: 65 20 72 61 6e 67 65 20 69 73 20 64 65 66 69 6e e range is defin
8db0: 65 64 20 61 73 20 74 68 65 20 72 61 6e 67 65 20 ed as the range
8dc0: 6f 66 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 of the revisions
8dd0: 20 74 68 65 20 74 61 67 73 0a 09 23 20 61 72 65 the tags..# are
8de0: 20 61 74 74 61 63 68 65 64 20 74 6f 2e 0a 0a 09 attached to....
8df0: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f set theset ('[jo
8e00: 69 6e 20 24 74 61 67 73 20 7b 27 2c 27 7d 5d 27 in $tags {','}]'
8e10: 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 )..return [state
8e20: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 run [subst -noc
8e30: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 ommands -nobacks
8e40: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 lashes {.. SE
8e50: 4c 45 43 54 20 4d 49 4e 28 52 2e 64 61 74 65 29 LECT MIN(R.date)
8e60: 2c 20 4d 41 58 28 52 2e 64 61 74 65 29 0a 09 20 , MAX(R.date)..
8e70: 20 20 20 46 52 4f 4d 20 20 20 74 61 67 20 54 2c FROM tag T,
8e80: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 revision R..
8e90: 20 57 48 45 52 45 20 20 54 2e 74 69 64 20 49 4e WHERE T.tid IN
8ea0: 20 24 74 68 65 73 65 74 0a 20 20 20 20 20 20 20 $theset.
8eb0: 20 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72 69 AND R.ri
8ec0: 64 20 3d 20 54 2e 72 65 76 0a 09 7d 5d 5d 0a 20 d = T.rev..}]].
8ed0: 20 20 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 }.. # var(
8ee0: 64 76 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d dv) = dict (item
8ef0: 20 2d 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 -> list (item))
8f00: 2c 20 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 , item = list (
8f10: 74 79 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 type id). typ
8f20: 65 6d 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f emethod successo
8f30: 72 73 20 7b 64 76 20 74 61 67 73 7d 20 7b 0a 09 rs {dv tags} {..
8f40: 23 20 54 61 67 73 20 68 61 76 65 20 6e 6f 20 73 # Tags have no s
8f50: 75 63 63 65 73 73 6f 72 73 2e 0a 09 72 65 74 75 uccessors...retu
8f60: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 rn. }.. #
8f70: 72 65 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 result = 4-list
8f80: 28 69 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 (itemtype itemid
8f90: 20 6e 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 nextitemtype ne
8fa0: 78 74 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 xtitemid ...).
8fb0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f typemethod loo
8fc0: 70 73 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20 54 ps {tags} {..# T
8fd0: 61 67 73 20 68 61 76 65 20 6e 6f 20 73 75 63 63 ags have no succ
8fe0: 65 73 73 6f 72 73 2c 20 74 68 65 72 65 66 6f 72 essors, therefor
8ff0: 65 20 63 61 6e 6e 6f 74 20 63 61 75 73 65 20 6c e cannot cause l
9000: 6f 6f 70 73 0a 09 72 65 74 75 72 6e 20 7b 7d 0a oops..return {}.
9010: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 }.. # res
9020: 75 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e ult = list (chan
9030: 67 65 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79 geset-id). ty
9040: 70 65 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63 pemethod cs_succ
9050: 65 73 73 6f 72 73 20 7b 74 61 67 73 7d 20 7b 0a essors {tags} {.
9060: 09 23 20 54 61 67 73 20 68 61 76 65 20 6e 6f 20 .# Tags have no
9070: 73 75 63 63 65 73 73 6f 72 73 2e 0a 09 72 65 74 successors...ret
9080: 75 72 6e 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 urn. }.}..# #
9090: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 ## ### ##### ##
90a0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
90b0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
90c0: 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 48 65 ##########.## He
90d0: 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 lper singleton.
90e0: 43 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 62 72 61 Commands for bra
90f0: 6e 63 68 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 nch symbol chang
9100: 65 73 65 74 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 esets...snit::ty
9110: 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a pe ::vc::fossil:
9120: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 :import::cvs::pr
9130: 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a 73 79 6d 3a oject::rev::sym:
9140: 3a 62 72 61 6e 63 68 20 7b 0a 20 20 20 20 74 79 :branch {. ty
9150: 70 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 pemethod byrevis
9160: 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 ion {} { return
9170: 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 0 }. typemeth
9180: 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d od bysymbol {}
9190: 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20 20 { return 1 }.
91a0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74 typemethod ist
91b0: 61 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 ag {} { ret
91c0: 75 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 65 urn 0 }. type
91d0: 6d 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20 method isbranch
91e0: 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 {} { return 1
91f0: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f }.. typemetho
9200: 64 20 73 74 72 20 7b 62 72 61 6e 63 68 7d 20 7b d str {branch} {
9210: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 ..struct::list a
9220: 73 73 69 67 6e 20 5b 73 74 61 74 65 20 72 75 6e ssign [state run
9230: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 53 {.. SELECT S
9240: 2e 6e 61 6d 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 .name, F.name, P
9250: 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 .name.. FROM
9260: 20 20 62 72 61 6e 63 68 20 42 2c 20 73 79 6d 62 branch B, symb
9270: 6f 6c 20 53 2c 20 66 69 6c 65 20 46 2c 20 70 72 ol S, file F, pr
9280: 6f 6a 65 63 74 20 50 0a 09 20 20 20 20 57 48 45 oject P.. WHE
9290: 52 45 20 20 42 2e 62 69 64 20 3d 20 24 62 72 61 RE B.bid = $bra
92a0: 6e 63 68 0a 09 20 20 20 20 41 4e 44 20 20 20 20 nch.. AND
92b0: 46 2e 66 69 64 20 3d 20 42 2e 66 69 64 0a 09 20 F.fid = B.fid..
92c0: 20 20 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20 AND P.pid
92d0: 3d 20 46 2e 70 69 64 0a 09 20 20 20 20 41 4e 44 = F.pid.. AND
92e0: 20 20 20 20 53 2e 73 69 64 20 3d 20 42 2e 73 69 S.sid = B.si
92f0: 64 0a 09 7d 5d 20 73 6e 61 6d 65 20 66 6e 61 6d d..}] sname fnam
9300: 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20 e pname..return
9310: 22 24 70 6e 61 6d 65 2f 42 27 24 7b 73 6e 61 6d "$pname/B'${snam
9320: 65 7d 27 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20 e}'::$fname".
9330: 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 }.. # result
9340: 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65 = list (mintime
9350: 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74 , maxtime). t
9360: 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61 ypemethod timera
9370: 6e 67 65 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b nge {branches} {
9380: 0a 09 23 20 54 68 65 20 72 61 6e 67 65 20 6f 66 ..# The range of
9390: 20 61 20 62 72 61 6e 63 68 20 69 73 20 64 65 66 a branch is def
93a0: 69 6e 65 64 20 61 73 20 74 68 65 20 72 61 6e 67 ined as the rang
93b0: 65 20 6f 66 20 74 68 65 0a 09 23 20 72 65 76 69 e of the..# revi
93c0: 73 69 6f 6e 73 20 74 68 65 20 62 72 61 6e 63 68 sions the branch
93d0: 65 73 20 61 72 65 20 73 70 61 77 6e 65 64 20 62 es are spawned b
93e0: 79 2e 20 4e 4f 54 45 20 68 6f 77 65 76 65 72 20 y. NOTE however
93f0: 74 68 61 74 20 74 68 65 0a 09 23 20 62 72 61 6e that the..# bran
9400: 63 68 65 73 20 61 73 73 6f 63 69 61 74 65 64 20 ches associated
9410: 77 69 74 68 20 61 20 64 65 74 61 63 68 65 64 20 with a detached
9420: 4e 54 44 42 20 77 69 6c 6c 20 68 61 76 65 20 6e NTDB will have n
9430: 6f 20 72 6f 6f 74 0a 09 23 20 73 70 61 77 6e 69 o root..# spawni
9440: 6e 67 20 74 68 65 6d 2c 20 68 65 6e 63 65 20 74 ng them, hence t
9450: 68 65 79 20 68 61 76 65 20 6e 6f 20 72 65 61 6c hey have no real
9460: 20 74 69 6d 65 72 61 6e 67 65 20 61 6e 79 0a 09 timerange any..
9470: 23 20 6c 6f 6e 67 65 72 2e 20 42 79 20 75 73 69 # longer. By usi
9480: 6e 67 20 30 20 77 65 20 70 75 74 20 74 68 65 6d ng 0 we put them
9490: 20 69 6e 20 66 72 6f 6e 74 20 6f 66 20 65 76 65 in front of eve
94a0: 72 79 74 68 69 6e 67 20 65 6c 73 65 2c 0a 09 23 rything else,..#
94b0: 20 61 73 20 74 68 65 79 20 6c 6f 67 69 63 61 6c as they logical
94c0: 6c 79 20 61 72 65 2e 0a 0a 09 73 65 74 20 74 68 ly are....set th
94d0: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 eset ('[join $br
94e0: 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a anches {','}]').
94f0: 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 .return [state r
9500: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d un [subst -nocom
9510: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
9520: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 shes {.. SELE
9530: 43 54 20 49 46 4e 55 4c 4c 28 4d 49 4e 28 52 2e CT IFNULL(MIN(R.
9540: 64 61 74 65 29 2c 30 29 2c 20 49 46 4e 55 4c 4c date),0), IFNULL
9550: 28 4d 41 58 28 52 2e 64 61 74 65 29 2c 30 29 0a (MAX(R.date),0).
9560: 09 20 20 20 20 46 52 4f 4d 20 20 62 72 61 6e 63 . FROM branc
9570: 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a h B, revision R.
9580: 09 20 20 20 20 57 48 45 52 45 20 42 2e 62 69 64 . WHERE B.bid
9590: 20 49 4e 20 24 74 68 65 73 65 74 0a 20 20 20 20 IN $theset.
95a0: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 52 2e AND R.
95b0: 72 69 64 20 3d 20 42 2e 72 6f 6f 74 0a 09 7d 5d rid = B.root..}]
95c0: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 ]. }.. # r
95d0: 65 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28 esult = 4-list (
95e0: 69 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 20 itemtype itemid
95f0: 6e 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 78 nextitemtype nex
9600: 74 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 titemid ...).
9610: 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 typemethod loop
9620: 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 s {branches} {..
9630: 23 20 4e 6f 74 65 3a 20 52 65 76 69 73 69 6f 6e # Note: Revision
9640: 73 20 61 6e 64 20 74 61 67 73 20 63 61 6e 6e 6f s and tags canno
9650: 74 20 63 61 75 73 65 20 74 68 65 20 6c 6f 6f 70 t cause the loop
9660: 2e 20 42 65 69 6e 67 20 6f 66 20 61 0a 09 23 20 . Being of a..#
9670: 66 75 6e 64 61 6d 65 6e 74 61 6c 6c 79 20 64 69 fundamentally di
9680: 66 66 65 72 65 6e 74 20 74 79 70 65 20 74 68 65 fferent type the
9690: 79 20 63 61 6e 6e 6f 74 20 62 65 20 69 6e 20 74 y cannot be in t
96a0: 68 65 20 69 6e 63 6f 6d 69 6e 67 0a 09 23 20 73 he incoming..# s
96b0: 65 74 20 6f 66 20 69 64 73 2e 0a 0a 09 73 65 74 et of ids....set
96c0: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 theset ('[join
96d0: 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d $branches {','}]
96e0: 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 ')..return [stat
96f0: 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f e run [subst -no
9700: 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b commands -noback
9710: 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 slashes {.. S
9720: 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 58 2e ELECT B.bid, BX.
9730: 62 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 bid.. FROM
9740: 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72 branch B, prefer
9750: 65 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61 6e edparent P, bran
9760: 63 68 20 42 58 0a 09 20 20 20 20 57 48 45 52 45 ch BX.. WHERE
9770: 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 B.bid IN $thes
9780: 65 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 et.. AND B
9790: 2e 73 69 64 20 3d 20 50 2e 70 69 64 0a 09 20 20 .sid = P.pid..
97a0: 20 20 41 4e 44 20 20 20 20 42 58 2e 73 69 64 20 AND BX.sid
97b0: 3d 20 50 2e 73 69 64 0a 09 20 20 20 20 41 4e 44 = P.sid.. AND
97c0: 20 20 20 20 42 58 2e 62 69 64 20 49 4e 20 24 74 BX.bid IN $t
97d0: 68 65 73 65 74 0a 09 7d 5d 5d 0a 20 20 20 20 7d heset..}]]. }
97e0: 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 29 20 .. # var(dv)
97f0: 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d 3e 20 = dict (item ->
9800: 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20 69 74 list (item)), it
9810: 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79 70 65 em = list (type
9820: 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74 id). typemet
9830: 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73 20 7b hod successors {
9840: 64 76 20 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 dv branches} {..
9850: 75 70 76 61 72 20 31 20 24 64 76 20 64 65 70 65 upvar 1 $dv depe
9860: 6e 64 65 6e 63 69 65 73 0a 09 23 20 54 68 65 20 ndencies..# The
9870: 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 63 first revision c
9880: 6f 6d 6d 69 74 74 65 64 20 6f 6e 20 61 20 62 72 ommitted on a br
9890: 61 6e 63 68 2c 20 61 6e 64 20 61 6c 6c 20 62 72 anch, and all br
98a0: 61 6e 63 68 65 73 0a 09 23 20 61 6e 64 20 74 61 anches..# and ta
98b0: 67 73 20 77 68 69 63 68 20 68 61 76 65 20 69 74 gs which have it
98c0: 20 61 73 20 74 68 65 69 72 20 70 72 65 66 65 72 as their prefer
98d0: 65 64 20 70 61 72 65 6e 74 20 61 72 65 20 74 68 ed parent are th
98e0: 65 0a 09 23 20 73 75 63 63 65 73 73 6f 72 73 20 e..# successors
98f0: 6f 66 20 61 20 62 72 61 6e 63 68 2e 0a 0a 09 73 of a branch....s
9900: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 et theset ('[joi
9910: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 n $branches {','
9920: 7d 5d 27 29 0a 09 66 6f 72 65 61 63 68 20 7b 62 }]')..foreach {b
9930: 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 id child} [state
9940: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 run [subst -noc
9950: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 ommands -nobacks
9960: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 lashes {.. SE
9970: 4c 45 43 54 20 42 2e 62 69 64 2c 20 52 2e 72 69 LECT B.bid, R.ri
9980: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 d.. FROM br
9990: 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e anch B, revision
99a0: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 R.. WHERE B
99b0: 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 0a .bid IN $theset.
99c0: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 66 69 . AND B.fi
99d0: 72 73 74 20 3d 20 52 2e 72 69 64 0a 09 7d 5d 5d rst = R.rid..}]]
99e0: 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 {.. lappend
99f0: 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 dependencies([li
9a00: 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 st sym::branch $
9a10: 62 69 64 5d 29 20 5b 6c 69 73 74 20 72 65 76 20 bid]) [list rev
9a20: 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 6f 72 65 $child]..}..fore
9a30: 61 63 68 20 7b 62 69 64 20 63 68 69 6c 64 7d 20 ach {bid child}
9a40: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 [state run [subs
9a50: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e t -nocommands -n
9a60: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 obackslashes {..
9a70: 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 SELECT B.bid
9a80: 2c 20 42 58 2e 62 69 64 0a 09 20 20 20 20 46 52 , BX.bid.. FR
9a90: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70 OM branch B, p
9aa0: 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c referedparent P,
9ab0: 20 62 72 61 6e 63 68 20 42 58 0a 09 20 20 20 20 branch BX..
9ac0: 57 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 WHERE B.bid IN
9ad0: 24 74 68 65 73 65 74 0a 09 20 20 20 20 41 4e 44 $theset.. AND
9ae0: 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 B.sid = P.pi
9af0: 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 58 d.. AND BX
9b00: 2e 73 69 64 20 3d 20 50 2e 73 69 64 0a 09 7d 5d .sid = P.sid..}]
9b10: 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 ] {.. lappend
9b20: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c dependencies([l
9b30: 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 ist sym::branch
9b40: 24 62 69 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d $bid]) [list sym
9b50: 3a 3a 62 72 61 6e 63 68 20 24 63 68 69 6c 64 5d ::branch $child]
9b60: 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b 62 69 ..}..foreach {bi
9b70: 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 d child} [state
9b80: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f run [subst -noco
9b90: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c mmands -nobacksl
9ba0: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c ashes {.. SEL
9bb0: 45 43 54 20 42 2e 62 69 64 2c 20 54 2e 74 69 64 ECT B.bid, T.tid
9bc0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 .. FROM bra
9bd0: 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 70 nch B, preferedp
9be0: 61 72 65 6e 74 20 50 2c 20 74 61 67 20 54 0a 09 arent P, tag T..
9bf0: 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 WHERE B.bid
9c00: 20 49 4e 20 24 74 68 65 73 65 74 0a 09 20 20 20 IN $theset..
9c10: 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 AND B.sid =
9c20: 50 2e 70 69 64 0a 09 20 20 20 20 41 4e 44 20 20 P.pid.. AND
9c30: 20 20 54 2e 73 69 64 20 3d 20 50 2e 73 69 64 0a T.sid = P.sid.
9c40: 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 .}]] {.. lapp
9c50: 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 end dependencies
9c60: 28 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e ([list sym::bran
9c70: 63 68 20 24 62 69 64 5d 29 20 5b 6c 69 73 74 20 ch $bid]) [list
9c80: 73 79 6d 3a 3a 74 61 67 20 24 63 68 69 6c 64 5d sym::tag $child]
9c90: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 ..}..return.
9ca0: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 }.. # result
9cb0: 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 65 73 65 = list (changese
9cc0: 74 2d 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65 t-id). typeme
9cd0: 74 68 6f 64 20 63 73 5f 73 75 63 63 65 73 73 6f thod cs_successo
9ce0: 72 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a rs {branches} {.
9cf0: 20 20 20 20 20 20 20 20 23 20 54 68 69 73 20 69 # This i
9d00: 73 20 61 20 76 61 72 69 61 6e 74 20 6f 66 20 27 s a variant of '
9d10: 73 75 63 63 65 73 73 6f 72 73 27 20 77 68 69 63 successors' whic
9d20: 68 20 6d 61 70 73 20 74 68 65 20 6c 6f 77 2d 6c h maps the low-l
9d30: 65 76 65 6c 0a 20 20 20 20 20 20 20 20 23 20 64 evel. # d
9d40: 61 74 61 20 64 69 72 65 63 74 6c 79 20 74 6f 20 ata directly to
9d50: 74 68 65 20 61 73 73 6f 63 69 61 74 65 64 20 63 the associated c
9d60: 68 61 6e 67 65 73 65 74 73 2e 20 49 2e 65 2e 20 hangesets. I.e.
9d70: 69 6e 73 74 65 61 64 0a 20 20 20 20 20 20 20 20 instead.
9d80: 23 20 6d 69 6c 6c 69 6f 6e 73 20 6f 66 20 64 65 # millions of de
9d90: 70 65 6e 64 65 6e 63 79 20 70 61 69 72 73 20 28 pendency pairs (
9da0: 69 6e 20 65 78 74 72 65 6d 65 20 63 61 73 65 73 in extreme cases
9db0: 20 28 45 78 61 6d 70 6c 65 3a 20 54 63 6c 0a 20 (Example: Tcl.
9dc0: 20 20 20 20 20 20 20 23 20 43 56 53 29 29 20 77 # CVS)) w
9dd0: 65 20 72 65 74 75 72 6e 20 61 20 76 65 72 79 20 e return a very
9de0: 73 68 6f 72 74 20 61 6e 64 20 6d 75 63 68 20 6d short and much m
9df0: 6f 72 65 20 6d 61 6e 61 67 65 61 62 6c 65 20 6c ore manageable l
9e00: 69 73 74 0a 20 20 20 20 20 20 20 20 23 20 6f 66 ist. # of
9e10: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09 73 changesets....s
9e20: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 et theset ('[joi
9e30: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 n $branches {','
9e40: 7d 5d 27 29 0a 20 20 20 20 20 20 20 20 72 65 74 }]'). ret
9e50: 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b urn [state run [
9e60: 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 subst -nocommand
9e70: 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 s -nobackslashes
9e80: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 {.. SELECT C
9e90: 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 .cid.. FROM
9ea0: 20 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73 branch B, revis
9eb0: 69 6f 6e 20 52 2c 20 63 73 69 74 65 6d 20 43 49 ion R, csitem CI
9ec0: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20 , changeset C..
9ed0: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 WHERE B.bid
9ee0: 49 4e 20 24 74 68 65 73 65 74 0a 09 20 20 20 20 IN $theset..
9ef0: 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20 3d AND B.first =
9f00: 20 52 2e 72 69 64 0a 20 20 20 20 20 20 20 20 20 R.rid.
9f10: 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 AND CI.iid
9f20: 20 3d 20 52 2e 72 69 64 0a 20 20 20 20 20 20 20 = R.rid.
9f30: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 AND C.ci
9f40: 64 20 3d 20 43 49 2e 63 69 64 0a 20 20 20 20 20 d = CI.cid.
9f50: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e AND C.
9f60: 74 79 70 65 20 3d 20 30 0a 20 20 20 20 55 4e 49 type = 0. UNI
9f70: 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 ON.. SELECT C
9f80: 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 .cid.. FROM
9f90: 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 branch B, prefe
9fa0: 72 65 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61 redparent P, bra
9fb0: 6e 63 68 20 42 58 2c 20 63 73 69 74 65 6d 20 43 nch BX, csitem C
9fc0: 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 I, changeset C..
9fd0: 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 WHERE B.bid
9fe0: 20 49 4e 20 24 74 68 65 73 65 74 0a 09 20 20 20 IN $theset..
9ff0: 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 AND B.sid =
a000: 50 2e 70 69 64 0a 09 20 20 20 20 41 4e 44 20 20 P.pid.. AND
a010: 20 20 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 64 BX.sid = P.sid
a020: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 . AND
a030: 20 20 20 20 43 49 2e 69 69 64 20 3d 20 42 58 2e CI.iid = BX.
a040: 62 69 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 bid.
a050: 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 AND C.cid = C
a060: 49 2e 63 69 64 0a 20 20 20 20 20 20 20 20 20 20 I.cid.
a070: 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 AND C.type
a080: 3d 20 32 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 = 2. UNION..
a090: 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a SELECT C.cid.
a0a0: 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e . FROM bran
a0b0: 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 70 61 ch B, preferedpa
a0c0: 72 65 6e 74 20 50 2c 20 74 61 67 20 54 2c 20 63 rent P, tag T, c
a0d0: 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 sitem CI, change
a0e0: 73 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 set C.. WHERE
a0f0: 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 B.bid IN $thes
a100: 65 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 et.. AND B
a110: 2e 73 69 64 20 3d 20 50 2e 70 69 64 0a 09 20 20 .sid = P.pid..
a120: 20 20 41 4e 44 20 20 20 20 54 2e 73 69 64 20 3d AND T.sid =
a130: 20 50 2e 73 69 64 0a 20 20 20 20 20 20 20 20 20 P.sid.
a140: 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 AND CI.iid
a150: 20 3d 20 54 2e 74 69 64 0a 20 20 20 20 20 20 20 = T.tid.
a160: 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 AND C.ci
a170: 64 20 3d 20 43 49 2e 63 69 64 0a 20 20 20 20 20 d = CI.cid.
a180: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e AND C.
a190: 74 79 70 65 20 3d 20 31 0a 09 7d 5d 5d 0a 09 72 type = 1..}]]..r
a1a0: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
a1b0: 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 69 6d 69 typemethod limi
a1c0: 74 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a ts {branches} {.
a1d0: 09 23 20 4e 6f 74 65 73 2e 20 54 68 69 73 20 6d .# Notes. This m
a1e0: 65 74 68 6f 64 20 65 78 69 73 74 73 20 6f 6e 6c ethod exists onl
a1f0: 79 20 66 6f 72 20 62 72 61 6e 63 68 65 73 2e 20 y for branches.
a200: 49 74 20 69 73 20 6e 65 65 64 65 64 20 74 6f 0a It is needed to.
a210: 09 23 20 67 65 74 20 64 65 74 61 69 6c 65 64 20 .# get detailed
a220: 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 information abou
a230: 74 20 61 20 62 61 63 6b 77 61 72 64 20 62 72 61 t a backward bra
a240: 6e 63 68 2e 20 49 74 20 64 6f 65 73 0a 09 23 20 nch. It does..#
a250: 6e 6f 74 20 61 70 70 6c 79 20 74 6f 20 74 61 67 not apply to tag
a260: 73 2c 20 6e 6f 72 20 72 65 76 69 73 69 6f 6e 73 s, nor revisions
a270: 2e 20 54 68 65 20 71 75 65 72 69 65 73 20 63 61 . The queries ca
a280: 6e 20 61 6c 73 6f 0a 09 23 20 72 65 73 74 72 69 n also..# restri
a290: 63 74 20 74 68 65 6d 73 65 6c 76 65 73 20 74 6f ct themselves to
a2a0: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 73 75 the revision su
a2b0: 63 65 73 73 6f 72 73 2f 70 72 65 64 65 63 65 73 cessors/predeces
a2c0: 73 6f 72 73 0a 09 23 20 6f 66 20 62 72 61 6e 63 sors..# of branc
a2d0: 68 65 73 2c 20 61 73 20 6f 6e 6c 79 20 74 68 65 hes, as only the
a2e0: 79 20 68 61 76 65 20 6f 72 64 65 72 69 6e 67 20 y have ordering
a2f0: 64 61 74 61 20 61 6e 64 20 74 68 75 73 20 63 61 data and thus ca
a300: 6e 0a 09 23 20 63 61 75 73 65 20 74 68 65 20 62 n..# cause the b
a310: 61 63 6b 77 61 72 64 6e 65 73 73 2e 0a 0a 09 73 ackwardness....s
a320: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 et theset ('[joi
a330: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 n $branches {','
a340: 7d 5d 27 29 0a 0a 09 73 65 74 20 6d 61 78 70 20 }]')...set maxp
a350: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 [state run [subs
a360: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e t -nocommands -n
a370: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 obackslashes {..
a380: 20 20 20 20 2d 2d 20 6d 61 78 69 6d 61 6c 20 70 -- maximal p
a390: 72 65 64 65 63 65 73 73 6f 72 20 70 6f 73 69 74 redecessor posit
a3a0: 69 6f 6e 20 70 65 72 20 62 72 61 6e 63 68 0a 09 ion per branch..
a3b0: 20 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 SELECT B.bid
a3c0: 2c 20 4d 41 58 20 28 43 4f 2e 70 6f 73 29 0a 09 , MAX (CO.pos)..
a3d0: 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 FROM branc
a3e0: 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c h B, revision R,
a3f0: 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e csitem CI, chan
a400: 67 65 73 65 74 20 43 2c 20 63 73 6f 72 64 65 72 geset C, csorder
a410: 20 43 4f 0a 09 20 20 20 20 57 48 45 52 45 20 20 CO.. WHERE
a420: 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 B.bid IN $theset
a430: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 .. AND B.r
a440: 6f 6f 74 20 3d 20 52 2e 72 69 64 0a 09 20 20 20 oot = R.rid..
a450: 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d AND CI.iid =
a460: 20 52 2e 72 69 64 0a 09 20 20 20 20 41 4e 44 20 R.rid.. AND
a470: 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 C.cid = CI.ci
a480: 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 2e d.. AND C.
a490: 74 79 70 65 20 3d 20 30 0a 09 20 20 20 20 41 4e type = 0.. AN
a4a0: 44 20 20 20 20 43 4f 2e 63 69 64 20 3d 20 43 2e D CO.cid = C.
a4b0: 63 69 64 0a 09 20 20 20 20 47 52 4f 55 50 20 42 cid.. GROUP B
a4c0: 59 20 42 2e 62 69 64 0a 09 7d 5d 5d 0a 0a 09 73 Y B.bid..}]]...s
a4d0: 65 74 20 6d 69 6e 73 20 5b 73 74 61 74 65 20 72 et mins [state r
a4e0: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d un [subst -nocom
a4f0: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
a500: 73 68 65 73 20 7b 0a 09 20 20 20 20 2d 2d 20 6d shes {.. -- m
a510: 69 6e 69 6d 61 6c 20 73 75 63 63 65 73 73 6f 72 inimal successor
a520: 20 70 6f 73 69 74 69 6f 6e 20 70 65 72 20 62 72 position per br
a530: 61 6e 63 68 0a 09 20 20 20 20 53 45 4c 45 43 54 anch.. SELECT
a540: 20 42 2e 62 69 64 2c 20 4d 49 4e 20 28 43 4f 2e B.bid, MIN (CO.
a550: 70 6f 73 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 pos).. FROM
a560: 20 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73 branch B, revis
a570: 69 6f 6e 20 52 2c 20 63 73 69 74 65 6d 20 43 49 ion R, csitem CI
a580: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 , changeset C, c
a590: 73 6f 72 64 65 72 20 43 4f 0a 09 20 20 20 20 57 sorder CO.. W
a5a0: 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 HERE B.bid IN $
a5b0: 74 68 65 73 65 74 0a 09 20 20 20 20 41 4e 44 20 theset.. AND
a5c0: 20 20 20 42 2e 66 69 72 73 74 20 3d 20 52 2e 72 B.first = R.r
a5d0: 69 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 id.. AND C
a5e0: 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 0a 09 20 I.iid = R.rid..
a5f0: 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 AND C.cid
a600: 3d 20 43 49 2e 63 69 64 0a 09 20 20 20 20 41 4e = CI.cid.. AN
a610: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30 0a D C.type = 0.
a620: 09 20 20 20 20 41 4e 44 20 20 20 20 43 4f 2e 63 . AND CO.c
a630: 69 64 20 3d 20 43 2e 63 69 64 0a 09 20 20 20 20 id = C.cid..
a640: 47 52 4f 55 50 20 42 59 20 42 2e 62 69 64 0a 09 GROUP BY B.bid..
a650: 7d 5d 5d 0a 0a 20 20 20 20 20 20 20 20 72 65 74 }]].. ret
a660: 75 72 6e 20 5b 6c 69 73 74 20 24 6d 61 78 70 20 urn [list $maxp
a670: 24 6d 69 6e 73 5d 0a 20 20 20 20 7d 0a 0a 20 20 $mins]. }..
a680: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 # # ## ### ###
a690: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 ## ######## ####
a6a0: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 #########. ##
a6b0: 20 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a 0a Configuration..
a6c0: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 69 pragma -hasi
a6d0: 6e 73 74 61 6e 63 65 73 20 20 20 6e 6f 20 3b 20 nstances no ;
a6e0: 23 20 73 69 6e 67 6c 65 74 6f 6e 0a 20 20 20 20 # singleton.
a6f0: 70 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65 69 pragma -hastypei
a700: 6e 66 6f 20 20 20 20 6e 6f 20 3b 20 23 20 6e 6f nfo no ; # no
a710: 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20 introspection.
a720: 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 79 pragma -hasty
a730: 70 65 64 65 73 74 72 6f 79 20 6e 6f 20 3b 20 23 pedestroy no ; #
a740: 20 69 6d 6d 6f 72 74 61 6c 0a 7d 0a 0a 23 20 23 immortal.}..# #
a750: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 ## ### ##### ##
a760: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
a770: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
a780: 23 23 23 23 23 23 23 23 23 23 0a 23 23 0a 0a 6e ##########.##..n
a790: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a amespace eval ::
a7a0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f vc::fossil::impo
a7b0: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 rt::cvs::project
a7c0: 20 7b 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 {. namespace
a7d0: 20 65 78 70 6f 72 74 20 72 65 76 0a 20 20 20 20 export rev.
a7e0: 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 72 namespace eval r
a7f0: 65 76 20 7b 0a 09 6e 61 6d 65 73 70 61 63 65 20 ev {..namespace
a800: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 import ::vc::fos
a810: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 sil::import::cvs
a820: 3a 3a 73 74 61 74 65 0a 09 6e 61 6d 65 73 70 61 ::state..namespa
a830: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a ce import ::vc::
a840: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a fossil::import::
a850: 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09 cvs::integrity..
a860: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 namespace import
a870: 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 ::vc::tools::mi
a880: 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73 70 61 63 65 sc::*..namespace
a890: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f import ::vc::to
a8a0: 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 0a 09 6e 61 ols::trouble..na
a8b0: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a mespace import :
a8c0: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a :vc::tools::log.
a8d0: 09 6c 6f 67 20 72 65 67 69 73 74 65 72 20 63 73 .log register cs
a8e0: 65 74 73 0a 0a 09 23 20 53 65 74 20 75 70 20 74 ets...# Set up t
a8f0: 68 65 20 68 65 6c 70 65 72 20 73 69 6e 67 6c 65 he helper single
a900: 74 6f 6e 73 0a 09 6e 61 6d 65 73 70 61 63 65 20 tons..namespace
a910: 65 76 61 6c 20 72 65 76 20 7b 0a 09 20 20 20 20 eval rev {..
a920: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 namespace import
a930: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 ::vc::fossil::i
a940: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 mport::cvs::stat
a950: 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 e.. namespace
a960: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f import ::vc::fo
a970: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 ssil::import::cv
a980: 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09 7d 0a s::integrity..}.
a990: 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 .namespace eval
a9a0: 73 79 6d 3a 3a 74 61 67 20 7b 0a 09 20 20 20 20 sym::tag {..
a9b0: 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 namespace import
a9c0: 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 ::vc::fossil::i
a9d0: 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 mport::cvs::stat
a9e0: 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 e.. namespace
a9f0: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f import ::vc::fo
aa00: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 ssil::import::cv
aa10: 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09 7d 0a s::integrity..}.
aa20: 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 .namespace eval
aa30: 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b 0a 09 20 sym::branch {..
aa40: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 namespace imp
aa50: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c ort ::vc::fossil
aa60: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 ::import::cvs::s
aa70: 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 70 tate.. namesp
aa80: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a ace import ::vc:
aa90: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a :fossil::import:
aaa0: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 0a :cvs::integrity.
aab0: 09 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 .}. }.}..# #
aac0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
aad0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
aae0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
aaf0: 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 61 #########.## Rea
ab00: 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f 76 dy..package prov
ab10: 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a ide vc::fossil::
ab20: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f import::cvs::pro
ab30: 6a 65 63 74 3a 3a 72 65 76 20 31 2e 30 0a 72 65 ject::rev 1.0.re
ab40: 74 75 72 6e 0a turn.