Overview
SHA1 Hash: | fb1e36d29079d0277625d26dc936071b80687370 |
---|---|
Date: | 2007-10-05 06:50:57 |
User: | aku |
Comment: | Extended state handling with methods to declare usage and structure of state, started integration of state with pass I, collection of projects and files. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified tools/cvs2fossil/lib/c2f_pcollar.tcl from [bae64eb186] to [6434dc7e4c].
@@ -24,10 +24,11 @@ package require fileutil ; # File & path utilities. package require vc::tools::trouble ; # Error reporting. package require vc::tools::log ; # User feedback. package require vc::fossil::import::cvs::pass ; # Pass management. package require vc::fossil::import::cvs::repository ; # Repository management. +package require vc::fossil::import::cvs::state ; # State storage # # ## ### ##### ######## ############# ##################### ## Register the pass with the management vc::fossil::import::cvs::pass define \ @@ -41,11 +42,24 @@ snit::type ::vc::fossil::import::cvs::pass::collar { # # ## ### ##### ######## ############# ## Public API typemethod setup {} { - # TODO ... artifact/cache - drop projects/files, create projects/files + # Define names and structure of the persistent state of this + # pass. + + state writing project { + pid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL UNIQUE + } + state writing files { + fid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + pid INTEGER NOT NULL REFERENCES project, + name TEXT NOT NULL UNIQUE, + visible TEXT NOT NULL UNIQUE + } + return } typemethod run {} { set rbase [repository base?] foreach project [repository projects] { @@ -164,10 +178,11 @@ namespace eval ::vc::fossil::import::cvs::pass { namespace export collar namespace eval collar { namespace import ::vc::fossil::import::cvs::repository + namespace import ::vc::fossil::import::cvs::state namespace import ::vc::tools::trouble namespace import ::vc::tools::log log register collar } }
Modified tools/cvs2fossil/lib/c2f_state.tcl from [52c46d7daa] to [2094dd757c].
@@ -61,25 +61,29 @@ # A previously defined state database is closed before # committing to the new definition. We do not store the path # itself, this ensures that the file is _not_ cleaned up after # a run. - catch { ${type}::STATE close } - rename ${type}::TEMP ${type}::STATE - - set mypath {} + set mystate ${type}::STATE + set mypath {} + + catch { $mystate close } + rename ${type}::TEMP $mystate + + log write 2 state "is $path" return } typemethod setup {} { # If, and only if no state database was defined by the user # then it is now the time to create our own using a tempfile. - if {[llength [info commands ${type}::STATE]]} return + if {$mystate ne ""} return set mypath [fileutil::tempfile cvs2fossil_state_] - sqlite3 ${type}::STATE $mypath + set mystate ${type}::STATE + sqlite3 $mystate $mypath log write 2 state "using $mypath" return } @@ -87,10 +91,46 @@ log write 2 state release ${type}::STATE close if {$mypath eq ""} return file delete $mypath return + } + + typemethod writing {name definition} { + # Method for a user to declare a table its needs for storing + # persistent state, and the expected structure. A possibly + # previously existing definition is dropped. + + $mystate transaction { + catch { $mystate eval "DROP TABLE $name" } + $mystate eval "CREATE TABLE $name ( $definition )" + } + return + } + + typemethod reading {name} { + # Method for a user to declare a table it wishes to read + # from. A missing table is an internal error causing an + # immediate exit. + + set found [llength [$mystate eval { + SELECT name + FROM sqlite_master + WHERE type = 'table' + AND name = $name + ; + }]] + + if {$found} return + + trouble internal "The required table \"$name\" is not defined." + # Not reached + return + } + + typemethod run {args} { + return [uplevel 1 [linsert $args 0 $mystate eval]] } # # ## ### ##### ######## ############# ## State