52f2254007 2007-10-04 aku: ## -*- tcl -*- 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# ##################### 52f2254007 2007-10-04 aku: ## Copyright (c) 2007 Andreas Kupries. 52f2254007 2007-10-04 aku: # 52f2254007 2007-10-04 aku: # This software is licensed as described in the file LICENSE, which 52f2254007 2007-10-04 aku: # you should have received as part of this distribution. 52f2254007 2007-10-04 aku: # 52f2254007 2007-10-04 aku: # This software consists of voluntary contributions made by many 52f2254007 2007-10-04 aku: # individuals. For exact contribution history, see the revision 52f2254007 2007-10-04 aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# ##################### 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: ## Project, part of a CVS repository. Multiple instances are possible. 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# ##################### 52f2254007 2007-10-04 aku: ## Requirements 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: package require Tcl 8.4 ; # Required runtime. 52f2254007 2007-10-04 aku: package require snit ; # OO system. 8a93ffa9c1 2007-10-06 aku: package require vc::fossil::import::cvs::file ; # CVS archive file. 042d54bae5 2007-10-05 aku: package require vc::fossil::import::cvs::state ; # State storage 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# ##################### 52f2254007 2007-10-04 aku: ## 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: snit::type ::vc::fossil::import::cvs::project { 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# 52f2254007 2007-10-04 aku: ## Public API 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: constructor {path} { 52f2254007 2007-10-04 aku: set mybase $path 52f2254007 2007-10-04 aku: return 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: method base {} { return $mybase } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: method printbase {} { 52f2254007 2007-10-04 aku: if {$mybase eq ""} {return <Repository>} 52f2254007 2007-10-04 aku: return $mybase 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: method add {rcs usr} { 52f2254007 2007-10-04 aku: set myfiles($rcs) $usr 52f2254007 2007-10-04 aku: return 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 8a93ffa9c1 2007-10-06 aku: method filenames {} { ec053168a8 2007-10-06 aku: return [lsort -dict [array names myfiles]] 8a93ffa9c1 2007-10-06 aku: } 8a93ffa9c1 2007-10-06 aku: 8a93ffa9c1 2007-10-06 aku: method files {} { 8a93ffa9c1 2007-10-06 aku: # TODO: Loading from state 8a93ffa9c1 2007-10-06 aku: set res {} ec053168a8 2007-10-06 aku: foreach f [lsort -dict [array names myfiles]] { 8a93ffa9c1 2007-10-06 aku: lappend res [file %AUTO% $f $self] 8a93ffa9c1 2007-10-06 aku: } 8a93ffa9c1 2007-10-06 aku: return $res 042d54bae5 2007-10-05 aku: } 042d54bae5 2007-10-05 aku: 042d54bae5 2007-10-05 aku: method persist {} { 042d54bae5 2007-10-05 aku: state transaction { 042d54bae5 2007-10-05 aku: # Project data first. Required so that we have its id 042d54bae5 2007-10-05 aku: # ready for the files. 042d54bae5 2007-10-05 aku: 042d54bae5 2007-10-05 aku: state run { 042d54bae5 2007-10-05 aku: INSERT INTO project (pid, name) 042d54bae5 2007-10-05 aku: VALUES (NULL, $mybase); 042d54bae5 2007-10-05 aku: } 042d54bae5 2007-10-05 aku: set pid [state id] 042d54bae5 2007-10-05 aku: 042d54bae5 2007-10-05 aku: # Then all files, with proper backreference to their 042d54bae5 2007-10-05 aku: # project. 042d54bae5 2007-10-05 aku: 042d54bae5 2007-10-05 aku: foreach {rcs usr} [array get myfiles] { 042d54bae5 2007-10-05 aku: state run { 042d54bae5 2007-10-05 aku: INSERT INTO file (fid, pid, name, visible) 042d54bae5 2007-10-05 aku: VALUES (NULL, $pid, $rcs, $usr); 042d54bae5 2007-10-05 aku: } 042d54bae5 2007-10-05 aku: } 042d54bae5 2007-10-05 aku: } 042d54bae5 2007-10-05 aku: return 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# 52f2254007 2007-10-04 aku: ## State 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: variable mybase {} ; # Project directory 8a93ffa9c1 2007-10-06 aku: variable myfiles -array {} ; # Maps rcs archive to their user files. 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# 52f2254007 2007-10-04 aku: ## Internal methods 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: pragma -hastypeinfo no ; # no type introspection 52f2254007 2007-10-04 aku: pragma -hasinfo no ; # no object introspection 52f2254007 2007-10-04 aku: pragma -hastypemethods no ; # type is not relevant. 52f2254007 2007-10-04 aku: pragma -simpledispatch yes ; # simple fast dispatch 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: namespace eval ::vc::fossil::import::cvs { 52f2254007 2007-10-04 aku: namespace export project 042d54bae5 2007-10-05 aku: namespace eval project { 8a93ffa9c1 2007-10-06 aku: namespace import ::vc::fossil::import::cvs::file 042d54bae5 2007-10-05 aku: namespace import ::vc::fossil::import::cvs::state 042d54bae5 2007-10-05 aku: } 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# ##################### 52f2254007 2007-10-04 aku: ## Ready 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: package provide vc::fossil::import::cvs::project 1.0 52f2254007 2007-10-04 aku: return