Artifact 2094dd757c13469ca5b200e28952cd60abdb52b3:
File
tools/cvs2fossil/lib/c2f_state.tcl
part of check-in
[fb1e36d290]
- Extended state handling with methods to declare usage and structure of state,
started integration of state with pass I, collection of projects and files.
by
aku on
2007-10-05 06:50:57.
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 53 74 61 ########..## Sta
0200: 74 65 20 6d 61 6e 61 67 65 72 2e 20 4d 61 69 6e te manager. Main
0210: 74 61 69 6e 73 20 74 68 65 20 73 71 6c 69 74 65 tains the sqlite
0220: 20 64 61 74 61 62 61 73 65 20 75 73 65 64 20 62 database used b
0230: 79 20 61 6c 6c 20 74 68 65 20 6f 74 68 65 72 0a y all the other.
0240: 23 23 20 70 61 72 74 73 20 6f 66 20 74 68 65 20 ## parts of the
0250: 73 79 73 74 65 6d 2c 20 65 73 70 65 63 69 61 6c system, especial
0260: 6c 79 20 74 68 65 20 70 61 73 73 65 73 20 61 6e ly the passes an
0270: 64 20 74 68 65 69 72 20 73 75 70 70 6f 72 74 20 d their support
0280: 63 6f 64 65 2c 0a 23 23 20 74 6f 20 70 65 72 73 code,.## to pers
0290: 69 73 74 20 61 6e 64 20 72 65 73 74 6f 72 65 20 ist and restore
02a0: 74 68 65 69 72 20 73 74 61 74 65 20 61 63 72 6f their state acro
02b0: 73 73 20 69 6e 76 6f 6b 61 74 69 6f 6e 73 2e 0a ss invokations..
02c0: 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 23 .# # ## ### ####
02d0: 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 23 # ######## #####
02e0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 ######## #######
02f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 ##############.#
0300: 23 20 52 65 71 75 69 72 65 6d 65 6e 74 73 0a 0a # Requirements..
0310: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 package require
0320: 54 63 6c 20 38 2e 34 20 20 20 20 20 20 20 20 20 Tcl 8.4
0330: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0340: 20 3b 20 23 20 52 65 71 75 69 72 65 64 20 72 75 ; # Required ru
0350: 6e 74 69 6d 65 2e 0a 70 61 63 6b 61 67 65 20 72 ntime..package r
0360: 65 71 75 69 72 65 20 73 6e 69 74 20 20 20 20 20 equire snit
0370: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0380: 20 20 20 20 20 20 20 20 3b 20 23 20 4f 4f 20 73 ; # OO s
0390: 79 73 74 65 6d 2e 0a 70 61 63 6b 61 67 65 20 72 ystem..package r
03a0: 65 71 75 69 72 65 20 66 69 6c 65 75 74 69 6c 20 equire fileutil
03b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
03c0: 20 20 20 20 20 20 20 20 3b 20 23 20 46 69 6c 65 ; # File
03d0: 20 6f 70 65 72 61 74 69 6f 6e 73 2e 0a 70 61 63 operations..pac
03e0: 6b 61 67 65 20 72 65 71 75 69 72 65 20 73 71 6c kage require sql
03f0: 69 74 65 33 20 20 20 20 20 20 20 20 20 20 20 20 ite3
0400: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b 20 ;
0410: 23 20 44 61 74 61 62 61 73 65 20 61 63 63 65 73 # Database acces
0420: 73 2e 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 s..package requi
0430: 72 65 20 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 74 72 re vc::tools::tr
0440: 6f 75 62 6c 65 20 20 20 20 20 20 20 20 20 20 20 ouble
0450: 20 20 20 20 3b 20 23 20 45 72 72 6f 72 20 72 65 ; # Error re
0460: 70 6f 72 74 69 6e 67 2e 0a 70 61 63 6b 61 67 65 porting..package
0470: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f require vc::too
0480: 6c 73 3a 3a 6c 6f 67 20 20 20 20 20 20 20 20 20 ls::log
0490: 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 55 73 ; # Us
04a0: 65 72 20 66 65 65 64 62 61 63 6b 2e 0a 0a 23 20 er feedback...#
04b0: 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 # ## ### ##### #
04c0: 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 ####### ########
04d0: 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 ##### ##########
04e0: 23 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 0a ###########.## .
04f0: 0a 73 6e 69 74 3a 3a 74 79 70 65 20 3a 3a 76 63 .snit::type ::vc
0500: 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 ::fossil::import
0510: 3a 3a 63 76 73 3a 3a 73 74 61 74 65 20 7b 0a 20 ::cvs::state {.
0520: 20 20 20 23 20 23 20 23 23 20 23 23 23 20 23 23 # # ## ### ##
0530: 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 ### ######## ###
0540: 23 23 23 23 23 23 23 23 23 23 0a 20 20 20 20 23 ##########. #
0550: 23 20 50 75 62 6c 69 63 20 41 50 49 0a 0a 20 20 # Public API..
0560: 20 20 74 79 70 65 6d 65 74 68 6f 64 20 75 73 65 typemethod use
0570: 20 7b 70 61 74 68 7d 20 7b 0a 09 23 20 49 6d 6d {path} {..# Imm
0580: 65 64 69 61 74 65 20 76 61 6c 69 64 61 74 69 6f ediate validatio
0590: 6e 2e 20 54 68 65 72 65 20 61 72 65 20 61 72 65 n. There are are
05a0: 20 74 77 6f 20 70 6f 73 73 69 62 69 6c 69 74 69 two possibiliti
05b0: 65 73 20 74 6f 0a 09 23 20 63 6f 6e 73 69 64 65 es to..# conside
05c0: 72 2e 20 54 68 65 20 70 61 74 68 20 65 78 69 73 r. The path exis
05d0: 74 73 20 6f 72 20 69 74 20 64 6f 65 73 6e 27 74 ts or it doesn't
05e0: 2e 0a 0a 09 23 20 49 6e 20 74 68 65 20 66 69 72 ....# In the fir
05f0: 73 74 20 63 61 73 65 20 69 74 20 68 61 73 20 74 st case it has t
0600: 6f 20 62 65 20 61 20 72 65 61 64 61 62 6c 65 20 o be a readable
0610: 61 6e 64 20 77 72 69 74 61 62 6c 65 20 66 69 6c and writable fil
0620: 65 2c 0a 09 23 20 61 6e 64 20 69 74 20 68 61 73 e,..# and it has
0630: 20 74 6f 20 62 65 20 61 20 70 72 6f 70 65 72 20 to be a proper
0640: 73 71 6c 69 74 65 20 64 61 74 61 62 61 73 65 2e sqlite database.
0650: 20 46 75 72 74 68 65 72 20 63 68 65 63 6b 73 0a Further checks.
0660: 09 23 20 72 65 67 61 72 64 69 6e 67 20 74 68 65 .# regarding the
0670: 20 72 65 71 75 69 72 65 64 20 74 61 62 6c 65 73 required tables
0680: 20 77 69 6c 6c 20 62 65 20 64 6f 6e 65 20 6c 61 will be done la
0690: 74 65 72 2c 20 62 79 20 74 68 65 0a 09 23 20 70 ter, by the..# p
06a0: 61 73 73 65 73 2c 20 64 75 72 69 6e 67 20 74 68 asses, during th
06b0: 65 69 72 20 73 65 74 75 70 2e 0a 0a 09 23 20 49 eir setup....# I
06c0: 6e 20 74 68 65 20 73 65 63 6f 6e 64 20 63 61 73 n the second cas
06d0: 65 20 77 65 20 68 61 76 65 20 74 6f 20 62 65 20 e we have to be
06e0: 61 62 6c 65 20 74 6f 20 63 72 65 61 74 65 20 74 able to create t
06f0: 68 65 20 66 69 6c 65 2c 0a 09 23 20 61 6e 64 20 he file,..# and
0700: 63 68 65 63 6b 20 74 68 61 74 2e 20 54 68 69 73 check that. This
0710: 20 69 73 20 64 6f 6e 65 20 62 79 20 6f 70 65 6e is done by open
0720: 69 6e 67 20 69 74 2c 20 73 71 6c 69 74 65 20 77 ing it, sqlite w
0730: 69 6c 6c 20 74 68 65 6e 0a 09 23 20 74 72 79 20 ill then..# try
0740: 74 6f 20 63 72 65 61 74 65 20 69 74 2c 20 61 6e to create it, an
0750: 64 20 6d 61 79 20 66 61 69 6c 2e 0a 0a 09 69 66 d may fail....if
0760: 20 7b 5b 66 69 6c 65 20 65 78 69 73 74 73 20 24 {[file exists $
0770: 70 61 74 68 5d 7d 20 7b 0a 09 20 20 20 20 69 66 path]} {.. if
0780: 20 7b 21 5b 66 69 6c 65 75 74 69 6c 3a 3a 74 65 {![fileutil::te
0790: 73 74 20 24 70 61 74 68 20 66 72 77 20 6d 73 67 st $path frw msg
07a0: 20 7b 63 76 73 32 66 6f 73 73 69 6c 20 73 74 61 {cvs2fossil sta
07b0: 74 65 7d 5d 7d 20 7b 0a 09 09 74 72 6f 75 62 6c te}]} {...troubl
07c0: 65 20 66 61 74 61 6c 20 24 6d 73 67 0a 09 09 72 e fatal $msg...r
07d0: 65 74 75 72 6e 0a 09 20 20 20 20 7d 0a 09 7d 0a eturn.. }..}.
07e0: 0a 09 69 66 20 7b 5b 63 61 74 63 68 20 7b 0a 09 ..if {[catch {..
07f0: 20 20 20 20 73 71 6c 69 74 65 33 20 24 7b 74 79 sqlite3 ${ty
0800: 70 65 7d 3a 3a 54 45 4d 50 20 24 70 61 74 68 0a pe}::TEMP $path.
0810: 09 7d 20 72 65 73 5d 7d 20 7b 0a 09 20 20 20 20 .} res]} {..
0820: 74 72 6f 75 62 6c 65 20 66 61 74 61 6c 20 24 72 trouble fatal $r
0830: 65 73 0a 09 20 20 20 20 72 65 74 75 72 6e 0a 09 es.. return..
0840: 7d 0a 0a 09 23 20 41 20 70 72 65 76 69 6f 75 73 }...# A previous
0850: 6c 79 20 64 65 66 69 6e 65 64 20 73 74 61 74 65 ly defined state
0860: 20 64 61 74 61 62 61 73 65 20 69 73 20 63 6c 6f database is clo
0870: 73 65 64 20 62 65 66 6f 72 65 0a 09 23 20 63 6f sed before..# co
0880: 6d 6d 69 74 74 69 6e 67 20 74 6f 20 74 68 65 20 mmitting to the
0890: 6e 65 77 20 64 65 66 69 6e 69 74 69 6f 6e 2e 20 new definition.
08a0: 57 65 20 64 6f 20 6e 6f 74 20 73 74 6f 72 65 20 We do not store
08b0: 74 68 65 20 70 61 74 68 0a 09 23 20 69 74 73 65 the path..# itse
08c0: 6c 66 2c 20 74 68 69 73 20 65 6e 73 75 72 65 73 lf, this ensures
08d0: 20 74 68 61 74 20 74 68 65 20 66 69 6c 65 20 69 that the file i
08e0: 73 20 5f 6e 6f 74 5f 20 63 6c 65 61 6e 65 64 20 s _not_ cleaned
08f0: 75 70 20 61 66 74 65 72 0a 09 23 20 61 20 72 75 up after..# a ru
0900: 6e 2e 0a 0a 09 73 65 74 20 6d 79 73 74 61 74 65 n....set mystate
0910: 20 24 7b 74 79 70 65 7d 3a 3a 53 54 41 54 45 0a ${type}::STATE.
0920: 09 73 65 74 20 6d 79 70 61 74 68 20 20 7b 7d 0a .set mypath {}.
0930: 0a 09 63 61 74 63 68 20 7b 20 24 6d 79 73 74 61 ..catch { $mysta
0940: 74 65 20 63 6c 6f 73 65 20 7d 0a 09 72 65 6e 61 te close }..rena
0950: 6d 65 20 20 24 7b 74 79 70 65 7d 3a 3a 54 45 4d me ${type}::TEM
0960: 50 20 24 6d 79 73 74 61 74 65 0a 0a 09 6c 6f 67 P $mystate...log
0970: 20 77 72 69 74 65 20 32 20 73 74 61 74 65 20 22 write 2 state "
0980: 69 73 20 24 70 61 74 68 22 0a 09 72 65 74 75 72 is $path"..retur
0990: 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 n. }.. typ
09a0: 65 6d 65 74 68 6f 64 20 73 65 74 75 70 20 7b 7d emethod setup {}
09b0: 20 7b 0a 09 23 20 49 66 2c 20 61 6e 64 20 6f 6e {..# If, and on
09c0: 6c 79 20 69 66 20 6e 6f 20 73 74 61 74 65 20 64 ly if no state d
09d0: 61 74 61 62 61 73 65 20 77 61 73 20 64 65 66 69 atabase was defi
09e0: 6e 65 64 20 62 79 20 74 68 65 20 75 73 65 72 0a ned by the user.
09f0: 09 23 20 74 68 65 6e 20 69 74 20 69 73 20 6e 6f .# then it is no
0a00: 77 20 74 68 65 20 74 69 6d 65 20 74 6f 20 63 72 w the time to cr
0a10: 65 61 74 65 20 6f 75 72 20 6f 77 6e 20 75 73 69 eate our own usi
0a20: 6e 67 20 61 20 74 65 6d 70 66 69 6c 65 2e 0a 0a ng a tempfile...
0a30: 09 69 66 20 7b 24 6d 79 73 74 61 74 65 20 6e 65 .if {$mystate ne
0a40: 20 22 22 7d 20 72 65 74 75 72 6e 0a 0a 09 73 65 ""} return...se
0a50: 74 20 6d 79 70 61 74 68 20 20 5b 66 69 6c 65 75 t mypath [fileu
0a60: 74 69 6c 3a 3a 74 65 6d 70 66 69 6c 65 20 63 76 til::tempfile cv
0a70: 73 32 66 6f 73 73 69 6c 5f 73 74 61 74 65 5f 5d s2fossil_state_]
0a80: 0a 09 73 65 74 20 6d 79 73 74 61 74 65 20 24 7b ..set mystate ${
0a90: 74 79 70 65 7d 3a 3a 53 54 41 54 45 0a 09 73 71 type}::STATE..sq
0aa0: 6c 69 74 65 33 20 24 6d 79 73 74 61 74 65 20 24 lite3 $mystate $
0ab0: 6d 79 70 61 74 68 0a 0a 09 6c 6f 67 20 77 72 69 mypath...log wri
0ac0: 74 65 20 32 20 73 74 61 74 65 20 22 75 73 69 6e te 2 state "usin
0ad0: 67 20 24 6d 79 70 61 74 68 22 0a 09 72 65 74 75 g $mypath"..retu
0ae0: 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 74 79 rn. }.. ty
0af0: 70 65 6d 65 74 68 6f 64 20 72 65 6c 65 61 73 65 pemethod release
0b00: 20 7b 7d 20 7b 0a 09 6c 6f 67 20 77 72 69 74 65 {} {..log write
0b10: 20 32 20 73 74 61 74 65 20 72 65 6c 65 61 73 65 2 state release
0b20: 0a 09 24 7b 74 79 70 65 7d 3a 3a 53 54 41 54 45 ..${type}::STATE
0b30: 20 63 6c 6f 73 65 0a 09 69 66 20 7b 24 6d 79 70 close..if {$myp
0b40: 61 74 68 20 65 71 20 22 22 7d 20 72 65 74 75 72 ath eq ""} retur
0b50: 6e 0a 09 66 69 6c 65 20 64 65 6c 65 74 65 20 24 n..file delete $
0b60: 6d 79 70 61 74 68 0a 09 72 65 74 75 72 6e 0a 20 mypath..return.
0b70: 20 20 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 }.. typeme
0b80: 74 68 6f 64 20 77 72 69 74 69 6e 67 20 7b 6e 61 thod writing {na
0b90: 6d 65 20 64 65 66 69 6e 69 74 69 6f 6e 7d 20 7b me definition} {
0ba0: 0a 09 23 20 4d 65 74 68 6f 64 20 66 6f 72 20 61 ..# Method for a
0bb0: 20 75 73 65 72 20 74 6f 20 64 65 63 6c 61 72 65 user to declare
0bc0: 20 61 20 74 61 62 6c 65 20 69 74 73 20 6e 65 65 a table its nee
0bd0: 64 73 20 66 6f 72 20 73 74 6f 72 69 6e 67 0a 09 ds for storing..
0be0: 23 20 70 65 72 73 69 73 74 65 6e 74 20 73 74 61 # persistent sta
0bf0: 74 65 2c 20 61 6e 64 20 74 68 65 20 65 78 70 65 te, and the expe
0c00: 63 74 65 64 20 73 74 72 75 63 74 75 72 65 2e 20 cted structure.
0c10: 41 20 70 6f 73 73 69 62 6c 79 0a 09 23 20 70 72 A possibly..# pr
0c20: 65 76 69 6f 75 73 6c 79 20 65 78 69 73 74 69 6e eviously existin
0c30: 67 20 64 65 66 69 6e 69 74 69 6f 6e 20 69 73 20 g definition is
0c40: 64 72 6f 70 70 65 64 2e 0a 0a 09 24 6d 79 73 74 dropped....$myst
0c50: 61 74 65 20 74 72 61 6e 73 61 63 74 69 6f 6e 20 ate transaction
0c60: 7b 0a 09 20 20 20 20 63 61 74 63 68 20 7b 20 24 {.. catch { $
0c70: 6d 79 73 74 61 74 65 20 65 76 61 6c 20 22 44 52 mystate eval "DR
0c80: 4f 50 20 54 41 42 4c 45 20 24 6e 61 6d 65 22 20 OP TABLE $name"
0c90: 7d 0a 09 20 20 20 20 24 6d 79 73 74 61 74 65 20 }.. $mystate
0ca0: 65 76 61 6c 20 22 43 52 45 41 54 45 20 54 41 42 eval "CREATE TAB
0cb0: 4c 45 20 24 6e 61 6d 65 20 28 20 24 64 65 66 69 LE $name ( $defi
0cc0: 6e 69 74 69 6f 6e 20 29 22 0a 09 7d 0a 09 72 65 nition )"..}..re
0cd0: 74 75 72 6e 0a 20 20 20 20 7d 0a 0a 20 20 20 20 turn. }..
0ce0: 74 79 70 65 6d 65 74 68 6f 64 20 72 65 61 64 69 typemethod readi
0cf0: 6e 67 20 7b 6e 61 6d 65 7d 20 7b 0a 09 23 20 4d ng {name} {..# M
0d00: 65 74 68 6f 64 20 66 6f 72 20 61 20 75 73 65 72 ethod for a user
0d10: 20 74 6f 20 64 65 63 6c 61 72 65 20 61 20 74 61 to declare a ta
0d20: 62 6c 65 20 69 74 20 77 69 73 68 65 73 20 74 6f ble it wishes to
0d30: 20 72 65 61 64 0a 09 23 20 66 72 6f 6d 2e 20 41 read..# from. A
0d40: 20 6d 69 73 73 69 6e 67 20 74 61 62 6c 65 20 69 missing table i
0d50: 73 20 61 6e 20 69 6e 74 65 72 6e 61 6c 20 65 72 s an internal er
0d60: 72 6f 72 20 63 61 75 73 69 6e 67 20 61 6e 0a 09 ror causing an..
0d70: 23 20 69 6d 6d 65 64 69 61 74 65 20 65 78 69 74 # immediate exit
0d80: 2e 0a 0a 09 73 65 74 20 66 6f 75 6e 64 20 5b 6c ....set found [l
0d90: 6c 65 6e 67 74 68 20 5b 24 6d 79 73 74 61 74 65 length [$mystate
0da0: 20 65 76 61 6c 20 7b 0a 09 20 20 20 20 53 45 4c eval {.. SEL
0db0: 45 43 54 20 6e 61 6d 65 0a 09 20 20 20 20 46 52 ECT name.. FR
0dc0: 4f 4d 20 73 71 6c 69 74 65 5f 6d 61 73 74 65 72 OM sqlite_master
0dd0: 0a 09 20 20 20 20 57 48 45 52 45 20 74 79 70 65 .. WHERE type
0de0: 20 3d 20 27 74 61 62 6c 65 27 0a 09 20 20 20 20 = 'table'..
0df0: 41 4e 44 20 20 20 6e 61 6d 65 20 3d 20 24 6e 61 AND name = $na
0e00: 6d 65 0a 09 20 20 20 20 3b 0a 09 7d 5d 5d 0a 0a me.. ;..}]]..
0e10: 09 69 66 20 7b 24 66 6f 75 6e 64 7d 20 72 65 74 .if {$found} ret
0e20: 75 72 6e 0a 0a 09 74 72 6f 75 62 6c 65 20 69 6e urn...trouble in
0e30: 74 65 72 6e 61 6c 20 22 54 68 65 20 72 65 71 75 ternal "The requ
0e40: 69 72 65 64 20 74 61 62 6c 65 20 5c 22 24 6e 61 ired table \"$na
0e50: 6d 65 5c 22 20 69 73 20 6e 6f 74 20 64 65 66 69 me\" is not defi
0e60: 6e 65 64 2e 22 0a 09 23 20 4e 6f 74 20 72 65 61 ned."..# Not rea
0e70: 63 68 65 64 0a 09 72 65 74 75 72 6e 0a 20 20 20 ched..return.
0e80: 20 7d 0a 0a 20 20 20 20 74 79 70 65 6d 65 74 68 }.. typemeth
0e90: 6f 64 20 72 75 6e 20 7b 61 72 67 73 7d 20 7b 0a od run {args} {.
0ea0: 09 72 65 74 75 72 6e 20 5b 75 70 6c 65 76 65 6c .return [uplevel
0eb0: 20 31 20 5b 6c 69 6e 73 65 72 74 20 24 61 72 67 1 [linsert $arg
0ec0: 73 20 30 20 24 6d 79 73 74 61 74 65 20 65 76 61 s 0 $mystate eva
0ed0: 6c 5d 5d 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 l]]. }.. #
0ee0: 20 23 20 23 23 20 23 23 23 20 23 23 23 23 23 20 # ## ### #####
0ef0: 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 23 ######## #######
0f00: 23 23 23 23 23 23 0a 20 20 20 20 23 23 20 53 74 ######. ## St
0f10: 61 74 65 0a 0a 20 20 20 20 74 79 70 65 76 61 72 ate.. typevar
0f20: 69 61 62 6c 65 20 6d 79 73 74 61 74 65 20 7b 7d iable mystate {}
0f30: 20 3b 20 23 20 53 71 6c 69 74 65 20 64 61 74 61 ; # Sqlite data
0f40: 62 61 73 65 20 28 63 6f 6d 6d 61 6e 64 29 20 68 base (command) h
0f50: 6f 6c 64 69 6e 67 20 74 68 65 20 63 6f 6e 76 65 olding the conve
0f60: 72 74 65 72 20 73 74 61 74 65 2e 0a 20 20 20 20 rter state..
0f70: 74 79 70 65 76 61 72 69 61 62 6c 65 20 6d 79 70 typevariable myp
0f80: 61 74 68 20 20 7b 7d 20 3b 20 23 20 50 61 74 68 ath {} ; # Path
0f90: 20 74 6f 20 74 68 65 20 64 61 74 61 62 61 73 65 to the database
0fa0: 2c 20 66 6f 72 20 63 6c 65 61 6e 75 70 20 6f 66 , for cleanup of
0fb0: 20 61 20 74 65 6d 70 20 64 61 74 61 62 61 73 65 a temp database
0fc0: 2e 0a 0a 20 20 20 20 23 20 23 20 23 23 20 23 23 ... # # ## ##
0fd0: 23 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 # ##### ########
0fe0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 #############.
0ff0: 20 20 20 23 23 20 49 6e 74 65 72 6e 61 6c 20 6d ## Internal m
1000: 65 74 68 6f 64 73 0a 0a 0a 20 20 20 20 23 20 23 ethods... # #
1010: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 ## ### ##### ##
1020: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
1030: 23 23 23 23 0a 20 20 20 20 23 23 20 43 6f 6e 66 ####. ## Conf
1040: 69 67 75 72 61 74 69 6f 6e 0a 0a 20 20 20 20 70 iguration.. p
1050: 72 61 67 6d 61 20 2d 68 61 73 69 6e 73 74 61 6e ragma -hasinstan
1060: 63 65 73 20 20 20 6e 6f 20 3b 20 23 20 73 69 6e ces no ; # sin
1070: 67 6c 65 74 6f 6e 0a 20 20 20 20 70 72 61 67 6d gleton. pragm
1080: 61 20 2d 68 61 73 74 79 70 65 69 6e 66 6f 20 20 a -hastypeinfo
1090: 20 20 6e 6f 20 3b 20 23 20 6e 6f 20 69 6e 74 72 no ; # no intr
10a0: 6f 73 70 65 63 74 69 6f 6e 0a 20 20 20 20 70 72 ospection. pr
10b0: 61 67 6d 61 20 2d 68 61 73 74 79 70 65 64 65 73 agma -hastypedes
10c0: 74 72 6f 79 20 6e 6f 20 3b 20 23 20 69 6d 6d 6f troy no ; # immo
10d0: 72 74 61 6c 0a 0a 20 20 20 20 23 20 23 20 23 23 rtal.. # # ##
10e0: 20 23 23 23 20 23 23 23 23 23 20 23 23 23 23 23 ### ##### #####
10f0: 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 23 ### ############
1100: 23 0a 7d 0a 0a 6e 61 6d 65 73 70 61 63 65 20 65 #.}..namespace e
1110: 76 61 6c 20 3a 3a 76 63 3a 3a 66 6f 73 73 69 6c val ::vc::fossil
1120: 3a 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 20 7b 0a ::import::cvs {.
1130: 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 65 78 namespace ex
1140: 70 6f 72 74 20 73 74 61 74 65 0a 20 20 20 20 6e port state. n
1150: 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 73 74 amespace eval st
1160: 61 74 65 20 7b 0a 09 6e 61 6d 65 73 70 61 63 65 ate {..namespace
1170: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f import ::vc::to
1180: 6f 6c 73 3a 3a 74 72 6f 75 62 6c 65 0a 09 6e 61 ols::trouble..na
1190: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a mespace import :
11a0: 3a 76 63 3a 3a 74 6f 6f 6c 73 3a 3a 6c 6f 67 0a :vc::tools::log.
11b0: 09 6c 6f 67 20 72 65 67 69 73 74 65 72 20 73 74 .log register st
11c0: 61 74 65 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 23 ate. }.}..# #
11d0: 20 23 23 20 23 23 23 20 23 23 23 23 23 20 23 23 ## ### ##### ##
11e0: 23 23 23 23 23 23 20 23 23 23 23 23 23 23 23 23 ###### #########
11f0: 23 23 23 23 20 23 23 23 23 23 23 23 23 23 23 23 #### ###########
1200: 23 23 23 23 23 23 23 23 23 23 0a 23 23 20 52 65 ##########.## Re
1210: 61 64 79 0a 0a 70 61 63 6b 61 67 65 20 70 72 6f ady..package pro
1220: 76 69 64 65 20 76 63 3a 3a 66 6f 73 73 69 6c 3a vide vc::fossil:
1230: 3a 69 6d 70 6f 72 74 3a 3a 63 76 73 3a 3a 73 74 :import::cvs::st
1240: 61 74 65 20 31 2e 30 0a 72 65 74 75 72 6e 0a ate 1.0.return.