Fossil

Check-in [510cd023]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Continued the work on pass II, wrangling a file into shape. Completed handling of unnecessary initial deletions on branches.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:510cd0230374a2ccb952d45203fde9245ddbf8e6
User & Date: aku 2007-10-19 07:23:57
Context
2007-10-21
04:42
Created a separate common class for the id databases used by the repository, and updated the repository code to use it. check-in: 99e165d5 user: aku tags: trunk
2007-10-19
07:23
Continued the work on pass II, wrangling a file into shape. Completed handling of unnecessary initial deletions on branches. check-in: 510cd023 user: aku tags: trunk
07:22
Extended the RCS parser to handle extended (aka new) phrases coming after the regular data of a revision, in the revision tree. check-in: 294156a3 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/cvs2fossil/lib/c2f_file.tcl.

689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
...
729
730
731
732
733
734
735
736
737
738
739
740
741
742































































743
744
745
746
747
748
749
	foreach {_ taglist} [array get mytags] {
	    foreach tag $taglist { $tag checklod }
	}
	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.

	foreach root $myroots {
	    if {[$root isneeded]} continue
	    log write 2 file "Removing unnecessary dead revision [$root revnr]"

	    # Remove as root, make its child new root after
	    # disconnecting it from the revision just going away.
................................................................................

	    # Tagging a dead revision doesn't do anything, so remove
	    # any tags that were set on it.

	    $root removealltags

	    # This can only happen once per file, and we might have
	    # just changed myroots, so break out of the loop:
	    break
	}
	return
    }

    method RemoveInitialBranchDeletions {} {































































    }

    method ExcludeNonTrunkInformation {} {
    }

    # # ## ### ##### ######## #############
    ## Configuration







<
|
|
|







 







|






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







689
690
691
692
693
694
695

696
697
698
699
700
701
702
703
704
705
...
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
	foreach {_ taglist} [array get mytags] {
	    foreach tag $taglist { $tag checklod }
	}
	return
    }

    method RemoveIrrelevantDeletions {} {

	# 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]"

	    # Remove as root, make its child new root after
	    # disconnecting it from the revision just going away.
................................................................................

	    # Tagging a dead revision doesn't do anything, so remove
	    # any tags that were set on it.

	    $root removealltags

	    # This can only happen once per file, and we might have
	    # 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 {} {
    }

    # # ## ### ##### ######## #############
    ## Configuration

Changes to tools/cvs2fossil/lib/c2f_frev.tcl.

65
66
67
68
69
70
71





































