Differences From:
File
tools/cvs2fossil/lib/c2f_frev.tcl
part of check-in
[e5441b908d]
- Continued work on pass II, starting to post-process tags, branches, and revisions, cleaning up cvs quirks, determining higher-level aggregates ...
by
aku on
2007-10-15 00:03:30.
[view]
To:
File
tools/cvs2fossil/lib/c2f_frev.tcl
part of check-in
[177a0cc55c]
- Fix setting of myimported, wrong condition.
Fix item assignment when sorting branches.
Fix parent/child linkage when setting up branch dependencies.
Completed processes on non-trunk default branch revisions.
Added skeleton code for the deletion of superfluous revisions.
by
aku on
2007-10-17 03:15:12.
[view]
@@ -16,8 +16,9 @@
## Requirements
package require Tcl 8.4 ; # Required runtime.
package require snit ; # OO system.
+package require vc::tools::misc ; # Text formatting
# # ## ### ##### ######## ############# #####################
##
@@ -35,16 +36,22 @@
}
# Basic pieces ________________________
- method hasmeta {} { return [expr {$mymetaid ne ""}] }
+ method hasmeta {} { return [expr {$mymetaid ne ""}] }
+ method hastext {} {
+ struct::list assign $mytext s e
+ return [expr {$s <= $e}]
+ }
+
method setmeta {meta} { set mymetaid $meta ; return }
method settext {text} { set mytext $text ; return }
method setlod {lod} { set mylod $lod ; return }
method revnr {} { return $myrevnr }
method state {} { return $mystate }
method lod {} { return $mylod }
+ method date {} { return $mydate }
# Basic parent/child linkage __________
method hasparent {} { return [expr {$myparent ne ""}] }
@@ -54,8 +61,11 @@
if {$myparent ne ""} { trouble internal "Parent already defined" }
set myparent $parent
return
}
+
+ method cutfromparent {} { set myparent "" ; return }
+ method cutfromchild {} { set mychild "" ; return }
method setchild {child} {
if {$mychild ne ""} { trouble internal "Child already defined" }
set mychild $child
@@ -72,11 +82,12 @@
set myparentbranch $branch
return
}
+ method parentbranch {} { return $myparentbranch }
+
method addbranch {branch} {
lappend mybranches $branch
- #sorted in ascending order by branch number?
return
}
method addchildonbranch {child} {
@@ -83,12 +94,17 @@
lappend mybranchchildren $child
return
}
- # Tag linkage _________________________
-
- method addtag {tag} {
- lappend mytags $tag
+ method cutfromparentbranch {} { set myparentbranch "" ; return }
+
+ method removebranch {branch} {
+ ldelete mybranches $branch
+ return
+ }
+
+ method removechildonbranch {rev} {
+ ldelete mybranchchildren $rev
return
}
method sortbranches {} {
@@ -110,13 +126,61 @@
}
set mybranches {}
foreach item [lsort -index 1 -decreasing $tmp] {
- struct::list assign $item -> branch position
+ struct::list assign $item branch position
lappend mybranches $branch
}
return
}
+
+ method movebranchesto {rev} {
+ set revlod [$rev lod]
+ foreach branch $mybranches {
+ $rev addbranch $branch
+ $branch setparent $rev
+ $branch setlod $revlod
+ }
+ foreach branchrev $mybranchchildren {
+ $rev addchildonbranch $branchrev
+ $branchrev cutfromparent
+ $branchrev setparent $rev
+ }
+ set mybranches {}
+ set mybranchchildren {}
+ return
+ }
+
+ # Tag linkage _________________________
+
+ method addtag {tag} {
+ lappend mytags $tag
+ return
+ }
+
+ method movetagsto {rev} {
+ set revlod [$rev lod]
+ foreach tag $mytags {
+ $rev addtag $tag
+ $tag settagrev $rev
+ $tag setlod $revlod
+ }
+ set mytags {}
+ return
+ }
+
+ # general symbol operations ___________
+
+ method movesymbolsto {rev} {
+ # Move the tags and branches attached to this revision to the
+ # destination and fix all pointers.
+
+ $self movetagsto $rev
+ $self movebranchesto $rev
+ return
+ }
+
+ # Derived stuff _______________________
method determineoperation {} {
# Look at the state of both this revision and its parent to
# determine the type opf operation which was performed (add,
@@ -127,8 +191,25 @@
set sdead [expr {$mystate eq "dead"}]
set pdead [expr {$myparent eq "" || [$myparent state] eq "dead"}]
+ set myoperation $myopstate([list $pdead $sdead])
+ return
+ }
+
+ method operation {} { return $myoperation }
+ method retype {x} { set myoperation $x ; return }
+
+ method isondefaultbranch {} { set myisondefaultbranch 1 ; return }
+
+ method setdefaultbranchchild {rev} { set mydbchild $rev ; return }
+ method setdefaultbranchparent {rev} {
+ set mydbparent $rev
+
+ # Retype the revision (may change from 'add' to 'change').
+
+ set sdead [expr {$myoperation ne "change"}]
+ set pdead [expr {[$rev operation] ne "change"}]
set myoperation $myopstate([list $pdead $sdead])
return
}
@@ -235,11 +316,23 @@
variable mytags {} ; # List of tags (objs) associated with this revision.
# More derived data
- variable myoperation {} ; # One of 'add', 'change', 'delete', or
- # 'nothing'. Derived from our and its
- # parent's state.
+ variable myoperation {} ; # One of 'add', 'change', 'delete', or
+ # 'nothing'. Derived from our and
+ # its parent's state.
+ variable myisondefaultbranch 0 ; # Boolean flag, set if the
+ # revision is on the non-trunk
+ # default branch, aka vendor
+ # branch.
+ variable mydbparent {} ; # Reference to the last revision
+ # on the vendor branch if this is
+ # the primary child of the
+ # regular root.
+ variable mydbchild {} ; # Reference to the primary child
+ # of the regular root if this is
+ # the last revision on the vendor
+ # branch.
# dead(self) x dead(parent) -> operation
typevariable myopstate -array {
{0 0} change
@@ -262,11 +355,14 @@
}
namespace eval ::vc::fossil::import::cvs::file {
namespace export rev
+ namespace eval rev {
+ namespace import ::vc::tools::misc::*
+ }
}
# # ## ### ##### ######## ############# #####################
## Ready
package provide vc::fossil::import::cvs::file::rev 1.0
return