Diff
Not logged in

Differences From:

File tools/tclfossil/lib/vc/fossil/db-1.0.tm part of check-in [2b9c6df430] - tclfossil: initial directory structure and package split up by mjanssen on 2008-02-19 18:05:51. Also file tools/tclfossil/lib/tf_db.tcl part of check-in [1c92462c04] - tclfossil: added revlist command by mjanssen on 2008-02-03 18:18:43. [view]

To:

File tools/tclfossil/lib/vc/fossil/db-1.0.tm part of check-in [8c4b530084] - tclfossil: added schema command by mjanssen on 2008-02-19 21:58:14. [view]

@@ -1,19 +1,54 @@
-package require Tcl 8.5
+## -*- tcl -*-
+# # ## ### ##### ######## ############# #####################
+## Copyright (c) 2008 Mark Janssen.
+#
+# 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
+# # ## ### ##### ######## ############# #####################
+
+## Db commands
+
+# # ## ### ##### ######## ############# #####################
+## Requirements
+
+package require Tcl 8.5                             ; # Required runtime.
+package require snit                                ; # OO system.
 package require sqlite3
-package require snit
+package require vc::fossil::schema      1.0         ; # Fossil repo schema
+
+package provide vc::fossil::db 1.0
+
+# # ## ### ##### ######## ############# #####################
+##
+
+
+
+namespace eval ::vc::fossil {
+
+    snit::type db {
+	typevariable schemadir [file join [file dirname [info script]] schema]
+        typevariable dbcmd [namespace current]::sqldb
+
+	typemethod create_repository {filename} {
+	    if {[file exists $filename]} {
+		ui panic "file already exists: $filename"
+	    }
+	    db init_database $filename [schema repo1] [schema repo2]
+	}
 
-snit::type ::vc::fossil::db {
-    variable db
-    method open_repository {{name {}}} {
-	sqlite3 db1 c:/src/fossil.fsl
-        set db db1
-    }
-    method revlist {} {
-	$db eval {select uuid from blob}
+	typemethod init_database {filename schema args} {
+	    sqlite3 $dbcmd $filename
+	    $dbcmd transaction {
+		$dbcmd eval $schema
+		foreach schema $args {
+		    $dbcmd eval $schema
+		}
+	    }
+	    $dbcmd close
+	}
     }
 }
-
-vc::fossil::db create fossildb
-
-fossildb open_repository
-puts [fossildb revlist]