Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [85bd219d0b] - Continued work on pass 6. Completed creation of changeset graph (nodes, dependencies), started on topological iteration and breaking cycles. Basic iteration is complete, fiding a cycle ditto. Not yet done is to actually break a found cycle. Extended the changeset class with the necessary accessor methods (getting cset type, successors, time range). Note: Looking at my code it may be that my decision to save the cset order caused this pass to subsume the RevisionTopologicalSortPass of cvs2svn. Check again when I am done. Note 2: The test case (tcl repository, tcl project) had no cycles. by aku on 2007-11-13 07:22:35. [view]

To:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [94c39d6375] - Completed pass 6, wrote the code performing the breaking of cycles. Done by analysing each triple of changesets in the cycle at the file dependency level to see which revisions can be sorted apart. Added some additional utility routines. Extended the changeset class with the accessors required by the cycle breaker. by aku on 2007-11-14 05:11:56. [view]

@@ -45,8 +45,9 @@
     }
 
     method id        {} { return $myid }
     method revisions {} { return $myrevisions }
+    method data      {} { return [list $myproject $mytype $mysrcid] }
 
     method setid {id} { set myid $id ; return }
 
     method bysymbol   {} { return [expr {$mytype eq "sym"}] }
@@ -53,15 +54,22 @@
     method byrevision {} { return [expr {$mytype eq "rev"}] }
 
     method successors {} {
 	# NOTE / FUTURE: Possible bottleneck.
-	array set dependencies {}
-	PullSuccessorRevisions dependencies $myrevisions
 	set csets {}
-	foreach {_ child} [array get dependencies] {
-	    lappend csets $myrevmap($child)
+	foreach {_ children} [$self nextmap] {
+	    foreach child $children {
+		lappend csets $myrevmap($child)
+	    }
 	}
 	return [lsort -unique $csets]
+    }
+
+    method nextmap {} {
+	if {[llength $mynextmap]} { return $mynextmap }
+	PullSuccessorRevisions tmp $myrevisions
+	set mynextmap [array get tmp]
+	return $mynextmap
     }
 
     method breakinternaldependencies {} {
 	# This method inspects the changesets for internal
@@ -85,9 +93,9 @@
 	# Array of dependencies (parent -> child). This is pulled from
 	# the state, and limited to successors within the changeset.
 
 	array set dependencies {}
-	PullSuccessorRevisions dependencies $myrevisions
+	PullInternalSuccessorRevisions dependencies $myrevisions
 	if {![array size dependencies]} {return 0} ; # Nothing to break.
 
 	log write 6 csets ...<$myid>.......................................................
 
@@ -233,16 +241,38 @@
 	    WHERE R.rid IN $theset
 	"]
     }
 
+    method drop {} {
+	state transaction {
+	    state run {
+		DELETE FROM changeset  WHERE cid = $myid;
+		DELETE FROM csrevision WHERE cid = $myid;
+	    }
+	}
+	foreach r $myrevisions { unset myrevmap($r) }
+	set pos          [lsearch -exact $mychangesets $self]
+	set mychangesets [lreplace $mychangesets $pos $pos]
+	return
+    }
+
     # # ## ### ##### ######## #############
     ## State
 
-    variable myid        ; # Id of the cset for the persistent state.
-    variable myproject   ; # Reference of the project object the changeset belongs to.
-    variable mytype      ; # rev or sym, where the cset originated from.
-    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 myid        {} ; # Id of the cset for the persistent
+			      # state.
+    variable myproject   {} ; # Reference of the project object the
+			      # changeset belongs to.
+    variable mytype      {} ; # rev or sym, where the cset originated
+			      # from.
+    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 mynextmap   {} ; # Dictionary mapping from the revisions
+			      # to their successors. Cache to avoid
+			      # loading this from the state more than
+			      # once.
 
     # # ## ### ##### ######## #############
     ## Internal methods
 
@@ -255,9 +285,9 @@
 	}] { set mycstype($name) $tid }
 	return
     }
 
-    proc PullSuccessorRevisions {dv revisions} {
+    proc PullInternalSuccessorRevisions {dv revisions} {
 	upvar 1 $dv dependencies
 	set theset ('[join $revisions {','}]')
 
 	foreach {rid child} [state run "
@@ -285,9 +315,40 @@
 	    # Consider moving this to the integrity module.
 	    if {$rid == $child} {
 		trouble internal "Revision $rid depends on itself."
 	    }
-	    set dependencies($rid) $child
+	    lappend dependencies($rid) $child
+	}
+    }
+
+    proc PullSuccessorRevisions {dv revisions} {
+	upvar 1 $dv dependencies
+	set theset ('[join $revisions {','}]')
+
+	foreach {rid child} [state run "
+   -- Primary children
+	    SELECT R.rid, R.child
+	    FROM   revision R
+	    WHERE  R.rid   IN $theset
+	    AND    R.child IS NOT NULL
+    UNION
+    -- Transition NTDB to trunk
+	    SELECT R.rid, R.dbchild
+	    FROM   revision R
+	    WHERE  R.rid   IN $theset
+	    AND    R.dbchild IS NOT NULL
+    UNION
+    -- Secondary (branch) children
+	    SELECT R.rid, B.brid
+	    FROM   revision R, revisionbranchchildren B
+	    WHERE  R.rid   IN $theset
+	    AND    R.rid = B.rid
+	"] {
+	    # Consider moving this to the integrity module.
+	    if {$rid == $child} {
+		trouble internal "Revision $rid depends on itself."
+	    }
+	    lappend dependencies($rid) $child
 	}
     }
 
     proc InitializeBreakState {revisions} {
@@ -319,9 +380,9 @@
 	#
 	# Note 2: start == end is not possible. It indicates a
 	#         self-dependency due to the uniqueness of positions,
 	#         and that is something we have ruled out already, see
-	#         PullSuccessorRevisions.
+	#         PullInternalSuccessorRevisions.
 
 	foreach {rid child} [array get dependencies] {
 	    set dkey    [list $rid $child]
 	    set start   $pos($rid)