Check-in [c3d5104084]
Not logged in
Overview

SHA1 Hash:c3d5104084f1efe90c40608171ef82969f7065de
Date: 2007-11-02 04:26:32
User: aku
Comment:Added code for the loading of pass II data (currently only the smybols) from the state when pass II is skipped.
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 [e14d8add6b] to [d447e0dea4].

@@ -8,20 +8,18 @@
 # This software consists of voluntary contributions made by many
 # individuals.  For exact contribution history, see the revision
 # history and logs, available at http://fossil-scm.hwaci.com/fossil
 # # ## ### ##### ######## ############# #####################
 
-## Pass II. This pass parses the colected rcs archives and extracts
+## Pass II. This pass parses the collected rcs archives and extracts
 ## all the information they contain (revisions, and symbols).
 
 # # ## ### ##### ######## ############# #####################
 ## 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::fossil::import::cvs::repository ; # Repository management.
 package require vc::fossil::import::cvs::state      ; # State storage.
@@ -176,11 +174,11 @@
 
 	state writing symbol {
 	    sid  INTEGER  NOT NULL  PRIMARY KEY AUTOINCREMENT,
 	    pid  INTEGER  NOT NULL  REFERENCES project,  -- Project the symbol belongs to
 	    name TEXT     NOT NULL,
-	    type INTEGER  NOT NULL,                      -- enum { tag = 1, branch, undefined }
+	    type INTEGER  NOT NULL  REFERENCES symtype,  -- enum { excluded = 0, tag, branch, undefined }
 
 	    tag_count    INTEGER  NOT NULL, -- How often the symbol is used as tag.
 	    branch_count INTEGER  NOT NULL, -- How often the symbol is used as branch
 	    commit_count INTEGER  NOT NULL, -- How often a file was committed on the symbol
 
@@ -202,10 +200,22 @@
 
 	    sid INTEGER  NOT NULL  REFERENCES symbol, --
 	    pid INTEGER  NOT NULL  REFERENCES symbol, -- Possible parent of sid
 	    n   INTEGER  NOT NULL,                    -- How often pid can act as parent.
 	    UNIQUE (sid, pid)
+	}
+
+	state writing symtype {
+	    tid   INTEGER  NOT NULL  PRIMARY KEY,
+	    name  TEXT     NOT NULL,
+	    UNIQUE (name)
+	}
+	state run {
+	    INSERT INTO symtype VALUES (0,'excluded');
+	    INSERT INTO symtype VALUES (1,'tag');
+	    INSERT INTO symtype VALUES (2,'branch');
+	    INSERT INTO symtype VALUES (3,'undefined');
 	}
 
 	state writing meta {
 	    -- Meta data of revisions. See revision.mid for the
 	    -- reference. Many revisions can share meta data. This is
@@ -249,11 +259,13 @@
 
 	return
     }
 
     typemethod load {} {
-	# TODO
+	state reading symbol
+
+	repository loadsymbols
 	return
     }
 
     typemethod run {} {
 	# Pass manager interface. Executed to perform the
@@ -313,10 +325,11 @@
 	state discard tag
 	state discard branch
 	state discard symbol
 	state discard blocker
 	state discard parent
+	state discard symtype
 	state discard meta
 	state discard author
 	state discard cmessage
 	return
     }

Modified tools/cvs2fossil/lib/c2f_project.tcl from [95678098d7] to [974891062e].

@@ -76,10 +76,14 @@
 	if {![info exists mysymbol($name)]} {
 	    set mysymbol($name) \
 		[sym %AUTO% $name [$myrepository defsymbol $myid $name] $self]
 	}
 	return $mysymbol($name)
