File Annotation
Not logged in
df91d389d5 2007-09-04       aku: # -----------------------------------------------------------------------------
df91d389d5 2007-09-04       aku: # Repository management (CVS)
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # -----------------------------------------------------------------------------
df91d389d5 2007-09-04       aku: # Requirements
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: package require Tcl 8.4
1593006ef3 2007-09-17       aku: package require fileutil              ; # Tcllib (traverse directory hierarchy)
1593006ef3 2007-09-17       aku: package require vc::rcs::parser       ; # Handling the RCS archive files.
1593006ef3 2007-09-17       aku: package require vc::tools::log        ; # User feedback
a5476aed27 2007-09-20       aku: package require vc::tools::trouble    ; # Error handling
1593006ef3 2007-09-17       aku: package require vc::cvs::cmd          ; # Access to cvs application.
1593006ef3 2007-09-17       aku: package require vc::cvs::ws::files    ; # Scan CVS repository for relevant files.
1593006ef3 2007-09-17       aku: package require vc::cvs::ws::timeline ; # Manage timeline of all changes.
ae54e928c2 2007-09-17       aku: package require vc::cvs::ws::csets    ; # Manage the changesets found in the timeline
72dac950c3 2007-09-26       aku: package require vc::cvs::ws::branch   ; # Branch database
72dac950c3 2007-09-26       aku: package require vc::cvs::ws::sig      ; # Changeset file/rev signatures
00228d1547 2007-09-13       aku: 
00228d1547 2007-09-13       aku: namespace eval ::vc::cvs::ws {
86a7f249c1 2007-09-09       aku:     vc::tools::log::system cvs
86a7f249c1 2007-09-09       aku:     namespace import ::vc::tools::log::write
d4aa7da67d 2007-09-13       aku:     namespace import ::vc::rcs::parser::process
cdf5e6d8b7 2007-09-13       aku:     namespace import ::vc::cvs::cmd::dova
a5476aed27 2007-09-20       aku: 
a5476aed27 2007-09-20       aku:     namespace eval trouble { namespace import ::vc::tools::trouble::* }
be32ebcb41 2007-09-08       aku: }
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # -----------------------------------------------------------------------------
df91d389d5 2007-09-04       aku: # API
df91d389d5 2007-09-04       aku: 
d8c18fc148 2007-09-17       aku: # vc::cvs::ws::configure key value    - Configure the subsystem.
d8c18fc148 2007-09-17       aku: # vc::cvs::ws::check     src mv       - Check if src is a CVS repository directory.
d8c18fc148 2007-09-17       aku: # vc::cvs::ws::begin     src          - Start new workspace and return the top-
d8c18fc148 2007-09-17       aku: #                                       most directory co'd files are put into.
cbbf9a7575 2007-09-20       aku: # vc::cvs::ws::ncsets                 - Retrieve total number of csets
cbbf9a7575 2007-09-20       aku: # vc::cvs::ws::nimportable            - Retrieve number of importable csets
d8c18fc148 2007-09-17       aku: # vc::cvs::ws::foreach   csvar script - Run the script for each changeset, the
d8c18fc148 2007-09-17       aku: #                                       id of the current changeset stored in
d8c18fc148 2007-09-17       aku: #                                       the variable named by csvar.
d8c18fc148 2007-09-17       aku: # vc::cvs::ws::done                   - Close workspace and delete it.
d8c18fc148 2007-09-17       aku: # vc::cvs::ws::isadmin path           - Check if path is an admin file of CVS
d8c18fc148 2007-09-17       aku: # vc::cvs::ws::checkout id            - Have workspace contain the changeset id.
cbbf9a7575 2007-09-20       aku: # vc::cvs::ws::get      id            - Retrieve data of a changeset.
d8c18fc148 2007-09-17       aku: #
d8c18fc148 2007-09-17       aku: # Configuration keys:
d8c18fc148 2007-09-17       aku: #
d8c18fc148 2007-09-17       aku: # -project path - Sub directory under 'src' to limit the import to.
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: # -----------------------------------------------------------------------------
d8c18fc148 2007-09-17       aku: # API Implementation
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::configure {key value} {
d8c18fc148 2007-09-17       aku:     variable project
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku:     switch -exact -- $key {
d8c18fc148 2007-09-17       aku: 	-project { set project $value }
d8c18fc148 2007-09-17       aku: 	default {
d8c18fc148 2007-09-17       aku: 	    return -code error "Unknown switch $key, expected \
d8c18fc148 2007-09-17       aku:                                    -project"
df91d389d5 2007-09-04       aku: 	}
d8c18fc148 2007-09-17       aku:     }
d8c18fc148 2007-09-17       aku:     return
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::check {src mv} {
d8c18fc148 2007-09-17       aku:     variable project
d8c18fc148 2007-09-17       aku:     upvar 1 $mv msg
d8c18fc148 2007-09-17       aku:     if {
d8c18fc148 2007-09-17       aku: 	![fileutil::test $src         erd msg "CVS Repository"] ||
d8c18fc148 2007-09-17       aku: 	![fileutil::test $src/CVSROOT erd msg "CVS Admin directory"] ||
d8c18fc148 2007-09-17       aku: 	(($project ne "") &&
d8c18fc148 2007-09-17       aku: 	 ![fileutil::test $src/$project erd msg "Project directory"])
d8c18fc148 2007-09-17       aku:     } {
d8c18fc148 2007-09-17       aku: 	return 0
d8c18fc148 2007-09-17       aku:     }
d8c18fc148 2007-09-17       aku:     return 1
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::begin {src} {
1593006ef3 2007-09-17       aku:     if {![check $src msg]} { return -code error $msg }
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     DefBase $src
1593006ef3 2007-09-17       aku:     MakeTimeline [ScanArchives [files::find [RootPath]]]
ae54e928c2 2007-09-17       aku:     MakeChangesets
cbbf9a7575 2007-09-20       aku:     ProcessBranches
2740b48b63 2007-09-17       aku: 
2740b48b63 2007-09-17       aku:     return [MakeWorkspace]
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::done {} {
2740b48b63 2007-09-17       aku:     variable            workspace
d8c18fc148 2007-09-17       aku:     file delete -force $workspace
d8c18fc148 2007-09-17       aku:     return
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::foreach {cv script} {
cbbf9a7575 2007-09-20       aku:     variable importable
cbbf9a7575 2007-09-20       aku:     upvar 1 $cv c
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku:     ::foreach c [lsort -integer -increasing $importable] {
cbbf9a7575 2007-09-20       aku: 	set code [catch {uplevel 1 $script} res]
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku: 	# 0 - ok, 1 - error, 2 - return, 3 - break, 4 - continue
cbbf9a7575 2007-09-20       aku: 	switch -- $code {
cbbf9a7575 2007-09-20       aku: 	    0 {}
cbbf9a7575 2007-09-20       aku: 	    1 { return -errorcode $::errorCode -errorinfo $::errorInfo -code error $res }
cbbf9a7575 2007-09-20       aku: 	    2 {}
cbbf9a7575 2007-09-20       aku: 	    3 { return }
cbbf9a7575 2007-09-20       aku: 	    4 {}
cbbf9a7575 2007-09-20       aku: 	    default { return -code $code $result }
df91d389d5 2007-09-04       aku: 	}
cbbf9a7575 2007-09-20       aku:     }
cbbf9a7575 2007-09-20       aku:     return
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::ncsets {args} {
ae54e928c2 2007-09-17       aku:     return [csets::num]
cbbf9a7575 2007-09-20       aku: }
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku: proc ::vc::cvs::ws::nimportable {args} {
cbbf9a7575 2007-09-20       aku:     variable importable
cbbf9a7575 2007-09-20       aku:     return [llength $importable]
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::isadmin {path} {
d8c18fc148 2007-09-17       aku:     # Check if path is a CVS admin file.
d8c18fc148 2007-09-17       aku:     if {[string match CVS/*   $path]} {return 1}
d8c18fc148 2007-09-17       aku:     if {[string match */CVS/* $path]} {return 1}
d8c18fc148 2007-09-17       aku:     return 0
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
cbbf9a7575 2007-09-20       aku: proc ::vc::cvs::ws::parentOf {id} { csets::parentOf $id }
cbbf9a7575 2007-09-20       aku: 
d8c18fc148 2007-09-17       aku: proc ::vc::cvs::ws::checkout {id} {
ae54e928c2 2007-09-17       aku:     variable workspace
ae54e928c2 2007-09-17       aku:     cd      $workspace
ae54e928c2 2007-09-17       aku: 
cbbf9a7575 2007-09-20       aku:     # TODO: Hide the direct access to the data structures behind
cbbf9a7575 2007-09-20       aku:     # TODO: accessors for date, cmsg, removed, added, changed, and
cbbf9a7575 2007-09-20       aku:     # TODO: author
ae54e928c2 2007-09-17       aku:     array set cs [csets::get $id]
ae54e928c2 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku:     write 1 cvs "@  $cs(date)"
ae54e928c2 2007-09-17       aku:     ::foreach l [split [string trim $cs(cmsg)] \n] {
ae54e928c2 2007-09-17       aku: 	write 1 cvs "|  $l"
ae54e928c2 2007-09-17       aku:     }
ae54e928c2 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku:     ::foreach {f r} $cs(removed) { write 2 cvs "R  $f $r" ; Remove   $f $r }
ae54e928c2 2007-09-17       aku:     ::foreach {f r} $cs(added)   { write 2 cvs "A  $f $r" ; Checkout $f $r }
ae54e928c2 2007-09-17       aku:     ::foreach {f r} $cs(changed) { write 2 cvs "M  $f $r" ; Checkout $f $r }
ae54e928c2 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku:     # Provide metadata about the changeset the backend may wish to have
ae54e928c2 2007-09-17       aku:     return [list $cs(author) $cs(date) $cs(cmsg)]
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
d8c18fc148 2007-09-17       aku: # -----------------------------------------------------------------------------
ae54e928c2 2007-09-17       aku: # Internals
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::DefBase {path} {
6f121db1e2 2007-09-17       aku:     variable project
6f121db1e2 2007-09-17       aku:     variable base
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     set base $path
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     write 0 cvs "Base:    $base"
1593006ef3 2007-09-17       aku:     if {$project eq ""} {
1593006ef3 2007-09-17       aku: 	write 0 cvs "Project: <ALL>"
1593006ef3 2007-09-17       aku:     } else {
1593006ef3 2007-09-17       aku: 	write 0 cvs "Project: $project"
1593006ef3 2007-09-17       aku:     }
df91d389d5 2007-09-04       aku:     return
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::RootPath {} {
d8c18fc148 2007-09-17       aku:     variable project
d8c18fc148 2007-09-17       aku:     variable base
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     if {$project eq ""} {
1593006ef3 2007-09-17       aku: 	return $base
1593006ef3 2007-09-17       aku:     } else {
1593006ef3 2007-09-17       aku: 	return $base/$project
1593006ef3 2007-09-17       aku:     }
1593006ef3 2007-09-17       aku: }
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::ScanArchives {files} {
1593006ef3 2007-09-17       aku:     write 0 cvs "Scanning archives ..."
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     set d [RootPath]
1593006ef3 2007-09-17       aku:     set r {}
d8c18fc148 2007-09-17       aku:     set n 0
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     ::foreach {rcs f} $files {
d8c18fc148 2007-09-17       aku: 	write 1 cvs "Archive $rcs"
1593006ef3 2007-09-17       aku: 	# Get the meta data we need (revisions, timeline, messages).
1593006ef3 2007-09-17       aku: 	lappend r $f [process $d/$rcs]
1593006ef3 2007-09-17       aku: 	incr    n
1593006ef3 2007-09-17       aku:     }
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     write 0 cvs "Processed [NSIPL $n file]"
1593006ef3 2007-09-17       aku:     return $r
1593006ef3 2007-09-17       aku: }
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::MakeTimeline {meta} {
1593006ef3 2007-09-17       aku:     write 0 cvs "Generating coalesced timeline ..."
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku:     set n 0
1593006ef3 2007-09-17       aku:     ::foreach {f meta} $meta {
1593006ef3 2007-09-17       aku: 	array set md   $meta
1593006ef3 2007-09-17       aku: 	array set date $md(date)
1593006ef3 2007-09-17       aku: 	array set auth $md(author)
1593006ef3 2007-09-17       aku: 	array set cmsg $md(commit)
1593006ef3 2007-09-17       aku: 	array set stat $md(state)
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku: 	::foreach rev [lsort -dict [array names date]] {
1593006ef3 2007-09-17       aku: 	    set operation [Operation $rev $stat($rev)]
1593006ef3 2007-09-17       aku: 	    NoteDeadRoots $f $rev $operation
1593006ef3 2007-09-17       aku: 	    timeline::add $date($rev) $f $rev $operation $auth($rev) $cmsg($rev)
df91d389d5 2007-09-04       aku: 	    incr n
df91d389d5 2007-09-04       aku: 	}
d8c18fc148 2007-09-17       aku: 
72dac950c3 2007-09-26       aku: 	if {[info exists md(symbol)]} {
72dac950c3 2007-09-26       aku: 	    branch::def $f date $md(symbol)
d8c18fc148 2007-09-17       aku: 	}
d8c18fc148 2007-09-17       aku: 
10e3b3ed76 2007-09-17       aku: 	unset md
10e3b3ed76 2007-09-17       aku: 	unset date
10e3b3ed76 2007-09-17       aku: 	unset auth
10e3b3ed76 2007-09-17       aku: 	unset cmsg
10e3b3ed76 2007-09-17       aku: 	unset stat
df91d389d5 2007-09-04       aku:     }
df91d389d5 2007-09-04       aku: 
ae54e928c2 2007-09-17       aku:     write 0 cvs "Timeline has [NSIPL $n entry entries]"
1593006ef3 2007-09-17       aku:     return
1593006ef3 2007-09-17       aku: }
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::NoteDeadRoots {f rev operation} {
1593006ef3 2007-09-17       aku:     # A dead-first revision is rev 1.1 with op R. For an example see
1593006ef3 2007-09-17       aku:     # the file memchan/DEPENDENCIES. Such a file seems to exist only!
1593006ef3 2007-09-17       aku:     # on its branch. The branches information is set on the revision
1593006ef3 2007-09-17       aku:     # (extend rcsparser!), symbols has a tag, refering to a branch,
1593006ef3 2007-09-17       aku:     # possibly magic.
1593006ef3 2007-09-17       aku: 
1593006ef3 2007-09-17       aku:     if {($rev eq "1.1") && ($operation eq "R")} {
1593006ef3 2007-09-17       aku: 	write 2 cvs "Dead root revision: $f"
1593006ef3 2007-09-17       aku:     }
df91d389d5 2007-09-04       aku:     return
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::Operation {rev state} {
72dac950c3 2007-09-26       aku:     if {$state eq "dead"}          {return "R"} ; # Removed
72dac950c3 2007-09-26       aku:     if {$rev   eq "1.1"}           {return "A"} ; # Added
72dac950c3 2007-09-26       aku:     if {[string match *.1.1 $rev]} {return "A"} ; # Added on a branch
72dac950c3 2007-09-26       aku:     return "M"                                  ; # Modified
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
ae54e928c2 2007-09-17       aku: proc ::vc::cvs::ws::MakeChangesets {} {
1593006ef3 2007-09-17       aku:     write 0 cvs "Generating changesets from timeline"
1593006ef3 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku:     csets::init
1593006ef3 2007-09-17       aku:     timeline::foreach date file revision operation author cmsg {
ae54e928c2 2007-09-17       aku: 	csets::add $date $file $revision $operation $author $cmsg
df91d389d5 2007-09-04       aku:     }
ae54e928c2 2007-09-17       aku:     csets::done
ae54e928c2 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku:     write 0 cvs "Found [NSIPL [csets::num] changeset]"
df91d389d5 2007-09-04       aku:     return
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
2740b48b63 2007-09-17       aku: proc ::vc::cvs::ws::MakeWorkspace {} {
2740b48b63 2007-09-17       aku:     variable project
df91d389d5 2007-09-04       aku:     variable workspace [fileutil::tempfile importF_cvs_ws_]
2740b48b63 2007-09-17       aku: 
2740b48b63 2007-09-17       aku:     set w $workspace
2740b48b63 2007-09-17       aku:     if {$project ne ""} { append w /$project }
2740b48b63 2007-09-17       aku: 
df91d389d5 2007-09-04       aku:     file delete $workspace
2740b48b63 2007-09-17       aku:     file mkdir  $w
be32ebcb41 2007-09-08       aku: 
be32ebcb41 2007-09-08       aku:     write 0 cvs "Workspace:  $workspace"
2740b48b63 2007-09-17       aku:     return $w
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
d8c18fc148 2007-09-17       aku: # Building the revision tree from the changesets.
d8c18fc148 2007-09-17       aku: # Limitation: Currently only trunk csets is handled.
d8c18fc148 2007-09-17       aku: # Limitation: Dead files are not removed, i.e. no 'R' actions right now.
d8c18fc148 2007-09-17       aku: 
cbbf9a7575 2007-09-20       aku: proc ::vc::cvs::ws::ProcessBranches {} {
cbbf9a7575 2007-09-20       aku:     variable importable
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku:     write 0 cvs "Organizing the changesets into branches"
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku:     set remainder [ProcessTrunk]
25bc721076 2007-09-20       aku:     while {[llength $remainder]} {
25bc721076 2007-09-20       aku: 	set remainder [ProcessBranch $remainder]
25bc721076 2007-09-20       aku: 	# return -code break may be signaled to give up with non-empty
25bc721076 2007-09-20       aku: 	# set of unprocessed changesets.
d8c18fc148 2007-09-17       aku:     }
d8c18fc148 2007-09-17       aku: 
cbbf9a7575 2007-09-20       aku:     # Status information ...
cbbf9a7575 2007-09-20       aku:     set nr  [llength $remainder]
cbbf9a7575 2007-09-20       aku:     set ni  [llength $importable]
cbbf9a7575 2007-09-20       aku:     set fmt %[string length [csets::num]]s
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku:     write 0 cvs "Unprocessed: [format $fmt $nr] [SIPL $nr changeset] (Will be ignored)"
cbbf9a7575 2007-09-20       aku:     write 0 cvs "To import:   [format $fmt $ni] [SIPL $ni changeset]"
df91d389d5 2007-09-04       aku:     return
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
cbbf9a7575 2007-09-20       aku: proc ::vc::cvs::ws::ProcessTrunk {} {
cbbf9a7575 2007-09-20       aku:     variable importable
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku:     write 0 cvs "Processing the trunk changesets"
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku:     set remainder {}
cbbf9a7575 2007-09-20       aku:     set t         0
cbbf9a7575 2007-09-20       aku:     set n         [csets::num]
cbbf9a7575 2007-09-20       aku:     set parent    {}
cbbf9a7575 2007-09-20       aku: 
cbbf9a7575 2007-09-20       aku:     for {set c 0} {$c < $n} {incr c} {
cbbf9a7575 2007-09-20       aku: 	if {[csets::isTrunk $c]} {
cbbf9a7575 2007-09-20       aku: 	    csets::setParentOf $c $parent
cbbf9a7575 2007-09-20       aku: 	    set parent $c
cbbf9a7575 2007-09-20       aku: 	    incr t
cbbf9a7575 2007-09-20       aku: 	    lappend importable $c
cbbf9a7575 2007-09-20       aku: 	} else {
cbbf9a7575 2007-09-20       aku: 	    lappend remainder $c
cbbf9a7575 2007-09-20       aku: 	}
df91d389d5 2007-09-04       aku:     }
df91d389d5 2007-09-04       aku: 
cbbf9a7575 2007-09-20       aku:     write 0 cvs "Found [NSIPL $t {trunk changeset}], [NSIPL [llength $remainder] {branch changeset}]"
25bc721076 2007-09-20       aku:     return $remainder
d8c18fc148 2007-09-17       aku: }
d8c18fc148 2007-09-17       aku: 
25bc721076 2007-09-20       aku: proc ::vc::cvs::ws::ProcessBranch {cslist} {
72dac950c3 2007-09-26       aku:     write 0 cvs "Processing the remaining [SIPL [llength $cslist] changeset "[llength $cslist] changesets"]"
25bc721076 2007-09-20       aku: 
25bc721076 2007-09-20       aku:     set base   [lindex $cslist 0]
25bc721076 2007-09-20       aku:     set cslist [lrange $cslist 1 end]
25bc721076 2007-09-20       aku: 
72dac950c3 2007-09-26       aku:     csets::DUMP $base
25bc721076 2007-09-20       aku: 
25bc721076 2007-09-20       aku:     # Which branch does base belong to?
25bc721076 2007-09-20       aku:     # - It has to be the base of an unprocessed branch!
25bc721076 2007-09-20       aku:     #   Otherwise it would have been on either the trunk
25bc721076 2007-09-20       aku:     #   or an already processed branch.
25bc721076 2007-09-20       aku:     # Where is its root changeset ?
25bc721076 2007-09-20       aku:     # - The root has to come before the base, it has already
25bc721076 2007-09-20       aku:     #   been processed => Smaller id, older in time.
25bc721076 2007-09-20       aku:     # - Based on the files changed/removed by the base, and their
25bc721076 2007-09-20       aku:     #   versions we know the root versions of these files, and we
25bc721076 2007-09-20       aku:     #   can determine the changesets they are in => Intersection
25bc721076 2007-09-20       aku:     #   plus cap from previous contraint gives us the possible
25bc721076 2007-09-20       aku:     #   candidates.
25bc721076 2007-09-20       aku: 
72dac950c3 2007-09-26       aku:     write 4 cvs "Branch base $base"
72dac950c3 2007-09-26       aku: 
72dac950c3 2007-09-26       aku:     ::foreach {tag rootsig} [branch::find [csets::get $base]] break
72dac950c3 2007-09-26       aku: 
72dac950c3 2007-09-26       aku:     write 4 cvs "Branch tag  $tag"
7a64b9e738 2007-09-27       aku:     write 5 cvs "Root sig    $rootsig"
72dac950c3 2007-09-26       aku: 
72dac950c3 2007-09-26       aku:     set root [sig::find $base $rootsig]
72dac950c3 2007-09-26       aku: 
72dac950c3 2007-09-26       aku:     write 4 cvs "Branch root $root"
72dac950c3 2007-09-26       aku: 
72dac950c3 2007-09-26       aku:     write 0 cvs "Changeset $base, starting branch \"$tag\", rooted at $root"
25bc721076 2007-09-20       aku:     csets::setParentOf $base $root
25bc721076 2007-09-20       aku: 
72dac950c3 2007-09-26       aku:     set remainder {}
72dac950c3 2007-09-26       aku:     set t         1
72dac950c3 2007-09-26       aku: 
72dac950c3 2007-09-26       aku:     ::foreach c $cslist {
72dac950c3 2007-09-26       aku: 	#csets::DUMP $c
72dac950c3 2007-09-26       aku: 	if {[csets::sameBranch $c $base $tag]} {
25bc721076 2007-09-20       aku: 	    csets::setParentOf $c $base
25bc721076 2007-09-20       aku: 	    set base $c
25bc721076 2007-09-20       aku: 	    incr t
25bc721076 2007-09-20       aku: 	    lappend importable $c
df91d389d5 2007-09-04       aku: 	} else {
25bc721076 2007-09-20       aku: 	    lappend remainder $c
ae54e928c2 2007-09-17       aku: 	}
2740b48b63 2007-09-17       aku:     }
2740b48b63 2007-09-17       aku: 
72dac950c3 2007-09-26       aku:     write 0 cvs "Found [NSIPL $t "$tag changeset"], [NSIPL [llength $remainder] changeset] outside"
cbbf9a7575 2007-09-20       aku:     return $remainder
1593006ef3 2007-09-17       aku: }
1593006ef3 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku: proc ::vc::cvs::ws::Checkout {f r} {
1593006ef3 2007-09-17       aku:     variable base
1593006ef3 2007-09-17       aku:     variable project
1593006ef3 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku:     # Added or modified, put the requested version of the file into
ae54e928c2 2007-09-17       aku:     # the workspace.
ae54e928c2 2007-09-17       aku: 
ae54e928c2 2007-09-17       aku:     if {$project ne ""} {set f $project/$f}
ae54e928c2 2007-09-17       aku:     if {[catch {
ae54e928c2 2007-09-17       aku: 	dova -d $base co -r $r $f
ae54e928c2 2007-09-17       aku:     } msg]} {
ae54e928c2 2007-09-17       aku: 	if {[string match {*invalid change text*} $msg]} {
df91d389d5 2007-09-04       aku: 
ae54e928c2 2007-09-17       aku: 	    # The archive of the file is corrupted and the chosen
ae54e928c2 2007-09-17       aku: 	    # version not accessible due to that. We report the
ae54e928c2 2007-09-17       aku: 	    # problem, but otherwise ignore it. As a consequence the
ae54e928c2 2007-09-17       aku: 	    # destination repository will not contain the full history
ae54e928c2 2007-09-17       aku: 	    # of the named file. By ignoring the problem we however
ae54e928c2 2007-09-17       aku: 	    # get as much as is possible.
df91d389d5 2007-09-04       aku: 
a5476aed27 2007-09-20       aku: 	    trouble::add "$f: Corrupted archive file. Inaccessible revision $r."
ae54e928c2 2007-09-17       aku: 	    return
df91d389d5 2007-09-04       aku: 	}
ae54e928c2 2007-09-17       aku: 	return -code error $msg
df91d389d5 2007-09-04       aku:     }
ae54e928c2 2007-09-17       aku:     return
8469631cc9 2007-09-08       aku: }
8469631cc9 2007-09-08       aku: 
ae54e928c2 2007-09-17       aku: proc ::vc::cvs::ws::Remove {f r} {
ae54e928c2 2007-09-17       aku:     # Remove file from workspace. Prune empty directories.
ae54e928c2 2007-09-17       aku:     # NOTE: A dead-first file (rev 1.1 dead) will never have existed.
df91d389d5 2007-09-04       aku: 
ae54e928c2 2007-09-17       aku:     file delete $f
ae54e928c2 2007-09-17       aku:     Prune [file dirname $f]
ae54e928c2 2007-09-17       aku:     return
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
ae54e928c2 2007-09-17       aku: proc ::vc::cvs::ws::Prune {path} {
ae54e928c2 2007-09-17       aku:     # NOTE: Logically empty directories still physically contain the
ae54e928c2 2007-09-17       aku:     # CVS admin directory, hence the check for == 1, not == 0. There
ae54e928c2 2007-09-17       aku:     # might also be hidden files, we count them as well. Always hidden
ae54e928c2 2007-09-17       aku:     # are . and .. and they do not count as user file.
df91d389d5 2007-09-04       aku: 
ae54e928c2 2007-09-17       aku:     if {
ae54e928c2 2007-09-17       aku: 	([llength [glob -nocomplain -directory              $path *]] == 1) &&
ae54e928c2 2007-09-17       aku: 	([llength [glob -nocomplain -directory -type hidden $path *]] == 2)
ae54e928c2 2007-09-17       aku:     } {
ae54e928c2 2007-09-17       aku: 	file delete -force $path
df91d389d5 2007-09-04       aku:     }
df91d389d5 2007-09-04       aku:     return
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::NSIPL {n singular {plural {}}} {
1593006ef3 2007-09-17       aku:     return "$n [SIPL $n $singular $plural]"
df91d389d5 2007-09-04       aku: }
1593006ef3 2007-09-17       aku: proc ::vc::cvs::ws::SIPL {n singular {plural {}}} {
1593006ef3 2007-09-17       aku:     if {$n == 1} {return $singular}
1593006ef3 2007-09-17       aku:     if {$plural eq ""} {set plural ${singular}s}
1593006ef3 2007-09-17       aku:     return $plural
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
00228d1547 2007-09-13       aku: # -----------------------------------------------------------------------------
00228d1547 2007-09-13       aku: 
1593006ef3 2007-09-17       aku: namespace eval ::vc::cvs::ws {
cbbf9a7575 2007-09-20       aku:     variable base       {} ; # Toplevel repository directory
cbbf9a7575 2007-09-20       aku:     variable project    {} ; # Sub directory to limit the import to.
cbbf9a7575 2007-09-20       aku:     variable workspace  {} ; # Directory to checkout changesets to.
cbbf9a7575 2007-09-20       aku:     variable importable {} ; # List of the csets which can be imported.
be32ebcb41 2007-09-08       aku: 
cbbf9a7575 2007-09-20       aku:     namespace export configure begin done foreach ncsets nimportable checkout
cbbf9a7575 2007-09-20       aku:     namespace export parentOf
df91d389d5 2007-09-04       aku: }
df91d389d5 2007-09-04       aku: 
df91d389d5 2007-09-04       aku: # -----------------------------------------------------------------------------
00228d1547 2007-09-13       aku: # Ready
df91d389d5 2007-09-04       aku: 
00228d1547 2007-09-13       aku: package provide vc::cvs::ws 1.0
df91d389d5 2007-09-04       aku: return