Fossil

Check-in [8c4b5300]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:tclfossil: added schema command
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | tclfossil-1
Files: files | file ages | folders
SHA1:8c4b53008470dd64ab949ed219afd2c53fd023bc
User & Date: mjanssen 2008-02-19 21:58:14
References
2008-10-26
04:44 New ticket [d0a7fc67] fossil crashes with assert() if non-existant sha identifier picked for checkout. artifact: 3023be13 user: anonymous
Context
2008-02-19
21:58
tclfossil: added schema command Closed-Leaf check-in: 8c4b5300 user: mjanssen tags: tclfossil-1
18:05
tclfossil: initial directory structure and package split up check-in: 2b9c6df4 user: mjanssen tags: tclfossil-1
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added tools/tclfossil/lib/vc/fossil/cmd/new-1.0.tm.

























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## -*- 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
# # ## ### ##### ######## ############# #####################


# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.5                             ; # Required runtime.
package require snit                                ; # OO system.
package require vc::fossil::cmd 1.0                 ; # Subcommand management
package require vc::fossil::db 1.0
                
package provide vc::fossil::cmd::new 1.0
vc::fossil::cmd add new

# # ## ### ##### ######## ############# #####################
## Imports



# # ## ### ##### ######## ############# #####################
##


namespace eval ::vc::fossil::cmd {
    proc new {args} {
	if {[ui argc] != 3} {
	    ui usage "REPOSITORY-NAME"
	}
	
	set filename [file normalize [lindex [ui argv] 2]]
	db create_repository $filename
		       
    }
}

Changes to tools/tclfossil/lib/vc/fossil/db-1.0.tm.


















1
2
3

4









5

6
7
8
9
10
11
12



13

14
15
16






17
18
19






















package require Tcl 8.5
package require sqlite3
package require snit











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}



    }

}

vc::fossil::db create fossildb







fossildb open_repository
puts [fossildb revlist]





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
>
|
>
>
>
>
>
>
>
>
>
|
>
|
<
<
<
|
<
<
>
>
>
|
>
|
|
<
>
>
>
>
>
>
|
<
<
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34



35


36
37
38
39
40
41
42

43
44
45
46
47
48
49


50
51
52
53
54
## -*- 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 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]
	}


	typemethod init_database {filename schema args} {
	    sqlite3 $dbcmd $filename
	    $dbcmd transaction {
		$dbcmd eval $schema
		foreach schema $args {
		    $dbcmd eval $schema
		}


	    }
	    $dbcmd close
	}
    }
}

Added tools/tclfossil/lib/vc/fossil/schema-1.0.tm.































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
## -*- 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
# # ## ### ##### ######## ############# #####################

## Repository schema's

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.5                             ; # Required runtime.
package require snit                                ; # OO system.

package provide vc::fossil::schema 1.0

# # ## ### ##### ######## ############# #####################
##



namespace eval ::vc::fossil {

