Overview
SHA1 Hash: | eb656de7d9a95af6a040f307c0b1d5c253b4d246 |
---|---|
Date: | 2007-10-05 05:33:14 |
User: | aku |
Comment: | Added the basic parts of the state manager and integrated it with option processor and pass manager. |
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_option.tcl from [79fff162dc] to [5618bdee19].
@@ -23,10 +23,11 @@ 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::pass::collar ; # Pass I. package require vc::fossil::import::cvs::repository ; # Repository management +package require vc::fossil::import::cvs::state ; # State storage # # ## ### ##### ######## ############# ##################### ## snit::type ::vc::fossil::import::cvs::option { @@ -38,50 +39,45 @@ # -p, --pass, --passes # --ignore-conflicting-attics # --project # -v, --verbose # -q, --quiet - - # --cache (conversion status, ala config.cache) + # --state (conversion status, ala config.cache) + # -o, --output # --dry-run # --trunk-only # --force-branch RE # --force-tag RE # --symbol-transform RE:XX # --exclude - # -p, --passes # # ## ### ##### ######## ############# ## Public API, Methods typemethod process {arguments} { # Syntax of arguments: ?option ?value?...? /path/to/cvs/repository while {[IsOption arguments -> option]} { switch -exact -- $option { - -h - - --help { PrintHelp ; exit 0 } - --help-passes { pass help ; exit 0 } - --version { PrintVersion ; exit 0 } - + -h - + --help { PrintHelp ; exit 0 } + --help-passes { pass help ; exit 0 } + --version { PrintVersion ; exit 0 } -p - --pass - --passes { pass select [Value arguments] } - --ignore-conflicting-attics { collar ignore_conflicting_attics } - - --project { repository add [Value arguments] } - -v - - --verbose { log verbose } - -q - - --quiet { log quiet } - - --cache { - # [Value arguments] - } - default { Usage $badoption$option\n$gethelp } + --project { repository add [Value arguments] } + -v - + --verbose { log verbose } + -q - + --quiet { log quiet } + --state { state use [Value arguments] } + default { + Usage $badoption$option\n$gethelp + } } } if {[llength $arguments] > 1} Usage if {[llength $arguments] < 1} { Usage $nocvs } @@ -101,10 +97,12 @@ trouble info " Information options" trouble info "" trouble info " -h, --help Print this message and exit with success" trouble info " --help-passes Print list of passes and exit with success" trouble info " --version Print version number of $argv0" + trouble info " -v, --verbose Increase application's verbosity" + trouble info " -q, --quiet Decrease application's verbosity" trouble info "" trouble info " Conversion control options" trouble info "" trouble info " -p, --pass PASS Run only the specified conversion pass" trouble info " -p, --passes ?START?:?END? Run only the passes START through END," @@ -113,10 +111,13 @@ trouble info " Passes are specified by name." trouble info "" trouble info " --ignore-conflicting-attics" trouble info " Prevent abort when conflicting archives" trouble info " were found in both regular and Attic." + trouble info "" + trouble info " --state PATH Save state to the specified file, and" + trouble info " load state of previous runs from it too." trouble info "" # --project, --cache # ... return @@ -166,10 +167,11 @@ proc Validate {} { # Prevent in-depth validation if the options were already bad. trouble abort? repository validate + state setup trouble abort? return } @@ -189,13 +191,14 @@ namespace import ::vc::tools::trouble namespace import ::vc::tools::log namespace import ::vc::fossil::import::cvs::pass namespace import ::vc::fossil::import::cvs::pass::collar namespace import ::vc::fossil::import::cvs::repository + namespace import ::vc::fossil::import::cvs::state } } # # ## ### ##### ######## ############# ##################### ## Ready package provide vc::fossil::import::cvs::option 1.0 return
Modified tools/cvs2fossil/lib/c2f_pass.tcl from [6e976f604b] to [556a226a8a].
@@ -17,10 +17,11 @@ # # ## ### ##### ######## ############# ##################### ## Requirements package require Tcl 8.4 ; # Required runtime. package require snit ; # OO system. +package require vc::fossil::import::cvs::state ; # State storage package require vc::tools::trouble ; # Error reporting. package require vc::tools::log ; # User feedback. package require struct::list ; # Portable lassign # # ## ### ##### ######## ############# ##################### @@ -106,10 +107,12 @@ log write 0 pass "Begin $p" Call $p run log write 0 pass "Done $p" trouble abort? } + + state release return } # # ## ### ##### ######## ############# ## Internal methods @@ -163,10 +166,11 @@ } namespace eval ::vc::fossil::import::cvs { namespace export pass namespace eval pass { + namespace import ::vc::fossil::import::cvs::state namespace import ::vc::tools::trouble namespace import ::vc::tools::log log register pass } }
Modified tools/cvs2fossil/lib/c2f_repository.tcl from [ccb926d285] to [253c3cc7e6].
@@ -20,10 +20,11 @@ package require vc::tools::trouble ; # Error reporting. package require vc::tools::log ; # User feedback. package require vc::tools::misc ; # Text formatting package require vc::fossil::import::cvs::project ; # CVS projects package require struct::list ; # List operations. +package require fileutil ; # File operations. # # ## ### ##### ######## ############# ##################### ## snit::type ::vc::fossil::import::cvs::repository {
Added tools/cvs2fossil/lib/c2f_state.tcl version [52c46d7daa]
@@ -1,1 +1,127 @@ +## -*- tcl -*- +# # ## ### ##### ######## ############# ##################### +## Copyright (c) 2007 Andreas Kupries. +# +# This software is licensed as described in the file LICENSE, which +# you should have received as part of this distribution. +# +# This software consists of voluntary contributions made by many +# individuals. For exact contribution history, see the revision +# history and logs, available at http://fossil-scm.hwaci.com/fossil +# # ## ### ##### ######## ############# ##################### + +## State manager. Maintains the sqlite database used by all the other +## parts of the system, especially the passes and their support code, +## to persist and restore their state across invokations. + +# # ## ### ##### ######## ############# ##################### +## Requirements + +package require Tcl 8.4 ; # Required runtime. +package require snit ; # OO system. +package require fileutil ; # File operations. +package require sqlite3 ; # Database access. +package require vc::tools::trouble ; # Error reporting. +package require vc::tools::log ; # User feedback. + +# # ## ### ##### ######## ############# ##################### +## + +snit::type ::vc::fossil::import::cvs::state { + # # ## ### ##### ######## ############# + ## Public API + + typemethod use {path} { + # Immediate validation. There are are two possibilities to + # consider. The path exists or it doesn't. + + # In the first case it has to be a readable and writable file, + # and it has to be a proper sqlite database. Further checks + # regarding the required tables will be done later, by the + # passes, during their setup. + + # In the second case we have to be able to create the file, + # and check that. This is done by opening it, sqlite will then + # try to create it, and may fail. + + if {[file exists $path]} { + if {![fileutil::test $path frw msg {cvs2fossil state}]} { + trouble fatal $msg + return + } + } + + if {[catch { + sqlite3 ${type}::TEMP $path + } res]} { + trouble fatal $res + return + } + + # 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 {} + 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 + + set mypath [fileutil::tempfile cvs2fossil_state_] + sqlite3 ${type}::STATE $mypath + + log write 2 state "using $mypath" + return + } + + typemethod release {} { + log write 2 state release + ${type}::STATE close + if {$mypath eq ""} return + file delete $mypath + return + } + + # # ## ### ##### ######## ############# + ## State + + typevariable mystate {} ; # Sqlite database (command) holding the converter state. + typevariable mypath {} ; # Path to the database, for cleanup of a temp database. + + # # ## ### ##### ######## ############# + ## Internal methods + + + # # ## ### ##### ######## ############# + ## Configuration + + pragma -hasinstances no ; # singleton + pragma -hastypeinfo no ; # no introspection + pragma -hastypedestroy no ; # immortal + + # # ## ### ##### ######## ############# +} + +namespace eval ::vc::fossil::import::cvs { + namespace export state + namespace eval state { + namespace import ::vc::tools::trouble + namespace import ::vc::tools::log + log register state + } +} + +# # ## ### ##### ######## ############# ##################### +## Ready +package provide vc::fossil::import::cvs::state 1.0 +return
Modified tools/cvs2fossil/lib/pkgIndex.tcl from [e327e448a1] to [f6ad9cb77b].
@@ -7,9 +7,10 @@ package ifneeded vc::fossil::import::cvs::option 1.0 [list source [file join $dir c2f_option.tcl]] package ifneeded vc::fossil::import::cvs::pass 1.0 [list source [file join $dir c2f_pass.tcl]] package ifneeded vc::fossil::import::cvs::pass::collar 1.0 [list source [file join $dir c2f_pcollar.tcl]] package ifneeded vc::fossil::import::cvs::repository 1.0 [list source [file join $dir c2f_repository.tcl]] package ifneeded vc::fossil::import::cvs::project 1.0 [list source [file join $dir c2f_project.tcl]] +package ifneeded vc::fossil::import::cvs::state 1.0 [list source [file join $dir c2f_state.tcl]] package ifneeded vc::tools::trouble 1.0 [list source [file join $dir trouble.tcl]] package ifneeded vc::tools::log 1.0 [list source [file join $dir log.tcl]] package ifneeded vc::tools::misc 1.0 [list source [file join $dir misc.tcl]]