File Annotation
Not logged in
6d4eb24738 2007-11-02       aku: ## -*- tcl -*-
6d4eb24738 2007-11-02       aku: # # ## ### ##### ######## ############# #####################
6d4eb24738 2007-11-02       aku: ## Copyright (c) 2007 Andreas Kupries.
6d4eb24738 2007-11-02       aku: #
6d4eb24738 2007-11-02       aku: # This software is licensed as described in the file LICENSE, which
6d4eb24738 2007-11-02       aku: # you should have received as part of this distribution.
6d4eb24738 2007-11-02       aku: #
6d4eb24738 2007-11-02       aku: # This software consists of voluntary contributions made by many
6d4eb24738 2007-11-02       aku: # individuals.  For exact contribution history, see the revision
6d4eb24738 2007-11-02       aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil
6d4eb24738 2007-11-02       aku: # # ## ### ##### ######## ############# #####################
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: ## Pass III. This pass divides the symbols collected by the previous
7eaa420a23 2007-11-05       aku: ## pass into branches, tags, and excludes. The latter are also
7eaa420a23 2007-11-05       aku: ## partially deleted by this pass, not only marked. It is the next
7eaa420a23 2007-11-05       aku: ## pass however, 'FilterSym', which performs the full deletion.
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: # # ## ### ##### ######## ############# #####################
6d4eb24738 2007-11-02       aku: ## Requirements
6d4eb24738 2007-11-02       aku: 
f888f06fe3 2007-11-02       aku: package require Tcl 8.4                               ; # Required runtime.
f888f06fe3 2007-11-02       aku: package require snit                                  ; # OO system.
7eaa420a23 2007-11-05       aku: package require vc::tools::trouble                    ; # Error reporting.
7eaa420a23 2007-11-05       aku: package require vc::tools::log                        ; # User feedback.
f888f06fe3 2007-11-02       aku: package require vc::fossil::import::cvs::repository   ; # Repository management.
f888f06fe3 2007-11-02       aku: package require vc::fossil::import::cvs::state        ; # State storage.
f888f06fe3 2007-11-02       aku: package require vc::fossil::import::cvs::project::sym ; # Project level symbols
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: # # ## ### ##### ######## ############# #####################
6d4eb24738 2007-11-02       aku: ## Register the pass with the management
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: vc::fossil::import::cvs::pass define \
6d4eb24738 2007-11-02       aku:     CollateSymbols \
6d4eb24738 2007-11-02       aku:     {Collate symbols} \
6d4eb24738 2007-11-02       aku:     ::vc::fossil::import::cvs::pass::collsym
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: # # ## ### ##### ######## ############# #####################
6d4eb24738 2007-11-02       aku: ##
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: snit::type ::vc::fossil::import::cvs::pass::collsym {
6d4eb24738 2007-11-02       aku:     # # ## ### ##### ######## #############
6d4eb24738 2007-11-02       aku:     ## Public API
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     typemethod setup {} {
6d4eb24738 2007-11-02       aku: 	# Define names and structure of the persistent state of this
6d4eb24738 2007-11-02       aku: 	# pass.
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: 	state reading symbol
6d4eb24738 2007-11-02       aku: 	state reading blocker
6d4eb24738 2007-11-02       aku: 	state reading parent
6d4eb24738 2007-11-02       aku: 	return
6d4eb24738 2007-11-02       aku:     }
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     typemethod load {} {
6d4eb24738 2007-11-02       aku: 	# TODO
6d4eb24738 2007-11-02       aku: 	return
6d4eb24738 2007-11-02       aku:     }
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     typemethod run {} {
6d4eb24738 2007-11-02       aku: 	# Pass manager interface. Executed to perform the
6d4eb24738 2007-11-02       aku: 	# functionality of the pass.
6d4eb24738 2007-11-02       aku: 
f888f06fe3 2007-11-02       aku: 	state transaction {
f888f06fe3 2007-11-02       aku: 	    repository   determinesymboltypes
f888f06fe3 2007-11-02       aku: 
f888f06fe3 2007-11-02       aku: 	    project::sym printrulestatistics
f888f06fe3 2007-11-02       aku: 	    project::sym printtypestatistics
f888f06fe3 2007-11-02       aku: 	}
f888f06fe3 2007-11-02       aku: 
7eaa420a23 2007-11-05       aku: 	if {![trouble ?]} {
7eaa420a23 2007-11-05       aku: 	    UnconvertedSymbols
7eaa420a23 2007-11-05       aku: 	    BadSymbolTypes
7eaa420a23 2007-11-05       aku: 	    BlockedExcludes
7eaa420a23 2007-11-05       aku: 	    InvalidTags
7eaa420a23 2007-11-05       aku: 	}
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	if {![trouble ?]} {
7eaa420a23 2007-11-05       aku: 	    DropExcludedSymbolsFromReferences
7eaa420a23 2007-11-05       aku: 	}
7eaa420a23 2007-11-05       aku: 
6d4eb24738 2007-11-02       aku: 	log write 1 collsym "Collation completed"
6d4eb24738 2007-11-02       aku: 	return
6d4eb24738 2007-11-02       aku:     }
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     typemethod discard {} {
6d4eb24738 2007-11-02       aku: 	# Pass manager interface. Executed for all passes after the
6d4eb24738 2007-11-02       aku: 	# run passes, to remove all data of this pass from the state,
6d4eb24738 2007-11-02       aku: 	# as being out of date.
6d4eb24738 2007-11-02       aku: 	return
6d4eb24738 2007-11-02       aku:     }
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     # # ## ### ##### ######## #############
6d4eb24738 2007-11-02       aku:     ## Internal methods
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku:     proc UnconvertedSymbols {} {
7eaa420a23 2007-11-05       aku: 	# Paranoia - Have we left symbols without conversion
7eaa420a23 2007-11-05       aku: 	# information (i.e. with type 'undefined') ?
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	set undef [project::sym undef]
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	foreach {pname sname} [state run {
7eaa420a23 2007-11-05       aku: 	    SELECT P.name, S.name
7eaa420a23 2007-11-05       aku: 	    FROM   project P, symbol S
7eaa420a23 2007-11-05       aku: 	    WHERE  P.pid = S.pid
7eaa420a23 2007-11-05       aku: 	    AND    S.type = $undef
7eaa420a23 2007-11-05       aku: 	}] {
7eaa420a23 2007-11-05       aku: 	    trouble fatal "$pname : The symbol '$sname' was left undefined"
7eaa420a23 2007-11-05       aku: 	}
7eaa420a23 2007-11-05       aku: 	return
7eaa420a23 2007-11-05       aku:     }
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku:     proc BadSymbolTypes {} {
7eaa420a23 2007-11-05       aku: 	# Paranoia - Have we left symbols with bogus conversion
7eaa420a23 2007-11-05       aku: 	# information (type out of the valid range (excluded, branch,
7eaa420a23 2007-11-05       aku: 	# tag)) ?
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	foreach {pname sname} [state run {
7eaa420a23 2007-11-05       aku: 	    SELECT P.name, S.name
7eaa420a23 2007-11-05       aku: 	    FROM   project P, symbol S
7eaa420a23 2007-11-05       aku: 	    WHERE  P.pid = S.pid
7eaa420a23 2007-11-05       aku: 	    AND    S.type NOT IN (0,1,2)
7eaa420a23 2007-11-05       aku: 	}] {
7eaa420a23 2007-11-05       aku: 	    trouble fatal "$pname : The symbol '$sname' has no proper conversion type"
7eaa420a23 2007-11-05       aku: 	}
7eaa420a23 2007-11-05       aku: 	return
7eaa420a23 2007-11-05       aku:     }
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku:     proc BlockedExcludes {} {
7eaa420a23 2007-11-05       aku: 	# Paranoia - Have we scheduled symbols for exclusion without
7eaa420a23 2007-11-05       aku: 	# also excluding their dependent symbols ?
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	set excl [project::sym excluded]
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	foreach {pname sname bname} [state run {
7eaa420a23 2007-11-05       aku: 	    SELECT P.name, S.name, SB.name
7eaa420a23 2007-11-05       aku: 	    FROM   project P, symbol S, blocker B, symbol SB
7eaa420a23 2007-11-05       aku: 	    WHERE  P.pid = S.pid
7eaa420a23 2007-11-05       aku: 	    AND    S.type = $excl
7eaa420a23 2007-11-05       aku: 	    AND    S.sid = B.sid
7eaa420a23 2007-11-05       aku: 	    AND    B.bid = SB.sid
7eaa420a23 2007-11-05       aku: 	    AND    SB.type != $excl
7eaa420a23 2007-11-05       aku: 	}] {
7eaa420a23 2007-11-05       aku: 	    trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it."
7eaa420a23 2007-11-05       aku: 	}
7eaa420a23 2007-11-05       aku: 	return
7eaa420a23 2007-11-05       aku:     }
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku:     proc InvalidTags {} {
7eaa420a23 2007-11-05       aku: 	# Paranoia - Have we scheduled symbols for conversion as tags
7eaa420a23 2007-11-05       aku: 	# which absolutely cannot be converted as tags due to commits
7eaa420a23 2007-11-05       aku: 	# made on them ?
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	# In other words, this checks finds out if the user has asked
7eaa420a23 2007-11-05       aku: 	# nonsensical conversions of symbols, which should have been
7eaa420a23 2007-11-05       aku: 	# left to the heuristics, most specifically
7eaa420a23 2007-11-05       aku: 	# 'project::sym.HasCommits()'.
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	set tag [project::sym tag]
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	foreach {pname sname} [state run {
7eaa420a23 2007-11-05       aku: 	    SELECT P.name, S.name
7eaa420a23 2007-11-05       aku: 	    FROM   project P, symbol S
7eaa420a23 2007-11-05       aku: 	    WHERE  P.pid = S.pid
7eaa420a23 2007-11-05       aku: 	    AND    S.type = $tag
7eaa420a23 2007-11-05       aku: 	    AND    S.commit_count > 0
7eaa420a23 2007-11-05       aku: 	}] {
7eaa420a23 2007-11-05       aku: 	    trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits."
7eaa420a23 2007-11-05       aku: 	}
7eaa420a23 2007-11-05       aku: 	return
7eaa420a23 2007-11-05       aku:     }
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku:     proc DropExcludedSymbolsFromReferences {} {
7eaa420a23 2007-11-05       aku: 	# The excluded symbols cann be used as blockers nor as
7eaa420a23 2007-11-05       aku: 	# possible parent for other symbols. We now drop the relevant
7eaa420a23 2007-11-05       aku: 	# entries to prevent them from causing confusion later on.
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	set excl [project::sym excluded]
7eaa420a23 2007-11-05       aku: 
7eaa420a23 2007-11-05       aku: 	state run {
7eaa420a23 2007-11-05       aku: 	    DELETE FROM blocker
7eaa420a23 2007-11-05       aku: 	    WHERE bid IN (SELECT sid
7eaa420a23 2007-11-05       aku: 			  FROM   symbol
7eaa420a23 2007-11-05       aku: 			  WhERE  type = $excl);
7eaa420a23 2007-11-05       aku: 	    DELETE FROM parent
7eaa420a23 2007-11-05       aku: 	    WHERE pid IN (SELECT sid
7eaa420a23 2007-11-05       aku: 			  FROM   symbol
7eaa420a23 2007-11-05       aku: 			  WhERE  type = $excl);
7eaa420a23 2007-11-05       aku: 	}
7eaa420a23 2007-11-05       aku: 	return
7eaa420a23 2007-11-05       aku:     }
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     # # ## ### ##### ######## #############
6d4eb24738 2007-11-02       aku:     ## Configuration
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     pragma -hasinstances   no ; # singleton
6d4eb24738 2007-11-02       aku:     pragma -hastypeinfo    no ; # no introspection
6d4eb24738 2007-11-02       aku:     pragma -hastypedestroy no ; # immortal
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku:     # # ## ### ##### ######## #############
6d4eb24738 2007-11-02       aku: }
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: namespace eval ::vc::fossil::import::cvs::pass {
6d4eb24738 2007-11-02       aku:     namespace export collsym
6d4eb24738 2007-11-02       aku:     namespace eval collsym {
f888f06fe3 2007-11-02       aku: 	namespace import ::vc::fossil::import::cvs::repository
6d4eb24738 2007-11-02       aku: 	namespace import ::vc::fossil::import::cvs::state
f888f06fe3 2007-11-02       aku: 	namespace eval project {
f888f06fe3 2007-11-02       aku: 	    namespace import ::vc::fossil::import::cvs::project::sym
f888f06fe3 2007-11-02       aku: 	}
7eaa420a23 2007-11-05       aku: 	namespace import ::vc::tools::trouble
6d4eb24738 2007-11-02       aku: 	namespace import ::vc::tools::log
6d4eb24738 2007-11-02       aku: 	log register collsym
6d4eb24738 2007-11-02       aku:     }
6d4eb24738 2007-11-02       aku: }
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: # # ## ### ##### ######## ############# #####################
6d4eb24738 2007-11-02       aku: ## Ready
6d4eb24738 2007-11-02       aku: 
6d4eb24738 2007-11-02       aku: package provide vc::fossil::import::cvs::pass::collsym 1.0
6d4eb24738 2007-11-02       aku: return