Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_pcollsym.tcl part of check-in [f888f06fe3] - Continued work on pass 3, added code to determine the type of symbols based on the tag-, branch-, and commit-counts. Hook for handling data coming from the option processoris present (UserConfig), but only as a placeholder. by aku on 2007-11-02 06:06:24. [view]

To:

File tools/cvs2fossil/lib/c2f_pcollsym.tcl part of check-in [7eaa420a23] - Extended options processing to handle --exclude, --force-tag, and --force-branch options. Extended project::sym class with in-memkory databases to hold the option information and replaced the 'UserConfig' placeholder with the actual code using the new databases to determine symbol types based on user-requests. Extended the pass itself with code performing various checks on the results of type determination, partially paranoia, partially to find genuine bad requests (excluding symbols with unexcluded blockers, making a symbol with commits on it a tag, ...). NYI: Computation of the prefered parent for all symbols. by aku on 2007-11-05 09:04:25. [view]

@@ -10,22 +10,19 @@
 # history and logs, available at http://fossil-scm.hwaci.com/fossil
 # # ## ### ##### ######## ############# #####################
 
 ## Pass III. This pass divides the symbols collected by the previous
-## pass into branches, tags, and excludes. The latter are __not__
-## deleted by this pass, only marked. It is the next pass,
-## 'FilterSym', which performs the actual deletion.
+## pass into branches, tags, and excludes. The latter are also
+## partially deleted by this pass, not only marked. It is the next
+## pass however, 'FilterSym', which performs the full deletion.
 
 # # ## ### ##### ######## ############# #####################
 ## Requirements
 
 package require Tcl 8.4                               ; # Required runtime.
 package require snit                                  ; # OO system.
-#package require fileutil::traverse                    ; # Directory traversal.
-#package require fileutil                              ; # File & path utilities.
-#package require vc::tools::trouble                    ; # Error reporting.
-package require vc::tools::log                        ; # User feedback.
-#package require vc::fossil::import::cvs::pass         ; # Pass management.
+package require vc::tools::trouble                    ; # Error reporting.
+package require vc::tools::log                        ; # User feedback.
 package require vc::fossil::import::cvs::repository   ; # Repository management.
 package require vc::fossil::import::cvs::state        ; # State storage.
 package require vc::fossil::import::cvs::project::sym ; # Project level symbols
 
@@ -50,9 +47,8 @@
 
 	state reading symbol
 	state reading blocker
 	state reading parent
-
 	return
     }
 
     typemethod load {} {
@@ -70,8 +66,19 @@
 	    project::sym printrulestatistics
 	    project::sym printtypestatistics
 	}
 
+	if {![trouble ?]} {
+	    UnconvertedSymbols
+	    BadSymbolTypes
+	    BlockedExcludes
+	    InvalidTags
+	}
+
+	if {![trouble ?]} {
+	    DropExcludedSymbolsFromReferences
+	}
+
 	log write 1 collsym "Collation completed"
 	return
     }
 
@@ -78,14 +85,110 @@
     typemethod discard {} {
 	# Pass manager interface. Executed for all passes after the
 	# run passes, to remove all data of this pass from the state,
 	# as being out of date.
-
 	return
     }
 
     # # ## ### ##### ######## #############
     ## Internal methods
+
+    proc UnconvertedSymbols {} {
+	# Paranoia - Have we left symbols without conversion
+	# information (i.e. with type 'undefined') ?
+
+	set undef [project::sym undef]
+
+	foreach {pname sname} [state run {
+	    SELECT P.name, S.name
+	    FROM   project P, symbol S
+	    WHERE  P.pid = S.pid
+	    AND    S.type = $undef
+	}] {
+	    trouble fatal "$pname : The symbol '$sname' was left undefined"
+	}
+	return
+    }
+
+    proc BadSymbolTypes {} {
+	# Paranoia - Have we left symbols with bogus conversion
+	# information (type out of the valid range (excluded, branch,
+	# tag)) ?
+
+	foreach {pname sname} [state run {
+	    SELECT P.name, S.name
+	    FROM   project P, symbol S
+	    WHERE  P.pid = S.pid
+	    AND    S.type NOT IN (0,1,2)
+	}] {
+	    trouble fatal "$pname : The symbol '$sname' has no proper conversion type"
+	}
+	return
+    }
+
+    proc BlockedExcludes {} {
+	# Paranoia - Have we scheduled symbols for exclusion without
+	# also excluding their dependent symbols ?
+
+	set excl [project::sym excluded]
+
+	foreach {pname sname bname} [state run {
+	    SELECT P.name, S.name, SB.name
+	    FROM   project P, symbol S, blocker B, symbol SB
+	    WHERE  P.pid = S.pid
+	    AND    S.type = $excl
+	    AND    S.sid = B.sid
+	    AND    B.bid = SB.sid
+	    AND    SB.type != $excl
+	}] {
+	    trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it."
+	}
+	return
+    }
+
+    proc InvalidTags {} {
+	# Paranoia - Have we scheduled symbols for conversion as tags
+	# which absolutely cannot be converted as tags due to commits
+	# made on them ?
+
+	# In other words, this checks finds out if the user has asked
+	# nonsensical conversions of symbols, which should have been
+	# left to the heuristics, most specifically
+	# 'project::sym.HasCommits()'.
+
+	set tag [project::sym tag]
+
+	foreach {pname sname} [state run {
+	    SELECT P.name, S.name
+	    FROM   project P, symbol S
+	    WHERE  P.pid = S.pid
+	    AND    S.type = $tag
+	    AND    S.commit_count > 0
+	}] {
+	    trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits."
+	}
+	return
+    }
+
+    proc DropExcludedSymbolsFromReferences {} {
+	# The excluded symbols cann be used as blockers nor as
+	# possible parent for other symbols. We now drop the relevant
+	# entries to prevent them from causing confusion later on.
+
+	set excl [project::sym excluded]
+
+	state run {
+	    DELETE FROM blocker
+	    WHERE bid IN (SELECT sid
+			  FROM   symbol
+			  WhERE  type = $excl);
+	    DELETE FROM parent
+	    WHERE pid IN (SELECT sid
+			  FROM   symbol
+			  WhERE  type = $excl);
+	}
+	return
+    }
 
     # # ## ### ##### ######## #############
     ## Configuration
 
@@ -103,9 +206,9 @@
 	namespace import ::vc::fossil::import::cvs::state
 	namespace eval project {
 	    namespace import ::vc::fossil::import::cvs::project::sym
 	}
-	#namespace import ::vc::tools::trouble
+	namespace import ::vc::tools::trouble
 	namespace import ::vc::tools::log
 	log register collsym
     }
 }