Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_repository.tcl part of check-in [6d1811d61e] - Continued work on pass II, skeleton of it completed by adding outline of code for persistence. by aku on 2007-10-06 21:19:26. [view]

To:

File tools/cvs2fossil/lib/c2f_repository.tcl part of check-in [3d88cfd05d] - Started capture of revision information in file objects. Capturing authors and commit messages and repository level. Completed persistence for these latter too. Rearranged the requirements, imports, and exports a bit to handle the new dependency cycle repository <- project <- file <- repository by aku on 2007-10-06 21:59:03. [view]

@@ -11,8 +11,10 @@
 # # ## ### ##### ######## ############# #####################
 
 ## Repository manager. Keeps projects and their files around.
 
+package provide vc::fossil::import::cvs::repository 1.0
+
 # # ## ### ##### ######## ############# #####################
 ## Requirements
 
 package require Tcl 8.4                          ; # Required runtime.
@@ -19,9 +21,9 @@
 package require snit                             ; # OO system.
 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
+# CVS Projects later (see bottom) to handle circular dependency in 'file'.
 package require vc::fossil::import::cvs::state   ; # State storage
 package require struct::list                     ; # List operations.
 package require fileutil                         ; # File operations.
 
@@ -69,8 +71,18 @@
 	    if {![IsProjectBase $mybase/$pp $mybase/CVSROOT msg]} {
 		trouble fatal $msg
 	    }
 	}
+	return
+    }
+
+    typemethod author {a} {
+	set myauthor($a) ""
+	return
+    }
+
+    typemethod cmessage {cm} {
+	set mycmsg($cm) ""
 	return
     }
 
     # pass I results
@@ -135,9 +147,10 @@
 
     # pass II persistence
     typemethod persistrev {} {
 	state transaction {
-	    # TODO: per repository persistence (authors, commit messages)
+	    SaveAuthors
+	    SaveCommitMessages
 	    foreach p [TheProjects] { $p persistrev }
 	}
 	return
     }
@@ -144,11 +157,13 @@
 
     # # ## ### ##### ######## #############
     ## State
 
-    typevariable mybase      {}
-    typevariable myprojpaths {}
-    typevariable myprojects  {}
+    typevariable mybase          {} ; # Base path to CVS repository.
+    typevariable myprojpaths     {} ; # Paths to all declared projects, relative to mybase.
+    typevariable myprojects      {} ; # Objects for all declared projects.
+    typevariable myauthor -array {} ; # Names of all authors found, later with id.
+    typevariable mycmsg   -array {} ; # All commit messages found, later with id.
 
     # # ## ### ##### ######## #############
     ## Internal methods
 
@@ -202,8 +217,34 @@
 	}
 	return $res
     }
 
+    proc SaveAuthors {} {
+	::variable myauthor
+	foreach a [lsort -dict [array names myauthor]] {
+	    state run {
+		INSERT INTO author (aid, name)
+		VALUES             (NULL, $a);
+	    }
+	    # Save id for use by the project/file persistence code.
+	    set myauthor($a) [state id]
+	}
+	return
+    }
+
+    proc SaveCommitMessages {} {
+	::variable mycmsg
+	foreach t [lsort -dict [array names mycmsg]] {
+	    state run {
+		INSERT INTO cmessage (cid, text)
+		VALUES             (NULL, $t);
+	    }
+	    # Save id for use by the project/file persistence code.
+	    set mycmsg($t) [state id]
+	}
+	return
+    }
+
     # # ## ### ##### ######## #############
     ## Configuration
 
     pragma -hasinstances   no ; # singleton
@@ -214,19 +255,24 @@
 }
 
 namespace eval ::vc::fossil::import::cvs {
     namespace export repository
-    namespace eval repository {
-	namespace import ::vc::fossil::import::cvs::project
-	namespace import ::vc::fossil::import::cvs::state
-	namespace import ::vc::tools::misc::*
-	namespace import ::vc::tools::trouble
-	namespace import ::vc::tools::log
-	log register repository
-    }
+}
+
+# CVS projects here to handle circular dependency
+# repository <- project <- file <- repository
+
+package require vc::fossil::import::cvs::project
+
+namespace eval ::vc::fossil::import::cvs::repository {
+    namespace import ::vc::fossil::import::cvs::project
+    namespace import ::vc::fossil::import::cvs::state
+    namespace import ::vc::tools::misc::*
+    namespace import ::vc::tools::trouble
+    namespace import ::vc::tools::log
+    log register repository
 }
 
 # # ## ### ##### ######## ############# #####################
 ## Ready
 
-package provide vc::fossil::import::cvs::repository 1.0
 return