47740cc1f6 2007-10-03 aku: ## -*- tcl -*- 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# ##################### 47740cc1f6 2007-10-03 aku: ## Copyright (c) 2007 Andreas Kupries. 47740cc1f6 2007-10-03 aku: # 47740cc1f6 2007-10-03 aku: # This software is licensed as described in the file LICENSE, which 47740cc1f6 2007-10-03 aku: # you should have received as part of this distribution. 47740cc1f6 2007-10-03 aku: # 47740cc1f6 2007-10-03 aku: # This software consists of voluntary contributions made by many 47740cc1f6 2007-10-03 aku: # individuals. For exact contribution history, see the revision 47740cc1f6 2007-10-03 aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# ##################### 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: ## Repository manager. Keeps projects and their files around. 47740cc1f6 2007-10-03 aku: 3d88cfd05d 2007-10-06 aku: package provide vc::fossil::import::cvs::repository 1.0 3d88cfd05d 2007-10-06 aku: 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# ##################### 47740cc1f6 2007-10-03 aku: ## Requirements 47740cc1f6 2007-10-03 aku: 52f2254007 2007-10-04 aku: package require Tcl 8.4 ; # Required runtime. 52f2254007 2007-10-04 aku: package require snit ; # OO system. 52f2254007 2007-10-04 aku: package require vc::tools::trouble ; # Error reporting. 52f2254007 2007-10-04 aku: package require vc::tools::log ; # User feedback. 8487172254 2007-10-06 aku: package require vc::tools::misc ; # Text formatting. 99e165d5c4 2007-10-21 aku: package require vc::tools::id ; # Indexing and id generation. 8487172254 2007-10-06 aku: package require vc::fossil::import::cvs::project ; # CVS projects. 8487172254 2007-10-06 aku: package require vc::fossil::import::cvs::state ; # State storage. 52f2254007 2007-10-04 aku: package require struct::list ; # List operations. eb656de7d9 2007-10-05 aku: package require fileutil ; # File operations. 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# ##################### 47740cc1f6 2007-10-03 aku: ## 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: snit::type ::vc::fossil::import::cvs::repository { 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# 47740cc1f6 2007-10-03 aku: ## Public API 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: typemethod base {path} { 52f2254007 2007-10-04 aku: # Could be checked, easier to defer to the overall validation. 52f2254007 2007-10-04 aku: set mybase $path 52f2254007 2007-10-04 aku: return 47740cc1f6 2007-10-03 aku: } 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: typemethod add {path} { d174affb48 2007-10-05 aku: # Most things cannot be checked immediately, as the base is d174affb48 2007-10-05 aku: # not known while projects are added. We can and do check for d174affb48 2007-10-05 aku: # uniqueness. We accept multiple occurences of a name, and d174affb48 2007-10-05 aku: # treat them as a single project. d174affb48 2007-10-05 aku: d174affb48 2007-10-05 aku: if {[lsearch -exact $myprojpaths $path] >= 0} return 52f2254007 2007-10-04 aku: lappend myprojpaths $path 52f2254007 2007-10-04 aku: return 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 3bde1a2e2f 2007-10-17 aku: typemethod trunkonly! {} { set mytrunkonly 1 ; return } 3bde1a2e2f 2007-10-17 aku: typemethod trunkonly {} { return $mytrunkonly } 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: typemethod projects {} { 52f2254007 2007-10-04 aku: return [TheProjects] 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: typemethod base? {} { return $mybase } 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: typemethod validate {} { 52f2254007 2007-10-04 aku: if {![IsRepositoryBase $mybase msg]} { 52f2254007 2007-10-04 aku: trouble fatal $msg 52f2254007 2007-10-04 aku: # Without a good base directory checking any projects is 52f2254007 2007-10-04 aku: # wasted time, so we leave now. 52f2254007 2007-10-04 aku: return 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: foreach pp $myprojpaths { 52f2254007 2007-10-04 aku: if {![IsProjectBase $mybase/$pp $mybase/CVSROOT msg]} { 52f2254007 2007-10-04 aku: trouble fatal $msg 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: return 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 99e165d5c4 2007-10-21 aku: typemethod defauthor {a} { $myauthor put $a } 99e165d5c4 2007-10-21 aku: typemethod defcmessage {cm} { $mycmsg put $cm } 99e165d5c4 2007-10-21 aku: typemethod defsymbol {pid name} { $mysymbol put [list $pid $name] } 99e165d5c4 2007-10-21 aku: typemethod defmeta {pid bid aid cid} { $mymeta put [list $pid $bid $aid $cid] } 99e165d5c4 2007-10-21 aku: 99e165d5c4 2007-10-21 aku: typemethod commitmessageof {mid} { 99e165d5c4 2007-10-21 aku: struct::list assign [$mymeta keyof $mid] pid bid aid cid 99e165d5c4 2007-10-21 aku: return [$mycmsg keyof $cid] 3d88cfd05d 2007-10-06 aku: } 3d88cfd05d 2007-10-06 aku: 6d1811d61e 2007-10-06 aku: # pass I results 52f2254007 2007-10-04 aku: typemethod printstatistics {} { 52f2254007 2007-10-04 aku: set prlist [TheProjects] 52f2254007 2007-10-04 aku: set npr [llength $prlist] 52f2254007 2007-10-04 aku: 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: Scanned [nsp $npr project]" 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: if {$npr > 1} { 52f2254007 2007-10-04 aku: set bmax [max [struct::list map $prlist [myproc .BaseLength]]] 52f2254007 2007-10-04 aku: incr bmax 2 52f2254007 2007-10-04 aku: set bfmt %-${bmax}s 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: set nmax [max [struct::list map $prlist [myproc .NFileLength]]] 52f2254007 2007-10-04 aku: set nfmt %${nmax}s 52f2254007 2007-10-04 aku: } else { 52f2254007 2007-10-04 aku: set bfmt %s 52f2254007 2007-10-04 aku: set nfmt %s 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: set keep {} 52f2254007 2007-10-04 aku: foreach p $prlist { 8a93ffa9c1 2007-10-06 aku: set nfiles [llength [$p filenames]] 96b7bfb834 2007-11-16 aku: set line "Statistics: Project [format $bfmt \"[$p printbase]\"] : [format $nfmt $nfiles] [sp $nfiles file]" 52f2254007 2007-10-04 aku: if {$nfiles < 1} { 52f2254007 2007-10-04 aku: append line ", dropped" 52f2254007 2007-10-04 aku: } else { 52f2254007 2007-10-04 aku: lappend keep $p 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: log write 2 repository $line 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: if {![llength $keep]} { 52f2254007 2007-10-04 aku: trouble warn "Dropped all projects" 52f2254007 2007-10-04 aku: } elseif {$npr == [llength $keep]} { 52f2254007 2007-10-04 aku: log write 2 repository "Keeping all projects" 52f2254007 2007-10-04 aku: } else { 52f2254007 2007-10-04 aku: log write 2 repository "Keeping [nsp [llength $keep] project]" 52f2254007 2007-10-04 aku: trouble warn "Dropped [nsp [expr {$npr - [llength $keep]}] {empty project}]" 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # Keep reduced set of projects. 52f2254007 2007-10-04 aku: set projects $keep 52f2254007 2007-10-04 aku: return 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 6d1811d61e 2007-10-06 aku: # pass I persistence 52f2254007 2007-10-04 aku: typemethod persist {} { 67600f777b 2007-11-14 aku: ::variable myprojmap 54ac684df7 2007-10-13 aku: state transaction { 67600f777b 2007-11-14 aku: foreach p [TheProjects] { 67600f777b 2007-11-14 aku: $p persist 67600f777b 2007-11-14 aku: set myprojmap([$p id]) $p 67600f777b 2007-11-14 aku: } 54ac684df7 2007-10-13 aku: } 54ac684df7 2007-10-13 aku: return 54ac684df7 2007-10-13 aku: } 54ac684df7 2007-10-13 aku: 54ac684df7 2007-10-13 aku: typemethod load {} { 6d1811d61e 2007-10-06 aku: state transaction { 54ac684df7 2007-10-13 aku: foreach {pid name} [state run { 54ac684df7 2007-10-13 aku: SELECT pid, name FROM project ; 54ac684df7 2007-10-13 aku: }] { c3d5104084 2007-11-02 aku: set project [project %AUTO% $name $type] c3d5104084 2007-11-02 aku: 54ac684df7 2007-10-13 aku: lappend myprojpaths $name c3d5104084 2007-11-02 aku: lappend myprojects $project c3d5104084 2007-11-02 aku: set myprojmap($pid) $project c3d5104084 2007-11-02 aku: $project setid $pid 54ac684df7 2007-10-13 aku: } 54ac684df7 2007-10-13 aku: foreach {fid pid name visible exec} [state run { 54ac684df7 2007-10-13 aku: SELECT fid, pid, name, visible, exec FROM file ; 54ac684df7 2007-10-13 aku: }] { c3d5104084 2007-11-02 aku: $myprojmap($pid) addfile $name $visible $exec $fid 54ac684df7 2007-10-13 aku: } 6d1811d61e 2007-10-06 aku: } 6d1811d61e 2007-10-06 aku: return 6d1811d61e 2007-10-06 aku: } 6d1811d61e 2007-10-06 aku: 6d1811d61e 2007-10-06 aku: # pass II results 6d1811d61e 2007-10-06 aku: typemethod printrevstatistics {} { 96b7bfb834 2007-11-16 aku: log write 2 repository "Revision statistics" 96b7bfb834 2007-11-16 aku: # number of revisions, symbols, repository wide, and per project ... 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: set rcount [state one { SELECT COUNT (*) FROM revision }] 96b7bfb834 2007-11-16 aku: set tcount [state one { SELECT COUNT (*) FROM tag }] 96b7bfb834 2007-11-16 aku: set bcount [state one { SELECT COUNT (*) FROM branch }] 96b7bfb834 2007-11-16 aku: set scount [state one { SELECT COUNT (*) FROM symbol }] 96b7bfb834 2007-11-16 aku: set acount [state one { SELECT COUNT (*) FROM author }] 96b7bfb834 2007-11-16 aku: set ccount [state one { SELECT COUNT (*) FROM cmessage }] 96b7bfb834 2007-11-16 aku: set fmt %[string length [max [list $rcount $tcount $bcount $scount $acount $ccount]]]s 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $rcount] [sp $rcount revision]" 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $tcount] [sp $tcount tag]" 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $bcount] [sp $bcount branch branches]" 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $scount] [sp $scount symbol]" 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $acount] [sp $acount author]" 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $ccount] [sp $ccount {log message}]" 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: set prlist [TheProjects] 96b7bfb834 2007-11-16 aku: set npr [llength $prlist] 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: if {$npr > 1} { 96b7bfb834 2007-11-16 aku: set bmax [max [struct::list map $prlist [myproc .BaseLength]]] 96b7bfb834 2007-11-16 aku: incr bmax 2 96b7bfb834 2007-11-16 aku: set bfmt %-${bmax}s 96b7bfb834 2007-11-16 aku: } else { 96b7bfb834 2007-11-16 aku: set bfmt %s 96b7bfb834 2007-11-16 aku: } 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: foreach p $prlist { 96b7bfb834 2007-11-16 aku: set pid [$p id] 2630e50610 2007-11-22 aku: set prefix "Project [format $bfmt \"[$p printbase]\"]" 96b7bfb834 2007-11-16 aku: regsub -all {[^ ]} $prefix { } blanks 96b7bfb834 2007-11-16 aku: set sep " : " 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: set rcount [state one { SELECT COUNT (*) FROM revision R, file F WHERE R.fid = F.fid AND F.pid = $pid }] 96b7bfb834 2007-11-16 aku: set tcount [state one { SELECT COUNT (*) FROM tag T, file F WHERE T.fid = F.fid AND F.pid = $pid }] 96b7bfb834 2007-11-16 aku: set bcount [state one { SELECT COUNT (*) FROM branch B, file F WHERE B.fid = F.fid AND F.pid = $pid }] 96b7bfb834 2007-11-16 aku: set scount [state one { SELECT COUNT (*) FROM symbol WHERE pid = $pid }] 96b7bfb834 2007-11-16 aku: set acount [state one { SELECT COUNT (*) FROM author WHERE aid IN (SELECT DISTINCT aid FROM meta WHERE pid = $pid) }] 96b7bfb834 2007-11-16 aku: set ccount [state one { SELECT COUNT (*) FROM cmessage WHERE cid IN (SELECT DISTINCT cid FROM meta WHERE pid = $pid) }] 96b7bfb834 2007-11-16 aku: 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $prefix$sep[format $fmt $rcount] [sp $rcount revision]" 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $tcount] [sp $tcount tag]" 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $bcount] [sp $bcount branch branches]" 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $scount] [sp $scount symbol]" 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $acount] [sp $acount author]" 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $ccount] [sp $ccount {log message}]" 96b7bfb834 2007-11-16 aku: } 6d1811d61e 2007-10-06 aku: return 6d1811d61e 2007-10-06 aku: } 6d1811d61e 2007-10-06 aku: 6d1811d61e 2007-10-06 aku: # pass II persistence 6d1811d61e 2007-10-06 aku: typemethod persistrev {} { 6d1811d61e 2007-10-06 aku: state transaction { 3d88cfd05d 2007-10-06 aku: SaveAuthors 3d88cfd05d 2007-10-06 aku: SaveCommitMessages 67c24820c7 2007-10-14 aku: # TODO: Save symbols of all projects (before the revisions 67c24820c7 2007-10-14 aku: # in the projects, as they are referenced by the meta 67c24820c7 2007-10-14 aku: # tuples) 67c24820c7 2007-10-14 aku: SaveMeta 6d1811d61e 2007-10-06 aku: foreach p [TheProjects] { $p persistrev } 6d1811d61e 2007-10-06 aku: } 6d1811d61e 2007-10-06 aku: return 6d1811d61e 2007-10-06 aku: } 6d1811d61e 2007-10-06 aku: c3d5104084 2007-11-02 aku: typemethod loadsymbols {} { 042d54bae5 2007-10-05 aku: state transaction { c3d5104084 2007-11-02 aku: # We load the symbol ids at large to have the mapping c3d5104084 2007-11-02 aku: # right from the beginning. c3d5104084 2007-11-02 aku: c3d5104084 2007-11-02 aku: foreach {sid pid name tc bc cc} [state run { c3d5104084 2007-11-02 aku: SELECT sid, pid, name, tag_count, branch_count, commit_count c3d5104084 2007-11-02 aku: FROM symbol c3d5104084 2007-11-02 aku: ; c3d5104084 2007-11-02 aku: }] { c3d5104084 2007-11-02 aku: $mysymbol map $sid [list $pid $name] c3d5104084 2007-11-02 aku: set project $myprojmap($pid) c3d5104084 2007-11-02 aku: c3d5104084 2007-11-02 aku: set force [$project hassymbol $name] c3d5104084 2007-11-02 aku: set symbol [$project getsymbol $name] c3d5104084 2007-11-02 aku: c3d5104084 2007-11-02 aku: # Forcing happens only for the trunks. c3d5104084 2007-11-02 aku: if {$force} { $symbol forceid $sid } c3d5104084 2007-11-02 aku: c3d5104084 2007-11-02 aku: # Set the loaded counts. c3d5104084 2007-11-02 aku: $symbol defcounts $tc $bc $cc c3d5104084 2007-11-02 aku: c3d5104084 2007-11-02 aku: # Note: The type is neither retrieved nor set, for c3d5104084 2007-11-02 aku: # this is used to load the pass II data, which means c3d5104084 2007-11-02 aku: # that everything is 'undefined' at this point anyway. c3d5104084 2007-11-02 aku: c3d5104084 2007-11-02 aku: # future: $symbol load (blockers, and parents) c3d5104084 2007-11-02 aku: } f888f06fe3 2007-11-02 aku: } f888f06fe3 2007-11-02 aku: return f888f06fe3 2007-11-02 aku: } f888f06fe3 2007-11-02 aku: f888f06fe3 2007-11-02 aku: typemethod determinesymboltypes {} { f888f06fe3 2007-11-02 aku: foreach project [TheProjects] { f888f06fe3 2007-11-02 aku: $project determinesymboltypes 5f7acef887 2007-11-10 aku: } 5f7acef887 2007-11-10 aku: return 5f7acef887 2007-11-10 aku: } 5f7acef887 2007-11-10 aku: 5f7acef887 2007-11-10 aku: typemethod projectof {pid} { 5f7acef887 2007-11-10 aku: return $myprojmap($pid) 96b7bfb834 2007-11-16 aku: } 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: # pass IV+ results 96b7bfb834 2007-11-16 aku: typemethod printcsetstatistics {} { 96b7bfb834 2007-11-16 aku: log write 2 repository "Changeset statistics" 96b7bfb834 2007-11-16 aku: # number of revisions, symbols, repository wide, and per project ... 96b7bfb834 2007-11-16 aku: 8e3012423b 2007-11-29 aku: set ccount [state one { SELECT COUNT (*) FROM changeset }] 96b7bfb834 2007-11-16 aku: set rcount [state one { SELECT COUNT (*) FROM changeset WHERE type = 0 }] 8e3012423b 2007-11-29 aku: set tcount [state one { SELECT COUNT (*) FROM changeset WHERE type = 1 }] 8e3012423b 2007-11-29 aku: set bcount [state one { SELECT COUNT (*) FROM changeset WHERE type = 2 }] 8e3012423b 2007-11-29 aku: set fmt %[string length [max [list $ccount $rcount $tcount $bcount]]]s 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $ccount] [sp $ccount changeset]" 96b7bfb834 2007-11-16 aku: log write 2 repository "Statistics: [format $fmt $rcount] [sp $rcount {revision changeset}]" 8e3012423b 2007-11-29 aku: log write 2 repository "Statistics: [format $fmt $tcount] [sp $tcount {tag symbol changeset}]" 8e3012423b 2007-11-29 aku: log write 2 repository "Statistics: [format $fmt $bcount] [sp $bcount {branch symbol changeset}]" 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: set prlist [TheProjects] 96b7bfb834 2007-11-16 aku: set npr [llength $prlist] 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: if {$npr > 1} { 96b7bfb834 2007-11-16 aku: set bmax [max [struct::list map $prlist [myproc .BaseLength]]] 96b7bfb834 2007-11-16 aku: incr bmax 2 96b7bfb834 2007-11-16 aku: set bfmt %-${bmax}s 96b7bfb834 2007-11-16 aku: } else { 96b7bfb834 2007-11-16 aku: set bfmt %s 96b7bfb834 2007-11-16 aku: } 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: foreach p $prlist { 96b7bfb834 2007-11-16 aku: set pid [$p id] 2630e50610 2007-11-22 aku: set prefix "Project [format $bfmt \"[$p printbase]\"]" 96b7bfb834 2007-11-16 aku: regsub -all {[^ ]} $prefix { } blanks 96b7bfb834 2007-11-16 aku: set sep " : " 96b7bfb834 2007-11-16 aku: 96b7bfb834 2007-11-16 aku: set ccount [state one { SELECT COUNT (*) FROM changeset WHERE pid = $pid }] 96b7bfb834 2007-11-16 aku: set rcount [state one { SELECT COUNT (*) FROM changeset WHERE pid = $pid AND type = 0 }] 8e3012423b 2007-11-29 aku: set tcount [state one { SELECT COUNT (*) FROM changeset WHERE pid = $pid AND type = 1 }] 8e3012423b 2007-11-29 aku: set bcount [state one { SELECT COUNT (*) FROM changeset WHERE pid = $pid AND type = 2 }] 2630e50610 2007-11-22 aku: 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $prefix$sep[format $fmt $ccount] [sp $ccount changeset]" 2630e50610 2007-11-22 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $rcount] [sp $rcount {revision changeset}]" 8e3012423b 2007-11-29 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $tcount] [sp $tcount {tag symbol changeset}]" 8e3012423b 2007-11-29 aku: log write 2 repository "Statistics: $blanks$sep[format $fmt $bcount] [sp $bcount {branch symbol changeset}]" 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: cfe4b269ac 2007-10-17 aku: typevariable mybase {} ; # Base path to CVS repository. cfe4b269ac 2007-10-17 aku: typevariable myprojpaths {} ; # List of paths to all declared cfe4b269ac 2007-10-17 aku: # projects, relative to mybase. cfe4b269ac 2007-10-17 aku: typevariable myprojects {} ; # List of objects for all cfe4b269ac 2007-10-17 aku: # declared projects. c3d5104084 2007-11-02 aku: typevariable myprojmap -array {} ; # Map from project ids to their c3d5104084 2007-11-02 aku: # objects. 99e165d5c4 2007-10-21 aku: typevariable myauthor {} ; # Names of all authors found, cfe4b269ac 2007-10-17 aku: # maps to their ids. 99e165d5c4 2007-10-21 aku: typevariable mycmsg {} ; # All commit messages found, cfe4b269ac 2007-10-17 aku: # maps to their ids. 99e165d5c4 2007-10-21 aku: typevariable mymeta {} ; # Maps all meta data tuples cfe4b269ac 2007-10-17 aku: # (project, branch, author, cfe4b269ac 2007-10-17 aku: # cmessage) to their ids. 99e165d5c4 2007-10-21 aku: typevariable mysymbol {} ; # Map symbols identified by cfe4b269ac 2007-10-17 aku: # project and name to their cfe4b269ac 2007-10-17 aku: # id. This information is not cfe4b269ac 2007-10-17 aku: # saved directly. cfe4b269ac 2007-10-17 aku: typevariable mytrunkonly 0 ; # Boolean flag. Set by option cfe4b269ac 2007-10-17 aku: # processing when the user cfe4b269ac 2007-10-17 aku: # requested a trunk-only import 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: # # ## ### ##### ######## ############# 52f2254007 2007-10-04 aku: ## Internal methods 99e165d5c4 2007-10-21 aku: 99e165d5c4 2007-10-21 aku: typeconstructor { 99e165d5c4 2007-10-21 aku: set myauthor [vc::tools::id %AUTO%] 99e165d5c4 2007-10-21 aku: set mycmsg [vc::tools::id %AUTO%] 99e165d5c4 2007-10-21 aku: set mymeta [vc::tools::id %AUTO%] 99e165d5c4 2007-10-21 aku: set mysymbol [vc::tools::id %AUTO%] 99e165d5c4 2007-10-21 aku: return 99e165d5c4 2007-10-21 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: proc .BaseLength {p} { 52f2254007 2007-10-04 aku: return [string length [$p printbase]] 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: proc .NFileLength {p} { 8a93ffa9c1 2007-10-06 aku: return [string length [llength [$p filenames]]] 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: proc IsRepositoryBase {path mv} { 70b0aa899a 2007-10-06 aku: ::variable mybase 70b0aa899a 2007-10-06 aku: upvar 1 $mv msg 52f2254007 2007-10-04 aku: if {![fileutil::test $mybase edr msg {CVS Repository}]} {return 0} 52f2254007 2007-10-04 aku: if {![fileutil::test $mybase/CVSROOT edr msg {CVS Admin Directory}]} {return 0} 52f2254007 2007-10-04 aku: return 1 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: proc IsProjectBase {path admin mv} { 52f2254007 2007-10-04 aku: upvar 1 $mv msg 52f2254007 2007-10-04 aku: if {![fileutil::test $path edr msg Project]} {return 0} 52f2254007 2007-10-04 aku: if { 52f2254007 2007-10-04 aku: ($path eq $admin) || 52f2254007 2007-10-04 aku: [string match $admin/* $path] 52f2254007 2007-10-04 aku: } { 52f2254007 2007-10-04 aku: set msg "Administrative subdirectory $path cannot be a project" 52f2254007 2007-10-04 aku: return 0 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: return 1 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: proc TheProjects {} { 70b0aa899a 2007-10-06 aku: upvar 1 type type 70b0aa899a 2007-10-06 aku: ::variable myprojects 70b0aa899a 2007-10-06 aku: ::variable myprojpaths 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: if {![llength $myprojects]} { 52f2254007 2007-10-04 aku: set myprojects [EmptyProjects $myprojpaths] 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: return $myprojects 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: 52f2254007 2007-10-04 aku: proc EmptyProjects {projpaths} { 70b0aa899a 2007-10-06 aku: ::variable mybase 70b0aa899a 2007-10-06 aku: upvar 1 type type 52f2254007 2007-10-04 aku: set res {} 52f2254007 2007-10-04 aku: if {[llength $projpaths]} { 52f2254007 2007-10-04 aku: foreach pp $projpaths { 8487172254 2007-10-06 aku: lappend res [project %AUTO% $pp $type] 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: } else { 52f2254007 2007-10-04 aku: # Base is the single project. 8487172254 2007-10-06 aku: lappend res [project %AUTO% "" $type] 52f2254007 2007-10-04 aku: } 52f2254007 2007-10-04 aku: return $res 3d88cfd05d 2007-10-06 aku: } 3d88cfd05d 2007-10-06 aku: 3d88cfd05d 2007-10-06 aku: proc SaveAuthors {} { 3d88cfd05d 2007-10-06 aku: ::variable myauthor 89e9b357ed 2007-10-25 aku: foreach {name aid} [$myauthor get] { 3d88cfd05d 2007-10-06 aku: state run { 67c24820c7 2007-10-14 aku: INSERT INTO author ( aid, name) 67c24820c7 2007-10-14 aku: VALUES ($aid, $name); 67c24820c7 2007-10-14 aku: } 3d88cfd05d 2007-10-06 aku: } 3d88cfd05d 2007-10-06 aku: return 3d88cfd05d 2007-10-06 aku: } 3d88cfd05d 2007-10-06 aku: 3d88cfd05d 2007-10-06 aku: proc SaveCommitMessages {} { 3d88cfd05d 2007-10-06 aku: ::variable mycmsg 89e9b357ed 2007-10-25 aku: foreach {text cid} [$mycmsg get] { 3d88cfd05d 2007-10-06 aku: state run { 67c24820c7 2007-10-14 aku: INSERT INTO cmessage ( cid, text) 67c24820c7 2007-10-14 aku: VALUES ($cid, $text); 3d88cfd05d 2007-10-06 aku: } 67c24820c7 2007-10-14 aku: } 67c24820c7 2007-10-14 aku: return 67c24820c7 2007-10-14 aku: } 67c24820c7 2007-10-14 aku: 67c24820c7 2007-10-14 aku: proc SaveMeta {} { 67c24820c7 2007-10-14 aku: ::variable mymeta 89e9b357ed 2007-10-25 aku: foreach {key mid} [$mymeta get] { 67c24820c7 2007-10-14 aku: struct::list assign $key pid bid aid cid 89e9b357ed 2007-10-25 aku: state run { 89e9b357ed 2007-10-25 aku: INSERT INTO meta ( mid, pid, bid, aid, cid) 89e9b357ed 2007-10-25 aku: VALUES ($mid, $pid, $bid, $aid, $cid); 67c24820c7 2007-10-14 aku: } 3d88cfd05d 2007-10-06 aku: } 3d88cfd05d 2007-10-06 aku: return 47740cc1f6 2007-10-03 aku: } 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# 47740cc1f6 2007-10-03 aku: ## Configuration 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: pragma -hasinstances no ; # singleton 47740cc1f6 2007-10-03 aku: pragma -hastypeinfo no ; # no introspection 47740cc1f6 2007-10-03 aku: pragma -hastypedestroy no ; # immortal 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# 47740cc1f6 2007-10-03 aku: } 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: namespace eval ::vc::fossil::import::cvs { 47740cc1f6 2007-10-03 aku: namespace export repository 47740cc1f6 2007-10-03 aku: namespace eval repository { 52f2254007 2007-10-04 aku: namespace import ::vc::fossil::import::cvs::project 042d54bae5 2007-10-05 aku: namespace import ::vc::fossil::import::cvs::state 43d72c6246 2007-10-06 aku: namespace import ::vc::tools::misc::* 99e165d5c4 2007-10-21 aku: namespace import ::vc::tools::id 52f2254007 2007-10-04 aku: namespace import ::vc::tools::trouble 52f2254007 2007-10-04 aku: namespace import ::vc::tools::log 52f2254007 2007-10-04 aku: log register repository 47740cc1f6 2007-10-03 aku: } 47740cc1f6 2007-10-03 aku: } 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: # # ## ### ##### ######## ############# ##################### 47740cc1f6 2007-10-03 aku: ## Ready 47740cc1f6 2007-10-03 aku: 47740cc1f6 2007-10-03 aku: return