Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [84de38d73f] - Added a lot of skeleton files for the revision and symbol data structures, for both project and file level. by aku on 2007-10-10 03:28:22. [view]

To:

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. [view]

@@ -9,15 +9,17 @@
 # individuals.  For exact contribution history, see the revision
 # history and logs, available at http://fossil-scm.hwaci.com/fossil
 # # ## ### ##### ######## ############# #####################
 
-## Revisions per project, aka Changesets.
+## Revisions per project, aka Changesets. These objects are first used
+## in pass 5, which creates the initial set covering the repository.
 
 # # ## ### ##### ######## ############# #####################
 ## Requirements
 
-package require Tcl 8.4                             ; # Required runtime.
-package require snit                                ; # OO system.
+package require Tcl 8.4                               ; # Required runtime.
+package require snit                                  ; # OO system.
+package require vc::fossil::import::cvs::state        ; # State storage.
 
 # # ## ### ##### ######## ############# #####################
 ##
 
@@ -24,34 +26,79 @@
 snit::type ::vc::fossil::import::cvs::project::rev {
     # # ## ### ##### ######## #############
     ## Public API
 
-    constructor {} {
+    constructor {project cstype srcid revisions} {
+	set myid        [incr mycounter]
+	set myproject   $project
+	set mytype      $cstype
+	set mysrcid	$srcid
+	set myrevisions $revisions
+	return
+    }
+
+    method persist {} {
+	set tid $mycstype($mytype)
+	set pid [$myproject id]
+	set pos 0
+
+	state transaction {
+	    state run {
+		INSERT INTO changeset (cid,   pid,  type, src)
+		VALUES                ($myid, $pid, $tid, $mysrcid);
+	    }
+
+	    foreach rid $myrevisions {
+		state run {
+		    INSERT INTO csrevision (cid,   pos,  rid)
+		    VALUES                 ($myid, $pos, $rid);
+		}
+		incr pos
+	    }
+	}
 	return
     }
 
     # # ## ### ##### ######## #############
     ## State
 
+    variable myid        ; # Id of the cset for the persistent state.
+    variable myproject   ; # Reference of the project object the changeset belongs to.
+    variable mytype      ; # rev or sym, where the cset originated from.
+    variable mysrcid     ; # id of the metadata or symbol the cset is based on.
+    variable myrevisions ; # List of the file level revisions in the cset.
+
     # # ## ### ##### ######## #############
     ## Internal methods
+
+    typevariable mycounter        0 ; # Id counter for csets.
+    typevariable mycstype -array {} ; # Map cstypes to persistent ids.
+
+    typemethod getcstypes {} {
+	foreach {tid name} [state run {
+	    SELECT tid, name FROM cstype;
+	}] { set mycstype($name) $tid }
+	return
+    }
 
     # # ## ### ##### ######## #############
     ## Configuration
 
     pragma -hastypeinfo    no  ; # no type introspection
     pragma -hasinfo        no  ; # no object introspection
-    pragma -hastypemethods no  ; # type is not relevant.
     pragma -simpledispatch yes ; # simple fast dispatch
 
     # # ## ### ##### ######## #############
 }
 
 namespace eval ::vc::fossil::import::cvs::project {
     namespace export rev
+    namespace eval rev {
+	namespace import ::vc::fossil::import::cvs::state
+    }
 }
 
 # # ## ### ##### ######## ############# #####################
 ## Ready
 
 package provide vc::fossil::import::cvs::project::rev 1.0
 return