+    }
+
+    method hassymbol {name} {
+	return [info exists mysymbol($name)]
     }
 
     method purgeghostsymbols {} {
 	set changes 1
 	while {$changes} {

Modified tools/cvs2fossil/lib/c2f_psym.tcl from [ec9334ebb7] to [08079c4d5a].

@@ -38,10 +38,17 @@
     method id   {} { return $myid   }
 
     # # ## ### ##### ######## #############
     ## Symbol statistics
 
+    method defcounts {tc bc cc} {
+	set mybranchcount $tc
+	set mytagcount    $bc
+	set mycommitcount $cc
+	return
+    }
+
     method countasbranch {} { incr mybranchcount ; return }
     method countastag    {} { incr mytagcount    ; return }
     method countacommit  {} { incr mycommitcount ; return }
 
     method blockedby {symbol} {
@@ -120,13 +127,15 @@
 
     variable mypparent -array {} ; # Maps from symbols to the number
 				   # of files in which it could have
 				   # been a parent of this symbol.
 
-    typevariable mytag    1 ; # Code for symbols which are tags.
-    typevariable mybranch 2 ; # Code for symbols which are branches.
-    typevariable myundef  3 ; # Code for symbols of unknown type.
+    # Keep the codes below in sync with 'pass::collrev/setup('symtype').
+    typevariable myexcluded 0 ; # Code for symbols which are excluded.
+    typevariable mytag      1 ; # Code for symbols which are tags.
+    typevariable mybranch   2 ; # Code for symbols which are branches.
+    typevariable myundef    3 ; # Code for symbols of unknown type.
 
     # # ## ### ##### ######## #############
     ## Internal methods
 
     # # ## ### ##### ######## #############

Modified tools/cvs2fossil/lib/c2f_ptrunk.tcl from [7dec41a873] to [6237ca73d6].

@@ -37,10 +37,14 @@
 
     method name    {} { return $myname }
     method id      {} { return $myid   }
     method istrunk {} { return 1 }
     method symbol  {} { return $self }
+
+    method forceid {id} { set myid $id ; return }
+
+    method defcounts {tc bc cc} {}
 
     method countasbranch {} {}
     method countastag    {} {}
     method countacommit  {} {}
 

Modified tools/cvs2fossil/lib/c2f_repository.tcl from [f4ffdfa30f] to [9474ee1654].

@@ -138,23 +138,25 @@
 	}
 	return
     }
 
     typemethod load {} {
-	array set pr {}
 	state transaction {
 	    foreach   {pid  name} [state run {
 		SELECT pid, name FROM project ;
 	    }] {
+		set project [project %AUTO% $name $type]
+
 		lappend myprojpaths $name
-		lappend myprojects [set pr($pid) [project %AUTO% $name $type]]
-		$pr($pid) setid $pid
+		lappend myprojects  $project
+		set myprojmap($pid) $project
+		$project setid $pid
 	    }
 	    foreach   {fid  pid  name  visible  exec} [state run {
 		SELECT fid, pid, name, visible, exec FROM file ;
 	    }] {
-		$pr($pid) addfile $name $visible $exec $fid
+		$myprojmap($pid) addfile $name $visible $exec $fid
 	    }
 	}
 	return
     }
 
@@ -177,18 +179,52 @@
 	    foreach p [TheProjects] { $p persistrev }
 	}
 	return
     }
 
+    typemethod loadsymbols {} {
+	state transaction {
+	    # We load the symbol ids at large to have the mapping
+	    # right from the beginning.
+
+	    foreach {sid pid name tc bc cc} [state run {
+		SELECT sid, pid, name, tag_count, branch_count, commit_count
+		FROM symbol
+		;
+	    }] {
+		$mysymbol map $sid [list $pid $name]
+		set project $myprojmap($pid)
+
+		set force  [$project hassymbol $name]
+		set symbol [$project getsymbol $name]
+
+		# Forcing happens only for the trunks.
+		if {$force} { $symbol forceid $sid }
+
+		# Set the loaded counts.
+		$symbol defcounts $tc $bc $cc
+
+		# Note: The type is neither retrieved nor set, for
+		# this is used to load the pass II data, which means
+		# that everything is 'undefined' at this point anyway.
+
+		# future: $symbol load (blockers, and parents)
+	    }
+	}
+	return
+    }
+
     # # ## ### ##### ######## #############
     ## State
 
     typevariable mybase           {} ; # Base path to CVS repository.
     typevariable myprojpaths      {} ; # List of paths to all declared
 				       # projects, relative to mybase.
     typevariable myprojects       {} ; # List of objects for all
 				       # declared projects.
+    typevariable myprojmap -array {} ; # Map from project ids to their
+				       # objects.
     typevariable myauthor         {} ; # Names of all authors found,
 				       # maps to their ids.
     typevariable mycmsg           {} ; # All commit messages found,
 				       # maps to their ids.
     typevariable mymeta           {} ; # Maps all meta data tuples

Modified tools/cvs2fossil/lib/id.tcl from [618dedd478] to [ad0171bebe].

@@ -31,10 +31,16 @@
 
 	set mydata($key)   $mycounter
 	set myinvert($mycounter) $key
 
 	return $mycounter
+    }
+
+    # Explicitly load the database with a mapping.
+    method map {id key} {
+	set mydata($key)   $id
+	set myinvert($id) $key
     }
 
     method keyof {id} { return $myinvert($id) }
     method get   {}   { return [array get mydata] }