Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_pbreakacycle.tcl part of check-in [de4cff4142] - Extended changeset class with in-memory database mapping from changeset ids to the proper object, and extended the objects with position information and associated accessors. Extended pass 8 to load the commit order computed in pass 6, this is stored in the new position slot of changesets, and an inverted index mapping from position to changeset at that position. by aku on 2007-11-22 03:21:43. [view]

To:

File tools/cvs2fossil/lib/c2f_pbreakacycle.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]

@@ -21,9 +21,11 @@
 
 package require Tcl 8.4                                   ; # Required runtime.
 package require snit                                      ; # OO system.
 package require struct::list                              ; # Higher order list operations.
+package require vc::tools::misc                           ; # Min, max.
 package require vc::tools::log                            ; # User feedback.
+package require vc::tools::trouble                        ; # Error reporting.
 package require vc::fossil::import::cvs::repository       ; # Repository management.
 package require vc::fossil::import::cvs::cyclebreaker     ; # Breaking dependency cycles.
 package require vc::fossil::import::cvs::state            ; # State storage.
 package require vc::fossil::import::cvs::project::rev     ; # Project level changesets
@@ -106,8 +108,41 @@
 
     # # ## ### ##### ######## #############
 
     proc BreakRetrogradeBranches {graph} {
+	# We go over all branch changesets, i.e. the changesets
+	# created by the symbols which are translated as branches, and
+	# break any which are 'retrograde'. Meaning that they have
+	# incoming revision changesets which are committed after some
+	# outgoing revision changeset.
+
+	# NOTE: We might be able to use our knowledge that we are
+	# looking at all changesets to create a sql which selects all
+	# the branch changesets from the state in one go instead of
+	# having to check each changeset separately. Consider this
+	# later, get the pass working first.
+	#
+	# NOTE 2: Might we even be able to select the retrograde
+	# changesets too ?
+
+	foreach cset [$graph nodes] {
+	    if {![$cset isbranch]} continue
+	    CheckAndBreakRetrograde $graph $cset
+	}
+	return
+    }
+
+    proc CheckAndBreakRetrograde {graph cset} {
+	while {[IsRetrograde $graph $cset]} {
+	    log write 5 breakacycle "Breaking retrograde changeset <[$cset id]>"
+
+	    break
+	}
+	return
+    }
+
+    proc IsRetrograde {dg cset} {
+	return 0
     }
 
     # # ## ### ##### ######## #############
 
@@ -144,8 +179,10 @@
 	namespace import ::vc::fossil::import::cvs::state
 	namespace eval project {
 	    namespace import ::vc::fossil::import::cvs::project::rev
 	}
+	namespace import ::vc::tools::misc::*
+	namespace import ::vc::tools::trouble
 	namespace import ::vc::tools::log
 	log register breakacycle
     }
 }