Differences From:
File
tools/cvs2fossil/lib/c2f_frev.tcl
part of check-in
[da9295c6f6]
- Continued to flesh out revision and symbol processing. Started on the project level classses.
by
aku on
2007-10-12 07:18:27.
[view]
To:
File
tools/cvs2fossil/lib/c2f_frev.tcl
part of check-in
[cb70cf4ad6]
- The basic work of setting up and linking revisions, tags, and branches is complete.
by
aku on
2007-10-13 05:39:00.
[view]
@@ -25,31 +25,96 @@
# # ## ### ##### ######## #############
## Public API
constructor {revnr date author state thefile} {
- set myrevnr $revnr
- set mydate $date
- set myauthor $author
- set mystate $state
- set myfile $thefile
+ set myrevnr $revnr
+ set mydate $date
+ set myorigdate $date
+ set myauthor $author
+ set mystate $state
+ set myfile $thefile
return
}
+
+ # Basic pieces ________________________
method hascommitmsg {} { return $myhascm }
- method setcommitmsg {cm} {
- set mycommitmsg $cm
- set myhascm 1
+ method setcommitmsg {cm} { set mycommitmsg $cm ; set myhascm 1 ; return }
+ method settext {text} { set mytext $text ; return }
+ method setbranchname {name} { set mybranchname $name ; return }
+
+ method revnr {} { return $myrevnr }
+
+ # Basic parent/child linkage __________
+
+ method hasparent {} { return [expr {$myparent ne ""}] }
+ method haschild {} { return [expr {$mychild ne ""}] }
+
+ method setparent {parent} {
+ if {$myparent ne ""} { trouble internal "Parent already defined" }
+ set myparent $parent
+ return
+ }
+
+ method setchild {child} {
+ if {$mychild ne ""} { trouble internal "Child already defined" }
+ set mychild $child
+ return
+ }
+
+ method parent {} { return $myparent }
+ method child {} { return $mychild }
+
+ # Branch linkage ______________________
+
+ method setparentbranch {branch} {
+ if {$myparentbranch ne ""} { trouble internal "Branch parent already defined" }
+ set myparentbranch $branch
+ return
+ }
+
+ method addbranch {branch} {
+ lappend mybranches $branch
+ #sorted in ascending order by branch number?
+ return
+ }
+
+ method addchildonbranch {child} {
+ lappend mybranchchildren $child
return
}
- method settext {text} {
- set mytext $text
+ # Tag linkage _________________________
+
+ method addtag {tag} {
+ lappend mytags $tag
return
}
- method setbranch {branchnr} {
- set mybranchnr $branchnr
+ method sortbranches {} {
+ if {![llength $mybranches]} return
+
+ # Sort the branches spawned by this revision in creation
+ # order. To help in this our file gave all branches a position
+ # id, in order of their definition by the RCS archive.
+ #
+ # The creation order is (apparently) the reverse of the
+ # definition order. (If a branch is created then deleted, a
+ # later branch can be assigned the recycled branch number;
+ # therefore branch numbers are not an indication of creation
+ # order.)
+
+ set tmp {}
+ foreach branch $mybranches {
+ lappend tmp [list $branch [$branch position]]
+ }
+
+ set mybranches {}
+ foreach item [lsort -index 1 -decreasing $tmp] {
+ struct::list assign $item -> branch position
+ lappend mybranches $branch
+ }
return
}
# # ## ### ##### ######## #############
@@ -56,8 +121,17 @@
## Type API
typemethod istrunkrevnr {revnr} {
return [expr {[llength [split $revnr .]] == 2}]
+ }
+
+ typemethod isbranchrevnr {revnr _ bv} {
+ if {[regexp $mybranchpattern $revnr -> head tail]} {
+ upvar 1 $bv branchnr
+ set branchnr ${head}$tail
+ return 1
+ }
+ return 0
}
typemethod 2branchnr {revnr} {
# Input is a branch revision number, i.e. a revision number
@@ -71,15 +145,11 @@
}
return [join [lrange [split $revnr .] 0 end-1] .]
}
- typemethod isbranchrevnr {revnr _ bv} {
- if {[regexp $mybranchpattern $revnr -> head tail]} {
- upvar 1 $bv branchnr
- set branchnr ${head}$tail
- return 1
- }
- return 0
+ typemethod 2branchparentrevnr {branchnr} {
+ # Chop the last segment off
+ return [join [lrange [split $branchnr .] 0 end-1] .]
}
# # ## ### ##### ######## #############
## State
@@ -90,8 +160,9 @@
# And the last digit group.
variable myrevnr {} ; # Revision number of the revision.
variable mydate {} ; # Timestamp of the revision, seconds since epoch
+ variable myorigdate {} ; # Original unmodified timestamp.
variable mystate {} ; # State of the revision.
variable myfile {} ; # Ref to the file object the revision belongs to.
variable myhascm 0 ; # Bool flag, set when the commit msg was set.
variable mytext {} ; # Range of the (delta) text for this revision in the file.
@@ -99,11 +170,49 @@
# The meta data block used later to group revisions into changesets.
# The project name factors into this as well, but is not stored
# here. The name is acessible via myfile's project.
- variable myauthor {} ; # Name of the user who committed the revision.
- variable mycommitmsg {} ; # The message entered as part of the commit.
- variable mybranchnr {} ; # The number of the branch the commit was done on.
+ variable myauthor {} ; # Name of the user who committed the revision.
+ variable mycommitmsg {} ; # The message entered as part of the commit.
+ variable mybranchname {} ; # The name of the branch the revision was committed on.
+
+ # Basic parent/child linkage (lines of development)
+
+ variable myparent {} ; # Ref to parent revision object. Link required because of
+ # ; # 'cvsadmin -o', which can create arbitrary gaps in the
+ # ; # numbering sequence. This is in the same line of development
+ # ; # Note: For the first revision on a branch the revision
+ # ; # it was spawned from is the parent. Only the root revision
+ # ; # of myfile's revision tree has nothing set here.
+ # ; #
+
+ variable mychild {} ; # Ref to the primary child revision object, i.e. the next
+ # ; # revision in the same line of development.
+
+ # Branch linkage ____________________
+
+ variable mybranches {} ; # List of the branches (objs) spawned by this revision.
+ variable myparentbranch {} ; # For the first revision on a branch the relevant
+ # ; # branch object. This also allows us to determine if
+ # ; # myparent is in the same LOD, or the revision the
+ # ; # branch spawned from.
+
+ # List of the revision objects of the first commits on any
+ # branches spawned by this revision on which commits occurred.
+ # This dependency is kept explicitly because otherwise a
+ # revision-only topological sort would miss the dependency that
+ # exists via -> mybranches.
+
+ variable mybranchchildren {} ; # List of the revisions (objs) which are the first
+ # ; # commits on any of the branches spawned from this
+ # ; # revision. The dependency is kept explicitly to
+ # ; # ensure that a revision-only topological sort will
+ # ; # not miss it, as it otherwise exists only via
+ # ; # mybranches.
+
+ # Tag linkage ________________________
+
+ variable mytags {} ; # List of tags (objs) associated with this revision.
# # ## ### ##### ######## #############
## Internal methods