Artifact 855ccb9239185ee913fd92b0c53c6bce7d748b70:
File
tools/cvs2fossil/lib/c2f_prev.tcl
part of check-in
[5f7acef887]
- Completed pass 5, computing the initial set of changesets. Defined persistent structure and filled out the long-existing placeholder class (project::rev).
by
aku on
2007-11-10 07:46:20.
0000: 23 23 20 2d 2a 2d 20 74 63 6c 20 2d 2a 2d 0a 23 ## -*- tcl -*-.#
0010: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 # ## ### #####
0020: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 ######## #######
0030: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
0040: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 ############.##
0050: 43 6f 70 79 72 69 67 68 74 20 28 63 29 20 32 30 Copyright (c) 20
0060: 30 37 20 41 6e 64 72 65 61 73 20 4b 75 70 72 69 07 Andreas Kupri
0070: 65 73 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 es..#.# This sof
0080: 74 77 61 72 65 20 69 73 20 6c 69 63 65 6e 73 65 tware is license
0090: 64 20 61 73 20 64 65 73 63 72 69 62 65 64 20 69 d as described i
00a0: 6e 20 74 68 65 20 66 69 6c 65 20 4c 49 43 45 4e n the file LICEN
00b0: 53 45 2c 20 77 68 69 63 68 0a 23 20 79 6f 75 20 SE, which.# you
00c0: 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65 should have rece
00d0: 69 76 65 64 20 61 73 20 70 61 72 74 20 6f 66 20 ived as part of
00e0: 74 68 69 73 20 64 69 73 74 72 69 62 75 74 69 6f this distributio
00f0: 6e 2e 0a 23 0a 23 20 54 68 69 73 20 73 6f 66 74 n..#.# This soft
0100: 77 61 72 65 20 63 6f 6e 73 69 73 74 73 20 6f 66 ware consists of
0110: 20 76 6f 6c 75 6e 74 61 72 79 20 63 6f 6e 74 72 voluntary contr
0120: 69 62 75 74 69 6f 6e 73 20 6d 61 64 65 20 62 79 ibutions made by
0130: 20 6d 61 6e 79 0a 23 20 69 6e 64 69 76 69 64 75 many.# individu
0140: 61 6c 73 2e 20 20 46 6f 72 20 65 78 61 63 74 20 als. For exact
0150: 63 6f 6e 74 72 69 62 75 74 69 6f 6e 20 68 69 73 contribution his
0160: 74 6f 72 79 2c 20 73 65 65 20 74 68 65 20 72 65 tory, see the re
0170: 76 69 73 69 6f 6e 0a 23 20 68 69 73 74 6f 72 79 vision.# history
0180: 20 61 6e 64 20 6c 6f 67 73 2c 20 61 76 61 69 6c and logs, avail
0190: 61 62 6c 65 20 61 74 20 68 74 74 70 3a 2f 2f 66 able at http://f
01a0: 6f 73 73 69 6c 2d 73 63 6d 2e 68 77 61 63 69 2e ossil-scm.hwaci.
01b0: 63 6f 6d 2f 66 6f 73 73 69 6c 0a 23 20 23 20 23 com/fossil.# # #
01c0: 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 # ### ##### ####
01d0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
01e0: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
01f0: 23 23 23 23 23 23 23 23 0a 0a 23 23 20 52 65 76 ########..## Rev
0200: 69 73 69 6f 6e 73 20 70 65 72 20 70 72 6f 6a 65 isions per proje
0210: 63 74 2c 20 61 6b 61 20 43 68 61 6e 67 65 73 65 ct, aka Changese
0220: 74 73 2e 20 54 68 65 73 65 20 6f 62 6a 65 63 74 ts. These object
0230: 73 20 61 72 65 20 66 69 72 73 74 20 75 73 65 64 s are first used
0240: 0a 23 23 20 69 6e 20 70 61 73 73 20 35 2c 20 77 .## in pass 5, w
0250: 68 69 63 68 20 63 72 65 61 74 65 73 20 74 68 65 hich creates the
0260: 20 69 6e 69 74 69 61 6c 20 73 65 74 20 63 6f 76 initial set cov
0270: 65 72 69 6e 67 20 74 68 65 20 72 65 70 6f 73 69 ering the reposi
0280: 74 6f 72 79 2e 0a 0a 23 20 23 20 23 23 20 23 23 tory...# # ## ##
0290: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 # ##### ########
02a0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 ############# #
02b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
02c0: 23 23 23 23 0a 23 23 20 52 65 71 75 69 72 65 6d ####.## Requirem
02d0: 65 6e 74 73 0a 0a 70 61 63 6b 61 67 65 20 72 65 ents..package re
02e0: 71 75 69 72 65 20 54 63 6c 20 38 2e 34 20 20 20 quire Tcl 8.4
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0300: 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 ; #
0310: 52 65 71 75 69 72 65 64 20 72 75 6e 74 69 6d 65 Required runtime
0320: 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 ..package requir
0330: 65 20 73 6e 69 74 20 20 20 20 20 20 20 20 20 20 e snit
0340: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0350: 20 20 20 20 20 20 20 20 3b 20 23 20 4f 4f 20 73 ; # OO s
0360: 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67 65 20 72 ystem..package r
0370: 65 71 75 69 72 65 20 76 63 3a 3a 66 6f 73 73 69 equire vc::fossi
0380: 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a l::import::cvs::
0390: 73 74 61 74 65 20 20 20 20 20 20 20 20 3b 20 23 state ; #
03a0: 20 53 74 61 74 65 20 73 74 6f 72 61 67 65 2e 0a State storage..
03b0: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 .# # ## ### ####
03c0: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 # ######## #####
03d0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 ######## #######
03e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 ##############.#
03f0: 23 20 0a 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a # ..snit::type :
0400: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 :vc::fossil::imp
0410: 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 ort::cvs::projec
0420: 74 3a 3a 72 65 76 20 7b 0a 20 20 20 20 23 20 23 t::rev {. # #
0430: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 ## ### ##### ##
0440: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
0450: 23 23 23 23 0a 20 20 20 20 23 23 20 50 75 62 6c ####. ## Publ
0460: 69 63 20 41 50 49 0a 0a 20 20 20 20 63 6f 6e 73 ic API.. cons
0470: 74 72 75 63 74 6f 72 20 7b 70 72 6f 6a 65 63 74 tructor {project
0480: 20 63 73 74 79 70 65 20 73 72 63 69 64 20 72 65 cstype srcid re
0490: 76 69 73 69 6f 6e 73 7d 20 7b 0a 09 73 65 74 20 visions} {..set
04a0: 6d 79 69 64 20 20 20 20 20 20 20 20 5b 69 6e 63 myid [inc
04b0: 72 20 6d 79 63 6f 75 6e 74 65 72 5d 0a 09 73 65 r mycounter]..se
04c0: 74 20 6d 79 70 72 6f 6a 65 63 74 20 20 20 24 70 t myproject $p
04d0: 72 6f 6a 65 63 74 0a 09 73 65 74 20 6d 79 74 79 roject..set myty
04e0: 70 65 20 20 20 20 20 20 24 63 73 74 79 70 65 09 pe $cstype.
04f0: 20 20 0a 09 73 65 74 20 6d 79 73 72 63 69 64 09 ..set mysrcid.
0500: 24 73 72 63 69 64 09 20 20 0a 09 73 65 74 20 6d $srcid. ..set m
0510: 79 72 65 76 69 73 69 6f 6e 73 20 24 72 65 76 69 yrevisions $revi
0520: 73 69 6f 6e 73 0a 09 72 65 74 75 72 6e 0a 20 20 sions..return.
0530: 20 20 7d 0a 0a 20 20 20 20 6d 65 74 68 6f 64 20 }.. method
0540: 70 65 72 73 69 73 74 20 7b 7d 20 7b 0a 09 73 65 persist {} {..se
0550: 74 20 74 69 64 20 24 6d 79 63 73 74 79 70 65 28 t tid $mycstype(
0560: 24 6d 79 74 79 70 65 29 0a 09 73 65 74 20 70 69 $mytype)..set pi
0570: 64 20 5b 24 6d 79 70 72 6f 6a 65 63 74 20 69 64 d [$myproject id
0580: 5d 0a 09 73 65 74 20 70 6f 73 20 30 0a 0a 09 73 ]..set pos 0...s
0590: 74 61 74 65 20 74 72 61 6e 73 61 63 74 69 6f 6e tate transaction
05a0: 20 7b 0a 09 20 20 20 20 73 74 61 74 65 20 72 75 {.. state ru
05b0: 6e 20 7b 0a 09 09 49 4e 53 45 52 54 20 49 4e 54 n {...INSERT INT
05c0: 4f 20 63 68 61 6e 67 65 73 65 74 20 28 63 69 64 O changeset (cid
05d0: 2c 20 20 20 70 69 64 2c 20 20 74 79 70 65 2c 20 , pid, type,
05e0: 73 72 63 29 0a 09 09 56 41 4c 55 45 53 20 20 20 src)...VALUES
05f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 24 6d ($m
0600: 79 69 64 2c 20 24 70 69 64 2c 20 24 74 69 64 2c yid, $pid, $tid,
0610: 20 24 6d 79 73 72 63 69 64 29 3b 0a 09 20 20 20 $mysrcid);..
0620: 20 7d 0a 0a 09 20 20 20 20 66 6f 72 65 61 63 68 }... foreach
0630: 20 72 69 64 20 24 6d 79 72 65 76 69 73 69 6f 6e rid $myrevision
0640: 73 20 7b 0a 09 09 73 74 61 74 65 20 72 75 6e 20 s {...state run
0650: 7b 0a 09 09 20 20 20 20 49 4e 53 45 52 54 20 49 {... INSERT I
0660: 4e 54 4f 20 63 73 72 65 76 69 73 69 6f 6e 20 28 NTO csrevision (
0670: 63 69 64 2c 20 20 20 70 6f 73 2c 20 20 72 69 64 cid, pos, rid
0680: 29 0a 09 09 20 20 20 20 56 41 4c 55 45 53 20 20 )... VALUES
0690: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 (
06a0: 24 6d 79 69 64 2c 20 24 70 6f 73 2c 20 24 72 69 $myid, $pos, $ri
06b0: 64 29 3b 0a 09 09 7d 0a 09 09 69 6e 63 72 20 70 d);...}...incr p
06c0: 6f 73 0a 09 20 20 20 20 7d 0a 09 7d 0a 09 72 65 os.. }..}..re
06d0: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
06e0: 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 # # ## ### #####
06f0: 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 ######## ######
0700: 23 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 53 #######. ## S
0710: 74 61 74 65 0a 0a 20 20 20 20 76 61 72 69 61 62 tate.. variab
0720: 6c 65 20 6d 79 69 64 20 20 20 20 20 20 20 20 3b le myid ;
0730: 20 23 20 49 64 20 6f 66 20 74 68 65 20 63 73 65 # Id of the cse
0740: 74 20 66 6f 72 20 74 68 65 20 70 65 72 73 69 73 t for the persis
0750: 74 65 6e 74 20 73 74 61 74 65 2e 0a 20 20 20 20 tent state..
0760: 76 61 72 69 61 62 6c 65 20 6d 79 70 72 6f 6a 65 variable myproje
0770: 63 74 20 20 20 3b 20 23 20 52 65 66 65 72 65 6e ct ; # Referen
0780: 63 65 20 6f 66 20 74 68 65 20 70 72 6f 6a 65 63 ce of the projec
0790: 74 20 6f 62 6a 65 63 74 20 74 68 65 20 63 68 61 t object the cha
07a0: 6e 67 65 73 65 74 20 62 65 6c 6f 6e 67 73 20 74 ngeset belongs t
07b0: 6f 2e 0a 20 20 20 20 76 61 72 69 61 62 6c 65 20 o.. variable
07c0: 6d 79 74 79 70 65 20 20 20 20 20 20 3b 20 23 20 mytype ; #
07d0: 72 65 76 20 6f 72 20 73 79 6d 2c 20 77 68 65 72 rev or sym, wher
07e0: 65 20 74 68 65 20 63 73 65 74 20 6f 72 69 67 69 e the cset origi
07f0: 6e 61 74 65 64 20 66 72 6f 6d 2e 0a 20 20 20 20 nated from..
0800: 76 61 72 69 61 62 6c 65 20 6d 79 73 72 63 69 64 variable mysrcid
0810: 20 20 20 20 20 3b 20 23 20 69 64 20 6f 66 20 74 ; # id of t
0820: 68 65 20 6d 65 74 61 64 61 74 61 20 6f 72 20 73 he metadata or s
0830: 79 6d 62 6f 6c 20 74 68 65 20 63 73 65 74 20 69 ymbol the cset i
0840: 73 20 62 61 73 65 64 20 6f 6e 2e 0a 20 20 20 20 s based on..
0850: 76 61 72 69 61 62 6c 65 20 6d 79 72 65 76 69 73 variable myrevis
0860: 69 6f 6e 73 20 3b 20 23 20 4c 69 73 74 20 6f 66 ions ; # List of
0870: 20 74 68 65 20 66 69 6c 65 20 6c 65 76 65 6c 20 the file level
0880: 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 74 68 65 revisions in the
0890: 20 63 73 65 74 2e 0a 0a 20 20 20 20 23 20 23 20 cset... # #
08a0: 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 23 ## ### ##### ###
08b0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
08c0: 23 23 23 0a 20 20 20 20 23 23 20 49 6e 74 65 72 ###. ## Inter
08d0: 6e 61 6c 20 6d 65 74 68 6f 64 73 0a 0a 20 20 20 nal methods..
08e0: 20 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 typevariable my
08f0: 63 6f 75 6e 74 65 72 20 20 20 20 20 20 20 20 30 counter 0
0900: 20 3b 20 23 20 49 64 20 63 6f 75 6e 74 65 72 20 ; # Id counter
0910: 66 6f 72 20 63 73 65 74 73 2e 0a 20 20 20 20 74 for csets.. t
0920: 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 63 73 ypevariable mycs
0930: 74 79 70 65 20 2d 61 72 72 61 79 20 7b 7d 20 3b type -array {} ;
0940: 20 23 20 4d 61 70 20 63 73 74 79 70 65 73 20 74 # Map cstypes t
0950: 6f 20 70 65 72 73 69 73 74 65 6e 74 20 69 64 73 o persistent ids
0960: 2e 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 6f ... typemetho
0970: 64 20 67 65 74 63 73 74 79 70 65 73 20 7b 7d 20 d getcstypes {}
0980: 7b 0a 09 66 6f 72 65 61 63 68 20 7b 74 69 64 20 {..foreach {tid
0990: 6e 61 6d 65 7d 20 5b 73 74 61 74 65 20 72 75 6e name} [state run
09a0: 20 7b 0a 09 20 20 20 20 53 45 4c 45 43 54 20 74 {.. SELECT t
09b0: 69 64 2c 20 6e 61 6d 65 20 46 52 4f 4d 20 63 73 id, name FROM cs
09c0: 74 79 70 65 3b 0a 09 7d 5d 20 7b 20 73 65 74 20 type;..}] { set
09d0: 6d 79 63 73 74 79 70 65 28 24 6e 61 6d 65 29 20 mycstype($name)
09e0: 24 74 69 64 20 7d 0a 09 72 65 74 75 72 6e 0a 20 $tid }..return.
09f0: 20 20 20 7d 0a 0a 20 20 20 20 23 20 23 20 23 23 }.. # # ##
0a00: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
0a10: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
0a20: 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 69 67 75 #. ## Configu
0a30: 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 72 61 67 ration.. prag
0a40: 6d 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 ma -hastypeinfo
0a50: 20 20 20 6e 6f 20 20 3b 20 23 20 6e 6f 20 74 79 no ; # no ty
0a60: 70 65 20 69 6e 74 72 6f 73 70 65 63 74 69 6f 6e pe introspection
0a70: 0a 20 20 20 20 70 72 61 67 6d 61 20 2d 68 61 73 . pragma -has
0a80: 69 6e 66 6f 20 20 20 20 20 20 20 20 6e 6f 20 20 info no
0a90: 3b 20 23 20 6e 6f 20 6f 62 6a 65 63 74 20 69 6e ; # no object in
0aa0: 74 72 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 trospection.
0ab0: 70 72 61 67 6d 61 20 2d 73 69 6d 70 6c 65 64 69 pragma -simpledi
0ac0: 73 70 61 74 63 68 20 79 65 73 20 3b 20 23 20 73 spatch yes ; # s
0ad0: 69 6d 70 6c 65 20 66 61 73 74 20 64 69 73 70 61 imple fast dispa
0ae0: 74 63 68 0a 0a 20 20 20 20 23 20 23 20 23 23 20 tch.. # # ##
0af0: 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 23 ### ##### ######
0b00: 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ## #############
0b10: 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 76 .}..namespace ev
0b20: 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a al ::vc::fossil:
0b30: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 :import::cvs::pr
0b40: 6f 6a 65 63 74 20 7b 0a 20 20 20 20 6e 61 6d 65 oject {. name
0b50: 73 70 61 63 65 20 65 78 70 6f 72 74 20 72 65 76 space export rev
0b60: 0a 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 . namespace e
0b70: 76 61 6c 20 72 65 76 20 7b 0a 09 6e 61 6d 65 73 val rev {..names
0b80: 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 pace import ::vc
0b90: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 ::fossil::import
0ba0: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 20 20 20 ::cvs::state.
0bb0: 20 7d 0a 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 }.}..# # ## ###
0bc0: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 ##### ########
0bd0: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 ############# ##
0be0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0bf0: 23 23 23 0a 23 23 20 52 65 61 64 79 0a 0a 70 61 ###.## Ready..pa
0c00: 63 6b 61 67 65 20 70 72 6f 76 69 64 65 20 76 63 ckage provide vc
0c10: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 ::fossil::import
0c20: 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a ::cvs::project::
0c30: 72 65 76 20 31 2e 30 0a 72 65 74 75 72 6e 0a rev 1.0.return.