Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tclfossil-1 Excluding Merge-Ins
This is equivalent to a diff from 348e45b0d6 to 8c4b530084
2008-02-19
| ||
21:58 | tclfossil: added schema command Closed-Leaf check-in: 8c4b530084 user: mjanssen tags: tclfossil-1 | |
18:05 | tclfossil: initial directory structure and package split up check-in: 2b9c6df430 user: mjanssen tags: tclfossil-1 | |
2008-01-31
| ||
05:39 | Moved the most complex parts of pushto into their own commands. check-in: 3cd599cacd user: aku tags: trunk | |
2008-01-30
| ||
21:53 | Branch created tclfossil check-in: abbdb0e8c9 user: mjanssen tags: tclfossil-1 | |
08:28 | Added basic import of changesets. Note that this code is incomplete with regard to handling the various possible interactions between a vendor-branh and trunk. check-in: 348e45b0d6 user: aku tags: trunk | |
08:25 | Added placeholder code to the fossil accessor class for the import of a revision. currently only logging the call. check-in: f9e0d23d97 user: aku tags: trunk | |
Added tools/tclfossil/dependencies.txt.
1 +zlib: http://pascal.scheffers.net/software/zlib-1.1.1.tar.bz2
Added tools/tclfossil/goals.txt.
1 +* use Tcl and the sqlite3 extensions to provide a CLI to fossil 2 +* use Tcl sockets and events to prevent having to use non-portable things like fork 3 +* get fossil on all platforms that support Tcl and SQlite 4 +* allow easy extensibility using Tcl 5 +* provide performance critical parts as TEA extensions 6 +* allow apps to use DVCS by package require fossil
Added tools/tclfossil/lib/vc/fossil/blob-1.0.tm.
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 +## Commands for creating and managing fossil blobs. 14 + 15 +# # ## ### ##### ######## ############# ##################### 16 +## Requirements 17 + 18 +package require Tcl 8.5 ; # Required runtime. 19 +package require sqlite3 ; # Fossil database access 20 +package require snit ; # OO system. 21 +package require zlib 22 + 23 +package provide vc::fossil::blob 1.0 24 + 25 +# # ## ### ##### ######## ############# ##################### 26 +## 27 + 28 +namespace eval ::vc::fossil { 29 + namespace export blob 30 + snit::type blob { 31 + option -data "" 32 + 33 + constructor {args} { 34 + $self configurelist $args 35 + } 36 + 37 + method compress {} { 38 + set data [$self cget -data] 39 + set n [string length $data] 40 + set data [zlib compress $data 9] 41 + set header [binary format I $n] 42 + return $header$data 43 + } 44 + 45 + method decompress {} { 46 + set data [$self cget -data] 47 + binary scan $data I length 48 + return [zlib decompress [string range $data 4 end] $length ] 49 + } 50 + } 51 +} 52 +
Added tools/tclfossil/lib/vc/fossil/cmd-1.0.tm.
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 +## Fossil subcommand managment. 14 + 15 +# # ## ### ##### ######## ############# ##################### 16 +## Requirements 17 + 18 +package require Tcl 8.5 ; # Required runtime. 19 +package require sqlite3 ; # Fossil database access 20 +package require snit ; # OO system. 21 + 22 + 23 +package provide vc::fossil::cmd 1.0 24 + 25 +# # ## ### ##### ######## ############# ##################### 26 +## 27 + 28 +namespace eval ::vc::fossil { 29 + namespace export cmd 30 + snit::type cmd { 31 + typevariable commands "" 32 + 33 + typemethod add {command} { 34 + lappend commands $command 35 + 36 + } 37 + 38 + typemethod list {} { 39 + return $commands 40 + } 41 + } 42 +} 43 +
Added tools/tclfossil/lib/vc/fossil/cmd/clone-1.0.tm.
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 + 14 +# # ## ### ##### ######## ############# ##################### 15 +## Requirements 16 + 17 +package require Tcl 8.5 ; # Required runtime. 18 +package require snit ; # OO system. 19 +package require vc::fossil::cmd 1.0 ; # Subcommand management 20 +package require vc::fossil::blob 1.0 21 + 22 +package provide vc::fossil::cmd::clone 1.0 23 + 24 +# # ## ### ##### ######## ############# ##################### 25 +## Imports 26 + 27 +namespace import ::vc::fossil::blob 28 + 29 + 30 +# # ## ### ##### ######## ############# ##################### 31 +## 32 + 33 +vc::fossil::cmd add clone 34 + 35 +namespace eval ::vc::fossil::cmd { 36 + proc clone {args} { 37 + if {[ui argc] != 4} { 38 + ui usage "FILE-OR-URL NEW-REPOSITORY" 39 + } 40 + 41 + set local_file [lindex [ui argv] 3] 42 + if {[file exists $local_file]} { 43 + ui panic "file already exists: $local_file" 44 + } 45 + puts "cloning: $args" 46 + package require http 47 + package require sha1 48 + package require autoproxy 49 + 50 + autoproxy::init 51 + puts [autoproxy::configure] 52 + 53 + proc login_card {userid password message} { 54 + # calculates the login card for the specific user for this msg 55 + 56 + set nonce [sha1::sha1 -hex $message] 57 + set signature [sha1::sha1 -hex $nonce$password] 58 + return "login $userid $nonce $signature\n" 59 + } 60 + 61 + proc http_req {url user password message} { 62 + set login_card [login_card $user $password $message] 63 + blob blob_a -data $login_card$message 64 + set message [blob_a compress] 65 + blob_a destroy 66 + return [http::geturl $url/xfer -binary 1 -query $message -type application/x-fossil] 67 + } 68 + 69 + 70 + set tok [http_req http://www.fossil-scm.org/fossil MJanssen {} clone\n] 71 + http::wait $tok 72 + set zip_body [http::data $tok] 73 + blob blob_a -data $zip_body 74 + set body [blob_a decompress] 75 + blob_a destroy 76 + set lines [split $body \n] 77 + puts $body 78 + puts "Received:\t[string length $body] ([string length $zip_body]) bytes,\t[llength $lines] messages" 79 + 80 + 81 + } 82 +}
Added tools/tclfossil/lib/vc/fossil/cmd/new-1.0.tm.
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 + 14 +# # ## ### ##### ######## ############# ##################### 15 +## Requirements 16 + 17 +package require Tcl 8.5 ; # Required runtime. 18 +package require snit ; # OO system. 19 +package require vc::fossil::cmd 1.0 ; # Subcommand management 20 +package require vc::fossil::db 1.0 21 + 22 +package provide vc::fossil::cmd::new 1.0 23 +vc::fossil::cmd add new 24 + 25 +# # ## ### ##### ######## ############# ##################### 26 +## Imports 27 + 28 + 29 + 30 +# # ## ### ##### ######## ############# ##################### 31 +## 32 + 33 + 34 +namespace eval ::vc::fossil::cmd { 35 + proc new {args} { 36 + if {[ui argc] != 3} { 37 + ui usage "REPOSITORY-NAME" 38 + } 39 + 40 + set filename [file normalize [lindex [ui argv] 2]] 41 + db create_repository $filename 42 + 43 + } 44 +}
Added tools/tclfossil/lib/vc/fossil/db-1.0.tm.
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 +}
Added tools/tclfossil/lib/vc/fossil/schema-1.0.tm.
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 +## Repository schema's 14 + 15 +# # ## ### ##### ######## ############# ##################### 16 +## Requirements 17 + 18 +package require Tcl 8.5 ; # Required runtime. 19 +package require snit ; # OO system. 20 + 21 +package provide vc::fossil::schema 1.0 22 + 23 +# # ## ### ##### ######## ############# ##################### 24 +## 25 + 26 + 27 + 28 +namespace eval ::vc::fossil { 29 + 30 + snit::type schema { 31 + typemethod repo1 {} { 32 + return { 33 + -- The BLOB and DELTA tables contain all records held in the repository. 34 + -- 35 + -- The BLOB.CONTENT column is always compressed using libz. This 36 + -- column might hold the full text of the record or it might hold 37 + -- a delta that is able to reconstruct the record from some other 38 + -- record. If BLOB.CONTENT holds a delta, then a DELTA table entry 39 + -- will exist for the record and that entry will point to another 40 + -- entry that holds the source of the delta. Deltas can be chained. 41 + -- 42 + CREATE TABLE blob( 43 + rid INTEGER PRIMARY KEY, -- Record ID 44 + rcvid INTEGER, -- Origin of this record 45 + size INTEGER, -- Size of content. -1 for a phantom. 46 + uuid TEXT UNIQUE, -- SHA1 hash of the content 47 + content BLOB -- Compressed content of this record 48 + ); 49 + CREATE TABLE delta( 50 + rid INTEGER PRIMARY KEY, -- Record ID 51 + srcid INTEGER NOT NULL REFERENCES blob -- Record holding source document 52 + ); 53 + CREATE INDEX delta_i1 ON delta(srcid); 54 + 55 + -- Whenever new blobs are received into the repository, an entry 56 + -- in this table records the source of the blob. 57 + -- 58 + CREATE TABLE rcvfrom( 59 + rcvid INTEGER PRIMARY KEY, -- Received-From ID 60 + uid INTEGER REFERENCES user, -- User login 61 + mtime DATETIME, -- Time or receipt 62 + nonce TEXT UNIQUE, -- Nonce used for login 63 + ipaddr TEXT -- Remote IP address. NULL for direct. 64 + ); 65 + 66 + -- Information about users 67 + -- 68 + CREATE TABLE user( 69 + uid INTEGER PRIMARY KEY, -- User ID 70 + login TEXT, -- login name of the user 71 + pw TEXT, -- password 72 + cap TEXT, -- Capabilities of this user 73 + cookie TEXT, -- WWW login cookie 74 + ipaddr TEXT, -- IP address for which cookie is valid 75 + cexpire DATETIME, -- Time when cookie expires 76 + info TEXT, -- contact information 77 + photo BLOB -- JPEG image of this user 78 + ); 79 + 80 + -- The VAR table holds miscellanous information about the repository. 81 + -- in the form of name-value pairs. 82 + -- 83 + CREATE TABLE config( 84 + name TEXT PRIMARY KEY NOT NULL, -- Primary name of the entry 85 + value CLOB, -- Content of the named parameter 86 + CHECK( typeof(name)='text' AND length(name)>=1 ) 87 + ); 88 + 89 + -- Artifacts that should not be processed are identified in the 90 + -- "shun" table. Artifacts that are control-file forgeries or 91 + -- spam can be shunned in order to prevent them from contaminating 92 + -- the repository. 93 + -- 94 + CREATE TABLE shun(uuid UNIQUE); 95 + 96 + -- An entry in this table describes a database query that generates a 97 + -- table of tickets. 98 + -- 99 + CREATE TABLE reportfmt( 100 + rn integer primary key, -- Report number 101 + owner text, -- Owner of this report format (not used) 102 + title text, -- Title of this report 103 + cols text, -- A color-key specification 104 + sqlcode text -- An SQL SELECT statement for this report 105 + ); 106 + } 107 + } 108 + typemethod repo2 {} { 109 + return { 110 + -- Filenames 111 + -- 112 + CREATE TABLE filename( 113 + fnid INTEGER PRIMARY KEY, -- Filename ID 114 + name TEXT UNIQUE -- Name of file page 115 + ); 116 + 117 + -- Linkages between manifests, files created by that manifest, and 118 + -- the names of those files. 119 + -- 120 + -- pid==0 if the file is added by check-in mid. 121 + -- fid==0 if the file is removed by check-in mid. 122 + -- 123 + CREATE TABLE mlink( 124 + mid INTEGER REFERENCES blob, -- Manifest ID where change occurs 125 + pid INTEGER REFERENCES blob, -- File ID in parent manifest 126 + fid INTEGER REFERENCES blob, -- Changed file ID in this manifest 127 + fnid INTEGER REFERENCES filename -- Name of the file 128 + ); 129 + CREATE INDEX mlink_i1 ON mlink(mid); 130 + CREATE INDEX mlink_i2 ON mlink(fnid); 131 + CREATE INDEX mlink_i3 ON mlink(fid); 132 + CREATE INDEX mlink_i4 ON mlink(pid); 133 + 134 + -- Parent/child linkages 135 + -- 136 + CREATE TABLE plink( 137 + pid INTEGER REFERENCES blob, -- Parent manifest 138 + cid INTEGER REFERENCES blob, -- Child manifest 139 + isprim BOOLEAN, -- pid is the primary parent of cid 140 + mtime DATETIME, -- the date/time stamp on cid 141 + UNIQUE(pid, cid) 142 + ); 143 + CREATE INDEX plink_i2 ON plink(cid); 144 + 145 + -- Events used to generate a timeline 146 + -- 147 + CREATE TABLE event( 148 + type TEXT, -- Type of event 149 + mtime DATETIME, -- Date and time when the event occurs 150 + objid INTEGER PRIMARY KEY, -- Associated record ID 151 + uid INTEGER REFERENCES user, -- User who caused the event 152 + bgcolor TEXT, -- Color set by 'bgcolor' property 153 + brbgcolor TEXT, -- Color set by 'br-bgcolor' property 154 + euser TEXT, -- User set by 'user' property 155 + user TEXT, -- Name of the user 156 + ecomment TEXT, -- Comment set by 'comment' property 157 + comment TEXT -- Comment describing the event 158 + ); 159 + CREATE INDEX event_i1 ON event(mtime); 160 + 161 + -- A record of phantoms. A phantom is a record for which we know the 162 + -- UUID but we do not (yet) know the file content. 163 + -- 164 + CREATE TABLE phantom( 165 + rid INTEGER PRIMARY KEY -- Record ID of the phantom 166 + ); 167 + 168 + -- Unclustered records. An unclustered record is a record (including 169 + -- a cluster records themselves) that is not mentioned by some other 170 + -- cluster. 171 + -- 172 + -- Phantoms are usually included in the unclustered table. A new cluster 173 + -- will never be created that contains a phantom. But another repository 174 + -- might send us a cluster that contains entries that are phantoms to 175 + -- us. 176 + -- 177 + CREATE TABLE unclustered( 178 + rid INTEGER PRIMARY KEY -- Record ID of the unclustered file 179 + ); 180 + 181 + -- Records which have never been pushed to another server. This is 182 + -- used to reduce push operations to a single HTTP request in the 183 + -- common case when one repository only talks to a single server. 184 + -- 185 + CREATE TABLE unsent( 186 + rid INTEGER PRIMARY KEY -- Record ID of the phantom 187 + ); 188 + 189 + -- Each baseline or manifest can have one or more tags. A tag 190 + -- is defined by a row in the next table. 191 + -- 192 + -- Wiki pages are tagged with "wiki-NAME" where NAME is the name of 193 + -- the wiki page. Tickets changes are tagged with "ticket-UUID" where 194 + -- UUID is the indentifier of the ticket. 195 + -- 196 + CREATE TABLE tag( 197 + tagid INTEGER PRIMARY KEY, -- Numeric tag ID 198 + tagname TEXT UNIQUE -- Tag name. 199 + ); 200 + INSERT INTO tag VALUES(1, 'bgcolor'); -- TAG_BGCOLOR 201 + INSERT INTO tag VALUES(2, 'comment'); -- TAG_COMMENT 202 + INSERT INTO tag VALUES(3, 'user'); -- TAG_USER 203 + INSERT INTO tag VALUES(4, 'hidden'); -- TAG_HIDDEN 204 + 205 + -- Assignments of tags to baselines. Note that we allow tags to 206 + -- have values assigned to them. So we are not really dealing with 207 + -- tags here. These are really properties. But we are going to 208 + -- keep calling them tags because in many cases the value is ignored. 209 + -- 210 + CREATE TABLE tagxref( 211 + tagid INTEGER REFERENCES tag, -- The tag that added or removed 212 + tagtype INTEGER, -- 0:cancel 1:single 2:branch 213 + srcid INTEGER REFERENCES blob, -- Origin of the tag. 0 for propagated tags 214 + value TEXT, -- Value of the tag. Might be NULL. 215 + mtime TIMESTAMP, -- Time of addition or removal 216 + rid INTEGER REFERENCE blob, -- Baseline that tag added/removed from 217 + UNIQUE(rid, tagid) 218 + ); 219 + CREATE INDEX tagxref_i1 ON tagxref(tagid, mtime); 220 + } 221 + } 222 + } 223 +}
Added tools/tclfossil/lib/vc/fossil/ui-1.0.tm.
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 +## Command line user interface for tclfossil. 14 + 15 +# # ## ### ##### ######## ############# ##################### 16 +## Requirements 17 + 18 +package require Tcl 8.5 ; # Required runtime. 19 +package require snit ; # OO system. 20 +package require vc::fossil::cmd::clone 1.0 ; # Clone command 21 +package require vc::fossil::cmd::new 1.0 ; # New command 22 + 23 +package provide vc::fossil::ui 1.0 24 + 25 +# # ## ### ##### ######## ############# ##################### 26 +## 27 + 28 +namespace eval ::vc::fossil { 29 + snit::type ui { 30 + typevariable argv 31 + typevariable argc 32 + typevariable command 33 + typevariable fSqlTrace 34 + typevariable fUser 35 + 36 + typemethod run {args} { 37 + 38 + # TODO parse options 39 + set argv $args 40 + set argc [llength $args] 41 + 42 + if {$argc < 2} { 43 + ui usage "COMMAND ..." 44 + } 45 + 46 + # TODO better command searching so prefixes work 47 + set command [lindex $argv 1] 48 + set commands [vc::fossil::cmd list] 49 + 50 + if {[lsearch $commands $command] < 0} { 51 + puts "unknown command: $command" 52 + puts {use "help" for more information} 53 + exit 1 54 + } 55 + vc::fossil::cmd::$command {*}[lrange $argv 1 end] 56 + return 57 + } 58 + 59 + typemethod usage {str} { 60 + puts stderr "Usage: [lrange $argv 0 1] $str" 61 + exit 1 62 + } 63 + 64 + typemethod panic {str} { 65 + puts stderr "[lindex $argv 0]: $str" 66 + exit 1 67 + } 68 + 69 + 70 + typemethod argc {} { 71 + return $argc 72 + } 73 + 74 + typemethod argv {} { 75 + return $argv 76 + } 77 + } 78 +}
Added tools/tclfossil/tf.
1 +#!/bin/sh 2 +## -*- tcl -*- \ 3 +exec tclsh "$0" ${1+"$@"} 4 + 5 +# # ## ### ##### ######## ############# ##################### 6 +## Copyright (c) 2008 Mark Janssen. 7 +# 8 +# This software is licensed as described in the file LICENSE, which 9 +# you should have received as part of this distribution. 10 +# 11 +# This software consists of voluntary contributions made by many 12 +# individuals. For exact contribution history, see the revision 13 +# history and logs, available at http://fossil-scm.hwaci.com/fossil 14 +# # ## ### ##### ######## ############# ##################### 15 + 16 +## Command line application wrapped around the import packages. 17 + 18 +# # ## ### ##### ######## ############# ##################### 19 +## Requirements, extended package management for local packages. 20 + 21 +::tcl::tm::path add [file normalize [file join [file dirname [info script]] lib]] 22 + 23 +package require Tcl 8.5 ; # Required runtime. 24 +package require vc::fossil::ui ; # Main functionality. 25 + 26 +# # ## ### ##### ######## ############# ##################### 27 +## Execution 28 + 29 +vc::fossil::ui run $::argv0 {*}$argv 30 +exit 0 31 + 32 +# # ## ### ##### ######## ############# #####################