Fossil SCM

Continued the work on pass II, wrangling a file into shape. Completed handling of unnecessary initial deletions on branches.

aku 2007-10-19 07:23 trunk
Commit 510cd0230374a2ccb952d45203fde9245ddbf8e6
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -691,14 +691,13 @@
691691
}
692692
return
693693
}
694694
695695
method RemoveIrrelevantDeletions {} {
696
- # From cvs2fossil:
697
- # If a file is added on a branch, then a trunk revision is
698
- # added at the same time in the 'Dead' state. This revision
699
- # doesn't do anything useful, so delete it.
696
+ # From cvs2svn: If a file is added on a branch, then a trunk
697
+ # revision is added at the same time in the 'Dead' state.
698
+ # This revision doesn't do anything useful, so delete it.
700699
701700
foreach root $myroots {
702701
if {[$root isneeded]} continue
703702
log write 2 file "Removing unnecessary dead revision [$root revnr]"
704703
@@ -731,17 +730,80 @@
731730
# any tags that were set on it.
732731
733732
$root removealltags
734733
735734
# This can only happen once per file, and we might have
736
- # just changed myroots, so break out of the loop:
735
+ # just changed myroots, so end the loop
737736
break
738737
}
739738
return
740739
}
741740
742741
method RemoveInitialBranchDeletions {} {
742
+ # From cvs2svn: If the first revision on a branch is an
743
+ # unnecessary delete, remove it.
744
+ #
745
+ # If a file is added on a branch (whether or not it already
746
+ # existed on trunk), then new versions of CVS add a first
747
+ # branch revision in the 'dead' state (to indicate that the
748
+ # file did not exist on the branch when the branch was
749
+ # created) followed by the second branch revision, which is an
750
+ # add. When we encounter this situation, we sever the branch
751
+ # from trunk and delete the first branch revision.
752
+
753
+ # At this point we may have already multiple roots in myroots,
754
+ # we have to process them all.
755
+
756
+ set lodroots [$self LinesOfDevelopment]
757
+ foreach root $lodroots {
758
+ if {[$root isneededbranchdel]} continue
759
+ log write 2 file "Removing unnecessary initial branch delete [$root revnr]"
760
+
761
+ set branch [$root parentbranch]
762
+ set parent [$root parent]
763
+ set child [$root child]
764
+
765
+ ldelete myroots $root
766
+ unset myrev([$root revnr])
767
+ $child cutfromparent
768
+ lappend myroots $child
769
+
770
+ $parent removechildonbranch $root
771
+ $parent removebranch $branch
772
+
773
+ $branch destroy
774
+ $root destroy
775
+ }
776
+ return
777
+ }
778
+
779
+ method LinesOfDevelopment {} {
780
+ # Determine all lines of development for the file. This are
781
+ # the known roots, and the root of all branches found on the
782
+ # line of primary children.
783
+
784
+ set lodroots {}
785
+ foreach root $myroots {
786
+ $self AddBranchedLinesOfDevelopment lodroots $root
787
+ lappend lodroots $root
788
+ }
789
+ return $lodroots
790
+ }
791
+
792
+ method AddBranchedLinesOfDevelopment {lv root} {
793
+ upvar 1 $lv lodroots
794
+ while {$root ne ""} {
795
+ foreach branch [$root branches] {
796
+ if {![$branch haschild]} continue
797
+ set child [$branch child]
798
+ # Recurse into the branch for deeper branches.
799
+ $self AddBranchedLinesOfDevelopment lodroots $child
800
+ lappend lodroots $child
801
+ }
802
+ set root [$root child]
803
+ }
804
+ return
743805
}
744806
745807
method ExcludeNonTrunkInformation {} {
746808
}
747809
748810
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -691,14 +691,13 @@
691 }
692 return
693 }
694
695 method RemoveIrrelevantDeletions {} {
696 # From cvs2fossil:
697 # If a file is added on a branch, then a trunk revision is
698 # added at the same time in the 'Dead' state. This revision
699 # doesn't do anything useful, so delete it.
700
701 foreach root $myroots {
702 if {[$root isneeded]} continue
703 log write 2 file "Removing unnecessary dead revision [$root revnr]"
704
@@ -731,17 +730,80 @@
731 # any tags that were set on it.
732
733 $root removealltags
734
735 # This can only happen once per file, and we might have
736 # just changed myroots, so break out of the loop:
737 break
738 }
739 return
740 }
741
742 method RemoveInitialBranchDeletions {} {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
743 }
744
745 method ExcludeNonTrunkInformation {} {
746 }
747
748
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -691,14 +691,13 @@
691 }
692 return
693 }
694
695 method RemoveIrrelevantDeletions {} {
696 # From cvs2svn: If a file is added on a branch, then a trunk
697 # revision is added at the same time in the 'Dead' state.
698 # This revision doesn't do anything useful, so delete it.
 
699
700 foreach root $myroots {
701 if {[$root isneeded]} continue
702 log write 2 file "Removing unnecessary dead revision [$root revnr]"
703
@@ -731,17 +730,80 @@
730 # any tags that were set on it.
731
732 $root removealltags
733
734 # This can only happen once per file, and we might have
735 # just changed myroots, so end the loop
736 break
737 }
738 return
739 }
740
741 method RemoveInitialBranchDeletions {} {
742 # From cvs2svn: If the first revision on a branch is an
743 # unnecessary delete, remove it.
744 #
745 # If a file is added on a branch (whether or not it already
746 # existed on trunk), then new versions of CVS add a first
747 # branch revision in the 'dead' state (to indicate that the
748 # file did not exist on the branch when the branch was
749 # created) followed by the second branch revision, which is an
750 # add. When we encounter this situation, we sever the branch
751 # from trunk and delete the first branch revision.
752
753 # At this point we may have already multiple roots in myroots,
754 # we have to process them all.
755
756 set lodroots [$self LinesOfDevelopment]
757 foreach root $lodroots {
758 if {[$root isneededbranchdel]} continue
759 log write 2 file "Removing unnecessary initial branch delete [$root revnr]"
760
761 set branch [$root parentbranch]
762 set parent [$root parent]
763 set child [$root child]
764
765 ldelete myroots $root
766 unset myrev([$root revnr])
767 $child cutfromparent
768 lappend myroots $child
769
770 $parent removechildonbranch $root
771 $parent removebranch $branch
772
773 $branch destroy
774 $root destroy
775 }
776 return
777 }
778
779 method LinesOfDevelopment {} {
780 # Determine all lines of development for the file. This are
781 # the known roots, and the root of all branches found on the
782 # line of primary children.
783
784 set lodroots {}
785 foreach root $myroots {
786 $self AddBranchedLinesOfDevelopment lodroots $root
787 lappend lodroots $root
788 }
789 return $lodroots
790 }
791
792 method AddBranchedLinesOfDevelopment {lv root} {
793 upvar 1 $lv lodroots
794 while {$root ne ""} {
795 foreach branch [$root branches] {
796 if {![$branch haschild]} continue
797 set child [$branch child]
798 # Recurse into the branch for deeper branches.
799 $self AddBranchedLinesOfDevelopment lodroots $child
800 lappend lodroots $child
801 }
802 set root [$root child]
803 }
804 return
805 }
806
807 method ExcludeNonTrunkInformation {} {
808 }
809
810
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -67,10 +67,47 @@
6767
set gen "file [file tail [$myfile usrpath]] was initially added on branch [$firstbranch name]."
6868
set log [$myfile commitmessageof $mymetaid]
6969
7070
return [expr {$log ne $gen}]
7171
}
72
+
73
+ method isneededbranchdel {} {
74
+ if {$myparentbranch eq ""} {return 1} ; # not first on a branch, needed
75
+ set base [$myparentbranch parent]
76
+ if {$base eq ""} {return 1} ; # branch has parent lod, needed
77
+ if {[$self LODLength] < 2} {return 1} ; # our lod contains only ourselves, needed.
78
+ if {$myoperation ne "delete"} {return 1} ; # Not a deletion, needed
79
+ if {[llength $mytags]} {return 1} ; # Have tags, needed
80
+ if {[llength $mybranches]} {return 1} ; # Have other branches, needed
81
+ if {abs($mydate - [$base date]) > 2} {return 1} ; # Next rev > 2 seconds apart, needed
82
+
83
+ # FIXME: This message will not match if the RCS file was
84
+ # renamed manually after it was created.
85
+
86
+ set qfile [string map {
87
+ . \\. ? \\? * \\* \\ \\\\ + \\+ ^ \\^ $ \\$
88
+ \[ \\\[ \] \\\] ( \\( ) \\) \{ \\\{ \} \\\}
89
+ } [file tail [$myfile usrpath]]]
90
+ set pattern "file $qfile was added on branch .* on \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}( \[+-\]\\d{4})?"
91
+ set log [$myfile commitmessageof $mymetaid]
92
+
93
+ # Not the special message, needed
94
+ if {![regexp -- $pattern $log]} {return 1}
95
+
96
+ # This is an unneeded initial branch delete.
97
+ return 0
98
+ }
99
+
100
+ method LODLength {} {
101
+ set n 1 ; # count self
102
+ set rev $mychild
103
+ while {$rev ne ""} {
104
+ incr n
105
+ set rev [$rev child]
106
+ }
107
+ return $n
108
+ }
72109
73110
# Basic parent/child linkage __________
74111
75112
method hasparent {} { return [expr {$myparent ne ""}] }
76113
method haschild {} { return [expr {$mychild ne ""}] }
77114
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -67,10 +67,47 @@
67 set gen "file [file tail [$myfile usrpath]] was initially added on branch [$firstbranch name]."
68 set log [$myfile commitmessageof $mymetaid]
69
70 return [expr {$log ne $gen}]
71 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
73 # Basic parent/child linkage __________
74
75 method hasparent {} { return [expr {$myparent ne ""}] }
76 method haschild {} { return [expr {$mychild ne ""}] }
77
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -67,10 +67,47 @@
67 set gen "file [file tail [$myfile usrpath]] was initially added on branch [$firstbranch name]."
68 set log [$myfile commitmessageof $mymetaid]
69
70 return [expr {$log ne $gen}]
71 }
72
73 method isneededbranchdel {} {
74 if {$myparentbranch eq ""} {return 1} ; # not first on a branch, needed
75 set base [$myparentbranch parent]
76 if {$base eq ""} {return 1} ; # branch has parent lod, needed
77 if {[$self LODLength] < 2} {return 1} ; # our lod contains only ourselves, needed.
78 if {$myoperation ne "delete"} {return 1} ; # Not a deletion, needed
79 if {[llength $mytags]} {return 1} ; # Have tags, needed
80 if {[llength $mybranches]} {return 1} ; # Have other branches, needed
81 if {abs($mydate - [$base date]) > 2} {return 1} ; # Next rev > 2 seconds apart, needed
82
83 # FIXME: This message will not match if the RCS file was
84 # renamed manually after it was created.
85
86 set qfile [string map {
87 . \\. ? \\? * \\* \\ \\\\ + \\+ ^ \\^ $ \\$
88 \[ \\\[ \] \\\] ( \\( ) \\) \{ \\\{ \} \\\}
89 } [file tail [$myfile usrpath]]]
90 set pattern "file $qfile was added on branch .* on \\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}( \[+-\]\\d{4})?"
91 set log [$myfile commitmessageof $mymetaid]
92
93 # Not the special message, needed
94 if {![regexp -- $pattern $log]} {return 1}
95
96 # This is an unneeded initial branch delete.
97 return 0
98 }
99
100 method LODLength {} {
101 set n 1 ; # count self
102 set rev $mychild
103 while {$rev ne ""} {
104 incr n
105 set rev [$rev child]
106 }
107 return $n
108 }
109
110 # Basic parent/child linkage __________
111
112 method hasparent {} { return [expr {$myparent ne ""}] }
113 method haschild {} { return [expr {$mychild ne ""}] }
114
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -76,39 +76,39 @@
7676
}
7777
7878
typemethod defauthor {a} {
7979
if {![info exists myauthor($a)]} {
8080
set myauthor($a) [incr myauthorcnt]
81
- log write 6 repository "author '$a' = $myauthor($a)"
81
+ log write 7 repository "author '$a' = $myauthor($a)"
8282
}
8383
return $myauthor($a)
8484
}
8585
8686
typemethod defcmessage {cm} {
8787
if {![info exists mycmsg($cm)]} {
8888
set mycmsg($cm) [set cid [incr mycmsgcnt]]
8989
set mycmsginv($cid) $cm
90
- log write 6 repository "cmessage '$cm' = $cid"
90
+ log write 7 repository "cmessage '$cm' = $cid"
9191
}
9292
return $mycmsg($cm)
9393
}
9494
9595
typemethod defsymbol {pid name} {
9696
set key [list $pid $name]
9797
if {![info exists mysymbol($key)]} {
9898
set mysymbol($key) [incr mysymbolcnt]
99
- log write 6 repository "symbol ($key) = $mysymbol($key)"
99
+ log write 7 repository "symbol ($key) = $mysymbol($key)"
100100
}
101101
return $mysymbol($key)
102102
}
103103
104104
typemethod defmeta {pid bid aid cid} {
105105
set key [list $pid $bid $aid $cid]
106106
if {![info exists mymeta($key)]} {
107107
set mymeta($key) [set mid [incr mymetacnt]]
108108
set mymetainv($mid) $key
109
- log write 6 repository "meta ($key) = $mymeta($key)"
109
+ log write 7 repository "meta ($key) = $mymeta($key)"
110110
}
111111
return $mymeta($key)
112112
}
113113
114114
typemethod commitmessageof {metaid} {
115115
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -76,39 +76,39 @@
76 }
77
78 typemethod defauthor {a} {
79 if {![info exists myauthor($a)]} {
80 set myauthor($a) [incr myauthorcnt]
81 log write 6 repository "author '$a' = $myauthor($a)"
82 }
83 return $myauthor($a)
84 }
85
86 typemethod defcmessage {cm} {
87 if {![info exists mycmsg($cm)]} {
88 set mycmsg($cm) [set cid [incr mycmsgcnt]]
89 set mycmsginv($cid) $cm
90 log write 6 repository "cmessage '$cm' = $cid"
91 }
92 return $mycmsg($cm)
93 }
94
95 typemethod defsymbol {pid name} {
96 set key [list $pid $name]
97 if {![info exists mysymbol($key)]} {
98 set mysymbol($key) [incr mysymbolcnt]
99 log write 6 repository "symbol ($key) = $mysymbol($key)"
100 }
101 return $mysymbol($key)
102 }
103
104 typemethod defmeta {pid bid aid cid} {
105 set key [list $pid $bid $aid $cid]
106 if {![info exists mymeta($key)]} {
107 set mymeta($key) [set mid [incr mymetacnt]]
108 set mymetainv($mid) $key
109 log write 6 repository "meta ($key) = $mymeta($key)"
110 }
111 return $mymeta($key)
112 }
113
114 typemethod commitmessageof {metaid} {
115
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -76,39 +76,39 @@
76 }
77
78 typemethod defauthor {a} {
79 if {![info exists myauthor($a)]} {
80 set myauthor($a) [incr myauthorcnt]
81 log write 7 repository "author '$a' = $myauthor($a)"
82 }
83 return $myauthor($a)
84 }
85
86 typemethod defcmessage {cm} {
87 if {![info exists mycmsg($cm)]} {
88 set mycmsg($cm) [set cid [incr mycmsgcnt]]
89 set mycmsginv($cid) $cm
90 log write 7 repository "cmessage '$cm' = $cid"
91 }
92 return $mycmsg($cm)
93 }
94
95 typemethod defsymbol {pid name} {
96 set key [list $pid $name]
97 if {![info exists mysymbol($key)]} {
98 set mysymbol($key) [incr mysymbolcnt]
99 log write 7 repository "symbol ($key) = $mysymbol($key)"
100 }
101 return $mysymbol($key)
102 }
103
104 typemethod defmeta {pid bid aid cid} {
105 set key [list $pid $bid $aid $cid]
106 if {![info exists mymeta($key)]} {
107 set mymeta($key) [set mid [incr mymetacnt]]
108 set mymetainv($mid) $key
109 log write 7 repository "meta ($key) = $mymeta($key)"
110 }
111 return $mymeta($key)
112 }
113
114 typemethod commitmessageof {metaid} {
115

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button