Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [4866889e88] - Continued work on pass 8, added outline for handling of retrograde branches, extended changesets with predicate allowing us to find the branch changesets. by aku on 2007-11-22 03:33:32. [view]

To:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [e50f9ed55e] - Continued work on pass 8. Completed the handling of backward branches, file level analysis and splitting them. Extended changesets with the necessary methods to the predecessor data and proper per-revision maps. by aku on 2007-11-22 04:21:37. [view]

@@ -68,8 +68,20 @@
 			  SELECT type FROM symbol WHERE sid = $mysrcid
 		      }])}]
     }
 
+    method successormap {} {
+	# NOTE / FUTURE: Possible bottleneck.
+	array set tmp {}
+	foreach {rev children} [$self nextmap] {
+	    foreach child $children {
+		lappend tmp($rev) $myrevmap($child)
+	    }
+	    set tmp($rev) [lsort -unique $tmp($rev)]
+	}
+	return [array get tmp]
+    }
+
     method successors {} {
 	# NOTE / FUTURE: Possible bottleneck.
 	set csets {}
 	foreach {_ children} [$self nextmap] {
@@ -79,14 +91,34 @@
 	}
 	return [lsort -unique $csets]
     }
 
+    method predecessormap {} {
+	# NOTE / FUTURE: Possible bottleneck.
+	array set tmp {}
+	foreach {rev children} [$self premap] {
+	    foreach child $children {
+		lappend tmp($rev) $myrevmap($child)
+	    }
+	    set tmp($rev) [lsort -unique $tmp($rev)]
+	}
+	return [array get tmp]
+    }
+
     # revision -> list (revision)
     method nextmap {} {
 	if {[llength $mynextmap]} { return $mynextmap }
 	PullSuccessorRevisions tmp $myrevisions
 	set mynextmap [array get tmp]
 	return $mynextmap
+    }
+
+    # revision -> list (revision)
+    method premap {} {
+	if {[llength $mypremap]} { return $mypremap }
+	PullPredecessorRevisions tmp $myrevisions
+	set mypremap [array get tmp]
+	return $mypremap
     }
 
     method breakinternaldependencies {} {
 	# This method inspects the changesets for internal
@@ -304,8 +336,12 @@
     variable mysrcid     {} ; # Id of the metadata or symbol the cset
 			      # is based on.
     variable myrevisions {} ; # List of the file level revisions in
 			      # the cset.
+    variable mypremap    {} ; # Dictionary mapping from the revisions
+			      # to their predecessors. Cache to avoid
+			      # loading this from the state more than
+			      # once.
     variable mynextmap   {} ; # Dictionary mapping from the revisions
 			      # to their successors. Cache to avoid
 			      # loading this from the state more than
 			      # once.
@@ -392,8 +428,33 @@
 	    if {$rid == $child} {
 		trouble internal "Revision $rid depends on itself."
 	    }
 	    lappend dependencies($rid) $child
+	}
+    }
+
+    proc PullPredecessorRevisions {dv revisions} {
+	upvar 1 $dv dependencies
+	set theset ('[join $revisions {','}]')
+
+	foreach {rid parent} [state run "
+   -- Primary parent, can be in different LOD for first in a branch
+	    SELECT R.rid, R.parent
+	    FROM   revision R
+	    WHERE  R.rid   IN $theset
+	    AND    R.parent IS NOT NULL
+    UNION
+    -- Transition trunk to NTDB
+	    SELECT R.rid, R.dbparent
+	    FROM   revision R
+	    WHERE  R.rid   IN $theset
+	    AND    R.dbparent IS NOT NULL
+	"] {
+	    # Consider moving this to the integrity module.
+	    if {$rid == $parent} {
+		trouble internal "Revision $rid depends on itself."
+	    }
+	    lappend dependencies($rid) $parent
 	}
     }
 
     proc InitializeBreakState {revisions} {
@@ -609,10 +670,11 @@
     typevariable myrevmap -array {} ; # Map from revisions to their changeset.
     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) }
+    typemethod all   {}   { return $mychangesets }
+    typemethod of    {id} { return $myidmap($id) }
+    typemethod ofrev {id} { return $myrevmap($id) }
 
     typeconstructor {
 	set mybranchcode [project::sym branch]
 	return