Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [348e45b0d6] - Added basic import of changesets. Note that this code is incomplete with regard to handling the various possible interactions between a vendor-branh and trunk. by aku on 2008-01-30 08:28:34. [view]

To:

File tools/cvs2fossil/lib/c2f_prev.tcl part of check-in [3cd599cacd] - Moved the most complex parts of pushto into their own commands. by aku on 2008-01-31 05:39:51. [view]

@@ -409,8 +409,44 @@
 
 	struct::list assign [$myproject getmeta $mysrcid] __ branch user message
 	struct::list assign $branch __ lodname
 
+	# Perform the import. As part of that convert the list of
+	# items in the changeset into uuids and printable data.
+
+	set uuid [Updatestate state $lodname \
+		      [$repository importrevision [$self str] \
+			   $user $message $date \
+			   [Getparent state $lodname $myproject] \
+			   [Getrevisioninfo $myitems]]]
+
+	# Remember the whole changeset / uuid mapping, for the tags.
+
+	state run {
+	    INSERT INTO csuuid (cid,   uuid)
+	    VALUES             ($myid, $uuid)
+	}
+	return
+    }
+
+    proc Getrevisioninfo {revisions} {
+	set theset ('[join $revisions {','}]')
+	set revisions {}
+	foreach {uuid fname revnr} [state run [subst -nocommands -nobackslashes {
+	    SELECT U.uuid, F.name, R.rev
+	    FROM   revision R, revuuid U, file F
+	    WHERE  R.rid IN $theset  -- All specified revisions
+	    AND    U.rid = R.rid     -- get fossil uuid of revision
+	    AND    F.fid = R.fid     -- get file of revision
+	}]] {
+	    lappend revisions $uuid $fname $revnr
+	}
+	return $revisions
+    }
+
+    proc Getparent {sv lodname project} {
+	upvar 1 $sv state
+
 	# The parent is determined via the line-of-development (LOD)
 	# information of each changeset, and the history of
 	# imports. The last changeset committed to the same LOD is
 	# taken as the parent of the current changeset. If the
@@ -428,52 +464,34 @@
 	#       trunk are not fully handled.
 
 	if {[info exists state($lodname)]} {
 	    # LOD exists and has already been committed to.
-	    set parent $state($lodname)
-	} else {
-	    # LOD has not been committed to before, this is the first
-	    # time. Determine the name of the parent LOD.
-
-	    set plodname [[[$myproject getsymbol $lodname] parent] name]
-
-	    if {[info exists state($plodname)]} {
-		# The parental LOD has been committed to, take that
-		# last changeset as the spawnpoint for the new LOD.
-		set parent $state($plodname)
-	    } else {
-		# The parental LOD is not defined (yet). This LOD is
-		# detached. We choose as our parent the automatic
-		# empty root baseline of the target repository.
-		set parent {}
-	    }
-	}
-
-	# Perform the import. As part of that convert the list of
-	# items in the changeset into uuids and printable data.
-
-	set theset ('[join $myitems {','}]')
-	set uuid [$repository importrevision [$self str] \
-		      $user $message $date $parent \
-		      [state run [subst -nocommands -nobackslashes {
-			  SELECT U.uuid, F.name, R.rev
-			  FROM   revision R, revuuid U, file F
-			  WHERE  R.rid IN $theset  -- All specified revisions
-			  AND    U.rid = R.rid     -- get fossil uuid of revision
-			  AND    F.fid = R.fid     -- get file of revision
-		      }]]]
-
+	    return $state($lodname)
+	}
+
+	# LOD has not been committed to before, this is the first
+	# time. Determine the name of the parent LOD.
+
+	set lodname [[[$project getsymbol $lodname] parent] name]
+
+	if {[info exists state($lodname)]} {
+	    # The parental LOD has been committed to, take that last
+	    # changeset as the spawnpoint for the new LOD.
+	    return $state($lodname)
+	}
+
+	# The parental LOD is not defined (yet). This LOD is
+	# detached. We choose as our parent the automatic empty root
+	# baseline of the target repository.
+	return {}
+    }
+
+    proc Updatestate {sv lodname uuid} {
 	# Remember the imported changeset in the state, under our LOD.
 
+	upvar 1 $sv state
 	set state($lodname) $uuid
-
-	# Remember the whole changeset / uuid mapping, for the tags.
-
-	state run {
-	    INSERT INTO csuuid (cid,   uuid)
-	    VALUES             ($myid, $uuid)
-	}
-	return
+	return $uuid
     }
 
     typemethod split {cset args} {
 	# As part of the creation of the new changesets specified in