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 6d 65 74 68 6f 64 20 70 75 73 68 74 6f 20 7b method pushto {
31f0: 73 76 20 72 65 70 6f 73 69 74 6f 72 79 20 64 61 sv repository da
3200: 74 65 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 te} {..upvar 1 $
3210: 73 76 20 73 74 61 74 65 0a 0a 09 23 20 47 65 6e sv state...# Gen
3220: 65 72 61 74 65 20 61 6e 64 20 69 6d 70 6f 72 74 erate and import
3230: 20 74 68 65 20 6d 61 6e 69 66 65 73 74 20 66 6f the manifest fo
3240: 72 20 74 68 69 73 20 63 68 61 6e 67 65 73 65 74 r this changeset
3250: 2e 0a 09 23 0a 09 23 20 44 61 74 61 20 6e 65 65 ...#..# Data nee
3260: 64 65 64 3a 0a 09 23 20 2d 20 43 6f 6d 6d 69 74 ded:..# - Commit
3270: 20 6d 65 73 73 61 67 65 20 20 20 20 20 20 20 20 message
3280: 20 20 20 20 20 20 20 28 2d 2d 20 6d 79 73 72 63 (-- mysrc
3290: 69 64 20 2d 3e 20 72 65 70 6f 73 69 74 6f 72 79 id -> repository
32a0: 20 6d 65 74 61 29 0a 09 23 20 2d 20 55 73 65 72 meta)..# - User
32b0: 20 64 6f 69 6e 67 20 74 68 65 20 63 6f 6d 6d 69 doing the commi
32c0: 74 20 20 20 20 20 20 20 20 28 73 2e 61 2e 29 0a t (s.a.).
32d0: 09 23 0a 09 23 20 2d 20 54 69 6d 65 73 74 61 6d .#..# - Timestam
32e0: 70 20 6f 66 20 77 68 65 6e 20 63 6f 6d 6d 69 74 p of when commit
32f0: 74 65 64 20 20 28 63 6f 6d 6d 61 6e 64 20 61 72 ted (command ar
3300: 67 75 6d 65 6e 74 29 0a 09 23 0a 09 23 20 2d 20 gument)..#..# -
3310: 54 68 65 20 70 61 72 65 6e 74 20 63 68 61 6e 67 The parent chang
3320: 65 73 65 74 2c 20 69 66 20 61 6e 79 2e 20 49 66 eset, if any. If
3330: 20 74 68 65 72 65 20 69 73 20 6e 6f 20 70 61 72 there is no par
3340: 65 6e 74 20 75 73 65 0a 09 23 20 20 20 74 68 65 ent use..# the
3350: 20 65 6d 70 74 79 20 62 61 73 65 20 72 65 76 69 empty base revi
3360: 73 69 6f 6e 20 61 73 20 70 61 72 65 6e 74 2e 0a sion as parent..
3370: 09 23 0a 09 23 20 2d 20 4c 69 73 74 20 6f 66 20 .#..# - List of
3380: 74 68 65 20 66 69 6c 65 20 72 65 76 69 73 69 6f the file revisio
3390: 6e 73 20 69 6e 20 74 68 65 20 63 68 61 6e 67 65 ns in the change
33a0: 73 65 74 2e 0a 0a 09 73 74 72 75 63 74 3a 3a 6c set....struct::l
33b0: 69 73 74 20 61 73 73 69 67 6e 20 5b 24 6d 79 70 ist assign [$myp
33c0: 72 6f 6a 65 63 74 20 67 65 74 6d 65 74 61 20 24 roject getmeta $
33d0: 6d 79 73 72 63 69 64 5d 20 5f 5f 20 62 72 61 6e mysrcid] __ bran
33e0: 63 68 20 75 73 65 72 20 6d 65 73 73 61 67 65 0a ch user message.
33f0: 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 .struct::list as
3400: 73 69 67 6e 20 24 62 72 61 6e 63 68 20 5f 5f 20 sign $branch __
3410: 6c 6f 64 6e 61 6d 65 0a 0a 09 23 20 50 65 72 66 lodname...# Perf
3420: 6f 72 6d 20 74 68 65 20 69 6d 70 6f 72 74 2e 20 orm the import.
3430: 41 73 20 70 61 72 74 20 6f 66 20 74 68 61 74 20 As part of that
3440: 63 6f 6e 76 65 72 74 20 74 68 65 20 6c 69 73 74 convert the list
3450: 20 6f 66 0a 09 23 20 69 74 65 6d 73 20 69 6e 20 of..# items in
3460: 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 69 6e the changeset in
3470: 74 6f 20 75 75 69 64 73 20 61 6e 64 20 70 72 69 to uuids and pri
3480: 6e 74 61 62 6c 65 20 64 61 74 61 2e 0a 0a 09 73 ntable data....s
3490: 65 74 20 75 75 69 64 20 5b 55 70 64 61 74 65 73 et uuid [Updates
34a0: 74 61 74 65 20 73 74 61 74 65 20 24 6c 6f 64 6e tate state $lodn
34b0: 61 6d 65 20 5c 0a 09 09 20 20 20 20 20 20 5b 24 ame \... [$
34c0: 72 65 70 6f 73 69 74 6f 72 79 20 69 6d 70 6f 72 repository impor
34d0: 74 72 65 76 69 73 69 6f 6e 20 5b 24 73 65 6c 66 trevision [$self
34e0: 20 73 74 72 5d 20 5c 0a 09 09 09 20 20 20 24 75 str] \.... $u
34f0: 73 65 72 20 24 6d 65 73 73 61 67 65 20 24 64 61 ser $message $da
3500: 74 65 20 5c 0a 09 09 09 20 20 20 5b 47 65 74 70 te \.... [Getp
3510: 61 72 65 6e 74 20 73 74 61 74 65 20 24 6c 6f 64 arent state $lod
3520: 6e 61 6d 65 20 24 6d 79 70 72 6f 6a 65 63 74 5d name $myproject]
3530: 20 5c 0a 09 09 09 20 20 20 5b 47 65 74 72 65 76 \.... [Getrev
3540: 69 73 69 6f 6e 69 6e 66 6f 20 24 6d 79 69 74 65 isioninfo $myite
3550: 6d 73 5d 5d 5d 0a 0a 09 23 20 52 65 6d 65 6d 62 ms]]]...# Rememb
3560: 65 72 20 74 68 65 20 77 68 6f 6c 65 20 63 68 61 er the whole cha
3570: 6e 67 65 73 65 74 20 2f 20 75 75 69 64 20 6d 61 ngeset / uuid ma
3580: 70 70 69 6e 67 2c 20 66 6f 72 20 74 68 65 20 74 pping, for the t
3590: 61 67 73 2e 0a 0a 09 73 74 61 74 65 20 72 75 6e ags....state run
35a0: 20 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 {.. INSERT I
35b0: 4e 54 4f 20 63 73 75 75 69 64 20 28 63 69 64 2c NTO csuuid (cid,
35c0: 20 20 20 75 75 69 64 29 0a 09 20 20 20 20 56 41 uuid).. VA
35d0: 4c 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 LUES
35e0: 20 28 24 6d 79 69 64 2c 20 24 75 75 69 64 29 0a ($myid, $uuid).
35f0: 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d .}..return. }
3600: 0a 0a 20 20 20 20 70 72 6f 63 20 47 65 74 72 65 .. proc Getre
3610: 76 69 73 69 6f 6e 69 6e 66 6f 20 7b 72 65 76 69 visioninfo {revi
3620: 73 69 6f 6e 73 7d 20 7b 0a 09 73 65 74 20 74 68 sions} {..set th
3630: 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 eset ('[join $re
3640: 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 visions {','}]')
3650: 0a 09 73 65 74 20 72 65 76 69 73 69 6f 6e 73 20 ..set revisions
3660: 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b 75 75 69 {}..foreach {uui
3670: 64 20 66 6e 61 6d 65 20 72 65 76 6e 72 7d 20 5b d fname revnr} [
3680: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 state run [subst
3690: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f -nocommands -no
36a0: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 backslashes {..
36b0: 20 20 20 53 45 4c 45 43 54 20 55 2e 75 75 69 64 SELECT U.uuid
36c0: 2c 20 46 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a , F.name, R.rev.
36d0: 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 . FROM revi
36e0: 73 69 6f 6e 20 52 2c 20 72 65 76 75 75 69 64 20 sion R, revuuid
36f0: 55 2c 20 66 69 6c 65 20 46 0a 09 20 20 20 20 57 U, file F.. W
3700: 48 45 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24 HERE R.rid IN $
3710: 74 68 65 73 65 74 20 20 2d 2d 20 41 6c 6c 20 73 theset -- All s
3720: 70 65 63 69 66 69 65 64 20 72 65 76 69 73 69 6f pecified revisio
3730: 6e 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20 55 ns.. AND U
3740: 2e 72 69 64 20 3d 20 52 2e 72 69 64 20 20 20 20 .rid = R.rid
3750: 20 2d 2d 20 67 65 74 20 66 6f 73 73 69 6c 20 75 -- get fossil u
3760: 75 69 64 20 6f 66 20 72 65 76 69 73 69 6f 6e 0a uid of revision.
3770: 09 20 20 20 20 41 4e 44 20 20 20 20 46 2e 66 69 . AND F.fi
3780: 64 20 3d 20 52 2e 66 69 64 20 20 20 20 20 2d 2d d = R.fid --
3790: 20 67 65 74 20 66 69 6c 65 20 6f 66 20 72 65 76 get file of rev
37a0: 69 73 69 6f 6e 0a 09 7d 5d 5d 20 7b 0a 09 20 20 ision..}]] {..
37b0: 20 20 6c 61 70 70 65 6e 64 20 72 65 76 69 73 69 lappend revisi
37c0: 6f 6e 73 20 24 75 75 69 64 20 24 66 6e 61 6d 65 ons $uuid $fname
37d0: 20 24 72 65 76 6e 72 0a 09 7d 0a 09 72 65 74 75 $revnr..}..retu
37e0: 72 6e 20 24 72 65 76 69 73 69 6f 6e 73 0a 20 20 rn $revisions.
37f0: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 47 65 }.. proc Ge
3800: 74 70 61 72 65 6e 74 20 7b 73 76 20 6c 6f 64 6e tparent {sv lodn
3810: 61 6d 65 20 70 72 6f 6a 65 63 74 7d 20 7b 0a 09 ame project} {..
3820: 75 70 76 61 72 20 31 20 24 73 76 20 73 74 61 74 upvar 1 $sv stat
3830: 65 0a 0a 09 23 20 54 68 65 20 70 61 72 65 6e 74 e...# The parent
3840: 20 69 73 20 64 65 74 65 72 6d 69 6e 65 64 20 76 is determined v
3850: 69 61 20 74 68 65 20 6c 69 6e 65 2d 6f 66 2d 64 ia the line-of-d
3860: 65 76 65 6c 6f 70 6d 65 6e 74 20 28 4c 4f 44 29 evelopment (LOD)
3870: 0a 09 23 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 ..# information
3880: 6f 66 20 65 61 63 68 20 63 68 61 6e 67 65 73 65 of each changese
3890: 74 2c 20 61 6e 64 20 74 68 65 20 68 69 73 74 6f t, and the histo
38a0: 72 79 20 6f 66 0a 09 23 20 69 6d 70 6f 72 74 73 ry of..# imports
38b0: 2e 20 54 68 65 20 6c 61 73 74 20 63 68 61 6e 67 . The last chang
38c0: 65 73 65 74 20 63 6f 6d 6d 69 74 74 65 64 20 74 eset committed t
38d0: 6f 20 74 68 65 20 73 61 6d 65 20 4c 4f 44 20 69 o the same LOD i
38e0: 73 0a 09 23 20 74 61 6b 65 6e 20 61 73 20 74 68 s..# taken as th
38f0: 65 20 70 61 72 65 6e 74 20 6f 66 20 74 68 65 20 e parent of the
3900: 63 75 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65 current changese
3910: 74 2e 20 49 66 20 74 68 65 0a 09 23 20 63 68 61 t. If the..# cha
3920: 6e 67 65 73 65 74 20 69 73 20 74 68 65 20 66 69 ngeset is the fi
3930: 72 73 74 20 6f 6e 20 74 68 61 74 20 4c 4f 44 20 rst on that LOD
3940: 69 74 20 63 61 6e 20 62 65 20 65 69 74 68 65 72 it can be either
3950: 20 73 70 61 77 6e 65 64 0a 09 23 20 66 72 6f 6d spawned..# from
3960: 20 61 6e 6f 74 68 65 72 20 4c 4f 44 2c 20 6f 72 another LOD, or
3970: 20 64 65 74 61 63 68 65 64 2e 20 46 6f 72 20 74 detached. For t
3980: 68 65 20 66 69 72 73 74 20 63 61 73 65 20 77 65 he first case we
3990: 0a 09 23 20 72 65 74 72 69 65 76 65 20 74 68 65 ..# retrieve the
39a0: 20 70 61 72 65 6e 74 20 4c 4f 44 20 6f 66 20 74 parent LOD of t
39b0: 68 65 20 63 75 72 72 65 6e 74 20 4c 4f 44 20 73 he current LOD s
39c0: 79 6d 62 6f 6c 20 28 2a 29 20 61 6e 64 0a 09 23 ymbol (*) and..#
39d0: 20 72 65 63 68 65 63 6b 20 66 6f 72 20 61 20 63 recheck for a c
39e0: 6f 6d 6d 69 74 74 65 64 20 63 68 61 6e 67 65 73 ommitted changes
39f0: 65 74 2e 20 54 68 65 20 73 65 63 6f 6e 64 20 63 et. The second c
3a00: 61 73 65 20 69 73 20 74 61 6b 65 6e 0a 09 23 20 ase is taken..#
3a10: 69 66 20 74 68 61 74 20 6c 6f 6f 6b 75 70 20 66 if that lookup f
3a20: 61 69 6c 73 20 61 73 20 77 65 6c 6c 2e 0a 09 23 ails as well...#
3a30: 0a 09 23 20 28 2a 29 20 41 6e 64 20 74 68 69 73 ..# (*) And this
3a40: 20 70 61 72 65 6e 74 20 77 61 73 20 66 6f 75 6e parent was foun
3a50: 64 20 69 6e 20 70 72 65 76 69 6f 75 73 20 70 61 d in previous pa
3a60: 73 73 65 73 20 77 68 65 6e 0a 09 23 20 20 20 20 sses when..#
3a70: 20 64 65 74 65 72 6d 69 6e 69 6e 67 20 74 68 65 determining the
3a80: 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e 74 prefered parent
3a90: 73 20 6f 66 20 61 6c 6c 20 74 68 65 20 73 79 6d s of all the sym
3aa0: 62 6f 6c 73 2e 0a 0a 09 23 20 4e 4f 54 45 3a 20 bols....# NOTE:
3ab0: 54 68 65 20 61 62 6f 76 65 20 69 73 20 69 6e 63 The above is inc
3ac0: 6f 6d 70 6c 65 74 65 20 61 6e 64 20 62 75 67 67 omplete and bugg
3ad0: 79 2e 20 56 65 6e 64 6f 72 2d 62 72 61 6e 63 68 y. Vendor-branch
3ae0: 65 73 20 61 6e 64 0a 09 23 20 20 20 20 20 20 20 es and..#
3af0: 74 68 65 20 76 61 72 69 6f 75 73 20 70 6f 73 73 the various poss
3b00: 69 62 69 6c 69 74 69 65 73 20 6f 66 20 69 74 73 ibilities of its
3b10: 20 69 6e 74 65 72 61 63 74 69 6f 6e 20 77 69 74 interaction wit
3b20: 68 20 74 68 65 0a 09 23 20 20 20 20 20 20 20 74 h the..# t
3b30: 72 75 6e 6b 20 61 72 65 20 6e 6f 74 20 66 75 6c runk are not ful
3b40: 6c 79 20 68 61 6e 64 6c 65 64 2e 0a 0a 09 69 66 ly handled....if
3b50: 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 73 {[info exists s
3b60: 74 61 74 65 28 24 6c 6f 64 6e 61 6d 65 29 5d 7d tate($lodname)]}
3b70: 20 7b 0a 09 20 20 20 20 23 20 4c 4f 44 20 65 78 {.. # LOD ex
3b80: 69 73 74 73 20 61 6e 64 20 68 61 73 20 61 6c 72 ists and has alr
3b90: 65 61 64 79 20 62 65 65 6e 20 63 6f 6d 6d 69 74 eady been commit
3ba0: 74 65 64 20 74 6f 2e 0a 09 20 20 20 20 72 65 74 ted to... ret
3bb0: 75 72 6e 20 24 73 74 61 74 65 28 24 6c 6f 64 6e urn $state($lodn
3bc0: 61 6d 65 29 0a 09 7d 0a 0a 09 23 20 4c 4f 44 20 ame)..}...# LOD
3bd0: 68 61 73 20 6e 6f 74 20 62 65 65 6e 20 63 6f 6d has not been com
3be0: 6d 69 74 74 65 64 20 74 6f 20 62 65 66 6f 72 65 mitted to before
3bf0: 2c 20 74 68 69 73 20 69 73 20 74 68 65 20 66 69 , this is the fi
3c00: 72 73 74 0a 09 23 20 74 69 6d 65 2e 20 44 65 74 rst..# time. Det
3c10: 65 72 6d 69 6e 65 20 74 68 65 20 6e 61 6d 65 20 ermine the name
3c20: 6f 66 20 74 68 65 20 70 61 72 65 6e 74 20 4c 4f of the parent LO
3c30: 44 2e 0a 0a 09 73 65 74 20 6c 6f 64 6e 61 6d 65 D....set lodname
3c40: 20 5b 5b 5b 24 70 72 6f 6a 65 63 74 20 67 65 74 [[[$project get
3c50: 73 79 6d 62 6f 6c 20 24 6c 6f 64 6e 61 6d 65 5d symbol $lodname]
3c60: 20 70 61 72 65 6e 74 5d 20 6e 61 6d 65 5d 0a 0a parent] name]..
3c70: 09 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 .if {[info exist
3c80: 73 20 73 74 61 74 65 28 24 6c 6f 64 6e 61 6d 65 s state($lodname
3c90: 29 5d 7d 20 7b 0a 09 20 20 20 20 23 20 54 68 65 )]} {.. # The
3ca0: 20 70 61 72 65 6e 74 61 6c 20 4c 4f 44 20 68 61 parental LOD ha
3cb0: 73 20 62 65 65 6e 20 63 6f 6d 6d 69 74 74 65 64 s been committed
3cc0: 20 74 6f 2c 20 74 61 6b 65 20 74 68 61 74 20 6c to, take that l
3cd0: 61 73 74 0a 09 20 20 20 20 23 20 63 68 61 6e 67 ast.. # chang
3ce0: 65 73 65 74 20 61 73 20 74 68 65 20 73 70 61 77 eset as the spaw
3cf0: 6e 70 6f 69 6e 74 20 66 6f 72 20 74 68 65 20 6e npoint for the n
3d00: 65 77 20 4c 4f 44 2e 0a 09 20 20 20 20 72 65 74 ew LOD... ret
3d10: 75 72 6e 20 24 73 74 61 74 65 28 24 6c 6f 64 6e urn $state($lodn
3d20: 61 6d 65 29 0a 09 7d 0a 0a 09 23 20 54 68 65 20 ame)..}...# The
3d30: 70 61 72 65 6e 74 61 6c 20 4c 4f 44 20 69 73 20 parental LOD is
3d40: 6e 6f 74 20 64 65 66 69 6e 65 64 20 28 79 65 74 not defined (yet
3d50: 29 2e 20 54 68 69 73 20 4c 4f 44 20 69 73 0a 09 ). This LOD is..
3d60: 23 20 64 65 74 61 63 68 65 64 2e 20 57 65 20 63 # detached. We c
3d70: 68 6f 6f 73 65 20 61 73 20 6f 75 72 20 70 61 72 hoose as our par
3d80: 65 6e 74 20 74 68 65 20 61 75 74 6f 6d 61 74 69 ent the automati
3d90: 63 20 65 6d 70 74 79 20 72 6f 6f 74 0a 09 23 20 c empty root..#
3da0: 62 61 73 65 6c 69 6e 65 20 6f 66 20 74 68 65 20 baseline of the
3db0: 74 61 72 67 65 74 20 72 65 70 6f 73 69 74 6f 72 target repositor
3dc0: 79 2e 0a 09 72 65 74 75 72 6e 20 7b 7d 0a 20 20 y...return {}.
3dd0: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 55 70 }.. proc Up
3de0: 64 61 74 65 73 74 61 74 65 20 7b 73 76 20 6c 6f datestate {sv lo
3df0: 64 6e 61 6d 65 20 75 75 69 64 7d 20 7b 0a 09 23 dname uuid} {..#
3e00: 20 52 65 6d 65 6d 62 65 72 20 74 68 65 20 69 6d Remember the im
3e10: 70 6f 72 74 65 64 20 63 68 61 6e 67 65 73 65 74 ported changeset
3e20: 20 69 6e 20 74 68 65 20 73 74 61 74 65 2c 20 75 in the state, u
3e30: 6e 64 65 72 20 6f 75 72 20 4c 4f 44 2e 0a 0a 09 nder our LOD....
3e40: 75 70 76 61 72 20 31 20 24 73 76 20 73 74 61 74 upvar 1 $sv stat
3e50: 65 0a 09 73 65 74 20 73 74 61 74 65 28 24 6c 6f e..set state($lo
3e60: 64 6e 61 6d 65 29 20 24 75 75 69 64 0a 09 72 65 dname) $uuid..re
3e70: 74 75 72 6e 20 24 75 75 69 64 0a 20 20 20 20 7d turn $uuid. }
3e80: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 .. typemethod
3e90: 20 73 70 6c 69 74 20 7b 63 73 65 74 20 61 72 67 split {cset arg
3ea0: 73 7d 20 7b 0a 09 23 20 41 73 20 70 61 72 74 20 s} {..# As part
3eb0: 6f 66 20 74 68 65 20 63 72 65 61 74 69 6f 6e 20 of the creation
3ec0: 6f 66 20 74 68 65 20 6e 65 77 20 63 68 61 6e 67 of the new chang
3ed0: 65 73 65 74 73 20 73 70 65 63 69 66 69 65 64 20 esets specified
3ee0: 69 6e 0a 09 23 20 41 52 47 53 20 61 73 20 73 65 in..# ARGS as se
3ef0: 74 73 20 6f 66 20 69 74 65 6d 73 2c 20 61 6c 6c ts of items, all
3f00: 20 73 75 62 73 65 74 73 20 6f 66 20 43 53 45 54 subsets of CSET
3f10: 27 73 20 69 74 65 6d 20 73 65 74 2c 20 43 53 45 's item set, CSE
3f20: 54 0a 09 23 20 77 69 6c 6c 20 62 65 20 64 72 6f T..# will be dro
3f30: 70 70 65 64 20 66 72 6f 6d 20 61 6c 6c 20 64 61 pped from all da
3f40: 74 61 62 61 73 65 73 2c 20 69 6e 20 61 6e 64 20 tabases, in and
3f50: 6f 75 74 20 6f 66 20 6d 65 6d 6f 72 79 2c 0a 09 out of memory,..
3f60: 23 20 61 6e 64 20 74 68 65 6e 20 64 65 73 74 72 # and then destr
3f70: 6f 79 65 64 2e 0a 09 23 0a 09 23 20 4e 6f 74 65 oyed...#..# Note
3f80: 3a 20 54 68 65 20 69 74 65 6d 20 6c 69 73 74 73 : The item lists
3f90: 20 66 6f 75 6e 64 20 69 6e 20 61 72 67 73 20 61 found in args a
3fa0: 72 65 20 74 61 67 67 65 64 20 69 74 65 6d 73 2e re tagged items.
3fb0: 20 54 68 65 79 0a 09 23 20 68 61 76 65 20 74 6f They..# have to
3fc0: 20 68 61 76 65 20 74 68 65 20 73 61 6d 65 20 74 have the same t
3fd0: 79 70 65 20 61 73 20 74 68 65 20 63 68 61 6e 67 ype as the chang
3fe0: 65 73 65 74 2c 20 62 65 69 6e 67 20 73 75 62 73 eset, being subs
3ff0: 65 74 73 0a 09 23 20 6f 66 20 69 74 73 20 69 74 ets..# of its it
4000: 65 6d 73 2e 20 54 68 69 73 20 69 73 20 63 68 65 ems. This is che
4010: 63 6b 65 64 20 69 6e 20 55 6e 74 61 67 31 2e 0a cked in Untag1..
4020: 0a 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 ..log write 8 cs
4030: 65 74 73 20 7b 4f 4c 44 3a 20 5b 6c 73 6f 72 74 ets {OLD: [lsort
4040: 20 5b 24 63 73 65 74 20 69 74 65 6d 73 5d 5d 7d [$cset items]]}
4050: 0a 09 56 61 6c 69 64 61 74 65 46 72 61 67 6d 65 ..ValidateFragme
4060: 6e 74 73 20 24 63 73 65 74 20 24 61 72 67 73 0a nts $cset $args.
4070: 0a 09 23 20 41 6c 6c 20 63 68 65 63 6b 73 20 70 ..# All checks p
4080: 61 73 73 2c 20 61 63 74 75 61 6c 6c 79 20 70 65 ass, actually pe
4090: 72 66 6f 72 6d 20 74 68 65 20 73 70 6c 69 74 2e rform the split.
40a0: 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 ...struct::list
40b0: 61 73 73 69 67 6e 20 5b 24 63 73 65 74 20 64 61 assign [$cset da
40c0: 74 61 5d 20 70 72 6f 6a 65 63 74 20 63 73 74 79 ta] project csty
40d0: 70 65 20 63 73 73 72 63 0a 0a 09 73 65 74 20 70 pe cssrc...set p
40e0: 72 65 64 65 63 65 73 73 6f 72 73 20 5b 24 63 73 redecessors [$cs
40f0: 65 74 20 64 72 6f 70 5d 0a 09 24 63 73 65 74 20 et drop]..$cset
4100: 64 65 73 74 72 6f 79 0a 0a 09 73 65 74 20 6e 65 destroy...set ne
4110: 77 63 73 65 74 73 20 7b 7d 0a 09 66 6f 72 65 61 wcsets {}..forea
4120: 63 68 20 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 ch fragmentitems
4130: 20 24 61 72 67 73 20 7b 0a 09 20 20 20 20 6c 6f $args {.. lo
4140: 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 g write 8 csets
4150: 7b 4d 41 4b 45 3a 20 5b 6c 73 6f 72 74 20 24 66 {MAKE: [lsort $f
4160: 72 61 67 6d 65 6e 74 69 74 65 6d 73 5d 7d 0a 0a ragmentitems]}..
4170: 09 20 20 20 20 73 65 74 20 66 72 61 67 6d 65 6e . set fragmen
4180: 74 20 5b 24 74 79 70 65 20 25 41 55 54 4f 25 20 t [$type %AUTO%
4190: 24 70 72 6f 6a 65 63 74 20 24 63 73 74 79 70 65 $project $cstype
41a0: 20 24 63 73 73 72 63 20 5c 0a 09 09 09 20 20 20 $cssrc \....
41b0: 20 20 20 5b 55 6e 74 61 67 20 24 66 72 61 67 6d [Untag $fragm
41c0: 65 6e 74 69 74 65 6d 73 20 24 63 73 74 79 70 65 entitems $cstype
41d0: 5d 5d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 ]].. lappend
41e0: 6e 65 77 63 73 65 74 73 20 24 66 72 61 67 6d 65 newcsets $fragme
41f0: 6e 74 0a 0a 09 20 20 20 20 24 66 72 61 67 6d 65 nt... $fragme
4200: 6e 74 20 70 65 72 73 69 73 74 0a 09 20 20 20 20 nt persist..
4210: 24 66 72 61 67 6d 65 6e 74 20 64 65 74 65 72 6d $fragment determ
4220: 69 6e 65 73 75 63 63 65 73 73 6f 72 73 0a 09 7d inesuccessors..}
4230: 0a 0a 09 23 20 54 68 65 20 70 72 65 64 65 63 65 ...# The predece
4240: 73 73 6f 72 73 20 68 61 76 65 20 74 6f 20 72 65 ssors have to re
4250: 63 6f 6d 70 75 74 65 20 74 68 65 69 72 20 73 75 compute their su
4260: 63 63 65 73 73 6f 72 73 2c 20 69 2e 65 2e 0a 09 ccessors, i.e...
4270: 23 20 72 65 6d 6f 76 65 20 74 68 65 20 64 72 6f # remove the dro
4280: 70 70 65 64 20 63 68 61 6e 67 65 73 65 74 20 61 pped changeset a
4290: 6e 64 20 70 75 74 20 6f 6e 65 20 6f 66 20 74 68 nd put one of th
42a0: 65 20 66 72 61 67 6d 65 6e 74 73 0a 09 23 20 69 e fragments..# i
42b0: 6e 74 6f 20 69 74 73 20 70 6c 61 63 65 2e 0a 09 nto its place...
42c0: 66 6f 72 65 61 63 68 20 70 20 24 70 72 65 64 65 foreach p $prede
42d0: 63 65 73 73 6f 72 73 20 7b 0a 09 20 20 20 20 24 cessors {.. $
42e0: 70 20 64 65 74 65 72 6d 69 6e 65 73 75 63 63 65 p determinesucce
42f0: 73 73 6f 72 73 0a 09 7d 0a 0a 09 72 65 74 75 72 ssors..}...retur
4300: 6e 20 24 6e 65 77 63 73 65 74 73 0a 20 20 20 20 n $newcsets.
4310: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f }.. typemetho
4320: 64 20 69 74 65 6d 73 74 72 20 7b 69 74 65 6d 7d d itemstr {item}
4330: 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 {..struct::list
4340: 20 61 73 73 69 67 6e 20 24 69 74 65 6d 20 69 74 assign $item it
4350: 79 70 65 20 69 69 64 0a 09 72 65 74 75 72 6e 20 ype iid..return
4360: 5b 24 69 74 79 70 65 20 73 74 72 20 24 69 69 64 [$itype str $iid
4370: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 ]. }.. typ
4380: 65 6d 65 74 68 6f 64 20 73 74 72 6c 69 73 74 20 emethod strlist
4390: 7b 63 68 61 6e 67 65 73 65 74 73 7d 20 7b 0a 09 {changesets} {..
43a0: 72 65 74 75 72 6e 20 5b 6a 6f 69 6e 20 5b 73 74 return [join [st
43b0: 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 ruct::list map $
43c0: 63 68 61 6e 67 65 73 65 74 73 20 5b 6d 79 70 72 changesets [mypr
43d0: 6f 63 20 49 44 5d 5d 5d 0a 20 20 20 20 7d 0a 0a oc ID]]]. }..
43e0: 20 20 20 20 70 72 6f 63 20 49 44 20 7b 63 73 65 proc ID {cse
43f0: 74 7d 20 7b 20 24 63 73 65 74 20 73 74 72 20 7d t} { $cset str }
4400: 0a 0a 20 20 20 20 70 72 6f 63 20 55 6e 74 61 67 .. proc Untag
4410: 20 7b 74 61 67 67 65 64 69 74 65 6d 73 20 63 73 {taggeditems cs
4420: 74 79 70 65 7d 20 7b 0a 09 72 65 74 75 72 6e 20 type} {..return
4430: 5b 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 [struct::list ma
4440: 70 20 24 74 61 67 67 65 64 69 74 65 6d 73 20 5b p $taggeditems [
4450: 6d 79 70 72 6f 63 20 55 6e 74 61 67 31 20 24 63 myproc Untag1 $c
4460: 73 74 79 70 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 stype]]. }..
4470: 20 20 20 70 72 6f 63 20 55 6e 74 61 67 31 20 7b proc Untag1 {
4480: 63 73 74 79 70 65 20 74 68 65 69 74 65 6d 7d 20 cstype theitem}
4490: 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 {..struct::list
44a0: 61 73 73 69 67 6e 20 24 74 68 65 69 74 65 6d 20 assign $theitem
44b0: 74 20 69 0a 09 69 6e 74 65 67 72 69 74 79 20 61 t i..integrity a
44c0: 73 73 65 72 74 20 7b 24 63 73 74 79 70 65 20 65 ssert {$cstype e
44d0: 71 20 24 74 7d 20 7b 49 74 65 6d 20 24 69 27 73 q $t} {Item $i's
44e0: 20 74 79 70 65 20 69 73 20 27 24 74 27 2c 20 65 type is '$t', e
44f0: 78 70 65 63 74 65 64 20 27 24 63 73 74 79 70 65 xpected '$cstype
4500: 27 7d 0a 09 72 65 74 75 72 6e 20 24 69 0a 20 20 '}..return $i.
4510: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 54 61 }.. proc Ta
4520: 67 49 74 65 6d 44 69 63 74 20 7b 69 74 65 6d 64 gItemDict {itemd
4530: 69 63 74 20 63 73 74 79 70 65 7d 20 7b 0a 09 73 ict cstype} {..s
4540: 65 74 20 72 65 73 20 7b 7d 0a 09 66 6f 72 65 61 et res {}..forea
4550: 63 68 20 7b 69 20 76 7d 20 24 69 74 65 6d 64 69 ch {i v} $itemdi
4560: 63 74 20 7b 20 6c 61 70 70 65 6e 64 20 72 65 73 ct { lappend res
4570: 20 5b 6c 69 73 74 20 24 63 73 74 79 70 65 20 24 [list $cstype $
4580: 69 5d 20 24 76 20 7d 0a 09 72 65 74 75 72 6e 20 i] $v }..return
4590: 24 72 65 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 $res. }..
45a0: 70 72 6f 63 20 56 61 6c 69 64 61 74 65 46 72 61 proc ValidateFra
45b0: 67 6d 65 6e 74 73 20 7b 63 73 65 74 20 66 72 61 gments {cset fra
45c0: 67 6d 65 6e 74 73 7d 20 7b 0a 09 23 20 43 68 65 gments} {..# Che
45d0: 63 6b 20 74 68 65 20 76 61 72 69 6f 75 73 20 69 ck the various i
45e0: 6e 74 65 67 72 69 74 79 20 63 6f 6e 73 74 72 61 ntegrity constra
45f0: 69 6e 74 73 20 66 6f 72 20 74 68 65 20 66 72 61 ints for the fra
4600: 67 6d 65 6e 74 73 0a 09 23 20 73 70 65 63 69 66 gments..# specif
4610: 79 69 6e 67 20 68 6f 77 20 74 6f 20 73 70 6c 69 ying how to spli
4620: 74 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 3a t the changeset:
4630: 0a 09 23 0a 09 23 20 2a 20 57 65 20 6d 75 73 74 ..#..# * We must
4640: 20 68 61 76 65 20 74 77 6f 20 6f 72 20 6d 6f 72 have two or mor
4650: 65 20 66 72 61 67 6d 65 6e 74 73 2c 20 61 73 20 e fragments, as
4660: 73 70 6c 69 74 74 69 6e 67 20 61 0a 09 23 20 20 splitting a..#
4670: 20 63 68 61 6e 67 65 73 65 74 20 69 6e 74 6f 20 changeset into
4680: 6f 6e 65 20 6d 61 6b 65 73 20 6e 6f 20 73 65 6e one makes no sen
4690: 73 65 2e 0a 09 23 20 2a 20 4e 6f 20 66 72 61 67 se...# * No frag
46a0: 6d 65 6e 74 20 6d 61 79 20 62 65 20 65 6d 70 74 ment may be empt
46b0: 79 2e 0a 09 23 20 2a 20 41 6c 6c 20 66 72 61 67 y...# * All frag
46c0: 6d 65 6e 74 73 20 68 61 76 65 20 74 6f 20 62 65 ments have to be
46d0: 20 74 72 75 65 20 73 75 62 73 65 74 73 20 6f 66 true subsets of
46e0: 20 74 68 65 20 69 74 65 6d 73 20 69 6e 20 74 68 the items in th
46f0: 65 0a 09 23 20 20 20 63 68 61 6e 67 65 73 65 74 e..# changeset
4700: 20 74 6f 20 73 70 6c 69 74 2e 20 54 68 65 20 27 to split. The '
4710: 74 72 75 65 27 20 69 73 20 69 6d 70 6c 69 65 64 true' is implied
4720: 20 62 65 63 61 75 73 65 20 6e 6f 6e 65 20 61 72 because none ar
4730: 65 0a 09 23 20 20 20 61 6c 6c 6f 77 65 64 20 74 e..# allowed t
4740: 6f 20 62 65 20 65 6d 70 74 79 2c 20 73 6f 20 65 o be empty, so e
4750: 61 63 68 20 68 61 73 20 74 6f 20 62 65 20 73 6d ach has to be sm
4760: 61 6c 6c 65 72 20 74 68 61 6e 20 74 68 65 0a 09 aller than the..
4770: 23 20 20 20 74 6f 74 61 6c 2e 0a 09 23 20 2a 20 # total...# *
4780: 54 68 65 20 75 6e 69 6f 6e 20 6f 66 20 74 68 65 The union of the
4790: 20 66 72 61 67 6d 65 6e 74 73 20 68 61 73 20 74 fragments has t
47a0: 6f 20 62 65 20 74 68 65 20 69 74 65 6d 20 73 65 o be the item se
47b0: 74 20 6f 66 20 74 68 65 0a 09 23 20 20 20 63 68 t of the..# ch
47c0: 61 6e 67 65 73 65 74 2e 0a 09 23 20 2a 20 54 68 angeset...# * Th
47d0: 65 20 66 72 61 67 6d 65 6e 74 20 6d 75 73 74 20 e fragment must
47e0: 6e 6f 74 20 6f 76 65 72 6c 61 70 2c 20 69 2e 65 not overlap, i.e
47f0: 2e 20 74 68 65 69 72 20 70 61 69 72 77 69 73 65 . their pairwise
4800: 0a 09 23 20 20 20 69 6e 74 65 72 73 65 63 74 69 ..# intersecti
4810: 6f 6e 73 20 68 61 76 65 20 74 6f 20 62 65 20 65 ons have to be e
4820: 6d 70 74 79 2e 0a 0a 09 73 65 74 20 63 6f 76 65 mpty....set cove
4830: 72 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 66 72 r {}..foreach fr
4840: 61 67 6d 65 6e 74 69 74 65 6d 73 20 24 66 72 61 agmentitems $fra
4850: 67 6d 65 6e 74 73 20 7b 0a 09 20 20 20 20 6c 6f gments {.. lo
4860: 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 g write 8 csets
4870: 7b 4e 45 57 3a 20 5b 6c 73 6f 72 74 20 24 66 72 {NEW: [lsort $fr
4880: 61 67 6d 65 6e 74 69 74 65 6d 73 5d 7d 0a 0a 09 agmentitems]}...
4890: 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 73 integrity as
48a0: 73 65 72 74 20 7b 0a 09 09 21 5b 73 74 72 75 63 sert {...![struc
48b0: 74 3a 3a 73 65 74 20 65 6d 70 74 79 20 24 66 72 t::set empty $fr
48c0: 61 67 6d 65 6e 74 69 74 65 6d 73 5d 0a 09 20 20 agmentitems]..
48d0: 20 20 7d 20 7b 63 68 61 6e 67 65 73 65 74 20 66 } {changeset f
48e0: 72 61 67 6d 65 6e 74 20 69 73 20 65 6d 70 74 79 ragment is empty
48f0: 7d 0a 0a 09 20 20 20 20 69 6e 74 65 67 72 69 74 }... integrit
4900: 79 20 61 73 73 65 72 74 20 7b 0a 09 09 5b 73 74 y assert {...[st
4910: 72 75 63 74 3a 3a 73 65 74 20 73 75 62 73 65 74 ruct::set subset
4920: 6f 66 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d of $fragmentitem
4930: 73 20 5b 24 63 73 65 74 20 69 74 65 6d 73 5d 5d s [$cset items]]
4940: 0a 09 20 20 20 20 7d 20 7b 63 68 61 6e 67 65 73 .. } {changes
4950: 65 74 20 66 72 61 67 6d 65 6e 74 20 69 73 20 6e et fragment is n
4960: 6f 74 20 61 20 73 75 62 73 65 74 7d 0a 09 20 20 ot a subset}..
4970: 20 20 73 74 72 75 63 74 3a 3a 73 65 74 20 61 64 struct::set ad
4980: 64 20 63 6f 76 65 72 20 24 66 72 61 67 6d 65 6e d cover $fragmen
4990: 74 69 74 65 6d 73 0a 09 7d 0a 0a 09 69 6e 74 65 titems..}...inte
49a0: 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 0a 09 grity assert {..
49b0: 20 20 20 20 5b 73 74 72 75 63 74 3a 3a 73 65 74 [struct::set
49c0: 20 65 71 75 61 6c 20 24 63 6f 76 65 72 20 5b 24 equal $cover [$
49d0: 63 73 65 74 20 69 74 65 6d 73 5d 5d 0a 09 20 7d cset items]].. }
49e0: 20 7b 54 68 65 20 66 72 61 67 6d 65 6e 74 73 20 {The fragments
49f0: 64 6f 20 6e 6f 74 20 63 6f 76 65 72 20 74 68 65 do not cover the
4a00: 20 6f 72 69 67 69 6e 61 6c 20 63 68 61 6e 67 65 original change
4a10: 73 65 74 7d 0a 0a 09 73 65 74 20 69 20 31 0a 09 set}...set i 1..
4a20: 66 6f 72 65 61 63 68 20 66 69 61 20 24 66 72 61 foreach fia $fra
4a30: 67 6d 65 6e 74 73 20 7b 0a 09 20 20 20 20 66 6f gments {.. fo
4a40: 72 65 61 63 68 20 66 69 62 20 5b 6c 72 61 6e 67 reach fib [lrang
4a50: 65 20 24 66 72 61 67 6d 65 6e 74 73 20 24 69 20 e $fragments $i
4a60: 65 6e 64 5d 20 7b 0a 09 09 69 6e 74 65 67 72 69 end] {...integri
4a70: 74 79 20 61 73 73 65 72 74 20 7b 0a 09 09 20 20 ty assert {...
4a80: 20 20 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 65 [struct::set e
4a90: 6d 70 74 79 20 5b 73 74 72 75 63 74 3a 3a 73 65 mpty [struct::se
4aa0: 74 20 69 6e 74 65 72 73 65 63 74 20 24 66 69 61 t intersect $fia
4ab0: 20 24 66 69 62 5d 5d 0a 09 09 7d 20 7b 54 68 65 $fib]]...} {The
4ac0: 20 66 72 61 67 6d 65 6e 74 73 20 3c 24 66 69 61 fragments <$fia
4ad0: 3e 20 61 6e 64 20 3c 24 66 69 62 3e 20 6f 76 65 > and <$fib> ove
4ae0: 72 6c 61 70 7d 0a 09 20 20 20 20 7d 0a 09 20 20 rlap}.. }..
4af0: 20 20 69 6e 63 72 20 69 0a 09 7d 0a 0a 09 72 65 incr i..}...re
4b00: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
4b10: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 # # ## ### #####
4b20: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 ######## ######
4b30: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 53 #######. ## S
4b40: 74 61 74 65 0a 0a 20 20 20 20 76 61 72 69 61 62 tate.. variab
4b50: 6c 65 20 6d 79 69 64 20 20 20 20 20 20 20 20 7b le myid {
4b60: 7d 20 3b 20 23 20 49 64 20 6f 66 20 74 68 65 20 } ; # Id of the
4b70: 63 73 65 74 20 66 6f 72 20 74 68 65 20 70 65 72 cset for the per
4b80: 73 69 73 74 65 6e 74 0a 09 09 09 20 20 20 20 20 sistent....
4b90: 20 23 20 73 74 61 74 65 2e 0a 20 20 20 20 76 61 # state.. va
4ba0: 72 69 61 62 6c 65 20 6d 79 70 72 6f 6a 65 63 74 riable myproject
4bb0: 20 20 20 7b 7d 20 3b 20 23 20 52 65 66 65 72 65 {} ; # Refere
4bc0: 6e 63 65 20 6f 66 20 74 68 65 20 70 72 6f 6a 65 nce of the proje
4bd0: 63 74 20 6f 62 6a 65 63 74 20 74 68 65 0a 09 09 ct object the...
4be0: 09 20 20 20 20 20 20 23 20 63 68 61 6e 67 65 73 . # changes
4bf0: 65 74 20 62 65 6c 6f 6e 67 73 20 74 6f 2e 0a 20 et belongs to..
4c00: 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 74 79 variable myty
4c10: 70 65 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 57 pe {} ; # W
4c20: 68 61 74 20 74 68 65 20 63 68 61 6e 67 65 73 65 hat the changese
4c30: 74 20 69 73 20 62 61 73 65 64 20 6f 6e 0a 09 09 t is based on...
4c40: 09 20 20 20 20 20 20 23 20 28 72 65 76 69 73 69 . # (revisi
4c50: 6f 6e 73 2c 20 74 61 67 73 2c 20 6f 72 20 62 72 ons, tags, or br
4c60: 61 6e 63 68 65 73 29 2e 0a 09 09 09 20 20 20 20 anches).....
4c70: 20 20 23 20 56 61 6c 75 65 73 3a 20 53 65 65 20 # Values: See
4c80: 6d 79 63 73 74 79 70 65 2e 20 4e 6f 74 65 20 74 mycstype. Note t
4c90: 68 61 74 20 77 65 0a 09 09 09 20 20 20 20 20 20 hat we....
4ca0: 23 20 68 61 76 65 20 74 6f 20 6b 65 65 70 20 74 # have to keep t
4cb0: 68 65 20 6e 61 6d 65 73 20 6f 66 20 74 68 65 20 he names of the
4cc0: 68 65 6c 70 65 72 0a 09 09 09 20 20 20 20 20 20 helper....
4cd0: 23 20 73 69 6e 67 6c 65 74 6f 6e 73 20 69 6e 20 # singletons in
4ce0: 73 79 6e 63 20 77 69 74 68 20 74 68 65 20 63 6f sync with the co
4cf0: 6e 74 65 6e 74 73 0a 09 09 09 20 20 20 20 20 20 ntents....
4d00: 23 20 6f 66 20 73 74 61 74 65 20 74 61 62 6c 65 # of state table
4d10: 20 27 63 73 74 79 70 65 27 2c 20 61 6e 64 20 76 'cstype', and v
4d20: 61 72 69 6f 75 73 0a 09 09 09 20 20 20 20 20 20 arious....
4d30: 23 20 6f 74 68 65 72 20 70 6c 61 63 65 73 20 75 # other places u
4d40: 73 69 6e 67 20 74 68 65 6d 20 68 61 72 64 77 69 sing them hardwi
4d50: 72 65 64 2e 0a 20 20 20 20 76 61 72 69 61 62 6c red.. variabl
4d60: 65 20 6d 79 74 79 70 65 6f 62 6a 20 20 20 7b 7d e mytypeobj {}
4d70: 20 3b 20 23 20 52 65 66 65 72 65 6e 63 65 20 74 ; # Reference t
4d80: 6f 20 74 68 65 20 63 6f 6e 74 61 69 6e 65 72 20 o the container
4d90: 66 6f 72 20 74 68 65 0a 09 09 09 20 20 20 20 20 for the....
4da0: 20 23 20 74 79 70 65 20 64 65 70 65 6e 64 65 6e # type dependen
4db0: 74 20 63 6f 64 65 2e 20 44 65 72 69 76 65 64 20 t code. Derived
4dc0: 66 72 6f 6d 0a 09 09 09 20 20 20 20 20 20 23 20 from.... #
4dd0: 6d 79 74 79 70 65 2e 0a 20 20 20 20 76 61 72 69 mytype.. vari
4de0: 61 62 6c 65 20 6d 79 73 72 63 69 64 20 20 20 20 able mysrcid
4df0: 20 7b 7d 20 3b 20 23 20 49 64 20 6f 66 20 74 68 {} ; # Id of th
4e00: 65 20 6d 65 74 61 64 61 74 61 20 6f 72 20 73 79 e metadata or sy
4e10: 6d 62 6f 6c 20 74 68 65 20 63 73 65 74 0a 09 09 mbol the cset...
4e20: 09 20 20 20 20 20 20 23 20 69 73 20 62 61 73 65 . # is base
4e30: 64 20 6f 6e 2e 0a 20 20 20 20 76 61 72 69 61 62 d on.. variab
4e40: 6c 65 20 6d 79 69 74 65 6d 73 20 20 20 20 20 7b le myitems {
4e50: 7d 20 3b 20 23 20 4c 69 73 74 20 6f 66 20 74 68 } ; # List of th
4e60: 65 20 66 69 6c 65 20 6c 65 76 65 6c 20 72 65 76 e file level rev
4e70: 69 73 69 6f 6e 73 2c 0a 09 09 09 20 20 20 20 20 isions,....
4e80: 20 23 20 74 61 67 73 2c 20 6f 72 20 62 72 61 6e # tags, or bran
4e90: 63 68 65 73 20 69 6e 20 74 68 65 20 63 73 65 74 ches in the cset
4ea0: 2c 20 61 73 0a 09 09 09 20 20 20 20 20 20 23 20 , as.... #
4eb0: 69 64 73 2e 20 4e 6f 74 20 74 61 67 67 65 64 2e ids. Not tagged.
4ec0: 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 . variable my
4ed0: 74 69 74 65 6d 73 20 20 20 20 7b 7d 20 3b 20 23 titems {} ; #
4ee0: 20 41 73 20 6d 79 69 74 65 6d 73 2c 20 74 68 65 As myitems, the
4ef0: 20 74 61 67 67 65 64 20 66 6f 72 6d 2e 0a 20 20 tagged form..
4f00: 20 20 76 61 72 69 61 62 6c 65 20 6d 79 70 6f 73 variable mypos
4f10: 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 43 6f {} ; # Co
4f20: 6d 6d 69 74 20 70 6f 73 69 74 69 6f 6e 20 6f 66 mmit position of
4f30: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 2c 20 the changeset,
4f40: 69 66 0a 09 09 09 20 20 20 20 20 20 23 20 6b 6e if.... # kn
4f50: 6f 77 6e 2e 0a 0a 20 20 20 20 23 20 23 20 23 23 own... # # ##
4f60: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
4f70: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
4f80: 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72 6e 61 #. ## Interna
4f90: 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20 20 74 l methods.. t
4fa0: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 63 6f ypevariable myco
4fb0: 75 6e 74 65 72 20 20 20 20 20 20 20 20 30 20 3b unter 0 ;
4fc0: 20 23 20 49 64 20 63 6f 75 6e 74 65 72 20 66 6f # Id counter fo
4fd0: 72 20 63 73 65 74 73 2e 20 4c 61 73 74 20 69 64 r csets. Last id
4fe0: 0a 09 09 09 09 20 20 20 20 20 20 23 20 75 73 65 ..... # use
4ff0: 64 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 d.. typevaria
5000: 62 6c 65 20 6d 79 63 73 74 79 70 65 20 2d 61 72 ble mycstype -ar
5010: 72 61 79 20 7b 7d 20 3b 20 23 20 4d 61 70 20 63 ray {} ; # Map c
5020: 73 74 79 70 65 73 20 28 6e 61 6d 65 73 29 20 74 stypes (names) t
5030: 6f 20 70 65 72 73 69 73 74 65 6e 74 0a 09 09 09 o persistent....
5040: 09 20 20 20 20 20 20 23 20 69 64 73 2e 20 4e 6f . # ids. No
5050: 74 65 20 74 68 61 74 20 77 65 20 68 61 76 65 20 te that we have
5060: 74 6f 20 6b 65 65 70 0a 09 09 09 09 20 20 20 20 to keep.....
5070: 20 20 23 20 74 68 65 20 6e 61 6d 65 73 20 69 6e # the names in
5080: 20 74 68 65 20 74 61 62 6c 65 20 27 63 73 74 79 the table 'csty
5090: 70 65 27 0a 09 09 09 09 20 20 20 20 20 20 23 20 pe'..... #
50a0: 69 6e 20 73 79 6e 63 20 77 69 74 68 20 74 68 65 in sync with the
50b0: 20 6e 61 6d 65 73 20 6f 66 20 74 68 65 0a 09 09 names of the...
50c0: 09 09 20 20 20 20 20 20 23 20 68 65 6c 70 65 72 .. # helper
50d0: 20 73 69 6e 67 6c 65 74 6f 6e 73 2e 0a 0a 20 20 singletons...
50e0: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 6e 6f typemethod ino
50f0: 72 64 65 72 20 7b 70 72 6f 6a 65 63 74 69 64 7d rder {projectid}
5100: 20 7b 0a 09 23 20 52 65 74 75 72 6e 20 61 6c 6c {..# Return all
5110: 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 revision change
5120: 73 65 74 73 20 66 6f 72 20 74 68 65 20 73 70 65 sets for the spe
5130: 63 69 66 69 65 64 20 70 72 6f 6a 65 63 74 2c 20 cified project,
5140: 69 6e 0a 09 23 20 74 68 65 20 6f 72 64 65 72 20 in..# the order
5150: 67 69 76 65 6e 20 74 6f 20 74 68 65 6d 20 62 79 given to them by
5160: 20 74 68 65 20 73 6f 72 74 20 70 61 73 73 65 73 the sort passes
5170: 2e 20 42 6f 74 68 20 74 68 65 0a 09 23 20 66 69 . Both the..# fi
5180: 6c 74 65 72 69 6e 67 20 62 79 20 70 72 6f 6a 65 ltering by proje
5190: 63 74 20 61 6e 64 20 73 6f 72 74 69 6e 67 20 6d ct and sorting m
51a0: 61 6b 65 20 75 73 65 20 6f 66 20 27 70 72 6f 6a ake use of 'proj
51b0: 65 63 74 3a 3a 72 65 76 0a 09 23 20 72 65 76 27 ect::rev..# rev'
51c0: 20 69 6d 70 6f 73 73 69 62 6c 65 2e 0a 0a 09 73 impossible....s
51d0: 65 74 20 72 65 73 20 7b 7d 0a 09 66 6f 72 65 61 et res {}..forea
51e0: 63 68 20 7b 63 69 64 20 63 64 61 74 65 7d 20 5b ch {cid cdate} [
51f0: 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 state run {..
5200: 20 53 45 4c 45 43 54 20 43 2e 63 69 64 2c 20 54 SELECT C.cid, T
5210: 2e 64 61 74 65 0a 09 20 20 20 20 46 52 4f 4d 20 .date.. FROM
5220: 20 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 63 changeset C, c
5230: 73 74 69 6d 65 73 74 61 6d 70 20 54 0a 09 20 20 stimestamp T..
5240: 20 20 57 48 45 52 45 20 20 43 2e 74 79 70 65 20 WHERE C.type
5250: 3d 20 30 20 20 20 20 20 20 20 20 20 20 2d 2d 20 = 0 --
5260: 6c 69 6d 69 74 20 74 6f 20 72 65 76 69 73 69 6f limit to revisio
5270: 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 09 20 20 n changesets..
5280: 20 20 41 4e 44 20 20 20 20 43 2e 70 69 64 20 20 AND C.pid
5290: 3d 20 24 70 72 6f 6a 65 63 74 69 64 20 2d 2d 20 = $projectid --
52a0: 6c 69 6d 69 74 20 74 6f 20 63 68 61 6e 67 65 73 limit to changes
52b0: 65 74 73 20 69 6e 20 70 72 6f 6a 65 63 74 0a 09 ets in project..
52c0: 20 20 20 20 41 4e 44 20 20 20 20 54 2e 63 69 64 AND T.cid
52d0: 20 20 3d 20 43 2e 63 69 64 20 20 20 20 20 20 2d = C.cid -
52e0: 2d 20 67 65 74 20 6f 72 64 65 72 69 6e 67 20 69 - get ordering i
52f0: 6e 66 6f 72 6d 61 74 69 6f 6e 0a 09 20 20 20 20 nformation..
5300: 4f 52 44 45 52 20 42 59 20 54 2e 64 61 74 65 20 ORDER BY T.date
5310: 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 73 6f -- so
5320: 72 74 20 69 6e 74 6f 20 63 6f 6d 6d 69 74 20 6f rt into commit o
5330: 72 64 65 72 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 rder..}] {..
5340: 6c 61 70 70 65 6e 64 20 72 65 73 20 24 6d 79 69 lappend res $myi
5350: 64 6d 61 70 28 24 63 69 64 29 20 24 63 64 61 74 dmap($cid) $cdat
5360: 65 0a 09 7d 0a 09 72 65 74 75 72 6e 20 24 72 65 e..}..return $re
5370: 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 s. }.. typ
5380: 65 6d 65 74 68 6f 64 20 67 65 74 63 73 74 79 70 emethod getcstyp
5390: 65 73 20 7b 7d 20 7b 0a 09 66 6f 72 65 61 63 68 es {} {..foreach
53a0: 20 7b 74 69 64 20 6e 61 6d 65 7d 20 5b 73 74 61 {tid name} [sta
53b0: 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 te run {.. SE
53c0: 4c 45 43 54 20 74 69 64 2c 20 6e 61 6d 65 20 46 LECT tid, name F
53d0: 52 4f 4d 20 63 73 74 79 70 65 3b 0a 09 7d 5d 20 ROM cstype;..}]
53e0: 7b 20 73 65 74 20 6d 79 63 73 74 79 70 65 28 24 { set mycstype($
53f0: 6e 61 6d 65 29 20 24 74 69 64 20 7d 0a 09 72 65 name) $tid }..re
5400: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
5410: 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61 64 20 typemethod load
5420: 7b 72 65 70 6f 73 69 74 6f 72 79 7d 20 7b 0a 09 {repository} {..
5430: 73 65 74 20 6e 20 30 0a 09 6c 6f 67 20 77 72 69 set n 0..log wri
5440: 74 65 20 32 20 63 73 65 74 73 20 7b 4c 6f 61 64 te 2 csets {Load
5450: 69 6e 67 20 74 68 65 20 63 68 61 6e 67 65 73 65 ing the changese
5460: 74 73 7d 0a 09 66 6f 72 65 61 63 68 20 7b 69 64 ts}..foreach {id
5470: 20 70 69 64 20 63 73 74 79 70 65 20 73 72 63 69 pid cstype srci
5480: 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a d} [state run {.
5490: 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 . SELECT C.ci
54a0: 64 2c 20 43 2e 70 69 64 2c 20 43 53 2e 6e 61 6d d, C.pid, CS.nam
54b0: 65 2c 20 43 2e 73 72 63 0a 09 20 20 20 20 46 52 e, C.src.. FR
54c0: 4f 4d 20 20 20 63 68 61 6e 67 65 73 65 74 20 43 OM changeset C
54d0: 2c 20 63 73 74 79 70 65 20 43 53 0a 09 20 20 20 , cstype CS..
54e0: 20 57 48 45 52 45 20 20 43 2e 74 79 70 65 20 3d WHERE C.type =
54f0: 20 43 53 2e 74 69 64 0a 09 20 20 20 20 4f 52 44 CS.tid.. ORD
5500: 45 52 20 42 59 20 43 2e 63 69 64 0a 09 7d 5d 20 ER BY C.cid..}]
5510: 7b 0a 09 20 20 20 20 6c 6f 67 20 70 72 6f 67 72 {.. log progr
5520: 65 73 73 20 32 20 63 73 65 74 73 20 24 6e 20 7b ess 2 csets $n {
5530: 7d 0a 09 20 20 20 20 73 65 74 20 72 20 5b 24 74 }.. set r [$t
5540: 79 70 65 20 25 41 55 54 4f 25 20 5b 24 72 65 70 ype %AUTO% [$rep
5550: 6f 73 69 74 6f 72 79 20 70 72 6f 6a 65 63 74 6f ository projecto
5560: 66 20 24 70 69 64 5d 20 24 63 73 74 79 70 65 20 f $pid] $cstype
5570: 24 73 72 63 69 64 20 5b 73 74 61 74 65 20 72 75 $srcid [state ru
5580: 6e 20 7b 0a 09 09 53 45 4c 45 43 54 20 43 2e 69 n {...SELECT C.i
5590: 69 64 0a 09 09 46 52 4f 4d 20 20 20 63 73 69 74 id...FROM csit
55a0: 65 6d 20 43 0a 09 09 57 48 45 52 45 20 20 43 2e em C...WHERE C.
55b0: 63 69 64 20 3d 20 24 69 64 0a 09 09 4f 52 44 45 cid = $id...ORDE
55c0: 52 20 42 59 20 43 2e 70 6f 73 0a 09 20 20 20 20 R BY C.pos..
55d0: 7d 5d 20 24 69 64 5d 0a 09 20 20 20 20 69 6e 63 }] $id].. inc
55e0: 72 20 6e 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 r n..}..return.
55f0: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 }.. typeme
5600: 74 68 6f 64 20 6c 6f 61 64 63 6f 75 6e 74 65 72 thod loadcounter
5610: 20 7b 7d 20 7b 0a 09 23 20 49 6e 69 74 69 61 6c {} {..# Initial
5620: 69 7a 65 20 74 68 65 20 63 6f 75 6e 74 65 72 20 ize the counter
5630: 66 72 6f 6d 20 74 68 65 20 73 74 61 74 65 0a 09 from the state..
5640: 6c 6f 67 20 77 72 69 74 65 20 32 20 63 73 65 74 log write 2 cset
5650: 73 20 7b 4c 6f 61 64 69 6e 67 20 63 68 61 6e 67 s {Loading chang
5660: 65 73 65 74 20 63 6f 75 6e 74 65 72 7d 0a 09 73 eset counter}..s
5670: 65 74 20 6d 79 63 6f 75 6e 74 65 72 20 5b 73 74 et mycounter [st
5680: 61 74 65 20 6f 6e 65 20 7b 20 53 45 4c 45 43 54 ate one { SELECT
5690: 20 4d 41 58 28 63 69 64 29 20 46 52 4f 4d 20 63 MAX(cid) FROM c
56a0: 68 61 6e 67 65 73 65 74 20 7d 5d 0a 09 72 65 74 hangeset }]..ret
56b0: 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 urn. }.. t
56c0: 79 70 65 6d 65 74 68 6f 64 20 6e 75 6d 20 7b 7d ypemethod num {}
56d0: 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 63 6f 75 { return $mycou
56e0: 6e 74 65 72 20 7d 0a 0a 20 20 20 20 70 72 6f 63 nter }.. proc
56f0: 20 49 6e 69 74 69 61 6c 69 7a 65 42 72 65 61 6b InitializeBreak
5700: 53 74 61 74 65 20 7b 72 65 76 69 73 69 6f 6e 73 State {revisions
5710: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 70 6f 73 } {..upvar 1 pos
5720: 20 70 6f 73 20 63 72 6f 73 73 20 63 72 6f 73 73 pos cross cross
5730: 20 72 61 6e 67 65 20 72 61 6e 67 65 20 64 65 70 range range dep
5740: 63 20 64 65 70 63 20 64 65 6c 74 61 20 64 65 6c c depc delta del
5750: 74 61 20 5c 0a 09 20 20 20 20 64 65 70 65 6e 64 ta \.. depend
5760: 65 6e 63 69 65 73 20 64 65 70 65 6e 64 65 6e 63 encies dependenc
5770: 69 65 73 0a 0a 09 23 20 46 69 72 73 74 20 77 65 ies...# First we
5780: 20 63 72 65 61 74 65 20 61 20 6d 61 70 20 6f 66 create a map of
5790: 20 70 6f 73 69 74 69 6f 6e 73 20 74 6f 20 6d 61 positions to ma
57a0: 6b 65 20 69 74 20 65 61 73 69 65 72 20 74 6f 0a ke it easier to.
57b0: 09 23 20 64 65 74 65 72 6d 69 6e 65 20 77 68 65 .# determine whe
57c0: 74 68 65 72 20 61 20 64 65 70 65 6e 64 65 6e 63 ther a dependenc
57d0: 79 20 63 72 6f 73 73 65 73 20 61 20 70 61 72 74 y crosses a part
57e0: 69 63 75 6c 61 72 20 69 6e 64 65 78 2e 0a 0a 09 icular index....
57f0: 61 72 72 61 79 20 73 65 74 20 70 6f 73 20 20 20 array set pos
5800: 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 20 63 72 {}..array set cr
5810: 6f 73 73 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 oss {}..array se
5820: 74 20 64 65 70 63 20 20 7b 7d 0a 09 73 65 74 20 t depc {}..set
5830: 72 61 6e 67 65 20 20 20 20 20 20 20 7b 7d 0a 09 range {}..
5840: 73 65 74 20 6e 20 30 0a 09 66 6f 72 65 61 63 68 set n 0..foreach
5850: 20 72 65 76 20 24 72 65 76 69 73 69 6f 6e 73 20 rev $revisions
5860: 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 72 {.. lappend r
5870: 61 6e 67 65 20 24 6e 0a 09 20 20 20 20 73 65 74 ange $n.. set
5880: 20 70 6f 73 28 24 72 65 76 29 20 24 6e 0a 09 20 pos($rev) $n..
5890: 20 20 20 73 65 74 20 63 72 6f 73 73 28 24 6e 29 set cross($n)
58a0: 20 30 0a 09 20 20 20 20 69 6e 63 72 20 6e 0a 09 0.. incr n..
58b0: 7d 0a 0a 09 23 20 53 65 63 6f 6e 64 6c 79 20 77 }...# Secondly w
58c0: 65 20 63 6f 75 6e 74 20 74 68 65 20 63 72 6f 73 e count the cros
58d0: 73 69 6e 67 73 20 70 65 72 20 70 6f 73 69 74 69 sings per positi
58e0: 6f 6e 2c 20 62 79 20 69 74 65 72 61 74 69 6e 67 on, by iterating
58f0: 0a 09 23 20 6f 76 65 72 20 74 68 65 20 72 65 63 ..# over the rec
5900: 6f 72 64 65 64 20 69 6e 74 65 72 6e 61 6c 20 64 orded internal d
5910: 65 70 65 6e 64 65 6e 63 69 65 73 2e 0a 0a 09 23 ependencies....#
5920: 20 4e 6f 74 65 3a 20 49 66 20 74 68 65 20 74 69 Note: If the ti
5930: 6d 65 73 74 61 6d 70 73 20 61 72 65 20 62 61 64 mestamps are bad
5940: 6c 79 20 6f 75 74 20 6f 66 20 6f 72 64 65 72 20 ly out of order
5950: 69 74 20 69 73 0a 09 23 20 20 20 20 20 20 20 70 it is..# p
5960: 6f 73 73 69 62 6c 65 20 74 6f 20 68 61 76 65 20 ossible to have
5970: 61 20 62 61 63 6b 77 61 72 64 20 73 75 63 63 65 a backward succe
5980: 73 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 79 2c ssor dependency,
5990: 0a 09 23 20 20 20 20 20 20 20 69 2e 65 2e 20 77 ..# i.e. w
59a0: 69 74 68 20 73 74 61 72 74 20 3e 20 65 6e 64 2e ith start > end.
59b0: 20 57 65 20 6d 61 79 20 68 61 76 65 20 74 6f 20 We may have to
59c0: 73 77 61 70 20 74 68 65 20 69 6e 64 69 63 65 73 swap the indices
59d0: 0a 09 23 20 20 20 20 20 20 20 74 6f 20 65 6e 73 ..# to ens
59e0: 75 72 65 20 74 68 61 74 20 74 68 65 20 66 6f 6c ure that the fol
59f0: 6c 6f 77 69 6e 67 20 6c 6f 6f 70 20 72 75 6e 73 lowing loop runs
5a00: 20 63 6f 72 72 65 63 74 6c 79 2e 0a 09 23 0a 09 correctly...#..
5a10: 23 20 4e 6f 74 65 20 32 3a 20 73 74 61 72 74 20 # Note 2: start
5a20: 3d 3d 20 65 6e 64 20 69 73 20 6e 6f 74 20 70 6f == end is not po
5a30: 73 73 69 62 6c 65 2e 20 49 74 20 69 6e 64 69 63 ssible. It indic
5a40: 61 74 65 73 20 61 0a 09 23 20 20 20 20 20 20 20 ates a..#
5a50: 20 20 73 65 6c 66 2d 64 65 70 65 6e 64 65 6e 63 self-dependenc
5a60: 79 20 64 75 65 20 74 6f 20 74 68 65 20 75 6e 69 y due to the uni
5a70: 71 75 65 6e 65 73 73 20 6f 66 20 70 6f 73 69 74 queness of posit
5a80: 69 6f 6e 73 2c 0a 09 23 20 20 20 20 20 20 20 20 ions,..#
5a90: 20 61 6e 64 20 74 68 61 74 20 69 73 20 73 6f 6d and that is som
5aa0: 65 74 68 69 6e 67 20 77 65 20 68 61 76 65 20 72 ething we have r
5ab0: 75 6c 65 64 20 6f 75 74 20 61 6c 72 65 61 64 79 uled out already
5ac0: 2c 20 73 65 65 0a 09 23 20 20 20 20 20 20 20 20 , see..#
5ad0: 20 27 72 65 76 20 69 6e 74 65 72 6e 61 6c 73 75 'rev internalsu
5ae0: 63 63 65 73 73 6f 72 73 27 2e 0a 0a 09 66 6f 72 ccessors'....for
5af0: 65 61 63 68 20 7b 72 69 64 20 63 68 69 6c 64 72 each {rid childr
5b00: 65 6e 7d 20 5b 61 72 72 61 79 20 67 65 74 20 64 en} [array get d
5b10: 65 70 65 6e 64 65 6e 63 69 65 73 5d 20 7b 0a 09 ependencies] {..
5b20: 20 20 20 20 66 6f 72 65 61 63 68 20 63 68 69 6c foreach chil
5b30: 64 20 24 63 68 69 6c 64 72 65 6e 20 7b 0a 09 09 d $children {...
5b40: 73 65 74 20 64 6b 65 79 20 20 20 20 5b 6c 69 73 set dkey [lis
5b50: 74 20 24 72 69 64 20 24 63 68 69 6c 64 5d 0a 09 t $rid $child]..
5b60: 09 73 65 74 20 73 74 61 72 74 20 20 20 24 70 6f .set start $po
5b70: 73 28 24 72 69 64 29 0a 09 09 73 65 74 20 65 6e s($rid)...set en
5b80: 64 20 20 20 20 20 24 70 6f 73 28 24 63 68 69 6c d $pos($chil
5b90: 64 29 0a 09 09 73 65 74 20 63 72 6f 73 73 65 73 d)...set crosses
5ba0: 20 7b 7d 0a 0a 09 09 69 66 20 7b 24 73 74 61 72 {}....if {$star
5bb0: 74 20 3e 20 24 65 6e 64 7d 20 7b 0a 09 09 20 20 t > $end} {...
5bc0: 20 20 77 68 69 6c 65 20 7b 24 65 6e 64 20 3c 20 while {$end <
5bd0: 24 73 74 61 72 74 7d 20 7b 0a 09 09 09 6c 61 70 $start} {....lap
5be0: 70 65 6e 64 20 63 72 6f 73 73 65 73 20 24 65 6e pend crosses $en
5bf0: 64 0a 09 09 09 69 6e 63 72 20 63 72 6f 73 73 28 d....incr cross(
5c00: 24 65 6e 64 29 0a 09 09 09 69 6e 63 72 20 65 6e $end)....incr en
5c10: 64 0a 09 09 20 20 20 20 7d 0a 09 09 7d 20 65 6c d... }...} el
5c20: 73 65 20 7b 0a 09 09 20 20 20 20 77 68 69 6c 65 se {... while
5c30: 20 7b 24 73 74 61 72 74 20 3c 20 24 65 6e 64 7d {$start < $end}
5c40: 20 7b 0a 09 09 09 6c 61 70 70 65 6e 64 20 63 72 {....lappend cr
5c50: 6f 73 73 65 73 20 24 73 74 61 72 74 0a 09 09 09 osses $start....
5c60: 69 6e 63 72 20 63 72 6f 73 73 28 24 73 74 61 72 incr cross($star
5c70: 74 29 0a 09 09 09 69 6e 63 72 20 73 74 61 72 74 t)....incr start
5c80: 0a 09 09 20 20 20 20 7d 0a 09 09 7d 0a 09 09 73 ... }...}...s
5c90: 65 74 20 64 65 70 63 28 24 64 6b 65 79 29 20 24 et depc($dkey) $
5ca0: 63 72 6f 73 73 65 73 0a 09 20 20 20 20 7d 0a 09 crosses.. }..
5cb0: 7d 0a 0a 09 49 6e 69 74 69 61 6c 69 7a 65 44 65 }...InitializeDe
5cc0: 6c 74 61 73 20 24 72 65 76 69 73 69 6f 6e 73 0a ltas $revisions.
5cd0: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 .return. }..
5ce0: 20 20 20 70 72 6f 63 20 49 6e 69 74 69 61 6c 69 proc Initiali
5cf0: 7a 65 44 65 6c 74 61 73 20 7b 72 65 76 69 73 69 zeDeltas {revisi
5d00: 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 ons} {..upvar 1
5d10: 64 65 6c 74 61 20 64 65 6c 74 61 0a 0a 09 23 20 delta delta...#
5d20: 50 75 6c 6c 20 74 68 65 20 74 69 6d 65 73 74 61 Pull the timesta
5d30: 6d 70 73 20 66 6f 72 20 61 6c 6c 20 72 65 76 69 mps for all revi
5d40: 73 69 6f 6e 73 20 69 6e 20 74 68 65 20 63 68 61 sions in the cha
5d50: 6e 67 65 73 65 74 73 20 61 6e 64 0a 09 23 20 63 ngesets and..# c
5d60: 6f 6d 70 75 74 65 20 74 68 65 69 72 20 64 65 6c ompute their del
5d70: 74 61 73 20 66 6f 72 20 75 73 65 20 62 79 20 74 tas for use by t
5d80: 68 65 20 62 72 65 61 6b 20 66 69 6e 64 65 72 2e he break finder.
5d90: 0a 0a 09 61 72 72 61 79 20 73 65 74 20 64 65 6c ...array set del
5da0: 74 61 20 7b 7d 0a 09 61 72 72 61 79 20 73 65 74 ta {}..array set
5db0: 20 73 74 61 6d 70 20 7b 7d 0a 0a 09 73 65 74 20 stamp {}...set
5dc0: 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 theset ('[join $
5dd0: 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d revisions {','}]
5de0: 27 29 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 ')..foreach {rid
5df0: 20 74 69 6d 65 7d 20 5b 73 74 61 74 65 20 72 75 time} [state ru
5e00: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d n [subst -nocomm
5e10: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 ands -nobackslas
5e20: 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 hes {.. SELEC
5e30: 54 20 52 2e 72 69 64 2c 20 52 2e 64 61 74 65 0a T R.rid, R.date.
5e40: 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 . FROM revisi
5e50: 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 on R.. WHERE
5e60: 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 R.rid IN $theset
5e70: 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 73 65 74 ..}]] {.. set
5e80: 20 73 74 61 6d 70 28 24 72 69 64 29 20 24 74 69 stamp($rid) $ti
5e90: 6d 65 0a 09 7d 0a 0a 09 73 65 74 20 6e 20 30 0a me..}...set n 0.
5ea0: 09 66 6f 72 65 61 63 68 20 72 69 64 20 5b 6c 72 .foreach rid [lr
5eb0: 61 6e 67 65 20 24 72 65 76 69 73 69 6f 6e 73 20 ange $revisions
5ec0: 30 20 65 6e 64 2d 31 5d 20 72 6e 65 78 74 20 5b 0 end-1] rnext [
5ed0: 6c 72 61 6e 67 65 20 24 72 65 76 69 73 69 6f 6e lrange $revision
5ee0: 73 20 31 20 65 6e 64 5d 20 7b 0a 09 20 20 20 20 s 1 end] {..
5ef0: 73 65 74 20 64 65 6c 74 61 28 24 6e 29 20 5b 65 set delta($n) [e
5f00: 78 70 72 20 7b 24 73 74 61 6d 70 28 24 72 6e 65 xpr {$stamp($rne
5f10: 78 74 29 20 2d 20 24 73 74 61 6d 70 28 24 72 69 xt) - $stamp($ri
5f20: 64 29 7d 5d 0a 09 20 20 20 20 69 6e 63 72 20 6e d)}].. incr n
5f30: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 ..}..return.
5f40: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 46 69 6e 64 }.. proc Find
5f50: 42 65 73 74 42 72 65 61 6b 20 7b 72 61 6e 67 65 BestBreak {range
5f60: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 63 72 6f } {..upvar 1 cro
5f70: 73 73 20 63 72 6f 73 73 20 64 65 6c 74 61 20 64 ss cross delta d
5f80: 65 6c 74 61 0a 0a 09 23 20 44 65 74 65 72 6d 69 elta...# Determi
5f90: 6e 65 20 74 68 65 20 62 65 73 74 20 62 72 65 61 ne the best brea
5fa0: 6b 20 6c 6f 63 61 74 69 6f 6e 20 69 6e 20 74 68 k location in th
5fb0: 65 20 67 69 76 65 6e 20 72 61 6e 67 65 20 6f 66 e given range of
5fc0: 0a 09 23 20 70 6f 73 69 74 69 6f 6e 73 2e 20 46 ..# positions. F
5fd0: 69 72 73 74 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 irst we look for
5fe0: 20 74 68 65 20 6c 6f 63 61 74 69 6f 6e 73 20 77 the locations w
5ff0: 69 74 68 20 74 68 65 20 6d 61 78 69 6d 61 6c 0a ith the maximal.
6000: 09 23 20 6e 75 6d 62 65 72 20 6f 66 20 63 72 6f .# number of cro
6010: 73 73 69 6e 67 73 2e 20 49 66 20 74 68 65 72 65 ssings. If there
6020: 20 61 72 65 20 73 65 76 65 72 61 6c 20 77 65 20 are several we
6030: 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 0a 09 23 20 look for the..#
6040: 73 68 6f 72 74 65 73 74 20 74 69 6d 65 20 69 6e shortest time in
6050: 74 65 72 76 61 6c 20 61 6d 6f 6e 67 20 74 68 65 terval among the
6060: 6d 2e 20 49 66 20 77 65 20 73 74 69 6c 6c 20 68 m. If we still h
6070: 61 76 65 20 6d 75 6c 74 69 70 6c 65 0a 09 23 20 ave multiple..#
6080: 70 6f 73 73 69 62 69 6c 69 74 69 65 73 20 61 66 possibilities af
6090: 74 65 72 20 74 68 61 74 20 77 65 20 73 65 6c 65 ter that we sele
60a0: 63 74 20 74 68 65 20 65 61 72 6c 69 65 73 74 20 ct the earliest
60b0: 6c 6f 63 61 74 69 6f 6e 0a 09 23 20 61 6d 6f 6e location..# amon
60c0: 67 20 74 68 65 73 65 2e 0a 0a 09 23 20 4e 6f 74 g these....# Not
60d0: 65 3a 20 49 66 20 74 68 65 20 6d 61 78 69 6d 61 e: If the maxima
60e0: 6c 20 6e 75 6d 62 65 72 20 6f 66 20 63 72 6f 73 l number of cros
60f0: 73 69 6e 67 73 20 69 73 20 30 20 74 68 65 6e 20 sings is 0 then
6100: 74 68 65 20 72 61 6e 67 65 0a 09 23 20 20 20 20 the range..#
6110: 20 20 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e has no intern
6120: 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 2c al dependencies,
6130: 20 61 6e 64 20 6e 6f 20 62 72 65 61 6b 20 6c 6f and no break lo
6140: 63 61 74 69 6f 6e 20 61 74 0a 09 23 20 20 20 20 cation at..#
6150: 20 20 20 61 6c 6c 2e 20 54 68 69 73 20 70 6f 73 all. This pos
6160: 73 69 62 69 6c 69 74 79 20 69 73 20 73 69 67 6e sibility is sign
6170: 61 6c 65 64 20 76 69 61 20 72 65 73 75 6c 74 20 aled via result
6180: 2d 31 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 41 20 -1....# Note: A
6190: 72 61 6e 67 65 20 6f 66 20 6c 65 6e 67 74 68 20 range of length
61a0: 31 20 6f 72 20 6c 65 73 73 20 63 61 6e 6e 6f 74 1 or less cannot
61b0: 20 68 61 76 65 20 69 6e 74 65 72 6e 61 6c 0a 09 have internal..
61c0: 23 20 20 20 20 20 20 20 64 65 70 65 6e 64 65 6e # dependen
61d0: 63 69 65 73 2c 20 61 73 20 74 68 61 74 20 6e 65 cies, as that ne
61e0: 65 64 73 20 61 74 20 6c 65 61 73 74 20 74 77 6f eds at least two
61f0: 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 0a 09 23 revisions in..#
6200: 20 20 20 20 20 20 20 74 68 65 20 72 61 6e 67 65 the range
6210: 2e 0a 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 ....if {[llength
6220: 20 24 72 61 6e 67 65 5d 20 3c 20 32 7d 20 7b 20 $range] < 2} {
6230: 72 65 74 75 72 6e 20 2d 31 20 7d 0a 0a 09 73 65 return -1 }...se
6240: 74 20 6d 61 78 20 2d 31 0a 09 73 65 74 20 62 65 t max -1..set be
6250: 73 74 20 7b 7d 0a 0a 09 66 6f 72 65 61 63 68 20 st {}...foreach
6260: 6c 6f 63 61 74 69 6f 6e 20 24 72 61 6e 67 65 20 location $range
6270: 7b 0a 09 20 20 20 20 73 65 74 20 63 72 6f 73 73 {.. set cross
6280: 69 6e 67 73 20 24 63 72 6f 73 73 28 24 6c 6f 63 ings $cross($loc
6290: 61 74 69 6f 6e 29 0a 09 20 20 20 20 69 66 20 7b ation).. if {
62a0: 24 63 72 6f 73 73 69 6e 67 73 20 3e 20 24 6d 61 $crossings > $ma
62b0: 78 7d 20 7b 0a 09 09 73 65 74 20 6d 61 78 20 20 x} {...set max
62c0: 24 63 72 6f 73 73 69 6e 67 73 0a 09 09 73 65 74 $crossings...set
62d0: 20 62 65 73 74 20 5b 6c 69 73 74 20 24 6c 6f 63 best [list $loc
62e0: 61 74 69 6f 6e 5d 0a 09 09 63 6f 6e 74 69 6e 75 ation]...continu
62f0: 65 0a 09 20 20 20 20 7d 20 65 6c 73 65 69 66 20 e.. } elseif
6300: 7b 24 63 72 6f 73 73 69 6e 67 73 20 3d 3d 20 24 {$crossings == $
6310: 6d 61 78 7d 20 7b 0a 09 09 6c 61 70 70 65 6e 64 max} {...lappend
6320: 20 62 65 73 74 20 24 6c 6f 63 61 74 69 6f 6e 0a best $location.
6330: 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b . }..}...if {
6340: 24 6d 61 78 20 3d 3d 20 30 7d 20 20 20 20 20 20 $max == 0}
6350: 20 20 20 20 20 20 7b 20 72 65 74 75 72 6e 20 2d { return -
6360: 31 20 7d 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 1 }..if {[llengt
6370: 68 20 24 62 65 73 74 5d 20 3d 3d 20 31 7d 20 7b h $best] == 1} {
6380: 20 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78 20 return [lindex
6390: 24 62 65 73 74 20 30 5d 20 7d 0a 0a 09 73 65 74 $best 0] }...set
63a0: 20 6c 6f 63 61 74 69 6f 6e 73 20 24 62 65 73 74 locations $best
63b0: 0a 09 73 65 74 20 62 65 73 74 20 7b 7d 0a 09 73 ..set best {}..s
63c0: 65 74 20 6d 69 6e 20 2d 31 0a 0a 09 66 6f 72 65 et min -1...fore
63d0: 61 63 68 20 6c 6f 63 61 74 69 6f 6e 20 24 6c 6f ach location $lo
63e0: 63 61 74 69 6f 6e 73 20 7b 0a 09 20 20 20 20 73 cations {.. s
63f0: 65 74 20 69 6e 74 65 72 76 61 6c 20 24 64 65 6c et interval $del
6400: 74 61 28 24 6c 6f 63 61 74 69 6f 6e 29 0a 09 20 ta($location)..
6410: 20 20 20 69 66 20 7b 28 24 6d 69 6e 20 3c 20 30 if {($min < 0
6420: 29 20 7c 7c 20 28 24 69 6e 74 65 72 76 61 6c 20 ) || ($interval
6430: 3c 20 24 6d 69 6e 29 7d 20 7b 0a 09 09 73 65 74 < $min)} {...set
6440: 20 6d 69 6e 20 20 24 69 6e 74 65 72 76 61 6c 0a min $interval.
6450: 09 09 73 65 74 20 62 65 73 74 20 5b 6c 69 73 74 ..set best [list
6460: 20 24 6c 6f 63 61 74 69 6f 6e 5d 0a 09 20 20 20 $location]..
6470: 20 7d 20 65 6c 73 65 69 66 20 7b 24 69 6e 74 65 } elseif {$inte
6480: 72 76 61 6c 20 3d 3d 20 24 6d 69 6e 7d 20 7b 0a rval == $min} {.
6490: 09 09 6c 61 70 70 65 6e 64 20 62 65 73 74 20 24 ..lappend best $
64a0: 6c 6f 63 61 74 69 6f 6e 0a 09 20 20 20 20 7d 0a location.. }.
64b0: 09 7d 0a 0a 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 .}...if {[llengt
64c0: 68 20 24 62 65 73 74 5d 20 3d 3d 20 31 7d 20 7b h $best] == 1} {
64d0: 20 72 65 74 75 72 6e 20 5b 6c 69 6e 64 65 78 20 return [lindex
64e0: 24 62 65 73 74 20 30 5d 20 7d 0a 0a 09 72 65 74 $best 0] }...ret
64f0: 75 72 6e 20 5b 6c 69 6e 64 65 78 20 5b 6c 73 6f urn [lindex [lso
6500: 72 74 20 2d 69 6e 74 65 67 65 72 20 2d 69 6e 63 rt -integer -inc
6510: 72 65 61 73 69 6e 67 20 24 62 65 73 74 5d 20 30 reasing $best] 0
6520: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f ]. }.. pro
6530: 63 20 43 75 74 41 74 20 7b 6c 6f 63 61 74 69 6f c CutAt {locatio
6540: 6e 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 63 72 n} {..upvar 1 cr
6550: 6f 73 73 20 63 72 6f 73 73 20 64 65 70 63 20 64 oss cross depc d
6560: 65 70 63 0a 0a 09 23 20 49 74 20 77 61 73 20 64 epc...# It was d
6570: 65 63 69 64 65 64 20 74 6f 20 73 70 6c 69 74 20 ecided to split
6580: 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 61 74 the changeset at
6590: 20 74 68 65 20 67 69 76 65 6e 0a 09 23 20 6c 6f the given..# lo
65a0: 63 61 74 69 6f 6e 2e 20 54 68 69 73 20 63 75 74 cation. This cut
65b0: 73 20 61 20 6e 75 6d 62 65 72 20 6f 66 20 64 65 s a number of de
65c0: 70 65 6e 64 65 6e 63 69 65 73 2e 20 48 65 72 65 pendencies. Here
65d0: 20 77 65 20 75 70 64 61 74 65 0a 09 23 20 74 68 we update..# th
65e0: 65 20 63 72 6f 73 73 20 69 6e 66 6f 72 6d 61 74 e cross informat
65f0: 69 6f 6e 20 73 6f 20 74 68 61 74 20 74 68 65 20 ion so that the
6600: 62 72 65 61 6b 20 66 69 6e 64 65 72 20 68 61 73 break finder has
6610: 20 61 63 63 75 72 61 74 65 0a 09 23 20 64 61 74 accurate..# dat
6620: 61 20 77 68 65 6e 20 77 65 20 6c 6f 6f 6b 20 61 a when we look a
6630: 74 20 74 68 65 20 67 65 6e 65 72 61 74 65 64 20 t the generated
6640: 66 72 61 67 6d 65 6e 74 73 2e 0a 0a 09 73 65 74 fragments....set
6650: 20 73 69 78 20 5b 6c 6f 67 20 76 69 73 69 62 6c six [log visibl
6660: 65 3f 20 36 5d 0a 0a 09 66 6f 72 65 61 63 68 20 e? 6]...foreach
6670: 7b 64 65 70 20 72 61 6e 67 65 7d 20 5b 61 72 72 {dep range} [arr
6680: 61 79 20 67 65 74 20 64 65 70 63 5d 20 7b 0a 09 ay get depc] {..
6690: 20 20 20 20 23 20 43 68 65 63 6b 20 61 6c 6c 20 # Check all
66a0: 64 65 70 65 6e 64 65 6e 63 69 65 73 20 73 74 69 dependencies sti
66b0: 6c 6c 20 6b 6e 6f 77 6e 2c 20 74 61 6b 65 20 74 ll known, take t
66c0: 68 65 69 72 20 72 61 6e 67 65 20 61 6e 64 0a 09 heir range and..
66d0: 20 20 20 20 23 20 73 65 65 20 69 66 20 74 68 65 # see if the
66e0: 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 6f 6e 20 break location
66f0: 66 61 6c 6c 73 20 77 69 74 68 69 6e 2e 0a 0a 09 falls within....
6700: 20 20 20 20 42 6f 72 64 65 72 20 24 72 61 6e 67 Border $rang
6710: 65 20 73 20 65 0a 09 20 20 20 20 69 66 20 7b 24 e s e.. if {$
6720: 6c 6f 63 61 74 69 6f 6e 20 3c 20 24 73 7d 20 63 location < $s} c
6730: 6f 6e 74 69 6e 75 65 20 3b 20 23 20 62 72 65 61 ontinue ; # brea
6740: 6b 20 62 65 66 6f 72 65 20 72 61 6e 67 65 2c 20 k before range,
6750: 69 67 6e 6f 72 65 0a 09 20 20 20 20 69 66 20 7b ignore.. if {
6760: 24 6c 6f 63 61 74 69 6f 6e 20 3e 20 24 65 7d 20 $location > $e}
6770: 63 6f 6e 74 69 6e 75 65 20 3b 20 23 20 62 72 65 continue ; # bre
6780: 61 6b 20 61 66 74 65 72 20 72 61 6e 67 65 2c 20 ak after range,
6790: 69 67 6e 6f 72 65 2e 0a 0a 09 20 20 20 20 23 20 ignore.... #
67a0: 54 68 69 73 20 64 65 70 65 6e 64 65 6e 63 79 20 This dependency
67b0: 63 72 6f 73 73 65 73 20 74 68 65 20 62 72 65 61 crosses the brea
67c0: 6b 20 6c 6f 63 61 74 69 6f 6e 2e 20 57 65 20 72 k location. We r
67d0: 65 6d 6f 76 65 20 69 74 0a 09 20 20 20 20 23 20 emove it.. #
67e0: 66 72 6f 6d 20 74 68 65 20 63 72 6f 73 73 69 6e from the crossin
67f0: 67 73 20 63 6f 75 6e 74 65 72 73 2c 20 61 6e 64 gs counters, and
6800: 20 74 68 65 6e 20 61 6c 73 6f 20 66 72 6f 6d 20 then also from
6810: 74 68 65 20 73 65 74 0a 09 20 20 20 20 23 20 6f the set.. # o
6820: 66 20 6b 6e 6f 77 6e 20 64 65 70 65 6e 64 65 6e f known dependen
6830: 63 69 65 73 2c 20 61 73 20 77 65 20 61 72 65 20 cies, as we are
6840: 64 6f 6e 65 20 77 69 74 68 20 69 74 2e 0a 0a 09 done with it....
6850: 20 20 20 20 66 6f 72 65 61 63 68 20 6c 6f 63 20 foreach loc
6860: 24 64 65 70 63 28 24 64 65 70 29 20 7b 20 69 6e $depc($dep) { in
6870: 63 72 20 63 72 6f 73 73 28 24 6c 6f 63 29 20 2d cr cross($loc) -
6880: 31 20 7d 0a 09 20 20 20 20 75 6e 73 65 74 20 64 1 }.. unset d
6890: 65 70 63 28 24 64 65 70 29 0a 0a 09 20 20 20 20 epc($dep)...
68a0: 69 66 20 7b 21 24 73 69 78 7d 20 63 6f 6e 74 69 if {!$six} conti
68b0: 6e 75 65 0a 0a 09 20 20 20 20 73 74 72 75 63 74 nue... struct
68c0: 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24 64 ::list assign $d
68d0: 65 70 20 70 61 72 65 6e 74 20 63 68 69 6c 64 0a ep parent child.
68e0: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 35 . log write 5
68f0: 20 63 73 65 74 73 20 22 42 72 6f 6b 65 20 64 65 csets "Broke de
6900: 70 65 6e 64 65 6e 63 79 20 5b 50 44 20 24 70 61 pendency [PD $pa
6910: 72 65 6e 74 5d 20 2d 2d 3e 20 5b 50 44 20 24 63 rent] --> [PD $c
6920: 68 69 6c 64 5d 22 0a 09 7d 0a 0a 09 72 65 74 75 hild]"..}...retu
6930: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 rn. }.. #
6940: 50 72 69 6e 74 20 69 64 65 6e 74 69 66 79 69 6e Print identifyin
6950: 67 20 64 61 74 61 20 66 6f 72 20 61 20 72 65 76 g data for a rev
6960: 69 73 69 6f 6e 20 28 70 72 6f 6a 65 63 74 2c 20 ision (project,
6970: 66 69 6c 65 2c 20 64 6f 74 74 65 64 20 72 65 76 file, dotted rev
6980: 0a 20 20 20 20 23 20 6e 75 6d 62 65 72 29 2c 20 . # number),
6990: 66 6f 72 20 68 69 67 68 20 76 65 72 62 6f 73 69 for high verbosi
69a0: 74 79 20 6c 6f 67 20 6f 75 74 70 75 74 2e 0a 20 ty log output..
69b0: 20 20 20 23 20 54 4f 44 4f 3a 20 52 65 70 6c 61 # TODO: Repla
69c0: 63 65 20 77 69 74 68 20 63 61 6c 6c 20 74 6f 20 ce with call to
69d0: 69 74 65 6d 73 74 72 20 28 6c 69 73 74 20 72 65 itemstr (list re
69e0: 76 20 24 69 64 29 0a 0a 20 20 20 20 70 72 6f 63 v $id).. proc
69f0: 20 50 44 20 7b 69 64 7d 20 7b 0a 09 66 6f 72 65 PD {id} {..fore
6a00: 61 63 68 20 7b 70 20 66 20 72 7d 20 5b 73 74 61 ach {p f r} [sta
6a10: 74 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c 45 43 te run {...SELEC
6a20: 54 20 50 2e 6e 61 6d 65 20 2c 20 46 2e 6e 61 6d T P.name , F.nam
6a30: 65 2c 20 52 2e 72 65 76 0a 09 09 46 52 4f 4d 20 e, R.rev...FROM
6a40: 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c 65 revision R, file
6a50: 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a 09 09 F, project P...
6a60: 57 48 45 52 45 20 52 2e 72 69 64 20 3d 20 24 69 WHERE R.rid = $i
6a70: 64 20 20 20 20 2d 2d 20 46 69 6e 64 20 73 70 65 d -- Find spe
6a80: 63 69 66 69 65 64 20 66 69 6c 65 20 72 65 76 69 cified file revi
6a90: 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 46 2e 66 sion...AND F.f
6aa0: 69 64 20 3d 20 52 2e 66 69 64 20 20 2d 2d 20 47 id = R.fid -- G
6ab0: 65 74 20 66 69 6c 65 20 6f 66 20 74 68 65 20 72 et file of the r
6ac0: 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 20 evision...AND
6ad0: 50 2e 70 69 64 20 3d 20 46 2e 70 69 64 20 20 2d P.pid = F.pid -
6ae0: 2d 20 47 65 74 20 70 72 6f 6a 65 63 74 20 6f 66 - Get project of
6af0: 20 74 68 65 20 66 69 6c 65 2e 0a 09 7d 5d 20 62 the file...}] b
6b00: 72 65 61 6b 0a 09 72 65 74 75 72 6e 20 22 27 24 reak..return "'$
6b10: 70 20 3a 20 24 66 2f 24 72 27 22 0a 20 20 20 20 p : $f/$r'".
6b20: 7d 0a 0a 20 20 20 20 23 20 50 72 69 6e 74 69 6e }.. # Printin
6b30: 67 20 6f 6e 65 20 6f 72 20 6d 6f 72 65 20 72 61 g one or more ra
6b40: 6e 67 65 73 2c 20 66 6f 72 6d 61 74 74 65 64 2c nges, formatted,
6b50: 20 61 6e 64 20 6f 6e 6c 79 20 74 68 65 69 72 20 and only their
6b60: 62 6f 72 64 65 72 20 74 6f 0a 20 20 20 20 23 20 border to. #
6b70: 6b 65 65 70 20 74 68 65 20 73 74 72 69 6e 67 73 keep the strings
6b80: 20 73 68 6f 72 74 2e 0a 0a 20 20 20 20 70 72 6f short... pro
6b90: 63 20 50 52 73 20 7b 72 61 6e 67 65 73 7d 20 7b c PRs {ranges} {
6ba0: 0a 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 ..return [struct
6bb0: 3a 3a 6c 69 73 74 20 6d 61 70 20 24 72 61 6e 67 ::list map $rang
6bc0: 65 73 20 5b 6d 79 70 72 6f 63 20 50 52 5d 5d 0a es [myproc PR]].
6bd0: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
6be0: 50 52 20 7b 72 61 6e 67 65 7d 20 7b 0a 09 42 6f PR {range} {..Bo
6bf0: 72 64 65 72 20 24 72 61 6e 67 65 20 73 20 65 0a rder $range s e.
6c00: 09 72 65 74 75 72 6e 20 3c 24 7b 73 7d 2e 2e 2e .return <${s}...
6c10: 24 7b 65 7d 3e 0a 20 20 20 20 7d 0a 0a 20 20 20 ${e}>. }..
6c20: 20 70 72 6f 63 20 42 6f 72 64 65 72 20 7b 72 61 proc Border {ra
6c30: 6e 67 65 20 73 76 20 65 76 7d 20 7b 0a 09 75 70 nge sv ev} {..up
6c40: 76 61 72 20 31 20 24 73 76 20 73 20 24 65 76 20 var 1 $sv s $ev
6c50: 65 0a 09 73 65 74 20 73 20 5b 6c 69 6e 64 65 78 e..set s [lindex
6c60: 20 24 72 61 6e 67 65 20 30 5d 0a 09 73 65 74 20 $range 0]..set
6c70: 65 20 5b 6c 69 6e 64 65 78 20 24 72 61 6e 67 65 e [lindex $range
6c80: 20 65 6e 64 5d 0a 09 72 65 74 75 72 6e 0a 20 20 end]..return.
6c90: 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 }.. # # ##
6ca0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 ### ##### ######
6cb0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
6cc0: 0a 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 62 .. typevariab
6cd0: 6c 65 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 le mychangesets
6ce0: 20 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 4c {} ; # L
6cf0: 69 73 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e ist of all known
6d00: 0a 09 09 09 09 09 20 20 20 23 20 63 68 61 6e 67 ...... # chang
6d10: 65 73 65 74 73 2e 0a 20 20 20 20 74 79 70 65 76 esets.. typev
6d20: 61 72 69 61 62 6c 65 20 6d 79 74 63 68 61 6e 67 ariable mytchang
6d30: 65 73 65 74 73 20 2d 61 72 72 61 79 20 7b 7d 20 esets -array {}
6d40: 3b 20 23 20 4c 69 73 74 20 6f 66 20 61 6c 6c 20 ; # List of all
6d50: 6b 6e 6f 77 6e 0a 09 09 09 09 09 20 20 20 23 20 known...... #
6d60: 63 68 61 6e 67 65 73 65 74 73 20 6f 66 20 61 20 changesets of a
6d70: 74 79 70 65 2e 0a 20 20 20 20 74 79 70 65 76 61 type.. typeva
6d80: 72 69 61 62 6c 65 20 6d 79 69 74 65 6d 6d 61 70 riable myitemmap
6d90: 20 20 20 20 20 2d 61 72 72 61 79 20 7b 7d 20 3b -array {} ;
6da0: 20 23 20 4d 61 70 20 66 72 6f 6d 20 69 74 65 6d # Map from item
6db0: 73 20 28 74 61 67 67 65 64 29 0a 09 09 09 09 09 s (tagged)......
6dc0: 20 20 20 23 20 74 6f 20 74 68 65 20 6c 69 73 74 # to the list
6dd0: 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73 0a 09 of changesets..
6de0: 09 09 09 09 20 20 20 23 20 63 6f 6e 74 61 69 6e .... # contain
6df0: 69 6e 67 20 69 74 2e 20 45 61 63 68 20 69 74 65 ing it. Each ite
6e00: 6d 0a 09 09 09 09 09 20 20 20 23 20 63 61 6e 20 m...... # can
6e10: 62 65 20 75 73 65 64 20 62 79 20 6f 6e 6c 79 20 be used by only
6e20: 6f 6e 65 0a 09 09 09 09 09 20 20 20 23 20 63 68 one...... # ch
6e30: 61 6e 67 65 73 65 74 2e 0a 20 20 20 20 74 79 70 angeset.. typ
6e40: 65 76 61 72 69 61 62 6c 65 20 6d 79 69 64 6d 61 evariable myidma
6e50: 70 20 20 20 2d 61 72 72 61 79 20 7b 7d 20 3b 20 p -array {} ;
6e60: 23 20 4d 61 70 20 66 72 6f 6d 20 63 68 61 6e 67 # Map from chang
6e70: 65 73 65 74 20 69 64 20 74 6f 0a 09 09 09 09 20 eset id to.....
6e80: 20 20 20 20 20 20 23 20 63 68 61 6e 67 65 73 65 # changese
6e90: 74 2e 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 t... typemeth
6ea0: 6f 64 20 61 6c 6c 20 20 20 20 7b 7d 20 20 20 20 od all {}
6eb0: 7b 20 72 65 74 75 72 6e 20 24 6d 79 63 68 61 6e { return $mychan
6ec0: 67 65 73 65 74 73 20 7d 0a 20 20 20 20 74 79 70 gesets }. typ
6ed0: 65 6d 65 74 68 6f 64 20 6f 66 20 20 20 20 20 7b emethod of {
6ee0: 63 69 64 7d 20 7b 20 72 65 74 75 72 6e 20 24 6d cid} { return $m
6ef0: 79 69 64 6d 61 70 28 24 63 69 64 29 20 7d 0a 20 yidmap($cid) }.
6f00: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6f 66 typemethod of
6f10: 69 74 65 6d 20 7b 69 69 64 7d 20 7b 20 72 65 74 item {iid} { ret
6f20: 75 72 6e 20 24 6d 79 69 74 65 6d 6d 61 70 28 24 urn $myitemmap($
6f30: 69 69 64 29 20 7d 0a 0a 20 20 20 20 74 79 70 65 iid) }.. type
6f40: 6d 65 74 68 6f 64 20 72 65 76 20 20 20 20 7b 7d method rev {}
6f50: 20 20 20 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 { return $my
6f60: 74 63 68 61 6e 67 65 73 65 74 73 28 72 65 76 29 tchangesets(rev)
6f70: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f }. typemetho
6f80: 64 20 73 79 6d 20 20 20 20 7b 7d 20 20 20 20 7b d sym {} {
6f90: 20 72 65 74 75 72 6e 20 5b 63 6f 6e 63 61 74 20 return [concat
6fa0: 5c 0a 09 09 09 09 09 20 20 24 7b 6d 79 74 63 68 \...... ${mytch
6fb0: 61 6e 67 65 73 65 74 73 28 73 79 6d 3a 3a 62 72 angesets(sym::br
6fc0: 61 6e 63 68 29 7d 20 5c 0a 09 09 09 09 09 20 20 anch)} \......
6fd0: 24 7b 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 ${mytchangesets(
6fe0: 73 79 6d 3a 3a 74 61 67 29 7d 5d 20 7d 0a 0a 20 sym::tag)}] }..
6ff0: 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 # # ## ### ##
7000: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 ### ######## ###
7010: 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 ##########. #
7020: 23 20 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e 0a # Configuration.
7030: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 . pragma -has
7040: 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 20 typeinfo no
7050: 3b 20 23 20 6e 6f 20 74 79 70 65 20 69 6e 74 72 ; # no type intr
7060: 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 ospection. pr
7070: 61 67 6d 61 20 2d 68 61 73 69 6e 66 6f 20 20 20 agma -hasinfo
7080: 20 20 20 20 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 no ; # no
7090: 6f 62 6a 65 63 74 20 69 6e 74 72 6f 73 70 65 63 object introspec
70a0: 74 69 6f 6e 0a 0a 20 20 20 20 23 20 23 20 23 23 tion.. # # ##
70b0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
70c0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
70d0: 23 0a 7d 0a 0a 23 23 0a 23 23 20 4e 4f 54 45 3a #.}..##.## NOTE:
70e0: 20 54 68 65 20 73 75 63 63 65 73 73 6f 72 20 61 The successor a
70f0: 6e 64 20 70 72 65 64 65 63 65 73 73 6f 72 20 6d nd predecessor m
7100: 65 74 68 6f 64 73 20 64 65 66 69 6e 65 64 20 62 ethods defined b
7110: 79 20 74 68 65 20 63 6c 61 73 73 65 73 0a 23 23 y the classes.##
7120: 20 20 20 20 20 20 20 62 65 6c 6f 77 20 61 72 65 below are
7130: 20 2d 2d 20 62 6f 74 74 6c 65 20 6e 65 63 6b 73 -- bottle necks
7140: 20 2d 2d 2e 20 4c 6f 6f 6b 20 66 6f 72 20 77 61 --. Look for wa
7150: 79 73 20 74 6f 20 6d 61 6b 65 20 74 68 65 20 53 ys to make the S
7160: 51 4c 0a 23 23 20 20 20 20 20 20 20 66 61 73 74 QL.## fast
7170: 65 72 2e 0a 23 23 0a 0a 23 20 23 20 23 23 20 23 er..##..# # ## #
7180: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 ## ##### #######
7190: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 # #############
71a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
71b0: 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65 72 20 #####.## Helper
71c0: 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d 6d 61 singleton. Comma
71d0: 6e 64 73 20 66 6f 72 20 72 65 76 69 73 69 6f 6e nds for revision
71e0: 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e changesets...sn
71f0: 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 it::type ::vc::f
7200: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 ossil::import::c
7210: 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 vs::project::rev
7220: 3a 3a 72 65 76 20 7b 0a 20 20 20 20 74 79 70 65 ::rev {. type
7230: 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 69 6f method byrevisio
7240: 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 n {} { return 1
7250: 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 }. typemethod
7260: 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 7b bysymbol {} {
7270: 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 return 0 }.
7280: 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74 61 67 typemethod istag
7290: 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 {} { retur
72a0: 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 n 0 }. typeme
72b0: 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20 20 20 thod isbranch
72c0: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a {} { return 0 }.
72d0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
72e0: 73 74 72 20 7b 72 65 76 69 73 69 6f 6e 7d 20 7b str {revision} {
72f0: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 ..struct::list a
7300: 73 73 69 67 6e 20 5b 73 74 61 74 65 20 72 75 6e ssign [state run
7310: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 {.. SELECT R
7320: 2e 72 65 76 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e .rev, F.name, P.
7330: 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 name.. FROM
7340: 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 69 6c revision R, fil
7350: 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 0a 09 e F, project P..
7360: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 WHERE R.rid
7370: 20 3d 20 24 72 65 76 69 73 69 6f 6e 20 2d 2d 20 = $revision --
7380: 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 20 66 Find specified f
7390: 69 6c 65 20 72 65 76 69 73 69 6f 6e 0a 09 20 20 ile revision..
73a0: 20 20 41 4e 44 20 20 20 20 46 2e 66 69 64 20 3d AND F.fid =
73b0: 20 52 2e 66 69 64 20 20 20 20 20 2d 2d 20 47 65 R.fid -- Ge
73c0: 74 20 66 69 6c 65 20 6f 66 20 74 68 65 20 72 65 t file of the re
73d0: 76 69 73 69 6f 6e 0a 09 20 20 20 20 41 4e 44 20 vision.. AND
73e0: 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 69 64 P.pid = F.pid
73f0: 20 20 20 20 20 2d 2d 20 47 65 74 20 70 72 6f 6a -- Get proj
7400: 65 63 74 20 6f 66 20 74 68 65 20 66 69 6c 65 2e ect of the file.
7410: 0a 09 7d 5d 20 72 65 76 6e 72 20 66 6e 61 6d 65 ..}] revnr fname
7420: 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e 20 22 pname..return "
7430: 24 70 6e 61 6d 65 2f 24 7b 72 65 76 6e 72 7d 3a $pname/${revnr}:
7440: 3a 24 66 6e 61 6d 65 22 0a 20 20 20 20 7d 0a 0a :$fname". }..
7450: 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c # result = l
7460: 69 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20 6d 61 ist (mintime, ma
7470: 78 74 69 6d 65 29 0a 20 20 20 20 74 79 70 65 6d xtime). typem
7480: 65 74 68 6f 64 20 74 69 6d 65 72 61 6e 67 65 20 ethod timerange
7490: 7b 69 74 65 6d 73 7d 20 7b 0a 09 73 65 74 20 74 {items} {..set t
74a0: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 69 heset ('[join $i
74b0: 74 65 6d 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 tems {','}]')..r
74c0: 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e eturn [state run
74d0: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 [subst -nocomma
74e0: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 nds -nobackslash
74f0: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 es {.. SELECT
7500: 20 4d 49 4e 28 52 2e 64 61 74 65 29 2c 20 4d 41 MIN(R.date), MA
7510: 58 28 52 2e 64 61 74 65 29 0a 09 20 20 20 20 46 X(R.date).. F
7520: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 ROM revision R..
7530: 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 64 20 WHERE R.rid
7540: 49 4e 20 24 74 68 65 73 65 74 20 2d 2d 20 52 65 IN $theset -- Re
7550: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 strict to revisi
7560: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a ons of interest.
7570: 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 .}]]. }..
7580: 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 63 74 # var(dv) = dict
7590: 20 28 72 65 76 69 73 69 6f 6e 20 2d 3e 20 6c 69 (revision -> li
75a0: 73 74 20 28 72 65 76 69 73 69 6f 6e 29 29 0a 20 st (revision)).
75b0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 6e typemethod in
75c0: 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f 72 73 ternalsuccessors
75d0: 20 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 7d 20 {dv revisions}
75e0: 7b 0a 09 75 70 76 61 72 20 31 20 24 64 76 20 64 {..upvar 1 $dv d
75f0: 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 65 74 ependencies..set
7600: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 theset ('[join
7610: 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d $revisions {','}
7620: 5d 27 29 0a 0a 09 23 20 53 65 65 20 27 73 75 63 ]')...# See 'suc
7630: 63 65 73 73 6f 72 73 27 20 62 65 6c 6f 77 20 66 cessors' below f
7640: 6f 72 20 74 68 65 20 6d 61 69 6e 20 65 78 70 6c or the main expl
7650: 61 6e 61 74 69 6f 6e 20 6f 66 0a 09 23 20 74 68 anation of..# th
7660: 65 20 76 61 72 69 6f 75 73 20 63 61 73 65 73 2e e various cases.
7670: 20 54 68 69 73 20 70 69 65 63 65 20 69 73 20 73 This piece is s
7680: 70 65 63 69 61 6c 20 69 6e 20 74 68 61 74 20 69 pecial in that i
7690: 74 0a 09 23 20 72 65 73 74 72 69 63 74 73 20 74 t..# restricts t
76a0: 68 65 20 73 75 63 63 65 73 73 6f 72 73 20 77 65 he successors we
76b0: 20 6c 6f 6f 6b 20 66 6f 72 20 74 6f 20 74 68 65 look for to the
76c0: 20 73 61 6d 65 20 73 65 74 20 6f 66 0a 09 23 20 same set of..#
76d0: 72 65 76 69 73 69 6f 6e 73 20 77 65 20 73 74 61 revisions we sta
76e0: 72 74 20 66 72 6f 6d 2e 20 53 65 6e 73 69 62 6c rt from. Sensibl
76f0: 65 20 61 73 20 77 65 20 61 72 65 20 6c 6f 6f 6b e as we are look
7700: 69 6e 67 20 66 6f 72 0a 09 23 20 63 68 61 6e 67 ing for..# chang
7710: 65 73 65 74 20 69 6e 74 65 72 6e 61 6c 20 64 65 eset internal de
7720: 70 65 6e 64 65 6e 63 69 65 73 2e 0a 0a 09 61 72 pendencies....ar
7730: 72 61 79 20 73 65 74 20 64 65 70 20 7b 7d 0a 0a ray set dep {}..
7740: 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 63 68 .foreach {rid ch
7750: 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 ild} [state run
7760: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e [subst -nocomman
7770: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 ds -nobackslashe
7780: 73 20 7b 0a 20 20 20 20 2d 2d 20 28 31 29 20 50 s {. -- (1) P
7790: 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20 rimary child..
77a0: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 SELECT R.rid,
77b0: 52 2e 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f R.child.. FRO
77c0: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 M revision R..
77d0: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 WHERE R.rid
77e0: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 IN $theset
77f0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f -- Restrict to
7800: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e revisions of in
7810: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 terest.. AND
7820: 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f R.child IS NO
7830: 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 T NULL -- Has
7840: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 primary child..
7850: 20 20 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 AND R.chi
7860: 6c 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 ld IN $theset
7870: 20 20 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c -- Which is al
7880: 73 6f 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 so of interest.
7890: 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 UNION. --
78a0: 28 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 (2) Secondary (b
78b0: 72 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a ranch) children.
78c0: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 . SELECT R.ri
78d0: 64 2c 20 42 2e 62 72 69 64 0a 09 20 20 20 20 46 d, B.brid.. F
78e0: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 ROM revision R
78f0: 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 , revisionbranch
7900: 63 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 children B..
7910: 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 WHERE R.rid I
7920: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d N $theset --
7930: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 Restrict to rev
7940: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 isions of intere
7950: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 st.. AND R
7960: 2e 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 .rid = B.rid
7970: 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 -- Select
7980: 73 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 subset of branch
7990: 20 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 41 children.. A
79a0: 4e 44 20 20 20 20 42 2e 62 72 69 64 20 49 4e 20 ND B.brid IN
79b0: 24 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 $theset --
79c0: 57 68 69 63 68 20 69 73 20 61 6c 73 6f 20 6f 66 Which is also of
79d0: 20 69 6e 74 65 72 65 73 74 0a 20 20 20 20 55 4e interest. UN
79e0: 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20 43 ION. -- (4) C
79f0: 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f hild of trunk ro
7a00: 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 ot successor of
7a10: 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 last NTDB on tru
7a20: 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 nk... SELECT
7a30: 52 2e 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a R.rid, RA.child.
7a40: 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69 73 69 . FROM revisi
7a50: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 on R, revision R
7a60: 41 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 A.. WHERE R.r
7a70: 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 id IN $theset
7a80: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 -- Restrict
7a90: 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 to revisions of
7aa0: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 interest.. A
7ab0: 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75 6c 74 ND R.isdefault
7ac0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 --
7ad0: 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 44 42 Restrict to NTDB
7ae0: 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e 64 62 .. AND R.db
7af0: 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 4c child IS NOT NUL
7b00: 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73 74 20 L -- and last
7b10: 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67 20 74 NTDB belonging t
7b20: 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 41 4e 44 o trunk.. AND
7b30: 20 20 20 52 41 2e 72 69 64 20 3d 20 52 2e 64 62 RA.rid = R.db
7b40: 63 68 69 6c 64 20 20 20 20 20 20 2d 2d 20 47 6f child -- Go
7b50: 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 72 75 directly to tru
7b60: 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41 4e 44 nk root.. AND
7b70: 20 20 20 52 41 2e 63 68 69 6c 64 20 49 53 20 4e RA.child IS N
7b80: 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 OT NULL -- Ha
7b90: 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 2e s primary child.
7ba0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 . AND
7bb0: 20 20 20 52 41 2e 63 68 69 6c 64 20 49 4e 20 24 RA.child IN $
7bc0: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 57 68 theset -- Wh
7bd0: 69 63 68 20 69 73 20 61 6c 73 6f 20 6f 66 20 69 ich is also of i
7be0: 6e 74 65 72 65 73 74 0a 09 7d 5d 5d 20 7b 0a 09 nterest..}]] {..
7bf0: 20 20 20 20 23 20 43 6f 6e 73 69 64 65 72 20 6d # Consider m
7c00: 6f 76 69 6e 67 20 74 68 69 73 20 74 6f 20 74 68 oving this to th
7c10: 65 20 69 6e 74 65 67 72 69 74 79 20 6d 6f 64 75 e integrity modu
7c20: 6c 65 2e 0a 09 20 20 20 20 69 6e 74 65 67 72 69 le... integri
7c30: 74 79 20 61 73 73 65 72 74 20 7b 24 72 69 64 20 ty assert {$rid
7c40: 21 3d 20 24 63 68 69 6c 64 7d 20 7b 52 65 76 69 != $child} {Revi
7c50: 73 69 6f 6e 20 24 72 69 64 20 64 65 70 65 6e 64 sion $rid depend
7c60: 73 20 6f 6e 20 69 74 73 65 6c 66 2e 7d 0a 09 20 s on itself.}..
7c70: 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e lappend depen
7c80: 64 65 6e 63 69 65 73 28 24 72 69 64 29 20 24 63 dencies($rid) $c
7c90: 68 69 6c 64 0a 09 20 20 20 20 73 65 74 20 64 65 hild.. set de
7ca0: 70 28 24 72 69 64 2c 24 63 68 69 6c 64 29 20 2e p($rid,$child) .
7cb0: 0a 09 7d 0a 0a 09 23 20 54 68 65 20 73 71 6c 20 ..}...# The sql
7cc0: 73 74 61 74 65 6d 65 6e 74 73 20 61 62 6f 76 65 statements above
7cd0: 20 6c 6f 6f 6b 73 20 6f 6e 6c 79 20 66 6f 72 20 looks only for
7ce0: 64 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63 direct dependenc
7cf0: 69 65 73 0a 09 23 20 62 65 74 77 65 65 6e 20 72 ies..# between r
7d00: 65 76 69 73 69 6f 6e 20 69 6e 20 74 68 65 20 63 evision in the c
7d10: 68 61 6e 67 65 73 65 74 2e 20 48 6f 77 65 76 65 hangeset. Howeve
7d20: 72 20 64 75 65 20 74 6f 20 74 68 65 0a 09 23 20 r due to the..#
7d30: 76 61 67 61 72 69 65 73 20 6f 66 20 6d 65 74 61 vagaries of meta
7d40: 20 64 61 74 61 20 69 74 20 69 73 20 70 6f 73 73 data it is poss
7d50: 69 62 6c 65 20 66 6f 72 20 74 77 6f 20 72 65 76 ible for two rev
7d60: 69 73 69 6f 6e 73 20 6f 66 0a 09 23 20 74 68 65 isions of..# the
7d70: 20 73 61 6d 65 20 66 69 6c 65 20 74 6f 20 65 6e same file to en
7d80: 64 20 75 70 20 69 6e 20 74 68 65 20 73 61 6d 65 d up in the same
7d90: 20 63 68 61 6e 67 65 73 65 74 2c 20 77 69 74 68 changeset, with
7da0: 6f 75 74 20 61 0a 09 23 20 64 69 72 65 63 74 20 out a..# direct
7db0: 64 65 70 65 6e 64 65 6e 63 79 20 62 65 74 77 65 dependency betwe
7dc0: 65 6e 20 74 68 65 6d 2e 20 48 6f 77 65 76 65 72 en them. However
7dd0: 20 77 65 20 6b 6e 6f 77 20 74 68 61 74 20 74 68 we know that th
7de0: 65 72 65 0a 09 23 20 68 61 73 20 74 6f 20 62 65 ere..# has to be
7df0: 20 61 20 61 6e 20 69 6e 64 69 72 65 63 74 20 64 a an indirect d
7e00: 65 70 65 6e 64 65 6e 63 79 2c 20 62 65 20 69 74 ependency, be it
7e10: 20 74 68 72 6f 75 67 68 20 70 72 69 6d 61 72 79 through primary
7e20: 0a 09 23 20 63 68 69 6c 64 72 65 6e 2c 20 62 72 ..# children, br
7e30: 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 2c 20 6f anch children, o
7e40: 72 20 61 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20 r a combination
7e50: 74 68 65 72 65 6f 66 2e 0a 0a 09 23 20 57 65 20 thereof....# We
7e60: 6e 6f 77 20 66 69 6c 6c 20 69 6e 20 74 68 65 73 now fill in thes
7e70: 65 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 e pseudo-depende
7e80: 6e 63 69 65 73 2c 20 69 66 20 6e 6f 20 73 75 63 ncies, if no suc
7e90: 68 0a 09 23 20 64 65 70 65 6e 64 65 6e 63 79 20 h..# dependency
7ea0: 65 78 69 73 74 73 20 61 6c 72 65 61 64 79 2e 20 exists already.
7eb0: 54 68 65 20 64 69 72 65 63 74 69 6f 6e 20 6f 66 The direction of
7ec0: 20 74 68 65 20 64 65 70 65 6e 64 65 6e 63 79 0a the dependency.
7ed0: 09 23 20 69 73 20 61 63 74 75 61 6c 6c 79 20 69 .# is actually i
7ee0: 72 72 65 6c 65 76 61 6e 74 20 66 6f 72 20 74 68 rrelevant for th
7ef0: 69 73 2e 0a 0a 09 23 20 4e 4f 54 45 3a 20 54 68 is....# NOTE: Th
7f00: 69 73 20 69 73 20 64 69 66 66 65 72 65 6e 74 20 is is different
7f10: 66 72 6f 6d 20 63 76 73 32 73 76 6e 2e 20 4f 75 from cvs2svn. Ou
7f20: 72 20 73 70 69 72 69 74 75 61 6c 20 61 6e 63 65 r spiritual ance
7f30: 73 74 6f 72 0a 09 23 20 64 6f 65 73 20 6e 6f 74 stor..# does not
7f40: 20 75 73 65 20 73 75 63 68 20 70 73 65 75 64 6f use such pseudo
7f50: 2d 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 68 -dependencies, h
7f60: 6f 77 65 76 65 72 20 69 74 20 75 73 65 73 20 61 owever it uses a
7f70: 0a 09 23 20 43 4f 4d 4d 49 54 5f 54 48 52 45 53 ..# COMMIT_THRES
7f80: 48 4f 4c 44 2c 20 61 20 74 69 6d 65 20 69 6e 74 HOLD, a time int
7f90: 65 72 76 61 6c 20 63 6f 6d 6d 69 74 73 20 73 68 erval commits sh
7fa0: 6f 75 6c 64 20 66 61 6c 6c 2e 20 54 68 69 73 0a ould fall. This.
7fb0: 09 23 20 77 69 6c 6c 20 67 72 65 61 74 6c 79 20 .# will greatly
7fc0: 72 65 64 75 63 65 73 20 74 68 65 20 72 69 73 6b reduces the risk
7fd0: 20 6f 66 20 67 65 74 74 69 6e 67 20 66 61 72 20 of getting far
7fe0: 73 65 70 61 72 61 74 65 64 0a 09 23 20 72 65 76 separated..# rev
7ff0: 69 73 69 6f 6e 73 20 6f 66 20 74 68 65 20 73 61 isions of the sa
8000: 6d 65 20 66 69 6c 65 20 69 6e 74 6f 20 6f 6e 65 me file into one
8010: 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 23 20 changeset....#
8020: 57 65 20 61 6c 6c 6f 77 20 72 65 76 69 73 69 6f We allow revisio
8030: 6e 73 20 74 6f 20 62 65 20 66 61 72 20 61 70 61 ns to be far apa
8040: 72 74 20 69 6e 20 74 69 6d 65 20 69 6e 20 74 68 rt in time in th
8050: 65 20 73 61 6d 65 0a 09 23 20 63 68 61 6e 67 65 e same..# change
8060: 73 65 74 2c 20 62 75 74 20 69 6e 20 74 75 72 6e set, but in turn
8070: 20 6e 65 65 64 20 74 68 65 20 70 73 65 75 64 6f need the pseudo
8080: 2d 64 65 70 65 6e 64 65 6e 63 69 65 73 20 74 6f -dependencies to
8090: 0a 09 23 20 68 61 6e 64 6c 65 20 74 68 69 73 2e ..# handle this.
80a0: 0a 0a 09 61 72 72 61 79 20 73 65 74 20 66 69 64 ...array set fid
80b0: 73 20 7b 7d 0a 09 66 6f 72 65 61 63 68 20 7b 72 s {}..foreach {r
80c0: 69 64 20 66 69 64 7d 20 5b 73 74 61 74 65 20 72 id fid} [state r
80d0: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d un [subst -nocom
80e0: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
80f0: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 shes {.. SELE
8100: 43 54 20 52 2e 72 69 64 2c 20 52 2e 66 69 64 0a CT R.rid, R.fid.
8110: 20 20 20 20 20 20 20 20 20 20 20 20 46 52 4f 4d FROM
8120: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 20 20 revision R.
8130: 20 20 20 20 20 20 20 20 20 20 57 48 45 52 45 20 WHERE
8140: 20 52 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 R.rid IN $these
8150: 74 0a 09 7d 5d 5d 20 7b 20 6c 61 70 70 65 6e 64 t..}]] { lappend
8160: 20 66 69 64 73 28 24 66 69 64 29 20 24 72 69 64 fids($fid) $rid
8170: 20 7d 0a 0a 09 66 6f 72 65 61 63 68 20 7b 66 69 }...foreach {fi
8180: 64 20 72 69 64 73 7d 20 5b 61 72 72 61 79 20 67 d rids} [array g
8190: 65 74 20 66 69 64 73 5d 20 7b 0a 09 20 20 20 20 et fids] {..
81a0: 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 72 69 if {[llength $ri
81b0: 64 73 5d 20 3c 20 32 7d 20 63 6f 6e 74 69 6e 75 ds] < 2} continu
81c0: 65 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20 61 e.. foreach a
81d0: 20 24 72 69 64 73 20 7b 0a 09 09 66 6f 72 65 61 $rids {...forea
81e0: 63 68 20 62 20 24 72 69 64 73 20 7b 0a 09 09 20 ch b $rids {...
81f0: 20 20 20 69 66 20 7b 24 61 20 3d 3d 20 24 62 7d if {$a == $b}
8200: 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20 20 continue...
8210: 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 73 74 73 if {[info exists
8220: 20 64 65 70 28 24 61 2c 24 62 29 5d 7d 20 63 6f dep($a,$b)]} co
8230: 6e 74 69 6e 75 65 0a 09 09 20 20 20 20 69 66 20 ntinue... if
8240: 7b 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 64 65 {[info exists de
8250: 70 28 24 62 2c 24 61 29 5d 7d 20 63 6f 6e 74 69 p($b,$a)]} conti
8260: 6e 75 65 0a 09 09 20 20 20 20 6c 61 70 70 65 6e nue... lappen
8270: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 24 d dependencies($
8280: 61 29 20 24 62 0a 09 09 20 20 20 20 73 65 74 20 a) $b... set
8290: 64 65 70 28 24 61 2c 24 62 29 20 2e 0a 09 09 20 dep($a,$b) ....
82a0: 20 20 20 73 65 74 20 64 65 70 28 24 62 2c 24 61 set dep($b,$a
82b0: 29 20 2e 0a 09 09 7d 0a 09 20 20 20 20 7d 0a 09 ) ....}.. }..
82c0: 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a }..return. }.
82d0: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 . # result =
82e0: 34 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70 65 4-list (itemtype
82f0: 20 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65 6d itemid nextitem
8300: 74 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64 20 type nextitemid
8310: 2e 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65 74 ...). typemet
8320: 68 6f 64 20 6c 6f 6f 70 73 20 7b 72 65 76 69 73 hod loops {revis
8330: 69 6f 6e 73 7d 20 7b 0a 09 23 20 4e 6f 74 65 3a ions} {..# Note:
8340: 20 54 61 67 73 20 61 6e 64 20 62 72 61 6e 63 68 Tags and branch
8350: 65 73 20 63 61 6e 6e 6f 74 20 63 61 75 73 65 20 es cannot cause
8360: 74 68 65 20 6c 6f 6f 70 2e 20 54 68 65 69 72 20 the loop. Their
8370: 69 64 27 73 2c 0a 09 23 20 62 65 69 6e 67 20 6f id's,..# being o
8380: 66 20 61 20 66 75 6e 64 61 6d 65 6e 74 61 6c 6c f a fundamentall
8390: 79 20 64 69 66 66 65 72 65 6e 74 20 74 79 70 65 y different type
83a0: 20 74 68 61 6e 20 74 68 65 20 72 65 76 69 73 69 than the revisi
83b0: 6f 6e 73 0a 09 23 20 63 6f 6d 69 6e 67 20 69 6e ons..# coming in
83c0: 20 63 61 6e 6e 6f 74 20 62 65 20 69 6e 20 74 68 cannot be in th
83d0: 65 20 73 65 74 2e 0a 0a 09 73 65 74 20 74 68 65 e set....set the
83e0: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 set ('[join $rev
83f0: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a isions {','}]').
8400: 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 .return [state r
8410: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d un [subst -nocom
8420: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
8430: 73 68 65 73 20 7b 0a 09 20 20 20 20 2d 2d 20 28 shes {.. -- (
8440: 31 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c 64 1) Primary child
8450: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 .. SELECT R.r
8460: 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20 20 id, R.child..
8470: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e FROM revision
8480: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 R.. WHERE R
8490: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 .rid IN $these
84a0: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 t -- Restric
84b0: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f t to revisions o
84c0: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 f interest..
84d0: 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 AND R.child I
84e0: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d S NOT NULL --
84f0: 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 Has primary chi
8500: 6c 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 ld.. AND R
8510: 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73 65 .child IN $these
8520: 74 20 20 20 20 20 2d 2d 20 4c 6f 6f 70 0a 09 20 t -- Loop..
8530: 20 20 20 2d 2d 0a 09 20 20 20 20 55 4e 49 4f 4e --.. UNION
8540: 0a 09 20 20 20 20 2d 2d 20 28 32 29 20 53 65 63 .. -- (2) Sec
8550: 6f 6e 64 61 72 79 20 28 62 72 61 6e 63 68 29 20 ondary (branch)
8560: 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 53 45 children.. SE
8570: 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 72 LECT R.rid, B.br
8580: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 id.. FROM r
8590: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 evision R, revis
85a0: 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65 ionbranchchildre
85b0: 6e 20 42 0a 09 20 20 20 20 57 48 45 52 45 20 20 n B.. WHERE
85c0: 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 R.rid IN $thes
85d0: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 et -- Restri
85e0: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 ct to revisions
85f0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
8600: 20 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20 AND R.rid =
8610: 42 2e 72 69 64 20 20 20 20 20 20 20 20 20 20 2d B.rid -
8620: 2d 20 53 65 6c 65 63 74 20 73 75 62 73 65 74 20 - Select subset
8630: 6f 66 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72 of branch childr
8640: 65 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 en.. AND B
8650: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 .rid IN $these
8660: 74 20 20 20 20 20 2d 2d 20 4c 6f 6f 70 0a 09 20 t -- Loop..
8670: 20 20 20 2d 2d 0a 09 20 20 20 20 55 4e 49 4f 4e --.. UNION
8680: 0a 09 20 20 20 20 2d 2d 20 28 34 29 20 43 68 69 .. -- (4) Chi
8690: 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74 ld of trunk root
86a0: 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 6c 61 successor of la
86b0: 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b st NTDB on trunk
86c0: 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e ... SELECT R.
86d0: 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09 20 rid, RA.child..
86e0: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 FROM revisi
86f0: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 on R, revision R
8700: 41 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e A.. WHERE R.
8710: 72 69 64 20 20 20 20 49 4e 20 24 74 68 65 73 65 rid IN $these
8720: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 t -- Restric
8730: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f t to revisions o
8740: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 f interest..
8750: 41 4e 44 20 20 20 20 52 2e 69 73 64 65 66 61 75 AND R.isdefau
8760: 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d lt -
8770: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 - Restrict to NT
8780: 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 DB.. AND R
8790: 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 .dbchild IS NOT
87a0: 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 NULL -- and la
87b0: 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e st NTDB belongin
87c0: 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 g to trunk..
87d0: 41 4e 44 20 20 20 20 52 41 2e 72 69 64 20 3d 20 AND RA.rid =
87e0: 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d R.dbchild -
87f0: 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f - Go directly to
8800: 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 trunk root..
8810: 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c 64 AND RA.child
8820: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 IS NOT NULL
8830: 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 -- Has primary c
8840: 68 69 6c 64 2e 0a 09 20 20 20 20 41 4e 44 20 20 hild... AND
8850: 20 20 52 41 2e 63 68 69 6c 64 20 49 4e 20 24 74 RA.child IN $t
8860: 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c 6f 6f heset -- Loo
8870: 70 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 p..}]]. }..
8880: 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 # var(dv) = di
8890: 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 ct (item -> list
88a0: 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 (item)), item
88b0: 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29 = list (type id)
88c0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
88d0: 73 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20 72 successors {dv r
88e0: 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 evisions} {..upv
88f0: 61 72 20 31 20 24 64 76 20 64 65 70 65 6e 64 65 ar 1 $dv depende
8900: 6e 63 69 65 73 0a 09 73 65 74 20 74 68 65 73 65 ncies..set these
8910: 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 t ('[join $revis
8920: 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 ions {','}]')...
8930: 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 # The following
8940: 63 61 73 65 73 20 73 70 65 63 69 66 79 20 77 68 cases specify wh
8950: 65 6e 20 61 20 72 65 76 69 73 69 6f 6e 20 53 20 en a revision S
8960: 69 73 20 61 20 73 75 63 63 65 73 73 6f 72 0a 09 is a successor..
8970: 23 20 6f 66 20 61 20 72 65 76 69 73 69 6f 6e 20 # of a revision
8980: 52 2e 20 45 61 63 68 20 6f 66 20 74 68 65 20 63 R. Each of the c
8990: 61 73 65 73 20 74 72 61 6e 73 6c 61 74 65 73 20 ases translates
89a0: 69 6e 74 6f 20 6f 6e 65 20 6f 66 0a 09 23 20 74 into one of..# t
89b0: 68 65 20 62 72 61 6e 63 68 65 73 20 6f 66 20 74 he branches of t
89c0: 68 65 20 53 51 4c 20 55 4e 49 4f 4e 20 63 6f 6d he SQL UNION com
89d0: 69 6e 67 20 62 65 6c 6f 77 2e 0a 09 23 0a 09 23 ing below...#..#
89e0: 20 28 31 29 20 53 20 63 61 6e 20 62 65 20 61 20 (1) S can be a
89f0: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 6f 66 primary child of
8a00: 20 52 2c 20 69 2e 65 2e 20 69 6e 20 74 68 65 20 R, i.e. in the
8a10: 73 61 6d 65 20 4c 4f 44 2e 20 52 0a 09 23 20 20 same LOD. R..#
8a20: 20 20 20 72 65 66 65 72 65 6e 63 65 73 20 53 20 references S
8a30: 64 69 72 65 63 74 6c 79 2e 20 52 2e 63 68 69 6c directly. R.chil
8a40: 64 20 3d 20 53 28 2e 72 69 64 29 2c 20 69 66 20 d = S(.rid), if
8a50: 69 74 20 65 78 69 73 74 73 2e 0a 09 23 0a 09 23 it exists...#..#
8a60: 20 28 32 29 20 53 20 63 61 6e 20 62 65 20 61 20 (2) S can be a
8a70: 73 65 63 6f 6e 64 61 72 79 2c 20 69 2e 65 2e 20 secondary, i.e.
8a80: 62 72 61 6e 63 68 2c 20 63 68 69 6c 64 20 6f 66 branch, child of
8a90: 20 52 2e 20 48 65 72 65 20 74 68 65 0a 09 23 20 R. Here the..#
8aa0: 20 20 20 20 6c 69 6e 6b 20 69 73 20 6d 61 64 65 link is made
8ab0: 20 74 68 72 6f 75 67 68 20 74 68 65 20 68 65 6c through the hel
8ac0: 70 65 72 20 74 61 62 6c 65 0a 09 23 20 20 20 20 per table..#
8ad0: 20 52 45 56 49 53 49 4f 4e 42 52 41 4e 43 48 43 REVISIONBRANCHC
8ae0: 48 49 4c 44 52 45 4e 2e 20 52 2e 72 69 64 20 2d HILDREN. R.rid -
8af0: 3e 20 52 42 43 2e 72 69 64 2c 20 52 42 43 2e 62 > RBC.rid, RBC.b
8b00: 72 69 64 20 3d 0a 09 23 20 20 20 20 20 53 28 2e rid =..# S(.
8b10: 72 69 64 29 0a 09 23 0a 09 23 20 28 33 29 20 4f rid)..#..# (3) O
8b20: 72 69 67 69 6e 61 6c 6c 79 20 74 68 69 73 20 75 riginally this u
8b30: 73 65 20 63 61 73 65 20 64 65 66 69 6e 65 64 20 se case defined
8b40: 74 68 65 20 72 6f 6f 74 20 6f 66 20 61 20 64 65 the root of a de
8b50: 74 61 63 68 65 64 0a 09 23 20 20 20 20 20 4e 54 tached..# NT
8b60: 44 42 20 61 73 20 74 68 65 20 73 75 63 63 65 73 DB as the succes
8b70: 73 6f 72 20 6f 66 20 74 68 65 20 74 72 75 6e 6b sor of the trunk
8b80: 20 72 6f 6f 74 2e 20 54 68 69 73 20 6c 65 61 64 root. This lead
8b90: 73 20 74 6f 20 61 0a 09 23 20 20 20 20 20 62 61 s to a..# ba
8ba0: 64 20 74 61 6e 67 6c 65 20 6c 61 74 65 72 20 6f d tangle later o
8bb0: 6e 2e 20 57 69 74 68 20 61 20 64 65 74 61 63 68 n. With a detach
8bc0: 65 64 20 4e 54 44 42 20 74 68 65 20 6f 72 69 67 ed NTDB the orig
8bd0: 69 6e 61 6c 0a 09 23 20 20 20 20 20 74 72 75 6e inal..# trun
8be0: 6b 20 72 6f 6f 74 20 72 65 76 69 73 69 6f 6e 20 k root revision
8bf0: 77 61 73 20 72 65 6d 6f 76 65 64 20 61 73 20 69 was removed as i
8c00: 72 72 65 6c 65 76 61 6e 74 2c 20 61 6c 6c 6f 77 rrelevant, allow
8c10: 69 6e 67 0a 09 23 20 20 20 20 20 74 68 65 20 6e ing..# the n
8c20: 6f 6d 69 6e 61 6c 20 72 6f 6f 74 20 74 6f 20 62 ominal root to b
8c30: 65 20 6c 61 74 65 72 20 69 6e 20 74 69 6d 65 20 e later in time
8c40: 74 68 61 6e 20 74 68 65 20 4e 54 44 42 0a 09 23 than the NTDB..#
8c50: 20 20 20 20 20 72 6f 6f 74 2e 20 4e 6f 77 20 73 root. Now s
8c60: 65 74 74 69 6e 67 20 74 68 69 73 20 64 65 70 65 etting this depe
8c70: 6e 64 65 6e 63 79 20 77 69 6c 6c 20 62 65 20 62 ndency will be b
8c80: 61 63 6b 77 61 72 64 20 69 6e 0a 09 23 20 20 20 ackward in..#
8c90: 20 20 74 69 6d 65 2e 20 52 45 4d 4f 56 45 44 2e time. REMOVED.
8ca0: 0a 09 23 0a 09 23 20 28 34 29 20 49 66 20 52 20 ..#..# (4) If R
8cb0: 69 73 20 74 68 65 20 6c 61 73 74 20 6f 66 20 74 is the last of t
8cc0: 68 65 20 4e 54 44 42 20 72 65 76 69 73 69 6f 6e he NTDB revision
8cd0: 73 20 77 68 69 63 68 20 62 65 6c 6f 6e 67 20 74 s which belong t
8ce0: 6f 0a 09 23 20 20 20 20 20 74 68 65 20 74 72 75 o..# the tru
8cf0: 6e 6b 2c 20 74 68 65 6e 20 74 68 65 20 70 72 69 nk, then the pri
8d00: 6d 61 72 79 20 63 68 69 6c 64 20 6f 66 20 74 68 mary child of th
8d10: 65 20 74 72 75 6e 6b 20 72 6f 6f 74 20 28 74 68 e trunk root (th
8d20: 65 0a 09 23 20 20 20 20 20 27 31 2e 32 27 20 72 e..# '1.2' r
8d30: 65 76 69 73 69 6f 6e 29 20 69 73 20 61 20 73 75 evision) is a su
8d40: 63 63 65 73 73 6f 72 2c 20 69 66 20 69 74 20 65 ccessor, if it e
8d50: 78 69 73 74 73 2e 0a 0a 09 23 20 4e 6f 74 65 20 xists....# Note
8d60: 74 68 61 74 20 74 68 65 20 62 72 61 6e 63 68 65 that the branche
8d70: 73 20 73 70 61 77 6e 65 64 20 66 72 6f 6d 20 74 s spawned from t
8d80: 68 65 20 72 65 76 69 73 69 6f 6e 73 2c 20 61 6e he revisions, an
8d90: 64 20 74 68 65 0a 09 23 20 74 61 67 73 20 61 73 d the..# tags as
8da0: 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 sociated with th
8db0: 65 6d 20 61 72 65 20 73 75 63 63 65 73 73 6f 72 em are successor
8dc0: 73 20 61 73 20 77 65 6c 6c 2e 0a 0a 09 66 6f 72 s as well....for
8dd0: 65 61 63 68 20 7b 72 69 64 20 63 68 69 6c 64 7d each {rid child}
8de0: 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 [state run [sub
8df0: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d st -nocommands -
8e00: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a nobackslashes {.
8e10: 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 -- (1) Prima
8e20: 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53 45 ry child.. SE
8e30: 4c 45 43 54 20 52 2e 72 69 64 2c 20 52 2e 63 68 LECT R.rid, R.ch
8e40: 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 ild.. FROM
8e50: 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 revision R..
8e60: 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 WHERE R.rid I
8e70: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d N $theset --
8e80: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 Restrict to rev
8e90: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 isions of intere
8ea0: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 st.. AND R
8eb0: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 .child IS NOT NU
8ec0: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 LL -- Has pri
8ed0: 6d 61 72 79 20 63 68 69 6c 64 0a 20 20 20 20 55 mary child. U
8ee0: 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 32 29 20 NION. -- (2)
8ef0: 53 65 63 6f 6e 64 61 72 79 20 28 62 72 61 6e 63 Secondary (branc
8f00: 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 h) children..
8f10: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 SELECT R.rid, B
8f20: 2e 62 72 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 .brid.. FROM
8f30: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 revision R, re
8f40: 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c visionbranchchil
8f50: 64 72 65 6e 20 42 0a 09 20 20 20 20 57 48 45 52 dren B.. WHER
8f60: 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 E R.rid IN $t
8f70: 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 heset -- Res
8f80: 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f trict to revisio
8f90: 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 ns of interest..
8fa0: 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72 69 64 AND R.rid
8fb0: 20 3d 20 42 2e 72 69 64 20 20 20 20 20 20 20 20 = B.rid
8fc0: 20 20 2d 2d 20 53 65 6c 65 63 74 20 73 75 62 73 -- Select subs
8fd0: 65 74 20 6f 66 20 62 72 61 6e 63 68 20 63 68 69 et of branch chi
8fe0: 6c 64 72 65 6e 0a 20 20 20 20 55 4e 49 4f 4e 0a ldren. UNION.
8ff0: 20 20 20 20 2d 2d 20 28 34 29 20 43 68 69 6c 64 -- (4) Child
9000: 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74 20 73 of trunk root s
9010: 75 63 63 65 73 73 6f 72 20 6f 66 20 6c 61 73 74 uccessor of last
9020: 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b 2e 0a NTDB on trunk..
9030: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 . SELECT R.ri
9040: 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09 20 20 20 d, RA.child..
9050: 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 FROM revision R
9060: 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 0a 09 20 , revision RA..
9070: 20 20 20 57 48 45 52 45 20 52 2e 72 69 64 20 20 WHERE R.rid
9080: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 IN $theset
9090: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 -- Restrict to
90a0: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 revisions of int
90b0: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 erest.. AND
90c0: 20 52 2e 69 73 64 65 66 61 75 6c 74 20 20 20 20 R.isdefault
90d0: 20 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 -- Rest
90e0: 72 69 63 74 20 74 6f 20 4e 54 44 42 0a 09 20 20 rict to NTDB..
90f0: 20 20 41 4e 44 20 20 20 52 2e 64 62 63 68 69 6c AND R.dbchil
9100: 64 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 d IS NOT NULL
9110: 2d 2d 20 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 -- and last NTDB
9120: 20 62 65 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 belonging to tr
9130: 75 6e 6b 0a 09 20 20 20 20 41 4e 44 20 20 20 52 unk.. AND R
9140: 41 2e 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c A.rid = R.dbchil
9150: 64 20 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 d -- Go dir
9160: 65 63 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 ectly to trunk r
9170: 6f 6f 74 0a 09 20 20 20 20 41 4e 44 20 20 20 52 oot.. AND R
9180: 41 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e A.child IS NOT N
9190: 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 ULL -- Has pr
91a0: 69 6d 61 72 79 20 63 68 69 6c 64 2e 0a 09 7d 5d imary child...}]
91b0: 5d 20 7b 0a 09 20 20 20 20 23 20 43 6f 6e 73 69 ] {.. # Consi
91c0: 64 65 72 20 6d 6f 76 69 6e 67 20 74 68 69 73 20 der moving this
91d0: 74 6f 20 74 68 65 20 69 6e 74 65 67 72 69 74 79 to the integrity
91e0: 20 6d 6f 64 75 6c 65 2e 0a 09 20 20 20 20 69 6e module... in
91f0: 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b tegrity assert {
9200: 24 72 69 64 20 21 3d 20 24 63 68 69 6c 64 7d 20 $rid != $child}
9210: 7b 52 65 76 69 73 69 6f 6e 20 24 72 69 64 20 64 {Revision $rid d
9220: 65 70 65 6e 64 73 20 6f 6e 20 69 74 73 65 6c 66 epends on itself
9230: 2e 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 .}.. lappend
9240: 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 dependencies([li
9250: 73 74 20 72 65 76 20 24 72 69 64 5d 29 20 5b 6c st rev $rid]) [l
9260: 69 73 74 20 72 65 76 20 24 63 68 69 6c 64 5d 0a ist rev $child].
9270: 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 .}..foreach {rid
9280: 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 20 72 child} [state r
9290: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d un [subst -nocom
92a0: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
92b0: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 shes {.. SELE
92c0: 43 54 20 52 2e 72 69 64 2c 20 54 2e 74 69 64 0a CT R.rid, T.tid.
92d0: 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 . FROM revi
92e0: 73 69 6f 6e 20 52 2c 20 74 61 67 20 54 0a 09 20 sion R, tag T..
92f0: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 WHERE R.rid
9300: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 20 IN $theset
9310: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 -- Restrict to
9320: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 revisions of int
9330: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 erest.. AND
9340: 20 20 54 2e 72 65 76 20 3d 20 52 2e 72 69 64 20 T.rev = R.rid
9350: 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 -- Sele
9360: 63 74 20 74 61 67 73 20 61 74 74 61 63 68 65 64 ct tags attached
9370: 20 74 6f 20 74 68 65 6d 0a 09 7d 5d 5d 20 7b 0a to them..}]] {.
9380: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 . lappend dep
9390: 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 endencies([list
93a0: 72 65 76 20 24 72 69 64 5d 29 20 5b 6c 69 73 74 rev $rid]) [list
93b0: 20 73 79 6d 3a 3a 74 61 67 20 24 63 68 69 6c 64 sym::tag $child
93c0: 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b 72 ]..}..foreach {r
93d0: 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 id child} [state
93e0: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 run [subst -noc
93f0: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 ommands -nobacks
9400: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 lashes {.. SE
9410: 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 69 LECT R.rid, B.bi
9420: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 d.. FROM re
9430: 76 69 73 69 6f 6e 20 52 2c 20 62 72 61 6e 63 68 vision R, branch
9440: 20 42 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 B.. WHERE R
9450: 2e 72 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 .rid IN $theset
9460: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 -- Restric
9470: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f t to revisions o
9480: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 f interest..
9490: 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20 AND B.root =
94a0: 52 2e 72 69 64 20 20 20 20 20 20 20 20 20 2d 2d R.rid --
94b0: 20 53 65 6c 65 63 74 20 62 72 61 6e 63 68 65 73 Select branches
94c0: 20 61 74 74 61 63 68 65 64 20 74 6f 20 74 68 65 attached to the
94d0: 6d 0a 09 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 m..}]] {.. la
94e0: 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 ppend dependenci
94f0: 65 73 28 5b 6c 69 73 74 20 72 65 76 20 24 72 69 es([list rev $ri
9500: 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 d]) [list sym::b
9510: 72 61 6e 63 68 20 24 63 68 69 6c 64 5d 0a 09 7d ranch $child]..}
9520: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a ..return. }..
9530: 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c # result = l
9540: 69 73 74 20 28 63 68 61 6e 67 65 73 65 74 2d 69 ist (changeset-i
9550: 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f d). typemetho
9560: 64 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73 20 d cs_successors
9570: 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 20 20 {revisions} {.
9580: 20 20 20 20 20 20 23 20 54 68 69 73 20 69 73 20 # This is
9590: 61 20 76 61 72 69 61 6e 74 20 6f 66 20 27 73 75 a variant of 'su
95a0: 63 63 65 73 73 6f 72 73 27 20 77 68 69 63 68 20 ccessors' which
95b0: 6d 61 70 73 20 74 68 65 20 6c 6f 77 2d 6c 65 76 maps the low-lev
95c0: 65 6c 0a 20 20 20 20 20 20 20 20 23 20 64 61 74 el. # dat
95d0: 61 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 68 a directly to th
95e0: 65 20 61 73 73 6f 63 69 61 74 65 64 20 63 68 61 e associated cha
95f0: 6e 67 65 73 65 74 73 2e 20 49 2e 65 2e 20 69 6e ngesets. I.e. in
9600: 73 74 65 61 64 0a 20 20 20 20 20 20 20 20 23 20 stead. #
9610: 6d 69 6c 6c 69 6f 6e 73 20 6f 66 20 64 65 70 65 millions of depe
9620: 6e 64 65 6e 63 79 20 70 61 69 72 73 20 28 69 6e ndency pairs (in
9630: 20 65 78 74 72 65 6d 65 20 63 61 73 65 73 20 28 extreme cases (
9640: 45 78 61 6d 70 6c 65 3a 20 54 63 6c 0a 20 20 20 Example: Tcl.
9650: 20 20 20 20 20 23 20 43 56 53 29 29 20 77 65 20 # CVS)) we
9660: 72 65 74 75 72 6e 20 61 20 76 65 72 79 20 73 68 return a very sh
9670: 6f 72 74 20 61 6e 64 20 6d 75 63 68 20 6d 6f 72 ort and much mor
9680: 65 20 6d 61 6e 61 67 65 61 62 6c 65 20 6c 69 73 e manageable lis
9690: 74 0a 20 20 20 20 20 20 20 20 23 20 6f 66 20 63 t. # of c
96a0: 68 61 6e 67 65 73 65 74 73 2e 0a 0a 09 73 65 74 hangesets....set
96b0: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 theset ('[join
96c0: 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d $revisions {','}
96d0: 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 ]')..return [sta
96e0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e te run [subst -n
96f0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 ocommands -nobac
9700: 6b 73 6c 61 73 68 65 73 20 7b 0a 20 20 20 20 2d kslashes {. -
9710: 2d 20 28 31 29 20 50 72 69 6d 61 72 79 20 63 68 - (1) Primary ch
9720: 69 6c 64 0a 09 20 20 20 20 53 45 4c 45 43 54 20 ild.. SELECT
9730: 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 C.cid.. FROM
9740: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 63 73 revision R, cs
9750: 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 item CI, changes
9760: 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 et C.. WHERE
9770: 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 R.rid IN $the
9780: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 set -- Restr
9790: 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 ict to revisions
97a0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 of interest..
97b0: 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 AND R.child
97c0: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 IS NOT NULL
97d0: 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 -- Has primary c
97e0: 68 69 6c 64 0a 20 20 20 20 20 20 20 20 20 20 20 hild.
97f0: 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d AND CI.iid =
9800: 20 52 2e 63 68 69 6c 64 20 20 20 20 20 20 20 2d R.child -
9810: 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 - Select all cha
9820: 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20 20 20 ngesets.
9830: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 AND C.cid
9840: 20 3d 20 43 49 2e 63 69 64 20 20 20 20 20 20 20 = CI.cid
9850: 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 -- containing
9860: 74 68 65 20 70 72 69 6d 61 72 79 20 63 68 69 6c the primary chil
9870: 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e d. AN
9880: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 30 20 D C.type = 0
9890: 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20 77 -- w
98a0: 68 69 63 68 20 61 72 65 20 72 65 76 69 73 69 6f hich are revisio
98b0: 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 n changesets.
98c0: 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 32 UNION. -- (2
98d0: 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72 61 ) Secondary (bra
98e0: 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 20 nch) children..
98f0: 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a SELECT C.cid.
9900: 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 . FROM revi
9910: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e sion R, revision
9920: 62 72 61 6e 63 68 63 68 69 6c 64 72 65 6e 20 42 branchchildren B
9930: 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 , csitem CI, cha
9940: 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 ngeset C.. WH
9950: 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 ERE R.rid IN
9960: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 $theset -- R
9970: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 estrict to revis
9980: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 ions of interest
9990: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 72 .. AND R.r
99a0: 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 20 20 id = B.rid
99b0: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 73 75 -- Select su
99c0: 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 20 63 bset of branch c
99d0: 68 69 6c 64 72 65 6e 0a 20 20 20 20 20 20 20 20 hildren.
99e0: 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 AND CI.ii
99f0: 64 20 3d 20 42 2e 62 72 69 64 20 20 20 20 20 20 d = B.brid
9a00: 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 -- Select all
9a10: 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 20 changesets.
9a20: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e AND C.
9a30: 63 69 64 20 3d 20 43 49 2e 63 69 64 09 20 20 2d cid = CI.cid. -
9a40: 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 - containing the
9a50: 20 62 72 61 6e 63 68 0a 20 20 20 20 20 20 20 20 branch.
9a60: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 AND C.typ
9a70: 65 20 3d 20 30 09 09 20 20 2d 2d 20 77 68 69 63 e = 0.. -- whic
9a80: 68 20 61 72 65 20 72 65 76 69 73 69 6f 6e 20 63 h are revision c
9a90: 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e hangesets. UN
9aa0: 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20 43 ION. -- (4) C
9ab0: 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f hild of trunk ro
9ac0: 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 ot successor of
9ad0: 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 last NTDB on tru
9ae0: 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 nk... SELECT
9af0: 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 C.cid.. FROM
9b00: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 revision R, re
9b10: 76 69 73 69 6f 6e 20 52 41 2c 20 63 73 69 74 65 vision RA, csite
9b20: 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 m CI, changeset
9b30: 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e C.. WHERE R.
9b40: 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 74 rid IN $theset
9b50: 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 -- Restric
9b60: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f t to revisions o
9b70: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 f interest..
9b80: 41 4e 44 20 20 20 20 52 2e 69 73 64 65 66 61 75 AND R.isdefau
9b90: 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d lt -
9ba0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 - Restrict to NT
9bb0: 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 DB.. AND R
9bc0: 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 .dbchild IS NOT
9bd0: 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 NULL -- and la
9be0: 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e st NTDB belongin
9bf0: 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 g to trunk..
9c00: 41 4e 44 20 20 20 20 52 41 2e 72 69 64 20 3d 20 AND RA.rid =
9c10: 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d R.dbchild -
9c20: 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f - Go directly to
9c30: 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 trunk root..
9c40: 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c 64 AND RA.child
9c50: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 IS NOT NULL
9c60: 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 -- Has primary c
9c70: 68 69 6c 64 2e 0a 20 20 20 20 20 20 20 20 20 20 hild..
9c80: 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 AND CI.iid
9c90: 3d 20 52 41 2e 63 68 69 6c 64 20 20 20 20 20 20 = RA.child
9ca0: 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 -- Select all c
9cb0: 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20 hangesets.
9cc0: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 AND C.c
9cd0: 69 64 20 3d 20 43 49 2e 63 69 64 09 20 20 20 2d id = CI.cid. -
9ce0: 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 - containing the
9cf0: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 20 primary child.
9d00: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 AND
9d10: 20 20 43 2e 74 79 70 65 20 3d 20 30 09 09 20 20 C.type = 0..
9d20: 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 72 65 -- which are re
9d30: 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 vision changeset
9d40: 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 s. UNION..
9d50: 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 SELECT C.cid..
9d60: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 FROM revisi
9d70: 6f 6e 20 52 2c 20 74 61 67 20 54 2c 20 63 73 69 on R, tag T, csi
9d80: 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 tem CI, changese
9d90: 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 t C.. WHERE
9da0: 52 2e 72 69 64 20 69 6e 20 24 74 68 65 73 65 74 R.rid in $theset
9db0: 20 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 -- Restr
9dc0: 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 ict to revisions
9dd0: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 of interest..
9de0: 20 20 41 4e 44 20 20 20 20 54 2e 72 65 76 20 3d AND T.rev =
9df0: 20 52 2e 72 69 64 09 20 20 20 2d 2d 20 53 65 6c R.rid. -- Sel
9e00: 65 63 74 20 74 61 67 73 20 61 74 74 61 63 68 65 ect tags attache
9e10: 64 20 74 6f 20 74 68 65 6d 0a 20 20 20 20 20 20 d to them.
9e20: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e AND CI.
9e30: 69 69 64 20 3d 20 54 2e 74 69 64 20 20 20 20 20 iid = T.tid
9e40: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 -- Select a
9e50: 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 ll changesets.
9e60: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
9e70: 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 C.cid = CI.cid.
9e80: 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 -- containing
9e90: 20 74 68 65 20 74 61 67 73 0a 20 20 20 20 20 20 the tags.
9ea0: 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 AND C.t
9eb0: 79 70 65 20 3d 20 31 09 09 20 20 20 2d 2d 20 77 ype = 1.. -- w
9ec0: 68 69 63 68 20 61 72 65 20 74 61 67 20 63 68 61 hich are tag cha
9ed0: 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f ngesets. UNIO
9ee0: 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e N.. SELECT C.
9ef0: 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 cid.. FROM
9f00: 72 65 76 69 73 69 6f 6e 20 52 2c 20 62 72 61 6e revision R, bran
9f10: 63 68 20 42 2c 20 63 73 69 74 65 6d 20 43 49 2c ch B, csitem CI,
9f20: 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20 20 changeset C..
9f30: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 69 WHERE R.rid i
9f40: 6e 20 24 74 68 65 73 65 74 20 20 20 20 20 20 20 n $theset
9f50: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 -- Restrict to
9f60: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 revisions of int
9f70: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 erest.. AND
9f80: 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 69 64 B.root = R.rid
9f90: 09 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 62 72 . -- Select br
9fa0: 61 6e 63 68 65 73 20 61 74 74 61 63 68 65 64 20 anches attached
9fb0: 74 6f 20 74 68 65 6d 0a 20 20 20 20 20 20 20 20 to them.
9fc0: 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 AND CI.ii
9fd0: 64 20 3d 20 42 2e 62 69 64 20 20 20 20 20 20 20 d = B.bid
9fe0: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c 6c -- Select all
9ff0: 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 changesets.
a000: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 AND C
a010: 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 20 20 .cid = CI.cid.
a020: 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 -- containing t
a030: 68 65 20 62 72 61 6e 63 68 65 73 0a 20 20 20 20 he branches.
a040: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 AND C
a050: 2e 74 79 70 65 20 3d 20 32 09 09 20 20 20 2d 2d .type = 2.. --
a060: 20 77 68 69 63 68 20 61 72 65 20 62 72 61 6e 63 which are branc
a070: 68 20 63 68 61 6e 67 65 73 65 74 73 0a 09 7d 5d h changesets..}]
a080: 5d 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 ]. }.}..# # #
a090: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
a0a0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
a0b0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
a0c0: 23 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 ########.## Help
a0d0: 65 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f er singleton. Co
a0e0: 6d 6d 61 6e 64 73 20 66 6f 72 20 74 61 67 20 73 mmands for tag s
a0f0: 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 74 73 ymbol changesets
a100: 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a ...snit::type ::
a110: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f vc::fossil::impo
a120: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 rt::cvs::project
a130: 3a 3a 72 65 76 3a 3a 73 79 6d 3a 3a 74 61 67 20 ::rev::sym::tag
a140: 7b 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 {. typemethod
a150: 20 62 79 72 65 76 69 73 69 6f 6e 20 7b 7d 20 7b byrevision {} {
a160: 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 20 20 return 0 }.
a170: 74 79 70 65 6d 65 74 68 6f 64 20 62 79 73 79 6d typemethod bysym
a180: 62 6f 6c 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 bol {} { retur
a190: 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 n 1 }. typeme
a1a0: 74 68 6f 64 20 69 73 74 61 67 20 20 20 20 20 20 thod istag
a1b0: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a {} { return 1 }.
a1c0: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 typemethod i
a1d0: 73 62 72 61 6e 63 68 20 20 20 7b 7d 20 7b 20 72 sbranch {} { r
a1e0: 65 74 75 72 6e 20 30 20 7d 0a 0a 20 20 20 20 74 eturn 0 }.. t
a1f0: 79 70 65 6d 65 74 68 6f 64 20 73 74 72 20 7b 74 ypemethod str {t
a200: 61 67 7d 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c ag} {..struct::l
a210: 69 73 74 20 61 73 73 69 67 6e 20 5b 73 74 61 74 ist assign [stat
a220: 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c e run {.. SEL
a230: 45 43 54 20 53 2e 6e 61 6d 65 2c 20 46 2e 6e 61 ECT S.name, F.na
a240: 6d 65 2c 20 50 2e 6e 61 6d 65 0a 09 20 20 20 20 me, P.name..
a250: 46 52 4f 4d 20 20 20 74 61 67 20 54 2c 20 73 79 FROM tag T, sy
a260: 6d 62 6f 6c 20 53 2c 20 66 69 6c 65 20 46 2c 20 mbol S, file F,
a270: 70 72 6f 6a 65 63 74 20 50 0a 09 20 20 20 20 57 project P.. W
a280: 48 45 52 45 20 20 54 2e 74 69 64 20 3d 20 24 74 HERE T.tid = $t
a290: 61 67 20 20 20 2d 2d 20 46 69 6e 64 20 73 70 65 ag -- Find spe
a2a0: 63 69 66 69 65 64 20 74 61 67 0a 09 20 20 20 20 cified tag..
a2b0: 41 4e 44 20 20 20 20 46 2e 66 69 64 20 3d 20 54 AND F.fid = T
a2c0: 2e 66 69 64 20 20 2d 2d 20 47 65 74 20 66 69 6c .fid -- Get fil
a2d0: 65 20 6f 66 20 74 61 67 0a 09 20 20 20 20 41 4e e of tag.. AN
a2e0: 44 20 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 D P.pid = F.p
a2f0: 69 64 20 20 2d 2d 20 47 65 74 20 70 72 6f 6a 65 id -- Get proje
a300: 63 74 20 6f 66 20 66 69 6c 65 0a 09 20 20 20 20 ct of file..
a310: 41 4e 44 20 20 20 20 53 2e 73 69 64 20 3d 20 54 AND S.sid = T
a320: 2e 73 69 64 20 20 2d 2d 20 47 65 74 20 73 79 6d .sid -- Get sym
a330: 62 6f 6c 20 6f 66 20 74 61 67 0a 09 7d 5d 20 73 bol of tag..}] s
a340: 6e 61 6d 65 20 66 6e 61 6d 65 20 70 6e 61 6d 65 name fname pname
a350: 0a 09 72 65 74 75 72 6e 20 22 24 70 6e 61 6d 65 ..return "$pname
a360: 2f 54 27 24 7b 73 6e 61 6d 65 7d 27 3a 3a 24 66 /T'${sname}'::$f
a370: 6e 61 6d 65 22 0a 20 20 20 20 7d 0a 0a 20 20 20 name". }..
a380: 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 # result = list
a390: 20 28 6d 69 6e 74 69 6d 65 2c 20 6d 61 78 74 69 (mintime, maxti
a3a0: 6d 65 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 me). typemeth
a3b0: 6f 64 20 74 69 6d 65 72 61 6e 67 65 20 7b 74 61 od timerange {ta
a3c0: 67 73 7d 20 7b 0a 09 23 20 54 68 65 20 72 61 6e gs} {..# The ran
a3d0: 67 65 20 69 73 20 64 65 66 69 6e 65 64 20 61 73 ge is defined as
a3e0: 20 74 68 65 20 72 61 6e 67 65 20 6f 66 20 74 68 the range of th
a3f0: 65 20 72 65 76 69 73 69 6f 6e 73 20 74 68 65 20 e revisions the
a400: 74 61 67 73 0a 09 23 20 61 72 65 20 61 74 74 61 tags..# are atta
a410: 63 68 65 64 20 74 6f 2e 0a 0a 09 73 65 74 20 74 ched to....set t
a420: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 74 heset ('[join $t
a430: 61 67 73 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 ags {','}]')..re
a440: 74 75 72 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 turn [state run
a450: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e [subst -nocomman
a460: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 ds -nobackslashe
a470: 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 s {.. SELECT
a480: 4d 49 4e 28 52 2e 64 61 74 65 29 2c 20 4d 41 58 MIN(R.date), MAX
a490: 28 52 2e 64 61 74 65 29 0a 09 20 20 20 20 46 52 (R.date).. FR
a4a0: 4f 4d 20 20 20 74 61 67 20 54 2c 20 72 65 76 69 OM tag T, revi
a4b0: 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 sion R.. WHER
a4c0: 45 20 20 54 2e 74 69 64 20 49 4e 20 24 74 68 65 E T.tid IN $the
a4d0: 73 65 74 20 20 2d 2d 20 52 65 73 74 72 69 63 74 set -- Restrict
a4e0: 20 74 6f 20 74 61 67 73 20 6f 66 20 69 6e 74 65 to tags of inte
a4f0: 72 65 73 74 0a 20 20 20 20 20 20 20 20 20 20 20 rest.
a500: 20 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20 AND R.rid =
a510: 54 2e 72 65 76 20 20 20 20 20 2d 2d 20 53 65 6c T.rev -- Sel
a520: 65 63 74 20 74 61 67 20 70 61 72 65 6e 74 20 72 ect tag parent r
a530: 65 76 69 73 69 6f 6e 73 0a 09 7d 5d 5d 0a 20 20 evisions..}]].
a540: 20 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 }.. # var(d
a550: 76 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20 v) = dict (item
a560: 2d 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c -> list (item)),
a570: 20 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 item = list (t
a580: 79 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 65 ype id). type
a590: 6d 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72 method successor
a5a0: 73 20 7b 64 76 20 74 61 67 73 7d 20 7b 0a 09 23 s {dv tags} {..#
a5b0: 20 54 61 67 73 20 68 61 76 65 20 6e 6f 20 73 75 Tags have no su
a5c0: 63 63 65 73 73 6f 72 73 2e 0a 09 72 65 74 75 72 ccessors...retur
a5d0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 n. }.. # r
a5e0: 65 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 28 esult = 4-list (
a5f0: 69 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 20 itemtype itemid
a600: 6e 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 78 nextitemtype nex
a610: 74 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 20 titemid ...).
a620: 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f 70 typemethod loop
a630: 73 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20 54 61 s {tags} {..# Ta
a640: 67 73 20 68 61 76 65 20 6e 6f 20 73 75 63 63 65 gs have no succe
a650: 73 73 6f 72 73 2c 20 74 68 65 72 65 66 6f 72 65 ssors, therefore
a660: 20 63 61 6e 6e 6f 74 20 63 61 75 73 65 20 6c 6f cannot cause lo
a670: 6f 70 73 0a 09 72 65 74 75 72 6e 20 7b 7d 0a 20 ops..return {}.
a680: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 }.. # resu
a690: 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 lt = list (chang
a6a0: 65 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79 70 eset-id). typ
a6b0: 65 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63 65 emethod cs_succe
a6c0: 73 73 6f 72 73 20 7b 74 61 67 73 7d 20 7b 0a 09 ssors {tags} {..
a6d0: 23 20 54 61 67 73 20 68 61 76 65 20 6e 6f 20 73 # Tags have no s
a6e0: 75 63 63 65 73 73 6f 72 73 2e 0a 09 72 65 74 75 uccessors...retu
a6f0: 72 6e 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 rn. }.}..# #
a700: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
a710: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
a720: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
a730: 23 23 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c #########.## Hel
a740: 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 per singleton. C
a750: 6f 6d 6d 61 6e 64 73 20 66 6f 72 20 62 72 61 6e ommands for bran
a760: 63 68 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 ch symbol change
a770: 73 65 74 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 sets...snit::typ
a780: 65 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a e ::vc::fossil::
a790: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f import::cvs::pro
a7a0: 6a 65 63 74 3a 3a 72 65 76 3a 3a 73 79 6d 3a 3a ject::rev::sym::
a7b0: 62 72 61 6e 63 68 20 7b 0a 20 20 20 20 74 79 70 branch {. typ
a7c0: 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 69 emethod byrevisi
a7d0: 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 on {} { return 0
a7e0: 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f }. typemetho
a7f0: 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 d bysymbol {}
a800: 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20 20 20 { return 1 }.
a810: 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74 61 typemethod ista
a820: 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 g {} { retu
a830: 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d rn 0 }. typem
a840: 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20 20 ethod isbranch
a850: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d {} { return 1 }
a860: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 .. typemethod
a870: 20 73 74 72 20 7b 62 72 61 6e 63 68 7d 20 7b 0a str {branch} {.
a880: 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 .struct::list as
a890: 73 69 67 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 sign [state run
a8a0: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 53 2e {.. SELECT S.
a8b0: 6e 61 6d 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e name, F.name, P.
a8c0: 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 name.. FROM
a8d0: 20 62 72 61 6e 63 68 20 42 2c 20 73 79 6d 62 6f branch B, symbo
a8e0: 6c 20 53 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f l S, file F, pro
a8f0: 6a 65 63 74 20 50 0a 09 20 20 20 20 57 48 45 52 ject P.. WHER
a900: 45 20 20 42 2e 62 69 64 20 3d 20 24 62 72 61 6e E B.bid = $bran
a910: 63 68 20 20 2d 2d 20 46 69 6e 64 20 73 70 65 63 ch -- Find spec
a920: 69 66 69 65 64 20 62 72 61 6e 63 68 0a 09 20 20 ified branch..
a930: 20 20 41 4e 44 20 20 20 20 46 2e 66 69 64 20 3d AND F.fid =
a940: 20 42 2e 66 69 64 20 20 20 20 2d 2d 20 47 65 74 B.fid -- Get
a950: 20 66 69 6c 65 20 6f 66 20 62 72 61 6e 63 68 0a file of branch.
a960: 09 20 20 20 20 41 4e 44 20 20 20 20 50 2e 70 69 . AND P.pi
a970: 64 20 3d 20 46 2e 70 69 64 20 20 20 20 2d 2d 20 d = F.pid --
a980: 47 65 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 66 Get project of f
a990: 69 6c 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 ile.. AND
a9a0: 53 2e 73 69 64 20 3d 20 42 2e 73 69 64 20 20 20 S.sid = B.sid
a9b0: 20 2d 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f -- Get symbol o
a9c0: 66 20 62 72 61 6e 63 68 0a 09 7d 5d 20 73 6e 61 f branch..}] sna
a9d0: 6d 65 20 66 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 me fname pname..
a9e0: 72 65 74 75 72 6e 20 22 24 70 6e 61 6d 65 2f 42 return "$pname/B
a9f0: 27 24 7b 73 6e 61 6d 65 7d 27 3a 3a 24 66 6e 61 '${sname}'::$fna
aa00: 6d 65 22 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 me". }.. #
aa10: 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 result = list (
aa20: 6d 69 6e 74 69 6d 65 2c 20 6d 61 78 74 69 6d 65 mintime, maxtime
aa30: 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 ). typemethod
aa40: 20 74 69 6d 65 72 61 6e 67 65 20 7b 62 72 61 6e timerange {bran
aa50: 63 68 65 73 7d 20 7b 0a 09 23 20 54 68 65 20 72 ches} {..# The r
aa60: 61 6e 67 65 20 6f 66 20 61 20 62 72 61 6e 63 68 ange of a branch
aa70: 20 69 73 20 64 65 66 69 6e 65 64 20 61 73 20 74 is defined as t
aa80: 68 65 20 72 61 6e 67 65 20 6f 66 20 74 68 65 0a he range of the.
aa90: 09 23 20 72 65 76 69 73 69 6f 6e 73 20 74 68 65 .# revisions the
aaa0: 20 62 72 61 6e 63 68 65 73 20 61 72 65 20 73 70 branches are sp
aab0: 61 77 6e 65 64 20 62 79 2e 20 4e 4f 54 45 20 68 awned by. NOTE h
aac0: 6f 77 65 76 65 72 20 74 68 61 74 20 74 68 65 0a owever that the.
aad0: 09 23 20 62 72 61 6e 63 68 65 73 20 61 73 73 6f .# branches asso
aae0: 63 69 61 74 65 64 20 77 69 74 68 20 61 20 64 65 ciated with a de
aaf0: 74 61 63 68 65 64 20 4e 54 44 42 20 77 69 6c 6c tached NTDB will
ab00: 20 68 61 76 65 20 6e 6f 20 72 6f 6f 74 0a 09 23 have no root..#
ab10: 20 73 70 61 77 6e 69 6e 67 20 74 68 65 6d 2c 20 spawning them,
ab20: 68 65 6e 63 65 20 74 68 65 79 20 68 61 76 65 20 hence they have
ab30: 6e 6f 20 72 65 61 6c 20 74 69 6d 65 72 61 6e 67 no real timerang
ab40: 65 20 61 6e 79 0a 09 23 20 6c 6f 6e 67 65 72 2e e any..# longer.
ab50: 20 42 79 20 75 73 69 6e 67 20 30 20 77 65 20 70 By using 0 we p
ab60: 75 74 20 74 68 65 6d 20 69 6e 20 66 72 6f 6e 74 ut them in front
ab70: 20 6f 66 20 65 76 65 72 79 74 68 69 6e 67 20 65 of everything e
ab80: 6c 73 65 2c 0a 09 23 20 61 73 20 74 68 65 79 20 lse,..# as they
ab90: 6c 6f 67 69 63 61 6c 6c 79 20 61 72 65 2e 0a 0a logically are...
aba0: 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a .set theset ('[j
abb0: 6f 69 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 oin $branches {'
abc0: 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b ,'}]')..return [
abd0: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 state run [subst
abe0: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f -nocommands -no
abf0: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 backslashes {..
ac00: 20 20 20 53 45 4c 45 43 54 20 49 46 4e 55 4c 4c SELECT IFNULL
ac10: 28 4d 49 4e 28 52 2e 64 61 74 65 29 2c 30 29 2c (MIN(R.date),0),
ac20: 20 49 46 4e 55 4c 4c 28 4d 41 58 28 52 2e 64 61 IFNULL(MAX(R.da
ac30: 74 65 29 2c 30 29 0a 09 20 20 20 20 46 52 4f 4d te),0).. FROM
ac40: 20 20 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 branch B, revi
ac50: 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 sion R.. WHER
ac60: 45 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 E B.bid IN $thes
ac70: 65 74 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 et -- Restrict
ac80: 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 to branches of
ac90: 69 6e 74 65 72 65 73 74 0a 20 20 20 20 20 20 20 interest.
aca0: 20 20 20 20 20 41 4e 44 20 20 20 52 2e 72 69 64 AND R.rid
acb0: 20 3d 20 42 2e 72 6f 6f 74 20 20 20 20 20 2d 2d = B.root --
acc0: 20 53 65 6c 65 63 74 20 62 72 61 6e 63 68 20 70 Select branch p
acd0: 61 72 65 6e 74 20 72 65 76 69 73 69 6f 6e 73 0a arent revisions.
ace0: 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 .}]]. }..
acf0: 23 20 72 65 73 75 6c 74 20 3d 20 34 2d 6c 69 73 # result = 4-lis
ad00: 74 20 28 69 74 65 6d 74 79 70 65 20 69 74 65 6d t (itemtype item
ad10: 69 64 20 6e 65 78 74 69 74 65 6d 74 79 70 65 20 id nextitemtype
ad20: 6e 65 78 74 69 74 65 6d 69 64 20 2e 2e 2e 29 0a nextitemid ...).
ad30: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6c typemethod l
ad40: 6f 6f 70 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 oops {branches}
ad50: 7b 0a 09 23 20 4e 6f 74 65 3a 20 52 65 76 69 73 {..# Note: Revis
ad60: 69 6f 6e 73 20 61 6e 64 20 74 61 67 73 20 63 61 ions and tags ca
ad70: 6e 6e 6f 74 20 63 61 75 73 65 20 74 68 65 20 6c nnot cause the l
ad80: 6f 6f 70 2e 20 42 65 69 6e 67 20 6f 66 20 61 0a oop. Being of a.
ad90: 09 23 20 66 75 6e 64 61 6d 65 6e 74 61 6c 6c 79 .# fundamentally
ada0: 20 64 69 66 66 65 72 65 6e 74 20 74 79 70 65 20 different type
adb0: 74 68 65 79 20 63 61 6e 6e 6f 74 20 62 65 20 69 they cannot be i
adc0: 6e 20 74 68 65 20 69 6e 63 6f 6d 69 6e 67 0a 09 n the incoming..
add0: 23 20 73 65 74 20 6f 66 20 69 64 73 2e 0a 0a 09 # set of ids....
ade0: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f set theset ('[jo
adf0: 69 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c in $branches {',
ae00: 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 '}]')..return [s
ae10: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 tate run [subst
ae20: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 -nocommands -nob
ae30: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 ackslashes {..
ae40: 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 SELECT B.bid,
ae50: 42 58 2e 62 69 64 0a 09 20 20 20 20 46 52 4f 4d BX.bid.. FROM
ae60: 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 branch B, pre
ae70: 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20 62 feredparent P, b
ae80: 72 61 6e 63 68 20 42 58 0a 09 20 20 20 20 57 48 ranch BX.. WH
ae90: 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 ERE B.bid IN $t
aea0: 68 65 73 65 74 20 20 20 2d 2d 20 52 65 73 74 72 heset -- Restr
aeb0: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 ict to branches
aec0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
aed0: 20 41 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 AND B.sid =
aee0: 50 2e 70 69 64 20 20 20 20 20 20 2d 2d 20 47 65 P.pid -- Ge
aef0: 74 20 74 68 65 20 70 72 65 66 65 72 65 64 20 62 t the prefered b
af00: 72 61 6e 63 68 65 73 20 76 69 61 0a 09 20 20 20 ranches via..
af10: 20 41 4e 44 20 20 20 20 42 58 2e 73 69 64 20 3d AND BX.sid =
af20: 20 50 2e 73 69 64 20 20 20 20 20 2d 2d 20 74 68 P.sid -- th
af30: 65 20 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 73 e branch symbols
af40: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e .. AND BX.
af50: 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 bid IN $theset
af60: 2d 2d 20 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20 20 -- Loop..}]].
af70: 20 7d 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 }.. # var(dv
af80: 29 20 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d ) = dict (item -
af90: 3e 20 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20 > list (item)),
afa0: 69 74 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79 item = list (ty
afb0: 70 65 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d pe id). typem
afc0: 65 74 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73 ethod successors
afd0: 20 7b 64 76 20 62 72 61 6e 63 68 65 73 7d 20 7b {dv branches} {
afe0: 0a 09 75 70 76 61 72 20 31 20 24 64 76 20 64 65 ..upvar 1 $dv de
aff0: 70 65 6e 64 65 6e 63 69 65 73 0a 09 23 20 54 68 pendencies..# Th
b000: 65 20 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e e first revision
b010: 20 63 6f 6d 6d 69 74 74 65 64 20 6f 6e 20 61 20 committed on a
b020: 62 72 61 6e 63 68 2c 20 61 6e 64 20 61 6c 6c 20 branch, and all
b030: 62 72 61 6e 63 68 65 73 0a 09 23 20 61 6e 64 20 branches..# and
b040: 74 61 67 73 20 77 68 69 63 68 20 68 61 76 65 20 tags which have
b050: 69 74 20 61 73 20 74 68 65 69 72 20 70 72 65 66 it as their pref
b060: 65 72 65 64 20 70 61 72 65 6e 74 20 61 72 65 20 ered parent are
b070: 74 68 65 0a 09 23 20 73 75 63 63 65 73 73 6f 72 the..# successor
b080: 73 20 6f 66 20 61 20 62 72 61 6e 63 68 2e 0a 0a s of a branch...
b090: 09 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a .set theset ('[j
b0a0: 6f 69 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 oin $branches {'
b0b0: 2c 27 7d 5d 27 29 0a 09 66 6f 72 65 61 63 68 20 ,'}]')..foreach
b0c0: 7b 62 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 {bid child} [sta
b0d0: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e te run [subst -n
b0e0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 ocommands -nobac
b0f0: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 kslashes {..
b100: 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 52 2e SELECT B.bid, R.
b110: 72 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 rid.. FROM
b120: 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 branch B, revisi
b130: 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 on R.. WHERE
b140: 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 B.bid IN $these
b150: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 t -- Restric
b160: 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 t to branches of
b170: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 interest.. A
b180: 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20 3d 20 ND B.first =
b190: 52 2e 72 69 64 20 20 20 20 20 20 2d 2d 20 47 65 R.rid -- Ge
b1a0: 74 20 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e t first revision
b1b0: 20 6f 6e 20 74 68 65 20 62 72 61 6e 63 68 0a 09 on the branch..
b1c0: 7d 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 }]] {.. lappe
b1d0: 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 nd dependencies(
b1e0: 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 [list sym::branc
b1f0: 68 20 24 62 69 64 5d 29 20 5b 6c 69 73 74 20 72 h $bid]) [list r
b200: 65 76 20 24 63 68 69 6c 64 5d 0a 09 7d 0a 09 66 ev $child]..}..f
b210: 6f 72 65 61 63 68 20 7b 62 69 64 20 63 68 69 6c oreach {bid chil
b220: 64 7d 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 d} [state run [s
b230: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 ubst -nocommands
b240: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 -nobackslashes
b250: 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e {.. SELECT B.
b260: 62 69 64 2c 20 42 58 2e 62 69 64 0a 09 20 20 20 bid, BX.bid..
b270: 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 FROM branch B
b280: 2c 20 70 72 65 66 65 72 65 64 70 61 72 65 6e 74 , preferedparent
b290: 20 50 2c 20 62 72 61 6e 63 68 20 42 58 0a 09 20 P, branch BX..
b2a0: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 WHERE B.bid
b2b0: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d IN $theset -
b2c0: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 - Restrict to br
b2d0: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 anches of intere
b2e0: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 st.. AND B
b2f0: 2e 73 69 64 20 3d 20 50 2e 70 69 64 20 20 20 20 .sid = P.pid
b300: 20 20 20 20 2d 2d 20 47 65 74 20 73 75 62 6f 72 -- Get subor
b310: 64 69 6e 61 74 65 20 62 72 61 6e 63 68 65 73 20 dinate branches
b320: 76 69 61 20 74 68 65 0a 09 20 20 20 20 41 4e 44 via the.. AND
b330: 20 20 20 20 42 58 2e 73 69 64 20 3d 20 50 2e 73 BX.sid = P.s
b340: 69 64 20 20 20 20 20 20 20 2d 2d 20 70 72 65 66 id -- pref
b350: 65 72 65 64 20 70 61 72 65 6e 74 73 20 6f 66 20 ered parents of
b360: 74 68 65 69 72 20 73 79 6d 62 6f 6c 73 0a 09 7d their symbols..}
b370: 5d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e ]] {.. lappen
b380: 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b d dependencies([
b390: 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 list sym::branch
b3a0: 20 24 62 69 64 5d 29 20 5b 6c 69 73 74 20 73 79 $bid]) [list sy
b3b0: 6d 3a 3a 62 72 61 6e 63 68 20 24 63 68 69 6c 64 m::branch $child
b3c0: 5d 0a 09 7d 0a 09 66 6f 72 65 61 63 68 20 7b 62 ]..}..foreach {b
b3d0: 69 64 20 63 68 69 6c 64 7d 20 5b 73 74 61 74 65 id child} [state
b3e0: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 run [subst -noc
b3f0: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 ommands -nobacks
b400: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 lashes {.. SE
b410: 4c 45 43 54 20 42 2e 62 69 64 2c 20 54 2e 74 69 LECT B.bid, T.ti
b420: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 d.. FROM br
b430: 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65 64 anch B, prefered
b440: 70 61 72 65 6e 74 20 50 2c 20 74 61 67 20 54 0a parent P, tag T.
b450: 09 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 . WHERE B.bi
b460: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 d IN $theset
b470: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 -- Restrict to
b480: 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 branches of inte
b490: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 rest.. AND
b4a0: 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 64 20 20 B.sid = P.pid
b4b0: 20 20 20 20 20 20 2d 2d 20 47 65 74 20 73 75 62 -- Get sub
b4c0: 6f 72 64 69 6e 61 74 65 20 74 61 67 73 20 76 69 ordinate tags vi
b4d0: 61 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 a the.. AND
b4e0: 20 20 54 2e 73 69 64 20 3d 20 50 2e 73 69 64 20 T.sid = P.sid
b4f0: 20 20 20 20 20 20 20 2d 2d 20 70 72 65 66 65 72 -- prefer
b500: 65 64 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68 ed parents of th
b510: 65 69 72 20 73 79 6d 62 6f 6c 73 0a 09 7d 5d 5d eir symbols..}]]
b520: 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 {.. lappend
b530: 64 65 70 65 6e 64 65 6e 63 69 65 73 28 5b 6c 69 dependencies([li
b540: 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 24 st sym::branch $
b550: 62 69 64 5d 29 20 5b 6c 69 73 74 20 73 79 6d 3a bid]) [list sym:
b560: 3a 74 61 67 20 24 63 68 69 6c 64 5d 0a 09 7d 0a :tag $child]..}.
b570: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 .return. }..
b580: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 # result = li
b590: 73 74 20 28 63 68 61 6e 67 65 73 65 74 2d 69 64 st (changeset-id
b5a0: 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 ). typemethod
b5b0: 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73 20 7b cs_successors {
b5c0: 62 72 61 6e 63 68 65 73 7d 20 7b 0a 20 20 20 20 branches} {.
b5d0: 20 20 20 20 23 20 54 68 69 73 20 69 73 20 61 20 # This is a
b5e0: 76 61 72 69 61 6e 74 20 6f 66 20 27 73 75 63 63 variant of 'succ
b5f0: 65 73 73 6f 72 73 27 20 77 68 69 63 68 20 6d 61 essors' which ma
b600: 70 73 20 74 68 65 20 6c 6f 77 2d 6c 65 76 65 6c ps the low-level
b610: 0a 20 20 20 20 20 20 20 20 23 20 64 61 74 61 20 . # data
b620: 64 69 72 65 63 74 6c 79 20 74 6f 20 74 68 65 20 directly to the
b630: 61 73 73 6f 63 69 61 74 65 64 20 63 68 61 6e 67 associated chang
b640: 65 73 65 74 73 2e 20 49 2e 65 2e 20 69 6e 73 74 esets. I.e. inst
b650: 65 61 64 0a 20 20 20 20 20 20 20 20 23 20 6d 69 ead. # mi
b660: 6c 6c 69 6f 6e 73 20 6f 66 20 64 65 70 65 6e 64 llions of depend
b670: 65 6e 63 79 20 70 61 69 72 73 20 28 69 6e 20 65 ency pairs (in e
b680: 78 74 72 65 6d 65 20 63 61 73 65 73 20 28 45 78 xtreme cases (Ex
b690: 61 6d 70 6c 65 3a 20 54 63 6c 0a 20 20 20 20 20 ample: Tcl.
b6a0: 20 20 20 23 20 43 56 53 29 29 20 77 65 20 72 65 # CVS)) we re
b6b0: 74 75 72 6e 20 61 20 76 65 72 79 20 73 68 6f 72 turn a very shor
b6c0: 74 20 61 6e 64 20 6d 75 63 68 20 6d 6f 72 65 20 t and much more
b6d0: 6d 61 6e 61 67 65 61 62 6c 65 20 6c 69 73 74 0a manageable list.
b6e0: 20 20 20 20 20 20 20 20 23 20 6f 66 20 63 68 61 # of cha
b6f0: 6e 67 65 73 65 74 73 2e 0a 0a 09 73 65 74 20 74 ngesets....set t
b700: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 heset ('[join $b
b710: 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 ranches {','}]')
b720: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 . return
b730: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 [state run [subs
b740: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e t -nocommands -n
b750: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 obackslashes {..
b760: 20 20 20 20 53 45 4c 45 43 54 20 43 2e 63 69 64 SELECT C.cid
b770: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 61 .. FROM bra
b780: 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 nch B, revision
b790: 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 R, csitem CI, ch
b7a0: 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 angeset C.. W
b7b0: 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 24 HERE B.bid IN $
b7c0: 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 65 theset -- Re
b7d0: 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 68 strict to branch
b7e0: 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 es of interest..
b7f0: 20 20 20 20 41 4e 44 20 20 20 20 42 2e 66 69 72 AND B.fir
b800: 73 74 20 3d 20 52 2e 72 69 64 09 2d 2d 20 47 65 st = R.rid.-- Ge
b810: 74 20 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e t first revision
b820: 20 6f 6e 20 74 68 65 20 62 72 61 6e 63 68 0a 20 on the branch.
b830: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 AND
b840: 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 CI.iid = R.rid
b850: 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 -- Select
b860: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a all changesets.
b870: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 AND
b880: 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 C.cid = CI.ci
b890: 64 09 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 d.-- containing
b8a0: 74 68 69 73 20 72 65 76 69 73 69 6f 6e 0a 20 20 this revision.
b8b0: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
b8c0: 20 43 2e 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 C.type = 0..--
b8d0: 77 68 69 63 68 20 61 72 65 20 72 65 76 69 73 69 which are revisi
b8e0: 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 on changesets.
b8f0: 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c UNION.. SEL
b900: 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 ECT C.cid.. F
b910: 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 ROM branch B,
b920: 70 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 preferedparent P
b930: 2c 20 62 72 61 6e 63 68 20 42 58 2c 20 63 73 69 , branch BX, csi
b940: 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 tem CI, changese
b950: 74 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 t C.. WHERE
b960: 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 B.bid IN $theset
b970: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 -- Restrict
b980: 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 to branches of
b990: 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e interest.. AN
b9a0: 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e 70 D B.sid = P.p
b9b0: 69 64 09 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 id.-- Get subord
b9c0: 69 6e 61 74 65 20 62 72 61 6e 63 68 65 73 20 76 inate branches v
b9d0: 69 61 20 74 68 65 0a 09 20 20 20 20 41 4e 44 20 ia the.. AND
b9e0: 20 20 20 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 BX.sid = P.si
b9f0: 64 09 2d 2d 20 70 72 65 66 65 72 65 64 20 70 61 d.-- prefered pa
ba00: 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20 73 rents of their s
ba10: 79 6d 62 6f 6c 73 0a 20 20 20 20 20 20 20 20 20 ymbols.
ba20: 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 AND CI.iid
ba30: 20 3d 20 42 58 2e 62 69 64 20 20 20 20 20 20 2d = BX.bid -
ba40: 2d 20 53 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 - Select all cha
ba50: 6e 67 65 73 65 74 73 0a 20 20 20 20 20 20 20 20 ngesets.
ba60: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 64 AND C.cid
ba70: 20 3d 20 43 49 2e 63 69 64 09 2d 2d 20 63 6f 6e = CI.cid.-- con
ba80: 74 61 69 6e 69 6e 67 20 74 68 65 20 73 75 62 6f taining the subo
ba90: 72 64 69 6e 61 74 65 20 62 72 61 6e 63 68 65 73 rdinate branches
baa0: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 . AND
bab0: 20 20 20 20 43 2e 74 79 70 65 20 3d 20 32 09 09 C.type = 2..
bac0: 2d 2d 20 77 68 69 63 68 20 61 72 65 20 62 72 61 -- which are bra
bad0: 6e 63 68 20 63 68 61 6e 67 65 73 65 74 73 0a 20 nch changesets.
bae0: 20 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 UNION.. SE
baf0: 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 LECT C.cid..
bb00: 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c FROM branch B,
bb10: 20 70 72 65 66 65 72 65 64 70 61 72 65 6e 74 20 preferedparent
bb20: 50 2c 20 74 61 67 20 54 2c 20 63 73 69 74 65 6d P, tag T, csitem
bb30: 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 CI, changeset C
bb40: 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 .. WHERE B.b
bb50: 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 id IN $theset
bb60: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f -- Restrict to
bb70: 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 branches of int
bb80: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 erest.. AND
bb90: 20 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 64 09 B.sid = P.pid.
bba0: 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 69 6e 61 -- Get subordina
bbb0: 74 65 20 74 61 67 73 20 76 69 61 20 74 68 65 0a te tags via the.
bbc0: 09 20 20 20 20 41 4e 44 20 20 20 20 54 2e 73 69 . AND T.si
bbd0: 64 20 3d 20 50 2e 73 69 64 09 2d 2d 20 70 72 65 d = P.sid.-- pre
bbe0: 66 65 72 65 64 20 70 61 72 65 6e 74 73 20 6f 66 fered parents of
bbf0: 20 74 68 65 69 72 20 73 79 6d 62 6f 6c 73 0a 20 their symbols.
bc00: 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 AND
bc10: 20 20 43 49 2e 69 69 64 20 3d 20 54 2e 74 69 64 CI.iid = T.tid
bc20: 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 -- Select
bc30: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a all changesets.
bc40: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 AND
bc50: 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 C.cid = CI.ci
bc60: 64 09 2d 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 d.-- containing
bc70: 74 68 65 20 73 75 62 6f 72 64 69 6e 61 74 65 20 the subordinate
bc80: 74 61 67 73 0a 20 20 20 20 20 20 20 20 20 20 20 tags.
bc90: 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d AND C.type =
bca0: 20 31 09 09 2d 2d 20 77 68 69 63 68 20 61 72 65 1..-- which are
bcb0: 20 74 61 67 20 63 68 61 6e 67 65 73 65 74 73 0a tag changesets.
bcc0: 09 7d 5d 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 .}]]..return.
bcd0: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 }.. typemeth
bce0: 6f 64 20 6c 69 6d 69 74 73 20 7b 62 72 61 6e 63 od limits {branc
bcf0: 68 65 73 7d 20 7b 0a 09 23 20 4e 6f 74 65 73 2e hes} {..# Notes.
bd00: 20 54 68 69 73 20 6d 65 74 68 6f 64 20 65 78 69 This method exi
bd10: 73 74 73 20 6f 6e 6c 79 20 66 6f 72 20 62 72 61 sts only for bra
bd20: 6e 63 68 65 73 2e 20 49 74 20 69 73 20 6e 65 65 nches. It is nee
bd30: 64 65 64 20 74 6f 0a 09 23 20 67 65 74 20 64 65 ded to..# get de
bd40: 74 61 69 6c 65 64 20 69 6e 66 6f 72 6d 61 74 69 tailed informati
bd50: 6f 6e 20 61 62 6f 75 74 20 61 20 62 61 63 6b 77 on about a backw
bd60: 61 72 64 20 62 72 61 6e 63 68 2e 20 49 74 20 64 ard branch. It d
bd70: 6f 65 73 0a 09 23 20 6e 6f 74 20 61 70 70 6c 79 oes..# not apply
bd80: 20 74 6f 20 74 61 67 73 2c 20 6e 6f 72 20 72 65 to tags, nor re
bd90: 76 69 73 69 6f 6e 73 2e 20 54 68 65 20 71 75 65 visions. The que
bda0: 72 69 65 73 20 63 61 6e 20 61 6c 73 6f 0a 09 23 ries can also..#
bdb0: 20 72 65 73 74 72 69 63 74 20 74 68 65 6d 73 65 restrict themse
bdc0: 6c 76 65 73 20 74 6f 20 74 68 65 20 72 65 76 69 lves to the revi
bdd0: 73 69 6f 6e 20 73 75 63 65 73 73 6f 72 73 2f 70 sion sucessors/p
bde0: 72 65 64 65 63 65 73 73 6f 72 73 0a 09 23 20 6f redecessors..# o
bdf0: 66 20 62 72 61 6e 63 68 65 73 2c 20 61 73 20 6f f branches, as o
be00: 6e 6c 79 20 74 68 65 79 20 68 61 76 65 20 6f 72 nly they have or
be10: 64 65 72 69 6e 67 20 64 61 74 61 20 61 6e 64 20 dering data and
be20: 74 68 75 73 20 63 61 6e 0a 09 23 20 63 61 75 73 thus can..# caus
be30: 65 20 74 68 65 20 62 61 63 6b 77 61 72 64 6e 65 e the backwardne
be40: 73 73 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 ss....set theset
be50: 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e 63 68 ('[join $branch
be60: 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 73 65 es {','}]')...se
be70: 74 20 6d 61 78 70 20 5b 73 74 61 74 65 20 72 75 t maxp [state ru
be80: 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d n [subst -nocomm
be90: 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 ands -nobackslas
bea0: 68 65 73 20 7b 0a 09 20 20 20 20 2d 2d 20 6d 61 hes {.. -- ma
beb0: 78 69 6d 61 6c 20 70 72 65 64 65 63 65 73 73 6f ximal predecesso
bec0: 72 20 70 6f 73 69 74 69 6f 6e 20 70 65 72 20 62 r position per b
bed0: 72 61 6e 63 68 0a 09 20 20 20 20 53 45 4c 45 43 ranch.. SELEC
bee0: 54 20 42 2e 62 69 64 2c 20 4d 41 58 20 28 43 4f T B.bid, MAX (CO
bef0: 2e 70 6f 73 29 0a 09 20 20 20 20 46 52 4f 4d 20 .pos).. FROM
bf00: 20 20 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 branch B, revi
bf10: 73 69 6f 6e 20 52 2c 20 63 73 69 74 65 6d 20 43 sion R, csitem C
bf20: 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 2c 20 I, changeset C,
bf30: 63 73 6f 72 64 65 72 20 43 4f 0a 09 20 20 20 20 csorder CO..
bf40: 57 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e 20 WHERE B.bid IN
bf50: 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 52 $theset -- R
bf60: 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 estrict to branc
bf70: 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a hes of interest.
bf80: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 6f . AND B.ro
bf90: 6f 74 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 ot = R.rid
bfa0: 20 2d 2d 20 47 65 74 20 62 72 61 6e 63 68 20 72 -- Get branch r
bfb0: 6f 6f 74 20 72 65 76 69 73 69 6f 6e 73 0a 09 20 oot revisions..
bfc0: 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 69 64 AND CI.iid
bfd0: 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 20 2d = R.rid -
bfe0: 2d 20 47 65 74 20 63 68 61 6e 67 65 73 65 74 73 - Get changesets
bff0: 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 0a containing the.
c000: 09 20 20 20 20 41 4e 44 20 20 20 20 43 2e 63 69 . AND C.ci
c010: 64 20 3d 20 43 49 2e 63 69 64 20 20 20 20 20 20 d = CI.cid
c020: 20 2d 2d 20 72 6f 6f 74 20 72 65 76 69 73 69 6f -- root revisio
c030: 6e 73 2c 20 77 68 69 63 68 20 61 72 65 0a 09 20 ns, which are..
c040: 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 AND C.type
c050: 20 3d 20 30 20 20 20 20 20 20 20 20 20 20 20 2d = 0 -
c060: 2d 20 72 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 - revision chang
c070: 65 73 65 74 73 0a 09 20 20 20 20 41 4e 44 20 20 esets.. AND
c080: 20 20 43 4f 2e 63 69 64 20 3d 20 43 2e 63 69 64 CO.cid = C.cid
c090: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 74 68 -- Get th
c0a0: 65 69 72 20 74 6f 70 6f 6c 6f 67 69 63 61 6c 20 eir topological
c0b0: 6f 72 64 65 72 69 6e 67 0a 09 20 20 20 20 47 52 ordering.. GR
c0c0: 4f 55 50 20 42 59 20 42 2e 62 69 64 0a 09 7d 5d OUP BY B.bid..}]
c0d0: 5d 0a 0a 09 73 65 74 20 6d 69 6e 73 20 5b 73 74 ]...set mins [st
c0e0: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d ate run [subst -
c0f0: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 nocommands -noba
c100: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 ckslashes {..
c110: 20 2d 2d 20 6d 69 6e 69 6d 61 6c 20 73 75 63 63 -- minimal succ
c120: 65 73 73 6f 72 20 70 6f 73 69 74 69 6f 6e 20 70 essor position p
c130: 65 72 20 62 72 61 6e 63 68 0a 09 20 20 20 20 53 er branch.. S
c140: 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 4d 49 4e ELECT B.bid, MIN
c150: 20 28 43 4f 2e 70 6f 73 29 0a 09 20 20 20 20 46 (CO.pos).. F
c160: 52 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 ROM branch B,
c170: 72 65 76 69 73 69 6f 6e 20 52 2c 20 63 73 69 74 revision R, csit
c180: 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 em CI, changeset
c190: 20 43 2c 20 63 73 6f 72 64 65 72 20 43 4f 0a 09 C, csorder CO..
c1a0: 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 WHERE B.bid
c1b0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 IN $theset
c1c0: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 -- Restrict to b
c1d0: 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 ranches of inter
c1e0: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 est.. AND
c1f0: 42 2e 66 69 72 73 74 20 3d 20 52 2e 72 69 64 20 B.first = R.rid
c200: 20 20 20 20 20 2d 2d 20 47 65 74 20 74 68 65 20 -- Get the
c210: 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e 73 20 first revisions
c220: 6f 6e 20 74 68 65 20 62 72 61 6e 63 68 65 73 0a on the branches.
c230: 09 20 20 20 20 41 4e 44 20 20 20 20 43 49 2e 69 . AND CI.i
c240: 69 64 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 id = R.rid
c250: 20 2d 2d 20 47 65 74 20 63 68 61 6e 67 65 73 65 -- Get changese
c260: 74 73 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 ts containing th
c270: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 2e e.. AND C.
c280: 63 69 64 20 3d 20 43 49 2e 63 69 64 09 2d 2d 20 cid = CI.cid.--
c290: 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e 73 2c first revisions,
c2a0: 20 77 68 69 63 68 20 61 72 65 0a 09 20 20 20 20 which are..
c2b0: 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 AND C.type =
c2c0: 30 09 09 2d 2d 20 72 65 76 69 73 69 6f 6e 20 63 0..-- revision c
c2d0: 68 61 6e 67 65 73 65 74 73 0a 09 20 20 20 20 41 hangesets.. A
c2e0: 4e 44 20 20 20 20 43 4f 2e 63 69 64 20 3d 20 43 ND CO.cid = C
c2f0: 2e 63 69 64 09 2d 2d 20 47 65 74 20 74 68 65 69 .cid.-- Get thei
c300: 72 20 74 6f 70 6f 6c 6f 67 69 63 61 6c 20 6f 72 r topological or
c310: 64 65 72 69 6e 67 0a 09 20 20 20 20 47 52 4f 55 dering.. GROU
c320: 50 20 42 59 20 42 2e 62 69 64 0a 09 7d 5d 5d 0a P BY B.bid..}]].
c330: 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 . return
c340: 5b 6c 69 73 74 20 24 6d 61 78 70 20 24 6d 69 6e [list $maxp $min
c350: 73 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 s]. }.. #
c360: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 # ## ### ##### #
c370: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 ####### ########
c380: 23 23 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e #####. ## Con
c390: 66 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 figuration..
c3a0: 70 72 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 pragma -hasinsta
c3b0: 6e 63 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 nces no ; # si
c3c0: 6e 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 ngleton. prag
c3d0: 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 ma -hastypeinfo
c3e0: 20 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 no ; # no int
c3f0: 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 rospection. p
c400: 72 61 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65 ragma -hastypede
c410: 73 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d stroy no ; # imm
c420: 6f 72 74 61 6c 0a 7d 0a 0a 23 20 23 20 23 23 20 ortal.}..# # ##
c430: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 ### ##### ######
c440: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
c450: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
c460: 23 23 23 23 23 23 0a 23 23 0a 0a 6e 61 6d 65 73 ######.##..names
c470: 70 61 63 65 20 65 76 61 6c 20 3a 3a 76 63 3a 3a pace eval ::vc::
c480: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a fossil::import::
c490: 63 76 73 3a 3a 70 72 6f 6a 65 63 74 20 7b 0a 20 cvs::project {.
c4a0: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 70 namespace exp
c4b0: 6f 72 74 20 72 65 76 0a 20 20 20 20 6e 61 6d 65 ort rev. name
c4c0: 73 70 61 63 65 20 65 76 61 6c 20 72 65 76 20 7b space eval rev {
c4d0: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f ..namespace impo
c4e0: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a rt ::vc::fossil:
c4f0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 :import::cvs::st
c500: 61 74 65 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 ate..namespace i
c510: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 mport ::vc::foss
c520: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a il::import::cvs:
c530: 3a 69 6e 74 65 67 72 69 74 79 0a 09 6e 61 6d 65 :integrity..name
c540: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 space import ::v
c550: 63 3a 3a 74 6f 6f 6c 73 3a 3a 6d 69 73 63 3a 3a c::tools::misc::
c560: 2a 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 *..namespace imp
c570: 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a ort ::vc::tools:
c580: 3a 74 72 6f 75 62 6c 65 0a 09 6e 61 6d 65 73 70 :trouble..namesp
c590: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a ace import ::vc:
c5a0: 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 6c 6f 67 :tools::log..log
c5b0: 20 72 65 67 69 73 74 65 72 20 63 73 65 74 73 0a register csets.
c5c0: 0a 09 23 20 53 65 74 20 75 70 20 74 68 65 20 68 ..# Set up the h
c5d0: 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 6f 6e 73 elper singletons
c5e0: 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c ..namespace eval
c5f0: 20 72 65 76 20 7b 0a 09 20 20 20 20 6e 61 6d 65 rev {.. name
c600: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 space import ::v
c610: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 c::fossil::impor
c620: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 20 t::cvs::state..
c630: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 namespace imp
c640: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c ort ::vc::fossil
c650: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 ::import::cvs::i
c660: 6e 74 65 67 72 69 74 79 0a 09 7d 0a 09 6e 61 6d ntegrity..}..nam
c670: 65 73 70 61 63 65 20 65 76 61 6c 20 73 79 6d 3a espace eval sym:
c680: 3a 74 61 67 20 7b 0a 09 20 20 20 20 6e 61 6d 65 :tag {.. name
c690: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 space import ::v
c6a0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 c::fossil::impor
c6b0: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 20 t::cvs::state..
c6c0: 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 namespace imp
c6d0: 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c ort ::vc::fossil
c6e0: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 ::import::cvs::i
c6f0: 6e 74 65 67 72 69 74 79 0a 09 7d 0a 09 6e 61 6d ntegrity..}..nam
c700: 65 73 70 61 63 65 20 65 76 61 6c 20 73 79 6d 3a espace eval sym:
c710: 3a 62 72 61 6e 63 68 20 7b 0a 09 20 20 20 20 6e :branch {.. n
c720: 61 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 amespace import
c730: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d ::vc::fossil::im
c740: 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 port::cvs::state
c750: 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 .. namespace
c760: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 import ::vc::fos
c770: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 sil::import::cvs
c780: 3a 3a 69 6e 74 65 67 72 69 74 79 0a 09 7d 0a 20 ::integrity..}.
c790: 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 }.}..# # ## #
c7a0: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 ## ##### #######
c7b0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 # #############
c7c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
c7d0: 23 23 23 23 23 0a 23 23 20 52 65 61 64 79 0a 0a #####.## Ready..
c7e0: 70 61 63 6b 61 67 65 20 70 72 6f 76 69 64 65 20 package provide
c7f0: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f vc::fossil::impo
c800: 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 rt::cvs::project
c810: 3a 3a 72 65 76 20 31 2e 30 0a 72 65 74 75 72 6e ::rev 1.0.return
c820: 0a .