Diff
Not logged in

Differences From:

File tools/cvs2fossil/lib/c2f_file.tcl part of check-in [cfe4b269ac] - Added detection of irrelevant trunk revisions for files added to a branch but not the trunk. Repository extended to keep inverted indices for the meta data and commit messages for retrieval of commit messages per meta data, required for the previous. fixed problem with file objects, we kept only the rcs path, and need the user visible path too. by aku on 2007-10-17 04:37:05. [view]

To:

File tools/cvs2fossil/lib/c2f_file.tcl part of check-in [510cd02303] - Continued the work on pass II, wrangling a file into shape. Completed handling of unnecessary initial deletions on branches. by aku on 2007-10-19 07:23:57. [view]

@@ -692,12 +692,11 @@
 	return
     }
 
     method RemoveIrrelevantDeletions {} {
-	# From cvs2fossil:
-	# If a file is added on a branch, then a trunk revision is
-	# added at the same time in the 'Dead' state.  This revision
-	# doesn't do anything useful, so delete it.
+	# From cvs2svn: If a file is added on a branch, then a trunk
+	# revision is added at the same time in the 'Dead' state.
+	# This revision doesn't do anything useful, so delete it.
 
 	foreach root $myroots {
 	    if {[$root isneeded]} continue
 	    log write 2 file "Removing unnecessary dead revision [$root revnr]"
@@ -732,15 +731,78 @@
 
 	    $root removealltags
 
 	    # This can only happen once per file, and we might have
-	    # just changed myroots, so break out of the loop:
+	    # just changed myroots, so end the loop
 	    break
 	}
 	return
     }
 
     method RemoveInitialBranchDeletions {} {
+	# From cvs2svn: If the first revision on a branch is an
+	# unnecessary delete, remove it.
+	#
+	# If a file is added on a branch (whether or not it already
+	# existed on trunk), then new versions of CVS add a first
+	# branch revision in the 'dead' state (to indicate that the
+	# file did not exist on the branch when the branch was
+	# created) followed by the second branch revision, which is an
+	# add.  When we encounter this situation, we sever the branch
+	# from trunk and delete the first branch revision.
+
+	# At this point we may have already multiple roots in myroots,
+	# we have to process them all.
+
+	set lodroots [$self LinesOfDevelopment]
+	foreach root $lodroots {
+	    if {[$root isneededbranchdel]} continue
+	    log write 2 file "Removing unnecessary initial branch delete [$root revnr]"
+
+	    set branch [$root parentbranch]
+	    set parent [$root parent]
+	    set child  [$root child]
+
+	    ldelete myroots $root
+	    unset myrev([$root revnr])
+	    $child cutfromparent
+	    lappend myroots $child
+
+	    $parent removechildonbranch $root
+	    $parent removebranch        $branch
+
+	    $branch destroy
+	    $root   destroy
+	}
+	return
+    }
+
+    method LinesOfDevelopment {} {
+	# Determine all lines of development for the file. This are
+	# the known roots, and the root of all branches found on the
+	# line of primary children.
+
+	set lodroots {}
+	foreach root $myroots {
+	    $self AddBranchedLinesOfDevelopment lodroots $root
+	    lappend lodroots $root
+	}
+	return $lodroots
+    }
+
+    method AddBranchedLinesOfDevelopment {lv root} {
+	upvar 1 $lv lodroots
+	while {$root ne ""} {
+	    foreach branch [$root branches] {
+		if {![$branch haschild]} continue
+		set child [$branch child]
+		# Recurse into the branch for deeper branches.
+		$self AddBranchedLinesOfDevelopment lodroots $child
+		lappend lodroots $child
+	    }
+	    set root [$root child]
+	}
+	return
     }
 
     method ExcludeNonTrunkInformation {} {
     }