Check-in [6809145eb1]
Not logged in
Overview

SHA1 Hash:6809145eb16fb372e2e15f2dbc76b024db4fd095
Date: 2008-01-19 06:07:49
User: aku
Comment:More comments on sql statements.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified tools/cvs2fossil/lib/c2f_pcollrev.tcl from [f56e45ca7e] to [8de6139917].

@@ -247,14 +247,14 @@
 	    plural TEXT     NOT NULL,
 	    UNIQUE (name)
 	    UNIQUE (plural)
 	}
 	state run {
-	    INSERT INTO symtype VALUES (0,'excluded', 'excluded');
-	    INSERT INTO symtype VALUES (1,'tag',      'tags');
-	    INSERT INTO symtype VALUES (2,'branch',   'branches');
-	    INSERT INTO symtype VALUES (3,'undefined','undefined');
+	    INSERT INTO symtype VALUES (0,'excluded', 'excluded');  -- The ids are the fixed
+	    INSERT INTO symtype VALUES (1,'tag',      'tags');      -- pieces, see project::sym,
+	    INSERT INTO symtype VALUES (2,'branch',   'branches');  -- getsymtypes and associated
+	    INSERT INTO symtype VALUES (3,'undefined','undefined'); -- typevariables.
 	}
 
 	state extend meta {
 	    -- Meta data of revisions. See revision.mid for the
 	    -- reference. Many revisions can share meta data. This is
@@ -285,17 +285,17 @@
 
 	# Authors and commit messages are fully global, i.e. per
 	# repository.
 
 	state extend author {
-	    aid  INTEGER  NOT NULL  PRIMARY KEY  AUTOINCREMENT,
-	    name TEXT     NOT NULL  UNIQUE
+	    aid  INTEGER  NOT NULL  PRIMARY KEY  AUTOINCREMENT, -- Pool of the unique
+	    name TEXT     NOT NULL  UNIQUE                      -- author names.
 	}
 
 	state extend cmessage {
-	    cid  INTEGER  NOT NULL  PRIMARY KEY  AUTOINCREMENT,
-	    text TEXT     NOT NULL  UNIQUE
+	    cid  INTEGER  NOT NULL  PRIMARY KEY  AUTOINCREMENT, -- Pool of the unique
+	    text TEXT     NOT NULL  UNIQUE                      -- log messages
 	}
 
 	project::sym getsymtypes
 	file::rev    getopcodes
 	return

Modified tools/cvs2fossil/lib/c2f_pfiltersym.tcl from [84d0049634] to [a9820cd0e4].

@@ -149,13 +149,13 @@
 	array set link {}
 
 	foreach {id parent transfer} [state run {
 	    SELECT R.rid, R.parent, R.dbchild
 	    FROM  revision R, symbol S
-	    WHERE R.lod = S.sid
-	    AND   S.sid IN excludedsymbols
-	    AND   R.isdefault
+	    WHERE R.lod = S.sid            -- Get symbol of line-of-development of all revisions
+	    AND   S.sid IN excludedsymbols -- Restrict to the excluded symbols
+	    AND   R.isdefault              -- Restrict to NTDB revisions
 	}] {
 	    set ntdb($id) $parent
 	    if {$transfer eq ""} continue
 	    set link($id) $transfer
 	}
@@ -315,33 +315,33 @@
 	}] { set fpn($id) [list $fn $pn] }
 
 	set tagstoadjust [state run {
 	    SELECT T.tid, T.fid, T.lod, P.pid, S.name, R.rev, R.rid
 	    FROM tag T, preferedparent P, symbol S, revision R
-	    WHERE T.sid = P.sid
-	    AND   T.lod != P.pid
-	    AND   P.pid = S.sid
-	    AND   S.name != ':trunk:'
-	    AND   T.rev = R.rid
+	    WHERE T.sid = P.sid        -- For all tags, get left-hand of prefered parent via symbol
+	    AND   T.lod != P.pid       -- Restrict to tags whose LOD is not their prefered parent
+	    AND   P.pid = S.sid        -- Get symbol of prefered parent
+	    AND   S.name != ':trunk:'  -- Exclude trunk parentage
+	    AND   T.rev = R.rid        -- Get revision the tag is attached to.
 	}]
 
 	set branchestoadjust [state run {
 	    SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, NULL, NULL
 	    FROM branch B, preferedparent P, symbol S
-	    WHERE B.sid = P.sid
-	    AND   B.lod != P.pid
-	    AND   P.pid = S.sid
-	    AND   S.name != ':trunk:'
-	    AND   B.root IS NULL -- Accept free-floating branch
-	    UNION
+	    WHERE B.sid = P.sid        -- For all branches, get left-hand of prefered parent via symbol
+	    AND   B.lod != P.pid       -- Restrict to branches whose LOD is not their prefered parent
+	    AND   P.pid = S.sid        -- Get symbol of prefered parent
+	    AND   S.name != ':trunk:'  -- Exclude trunk parentage
+	    AND   B.root IS NULL       -- Accept free-floating branch
+    UNION
 	    SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
 	    FROM branch B, preferedparent P, symbol S, revision R
-	    WHERE B.sid = P.sid
-	    AND   B.lod != P.pid
-	    AND   P.pid = S.sid
-	    AND   S.name != ':trunk:'
-	    AND   B.root = R.rid
+	    WHERE B.sid = P.sid        -- For all branches, get left-hand of prefered parent via symbol
+	    AND   B.lod != P.pid       -- Restrict to branches whose LOD is not their prefered parent
+	    AND   P.pid = S.sid	       -- Get symbol of prefered parent
+	    AND   S.name != ':trunk:'  -- Exclude trunk parentage
+	    AND   B.root = R.rid       -- Get root revision of the branch
 	}]
 
 	set tmax [expr {[llength $tagstoadjust] / 7}]
 	set bmax [expr {[llength $branchestoadjust] / 8}]
 