72
73
74
75
76
77
78
	# manually after it was created.

	set gen "file [file tail [$myfile usrpath]] was initially added on branch [$firstbranch name]."
	set log [$myfile commitmessageof $mymetaid]

	return [expr {$log ne $gen}]
    }






































    # Basic parent/child linkage __________

    method hasparent {} { return [expr {$myparent ne ""}] }
    method haschild  {} { return [expr {$mychild  ne ""}] }

    method setparent {parent} {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
	# manually after it was created.

	set gen "file [file tail [$myfile usrpath]] was initially added on branch [$firstbranch name]."
	set log [$myfile commitmessageof $mymetaid]

	return [expr {$log ne $gen}]
    }

    method isneededbranchdel {} {
	if {$myparentbranch eq ""}           {return 1} ; # not first on a branch, needed
	set base [$myparentbranch parent]
	if {$base           eq ""}           {return 1} ; # branch has parent lod, needed
	if {[$self LODLength] < 2}           {return 1} ; # our lod contains only ourselves, needed.
	if {$myoperation ne "delete"}        {return 1} ; # Not a deletion, needed
	if {[llength $mytags]}               {return 1} ; # Have tags, needed
	if {[llength $mybranches]}           {return 1} ; # Have other branches, needed
	if {abs($mydate - [$base date]) > 2} {return 1} ; # Next rev > 2 seconds apart, needed

        # FIXME: This message will not match if the RCS file was
        # renamed manually after it was created.

	set qfile [string map {
	    .  \\.  ?  \\?  *  \\*  \\ \\\\ +  \\+  ^ \\^ $ \\$
	    \[ \\\[ \] \\\] (  \\(   ) \\)  \{ \\\{ \} \\\}
	} [file tail [$myfile usrpath]]]
	set pattern "file $qfile was added on branch .* on \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}( \[+-\]\\d{4})?"
	set log     [$myfile commitmessageof $mymetaid]

	# Not the special message, needed
	if {![regexp -- $pattern $log]} {return 1}

	# This is an unneeded initial branch delete.
	return 0
    }

    method LODLength {} {
	set n 1 ; # count self
	set rev $mychild
	while {$rev ne ""} {
	    incr n
	    set rev [$rev child]
	}
	return $n
    }

    # Basic parent/child linkage __________

    method hasparent {} { return [expr {$myparent ne ""}] }
    method haschild  {} { return [expr {$mychild  ne ""}] }

    method setparent {parent} {

Changes to tools/cvs2fossil/lib/c2f_repository.tcl.

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
	}
	return
    }

    typemethod defauthor {a} {
	if {![info exists myauthor($a)]} {
	    set myauthor($a) [incr myauthorcnt]
	    log write 6 repository "author '$a' =  $myauthor($a)"
	}
	return $myauthor($a)
    }

    typemethod defcmessage {cm} {
	if {![info exists mycmsg($cm)]} {
	    set mycmsg($cm) [set cid [incr mycmsgcnt]]
	    set mycmsginv($cid) $cm
	    log write 6 repository "cmessage '$cm' =  $cid"
	}
	return $mycmsg($cm)
    }

    typemethod defsymbol {pid name} {
	set key [list $pid $name]
	if {![info exists mysymbol($key)]} {
	    set mysymbol($key) [incr mysymbolcnt]
	    log write 6 repository "symbol ($key) =  $mysymbol($key)"
	}
	return $mysymbol($key)
    }

    typemethod defmeta {pid bid aid cid} {
	set key [list $pid $bid $aid $cid]
	if {![info exists mymeta($key)]} {
	    set mymeta($key) [set mid [incr mymetacnt]]
	    set mymetainv($mid) $key
	    log write 6 repository "meta ($key) =  $mymeta($key)"
	}
	return $mymeta($key)
    }

    typemethod commitmessageof {metaid} {
	struct::list assign $mymetainv($metaid) pid bid aid cid
	return $mycmsginv($cid)







|








|








|









|







74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
	}
	return
    }

    typemethod defauthor {a} {
	if {![info exists myauthor($a)]} {
	    set myauthor($a) [incr myauthorcnt]
	    log write 7 repository "author '$a' =  $myauthor($a)"
	}
	return $myauthor($a)
    }

    typemethod defcmessage {cm} {
	if {![info exists mycmsg($cm)]} {
	    set mycmsg($cm) [set cid [incr mycmsgcnt]]
	    set mycmsginv($cid) $cm
	    log write 7 repository "cmessage '$cm' =  $cid"
	}
	return $mycmsg($cm)
    }

    typemethod defsymbol {pid name} {
	set key [list $pid $name]
	if {![info exists mysymbol($key)]} {
	    set mysymbol($key) [incr mysymbolcnt]
	    log write 7 repository "symbol ($key) =  $mysymbol($key)"
	}
	return $mysymbol($key)
    }

    typemethod defmeta {pid bid aid cid} {
	set key [list $pid $bid $aid $cid]
	if {![info exists mymeta($key)]} {
	    set mymeta($key) [set mid [incr mymetacnt]]
	    set mymetainv($mid) $key
	    log write 7 repository "meta ($key) =  $mymeta($key)"
	}
	return $mymeta($key)
    }

    typemethod commitmessageof {metaid} {
	struct::list assign $mymetainv($metaid) pid bid aid cid
	return $mycmsginv($cid)