Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [eabaea870a] - Added a number of assertions and must-not-happens with associated log output. Plus some small tweaks, and notes. by aku on 2007-11-24 04:15:46. [view]

To:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [8c9030e3e8] - 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. by aku on 2007-11-24 04:29:30. [view]

@@ -47,9 +47,9 @@
 	# 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 }
@@ -68,14 +68,18 @@
 			  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]
@@ -85,20 +89,27 @@
 	# 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]
@@ -297,9 +308,16 @@
 		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
     }
@@ -671,9 +689,16 @@
 
     # # ## ### ##### ######## #############
 
     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 }