    snit::type schema {
        typemethod repo1 {} {
	    return {
		-- The BLOB and DELTA tables contain all records held in the repository.
		--
		-- The BLOB.CONTENT column is always compressed using libz.  This
		-- column might hold the full text of the record or it might hold
		-- a delta that is able to reconstruct the record from some other
		-- record.  If BLOB.CONTENT holds a delta, then a DELTA table entry
		-- will exist for the record and that entry will point to another
		-- entry that holds the source of the delta.  Deltas can be chained.
		--
		CREATE TABLE blob(
				  rid INTEGER PRIMARY KEY,        -- Record ID
				  rcvid INTEGER,                  -- Origin of this record
				  size INTEGER,                   -- Size of content. -1 for a phantom.
				  uuid TEXT UNIQUE,               -- SHA1 hash of the content
				  content BLOB                    -- Compressed content of this record
				  );
		CREATE TABLE delta(
				   rid INTEGER PRIMARY KEY,                 -- Record ID
				   srcid INTEGER NOT NULL REFERENCES blob   -- Record holding source document
				   );
		CREATE INDEX delta_i1 ON delta(srcid);

		-- Whenever new blobs are received into the repository, an entry
		-- in this table records the source of the blob.
		--
		CREATE TABLE rcvfrom(
				     rcvid INTEGER PRIMARY KEY,      -- Received-From ID
				     uid INTEGER REFERENCES user,    -- User login
				     mtime DATETIME,                 -- Time or receipt
				     nonce TEXT UNIQUE,              -- Nonce used for login
				     ipaddr TEXT                     -- Remote IP address.  NULL for direct.
				     );

		-- Information about users
		--
		CREATE TABLE user(
				  uid INTEGER PRIMARY KEY,        -- User ID
				  login TEXT,                     -- login name of the user
				  pw TEXT,                        -- password
				  cap TEXT,                       -- Capabilities of this user
				  cookie TEXT,                    -- WWW login cookie
				  ipaddr TEXT,                    -- IP address for which cookie is valid
				  cexpire DATETIME,               -- Time when cookie expires
				  info TEXT,                      -- contact information
				  photo BLOB                      -- JPEG image of this user
				  );

		-- The VAR table holds miscellanous information about the repository.
		-- in the form of name-value pairs.
		--
		CREATE TABLE config(
				    name TEXT PRIMARY KEY NOT NULL,  -- Primary name of the entry
				    value CLOB,                      -- Content of the named parameter
				    CHECK( typeof(name)='text' AND length(name)>=1 )
				    );

		-- Artifacts that should not be processed are identified in the
		-- "shun" table.  Artifacts that are control-file forgeries or
		-- spam can be shunned in order to prevent them from contaminating
		-- the repository.
		--
		CREATE TABLE shun(uuid UNIQUE);

		-- An entry in this table describes a database query that generates a
		-- table of tickets.
		--
		CREATE TABLE reportfmt(
				       rn integer primary key,  -- Report number
				       owner text,              -- Owner of this report format (not used)
				       title text,              -- Title of this report
				       cols text,               -- A color-key specification
				       sqlcode text             -- An SQL SELECT statement for this report
				       );
	    }
	}
	typemethod repo2 {} {
	    return {
		-- Filenames
		--
		CREATE TABLE filename(
				      fnid INTEGER PRIMARY KEY,    -- Filename ID
				      name TEXT UNIQUE             -- Name of file page
				      );

		-- Linkages between manifests, files created by that manifest, and
		-- the names of those files.
		--
		-- pid==0 if the file is added by check-in mid.
		-- fid==0 if the file is removed by check-in mid.
		--
		CREATE TABLE mlink(
				   mid INTEGER REFERENCES blob,        -- Manifest ID where change occurs
				   pid INTEGER REFERENCES blob,        -- File ID in parent manifest
				   fid INTEGER REFERENCES blob,        -- Changed file ID in this manifest
				   fnid INTEGER REFERENCES filename    -- Name of the file
				   );
		CREATE INDEX mlink_i1 ON mlink(mid);
		CREATE INDEX mlink_i2 ON mlink(fnid);
		CREATE INDEX mlink_i3 ON mlink(fid);
		CREATE INDEX mlink_i4 ON mlink(pid);

		-- Parent/child linkages
		--
		CREATE TABLE plink(
				   pid INTEGER REFERENCES blob,    -- Parent manifest
				   cid INTEGER REFERENCES blob,    -- Child manifest
				   isprim BOOLEAN,                 -- pid is the primary parent of cid
				   mtime DATETIME,                 -- the date/time stamp on cid
				   UNIQUE(pid, cid)
				   );
		CREATE INDEX plink_i2 ON plink(cid);

		-- Events used to generate a timeline
		--
		CREATE TABLE event(
				   type TEXT,                      -- Type of event
				   mtime DATETIME,                 -- Date and time when the event occurs
				   objid INTEGER PRIMARY KEY,      -- Associated record ID
				   uid INTEGER REFERENCES user,    -- User who caused the event
				   bgcolor TEXT,                   -- Color set by 'bgcolor' property
				   brbgcolor TEXT,                 -- Color set by 'br-bgcolor' property
				   euser TEXT,                     -- User set by 'user' property
				   user TEXT,                      -- Name of the user
				   ecomment TEXT,                  -- Comment set by 'comment' property
				   comment TEXT                    -- Comment describing the event
				   );
		CREATE INDEX event_i1 ON event(mtime);

		-- A record of phantoms.  A phantom is a record for which we know the
		-- UUID but we do not (yet) know the file content.
		--
		CREATE TABLE phantom(
				     rid INTEGER PRIMARY KEY         -- Record ID of the phantom
				     );

		-- Unclustered records.  An unclustered record is a record (including
									    -- a cluster records themselves) that is not mentioned by some other
		-- cluster.
		--
		-- Phantoms are usually included in the unclustered table.  A new cluster
		-- will never be created that contains a phantom.  But another repository
		-- might send us a cluster that contains entries that are phantoms to
		-- us.
		--
		CREATE TABLE unclustered(
					 rid INTEGER PRIMARY KEY         -- Record ID of the unclustered file
					 );

		-- Records which have never been pushed to another server.  This is
		-- used to reduce push operations to a single HTTP request in the
		-- common case when one repository only talks to a single server.
		--
		CREATE TABLE unsent(
				    rid INTEGER PRIMARY KEY         -- Record ID of the phantom
				    );

		-- Each baseline or manifest can have one or more tags.  A tag
		-- is defined by a row in the next table.
		-- 
		-- Wiki pages are tagged with "wiki-NAME" where NAME is the name of
		-- the wiki page.  Tickets changes are tagged with "ticket-UUID" where 
		-- UUID is the indentifier of the ticket.
		--
		CREATE TABLE tag(
				 tagid INTEGER PRIMARY KEY,       -- Numeric tag ID
				 tagname TEXT UNIQUE              -- Tag name.
				 );
		INSERT INTO tag VALUES(1, 'bgcolor');         -- TAG_BGCOLOR
		INSERT INTO tag VALUES(2, 'comment');         -- TAG_COMMENT
		INSERT INTO tag VALUES(3, 'user');            -- TAG_USER
		INSERT INTO tag VALUES(4, 'hidden');          -- TAG_HIDDEN

		-- Assignments of tags to baselines.  Note that we allow tags to
		-- have values assigned to them.  So we are not really dealing with
		-- tags here.  These are really properties.  But we are going to
		-- keep calling them tags because in many cases the value is ignored.
		--
		CREATE TABLE tagxref(
				     tagid INTEGER REFERENCES tag,   -- The tag that added or removed
				     tagtype INTEGER,                -- 0:cancel  1:single  2:branch
				     srcid INTEGER REFERENCES blob,  -- Origin of the tag. 0 for propagated tags
				     value TEXT,                     -- Value of the tag.  Might be NULL.
				     mtime TIMESTAMP,                -- Time of addition or removal
				     rid INTEGER REFERENCE blob,     -- Baseline that tag added/removed from
				     UNIQUE(rid, tagid)
				     );
		CREATE INDEX tagxref_i1 ON tagxref(tagid, mtime);
	    }
	}  
    }
}

Changes to tools/tclfossil/lib/vc/fossil/ui-1.0.tm.

14
15
16
17
18
19
20

21
22
23
24
25
26
27

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.5                             ; # Required runtime.
package require snit                                ; # OO system.
package require vc::fossil::cmd::clone 1.0          ; # Clone command


package provide vc::fossil::ui 1.0

# # ## ### ##### ######## ############# #####################
##

namespace eval ::vc::fossil {







>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.5                             ; # Required runtime.
package require snit                                ; # OO system.
package require vc::fossil::cmd::clone 1.0          ; # Clone command
package require vc::fossil::cmd::new   1.0          ; # New command

package provide vc::fossil::ui 1.0

# # ## ### ##### ######## ############# #####################
##

namespace eval ::vc::fossil {