Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_frev.tcl part of check-in [a766b08198] - Reworked object deletion to happen centrally after the file has been processed (drop). Simplified the code restructuring the revision tree as it now doesn't have to think about when and where to remove objects. by aku on 2007-10-23 03:29:36. [view]

To:

File tools/cvs2fossil/lib/c2f_frev.tcl part of check-in [adf168e23e] - Extended handling of id's for files so that we have them for backreferences from symbols and revisions. Completed persistence of revisions and symbols at file-level and fixed small problem with left-over links to branches. by aku on 2007-10-24 08:01:01. [view]

@@ -17,8 +17,9 @@
 
 package require Tcl 8.4                             ; # Required runtime.
 package require snit                                ; # OO system.
 package require vc::tools::misc                     ; # Text formatting
+package require vc::fossil::import::cvs::state      ; # State storage.
 
 # # ## ### ##### ######## ############# #####################
 ##
 
@@ -33,8 +34,15 @@
 	set mystate    $state
 	set myfile     $thefile
 	return
     }
+
+    method defid {} {
+	set myid [incr myidcounter]
+	return
+    }
+
+    method id {} { return $myid }
 
     # Basic pieces ________________________
 
     method hasmeta {} { return [expr {$mymetaid ne ""}] }
@@ -333,14 +341,62 @@
 	return [join [lrange [split $branchnr .] 0 end-1] .]
     }
 
     # # ## ### ##### ######## #############
+
+    method persist {} {
+	set fid [$myfile id]
+	set op  $myopcode($myoperation)
+	set idb $myisondefaultbranch
+
+	struct::list assign $mytext cs cl
+	set cl [expr {$cl - $cs}]
+
+	lappend map @L@ [expr { [$mylod istrunk]        ? "NULL" : [$mylod          id] }]
+	lappend map @P@ [expr { ($myparent       eq "") ? "NULL" : [$myparent       id] }]
+	lappend map @C@ [expr { ($mychild        eq "") ? "NULL" : [$mychild        id] }]
+	lappend map @DP [expr { ($mydbparent     eq "") ? "NULL" : [$mydbparent     id] }]
+	lappend map @DC [expr { ($mydbchild      eq "") ? "NULL" : [$mydbchild      id] }]
+	lappend map @BP [expr { ($myparentbranch eq "") ? "NULL" : [$myparentbranch id] }]
+
+	set cmd {
+	    INSERT INTO revision ( rid,   fid, lod,  rev,      date,    state,    mid,       cs,  cl, op,   isdefault, parent, child, dbparent, dbchild, bparent)
+	    VALUES               ($myid, $fid, @L@, $myrevnr, $mydate, $mystate, $mymetaid, $cs, $cl, $op, $idb,       @P@,    @C@,   @DP,      @DC,     @BP);
+	}
+
+	state transaction {
+	    state run [string map $map $cmd]
+	}
+	return
+    }
+
+    # # ## ### ##### ######## #############
     ## State
+
+    # Persistent: myid                - revision.rid
+    #             myfile              - revision.fid
+    #             mylod               - revision.lod
+    #             myrevnr             - revision.rev
+    #             mydate              - revision.date
+    #             mystate             - revision.state
+    #             mymetaid            - revision.mid
+    #             mytext              - revision.{cs,cl}
+    #             myparent            - revision.parent
+    #             mychild             - revision.child
+    #             myparentbranch      - revision.bparent
+    #             myoperation         - revision.op
+    #             myisondefaultbranch - revision.isdefault
+    #             mydbparent          - revision.dbparent
+    #             mydbchild           - revision.dbchild
+
 
     typevariable mybranchpattern {^((?:\d+\.\d+\.)+)(?:0\.)?(\d+)$}
     # First a nonzero even number of digit groups with trailing dot
     # CVS then sticks an extra 0 in here; RCS does not.
     # And the last digit group.
+
+    typevariable myidcounter 0 ; # Counter for revision ids.
+    variable myid           {} ; # Revision id.
 
     variable myrevnr     {} ; # Revision number of the revision.
     variable mydate      {} ; # Timestamp of the revision, seconds since epoch
     variable myorigdate  {} ; # Original unmodified timestamp.
@@ -425,8 +481,14 @@
 	{0 1} delete
 	{1 0} add
 	{1 1} nothing
     }
+    typevariable myopcode -array {
+	change   2
+	delete  -1
+	add      1
+	nothing  0
+    }
 
     # # ## ### ##### ######## #############
     ## Internal methods
 
@@ -443,8 +505,9 @@
 namespace eval ::vc::fossil::import::cvs::file {
     namespace export rev
     namespace eval rev {
 	namespace import ::vc::tools::misc::*
+	namespace import ::vc::fossil::import::cvs::state
     }
 }
 
 # # ## ### ##### ######## ############# #####################