Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_integrity.tcl part of check-in [7c28fe1312] - Started to adapt the integrity module. Renamed Check to CheckRev, and added analoguous commands for Tags and Branches. Added placeholders for the new integrity commands, updated main changeset integrity command. by aku on 2007-11-29 06:31:08. [view]

To:

File tools/cvs2fossil/lib/c2f_integrity.tcl part of check-in [de10b2301e] - Shuffled and updated the existing checks of revision changesets. by aku on 2007-11-29 06:40:19. [view]

@@ -301,9 +301,9 @@
 	    }
 	return
     }
 
-    proc AllChangesets {} {
+    proc RevisionChangesets {} {
 	# This code performs a number of paranoid checks of the
 	# database, searching for inconsistent changeset/revision
 	# information.
 
@@ -310,12 +310,12 @@
 	upvar 1 n n ; # Counter for the checks (we print an id before
 		      # the main label).
 
 	# Find all revisions which are not used by at least one
-	# revision changeset.
+	# changeset.
 	CheckRev \
-	    {All revisions have to be used by least one revision changeset} \
-	    {is not used by a revision changeset} {
+	    {All revisions have to be used by least one changeset} \
+	    {is not used by a changeset} {
 		-- Unused revisions = All revisions
 		--                  - revisions used by revision changesets.
 		--
 		-- Both sets can be computed easily, and subtracted
@@ -323,20 +323,22 @@
                 -- file (name) for display.
 
 		SELECT F.name, R.rev
 		FROM revision R, file F
-		WHERE R.rid IN (SELECT rid FROM revision                      -- All revisions
-				EXCEPT                                     -- subtract
-				SELECT CR.rid FROM csrevision CR, changeset C -- revisions used
-				WHERE C.cid = CR.cid                          -- by any revision
-				AND C.type = 0)                               -- changeset
+		WHERE R.rid IN (SELECT rid
+				FROM revision                -- All revisions
+				EXCEPT                       -- subtract
+				SELECT CR.rid
+				FROM csrevision CR, changeset C  -- revisions used
+				WHERE C.cid = CR.cid         -- by any revision
+				AND C.type = 0)              -- changeset
 		AND   R.fid = F.fid              -- get file of unused revision
 	    }
-	# Find all revisions which are used by more than one revision
+	# Find all revisions which are used by more than one
 	# changeset.
 	CheckRev \
-	    {All revisions have to be used by at most one revision changeset} \
-	    {is used by multiple revision changesets} {
+	    {All revisions have to be used by at most one changeset} \
+	    {is used by multiple changesets} {
 		-- Principle of operation: Get all revision/changeset
                 -- pairs for all revision changesets, group by
                 -- revision to aggregate the changeset, counting
                 -- them. From the resulting revision/count table
@@ -348,16 +350,30 @@
 		     (SELECT CR.rid AS rid, count(CR.cid) AS count
 		      FROM csrevision CR, changeset C
 		      WHERE C.type = 0
 		      AND   C.cid = CR.cid
-		      GROUP BY CR.rid ) AS U
+		      GROUP BY CR.rid) AS U
 		WHERE U.count > 1
 		AND R.rid = U.rid
 		AND R.fid = F.fid
 	    }
-	# All revisions in all changesets have to agree on the LOD
-	# their changeset belongs to. In other words, all revisions in
-	# a changeset have to refer to the same line of development.
+	# All revisions have to refer to the same meta information as
+	# their changeset.
+	CheckRevCS \
+	    {All revisions have to agree with their changeset about the used meta information} \
+	    {disagrees with its changeset @ about the meta information} {
+		SELECT CT.name, C.cid, F.name, R.rev
+		FROM changeset C, cstype CT, revision R, file F, csrevision CR
+		WHERE C.type = 0       -- revision changesets only
+		AND   C.cid  = CR.cid  -- changeset --> its revisions
+		AND   R.rid  = CR.rid  -- look at them
+		AND   R.mid != C.src   -- Only those which disagree with changeset about the meta
+		AND   R.fid = F.fid    -- get file of the revision
+		AND   CT.tid = C.type  -- get changeset type, for labeling
+	    }
+	# All revisions have to agree on the LOD their changeset
+	# belongs to. In other words, all revisions in a changeset
+	# have to refer to the same line of development.
 	#
 	# Instead of looking at all pairs of revisions in all
 	# changesets we generate the distinct set of all LODs
 	# referenced by the revisions of a changeset, look for those
@@ -369,16 +385,18 @@
 		SELECT T.name, C.cid
 		FROM   changeset C, cstype T
 		WHERE  C.cid IN (SELECT U.cid
 				 FROM (SELECT DISTINCT CR.cid AS cid, R.lod AS lod
-				       FROM   csrevision CR, revision R
-				       WHERE  CR.rid = R.rid) AS U
+				       FROM   csrevision CR, changeset C, revision R
+				       WHERE  CR.rid = R.rid
+				       AND    C.cid = CR.cid
+				       AND    C.type = 0) AS U
 				 GROUP BY U.cid HAVING COUNT(U.lod) > 1)
 		AND    T.tid = C.type
 	    }
-	# All revisions in all changesets have to agree on the project
-	# their changeset belongs to. In other words, all revisions in
-	# a changeset have to refer to the same project.
+	# All revisions have to agree on the project their changeset
+	# belongs to. In other words, all revisions in a changeset
+	# have to refer to the same project.
 	#
 	# Instead of looking at all pairs of revisions in all
 	# changesets we generate the distinct set of all projects
 	# referenced by the revisions of a changeset, look for those
@@ -390,10 +408,12 @@
 		SELECT T.name, C.cid
 		FROM   changeset C, cstype T
 		WHERE  C.cid IN (SELECT U.cid
 				 FROM (SELECT DISTINCT CR.cid AS cid, F.pid AS pid
-				       FROM   csrevision CR, revision R, file F
+				       FROM   csrevision CR, changeset C, revision R, file F
 				       WHERE  CR.rid = R.rid
+				       AND    C.cid = CR.cid
+				       AND    C.type = 0
 				       AND    F.fid  = R.fid) AS U
 				 GROUP BY U.cid HAVING COUNT(U.pid) > 1)
 		AND    T.tid = C.type
 	    }
