File Annotation
Not logged in
f166b0a63c 2007-08-31       aku: #!/bin/sh
f166b0a63c 2007-08-31       aku: # -*- tcl -*- \
f166b0a63c 2007-08-31       aku: exec tclsh "$0" ${1+"$@"}
f166b0a63c 2007-08-31       aku: 
f166b0a63c 2007-08-31       aku: # -----------------------------------------------------------------------------
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # Import the trunk of a CVS repository wholesale into a fossil repository.
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # Limitations implicitly mentioned:
df91d389d5 2007-09-04       aku: # - No incremental import.
df91d389d5 2007-09-04       aku: # - No import of branches.
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # WIBNI features (beyond eliminating the limitations):
df91d389d5 2007-09-04       aku: # - Restrict import to specific directory subtrees (SF projects use
df91d389d5 2007-09-04       aku: #   one repository for several independent modules. Examples: tcllib
df91d389d5 2007-09-04       aku: #   -> tcllib, tklib, tclapps, etc.). The restriction would allow import
df91d389d5 2007-09-04       aku: #   of only a specific module.
df91d389d5 2007-09-04       aku: # - Related to the previous, strip elements from the base path to keep
df91d389d5 2007-09-04       aku: #   it short.
df91d389d5 2007-09-04       aku: # - Export to CVS, trunk, possibly branches. I.e. extend the system to be
df91d389d5 2007-09-04       aku: #   a full bridge. Either Fossil or CVS could be the master repository.
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # HACKS. I.e. I do not know if the 'fixes' I use are the correct way
df91d389d5 2007-09-04       aku: #        of handling the encountered situations.
df91d389d5 2007-09-04       aku: #
df91d389d5 2007-09-04       aku: # - File F has archives F,v and Attic/F,v. Currently I will ignore the
df91d389d5 2007-09-04       aku: #   file in the Attic.
df91d389d5 2007-09-04       aku: #   Examples: sqlite/os_unix.h
df91d389d5 2007-09-04       aku: #
df91d389d5 2007-09-04       aku: # - A specific revision of a file F cannot be checked out (reported
df91d389d5 2007-09-04       aku: #   error is 'invalid change text'). This indicates a corrupt RCS
df91d389d5 2007-09-04       aku: #   file, one or more delta are bad. We report but ignore the problem
df91d389d5 2007-09-04       aku: #   in a best-effort attempt at getting as much history as possible.
df91d389d5 2007-09-04       aku: #   Examples: tcllib/tklib/modules/tkpiechart/pie.tcl
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # -----------------------------------------------------------------------------
f166b0a63c 2007-08-31       aku: # Make private packages accessible.
f166b0a63c 2007-08-31       aku: 
f166b0a63c 2007-08-31       aku: lappend auto_path [file join [file dirname [info script]] lib]
f166b0a63c 2007-08-31       aku: 
f166b0a63c 2007-08-31       aku: # -----------------------------------------------------------------------------
df91d389d5 2007-09-04       aku: # Requirements
df91d389d5 2007-09-04       aku: 
7003caa982 2007-09-04       aku: package require Tcl 8.4
9671b65174 2007-09-13       aku: package require vc::tools::log          ; # User Feedback
9671b65174 2007-09-13       aku: package require vc::fossil::import::cvs ; # Importer Control
9671b65174 2007-09-13       aku: 
9671b65174 2007-09-13       aku: namespace eval ::import {
9671b65174 2007-09-13       aku:     namespace import ::vc::fossil::import::cvs::*
f166b0a63c 2007-08-31       aku: }
f166b0a63c 2007-08-31       aku: 
df91d389d5 2007-09-04       aku: # -----------------------------------------------------------------------------
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: proc main {} {
9671b65174 2007-09-13       aku:     commandline -> cvs  fossil
9671b65174 2007-09-13       aku:     import::run   $cvs $fossil
492531e3a8 2007-09-04       aku:     return
f166b0a63c 2007-08-31       aku: }
f166b0a63c 2007-08-31       aku: 
492531e3a8 2007-09-04       aku: # -----------------------------------------------------------------------------
492531e3a8 2007-09-04       aku: 
c172959c32 2007-09-08       aku: proc commandline {__ cv fv} {
c172959c32 2007-09-08       aku:     global argv
c172959c32 2007-09-08       aku:     upvar 1 $cv cvs $fv fossil
df91d389d5 2007-09-04       aku: 
be32ebcb41 2007-09-08       aku:     set verbosity 0
f166b0a63c 2007-08-31       aku: 
c172959c32 2007-09-08       aku:     clinit
c172959c32 2007-09-08       aku:     while {[string match "-*" [set opt [this]]]} {
c172959c32 2007-09-08       aku: 	switch -exact -- $opt {
9671b65174 2007-09-13       aku: 	    --nosign      {        import::configure -nosign      1 }
9671b65174 2007-09-13       aku: 	    --debugcommit {        import::configure -debugcommit 1 }
9671b65174 2007-09-13       aku: 	    --stopat      { next ; import::configure -stopat [this] }
86a7f249c1 2007-09-09       aku: 	    -v            { incr verbosity ; ::vc::tools::log::verbosity $verbosity }
c172959c32 2007-09-08       aku: 	    default usage
492531e3a8 2007-09-04       aku: 	}
c172959c32 2007-09-08       aku: 	next
492531e3a8 2007-09-04       aku:     }
f166b0a63c 2007-08-31       aku: 
c172959c32 2007-09-08       aku:     remainder
df91d389d5 2007-09-04       aku:     if {[llength $argv] != 2} usage
df91d389d5 2007-09-04       aku:     foreach {cvs fossil} $argv break
f166b0a63c 2007-08-31       aku: 
df91d389d5 2007-09-04       aku:     if {
df91d389d5 2007-09-04       aku: 	![file exists      $cvs] ||
df91d389d5 2007-09-04       aku: 	![file readable    $cvs] ||
df91d389d5 2007-09-04       aku: 	![file isdirectory $cvs]
df91d389d5 2007-09-04       aku:     } {
df91d389d5 2007-09-04       aku: 	usage "CVS directory missing, not readable, or not a directory."
df91d389d5 2007-09-04       aku:     } elseif {[file exists $fossil]} {
df91d389d5 2007-09-04       aku: 	usage "Fossil destination repository exists already."
f166b0a63c 2007-08-31       aku:     }
f166b0a63c 2007-08-31       aku: 
c172959c32 2007-09-08       aku:     return
c172959c32 2007-09-08       aku: }
c172959c32 2007-09-08       aku: 
c172959c32 2007-09-08       aku: proc this {} {
c172959c32 2007-09-08       aku:     global argv
c172959c32 2007-09-08       aku:     upvar 1 at at
c172959c32 2007-09-08       aku:     return [lindex $argv $at]
c172959c32 2007-09-08       aku: }
c172959c32 2007-09-08       aku: 
c172959c32 2007-09-08       aku: proc next {} {
c172959c32 2007-09-08       aku:     upvar 1 at at
c172959c32 2007-09-08       aku:     incr at
c172959c32 2007-09-08       aku:     return
f166b0a63c 2007-08-31       aku: }
f166b0a63c 2007-08-31       aku: 
c172959c32 2007-09-08       aku: proc remainder {} {
c172959c32 2007-09-08       aku:     upvar 1 at at
c172959c32 2007-09-08       aku:     global argv
c172959c32 2007-09-08       aku:     set argv [lrange $argv $at end]
c172959c32 2007-09-08       aku:     return
f166b0a63c 2007-08-31       aku: }
f166b0a63c 2007-08-31       aku: 
c172959c32 2007-09-08       aku: proc clinit {} {
c172959c32 2007-09-08       aku:     upvar 1 at at
c172959c32 2007-09-08       aku:     set at 0
df91d389d5 2007-09-04       aku:     return
df91d389d5 2007-09-04       aku: }
f166b0a63c 2007-08-31       aku: 
df91d389d5 2007-09-04       aku: proc usage {{text {}}} {
df91d389d5 2007-09-04       aku:     global argv0
c172959c32 2007-09-08       aku:     puts stderr "Usage: $argv0 ?--nosign? ?-v? ?--stopat id? ?--debugcommit? cvs-repository fossil-repository"
df91d389d5 2007-09-04       aku:     if {$text eq ""} return
df91d389d5 2007-09-04       aku:     puts stderr "       $text"
df91d389d5 2007-09-04       aku:     exit
f166b0a63c 2007-08-31       aku: }
f166b0a63c 2007-08-31       aku: 
f166b0a63c 2007-08-31       aku: # -----------------------------------------------------------------------------
f166b0a63c 2007-08-31       aku: 
df91d389d5 2007-09-04       aku: main
df91d389d5 2007-09-04       aku: exit