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 d8c18fc148 2007-09-17 aku: package require vc::cvs::ws ; # CVS frontend 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 f166b0a63c 2007-08-31 aku: return f166b0a63c 2007-08-31 aku: } f166b0a63c 2007-08-31 aku: c172959c32 2007-09-08 aku: # ----------------------------------------------------------------------------- c172959c32 2007-09-08 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 f166b0a63c 2007-08-31 aku: c172959c32 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 { 7b2619b7ef 2007-09-13 aku: --breakat { next ; import::configure -breakat [this] } 7b2619b7ef 2007-09-13 aku: --nosign { import::configure -nosign 1 } 7b2619b7ef 2007-09-13 aku: --saveto { next ; import::configure -saveto [file normalize [this]] } d8c18fc148 2007-09-17 aku: --project { next ; import::configure -project [this] } 86a7f249c1 2007-09-09 aku: -v { incr verbosity ; ::vc::tools::log::verbosity $verbosity } 7b2619b7ef 2007-09-13 aku: -h - 7b2619b7ef 2007-09-13 aku: default usage f166b0a63c 2007-08-31 aku: } c172959c32 2007-09-08 aku: next c172959c32 2007-09-08 aku: } df91d389d5 2007-09-04 aku: c172959c32 2007-09-08 aku: remainder c172959c32 2007-09-08 aku: if {[llength $argv] != 2} usage c172959c32 2007-09-08 aku: foreach {cvs fossil} $argv break f166b0a63c 2007-08-31 aku: d8c18fc148 2007-09-17 aku: if {![::vc::cvs::ws::check $cvs msg]} { d8c18fc148 2007-09-17 aku: usage $msg c172959c32 2007-09-08 aku: } elseif {[file exists $fossil]} { c172959c32 2007-09-08 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] f166b0a63c 2007-08-31 aku: } f166b0a63c 2007-08-31 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] df91d389d5 2007-09-04 aku: return df91d389d5 2007-09-04 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 f166b0a63c 2007-08-31 aku: } f166b0a63c 2007-08-31 aku: df91d389d5 2007-09-04 aku: proc usage {{text {}}} { df91d389d5 2007-09-04 aku: global argv0 7b2619b7ef 2007-09-13 aku: puts stderr "Usage: $argv0 ?-v? ?--nosign? ?--breakat id? ?--saveto path? cvs-repository fossil-repository" 7b2619b7ef 2007-09-13 aku: if {$text eq ""} { 7b2619b7ef 2007-09-13 aku: puts stderr " --nosign: Do not sign the imported changesets." 7b2619b7ef 2007-09-13 aku: puts stderr " --breakat: Stop just before committing the identified changeset." d8c18fc148 2007-09-17 aku: puts stderr " --project: Path in the CVS repository to limit the import to." 7b2619b7ef 2007-09-13 aku: puts stderr " --saveto: Save commit command to the specified file." 7b2619b7ef 2007-09-13 aku: puts stderr " -v: Increase log verbosity. Can be used multiple times." df91d389d5 2007-09-04 aku: } else { 7b2619b7ef 2007-09-13 aku: puts stderr " $text" f166b0a63c 2007-08-31 aku: } c172959c32 2007-09-08 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