Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_pcollsym.tcl part of check-in [e288af3995] - Fluff: Renamed state methods use/reading/writing to usedb/use/extend for clarity. Updated all callers. Extended state module with code to dump the SQL statements it receives to a file for analysis. Extended the 'use' declarations of several passes. by aku on 2007-12-02 23:47:45. [view]

To:

File tools/cvs2fossil/lib/c2f_pcollsym.tcl part of check-in [f7fe15cd0c] - More comments on sql statements, slight reordering of some tables and conditions. by aku on 2007-12-08 03:39:27. [view]

@@ -59,9 +59,9 @@
 
 	    sid INTEGER  NOT NULL  PRIMARY KEY  REFERENCES symbol,
 	    pid INTEGER  NOT NULL               REFERENCES symbol
 	} { pid }
-	# Index on: pid (branch successors`)
+	# Index on: pid (branch successors)
 	return
     }
 
     typemethod load {} {
@@ -112,8 +112,11 @@
 
     # # ## ### ##### ######## #############
     ## Internal methods
 
+    ## TODO: Move UnconvertedSymbols, BadSymbolTypes, BlockedIncludes,
+    ##       InvalidTags to the integrity module?
+
     proc UnconvertedSymbols {} {
 	# Paranoia - Have we left symbols without conversion
 	# information (i.e. with type 'undefined') ?
 
@@ -120,11 +123,11 @@
 	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
+	    FROM   symbol S, project P
+	    WHERE  S.type = $undef  -- Restrict to undefined symbols
+	    AND    P.pid = S.pid    -- Get project for symbol
 	}] {
 	    trouble fatal "$pname : The symbol '$sname' was left undefined"
 	}
 	return
@@ -136,11 +139,11 @@
 	# 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)
+	    FROM   symbol S, project P
+	    WHERE  S.type NOT IN (0,1,2) -- Restrict to symbols with bogus type codes
+	    AND    P.pid = S.pid         -- Get project of symbol
 	}] {
 	    trouble fatal "$pname : The symbol '$sname' has no proper conversion type"
 	}
 	return
@@ -153,14 +156,14 @@
 	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
+	    FROM   symbol S, blocker B, symbol SB, project P
+	    WHERE  S.type = $excl   -- Restrict to excluded symbols
+	    AND    S.sid = B.sid    -- Get symbols blocking them
+	    AND    B.bid = SB.sid   -- and
+	    AND    SB.type != $excl -- which are not excluded themselves
+	    AND    P.pid = S.pid    -- Get project of symbol
 	}] {
 	    trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it."
 	}
 	return
@@ -180,11 +183,11 @@
 
 	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
+	    WHERE  S.type = $tag        -- Restrict to tag symbols
+	    AND    S.commit_count > 0   -- which have revisions committed to them
+	    AND    P.pid = S.pid        -- Get project of symbol
 	}] {
 	    trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits."
 	}
 	return
@@ -200,13 +203,13 @@
 	state run {
 	    DELETE FROM blocker
 	    WHERE bid IN (SELECT sid
 			  FROM   symbol
-			  WhERE  type = $excl);
+			  WhERE  type = $excl); -- Get excluded symbols
 	    DELETE FROM parent
 	    WHERE pid IN (SELECT sid
 			  FROM   symbol
-			  WhERE  type = $excl);
+			  WhERE  type = $excl); -- Get excluded symbols
 	}
 	return
     }
 
@@ -225,13 +228,14 @@
 
 	foreach {s p sname pname prname votes} [state run {
 	    SELECT   S.sid, P.pid, S.name, SB.name, PR.name, P.n
 	    FROM     symbol S, parent P, symbol SB, project PR
-	    WHERE    S.sid = P.sid
-	    AND      P.pid = SB.sid
-	    AND      S.pid = PR.pid
-	    AND      S.type != $excl
-	    ORDER BY P.n ASC, P.pid DESC
+	    WHERE    S.type != $excl      -- Restrict to wanted symbols
+	    AND      S.sid = P.sid        -- Get possible parents of symbol
+	    AND      P.pid = SB.sid       -- and
+	    AND      S.pid = PR.pid       -- the project of the symbol
+	    ORDER BY P.n ASC, P.pid DESC  -- Sorting, see below
+	    --
 	    -- Higher votes and smaller ids (= earlier branches) last
 	    -- We simply keep the last possible parent for each
 	    -- symbol.  This parent will have the max number of votes
 	    -- for its symbol and will be the earliest created branch
@@ -261,14 +265,15 @@
 	#            compute a prefered parent for them, see phase I.
 
 	foreach {pname sname} [state run {
 	    SELECT PR.name, S.name
-	    FROM   project PR, symbol S LEFT OUTER JOIN preferedparent P
-	    ON     S.sid = P.sid
-	    WHERE  P.pid IS NULL
-	    AND    S.name != ':trunk:'
-	    AND    S.pid = PR.pid
-	    AND    S.type != $excl
+	    FROM   symbol S LEFT OUTER JOIN preferedparent P
+	    ON     S.sid = P.sid,       -- From symbol to prefered parent
+	           project PR
+	    WHERE  P.pid IS NULL        -- restrict to symbols without a preference
+	    AND    S.type != $excl      -- which are not excluded
+	    AND    S.name != ':trunk:'  -- and are not a trunk
+	    AND    S.pid = PR.pid       -- get project of symbol
 	}] {
 	    trouble fatal "$pname : '$sname' has no prefered parent."
 	}