SHA1 Hash: | e288af39955b2602cd601c2cd928b8e68c7ff8d9 |
---|---|
Date: | 2007-12-02 23:47:45 |
User: | aku |
Comment: | Fluff: Renamed state methods use/reading/writing to usedb/use/extend for clarity. Updated all callers. Extended state module with code to dump the SQL statements it receives to a file for analysis. Extended the 'use' declarations of several passes. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Modified tools/cvs2fossil/lib/c2f_option.tcl from [5835c5aa1e] to [6e1ccf1f24].
@@ -73,18 +73,19 @@ --project { repository add [Value arguments] } -v - --verbose { log verbose } -q - --quiet { log quiet } - --state { state use [Value arguments] } + --state { state usedb [Value arguments] } --trunk-only { repository trunkonly! } --exclude { project::sym exclude [Value arguments] } --force-tag { project::sym forcetag [Value arguments] } --force-branch { project::sym forcebranch [Value arguments] } --batch { log noprogress } --dots { cyclebreaker dotsto [Value arguments] } --watch { cyclebreaker watch [Value arguments] } + --statesavequeriesto { state savequeriesto [Value arguments] } default { Usage $badoption$option\n$gethelp } } } @@ -142,10 +143,12 @@ trouble info " --force-branch ?PROJECT:?SYMBOL" trouble info " Force the named symbol from all or just" trouble info " the specified project to be converted as" trouble info " branch. Both project and symbol names" trouble info " are glob patterns." + trouble info "" + trouble info " Debug options" trouble info "" trouble info " --dots PATH Write the changeset graphs before, after," trouble info " and during breaking the of cycles to the" trouble info " direcotry PATH, using GraphViz's dot format" trouble info ""
Modified tools/cvs2fossil/lib/c2f_pass.tcl from [b27a6e1d11] to [2edf9bde57].
@@ -126,27 +126,35 @@ state release ShowTimes return } + typemethod current {} { return $mycurrentpass } + + # # ## ### ##### ######## ############# + ## Internal methods + proc Time {pass useconds} { ::variable mytime lappend mytime $pass $useconds + ShowTime $pass $useconds return } proc ShowTimes {} { ::variable mytime foreach {pass useconds} $mytime { - set sec [format %8.2f [expr {double($useconds)/1e6}]] - log write 0 pass "$sec sec/$pass" + ShowTime $pass $useconds } return } - # # ## ### ##### ######## ############# - ## Internal methods + proc ShowTime {pass useconds} { + set sec [format %8.2f [expr {double($useconds)/1e6}]] + log write 0 pass "$sec sec/$pass" + return + } proc Ok? {code label ov {emptyok 1}} { upvar 1 $ov ok ::variable mydesc if {$emptyok && ($code eq "")} return @@ -180,13 +188,14 @@ typevariable mypasses {} ; # List of registered passes (codes). typevariable mydesc -array {} ; # Pass descriptions (one line). typevariable mycmd -array {} ; # Pass callback command. - typevariable mystart -1 - typevariable myend -1 - typevariable mytime {} ; # Timing data for each executed pass. + typevariable mystart -1 + typevariable myend -1 + typevariable mytime {} ; # Timing data for each executed pass. + typevariable mycurrentpass {} ; # Pass currently running. # # ## ### ##### ######## ############# ## Configuration pragma -hasinstances no ; # singleton
Modified tools/cvs2fossil/lib/c2f_patopsort.tcl from [bd713af4f1] to [bd89b94e5f].
@@ -43,15 +43,20 @@ typemethod setup {} { # Define the names and structure of the persistent state of # this pass. - state reading revision - state reading changeset - state reading csorder - - state writing cstimestamp { + state use revision + state use tag + state use branch + state use symbol + state use changeset + state use csitem + state use cssuccessor + state use csorder + + state extend cstimestamp { -- Commit order of all changesets based on their -- dependencies, plus a monotonically increasing -- timestamp. cid INTEGER NOT NULL REFERENCES changeset,
Modified tools/cvs2fossil/lib/c2f_pbreakacycle.tcl from [9244bb5c27] to [7e073778fc].
@@ -49,13 +49,17 @@ typemethod setup {} { # Define the names and structure of the persistent state of # this pass. - state reading changeset - state reading csitem - state reading csorder + state use revision + state use tag + state use branch + state use symbol + state use changeset + state use csitem + state use cssuccessor return } typemethod load {} { # Pass manager interface. Executed to load data computed by
Modified tools/cvs2fossil/lib/c2f_pbreakrcycle.tcl from [3c073e957a] to [9b0d3d5360].
@@ -45,13 +45,17 @@ typemethod setup {} { # Define the names and structure of the persistent state of # this pass. - state reading revision - state reading changeset - state reading csitem + state use revision + state use symbol + state use changeset + state use csitem + state use cstype + state use cssuccessor + return } typemethod load {} { # Pass manager interface. Executed to load data computed by
Modified tools/cvs2fossil/lib/c2f_pbreakscycle.tcl from [24924cb693] to [9943947d7e].
@@ -45,13 +45,17 @@ typemethod setup {} { # Define the names and structure of the persistent state of # this pass. - state reading revision - state reading changeset - state reading csitem + state use revision + state use tag + state use branch + state use symbol + state use changeset + state use csitem + state use cssuccessor return } typemethod load {} { # Pass manager interface. Executed to load data computed by
Modified tools/cvs2fossil/lib/c2f_pcollar.tcl from [a368b702c3] to [b8d8d74143].
@@ -63,15 +63,15 @@ # associated with the rcs archive. # Both projects and files are identified by globally unique # integer ids, automatically assigned by the database. - state writing project { + state extend project { pid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL UNIQUE } - state writing file { + state extend file { fid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, pid INTEGER NOT NULL REFERENCES project, -- project the file belongs to name TEXT NOT NULL, visible TEXT NOT NULL, exec INTEGER NOT NULL, -- boolean, 'file executable'. @@ -83,12 +83,12 @@ typemethod load {} { # Pass manager interface. Executed for all passes before the # run passes, to load all data of their pass from the state, # as if it had been computed by the pass itself. - state reading project - state reading file + state use project + state use file repository load return }
Modified tools/cvs2fossil/lib/c2f_pcollrev.tcl from [e100446c46] to [5bb47f2e68].
@@ -45,12 +45,12 @@ typemethod setup {} { # Define names and structure of the persistent state of this # pass. - state reading project - state reading file + state use project + state use file # We deal with per project and per file data, the first # collated from the second. # Per file we have general information, ..., and then @@ -64,11 +64,11 @@ # Pseudo class hierarchy # Tag <- Symbol <- Event # Branch <- Symbol <- Event # Revision <- Event - state writing revision { + state extend revision { -- Revisions. Identified by a global numeric id each -- belongs to a single file, identified by its id. It -- further has a dotted revision number (DTN). -- -- Constraint: The dotted revision number is unique within @@ -144,11 +144,11 @@ clen INTEGER NOT NULL, UNIQUE (fid, rev) -- The DTN is unique within the revision's file. } - state writing optype { + state extend optype { oid INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL, UNIQUE(name) } state run { @@ -156,11 +156,11 @@ INSERT INTO optype VALUES ( 0,'nothing'); -- fixed pieces, see myopstate INSERT INTO optype VALUES ( 1,'add'); -- in file::rev. myopcode is INSERT INTO optype VALUES ( 2,'change'); -- loaded from this. } - state writing revisionbranchchildren { + state extend revisionbranchchildren { -- The non-primary children of a revision, as reachable -- through a branch symbol, are listed here. This is -- needed by pass 5 to break internal dependencies in a -- changeset. @@ -167,11 +167,11 @@ rid INTEGER NOT NULL REFERENCES revision, brid INTEGER NOT NULL REFERENCES revision, UNIQUE(rid,brid) } - state writing tag { + state extend tag { tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag @@ -178,11 +178,11 @@ rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged. } { rev sid } # Indices on: rev (revision successors) # sid (tag predecessors, branch successors/predecessors) - state writing branch { + state extend branch { bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch @@ -207,11 +207,11 @@ # # pTrunk <- pLineOfDevelopment # pBranch <- pSymbol, pLineOfDevelopment # pTag <- pSymbol, pLineOfDevelopment - state writing symbol { + state extend symbol { sid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, pid INTEGER NOT NULL REFERENCES project, -- Project the symbol belongs to name TEXT NOT NULL, type INTEGER NOT NULL REFERENCES symtype, -- enum { excluded = 0, tag, branch, undefined } @@ -220,30 +220,30 @@ commit_count INTEGER NOT NULL, -- How often a file was committed on the symbol UNIQUE (pid, name) -- Symbols are unique within the project } - state writing blocker { + state extend blocker { -- For each symbol we save which other symbols are -- blocking its removal (if the user asks for it). sid INTEGER NOT NULL REFERENCES symbol, -- bid INTEGER NOT NULL REFERENCES symbol, -- Sprouted from sid, blocks it. UNIQUE (sid, bid) } - state writing parent { + state extend parent { -- For each symbol we save which other symbols can act as -- a possible parent in some file, and how often. sid INTEGER NOT NULL REFERENCES symbol, -- pid INTEGER NOT NULL REFERENCES symbol, -- Possible parent of sid n INTEGER NOT NULL, -- How often pid can act as parent. UNIQUE (sid, pid) } - state writing symtype { + state extend symtype { tid INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL, plural TEXT NOT NULL, UNIQUE (name) UNIQUE (plural) @@ -253,11 +253,11 @@ INSERT INTO symtype VALUES (1,'tag', 'tags'); INSERT INTO symtype VALUES (2,'branch', 'branches'); INSERT INTO symtype VALUES (3,'undefined','undefined'); } - state writing meta { + state extend meta { -- Meta data of revisions. See revision.mid for the -- reference. Many revisions can share meta data. This is -- actually one of the criterions used to sort revisions -- into changesets. @@ -284,16 +284,16 @@ } # Authors and commit messages are fully global, i.e. per # repository. - state writing author { + state extend author { aid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL UNIQUE } - state writing cmessage { + state extend cmessage { cid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, text TEXT NOT NULL UNIQUE } project::sym getsymtypes @@ -300,13 +300,13 @@ file::rev getopcodes return } typemethod load {} { - state reading symbol - state reading symtype - state reading optype + state use symbol + state use symtype + state use optype project::sym getsymtypes file::rev getopcodes repository loadsymbols return
Modified tools/cvs2fossil/lib/c2f_pcollsym.tcl from [47871c6aa2] to [50ae29e5d8].
@@ -43,15 +43,17 @@ typemethod setup {} { # Define names and structure of the persistent state of this # pass. - state reading symbol - state reading blocker - state reading parent - - state writing preferedparent { + state use project + state use symbol + state use symtype + state use blocker + state use parent + + state extend preferedparent { -- For each symbol the prefered parent. This describes the -- tree of the found lines of development. Actually a -- forest in case of multiple projects, with one tree per -- project.
Modified tools/cvs2fossil/lib/c2f_pfiltersym.tcl from [940562fb7e] to [84d0049634].
@@ -43,20 +43,25 @@ typemethod setup {} { # Define names and structure of the persistent state of this # pass. - state reading symbol - state reading blocker - state reading parent - state reading preferedparent - state reading revision - state reading revisionbranchchildren - state reading branch - state reading tag - - state writing noop { + state use project + state use file + state use revision + state use revisionbranchchildren + state use branch + state use tag + state use symbol + state use blocker + state use parent + state use author + state use cmessage + state use preferedparent + + # NOTE: So far no pass coming after this makes us of this information. + state extend noop { id INTEGER NOT NULL PRIMARY KEY, -- tag/branch reference noop INTEGER NOT NULL } return }
Modified tools/cvs2fossil/lib/c2f_pinitcsets.tcl from [ced4d957b1] to [87cc4829ad].
@@ -43,29 +43,31 @@ typemethod setup {} { # Define the names and structure of the persistent state of # this pass. - state reading meta - state reading revision - state reading revisionbranchchildren - state reading branch - state reading tag - state reading symbol + state use project + state use file + state use revision + state use revisionbranchchildren + state use branch + state use tag + state use symbol + state use meta # Data per changeset, namely the project it belongs to, how it # was induced (revision or symbol), plus reference to the # primary entry causing it (meta entry or symbol). An adjunct # table translates the type id's into human readable labels. - state writing changeset { + state extend changeset { cid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, pid INTEGER NOT NULL REFERENCES project, type INTEGER NOT NULL REFERENCES cstype, src INTEGER NOT NULL -- REFERENCES meta|symbol (type dependent) } - state writing cstype { + state extend cstype { tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, UNIQUE (name) } # Note: Keep the labels used here in sync with the names for @@ -86,11 +88,11 @@ # from disparate sources the same id may have different # meaning, be in different changesets and so is formally not # unique. So we can only say that it is unique within the # changeset. The integrity module has stronger checks. - state writing csitem { + state extend csitem { cid INTEGER NOT NULL REFERENCES changeset, pos INTEGER NOT NULL, iid INTEGER NOT NULL, -- REFERENCES revision|tag|branch UNIQUE (cid, pos), UNIQUE (cid, iid) @@ -104,13 +106,13 @@ typemethod load {} { # Pass manager interface. Executed to load data computed by # this pass into memory when this pass is skipped instead of # executed. - state reading changeset - state reading csitem - state reading cstype + state use changeset + state use csitem + state use cstype # Need the types first, the constructor in the loop below uses # them to assert the correctness of type names. project::rev getcstypes
Modified tools/cvs2fossil/lib/c2f_prtopsort.tcl from [108eb140ec] to [bc1fe01638].
@@ -43,15 +43,18 @@ typemethod setup {} { # Define the names and structure of the persistent state of # this pass. - state reading revision - state reading changeset - state reading csitem - - state writing csorder { + state use revision + state use symbol + state use changeset + state use csitem + state use cstype + state use cssuccessor + + state extend csorder { -- Commit order of the revision changesets based on their -- dependencies cid INTEGER NOT NULL REFERENCES changeset, pos INTEGER NOT NULL, @@ -64,11 +67,11 @@ typemethod load {} { # Pass manager interface. Executed to load data computed by # this pass into memory when this pass is skipped instead of # executed. - state reading changeset + state use changeset project::rev loadcounter return } typemethod run {} {
Modified tools/cvs2fossil/lib/c2f_state.tcl from [e4b4a90ad7] to [6d7e829406].
@@ -29,11 +29,11 @@ snit::type ::vc::fossil::import::cvs::state { # # ## ### ##### ######## ############# ## Public API - typemethod use {path} { + typemethod usedb {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 @@ -93,38 +93,41 @@ if {$mypath eq ""} return file delete $mypath return } - typemethod writing {name definition {indices {}}} { - # 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. - - log write 1 state "writing $name" ; # TODO move to level 5 or so + # Declare a table needed for the storing of persistent state, and + # its structure. A possibly previously existing definition is + # dropped. To be used when a table is needed and not assumed to + # exist from previous passes. + + typemethod extend {name definition {indices {}}} { + log write 5 state "extend $name" + Save "extend $name ================================" $mystate transaction { catch { $mystate eval "DROP TABLE $name" } $mystate eval "CREATE TABLE $name ( $definition )" set id 0 foreach columns $indices { - log write 1 state "index $name$id" ; # TODO move to level 5 or so + log write 5 state "index $name$id" $mystate eval "CREATE INDEX ${name}$id ON ${name} ( [join $columns ,] )" incr id } } return } - typemethod reading {name} { - log write 1 state "reading $name" ; # TODO move to level 5 or so - - # Method for a user to declare a table it wishes to read - # from. A missing table is an internal error causing an - # immediate exit. + # Declare that a table is needed for reading from and/or storing + # to persistent state, and is assumed to already exist. A missing + # table is an internal error causing an immediate exit. + + typemethod use {name} { + log write 5 state "use $name" + Save "use $name ===================================" set found [llength [$mystate eval { SELECT name FROM sqlite_master WHERE type = 'table' @@ -141,24 +144,26 @@ typemethod discard {name} { # Method for a user to remove outdated information from the # persistent state, table by table. - log write 1 state "discard $name" ; # TODO move to level 5 or so + log write 5 state "discard $name" $mystate transaction { catch { $mystate eval "DROP TABLE $name" } } return } typemethod run {args} { + Save $args return [uplevel 1 [linsert $args 0 $mystate eval]] } typemethod one {args} { - return [lindex [uplevel 1 [linsert $args 0 $mystate eval]] 0] + Save $args + return [uplevel 1 [linsert $args 0 $mystate onecolumn]] } typemethod transaction {script} { return [uplevel 1 [list $mystate transaction $script]] } @@ -165,15 +170,30 @@ typemethod id {} { return [$mystate last_insert_rowid] } + typemethod savequeriesto {path} { + set mysavepath $path + return + } + + # # ## ### ##### ######## ############# + + proc Save {text} { + ::variable mysavepath + if {$mysavepath eq ""} return + fileutil::appendToFile $mysavepath $text\n\n + return + } + # # ## ### ##### ######## ############# ## State - typevariable mystate {} ; # Sqlite database (command) holding the converter state. - typevariable mypath {} ; # Path to the database, for cleanup of a temp database. + typevariable mystate {} ; # Sqlite database (command) holding the converter state. + typevariable mypath {} ; # Path to the database, for cleanup of a temp database. + typevariable mysavepath {} ; # Path where to save queries for introspection. # # ## ### ##### ######## ############# ## Internal methods