Check-in [8c9030e3e8]
Not logged in
Overview

SHA1 Hash:8c9030e3e8a69da37e09851baeccf04a1e965524
Date: 2007-11-24 04:29:30
User: aku
Comment:Bugfix in the changeset class. The index from revisions to containing changesets is not 1:1, but 1:n. While only one revision changeset is possible there can also be zero or more symbol changesets.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified tools/cvs2fossil/lib/c2f_prev.tcl from [3c9d1e003d] to [d3b49cf4d5].

@@ -46,11 +46,11 @@
 
 	# Keep track of the generated changesets and of the inverse
 	# mapping from revisions to them.
 	lappend mychangesets   $self
 	set     myidmap($myid) $self
-	foreach r $revisions { set myrevmap($r) $self }
+	foreach r $revisions { lappend myrevmap($r) $self }
 	return
     }
 
     method id        {} { return $myid }
     method revisions {} { return $myrevisions }
@@ -67,16 +67,20 @@
 		      ($mybranchcode == [state one {
 			  SELECT type FROM symbol WHERE sid = $mysrcid
 		      }])}]
     }
 
+    # result = dict (revision -> list (changeset))
     method successormap {} {
 	# NOTE / FUTURE: Possible bottleneck.
 	array set tmp {}
 	foreach {rev children} [$self nextmap] {
 	    foreach child $children {
-		lappend tmp($rev) $myrevmap($child)
+		# 8.5 lappend tmp($rev) {*}$myrevmap($child)
+		foreach cset $myrevmap($child) {
+		    lappend tmp($rev) $cset
+		}
 	    }
 	    set tmp($rev) [lsort -unique $tmp($rev)]
 	}
 	return [array get tmp]
     }
@@ -84,22 +88,29 @@
     method successors {} {
 	# NOTE / FUTURE: Possible bottleneck.
 	set csets {}
 	foreach {_ children} [$self nextmap] {
 	    foreach child $children {
-		lappend csets $myrevmap($child)
+		# 8.5 lappend csets {*}$myrevmap($child)
+		foreach cset $myrevmap($child) {
+		    lappend csets $cset
+		}
 	    }
 	}
 	return [lsort -unique $csets]
     }
 
+    # result = dict (revision -> list (changeset))
     method predecessormap {} {
 	# NOTE / FUTURE: Possible bottleneck.
 	array set tmp {}
 	foreach {rev children} [$self premap] {
 	    foreach child $children {
-		lappend tmp($rev) $myrevmap($child)
+		# 8.5 lappend tmp($rev) {*}$myrevmap($child)
+		foreach cset $myrevmap($child) {
+		    lappend tmp($rev) $cset
+		}
 	    }
 	    set tmp($rev) [lsort -unique $tmp($rev)]
 	}
 	return [array get tmp]
     }
@@ -296,11 +307,18 @@
 	    state run {
 		DELETE FROM changeset  WHERE cid = $myid;
 		DELETE FROM csrevision WHERE cid = $myid;
 	    }
 	}
-	foreach r $myrevisions { unset myrevmap($r) }
+	foreach r $myrevisions {
+	    if {[llength $myrevmap($r)] == 1} {
+		unset myrevmap($r)
+	    } else {
+		set pos [lsearch -exact $myrevmap($r) $self]
+		set myrevmap($r) [lreplace $myrevmap($r) $pos $pos]
+	    }
+	}
 	set pos          [lsearch -exact $mychangesets $self]
 	set mychangesets [lreplace $mychangesets $pos $pos]
 	return
     }
 
@@ -670,11 +688,18 @@
     }
 
     # # ## ### ##### ######## #############
 
     typevariable mychangesets    {} ; # List of all known changesets.
-    typevariable myrevmap -array {} ; # Map from revisions to their changeset.
+    typevariable myrevmap -array {} ; # Map from revisions to the list
+				      # of changesets containing
+				      # it. NOTE: While only one
+				      # revision changeset can contain
+				      # the revision, there can
+				      # however also be one or more
+				      # additional symbol changesets
+				      # which use it, hence a list.
     typevariable myidmap  -array {} ; # Map from changeset id to changeset.
     typevariable mybranchcode    {} ; # Local copy of project::sym/mybranch.
 
     typemethod all   {}   { return $mychangesets }
     typemethod of    {id} { return $myidmap($id) }