Overview
SHA1 Hash: | cbbf9a7575ae82dec05c2e5dda09d79e7c48f9b0 |
---|---|
Date: | 2007-09-20 07:14:44 |
User: | aku |
Comment: | Got rid of the explicit revision tree and rephrased the trunk processing to use a loop which is more self-explanatory. Started to add in code needed when we process the branches as well, currently they will have now effect. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified tools/lib/cvs.tcl from [9bc6bc7e05] to [1e095fdc74].
@@ -11,11 +11,10 @@ package require vc::tools::trouble ; # Error handling package require vc::cvs::cmd ; # Access to cvs application. package require vc::cvs::ws::files ; # Scan CVS repository for relevant files. package require vc::cvs::ws::timeline ; # Manage timeline of all changes. package require vc::cvs::ws::csets ; # Manage the changesets found in the timeline -package require struct::tree namespace eval ::vc::cvs::ws { vc::tools::log::system cvs namespace import ::vc::tools::log::write namespace import ::vc::rcs::parser::process @@ -29,17 +28,19 @@ # vc::cvs::ws::configure key value - Configure the subsystem. # vc::cvs::ws::check src mv - Check if src is a CVS repository directory. # vc::cvs::ws::begin src - Start new workspace and return the top- # most directory co'd files are put into. -# vc::cvs::ws::ncsets ?-import? - Retrieve number of csets (all/to import) +# vc::cvs::ws::ncsets - Retrieve total number of csets +# vc::cvs::ws::nimportable - Retrieve number of importable csets # vc::cvs::ws::foreach csvar script - Run the script for each changeset, the # id of the current changeset stored in # the variable named by csvar. # vc::cvs::ws::done - Close workspace and delete it. # vc::cvs::ws::isadmin path - Check if path is an admin file of CVS # vc::cvs::ws::checkout id - Have workspace contain the changeset id. +# vc::cvs::ws::get id - Retrieve data of a changeset. # # Configuration keys: # # -project path - Sub directory under 'src' to limit the import to. @@ -77,13 +78,11 @@ if {![check $src msg]} { return -code error $msg } DefBase $src MakeTimeline [ScanArchives [files::find [RootPath]]] MakeChangesets - - # OLD api calls ... TODO rework for more structure ... - rtree ; # Build revision tree (trunk only right now). + ProcessBranches return [MakeWorkspace] } proc ::vc::cvs::ws::done {} { @@ -91,41 +90,54 @@ file delete -force $workspace return } proc ::vc::cvs::ws::foreach {cv script} { - # OLD api ... TODO inline - uplevel 1 [list ::vc::cvs::ws::foreach_cset $cv 0 $script] + variable importable + upvar 1 $cv c + + ::foreach c [lsort -integer -increasing $importable] { + set code [catch {uplevel 1 $script} res] + + # 0 - ok, 1 - error, 2 - return, 3 - break, 4 - continue + switch -- $code { + 0 {} + 1 { return -errorcode $::errorCode -errorinfo $::errorInfo -code error $res } + 2 {} + 3 { return } + 4 {} + default { return -code $code $result } + } + } + return } proc ::vc::cvs::ws::ncsets {args} { - variable ntrunk - - if {[llength $args] > 1} { - return -code error "wrong#args: Expected ?-import?" - } elseif {[llength $args] == 1} { - if {[set k [lindex $args 0]] ne "-import"} { - return -code "Unknown switch $k, expected -import" - } else { - return $ntrunk - } - } - return [csets::num] +} + +proc ::vc::cvs::ws::nimportable {args} { + variable importable + return [llength $importable] } proc ::vc::cvs::ws::isadmin {path} { # Check if path is a CVS admin file. if {[string match CVS/* $path]} {return 1} if {[string match */CVS/* $path]} {return 1} return 0 } +proc ::vc::cvs::ws::parentOf {id} { csets::parentOf $id } + proc ::vc::cvs::ws::checkout {id} { variable workspace cd $workspace + # TODO: Hide the direct access to the data structures behind + # TODO: accessors for date, cmsg, removed, added, changed, and + # TODO: author array set cs [csets::get $id] write 1 cvs "@ $cs(date)" ::foreach l [split [string trim $cs(cmsg)] \n] { write 1 cvs "| $l" @@ -264,81 +276,52 @@ # Building the revision tree from the changesets. # Limitation: Currently only trunk csets is handled. # Limitation: Dead files are not removed, i.e. no 'R' actions right now. -proc ::vc::cvs::ws::rtree {} { - variable rtree {} - variable ntrunk 0 - - write 0 cvs "Extracting the trunk" - - set rtree [struct::tree ::vc::cvs::ws::RT] - $rtree rename root 0 ; # Root is first changeset, always. - set trunk 0 - set ntrunk 1 ; # Root is on the trunk. - set b 0 ; # No branch csets found yet. - - # Extracting the trunk is easy, simply by looking at the involved - # version numbers. - - for {set c 1} {$c < [csets::num]} {incr c} { - array set cs [csets::get $c] - # Ignore branch changes, just count them for the statistics. - if {$cs(lastd) != 2} { - incr b - continue - } - - # Trunk revision, connect to, and update the head. - $rtree insert $trunk end $c - set trunk $c - incr ntrunk - } - - write 0 cvs "Processed $ntrunk trunk [expr {($ntrunk == 1) ? "changeset" : "changesets"}]" - write 0 cvs "Ignored $b branch [expr {($b == 1) ? "changeset" : "changesets"}]" +proc ::vc::cvs::ws::ProcessBranches {} { + variable importable + + write 0 cvs "Organizing the changesets into branches" + + set remainder [ProcessTrunk] + # TODO: Processing non-trunk branches + + + # Status information ... + set nr [llength $remainder] + set ni [llength $importable] + set fmt %[string length [csets::num]]s + + write 0 cvs "Unprocessed: [format $fmt $nr] [SIPL $nr changeset] (Will be ignored)" + write 0 cvs "To import: [format $fmt $ni] [SIPL $ni changeset]" return } -namespace eval ::vc::cvs::ws { - # Tree holding trunk and branch information (struct::tree). - # Node names are cset id's. - - variable rtree {} - variable ntrunk 0 -} - -proc ::vc::cvs::ws::foreach_cset {cv node script} { - upvar 1 $cv c - variable rtree - - set c $node - while {1} { - set code [catch {uplevel 1 $script} res] - - # 0 - ok, 1 - error, 2 - return, 3 - break, 4 - continue - switch -- $code { - 0 {} - 1 { return -errorcode $::errorCode -errorinfo $::errorInfo -code error $res } - 2 {} - 3 { return } - 4 {} - default { - return -code $code $result - } +proc ::vc::cvs::ws::ProcessTrunk {} { + variable importable + + write 0 cvs "Processing the trunk changesets" + + set remainder {} + set t 0 + set n [csets::num] + set parent {} + + for {set c 0} {$c < $n} {incr c} { + if {[csets::isTrunk $c]} { + csets::setParentOf $c $parent + set parent $c + incr t + lappend importable $c + } else { + lappend remainder $c } - - # Stop on reaching the head. - if {![llength [$rtree children $c]]} break - - #puts <[$rtree children $c]> - - # Go to next child in trunk (leftmost). - set c [lindex [$rtree children $c] 0] } - return + + write 0 cvs "Found [NSIPL $t {trunk changeset}], [NSIPL [llength $remainder] {branch changeset}]" + return $remainder } proc ::vc::cvs::ws::Checkout {f r} { variable base variable project @@ -401,17 +384,19 @@ } # ----------------------------------------------------------------------------- namespace eval ::vc::cvs::ws { - variable base {} ; # Toplevel repository directory - variable project {} ; # Sub directory to limit the import to. - variable workspace {} ; # Directory to checkout changesets to. + variable base {} ; # Toplevel repository directory + variable project {} ; # Sub directory to limit the import to. + variable workspace {} ; # Directory to checkout changesets to. + variable importable {} ; # List of the csets which can be imported. - namespace export configure begin done foreach ncsets checkout + namespace export configure begin done foreach ncsets nimportable checkout + namespace export parentOf } # ----------------------------------------------------------------------------- # Ready package provide vc::cvs::ws 1.0 return
Modified tools/lib/cvs_csets.tcl from [4cf480aa53] to [2d31db2fdf].
@@ -20,10 +20,11 @@ # ----------------------------------------------------------------------------- # API Implementation proc ::vc::cvs::ws::csets::init {} { + variable ncs 0 Current::Clear return } proc ::vc::cvs::ws::csets::add {date file revision operation author cmsg} { @@ -47,10 +48,28 @@ } proc ::vc::cvs::ws::csets::num {} { variable csets return [array size csets] +} + +proc ::vc::cvs::ws::csets::isTrunk {id} { + variable csets + array set cs $csets($id) + return [expr {$cs(lastd) == 2}] +} + +proc ::vc::cvs::ws::csets::setParentOf {id parent} { + variable csets + lappend csets($id) parent $parent + return +} + +proc ::vc::cvs::ws::csets::parentOf {id} { + variable csets + array set cs $csets($id) + return $cs(parent) } # ----------------------------------------------------------------------------- # Internal helper commands: Changeset inspection and construction. @@ -196,13 +215,13 @@ variable changed {} ; # file -> revision of modified files. variable files array set files {} ; # file -> revision } - namespace export init add done get num + namespace export init add done get num isTrunk setParentOf parentOf } # ----------------------------------------------------------------------------- # Ready package provide vc::cvs::ws::csets 1.0 return
Modified tools/lib/fossil.tcl from [a6c49a2ab2] to [6aae29bf14].
@@ -19,10 +19,11 @@ # API # vc::fossil::ws::configure key value - Configure the subsystem. # vc::fossil::ws::begin src - Start new workspace for directory # vc::fossil::ws::done dst - Close workspace and copy to destination. +# vc::fossil::ws::setup uuid - Move workspace to an older revision. # vc::fossil::ws::commit cset usr time msg - Look for changes and commit as new revision. # Configuration keys: # # -nosign bool default 0 (= sign imported changesets) @@ -78,10 +79,19 @@ proc ::vc::fossil::ws::done {destination} { variable rp file rename -force $rp $destination set rp {} + return +} + +proc ::vc::fossil::ws::setup {uuid} { + variable lastuuid + if {$uuid eq $lastuuid} return + write 1 fossil "=> goto $uuid" + dova update $uuid + set lastuuid $uuid return } proc ::vc::fossil::ws::commit {cset user timestamp message} { variable lastuuid @@ -209,13 +219,13 @@ variable base {} ; # Workspace directory variable rp {} ; # Repository the package works on. variable lastuuid {} ; # Uuid of last imported changeset. - namespace export configure begin done commit + namespace export configure begin done setup commit } # ----------------------------------------------------------------------------- # Ready package provide vc::fossil::ws 1.0 return
Modified tools/lib/importcvs.tcl from [8476a3bcc6] to [d5f1e97a32].
@@ -60,18 +60,18 @@ # Import the CVS repository found at directory 'src' into the new # fossil repository at 'dst'. proc ::vc::fossil::import::cvs::run {src dst} { - #B map::set {} {} + map::set {} {} set src [file normalize $src] set dst [file normalize $dst] set ws [cvs::begin $src] fossil::begin $ws - stats::setup [cvs::ncsets -import] [cvs::ncsets] + stats::setup [cvs::nimportable] [cvs::ncsets] cvs::foreach cset { Import1 $cset } @@ -95,11 +95,11 @@ stats::csend $seconds return } proc ::vc::fossil::import::cvs::ImportCS {cset} { - #B fossil::setup [map::get [cvs::parentOf $cset]] + fossil::setup [map::get [cvs::parentOf $cset]] lassign [cvs::checkout $cset] user timestamp message lassign [fossil::commit $cset $user $timestamp $message] uuid ad rm ch write 2 import "== +${ad}-${rm}*${ch}" map::set $cset $uuid return