File Annotation
Not logged in
e7c805f137 2007-11-16       aku: ## -*- tcl -*-
e7c805f137 2007-11-16       aku: # # ## ### ##### ######## ############# #####################
e7c805f137 2007-11-16       aku: ## Copyright (c) 2007 Andreas Kupries.
e7c805f137 2007-11-16       aku: #
e7c805f137 2007-11-16       aku: # This software is licensed as described in the file LICENSE, which
e7c805f137 2007-11-16       aku: # you should have received as part of this distribution.
e7c805f137 2007-11-16       aku: #
e7c805f137 2007-11-16       aku: # This software consists of voluntary contributions made by many
e7c805f137 2007-11-16       aku: # individuals.  For exact contribution history, see the revision
e7c805f137 2007-11-16       aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil
e7c805f137 2007-11-16       aku: # # ## ### ##### ######## ############# #####################
e7c805f137 2007-11-16       aku: 
d743f04bd2 2007-11-25       aku: ## Pass IX. This is the final pass for breaking changeset dependency
d743f04bd2 2007-11-25       aku: ## cycles. The previous breaker passes (6 and 8) broke cycles covering
d743f04bd2 2007-11-25       aku: ## revision and symbol changesets, respectively. This pass now breaks
d743f04bd2 2007-11-25       aku: ## any remaining cycles, each of which has to contain at least one
d743f04bd2 2007-11-25       aku: ## revision and at least one symbol changeset.
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: # # ## ### ##### ######## ############# #####################
e7c805f137 2007-11-16       aku: ## Requirements
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: package require Tcl 8.4                                   ; # Required runtime.
e7c805f137 2007-11-16       aku: package require snit                                      ; # OO system.
e7c805f137 2007-11-16       aku: package require struct::list                              ; # Higher order list operations.
1ea319fb67 2007-11-25       aku: package require struct::set                               ; # Set operations.
4866889e88 2007-11-22       aku: package require vc::tools::misc                           ; # Min, max.
e7c805f137 2007-11-16       aku: package require vc::tools::log                            ; # User feedback.
4866889e88 2007-11-22       aku: package require vc::tools::trouble                        ; # Error reporting.
1f60018119 2007-11-21       aku: package require vc::fossil::import::cvs::repository       ; # Repository management.
e7c805f137 2007-11-16       aku: package require vc::fossil::import::cvs::cyclebreaker     ; # Breaking dependency cycles.
e7c805f137 2007-11-16       aku: package require vc::fossil::import::cvs::state            ; # State storage.
bf83201c7f 2007-11-27       aku: package require vc::fossil::import::cvs::integrity        ; # State integrity checks.
e7c805f137 2007-11-16       aku: package require vc::fossil::import::cvs::project::rev     ; # Project level changesets
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: # # ## ### ##### ######## ############# #####################
e7c805f137 2007-11-16       aku: ## Register the pass with the management
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: vc::fossil::import::cvs::pass define \
e7c805f137 2007-11-16       aku:     BreakAllCsetCycles \
e7c805f137 2007-11-16       aku:     {Break Remaining ChangeSet Dependency Cycles} \
e7c805f137 2007-11-16       aku:     ::vc::fossil::import::cvs::pass::breakacycle
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: # # ## ### ##### ######## ############# #####################
e7c805f137 2007-11-16       aku: ##
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: snit::type ::vc::fossil::import::cvs::pass::breakacycle {
e7c805f137 2007-11-16       aku:     # # ## ### ##### ######## #############
e7c805f137 2007-11-16       aku:     ## Public API
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku:     typemethod setup {} {
e7c805f137 2007-11-16       aku: 	# Define the names and structure of the persistent state of
e7c805f137 2007-11-16       aku: 	# this pass.
de4cff4142 2007-11-22       aku: 
2c9c26815f 2007-11-29       aku: 	state reading changeset
80b1e8936f 2007-11-29       aku: 	state reading csitem
de4cff4142 2007-11-22       aku: 	state reading csorder
e7c805f137 2007-11-16       aku: 	return
e7c805f137 2007-11-16       aku:     }
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku:     typemethod load {} {
e7c805f137 2007-11-16       aku: 	# Pass manager interface. Executed to load data computed by
e7c805f137 2007-11-16       aku: 	# this pass into memory when this pass is skipped instead of
e7c805f137 2007-11-16       aku: 	# executed.
e7c805f137 2007-11-16       aku: 	return
e7c805f137 2007-11-16       aku:     }
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku:     typemethod run {} {
e7c805f137 2007-11-16       aku: 	# Pass manager interface. Executed to perform the
e7c805f137 2007-11-16       aku: 	# functionality of the pass.
7f15be9078 2007-11-20       aku: 
1ea319fb67 2007-11-25       aku: 	set len [string length [project::rev num]]
1ea319fb67 2007-11-25       aku: 	set myatfmt %${len}s
6b520e7d97 2007-11-27       aku: 	incr len 12
1ea319fb67 2007-11-25       aku: 	set mycsfmt %${len}s
1ea319fb67 2007-11-25       aku: 
6b520e7d97 2007-11-27       aku: 	cyclebreaker precmd   [myproc BreakBackward]
6b520e7d97 2007-11-27       aku: 	cyclebreaker savecmd  [myproc KeepOrder]
1f60018119 2007-11-21       aku: 
1f60018119 2007-11-21       aku: 	state transaction {
de4cff4142 2007-11-22       aku: 	    LoadCommitOrder
1f60018119 2007-11-21       aku: 	    cyclebreaker run break-all [myproc Changesets]
1f60018119 2007-11-21       aku: 	}
1f60018119 2007-11-21       aku: 
1f60018119 2007-11-21       aku: 	repository printcsetstatistics
b42cff97e3 2007-11-30       aku: 	integrity changesets [project::rev all]
e7c805f137 2007-11-16       aku: 	return
e7c805f137 2007-11-16       aku:     }
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku:     typemethod discard {} {
e7c805f137 2007-11-16       aku: 	# Pass manager interface. Executed for all passes after the
e7c805f137 2007-11-16       aku: 	# run passes, to remove all data of this pass from the state,
e7c805f137 2007-11-16       aku: 	# as being out of date.
e7c805f137 2007-11-16       aku: 	return
e7c805f137 2007-11-16       aku:     }
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku:     # # ## ### ##### ######## #############
e7c805f137 2007-11-16       aku:     ## Internal methods
e7c805f137 2007-11-16       aku: 
2a0ec504c5 2007-11-21       aku:     proc Changesets {} { project::rev all }
2a0ec504c5 2007-11-21       aku: 
de4cff4142 2007-11-22       aku:     proc LoadCommitOrder {} {
de4cff4142 2007-11-22       aku: 	::variable mycset
1ea319fb67 2007-11-25       aku: 	::variable myrevisionchangesets
de4cff4142 2007-11-22       aku: 
de4cff4142 2007-11-22       aku: 	state transaction {
de4cff4142 2007-11-22       aku: 	    foreach {cid pos} [state run { SELECT cid, pos FROM csorder }] {
de4cff4142 2007-11-22       aku: 		set cset [project::rev of $cid]
de4cff4142 2007-11-22       aku: 		$cset setpos $pos
de4cff4142 2007-11-22       aku: 		set mycset($pos) $cset
1ea319fb67 2007-11-25       aku: 		lappend myrevisionchangesets $cset
1ea319fb67 2007-11-25       aku: 	    }
de4cff4142 2007-11-22       aku: 	}
de4cff4142 2007-11-22       aku: 	return
de4cff4142 2007-11-22       aku:     }
de4cff4142 2007-11-22       aku: 
1f60018119 2007-11-21       aku:     # # ## ### ##### ######## #############
1f60018119 2007-11-21       aku: 
6b520e7d97 2007-11-27       aku:     proc BreakBackward {graph} {
4866889e88 2007-11-22       aku: 	# We go over all branch changesets, i.e. the changesets
4866889e88 2007-11-22       aku: 	# created by the symbols which are translated as branches, and
4f1b60dd16 2007-11-22       aku: 	# break any which are 'backward', which means that they have
4f1b60dd16 2007-11-22       aku: 	# at least one incoming revision changeset which is committed
4f1b60dd16 2007-11-22       aku: 	# after at least one of the outgoing revision changesets, per
4f1b60dd16 2007-11-22       aku: 	# the order computed in pass 6. In "cvs2svn" this is called
4f1b60dd16 2007-11-22       aku: 	# "retrograde".
4f1b60dd16 2007-11-22       aku: 
a437da486d 2007-12-02       aku: 	set n 0
a437da486d 2007-12-02       aku: 	set max [llength [$graph nodes]]
4866889e88 2007-11-22       aku: 	foreach cset [$graph nodes] {
a437da486d 2007-12-02       aku: 	    log progress 2 breakacycle $n $max ; incr n
4866889e88 2007-11-22       aku: 	    if {![$cset isbranch]} continue
6b520e7d97 2007-11-27       aku: 	    CheckAndBreakBackward $graph $cset
e50f9ed55e 2007-11-22       aku: 	}
e50f9ed55e 2007-11-22       aku: 	return
e50f9ed55e 2007-11-22       aku:     }
e50f9ed55e 2007-11-22       aku: 
6b520e7d97 2007-11-27       aku:     proc CheckAndBreakBackward {graph cset} {
6b520e7d97 2007-11-27       aku: 	while {[IsBackward $graph $cset]} {
af5904e6b7 2007-11-29       aku: 	    # Knowing that the branch changeset is backward we now
af5904e6b7 2007-11-29       aku: 	    # look at the individual branches in the changeset and
af5904e6b7 2007-11-29       aku: 	    # determine which of them are responsible for the
af5904e6b7 2007-11-29       aku: 	    # overlap. This allows us to split them into two sets, one
af5904e6b7 2007-11-29       aku: 	    # of non-overlapping branches, and of overlapping
af5904e6b7 2007-11-29       aku: 	    # ones. Each set induces a new changeset, and the second
af5904e6b7 2007-11-29       aku: 	    # one may still be backward and in need of further
af5904e6b7 2007-11-29       aku: 	    # splitting. Hence the looping.
e50f9ed55e 2007-11-22       aku: 	    #
e50f9ed55e 2007-11-22       aku: 	    # The border used for the split is the minimal commit
e50f9ed55e 2007-11-22       aku: 	    # position among the minimal sucessor commit positions for
af5904e6b7 2007-11-29       aku: 	    # the branches in the changeset.
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	    # Note that individual branches may not have changesets
af5904e6b7 2007-11-29       aku: 	    # which are their predecessors and/or successors, leaving
e50f9ed55e 2007-11-22       aku: 	    # the limits partially or completely undefined.
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	    # limits : dict (revision -> list (max predecessor commit, min sucessor commit))
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	    ComputeLimits $cset limits border
e50f9ed55e 2007-11-22       aku: 
6b520e7d97 2007-11-27       aku: 	    log write 5 breakacycle "Breaking backward changeset [$cset str] with commit position $border as border"
6b520e7d97 2007-11-27       aku: 
af5904e6b7 2007-11-29       aku: 	    # Secondly we sort the file level items based on there
af5904e6b7 2007-11-29       aku: 	    # they sit relative to the border into before and after
af5904e6b7 2007-11-29       aku: 	    # the border.
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	    SplitItems $limits $border normalitems backwarditems
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	    set replacements [project::rev split $cset $normalitems $backwarditems]
e50f9ed55e 2007-11-22       aku: 	    cyclebreaker replace $graph $cset $replacements
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	    # At last check that the normal frament is indeed not
e50f9ed55e 2007-11-22       aku: 	    # backward, and iterate over the possibly still backward
e50f9ed55e 2007-11-22       aku: 	    # second fragment.
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	    struct::list assign $replacements normal backward
47d52d1efd 2007-11-28       aku: 	    integrity assert {
47d52d1efd 2007-11-28       aku: 		![IsBackward $graph $normal]
47d52d1efd 2007-11-28       aku: 	    } {The normal fragment is unexpectedly backward}
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	    set cset $backward
4f1b60dd16 2007-11-22       aku: 	}
4f1b60dd16 2007-11-22       aku: 	return
4f1b60dd16 2007-11-22       aku:     }
4f1b60dd16 2007-11-22       aku: 
6b520e7d97 2007-11-27       aku:     proc IsBackward {dg cset} {
4f1b60dd16 2007-11-22       aku: 	# A branch is "backward" if it has at least one incoming
4f1b60dd16 2007-11-22       aku: 	# revision changeset which is committed after at least one of
af5904e6b7 2007-11-29       aku: 	# the outgoing revision changesets, per the order computed by
4f1b60dd16 2007-11-22       aku: 	# pass 6.
4f1b60dd16 2007-11-22       aku: 
4f1b60dd16 2007-11-22       aku: 	# Rephrased, the maximal commit position found among the
4f1b60dd16 2007-11-22       aku: 	# incoming revision changesets is larger than the minimal
4f1b60dd16 2007-11-22       aku: 	# commit position found among the outgoing revision
4f1b60dd16 2007-11-22       aku: 	# changesets. Assuming that we have both incoming and outgoing
af5904e6b7 2007-11-29       aku: 	# revision changesets for the branch.
4f1b60dd16 2007-11-22       aku: 
4f1b60dd16 2007-11-22       aku: 	# The helper "Positions" computes the set of commit positions
4f1b60dd16 2007-11-22       aku: 	# for a set of changesets, which can be a mix of revision and
4f1b60dd16 2007-11-22       aku: 	# symbol changesets.
4f1b60dd16 2007-11-22       aku: 
4f1b60dd16 2007-11-22       aku: 	set predecessors [Positions [$dg nodes -in  $cset]]
4f1b60dd16 2007-11-22       aku: 	set successors   [Positions [$dg nodes -out $cset]]
4f1b60dd16 2007-11-22       aku: 
4f1b60dd16 2007-11-22       aku: 	return [expr {
4f1b60dd16 2007-11-22       aku: 		      [llength $predecessors] &&
4f1b60dd16 2007-11-22       aku: 		      [llength $successors]   &&
4f1b60dd16 2007-11-22       aku: 		      ([max $predecessors] >= [min $successors])
4f1b60dd16 2007-11-22       aku: 		  }]
4f1b60dd16 2007-11-22       aku:     }
4f1b60dd16 2007-11-22       aku: 
4f1b60dd16 2007-11-22       aku:     proc Positions {changesets} {
4f1b60dd16 2007-11-22       aku: 	# To compute the set of commit positions from the set of
4f1b60dd16 2007-11-22       aku: 	# changesets we first map each changeset to its position (*)
4f1b60dd16 2007-11-22       aku: 	# and then filter out the invalid responses (the empty string)
4f1b60dd16 2007-11-22       aku: 	# returned by the symbol changesets.
4f1b60dd16 2007-11-22       aku: 	#
4f1b60dd16 2007-11-22       aku: 	# (*) This data was loaded into memory earlir in the pass, by
4f1b60dd16 2007-11-22       aku: 	#     LoadCommitOrder.
4f1b60dd16 2007-11-22       aku: 
4f1b60dd16 2007-11-22       aku: 	return [struct::list filter [struct::list map $changesets \
4f1b60dd16 2007-11-22       aku: 					 [myproc ToPosition]] \
4f1b60dd16 2007-11-22       aku: 		    [myproc ValidPosition]]
4f1b60dd16 2007-11-22       aku:     }
4f1b60dd16 2007-11-22       aku: 
4f1b60dd16 2007-11-22       aku:     proc ToPosition    {cset} { $cset pos }
4f1b60dd16 2007-11-22       aku:     proc ValidPosition {pos}  { expr {$pos ne ""} }
4f1b60dd16 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku:     proc ComputeLimits {cset lv bv} {
e50f9ed55e 2007-11-22       aku: 	upvar 1 $lv thelimits $bv border
e50f9ed55e 2007-11-22       aku: 
af5904e6b7 2007-11-29       aku: 	# Initialize the boundaries for all items.
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	array set limits {}
af5904e6b7 2007-11-29       aku: 	foreach revision [$cset items] {
e50f9ed55e 2007-11-22       aku: 	    set limits($revision) {0 {}}
e50f9ed55e 2007-11-22       aku: 	}
e50f9ed55e 2007-11-22       aku: 
af5904e6b7 2007-11-29       aku: 	# Compute and store the maximal predecessors per item (branch)
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	foreach {item csets} [$cset predecessormap] {
e50f9ed55e 2007-11-22       aku: 	    set s [Positions $csets]
e50f9ed55e 2007-11-22       aku: 	    if {![llength $s]} continue
af5904e6b7 2007-11-29       aku: 	    set limits($item) [lreplace $limits($item) 0 0 [max $s]]
e50f9ed55e 2007-11-22       aku: 	}
e50f9ed55e 2007-11-22       aku: 
af5904e6b7 2007-11-29       aku: 	# Compute and store the minimal successors per item (branch)
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	foreach {item csets} [$cset successormap] {
e50f9ed55e 2007-11-22       aku: 	    set s [Positions $csets]
e50f9ed55e 2007-11-22       aku: 	    if {![llength $s]} continue
af5904e6b7 2007-11-29       aku: 	    set limits($item) [lreplace $limits($item) 1 1 [min $s]]
e50f9ed55e 2007-11-22       aku: 	}
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	# Check that the ordering at the file level is correct. We
af5904e6b7 2007-11-29       aku: 	# cannot have backward ordering per branch, or something is
e50f9ed55e 2007-11-22       aku: 	# wrong.
e50f9ed55e 2007-11-22       aku: 
af5904e6b7 2007-11-29       aku: 	foreach item [array names limits] {
af5904e6b7 2007-11-29       aku: 	    struct::list assign $limits($item) maxp mins
e50f9ed55e 2007-11-22       aku: 	    # Handle min successor position "" as representing infinity
47d52d1efd 2007-11-28       aku: 	    integrity assert {
47d52d1efd 2007-11-28       aku: 		($mins eq "") || ($maxp < $mins)
af5904e6b7 2007-11-29       aku: 	    } {Item <$item> is backward at file level ($maxp >= $mins)}
4866889e88 2007-11-22       aku: 	}
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	# Save the limits for the splitter, and compute the border at
e50f9ed55e 2007-11-22       aku: 	# which to split as the minimum of all minimal successor
e50f9ed55e 2007-11-22       aku: 	# positions.
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	set thelimits [array get limits]
e50f9ed55e 2007-11-22       aku: 	set border [min [struct::list filter [struct::list map [Values $thelimits] \
e50f9ed55e 2007-11-22       aku: 						  [myproc MinSuccessorPosition]] \
e50f9ed55e 2007-11-22       aku: 			     [myproc ValidPosition]]]
4866889e88 2007-11-22       aku: 	return
4866889e88 2007-11-22       aku:     }
4866889e88 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku:     proc Values {dict} {
e50f9ed55e 2007-11-22       aku: 	set res {}
e50f9ed55e 2007-11-22       aku: 	foreach {k v} $dict { lappend res $v }
e50f9ed55e 2007-11-22       aku: 	return $res
e50f9ed55e 2007-11-22       aku:     }
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku:     proc MinSuccessorPosition {item} { lindex $item 1 }
e50f9ed55e 2007-11-22       aku: 
af5904e6b7 2007-11-29       aku:     proc SplitItems {limits border nv bv} {
af5904e6b7 2007-11-29       aku: 	upvar 1 $nv normalitems $bv backwarditems
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	set normalitems   {}
af5904e6b7 2007-11-29       aku: 	set backwarditems {}
e50f9ed55e 2007-11-22       aku: 
e50f9ed55e 2007-11-22       aku: 	foreach {rev v} $limits {
e50f9ed55e 2007-11-22       aku: 	    struct::list assign $v maxp mins
e50f9ed55e 2007-11-22       aku: 	    if {$maxp >= $border} {
af5904e6b7 2007-11-29       aku: 		lappend backwarditems  $rev
e50f9ed55e 2007-11-22       aku: 	    } else {
af5904e6b7 2007-11-29       aku: 		lappend normalitems $rev
e50f9ed55e 2007-11-22       aku: 	    }
4866889e88 2007-11-22       aku: 	}
e50f9ed55e 2007-11-22       aku: 
af5904e6b7 2007-11-29       aku: 	integrity assert {[llength $normalitems]}   {Set of normal items is empty}
af5904e6b7 2007-11-29       aku: 	integrity assert {[llength $backwarditems]} {Set of backward items is empty}
4866889e88 2007-11-22       aku: 	return
1f60018119 2007-11-21       aku:     }
4866889e88 2007-11-22       aku: 
1f60018119 2007-11-21       aku: 
1f60018119 2007-11-21       aku:     # # ## ### ##### ######## #############
1f60018119 2007-11-21       aku: 
1ea319fb67 2007-11-25       aku:     proc KeepOrder {graph at cset} {
6b520e7d97 2007-11-27       aku: 	::variable myatfmt
6b520e7d97 2007-11-27       aku: 	::variable mycsfmt
6b520e7d97 2007-11-27       aku: 
87cf609021 2007-11-24       aku: 	set cid [$cset id]
87cf609021 2007-11-24       aku: 
6b520e7d97 2007-11-27       aku: 	log write 8 breakacycle "Changeset @ [format $myatfmt $at]: [format $mycsfmt [$cset str]] <<[FormatTR $graph $cset]>>"
1ea319fb67 2007-11-25       aku: 
1ea319fb67 2007-11-25       aku: 	# We see here a mixture of symbol and revision changesets.
1ea319fb67 2007-11-25       aku: 	# The symbol changesets are ignored as irrelevant.
1ea319fb67 2007-11-25       aku: 
1ea319fb67 2007-11-25       aku: 	if {[$cset pos] eq ""} return
1ea319fb67 2007-11-25       aku: 
1ea319fb67 2007-11-25       aku: 	# For the revision changesets we are sure that they are
1ea319fb67 2007-11-25       aku: 	# consumed in the same order as generated by pass 7
1ea319fb67 2007-11-25       aku: 	# (RevTopologicalSort). Per the code in cvs2svn.
1ea319fb67 2007-11-25       aku: 
af5904e6b7 2007-11-29       aku: 	# This works if and only if none of the symbol changesets are
af5904e6b7 2007-11-29       aku: 	# "backwards", hence our breaking of the backward changesets
af5904e6b7 2007-11-29       aku: 	# first, in the pre-hook.
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	# Note that tah changesets cannot be backward as they don't
af5904e6b7 2007-11-29       aku: 	# have successors at all.
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	# An interesting thing IMHO, is that after breaking the
af5904e6b7 2007-11-29       aku: 	# backward symbol changesets we should not have any circles
af5904e6b7 2007-11-29       aku: 	# any longer. Each circle which would still be present has to
af5904e6b7 2007-11-29       aku: 	# involve a backward symbol, and we split them all, so there
af5904e6b7 2007-11-29       aku: 	# can't be a circle..
af5904e6b7 2007-11-29       aku: 
af5904e6b7 2007-11-29       aku: 	# Proof:
af5904e6b7 2007-11-29       aku: 	# Let us assume we that have a circle
6b520e7d97 2007-11-27       aku: 	# 	C: R1 -> ... -> Rx -> S -> Ry -> ... -> Rn -> R1
af5904e6b7 2007-11-29       aku: 	# Let us further assume that the symbol changeset S in that
af5904e6b7 2007-11-29       aku: 	# circle is not backward. That means ORD(Rx) < ORD(Ry).  The
af5904e6b7 2007-11-29       aku: 	# earlier topological sorting without symbols now forces this
af5904e6b7 2007-11-29       aku: 	# relationship through to be ORD(Rx) < ORD(R1) < ORD(Rx).  We
af5904e6b7 2007-11-29       aku: 	# have reached an impossibility, a paradox. Our initial
6b520e7d97 2007-11-27       aku: 	# assumption of S not being backward cannot hold.
1ea319fb67 2007-11-25       aku: 	#
6b520e7d97 2007-11-27       aku: 	# Alternate, direct, reasoning: Without S the chain of
6b520e7d97 2007-11-27       aku: 	# dependencies is Ry -> .. -> R1 -> .. -> Rx, therefore
6b520e7d97 2007-11-27       aku: 	# ORD(Ry) < ORD(Rx) holds, and this means S is backward.
1ea319fb67 2007-11-25       aku: 
1ea319fb67 2007-11-25       aku: 	struct::set exclude myrevisionchangesets $cset
1ea319fb67 2007-11-25       aku: 
1ea319fb67 2007-11-25       aku: 	::variable mylastpos
1ea319fb67 2007-11-25       aku: 	set new [$cset pos]
1ea319fb67 2007-11-25       aku: 
1ea319fb67 2007-11-25       aku: 	if {$new != ($mylastpos + 1)} {
1ea319fb67 2007-11-25       aku: 	    if {$mylastpos < 0} {
1ea319fb67 2007-11-25       aku: 		set old "<NONE>"
1ea319fb67 2007-11-25       aku: 	    } else {
1ea319fb67 2007-11-25       aku: 		::variable mycset
1ea319fb67 2007-11-25       aku: 		set old [$mycset($mylastpos) str]@$mylastpos
1ea319fb67 2007-11-25       aku: 	    }
1ea319fb67 2007-11-25       aku: 
47d52d1efd 2007-11-28       aku: 	    integrity assert 0 {Ordering of revision changesets violated, [$cset str]@$new is not immediately after $old}
87cf609021 2007-11-24       aku: 	}
1ea319fb67 2007-11-25       aku: 
1ea319fb67 2007-11-25       aku: 	set mylastpos $new
87cf609021 2007-11-24       aku: 	return
87cf609021 2007-11-24       aku:     }
87cf609021 2007-11-24       aku: 
1ea319fb67 2007-11-25       aku:     proc FormatTR {graph cset} {
1ea319fb67 2007-11-25       aku: 	return [join [struct::list map [$graph node set $cset timerange] {clock format}] { -- }]
1f60018119 2007-11-21       aku:     }
de4cff4142 2007-11-22       aku: 
1ea319fb67 2007-11-25       aku:     typevariable mylastpos            -1 ; # Position of last revision changeset saved.
1ea319fb67 2007-11-25       aku:     typevariable myrevisionchangesets {} ; # Set of revision changesets
de4cff4142 2007-11-22       aku: 
1ea319fb67 2007-11-25       aku:     typevariable myatfmt ; # Format for log output to gain better alignment of the various columns.
1ea319fb67 2007-11-25       aku:     typevariable mycsfmt ; # Ditto for the changesets.
1f60018119 2007-11-21       aku: 
1f60018119 2007-11-21       aku:     # # ## ### ##### ######## #############
1f60018119 2007-11-21       aku: 
de4cff4142 2007-11-22       aku:     typevariable mycset -array {} ; # Map from commit positions to the
de4cff4142 2007-11-22       aku: 				    # changeset (object ref) at that
de4cff4142 2007-11-22       aku: 				    # position.
1f60018119 2007-11-21       aku: 
e7c805f137 2007-11-16       aku:     # # ## ### ##### ######## #############
e7c805f137 2007-11-16       aku:     ## Configuration
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku:     pragma -hasinstances   no ; # singleton
e7c805f137 2007-11-16       aku:     pragma -hastypeinfo    no ; # no introspection
e7c805f137 2007-11-16       aku:     pragma -hastypedestroy no ; # immortal
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku:     # # ## ### ##### ######## #############
e7c805f137 2007-11-16       aku: }
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: namespace eval ::vc::fossil::import::cvs::pass {
e7c805f137 2007-11-16       aku:     namespace export breakacycle
e7c805f137 2007-11-16       aku:     namespace eval breakacycle {
e7c805f137 2007-11-16       aku: 	namespace import ::vc::fossil::import::cvs::cyclebreaker
1f60018119 2007-11-21       aku: 	namespace import ::vc::fossil::import::cvs::repository
e7c805f137 2007-11-16       aku: 	namespace import ::vc::fossil::import::cvs::state
bf83201c7f 2007-11-27       aku: 	namespace import ::vc::fossil::import::cvs::integrity
e7c805f137 2007-11-16       aku: 	namespace eval project {
e7c805f137 2007-11-16       aku: 	    namespace import ::vc::fossil::import::cvs::project::rev
e7c805f137 2007-11-16       aku: 	}
4866889e88 2007-11-22       aku: 	namespace import ::vc::tools::misc::*
4866889e88 2007-11-22       aku: 	namespace import ::vc::tools::trouble
e7c805f137 2007-11-16       aku: 	namespace import ::vc::tools::log
e7c805f137 2007-11-16       aku: 	log register breakacycle
e7c805f137 2007-11-16       aku:     }
e7c805f137 2007-11-16       aku: }
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: # # ## ### ##### ######## ############# #####################
e7c805f137 2007-11-16       aku: ## Ready
e7c805f137 2007-11-16       aku: 
e7c805f137 2007-11-16       aku: package provide vc::fossil::import::cvs::pass::breakacycle 1.0
e7c805f137 2007-11-16       aku: return