File Annotation
Not logged in
66c85b4db4 2007-11-25       aku: ## -*- tcl -*-
66c85b4db4 2007-11-25       aku: # # ## ### ##### ######## ############# #####################
66c85b4db4 2007-11-25       aku: ## Copyright (c) 2007 Andreas Kupries.
66c85b4db4 2007-11-25       aku: #
66c85b4db4 2007-11-25       aku: # This software is licensed as described in the file LICENSE, which
66c85b4db4 2007-11-25       aku: # you should have received as part of this distribution.
66c85b4db4 2007-11-25       aku: #
66c85b4db4 2007-11-25       aku: # This software consists of voluntary contributions made by many
66c85b4db4 2007-11-25       aku: # individuals.  For exact contribution history, see the revision
66c85b4db4 2007-11-25       aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil
66c85b4db4 2007-11-25       aku: # # ## ### ##### ######## ############# #####################
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: ## Pass X. This pass goes over all changesets and sorts them
66c85b4db4 2007-11-25       aku: ## topologically. It assumes that there are no cycles which could
66c85b4db4 2007-11-25       aku: ## impede it, any remaining having been broken by the previous two
66c85b4db4 2007-11-25       aku: ## passes, and aborts if that condition doesn't hold.
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: # # ## ### ##### ######## ############# #####################
66c85b4db4 2007-11-25       aku: ## Requirements
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: package require Tcl 8.4                                   ; # Required runtime.
66c85b4db4 2007-11-25       aku: package require snit                                      ; # OO system.
66c85b4db4 2007-11-25       aku: package require struct::list                              ; # Higher order list operations.
66c85b4db4 2007-11-25       aku: package require vc::tools::log                            ; # User feedback.
66c85b4db4 2007-11-25       aku: package require vc::fossil::import::cvs::cyclebreaker     ; # Breaking dependency cycles.
66c85b4db4 2007-11-25       aku: package require vc::fossil::import::cvs::state            ; # State storage.
66c85b4db4 2007-11-25       aku: package require vc::fossil::import::cvs::project::rev     ; # Project level changesets
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: # # ## ### ##### ######## ############# #####################
66c85b4db4 2007-11-25       aku: ## Register the pass with the management
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: vc::fossil::import::cvs::pass define \
66c85b4db4 2007-11-25       aku:     AllTopologicalSort \
66c85b4db4 2007-11-25       aku:     {Topologically Sort All ChangeSets} \
66c85b4db4 2007-11-25       aku:     ::vc::fossil::import::cvs::pass::atopsort
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: # # ## ### ##### ######## ############# #####################
66c85b4db4 2007-11-25       aku: ##
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: snit::type ::vc::fossil::import::cvs::pass::atopsort {
66c85b4db4 2007-11-25       aku:     # # ## ### ##### ######## #############
66c85b4db4 2007-11-25       aku:     ## Public API
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     typemethod setup {} {
66c85b4db4 2007-11-25       aku: 	# Define the names and structure of the persistent state of
66c85b4db4 2007-11-25       aku: 	# this pass.
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	state reading csorder
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	state writing cstimestamp {
66c85b4db4 2007-11-25       aku: 	    -- Commit order of all changesets based on their
66c85b4db4 2007-11-25       aku: 	    -- dependencies, plus a monotonically increasing
66c85b4db4 2007-11-25       aku: 	    -- timestamp.
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	    cid  INTEGER  NOT NULL  REFERENCES changeset,
66c85b4db4 2007-11-25       aku: 	    pos  INTEGER  NOT NULL,
66c85b4db4 2007-11-25       aku: 	    date INTEGER  NOT NULL,
66c85b4db4 2007-11-25       aku: 	    UNIQUE (cid),
66c85b4db4 2007-11-25       aku: 	    UNIQUE (pos),
66c85b4db4 2007-11-25       aku: 	    UNIQUE (date)
66c85b4db4 2007-11-25       aku: 	}
66c85b4db4 2007-11-25       aku: 	return
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     typemethod load {} {
66c85b4db4 2007-11-25       aku: 	# Pass manager interface. Executed to load data computed by
66c85b4db4 2007-11-25       aku: 	# this pass into memory when this pass is skipped instead of
66c85b4db4 2007-11-25       aku: 	# executed.
66c85b4db4 2007-11-25       aku: 	return
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     typemethod run {} {
66c85b4db4 2007-11-25       aku: 	# Pass manager interface. Executed to perform the
66c85b4db4 2007-11-25       aku: 	# functionality of the pass.
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	cyclebreaker savecmd  [myproc SaveTimestamps]
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	state transaction {
66c85b4db4 2007-11-25       aku: 	    LoadSymbolChangesets
63052cb60a 2007-11-25       aku: 	    cyclebreaker run tsort-all [myproc Changesets]
66c85b4db4 2007-11-25       aku: 	}
66c85b4db4 2007-11-25       aku: 	return
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     typemethod discard {} {
66c85b4db4 2007-11-25       aku: 	# Pass manager interface. Executed for all passes after the
66c85b4db4 2007-11-25       aku: 	# run passes, to remove all data of this pass from the state,
66c85b4db4 2007-11-25       aku: 	# as being out of date.
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	state discard cstimestamp
66c85b4db4 2007-11-25       aku: 	return
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     # # ## ### ##### ######## #############
66c85b4db4 2007-11-25       aku:     ## Internal methods
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     proc Changesets {} { project::rev all }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     proc LoadSymbolChangesets {} {
66c85b4db4 2007-11-25       aku: 	set mysymchangesets [struct::list filter [project::rev all] [myproc IsBySymbol]]
66c85b4db4 2007-11-25       aku: 	return
66c85b4db4 2007-11-25       aku:     }
63052cb60a 2007-11-25       aku: 
63052cb60a 2007-11-25       aku:     proc IsBySymbol {cset} { $cset bysymbol }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     proc SaveTimestamps {graph at cset} {
66c85b4db4 2007-11-25       aku: 	set cid [$cset id]
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	set date [GetTime [lindex [$graph node get $cset timerange] 1] \
66c85b4db4 2007-11-25       aku: 		      [struct::set contain $mysymchangesets $cset]]
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	log write 4 atopsort "Changeset @ $at: [$cset str]"
66c85b4db4 2007-11-25       aku: 	state run {
66c85b4db4 2007-11-25       aku: 	    INSERT INTO cstimestamp (cid,  pos, date)
66c85b4db4 2007-11-25       aku: 	    VALUES                  ($cid, $at, $date)
66c85b4db4 2007-11-25       aku: 	}
66c85b4db4 2007-11-25       aku: 	return
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     proc GetTime {stamp expectchange} {
66c85b4db4 2007-11-25       aku: 	::variable mylasttimestamp
66c85b4db4 2007-11-25       aku: 	if {$stamp > $mymaxtimestamp} {
66c85b4db4 2007-11-25       aku: 	    # A timestamp in the future is believed to be bogus and
66c85b4db4 2007-11-25       aku: 	    # shifted backwars in time to prevent it from forcing
66c85b4db4 2007-11-25       aku: 	    # other timestamps to be pushed even further in the
66c85b4db4 2007-11-25       aku: 	    # future.
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	    # From cvs2svn: Note that this is not nearly a complete
66c85b4db4 2007-11-25       aku: 	    # solution to the bogus timestamp problem.  A timestamp in
66c85b4db4 2007-11-25       aku: 	    # the future still affects the ordering of changesets, and
66c85b4db4 2007-11-25       aku: 	    # a changeset having such a timestamp will not be
66c85b4db4 2007-11-25       aku: 	    # committed until all changesets with earlier timestamps
66c85b4db4 2007-11-25       aku: 	    # have been committed, even if other changesets with even
66c85b4db4 2007-11-25       aku: 	    # earlier timestamps depend on this one.
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: 	    incr mylasttimestamp
66c85b4db4 2007-11-25       aku: 	    if {!$expectchange} {
66c85b4db4 2007-11-25       aku: 		log write 4 atopsort "Timestamp [clock format $stamp] is in the future; shifted back to [clock format $mylasttimestamp]"
66c85b4db4 2007-11-25       aku: 	    }
66c85b4db4 2007-11-25       aku: 	} elseif {$stamp < ($mylasttimestamp)+1} {
66c85b4db4 2007-11-25       aku: 	    incr mylasttimestamp
66c85b4db4 2007-11-25       aku: 	    if {!$expectchange} {
66c85b4db4 2007-11-25       aku: 		log write 4 atopsort "Timestamp [clock format $stamp] adjusted to [clock format $mylasttimestamp]"
66c85b4db4 2007-11-25       aku: 	    }
66c85b4db4 2007-11-25       aku: 	} else {
66c85b4db4 2007-11-25       aku: 	    set mylasttimestamp $stamp
66c85b4db4 2007-11-25       aku: 	}
66c85b4db4 2007-11-25       aku: 	return $mylasttimestamp
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     typevariable mysymchangesets {} ; # Set of the symbol changesets.
66c85b4db4 2007-11-25       aku:     typevariable mylasttimestamp 0  ; # Last delivered timestamp.
66c85b4db4 2007-11-25       aku:     typevariable mymaxtimestamp
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     typeconstructor {
66c85b4db4 2007-11-25       aku: 	# The maximum timestamp considered as reasonable is
66c85b4db4 2007-11-25       aku: 	# "now + 1 day".
66c85b4db4 2007-11-25       aku: 	set  mymaxtimestamp [clock seconds]
66c85b4db4 2007-11-25       aku: 	incr mymaxtimestamp 86400 ; # 24h * 60min * 60sec
66c85b4db4 2007-11-25       aku: 	return
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     # # ## ### ##### ######## #############
66c85b4db4 2007-11-25       aku:     ## Configuration
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     pragma -hasinstances   no ; # singleton
66c85b4db4 2007-11-25       aku:     pragma -hastypeinfo    no ; # no introspection
66c85b4db4 2007-11-25       aku:     pragma -hastypedestroy no ; # immortal
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku:     # # ## ### ##### ######## #############
66c85b4db4 2007-11-25       aku: }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: namespace eval ::vc::fossil::import::cvs::pass {
66c85b4db4 2007-11-25       aku:     namespace export atopsort
66c85b4db4 2007-11-25       aku:     namespace eval atopsort {
66c85b4db4 2007-11-25       aku: 	namespace import ::vc::fossil::import::cvs::cyclebreaker
66c85b4db4 2007-11-25       aku: 	namespace import ::vc::fossil::import::cvs::state
66c85b4db4 2007-11-25       aku: 	namespace eval project {
66c85b4db4 2007-11-25       aku: 	    namespace import ::vc::fossil::import::cvs::project::rev
66c85b4db4 2007-11-25       aku: 	}
66c85b4db4 2007-11-25       aku: 	namespace import ::vc::tools::log
66c85b4db4 2007-11-25       aku: 	log register atopsort
66c85b4db4 2007-11-25       aku:     }
66c85b4db4 2007-11-25       aku: }
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: # # ## ### ##### ######## ############# #####################
66c85b4db4 2007-11-25       aku: ## Ready
66c85b4db4 2007-11-25       aku: 
66c85b4db4 2007-11-25       aku: package provide vc::fossil::import::cvs::pass::atopsort 1.0
66c85b4db4 2007-11-25       aku: return