@@ -414,13 +434,18 @@
 		FROM   changeset C, cstype T
 		WHERE  C.cid IN (SELECT VV.cid
 				 FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount
 				       FROM (SELECT DISTINCT CR.cid AS cid, R.fid AS fid
-					     FROM   csrevision CR, revision R
-					     WHERE  CR.rid = R.rid) AS U
+					     FROM   csrevision CR, changeset C, revision R
+					     WHERE  CR.rid = R.rid
+					     AND    C.cid = CR.cid
+					     AND    C.type = 0
+					     ) AS U
 				       GROUP BY U.cid) AS UU,
 				      (SELECT V.cid AS cid, COUNT (V.rid) AS rcount
-				       FROM csrevision V
+				       FROM   csrevision V, changeset X
+				       WHERE  X.cid = V.cid
+				       AND    X.type = 0
 				       GROUP BY V.cid) AS VV
 				 WHERE VV.cid = UU.cid
 				 AND   UU.fcount < VV.rcount)
 		AND    T.tid = C.type
@@ -427,39 +452,12 @@
 	    }
 	return
     }
 
-    proc RevisionChangesets {} {
+    proc TagChangesets {} {
 	# This code performs a number of paranoid checks of the
 	# database, searching for inconsistent changeset/revision
 	# information.
-
-	upvar 1 n n ; # Counter for the checks (we print an id before
-		      # the main label).
-
-	# All revisions used by revision changesets have to refer to
-	# the same meta information as their changeset.
-	CheckInCS \
-	    {All revisions have to agree with their revision changeset about the used meta information} \
-	    {disagrees with its revision changeset @ about the meta information} {
-		SELECT CT.name, C.cid, F.name, R.rev
-		FROM changeset C, cstype CT, revision R, file F, csrevision CR
-		WHERE C.type = 0       -- revision changesets only
-		AND   C.cid  = CR.cid  -- changeset --> its revisions
-		AND   R.rid  = CR.rid  -- look at them
-		AND   R.mid != C.src   -- Only those which disagree with changeset about the meta
-		AND   R.fid = F.fid    -- get file of the revision
-		AND   CT.tid = C.type  -- get changeset type, for labeling
-	    }
-	return
-    }
-
-    proc TagChangesets {} {
-	# This code performs a number of paranoid checks of the
-	# database, searching for inconsistent changeset/revision
-	# information.
-
-	return ; # Disabled for now, bottlenecks ...
 
 	upvar 1 n n ; # Counter for the checks (we print an id before
 		      # the main label).
     }
@@ -468,15 +466,13 @@
 	# This code performs a number of paranoid checks of the
 	# database, searching for inconsistent changeset/revision
 	# information.
 
-	return ; # Disabled for now, bottlenecks ...
-
 	upvar 1 n n ; # Counter for the checks (we print an id before
 		      # the main label).
     }
 
-    proc SymbolChangesets {} {
+    proc ___UnusedChangesetChecks___ {} {
 	# This code performs a number of paranoid checks of the
 	# database, searching for inconsistent changeset/revision
 	# information.
 
@@ -492,9 +488,9 @@
 	# indices, set and stream operations.
 
 	# All revisions used by tag symbol changesets have to have the
 	# changeset's tag associated with them.
-	CheckInCS \
+	CheckRevCS \
 	    {All revisions used by tag symbol changesets have to have the changeset's tag attached to them} \
 	    {does not have the tag of its symbol changeset @ attached to it} {
 		SELECT CT.name, C.cid, F.name, R.rev
 		FROM   changeset C, cstype CT, revision R, file F, csrevision CR, tag T
@@ -511,9 +507,9 @@
 
 	# All revisions used by branch symbol changesets have to have
 	# the changeset's branch associated with them.
 
-	CheckInCS \
+	CheckRevCS \
 	    {All revisions used by branch symbol changesets have to have the changeset's branch attached to them} \
 	    {does not have the branch of its symbol changeset @ attached to it} {
 		SELECT CT.name, C.cid, F.name, R.rev, C.cid
 		FROM   changeset C, cstype CT, revision R, file F, csrevision CR, branch B
@@ -543,9 +539,9 @@
 	upvar 1 n n
 	set ok 1
 	foreach {fname revnr} [state run $sql] {
 	    set ok 0
-	    trouble fatal "$fname <$revnr> $label"
+	    trouble fatal "${revnr}::$fname $label"
 	}
 	log write 5 integrity {\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header}
 	return
     }
@@ -582,9 +578,9 @@
 	log write 5 integrity {\[[format %02d [incr n]]\] [expr {$ok ? "Ok    " : "Failed"}] ... $header}
 	return
     }
 
-    proc CheckInCS {header label sql} {
+    proc CheckRevCS {header label sql} {
 	upvar 1 n n
 	set ok 1
 	foreach {cstype csid fname revnr} [state run $sql] {
 	    set ok 0