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 2d 32 30 30 38 20 41 6e 64 72 65 61 73 20 07-2008 Andreas
0070: 4b 75 70 72 69 65 73 2e 0a 23 0a 23 20 54 68 69 Kupries..#.# Thi
0080: 73 20 73 6f 66 74 77 61 72 65 20 69 73 20 6c 69 s software is li
0090: 63 65 6e 73 65 64 20 61 73 20 64 65 73 63 72 69 censed as descri
00a0: 62 65 64 20 69 6e 20 74 68 65 20 66 69 6c 65 20 bed in the file
00b0: 4c 49 43 45 4e 53 45 2c 20 77 68 69 63 68 0a 23 LICENSE, which.#
00c0: 20 79 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65 you should have
00d0: 20 72 65 63 65 69 76 65 64 20 61 73 20 70 61 72 received as par
00e0: 74 20 6f 66 20 74 68 69 73 20 64 69 73 74 72 69 t of this distri
00f0: 62 75 74 69 6f 6e 2e 0a 23 0a 23 20 54 68 69 73 bution..#.# This
0100: 20 73 6f 66 74 77 61 72 65 20 63 6f 6e 73 69 73 software consis
0110: 74 73 20 6f 66 20 76 6f 6c 75 6e 74 61 72 79 20 ts of voluntary
0120: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 73 20 6d 61 contributions ma
0130: 64 65 20 62 79 20 6d 61 6e 79 0a 23 20 69 6e 64 de by many.# ind
0140: 69 76 69 64 75 61 6c 73 2e 20 20 46 6f 72 20 65 ividuals. For e
0150: 78 61 63 74 20 63 6f 6e 74 72 69 62 75 74 69 6f xact contributio
0160: 6e 20 68 69 73 74 6f 72 79 2c 20 73 65 65 20 74 n history, see t
0170: 68 65 20 72 65 76 69 73 69 6f 6e 0a 23 20 68 69 he revision.# hi
0180: 73 74 6f 72 79 20 61 6e 64 20 6c 6f 67 73 2c 20 story and logs,
0190: 61 76 61 69 6c 61 62 6c 65 20 61 74 20 68 74 74 available at htt
01a0: 70 3a 2f 2f 66 6f 73 73 69 6c 2d 73 63 6d 2e 68 p://fossil-scm.h
01b0: 77 61 63 69 2e 63 6f 6d 2f 66 6f 73 73 69 6c 0a waci.com/fossil.
01c0: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 # # ## ### #####
01d0: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 ######## ######
01e0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 ####### ########
01f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a 23 #############..#
0200: 23 20 52 65 76 69 73 69 6f 6e 73 20 70 65 72 20 # Revisions per
0210: 70 72 6f 6a 65 63 74 2c 20 61 6b 61 20 43 68 61 project, aka Cha
0220: 6e 67 65 73 65 74 73 2e 20 54 68 65 73 65 20 6f ngesets. These o
0230: 62 6a 65 63 74 73 20 61 72 65 20 66 69 72 73 74 bjects are first
0240: 20 75 73 65 64 0a 23 23 20 69 6e 20 70 61 73 73 used.## in pass
0250: 20 35 2c 20 77 68 69 63 68 20 63 72 65 61 74 65 5, which create
0260: 73 20 74 68 65 20 69 6e 69 74 69 61 6c 20 73 65 s the initial se
0270: 74 20 63 6f 76 65 72 69 6e 67 20 74 68 65 20 72 t covering the r
0280: 65 70 6f 73 69 74 6f 72 79 2e 0a 0a 23 20 23 20 epository...# #
0290: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
02a0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
02b0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
02c0: 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 71 #########.## Req
02d0: 75 69 72 65 6d 65 6e 74 73 0a 0a 70 61 63 6b 61 uirements..packa
02e0: 67 65 20 72 65 71 75 69 72 65 20 54 63 6c 20 38 ge require Tcl 8
02f0: 2e 34 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .4
0300: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0310: 20 3b 20 23 20 52 65 71 75 69 72 65 64 20 72 75 ; # Required ru
0320: 6e 74 69 6d 65 2e 0a 70 61 63 6b 61 67 65 20 72 ntime..package r
0330: 65 71 75 69 72 65 20 73 6e 69 74 20 20 20 20 20 equire 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 20 20 20 20 20 3b 20 23 ; #
0360: 20 4f 4f 20 73 79 73 74 65 6d 2e 0a 70 61 63 6b OO system..pack
0370: 61 67 65 20 72 65 71 75 69 72 65 20 73 74 72 75 age require stru
0380: 63 74 3a 3a 73 65 74 20 20 20 20 20 20 20 20 20 ct::set
0390: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
03a0: 20 20 3b 20 23 20 53 65 74 20 6f 70 65 72 61 74 ; # Set operat
03b0: 69 6f 6e 73 2e 0a 70 61 63 6b 61 67 65 20 72 65 ions..package re
03c0: 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a quire vc::tools:
03d0: 3a 6d 69 73 63 20 20 20 20 20 20 20 20 20 20 20 :misc
03e0: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 ; #
03f0: 54 65 78 74 20 66 6f 72 6d 61 74 74 69 6e 67 0a Text formatting.
0400: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 package require
0410: 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 vc::tools::troub
0420: 6c 65 20 20 20 20 20 20 20 20 20 20 20 20 20 20 le
0430: 20 20 20 20 20 20 3b 20 23 20 45 72 72 6f 72 20 ; # Error
0440: 72 65 70 6f 72 74 69 6e 67 2e 0a 70 61 63 6b 61 reporting..packa
0450: 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 ge require vc::t
0460: 6f 6f 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20 20 ools::log
0470: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0480: 20 3b 20 23 20 55 73 65 72 20 66 65 65 64 62 61 ; # User feedba
0490: 63 6b 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 ck..package requ
04a0: 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a ire vc::fossil::
04b0: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 61 import::cvs::sta
04c0: 74 65 20 20 20 20 20 20 20 20 3b 20 23 20 53 74 te ; # St
04d0: 61 74 65 20 73 74 6f 72 61 67 65 2e 0a 70 61 63 ate storage..pac
04e0: 6b 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a kage require vc:
04f0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a :fossil::import:
0500: 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 20 :cvs::integrity
0510: 20 20 20 3b 20 23 20 53 74 61 74 65 20 69 6e 74 ; # State int
0520: 65 67 72 69 74 79 20 63 68 65 63 6b 73 2e 0a 0a egrity checks...
0530: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 # # ## ### #####
0540: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 ######## ######
0550: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 ####### ########
0560: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 #############.##
0570: 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 ..snit::type ::v
0580: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 c::fossil::impor
0590: 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a t::cvs::project:
05a0: 3a 72 65 76 20 7b 0a 20 20 20 20 23 20 23 20 23 :rev {. # # #
05b0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
05c0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
05d0: 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c 69 63 ##. ## Public
05e0: 20 41 50 49 0a 0a 20 20 20 20 63 6f 6e 73 74 72 API.. constr
05f0: 75 63 74 6f 72 20 7b 70 72 6f 6a 65 63 74 20 63 uctor {project c
0600: 73 74 79 70 65 20 73 72 63 69 64 20 69 74 65 6d stype srcid item
0610: 73 20 7b 74 68 65 69 64 20 7b 7d 7d 7d 20 7b 0a s {theid {}}} {.
0620: 09 69 66 20 7b 24 74 68 65 69 64 20 6e 65 20 22 .if {$theid ne "
0630: 22 7d 20 7b 0a 09 20 20 20 20 73 65 74 20 6d 79 "} {.. set my
0640: 69 64 20 24 74 68 65 69 64 0a 09 7d 20 65 6c 73 id $theid..} els
0650: 65 20 7b 0a 09 20 20 20 20 73 65 74 20 6d 79 69 e {.. set myi
0660: 64 20 5b 69 6e 63 72 20 6d 79 63 6f 75 6e 74 65 d [incr mycounte
0670: 72 5d 0a 09 7d 0a 0a 09 69 6e 74 65 67 72 69 74 r]..}...integrit
0680: 79 20 61 73 73 65 72 74 20 7b 0a 09 20 20 20 20 y assert {..
0690: 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 6d 79 63 [info exists myc
06a0: 73 74 79 70 65 28 24 63 73 74 79 70 65 29 5d 0a stype($cstype)].
06b0: 09 7d 20 7b 42 61 64 20 63 68 61 6e 67 65 73 65 .} {Bad changese
06c0: 74 20 74 79 70 65 20 27 24 63 73 74 79 70 65 27 t type '$cstype'
06d0: 2e 7d 0a 0a 09 73 65 74 20 6d 79 70 72 6f 6a 65 .}...set myproje
06e0: 63 74 20 20 20 24 70 72 6f 6a 65 63 74 0a 09 73 ct $project..s
06f0: 65 74 20 6d 79 74 79 70 65 20 20 20 20 20 20 24 et mytype $
0700: 63 73 74 79 70 65 0a 09 73 65 74 20 6d 79 74 79 cstype..set myty
0710: 70 65 6f 62 6a 20 20 20 3a 3a 76 63 3a 3a 66 6f peobj ::vc::fo
0720: 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 ssil::import::cv
0730: 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a s::project::rev:
0740: 3a 24 7b 63 73 74 79 70 65 7d 0a 09 73 65 74 20 :${cstype}..set
0750: 6d 79 73 72 63 69 64 09 24 73 72 63 69 64 0a 09 mysrcid.$srcid..
0760: 73 65 74 20 6d 79 69 74 65 6d 73 20 20 20 20 20 set myitems
0770: 24 69 74 65 6d 73 0a 09 73 65 74 20 6d 79 70 6f $items..set mypo
0780: 73 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 43 s {} ; # C
0790: 6f 6d 6d 69 74 20 6c 6f 63 61 74 69 6f 6e 20 69 ommit location i
07a0: 73 20 6e 6f 74 20 6b 6e 6f 77 6e 20 79 65 74 2e s not known yet.
07b0: 0a 0a 09 66 6f 72 65 61 63 68 20 69 69 64 20 24 ...foreach iid $
07c0: 69 74 65 6d 73 20 7b 20 6c 61 70 70 65 6e 64 20 items { lappend
07d0: 6d 79 74 69 74 65 6d 73 20 5b 6c 69 73 74 20 24 mytitems [list $
07e0: 63 73 74 79 70 65 20 24 69 69 64 5d 20 7d 0a 0a cstype $iid] }..
07f0: 09 23 20 4b 65 65 70 20 74 72 61 63 6b 20 6f 66 .# Keep track of
0800: 20 74 68 65 20 67 65 6e 65 72 61 74 65 64 20 63 the generated c
0810: 68 61 6e 67 65 73 65 74 73 20 61 6e 64 20 6f 66 hangesets and of
0820: 20 74 68 65 20 69 6e 76 65 72 73 65 0a 09 23 20 the inverse..#
0830: 6d 61 70 70 69 6e 67 20 66 72 6f 6d 20 69 74 65 mapping from ite
0840: 6d 73 20 74 6f 20 74 68 65 6d 2e 0a 09 6c 61 70 ms to them...lap
0850: 70 65 6e 64 20 6d 79 63 68 61 6e 67 65 73 65 74 pend mychangeset
0860: 73 20 20 20 24 73 65 6c 66 0a 09 6c 61 70 70 65 s $self..lappe
0870: 6e 64 20 6d 79 74 63 68 61 6e 67 65 73 65 74 73 nd mytchangesets
0880: 28 24 63 73 74 79 70 65 29 20 24 73 65 6c 66 0a ($cstype) $self.
0890: 09 73 65 74 20 20 20 20 20 6d 79 69 64 6d 61 70 .set myidmap
08a0: 28 24 6d 79 69 64 29 20 24 73 65 6c 66 0a 0a 09 ($myid) $self...
08b0: 4d 61 70 49 74 65 6d 73 20 24 63 73 74 79 70 65 MapItems $cstype
08c0: 20 24 69 74 65 6d 73 0a 09 72 65 74 75 72 6e 0a $items..return.
08d0: 20 20 20 20 7d 0a 0a 20 20 20 20 64 65 73 74 72 }.. destr
08e0: 75 63 74 6f 72 20 7b 0a 09 23 20 57 65 20 6d 61 uctor {..# We ma
08f0: 79 20 62 65 20 61 62 6c 65 20 74 6f 20 67 65 74 y be able to get
0900: 20 72 69 64 20 6f 66 20 74 68 69 73 20 65 6e 74 rid of this ent
0910: 69 72 65 6c 79 2c 20 61 74 20 6c 65 61 73 74 20 irely, at least
0920: 66 6f 72 0a 09 23 20 28 64 65 29 63 6f 6e 73 74 for..# (de)const
0930: 72 75 63 74 69 6f 6e 20 61 6e 64 20 70 61 73 73 ruction and pass
0940: 20 49 6e 69 74 43 53 65 74 73 2e 0a 0a 09 55 6e InitCSets....Un
0950: 6d 61 70 49 74 65 6d 73 20 24 6d 79 74 79 70 65 mapItems $mytype
0960: 20 24 6d 79 69 74 65 6d 73 0a 09 75 6e 73 65 74 $myitems..unset
0970: 20 6d 79 69 64 6d 61 70 28 24 6d 79 69 64 29 0a myidmap($myid).
0980: 0a 09 73 65 74 20 70 6f 73 20 20 20 20 20 20 20 ..set pos
0990: 20 20 20 20 20 20 20 20 20 20 20 20 20 5b 6c 73 [ls
09a0: 65 61 72 63 68 20 2d 65 78 61 63 74 20 24 6d 79 earch -exact $my
09b0: 63 68 61 6e 67 65 73 65 74 73 20 24 73 65 6c 66 changesets $self
09c0: 5d 0a 09 73 65 74 20 6d 79 63 68 61 6e 67 65 73 ]..set mychanges
09d0: 65 74 73 20 20 20 20 20 20 20 20 20 20 20 5b 6c ets [l
09e0: 72 65 70 6c 61 63 65 20 20 20 20 20 20 20 24 6d replace $m
09f0: 79 63 68 61 6e 67 65 73 65 74 73 20 24 70 6f 73 ychangesets $pos
0a00: 20 24 70 6f 73 5d 0a 09 73 65 74 20 70 6f 73 20 $pos]..set pos
0a10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0a20: 20 20 20 5b 6c 73 65 61 72 63 68 20 2d 65 78 61 [lsearch -exa
0a30: 63 74 20 24 6d 79 74 63 68 61 6e 67 65 73 65 74 ct $mytchangeset
0a40: 73 28 24 6d 79 74 79 70 65 29 20 24 73 65 6c 66 s($mytype) $self
0a50: 5d 0a 09 73 65 74 20 6d 79 74 63 68 61 6e 67 65 ]..set mytchange
0a60: 73 65 74 73 28 24 6d 79 74 79 70 65 29 20 5b 6c sets($mytype) [l
0a70: 72 65 70 6c 61 63 65 20 20 20 20 20 20 20 24 6d replace $m
0a80: 79 74 63 68 61 6e 67 65 73 65 74 73 28 24 6d 79 ytchangesets($my
0a90: 74 79 70 65 29 20 24 70 6f 73 20 24 70 6f 73 5d type) $pos $pos]
0aa0: 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a ..return. }..
0ab0: 20 20 20 20 6d 65 74 68 6f 64 20 73 74 72 20 7b method str {
0ac0: 7d 20 7b 0a 09 73 65 74 20 73 74 72 20 20 20 20 } {..set str
0ad0: 22 3c 22 0a 09 73 65 74 20 64 65 74 61 69 6c 20 "<"..set detail
0ae0: 22 22 0a 09 69 66 20 7b 5b 24 6d 79 74 79 70 65 ""..if {[$mytype
0af0: 6f 62 6a 20 62 79 73 79 6d 62 6f 6c 5d 7d 20 7b obj bysymbol]} {
0b00: 0a 09 20 20 20 20 73 65 74 20 64 65 74 61 69 6c .. set detail
0b10: 20 22 20 27 5b 73 74 61 74 65 20 6f 6e 65 20 7b " '[state one {
0b20: 0a 09 09 53 45 4c 45 43 54 20 53 2e 6e 61 6d 65 ...SELECT S.name
0b30: 0a 09 09 46 52 4f 4d 20 20 20 73 79 6d 62 6f 6c ...FROM symbol
0b40: 20 53 0a 09 09 57 48 45 52 45 20 20 53 2e 73 69 S...WHERE S.si
0b50: 64 20 3d 20 24 6d 79 73 72 63 69 64 0a 09 20 20 d = $mysrcid..
0b60: 20 20 7d 5d 27 22 0a 09 7d 0a 09 61 70 70 65 6e }]'"..}..appen
0b70: 64 20 73 74 72 20 22 24 6d 79 74 79 70 65 20 24 d str "$mytype $
0b80: 7b 6d 79 69 64 7d 24 7b 64 65 74 61 69 6c 7d 3e {myid}${detail}>
0b90: 22 0a 09 72 65 74 75 72 6e 20 24 73 74 72 0a 20 "..return $str.
0ba0: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 }.. method
0bb0: 20 6c 6f 64 20 7b 7d 20 7b 0a 09 72 65 74 75 72 lod {} {..retur
0bc0: 6e 20 5b 24 6d 79 74 79 70 65 6f 62 6a 20 63 73 n [$mytypeobj cs
0bd0: 5f 6c 6f 64 20 24 6d 79 69 74 65 6d 73 5d 0a 20 _lod $myitems].
0be0: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 }.. method
0bf0: 20 69 64 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 id {} { retu
0c00: 72 6e 20 24 6d 79 69 64 20 7d 0a 20 20 20 20 6d rn $myid }. m
0c10: 65 74 68 6f 64 20 69 74 65 6d 73 20 7b 7d 20 7b ethod items {} {
0c20: 20 72 65 74 75 72 6e 20 24 6d 79 74 69 74 65 6d return $mytitem
0c30: 73 20 7d 0a 20 20 20 20 6d 65 74 68 6f 64 20 64 s }. method d
0c40: 61 74 61 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e ata {} { return
0c50: 20 5b 6c 69 73 74 20 24 6d 79 70 72 6f 6a 65 63 [list $myprojec
0c60: 74 20 24 6d 79 74 79 70 65 20 24 6d 79 73 72 63 t $mytype $mysrc
0c70: 69 64 5d 20 7d 0a 0a 20 20 20 20 64 65 6c 65 67 id] }.. deleg
0c80: 61 74 65 20 6d 65 74 68 6f 64 20 62 79 73 79 6d ate method bysym
0c90: 62 6f 6c 20 20 20 74 6f 20 6d 79 74 79 70 65 6f bol to mytypeo
0ca0: 62 6a 0a 20 20 20 20 64 65 6c 65 67 61 74 65 20 bj. delegate
0cb0: 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 69 6f method byrevisio
0cc0: 6e 20 74 6f 20 6d 79 74 79 70 65 6f 62 6a 0a 20 n to mytypeobj.
0cd0: 20 20 20 64 65 6c 65 67 61 74 65 20 6d 65 74 68 delegate meth
0ce0: 6f 64 20 69 73 62 72 61 6e 63 68 20 20 20 74 6f od isbranch to
0cf0: 20 6d 79 74 79 70 65 6f 62 6a 0a 20 20 20 20 64 mytypeobj. d
0d00: 65 6c 65 67 61 74 65 20 6d 65 74 68 6f 64 20 69 elegate method i
0d10: 73 74 61 67 20 20 20 20 20 20 74 6f 20 6d 79 74 stag to myt
0d20: 79 70 65 6f 62 6a 0a 0a 20 20 20 20 6d 65 74 68 ypeobj.. meth
0d30: 6f 64 20 73 65 74 70 6f 73 20 7b 70 7d 20 7b 20 od setpos {p} {
0d40: 73 65 74 20 6d 79 70 6f 73 20 24 70 20 3b 20 72 set mypos $p ; r
0d50: 65 74 75 72 6e 20 7d 0a 20 20 20 20 6d 65 74 68 eturn }. meth
0d60: 6f 64 20 70 6f 73 20 20 20 20 7b 7d 20 20 7b 20 od pos {} {
0d70: 72 65 74 75 72 6e 20 24 6d 79 70 6f 73 20 7d 0a return $mypos }.
0d80: 0a 20 20 20 20 6d 65 74 68 6f 64 20 64 65 74 65 . method dete
0d90: 72 6d 69 6e 65 73 75 63 63 65 73 73 6f 72 73 20 rminesuccessors
0da0: 7b 7d 20 7b 0a 09 23 20 50 61 73 73 20 36 20 6f {} {..# Pass 6 o
0db0: 70 65 72 61 74 69 6f 6e 2e 20 43 6f 6d 70 75 74 peration. Comput
0dc0: 65 20 70 72 6f 6a 65 63 74 2d 6c 65 76 65 6c 20 e project-level
0dd0: 64 65 70 65 6e 64 65 6e 63 69 65 73 20 66 72 6f dependencies fro
0de0: 6d 0a 09 23 20 74 68 65 20 66 69 6c 65 2d 6c 65 m..# the file-le
0df0: 76 65 6c 20 64 61 74 61 20 61 6e 64 20 73 61 76 vel data and sav
0e00: 65 20 69 74 20 62 61 63 6b 20 74 6f 20 74 68 65 e it back to the
0e10: 20 73 74 61 74 65 2e 20 54 68 69 73 20 6d 61 79 state. This may
0e20: 0a 09 23 20 62 65 20 63 61 6c 6c 65 64 20 64 75 ..# be called du
0e30: 72 69 6e 67 20 74 68 65 20 63 79 63 6c 65 20 62 ring the cycle b
0e40: 72 65 61 6b 65 72 20 70 61 73 73 65 73 20 61 73 reaker passes as
0e50: 20 77 65 6c 6c 2c 20 74 6f 20 61 64 6a 75 73 74 well, to adjust
0e60: 0a 09 23 20 74 68 65 20 73 75 63 63 65 73 73 6f ..# the successo
0e70: 72 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 6f 66 r information of
0e80: 20 63 68 61 6e 67 65 73 65 74 73 20 77 68 69 63 changesets whic
0e90: 68 20 61 72 65 20 74 68 65 0a 09 23 20 70 72 65 h are the..# pre
0ea0: 64 65 63 65 73 73 6f 72 73 20 6f 66 20 64 72 6f decessors of dro
0eb0: 70 70 65 64 20 63 68 61 6e 67 65 73 65 74 73 2e pped changesets.
0ec0: 20 46 6f 72 20 74 68 65 6d 20 77 65 20 68 61 76 For them we hav
0ed0: 65 20 74 6f 0a 09 23 20 72 65 6d 6f 76 65 20 74 e to..# remove t
0ee0: 68 65 69 72 20 65 78 69 73 74 69 6e 67 20 69 6e heir existing in
0ef0: 66 6f 72 6d 61 74 69 6f 6e 20 66 69 72 73 74 20 formation first
0f00: 62 65 66 6f 72 65 20 69 6e 73 65 72 74 69 6e 67 before inserting
0f10: 20 74 68 65 0a 09 23 20 6e 65 77 20 64 61 74 61 the..# new data
0f20: 2e 0a 09 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 ...state run {..
0f30: 20 20 20 20 44 45 4c 45 54 45 20 46 52 4f 4d 20 DELETE FROM
0f40: 63 73 73 75 63 63 65 73 73 6f 72 20 57 48 45 52 cssuccessor WHER
0f50: 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b 0a 09 E cid = $myid;..
0f60: 7d 0a 09 73 65 74 20 6c 6f 6f 70 20 30 0a 09 23 }..set loop 0..#
0f70: 20 54 4f 44 4f 3a 20 43 68 65 63 6b 20 6f 74 68 TODO: Check oth
0f80: 65 72 20 75 73 65 73 20 6f 66 20 63 73 5f 73 75 er uses of cs_su
0f90: 63 65 73 73 6f 72 73 2e 0a 09 23 20 54 4f 44 4f cessors...# TODO
0fa0: 3a 20 43 6f 6e 73 69 64 65 72 20 6d 65 72 67 69 : Consider mergi
0fb0: 6e 67 20 63 73 5f 73 75 63 65 73 73 6f 72 27 73 ng cs_sucessor's
0fc0: 20 53 45 4c 45 43 54 20 77 69 74 68 20 74 68 65 SELECT with the
0fd0: 20 49 4e 53 45 52 54 20 68 65 72 65 2e 0a 09 66 INSERT here...f
0fe0: 6f 72 65 61 63 68 20 6e 69 64 20 5b 24 6d 79 74 oreach nid [$myt
0ff0: 79 70 65 6f 62 6a 20 63 73 5f 73 75 63 63 65 73 ypeobj cs_succes
1000: 73 6f 72 73 20 24 6d 79 69 74 65 6d 73 5d 20 7b sors $myitems] {
1010: 0a 09 20 20 20 20 73 74 61 74 65 20 72 75 6e 20 .. state run
1020: 7b 0a 09 09 49 4e 53 45 52 54 20 49 4e 54 4f 20 {...INSERT INTO
1030: 63 73 73 75 63 63 65 73 73 6f 72 20 28 63 69 64 cssuccessor (cid
1040: 2c 20 20 6e 69 64 29 0a 09 09 56 41 4c 55 45 53 , nid)...VALUES
1050: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1060: 20 20 28 24 6d 79 69 64 2c 24 6e 69 64 29 0a 09 ($myid,$nid)..
1070: 20 20 20 20 7d 0a 09 20 20 20 20 69 66 20 7b 24 }.. if {$
1080: 6e 69 64 20 3d 3d 20 24 6d 79 69 64 7d 20 7b 20 nid == $myid} {
1090: 73 65 74 20 6c 6f 6f 70 20 31 20 7d 0a 09 7d 0a set loop 1 }..}.
10a0: 09 23 20 52 65 70 6f 72 74 20 61 66 74 65 72 20 .# Report after
10b0: 74 68 65 20 63 6f 6d 70 6c 65 74 65 20 73 74 72 the complete str
10c0: 75 63 74 75 72 65 20 68 61 73 20 62 65 65 6e 20 ucture has been
10d0: 73 61 76 65 64 2e 0a 09 69 66 20 7b 24 6c 6f 6f saved...if {$loo
10e0: 70 7d 20 7b 20 24 73 65 6c 66 20 72 65 70 6f 72 p} { $self repor
10f0: 74 6c 6f 6f 70 20 7d 0a 09 72 65 74 75 72 6e 0a tloop }..return.
1100: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 }.. # res
1110: 75 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e ult = list (chan
1120: 67 65 73 65 74 29 0a 20 20 20 20 6d 65 74 68 6f geset). metho
1130: 64 20 73 75 63 63 65 73 73 6f 72 73 20 7b 7d 20 d successors {}
1140: 7b 0a 09 23 20 55 73 65 20 74 68 65 20 64 61 74 {..# Use the dat
1150: 61 20 73 61 76 65 64 20 62 79 20 70 61 73 73 20 a saved by pass
1160: 36 2e 0a 09 72 65 74 75 72 6e 20 5b 73 74 72 75 6...return [stru
1170: 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 5b 73 74 ct::list map [st
1180: 61 74 65 20 72 75 6e 20 7b 0a 09 20 20 20 20 53 ate run {.. S
1190: 45 4c 45 43 54 20 53 2e 6e 69 64 0a 09 20 20 20 ELECT S.nid..
11a0: 20 46 52 4f 4d 20 20 20 63 73 73 75 63 63 65 73 FROM cssucces
11b0: 73 6f 72 20 53 0a 09 20 20 20 20 57 48 45 52 45 sor S.. WHERE
11c0: 20 20 53 2e 63 69 64 20 3d 20 24 6d 79 69 64 0a S.cid = $myid.
11d0: 09 7d 5d 20 5b 6d 79 74 79 70 65 6d 65 74 68 6f .}] [mytypemetho
11e0: 64 20 6f 66 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 d of]]. }..
11f0: 20 20 23 20 69 74 65 6d 20 2d 3e 20 6c 69 73 74 # item -> list
1200: 20 28 69 74 65 6d 29 0a 20 20 20 20 6d 65 74 68 (item). meth
1210: 6f 64 20 6e 65 78 74 6d 61 70 20 7b 7d 20 7b 0a od nextmap {} {.
1220: 09 24 6d 79 74 79 70 65 6f 62 6a 20 73 75 63 63 .$mytypeobj succ
1230: 65 73 73 6f 72 73 20 74 6d 70 20 24 6d 79 69 74 essors tmp $myit
1240: 65 6d 73 0a 09 72 65 74 75 72 6e 20 5b 61 72 72 ems..return [arr
1250: 61 79 20 67 65 74 20 74 6d 70 5d 0a 20 20 20 20 ay get tmp].
1260: 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 62 72 }.. method br
1270: 65 61 6b 69 6e 74 65 72 6e 61 6c 64 65 70 65 6e eakinternaldepen
1280: 64 65 6e 63 69 65 73 20 7b 63 76 7d 20 7b 0a 09 dencies {cv} {..
1290: 75 70 76 61 72 20 31 20 24 63 76 20 63 6f 75 6e upvar 1 $cv coun
12a0: 74 65 72 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 ter..log write 1
12b0: 34 20 63 73 65 74 73 20 7b 5b 24 73 65 6c 66 20 4 csets {[$self
12c0: 73 74 72 5d 20 42 49 44 7d 0a 09 76 63 3a 3a 74 str] BID}..vc::t
12d0: 6f 6f 6c 73 3a 3a 6d 65 6d 3a 3a 6d 61 72 6b 0a ools::mem::mark.
12e0: 0a 09 23 20 54 68 69 73 20 6d 65 74 68 6f 64 20 ..# This method
12f0: 69 6e 73 70 65 63 74 73 20 74 68 65 20 63 68 61 inspects the cha
1300: 6e 67 65 73 65 74 2c 20 6c 6f 6f 6b 69 6e 67 20 ngeset, looking
1310: 66 6f 72 20 69 6e 74 65 72 6e 61 6c 0a 09 23 20 for internal..#
1320: 64 65 70 65 6e 64 65 6e 63 69 65 73 2e 20 4e 6f dependencies. No
1330: 74 68 69 6e 67 20 69 73 20 64 6f 6e 65 20 69 66 thing is done if
1340: 20 74 68 65 72 65 20 61 72 65 20 6e 6f 20 73 75 there are no su
1350: 63 68 2e 0a 0a 09 23 20 4f 74 68 65 72 77 69 73 ch....# Otherwis
1360: 65 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 e the changeset
1370: 69 73 20 73 70 6c 69 74 20 69 6e 74 6f 20 61 20 is split into a
1380: 73 65 74 20 6f 66 20 66 72 61 67 6d 65 6e 74 73 set of fragments
1390: 0a 09 23 20 77 68 69 63 68 20 68 61 76 65 20 6e ..# which have n
13a0: 6f 20 69 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e o internal depen
13b0: 64 65 6e 63 69 65 73 2c 20 74 72 61 6e 73 66 6f dencies, transfo
13c0: 72 6d 69 6e 67 20 74 68 65 0a 09 23 20 69 6e 74 rming the..# int
13d0: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 ernal dependenci
13e0: 65 73 20 69 6e 74 6f 20 65 78 74 65 72 6e 61 6c es into external
13f0: 20 6f 6e 65 73 2e 20 54 68 65 20 6e 65 77 20 63 ones. The new c
1400: 68 61 6e 67 65 73 65 74 73 0a 09 23 20 67 65 6e hangesets..# gen
1410: 65 72 61 74 65 64 20 66 72 6f 6d 20 74 68 65 20 erated from the
1420: 66 72 61 67 6d 65 6e 74 20 69 6e 66 6f 72 6d 61 fragment informa
1430: 74 69 6f 6e 20 61 72 65 20 61 64 64 65 64 20 74 tion are added t
1440: 6f 20 74 68 65 0a 09 23 20 6c 69 73 74 20 6f 66 o the..# list of
1450: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 20 all changesets
1460: 28 62 79 20 74 68 65 20 63 61 6c 6c 65 72 29 2e (by the caller).
1470: 0a 0a 09 23 20 54 68 65 20 63 6f 64 65 20 63 68 ...# The code ch
1480: 65 63 6b 73 20 6f 6e 6c 79 20 73 75 63 63 65 73 ecks only succes
1490: 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 69 65 73 sor dependencies
14a0: 2c 20 61 73 20 74 68 69 73 20 61 75 74 6f 2d 0a , as this auto-.
14b0: 09 23 20 6d 61 74 69 63 61 6c 6c 79 20 63 6f 76 .# matically cov
14c0: 65 72 73 20 74 68 65 20 70 72 65 64 65 63 65 73 ers the predeces
14d0: 73 6f 72 20 64 65 70 65 6e 64 65 6e 63 69 65 73 sor dependencies
14e0: 20 61 73 20 77 65 6c 6c 20 28 41 6e 79 0a 09 23 as well (Any..#
14f0: 20 73 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e successor depen
1500: 64 65 6e 63 79 20 61 20 2d 3e 20 62 20 69 73 20 dency a -> b is
1510: 61 6c 73 6f 20 61 20 70 72 65 64 65 63 65 73 73 also a predecess
1520: 6f 72 20 64 65 70 65 6e 64 65 6e 63 79 0a 09 23 or dependency..#
1530: 20 62 20 2d 3e 20 61 29 2e 0a 0a 09 61 72 72 61 b -> a)....arra
1540: 79 20 73 65 74 20 62 72 65 61 6b 73 20 7b 7d 0a y set breaks {}.
1550: 0a 09 73 65 74 20 66 72 61 67 6d 65 6e 74 73 20 ..set fragments
1560: 5b 42 72 65 61 6b 44 69 72 65 63 74 44 65 70 65 [BreakDirectDepe
1570: 6e 64 65 6e 63 69 65 73 20 24 6d 79 69 74 65 6d ndencies $myitem
1580: 73 20 62 72 65 61 6b 73 5d 0a 0a 09 69 66 20 7b s breaks]...if {
1590: 21 5b 6c 6c 65 6e 67 74 68 20 24 66 72 61 67 6d ![llength $fragm
15a0: 65 6e 74 73 5d 7d 20 7b 20 72 65 74 75 72 6e 20 ents]} { return
15b0: 7b 7d 20 7d 0a 0a 09 72 65 74 75 72 6e 20 5b 24 {} }...return [$
15c0: 73 65 6c 66 20 43 72 65 61 74 65 46 72 6f 6d 46 self CreateFromF
15d0: 72 61 67 6d 65 6e 74 73 20 24 66 72 61 67 6d 65 ragments $fragme
15e0: 6e 74 73 20 63 6f 75 6e 74 65 72 20 62 72 65 61 nts counter brea
15f0: 6b 73 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d ks]. }.. m
1600: 65 74 68 6f 64 20 70 65 72 73 69 73 74 20 7b 7d ethod persist {}
1610: 20 7b 0a 09 73 65 74 20 74 69 64 20 24 6d 79 63 {..set tid $myc
1620: 73 74 79 70 65 28 24 6d 79 74 79 70 65 29 0a 09 stype($mytype)..
1630: 73 65 74 20 70 69 64 20 5b 24 6d 79 70 72 6f 6a set pid [$myproj
1640: 65 63 74 20 69 64 5d 0a 09 73 65 74 20 70 6f 73 ect id]..set pos
1650: 20 30 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73 0...state trans
1660: 61 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74 action {.. st
1670: 61 74 65 20 72 75 6e 20 7b 0a 09 09 49 4e 53 45 ate run {...INSE
1680: 52 54 20 49 4e 54 4f 20 63 68 61 6e 67 65 73 65 RT INTO changese
1690: 74 20 28 63 69 64 2c 20 20 20 70 69 64 2c 20 20 t (cid, pid,
16a0: 74 79 70 65 2c 20 73 72 63 29 0a 09 09 56 41 4c type, src)...VAL
16b0: 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20 UES
16c0: 20 20 20 28 24 6d 79 69 64 2c 20 24 70 69 64 2c ($myid, $pid,
16d0: 20 24 74 69 64 2c 20 24 6d 79 73 72 63 69 64 29 $tid, $mysrcid)
16e0: 3b 0a 09 20 20 20 20 7d 0a 0a 09 20 20 20 20 66 ;.. }... f
16f0: 6f 72 65 61 63 68 20 69 69 64 20 24 6d 79 69 74 oreach iid $myit
1700: 65 6d 73 20 7b 0a 09 09 73 74 61 74 65 20 72 75 ems {...state ru
1710: 6e 20 7b 0a 09 09 20 20 20 20 49 4e 53 45 52 54 n {... INSERT
1720: 20 49 4e 54 4f 20 63 73 69 74 65 6d 20 28 63 69 INTO csitem (ci
1730: 64 2c 20 20 20 70 6f 73 2c 20 20 69 69 64 29 0a d, pos, iid).
1740: 09 09 20 20 20 20 56 41 4c 55 45 53 20 20 20 20 .. VALUES
1750: 20 20 20 20 20 20 20 20 20 28 24 6d 79 69 64 2c ($myid,
1760: 20 24 70 6f 73 2c 20 24 69 69 64 29 3b 0a 09 09 $pos, $iid);...
1770: 7d 0a 09 09 69 6e 63 72 20 70 6f 73 0a 09 20 20 }...incr pos..
1780: 20 20 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 }..}..return.
1790: 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 }.. method
17a0: 20 74 69 6d 65 72 61 6e 67 65 20 7b 7d 20 7b 20 timerange {} {
17b0: 72 65 74 75 72 6e 20 5b 24 6d 79 74 79 70 65 6f return [$mytypeo
17c0: 62 6a 20 74 69 6d 65 72 61 6e 67 65 20 24 6d 79 bj timerange $my
17d0: 69 74 65 6d 73 5d 20 7d 0a 0a 20 20 20 20 6d 65 items] }.. me
17e0: 74 68 6f 64 20 6c 69 6d 69 74 73 20 7b 7d 20 7b thod limits {} {
17f0: 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 ..struct::list a
1800: 73 73 69 67 6e 20 5b 24 6d 79 74 79 70 65 6f 62 ssign [$mytypeob
1810: 6a 20 6c 69 6d 69 74 73 20 24 6d 79 69 74 65 6d j limits $myitem
1820: 73 5d 20 6d 61 78 70 20 6d 69 6e 73 0a 09 72 65 s] maxp mins..re
1830: 74 75 72 6e 20 5b 6c 69 73 74 20 5b 54 61 67 49 turn [list [TagI
1840: 74 65 6d 44 69 63 74 20 24 6d 61 78 70 20 24 6d temDict $maxp $m
1850: 79 74 79 70 65 5d 20 5b 54 61 67 49 74 65 6d 44 ytype] [TagItemD
1860: 69 63 74 20 24 6d 69 6e 73 20 24 6d 79 74 79 70 ict $mins $mytyp
1870: 65 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d e]]. }.. m
1880: 65 74 68 6f 64 20 64 72 6f 70 20 7b 7d 20 7b 0a ethod drop {} {.
1890: 09 6c 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 .log write 8 cse
18a0: 74 73 20 7b 44 72 6f 70 70 69 6e 67 20 24 73 65 ts {Dropping $se
18b0: 6c 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d lf = [$self str]
18c0: 7d 0a 0a 09 73 74 61 74 65 20 74 72 61 6e 73 61 }...state transa
18d0: 63 74 69 6f 6e 20 7b 0a 09 20 20 20 20 73 74 61 ction {.. sta
18e0: 74 65 20 72 75 6e 20 7b 0a 09 09 44 45 4c 45 54 te run {...DELET
18f0: 45 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65 74 E FROM changeset
1900: 20 20 20 57 48 45 52 45 20 63 69 64 20 3d 20 24 WHERE cid = $
1910: 6d 79 69 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 myid;...DELETE F
1920: 52 4f 4d 20 63 73 69 74 65 6d 20 20 20 20 20 20 ROM csitem
1930: 57 48 45 52 45 20 63 69 64 20 3d 20 24 6d 79 69 WHERE cid = $myi
1940: 64 3b 0a 09 09 44 45 4c 45 54 45 20 46 52 4f 4d d;...DELETE FROM
1950: 20 63 73 73 75 63 63 65 73 73 6f 72 20 57 48 45 cssuccessor WHE
1960: 52 45 20 63 69 64 20 3d 20 24 6d 79 69 64 3b 0a RE cid = $myid;.
1970: 09 20 20 20 20 7d 0a 09 7d 0a 0a 09 23 20 52 65 . }..}...# Re
1980: 74 75 72 6e 20 74 68 65 20 6c 69 73 74 20 6f 66 turn the list of
1990: 20 70 72 65 64 65 63 65 73 73 6f 72 73 20 73 6f predecessors so
19a0: 20 74 68 61 74 20 74 68 65 79 20 63 61 6e 20 62 that they can b
19b0: 65 20 61 64 6a 75 73 74 65 64 2e 0a 09 72 65 74 e adjusted...ret
19c0: 75 72 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69 73 urn [struct::lis
19d0: 74 20 6d 61 70 20 5b 73 74 61 74 65 20 72 75 6e t map [state run
19e0: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 63 {.. SELECT c
19f0: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 63 id.. FROM c
1a00: 73 73 75 63 63 65 73 73 6f 72 0a 09 20 20 20 20 ssuccessor..
1a10: 57 48 45 52 45 20 20 6e 69 64 20 3d 20 24 6d 79 WHERE nid = $my
1a20: 69 64 0a 09 7d 5d 20 5b 6d 79 74 79 70 65 6d 65 id..}] [mytypeme
1a30: 74 68 6f 64 20 6f 66 5d 5d 0a 20 20 20 20 7d 0a thod of]]. }.
1a40: 0a 20 20 20 20 6d 65 74 68 6f 64 20 72 65 70 6f . method repo
1a50: 72 74 6c 6f 6f 70 20 7b 7b 6b 69 6c 6c 20 31 7d rtloop {{kill 1}
1a60: 7d 20 7b 0a 09 23 20 57 65 20 70 72 69 6e 74 20 } {..# We print
1a70: 74 68 65 20 69 74 65 6d 73 20 77 68 69 63 68 20 the items which
1a80: 61 72 65 20 70 72 6f 64 75 63 69 6e 67 20 74 68 are producing th
1a90: 65 20 6c 6f 6f 70 2c 20 61 6e 64 20 68 6f 77 2e e loop, and how.
1aa0: 0a 0a 09 73 65 74 20 68 64 72 20 22 53 65 6c 66 ...set hdr "Self
1ab0: 2d 72 65 66 65 72 65 6e 74 69 61 6c 20 63 68 61 -referential cha
1ac0: 6e 67 65 73 65 74 20 5b 24 73 65 6c 66 20 73 74 ngeset [$self st
1ad0: 72 5d 20 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f 5f r] _____________
1ae0: 5f 5f 5f 5f 5f 22 0a 09 73 65 74 20 66 74 72 20 _____"..set ftr
1af0: 5b 72 65 67 73 75 62 20 2d 61 6c 6c 20 7b 5b 5e [regsub -all {[^
1b00: 20 09 5d 7d 20 24 68 64 72 20 7b 5f 7d 5d 0a 0a .]} $hdr {_}]..
1b10: 09 6c 6f 67 20 77 72 69 74 65 20 30 20 63 73 65 .log write 0 cse
1b20: 74 73 20 24 68 64 72 0a 09 66 6f 72 65 61 63 68 ts $hdr..foreach
1b30: 20 7b 69 74 65 6d 20 6e 65 78 74 69 74 65 6d 7d {item nextitem}
1b40: 20 5b 24 6d 79 74 79 70 65 6f 62 6a 20 6c 6f 6f [$mytypeobj loo
1b50: 70 73 20 24 6d 79 69 74 65 6d 73 5d 20 7b 0a 09 ps $myitems] {..
1b60: 20 20 20 20 23 20 43 72 65 61 74 65 20 74 61 67 # Create tag
1b70: 67 65 64 20 69 74 65 6d 73 20 66 72 6f 6d 20 74 ged items from t
1b80: 68 65 20 69 64 20 61 6e 64 20 6f 75 72 20 74 79 he id and our ty
1b90: 70 65 2e 0a 09 20 20 20 20 73 65 74 20 69 74 65 pe... set ite
1ba0: 6d 20 20 20 20 20 5b 6c 69 73 74 20 24 6d 79 74 m [list $myt
1bb0: 79 70 65 20 20 24 69 74 65 6d 5d 0a 09 20 20 20 ype $item]..
1bc0: 20 73 65 74 20 6e 65 78 74 69 74 65 6d 20 5b 6c set nextitem [l
1bd0: 69 73 74 20 24 6d 79 74 79 70 65 20 24 6e 65 78 ist $mytype $nex
1be0: 74 69 74 65 6d 5d 0a 09 20 20 20 20 23 20 50 72 titem].. # Pr
1bf0: 69 6e 74 61 62 6c 65 20 6c 61 62 65 6c 73 2e 0a intable labels..
1c00: 09 20 20 20 20 73 65 74 20 69 20 20 22 3c 5b 24 . set i "<[$
1c10: 74 79 70 65 20 69 74 65 6d 73 74 72 20 24 69 74 type itemstr $it
1c20: 65 6d 5d 3e 22 0a 09 20 20 20 20 73 65 74 20 6e em]>".. set n
1c30: 20 20 22 3c 5b 24 74 79 70 65 20 69 74 65 6d 73 "<[$type items
1c40: 74 72 20 24 6e 65 78 74 69 74 65 6d 5d 3e 22 0a tr $nextitem]>".
1c50: 09 20 20 20 20 73 65 74 20 6e 63 73 20 24 6d 79 . set ncs $my
1c60: 69 74 65 6d 6d 61 70 28 24 6e 65 78 74 69 74 65 itemmap($nextite
1c70: 6d 29 0a 09 20 20 20 20 23 20 50 72 69 6e 74 0a m).. # Print.
1c80: 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 30 . log write 0
1c90: 20 63 73 65 74 73 20 7b 2a 20 24 69 20 2d 2d 3e csets {* $i -->
1ca0: 20 24 6e 20 2d 2d 3e 20 63 73 20 5b 24 6e 63 73 $n --> cs [$ncs
1cb0: 20 73 74 72 5d 7d 0a 09 7d 0a 09 6c 6f 67 20 77 str]}..}..log w
1cc0: 72 69 74 65 20 30 20 63 73 65 74 73 20 24 66 74 rite 0 csets $ft
1cd0: 72 0a 0a 09 69 66 20 7b 21 24 6b 69 6c 6c 7d 20 r...if {!$kill}
1ce0: 72 65 74 75 72 6e 0a 09 74 72 6f 75 62 6c 65 20 return..trouble
1cf0: 69 6e 74 65 72 6e 61 6c 20 22 5b 24 73 65 6c 66 internal "[$self
1d00: 20 73 74 72 5d 20 64 65 70 65 6e 64 73 20 6f 6e str] depends on
1d10: 20 69 74 73 65 6c 66 22 0a 09 72 65 74 75 72 6e itself"..return
1d20: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 . }.. meth
1d30: 6f 64 20 70 75 73 68 74 6f 20 7b 72 65 70 6f 73 od pushto {repos
1d40: 69 74 6f 72 79 20 64 61 74 65 20 72 73 74 61 74 itory date rstat
1d50: 65 7d 20 7b 0a 09 23 20 47 65 6e 65 72 61 74 65 e} {..# Generate
1d60: 20 61 6e 64 20 69 6d 70 6f 72 74 20 74 68 65 20 and import the
1d70: 6d 61 6e 69 66 65 73 74 20 66 6f 72 20 74 68 69 manifest for thi
1d80: 73 20 63 68 61 6e 67 65 73 65 74 2e 0a 09 23 0a s changeset...#.
1d90: 09 23 20 44 61 74 61 20 6e 65 65 64 65 64 3a 0a .# Data needed:.
1da0: 09 23 20 2d 20 43 6f 6d 6d 69 74 20 6d 65 73 73 .# - Commit mess
1db0: 61 67 65 20 20 20 20 20 20 20 20 20 20 20 20 20 age
1dc0: 20 20 28 2d 2d 20 6d 79 73 72 63 69 64 20 2d 3e (-- mysrcid ->
1dd0: 20 72 65 70 6f 73 69 74 6f 72 79 20 6d 65 74 61 repository meta
1de0: 29 0a 09 23 20 2d 20 55 73 65 72 20 64 6f 69 6e )..# - User doin
1df0: 67 20 74 68 65 20 63 6f 6d 6d 69 74 20 20 20 20 g the commit
1e00: 20 20 20 20 28 73 2e 61 2e 29 0a 09 23 0a 09 23 (s.a.)..#..#
1e10: 20 2d 20 54 69 6d 65 73 74 61 6d 70 20 6f 66 20 - Timestamp of
1e20: 77 68 65 6e 20 63 6f 6d 6d 69 74 74 65 64 20 20 when committed
1e30: 28 63 6f 6d 6d 61 6e 64 20 61 72 67 75 6d 65 6e (command argumen
1e40: 74 29 0a 09 23 0a 09 23 20 2d 20 54 68 65 20 70 t)..#..# - The p
1e50: 61 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2c arent changeset,
1e60: 20 69 66 20 61 6e 79 2e 20 49 66 20 74 68 65 72 if any. If ther
1e70: 65 20 69 73 20 6e 6f 20 70 61 72 65 6e 74 20 66 e is no parent f
1e80: 6f 73 73 69 6c 0a 09 23 20 20 20 77 69 6c 6c 20 ossil..# will
1e90: 75 73 65 20 74 68 65 20 65 6d 70 74 79 20 62 61 use the empty ba
1ea0: 73 65 20 72 65 76 69 73 69 6f 6e 20 61 73 20 70 se revision as p
1eb0: 61 72 65 6e 74 2e 0a 09 23 0a 09 23 20 2d 20 4c arent...#..# - L
1ec0: 69 73 74 20 6f 66 20 74 68 65 20 66 69 6c 65 20 ist of the file
1ed0: 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 74 68 65 revisions in the
1ee0: 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a 09 73 74 changeset....st
1ef0: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 ruct::list assig
1f00: 6e 20 5b 24 6d 79 70 72 6f 6a 65 63 74 20 67 65 n [$myproject ge
1f10: 74 6d 65 74 61 20 24 6d 79 73 72 63 69 64 5d 20 tmeta $mysrcid]
1f20: 5f 5f 20 5f 5f 20 75 73 65 72 20 6d 65 73 73 61 __ __ user messa
1f30: 67 65 0a 0a 09 23 20 57 65 20 64 65 72 69 76 65 ge...# We derive
1f40: 20 74 68 65 20 6c 6f 64 20 69 6e 66 6f 72 6d 61 the lod informa
1f50: 74 69 6f 6e 20 64 69 72 65 63 74 6c 79 20 66 72 tion directly fr
1f60: 6f 6d 20 74 68 65 20 72 65 76 69 73 69 6f 6e 73 om the revisions
1f70: 20 6f 66 0a 09 23 20 74 68 65 20 63 68 61 6e 67 of..# the chang
1f80: 65 73 65 74 2c 20 61 73 20 74 68 65 20 62 72 61 eset, as the bra
1f90: 6e 63 68 20 70 61 72 74 20 6f 66 20 74 68 65 20 nch part of the
1fa0: 6d 65 74 61 20 64 61 74 61 20 28 73 2e 61 2e 29 meta data (s.a.)
1fb0: 20 69 73 0a 09 23 20 6f 75 74 64 61 74 65 64 20 is..# outdated
1fc0: 73 69 6e 63 65 20 70 61 73 73 20 46 69 6c 74 65 since pass Filte
1fd0: 72 53 79 6d 62 6f 6c 73 2e 0a 0a 09 73 65 74 20 rSymbols....set
1fe0: 6c 6f 64 6e 61 6d 65 20 5b 24 73 65 6c 66 20 6c lodname [$self l
1ff0: 6f 64 5d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 od]...log write
2000: 32 20 63 73 65 74 73 20 7b 49 6d 70 6f 72 74 69 2 csets {Importi
2010: 6e 67 20 72 65 76 69 73 69 6f 6e 20 5b 24 73 65 ng revision [$se
2020: 6c 66 20 73 74 72 5d 20 6f 6e 20 24 6c 6f 64 6e lf str] on $lodn
2030: 61 6d 65 7d 0a 0a 09 23 20 50 65 72 66 6f 72 6d ame}...# Perform
2040: 20 74 68 65 20 69 6d 70 6f 72 74 2e 20 41 73 20 the import. As
2050: 70 61 72 74 20 6f 66 20 74 68 61 74 20 77 65 20 part of that we
2060: 64 65 74 65 72 6d 69 6e 65 20 74 68 65 20 70 61 determine the pa
2070: 72 65 6e 74 0a 09 23 20 77 65 20 6e 65 65 64 2c rent..# we need,
2080: 20 61 6e 64 20 63 6f 6e 76 65 72 74 20 74 68 65 and convert the
2090: 20 6c 69 73 74 20 6f 66 20 69 74 65 6d 73 20 69 list of items i
20a0: 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 20 n the changeset
20b0: 69 6e 74 6f 0a 09 23 20 75 75 69 64 73 20 61 6e into..# uuids an
20c0: 64 20 70 72 69 6e 74 61 62 6c 65 20 64 61 74 61 d printable data
20d0: 2e 0a 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 ....struct::list
20e0: 20 61 73 73 69 67 6e 20 5b 47 65 74 69 73 64 65 assign [Getisde
20f0: 66 61 75 6c 74 20 24 6d 79 69 74 65 6d 73 5d 20 fault $myitems]
2100: 69 73 64 65 66 61 75 6c 74 20 6c 61 73 74 64 65 isdefault lastde
2110: 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 0a 0a 09 6c faultontrunk...l
2120: 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73 og write 8 csets
2130: 20 7b 4c 4f 44 20 20 20 20 27 24 6c 6f 64 6e 61 {LOD '$lodna
2140: 6d 65 27 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 me'}..log write
2150: 38 20 63 73 65 74 73 20 7b 20 64 65 66 3f 20 20 8 csets { def?
2160: 24 69 73 64 65 66 61 75 6c 74 7d 0a 09 6c 6f 67 $isdefault}..log
2170: 20 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b write 8 csets {
2180: 20 6c 61 73 74 3f 20 24 6c 61 73 74 64 65 66 61 last? $lastdefa
2190: 75 6c 74 6f 6e 74 72 75 6e 6b 7d 0a 0a 09 73 65 ultontrunk}...se
21a0: 74 20 6c 77 73 20 20 5b 47 65 74 77 6f 72 6b 73 t lws [Getworks
21b0: 70 61 63 65 20 20 20 20 24 72 73 74 61 74 65 20 pace $rstate
21c0: 24 6c 6f 64 6e 61 6d 65 20 24 6d 79 70 72 6f 6a $lodname $myproj
21d0: 65 63 74 20 24 69 73 64 65 66 61 75 6c 74 5d 0a ect $isdefault].
21e0: 09 24 6c 77 73 20 61 64 64 20 5b 47 65 74 72 65 .$lws add [Getre
21f0: 76 69 73 69 6f 6e 69 6e 66 6f 20 24 6d 79 69 74 visioninfo $myit
2200: 65 6d 73 5d 0a 0a 09 73 65 74 20 75 75 69 64 20 ems]...set uuid
2210: 5b 24 72 65 70 6f 73 69 74 6f 72 79 20 69 6d 70 [$repository imp
2220: 6f 72 74 72 65 76 69 73 69 6f 6e 20 5b 24 73 65 ortrevision [$se
2230: 6c 66 20 73 74 72 5d 20 5c 0a 09 09 20 20 20 20 lf str] \...
2240: 20 20 24 75 73 65 72 20 24 6d 65 73 73 61 67 65 $user $message
2250: 20 24 64 61 74 65 20 5c 0a 09 09 20 20 20 20 20 $date \...
2260: 20 5b 24 6c 77 73 20 67 65 74 69 64 5d 20 5b 24 [$lws getid] [$
2270: 6c 77 73 20 67 65 74 5d 5d 0a 0a 09 23 20 52 65 lws get]]...# Re
2280: 6d 65 6d 62 65 72 20 74 68 65 20 69 6d 70 6f 72 member the impor
2290: 74 65 64 20 63 68 61 6e 67 65 73 65 74 20 69 6e ted changeset in
22a0: 20 74 68 65 20 73 74 61 74 65 2c 20 75 6e 64 65 the state, unde
22b0: 72 20 6f 75 72 0a 09 23 20 4c 4f 44 2e 20 41 6e r our..# LOD. An
22c0: 64 20 69 66 20 69 74 20 69 73 20 74 68 65 20 6c d if it is the l
22d0: 61 73 74 20 74 72 75 6e 6b 20 63 68 61 6e 67 65 ast trunk change
22e0: 73 65 74 20 6f 6e 20 74 68 65 20 76 65 6e 64 6f set on the vendo
22f0: 72 0a 09 23 20 62 72 61 6e 63 68 20 74 68 65 6e r..# branch then
2300: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 69 73 the revision is
2310: 20 61 6c 73 6f 20 74 68 65 20 61 63 74 75 61 6c also the actual
2320: 20 72 6f 6f 74 20 6f 66 20 74 68 65 0a 09 23 20 root of the..#
2330: 3a 74 72 75 6e 6b 3a 2c 20 73 6f 20 77 65 20 72 :trunk:, so we r
2340: 65 6d 65 6d 62 65 72 20 69 74 20 61 73 20 73 75 emember it as su
2350: 63 68 20 69 6e 20 74 68 65 20 73 74 61 74 65 2e ch in the state.
2360: 20 48 6f 77 65 76 65 72 20 69 66 0a 09 23 20 74 However if..# t
2370: 68 65 20 74 72 75 6e 6b 20 61 6c 72 65 61 64 79 he trunk already
2380: 20 65 78 69 73 74 73 20 74 68 65 6e 20 74 68 65 exists then the
2390: 20 63 68 61 6e 67 65 73 65 74 20 63 61 6e 6e 6f changeset canno
23a0: 74 20 62 65 20 6f 6e 20 69 74 0a 09 23 20 61 6e t be on it..# an
23b0: 79 20 6d 6f 72 65 2e 20 54 68 69 73 20 69 6e 64 y more. This ind
23c0: 69 63 61 74 65 73 20 77 65 69 72 64 6e 65 73 73 icates weirdness
23d0: 20 69 6e 20 74 68 65 20 73 65 74 75 70 20 6f 66 in the setup of
23e0: 20 74 68 65 0a 09 23 20 76 65 6e 64 6f 72 20 62 the..# vendor b
23f0: 72 61 6e 63 68 2c 20 62 75 74 20 6f 6e 65 20 77 ranch, but one w
2400: 65 20 63 61 6e 20 77 6f 72 6b 20 61 72 6f 75 6e e can work aroun
2410: 64 2e 0a 0a 09 24 6c 77 73 20 64 65 66 69 64 20 d....$lws defid
2420: 24 75 75 69 64 0a 09 69 66 20 7b 24 6c 61 73 74 $uuid..if {$last
2430: 64 65 66 61 75 6c 74 6f 6e 74 72 75 6e 6b 7d 20 defaultontrunk}
2440: 7b 0a 09 20 20 20 20 69 66 20 7b 5b 24 72 73 74 {.. if {[$rst
2450: 61 74 65 20 68 61 73 20 3a 74 72 75 6e 6b 3a 5d ate has :trunk:]
2460: 7d 20 7b 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 } {...log write
2470: 32 20 63 73 65 74 73 20 7b 4d 75 6c 74 69 70 6c 2 csets {Multipl
2480: 65 20 63 68 61 6e 67 65 73 65 74 73 20 64 65 63 e changesets dec
2490: 6c 61 72 65 64 20 74 6f 20 62 65 20 74 68 65 20 lared to be the
24a0: 6c 61 73 74 20 74 72 75 6e 6b 20 63 68 61 6e 67 last trunk chang
24b0: 65 73 65 74 20 6f 6e 20 74 68 65 20 76 65 6e 64 eset on the vend
24c0: 6f 72 2d 62 72 61 6e 63 68 7d 0a 09 20 20 20 20 or-branch}..
24d0: 7d 20 65 6c 73 65 20 7b 0a 09 09 24 72 73 74 61 } else {...$rsta
24e0: 74 65 20 6e 65 77 20 3a 74 72 75 6e 6b 3a 20 5b te new :trunk: [
24f0: 24 6c 77 73 20 6e 61 6d 65 5d 0a 09 20 20 20 20 $lws name]..
2500: 7d 0a 09 7d 0a 0a 09 23 20 52 65 6d 65 6d 62 65 }..}...# Remembe
2510: 72 20 74 68 65 20 77 68 6f 6c 65 20 63 68 61 6e r the whole chan
2520: 67 65 73 65 74 20 2f 20 75 75 69 64 20 6d 61 70 geset / uuid map
2530: 70 69 6e 67 2c 20 66 6f 72 20 74 68 65 20 74 61 ping, for the ta
2540: 67 73 2e 0a 0a 09 73 74 61 74 65 20 72 75 6e 20 gs....state run
2550: 7b 0a 09 20 20 20 20 49 4e 53 45 52 54 20 49 4e {.. INSERT IN
2560: 54 4f 20 63 73 75 75 69 64 20 28 63 69 64 2c 20 TO csuuid (cid,
2570: 20 20 75 75 69 64 29 0a 09 20 20 20 20 56 41 4c uuid).. VAL
2580: 55 45 53 20 20 20 20 20 20 20 20 20 20 20 20 20 UES
2590: 28 24 6d 79 69 64 2c 20 24 75 75 69 64 29 0a 09 ($myid, $uuid)..
25a0: 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a }..return. }.
25b0: 0a 20 20 20 20 70 72 6f 63 20 47 65 74 72 65 76 . proc Getrev
25c0: 69 73 69 6f 6e 69 6e 66 6f 20 7b 72 65 76 69 73 isioninfo {revis
25d0: 69 6f 6e 73 7d 20 7b 0a 09 73 65 74 20 74 68 65 ions} {..set the
25e0: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 set ('[join $rev
25f0: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a isions {','}]').
2600: 09 73 65 74 20 72 65 76 69 73 69 6f 6e 73 20 7b .set revisions {
2610: 7d 0a 09 73 74 61 74 65 20 66 6f 72 65 61 63 68 }..state foreach
2620: 72 6f 77 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f row [subst -noco
2630: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c mmands -nobacksl
2640: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c ashes {.. SEL
2650: 45 43 54 20 55 2e 75 75 69 64 20 20 20 20 41 53 ECT U.uuid AS
2660: 20 66 72 69 64 2c 0a 09 20 20 20 20 20 20 20 20 frid,..
2670: 20 20 20 46 2e 76 69 73 69 62 6c 65 20 41 53 20 F.visible AS
2680: 70 61 74 68 2c 0a 09 20 20 20 20 20 20 20 20 20 path,..
2690: 20 20 46 2e 6e 61 6d 65 20 20 20 20 41 53 20 66 F.name AS f
26a0: 6e 61 6d 65 2c 0a 09 20 20 20 20 20 20 20 20 20 name,..
26b0: 20 20 52 2e 72 65 76 20 20 20 20 20 41 53 20 72 R.rev AS r
26c0: 65 76 6e 72 2c 0a 09 20 20 20 20 20 20 20 20 20 evnr,..
26d0: 20 20 52 2e 6f 70 20 20 20 20 20 20 41 53 20 72 R.op AS r
26e0: 6f 70 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 op.. FROM r
26f0: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 75 75 evision R, revuu
2700: 69 64 20 55 2c 20 66 69 6c 65 20 46 0a 09 20 20 id U, file F..
2710: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 49 WHERE R.rid I
2720: 4e 20 24 74 68 65 73 65 74 20 20 2d 2d 20 41 6c N $theset -- Al
2730: 6c 20 73 70 65 63 69 66 69 65 64 20 72 65 76 69 l specified revi
2740: 73 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20 20 sions.. AND
2750: 20 20 55 2e 72 69 64 20 3d 20 52 2e 72 69 64 20 U.rid = R.rid
2760: 20 20 20 20 2d 2d 20 67 65 74 20 66 6f 73 73 69 -- get fossi
2770: 6c 20 75 75 69 64 20 6f 66 20 72 65 76 69 73 69 l uuid of revisi
2780: 6f 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20 46 on.. AND F
2790: 2e 66 69 64 20 3d 20 52 2e 66 69 64 20 20 20 20 .fid = R.fid
27a0: 20 2d 2d 20 67 65 74 20 66 69 6c 65 20 6f 66 20 -- get file of
27b0: 72 65 76 69 73 69 6f 6e 0a 09 7d 5d 20 7b 0a 09 revision..}] {..
27c0: 20 20 20 20 6c 61 70 70 65 6e 64 20 72 65 76 69 lappend revi
27d0: 73 69 6f 6e 73 20 24 66 72 69 64 20 24 70 61 74 sions $frid $pat
27e0: 68 20 24 66 6e 61 6d 65 2f 24 72 65 76 6e 72 20 h $fname/$revnr
27f0: 24 72 6f 70 0a 09 7d 0a 09 72 65 74 75 72 6e 20 $rop..}..return
2800: 24 72 65 76 69 73 69 6f 6e 73 0a 20 20 20 20 7d $revisions. }
2810: 0a 0a 20 20 20 20 70 72 6f 63 20 47 65 74 77 6f .. proc Getwo
2820: 72 6b 73 70 61 63 65 20 7b 72 73 74 61 74 65 20 rkspace {rstate
2830: 6c 6f 64 6e 61 6d 65 20 70 72 6f 6a 65 63 74 20 lodname project
2840: 69 73 64 65 66 61 75 6c 74 7d 20 7b 0a 0a 09 23 isdefault} {...#
2850: 20 54 68 65 20 73 74 61 74 65 20 6f 62 6a 65 63 The state objec
2860: 74 20 68 6f 6c 64 73 20 74 68 65 20 77 6f 72 6b t holds the work
2870: 73 70 61 63 65 20 73 74 61 74 65 20 6f 66 20 65 space state of e
2880: 61 63 68 20 6b 6e 6f 77 6e 0a 09 23 20 6c 69 6e ach known..# lin
2890: 65 2d 6f 66 2d 64 65 76 65 6c 6f 70 6d 65 6e 74 e-of-development
28a0: 20 28 4c 4f 44 29 2c 20 75 70 20 74 6f 20 74 68 (LOD), up to th
28b0: 65 20 6c 61 73 74 20 63 6f 6d 6d 69 74 74 65 64 e last committed
28c0: 0a 09 23 20 63 68 61 6e 67 65 73 65 74 20 62 65 ..# changeset be
28d0: 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 68 61 74 20 longing to that
28e0: 4c 4f 44 2e 0a 0a 09 23 20 28 2a 29 20 53 74 61 LOD....# (*) Sta
28f0: 6e 64 61 72 64 20 68 61 6e 64 6c 69 6e 67 20 69 ndard handling i
2900: 66 20 69 6e 2d 4c 4f 44 20 63 68 61 6e 67 65 73 f in-LOD changes
2910: 65 74 73 2e 20 49 66 20 74 68 65 20 4c 4f 44 20 ets. If the LOD
2920: 6f 66 0a 09 23 20 20 20 20 20 74 68 65 20 63 75 of..# the cu
2930: 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 20 rrent changeset
2940: 65 78 69 73 74 73 20 69 6e 20 74 68 65 20 73 74 exists in the st
2950: 61 74 65 20 28 3d 20 68 61 73 20 62 65 65 6e 0a ate (= has been.
2960: 09 23 20 20 20 20 20 63 6f 6d 6d 69 74 74 65 64 .# committed
2970: 20 74 6f 29 20 74 68 65 6e 20 74 68 69 73 20 69 to) then this i
2980: 74 20 68 61 73 20 74 68 65 20 77 6f 72 6b 73 70 t has the worksp
2990: 61 63 65 20 77 65 20 61 72 65 0a 09 23 20 20 20 ace we are..#
29a0: 20 20 6c 6f 6f 6b 69 6e 67 20 66 6f 72 2e 0a 0a looking for...
29b0: 09 69 66 20 7b 5b 24 72 73 74 61 74 65 20 68 61 .if {[$rstate ha
29c0: 73 20 24 6c 6f 64 6e 61 6d 65 5d 7d 20 7b 0a 09 s $lodname]} {..
29d0: 20 20 20 20 72 65 74 75 72 6e 20 5b 24 72 73 74 return [$rst
29e0: 61 74 65 20 67 65 74 20 24 6c 6f 64 6e 61 6d 65 ate get $lodname
29f0: 5d 0a 09 7d 0a 0a 09 23 20 49 66 20 74 68 65 20 ]..}...# If the
2a00: 4c 4f 44 20 69 73 20 68 6f 77 65 76 65 72 20 6e LOD is however n
2a10: 6f 74 20 79 65 74 20 6b 6e 6f 77 6e 2c 20 74 68 ot yet known, th
2a20: 65 6e 20 74 68 65 20 63 75 72 72 65 6e 74 0a 09 en the current..
2a30: 23 20 63 68 61 6e 67 65 73 65 74 20 63 61 6e 20 # changeset can
2a40: 62 65 20 65 69 74 68 65 72 20 6f 66 0a 09 23 20 be either of..#
2a50: 28 61 29 20 72 6f 6f 74 20 6f 66 20 61 20 76 65 (a) root of a ve
2a60: 6e 64 6f 72 20 62 72 61 6e 63 68 2c 0a 09 23 20 ndor branch,..#
2a70: 28 62 29 20 72 6f 6f 74 20 6f 66 20 74 68 65 20 (b) root of the
2a80: 74 72 75 6e 6b 20 4c 4f 44 2c 20 6f 72 0a 09 23 trunk LOD, or..#
2a90: 20 28 63 29 20 74 68 65 20 66 69 72 73 74 20 63 (c) the first c
2aa0: 68 61 6e 67 65 73 65 74 20 69 6e 20 61 20 6e 65 hangeset in a ne
2ab0: 77 20 4c 4f 44 20 77 68 69 63 68 20 77 61 73 20 w LOD which was
2ac0: 73 70 61 77 6e 65 64 20 66 72 6f 6d 0a 09 23 20 spawned from..#
2ad0: 20 20 20 20 61 6e 20 65 78 69 73 74 69 6e 67 20 an existing
2ae0: 4c 4f 44 2e 0a 0a 09 23 20 46 6f 72 20 62 6f 74 LOD....# For bot
2af0: 68 20 28 61 29 20 61 6e 64 20 28 62 29 20 77 65 h (a) and (b) we
2b00: 20 68 61 76 65 20 74 6f 20 63 72 65 61 74 65 20 have to create
2b10: 61 20 6e 65 77 20 77 6f 72 6b 73 70 61 63 65 20 a new workspace
2b20: 66 6f 72 0a 09 23 20 74 68 65 20 6c 6f 64 2c 20 for..# the lod,
2b30: 61 6e 64 20 69 74 20 64 6f 65 73 6e 27 74 20 69 and it doesn't i
2b40: 6e 68 65 72 69 74 20 66 72 6f 6d 20 61 6e 79 74 nherit from anyt
2b50: 68 69 6e 67 2e 0a 0a 09 23 20 4f 6e 65 20 65 78 hing....# One ex
2b60: 63 65 70 74 69 6f 6e 20 66 6f 72 20 28 61 29 2e ception for (a).
2b70: 20 49 66 20 77 65 20 61 6c 72 65 61 64 79 20 68 If we already h
2b80: 61 76 65 20 61 20 3a 76 65 6e 64 6f 72 3a 20 62 ave a :vendor: b
2b90: 72 61 6e 63 68 0a 09 23 20 74 68 65 6e 20 6d 75 ranch..# then mu
2ba0: 6c 74 69 70 6c 65 20 73 79 6d 62 6f 6c 73 20 77 ltiple symbols w
2bb0: 65 72 65 20 75 73 65 64 20 66 6f 72 20 74 68 65 ere used for the
2bc0: 20 76 65 6e 64 6f 72 20 62 72 61 6e 63 68 20 62 vendor branch b
2bd0: 79 0a 09 23 20 64 69 66 66 65 72 65 6e 74 20 66 y..# different f
2be0: 69 6c 65 73 2e 20 49 6e 20 74 68 61 74 20 63 61 iles. In that ca
2bf0: 73 65 20 74 68 65 20 27 6e 65 77 27 20 62 72 61 se the 'new' bra
2c00: 6e 63 68 20 69 73 20 6d 61 64 65 20 61 6e 0a 09 nch is made an..
2c10: 23 20 61 6c 69 61 73 20 6f 66 20 74 68 65 20 3a # alias of the :
2c20: 76 65 6e 64 6f 72 3a 2c 20 65 66 66 65 63 74 69 vendor:, effecti
2c30: 76 65 6c 79 20 6d 65 72 67 69 6e 67 20 74 68 65 vely merging the
2c40: 20 73 79 6d 62 6f 6c 73 0a 09 23 20 74 6f 67 65 symbols..# toge
2c50: 74 68 65 72 2e 0a 0a 09 23 20 4e 6f 74 65 20 74 ther....# Note t
2c60: 68 61 74 20 63 61 73 65 20 28 62 29 20 6d 61 79 hat case (b) may
2c70: 20 6e 65 76 65 72 20 6f 63 63 75 72 2e 20 53 65 never occur. Se
2c80: 65 20 74 68 65 20 76 61 72 69 61 62 6c 65 0a 09 e the variable..
2c90: 23 20 27 6c 61 73 74 64 65 66 61 75 6c 74 6f 6e # 'lastdefaulton
2ca0: 74 72 75 6e 6b 27 20 69 6e 20 74 68 65 20 63 61 trunk' in the ca
2cb0: 6c 6c 65 72 20 28 6d 65 74 68 6f 64 20 70 75 73 ller (method pus
2cc0: 68 74 6f 29 2e 20 54 68 69 73 0a 09 23 20 66 6c hto). This..# fl
2cd0: 61 67 20 63 61 6e 20 74 68 65 20 67 65 6e 65 72 ag can the gener
2ce0: 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 77 6f 72 ation of the wor
2cf0: 6b 73 70 61 63 65 20 66 6f 72 20 74 68 65 20 3a kspace for the :
2d00: 74 72 75 6e 6b 3a 20 4c 4f 44 0a 09 23 20 61 73 trunk: LOD..# as
2d10: 20 77 65 6c 6c 2c 20 6d 61 6b 69 6e 67 20 69 74 well, making it
2d20: 20 69 6e 68 65 72 69 74 20 74 68 65 20 73 74 61 inherit the sta
2d30: 74 65 20 6f 66 20 74 68 65 20 6c 61 73 74 0a 09 te of the last..
2d40: 23 20 74 72 75 6e 6b 2d 63 68 61 6e 67 65 73 65 # trunk-changese
2d50: 74 20 6f 6e 20 74 68 65 20 76 65 6e 64 6f 72 2d t on the vendor-
2d60: 62 72 61 6e 63 68 2e 0a 0a 09 69 66 20 7b 24 69 branch....if {$i
2d70: 73 64 65 66 61 75 6c 74 7d 20 7b 0a 09 20 20 20 sdefault} {..
2d80: 20 69 66 20 7b 21 5b 24 72 73 74 61 74 65 20 68 if {![$rstate h
2d90: 61 73 20 22 3a 76 65 6e 64 6f 72 3a 22 5d 7d 20 as ":vendor:"]}
2da0: 7b 0a 09 09 23 20 43 72 65 61 74 65 20 74 68 65 {...# Create the
2db0: 20 76 65 6e 64 6f 72 20 62 72 61 6e 63 68 20 69 vendor branch i
2dc0: 66 20 6e 6f 74 20 70 72 65 73 65 6e 74 20 61 6c f not present al
2dd0: 72 65 61 64 79 2e 0a 09 09 24 72 73 74 61 74 65 ready....$rstate
2de0: 20 6e 65 77 20 3a 76 65 6e 64 6f 72 3a 0a 09 20 new :vendor:..
2df0: 20 20 20 7d 0a 09 20 20 20 20 23 20 4d 65 72 67 }.. # Merg
2e00: 65 20 74 68 65 20 6e 65 77 20 73 79 6d 62 6f 6c e the new symbol
2e10: 20 74 6f 20 74 68 65 20 76 65 6e 64 6f 72 20 62 to the vendor b
2e20: 72 61 6e 63 68 0a 09 20 20 20 20 24 72 73 74 61 ranch.. $rsta
2e30: 74 65 20 64 75 70 20 24 6c 6f 64 6e 61 6d 65 20 te dup $lodname
2e40: 3c 2d 2d 20 3a 76 65 6e 64 6f 72 3a 0a 09 20 20 <-- :vendor:..
2e50: 20 20 72 65 74 75 72 6e 20 5b 24 72 73 74 61 74 return [$rstat
2e60: 65 20 67 65 74 20 24 6c 6f 64 6e 61 6d 65 5d 0a e get $lodname].
2e70: 09 7d 0a 0a 09 69 66 20 7b 24 6c 6f 64 6e 61 6d .}...if {$lodnam
2e80: 65 20 65 71 20 22 3a 74 72 75 6e 6b 3a 22 7d 20 e eq ":trunk:"}
2e90: 7b 0a 09 20 20 20 20 72 65 74 75 72 6e 20 5b 24 {.. return [$
2ea0: 72 73 74 61 74 65 20 6e 65 77 20 24 6c 6f 64 6e rstate new $lodn
2eb0: 61 6d 65 5d 0a 09 7d 0a 0a 09 23 20 43 61 73 65 ame]..}...# Case
2ec0: 20 28 63 29 2e 20 57 65 20 66 69 6e 64 20 74 68 (c). We find th
2ed0: 65 20 70 61 72 65 6e 74 20 4c 4f 44 20 6f 66 20 e parent LOD of
2ee0: 6f 75 72 20 4c 4f 44 20 61 6e 64 20 6c 65 74 20 our LOD and let
2ef0: 74 68 65 20 6e 65 77 0a 09 23 20 77 6f 72 6b 73 the new..# works
2f00: 70 61 63 65 20 69 6e 68 65 72 69 74 20 66 72 6f pace inherit fro
2f10: 6d 20 74 68 65 20 70 61 72 65 6e 74 27 73 20 77 m the parent's w
2f20: 6f 72 6b 73 70 61 63 65 2e 0a 0a 09 73 65 74 20 orkspace....set
2f30: 70 6c 6f 64 6e 61 6d 65 20 5b 5b 5b 24 70 72 6f plodname [[[$pro
2f40: 6a 65 63 74 20 67 65 74 73 79 6d 62 6f 6c 20 24 ject getsymbol $
2f50: 6c 6f 64 6e 61 6d 65 5d 20 70 61 72 65 6e 74 5d lodname] parent]
2f60: 20 6e 61 6d 65 5d 0a 0a 09 6c 6f 67 20 77 72 69 name]...log wri
2f70: 74 65 20 38 20 63 73 65 74 73 20 7b 70 4c 4f 44 te 8 csets {pLOD
2f80: 20 20 20 27 24 70 6c 6f 64 6e 61 6d 65 27 7d 0a '$plodname'}.
2f90: 0a 09 69 66 20 7b 5b 24 72 73 74 61 74 65 20 68 ..if {[$rstate h
2fa0: 61 73 20 24 70 6c 6f 64 6e 61 6d 65 5d 7d 20 7b as $plodname]} {
2fb0: 0a 09 20 20 20 20 72 65 74 75 72 6e 20 5b 24 72 .. return [$r
2fc0: 73 74 61 74 65 20 6e 65 77 20 24 6c 6f 64 6e 61 state new $lodna
2fd0: 6d 65 20 24 70 6c 6f 64 6e 61 6d 65 5d 0a 09 7d me $plodname]..}
2fe0: 0a 0a 09 66 6f 72 65 61 63 68 20 6b 20 5b 6c 73 ...foreach k [ls
2ff0: 6f 72 74 20 5b 24 72 73 74 61 74 65 20 6e 61 6d ort [$rstate nam
3000: 65 73 5d 5d 20 7b 0a 09 20 20 20 20 6c 6f 67 20 es]] {.. log
3010: 77 72 69 74 65 20 38 20 63 73 65 74 73 20 7b 20 write 8 csets {
3020: 20 20 20 24 6b 20 3d 20 5b 5b 24 72 73 74 61 74 $k = [[$rstat
3030: 65 20 67 65 74 20 24 6b 5d 20 67 65 74 69 64 5d e get $k] getid]
3040: 7d 0a 09 7d 0a 0a 09 74 72 6f 75 62 6c 65 20 69 }..}...trouble i
3050: 6e 74 65 72 6e 61 6c 20 7b 55 6e 61 62 6c 65 20 nternal {Unable
3060: 74 6f 20 64 65 74 65 72 6d 69 6e 65 20 63 68 61 to determine cha
3070: 6e 67 65 73 65 74 20 70 61 72 65 6e 74 7d 0a 09 ngeset parent}..
3080: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 return. }..
3090: 20 20 70 72 6f 63 20 47 65 74 69 73 64 65 66 61 proc Getisdefa
30a0: 75 6c 74 20 7b 72 65 76 69 73 69 6f 6e 73 7d 20 ult {revisions}
30b0: 7b 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 {..set theset ('
30c0: 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 [join $revisions
30d0: 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 73 74 72 75 {','}]')...stru
30e0: 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 ct::list assign
30f0: 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 [state run [subs
3100: 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e t -nocommands -n
3110: 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 obackslashes {..
3120: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 69 73 64 SELECT R.isd
3130: 65 66 61 75 6c 74 2c 20 52 2e 64 62 63 68 69 6c efault, R.dbchil
3140: 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 d.. FROM re
3150: 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 vision R.. WH
3160: 45 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24 74 ERE R.rid IN $t
3170: 68 65 73 65 74 20 20 2d 2d 20 41 6c 6c 20 73 70 heset -- All sp
3180: 65 63 69 66 69 65 64 20 72 65 76 69 73 69 6f 6e ecified revision
3190: 73 0a 09 20 20 20 20 4c 49 4d 49 54 20 31 0a 09 s.. LIMIT 1..
31a0: 7d 5d 5d 20 64 65 66 20 6c 61 73 74 0a 0a 09 23 }]] def last...#
31b0: 20 54 4f 44 4f 2f 43 48 45 43 4b 3a 20 6c 6f 6f TODO/CHECK: loo
31c0: 6b 20 66 6f 72 20 63 68 61 6e 67 65 73 65 74 73 k for changesets
31d0: 20 77 68 65 72 65 20 69 73 64 65 66 61 75 6c 74 where isdefault
31e0: 2f 64 62 63 68 69 6c 64 20 69 73 0a 09 23 20 61 /dbchild is..# a
31f0: 6d 62 69 67 6f 75 73 2e 0a 0a 09 72 65 74 75 72 mbigous....retur
3200: 6e 20 5b 6c 69 73 74 20 24 64 65 66 20 5b 65 78 n [list $def [ex
3210: 70 72 20 7b 24 6c 61 73 74 20 6e 65 20 22 22 7d pr {$last ne ""}
3220: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 ]]. }.. ty
3230: 70 65 6d 65 74 68 6f 64 20 73 70 6c 69 74 20 7b pemethod split {
3240: 63 73 65 74 20 61 72 67 73 7d 20 7b 0a 09 23 20 cset args} {..#
3250: 41 73 20 70 61 72 74 20 6f 66 20 74 68 65 20 63 As part of the c
3260: 72 65 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 6e reation of the n
3270: 65 77 20 63 68 61 6e 67 65 73 65 74 73 20 73 70 ew changesets sp
3280: 65 63 69 66 69 65 64 20 69 6e 0a 09 23 20 41 52 ecified in..# AR
3290: 47 53 20 61 73 20 73 65 74 73 20 6f 66 20 69 74 GS as sets of it
32a0: 65 6d 73 2c 20 61 6c 6c 20 73 75 62 73 65 74 73 ems, all subsets
32b0: 20 6f 66 20 43 53 45 54 27 73 20 69 74 65 6d 20 of CSET's item
32c0: 73 65 74 2c 20 43 53 45 54 0a 09 23 20 77 69 6c set, CSET..# wil
32d0: 6c 20 62 65 20 64 72 6f 70 70 65 64 20 66 72 6f l be dropped fro
32e0: 6d 20 61 6c 6c 20 64 61 74 61 62 61 73 65 73 2c m all databases,
32f0: 20 69 6e 20 61 6e 64 20 6f 75 74 20 6f 66 20 6d in and out of m
3300: 65 6d 6f 72 79 2c 0a 09 23 20 61 6e 64 20 74 68 emory,..# and th
3310: 65 6e 20 64 65 73 74 72 6f 79 65 64 2e 0a 09 23 en destroyed...#
3320: 0a 09 23 20 4e 6f 74 65 3a 20 54 68 65 20 69 74 ..# Note: The it
3330: 65 6d 20 6c 69 73 74 73 20 66 6f 75 6e 64 20 69 em lists found i
3340: 6e 20 61 72 67 73 20 61 72 65 20 74 61 67 67 65 n args are tagge
3350: 64 20 69 74 65 6d 73 2e 20 54 68 65 79 0a 09 23 d items. They..#
3360: 20 68 61 76 65 20 74 6f 20 68 61 76 65 20 74 68 have to have th
3370: 65 20 73 61 6d 65 20 74 79 70 65 20 61 73 20 74 e same type as t
3380: 68 65 20 63 68 61 6e 67 65 73 65 74 2c 20 62 65 he changeset, be
3390: 69 6e 67 20 73 75 62 73 65 74 73 0a 09 23 20 6f ing subsets..# o
33a0: 66 20 69 74 73 20 69 74 65 6d 73 2e 20 54 68 69 f its items. Thi
33b0: 73 20 69 73 20 63 68 65 63 6b 65 64 20 69 6e 20 s is checked in
33c0: 55 6e 74 61 67 31 2e 0a 0a 09 6c 6f 67 20 77 72 Untag1....log wr
33d0: 69 74 65 20 38 20 63 73 65 74 73 20 7b 4f 4c 44 ite 8 csets {OLD
33e0: 3a 20 5b 6c 73 6f 72 74 20 5b 24 63 73 65 74 20 : [lsort [$cset
33f0: 69 74 65 6d 73 5d 5d 7d 0a 09 56 61 6c 69 64 61 items]]}..Valida
3400: 74 65 46 72 61 67 6d 65 6e 74 73 20 24 63 73 65 teFragments $cse
3410: 74 20 24 61 72 67 73 0a 0a 09 23 20 41 6c 6c 20 t $args...# All
3420: 63 68 65 63 6b 73 20 70 61 73 73 2c 20 61 63 74 checks pass, act
3430: 75 61 6c 6c 79 20 70 65 72 66 6f 72 6d 20 74 68 ually perform th
3440: 65 20 73 70 6c 69 74 2e 0a 0a 09 73 74 72 75 63 e split....struc
3450: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 5b t::list assign [
3460: 24 63 73 65 74 20 64 61 74 61 5d 20 70 72 6f 6a $cset data] proj
3470: 65 63 74 20 63 73 74 79 70 65 20 63 73 73 72 63 ect cstype cssrc
3480: 0a 0a 09 73 65 74 20 70 72 65 64 65 63 65 73 73 ...set predecess
3490: 6f 72 73 20 5b 24 63 73 65 74 20 64 72 6f 70 5d ors [$cset drop]
34a0: 0a 09 24 63 73 65 74 20 64 65 73 74 72 6f 79 0a ..$cset destroy.
34b0: 0a 09 73 65 74 20 6e 65 77 63 73 65 74 73 20 7b ..set newcsets {
34c0: 7d 0a 09 66 6f 72 65 61 63 68 20 66 72 61 67 6d }..foreach fragm
34d0: 65 6e 74 69 74 65 6d 73 20 24 61 72 67 73 20 7b entitems $args {
34e0: 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 .. log write
34f0: 38 20 63 73 65 74 73 20 7b 4d 41 4b 45 3a 20 5b 8 csets {MAKE: [
3500: 6c 73 6f 72 74 20 24 66 72 61 67 6d 65 6e 74 69 lsort $fragmenti
3510: 74 65 6d 73 5d 7d 0a 0a 09 20 20 20 20 73 65 74 tems]}... set
3520: 20 66 72 61 67 6d 65 6e 74 20 5b 24 74 79 70 65 fragment [$type
3530: 20 25 41 55 54 4f 25 20 24 70 72 6f 6a 65 63 74 %AUTO% $project
3540: 20 24 63 73 74 79 70 65 20 24 63 73 73 72 63 20 $cstype $cssrc
3550: 5c 0a 09 09 09 20 20 20 20 20 20 5b 55 6e 74 61 \.... [Unta
3560: 67 20 24 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 g $fragmentitems
3570: 20 24 63 73 74 79 70 65 5d 5d 0a 09 20 20 20 20 $cstype]]..
3580: 6c 61 70 70 65 6e 64 20 6e 65 77 63 73 65 74 73 lappend newcsets
3590: 20 24 66 72 61 67 6d 65 6e 74 0a 0a 09 20 20 20 $fragment...
35a0: 20 24 66 72 61 67 6d 65 6e 74 20 70 65 72 73 69 $fragment persi
35b0: 73 74 0a 09 20 20 20 20 24 66 72 61 67 6d 65 6e st.. $fragmen
35c0: 74 20 64 65 74 65 72 6d 69 6e 65 73 75 63 63 65 t determinesucce
35d0: 73 73 6f 72 73 0a 09 7d 0a 0a 09 23 20 54 68 65 ssors..}...# The
35e0: 20 70 72 65 64 65 63 65 73 73 6f 72 73 20 68 61 predecessors ha
35f0: 76 65 20 74 6f 20 72 65 63 6f 6d 70 75 74 65 20 ve to recompute
3600: 74 68 65 69 72 20 73 75 63 63 65 73 73 6f 72 73 their successors
3610: 2c 20 69 2e 65 2e 0a 09 23 20 72 65 6d 6f 76 65 , i.e...# remove
3620: 20 74 68 65 20 64 72 6f 70 70 65 64 20 63 68 61 the dropped cha
3630: 6e 67 65 73 65 74 20 61 6e 64 20 70 75 74 20 6f ngeset and put o
3640: 6e 65 20 6f 66 20 74 68 65 20 66 72 61 67 6d 65 ne of the fragme
3650: 6e 74 73 0a 09 23 20 69 6e 74 6f 20 69 74 73 20 nts..# into its
3660: 70 6c 61 63 65 2e 0a 09 66 6f 72 65 61 63 68 20 place...foreach
3670: 70 20 24 70 72 65 64 65 63 65 73 73 6f 72 73 20 p $predecessors
3680: 7b 0a 09 20 20 20 20 24 70 20 64 65 74 65 72 6d {.. $p determ
3690: 69 6e 65 73 75 63 63 65 73 73 6f 72 73 0a 09 7d inesuccessors..}
36a0: 0a 0a 09 72 65 74 75 72 6e 20 24 6e 65 77 63 73 ...return $newcs
36b0: 65 74 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 ets. }.. t
36c0: 79 70 65 6d 65 74 68 6f 64 20 69 74 65 6d 73 74 ypemethod itemst
36d0: 72 20 7b 69 74 65 6d 7d 20 7b 0a 09 73 74 72 75 r {item} {..stru
36e0: 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 ct::list assign
36f0: 24 69 74 65 6d 20 69 74 79 70 65 20 69 69 64 0a $item itype iid.
3700: 09 72 65 74 75 72 6e 20 5b 24 69 74 79 70 65 20 .return [$itype
3710: 73 74 72 20 24 69 69 64 5d 0a 20 20 20 20 7d 0a str $iid]. }.
3720: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
3730: 73 74 72 6c 69 73 74 20 7b 63 68 61 6e 67 65 73 strlist {changes
3740: 65 74 73 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b ets} {..return [
3750: 6a 6f 69 6e 20 5b 73 74 72 75 63 74 3a 3a 6c 69 join [struct::li
3760: 73 74 20 6d 61 70 20 24 63 68 61 6e 67 65 73 65 st map $changese
3770: 74 73 20 5b 6d 79 70 72 6f 63 20 49 44 5d 5d 5d ts [myproc ID]]]
3780: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 . }.. proc
3790: 20 49 44 20 7b 63 73 65 74 7d 20 7b 20 24 63 73 ID {cset} { $cs
37a0: 65 74 20 73 74 72 20 7d 0a 0a 20 20 20 20 70 72 et str }.. pr
37b0: 6f 63 20 55 6e 74 61 67 20 7b 74 61 67 67 65 64 oc Untag {tagged
37c0: 69 74 65 6d 73 20 63 73 74 79 70 65 7d 20 7b 0a items cstype} {.
37d0: 09 72 65 74 75 72 6e 20 5b 73 74 72 75 63 74 3a .return [struct:
37e0: 3a 6c 69 73 74 20 6d 61 70 20 24 74 61 67 67 65 :list map $tagge
37f0: 64 69 74 65 6d 73 20 5b 6d 79 70 72 6f 63 20 55 ditems [myproc U
3800: 6e 74 61 67 31 20 24 63 73 74 79 70 65 5d 5d 0a ntag1 $cstype]].
3810: 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 }.. proc
3820: 55 6e 74 61 67 31 20 7b 63 73 74 79 70 65 20 74 Untag1 {cstype t
3830: 68 65 69 74 65 6d 7d 20 7b 0a 09 73 74 72 75 63 heitem} {..struc
3840: 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 6e 20 24 t::list assign $
3850: 74 68 65 69 74 65 6d 20 74 20 69 0a 09 69 6e 74 theitem t i..int
3860: 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 24 egrity assert {$
3870: 63 73 74 79 70 65 20 65 71 20 24 74 7d 20 7b 49 cstype eq $t} {I
3880: 74 65 6d 20 24 69 27 73 20 74 79 70 65 20 69 73 tem $i's type is
3890: 20 27 24 74 27 2c 20 65 78 70 65 63 74 65 64 20 '$t', expected
38a0: 27 24 63 73 74 79 70 65 27 7d 0a 09 72 65 74 75 '$cstype'}..retu
38b0: 72 6e 20 24 69 0a 20 20 20 20 7d 0a 0a 20 20 20 rn $i. }..
38c0: 20 70 72 6f 63 20 54 61 67 49 74 65 6d 44 69 63 proc TagItemDic
38d0: 74 20 7b 69 74 65 6d 64 69 63 74 20 63 73 74 79 t {itemdict csty
38e0: 70 65 7d 20 7b 0a 09 73 65 74 20 72 65 73 20 7b pe} {..set res {
38f0: 7d 0a 09 66 6f 72 65 61 63 68 20 7b 69 20 76 7d }..foreach {i v}
3900: 20 24 69 74 65 6d 64 69 63 74 20 7b 20 6c 61 70 $itemdict { lap
3910: 70 65 6e 64 20 72 65 73 20 5b 6c 69 73 74 20 24 pend res [list $
3920: 63 73 74 79 70 65 20 24 69 5d 20 24 76 20 7d 0a cstype $i] $v }.
3930: 09 72 65 74 75 72 6e 20 24 72 65 73 0a 20 20 20 .return $res.
3940: 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 56 61 6c }.. proc Val
3950: 69 64 61 74 65 46 72 61 67 6d 65 6e 74 73 20 7b idateFragments {
3960: 63 73 65 74 20 66 72 61 67 6d 65 6e 74 73 7d 20 cset fragments}
3970: 7b 0a 09 23 20 43 68 65 63 6b 20 74 68 65 20 76 {..# Check the v
3980: 61 72 69 6f 75 73 20 69 6e 74 65 67 72 69 74 79 arious integrity
3990: 20 63 6f 6e 73 74 72 61 69 6e 74 73 20 66 6f 72 constraints for
39a0: 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73 0a 09 the fragments..
39b0: 23 20 73 70 65 63 69 66 79 69 6e 67 20 68 6f 77 # specifying how
39c0: 20 74 6f 20 73 70 6c 69 74 20 74 68 65 20 63 68 to split the ch
39d0: 61 6e 67 65 73 65 74 3a 0a 09 23 0a 09 23 20 2a angeset:..#..# *
39e0: 20 57 65 20 6d 75 73 74 20 68 61 76 65 20 74 77 We must have tw
39f0: 6f 20 6f 72 20 6d 6f 72 65 20 66 72 61 67 6d 65 o or more fragme
3a00: 6e 74 73 2c 20 61 73 20 73 70 6c 69 74 74 69 6e nts, as splittin
3a10: 67 20 61 0a 09 23 20 20 20 63 68 61 6e 67 65 73 g a..# changes
3a20: 65 74 20 69 6e 74 6f 20 6f 6e 65 20 6d 61 6b 65 et into one make
3a30: 73 20 6e 6f 20 73 65 6e 73 65 2e 0a 09 23 20 2a s no sense...# *
3a40: 20 4e 6f 20 66 72 61 67 6d 65 6e 74 20 6d 61 79 No fragment may
3a50: 20 62 65 20 65 6d 70 74 79 2e 0a 09 23 20 2a 20 be empty...# *
3a60: 41 6c 6c 20 66 72 61 67 6d 65 6e 74 73 20 68 61 All fragments ha
3a70: 76 65 20 74 6f 20 62 65 20 74 72 75 65 20 73 75 ve to be true su
3a80: 62 73 65 74 73 20 6f 66 20 74 68 65 20 69 74 65 bsets of the ite
3a90: 6d 73 20 69 6e 20 74 68 65 0a 09 23 20 20 20 63 ms in the..# c
3aa0: 68 61 6e 67 65 73 65 74 20 74 6f 20 73 70 6c 69 hangeset to spli
3ab0: 74 2e 20 54 68 65 20 27 74 72 75 65 27 20 69 73 t. The 'true' is
3ac0: 20 69 6d 70 6c 69 65 64 20 62 65 63 61 75 73 65 implied because
3ad0: 20 6e 6f 6e 65 20 61 72 65 0a 09 23 20 20 20 61 none are..# a
3ae0: 6c 6c 6f 77 65 64 20 74 6f 20 62 65 20 65 6d 70 llowed to be emp
3af0: 74 79 2c 20 73 6f 20 65 61 63 68 20 68 61 73 20 ty, so each has
3b00: 74 6f 20 62 65 20 73 6d 61 6c 6c 65 72 20 74 68 to be smaller th
3b10: 61 6e 20 74 68 65 0a 09 23 20 20 20 74 6f 74 61 an the..# tota
3b20: 6c 2e 0a 09 23 20 2a 20 54 68 65 20 75 6e 69 6f l...# * The unio
3b30: 6e 20 6f 66 20 74 68 65 20 66 72 61 67 6d 65 6e n of the fragmen
3b40: 74 73 20 68 61 73 20 74 6f 20 62 65 20 74 68 65 ts has to be the
3b50: 20 69 74 65 6d 20 73 65 74 20 6f 66 20 74 68 65 item set of the
3b60: 0a 09 23 20 20 20 63 68 61 6e 67 65 73 65 74 2e ..# changeset.
3b70: 0a 09 23 20 2a 20 54 68 65 20 66 72 61 67 6d 65 ..# * The fragme
3b80: 6e 74 20 6d 75 73 74 20 6e 6f 74 20 6f 76 65 72 nt must not over
3b90: 6c 61 70 2c 20 69 2e 65 2e 20 74 68 65 69 72 20 lap, i.e. their
3ba0: 70 61 69 72 77 69 73 65 0a 09 23 20 20 20 69 6e pairwise..# in
3bb0: 74 65 72 73 65 63 74 69 6f 6e 73 20 68 61 76 65 tersections have
3bc0: 20 74 6f 20 62 65 20 65 6d 70 74 79 2e 0a 0a 09 to be empty....
3bd0: 73 65 74 20 63 6f 76 65 72 20 7b 7d 0a 09 66 6f set cover {}..fo
3be0: 72 65 61 63 68 20 66 72 61 67 6d 65 6e 74 69 74 reach fragmentit
3bf0: 65 6d 73 20 24 66 72 61 67 6d 65 6e 74 73 20 7b ems $fragments {
3c00: 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 .. log write
3c10: 38 20 63 73 65 74 73 20 7b 4e 45 57 3a 20 5b 6c 8 csets {NEW: [l
3c20: 73 6f 72 74 20 24 66 72 61 67 6d 65 6e 74 69 74 sort $fragmentit
3c30: 65 6d 73 5d 7d 0a 0a 09 20 20 20 20 69 6e 74 65 ems]}... inte
3c40: 67 72 69 74 79 20 61 73 73 65 72 74 20 7b 0a 09 grity assert {..
3c50: 09 21 5b 73 74 72 75 63 74 3a 3a 73 65 74 20 65 .![struct::set e
3c60: 6d 70 74 79 20 24 66 72 61 67 6d 65 6e 74 69 74 mpty $fragmentit
3c70: 65 6d 73 5d 0a 09 20 20 20 20 7d 20 7b 63 68 61 ems].. } {cha
3c80: 6e 67 65 73 65 74 20 66 72 61 67 6d 65 6e 74 20 ngeset fragment
3c90: 69 73 20 65 6d 70 74 79 7d 0a 0a 09 20 20 20 20 is empty}...
3ca0: 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 integrity assert
3cb0: 20 7b 0a 09 09 5b 73 74 72 75 63 74 3a 3a 73 65 {...[struct::se
3cc0: 74 20 73 75 62 73 65 74 6f 66 20 24 66 72 61 67 t subsetof $frag
3cd0: 6d 65 6e 74 69 74 65 6d 73 20 5b 24 63 73 65 74 mentitems [$cset
3ce0: 20 69 74 65 6d 73 5d 5d 0a 09 20 20 20 20 7d 20 items]].. }
3cf0: 7b 63 68 61 6e 67 65 73 65 74 20 66 72 61 67 6d {changeset fragm
3d00: 65 6e 74 20 69 73 20 6e 6f 74 20 61 20 73 75 62 ent is not a sub
3d10: 73 65 74 7d 0a 09 20 20 20 20 73 74 72 75 63 74 set}.. struct
3d20: 3a 3a 73 65 74 20 61 64 64 20 63 6f 76 65 72 20 ::set add cover
3d30: 24 66 72 61 67 6d 65 6e 74 69 74 65 6d 73 0a 09 $fragmentitems..
3d40: 7d 0a 0a 09 69 6e 74 65 67 72 69 74 79 20 61 73 }...integrity as
3d50: 73 65 72 74 20 7b 0a 09 20 20 20 20 5b 73 74 72 sert {.. [str
3d60: 75 63 74 3a 3a 73 65 74 20 65 71 75 61 6c 20 24 uct::set equal $
3d70: 63 6f 76 65 72 20 5b 24 63 73 65 74 20 69 74 65 cover [$cset ite
3d80: 6d 73 5d 5d 0a 09 20 7d 20 7b 54 68 65 20 66 72 ms]].. } {The fr
3d90: 61 67 6d 65 6e 74 73 20 64 6f 20 6e 6f 74 20 63 agments do not c
3da0: 6f 76 65 72 20 74 68 65 20 6f 72 69 67 69 6e 61 over the origina
3db0: 6c 20 63 68 61 6e 67 65 73 65 74 7d 0a 0a 09 73 l changeset}...s
3dc0: 65 74 20 69 20 31 0a 09 66 6f 72 65 61 63 68 20 et i 1..foreach
3dd0: 66 69 61 20 24 66 72 61 67 6d 65 6e 74 73 20 7b fia $fragments {
3de0: 0a 09 20 20 20 20 66 6f 72 65 61 63 68 20 66 69 .. foreach fi
3df0: 62 20 5b 6c 72 61 6e 67 65 20 24 66 72 61 67 6d b [lrange $fragm
3e00: 65 6e 74 73 20 24 69 20 65 6e 64 5d 20 7b 0a 09 ents $i end] {..
3e10: 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 .integrity asser
3e20: 74 20 7b 0a 09 09 20 20 20 20 5b 73 74 72 75 63 t {... [struc
3e30: 74 3a 3a 73 65 74 20 65 6d 70 74 79 20 5b 73 74 t::set empty [st
3e40: 72 75 63 74 3a 3a 73 65 74 20 69 6e 74 65 72 73 ruct::set inters
3e50: 65 63 74 20 24 66 69 61 20 24 66 69 62 5d 5d 0a ect $fia $fib]].
3e60: 09 09 7d 20 7b 54 68 65 20 66 72 61 67 6d 65 6e ..} {The fragmen
3e70: 74 73 20 3c 24 66 69 61 3e 20 61 6e 64 20 3c 24 ts <$fia> and <$
3e80: 66 69 62 3e 20 6f 76 65 72 6c 61 70 7d 0a 09 20 fib> overlap}..
3e90: 20 20 20 7d 0a 09 20 20 20 20 69 6e 63 72 20 69 }.. incr i
3ea0: 0a 09 7d 0a 0a 09 72 65 74 75 72 6e 0a 20 20 20 ..}...return.
3eb0: 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 }.. # # ## #
3ec0: 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 ## ##### #######
3ed0: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a # #############.
3ee0: 20 20 20 20 23 23 20 53 74 61 74 65 0a 0a 20 20 ## State..
3ef0: 20 20 76 61 72 69 61 62 6c 65 20 6d 79 69 64 20 variable myid
3f00: 20 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 49 64 {} ; # Id
3f10: 20 6f 66 20 74 68 65 20 63 73 65 74 20 66 6f 72 of the cset for
3f20: 20 74 68 65 20 70 65 72 73 69 73 74 65 6e 74 0a the persistent.
3f30: 09 09 09 20 20 20 20 20 20 23 20 73 74 61 74 65 ... # state
3f40: 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d .. variable m
3f50: 79 70 72 6f 6a 65 63 74 20 20 20 7b 7d 20 3b 20 yproject {} ;
3f60: 23 20 52 65 66 65 72 65 6e 63 65 20 6f 66 20 74 # Reference of t
3f70: 68 65 20 70 72 6f 6a 65 63 74 20 6f 62 6a 65 63 he project objec
3f80: 74 20 74 68 65 0a 09 09 09 20 20 20 20 20 20 23 t the.... #
3f90: 20 63 68 61 6e 67 65 73 65 74 20 62 65 6c 6f 6e changeset belon
3fa0: 67 73 20 74 6f 2e 0a 20 20 20 20 76 61 72 69 61 gs to.. varia
3fb0: 62 6c 65 20 6d 79 74 79 70 65 20 20 20 20 20 20 ble mytype
3fc0: 7b 7d 20 3b 20 23 20 57 68 61 74 20 74 68 65 20 {} ; # What the
3fd0: 63 68 61 6e 67 65 73 65 74 20 69 73 20 62 61 73 changeset is bas
3fe0: 65 64 20 6f 6e 0a 09 09 09 20 20 20 20 20 20 23 ed on.... #
3ff0: 20 28 72 65 76 69 73 69 6f 6e 73 2c 20 74 61 67 (revisions, tag
4000: 73 2c 20 6f 72 20 62 72 61 6e 63 68 65 73 29 2e s, or branches).
4010: 0a 09 09 09 20 20 20 20 20 20 23 20 56 61 6c 75 .... # Valu
4020: 65 73 3a 20 53 65 65 20 6d 79 63 73 74 79 70 65 es: See mycstype
4030: 2e 20 4e 6f 74 65 20 74 68 61 74 20 77 65 0a 09 . Note that we..
4040: 09 09 20 20 20 20 20 20 23 20 68 61 76 65 20 74 .. # have t
4050: 6f 20 6b 65 65 70 20 74 68 65 20 6e 61 6d 65 73 o keep the names
4060: 20 6f 66 20 74 68 65 20 68 65 6c 70 65 72 0a 09 of the helper..
4070: 09 09 20 20 20 20 20 20 23 20 73 69 6e 67 6c 65 .. # single
4080: 74 6f 6e 73 20 69 6e 20 73 79 6e 63 20 77 69 74 tons in sync wit
4090: 68 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 0a 09 h the contents..
40a0: 09 09 20 20 20 20 20 20 23 20 6f 66 20 73 74 61 .. # of sta
40b0: 74 65 20 74 61 62 6c 65 20 27 63 73 74 79 70 65 te table 'cstype
40c0: 27 2c 20 61 6e 64 20 76 61 72 69 6f 75 73 0a 09 ', and various..
40d0: 09 09 20 20 20 20 20 20 23 20 6f 74 68 65 72 20 .. # other
40e0: 70 6c 61 63 65 73 20 75 73 69 6e 67 20 74 68 65 places using the
40f0: 6d 20 68 61 72 64 77 69 72 65 64 2e 0a 20 20 20 m hardwired..
4100: 20 76 61 72 69 61 62 6c 65 20 6d 79 74 79 70 65 variable mytype
4110: 6f 62 6a 20 20 20 7b 7d 20 3b 20 23 20 52 65 66 obj {} ; # Ref
4120: 65 72 65 6e 63 65 20 74 6f 20 74 68 65 20 63 6f erence to the co
4130: 6e 74 61 69 6e 65 72 20 66 6f 72 20 74 68 65 0a ntainer for the.
4140: 09 09 09 20 20 20 20 20 20 23 20 74 79 70 65 20 ... # type
4150: 64 65 70 65 6e 64 65 6e 74 20 63 6f 64 65 2e 20 dependent code.
4160: 44 65 72 69 76 65 64 20 66 72 6f 6d 0a 09 09 09 Derived from....
4170: 20 20 20 20 20 20 23 20 6d 79 74 79 70 65 2e 0a # mytype..
4180: 20 20 20 20 76 61 72 69 61 62 6c 65 20 6d 79 73 variable mys
4190: 72 63 69 64 20 20 20 20 20 7b 7d 20 3b 20 23 20 rcid {} ; #
41a0: 49 64 20 6f 66 20 74 68 65 20 6d 65 74 61 64 61 Id of the metada
41b0: 74 61 20 6f 72 20 73 79 6d 62 6f 6c 20 74 68 65 ta or symbol the
41c0: 20 63 73 65 74 0a 09 09 09 20 20 20 20 20 20 23 cset.... #
41d0: 20 69 73 20 62 61 73 65 64 20 6f 6e 2e 0a 20 20 is based on..
41e0: 20 20 76 61 72 69 61 62 6c 65 20 6d 79 69 74 65 variable myite
41f0: 6d 73 20 20 20 20 20 7b 7d 20 3b 20 23 20 4c 69 ms {} ; # Li
4200: 73 74 20 6f 66 20 74 68 65 20 66 69 6c 65 20 6c st of the file l
4210: 65 76 65 6c 20 72 65 76 69 73 69 6f 6e 73 2c 0a evel revisions,.
4220: 09 09 09 20 20 20 20 20 20 23 20 74 61 67 73 2c ... # tags,
4230: 20 6f 72 20 62 72 61 6e 63 68 65 73 20 69 6e 20 or branches in
4240: 74 68 65 20 63 73 65 74 2c 20 61 73 0a 09 09 09 the cset, as....
4250: 20 20 20 20 20 20 23 20 69 64 73 2e 20 4e 6f 74 # ids. Not
4260: 20 74 61 67 67 65 64 2e 0a 20 20 20 20 76 61 72 tagged.. var
4270: 69 61 62 6c 65 20 6d 79 74 69 74 65 6d 73 20 20 iable mytitems
4280: 20 20 7b 7d 20 3b 20 23 20 41 73 20 6d 79 69 74 {} ; # As myit
4290: 65 6d 73 2c 20 74 68 65 20 74 61 67 67 65 64 20 ems, the tagged
42a0: 66 6f 72 6d 2e 0a 20 20 20 20 76 61 72 69 61 62 form.. variab
42b0: 6c 65 20 6d 79 70 6f 73 20 20 20 20 20 20 20 7b le mypos {
42c0: 7d 20 3b 20 23 20 43 6f 6d 6d 69 74 20 70 6f 73 } ; # Commit pos
42d0: 69 74 69 6f 6e 20 6f 66 20 74 68 65 20 63 68 61 ition of the cha
42e0: 6e 67 65 73 65 74 2c 20 69 66 0a 09 09 09 20 20 ngeset, if....
42f0: 20 20 20 20 23 20 6b 6e 6f 77 6e 2e 0a 0a 20 20 # known...
4300: 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 23 # # ## ### ###
4310: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 ## ######## ####
4320: 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 #########. ##
4330: 20 49 6e 74 65 72 6e 61 6c 20 6d 65 74 68 6f 64 Internal method
4340: 73 0a 0a 20 20 20 20 74 79 70 65 76 61 72 69 61 s.. typevaria
4350: 62 6c 65 20 6d 79 63 6f 75 6e 74 65 72 20 20 20 ble mycounter
4360: 20 20 20 20 20 30 20 3b 20 23 20 49 64 20 63 6f 0 ; # Id co
4370: 75 6e 74 65 72 20 66 6f 72 20 63 73 65 74 73 2e unter for csets.
4380: 20 4c 61 73 74 20 69 64 0a 09 09 09 09 20 20 20 Last id.....
4390: 20 20 20 23 20 75 73 65 64 2e 0a 20 20 20 20 74 # used.. t
43a0: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 63 73 ypevariable mycs
43b0: 74 79 70 65 20 2d 61 72 72 61 79 20 7b 7d 20 3b type -array {} ;
43c0: 20 23 20 4d 61 70 20 63 73 74 79 70 65 73 20 28 # Map cstypes (
43d0: 6e 61 6d 65 73 29 20 74 6f 20 70 65 72 73 69 73 names) to persis
43e0: 74 65 6e 74 0a 09 09 09 09 20 20 20 20 20 20 23 tent..... #
43f0: 20 69 64 73 2e 20 4e 6f 74 65 20 74 68 61 74 20 ids. Note that
4400: 77 65 20 68 61 76 65 20 74 6f 20 6b 65 65 70 0a we have to keep.
4410: 09 09 09 09 20 20 20 20 20 20 23 20 74 68 65 20 .... # the
4420: 6e 61 6d 65 73 20 69 6e 20 74 68 65 20 74 61 62 names in the tab
4430: 6c 65 20 27 63 73 74 79 70 65 27 0a 09 09 09 09 le 'cstype'.....
4440: 20 20 20 20 20 20 23 20 69 6e 20 73 79 6e 63 20 # in sync
4450: 77 69 74 68 20 74 68 65 20 6e 61 6d 65 73 20 6f with the names o
4460: 66 20 74 68 65 0a 09 09 09 09 20 20 20 20 20 20 f the.....
4470: 23 20 68 65 6c 70 65 72 20 73 69 6e 67 6c 65 74 # helper singlet
4480: 6f 6e 73 2e 0a 0a 20 20 20 20 74 79 70 65 6d 65 ons... typeme
4490: 74 68 6f 64 20 69 6e 6f 72 64 65 72 20 7b 70 72 thod inorder {pr
44a0: 6f 6a 65 63 74 69 64 7d 20 7b 0a 09 23 20 52 65 ojectid} {..# Re
44b0: 74 75 72 6e 20 61 6c 6c 20 72 65 76 69 73 69 6f turn all revisio
44c0: 6e 20 63 68 61 6e 67 65 73 65 74 73 20 66 6f 72 n changesets for
44d0: 20 74 68 65 20 73 70 65 63 69 66 69 65 64 20 70 the specified p
44e0: 72 6f 6a 65 63 74 2c 20 69 6e 0a 09 23 20 74 68 roject, in..# th
44f0: 65 20 6f 72 64 65 72 20 67 69 76 65 6e 20 74 6f e order given to
4500: 20 74 68 65 6d 20 62 79 20 74 68 65 20 73 6f 72 them by the sor
4510: 74 20 70 61 73 73 65 73 2e 20 42 6f 74 68 20 74 t passes. Both t
4520: 68 65 0a 09 23 20 66 69 6c 74 65 72 69 6e 67 20 he..# filtering
4530: 62 79 20 70 72 6f 6a 65 63 74 20 61 6e 64 20 73 by project and s
4540: 6f 72 74 69 6e 67 20 6d 61 6b 65 20 75 73 65 20 orting make use
4550: 6f 66 20 27 70 72 6f 6a 65 63 74 3a 3a 72 65 76 of 'project::rev
4560: 0a 09 23 20 72 65 76 27 20 69 6d 70 6f 73 73 69 ..# rev' impossi
4570: 62 6c 65 2e 0a 0a 09 73 65 74 20 72 65 73 20 7b ble....set res {
4580: 7d 0a 09 73 74 61 74 65 20 66 6f 72 65 61 63 68 }..state foreach
4590: 72 6f 77 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 row {.. SELEC
45a0: 54 20 43 2e 63 69 64 20 41 53 20 78 63 69 64 2c T C.cid AS xcid,
45b0: 20 54 2e 64 61 74 65 20 41 53 20 63 64 61 74 65 T.date AS cdate
45c0: 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 63 68 61 .. FROM cha
45d0: 6e 67 65 73 65 74 20 43 2c 20 63 73 74 69 6d 65 ngeset C, cstime
45e0: 73 74 61 6d 70 20 54 0a 09 20 20 20 20 57 48 45 stamp T.. WHE
45f0: 52 45 20 20 43 2e 74 79 70 65 20 3d 20 30 20 20 RE C.type = 0
4600: 20 20 20 20 20 20 20 20 2d 2d 20 6c 69 6d 69 74 -- limit
4610: 20 74 6f 20 72 65 76 69 73 69 6f 6e 20 63 68 61 to revision cha
4620: 6e 67 65 73 65 74 73 0a 09 20 20 20 20 41 4e 44 ngesets.. AND
4630: 20 20 20 20 43 2e 70 69 64 20 20 3d 20 24 70 72 C.pid = $pr
4640: 6f 6a 65 63 74 69 64 20 2d 2d 20 6c 69 6d 69 74 ojectid -- limit
4650: 20 74 6f 20 63 68 61 6e 67 65 73 65 74 73 20 69 to changesets i
4660: 6e 20 70 72 6f 6a 65 63 74 0a 09 20 20 20 20 41 n project.. A
4670: 4e 44 20 20 20 20 54 2e 63 69 64 20 20 3d 20 43 ND T.cid = C
4680: 2e 63 69 64 20 20 20 20 20 20 2d 2d 20 67 65 74 .cid -- get
4690: 20 6f 72 64 65 72 69 6e 67 20 69 6e 66 6f 72 6d ordering inform
46a0: 61 74 69 6f 6e 0a 09 20 20 20 20 4f 52 44 45 52 ation.. ORDER
46b0: 20 42 59 20 54 2e 64 61 74 65 20 20 20 20 20 20 BY T.date
46c0: 20 20 20 20 20 20 2d 2d 20 73 6f 72 74 20 69 6e -- sort in
46d0: 74 6f 20 63 6f 6d 6d 69 74 20 6f 72 64 65 72 0a to commit order.
46e0: 09 7d 20 7b 0a 09 20 20 20 20 6c 61 70 70 65 6e .} {.. lappen
46f0: 64 20 72 65 73 20 24 6d 79 69 64 6d 61 70 28 24 d res $myidmap($
4700: 78 63 69 64 29 20 24 63 64 61 74 65 0a 09 7d 0a xcid) $cdate..}.
4710: 09 72 65 74 75 72 6e 20 24 72 65 73 0a 20 20 20 .return $res.
4720: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 }.. typemeth
4730: 6f 64 20 67 65 74 63 73 74 79 70 65 73 20 7b 7d od getcstypes {}
4740: 20 7b 0a 09 73 74 61 74 65 20 66 6f 72 65 61 63 {..state foreac
4750: 68 72 6f 77 20 7b 0a 09 20 20 20 20 53 45 4c 45 hrow {.. SELE
4760: 43 54 20 74 69 64 2c 20 6e 61 6d 65 20 46 52 4f CT tid, name FRO
4770: 4d 20 63 73 74 79 70 65 3b 0a 09 7d 20 7b 20 73 M cstype;..} { s
4780: 65 74 20 6d 79 63 73 74 79 70 65 28 24 6e 61 6d et mycstype($nam
4790: 65 29 20 24 74 69 64 20 7d 0a 09 72 65 74 75 72 e) $tid }..retur
47a0: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 n. }.. typ
47b0: 65 6d 65 74 68 6f 64 20 6c 6f 61 64 20 7b 72 65 emethod load {re
47c0: 70 6f 73 69 74 6f 72 79 7d 20 7b 0a 09 73 65 74 pository} {..set
47d0: 20 6e 20 30 0a 09 6c 6f 67 20 77 72 69 74 65 20 n 0..log write
47e0: 32 20 63 73 65 74 73 20 7b 4c 6f 61 64 69 6e 67 2 csets {Loading
47f0: 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 73 7d the changesets}
4800: 0a 09 73 74 61 74 65 20 66 6f 72 65 61 63 68 72 ..state foreachr
4810: 6f 77 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 ow {.. SELECT
4820: 20 43 2e 63 69 64 20 20 20 41 53 20 69 64 2c 0a C.cid AS id,.
4830: 09 20 20 20 20 20 20 20 20 20 20 20 43 2e 70 69 . C.pi
4840: 64 20 20 20 41 53 20 78 70 69 64 2c 0a 20 20 20 d AS xpid,.
4850: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
4860: 43 53 2e 6e 61 6d 65 20 41 53 20 63 73 74 79 70 CS.name AS cstyp
4870: 65 2c 0a 09 20 20 20 20 20 20 20 20 20 20 20 43 e,.. C
4880: 2e 73 72 63 20 20 20 41 53 20 73 72 63 69 64 0a .src AS srcid.
4890: 09 20 20 20 20 46 52 4f 4d 20 20 20 63 68 61 6e . FROM chan
48a0: 67 65 73 65 74 20 43 2c 20 63 73 74 79 70 65 20 geset C, cstype
48b0: 43 53 0a 09 20 20 20 20 57 48 45 52 45 20 20 43 CS.. WHERE C
48c0: 2e 74 79 70 65 20 3d 20 43 53 2e 74 69 64 0a 09 .type = CS.tid..
48d0: 20 20 20 20 4f 52 44 45 52 20 42 59 20 43 2e 63 ORDER BY C.c
48e0: 69 64 0a 09 7d 20 7b 0a 09 20 20 20 20 6c 6f 67 id..} {.. log
48f0: 20 70 72 6f 67 72 65 73 73 20 32 20 63 73 65 74 progress 2 cset
4900: 73 20 24 6e 20 7b 7d 0a 09 20 20 20 20 73 65 74 s $n {}.. set
4910: 20 72 20 5b 24 74 79 70 65 20 25 41 55 54 4f 25 r [$type %AUTO%
4920: 20 5b 24 72 65 70 6f 73 69 74 6f 72 79 20 70 72 [$repository pr
4930: 6f 6a 65 63 74 6f 66 20 24 78 70 69 64 5d 20 24 ojectof $xpid] $
4940: 63 73 74 79 70 65 20 24 73 72 63 69 64 20 5b 73 cstype $srcid [s
4950: 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 45 4c tate run {...SEL
4960: 45 43 54 20 43 2e 69 69 64 0a 09 09 46 52 4f 4d ECT C.iid...FROM
4970: 20 20 20 63 73 69 74 65 6d 20 43 0a 09 09 57 48 csitem C...WH
4980: 45 52 45 20 20 43 2e 63 69 64 20 3d 20 24 69 64 ERE C.cid = $id
4990: 0a 09 09 4f 52 44 45 52 20 42 59 20 43 2e 70 6f ...ORDER BY C.po
49a0: 73 0a 09 20 20 20 20 7d 5d 20 24 69 64 5d 0a 09 s.. }] $id]..
49b0: 20 20 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 09 72 incr n..}..r
49c0: 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 eturn. }..
49d0: 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 61 64 typemethod load
49e0: 63 6f 75 6e 74 65 72 20 7b 7d 20 7b 0a 09 23 20 counter {} {..#
49f0: 49 6e 69 74 69 61 6c 69 7a 65 20 74 68 65 20 63 Initialize the c
4a00: 6f 75 6e 74 65 72 20 66 72 6f 6d 20 74 68 65 20 ounter from the
4a10: 73 74 61 74 65 0a 09 6c 6f 67 20 77 72 69 74 65 state..log write
4a20: 20 32 20 63 73 65 74 73 20 7b 4c 6f 61 64 69 6e 2 csets {Loadin
4a30: 67 20 63 68 61 6e 67 65 73 65 74 20 63 6f 75 6e g changeset coun
4a40: 74 65 72 7d 0a 09 73 65 74 20 6d 79 63 6f 75 6e ter}..set mycoun
4a50: 74 65 72 20 5b 73 74 61 74 65 20 6f 6e 65 20 7b ter [state one {
4a60: 20 53 45 4c 45 43 54 20 4d 41 58 28 63 69 64 29 SELECT MAX(cid)
4a70: 20 46 52 4f 4d 20 63 68 61 6e 67 65 73 65 74 20 FROM changeset
4a80: 7d 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d }]..return. }
4a90: 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 .. typemethod
4aa0: 20 6e 75 6d 20 7b 7d 20 7b 20 72 65 74 75 72 6e num {} { return
4ab0: 20 24 6d 79 63 6f 75 6e 74 65 72 20 7d 0a 0a 20 $mycounter }..
4ac0: 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 # # ## ### ##
4ad0: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 ### ######## ###
4ae0: 23 23 23 23 23 23 23 23 23 23 0a 0a 20 20 20 20 ##########..
4af0: 6d 65 74 68 6f 64 20 43 72 65 61 74 65 46 72 6f method CreateFro
4b00: 6d 46 72 61 67 6d 65 6e 74 73 20 7b 66 72 61 67 mFragments {frag
4b10: 6d 65 6e 74 73 20 63 76 20 62 76 7d 20 7b 0a 09 ments cv bv} {..
4b20: 75 70 76 61 72 20 31 20 24 63 76 20 63 6f 75 6e upvar 1 $cv coun
4b30: 74 65 72 20 24 62 76 20 62 72 65 61 6b 73 0a 09 ter $bv breaks..
4b40: 55 6e 6d 61 70 49 74 65 6d 73 20 24 6d 79 74 79 UnmapItems $myty
4b50: 70 65 20 24 6d 79 69 74 65 6d 73 0a 0a 09 23 20 pe $myitems...#
4b60: 43 72 65 61 74 65 20 63 68 61 6e 67 65 73 65 74 Create changeset
4b70: 73 20 66 6f 72 20 74 68 65 20 66 72 61 67 6d 65 s for the fragme
4b80: 6e 74 73 2c 20 72 65 75 73 69 6e 67 20 74 68 65 nts, reusing the
4b90: 20 63 75 72 72 65 6e 74 20 6f 6e 65 0a 09 23 20 current one..#
4ba0: 66 6f 72 20 74 68 65 20 66 69 72 73 74 20 66 72 for the first fr
4bb0: 61 67 6d 65 6e 74 2e 20 57 65 20 73 6f 72 74 20 agment. We sort
4bc0: 74 68 65 6d 20 69 6e 20 6f 72 64 65 72 20 74 6f them in order to
4bd0: 20 61 6c 6c 6f 77 0a 09 23 20 63 68 65 63 6b 69 allow..# checki
4be0: 6e 67 20 66 6f 72 20 67 61 70 73 20 61 6e 64 20 ng for gaps and
4bf0: 6e 69 63 65 20 6d 65 73 73 61 67 65 73 2e 0a 0a nice messages...
4c00: 09 73 65 74 20 6e 65 77 63 73 65 74 73 20 20 7b .set newcsets {
4c10: 7d 0a 09 73 65 74 20 66 72 61 67 6d 65 6e 74 73 }..set fragments
4c20: 20 5b 6c 73 6f 72 74 20 2d 69 6e 64 65 78 20 30 [lsort -index 0
4c30: 20 2d 69 6e 74 65 67 65 72 20 24 66 72 61 67 6d -integer $fragm
4c40: 65 6e 74 73 5d 0a 0a 09 23 70 75 74 73 20 5c 74 ents]...#puts \t
4c50: 2e 5b 6a 6f 69 6e 20 5b 50 52 73 20 24 66 72 61 .[join [PRs $fra
4c60: 67 6d 65 6e 74 73 5d 20 2e 5c 6e 5c 74 2e 5d 2e gments] .\n\t.].
4c70: 0a 0a 09 42 6f 72 64 65 72 20 5b 6c 69 6e 64 65 ...Border [linde
4c80: 78 20 24 66 72 61 67 6d 65 6e 74 73 20 30 5d 20 x $fragments 0]
4c90: 66 69 72 73 74 73 20 66 69 72 73 74 65 0a 0a 09 firsts firste...
4ca0: 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 integrity assert
4cb0: 20 7b 0a 09 20 20 20 20 24 66 69 72 73 74 73 20 {.. $firsts
4cc0: 3d 3d 20 30 0a 09 7d 20 7b 42 61 64 20 66 72 61 == 0..} {Bad fra
4cd0: 67 6d 65 6e 74 20 73 74 61 72 74 20 40 20 24 66 gment start @ $f
4ce0: 69 72 73 74 73 2c 20 67 61 70 2c 20 6f 72 20 62 irsts, gap, or b
4cf0: 65 66 6f 72 65 20 62 65 67 69 6e 6e 69 6e 67 20 efore beginning
4d00: 6f 66 20 74 68 65 20 72 61 6e 67 65 7d 0a 0a 09 of the range}...
4d10: 73 65 74 20 6c 61 73 74 65 20 24 66 69 72 73 74 set laste $first
4d20: 65 0a 09 66 6f 72 65 61 63 68 20 66 72 61 67 6d e..foreach fragm
4d30: 65 6e 74 20 5b 6c 72 61 6e 67 65 20 24 66 72 61 ent [lrange $fra
4d40: 67 6d 65 6e 74 73 20 31 20 65 6e 64 5d 20 7b 0a gments 1 end] {.
4d50: 09 20 20 20 20 42 6f 72 64 65 72 20 24 66 72 61 . Border $fra
4d60: 67 6d 65 6e 74 20 73 20 65 0a 09 20 20 20 20 69 gment s e.. i
4d70: 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 ntegrity assert
4d80: 7b 0a 09 09 24 6c 61 73 74 65 20 3d 3d 20 28 24 {...$laste == ($
4d90: 73 20 2d 20 31 29 0a 09 20 20 20 20 7d 20 7b 42 s - 1).. } {B
4da0: 61 64 20 66 72 61 67 6d 65 6e 74 20 62 6f 72 64 ad fragment bord
4db0: 65 72 20 3c 24 6c 61 73 74 65 20 7c 20 24 73 3e er <$laste | $s>
4dc0: 2c 20 67 61 70 20 6f 72 20 6f 76 65 72 6c 61 70 , gap or overlap
4dd0: 7d 0a 0a 09 20 20 20 20 73 65 74 20 6e 65 77 20 }... set new
4de0: 5b 24 74 79 70 65 20 25 41 55 54 4f 25 20 24 6d [$type %AUTO% $m
4df0: 79 70 72 6f 6a 65 63 74 20 24 6d 79 74 79 70 65 yproject $mytype
4e00: 20 24 6d 79 73 72 63 69 64 20 5b 6c 72 61 6e 67 $mysrcid [lrang
4e10: 65 20 24 6d 79 69 74 65 6d 73 20 24 73 20 24 65 e $myitems $s $e
4e20: 5d 5d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 ]].. lappend
4e30: 6e 65 77 63 73 65 74 73 20 24 6e 65 77 0a 09 20 newcsets $new..
4e40: 20 20 20 69 6e 63 72 20 63 6f 75 6e 74 65 72 0a incr counter.
4e50: 0a 20 20 20 20 20 20 20 20 20 20 20 20 6c 6f 67 . log
4e60: 20 77 72 69 74 65 20 34 20 63 73 65 74 73 20 7b write 4 csets {
4e70: 42 72 65 61 6b 69 6e 67 20 5b 24 73 65 6c 66 20 Breaking [$self
4e80: 73 74 72 20 5d 20 40 20 24 6c 61 73 74 65 2c 20 str ] @ $laste,
4e90: 6e 65 77 20 5b 24 6e 65 77 20 73 74 72 5d 2c 20 new [$new str],
4ea0: 63 75 74 74 69 6e 67 20 24 62 72 65 61 6b 73 28 cutting $breaks(
4eb0: 24 6c 61 73 74 65 29 7d 0a 0a 09 20 20 20 20 73 $laste)}... s
4ec0: 65 74 20 6c 61 73 74 65 20 24 65 0a 09 7d 0a 0a et laste $e..}..
4ed0: 09 69 6e 74 65 67 72 69 74 79 20 61 73 73 65 72 .integrity asser
4ee0: 74 20 7b 0a 09 20 20 20 20 24 6c 61 73 74 65 20 t {.. $laste
4ef0: 3d 3d 20 28 5b 6c 6c 65 6e 67 74 68 20 24 6d 79 == ([llength $my
4f00: 69 74 65 6d 73 5d 2d 31 29 0a 09 7d 20 7b 42 61 items]-1)..} {Ba
4f10: 64 20 66 72 61 67 6d 65 6e 74 20 65 6e 64 20 40 d fragment end @
4f20: 20 24 6c 61 73 74 65 2c 20 67 61 70 2c 20 6f 72 $laste, gap, or
4f30: 20 62 65 79 6f 6e 64 20 65 6e 64 20 6f 66 20 74 beyond end of t
4f40: 68 65 20 72 61 6e 67 65 7d 0a 0a 09 23 20 50 75 he range}...# Pu
4f50: 74 20 74 68 65 20 66 69 72 73 74 20 66 72 61 67 t the first frag
4f60: 6d 65 6e 74 20 69 6e 74 6f 20 74 68 65 20 63 75 ment into the cu
4f70: 72 72 65 6e 74 20 63 68 61 6e 67 65 73 65 74 2c rrent changeset,
4f80: 20 61 6e 64 0a 09 23 20 75 70 64 61 74 65 20 74 and..# update t
4f90: 68 65 20 69 6e 2d 6d 65 6d 6f 72 79 20 69 6e 64 he in-memory ind
4fa0: 65 78 2e 20 57 65 20 63 61 6e 20 73 69 6d 70 6c ex. We can simpl
4fb0: 79 20 28 72 65 29 61 64 64 20 74 68 65 20 69 74 y (re)add the it
4fc0: 65 6d 73 0a 09 23 20 62 65 63 61 75 73 65 20 77 ems..# because w
4fd0: 65 20 63 6c 65 61 72 65 64 20 74 68 65 20 70 72 e cleared the pr
4fe0: 65 76 69 6f 75 73 6c 79 20 65 78 69 73 74 69 6e eviously existin
4ff0: 67 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 2c 20 73 g information, s
5000: 65 65 0a 09 23 20 27 55 6e 6d 61 70 49 74 65 6d ee..# 'UnmapItem
5010: 73 27 20 61 62 6f 76 65 2e 20 50 65 72 73 69 73 s' above. Persis
5020: 74 65 6e 63 65 20 64 6f 65 73 20 6e 6f 74 20 6d tence does not m
5030: 61 74 74 65 72 20 68 65 72 65 2c 20 6e 6f 6e 65 atter here, none
5040: 0a 09 23 20 6f 66 20 74 68 65 20 63 68 61 6e 67 ..# of the chang
5050: 65 73 65 74 73 20 68 61 73 20 62 65 65 6e 20 73 esets has been s
5060: 61 76 65 64 20 74 6f 20 74 68 65 20 70 65 72 73 aved to the pers
5070: 69 73 74 65 6e 74 20 73 74 61 74 65 0a 09 23 20 istent state..#
5080: 79 65 74 2e 0a 0a 09 73 65 74 20 6d 79 69 74 65 yet....set myite
5090: 6d 73 20 20 5b 6c 72 61 6e 67 65 20 24 6d 79 69 ms [lrange $myi
50a0: 74 65 6d 73 20 20 30 20 24 66 69 72 73 74 65 5d tems 0 $firste]
50b0: 0a 09 73 65 74 20 6d 79 74 69 74 65 6d 73 20 5b ..set mytitems [
50c0: 6c 72 61 6e 67 65 20 24 6d 79 74 69 74 65 6d 73 lrange $mytitems
50d0: 20 30 20 24 66 69 72 73 74 65 5d 0a 09 4d 61 70 0 $firste]..Map
50e0: 49 74 65 6d 73 20 24 6d 79 74 79 70 65 20 24 6d Items $mytype $m
50f0: 79 69 74 65 6d 73 0a 09 72 65 74 75 72 6e 20 24 yitems..return $
5100: 6e 65 77 63 73 65 74 73 0a 20 20 20 20 7d 0a 0a newcsets. }..
5110: 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 # # ## ### #
5120: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 #### ######## ##
5130: 23 23 23 23 23 23 23 23 23 23 23 0a 0a 20 20 20 ###########..
5140: 20 70 72 6f 63 20 42 72 65 61 6b 44 69 72 65 63 proc BreakDirec
5150: 74 44 65 70 65 6e 64 65 6e 63 69 65 73 20 7b 74 tDependencies {t
5160: 68 65 69 74 65 6d 73 20 62 76 7d 20 7b 0a 09 75 heitems bv} {..u
5170: 70 76 61 72 20 31 20 6d 79 74 79 70 65 6f 62 6a pvar 1 mytypeobj
5180: 20 6d 79 74 79 70 65 6f 62 6a 20 73 65 6c 66 20 mytypeobj self
5190: 73 65 6c 66 20 24 62 76 20 62 72 65 61 6b 73 0a self $bv breaks.
51a0: 0a 09 23 20 41 72 72 61 79 20 6f 66 20 64 65 70 ..# Array of dep
51b0: 65 6e 64 65 6e 63 69 65 73 20 28 70 61 72 65 6e endencies (paren
51c0: 74 20 2d 3e 20 63 68 69 6c 64 29 2e 20 54 68 69 t -> child). Thi
51d0: 73 20 69 73 20 70 75 6c 6c 65 64 20 66 72 6f 6d s is pulled from
51e0: 0a 09 23 20 74 68 65 20 73 74 61 74 65 2c 20 61 ..# the state, a
51f0: 6e 64 20 6c 69 6d 69 74 65 64 20 74 6f 20 73 75 nd limited to su
5200: 63 63 65 73 73 6f 72 73 20 77 69 74 68 69 6e 20 ccessors within
5210: 74 68 65 20 63 68 61 6e 67 65 73 65 74 2e 0a 0a the changeset...
5220: 09 61 72 72 61 79 20 73 65 74 20 64 65 70 65 6e .array set depen
5230: 64 65 6e 63 69 65 73 20 7b 7d 0a 0a 09 24 6d 79 dencies {}...$my
5240: 74 79 70 65 6f 62 6a 20 69 6e 74 65 72 6e 61 6c typeobj internal
5250: 73 75 63 63 65 73 73 6f 72 73 20 64 65 70 65 6e successors depen
5260: 64 65 6e 63 69 65 73 20 24 74 68 65 69 74 65 6d dencies $theitem
5270: 73 0a 09 69 66 20 7b 21 5b 61 72 72 61 79 20 73 s..if {![array s
5280: 69 7a 65 20 64 65 70 65 6e 64 65 6e 63 69 65 73 ize dependencies
5290: 5d 7d 20 7b 0a 09 20 20 20 20 72 65 74 75 72 6e ]} {.. return
52a0: 20 7b 7d 0a 09 7d 20 3b 20 23 20 4e 6f 74 68 69 {}..} ; # Nothi
52b0: 6e 67 20 74 6f 20 62 72 65 61 6b 2e 0a 0a 09 6c ng to break....l
52c0: 6f 67 20 77 72 69 74 65 20 35 20 63 73 65 74 73 og write 5 csets
52d0: 20 2e 2e 2e 5b 24 73 65 6c 66 20 73 74 72 5d 2e ...[$self str].
52e0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e ................
52f0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e ................
5300: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e ................
5310: 2e 2e 2e 2e 2e 2e 0a 09 76 63 3a 3a 74 6f 6f 6c ........vc::tool
5320: 73 3a 3a 6d 65 6d 3a 3a 6d 61 72 6b 0a 0a 09 72 s::mem::mark...r
5330: 65 74 75 72 6e 20 5b 42 72 65 61 6b 65 72 43 6f eturn [BreakerCo
5340: 72 65 20 24 74 68 65 69 74 65 6d 73 20 64 65 70 re $theitems dep
5350: 65 6e 64 65 6e 63 69 65 73 20 62 72 65 61 6b 73 endencies breaks
5360: 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 6f ]. }.. pro
5370: 63 20 42 72 65 61 6b 65 72 43 6f 72 65 20 7b 74 c BreakerCore {t
5380: 68 65 69 74 65 6d 73 20 64 76 20 62 76 7d 20 7b heitems dv bv} {
5390: 0a 09 23 20 42 72 65 61 6b 20 61 20 73 65 74 20 ..# Break a set
53a0: 6f 66 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 74 of revisions int
53b0: 6f 20 66 72 61 67 6d 65 6e 74 73 20 77 68 69 63 o fragments whic
53c0: 68 20 68 61 76 65 20 6e 6f 0a 09 23 20 69 6e 74 h have no..# int
53d0: 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 ernal dependenci
53e0: 65 73 2e 0a 0a 09 23 20 57 65 20 70 65 72 66 6f es....# We perfo
53f0: 72 6d 20 61 6c 6c 20 6e 65 63 65 73 73 61 72 79 rm all necessary
5400: 20 73 70 6c 69 74 73 20 69 6e 20 6f 6e 65 20 67 splits in one g
5410: 6f 2c 20 69 6e 73 74 65 61 64 20 6f 66 20 6f 6e o, instead of on
5420: 6c 79 0a 09 23 20 6f 6e 65 2e 20 54 68 65 20 70 ly..# one. The p
5430: 72 65 76 69 6f 75 73 20 61 6c 67 6f 72 69 74 68 revious algorith
5440: 6d 2c 20 61 64 61 70 74 65 64 20 66 72 6f 6d 20 m, adapted from
5450: 63 76 73 32 73 76 6e 2c 20 63 6f 6d 70 75 74 65 cvs2svn, compute
5460: 64 0a 09 23 20 61 20 6c 6f 74 20 6f 66 20 73 74 d..# a lot of st
5470: 61 74 65 20 77 68 69 63 68 20 77 61 73 20 74 68 ate which was th
5480: 72 6f 77 6e 20 61 77 61 79 20 61 6e 64 20 74 68 rown away and th
5490: 65 6e 20 63 6f 6d 70 75 74 65 64 20 61 67 61 69 en computed agai
54a0: 6e 0a 09 23 20 66 6f 72 20 65 61 63 68 20 6f 66 n..# for each of
54b0: 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73 2e 20 the fragments.
54c0: 49 74 20 73 68 6f 75 6c 64 20 62 65 20 65 61 73 It should be eas
54d0: 69 65 72 20 74 6f 20 75 70 64 61 74 65 20 61 6e ier to update an
54e0: 64 0a 09 23 20 72 65 75 73 65 20 74 68 61 74 20 d..# reuse that
54f0: 73 74 61 74 65 2e 0a 0a 09 75 70 76 61 72 20 31 state....upvar 1
5500: 20 24 64 76 20 64 65 70 65 6e 64 65 6e 63 69 65 $dv dependencie
5510: 73 20 24 62 76 20 62 72 65 61 6b 73 0a 0a 09 23 s $bv breaks...#
5520: 20 57 65 20 68 61 76 65 20 69 6e 74 65 72 6e 61 We have interna
5530: 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 74 l dependencies t
5540: 6f 20 62 72 65 61 6b 2e 20 57 65 20 6e 6f 77 20 o break. We now
5550: 69 74 65 72 61 74 65 20 6f 76 65 72 0a 09 23 20 iterate over..#
5560: 61 6c 6c 20 70 6f 73 69 74 69 6f 6e 73 20 69 6e all positions in
5570: 20 74 68 65 20 6c 69 73 74 20 28 77 68 69 63 68 the list (which
5580: 20 69 73 20 63 68 72 6f 6e 6f 6c 6f 67 69 63 61 is chronologica
5590: 6c 2c 20 61 74 20 6c 65 61 73 74 0a 09 23 20 61 l, at least..# a
55a0: 73 20 66 61 72 20 61 73 20 74 68 65 20 74 69 6d s far as the tim
55b0: 65 73 74 61 6d 70 73 20 61 72 65 20 63 6f 72 72 estamps are corr
55c0: 65 63 74 20 61 6e 64 20 75 6e 69 71 75 65 29 20 ect and unique)
55d0: 61 6e 64 0a 09 23 20 64 65 74 65 72 6d 69 6e 65 and..# determine
55e0: 20 74 68 65 20 62 65 73 74 20 70 6f 73 69 74 69 the best positi
55f0: 6f 6e 20 66 6f 72 20 74 68 65 20 62 72 65 61 6b on for the break
5600: 2c 20 62 79 20 74 72 79 69 6e 67 20 74 6f 0a 09 , by trying to..
5610: 23 20 62 72 65 61 6b 20 61 73 20 6d 61 6e 79 20 # break as many
5620: 64 65 70 65 6e 64 65 6e 63 69 65 73 20 61 73 20 dependencies as
5630: 70 6f 73 73 69 62 6c 65 20 69 6e 20 6f 6e 65 20 possible in one
5640: 67 6f 2e 20 57 68 65 6e 20 61 0a 09 23 20 62 72 go. When a..# br
5650: 65 61 6b 20 77 61 73 20 66 6f 75 6e 64 20 74 68 eak was found th
5660: 69 73 20 69 73 20 72 65 64 6f 6e 65 20 66 6f 72 is is redone for
5670: 20 74 68 65 20 66 72 61 67 6d 65 6e 74 73 20 63 the fragments c
5680: 6f 6d 69 6e 67 20 61 6e 64 0a 09 23 20 61 66 74 oming and..# aft
5690: 65 72 2c 20 61 66 74 65 72 20 75 70 64 69 6e 67 er, after upding
56a0: 20 74 68 65 20 63 72 6f 73 73 69 6e 67 20 69 6e the crossing in
56b0: 66 6f 72 6d 61 74 69 6f 6e 2e 0a 0a 09 23 20 44 formation....# D
56c0: 61 74 61 20 73 74 72 75 63 74 75 72 65 73 3a 0a ata structures:.
56d0: 09 23 20 4d 61 70 3a 20 20 50 4f 53 20 20 20 72 .# Map: POS r
56e0: 65 76 69 73 69 6f 6e 20 69 64 20 20 20 20 20 20 evision id
56f0: 2d 3e 20 70 6f 73 69 74 69 6f 6e 20 69 6e 20 6c -> position in l
5700: 69 73 74 2e 0a 09 23 20 20 20 20 20 20 20 43 52 ist...# CR
5710: 4f 53 53 20 70 6f 73 69 74 69 6f 6e 20 69 6e 20 OSS position in
5720: 6c 69 73 74 20 2d 3e 20 6e 75 6d 62 65 72 20 6f list -> number o
5730: 66 20 64 65 70 65 6e 64 65 6e 63 69 65 73 20 63 f dependencies c
5740: 72 6f 73 73 69 6e 67 20 69 74 0a 09 23 20 20 20 rossing it..#
5750: 20 20 20 20 44 45 50 43 20 20 64 65 70 65 6e 64 DEPC depend
5760: 65 6e 63 79 20 20 20 20 20 20 20 2d 3e 20 70 6f ency -> po
5770: 73 69 74 69 6f 6e 73 20 69 74 20 63 72 6f 73 73 sitions it cross
5780: 65 73 0a 09 23 20 4c 69 73 74 3a 20 52 41 4e 47 es..# List: RANG
5790: 45 20 4f 66 20 74 68 65 20 70 6f 73 69 74 69 6f E Of the positio
57a0: 6e 73 20 69 74 73 65 6c 66 2e 0a 09 23 20 4d 61 ns itself...# Ma
57b0: 70 3a 20 20 44 45 4c 54 41 20 70 6f 73 69 74 69 p: DELTA positi
57c0: 6f 6e 20 69 6e 20 6c 69 73 74 20 2d 3e 20 74 69 on in list -> ti
57d0: 6d 65 20 64 65 6c 74 61 20 62 65 74 77 65 65 6e me delta between
57e0: 20 69 74 73 20 72 65 76 69 73 69 6f 6e 0a 09 23 its revision..#
57f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5800: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
5810: 20 61 6e 64 20 74 68 65 20 6e 65 78 74 2c 20 69 and the next, i
5820: 66 20 61 6e 79 2e 0a 09 23 20 41 20 64 65 70 65 f any...# A depe
5830: 6e 64 65 6e 63 79 20 69 73 20 61 20 73 69 6e 67 ndency is a sing
5840: 6c 65 2d 65 6c 65 6d 65 6e 74 20 6d 61 70 20 70 le-element map p
5850: 61 72 65 6e 74 20 2d 3e 20 63 68 69 6c 64 0a 0a arent -> child..
5860: 09 23 20 49 6e 69 74 69 61 6c 69 7a 65 42 72 65 .# InitializeBre
5870: 61 6b 53 74 61 74 65 20 69 6e 69 74 69 61 6c 69 akState initiali
5880: 7a 65 73 20 74 68 65 69 72 20 63 6f 6e 74 65 6e zes their conten
5890: 74 73 20 61 66 74 65 72 0a 09 23 20 75 70 76 61 ts after..# upva
58a0: 72 27 69 6e 67 20 74 68 65 6d 20 66 72 6f 6d 20 r'ing them from
58b0: 74 68 69 73 20 73 63 6f 70 65 2e 20 49 74 20 75 this scope. It u
58c0: 73 65 73 20 74 68 65 20 69 6e 66 6f 72 6d 61 74 ses the informat
58d0: 69 6f 6e 20 69 6e 0a 09 23 20 44 45 50 45 4e 44 ion in..# DEPEND
58e0: 45 4e 43 49 45 53 20 74 6f 20 64 6f 20 73 6f 2e ENCIES to do so.
58f0: 0a 0a 09 49 6e 69 74 69 61 6c 69 7a 65 42 72 65 ...InitializeBre
5900: 61 6b 53 74 61 74 65 20 24 74 68 65 69 74 65 6d akState $theitem
5910: 73 0a 0a 09 73 65 74 20 66 72 61 67 6d 65 6e 74 s...set fragment
5920: 73 20 7b 7d 0a 09 73 65 74 20 6e 65 77 20 20 20 s {}..set new
5930: 20 20 20 20 5b 6c 69 73 74 20 24 72 61 6e 67 65 [list $range
5940: 5d 0a 0a 09 23 20 49 6e 73 74 65 61 64 20 6f 66 ]...# Instead of
5950: 20 6f 6e 65 20 6c 69 73 74 20 68 6f 6c 64 69 6e one list holdin
5960: 67 20 62 6f 74 68 20 70 72 6f 63 65 73 73 65 64 g both processed
5970: 20 61 6e 64 20 70 65 6e 64 69 6e 67 0a 09 23 20 and pending..#
5980: 66 72 61 67 6d 65 6e 74 73 20 77 65 20 75 73 65 fragments we use
5990: 20 74 77 6f 2c 20 6f 6e 65 20 66 6f 72 20 74 68 two, one for th
59a0: 65 20 66 72 61 6d 65 6e 74 73 20 74 6f 20 70 72 e framents to pr
59b0: 6f 63 65 73 73 2c 20 6f 6e 65 0a 09 23 20 74 6f ocess, one..# to
59c0: 20 68 6f 6c 64 20 74 68 65 20 6e 65 77 20 66 72 hold the new fr
59d0: 61 67 6d 65 6e 74 73 2c 20 61 6e 64 20 74 68 65 agments, and the
59e0: 20 6c 61 74 74 65 72 20 69 73 20 63 6f 70 69 65 latter is copie
59f0: 64 20 74 6f 20 74 68 65 0a 09 23 20 66 6f 72 6d d to the..# form
5a00: 65 72 20 77 68 65 6e 20 74 68 65 79 20 72 75 6e er when they run
5a10: 20 6f 75 74 2e 20 54 68 69 73 20 6b 65 65 70 73 out. This keeps
5a20: 20 74 68 65 20 6c 69 73 74 20 6f 66 20 70 65 6e the list of pen
5a30: 64 69 6e 67 0a 09 23 20 66 72 61 67 6d 65 6e 74 ding..# fragment
5a40: 73 20 73 68 6f 72 74 20 77 69 74 68 6f 75 74 20 s short without
5a50: 73 61 63 72 69 66 69 63 69 6e 67 20 73 70 65 65 sacrificing spee
5a60: 64 20 62 79 20 73 68 69 66 74 69 6e 67 20 73 74 d by shifting st
5a70: 75 66 66 0a 09 23 20 64 6f 77 6e 2e 20 57 65 20 uff..# down. We
5a80: 65 73 70 65 63 69 61 6c 6c 79 20 64 72 6f 70 20 especially drop
5a90: 74 68 65 20 6d 65 6d 6f 72 79 20 6f 66 20 66 72 the memory of fr
5aa0: 61 67 6d 65 6e 74 73 20 62 72 6f 6b 65 6e 0a 09 agments broken..
5ab0: 23 20 64 75 72 69 6e 67 20 70 72 6f 63 65 73 73 # during process
5ac0: 69 6e 67 20 61 66 74 65 72 20 61 20 73 68 6f 72 ing after a shor
5ad0: 74 20 74 69 6d 65 2c 20 69 6e 73 74 65 61 64 20 t time, instead
5ae0: 6f 66 20 6c 65 74 74 69 6e 67 20 69 74 0a 09 23 of letting it..#
5af0: 20 63 6f 6e 73 75 6d 65 20 6d 65 6d 6f 72 79 2e consume memory.
5b00: 0a 0a 09 77 68 69 6c 65 20 7b 5b 6c 6c 65 6e 67 ...while {[lleng
5b10: 74 68 20 24 6e 65 77 5d 7d 20 7b 0a 0a 09 20 20 th $new]} {...
5b20: 20 20 73 65 74 20 70 65 6e 64 69 6e 67 20 24 6e set pending $n
5b30: 65 77 0a 09 20 20 20 20 73 65 74 20 6e 65 77 20 ew.. set new
5b40: 20 20 20 20 7b 7d 0a 09 20 20 20 20 73 65 74 20 {}.. set
5b50: 61 74 20 20 20 20 20 20 30 0a 0a 09 20 20 20 20 at 0...
5b60: 77 68 69 6c 65 20 7b 24 61 74 20 3c 20 5b 6c 6c while {$at < [ll
5b70: 65 6e 67 74 68 20 24 70 65 6e 64 69 6e 67 5d 7d ength $pending]}
5b80: 20 7b 0a 09 09 73 65 74 20 63 75 72 72 65 6e 74 {...set current
5b90: 20 5b 6c 69 6e 64 65 78 20 24 70 65 6e 64 69 6e [lindex $pendin
5ba0: 67 20 24 61 74 5d 0a 0a 09 09 6c 6f 67 20 77 72 g $at]....log wr
5bb0: 69 74 65 20 36 20 63 73 65 74 73 20 7b 2e 20 2e ite 6 csets {. .
5bc0: 20 2e 2e 20 2e 2e 2e 20 2e 2e 2e 2e 2e 20 2e 2e .. ... ..... ..
5bd0: 2e 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 2e ...... .........
5be0: 2e 2e 2e 2e 7d 0a 09 09 6c 6f 67 20 77 72 69 74 ....}...log writ
5bf0: 65 20 36 20 63 73 65 74 73 20 7b 53 63 68 65 64 e 6 csets {Sched
5c00: 75 6c 65 64 20 20 20 5b 6a 6f 69 6e 20 5b 50 52 uled [join [PR
5c10: 73 20 5b 6c 72 61 6e 67 65 20 24 70 65 6e 64 69 s [lrange $pendi
5c20: 6e 67 20 24 61 74 20 65 6e 64 5d 5d 20 7b 20 7d ng $at end]] { }
5c30: 5d 7d 0a 09 09 6c 6f 67 20 77 72 69 74 65 20 36 ]}...log write 6
5c40: 20 63 73 65 74 73 20 7b 43 6f 6e 73 69 64 65 72 csets {Consider
5c50: 69 6e 67 20 5b 50 52 20 24 63 75 72 72 65 6e 74 ing [PR $current
5c60: 5d 20 5c 5b 24 61 74 2f 5b 6c 6c 65 6e 67 74 68 ] \[$at/[llength
5c70: 20 24 70 65 6e 64 69 6e 67 5d 5c 5d 7d 0a 0a 09 $pending]\]}...
5c80: 09 73 65 74 20 62 65 73 74 20 5b 46 69 6e 64 42 .set best [FindB
5c90: 65 73 74 42 72 65 61 6b 20 24 63 75 72 72 65 6e estBreak $curren
5ca0: 74 5d 0a 0a 09 09 69 66 20 7b 24 62 65 73 74 20 t]....if {$best
5cb0: 3c 20 30 7d 20 7b 0a 09 09 20 20 20 20 23 20 54 < 0} {... # T
5cc0: 68 65 20 69 6e 73 70 65 63 74 65 64 20 72 61 6e he inspected ran
5cd0: 67 65 20 68 61 73 20 6e 6f 20 69 6e 74 65 72 6e ge has no intern
5ce0: 61 6c 0a 09 09 20 20 20 20 23 20 64 65 70 65 6e al... # depen
5cf0: 64 65 6e 63 69 65 73 2e 20 54 68 69 73 20 69 73 dencies. This is
5d00: 20 61 20 63 6f 6d 70 6c 65 74 65 20 66 72 61 67 a complete frag
5d10: 6d 65 6e 74 2e 0a 09 09 20 20 20 20 6c 61 70 70 ment.... lapp
5d20: 65 6e 64 20 66 72 61 67 6d 65 6e 74 73 20 24 63 end fragments $c
5d30: 75 72 72 65 6e 74 0a 0a 09 09 20 20 20 20 6c 6f urrent.... lo
5d40: 67 20 77 72 69 74 65 20 36 20 63 73 65 74 73 20 g write 6 csets
5d50: 22 4e 6f 20 62 72 65 61 6b 73 2c 20 66 69 6e 61 "No breaks, fina
5d60: 6c 22 0a 09 09 7d 20 65 6c 73 65 20 7b 0a 09 09 l"...} else {...
5d70: 20 20 20 20 23 20 53 70 6c 69 74 20 74 68 65 20 # Split the
5d80: 72 61 6e 67 65 20 61 6e 64 20 73 63 68 65 64 75 range and schedu
5d90: 6c 65 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 le the resulting
5da0: 0a 09 09 20 20 20 20 23 20 66 72 61 67 6d 65 6e ... # fragmen
5db0: 74 73 20 66 6f 72 20 66 75 72 74 68 65 72 20 69 ts for further i
5dc0: 6e 73 70 65 63 74 69 6f 6e 2e 20 52 65 6d 65 6d nspection. Remem
5dd0: 62 65 72 20 74 68 65 0a 09 09 20 20 20 20 23 20 ber the... #
5de0: 6e 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 number of depend
5df0: 65 6e 63 69 65 73 20 63 75 74 20 62 65 66 6f 72 encies cut befor
5e00: 65 20 77 65 20 72 65 6d 6f 76 65 20 74 68 65 6d e we remove them
5e10: 0a 09 09 20 20 20 20 23 20 66 72 6f 6d 20 63 6f ... # from co
5e20: 6e 73 69 64 65 72 61 74 69 6f 6e 2c 20 66 6f 72 nsideration, for
5e30: 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 20 6c documentation l
5e40: 61 74 65 72 2e 0a 0a 09 09 20 20 20 20 73 65 74 ater..... set
5e50: 20 62 72 65 61 6b 73 28 24 62 65 73 74 29 20 24 breaks($best) $
5e60: 63 72 6f 73 73 28 24 62 65 73 74 29 0a 0a 09 09 cross($best)....
5e70: 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 36 20 log write 6
5e80: 63 73 65 74 73 20 22 42 65 73 74 20 62 72 65 61 csets "Best brea
5e90: 6b 20 40 20 24 62 65 73 74 2c 20 63 75 74 74 69 k @ $best, cutti
5ea0: 6e 67 20 5b 6e 73 70 20 24 63 72 6f 73 73 28 24 ng [nsp $cross($
5eb0: 62 65 73 74 29 20 64 65 70 65 6e 64 65 6e 63 79 best) dependency
5ec0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 5d 22 0a dependencies]".
5ed0: 0a 09 09 20 20 20 20 23 20 4e 6f 74 65 3a 20 54 ... # Note: T
5ee0: 68 65 20 76 61 6c 75 65 20 6f 66 20 62 65 73 74 he value of best
5ef0: 20 69 73 20 61 6e 20 61 62 6f 6c 75 74 65 20 6c is an abolute l
5f00: 6f 63 61 74 69 6f 6e 0a 09 09 20 20 20 20 23 20 ocation... #
5f10: 69 6e 20 6d 79 69 74 65 6d 73 2e 20 55 73 65 20 in myitems. Use
5f20: 74 68 65 20 73 74 61 72 74 20 6f 66 20 63 75 72 the start of cur
5f30: 72 65 6e 74 20 74 6f 20 6d 61 6b 65 20 69 74 0a rent to make it.
5f40: 09 09 20 20 20 20 23 20 61 6e 20 69 6e 64 65 78 .. # an index
5f50: 20 61 62 73 6f 6c 75 74 65 20 74 6f 20 63 75 72 absolute to cur
5f60: 72 65 6e 74 2e 0a 0a 09 09 20 20 20 20 73 65 74 rent..... set
5f70: 20 62 72 65 6c 20 5b 65 78 70 72 20 7b 24 62 65 brel [expr {$be
5f80: 73 74 20 2d 20 5b 6c 69 6e 64 65 78 20 24 63 75 st - [lindex $cu
5f90: 72 72 65 6e 74 20 30 5d 7d 5d 0a 09 09 20 20 20 rrent 0]}]...
5fa0: 20 73 65 74 20 62 6e 65 78 74 20 24 62 72 65 6c set bnext $brel
5fb0: 20 3b 20 69 6e 63 72 20 62 6e 65 78 74 0a 09 09 ; incr bnext...
5fc0: 20 20 20 20 73 65 74 20 66 72 61 67 62 65 66 6f set fragbefo
5fd0: 72 65 20 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 re [lrange $curr
5fe0: 65 6e 74 20 30 20 24 62 72 65 6c 5d 0a 09 09 20 ent 0 $brel]...
5ff0: 20 20 20 73 65 74 20 66 72 61 67 61 66 74 65 72 set fragafter
6000: 20 20 5b 6c 72 61 6e 67 65 20 24 63 75 72 72 65 [lrange $curre
6010: 6e 74 20 24 62 6e 65 78 74 20 65 6e 64 5d 0a 0a nt $bnext end]..
6020: 09 09 20 20 20 20 6c 6f 67 20 77 72 69 74 65 20 .. log write
6030: 36 20 63 73 65 74 73 20 22 4e 65 77 20 70 69 65 6 csets "New pie
6040: 63 65 73 20 20 5b 50 52 20 24 66 72 61 67 62 65 ces [PR $fragbe
6050: 66 6f 72 65 5d 20 5b 50 52 20 24 66 72 61 67 61 fore] [PR $fraga
6060: 66 74 65 72 5d 22 0a 0a 09 09 20 20 20 20 69 6e fter]".... in
6070: 74 65 67 72 69 74 79 20 61 73 73 65 72 74 20 7b tegrity assert {
6080: 5b 6c 6c 65 6e 67 74 68 20 24 66 72 61 67 62 65 [llength $fragbe
6090: 66 6f 72 65 5d 7d 20 7b 46 6f 75 6e 64 20 7a 65 fore]} {Found ze
60a0: 72 6f 2d 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 ro-length fragme
60b0: 6e 74 20 61 74 20 74 68 65 20 62 65 67 69 6e 6e nt at the beginn
60c0: 69 6e 67 7d 0a 09 09 20 20 20 20 69 6e 74 65 67 ing}... integ
60d0: 72 69 74 79 20 61 73 73 65 72 74 20 7b 5b 6c 6c rity assert {[ll
60e0: 65 6e 67 74 68 20 24 66 72 61 67 61 66 74 65 72 ength $fragafter
60f0: 5d 7d 20 20 7b 46 6f 75 6e 64 20 7a 65 72 6f 2d ]} {Found zero-
6100: 6c 65 6e 67 74 68 20 66 72 61 67 6d 65 6e 74 20 length fragment
6110: 61 74 20 74 68 65 20 65 6e 64 7d 0a 0a 09 09 20 at the end}....
6120: 20 20 20 6c 61 70 70 65 6e 64 20 6e 65 77 20 24 lappend new $
6130: 66 72 61 67 62 65 66 6f 72 65 20 24 66 72 61 67 fragbefore $frag
6140: 61 66 74 65 72 0a 09 09 20 20 20 20 43 75 74 41 after... CutA
6150: 74 20 24 62 65 73 74 0a 09 09 7d 0a 0a 09 09 69 t $best...}....i
6160: 6e 63 72 20 61 74 0a 09 20 20 20 20 7d 0a 09 7d ncr at.. }..}
6170: 0a 0a 09 6c 6f 67 20 77 72 69 74 65 20 36 20 63 ...log write 6 c
6180: 73 65 74 73 20 22 2e 20 2e 20 2e 2e 20 2e 2e 2e sets ". . .. ...
6190: 20 2e 2e 2e 2e 2e 20 2e 2e 2e 2e 2e 2e 2e 2e 20 ..... ........
61a0: 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 22 0a 0a ............."..
61b0: 09 72 65 74 75 72 6e 20 24 66 72 61 67 6d 65 6e .return $fragmen
61c0: 74 73 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 ts. }.. pr
61d0: 6f 63 20 49 6e 69 74 69 61 6c 69 7a 65 42 72 65 oc InitializeBre
61e0: 61 6b 53 74 61 74 65 20 7b 72 65 76 69 73 69 6f akState {revisio
61f0: 6e 73 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 70 ns} {..upvar 1 p
6200: 6f 73 20 70 6f 73 20 63 72 6f 73 73 20 63 72 6f os pos cross cro
6210: 73 73 20 72 61 6e 67 65 20 72 61 6e 67 65 20 64 ss range range d
6220: 65 70 63 20 64 65 70 63 20 64 65 6c 74 61 20 64 epc depc delta d
6230: 65 6c 74 61 20 5c 0a 09 20 20 20 20 64 65 70 65 elta \.. depe
6240: 6e 64 65 6e 63 69 65 73 20 64 65 70 65 6e 64 65 ndencies depende
6250: 6e 63 69 65 73 0a 0a 09 23 20 46 69 72 73 74 20 ncies...# First
6260: 77 65 20 63 72 65 61 74 65 20 61 20 6d 61 70 20 we create a map
6270: 6f 66 20 70 6f 73 69 74 69 6f 6e 73 20 74 6f 20 of positions to
6280: 6d 61 6b 65 20 69 74 20 65 61 73 69 65 72 20 74 make it easier t
6290: 6f 0a 09 23 20 64 65 74 65 72 6d 69 6e 65 20 77 o..# determine w
62a0: 68 65 74 68 65 72 20 61 20 64 65 70 65 6e 64 65 hether a depende
62b0: 6e 63 79 20 63 72 6f 73 73 65 73 20 61 20 70 61 ncy crosses a pa
62c0: 72 74 69 63 75 6c 61 72 20 69 6e 64 65 78 2e 0a rticular index..
62d0: 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63 ..log write 14 c
62e0: 73 65 74 73 20 7b 49 42 53 3a 20 23 72 65 76 20 sets {IBS: #rev
62f0: 5b 6c 6c 65 6e 67 74 68 20 24 72 65 76 69 73 69 [llength $revisi
6300: 6f 6e 73 5d 7d 0a 09 6c 6f 67 20 77 72 69 74 65 ons]}..log write
6310: 20 31 34 20 63 73 65 74 73 20 7b 49 42 53 3a 20 14 csets {IBS:
6320: 70 6f 73 20 6d 61 70 2c 20 63 72 6f 73 73 20 63 pos map, cross c
6330: 6f 75 6e 74 65 72 7d 0a 0a 09 61 72 72 61 79 20 ounter}...array
6340: 73 65 74 20 70 6f 73 20 20 20 7b 7d 0a 09 61 72 set pos {}..ar
6350: 72 61 79 20 73 65 74 20 63 72 6f 73 73 20 7b 7d ray set cross {}
6360: 0a 09 61 72 72 61 79 20 73 65 74 20 64 65 70 63 ..array set depc
6370: 20 20 7b 7d 0a 09 73 65 74 20 72 61 6e 67 65 20 {}..set range
6380: 20 20 20 20 20 20 7b 7d 0a 09 73 65 74 20 6e 20 {}..set n
6390: 30 0a 09 66 6f 72 65 61 63 68 20 72 65 76 20 24 0..foreach rev $
63a0: 72 65 76 69 73 69 6f 6e 73 20 7b 0a 09 20 20 20 revisions {..
63b0: 20 6c 61 70 70 65 6e 64 20 72 61 6e 67 65 20 24 lappend range $
63c0: 6e 0a 09 20 20 20 20 73 65 74 20 70 6f 73 28 24 n.. set pos($
63d0: 72 65 76 29 20 24 6e 0a 09 20 20 20 20 73 65 74 rev) $n.. set
63e0: 20 63 72 6f 73 73 28 24 6e 29 20 30 0a 09 20 20 cross($n) 0..
63f0: 20 20 69 6e 63 72 20 6e 0a 09 7d 0a 0a 09 6c 6f incr n..}...lo
6400: 67 20 77 72 69 74 65 20 31 34 20 63 73 65 74 73 g write 14 csets
6410: 20 7b 49 42 53 3a 20 70 6f 73 2f 5b 61 72 72 61 {IBS: pos/[arra
6420: 79 20 73 69 7a 65 20 70 6f 73 5d 2c 20 63 72 6f y size pos], cro
6430: 73 73 2f 5b 61 72 72 61 79 20 73 69 7a 65 20 63 ss/[array size c
6440: 72 6f 73 73 5d 7d 0a 0a 09 23 20 53 65 63 6f 6e ross]}...# Secon
6450: 64 6c 79 20 77 65 20 63 6f 75 6e 74 20 74 68 65 dly we count the
6460: 20 63 72 6f 73 73 69 6e 67 73 20 70 65 72 20 70 crossings per p
6470: 6f 73 69 74 69 6f 6e 2c 20 62 79 20 69 74 65 72 osition, by iter
6480: 61 74 69 6e 67 0a 09 23 20 6f 76 65 72 20 74 68 ating..# over th
6490: 65 20 72 65 63 6f 72 64 65 64 20 69 6e 74 65 72 e recorded inter
64a0: 6e 61 6c 20 64 65 70 65 6e 64 65 6e 63 69 65 73 nal dependencies
64b0: 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 49 66 20 74 ....# Note: If t
64c0: 68 65 20 74 69 6d 65 73 74 61 6d 70 73 20 61 72 he timestamps ar
64d0: 65 20 62 61 64 6c 79 20 6f 75 74 20 6f 66 20 6f e badly out of o
64e0: 72 64 65 72 20 69 74 20 69 73 0a 09 23 20 20 20 rder it is..#
64f0: 20 20 20 20 70 6f 73 73 69 62 6c 65 20 74 6f 20 possible to
6500: 68 61 76 65 20 61 20 62 61 63 6b 77 61 72 64 20 have a backward
6510: 73 75 63 63 65 73 73 6f 72 20 64 65 70 65 6e 64 successor depend
6520: 65 6e 63 79 2c 0a 09 23 20 20 20 20 20 20 20 69 ency,..# i
6530: 2e 65 2e 20 77 69 74 68 20 73 74 61 72 74 20 3e .e. with start >
6540: 20 65 6e 64 2e 20 57 65 20 6d 61 79 20 68 61 76 end. We may hav
6550: 65 20 74 6f 20 73 77 61 70 20 74 68 65 20 69 6e e to swap the in
6560: 64 69 63 65 73 0a 09 23 20 20 20 20 20 20 20 74 dices..# t
6570: 6f 20 65 6e 73 75 72 65 20 74 68 61 74 20 74 68 o ensure that th
6580: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 6c 6f 6f 70 e following loop
6590: 20 72 75 6e 73 20 63 6f 72 72 65 63 74 6c 79 2e runs correctly.
65a0: 0a 09 23 0a 09 23 20 4e 6f 74 65 20 32 3a 20 73 ..#..# Note 2: s
65b0: 74 61 72 74 20 3d 3d 20 65 6e 64 20 69 73 20 6e tart == end is n
65c0: 6f 74 20 70 6f 73 73 69 62 6c 65 2e 20 49 74 20 ot possible. It
65d0: 69 6e 64 69 63 61 74 65 73 20 61 0a 09 23 20 20 indicates a..#
65e0: 20 20 20 20 20 20 20 73 65 6c 66 2d 64 65 70 65 self-depe
65f0: 6e 64 65 6e 63 79 20 64 75 65 20 74 6f 20 74 68 ndency due to th
6600: 65 20 75 6e 69 71 75 65 6e 65 73 73 20 6f 66 20 e uniqueness of
6610: 70 6f 73 69 74 69 6f 6e 73 2c 0a 09 23 20 20 20 positions,..#
6620: 20 20 20 20 20 20 61 6e 64 20 74 68 61 74 20 69 and that i
6630: 73 20 73 6f 6d 65 74 68 69 6e 67 20 77 65 20 68 s something we h
6640: 61 76 65 20 72 75 6c 65 64 20 6f 75 74 20 61 6c ave ruled out al
6650: 72 65 61 64 79 2c 20 73 65 65 0a 09 23 20 20 20 ready, see..#
6660: 20 20 20 20 20 20 27 72 65 76 20 69 6e 74 65 72 'rev inter
6670: 6e 61 6c 73 75 63 63 65 73 73 6f 72 73 27 2e 0a nalsuccessors'..
6680: 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63 ..log write 14 c
6690: 73 65 74 73 20 7b 49 42 53 3a 20 63 72 6f 73 73 sets {IBS: cross
66a0: 20 63 6f 75 6e 74 65 72 20 66 69 6c 6c 69 6e 67 counter filling
66b0: 2c 20 70 6f 73 2f 63 72 6f 73 73 20 6d 61 70 7d , pos/cross map}
66c0: 0a 0a 09 66 6f 72 65 61 63 68 20 7b 72 69 64 20 ...foreach {rid
66d0: 63 68 69 6c 64 72 65 6e 7d 20 5b 61 72 72 61 79 children} [array
66e0: 20 67 65 74 20 64 65 70 65 6e 64 65 6e 63 69 65 get dependencie
66f0: 73 5d 20 7b 0a 09 20 20 20 20 66 6f 72 65 61 63 s] {.. foreac
6700: 68 20 63 68 69 6c 64 20 24 63 68 69 6c 64 72 65 h child $childre
6710: 6e 20 7b 0a 09 09 73 65 74 20 64 6b 65 79 20 20 n {...set dkey
6720: 20 20 5b 6c 69 73 74 20 24 72 69 64 20 24 63 68 [list $rid $ch
6730: 69 6c 64 5d 0a 09 09 73 65 74 20 73 74 61 72 74 ild]...set start
6740: 20 20 20 24 70 6f 73 28 24 72 69 64 29 0a 09 09 $pos($rid)...
6750: 73 65 74 20 65 6e 64 20 20 20 20 20 24 70 6f 73 set end $pos
6760: 28 24 63 68 69 6c 64 29 0a 0a 09 09 69 66 20 7b ($child)....if {
6770: 24 73 74 61 72 74 20 3e 20 24 65 6e 64 7d 20 7b $start > $end} {
6780: 0a 09 09 20 20 20 20 73 65 74 20 63 72 6f 73 73 ... set cross
6790: 65 73 20 5b 6c 69 73 74 20 24 65 6e 64 20 5b 65 es [list $end [e
67a0: 78 70 72 20 7b 24 73 74 61 72 74 2d 31 7d 5d 5d xpr {$start-1}]]
67b0: 0a 09 09 20 20 20 20 77 68 69 6c 65 20 7b 24 65 ... while {$e
67c0: 6e 64 20 3c 20 24 73 74 61 72 74 7d 20 7b 0a 09 nd < $start} {..
67d0: 09 09 69 6e 63 72 20 63 72 6f 73 73 28 24 65 6e ..incr cross($en
67e0: 64 29 0a 09 09 09 69 6e 63 72 20 65 6e 64 0a 09 d)....incr end..
67f0: 09 20 20 20 20 7d 0a 09 09 7d 20 65 6c 73 65 20 . }...} else
6800: 7b 0a 09 09 20 20 20 20 73 65 74 20 63 72 6f 73 {... set cros
6810: 73 65 73 20 5b 6c 69 73 74 20 24 73 74 61 72 74 ses [list $start
6820: 20 5b 65 78 70 72 20 7b 24 65 6e 64 2d 31 7d 5d [expr {$end-1}]
6830: 5d 0a 09 09 20 20 20 20 77 68 69 6c 65 20 7b 24 ]... while {$
6840: 73 74 61 72 74 20 3c 20 24 65 6e 64 7d 20 7b 0a start < $end} {.
6850: 09 09 09 69 6e 63 72 20 63 72 6f 73 73 28 24 73 ...incr cross($s
6860: 74 61 72 74 29 0a 09 09 09 69 6e 63 72 20 73 74 tart)....incr st
6870: 61 72 74 0a 09 09 20 20 20 20 7d 0a 09 09 7d 0a art... }...}.
6880: 09 09 73 65 74 20 64 65 70 63 28 24 64 6b 65 79 ..set depc($dkey
6890: 29 20 24 63 72 6f 73 73 65 73 0a 09 20 20 20 20 ) $crosses..
68a0: 7d 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 74 65 }..}...log write
68b0: 20 31 34 20 63 73 65 74 73 20 7b 49 42 53 3a 20 14 csets {IBS:
68c0: 70 6f 73 2f 5b 61 72 72 61 79 20 73 69 7a 65 20 pos/[array size
68d0: 70 6f 73 5d 2c 20 63 72 6f 73 73 2f 5b 61 72 72 pos], cross/[arr
68e0: 61 79 20 73 69 7a 65 20 63 72 6f 73 73 5d 2c 20 ay size cross],
68f0: 64 65 70 63 2f 5b 61 72 72 61 79 20 73 69 7a 65 depc/[array size
6900: 20 64 65 70 63 5d 20 28 66 6f 72 20 5b 6c 6c 65 depc] (for [lle
6910: 6e 67 74 68 20 24 72 65 76 69 73 69 6f 6e 73 5d ngth $revisions]
6920: 29 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 31 34 )}..log write 14
6930: 20 63 73 65 74 73 20 7b 49 42 53 3a 20 74 69 6d csets {IBS: tim
6940: 65 73 74 61 6d 70 73 2c 20 64 65 6c 74 61 73 7d estamps, deltas}
6950: 0a 0a 09 49 6e 69 74 69 61 6c 69 7a 65 44 65 6c ...InitializeDel
6960: 74 61 73 20 24 72 65 76 69 73 69 6f 6e 73 0a 0a tas $revisions..
6970: 09 6c 6f 67 20 77 72 69 74 65 20 31 34 20 63 73 .log write 14 cs
6980: 65 74 73 20 7b 49 42 53 3a 20 64 65 6c 74 61 20 ets {IBS: delta
6990: 5b 61 72 72 61 79 20 73 69 7a 65 20 64 65 6c 74 [array size delt
69a0: 61 5d 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 a]}..return.
69b0: 7d 0a 0a 20 20 20 20 70 72 6f 63 20 49 6e 69 74 }.. proc Init
69c0: 69 61 6c 69 7a 65 44 65 6c 74 61 73 20 7b 72 65 ializeDeltas {re
69d0: 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 61 visions} {..upva
69e0: 72 20 31 20 64 65 6c 74 61 20 64 65 6c 74 61 0a r 1 delta delta.
69f0: 0a 09 23 20 50 75 6c 6c 20 74 68 65 20 74 69 6d ..# Pull the tim
6a00: 65 73 74 61 6d 70 73 20 66 6f 72 20 61 6c 6c 20 estamps for all
6a10: 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 74 68 65 revisions in the
6a20: 20 63 68 61 6e 67 65 73 65 74 73 20 61 6e 64 0a changesets and.
6a30: 09 23 20 63 6f 6d 70 75 74 65 20 74 68 65 69 72 .# compute their
6a40: 20 64 65 6c 74 61 73 20 66 6f 72 20 75 73 65 20 deltas for use
6a50: 62 79 20 74 68 65 20 62 72 65 61 6b 20 66 69 6e by the break fin
6a60: 64 65 72 2e 0a 0a 09 61 72 72 61 79 20 73 65 74 der....array set
6a70: 20 64 65 6c 74 61 20 7b 7d 0a 09 61 72 72 61 79 delta {}..array
6a80: 20 73 65 74 20 73 74 61 6d 70 20 7b 7d 0a 0a 09 set stamp {}...
6a90: 73 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f set theset ('[jo
6aa0: 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 in $revisions {'
6ab0: 2c 27 7d 5d 27 29 0a 09 73 74 61 74 65 20 66 6f ,'}]')..state fo
6ac0: 72 65 61 63 68 72 6f 77 20 5b 73 75 62 73 74 20 reachrow [subst
6ad0: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 -nocommands -nob
6ae0: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 ackslashes {..
6af0: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 20 41 SELECT R.rid A
6b00: 53 20 78 72 69 64 2c 20 52 2e 64 61 74 65 20 41 S xrid, R.date A
6b10: 53 20 74 69 6d 65 0a 09 20 20 20 20 46 52 4f 4d S time.. FROM
6b20: 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 20 revision R..
6b30: 20 57 48 45 52 45 20 52 2e 72 69 64 20 49 4e 20 WHERE R.rid IN
6b40: 24 74 68 65 73 65 74 0a 09 7d 5d 20 7b 0a 09 20 $theset..}] {..
6b50: 20 20 20 73 65 74 20 73 74 61 6d 70 28 24 78 72 set stamp($xr
6b60: 69 64 29 20 24 74 69 6d 65 0a 09 7d 0a 0a 09 6c id) $time..}...l
6b70: 6f 67 20 77 72 69 74 65 20 31 34 20 63 73 65 74 og write 14 cset
6b80: 73 20 7b 49 42 53 3a 20 73 74 61 6d 70 20 5b 61 s {IBS: stamp [a
6b90: 72 72 61 79 20 73 69 7a 65 20 73 74 61 6d 70 5d rray size stamp]
6ba0: 7d 0a 0a 09 73 65 74 20 6e 20 30 0a 09 66 6f 72 }...set n 0..for
6bb0: 65 61 63 68 20 72 69 64 20 5b 6c 72 61 6e 67 65 each rid [lrange
6bc0: 20 24 72 65 76 69 73 69 6f 6e 73 20 30 20 65 6e $revisions 0 en
6bd0: 64 2d 31 5d 20 72 6e 65 78 74 20 5b 6c 72 61 6e d-1] rnext [lran
6be0: 67 65 20 24 72 65 76 69 73 69 6f 6e 73 20 31 20 ge $revisions 1
6bf0: 65 6e 64 5d 20 7b 0a 09 20 20 20 20 73 65 74 20 end] {.. set
6c00: 64 65 6c 74 61 28 24 6e 29 20 5b 65 78 70 72 20 delta($n) [expr
6c10: 7b 24 73 74 61 6d 70 28 24 72 6e 65 78 74 29 20 {$stamp($rnext)
6c20: 2d 20 24 73 74 61 6d 70 28 24 72 69 64 29 7d 5d - $stamp($rid)}]
6c30: 0a 09 20 20 20 20 69 6e 63 72 20 6e 0a 09 7d 0a .. incr n..}.
6c40: 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 .return. }..
6c50: 20 20 20 70 72 6f 63 20 46 69 6e 64 42 65 73 74 proc FindBest
6c60: 42 72 65 61 6b 20 7b 72 61 6e 67 65 7d 20 7b 0a Break {range} {.
6c70: 09 75 70 76 61 72 20 31 20 63 72 6f 73 73 20 63 .upvar 1 cross c
6c80: 72 6f 73 73 20 64 65 6c 74 61 20 64 65 6c 74 61 ross delta delta
6c90: 0a 0a 09 23 20 44 65 74 65 72 6d 69 6e 65 20 74 ...# Determine t
6ca0: 68 65 20 62 65 73 74 20 62 72 65 61 6b 20 6c 6f he best break lo
6cb0: 63 61 74 69 6f 6e 20 69 6e 20 74 68 65 20 67 69 cation in the gi
6cc0: 76 65 6e 20 72 61 6e 67 65 20 6f 66 0a 09 23 20 ven range of..#
6cd0: 70 6f 73 69 74 69 6f 6e 73 2e 20 46 69 72 73 74 positions. First
6ce0: 20 77 65 20 6c 6f 6f 6b 20 66 6f 72 20 74 68 65 we look for the
6cf0: 20 6c 6f 63 61 74 69 6f 6e 73 20 77 69 74 68 20 locations with
6d00: 74 68 65 20 6d 61 78 69 6d 61 6c 0a 09 23 20 6e the maximal..# n
6d10: 75 6d 62 65 72 20 6f 66 20 63 72 6f 73 73 69 6e umber of crossin
6d20: 67 73 2e 20 49 66 20 74 68 65 72 65 20 61 72 65 gs. If there are
6d30: 20 73 65 76 65 72 61 6c 20 77 65 20 6c 6f 6f 6b several we look
6d40: 20 66 6f 72 20 74 68 65 0a 09 23 20 73 68 6f 72 for the..# shor
6d50: 74 65 73 74 20 74 69 6d 65 20 69 6e 74 65 72 76 test time interv
6d60: 61 6c 20 61 6d 6f 6e 67 20 74 68 65 6d 2e 20 49 al among them. I
6d70: 66 20 77 65 20 73 74 69 6c 6c 20 68 61 76 65 20 f we still have
6d80: 6d 75 6c 74 69 70 6c 65 0a 09 23 20 70 6f 73 73 multiple..# poss
6d90: 69 62 69 6c 69 74 69 65 73 20 61 66 74 65 72 20 ibilities after
6da0: 74 68 61 74 20 77 65 20 73 65 6c 65 63 74 20 74 that we select t
6db0: 68 65 20 65 61 72 6c 69 65 73 74 20 6c 6f 63 61 he earliest loca
6dc0: 74 69 6f 6e 0a 09 23 20 61 6d 6f 6e 67 20 74 68 tion..# among th
6dd0: 65 73 65 2e 0a 0a 09 23 20 4e 6f 74 65 3a 20 49 ese....# Note: I
6de0: 66 20 74 68 65 20 6d 61 78 69 6d 61 6c 20 6e 75 f the maximal nu
6df0: 6d 62 65 72 20 6f 66 20 63 72 6f 73 73 69 6e 67 mber of crossing
6e00: 73 20 69 73 20 30 20 74 68 65 6e 20 74 68 65 20 s is 0 then the
6e10: 72 61 6e 67 65 0a 09 23 20 20 20 20 20 20 20 68 range..# h
6e20: 61 73 20 6e 6f 20 69 6e 74 65 72 6e 61 6c 20 64 as no internal d
6e30: 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 61 6e 64 ependencies, and
6e40: 20 6e 6f 20 62 72 65 61 6b 20 6c 6f 63 61 74 69 no break locati
6e50: 6f 6e 20 61 74 0a 09 23 20 20 20 20 20 20 20 61 on at..# a
6e60: 6c 6c 2e 20 54 68 69 73 20 70 6f 73 73 69 62 69 ll. This possibi
6e70: 6c 69 74 79 20 69 73 20 73 69 67 6e 61 6c 65 64 lity is signaled
6e80: 20 76 69 61 20 72 65 73 75 6c 74 20 2d 31 2e 0a via result -1..
6e90: 0a 09 23 20 4e 6f 74 65 3a 20 41 20 72 61 6e 67 ..# Note: A rang
6ea0: 65 20 6f 66 20 6c 65 6e 67 74 68 20 31 20 6f 72 e of length 1 or
6eb0: 20 6c 65 73 73 20 63 61 6e 6e 6f 74 20 68 61 76 less cannot hav
6ec0: 65 20 69 6e 74 65 72 6e 61 6c 0a 09 23 20 20 20 e internal..#
6ed0: 20 20 20 20 64 65 70 65 6e 64 65 6e 63 69 65 73 dependencies
6ee0: 2c 20 61 73 20 74 68 61 74 20 6e 65 65 64 73 20 , as that needs
6ef0: 61 74 20 6c 65 61 73 74 20 74 77 6f 20 72 65 76 at least two rev
6f00: 69 73 69 6f 6e 73 20 69 6e 0a 09 23 20 20 20 20 isions in..#
6f10: 20 20 20 74 68 65 20 72 61 6e 67 65 2e 0a 0a 09 the range....
6f20: 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 72 61 if {[llength $ra
6f30: 6e 67 65 5d 20 3c 20 32 7d 20 7b 20 72 65 74 75 nge] < 2} { retu
6f40: 72 6e 20 2d 31 20 7d 0a 0a 09 73 65 74 20 6d 61 rn -1 }...set ma
6f50: 78 20 2d 31 0a 09 73 65 74 20 62 65 73 74 20 7b x -1..set best {
6f60: 7d 0a 0a 09 66 6f 72 65 61 63 68 20 6c 6f 63 61 }...foreach loca
6f70: 74 69 6f 6e 20 24 72 61 6e 67 65 20 7b 0a 09 20 tion $range {..
6f80: 20 20 20 73 65 74 20 63 72 6f 73 73 69 6e 67 73 set crossings
6f90: 20 24 63 72 6f 73 73 28 24 6c 6f 63 61 74 69 6f $cross($locatio
6fa0: 6e 29 0a 09 20 20 20 20 69 66 20 7b 24 63 72 6f n).. if {$cro
6fb0: 73 73 69 6e 67 73 20 3e 20 24 6d 61 78 7d 20 7b ssings > $max} {
6fc0: 0a 09 09 73 65 74 20 6d 61 78 20 20 24 63 72 6f ...set max $cro
6fd0: 73 73 69 6e 67 73 0a 09 09 73 65 74 20 62 65 73 ssings...set bes
6fe0: 74 20 5b 6c 69 73 74 20 24 6c 6f 63 61 74 69 6f t [list $locatio
6ff0: 6e 5d 0a 09 09 63 6f 6e 74 69 6e 75 65 0a 09 20 n]...continue..
7000: 20 20 20 7d 20 65 6c 73 65 69 66 20 7b 24 63 72 } elseif {$cr
7010: 6f 73 73 69 6e 67 73 20 3d 3d 20 24 6d 61 78 7d ossings == $max}
7020: 20 7b 0a 09 09 6c 61 70 70 65 6e 64 20 62 65 73 {...lappend bes
7030: 74 20 24 6c 6f 63 61 74 69 6f 6e 0a 09 20 20 20 t $location..
7040: 20 7d 0a 09 7d 0a 0a 09 69 66 20 7b 24 6d 61 78 }..}...if {$max
7050: 20 3d 3d 20 30 7d 20 20 20 20 20 20 20 20 20 20 == 0}
7060: 20 20 7b 20 72 65 74 75 72 6e 20 2d 31 20 7d 0a { return -1 }.
7070: 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 62 .if {[llength $b
7080: 65 73 74 5d 20 3d 3d 20 31 7d 20 7b 20 72 65 74 est] == 1} { ret
7090: 75 72 6e 20 5b 6c 69 6e 64 65 78 20 24 62 65 73 urn [lindex $bes
70a0: 74 20 30 5d 20 7d 0a 0a 09 73 65 74 20 6c 6f 63 t 0] }...set loc
70b0: 61 74 69 6f 6e 73 20 24 62 65 73 74 0a 09 73 65 ations $best..se
70c0: 74 20 62 65 73 74 20 7b 7d 0a 09 73 65 74 20 6d t best {}..set m
70d0: 69 6e 20 2d 31 0a 0a 09 66 6f 72 65 61 63 68 20 in -1...foreach
70e0: 6c 6f 63 61 74 69 6f 6e 20 24 6c 6f 63 61 74 69 location $locati
70f0: 6f 6e 73 20 7b 0a 09 20 20 20 20 73 65 74 20 69 ons {.. set i
7100: 6e 74 65 72 76 61 6c 20 24 64 65 6c 74 61 28 24 nterval $delta($
7110: 6c 6f 63 61 74 69 6f 6e 29 0a 09 20 20 20 20 69 location).. i
7120: 66 20 7b 28 24 6d 69 6e 20 3c 20 30 29 20 7c 7c f {($min < 0) ||
7130: 20 28 24 69 6e 74 65 72 76 61 6c 20 3c 20 24 6d ($interval < $m
7140: 69 6e 29 7d 20 7b 0a 09 09 73 65 74 20 6d 69 6e in)} {...set min
7150: 20 20 24 69 6e 74 65 72 76 61 6c 0a 09 09 73 65 $interval...se
7160: 74 20 62 65 73 74 20 5b 6c 69 73 74 20 24 6c 6f t best [list $lo
7170: 63 61 74 69 6f 6e 5d 0a 09 20 20 20 20 7d 20 65 cation].. } e
7180: 6c 73 65 69 66 20 7b 24 69 6e 74 65 72 76 61 6c lseif {$interval
7190: 20 3d 3d 20 24 6d 69 6e 7d 20 7b 0a 09 09 6c 61 == $min} {...la
71a0: 70 70 65 6e 64 20 62 65 73 74 20 24 6c 6f 63 61 ppend best $loca
71b0: 74 69 6f 6e 0a 09 20 20 20 20 7d 0a 09 7d 0a 0a tion.. }..}..
71c0: 09 69 66 20 7b 5b 6c 6c 65 6e 67 74 68 20 24 62 .if {[llength $b
71d0: 65 73 74 5d 20 3d 3d 20 31 7d 20 7b 20 72 65 74 est] == 1} { ret
71e0: 75 72 6e 20 5b 6c 69 6e 64 65 78 20 24 62 65 73 urn [lindex $bes
71f0: 74 20 30 5d 20 7d 0a 0a 09 72 65 74 75 72 6e 20 t 0] }...return
7200: 5b 6c 69 6e 64 65 78 20 5b 6c 73 6f 72 74 20 2d [lindex [lsort -
7210: 69 6e 74 65 67 65 72 20 2d 69 6e 63 72 65 61 73 integer -increas
7220: 69 6e 67 20 24 62 65 73 74 5d 20 30 5d 0a 20 20 ing $best] 0].
7230: 20 20 7d 0a 0a 20 20 20 20 70 72 6f 63 20 43 75 }.. proc Cu
7240: 74 41 74 20 7b 6c 6f 63 61 74 69 6f 6e 7d 20 7b tAt {location} {
7250: 0a 09 75 70 76 61 72 20 31 20 63 72 6f 73 73 20 ..upvar 1 cross
7260: 63 72 6f 73 73 20 64 65 70 63 20 64 65 70 63 0a cross depc depc.
7270: 0a 09 23 20 49 74 20 77 61 73 20 64 65 63 69 64 ..# It was decid
7280: 65 64 20 74 6f 20 73 70 6c 69 74 20 74 68 65 20 ed to split the
7290: 63 68 61 6e 67 65 73 65 74 20 61 74 20 74 68 65 changeset at the
72a0: 20 67 69 76 65 6e 0a 09 23 20 6c 6f 63 61 74 69 given..# locati
72b0: 6f 6e 2e 20 54 68 69 73 20 63 75 74 73 20 61 20 on. This cuts a
72c0: 6e 75 6d 62 65 72 20 6f 66 20 64 65 70 65 6e 64 number of depend
72d0: 65 6e 63 69 65 73 2e 20 48 65 72 65 20 77 65 20 encies. Here we
72e0: 75 70 64 61 74 65 0a 09 23 20 74 68 65 20 63 72 update..# the cr
72f0: 6f 73 73 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 oss information
7300: 73 6f 20 74 68 61 74 20 74 68 65 20 62 72 65 61 so that the brea
7310: 6b 20 66 69 6e 64 65 72 20 68 61 73 20 61 63 63 k finder has acc
7320: 75 72 61 74 65 0a 09 23 20 64 61 74 61 20 77 68 urate..# data wh
7330: 65 6e 20 77 65 20 6c 6f 6f 6b 20 61 74 20 74 68 en we look at th
7340: 65 20 67 65 6e 65 72 61 74 65 64 20 66 72 61 67 e generated frag
7350: 6d 65 6e 74 73 2e 0a 0a 09 73 65 74 20 73 69 78 ments....set six
7360: 20 5b 6c 6f 67 20 76 69 73 69 62 6c 65 3f 20 36 [log visible? 6
7370: 5d 0a 0a 09 23 20 4e 6f 74 65 3a 20 54 68 65 20 ]...# Note: The
7380: 6c 6f 6f 70 20 62 65 6c 6f 77 20 63 6f 75 6c 64 loop below could
7390: 20 62 65 20 6d 61 64 65 20 66 61 73 74 65 72 20 be made faster
73a0: 62 79 20 6b 65 65 70 69 6e 67 20 61 20 6d 61 70 by keeping a map
73b0: 0a 09 23 20 66 72 6f 6d 20 70 6f 73 69 74 69 6f ..# from positio
73c0: 6e 73 20 74 6f 20 74 68 65 20 64 65 70 65 6e 64 ns to the depend
73d0: 65 6e 63 69 65 73 20 63 72 6f 73 73 69 6e 67 2e encies crossing.
73e0: 20 41 6e 20 65 78 74 65 6e 73 69 6f 6e 20 6f 66 An extension of
73f0: 0a 09 23 20 43 52 4f 53 53 2c 20 69 2e 65 2e 20 ..# CROSS, i.e.
7400: 6c 69 73 74 20 6f 66 20 64 65 70 65 6e 64 65 6e list of dependen
7410: 63 69 65 73 2c 20 63 6f 75 6e 74 65 72 20 69 73 cies, counter is
7420: 20 69 6d 70 6c 69 65 64 2e 20 54 61 6b 65 73 0a implied. Takes.
7430: 09 23 20 61 20 6c 6f 74 20 6d 6f 72 65 20 6d 65 .# a lot more me
7440: 6d 6f 72 79 20 68 6f 77 65 76 65 72 2c 20 61 6e mory however, an
7450: 64 20 74 61 6b 65 73 20 74 69 6d 65 20 74 6f 20 d takes time to
7460: 75 70 64 61 74 65 20 68 65 72 65 0a 09 23 20 28 update here..# (
7470: 54 68 65 20 69 6e 6e 65 72 20 6c 6f 6f 70 20 69 The inner loop i
7480: 73 20 6e 6f 74 20 69 6e 63 72 20 2d 31 2c 20 62 s not incr -1, b
7490: 75 74 20 6c 64 65 6c 65 74 65 29 2e 0a 0a 09 66 ut ldelete)....f
74a0: 6f 72 65 61 63 68 20 64 65 70 20 5b 61 72 72 61 oreach dep [arra
74b0: 79 20 6e 61 6d 65 73 20 64 65 70 63 5d 20 7b 0a y names depc] {.
74c0: 09 20 20 20 20 73 65 74 20 72 61 6e 67 65 20 24 . set range $
74d0: 64 65 70 63 28 24 64 65 70 29 0a 09 20 20 20 20 depc($dep)..
74e0: 23 20 43 68 65 63 6b 20 61 6c 6c 20 64 65 70 65 # Check all depe
74f0: 6e 64 65 6e 63 69 65 73 20 73 74 69 6c 6c 20 6b ndencies still k
7500: 6e 6f 77 6e 2c 20 74 61 6b 65 20 74 68 65 69 72 nown, take their
7510: 20 72 61 6e 67 65 20 61 6e 64 0a 09 20 20 20 20 range and..
7520: 23 20 73 65 65 20 69 66 20 74 68 65 20 62 72 65 # see if the bre
7530: 61 6b 20 6c 6f 63 61 74 69 6f 6e 20 66 61 6c 6c ak location fall
7540: 73 20 77 69 74 68 69 6e 2e 0a 0a 09 20 20 20 20 s within....
7550: 42 6f 72 64 65 72 20 24 72 61 6e 67 65 20 73 20 Border $range s
7560: 65 0a 09 20 20 20 20 69 66 20 7b 24 6c 6f 63 61 e.. if {$loca
7570: 74 69 6f 6e 20 3c 20 24 73 7d 20 63 6f 6e 74 69 tion < $s} conti
7580: 6e 75 65 20 3b 20 23 20 62 72 65 61 6b 20 62 65 nue ; # break be
7590: 66 6f 72 65 20 72 61 6e 67 65 2c 20 69 67 6e 6f fore range, igno
75a0: 72 65 0a 09 20 20 20 20 69 66 20 7b 24 6c 6f 63 re.. if {$loc
75b0: 61 74 69 6f 6e 20 3e 20 24 65 7d 20 63 6f 6e 74 ation > $e} cont
75c0: 69 6e 75 65 20 3b 20 23 20 62 72 65 61 6b 20 61 inue ; # break a
75d0: 66 74 65 72 20 72 61 6e 67 65 2c 20 69 67 6e 6f fter range, igno
75e0: 72 65 2e 0a 0a 09 20 20 20 20 23 20 54 68 69 73 re.... # This
75f0: 20 64 65 70 65 6e 64 65 6e 63 79 20 63 72 6f 73 dependency cros
7600: 73 65 73 20 74 68 65 20 62 72 65 61 6b 20 6c 6f ses the break lo
7610: 63 61 74 69 6f 6e 2e 20 57 65 20 72 65 6d 6f 76 cation. We remov
7620: 65 20 69 74 0a 09 20 20 20 20 23 20 66 72 6f 6d e it.. # from
7630: 20 74 68 65 20 63 72 6f 73 73 69 6e 67 73 20 63 the crossings c
7640: 6f 75 6e 74 65 72 73 2c 20 61 6e 64 20 74 68 65 ounters, and the
7650: 6e 20 61 6c 73 6f 20 66 72 6f 6d 20 74 68 65 20 n also from the
7660: 73 65 74 0a 09 20 20 20 20 23 20 6f 66 20 6b 6e set.. # of kn
7670: 6f 77 6e 20 64 65 70 65 6e 64 65 6e 63 69 65 73 own dependencies
7680: 2c 20 61 73 20 77 65 20 61 72 65 20 64 6f 6e 65 , as we are done
7690: 20 77 69 74 68 20 69 74 2e 0a 0a 09 20 20 20 20 with it....
76a0: 42 6f 72 64 65 72 20 24 64 65 70 63 28 24 64 65 Border $depc($de
76b0: 70 29 20 64 73 20 64 65 0a 09 20 20 20 20 66 6f p) ds de.. fo
76c0: 72 20 7b 73 65 74 20 6c 6f 63 20 24 64 73 7d 20 r {set loc $ds}
76d0: 7b 24 6c 6f 63 20 3c 3d 20 24 64 65 7d 20 7b 69 {$loc <= $de} {i
76e0: 6e 63 72 20 6c 6f 63 7d 20 7b 0a 09 09 69 6e 63 ncr loc} {...inc
76f0: 72 20 63 72 6f 73 73 28 24 6c 6f 63 29 20 2d 31 r cross($loc) -1
7700: 0a 09 20 20 20 20 7d 0a 09 20 20 20 20 75 6e 73 .. }.. uns
7710: 65 74 20 64 65 70 63 28 24 64 65 70 29 0a 0a 09 et depc($dep)...
7720: 20 20 20 20 69 66 20 7b 21 24 73 69 78 7d 20 63 if {!$six} c
7730: 6f 6e 74 69 6e 75 65 0a 0a 09 20 20 20 20 73 74 ontinue... st
7740: 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 67 ruct::list assig
7750: 6e 20 24 64 65 70 20 70 61 72 65 6e 74 20 63 68 n $dep parent ch
7760: 69 6c 64 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 ild.. log wri
7770: 74 65 20 35 20 63 73 65 74 73 20 22 42 72 6f 6b te 5 csets "Brok
7780: 65 20 64 65 70 65 6e 64 65 6e 63 79 20 5b 50 44 e dependency [PD
7790: 20 24 70 61 72 65 6e 74 5d 20 2d 2d 3e 20 5b 50 $parent] --> [P
77a0: 44 20 24 63 68 69 6c 64 5d 22 0a 09 7d 0a 0a 09 D $child]"..}...
77b0: 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 return. }..
77c0: 20 20 23 20 50 72 69 6e 74 20 69 64 65 6e 74 69 # Print identi
77d0: 66 79 69 6e 67 20 64 61 74 61 20 66 6f 72 20 61 fying data for a
77e0: 20 72 65 76 69 73 69 6f 6e 20 28 70 72 6f 6a 65 revision (proje
77f0: 63 74 2c 20 66 69 6c 65 2c 20 64 6f 74 74 65 64 ct, file, dotted
7800: 20 72 65 76 0a 20 20 20 20 23 20 6e 75 6d 62 65 rev. # numbe
7810: 72 29 2c 20 66 6f 72 20 68 69 67 68 20 76 65 72 r), for high ver
7820: 62 6f 73 69 74 79 20 6c 6f 67 20 6f 75 74 70 75 bosity log outpu
7830: 74 2e 0a 20 20 20 20 23 20 54 4f 44 4f 3a 20 52 t.. # TODO: R
7840: 65 70 6c 61 63 65 20 77 69 74 68 20 63 61 6c 6c eplace with call
7850: 20 74 6f 20 69 74 65 6d 73 74 72 20 28 6c 69 73 to itemstr (lis
7860: 74 20 72 65 76 20 24 69 64 29 0a 0a 20 20 20 20 t rev $id)..
7870: 70 72 6f 63 20 50 44 20 7b 69 64 7d 20 7b 0a 09 proc PD {id} {..
7880: 66 6f 72 65 61 63 68 20 7b 70 20 66 20 72 7d 20 foreach {p f r}
7890: 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a 09 09 53 [state run {...S
78a0: 45 4c 45 43 54 20 50 2e 6e 61 6d 65 20 2c 20 46 ELECT P.name , F
78b0: 2e 6e 61 6d 65 2c 20 52 2e 72 65 76 0a 09 09 46 .name, R.rev...F
78c0: 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 ROM revision R,
78d0: 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 file F, project
78e0: 50 0a 09 09 57 48 45 52 45 20 52 2e 72 69 64 20 P...WHERE R.rid
78f0: 3d 20 24 69 64 20 20 20 20 2d 2d 20 46 69 6e 64 = $id -- Find
7900: 20 73 70 65 63 69 66 69 65 64 20 66 69 6c 65 20 specified file
7910: 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e 44 20 20 revision...AND
7920: 20 46 2e 66 69 64 20 3d 20 52 2e 66 69 64 20 20 F.fid = R.fid
7930: 2d 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 74 -- Get file of t
7940: 68 65 20 72 65 76 69 73 69 6f 6e 0a 09 09 41 4e he revision...AN
7950: 44 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 69 D P.pid = F.pi
7960: 64 20 20 2d 2d 20 47 65 74 20 70 72 6f 6a 65 63 d -- Get projec
7970: 74 20 6f 66 20 74 68 65 20 66 69 6c 65 2e 0a 09 t of the file...
7980: 7d 5d 20 62 72 65 61 6b 0a 09 72 65 74 75 72 6e }] break..return
7990: 20 22 27 24 70 20 3a 20 24 66 2f 24 72 27 22 0a "'$p : $f/$r'".
79a0: 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 50 72 69 }.. # Pri
79b0: 6e 74 69 6e 67 20 6f 6e 65 20 6f 72 20 6d 6f 72 nting one or mor
79c0: 65 20 72 61 6e 67 65 73 2c 20 66 6f 72 6d 61 74 e ranges, format
79d0: 74 65 64 2c 20 61 6e 64 20 6f 6e 6c 79 20 74 68 ted, and only th
79e0: 65 69 72 20 62 6f 72 64 65 72 20 74 6f 0a 20 20 eir border to.
79f0: 20 20 23 20 6b 65 65 70 20 74 68 65 20 73 74 72 # keep the str
7a00: 69 6e 67 73 20 73 68 6f 72 74 2e 0a 0a 20 20 20 ings short...
7a10: 20 70 72 6f 63 20 50 52 73 20 7b 72 61 6e 67 65 proc PRs {range
7a20: 73 7d 20 7b 0a 09 72 65 74 75 72 6e 20 5b 73 74 s} {..return [st
7a30: 72 75 63 74 3a 3a 6c 69 73 74 20 6d 61 70 20 24 ruct::list map $
7a40: 72 61 6e 67 65 73 20 5b 6d 79 70 72 6f 63 20 50 ranges [myproc P
7a50: 52 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 R]]. }.. p
7a60: 72 6f 63 20 50 52 20 7b 72 61 6e 67 65 7d 20 7b roc PR {range} {
7a70: 0a 09 42 6f 72 64 65 72 20 24 72 61 6e 67 65 20 ..Border $range
7a80: 73 20 65 0a 09 72 65 74 75 72 6e 20 3c 24 7b 73 s e..return <${s
7a90: 7d 2e 2e 2e 24 7b 65 7d 3e 0a 20 20 20 20 7d 0a }...${e}>. }.
7aa0: 0a 20 20 20 20 70 72 6f 63 20 42 6f 72 64 65 72 . proc Border
7ab0: 20 7b 72 61 6e 67 65 20 73 76 20 65 76 7d 20 7b {range sv ev} {
7ac0: 0a 09 75 70 76 61 72 20 31 20 24 73 76 20 73 20 ..upvar 1 $sv s
7ad0: 24 65 76 20 65 0a 09 73 65 74 20 73 20 5b 6c 69 $ev e..set s [li
7ae0: 6e 64 65 78 20 24 72 61 6e 67 65 20 30 5d 0a 09 ndex $range 0]..
7af0: 73 65 74 20 65 20 5b 6c 69 6e 64 65 78 20 24 72 set e [lindex $r
7b00: 61 6e 67 65 20 65 6e 64 5d 0a 09 72 65 74 75 72 ange end]..retur
7b10: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 n. }.. # #
7b20: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 ## ### ##### ##
7b30: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
7b40: 23 23 23 23 0a 0a 20 20 20 20 70 72 6f 63 20 55 ####.. proc U
7b50: 6e 6d 61 70 49 74 65 6d 73 20 7b 74 68 65 74 79 nmapItems {thety
7b60: 70 65 20 74 68 65 69 74 65 6d 73 7d 20 7b 0a 09 pe theitems} {..
7b70: 23 20 28 2a 29 20 57 65 20 63 6c 65 61 72 20 6f # (*) We clear o
7b80: 75 74 20 74 68 65 20 61 73 73 6f 63 69 61 74 65 ut the associate
7b90: 64 20 70 61 72 74 20 6f 66 20 74 68 65 20 6d 79 d part of the my
7ba0: 69 74 65 6d 6d 61 70 0a 09 23 20 69 6e 2d 6d 65 itemmap..# in-me
7bb0: 6d 6f 72 79 20 69 6e 64 65 78 20 69 6e 20 70 72 mory index in pr
7bc0: 65 70 61 72 61 74 69 6f 6e 20 66 6f 72 20 6e 65 eparation for ne
7bd0: 77 20 64 61 74 61 2c 20 6f 72 20 61 73 20 70 61 w data, or as pa
7be0: 72 74 20 6f 66 0a 09 23 20 6f 62 6a 65 63 74 20 rt of..# object
7bf0: 64 65 73 74 72 75 63 74 69 6f 6e 2e 20 41 20 73 destruction. A s
7c00: 69 6d 70 6c 65 20 75 6e 73 65 74 20 69 73 20 65 imple unset is e
7c10: 6e 6f 75 67 68 2c 20 77 65 20 68 61 76 65 20 6e nough, we have n
7c20: 6f 0a 09 23 20 73 79 6d 62 6f 6c 20 63 68 61 6e o..# symbol chan
7c30: 67 65 73 65 74 73 20 61 74 20 74 68 69 73 20 74 gesets at this t
7c40: 69 6d 65 2c 20 61 6e 64 20 74 68 75 73 20 6e 65 ime, and thus ne
7c50: 76 65 72 20 6d 6f 72 65 20 74 68 61 6e 20 6f 6e ver more than on
7c60: 65 0a 09 23 20 72 65 66 65 72 65 6e 63 65 20 69 e..# reference i
7c70: 6e 20 74 68 65 20 6c 69 73 74 2e 0a 0a 09 75 70 n the list....up
7c80: 76 61 72 20 31 20 6d 79 69 74 65 6d 6d 61 70 20 var 1 myitemmap
7c90: 6d 79 69 74 65 6d 6d 61 70 20 73 65 6c 66 20 73 myitemmap self s
7ca0: 65 6c 66 0a 09 66 6f 72 65 61 63 68 20 69 69 64 elf..foreach iid
7cb0: 20 24 74 68 65 69 74 65 6d 73 20 7b 0a 09 20 20 $theitems {..
7cc0: 20 20 73 65 74 20 6b 65 79 20 5b 6c 69 73 74 20 set key [list
7cd0: 24 74 68 65 74 79 70 65 20 24 69 69 64 5d 0a 09 $thetype $iid]..
7ce0: 20 20 20 20 75 6e 73 65 74 20 6d 79 69 74 65 6d unset myitem
7cf0: 6d 61 70 28 24 6b 65 79 29 0a 09 20 20 20 20 6c map($key).. l
7d00: 6f 67 20 77 72 69 74 65 20 38 20 63 73 65 74 73 og write 8 csets
7d10: 20 7b 4d 41 50 2d 20 69 74 65 6d 20 3c 24 6b 65 {MAP- item <$ke
7d20: 79 3e 20 24 73 65 6c 66 20 3d 20 5b 24 73 65 6c y> $self = [$sel
7d30: 66 20 73 74 72 5d 7d 0a 09 7d 0a 09 72 65 74 75 f str]}..}..retu
7d40: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 70 72 rn. }.. pr
7d50: 6f 63 20 4d 61 70 49 74 65 6d 73 20 7b 74 68 65 oc MapItems {the
7d60: 74 79 70 65 20 74 68 65 69 74 65 6d 73 7d 20 7b type theitems} {
7d70: 0a 09 75 70 76 61 72 20 31 20 6d 79 69 74 65 6d ..upvar 1 myitem
7d80: 6d 61 70 20 6d 79 69 74 65 6d 6d 61 70 20 73 65 map myitemmap se
7d90: 6c 66 20 73 65 6c 66 0a 0a 09 66 6f 72 65 61 63 lf self...foreac
7da0: 68 20 69 69 64 20 24 74 68 65 69 74 65 6d 73 20 h iid $theitems
7db0: 7b 0a 09 20 20 20 20 73 65 74 20 6b 65 79 20 5b {.. set key [
7dc0: 6c 69 73 74 20 24 74 68 65 74 79 70 65 20 24 69 list $thetype $i
7dd0: 69 64 5d 0a 09 20 20 20 20 73 65 74 20 6d 79 69 id].. set myi
7de0: 74 65 6d 6d 61 70 28 24 6b 65 79 29 20 24 73 65 temmap($key) $se
7df0: 6c 66 0a 09 20 20 20 20 6c 6f 67 20 77 72 69 74 lf.. log writ
7e00: 65 20 38 20 63 73 65 74 73 20 7b 4d 41 50 2b 20 e 8 csets {MAP+
7e10: 69 74 65 6d 20 3c 24 6b 65 79 3e 20 24 73 65 6c item <$key> $sel
7e20: 66 20 3d 20 5b 24 73 65 6c 66 20 73 74 72 5d 7d f = [$self str]}
7e30: 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 ..}..return.
7e40: 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 }.. # # ## ##
7e50: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 # ##### ########
7e60: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a #############..
7e70: 20 20 20 20 74 79 70 65 76 61 72 69 61 62 6c 65 typevariable
7e80: 20 6d 79 63 68 61 6e 67 65 73 65 74 73 20 20 20 mychangesets
7e90: 20 20 20 20 20 20 7b 7d 20 3b 20 23 20 4c 69 73 {} ; # Lis
7ea0: 74 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 0a 09 t of all known..
7eb0: 09 09 09 09 20 20 20 23 20 63 68 61 6e 67 65 73 .... # changes
7ec0: 65 74 73 2e 0a 0a 20 20 20 20 23 20 4c 69 73 74 ets... # List
7ed0: 20 6f 66 20 61 6c 6c 20 6b 6e 6f 77 6e 20 63 68 of all known ch
7ee0: 61 6e 67 65 73 65 74 73 20 6f 66 20 61 20 74 79 angesets of a ty
7ef0: 70 65 2e 0a 20 20 20 20 74 79 70 65 76 61 72 69 pe.. typevari
7f00: 61 62 6c 65 20 6d 79 74 63 68 61 6e 67 65 73 65 able mytchangese
7f10: 74 73 20 2d 61 72 72 61 79 20 7b 0a 09 73 79 6d ts -array {..sym
7f20: 3a 3a 62 72 61 6e 63 68 20 7b 7d 0a 09 73 79 6d ::branch {}..sym
7f30: 3a 3a 74 61 67 20 20 20 20 7b 7d 0a 09 72 65 76 ::tag {}..rev
7f40: 20 20 20 20 20 20 20 20 20 7b 7d 0a 20 20 20 20 {}.
7f50: 7d 0a 09 09 09 09 09 0a 20 20 20 20 74 79 70 65 }....... type
7f60: 76 61 72 69 61 62 6c 65 20 6d 79 69 74 65 6d 6d variable myitemm
7f70: 61 70 20 20 20 20 20 2d 61 72 72 61 79 20 7b 7d ap -array {}
7f80: 20 3b 20 23 20 4d 61 70 20 66 72 6f 6d 20 69 74 ; # Map from it
7f90: 65 6d 73 20 28 74 61 67 67 65 64 29 0a 09 09 09 ems (tagged)....
7fa0: 09 09 20 20 20 23 20 74 6f 20 74 68 65 20 6c 69 .. # to the li
7fb0: 73 74 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73 st of changesets
7fc0: 0a 09 09 09 09 09 20 20 20 23 20 63 6f 6e 74 61 ...... # conta
7fd0: 69 6e 69 6e 67 20 69 74 2e 20 45 61 63 68 20 69 ining it. Each i
7fe0: 74 65 6d 0a 09 09 09 09 09 20 20 20 23 20 63 61 tem...... # ca
7ff0: 6e 20 62 65 20 75 73 65 64 20 62 79 20 6f 6e 6c n be used by onl
8000: 79 20 6f 6e 65 0a 09 09 09 09 09 20 20 20 23 20 y one...... #
8010: 63 68 61 6e 67 65 73 65 74 2e 0a 20 20 20 20 74 changeset.. t
8020: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 69 64 ypevariable myid
8030: 6d 61 70 20 20 20 2d 61 72 72 61 79 20 7b 7d 20 map -array {}
8040: 3b 20 23 20 4d 61 70 20 66 72 6f 6d 20 63 68 61 ; # Map from cha
8050: 6e 67 65 73 65 74 20 69 64 20 74 6f 0a 09 09 09 ngeset id to....
8060: 09 20 20 20 20 20 20 20 23 20 63 68 61 6e 67 65 . # change
8070: 73 65 74 2e 0a 0a 20 20 20 20 74 79 70 65 6d 65 set... typeme
8080: 74 68 6f 64 20 61 6c 6c 20 20 20 20 7b 7d 20 20 thod all {}
8090: 20 20 7b 20 72 65 74 75 72 6e 20 24 6d 79 63 68 { return $mych
80a0: 61 6e 67 65 73 65 74 73 20 7d 0a 20 20 20 20 74 angesets }. t
80b0: 79 70 65 6d 65 74 68 6f 64 20 6f 66 20 20 20 20 ypemethod of
80c0: 20 7b 63 69 64 7d 20 7b 20 72 65 74 75 72 6e 20 {cid} { return
80d0: 24 6d 79 69 64 6d 61 70 28 24 63 69 64 29 20 7d $myidmap($cid) }
80e0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
80f0: 6f 66 69 74 65 6d 20 7b 69 69 64 7d 20 7b 20 72 ofitem {iid} { r
8100: 65 74 75 72 6e 20 24 6d 79 69 74 65 6d 6d 61 70 eturn $myitemmap
8110: 28 24 69 69 64 29 20 7d 0a 0a 20 20 20 20 74 79 ($iid) }.. ty
8120: 70 65 6d 65 74 68 6f 64 20 72 65 76 20 20 20 20 pemethod rev
8130: 7b 7d 20 20 20 20 7b 20 72 65 74 75 72 6e 20 24 {} { return $
8140: 6d 79 74 63 68 61 6e 67 65 73 65 74 73 28 72 65 mytchangesets(re
8150: 76 29 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 v) }. typemet
8160: 68 6f 64 20 73 79 6d 20 20 20 20 7b 7d 20 20 20 hod sym {}
8170: 20 7b 20 72 65 74 75 72 6e 20 5b 63 6f 6e 63 61 { return [conca
8180: 74 20 5c 0a 09 09 09 09 09 20 20 24 7b 6d 79 74 t \...... ${myt
8190: 63 68 61 6e 67 65 73 65 74 73 28 73 79 6d 3a 3a changesets(sym::
81a0: 62 72 61 6e 63 68 29 7d 20 5c 0a 09 09 09 09 09 branch)} \......
81b0: 20 20 24 7b 6d 79 74 63 68 61 6e 67 65 73 65 74 ${mytchangeset
81c0: 73 28 73 79 6d 3a 3a 74 61 67 29 7d 5d 20 7d 0a s(sym::tag)}] }.
81d0: 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 20 . # # ## ###
81e0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 ##### ######## #
81f0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 ############.
8200: 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74 69 6f ## Configuratio
8210: 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 n.. pragma -h
8220: 61 73 74 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f astypeinfo no
8230: 20 20 3b 20 23 20 6e 6f 20 74 79 70 65 20 69 6e ; # no type in
8240: 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 trospection.
8250: 70 72 61 67 6d 61 20 2d 68 61 73 69 6e 66 6f 20 pragma -hasinfo
8260: 20 20 20 20 20 20 20 6e 6f 20 20 3b 20 23 20 6e no ; # n
8270: 6f 20 6f 62 6a 65 63 74 20 69 6e 74 72 6f 73 70 o object introsp
8280: 65 63 74 69 6f 6e 0a 0a 20 20 20 20 23 20 23 20 ection.. # #
8290: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
82a0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
82b0: 23 23 23 0a 7d 0a 0a 23 23 0a 23 23 20 4e 4f 54 ###.}..##.## NOT
82c0: 45 3a 20 54 68 65 20 73 75 63 63 65 73 73 6f 72 E: The successor
82d0: 20 61 6e 64 20 70 72 65 64 65 63 65 73 73 6f 72 and predecessor
82e0: 20 6d 65 74 68 6f 64 73 20 64 65 66 69 6e 65 64 methods defined
82f0: 20 62 79 20 74 68 65 20 63 6c 61 73 73 65 73 0a by the classes.
8300: 23 23 20 20 20 20 20 20 20 62 65 6c 6f 77 20 61 ## below a
8310: 72 65 20 2d 2d 20 62 6f 74 74 6c 65 20 6e 65 63 re -- bottle nec
8320: 6b 73 20 2d 2d 2e 20 4c 6f 6f 6b 20 66 6f 72 20 ks --. Look for
8330: 77 61 79 73 20 74 6f 20 6d 61 6b 65 20 74 68 65 ways to make the
8340: 20 53 51 4c 0a 23 23 20 20 20 20 20 20 20 66 61 SQL.## fa
8350: 73 74 65 72 2e 0a 23 23 0a 0a 23 20 23 20 23 23 ster..##..# # ##
8360: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
8370: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
8380: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 # ##############
8390: 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65 #######.## Helpe
83a0: 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d r singleton. Com
83b0: 6d 61 6e 64 73 20 66 6f 72 20 72 65 76 69 73 69 mands for revisi
83c0: 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 2e 0a 0a on changesets...
83d0: 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 3a snit::type ::vc:
83e0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a :fossil::import:
83f0: 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 :cvs::project::r
8400: 65 76 3a 3a 72 65 76 20 7b 0a 20 20 20 20 74 79 ev::rev {. ty
8410: 70 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 73 pemethod byrevis
8420: 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 ion {} { return
8430: 31 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 68 1 }. typemeth
8440: 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d od bysymbol {}
8450: 20 7b 20 72 65 74 75 72 6e 20 30 20 7d 0a 20 20 { return 0 }.
8460: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 74 typemethod ist
8470: 61 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 ag {} { ret
8480: 75 72 6e 20 30 20 7d 0a 20 20 20 20 74 79 70 65 urn 0 }. type
8490: 6d 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 20 method isbranch
84a0: 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 {} { return 0
84b0: 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f }.. typemetho
84c0: 64 20 73 74 72 20 7b 72 65 76 69 73 69 6f 6e 7d d str {revision}
84d0: 20 7b 0a 09 73 74 72 75 63 74 3a 3a 6c 69 73 74 {..struct::list
84e0: 20 61 73 73 69 67 6e 20 5b 73 74 61 74 65 20 72 assign [state r
84f0: 75 6e 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 un {.. SELECT
8500: 20 52 2e 72 65 76 2c 20 46 2e 6e 61 6d 65 2c 20 R.rev, F.name,
8510: 50 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d P.name.. FROM
8520: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 66 revision R, f
8530: 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 20 50 ile F, project P
8540: 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 .. WHERE R.r
8550: 69 64 20 3d 20 24 72 65 76 69 73 69 6f 6e 20 2d id = $revision -
8560: 2d 20 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 - Find specified
8570: 20 66 69 6c 65 20 72 65 76 69 73 69 6f 6e 0a 09 file revision..
8580: 20 20 20 20 41 4e 44 20 20 20 20 46 2e 66 69 64 AND F.fid
8590: 20 3d 20 52 2e 66 69 64 20 20 20 20 20 2d 2d 20 = R.fid --
85a0: 47 65 74 20 66 69 6c 65 20 6f 66 20 74 68 65 20 Get file of the
85b0: 72 65 76 69 73 69 6f 6e 0a 09 20 20 20 20 41 4e revision.. AN
85c0: 44 20 20 20 20 50 2e 70 69 64 20 3d 20 46 2e 70 D P.pid = F.p
85d0: 69 64 20 20 20 20 20 2d 2d 20 47 65 74 20 70 72 id -- Get pr
85e0: 6f 6a 65 63 74 20 6f 66 20 74 68 65 20 66 69 6c oject of the fil
85f0: 65 2e 0a 09 7d 5d 20 72 65 76 6e 72 20 66 6e 61 e...}] revnr fna
8600: 6d 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 6e me pname..return
8610: 20 22 24 70 6e 61 6d 65 2f 24 7b 72 65 76 6e 72 "$pname/${revnr
8620: 7d 3a 3a 24 66 6e 61 6d 65 22 0a 20 20 20 20 7d }::$fname". }
8630: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d .. # result =
8640: 20 6c 69 73 74 20 28 6d 69 6e 74 69 6d 65 2c 20 list (mintime,
8650: 6d 61 78 74 69 6d 65 29 0a 20 20 20 20 74 79 70 maxtime). typ
8660: 65 6d 65 74 68 6f 64 20 74 69 6d 65 72 61 6e 67 emethod timerang
8670: 65 20 7b 69 74 65 6d 73 7d 20 7b 0a 09 73 65 74 e {items} {..set
8680: 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 theset ('[join
8690: 24 69 74 65 6d 73 20 7b 27 2c 27 7d 5d 27 29 0a $items {','}]').
86a0: 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 .return [state r
86b0: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d un [subst -nocom
86c0: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
86d0: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 shes {.. SELE
86e0: 43 54 20 4d 49 4e 28 52 2e 64 61 74 65 29 2c 20 CT MIN(R.date),
86f0: 4d 41 58 28 52 2e 64 61 74 65 29 0a 09 20 20 20 MAX(R.date)..
8700: 20 46 52 4f 4d 20 72 65 76 69 73 69 6f 6e 20 52 FROM revision R
8710: 0a 09 20 20 20 20 57 48 45 52 45 20 52 2e 72 69 .. WHERE R.ri
8720: 64 20 49 4e 20 24 74 68 65 73 65 74 20 2d 2d 20 d IN $theset --
8730: 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 Restrict to revi
8740: 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 sions of interes
8750: 74 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 t..}]]. }..
8760: 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 # var(dv) = di
8770: 63 74 20 28 72 65 76 69 73 69 6f 6e 20 2d 3e 20 ct (revision ->
8780: 6c 69 73 74 20 28 72 65 76 69 73 69 6f 6e 29 29 list (revision))
8790: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
87a0: 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f internalsuccesso
87b0: 72 73 20 7b 64 76 20 72 65 76 69 73 69 6f 6e 73 rs {dv revisions
87c0: 7d 20 7b 0a 09 75 70 76 61 72 20 31 20 24 64 76 } {..upvar 1 $dv
87d0: 20 64 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 73 dependencies..s
87e0: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 et theset ('[joi
87f0: 6e 20 24 72 65 76 69 73 69 6f 6e 73 20 7b 27 2c n $revisions {',
8800: 27 7d 5d 27 29 0a 0a 09 6c 6f 67 20 77 72 69 74 '}]')...log writ
8810: 65 20 31 34 20 63 73 65 74 73 20 69 6e 74 65 72 e 14 csets inter
8820: 6e 61 6c 73 75 63 63 65 73 73 6f 72 73 0a 0a 09 nalsuccessors...
8830: 23 20 53 65 65 20 27 73 75 63 63 65 73 73 6f 72 # See 'successor
8840: 73 27 20 62 65 6c 6f 77 20 66 6f 72 20 74 68 65 s' below for the
8850: 20 6d 61 69 6e 20 65 78 70 6c 61 6e 61 74 69 6f main explanatio
8860: 6e 20 6f 66 0a 09 23 20 74 68 65 20 76 61 72 69 n of..# the vari
8870: 6f 75 73 20 63 61 73 65 73 2e 20 54 68 69 73 20 ous cases. This
8880: 70 69 65 63 65 20 69 73 20 73 70 65 63 69 61 6c piece is special
8890: 20 69 6e 20 74 68 61 74 20 69 74 0a 09 23 20 72 in that it..# r
88a0: 65 73 74 72 69 63 74 73 20 74 68 65 20 73 75 63 estricts the suc
88b0: 63 65 73 73 6f 72 73 20 77 65 20 6c 6f 6f 6b 20 cessors we look
88c0: 66 6f 72 20 74 6f 20 74 68 65 20 73 61 6d 65 20 for to the same
88d0: 73 65 74 20 6f 66 0a 09 23 20 72 65 76 69 73 69 set of..# revisi
88e0: 6f 6e 73 20 77 65 20 73 74 61 72 74 20 66 72 6f ons we start fro
88f0: 6d 2e 20 53 65 6e 73 69 62 6c 65 20 61 73 20 77 m. Sensible as w
8900: 65 20 61 72 65 20 6c 6f 6f 6b 69 6e 67 20 66 6f e are looking fo
8910: 72 0a 09 23 20 63 68 61 6e 67 65 73 65 74 20 69 r..# changeset i
8920: 6e 74 65 72 6e 61 6c 20 64 65 70 65 6e 64 65 6e nternal dependen
8930: 63 69 65 73 2e 0a 0a 09 61 72 72 61 79 20 73 65 cies....array se
8940: 74 20 64 65 70 20 7b 7d 0a 0a 09 73 74 61 74 65 t dep {}...state
8950: 20 66 6f 72 65 61 63 68 72 6f 77 20 5b 73 75 62 foreachrow [sub
8960: 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d st -nocommands -
8970: 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a nobackslashes {.
8980: 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d 61 -- (1) Prima
8990: 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53 45 ry child.. SE
89a0: 4c 45 43 54 20 52 2e 72 69 64 20 41 53 20 78 72 LECT R.rid AS xr
89b0: 69 64 2c 20 52 2e 63 68 69 6c 64 20 41 53 20 78 id, R.child AS x
89c0: 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 child.. FROM
89d0: 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 20 20 revision R..
89e0: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 WHERE R.rid
89f0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 IN $theset
8a00: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 -- Restrict to r
8a10: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 evisions of inte
8a20: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 rest.. AND
8a30: 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 R.child IS NOT
8a40: 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 NULL -- Has p
8a50: 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20 rimary child..
8a60: 20 20 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 AND R.child
8a70: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 IN $theset
8a80: 2d 2d 20 57 68 69 63 68 20 69 73 20 61 6c 73 6f -- Which is also
8a90: 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20 20 of interest.
8aa0: 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 32 UNION. -- (2
8ab0: 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 72 61 ) Secondary (bra
8ac0: 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a 09 20 nch) children..
8ad0: 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 20 SELECT R.rid
8ae0: 41 53 20 78 72 69 64 2c 20 42 2e 62 72 69 64 20 AS xrid, B.brid
8af0: 41 53 20 78 63 68 69 6c 64 0a 09 20 20 20 20 46 AS xchild.. F
8b00: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 ROM revision R
8b10: 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e 63 68 , revisionbranch
8b20: 63 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 20 20 children B..
8b30: 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 WHERE R.rid I
8b40: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d N $theset --
8b50: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 Restrict to rev
8b60: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 isions of intere
8b70: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 st.. AND R
8b80: 2e 72 69 64 20 3d 20 42 2e 72 69 64 20 20 20 20 .rid = B.rid
8b90: 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 -- Select
8ba0: 73 75 62 73 65 74 20 6f 66 20 62 72 61 6e 63 68 subset of branch
8bb0: 20 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 41 children.. A
8bc0: 4e 44 20 20 20 20 42 2e 62 72 69 64 20 49 4e 20 ND B.brid IN
8bd0: 24 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 $theset --
8be0: 57 68 69 63 68 20 69 73 20 61 6c 73 6f 20 6f 66 Which is also of
8bf0: 20 69 6e 74 65 72 65 73 74 0a 20 20 20 20 55 4e interest. UN
8c00: 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 20 43 ION. -- (4) C
8c10: 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f hild of trunk ro
8c20: 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 ot successor of
8c30: 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 last NTDB on tru
8c40: 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 nk... SELECT
8c50: 52 2e 72 69 64 20 41 53 20 78 72 69 64 2c 20 52 R.rid AS xrid, R
8c60: 41 2e 63 68 69 6c 64 20 41 53 20 78 63 68 69 6c A.child AS xchil
8c70: 64 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 76 69 d.. FROM revi
8c80: 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e sion R, revision
8c90: 20 52 41 0a 09 20 20 20 20 57 48 45 52 45 20 52 RA.. WHERE R
8ca0: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 .rid IN $these
8cb0: 74 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 t -- Restri
8cc0: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 ct to revisions
8cd0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
8ce0: 20 41 4e 44 20 20 20 52 2e 69 73 64 65 66 61 75 AND R.isdefau
8cf0: 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d lt -
8d00: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 - Restrict to NT
8d10: 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 52 2e DB.. AND R.
8d20: 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e dbchild IS NOT N
8d30: 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 73 ULL -- and las
8d40: 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e 67 t NTDB belonging
8d50: 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 41 to trunk.. A
8d60: 4e 44 20 20 20 52 41 2e 72 69 64 20 3d 20 52 2e ND RA.rid = R.
8d70: 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d 2d 20 dbchild --
8d80: 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f 20 74 Go directly to t
8d90: 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 20 41 runk root.. A
8da0: 4e 44 20 20 20 52 41 2e 63 68 69 6c 64 20 49 53 ND RA.child IS
8db0: 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 NOT NULL --
8dc0: 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 6c Has primary chil
8dd0: 64 2e 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 d.. A
8de0: 4e 44 20 20 20 52 41 2e 63 68 69 6c 64 20 49 4e ND RA.child IN
8df0: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 $theset --
8e00: 57 68 69 63 68 20 69 73 20 61 6c 73 6f 20 6f 66 Which is also of
8e10: 20 69 6e 74 65 72 65 73 74 0a 09 7d 5d 20 7b 0a interest..}] {.
8e20: 09 20 20 20 20 23 20 43 6f 6e 73 69 64 65 72 20 . # Consider
8e30: 6d 6f 76 69 6e 67 20 74 68 69 73 20 74 6f 20 74 moving this to t
8e40: 68 65 20 69 6e 74 65 67 72 69 74 79 20 6d 6f 64 he integrity mod
8e50: 75 6c 65 2e 0a 09 20 20 20 20 69 6e 74 65 67 72 ule... integr
8e60: 69 74 79 20 61 73 73 65 72 74 20 7b 24 78 72 69 ity assert {$xri
8e70: 64 20 21 3d 20 24 78 63 68 69 6c 64 7d 20 7b 52 d != $xchild} {R
8e80: 65 76 69 73 69 6f 6e 20 24 78 72 69 64 20 64 65 evision $xrid de
8e90: 70 65 6e 64 73 20 6f 6e 20 69 74 73 65 6c 66 2e pends on itself.
8ea0: 7d 0a 09 20 20 20 20 6c 61 70 70 65 6e 64 20 64 }.. lappend d
8eb0: 65 70 65 6e 64 65 6e 63 69 65 73 28 24 78 72 69 ependencies($xri
8ec0: 64 29 20 24 78 63 68 69 6c 64 0a 09 20 20 20 20 d) $xchild..
8ed0: 73 65 74 20 64 65 70 28 24 78 72 69 64 2c 24 78 set dep($xrid,$x
8ee0: 63 68 69 6c 64 29 20 2e 0a 09 7d 0a 0a 09 23 20 child) ...}...#
8ef0: 54 68 65 20 73 71 6c 20 73 74 61 74 65 6d 65 6e The sql statemen
8f00: 74 73 20 61 62 6f 76 65 20 6c 6f 6f 6b 73 20 6f ts above looks o
8f10: 6e 6c 79 20 66 6f 72 20 64 69 72 65 63 74 20 64 nly for direct d
8f20: 65 70 65 6e 64 65 6e 63 69 65 73 0a 09 23 20 62 ependencies..# b
8f30: 65 74 77 65 65 6e 20 72 65 76 69 73 69 6f 6e 20 etween revision
8f40: 69 6e 20 74 68 65 20 63 68 61 6e 67 65 73 65 74 in the changeset
8f50: 2e 20 48 6f 77 65 76 65 72 20 64 75 65 20 74 6f . However due to
8f60: 20 74 68 65 0a 09 23 20 76 61 67 61 72 69 65 73 the..# vagaries
8f70: 20 6f 66 20 6d 65 74 61 20 64 61 74 61 20 69 74 of meta data it
8f80: 20 69 73 20 70 6f 73 73 69 62 6c 65 20 66 6f 72 is possible for
8f90: 20 74 77 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f two revisions o
8fa0: 66 0a 09 23 20 74 68 65 20 73 61 6d 65 20 66 69 f..# the same fi
8fb0: 6c 65 20 74 6f 20 65 6e 64 20 75 70 20 69 6e 20 le to end up in
8fc0: 74 68 65 20 73 61 6d 65 20 63 68 61 6e 67 65 73 the same changes
8fd0: 65 74 2c 20 77 69 74 68 6f 75 74 20 61 0a 09 23 et, without a..#
8fe0: 20 64 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e direct dependen
8ff0: 63 79 20 62 65 74 77 65 65 6e 20 74 68 65 6d 2e cy between them.
9000: 20 48 6f 77 65 76 65 72 20 77 65 20 6b 6e 6f 77 However we know
9010: 20 74 68 61 74 20 74 68 65 72 65 0a 09 23 20 68 that there..# h
9020: 61 73 20 74 6f 20 62 65 20 61 20 61 6e 20 69 6e as to be a an in
9030: 64 69 72 65 63 74 20 64 65 70 65 6e 64 65 6e 63 direct dependenc
9040: 79 2c 20 62 65 20 69 74 20 74 68 72 6f 75 67 68 y, be it through
9050: 20 70 72 69 6d 61 72 79 0a 09 23 20 63 68 69 6c primary..# chil
9060: 64 72 65 6e 2c 20 62 72 61 6e 63 68 20 63 68 69 dren, branch chi
9070: 6c 64 72 65 6e 2c 20 6f 72 20 61 20 63 6f 6d 62 ldren, or a comb
9080: 69 6e 61 74 69 6f 6e 20 74 68 65 72 65 6f 66 2e ination thereof.
9090: 0a 0a 09 23 20 57 65 20 6e 6f 77 20 66 69 6c 6c ...# We now fill
90a0: 20 69 6e 20 74 68 65 73 65 20 70 73 65 75 64 6f in these pseudo
90b0: 2d 64 65 70 65 6e 64 65 6e 63 69 65 73 2c 20 69 -dependencies, i
90c0: 66 20 6e 6f 20 73 75 63 68 0a 09 23 20 64 65 70 f no such..# dep
90d0: 65 6e 64 65 6e 63 79 20 65 78 69 73 74 73 20 61 endency exists a
90e0: 6c 72 65 61 64 79 2e 20 54 68 65 20 64 69 72 65 lready. The dire
90f0: 63 74 69 6f 6e 20 6f 66 20 74 68 65 20 64 65 70 ction of the dep
9100: 65 6e 64 65 6e 63 79 0a 09 23 20 69 73 20 61 63 endency..# is ac
9110: 74 75 61 6c 6c 79 20 69 72 72 65 6c 65 76 61 6e tually irrelevan
9120: 74 20 66 6f 72 20 74 68 69 73 2e 0a 0a 09 23 20 t for this....#
9130: 4e 4f 54 45 3a 20 54 68 69 73 20 69 73 20 64 69 NOTE: This is di
9140: 66 66 65 72 65 6e 74 20 66 72 6f 6d 20 63 76 73 fferent from cvs
9150: 32 73 76 6e 2e 20 4f 75 72 20 73 70 69 72 69 74 2svn. Our spirit
9160: 75 61 6c 20 61 6e 63 65 73 74 6f 72 0a 09 23 20 ual ancestor..#
9170: 64 6f 65 73 20 6e 6f 74 20 75 73 65 20 73 75 63 does not use suc
9180: 68 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 h pseudo-depende
9190: 6e 63 69 65 73 2c 20 68 6f 77 65 76 65 72 20 69 ncies, however i
91a0: 74 20 75 73 65 73 20 61 0a 09 23 20 43 4f 4d 4d t uses a..# COMM
91b0: 49 54 5f 54 48 52 45 53 48 4f 4c 44 2c 20 61 20 IT_THRESHOLD, a
91c0: 74 69 6d 65 20 69 6e 74 65 72 76 61 6c 20 63 6f time interval co
91d0: 6d 6d 69 74 73 20 73 68 6f 75 6c 64 20 66 61 6c mmits should fal
91e0: 6c 2e 20 54 68 69 73 0a 09 23 20 77 69 6c 6c 20 l. This..# will
91f0: 67 72 65 61 74 6c 79 20 72 65 64 75 63 65 73 20 greatly reduces
9200: 74 68 65 20 72 69 73 6b 20 6f 66 20 67 65 74 74 the risk of gett
9210: 69 6e 67 20 66 61 72 20 73 65 70 61 72 61 74 65 ing far separate
9220: 64 0a 09 23 20 72 65 76 69 73 69 6f 6e 73 20 6f d..# revisions o
9230: 66 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 20 f the same file
9240: 69 6e 74 6f 20 6f 6e 65 20 63 68 61 6e 67 65 73 into one changes
9250: 65 74 2e 0a 0a 09 23 20 57 65 20 61 6c 6c 6f 77 et....# We allow
9260: 20 72 65 76 69 73 69 6f 6e 73 20 74 6f 20 62 65 revisions to be
9270: 20 66 61 72 20 61 70 61 72 74 20 69 6e 20 74 69 far apart in ti
9280: 6d 65 20 69 6e 20 74 68 65 20 73 61 6d 65 0a 09 me in the same..
9290: 23 20 63 68 61 6e 67 65 73 65 74 2c 20 62 75 74 # changeset, but
92a0: 20 69 6e 20 74 75 72 6e 20 6e 65 65 64 20 74 68 in turn need th
92b0: 65 20 70 73 65 75 64 6f 2d 64 65 70 65 6e 64 65 e pseudo-depende
92c0: 6e 63 69 65 73 20 74 6f 0a 09 23 20 68 61 6e 64 ncies to..# hand
92d0: 6c 65 20 74 68 69 73 2e 0a 0a 09 6c 6f 67 20 77 le this....log w
92e0: 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b 69 rite 14 csets {i
92f0: 6e 74 65 72 6e 61 6c 20 20 5b 61 72 72 61 79 20 nternal [array
9300: 73 69 7a 65 20 64 65 70 5d 7d 0a 09 6c 6f 67 20 size dep]}..log
9310: 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b write 14 csets {
9320: 63 6f 6c 6c 65 63 74 65 64 20 5b 61 72 72 61 79 collected [array
9330: 20 73 69 7a 65 20 64 65 70 65 6e 64 65 6e 63 69 size dependenci
9340: 65 73 5d 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 es]}..log write
9350: 31 34 20 63 73 65 74 73 20 70 73 65 75 64 6f 2d 14 csets pseudo-
9360: 69 6e 74 65 72 6e 61 6c 73 75 63 63 65 73 73 6f internalsuccesso
9370: 72 73 0a 0a 09 61 72 72 61 79 20 73 65 74 20 66 rs...array set f
9380: 69 64 73 20 7b 7d 0a 09 73 74 61 74 65 20 66 6f ids {}..state fo
9390: 72 65 61 63 68 72 6f 77 20 5b 73 75 62 73 74 20 reachrow [subst
93a0: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 -nocommands -nob
93b0: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 ackslashes {..
93c0: 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 20 41 SELECT R.rid A
93d0: 53 20 78 72 69 64 2c 20 52 2e 66 69 64 20 41 53 S xrid, R.fid AS
93e0: 20 78 66 69 64 0a 20 20 20 20 20 20 20 20 20 20 xfid.
93f0: 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f FROM revisio
9400: 6e 20 52 0a 20 20 20 20 20 20 20 20 20 20 20 20 n R.
9410: 57 48 45 52 45 20 20 52 2e 72 69 64 20 49 4e 20 WHERE R.rid IN
9420: 24 74 68 65 73 65 74 0a 09 7d 5d 20 7b 20 6c 61 $theset..}] { la
9430: 70 70 65 6e 64 20 66 69 64 73 28 24 78 66 69 64 ppend fids($xfid
9440: 29 20 24 78 72 69 64 20 7d 0a 0a 09 73 65 74 20 ) $xrid }...set
9450: 67 72 6f 75 70 73 20 7b 7d 0a 09 66 6f 72 65 61 groups {}..forea
9460: 63 68 20 7b 66 69 64 20 72 69 64 73 7d 20 5b 61 ch {fid rids} [a
9470: 72 72 61 79 20 67 65 74 20 66 69 64 73 5d 20 7b rray get fids] {
9480: 0a 09 20 20 20 20 69 66 20 7b 5b 6c 6c 65 6e 67 .. if {[lleng
9490: 74 68 20 24 72 69 64 73 5d 20 3c 20 32 7d 20 63 th $rids] < 2} c
94a0: 6f 6e 74 69 6e 75 65 0a 09 20 20 20 20 66 6f 72 ontinue.. for
94b0: 65 61 63 68 20 61 20 24 72 69 64 73 20 7b 0a 09 each a $rids {..
94c0: 09 66 6f 72 65 61 63 68 20 62 20 24 72 69 64 73 .foreach b $rids
94d0: 20 7b 0a 09 09 20 20 20 20 69 66 20 7b 24 61 20 {... if {$a
94e0: 3d 3d 20 24 62 7d 20 63 6f 6e 74 69 6e 75 65 0a == $b} continue.
94f0: 09 09 20 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 .. if {[info
9500: 65 78 69 73 74 73 20 64 65 70 28 24 61 2c 24 62 exists dep($a,$b
9510: 29 5d 7d 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 )]} continue...
9520: 20 20 20 69 66 20 7b 5b 69 6e 66 6f 20 65 78 69 if {[info exi
9530: 73 74 73 20 64 65 70 28 24 62 2c 24 61 29 5d 7d sts dep($b,$a)]}
9540: 20 63 6f 6e 74 69 6e 75 65 0a 09 09 20 20 20 20 continue...
9550: 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e lappend dependen
9560: 63 69 65 73 28 24 61 29 20 24 62 0a 09 09 20 20 cies($a) $b...
9570: 20 20 73 65 74 20 64 65 70 28 24 61 2c 24 62 29 set dep($a,$b)
9580: 20 2e 0a 09 09 20 20 20 20 73 65 74 20 64 65 70 .... set dep
9590: 28 24 62 2c 24 61 29 20 2e 0a 09 09 7d 0a 09 20 ($b,$a) ....}..
95a0: 20 20 20 7d 0a 09 20 20 20 20 73 65 74 20 6e 20 }.. set n
95b0: 5b 6c 6c 65 6e 67 74 68 20 24 72 69 64 73 5d 0a [llength $rids].
95c0: 09 20 20 20 20 6c 61 70 70 65 6e 64 20 67 72 6f . lappend gro
95d0: 75 70 73 20 5b 6c 69 73 74 20 24 6e 20 5b 65 78 ups [list $n [ex
95e0: 70 72 20 7b 28 24 6e 2a 24 6e 2d 24 6e 29 2f 32 pr {($n*$n-$n)/2
95f0: 7d 5d 5d 0a 09 7d 0a 0a 09 6c 6f 67 20 77 72 69 }]]..}...log wri
9600: 74 65 20 31 34 20 63 73 65 74 73 20 7b 70 73 65 te 14 csets {pse
9610: 75 64 6f 20 20 20 20 5b 61 72 72 61 79 20 73 69 udo [array si
9620: 7a 65 20 66 69 64 73 5d 20 28 5b 6c 73 6f 72 74 ze fids] ([lsort
9630: 20 2d 69 6e 64 65 78 20 30 20 2d 64 65 63 72 65 -index 0 -decre
9640: 61 73 69 6e 67 20 2d 69 6e 74 65 67 65 72 20 24 asing -integer $
9650: 67 72 6f 75 70 73 5d 29 7d 0a 09 6c 6f 67 20 77 groups])}..log w
9660: 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b 69 rite 14 csets {i
9670: 6e 74 65 72 6e 61 6c 20 20 5b 61 72 72 61 79 20 nternal [array
9680: 73 69 7a 65 20 64 65 70 5d 7d 0a 09 6c 6f 67 20 size dep]}..log
9690: 77 72 69 74 65 20 31 34 20 63 73 65 74 73 20 7b write 14 csets {
96a0: 63 6f 6c 6c 65 63 74 65 64 20 5b 61 72 72 61 79 collected [array
96b0: 20 73 69 7a 65 20 64 65 70 65 6e 64 65 6e 63 69 size dependenci
96c0: 65 73 5d 7d 0a 09 6c 6f 67 20 77 72 69 74 65 20 es]}..log write
96d0: 31 34 20 63 73 65 74 73 20 63 6f 6d 70 6c 65 74 14 csets complet
96e0: 65 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a e..return. }.
96f0: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 . # result =
9700: 34 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70 65 4-list (itemtype
9710: 20 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65 6d itemid nextitem
9720: 74 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64 20 type nextitemid
9730: 2e 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65 74 ...). typemet
9740: 68 6f 64 20 6c 6f 6f 70 73 20 7b 72 65 76 69 73 hod loops {revis
9750: 69 6f 6e 73 7d 20 7b 0a 09 23 20 4e 6f 74 65 3a ions} {..# Note:
9760: 20 54 61 67 73 20 61 6e 64 20 62 72 61 6e 63 68 Tags and branch
9770: 65 73 20 63 61 6e 6e 6f 74 20 63 61 75 73 65 20 es cannot cause
9780: 74 68 65 20 6c 6f 6f 70 2e 20 54 68 65 69 72 20 the loop. Their
9790: 69 64 27 73 2c 0a 09 23 20 62 65 69 6e 67 20 6f id's,..# being o
97a0: 66 20 61 20 66 75 6e 64 61 6d 65 6e 74 61 6c 6c f a fundamentall
97b0: 79 20 64 69 66 66 65 72 65 6e 74 20 74 79 70 65 y different type
97c0: 20 74 68 61 6e 20 74 68 65 20 72 65 76 69 73 69 than the revisi
97d0: 6f 6e 73 0a 09 23 20 63 6f 6d 69 6e 67 20 69 6e ons..# coming in
97e0: 20 63 61 6e 6e 6f 74 20 62 65 20 69 6e 20 74 68 cannot be in th
97f0: 65 20 73 65 74 2e 0a 0a 09 73 65 74 20 74 68 65 e set....set the
9800: 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 set ('[join $rev
9810: 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a isions {','}]').
9820: 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 72 .return [state r
9830: 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d un [subst -nocom
9840: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
9850: 73 68 65 73 20 7b 0a 09 20 20 20 20 2d 2d 20 28 shes {.. -- (
9860: 31 29 20 50 72 69 6d 61 72 79 20 63 68 69 6c 64 1) Primary child
9870: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 .. SELECT R.r
9880: 69 64 2c 20 52 2e 63 68 69 6c 64 0a 09 20 20 20 id, R.child..
9890: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e FROM revision
98a0: 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 R.. WHERE R
98b0: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 .rid IN $these
98c0: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 t -- Restric
98d0: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f t to revisions o
98e0: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 f interest..
98f0: 41 4e 44 20 20 20 20 52 2e 63 68 69 6c 64 20 49 AND R.child I
9900: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d 2d S NOT NULL --
9910: 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 69 Has primary chi
9920: 6c 64 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 ld.. AND R
9930: 2e 63 68 69 6c 64 20 49 4e 20 24 74 68 65 73 65 .child IN $these
9940: 74 20 20 20 20 20 2d 2d 20 4c 6f 6f 70 0a 09 20 t -- Loop..
9950: 20 20 20 2d 2d 0a 09 20 20 20 20 55 4e 49 4f 4e --.. UNION
9960: 0a 09 20 20 20 20 2d 2d 20 28 32 29 20 53 65 63 .. -- (2) Sec
9970: 6f 6e 64 61 72 79 20 28 62 72 61 6e 63 68 29 20 ondary (branch)
9980: 63 68 69 6c 64 72 65 6e 0a 09 20 20 20 20 53 45 children.. SE
9990: 4c 45 43 54 20 52 2e 72 69 64 2c 20 42 2e 62 72 LECT R.rid, B.br
99a0: 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 72 id.. FROM r
99b0: 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 evision R, revis
99c0: 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 65 ionbranchchildre
99d0: 6e 20 42 0a 09 20 20 20 20 57 48 45 52 45 20 20 n B.. WHERE
99e0: 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 R.rid IN $thes
99f0: 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 et -- Restri
9a00: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 ct to revisions
9a10: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
9a20: 20 41 4e 44 20 20 20 20 52 2e 72 69 64 20 3d 20 AND R.rid =
9a30: 42 2e 72 69 64 20 20 20 20 20 20 20 20 20 20 2d B.rid -
9a40: 2d 20 53 65 6c 65 63 74 20 73 75 62 73 65 74 20 - Select subset
9a50: 6f 66 20 62 72 61 6e 63 68 20 63 68 69 6c 64 72 of branch childr
9a60: 65 6e 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 en.. AND B
9a70: 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 73 65 .rid IN $these
9a80: 74 20 20 20 20 20 2d 2d 20 4c 6f 6f 70 0a 09 20 t -- Loop..
9a90: 20 20 20 2d 2d 0a 09 20 20 20 20 55 4e 49 4f 4e --.. UNION
9aa0: 0a 09 20 20 20 20 2d 2d 20 28 34 29 20 43 68 69 .. -- (4) Chi
9ab0: 6c 64 20 6f 66 20 74 72 75 6e 6b 20 72 6f 6f 74 ld of trunk root
9ac0: 20 73 75 63 63 65 73 73 6f 72 20 6f 66 20 6c 61 successor of la
9ad0: 73 74 20 4e 54 44 42 20 6f 6e 20 74 72 75 6e 6b st NTDB on trunk
9ae0: 2e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e ... SELECT R.
9af0: 72 69 64 2c 20 52 41 2e 63 68 69 6c 64 0a 09 20 rid, RA.child..
9b00: 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 FROM revisi
9b10: 6f 6e 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 on R, revision R
9b20: 41 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 2e A.. WHERE R.
9b30: 72 69 64 20 20 20 20 49 4e 20 24 74 68 65 73 65 rid IN $these
9b40: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 t -- Restric
9b50: 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 6f t to revisions o
9b60: 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 f interest..
9b70: 41 4e 44 20 20 20 20 52 2e 69 73 64 65 66 61 75 AND R.isdefau
9b80: 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 20 2d lt -
9b90: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 4e 54 - Restrict to NT
9ba0: 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 DB.. AND R
9bb0: 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 .dbchild IS NOT
9bc0: 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c 61 NULL -- and la
9bd0: 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 6e st NTDB belongin
9be0: 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 20 g to trunk..
9bf0: 41 4e 44 20 20 20 20 52 41 2e 72 69 64 20 3d 20 AND RA.rid =
9c00: 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d R.dbchild -
9c10: 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f - Go directly to
9c20: 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 trunk root..
9c30: 20 41 4e 44 20 20 20 20 52 41 2e 63 68 69 6c 64 AND RA.child
9c40: 20 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 IS NOT NULL
9c50: 2d 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 -- Has primary c
9c60: 68 69 6c 64 2e 0a 09 20 20 20 20 41 4e 44 20 20 hild... AND
9c70: 20 20 52 41 2e 63 68 69 6c 64 20 49 4e 20 24 74 RA.child IN $t
9c80: 68 65 73 65 74 20 20 20 20 20 2d 2d 20 4c 6f 6f heset -- Loo
9c90: 70 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 p..}]]. }..
9ca0: 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 # var(dv) = di
9cb0: 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 ct (item -> list
9cc0: 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 (item)), item
9cd0: 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29 = list (type id)
9ce0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
9cf0: 73 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20 72 successors {dv r
9d00: 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 75 70 76 evisions} {..upv
9d10: 61 72 20 31 20 24 64 76 20 64 65 70 65 6e 64 65 ar 1 $dv depende
9d20: 6e 63 69 65 73 0a 09 73 65 74 20 74 68 65 73 65 ncies..set these
9d30: 74 20 28 27 5b 6a 6f 69 6e 20 24 72 65 76 69 73 t ('[join $revis
9d40: 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 29 0a 0a 09 ions {','}]')...
9d50: 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 # The following
9d60: 63 61 73 65 73 20 73 70 65 63 69 66 79 20 77 68 cases specify wh
9d70: 65 6e 20 61 20 72 65 76 69 73 69 6f 6e 20 53 20 en a revision S
9d80: 69 73 20 61 20 73 75 63 63 65 73 73 6f 72 0a 09 is a successor..
9d90: 23 20 6f 66 20 61 20 72 65 76 69 73 69 6f 6e 20 # of a revision
9da0: 52 2e 20 45 61 63 68 20 6f 66 20 74 68 65 20 63 R. Each of the c
9db0: 61 73 65 73 20 74 72 61 6e 73 6c 61 74 65 73 20 ases translates
9dc0: 69 6e 74 6f 20 6f 6e 65 20 6f 66 0a 09 23 20 74 into one of..# t
9dd0: 68 65 20 62 72 61 6e 63 68 65 73 20 6f 66 20 74 he branches of t
9de0: 68 65 20 53 51 4c 20 55 4e 49 4f 4e 20 63 6f 6d he SQL UNION com
9df0: 69 6e 67 20 62 65 6c 6f 77 2e 0a 09 23 0a 09 23 ing below...#..#
9e00: 20 28 31 29 20 53 20 63 61 6e 20 62 65 20 61 20 (1) S can be a
9e10: 70 72 69 6d 61 72 79 20 63 68 69 6c 64 20 6f 66 primary child of
9e20: 20 52 2c 20 69 2e 65 2e 20 69 6e 20 74 68 65 20 R, i.e. in the
9e30: 73 61 6d 65 20 4c 4f 44 2e 20 52 0a 09 23 20 20 same LOD. R..#
9e40: 20 20 20 72 65 66 65 72 65 6e 63 65 73 20 53 20 references S
9e50: 64 69 72 65 63 74 6c 79 2e 20 52 2e 63 68 69 6c directly. R.chil
9e60: 64 20 3d 20 53 28 2e 72 69 64 29 2c 20 69 66 20 d = S(.rid), if
9e70: 69 74 20 65 78 69 73 74 73 2e 0a 09 23 0a 09 23 it exists...#..#
9e80: 20 28 32 29 20 53 20 63 61 6e 20 62 65 20 61 20 (2) S can be a
9e90: 73 65 63 6f 6e 64 61 72 79 2c 20 69 2e 65 2e 20 secondary, i.e.
9ea0: 62 72 61 6e 63 68 2c 20 63 68 69 6c 64 20 6f 66 branch, child of
9eb0: 20 52 2e 20 48 65 72 65 20 74 68 65 0a 09 23 20 R. Here the..#
9ec0: 20 20 20 20 6c 69 6e 6b 20 69 73 20 6d 61 64 65 link is made
9ed0: 20 74 68 72 6f 75 67 68 20 74 68 65 20 68 65 6c through the hel
9ee0: 70 65 72 20 74 61 62 6c 65 0a 09 23 20 20 20 20 per table..#
9ef0: 20 52 45 56 49 53 49 4f 4e 42 52 41 4e 43 48 43 REVISIONBRANCHC
9f00: 48 49 4c 44 52 45 4e 2e 20 52 2e 72 69 64 20 2d HILDREN. R.rid -
9f10: 3e 20 52 42 43 2e 72 69 64 2c 20 52 42 43 2e 62 > RBC.rid, RBC.b
9f20: 72 69 64 20 3d 0a 09 23 20 20 20 20 20 53 28 2e rid =..# S(.
9f30: 72 69 64 29 0a 09 23 0a 09 23 20 28 33 29 20 4f rid)..#..# (3) O
9f40: 72 69 67 69 6e 61 6c 6c 79 20 74 68 69 73 20 75 riginally this u
9f50: 73 65 20 63 61 73 65 20 64 65 66 69 6e 65 64 20 se case defined
9f60: 74 68 65 20 72 6f 6f 74 20 6f 66 20 61 20 64 65 the root of a de
9f70: 74 61 63 68 65 64 0a 09 23 20 20 20 20 20 4e 54 tached..# NT
9f80: 44 42 20 61 73 20 74 68 65 20 73 75 63 63 65 73 DB as the succes
9f90: 73 6f 72 20 6f 66 20 74 68 65 20 74 72 75 6e 6b sor of the trunk
9fa0: 20 72 6f 6f 74 2e 20 54 68 69 73 20 6c 65 61 64 root. This lead
9fb0: 73 20 74 6f 20 61 0a 09 23 20 20 20 20 20 62 61 s to a..# ba
9fc0: 64 20 74 61 6e 67 6c 65 20 6c 61 74 65 72 20 6f d tangle later o
9fd0: 6e 2e 20 57 69 74 68 20 61 20 64 65 74 61 63 68 n. With a detach
9fe0: 65 64 20 4e 54 44 42 20 74 68 65 20 6f 72 69 67 ed NTDB the orig
9ff0: 69 6e 61 6c 0a 09 23 20 20 20 20 20 74 72 75 6e inal..# trun
a000: 6b 20 72 6f 6f 74 20 72 65 76 69 73 69 6f 6e 20 k root revision
a010: 77 61 73 20 72 65 6d 6f 76 65 64 20 61 73 20 69 was removed as i
a020: 72 72 65 6c 65 76 61 6e 74 2c 20 61 6c 6c 6f 77 rrelevant, allow
a030: 69 6e 67 0a 09 23 20 20 20 20 20 74 68 65 20 6e ing..# the n
a040: 6f 6d 69 6e 61 6c 20 72 6f 6f 74 20 74 6f 20 62 ominal root to b
a050: 65 20 6c 61 74 65 72 20 69 6e 20 74 69 6d 65 20 e later in time
a060: 74 68 61 6e 20 74 68 65 20 4e 54 44 42 0a 09 23 than the NTDB..#
a070: 20 20 20 20 20 72 6f 6f 74 2e 20 4e 6f 77 20 73 root. Now s
a080: 65 74 74 69 6e 67 20 74 68 69 73 20 64 65 70 65 etting this depe
a090: 6e 64 65 6e 63 79 20 77 69 6c 6c 20 62 65 20 62 ndency will be b
a0a0: 61 63 6b 77 61 72 64 20 69 6e 0a 09 23 20 20 20 ackward in..#
a0b0: 20 20 74 69 6d 65 2e 20 52 45 4d 4f 56 45 44 2e time. REMOVED.
a0c0: 0a 09 23 0a 09 23 20 28 34 29 20 49 66 20 52 20 ..#..# (4) If R
a0d0: 69 73 20 74 68 65 20 6c 61 73 74 20 6f 66 20 74 is the last of t
a0e0: 68 65 20 4e 54 44 42 20 72 65 76 69 73 69 6f 6e he NTDB revision
a0f0: 73 20 77 68 69 63 68 20 62 65 6c 6f 6e 67 20 74 s which belong t
a100: 6f 0a 09 23 20 20 20 20 20 74 68 65 20 74 72 75 o..# the tru
a110: 6e 6b 2c 20 74 68 65 6e 20 74 68 65 20 70 72 69 nk, then the pri
a120: 6d 61 72 79 20 63 68 69 6c 64 20 6f 66 20 74 68 mary child of th
a130: 65 20 74 72 75 6e 6b 20 72 6f 6f 74 20 28 74 68 e trunk root (th
a140: 65 0a 09 23 20 20 20 20 20 27 31 2e 32 27 20 72 e..# '1.2' r
a150: 65 76 69 73 69 6f 6e 29 20 69 73 20 61 20 73 75 evision) is a su
a160: 63 63 65 73 73 6f 72 2c 20 69 66 20 69 74 20 65 ccessor, if it e
a170: 78 69 73 74 73 2e 0a 0a 09 23 20 4e 6f 74 65 20 xists....# Note
a180: 74 68 61 74 20 74 68 65 20 62 72 61 6e 63 68 65 that the branche
a190: 73 20 73 70 61 77 6e 65 64 20 66 72 6f 6d 20 74 s spawned from t
a1a0: 68 65 20 72 65 76 69 73 69 6f 6e 73 2c 20 61 6e he revisions, an
a1b0: 64 20 74 68 65 0a 09 23 20 74 61 67 73 20 61 73 d the..# tags as
a1c0: 73 6f 63 69 61 74 65 64 20 77 69 74 68 20 74 68 sociated with th
a1d0: 65 6d 20 61 72 65 20 73 75 63 63 65 73 73 6f 72 em are successor
a1e0: 73 20 61 73 20 77 65 6c 6c 2e 0a 0a 09 73 74 61 s as well....sta
a1f0: 74 65 20 66 6f 72 65 61 63 68 72 6f 77 20 5b 73 te foreachrow [s
a200: 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 ubst -nocommands
a210: 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 -nobackslashes
a220: 7b 0a 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69 {. -- (1) Pri
a230: 6d 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 mary child..
a240: 53 45 4c 45 43 54 20 52 2e 72 69 64 20 41 53 20 SELECT R.rid AS
a250: 78 72 69 64 2c 20 52 2e 63 68 69 6c 64 20 41 53 xrid, R.child AS
a260: 20 78 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f xchild.. FRO
a270: 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 0a 09 M revision R..
a280: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 WHERE R.rid
a290: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 IN $theset
a2a0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f -- Restrict to
a2b0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e revisions of in
a2c0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 terest.. AND
a2d0: 20 20 20 52 2e 63 68 69 6c 64 20 49 53 20 4e 4f R.child IS NO
a2e0: 54 20 4e 55 4c 4c 20 20 20 20 2d 2d 20 48 61 73 T NULL -- Has
a2f0: 20 70 72 69 6d 61 72 79 20 63 68 69 6c 64 0a 20 primary child.
a300: 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 UNION. --
a310: 28 32 29 20 53 65 63 6f 6e 64 61 72 79 20 28 62 (2) Secondary (b
a320: 72 61 6e 63 68 29 20 63 68 69 6c 64 72 65 6e 0a ranch) children.
a330: 09 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 . SELECT R.ri
a340: 64 20 41 53 20 78 72 69 64 2c 20 42 2e 62 72 69 d AS xrid, B.bri
a350: 64 20 41 53 20 78 63 68 69 6c 64 0a 09 20 20 20 d AS xchild..
a360: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e FROM revision
a370: 20 52 2c 20 72 65 76 69 73 69 6f 6e 62 72 61 6e R, revisionbran
a380: 63 68 63 68 69 6c 64 72 65 6e 20 42 0a 09 20 20 chchildren B..
a390: 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 WHERE R.rid
a3a0: 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 IN $theset
a3b0: 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 -- Restrict to r
a3c0: 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 evisions of inte
a3d0: 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 rest.. AND
a3e0: 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 20 20 R.rid = B.rid
a3f0: 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 -- Selec
a400: 74 20 73 75 62 73 65 74 20 6f 66 20 62 72 61 6e t subset of bran
a410: 63 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 20 20 ch children.
a420: 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d 20 28 34 29 UNION. -- (4)
a430: 20 43 68 69 6c 64 20 6f 66 20 74 72 75 6e 6b 20 Child of trunk
a440: 72 6f 6f 74 20 73 75 63 63 65 73 73 6f 72 20 6f root successor o
a450: 66 20 6c 61 73 74 20 4e 54 44 42 20 6f 6e 20 74 f last NTDB on t
a460: 72 75 6e 6b 2e 0a 09 20 20 20 20 53 45 4c 45 43 runk... SELEC
a470: 54 20 52 2e 72 69 64 20 41 53 20 78 72 69 64 2c T R.rid AS xrid,
a480: 20 52 41 2e 63 68 69 6c 64 20 41 53 20 78 63 68 RA.child AS xch
a490: 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 72 65 ild.. FROM re
a4a0: 76 69 73 69 6f 6e 20 52 2c 20 72 65 76 69 73 69 vision R, revisi
a4b0: 6f 6e 20 52 41 0a 09 20 20 20 20 57 48 45 52 45 on RA.. WHERE
a4c0: 20 52 2e 72 69 64 20 20 20 49 4e 20 24 74 68 65 R.rid IN $the
a4d0: 73 65 74 20 20 20 20 20 20 2d 2d 20 52 65 73 74 set -- Rest
a4e0: 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e rict to revision
a4f0: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 s of interest..
a500: 20 20 20 41 4e 44 20 20 20 52 2e 69 73 64 65 66 AND R.isdef
a510: 61 75 6c 74 20 20 20 20 20 20 20 20 20 20 20 20 ault
a520: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 -- Restrict to
a530: 4e 54 44 42 0a 09 20 20 20 20 41 4e 44 20 20 20 NTDB.. AND
a540: 52 2e 64 62 63 68 69 6c 64 20 49 53 20 4e 4f 54 R.dbchild IS NOT
a550: 20 4e 55 4c 4c 20 20 20 2d 2d 20 61 6e 64 20 6c NULL -- and l
a560: 61 73 74 20 4e 54 44 42 20 62 65 6c 6f 6e 67 69 ast NTDB belongi
a570: 6e 67 20 74 6f 20 74 72 75 6e 6b 0a 09 20 20 20 ng to trunk..
a580: 20 41 4e 44 20 20 20 52 41 2e 72 69 64 20 3d 20 AND RA.rid =
a590: 52 2e 64 62 63 68 69 6c 64 20 20 20 20 20 20 2d R.dbchild -
a5a0: 2d 20 47 6f 20 64 69 72 65 63 74 6c 79 20 74 6f - Go directly to
a5b0: 20 74 72 75 6e 6b 20 72 6f 6f 74 0a 09 20 20 20 trunk root..
a5c0: 20 41 4e 44 20 20 20 52 41 2e 63 68 69 6c 64 20 AND RA.child
a5d0: 49 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 20 2d IS NOT NULL -
a5e0: 2d 20 48 61 73 20 70 72 69 6d 61 72 79 20 63 68 - Has primary ch
a5f0: 69 6c 64 2e 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 ild...}] {..
a600: 23 20 43 6f 6e 73 69 64 65 72 20 6d 6f 76 69 6e # Consider movin
a610: 67 20 74 68 69 73 20 74 6f 20 74 68 65 20 69 6e g this to the in
a620: 74 65 67 72 69 74 79 20 6d 6f 64 75 6c 65 2e 0a tegrity module..
a630: 09 20 20 20 20 69 6e 74 65 67 72 69 74 79 20 61 . integrity a
a640: 73 73 65 72 74 20 7b 24 78 72 69 64 20 21 3d 20 ssert {$xrid !=
a650: 24 78 63 68 69 6c 64 7d 20 7b 52 65 76 69 73 69 $xchild} {Revisi
a660: 6f 6e 20 24 78 72 69 64 20 64 65 70 65 6e 64 73 on $xrid depends
a670: 20 6f 6e 20 69 74 73 65 6c 66 2e 7d 0a 09 20 20 on itself.}..
a680: 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 lappend depend
a690: 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 72 65 76 encies([list rev
a6a0: 20 24 78 72 69 64 5d 29 20 5b 6c 69 73 74 20 72 $xrid]) [list r
a6b0: 65 76 20 24 78 63 68 69 6c 64 5d 0a 09 7d 0a 09 ev $xchild]..}..
a6c0: 73 74 61 74 65 20 66 6f 72 65 61 63 68 72 6f 77 state foreachrow
a6d0: 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 [subst -nocomma
a6e0: 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 nds -nobackslash
a6f0: 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 es {.. SELECT
a700: 20 52 2e 72 69 64 20 41 53 20 78 72 69 64 2c 20 R.rid AS xrid,
a710: 54 2e 74 69 64 20 41 53 20 78 63 68 69 6c 64 0a T.tid AS xchild.
a720: 09 20 20 20 20 46 52 4f 4d 20 20 20 72 65 76 69 . FROM revi
a730: 73 69 6f 6e 20 52 2c 20 74 61 67 20 54 0a 09 20 sion R, tag T..
a740: 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 20 WHERE R.rid
a750: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 20 IN $theset
a760: 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 -- Restrict to
a770: 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 revisions of int
a780: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 erest.. AND
a790: 20 20 54 2e 72 65 76 20 3d 20 52 2e 72 69 64 20 T.rev = R.rid
a7a0: 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 -- Sele
a7b0: 63 74 20 74 61 67 73 20 61 74 74 61 63 68 65 64 ct tags attached
a7c0: 20 74 6f 20 74 68 65 6d 0a 09 7d 5d 20 7b 0a 09 to them..}] {..
a7d0: 20 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 lappend depe
a7e0: 6e 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 72 ndencies([list r
a7f0: 65 76 20 24 78 72 69 64 5d 29 20 5b 6c 69 73 74 ev $xrid]) [list
a800: 20 73 79 6d 3a 3a 74 61 67 20 24 78 63 68 69 6c sym::tag $xchil
a810: 64 5d 0a 09 7d 0a 09 73 74 61 74 65 20 66 6f 72 d]..}..state for
a820: 65 61 63 68 72 6f 77 20 5b 73 75 62 73 74 20 2d eachrow [subst -
a830: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 nocommands -noba
a840: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 ckslashes {..
a850: 20 53 45 4c 45 43 54 20 52 2e 72 69 64 20 41 53 SELECT R.rid AS
a860: 20 78 72 69 64 2c 20 42 2e 62 69 64 20 41 53 20 xrid, B.bid AS
a870: 78 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d xchild.. FROM
a880: 20 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 62 revision R, b
a890: 72 61 6e 63 68 20 42 0a 09 20 20 20 20 57 48 45 ranch B.. WHE
a8a0: 52 45 20 20 52 2e 72 69 64 20 49 4e 20 24 74 68 RE R.rid IN $th
a8b0: 65 73 65 74 20 20 20 20 20 20 20 2d 2d 20 52 65 eset -- Re
a8c0: 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 69 strict to revisi
a8d0: 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a ons of interest.
a8e0: 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 72 6f . AND B.ro
a8f0: 6f 74 20 3d 20 52 2e 72 69 64 20 20 20 20 20 20 ot = R.rid
a900: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 62 72 61 -- Select bra
a910: 6e 63 68 65 73 20 61 74 74 61 63 68 65 64 20 74 nches attached t
a920: 6f 20 74 68 65 6d 0a 09 7d 5d 20 7b 0a 09 20 20 o them..}] {..
a930: 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 lappend depend
a940: 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 72 65 76 encies([list rev
a950: 20 24 78 72 69 64 5d 29 20 5b 6c 69 73 74 20 73 $xrid]) [list s
a960: 79 6d 3a 3a 62 72 61 6e 63 68 20 24 78 63 68 69 ym::branch $xchi
a970: 6c 64 5d 0a 09 7d 0a 09 72 65 74 75 72 6e 0a 20 ld]..}..return.
a980: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 }.. # resu
a990: 6c 74 20 3d 20 6c 69 73 74 20 28 63 68 61 6e 67 lt = list (chang
a9a0: 65 73 65 74 2d 69 64 29 0a 20 20 20 20 74 79 70 eset-id). typ
a9b0: 65 6d 65 74 68 6f 64 20 63 73 5f 73 75 63 63 65 emethod cs_succe
a9c0: 73 73 6f 72 73 20 7b 72 65 76 69 73 69 6f 6e 73 ssors {revisions
a9d0: 7d 20 7b 0a 20 20 20 20 20 20 20 20 23 20 54 68 } {. # Th
a9e0: 69 73 20 69 73 20 61 20 76 61 72 69 61 6e 74 20 is is a variant
a9f0: 6f 66 20 27 73 75 63 63 65 73 73 6f 72 73 27 20 of 'successors'
aa00: 77 68 69 63 68 20 6d 61 70 73 20 74 68 65 20 6c which maps the l
aa10: 6f 77 2d 6c 65 76 65 6c 0a 20 20 20 20 20 20 20 ow-level.
aa20: 20 23 20 64 61 74 61 20 64 69 72 65 63 74 6c 79 # data directly
aa30: 20 74 6f 20 74 68 65 20 61 73 73 6f 63 69 61 74 to the associat
aa40: 65 64 20 63 68 61 6e 67 65 73 65 74 73 2e 20 49 ed changesets. I
aa50: 2e 65 2e 20 69 6e 73 74 65 61 64 0a 20 20 20 20 .e. instead.
aa60: 20 20 20 20 23 20 6d 69 6c 6c 69 6f 6e 73 20 6f # millions o
aa70: 66 20 64 65 70 65 6e 64 65 6e 63 79 20 70 61 69 f dependency pai
aa80: 72 73 20 28 69 6e 20 65 78 74 72 65 6d 65 20 63 rs (in extreme c
aa90: 61 73 65 73 20 28 45 78 61 6d 70 6c 65 3a 20 54 ases (Example: T
aaa0: 63 6c 0a 20 20 20 20 20 20 20 20 23 20 43 56 53 cl. # CVS
aab0: 29 29 20 77 65 20 72 65 74 75 72 6e 20 61 20 76 )) we return a v
aac0: 65 72 79 20 73 68 6f 72 74 20 61 6e 64 20 6d 75 ery short and mu
aad0: 63 68 20 6d 6f 72 65 20 6d 61 6e 61 67 65 61 62 ch more manageab
aae0: 6c 65 20 6c 69 73 74 0a 20 20 20 20 20 20 20 20 le list.
aaf0: 23 20 6f 66 20 63 68 61 6e 67 65 73 65 74 73 2e # of changesets.
ab00: 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 27 ...set theset ('
ab10: 5b 6a 6f 69 6e 20 24 72 65 76 69 73 69 6f 6e 73 [join $revisions
ab20: 20 7b 27 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 {','}]')..retur
ab30: 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 5b 73 75 n [state run [su
ab40: 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 bst -nocommands
ab50: 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 20 7b -nobackslashes {
ab60: 0a 20 20 20 20 2d 2d 20 28 31 29 20 50 72 69 6d . -- (1) Prim
ab70: 61 72 79 20 63 68 69 6c 64 0a 09 20 20 20 20 53 ary child.. S
ab80: 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 ELECT C.cid..
ab90: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e FROM revision
aba0: 20 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 R, csitem CI, c
abb0: 68 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 hangeset C..
abc0: 57 48 45 52 45 20 20 52 2e 72 69 64 20 20 20 49 WHERE R.rid I
abd0: 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d N $theset --
abe0: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 Restrict to rev
abf0: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 isions of intere
ac00: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 st.. AND R
ac10: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 .child IS NOT NU
ac20: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 LL -- Has pri
ac30: 6d 61 72 79 20 63 68 69 6c 64 0a 20 20 20 20 20 mary child.
ac40: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 49 AND CI
ac50: 2e 69 69 64 20 3d 20 52 2e 63 68 69 6c 64 20 20 .iid = R.child
ac60: 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 -- Select a
ac70: 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 ll changesets.
ac80: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
ac90: 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 20 C.cid = CI.cid
aca0: 20 20 20 20 20 20 20 20 2d 2d 20 63 6f 6e 74 61 -- conta
acb0: 69 6e 69 6e 67 20 74 68 65 20 70 72 69 6d 61 72 ining the primar
acc0: 79 20 63 68 69 6c 64 0a 20 20 20 20 20 20 20 20 y child.
acd0: 20 20 20 20 41 4e 44 20 20 20 20 43 2e 74 79 70 AND C.typ
ace0: 65 20 3d 20 30 20 20 20 20 20 20 20 20 20 20 20 e = 0
acf0: 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 72 -- which are r
ad00: 65 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 evision changese
ad10: 74 73 0a 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 ts. UNION.
ad20: 20 2d 2d 20 28 32 29 20 53 65 63 6f 6e 64 61 72 -- (2) Secondar
ad30: 79 20 28 62 72 61 6e 63 68 29 20 63 68 69 6c 64 y (branch) child
ad40: 72 65 6e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 ren.. SELECT
ad50: 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 C.cid.. FROM
ad60: 20 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 72 65 revision R, re
ad70: 76 69 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c visionbranchchil
ad80: 64 72 65 6e 20 42 2c 20 63 73 69 74 65 6d 20 43 dren B, csitem C
ad90: 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 I, changeset C..
ada0: 20 20 20 20 57 48 45 52 45 20 20 52 2e 72 69 64 WHERE R.rid
adb0: 20 20 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 IN $theset
adc0: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f -- Restrict to
add0: 20 72 65 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e revisions of in
ade0: 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 terest.. AND
adf0: 20 20 20 52 2e 72 69 64 20 3d 20 42 2e 72 69 64 R.rid = B.rid
ae00: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c -- Sel
ae10: 65 63 74 20 73 75 62 73 65 74 20 6f 66 20 62 72 ect subset of br
ae20: 61 6e 63 68 20 63 68 69 6c 64 72 65 6e 0a 20 20 anch children.
ae30: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
ae40: 20 43 49 2e 69 69 64 20 3d 20 42 2e 62 72 69 64 CI.iid = B.brid
ae50: 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 -- Selec
ae60: 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 t all changesets
ae70: 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 . AND
ae80: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 C.cid = CI.c
ae90: 69 64 09 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 id. -- containi
aea0: 6e 67 20 74 68 65 20 62 72 61 6e 63 68 0a 20 20 ng the branch.
aeb0: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
aec0: 20 43 2e 74 79 70 65 20 3d 20 30 09 09 20 20 2d C.type = 0.. -
aed0: 2d 20 77 68 69 63 68 20 61 72 65 20 72 65 76 69 - which are revi
aee0: 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a sion changesets.
aef0: 20 20 20 20 55 4e 49 4f 4e 0a 20 20 20 20 2d 2d UNION. --
af00: 20 28 34 29 20 43 68 69 6c 64 20 6f 66 20 74 72 (4) Child of tr
af10: 75 6e 6b 20 72 6f 6f 74 20 73 75 63 63 65 73 73 unk root success
af20: 6f 72 20 6f 66 20 6c 61 73 74 20 4e 54 44 42 20 or of last NTDB
af30: 6f 6e 20 74 72 75 6e 6b 2e 0a 09 20 20 20 20 53 on trunk... S
af40: 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 ELECT C.cid..
af50: 20 46 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e FROM revision
af60: 20 52 2c 20 72 65 76 69 73 69 6f 6e 20 52 41 2c R, revision RA,
af70: 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e csitem CI, chan
af80: 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45 geset C.. WHE
af90: 52 45 20 20 52 2e 72 69 64 20 20 20 49 4e 20 24 RE R.rid IN $
afa0: 74 68 65 73 65 74 20 20 20 20 20 20 2d 2d 20 52 theset -- R
afb0: 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 69 73 estrict to revis
afc0: 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 73 74 ions of interest
afd0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 2e 69 .. AND R.i
afe0: 73 64 65 66 61 75 6c 74 20 20 20 20 20 20 20 20 sdefault
aff0: 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 -- Restrict
b000: 20 74 6f 20 4e 54 44 42 0a 09 20 20 20 20 41 4e to NTDB.. AN
b010: 44 20 20 20 20 52 2e 64 62 63 68 69 6c 64 20 49 D R.dbchild I
b020: 53 20 4e 4f 54 20 4e 55 4c 4c 20 20 20 2d 2d 20 S NOT NULL --
b030: 61 6e 64 20 6c 61 73 74 20 4e 54 44 42 20 62 65 and last NTDB be
b040: 6c 6f 6e 67 69 6e 67 20 74 6f 20 74 72 75 6e 6b longing to trunk
b050: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 2e .. AND RA.
b060: 72 69 64 20 3d 20 52 2e 64 62 63 68 69 6c 64 20 rid = R.dbchild
b070: 20 20 20 20 20 2d 2d 20 47 6f 20 64 69 72 65 63 -- Go direc
b080: 74 6c 79 20 74 6f 20 74 72 75 6e 6b 20 72 6f 6f tly to trunk roo
b090: 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 52 41 t.. AND RA
b0a0: 2e 63 68 69 6c 64 20 49 53 20 4e 4f 54 20 4e 55 .child IS NOT NU
b0b0: 4c 4c 20 20 20 20 2d 2d 20 48 61 73 20 70 72 69 LL -- Has pri
b0c0: 6d 61 72 79 20 63 68 69 6c 64 2e 0a 20 20 20 20 mary child..
b0d0: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 AND C
b0e0: 49 2e 69 69 64 20 3d 20 52 41 2e 63 68 69 6c 64 I.iid = RA.child
b0f0: 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 -- Select
b100: 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 73 0a all changesets.
b110: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 AND
b120: 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 C.cid = CI.ci
b130: 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69 6e 69 d. -- containi
b140: 6e 67 20 74 68 65 20 70 72 69 6d 61 72 79 20 63 ng the primary c
b150: 68 69 6c 64 0a 20 20 20 20 20 20 20 20 20 20 20 hild.
b160: 20 41 4e 44 20 20 20 20 43 2e 74 79 70 65 20 3d AND C.type =
b170: 20 30 09 09 20 20 20 2d 2d 20 77 68 69 63 68 20 0.. -- which
b180: 61 72 65 20 72 65 76 69 73 69 6f 6e 20 63 68 61 are revision cha
b190: 6e 67 65 73 65 74 73 0a 20 20 20 20 55 4e 49 4f ngesets. UNIO
b1a0: 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 20 43 2e N.. SELECT C.
b1b0: 63 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 cid.. FROM
b1c0: 72 65 76 69 73 69 6f 6e 20 52 2c 20 74 61 67 20 revision R, tag
b1d0: 54 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 68 T, csitem CI, ch
b1e0: 61 6e 67 65 73 65 74 20 43 0a 09 20 20 20 20 57 angeset C.. W
b1f0: 48 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20 24 HERE R.rid in $
b200: 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d theset --
b210: 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 76 Restrict to rev
b220: 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 65 isions of intere
b230: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 54 st.. AND T
b240: 2e 72 65 76 20 3d 20 52 2e 72 69 64 09 20 20 20 .rev = R.rid.
b250: 2d 2d 20 53 65 6c 65 63 74 20 74 61 67 73 20 61 -- Select tags a
b260: 74 74 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a ttached to them.
b270: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 AND
b280: 20 20 20 43 49 2e 69 69 64 20 3d 20 54 2e 74 69 CI.iid = T.ti
b290: 64 20 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 d -- Se
b2a0: 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 lect all changes
b2b0: 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 ets.
b2c0: 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 AND C.cid = C
b2d0: 49 2e 63 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74 I.cid. -- cont
b2e0: 61 69 6e 69 6e 67 20 74 68 65 20 74 61 67 73 0a aining the tags.
b2f0: 20 20 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 AND
b300: 20 20 20 43 2e 74 79 70 65 20 3d 20 31 09 09 20 C.type = 1..
b310: 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 20 74 -- which are t
b320: 61 67 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 ag changesets.
b330: 20 20 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c UNION.. SEL
b340: 45 43 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 ECT C.cid.. F
b350: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 ROM revision R
b360: 2c 20 62 72 61 6e 63 68 20 42 2c 20 63 73 69 74 , branch B, csit
b370: 65 6d 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 em CI, changeset
b380: 20 43 0a 09 20 20 20 20 57 48 45 52 45 20 20 52 C.. WHERE R
b390: 2e 72 69 64 20 69 6e 20 24 74 68 65 73 65 74 20 .rid in $theset
b3a0: 20 20 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 -- Restri
b3b0: 63 74 20 74 6f 20 72 65 76 69 73 69 6f 6e 73 20 ct to revisions
b3c0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
b3d0: 20 41 4e 44 20 20 20 20 42 2e 72 6f 6f 74 20 3d AND B.root =
b3e0: 20 52 2e 72 69 64 09 20 20 20 2d 2d 20 53 65 6c R.rid. -- Sel
b3f0: 65 63 74 20 62 72 61 6e 63 68 65 73 20 61 74 74 ect branches att
b400: 61 63 68 65 64 20 74 6f 20 74 68 65 6d 0a 20 20 ached to them.
b410: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
b420: 20 43 49 2e 69 69 64 20 3d 20 42 2e 62 69 64 20 CI.iid = B.bid
b430: 20 20 20 20 20 20 20 20 20 2d 2d 20 53 65 6c 65 -- Sele
b440: 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 73 65 74 ct all changeset
b450: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e s. AN
b460: 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e D C.cid = CI.
b470: 63 69 64 09 20 20 20 2d 2d 20 63 6f 6e 74 61 69 cid. -- contai
b480: 6e 69 6e 67 20 74 68 65 20 62 72 61 6e 63 68 65 ning the branche
b490: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e s. AN
b4a0: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 32 09 D C.type = 2.
b4b0: 09 20 20 20 2d 2d 20 77 68 69 63 68 20 61 72 65 . -- which are
b4c0: 20 62 72 61 6e 63 68 20 63 68 61 6e 67 65 73 65 branch changese
b4d0: 74 73 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 ts..}]]. }..
b4e0: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 73 79 # result = sy
b4f0: 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20 20 20 74 79 mbol name. ty
b500: 70 65 6d 65 74 68 6f 64 20 63 73 5f 6c 6f 64 20 pemethod cs_lod
b510: 7b 72 65 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 23 {revisions} {..#
b520: 20 44 65 74 65 72 6d 69 6e 65 73 20 74 68 65 20 Determines the
b530: 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 79 6d 62 name of the symb
b540: 6f 6c 20 77 68 69 63 68 20 69 73 20 74 68 65 20 ol which is the
b550: 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c line of..# devel
b560: 6f 70 6d 65 6e 74 20 66 6f 72 20 74 68 65 20 72 opment for the r
b570: 65 76 69 73 69 6f 6e 73 20 69 6e 20 61 20 63 68 evisions in a ch
b580: 61 6e 67 65 73 65 74 2e 0a 0a 09 73 65 74 20 74 angeset....set t
b590: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 72 heset ('[join $r
b5a0: 65 76 69 73 69 6f 6e 73 20 7b 27 2c 27 7d 5d 27 evisions {','}]'
b5b0: 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 )..return [state
b5c0: 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 run [subst -noc
b5d0: 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 ommands -nobacks
b5e0: 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 lashes {.. SE
b5f0: 4c 45 43 54 0a 09 20 20 20 20 44 49 53 54 49 4e LECT.. DISTIN
b600: 43 54 20 4c 2e 6e 61 6d 65 0a 09 20 20 20 20 46 CT L.name.. F
b610: 52 4f 4d 20 20 20 72 65 76 69 73 69 6f 6e 20 52 ROM revision R
b620: 2c 20 73 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20 , symbol L..
b630: 57 48 45 52 45 20 20 52 2e 72 69 64 20 69 6e 20 WHERE R.rid in
b640: 24 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d $theset -
b650: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 72 65 - Restrict to re
b660: 76 69 73 69 6f 6e 73 20 6f 66 20 69 6e 74 65 72 visions of inter
b670: 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 est.. AND
b680: 4c 2e 73 69 64 20 3d 20 52 2e 6c 6f 64 20 20 20 L.sid = R.lod
b690: 20 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 6c -- Get l
b6a0: 6f 64 20 73 79 6d 62 6f 6c 20 6f 66 20 72 65 76 od symbol of rev
b6b0: 69 73 69 6f 6e 0a 09 7d 5d 5d 0a 20 20 20 20 7d ision..}]]. }
b6c0: 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 .}..# # ## ### #
b6d0: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 #### ######## ##
b6e0: 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 ########### ####
b6f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
b700: 23 0a 23 23 20 48 65 6c 70 65 72 20 73 69 6e 67 #.## Helper sing
b710: 6c 65 74 6f 6e 2e 20 43 6f 6d 6d 61 6e 64 73 20 leton. Commands
b720: 66 6f 72 20 74 61 67 20 73 79 6d 62 6f 6c 20 63 for tag symbol c
b730: 68 61 6e 67 65 73 65 74 73 2e 0a 0a 73 6e 69 74 hangesets...snit
b740: 3a 3a 74 79 70 65 20 3a 3a 76 63 3a 3a 66 6f 73 ::type ::vc::fos
b750: 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 sil::import::cvs
b760: 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 3a 3a ::project::rev::
b770: 73 79 6d 3a 3a 74 61 67 20 7b 0a 20 20 20 20 74 sym::tag {. t
b780: 79 70 65 6d 65 74 68 6f 64 20 62 79 72 65 76 69 ypemethod byrevi
b790: 73 69 6f 6e 20 7b 7d 20 7b 20 72 65 74 75 72 6e sion {} { return
b7a0: 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 0 }. typemet
b7b0: 68 6f 64 20 62 79 73 79 6d 62 6f 6c 20 20 20 7b hod bysymbol {
b7c0: 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 20 } { return 1 }.
b7d0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 69 73 typemethod is
b7e0: 74 61 67 20 20 20 20 20 20 7b 7d 20 7b 20 72 65 tag {} { re
b7f0: 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 79 70 turn 1 }. typ
b800: 65 6d 65 74 68 6f 64 20 69 73 62 72 61 6e 63 68 emethod isbranch
b810: 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 {} { return 0
b820: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 }.. typemeth
b830: 6f 64 20 73 74 72 20 7b 74 61 67 7d 20 7b 0a 09 od str {tag} {..
b840: 73 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 struct::list ass
b850: 69 67 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b ign [state run {
b860: 0a 09 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e .. SELECT S.n
b870: 61 6d 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e ame, F.name, P.n
b880: 61 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 ame.. FROM
b890: 74 61 67 20 54 2c 20 73 79 6d 62 6f 6c 20 53 2c tag T, symbol S,
b8a0: 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 63 74 file F, project
b8b0: 20 50 0a 09 20 20 20 20 57 48 45 52 45 20 20 54 P.. WHERE T
b8c0: 2e 74 69 64 20 3d 20 24 74 61 67 20 20 20 2d 2d .tid = $tag --
b8d0: 20 46 69 6e 64 20 73 70 65 63 69 66 69 65 64 20 Find specified
b8e0: 74 61 67 0a 09 20 20 20 20 41 4e 44 20 20 20 20 tag.. AND
b8f0: 46 2e 66 69 64 20 3d 20 54 2e 66 69 64 20 20 2d F.fid = T.fid -
b900: 2d 20 47 65 74 20 66 69 6c 65 20 6f 66 20 74 61 - Get file of ta
b910: 67 0a 09 20 20 20 20 41 4e 44 20 20 20 20 50 2e g.. AND P.
b920: 70 69 64 20 3d 20 46 2e 70 69 64 20 20 2d 2d 20 pid = F.pid --
b930: 47 65 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 66 Get project of f
b940: 69 6c 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 ile.. AND
b950: 53 2e 73 69 64 20 3d 20 54 2e 73 69 64 20 20 2d S.sid = T.sid -
b960: 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 - Get symbol of
b970: 74 61 67 0a 09 7d 5d 20 73 6e 61 6d 65 20 66 6e tag..}] sname fn
b980: 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65 74 75 72 ame pname..retur
b990: 6e 20 22 24 70 6e 61 6d 65 2f 54 27 24 7b 73 6e n "$pname/T'${sn
b9a0: 61 6d 65 7d 27 3a 3a 24 66 6e 61 6d 65 22 0a 20 ame}'::$fname".
b9b0: 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 }.. # resu
b9c0: 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69 6e 74 69 lt = list (minti
b9d0: 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a 20 20 20 me, maxtime).
b9e0: 20 74 79 70 65 6d 65 74 68 6f 64 20 74 69 6d 65 typemethod time
b9f0: 72 61 6e 67 65 20 7b 74 61 67 73 7d 20 7b 0a 09 range {tags} {..
ba00: 23 20 54 68 65 20 72 61 6e 67 65 20 69 73 20 64 # The range is d
ba10: 65 66 69 6e 65 64 20 61 73 20 74 68 65 20 72 61 efined as the ra
ba20: 6e 67 65 20 6f 66 20 74 68 65 20 72 65 76 69 73 nge of the revis
ba30: 69 6f 6e 73 20 74 68 65 20 74 61 67 73 0a 09 23 ions the tags..#
ba40: 20 61 72 65 20 61 74 74 61 63 68 65 64 20 74 6f are attached to
ba50: 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 28 ....set theset (
ba60: 27 5b 6a 6f 69 6e 20 24 74 61 67 73 20 7b 27 2c '[join $tags {',
ba70: 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 '}]')..return [s
ba80: 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 tate run [subst
ba90: 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 -nocommands -nob
baa0: 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 ackslashes {..
bab0: 20 20 53 45 4c 45 43 54 20 4d 49 4e 28 52 2e 64 SELECT MIN(R.d
bac0: 61 74 65 29 2c 20 4d 41 58 28 52 2e 64 61 74 65 ate), MAX(R.date
bad0: 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 74 61 ).. FROM ta
bae0: 67 20 54 2c 20 72 65 76 69 73 69 6f 6e 20 52 0a g T, revision R.
baf0: 09 20 20 20 20 57 48 45 52 45 20 20 54 2e 74 69 . WHERE T.ti
bb00: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d d IN $theset --
bb10: 20 52 65 73 74 72 69 63 74 20 74 6f 20 74 61 67 Restrict to tag
bb20: 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 20 20 s of interest.
bb30: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
bb40: 20 52 2e 72 69 64 20 3d 20 54 2e 72 65 76 20 20 R.rid = T.rev
bb50: 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 74 61 67 -- Select tag
bb60: 20 70 61 72 65 6e 74 20 72 65 76 69 73 69 6f 6e parent revision
bb70: 73 0a 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 s..}]]. }..
bb80: 20 20 23 20 76 61 72 28 64 76 29 20 3d 20 64 69 # var(dv) = di
bb90: 63 74 20 28 69 74 65 6d 20 2d 3e 20 6c 69 73 74 ct (item -> list
bba0: 20 28 69 74 65 6d 29 29 2c 20 69 74 65 6d 20 20 (item)), item
bbb0: 3d 20 6c 69 73 74 20 28 74 79 70 65 20 69 64 29 = list (type id)
bbc0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
bbd0: 73 75 63 63 65 73 73 6f 72 73 20 7b 64 76 20 74 successors {dv t
bbe0: 61 67 73 7d 20 7b 0a 09 23 20 54 61 67 73 20 68 ags} {..# Tags h
bbf0: 61 76 65 20 6e 6f 20 73 75 63 63 65 73 73 6f 72 ave no successor
bc00: 73 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d s...return. }
bc10: 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d .. # result =
bc20: 20 34 2d 6c 69 73 74 20 28 69 74 65 6d 74 79 70 4-list (itemtyp
bc30: 65 20 69 74 65 6d 69 64 20 6e 65 78 74 69 74 65 e itemid nextite
bc40: 6d 74 79 70 65 20 6e 65 78 74 69 74 65 6d 69 64 mtype nextitemid
bc50: 20 2e 2e 2e 29 0a 20 20 20 20 74 79 70 65 6d 65 ...). typeme
bc60: 74 68 6f 64 20 6c 6f 6f 70 73 20 7b 74 61 67 73 thod loops {tags
bc70: 7d 20 7b 0a 09 23 20 54 61 67 73 20 68 61 76 65 } {..# Tags have
bc80: 20 6e 6f 20 73 75 63 63 65 73 73 6f 72 73 2c 20 no successors,
bc90: 74 68 65 72 65 66 6f 72 65 20 63 61 6e 6e 6f 74 therefore cannot
bca0: 20 63 61 75 73 65 20 6c 6f 6f 70 73 0a 09 72 65 cause loops..re
bcb0: 74 75 72 6e 20 7b 7d 0a 20 20 20 20 7d 0a 0a 20 turn {}. }..
bcc0: 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 # result = li
bcd0: 73 74 20 28 63 68 61 6e 67 65 73 65 74 2d 69 64 st (changeset-id
bce0: 29 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 ). typemethod
bcf0: 20 63 73 5f 73 75 63 63 65 73 73 6f 72 73 20 7b cs_successors {
bd00: 74 61 67 73 7d 20 7b 0a 09 23 20 54 61 67 73 20 tags} {..# Tags
bd10: 68 61 76 65 20 6e 6f 20 73 75 63 63 65 73 73 6f have no successo
bd20: 72 73 2e 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 rs...return.
bd30: 7d 0a 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 }.. # result
bd40: 3d 20 73 79 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20 = symbol name.
bd50: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f typemethod cs_
bd60: 6c 6f 64 20 7b 74 61 67 73 7d 20 7b 0a 09 23 20 lod {tags} {..#
bd70: 44 65 74 65 72 6d 69 6e 65 73 20 74 68 65 20 6e Determines the n
bd80: 61 6d 65 20 6f 66 20 74 68 65 20 73 79 6d 62 6f ame of the symbo
bd90: 6c 20 77 68 69 63 68 20 69 73 20 74 68 65 20 6c l which is the l
bda0: 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 6c 6f ine of..# develo
bdb0: 70 6d 65 6e 74 20 66 6f 72 20 74 68 65 20 74 61 pment for the ta
bdc0: 67 73 20 69 6e 20 61 20 63 68 61 6e 67 65 73 65 gs in a changese
bdd0: 74 2e 0a 0a 09 73 65 74 20 74 68 65 73 65 74 20 t....set theset
bde0: 28 27 5b 6a 6f 69 6e 20 24 74 61 67 73 20 7b 27 ('[join $tags {'
bdf0: 2c 27 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b ,'}]')..return [
be00: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 state run [subst
be10: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f -nocommands -no
be20: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 backslashes {..
be30: 20 20 20 53 45 4c 45 43 54 0a 09 20 20 20 20 44 SELECT.. D
be40: 49 53 54 49 4e 43 54 20 4c 2e 6e 61 6d 65 0a 09 ISTINCT L.name..
be50: 20 20 20 20 46 52 4f 4d 20 20 20 74 61 67 20 54 FROM tag T
be60: 2c 20 73 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20 , symbol L..
be70: 57 48 45 52 45 20 20 54 2e 74 69 64 20 69 6e 20 WHERE T.tid in
be80: 24 74 68 65 73 65 74 20 20 20 20 20 20 20 20 2d $theset -
be90: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 74 61 - Restrict to ta
bea0: 67 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 gs of interest..
beb0: 20 20 20 20 41 4e 44 20 20 20 20 4c 2e 73 69 64 AND L.sid
bec0: 20 3d 20 54 2e 6c 6f 64 20 20 20 20 20 20 20 20 = T.lod
bed0: 20 20 20 2d 2d 20 47 65 74 20 6c 6f 64 20 73 79 -- Get lod sy
bee0: 6d 62 6f 6c 20 6f 66 20 74 61 67 0a 09 7d 5d 5d mbol of tag..}]]
bef0: 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 . }.}..# # ##
bf00: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
bf10: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
bf20: 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 # ##############
bf30: 23 23 23 23 23 23 23 0a 23 23 20 48 65 6c 70 65 #######.## Helpe
bf40: 72 20 73 69 6e 67 6c 65 74 6f 6e 2e 20 43 6f 6d r singleton. Com
bf50: 6d 61 6e 64 73 20 66 6f 72 20 62 72 61 6e 63 68 mands for branch
bf60: 20 73 79 6d 62 6f 6c 20 63 68 61 6e 67 65 73 65 symbol changese
bf70: 74 73 2e 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 ts...snit::type
bf80: 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d ::vc::fossil::im
bf90: 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 port::cvs::proje
bfa0: 63 74 3a 3a 72 65 76 3a 3a 73 79 6d 3a 3a 62 72 ct::rev::sym::br
bfb0: 61 6e 63 68 20 7b 0a 20 20 20 20 74 79 70 65 6d anch {. typem
bfc0: 65 74 68 6f 64 20 62 79 72 65 76 69 73 69 6f 6e ethod byrevision
bfd0: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 30 20 7d {} { return 0 }
bfe0: 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 . typemethod
bff0: 62 79 73 79 6d 62 6f 6c 20 20 20 7b 7d 20 7b 20 bysymbol {} {
c000: 72 65 74 75 72 6e 20 31 20 7d 0a 20 20 20 20 74 return 1 }. t
c010: 79 70 65 6d 65 74 68 6f 64 20 69 73 74 61 67 20 ypemethod istag
c020: 20 20 20 20 20 7b 7d 20 7b 20 72 65 74 75 72 6e {} { return
c030: 20 30 20 7d 0a 20 20 20 20 74 79 70 65 6d 65 74 0 }. typemet
c040: 68 6f 64 20 69 73 62 72 61 6e 63 68 20 20 20 7b hod isbranch {
c050: 7d 20 7b 20 72 65 74 75 72 6e 20 31 20 7d 0a 0a } { return 1 }..
c060: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 73 typemethod s
c070: 74 72 20 7b 62 72 61 6e 63 68 7d 20 7b 0a 09 73 tr {branch} {..s
c080: 74 72 75 63 74 3a 3a 6c 69 73 74 20 61 73 73 69 truct::list assi
c090: 67 6e 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a gn [state run {.
c0a0: 09 20 20 20 20 53 45 4c 45 43 54 20 53 2e 6e 61 . SELECT S.na
c0b0: 6d 65 2c 20 46 2e 6e 61 6d 65 2c 20 50 2e 6e 61 me, F.name, P.na
c0c0: 6d 65 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 me.. FROM b
c0d0: 72 61 6e 63 68 20 42 2c 20 73 79 6d 62 6f 6c 20 ranch B, symbol
c0e0: 53 2c 20 66 69 6c 65 20 46 2c 20 70 72 6f 6a 65 S, file F, proje
c0f0: 63 74 20 50 0a 09 20 20 20 20 57 48 45 52 45 20 ct P.. WHERE
c100: 20 42 2e 62 69 64 20 3d 20 24 62 72 61 6e 63 68 B.bid = $branch
c110: 20 20 2d 2d 20 46 69 6e 64 20 73 70 65 63 69 66 -- Find specif
c120: 69 65 64 20 62 72 61 6e 63 68 0a 09 20 20 20 20 ied branch..
c130: 41 4e 44 20 20 20 20 46 2e 66 69 64 20 3d 20 42 AND F.fid = B
c140: 2e 66 69 64 20 20 20 20 2d 2d 20 47 65 74 20 66 .fid -- Get f
c150: 69 6c 65 20 6f 66 20 62 72 61 6e 63 68 0a 09 20 ile of branch..
c160: 20 20 20 41 4e 44 20 20 20 20 50 2e 70 69 64 20 AND P.pid
c170: 3d 20 46 2e 70 69 64 20 20 20 20 2d 2d 20 47 65 = F.pid -- Ge
c180: 74 20 70 72 6f 6a 65 63 74 20 6f 66 20 66 69 6c t project of fil
c190: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 53 2e e.. AND S.
c1a0: 73 69 64 20 3d 20 42 2e 73 69 64 20 20 20 20 2d sid = B.sid -
c1b0: 2d 20 47 65 74 20 73 79 6d 62 6f 6c 20 6f 66 20 - Get symbol of
c1c0: 62 72 61 6e 63 68 0a 09 7d 5d 20 73 6e 61 6d 65 branch..}] sname
c1d0: 20 66 6e 61 6d 65 20 70 6e 61 6d 65 0a 09 72 65 fname pname..re
c1e0: 74 75 72 6e 20 22 24 70 6e 61 6d 65 2f 42 27 24 turn "$pname/B'$
c1f0: 7b 73 6e 61 6d 65 7d 27 3a 3a 24 66 6e 61 6d 65 {sname}'::$fname
c200: 22 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 72 ". }.. # r
c210: 65 73 75 6c 74 20 3d 20 6c 69 73 74 20 28 6d 69 esult = list (mi
c220: 6e 74 69 6d 65 2c 20 6d 61 78 74 69 6d 65 29 0a ntime, maxtime).
c230: 20 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 74 typemethod t
c240: 69 6d 65 72 61 6e 67 65 20 7b 62 72 61 6e 63 68 imerange {branch
c250: 65 73 7d 20 7b 0a 09 23 20 54 68 65 20 72 61 6e es} {..# The ran
c260: 67 65 20 6f 66 20 61 20 62 72 61 6e 63 68 20 69 ge of a branch i
c270: 73 20 64 65 66 69 6e 65 64 20 61 73 20 74 68 65 s defined as the
c280: 20 72 61 6e 67 65 20 6f 66 20 74 68 65 0a 09 23 range of the..#
c290: 20 72 65 76 69 73 69 6f 6e 73 20 74 68 65 20 62 revisions the b
c2a0: 72 61 6e 63 68 65 73 20 61 72 65 20 73 70 61 77 ranches are spaw
c2b0: 6e 65 64 20 62 79 2e 20 4e 4f 54 45 20 68 6f 77 ned by. NOTE how
c2c0: 65 76 65 72 20 74 68 61 74 20 74 68 65 0a 09 23 ever that the..#
c2d0: 20 62 72 61 6e 63 68 65 73 20 61 73 73 6f 63 69 branches associ
c2e0: 61 74 65 64 20 77 69 74 68 20 61 20 64 65 74 61 ated with a deta
c2f0: 63 68 65 64 20 4e 54 44 42 20 77 69 6c 6c 20 68 ched NTDB will h
c300: 61 76 65 20 6e 6f 20 72 6f 6f 74 0a 09 23 20 73 ave no root..# s
c310: 70 61 77 6e 69 6e 67 20 74 68 65 6d 2c 20 68 65 pawning them, he
c320: 6e 63 65 20 74 68 65 79 20 68 61 76 65 20 6e 6f nce they have no
c330: 20 72 65 61 6c 20 74 69 6d 65 72 61 6e 67 65 20 real timerange
c340: 61 6e 79 0a 09 23 20 6c 6f 6e 67 65 72 2e 20 42 any..# longer. B
c350: 79 20 75 73 69 6e 67 20 30 20 77 65 20 70 75 74 y using 0 we put
c360: 20 74 68 65 6d 20 69 6e 20 66 72 6f 6e 74 20 6f them in front o
c370: 66 20 65 76 65 72 79 74 68 69 6e 67 20 65 6c 73 f everything els
c380: 65 2c 0a 09 23 20 61 73 20 74 68 65 79 20 6c 6f e,..# as they lo
c390: 67 69 63 61 6c 6c 79 20 61 72 65 2e 0a 0a 09 73 gically are....s
c3a0: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 et theset ('[joi
c3b0: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 n $branches {','
c3c0: 7d 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 }]')..return [st
c3d0: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d ate run [subst -
c3e0: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 nocommands -noba
c3f0: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 ckslashes {..
c400: 20 53 45 4c 45 43 54 20 49 46 4e 55 4c 4c 28 4d SELECT IFNULL(M
c410: 49 4e 28 52 2e 64 61 74 65 29 2c 30 29 2c 20 49 IN(R.date),0), I
c420: 46 4e 55 4c 4c 28 4d 41 58 28 52 2e 64 61 74 65 FNULL(MAX(R.date
c430: 29 2c 30 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 ),0).. FROM
c440: 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 branch B, revisi
c450: 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 45 20 on R.. WHERE
c460: 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 B.bid IN $theset
c470: 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 -- Restrict t
c480: 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e o branches of in
c490: 74 65 72 65 73 74 0a 20 20 20 20 20 20 20 20 20 terest.
c4a0: 20 20 20 41 4e 44 20 20 20 52 2e 72 69 64 20 3d AND R.rid =
c4b0: 20 42 2e 72 6f 6f 74 20 20 20 20 20 2d 2d 20 53 B.root -- S
c4c0: 65 6c 65 63 74 20 62 72 61 6e 63 68 20 70 61 72 elect branch par
c4d0: 65 6e 74 20 72 65 76 69 73 69 6f 6e 73 0a 09 7d ent revisions..}
c4e0: 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 20 ]]. }.. #
c4f0: 72 65 73 75 6c 74 20 3d 20 34 2d 6c 69 73 74 20 result = 4-list
c500: 28 69 74 65 6d 74 79 70 65 20 69 74 65 6d 69 64 (itemtype itemid
c510: 20 6e 65 78 74 69 74 65 6d 74 79 70 65 20 6e 65 nextitemtype ne
c520: 78 74 69 74 65 6d 69 64 20 2e 2e 2e 29 0a 20 20 xtitemid ...).
c530: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 6c 6f 6f typemethod loo
c540: 70 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a ps {branches} {.
c550: 09 23 20 4e 6f 74 65 3a 20 52 65 76 69 73 69 6f .# Note: Revisio
c560: 6e 73 20 61 6e 64 20 74 61 67 73 20 63 61 6e 6e ns and tags cann
c570: 6f 74 20 63 61 75 73 65 20 74 68 65 20 6c 6f 6f ot cause the loo
c580: 70 2e 20 42 65 69 6e 67 20 6f 66 20 61 0a 09 23 p. Being of a..#
c590: 20 66 75 6e 64 61 6d 65 6e 74 61 6c 6c 79 20 64 fundamentally d
c5a0: 69 66 66 65 72 65 6e 74 20 74 79 70 65 20 74 68 ifferent type th
c5b0: 65 79 20 63 61 6e 6e 6f 74 20 62 65 20 69 6e 20 ey cannot be in
c5c0: 74 68 65 20 69 6e 63 6f 6d 69 6e 67 0a 09 23 20 the incoming..#
c5d0: 73 65 74 20 6f 66 20 69 64 73 2e 0a 0a 09 73 65 set of ids....se
c5e0: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e t theset ('[join
c5f0: 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d $branches {','}
c600: 5d 27 29 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 ]')..return [sta
c610: 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e te run [subst -n
c620: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 ocommands -nobac
c630: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 kslashes {..
c640: 53 45 4c 45 43 54 20 42 2e 62 69 64 2c 20 42 58 SELECT B.bid, BX
c650: 2e 62 69 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 .bid.. FROM
c660: 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 branch B, prefe
c670: 72 65 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61 redparent P, bra
c680: 6e 63 68 20 42 58 0a 09 20 20 20 20 57 48 45 52 nch BX.. WHER
c690: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 E B.bid IN $the
c6a0: 73 65 74 20 20 20 2d 2d 20 52 65 73 74 72 69 63 set -- Restric
c6b0: 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 t to branches of
c6c0: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 interest.. A
c6d0: 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e ND B.sid = P.
c6e0: 70 69 64 20 20 20 20 20 20 2d 2d 20 47 65 74 20 pid -- Get
c6f0: 74 68 65 20 70 72 65 66 65 72 65 64 20 62 72 61 the prefered bra
c700: 6e 63 68 65 73 20 76 69 61 0a 09 20 20 20 20 41 nches via.. A
c710: 4e 44 20 20 20 20 42 58 2e 73 69 64 20 3d 20 50 ND BX.sid = P
c720: 2e 73 69 64 20 20 20 20 20 2d 2d 20 74 68 65 20 .sid -- the
c730: 62 72 61 6e 63 68 20 73 79 6d 62 6f 6c 73 0a 09 branch symbols..
c740: 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e 62 69 AND BX.bi
c750: 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 2d 2d d IN $theset --
c760: 20 4c 6f 6f 70 0a 09 7d 5d 5d 0a 20 20 20 20 7d Loop..}]]. }
c770: 0a 0a 20 20 20 20 23 20 76 61 72 28 64 76 29 20 .. # var(dv)
c780: 3d 20 64 69 63 74 20 28 69 74 65 6d 20 2d 3e 20 = dict (item ->
c790: 6c 69 73 74 20 28 69 74 65 6d 29 29 2c 20 69 74 list (item)), it
c7a0: 65 6d 20 20 3d 20 6c 69 73 74 20 28 74 79 70 65 em = list (type
c7b0: 20 69 64 29 0a 20 20 20 20 74 79 70 65 6d 65 74 id). typemet
c7c0: 68 6f 64 20 73 75 63 63 65 73 73 6f 72 73 20 7b hod successors {
c7d0: 64 76 20 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 dv branches} {..
c7e0: 75 70 76 61 72 20 31 20 24 64 76 20 64 65 70 65 upvar 1 $dv depe
c7f0: 6e 64 65 6e 63 69 65 73 0a 09 23 20 54 68 65 20 ndencies..# The
c800: 66 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 63 first revision c
c810: 6f 6d 6d 69 74 74 65 64 20 6f 6e 20 61 20 62 72 ommitted on a br
c820: 61 6e 63 68 2c 20 61 6e 64 20 61 6c 6c 20 62 72 anch, and all br
c830: 61 6e 63 68 65 73 0a 09 23 20 61 6e 64 20 74 61 anches..# and ta
c840: 67 73 20 77 68 69 63 68 20 68 61 76 65 20 69 74 gs which have it
c850: 20 61 73 20 74 68 65 69 72 20 70 72 65 66 65 72 as their prefer
c860: 65 64 20 70 61 72 65 6e 74 20 61 72 65 20 74 68 ed parent are th
c870: 65 0a 09 23 20 73 75 63 63 65 73 73 6f 72 73 20 e..# successors
c880: 6f 66 20 61 20 62 72 61 6e 63 68 2e 0a 0a 09 73 of a branch....s
c890: 65 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 et theset ('[joi
c8a0: 6e 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 n $branches {','
c8b0: 7d 5d 27 29 0a 09 73 74 61 74 65 20 66 6f 72 65 }]')..state fore
c8c0: 61 63 68 72 6f 77 20 5b 73 75 62 73 74 20 2d 6e achrow [subst -n
c8d0: 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 ocommands -nobac
c8e0: 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 20 kslashes {..
c8f0: 53 45 4c 45 43 54 20 42 2e 62 69 64 20 41 53 20 SELECT B.bid AS
c900: 78 62 69 64 2c 20 52 2e 72 69 64 20 41 53 20 78 xbid, R.rid AS x
c910: 63 68 69 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 child.. FROM
c920: 20 20 62 72 61 6e 63 68 20 42 2c 20 72 65 76 69 branch B, revi
c930: 73 69 6f 6e 20 52 0a 09 20 20 20 20 57 48 45 52 sion R.. WHER
c940: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 E B.bid IN $the
c950: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 set -- Restr
c960: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 ict to branches
c970: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
c980: 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20 AND B.first
c990: 3d 20 52 2e 72 69 64 20 20 20 20 20 20 2d 2d 20 = R.rid --
c9a0: 47 65 74 20 66 69 72 73 74 20 72 65 76 69 73 69 Get first revisi
c9b0: 6f 6e 20 6f 6e 20 74 68 65 20 62 72 61 6e 63 68 on on the branch
c9c0: 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 6c 61 70 70 ..}] {.. lapp
c9d0: 65 6e 64 20 64 65 70 65 6e 64 65 6e 63 69 65 73 end dependencies
c9e0: 28 5b 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e ([list sym::bran
c9f0: 63 68 20 24 78 62 69 64 5d 29 20 5b 6c 69 73 74 ch $xbid]) [list
ca00: 20 72 65 76 20 24 78 63 68 69 6c 64 5d 0a 09 7d rev $xchild]..}
ca10: 0a 09 73 74 61 74 65 20 66 6f 72 65 61 63 68 72 ..state foreachr
ca20: 6f 77 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d ow [subst -nocom
ca30: 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 mands -nobacksla
ca40: 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c 45 shes {.. SELE
ca50: 43 54 20 42 2e 62 69 64 20 41 53 20 78 62 69 64 CT B.bid AS xbid
ca60: 2c 20 42 58 2e 62 69 64 20 41 53 20 78 63 68 69 , BX.bid AS xchi
ca70: 6c 64 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 ld.. FROM b
ca80: 72 61 6e 63 68 20 42 2c 20 70 72 65 66 65 72 65 ranch B, prefere
ca90: 64 70 61 72 65 6e 74 20 50 2c 20 62 72 61 6e 63 dparent P, branc
caa0: 68 20 42 58 0a 09 20 20 20 20 57 48 45 52 45 20 h BX.. WHERE
cab0: 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 B.bid IN $these
cac0: 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 t -- Restric
cad0: 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 t to branches of
cae0: 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 interest.. A
caf0: 4e 44 20 20 20 20 42 2e 73 69 64 20 3d 20 50 2e ND B.sid = P.
cb00: 70 69 64 20 20 20 20 20 20 20 20 2d 2d 20 47 65 pid -- Ge
cb10: 74 20 73 75 62 6f 72 64 69 6e 61 74 65 20 62 72 t subordinate br
cb20: 61 6e 63 68 65 73 20 76 69 61 20 74 68 65 0a 09 anches via the..
cb30: 20 20 20 20 41 4e 44 20 20 20 20 42 58 2e 73 69 AND BX.si
cb40: 64 20 3d 20 50 2e 73 69 64 20 20 20 20 20 20 20 d = P.sid
cb50: 2d 2d 20 70 72 65 66 65 72 65 64 20 70 61 72 65 -- prefered pare
cb60: 6e 74 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d nts of their sym
cb70: 62 6f 6c 73 0a 09 7d 5d 20 7b 0a 09 20 20 20 20 bols..}] {..
cb80: 6c 61 70 70 65 6e 64 20 64 65 70 65 6e 64 65 6e lappend dependen
cb90: 63 69 65 73 28 5b 6c 69 73 74 20 73 79 6d 3a 3a cies([list sym::
cba0: 62 72 61 6e 63 68 20 24 78 62 69 64 5d 29 20 5b branch $xbid]) [
cbb0: 6c 69 73 74 20 73 79 6d 3a 3a 62 72 61 6e 63 68 list sym::branch
cbc0: 20 24 78 63 68 69 6c 64 5d 0a 09 7d 0a 09 73 74 $xchild]..}..st
cbd0: 61 74 65 20 66 6f 72 65 61 63 68 72 6f 77 20 5b ate foreachrow [
cbe0: 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 subst -nocommand
cbf0: 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 73 s -nobackslashes
cc00: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 {.. SELECT B
cc10: 2e 62 69 64 20 41 53 20 78 62 69 64 2c 20 54 2e .bid AS xbid, T.
cc20: 74 69 64 20 41 53 20 78 63 68 69 6c 64 0a 09 20 tid AS xchild..
cc30: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 FROM branch
cc40: 20 42 2c 20 70 72 65 66 65 72 65 64 70 61 72 65 B, preferedpare
cc50: 6e 74 20 50 2c 20 74 61 67 20 54 0a 09 20 20 20 nt P, tag T..
cc60: 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 49 4e WHERE B.bid IN
cc70: 20 24 74 68 65 73 65 74 20 20 20 20 20 2d 2d 20 $theset --
cc80: 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e Restrict to bran
cc90: 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 ches of interest
cca0: 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 2e 73 .. AND B.s
ccb0: 69 64 20 3d 20 50 2e 70 69 64 20 20 20 20 20 20 id = P.pid
ccc0: 20 20 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 69 -- Get subordi
ccd0: 6e 61 74 65 20 74 61 67 73 20 76 69 61 20 74 68 nate tags via th
cce0: 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 54 2e e.. AND T.
ccf0: 73 69 64 20 3d 20 50 2e 73 69 64 20 20 20 20 20 sid = P.sid
cd00: 20 20 20 2d 2d 20 70 72 65 66 65 72 65 64 20 70 -- prefered p
cd10: 61 72 65 6e 74 73 20 6f 66 20 74 68 65 69 72 20 arents of their
cd20: 73 79 6d 62 6f 6c 73 0a 09 7d 5d 20 7b 0a 09 20 symbols..}] {..
cd30: 20 20 20 6c 61 70 70 65 6e 64 20 64 65 70 65 6e lappend depen
cd40: 64 65 6e 63 69 65 73 28 5b 6c 69 73 74 20 73 79 dencies([list sy
cd50: 6d 3a 3a 62 72 61 6e 63 68 20 24 78 62 69 64 5d m::branch $xbid]
cd60: 29 20 5b 6c 69 73 74 20 73 79 6d 3a 3a 74 61 67 ) [list sym::tag
cd70: 20 24 78 63 68 69 6c 64 5d 0a 09 7d 0a 09 72 65 $xchild]..}..re
cd80: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
cd90: 23 20 72 65 73 75 6c 74 20 3d 20 6c 69 73 74 20 # result = list
cda0: 28 63 68 61 6e 67 65 73 65 74 2d 69 64 29 0a 20 (changeset-id).
cdb0: 20 20 20 74 79 70 65 6d 65 74 68 6f 64 20 63 73 typemethod cs
cdc0: 5f 73 75 63 63 65 73 73 6f 72 73 20 7b 62 72 61 _successors {bra
cdd0: 6e 63 68 65 73 7d 20 7b 0a 20 20 20 20 20 20 20 nches} {.
cde0: 20 23 20 54 68 69 73 20 69 73 20 61 20 76 61 72 # This is a var
cdf0: 69 61 6e 74 20 6f 66 20 27 73 75 63 63 65 73 73 iant of 'success
ce00: 6f 72 73 27 20 77 68 69 63 68 20 6d 61 70 73 20 ors' which maps
ce10: 74 68 65 20 6c 6f 77 2d 6c 65 76 65 6c 0a 20 20 the low-level.
ce20: 20 20 20 20 20 20 23 20 64 61 74 61 20 64 69 72 # data dir
ce30: 65 63 74 6c 79 20 74 6f 20 74 68 65 20 61 73 73 ectly to the ass
ce40: 6f 63 69 61 74 65 64 20 63 68 61 6e 67 65 73 65 ociated changese
ce50: 74 73 2e 20 49 2e 65 2e 20 69 6e 73 74 65 61 64 ts. I.e. instead
ce60: 0a 20 20 20 20 20 20 20 20 23 20 6d 69 6c 6c 69 . # milli
ce70: 6f 6e 73 20 6f 66 20 64 65 70 65 6e 64 65 6e 63 ons of dependenc
ce80: 79 20 70 61 69 72 73 20 28 69 6e 20 65 78 74 72 y pairs (in extr
ce90: 65 6d 65 20 63 61 73 65 73 20 28 45 78 61 6d 70 eme cases (Examp
cea0: 6c 65 3a 20 54 63 6c 0a 20 20 20 20 20 20 20 20 le: Tcl.
ceb0: 23 20 43 56 53 29 29 20 77 65 20 72 65 74 75 72 # CVS)) we retur
cec0: 6e 20 61 20 76 65 72 79 20 73 68 6f 72 74 20 61 n a very short a
ced0: 6e 64 20 6d 75 63 68 20 6d 6f 72 65 20 6d 61 6e nd much more man
cee0: 61 67 65 61 62 6c 65 20 6c 69 73 74 0a 20 20 20 ageable list.
cef0: 20 20 20 20 20 23 20 6f 66 20 63 68 61 6e 67 65 # of change
cf00: 73 65 74 73 2e 0a 0a 09 73 65 74 20 74 68 65 73 sets....set thes
cf10: 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 72 61 6e et ('[join $bran
cf20: 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 0a 20 20 ches {','}]').
cf30: 20 20 20 20 20 20 72 65 74 75 72 6e 20 5b 73 74 return [st
cf40: 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 20 2d ate run [subst -
cf50: 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 nocommands -noba
cf60: 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 20 20 ckslashes {..
cf70: 20 53 45 4c 45 43 54 20 43 2e 63 69 64 0a 09 20 SELECT C.cid..
cf80: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 FROM branch
cf90: 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 B, revision R,
cfa0: 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 csitem CI, chang
cfb0: 65 73 65 74 20 43 0a 09 20 20 20 20 57 48 45 52 eset C.. WHER
cfc0: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 E B.bid IN $the
cfd0: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 set -- Restr
cfe0: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 ict to branches
cff0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
d000: 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20 AND B.first
d010: 3d 20 52 2e 72 69 64 09 2d 2d 20 47 65 74 20 66 = R.rid.-- Get f
d020: 69 72 73 74 20 72 65 76 69 73 69 6f 6e 20 6f 6e irst revision on
d030: 20 74 68 65 20 62 72 61 6e 63 68 0a 20 20 20 20 the branch.
d040: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 AND C
d050: 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 20 20 20 I.iid = R.rid
d060: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c -- Select al
d070: 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 l changesets.
d080: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 AND
d090: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 2d C.cid = CI.cid.-
d0a0: 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 69 - containing thi
d0b0: 73 20 72 65 76 69 73 69 6f 6e 0a 20 20 20 20 20 s revision.
d0c0: 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 2e AND C.
d0d0: 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 77 68 69 type = 0..-- whi
d0e0: 63 68 20 61 72 65 20 72 65 76 69 73 69 6f 6e 20 ch are revision
d0f0: 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 55 changesets. U
d100: 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43 54 NION.. SELECT
d110: 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f 4d C.cid.. FROM
d120: 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70 72 65 branch B, pre
d130: 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20 62 feredparent P, b
d140: 72 61 6e 63 68 20 42 58 2c 20 63 73 69 74 65 6d ranch BX, csitem
d150: 20 43 49 2c 20 63 68 61 6e 67 65 73 65 74 20 43 CI, changeset C
d160: 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 2e 62 .. WHERE B.b
d170: 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 20 20 id IN $theset
d180: 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 74 6f -- Restrict to
d190: 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 branches of int
d1a0: 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 20 20 erest.. AND
d1b0: 20 20 42 2e 73 69 64 20 3d 20 50 2e 70 69 64 09 B.sid = P.pid.
d1c0: 2d 2d 20 47 65 74 20 73 75 62 6f 72 64 69 6e 61 -- Get subordina
d1d0: 74 65 20 62 72 61 6e 63 68 65 73 20 76 69 61 20 te branches via
d1e0: 74 68 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 the.. AND
d1f0: 42 58 2e 73 69 64 20 3d 20 50 2e 73 69 64 09 2d BX.sid = P.sid.-
d200: 2d 20 70 72 65 66 65 72 65 64 20 70 61 72 65 6e - prefered paren
d210: 74 73 20 6f 66 20 74 68 65 69 72 20 73 79 6d 62 ts of their symb
d220: 6f 6c 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 ols.
d230: 41 4e 44 20 20 20 20 43 49 2e 69 69 64 20 3d 20 AND CI.iid =
d240: 42 58 2e 62 69 64 20 20 20 20 20 20 2d 2d 20 53 BX.bid -- S
d250: 65 6c 65 63 74 20 61 6c 6c 20 63 68 61 6e 67 65 elect all change
d260: 73 65 74 73 0a 20 20 20 20 20 20 20 20 20 20 20 sets.
d270: 20 41 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 AND C.cid =
d280: 43 49 2e 63 69 64 09 2d 2d 20 63 6f 6e 74 61 69 CI.cid.-- contai
d290: 6e 69 6e 67 20 74 68 65 20 73 75 62 6f 72 64 69 ning the subordi
d2a0: 6e 61 74 65 20 62 72 61 6e 63 68 65 73 0a 20 20 nate branches.
d2b0: 20 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 AND
d2c0: 20 43 2e 74 79 70 65 20 3d 20 32 09 09 2d 2d 20 C.type = 2..--
d2d0: 77 68 69 63 68 20 61 72 65 20 62 72 61 6e 63 68 which are branch
d2e0: 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 20 changesets.
d2f0: 55 4e 49 4f 4e 0a 09 20 20 20 20 53 45 4c 45 43 UNION.. SELEC
d300: 54 20 43 2e 63 69 64 0a 09 20 20 20 20 46 52 4f T C.cid.. FRO
d310: 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 70 72 M branch B, pr
d320: 65 66 65 72 65 64 70 61 72 65 6e 74 20 50 2c 20 eferedparent P,
d330: 74 61 67 20 54 2c 20 63 73 69 74 65 6d 20 43 49 tag T, csitem CI
d340: 2c 20 63 68 61 6e 67 65 73 65 74 20 43 0a 09 20 , changeset C..
d350: 20 20 20 57 48 45 52 45 20 20 42 2e 62 69 64 20 WHERE B.bid
d360: 49 4e 20 24 74 68 65 73 65 74 20 20 20 20 20 2d IN $theset -
d370: 2d 20 52 65 73 74 72 69 63 74 20 74 6f 20 62 72 - Restrict to br
d380: 61 6e 63 68 65 73 20 6f 66 20 69 6e 74 65 72 65 anches of intere
d390: 73 74 0a 09 20 20 20 20 41 4e 44 20 20 20 20 42 st.. AND B
d3a0: 2e 73 69 64 20 3d 20 50 2e 70 69 64 09 2d 2d 20 .sid = P.pid.--
d3b0: 47 65 74 20 73 75 62 6f 72 64 69 6e 61 74 65 20 Get subordinate
d3c0: 74 61 67 73 20 76 69 61 20 74 68 65 0a 09 20 20 tags via the..
d3d0: 20 20 41 4e 44 20 20 20 20 54 2e 73 69 64 20 3d AND T.sid =
d3e0: 20 50 2e 73 69 64 09 2d 2d 20 70 72 65 66 65 72 P.sid.-- prefer
d3f0: 65 64 20 70 61 72 65 6e 74 73 20 6f 66 20 74 68 ed parents of th
d400: 65 69 72 20 73 79 6d 62 6f 6c 73 0a 20 20 20 20 eir symbols.
d410: 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 43 AND C
d420: 49 2e 69 69 64 20 3d 20 54 2e 74 69 64 20 20 20 I.iid = T.tid
d430: 20 20 20 20 2d 2d 20 53 65 6c 65 63 74 20 61 6c -- Select al
d440: 6c 20 63 68 61 6e 67 65 73 65 74 73 0a 20 20 20 l changesets.
d450: 20 20 20 20 20 20 20 20 20 41 4e 44 20 20 20 20 AND
d460: 43 2e 63 69 64 20 3d 20 43 49 2e 63 69 64 09 2d C.cid = CI.cid.-
d470: 2d 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 68 65 - containing the
d480: 20 73 75 62 6f 72 64 69 6e 61 74 65 20 74 61 67 subordinate tag
d490: 73 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 4e s. AN
d4a0: 44 20 20 20 20 43 2e 74 79 70 65 20 3d 20 31 09 D C.type = 1.
d4b0: 09 2d 2d 20 77 68 69 63 68 20 61 72 65 20 74 61 .-- which are ta
d4c0: 67 20 63 68 61 6e 67 65 73 65 74 73 0a 09 7d 5d g changesets..}]
d4d0: 5d 0a 09 72 65 74 75 72 6e 0a 20 20 20 20 7d 0a ]..return. }.
d4e0: 0a 20 20 20 20 23 20 72 65 73 75 6c 74 20 3d 20 . # result =
d4f0: 73 79 6d 62 6f 6c 20 6e 61 6d 65 0a 20 20 20 20 symbol name.
d500: 74 79 70 65 6d 65 74 68 6f 64 20 63 73 5f 6c 6f typemethod cs_lo
d510: 64 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 d {branches} {..
d520: 23 20 44 65 74 65 72 6d 69 6e 65 73 20 74 68 65 # Determines the
d530: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 73 79 6d name of the sym
d540: 62 6f 6c 20 77 68 69 63 68 20 69 73 20 74 68 65 bol which is the
d550: 20 6c 69 6e 65 20 6f 66 0a 09 23 20 64 65 76 65 line of..# deve
d560: 6c 6f 70 6d 65 6e 74 20 66 6f 72 20 74 68 65 20 lopment for the
d570: 62 72 61 6e 63 68 65 73 20 69 6e 20 61 20 63 68 branches in a ch
d580: 61 6e 67 65 73 65 74 2e 0a 0a 09 73 65 74 20 74 angeset....set t
d590: 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e 20 24 62 heset ('[join $b
d5a0: 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d 5d 27 29 ranches {','}]')
d5b0: 0a 09 72 65 74 75 72 6e 20 5b 73 74 61 74 65 20 ..return [state
d5c0: 72 75 6e 20 5b 73 75 62 73 74 20 2d 6e 6f 63 6f run [subst -noco
d5d0: 6d 6d 61 6e 64 73 20 2d 6e 6f 62 61 63 6b 73 6c mmands -nobacksl
d5e0: 61 73 68 65 73 20 7b 0a 09 20 20 20 20 53 45 4c ashes {.. SEL
d5f0: 45 43 54 0a 09 20 20 20 20 44 49 53 54 49 4e 43 ECT.. DISTINC
d600: 54 20 4c 2e 6e 61 6d 65 0a 09 20 20 20 20 46 52 T L.name.. FR
d610: 4f 4d 20 20 20 62 72 61 6e 63 68 20 42 2c 20 73 OM branch B, s
d620: 79 6d 62 6f 6c 20 4c 0a 09 20 20 20 20 57 48 45 ymbol L.. WHE
d630: 52 45 20 20 42 2e 62 69 64 20 69 6e 20 24 74 68 RE B.bid in $th
d640: 65 73 65 74 20 20 20 20 20 20 20 20 2d 2d 20 52 eset -- R
d650: 65 73 74 72 69 63 74 20 74 6f 20 62 72 61 6e 63 estrict to branc
d660: 68 65 73 20 6f 66 20 69 6e 74 65 72 65 73 74 0a hes of interest.
d670: 09 20 20 20 20 41 4e 44 20 20 20 20 4c 2e 73 69 . AND L.si
d680: 64 20 3d 20 42 2e 6c 6f 64 20 20 20 20 20 20 20 d = B.lod
d690: 20 20 20 20 2d 2d 20 47 65 74 20 6c 6f 64 20 73 -- Get lod s
d6a0: 79 6d 62 6f 6c 20 6f 66 20 62 72 61 6e 63 68 0a ymbol of branch.
d6b0: 09 7d 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 .}]]. }..
d6c0: 74 79 70 65 6d 65 74 68 6f 64 20 6c 69 6d 69 74 typemethod limit
d6d0: 73 20 7b 62 72 61 6e 63 68 65 73 7d 20 7b 0a 09 s {branches} {..
d6e0: 23 20 4e 6f 74 65 73 2e 20 54 68 69 73 20 6d 65 # Notes. This me
d6f0: 74 68 6f 64 20 65 78 69 73 74 73 20 6f 6e 6c 79 thod exists only
d700: 20 66 6f 72 20 62 72 61 6e 63 68 65 73 2e 20 49 for branches. I
d710: 74 20 69 73 20 6e 65 65 64 65 64 20 74 6f 0a 09 t is needed to..
d720: 23 20 67 65 74 20 64 65 74 61 69 6c 65 64 20 69 # get detailed i
d730: 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74 nformation about
d740: 20 61 20 62 61 63 6b 77 61 72 64 20 62 72 61 6e a backward bran
d750: 63 68 2e 20 49 74 20 64 6f 65 73 0a 09 23 20 6e ch. It does..# n
d760: 6f 74 20 61 70 70 6c 79 20 74 6f 20 74 61 67 73 ot apply to tags
d770: 2c 20 6e 6f 72 20 72 65 76 69 73 69 6f 6e 73 2e , nor revisions.
d780: 20 54 68 65 20 71 75 65 72 69 65 73 20 63 61 6e The queries can
d790: 20 61 6c 73 6f 0a 09 23 20 72 65 73 74 72 69 63 also..# restric
d7a0: 74 20 74 68 65 6d 73 65 6c 76 65 73 20 74 6f 20 t themselves to
d7b0: 74 68 65 20 72 65 76 69 73 69 6f 6e 20 73 75 63 the revision suc
d7c0: 65 73 73 6f 72 73 2f 70 72 65 64 65 63 65 73 73 essors/predecess
d7d0: 6f 72 73 0a 09 23 20 6f 66 20 62 72 61 6e 63 68 ors..# of branch
d7e0: 65 73 2c 20 61 73 20 6f 6e 6c 79 20 74 68 65 79 es, as only they
d7f0: 20 68 61 76 65 20 6f 72 64 65 72 69 6e 67 20 64 have ordering d
d800: 61 74 61 20 61 6e 64 20 74 68 75 73 20 63 61 6e ata and thus can
d810: 0a 09 23 20 63 61 75 73 65 20 74 68 65 20 62 61 ..# cause the ba
d820: 63 6b 77 61 72 64 6e 65 73 73 2e 0a 0a 09 73 65 ckwardness....se
d830: 74 20 74 68 65 73 65 74 20 28 27 5b 6a 6f 69 6e t theset ('[join
d840: 20 24 62 72 61 6e 63 68 65 73 20 7b 27 2c 27 7d $branches {','}
d850: 5d 27 29 0a 0a 09 73 65 74 20 6d 61 78 70 20 5b ]')...set maxp [
d860: 73 74 61 74 65 20 72 75 6e 20 5b 73 75 62 73 74 state run [subst
d870: 20 2d 6e 6f 63 6f 6d 6d 61 6e 64 73 20 2d 6e 6f -nocommands -no
d880: 62 61 63 6b 73 6c 61 73 68 65 73 20 7b 0a 09 20 backslashes {..
d890: 20 20 20 2d 2d 20 6d 61 78 69 6d 61 6c 20 70 72 -- maximal pr
d8a0: 65 64 65 63 65 73 73 6f 72 20 70 6f 73 69 74 69 edecessor positi
d8b0: 6f 6e 20 70 65 72 20 62 72 61 6e 63 68 0a 09 20 on per branch..
d8c0: 20 20 20 53 45 4c 45 43 54 20 42 2e 62 69 64 2c SELECT B.bid,
d8d0: 20 4d 41 58 20 28 43 4f 2e 70 6f 73 29 0a 09 20 MAX (CO.pos)..
d8e0: 20 20 20 46 52 4f 4d 20 20 20 62 72 61 6e 63 68 FROM branch
d8f0: 20 42 2c 20 72 65 76 69 73 69 6f 6e 20 52 2c 20 B, revision R,
d900: 63 73 69 74 65 6d 20 43 49 2c 20 63 68 61 6e 67 csitem CI, chang
d910: 65 73 65 74 20 43 2c 20 63 73 6f 72 64 65 72 20 eset C, csorder
d920: 43 4f 0a 09 20 20 20 20 57 48 45 52 45 20 20 42 CO.. WHERE B
d930: 2e 62 69 64 20 49 4e 20 24 74 68 65 73 65 74 20 .bid IN $theset
d940: 20 20 20 20 2d 2d 20 52 65 73 74 72 69 63 74 20 -- Restrict
d950: 74 6f 20 62 72 61 6e 63 68 65 73 20 6f 66 20 69 to branches of i
d960: 6e 74 65 72 65 73 74 0a 09 20 20 20 20 41 4e 44 nterest.. AND
d970: 20 20 20 20 42 2e 72 6f 6f 74 20 3d 20 52 2e 72 B.root = R.r
d980: 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 id -- Get
d990: 62 72 61 6e 63 68 20 72 6f 6f 74 20 72 65 76 69 branch root revi
d9a0: 73 69 6f 6e 73 0a 09 20 20 20 20 41 4e 44 20 20 sions.. AND
d9b0: 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 72 69 64 CI.iid = R.rid
d9c0: 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 63 68 -- Get ch
d9d0: 61 6e 67 65 73 65 74 73 20 63 6f 6e 74 61 69 6e angesets contain
d9e0: 69 6e 67 20 74 68 65 0a 09 20 20 20 20 41 4e 44 ing the.. AND
d9f0: 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 2e 63 C.cid = CI.c
da00: 69 64 20 20 20 20 20 20 20 2d 2d 20 72 6f 6f 74 id -- root
da10: 20 72 65 76 69 73 69 6f 6e 73 2c 20 77 68 69 63 revisions, whic
da20: 68 20 61 72 65 0a 09 20 20 20 20 41 4e 44 20 20 h are.. AND
da30: 20 20 43 2e 74 79 70 65 20 3d 20 30 20 20 20 20 C.type = 0
da40: 20 20 20 20 20 20 20 2d 2d 20 72 65 76 69 73 69 -- revisi
da50: 6f 6e 20 63 68 61 6e 67 65 73 65 74 73 0a 09 20 on changesets..
da60: 20 20 20 41 4e 44 20 20 20 20 43 4f 2e 63 69 64 AND CO.cid
da70: 20 3d 20 43 2e 63 69 64 20 20 20 20 20 20 20 2d = C.cid -
da80: 2d 20 47 65 74 20 74 68 65 69 72 20 74 6f 70 6f - Get their topo
da90: 6c 6f 67 69 63 61 6c 20 6f 72 64 65 72 69 6e 67 logical ordering
daa0: 0a 09 20 20 20 20 47 52 4f 55 50 20 42 59 20 42 .. GROUP BY B
dab0: 2e 62 69 64 0a 09 7d 5d 5d 0a 0a 09 73 65 74 20 .bid..}]]...set
dac0: 6d 69 6e 73 20 5b 73 74 61 74 65 20 72 75 6e 20 mins [state run
dad0: 5b 73 75 62 73 74 20 2d 6e 6f 63 6f 6d 6d 61 6e [subst -nocomman
dae0: 64 73 20 2d 6e 6f 62 61 63 6b 73 6c 61 73 68 65 ds -nobackslashe
daf0: 73 20 7b 0a 09 20 20 20 20 2d 2d 20 6d 69 6e 69 s {.. -- mini
db00: 6d 61 6c 20 73 75 63 63 65 73 73 6f 72 20 70 6f mal successor po
db10: 73 69 74 69 6f 6e 20 70 65 72 20 62 72 61 6e 63 sition per branc
db20: 68 0a 09 20 20 20 20 53 45 4c 45 43 54 20 42 2e h.. SELECT B.
db30: 62 69 64 2c 20 4d 49 4e 20 28 43 4f 2e 70 6f 73 bid, MIN (CO.pos
db40: 29 0a 09 20 20 20 20 46 52 4f 4d 20 20 20 62 72 ).. FROM br
db50: 61 6e 63 68 20 42 2c 20 72 65 76 69 73 69 6f 6e anch B, revision
db60: 20 52 2c 20 63 73 69 74 65 6d 20 43 49 2c 20 63 R, csitem CI, c
db70: 68 61 6e 67 65 73 65 74 20 43 2c 20 63 73 6f 72 hangeset C, csor
db80: 64 65 72 20 43 4f 0a 09 20 20 20 20 57 48 45 52 der CO.. WHER
db90: 45 20 20 42 2e 62 69 64 20 49 4e 20 24 74 68 65 E B.bid IN $the
dba0: 73 65 74 20 20 20 20 20 2d 2d 20 52 65 73 74 72 set -- Restr
dbb0: 69 63 74 20 74 6f 20 62 72 61 6e 63 68 65 73 20 ict to branches
dbc0: 6f 66 20 69 6e 74 65 72 65 73 74 0a 09 20 20 20 of interest..
dbd0: 20 41 4e 44 20 20 20 20 42 2e 66 69 72 73 74 20 AND B.first
dbe0: 3d 20 52 2e 72 69 64 20 20 20 20 20 20 2d 2d 20 = R.rid --
dbf0: 47 65 74 20 74 68 65 20 66 69 72 73 74 20 72 65 Get the first re
dc00: 76 69 73 69 6f 6e 73 20 6f 6e 20 74 68 65 20 62 visions on the b
dc10: 72 61 6e 63 68 65 73 0a 09 20 20 20 20 41 4e 44 ranches.. AND
dc20: 20 20 20 20 43 49 2e 69 69 64 20 3d 20 52 2e 72 CI.iid = R.r
dc30: 69 64 20 20 20 20 20 20 20 2d 2d 20 47 65 74 20 id -- Get
dc40: 63 68 61 6e 67 65 73 65 74 73 20 63 6f 6e 74 61 changesets conta
dc50: 69 6e 69 6e 67 20 74 68 65 0a 09 20 20 20 20 41 ining the.. A
dc60: 4e 44 20 20 20 20 43 2e 63 69 64 20 3d 20 43 49 ND C.cid = CI
dc70: 2e 63 69 64 09 2d 2d 20 66 69 72 73 74 20 72 65 .cid.-- first re
dc80: 76 69 73 69 6f 6e 73 2c 20 77 68 69 63 68 20 61 visions, which a
dc90: 72 65 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 re.. AND C
dca0: 2e 74 79 70 65 20 3d 20 30 09 09 2d 2d 20 72 65 .type = 0..-- re
dcb0: 76 69 73 69 6f 6e 20 63 68 61 6e 67 65 73 65 74 vision changeset
dcc0: 73 0a 09 20 20 20 20 41 4e 44 20 20 20 20 43 4f s.. AND CO
dcd0: 2e 63 69 64 20 3d 20 43 2e 63 69 64 09 2d 2d 20 .cid = C.cid.--
dce0: 47 65 74 20 74 68 65 69 72 20 74 6f 70 6f 6c 6f Get their topolo
dcf0: 67 69 63 61 6c 20 6f 72 64 65 72 69 6e 67 0a 09 gical ordering..
dd00: 20 20 20 20 47 52 4f 55 50 20 42 59 20 42 2e 62 GROUP BY B.b
dd10: 69 64 0a 09 7d 5d 5d 0a 0a 20 20 20 20 20 20 20 id..}]]..
dd20: 20 72 65 74 75 72 6e 20 5b 6c 69 73 74 20 24 6d return [list $m
dd30: 61 78 70 20 24 6d 69 6e 73 5d 0a 20 20 20 20 7d axp $mins]. }
dd40: 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 23 .. # # ## ###
dd50: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 ##### ########
dd60: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 #############.
dd70: 20 20 23 23 20 43 6f 6e 66 69 67 75 72 61 74 69 ## Configurati
dd80: 6f 6e 0a 0a 20 20 20 20 70 72 61 67 6d 61 20 2d on.. pragma -
dd90: 68 61 73 69 6e 73 74 61 6e 63 65 73 20 20 20 6e hasinstances n
dda0: 6f 20 3b 20 23 20 73 69 6e 67 6c 65 74 6f 6e 0a o ; # singleton.
ddb0: 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 74 pragma -hast
ddc0: 79 70 65 69 6e 66 6f 20 20 20 20 6e 6f 20 3b 20 ypeinfo no ;
ddd0: 23 20 6e 6f 20 69 6e 74 72 6f 73 70 65 63 74 69 # no introspecti
dde0: 6f 6e 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 on. pragma -h
ddf0: 61 73 74 79 70 65 64 65 73 74 72 6f 79 20 6e 6f astypedestroy no
de00: 20 3b 20 23 20 69 6d 6d 6f 72 74 61 6c 0a 7d 0a ; # immortal.}.
de10: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 .# # ## ### ####
de20: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 # ######## #####
de30: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 ######## #######
de40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 ##############.#
de50: 23 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 61 #..namespace eva
de60: 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a l ::vc::fossil::
de70: 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f import::cvs::pro
de80: 6a 65 63 74 20 7b 0a 20 20 20 20 6e 61 6d 65 73 ject {. names
de90: 70 61 63 65 20 65 78 70 6f 72 74 20 72 65 76 0a pace export rev.
dea0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 namespace ev
deb0: 61 6c 20 72 65 76 20 7b 0a 09 6e 61 6d 65 73 70 al rev {..namesp
dec0: 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a ace import ::vc:
ded0: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a :fossil::import:
dee0: 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 6e 61 6d :cvs::state..nam
def0: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a espace import ::
df00: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f vc::fossil::impo
df10: 72 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 rt::cvs::integri
df20: 74 79 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d ty..namespace im
df30: 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 port ::vc::tools
df40: 3a 3a 6d 69 73 63 3a 3a 2a 0a 09 6e 61 6d 65 73 ::misc::*..names
df50: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 pace import ::vc
df60: 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 ::tools::trouble
df70: 0a 09 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f ..namespace impo
df80: 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a rt ::vc::tools::
df90: 6c 6f 67 0a 09 6c 6f 67 20 72 65 67 69 73 74 65 log..log registe
dfa0: 72 20 63 73 65 74 73 0a 0a 09 23 20 53 65 74 20 r csets...# Set
dfb0: 75 70 20 74 68 65 20 68 65 6c 70 65 72 20 73 69 up the helper si
dfc0: 6e 67 6c 65 74 6f 6e 73 0a 09 6e 61 6d 65 73 70 ngletons..namesp
dfd0: 61 63 65 20 65 76 61 6c 20 72 65 76 20 7b 0a 09 ace eval rev {..
dfe0: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d namespace im
dff0: 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 port ::vc::fossi
e000: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a l::import::cvs::
e010: 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 73 state.. names
e020: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 pace import ::vc
e030: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 ::fossil::import
e040: 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 79 ::cvs::integrity
e050: 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 .. namespace
e060: 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f 6f import ::vc::too
e070: 6c 73 3a 3a 6c 6f 67 0a 09 7d 0a 09 6e 61 6d 65 ls::log..}..name
e080: 73 70 61 63 65 20 65 76 61 6c 20 73 79 6d 3a 3a space eval sym::
e090: 74 61 67 20 7b 0a 09 20 20 20 20 6e 61 6d 65 73 tag {.. names
e0a0: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 pace import ::vc
e0b0: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 ::fossil::import
e0c0: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 09 20 20 ::cvs::state..
e0d0: 20 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f namespace impo
e0e0: 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a rt ::vc::fossil:
e0f0: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 69 6e :import::cvs::in
e100: 74 65 67 72 69 74 79 0a 09 20 20 20 20 6e 61 6d tegrity.. nam
e110: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a espace import ::
e120: 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a 09 vc::tools::log..
e130: 7d 0a 09 6e 61 6d 65 73 70 61 63 65 20 65 76 61 }..namespace eva
e140: 6c 20 73 79 6d 3a 3a 62 72 61 6e 63 68 20 7b 0a l sym::branch {.
e150: 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 69 . namespace i
e160: 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 66 6f 73 73 mport ::vc::foss
e170: 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a il::import::cvs:
e180: 3a 73 74 61 74 65 0a 09 20 20 20 20 6e 61 6d 65 :state.. name
e190: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 space import ::v
e1a0: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 c::fossil::impor
e1b0: 74 3a 3a 63 76 73 3a 3a 69 6e 74 65 67 72 69 74 t::cvs::integrit
e1c0: 79 0a 09 20 20 20 20 6e 61 6d 65 73 70 61 63 65 y.. namespace
e1d0: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f import ::vc::to
e1e0: 6f 6c 73 3a 3a 6c 6f 67 0a 09 7d 0a 20 20 20 20 ols::log..}.
e1f0: 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 20 }.}..# # ## ###
e200: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 ##### ######## #
e210: 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 ############ ###
e220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
e230: 23 23 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 63 ##.## Ready..pac
e240: 6b 61 67 65 20 70 72 6f 76 69 64 65 20 76 63 3a kage provide vc:
e250: 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a :fossil::import:
e260: 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 :cvs::project::r
e270: 65 76 20 31 2e 30 0a 72 65 74 75 72 6e 0a ev 1.0.return.