Fossil SCM

fossil-scm / tools / tclfossil / lib / vc / fossil / db-1.0.tm
Blame History Raw 54 lines
1
## -*- tcl -*-
2
# # ## ### ##### ######## ############# #####################
3
## Copyright (c) 2008 Mark Janssen.
4
#
5
# This software is licensed as described in the file LICENSE, which
6
# you should have received as part of this distribution.
7
#
8
# This software consists of voluntary contributions made by many
9
# individuals. For exact contribution history, see the revision
10
# history and logs, available at http://fossil-scm.hwaci.com/fossil
11
# # ## ### ##### ######## ############# #####################
12
13
## Db commands
14
15
# # ## ### ##### ######## ############# #####################
16
## Requirements
17
18
package require Tcl 8.5 ; # Required runtime.
19
package require snit ; # OO system.
20
package require sqlite3
21
package require vc::fossil::schema 1.0 ; # Fossil repo schema
22
23
package provide vc::fossil::db 1.0
24
25
# # ## ### ##### ######## ############# #####################
26
##
27
28
29
30
namespace eval ::vc::fossil {
31
32
snit::type db {
33
typevariable schemadir [file join [file dirname [info script]] schema]
34
typevariable dbcmd [namespace current]::sqldb
35
36
typemethod create_repository {filename} {
37
if {[file exists $filename]} {
38
ui panic "file already exists: $filename"
39
}
40
db init_database $filename [schema repo1] [schema repo2]
41
}
42
43
typemethod init_database {filename schema args} {
44
sqlite3 $dbcmd $filename
45
$dbcmd transaction {
46
$dbcmd eval $schema
47
foreach schema $args {
48
$dbcmd eval $schema
49
}
50
}
51
$dbcmd close
52
}
53
}
54
}

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button