@@ -360,22 +360,22 @@
 	set n 0
 	foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {
 	    # BOTTLE-NECK ...
 	    #
 	    # The check if the candidate (pid) is truly viable is
-	    # based finding the branch as possible parent, and done
+	    # based on finding the branch as possible parent, and done
 	    # now instead of as part of the already complex join.
 	    #
 	    # ... AND P.pid IN (SELECT B.sid
 	    #                   FROM branch B
 	    #                   WHERE B.root = R.rid)
 
 	    if {![state one {
-		SELECT COUNT(*)
+		SELECT COUNT(*)       -- Count <=> Check existence.
 		FROM branch B
-		WHERE  B.sid  = $pid
-		AND    B.root = $rid
+		WHERE  B.sid  = $pid  -- Restrict to branch for that symbol
+		AND    B.root = $rid  -- attached to that revision
 	    }]} {
 		incr tmax -1
 		set  mxs [format $fmt $tmax]
 		continue
 	    }
@@ -432,15 +432,15 @@
 	    # Such a branch can be regrafted without trouble and there
 	    # is no need to look for the new parent in its
 	    # non-existent root.
 
 	    if {($rid ne "") && ![state one {
-		SELECT COUNT(*)
+		SELECT COUNT(*)       -- Count <=> Check existence.
 		FROM branch B
-		WHERE  B.sid  = $pid
-		AND    B.root = $rid
-		AND    B.pos  > $pos
+		WHERE  B.sid  = $pid  -- Look for branch by symbol
+		AND    B.root = $rid  -- Spawned by the given revision
+		AND    B.pos  > $pos  -- And defined before branch to mutate
 	    }]} {
 		incr bmax -1
 		set  mxs [format $fmt $bmax]
 		continue
 	    }
@@ -471,10 +471,13 @@
     proc RefineSymbols {} {
 	# Tags and branches are marked as normal/noop based on the op
 	# of their revision.
 
 	log write 3 filtersym "Refine symbols (no-op or not?)"
+
+	# Note: The noop information is not used anywhere. Consider
+	# disabling this code, and removing the data from the state.
 
 	log write 4 filtersym "    Regular tags"
 	state run {
 	    INSERT INTO noop
 	    SELECT T.tid, 0

Modified tools/cvs2fossil/lib/c2f_prev.tcl from [28af7570f1] to [08cfcb0706].

@@ -742,13 +742,13 @@
 
     proc PD {id} {
 	foreach {p f r} [state run {
 		SELECT P.name , F.name, R.rev
 		FROM revision R, file F, project P
-		WHERE R.rid = $id
-		AND   F.fid = R.fid
-		AND   P.pid = F.pid
+		WHERE R.rid = $id    -- Find specified file revision
+		AND   F.fid = R.fid  -- Get file of the revision
+		AND   P.pid = F.pid  -- Get project of the file.
 	}] break
 	return "'$p : $f/$r'"
     }
 
     # Printing one or more ranges, formatted, and only their border to
@@ -819,13 +819,13 @@
 
     typemethod str {revision} {
 	struct::list assign [state run {
 	    SELECT R.rev, F.name, P.name
 	    FROM   revision R, file F, project P
-	    WHERE  R.rid = $revision
-	    AND    F.fid = R.fid
-	    AND    P.pid = F.pid
+	    WHERE  R.rid = $revision -- Find specified file revision
+	    AND    F.fid = R.fid     -- Get file of the revision
+	    AND    P.pid = F.pid     -- Get project of the file.
 	}] revnr fname pname
 	return "$pname/${revnr}::$fname"
     }
 
     # result = list (mintime, maxtime)
@@ -832,11 +832,11 @@
     typemethod timerange {items} {
 	set theset ('[join $items {','}]')
 	return [state run [subst -nocommands -nobackslashes {
 	    SELECT MIN(R.date), MAX(R.date)
 	    FROM revision R
-	    WHERE R.rid IN $theset
+	    WHERE R.rid IN $theset -- Restrict to revisions of interest
 	}]]
     }
 
     # var(dv) = dict (revision -> list (revision))
     typemethod internalsuccessors {dv revisions} {
@@ -850,11 +850,11 @@
 	# changeset internal dependencies.
 
 	array set dep {}
 
 	foreach {rid child} [state run [subst -nocommands -nobackslashes {
-   -- (1) Primary child
+    -- (1) Primary child
 	    SELECT R.rid, R.child
 	    FROM   revision R
 	    WHERE  R.rid   IN $theset     -- Restrict to revisions of interest
 	    AND    R.child IS NOT NULL    -- Has primary child
 	    AND    R.child IN $theset     -- Which is also of interest
@@ -928,11 +928,11 @@
     }
 
     # result = 4-list (itemtype itemid nextitemtype nextitemid ...)
     typemethod loops {revisions} {
 	# Note: Tags and branches cannot cause the loop. Their id's,
-	# bein of a fundamentally different type than the revisions
+	# being of a fundamentally different type than the revisions
 	# coming in cannot be in the set.
 
 	set theset ('[join $revisions {','}]')
 	return [state run [subst -nocommands -nobackslashes {
 	    -- (1) Primary child
@@ -994,11 +994,11 @@
 
 	# Note that the branches spawned from the revisions, and the
 	# tags associated with them are successors as well.
 
 	foreach {rid child} [state run [subst -nocommands -nobackslashes {
-   -- (1) Primary child
+    -- (1) Primary child
 	    SELECT R.rid, R.child
 	    FROM   revision R
 	    WHERE  R.rid   IN $theset     -- Restrict to revisions of interest
 	    AND    R.child IS NOT NULL    -- Has primary child
     UNION
@@ -1022,20 +1022,20 @@
 	    lappend dependencies([list rev $rid]) [list rev $child]
 	}
 	foreach {rid child} [state run [subst -nocommands -nobackslashes {
 	    SELECT R.rid, T.tid
 	    FROM   revision R, tag T
-	    WHERE  R.rid IN $theset
-	    AND    T.rev = R.rid
+	    WHERE  R.rid IN $theset       -- Restrict to revisions of interest
+	    AND    T.rev = R.rid          -- Select tags attached to them
 	}]] {
 	    lappend dependencies([list rev $rid]) [list sym::tag $child]
 	}
 	foreach {rid child} [state run [subst -nocommands -nobackslashes {
 	    SELECT R.rid, B.bid
 	    FROM   revision R, branch B
-	    WHERE  R.rid IN $theset
-	    AND    B.root = R.rid
+	    WHERE  R.rid IN $theset       -- Restrict to revisions of interest
+	    AND    B.root = R.rid         -- Select branches attached to them
 	}]] {
 	    lappend dependencies([list rev $rid]) [list sym::branch $child]
 	}
 	return
     }
@@ -1048,52 +1048,55 @@
         # CVS)) we return a very short and much more manageable list
         # of changesets.
 
 	set theset ('[join $revisions {','}]')
 	return [state run [subst -nocommands -nobackslashes {
+    -- (1) Primary child
 	    SELECT C.cid
 	    FROM   revision R, csitem CI, changeset C
 	    WHERE  R.rid   IN $theset     -- Restrict to revisions of interest
 	    AND    R.child IS NOT NULL    -- Has primary child
-            AND    CI.iid = R.child
-            AND    C.cid = CI.cid
-            AND    C.type = 0
+            AND    CI.iid = R.child       -- Select all changesets
+            AND    C.cid = CI.cid         -- containing the primary child
+            AND    C.type = 0             -- which are revision changesets
     UNION
+    -- (2) Secondary (branch) children
 	    SELECT C.cid
 	    FROM   revision R, revisionbranchchildren B, csitem CI, changeset C
 	    WHERE  R.rid   IN $theset     -- Restrict to revisions of interest
 	    AND    R.rid = B.rid          -- Select subset of branch children
-            AND    CI.iid = B.brid
-            AND    C.cid = CI.cid
-            AND    C.type = 0
+            AND    CI.iid = B.brid        -- Select all changesets
+            AND    C.cid = CI.cid	  -- containing the branch
+            AND    C.type = 0		  -- which are revision changesets
     UNION
+    -- (4) Child of trunk root successor of last NTDB on trunk.
 	    SELECT C.cid
 	    FROM   revision R, revision RA, csitem CI, changeset C
 	    WHERE  R.rid   IN $theset      -- Restrict to revisions of interest
 	    AND    R.isdefault             -- Restrict to NTDB
 	    AND    R.dbchild IS NOT NULL   -- and last NTDB belonging to trunk
 	    AND    RA.rid = R.dbchild      -- Go directly to trunk root
 	    AND    RA.child IS NOT NULL    -- Has primary child.
-            AND    CI.iid = RA.child
-            AND    C.cid = CI.cid
-            AND    C.type = 0
+            AND    CI.iid = RA.child       -- Select all changesets
+            AND    C.cid = CI.cid	   -- containing the primary child
+            AND    C.type = 0		   -- which are revision changesets
     UNION
 	    SELECT C.cid
 	    FROM   revision R, tag T, csitem CI, changeset C
-	    WHERE  R.rid in $theset
-	    AND    T.rev = R.rid
-            AND    CI.iid = T.tid
-            AND    C.cid = CI.cid
-            AND    C.type = 1
+	    WHERE  R.rid in $theset        -- Restrict to revisions of interest
+	    AND    T.rev = R.rid	   -- Select tags attached to them
+            AND    CI.iid = T.tid          -- Select all changesets
+            AND    C.cid = CI.cid	   -- containing the tags
+            AND    C.type = 1		   -- which are tag changesets
     UNION
 	    SELECT C.cid
 	    FROM   revision R, branch B, csitem CI, changeset C
-	    WHERE  R.rid in $theset
-	    AND    B.root = R.rid
-            AND    CI.iid = B.bid
-            AND    C.cid = CI.cid
-            AND    C.type = 2
+	    WHERE  R.rid in $theset        -- Restrict to revisions of interest
+	    AND    B.root = R.rid	   -- Select branches attached to them
+            AND    CI.iid = B.bid          -- Select all changesets
+            AND    C.cid = CI.cid	   -- containing the branches
+            AND    C.type = 2		   -- which are branch changesets
 	}]]
     }
 }
 
 # # ## ### ##### ######## ############# #####################
@@ -1107,14 +1110,14 @@
 
     typemethod str {tag} {
 	struct::list assign [state run {
 	    SELECT S.name, F.name, P.name
 	    FROM   tag T, symbol S, file F, project P
-	    WHERE  T.tid = $tag
-	    AND    F.fid = T.fid
-	    AND    P.pid = F.pid
-	    AND    S.sid = T.sid
+	    WHERE  T.tid = $tag   -- Find specified tag
+	    AND    F.fid = T.fid  -- Get file of tag
+	    AND    P.pid = F.pid  -- Get project of file
+	    AND    S.sid = T.sid  -- Get symbol of tag
 	}] sname fname pname
 	return "$pname/T'${sname}'::$fname"
     }
 
     # result = list (mintime, maxtime)
@@ -1124,12 +1127,12 @@
 
 	set theset ('[join $tags {','}]')
 	return [state run [subst -nocommands -nobackslashes {
 	    SELECT MIN(R.date), MAX(R.date)
 	    FROM   tag T, revision R
-	    WHERE  T.tid IN $theset
-            AND    R.rid = T.rev
+	    WHERE  T.tid IN $theset  -- Restrict to tags of interest
+            AND    R.rid = T.rev     -- Select tag parent revisions
 	}]]
     }
 
     # var(dv) = dict (item -> list (item)), item  = list (type id)
     typemethod successors {dv tags} {
@@ -1161,14 +1164,14 @@
 
     typemethod str {branch} {
 	struct::list assign [state run {
 	    SELECT S.name, F.name, P.name
 	    FROM   branch B, symbol S, file F, project P
-	    WHERE  B.bid = $branch
-	    AND    F.fid = B.fid
-	    AND    P.pid = F.pid
-	    AND    S.sid = B.sid
+	    WHERE  B.bid = $branch  -- Find specified branch
+	    AND    F.fid = B.fid    -- Get file of branch
+	    AND    P.pid = F.pid    -- Get project of file
+	    AND    S.sid = B.sid    -- Get symbol of branch
 	}] sname fname pname
 	return "$pname/B'${sname}'::$fname"
     }
 
     # result = list (mintime, maxtime)
@@ -1182,12 +1185,12 @@
 
 	set theset ('[join $branches {','}]')
 	return [state run [subst -nocommands -nobackslashes {
 	    SELECT IFNULL(MIN(R.date),0), IFNULL(MAX(R.date),0)
 	    FROM  branch B, revision R
-	    WHERE B.bid IN $theset
-            AND   R.rid = B.root
+	    WHERE B.bid IN $theset   -- Restrict to branches of interest
+            AND   R.rid = B.root     -- Select branch parent revisions
 	}]]
     }
 
     # result = 4-list (itemtype itemid nextitemtype nextitemid ...)
     typemethod loops {branches} {
@@ -1197,14 +1200,14 @@
 
 	set theset ('[join $branches {','}]')
 	return [state run [subst -nocommands -nobackslashes {
 	    SELECT B.bid, BX.bid
 	    FROM   branch B, preferedparent P, branch BX
-	    WHERE  B.bid IN $theset
-	    AND    B.sid = P.pid
-	    AND    BX.sid = P.sid
-	    AND    BX.bid IN $theset
+	    WHERE  B.bid IN $theset   -- Restrict to branches of interest
+	    AND    B.sid = P.pid      -- Get the prefered branches via
+	    AND    BX.sid = P.sid     -- the branch symbols
+	    AND    BX.bid IN $theset  -- Loop
 	}]]
     }
 
     # var(dv) = dict (item -> list (item)), item  = list (type id)
     typemethod successors {dv branches} {
@@ -1215,30 +1218,30 @@
 
 	set theset ('[join $branches {','}]')
 	foreach {bid child} [state run [subst -nocommands -nobackslashes {
 	    SELECT B.bid, R.rid
 	    FROM   branch B, revision R
-	    WHERE  B.bid IN $theset
-	    AND    B.first = R.rid
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.first = R.rid      -- Get first revision on the branch
 	}]] {
 	    lappend dependencies([list sym::branch $bid]) [list rev $child]
 	}
 	foreach {bid child} [state run [subst -nocommands -nobackslashes {
 	    SELECT B.bid, BX.bid
 	    FROM   branch B, preferedparent P, branch BX
-	    WHERE  B.bid IN $theset
-	    AND    B.sid = P.pid
-	    AND    BX.sid = P.sid
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.sid = P.pid        -- Get subordinate branches via the
+	    AND    BX.sid = P.sid       -- prefered parents of their symbols
 	}]] {
 	    lappend dependencies([list sym::branch $bid]) [list sym::branch $child]
 	}
 	foreach {bid child} [state run [subst -nocommands -nobackslashes {
 	    SELECT B.bid, T.tid
 	    FROM   branch B, preferedparent P, tag T
-	    WHERE  B.bid IN $theset
-	    AND    B.sid = P.pid
-	    AND    T.sid = P.sid
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.sid = P.pid        -- Get subordinate tags via the
+	    AND    T.sid = P.sid        -- prefered parents of their symbols
 	}]] {
 	    lappend dependencies([list sym::branch $bid]) [list sym::tag $child]
 	}
 	return
     }
@@ -1253,33 +1256,33 @@
 
 	set theset ('[join $branches {','}]')
         return [state run [subst -nocommands -nobackslashes {
 	    SELECT C.cid
 	    FROM   branch B, revision R, csitem CI, changeset C
-	    WHERE  B.bid IN $theset
-	    AND    B.first = R.rid
-            AND    CI.iid = R.rid
-            AND    C.cid = CI.cid
-            AND    C.type = 0
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.first = R.rid	-- Get first revision on the branch
+            AND    CI.iid = R.rid       -- Select all changesets
+            AND    C.cid = CI.cid	-- containing this revision
+            AND    C.type = 0		-- which are revision changesets
     UNION
 	    SELECT C.cid
 	    FROM   branch B, preferedparent P, branch BX, csitem CI, changeset C
-	    WHERE  B.bid IN $theset
-	    AND    B.sid = P.pid
-	    AND    BX.sid = P.sid
-            AND    CI.iid = BX.bid
-            AND    C.cid = CI.cid
-            AND    C.type = 2
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.sid = P.pid	-- Get subordinate branches via the
+	    AND    BX.sid = P.sid	-- prefered parents of their symbols
+            AND    CI.iid = BX.bid      -- Select all changesets
+            AND    C.cid = CI.cid	-- containing the subordinate branches
+            AND    C.type = 2		-- which are branch changesets
     UNION
 	    SELECT C.cid
 	    FROM   branch B, preferedparent P, tag T, csitem CI, changeset C
-	    WHERE  B.bid IN $theset
-	    AND    B.sid = P.pid
-	    AND    T.sid = P.sid
-            AND    CI.iid = T.tid
-            AND    C.cid = CI.cid
-            AND    C.type = 1
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.sid = P.pid	-- Get subordinate tags via the
+	    AND    T.sid = P.sid	-- prefered parents of their symbols
+            AND    CI.iid = T.tid       -- Select all changesets
+            AND    C.cid = CI.cid	-- containing the subordinate tags
+            AND    C.type = 1		-- which are tag changesets
 	}]]
 	return
     }
 
     typemethod limits {branches} {
@@ -1294,29 +1297,29 @@
 
 	set maxp [state run [subst -nocommands -nobackslashes {
 	    -- maximal predecessor position per branch
 	    SELECT B.bid, MAX (CO.pos)
 	    FROM   branch B, revision R, csitem CI, changeset C, csorder CO
-	    WHERE  B.bid IN $theset
-	    AND    B.root = R.rid
-	    AND    CI.iid = R.rid
-	    AND    C.cid = CI.cid
-	    AND    C.type = 0
-	    AND    CO.cid = C.cid
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.root = R.rid       -- Get branch root revisions
+	    AND    CI.iid = R.rid       -- Get changesets containing the
+	    AND    C.cid = CI.cid       -- root revisions, which are
+	    AND    C.type = 0           -- revision changesets
+	    AND    CO.cid = C.cid       -- Get their topological ordering
 	    GROUP BY B.bid
 	}]]
 
 	set mins [state run [subst -nocommands -nobackslashes {
 	    -- minimal successor position per branch
 	    SELECT B.bid, MIN (CO.pos)
 	    FROM   branch B, revision R, csitem CI, changeset C, csorder CO
-	    WHERE  B.bid IN $theset
-	    AND    B.first = R.rid
-	    AND    CI.iid = R.rid
-	    AND    C.cid = CI.cid
-	    AND    C.type = 0
-	    AND    CO.cid = C.cid
+	    WHERE  B.bid IN $theset     -- Restrict to branches of interest
+	    AND    B.first = R.rid      -- Get the first revisions on the branches
+	    AND    CI.iid = R.rid       -- Get changesets containing the
+	    AND    C.cid = CI.cid	-- first revisions, which are
+	    AND    C.type = 0		-- revision changesets
+	    AND    CO.cid = C.cid	-- Get their topological ordering
 	    GROUP BY B.bid
 	}]]
 
         return [list $maxp $mins]
     }

Modified tools/cvs2fossil/lib/c2f_repository.tcl from [6b33138cb4] to [87c45ff178].

@@ -279,11 +279,11 @@
     # pass IV+ results
     typemethod printcsetstatistics {} {
 	log write 2 repository "Changeset statistics"
 	# number of revisions, symbols, repository wide, and per project ...
 
-	set ccount [state one { SELECT COUNT (*) FROM changeset                 }]
+	set ccount [state one { SELECT COUNT (*) FROM changeset                }]
 	set rcount [state one { SELECT COUNT (*) FROM changeset WHERE type = 0 }]
 	set tcount [state one { SELECT COUNT (*) FROM changeset WHERE type = 1 }]
 	set bcount [state one { SELECT COUNT (*) FROM changeset WHERE type = 2 }]
 	set fmt %[string length [max [list $ccount $rcount $tcount $bcount]]]s