Fossil SCM

Added code able to exclude all non-trunk revisions upon user request.

aku 2007-10-21 06:10 trunk
Commit 886b6f257bc784ae18865130f21f04ed2ebb3c4f
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -667,11 +667,11 @@
667667
}
668668
669669
# Mark all the special revisions as such
670670
foreach rev $revlist {
671671
log write 3 file "Revision on default branch: [$rev revnr]"
672
- $rev isondefaultbranch
672
+ $rev setondefaultbranch 1
673673
}
674674
675675
if {$stop ne ""} {
676676
# Revision 1.2 logically follows the imported revisions,
677677
# not 1.1. Accordingly, connect it to the last NTDBR and
@@ -751,12 +751,11 @@
751751
# from trunk and delete the first branch revision.
752752
753753
# At this point we may have already multiple roots in myroots,
754754
# we have to process them all.
755755
756
- set lodroots [$self LinesOfDevelopment]
757
- foreach root $lodroots {
756
+ foreach root [$self LinesOfDevelopment] {
758757
if {[$root isneededbranchdel]} continue
759758
log write 2 file "Removing unnecessary initial branch delete [$root revnr]"
760759
761760
set branch [$root parentbranch]
762761
set parent [$root parent]
@@ -803,10 +802,174 @@
803802
}
804803
return
805804
}
806805
807806
method ExcludeNonTrunkInformation {} {
807
+ # Remove all non-trunk branches, revisions, and tags. We do
808
+ # keep the tags which are on the trunk.
809
+
810
+ set ntdbroot ""
811
+ foreach root [$self LinesOfDevelopment] {
812
+ # Note: Here the order of the roots is important,
813
+ # i.e. that we get them in depth first order. This ensures
814
+ # that the removal of a branch happens only after the
815
+ # branches spawned from it were removed. Otherwise the
816
+ # system might try to access deleted objects.
817
+
818
+ # Do not exclude the trunk.
819
+ if {[[$root lod] istrunk]} continue
820
+ $self ExcludeBranch $root ntdbroot
821
+ }
822
+
823
+ if {$ntdbroot ne ""} {
824
+ $self GraftNTDB2Trunk $ntdbroot
825
+ }
826
+ return
827
+ }
828
+
829
+ method ExcludeBranch {root nv} {
830
+ # Exclude the branch/lod starting at root, a revision.
831
+ #
832
+ # If the LOD starts with non-trunk default branch revisions,
833
+ # we leave them in place and do not delete the branch. In that
834
+ # case the command sets the variable in NV so that we can
835
+ # later rework these revisons to be purely trunk.
836
+
837
+ if {[$root isondefaultbranch]} {
838
+ # Handling a NTDB. This branch may consists not only of
839
+ # NTDB revisions, but also some non-NTDB. The latter are
840
+ # truly on a branch and have to be excluded. The following
841
+ # loop determines if there are such revisions.
842
+
843
+ upvar 1 $nv ntdbroot
844
+ set ntdbroot $root
845
+
846
+ set rev [$root child]
847
+ while {$rev ne ""} {
848
+ # See note [x].
849
+ $rev removeallbranches
850
+ if {[$rev isondefaultbranch]} {
851
+ set rev [$rev child]
852
+ } else {
853
+ set rev ""
854
+ }
855
+ }
856
+
857
+ # rev now contains the first non-NTDB revision after the
858
+ # NTDB, or is empty if there is no such. If we have some
859
+ # they have to removed.
860
+
861
+ if {$rev ne ""} {
862
+ set lastntdb [$rev parent]
863
+ $lastntdb cutfromchild
864
+ while {$rev ne ""} {
865
+ set next [$rev child]
866
+ unset myrev([$rev revnr])
867
+ $rev removealltags
868
+ # Note [x]: We may still have had branches on the
869
+ # revision. Branches without revisions committed
870
+ # on them do not show up in the list of roots aka
871
+ # lines of development).
872
+ $root removeallbranches
873
+ $rev destroy
874
+ set rev $next
875
+ }
876
+ }
877
+ return
878
+ }
879
+
880
+ # No NTDB stuff to deal with. First delete the branch object
881
+ # itself, after cutting all the various connections.
882
+
883
+ set branch [$root parentbranch]
884
+ if {$branch ne ""} {
885
+ set bparentrev [$branch parent]
886
+ $bparentrev removebranch $branch
887
+ $bparentrev removechildonbranch $root
888
+ $branch destroy
889
+ }
890
+
891
+ # The root is no such any longer either.
892
+ ldelete myroots $root
893
+
894
+ # Now go through the line and remove all its revisions.
895
+
896
+ while {$root ne ""} {
897
+ set next [$root child]
898
+ unset myrev([$root revnr])
899
+ $root removealltags
900
+ # Note: See the note [x].
901
+ $root removeallbranches
902
+
903
+ # From cvs2svn: If this is the last default revision on a
904
+ # non-trunk default branch followed by a 1.2 revision,
905
+ # then the 1.2 revision depends on this one. FIXME: It is
906
+ # questionable whether this handling is correct, since the
907
+ # non-trunk default branch revisions affect trunk and
908
+ # should therefore not just be discarded even if
909
+ # --trunk-only.
910
+
911
+ if {[$root hasdefaultbranchchild]} {
912
+ set ntdbchild [$root defaultbranchchild]
913
+ if {[$ntdbchild defaultbranchparent] ne $ntdbchild} {
914
+ trouble internal "ntdb - trunk linkage broken"
915
+ }
916
+ $ntdbchild cutdefaultbranchparent
917
+ if {[$ntdbchild hasparent]} {
918
+ lappend myroots [$ntdbchild parent]
919
+ }
920
+ }
921
+
922
+ $root destroy
923
+ set root $next
924
+ }
925
+
926
+ return
927
+ }
928
+
929
+ method GraftNTDB2Trunk {root} {
930
+ # We can now graft the non-trunk default branch revisions to
931
+ # trunk. They should already be alone on a CVSBranch-less
932
+ # branch.
933
+
934
+ if {[$root hasparentbranch]} { trouble internal "NTDB root still has its branch symbol" }
935
+ if {[$root hasbranches]} { trouble internal "NTDB root still has spawned branches" }
936
+
937
+ set last $root
938
+ while {[$last haschild]} {set last [$last child]}
939
+
940
+ if {[$last hasdefaultbranchchild]} {
941
+
942
+ set rev12 [$last defaultbranchchild]
943
+ $rev12 cutdefaultbranchparent
944
+ $last cutdefaultbranchchild
945
+
946
+ # TODO :: Combine into one method 'changeparent', or
947
+ # 'moveparent', etc.
948
+ $rev12 cutfromparent
949
+ $rev12 setparent $last
950
+
951
+ $last cutfromchild
952
+ $last setchild $rev12
953
+
954
+ ldelete myroots $rev12
955
+
956
+ # Note and remember that the type of rev12 was already
957
+ # adjusted by AdjustNonTrunkDefaultBranch, so we don't
958
+ # have to change its type here.
959
+ }
960
+
961
+ while {$root ne ""} {
962
+ $root setondefaultbranch 0
963
+ $root setlod $mytrunk
964
+ foreach tag [$root tags] {
965
+ $tag setlod $mytrunk
966
+ }
967
+ set root [$root child]
968
+ }
969
+
970
+ return
808971
}
809972
810973
# # ## ### ##### ######## #############
811974
## Configuration
812975
813976
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -667,11 +667,11 @@
667 }
668
669 # Mark all the special revisions as such
670 foreach rev $revlist {
671 log write 3 file "Revision on default branch: [$rev revnr]"
672 $rev isondefaultbranch
673 }
674
675 if {$stop ne ""} {
676 # Revision 1.2 logically follows the imported revisions,
677 # not 1.1. Accordingly, connect it to the last NTDBR and
@@ -751,12 +751,11 @@
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]
@@ -803,10 +802,174 @@
803 }
804 return
805 }
806
807 method ExcludeNonTrunkInformation {} {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
808 }
809
810 # # ## ### ##### ######## #############
811 ## Configuration
812
813
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -667,11 +667,11 @@
667 }
668
669 # Mark all the special revisions as such
670 foreach rev $revlist {
671 log write 3 file "Revision on default branch: [$rev revnr]"
672 $rev setondefaultbranch 1
673 }
674
675 if {$stop ne ""} {
676 # Revision 1.2 logically follows the imported revisions,
677 # not 1.1. Accordingly, connect it to the last NTDBR and
@@ -751,12 +751,11 @@
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 foreach root [$self LinesOfDevelopment] {
 
757 if {[$root isneededbranchdel]} continue
758 log write 2 file "Removing unnecessary initial branch delete [$root revnr]"
759
760 set branch [$root parentbranch]
761 set parent [$root parent]
@@ -803,10 +802,174 @@
802 }
803 return
804 }
805
806 method ExcludeNonTrunkInformation {} {
807 # Remove all non-trunk branches, revisions, and tags. We do
808 # keep the tags which are on the trunk.
809
810 set ntdbroot ""
811 foreach root [$self LinesOfDevelopment] {
812 # Note: Here the order of the roots is important,
813 # i.e. that we get them in depth first order. This ensures
814 # that the removal of a branch happens only after the
815 # branches spawned from it were removed. Otherwise the
816 # system might try to access deleted objects.
817
818 # Do not exclude the trunk.
819 if {[[$root lod] istrunk]} continue
820 $self ExcludeBranch $root ntdbroot
821 }
822
823 if {$ntdbroot ne ""} {
824 $self GraftNTDB2Trunk $ntdbroot
825 }
826 return
827 }
828
829 method ExcludeBranch {root nv} {
830 # Exclude the branch/lod starting at root, a revision.
831 #
832 # If the LOD starts with non-trunk default branch revisions,
833 # we leave them in place and do not delete the branch. In that
834 # case the command sets the variable in NV so that we can
835 # later rework these revisons to be purely trunk.
836
837 if {[$root isondefaultbranch]} {
838 # Handling a NTDB. This branch may consists not only of
839 # NTDB revisions, but also some non-NTDB. The latter are
840 # truly on a branch and have to be excluded. The following
841 # loop determines if there are such revisions.
842
843 upvar 1 $nv ntdbroot
844 set ntdbroot $root
845
846 set rev [$root child]
847 while {$rev ne ""} {
848 # See note [x].
849 $rev removeallbranches
850 if {[$rev isondefaultbranch]} {
851 set rev [$rev child]
852 } else {
853 set rev ""
854 }
855 }
856
857 # rev now contains the first non-NTDB revision after the
858 # NTDB, or is empty if there is no such. If we have some
859 # they have to removed.
860
861 if {$rev ne ""} {
862 set lastntdb [$rev parent]
863 $lastntdb cutfromchild
864 while {$rev ne ""} {
865 set next [$rev child]
866 unset myrev([$rev revnr])
867 $rev removealltags
868 # Note [x]: We may still have had branches on the
869 # revision. Branches without revisions committed
870 # on them do not show up in the list of roots aka
871 # lines of development).
872 $root removeallbranches
873 $rev destroy
874 set rev $next
875 }
876 }
877 return
878 }
879
880 # No NTDB stuff to deal with. First delete the branch object
881 # itself, after cutting all the various connections.
882
883 set branch [$root parentbranch]
884 if {$branch ne ""} {
885 set bparentrev [$branch parent]
886 $bparentrev removebranch $branch
887 $bparentrev removechildonbranch $root
888 $branch destroy
889 }
890
891 # The root is no such any longer either.
892 ldelete myroots $root
893
894 # Now go through the line and remove all its revisions.
895
896 while {$root ne ""} {
897 set next [$root child]
898 unset myrev([$root revnr])
899 $root removealltags
900 # Note: See the note [x].
901 $root removeallbranches
902
903 # From cvs2svn: If this is the last default revision on a
904 # non-trunk default branch followed by a 1.2 revision,
905 # then the 1.2 revision depends on this one. FIXME: It is
906 # questionable whether this handling is correct, since the
907 # non-trunk default branch revisions affect trunk and
908 # should therefore not just be discarded even if
909 # --trunk-only.
910
911 if {[$root hasdefaultbranchchild]} {
912 set ntdbchild [$root defaultbranchchild]
913 if {[$ntdbchild defaultbranchparent] ne $ntdbchild} {
914 trouble internal "ntdb - trunk linkage broken"
915 }
916 $ntdbchild cutdefaultbranchparent
917 if {[$ntdbchild hasparent]} {
918 lappend myroots [$ntdbchild parent]
919 }
920 }
921
922 $root destroy
923 set root $next
924 }
925
926 return
927 }
928
929 method GraftNTDB2Trunk {root} {
930 # We can now graft the non-trunk default branch revisions to
931 # trunk. They should already be alone on a CVSBranch-less
932 # branch.
933
934 if {[$root hasparentbranch]} { trouble internal "NTDB root still has its branch symbol" }
935 if {[$root hasbranches]} { trouble internal "NTDB root still has spawned branches" }
936
937 set last $root
938 while {[$last haschild]} {set last [$last child]}
939
940 if {[$last hasdefaultbranchchild]} {
941
942 set rev12 [$last defaultbranchchild]
943 $rev12 cutdefaultbranchparent
944 $last cutdefaultbranchchild
945
946 # TODO :: Combine into one method 'changeparent', or
947 # 'moveparent', etc.
948 $rev12 cutfromparent
949 $rev12 setparent $last
950
951 $last cutfromchild
952 $last setchild $rev12
953
954 ldelete myroots $rev12
955
956 # Note and remember that the type of rev12 was already
957 # adjusted by AdjustNonTrunkDefaultBranch, so we don't
958 # have to change its type here.
959 }
960
961 while {$root ne ""} {
962 $root setondefaultbranch 0
963 $root setlod $mytrunk
964 foreach tag [$root tags] {
965 $tag setlod $mytrunk
966 }
967 set root [$root child]
968 }
969
970 return
971 }
972
973 # # ## ### ##### ######## #############
974 ## Configuration
975
976
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -136,10 +136,13 @@
136136
if {$myparentbranch ne ""} { trouble internal "Branch parent already defined" }
137137
set myparentbranch $branch
138138
return
139139
}
140140
141
+ method hasparentbranch {} { return [expr {$myparentbranch ne ""}] }
142
+ method hasbranches {} { return [llength $mybranches] }
143
+
141144
method parentbranch {} { return $myparentbranch }
142145
method branches {} { return $mybranches }
143146
144147
method addbranch {branch} {
145148
lappend mybranches $branch
@@ -220,10 +223,12 @@
220223
method addtag {tag} {
221224
lappend mytags $tag
222225
return
223226
}
224227
228
+ method tags {} { return $mytags }
229
+
225230
method removealltags {} {
226231
foreach tag $mytags { $tag destroy }
227232
set mytags {}
228233
return
229234
}
@@ -268,11 +273,13 @@
268273
}
269274
270275
method operation {} { return $myoperation }
271276
method retype {x} { set myoperation $x ; return }
272277
273
- method isondefaultbranch {} { set myisondefaultbranch 1 ; return }
278
+ method isondefaultbranch {} { return $myisondefaultbranch }
279
+
280
+ method setondefaultbranch {x} { set myisondefaultbranch $x ; return }
274281
275282
method setdefaultbranchchild {rev} { set mydbchild $rev ; return }
276283
method setdefaultbranchparent {rev} {
277284
set mydbparent $rev
278285
@@ -282,10 +289,19 @@
282289
set pdead [expr {[$rev operation] ne "change"}]
283290
set myoperation $myopstate([list $pdead $sdead])
284291
return
285292
}
286293
294
+ method cutdefaultbranchparent {} { set mydbparent "" ; return }
295
+ method cutdefaultbranchchild {} { set mydbchild "" ; return }
296
+
297
+ method defaultbranchchild {} { return $mydbchild }
298
+ method defaultbranchparent {} { return $mydbparent }
299
+
300
+ method hasdefaultbranchchild {} { return [expr {$mydbchild ne ""}] }
301
+ method hasdefaultbranchparent {} { return [expr {$mydbparent ne ""}] }
302
+
287303
# # ## ### ##### ######## #############
288304
## Type API
289305
290306
typemethod istrunkrevnr {revnr} {
291307
return [expr {[llength [split $revnr .]] == 2}]
292308
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -136,10 +136,13 @@
136 if {$myparentbranch ne ""} { trouble internal "Branch parent already defined" }
137 set myparentbranch $branch
138 return
139 }
140
 
 
 
141 method parentbranch {} { return $myparentbranch }
142 method branches {} { return $mybranches }
143
144 method addbranch {branch} {
145 lappend mybranches $branch
@@ -220,10 +223,12 @@
220 method addtag {tag} {
221 lappend mytags $tag
222 return
223 }
224
 
 
225 method removealltags {} {
226 foreach tag $mytags { $tag destroy }
227 set mytags {}
228 return
229 }
@@ -268,11 +273,13 @@
268 }
269
270 method operation {} { return $myoperation }
271 method retype {x} { set myoperation $x ; return }
272
273 method isondefaultbranch {} { set myisondefaultbranch 1 ; return }
 
 
274
275 method setdefaultbranchchild {rev} { set mydbchild $rev ; return }
276 method setdefaultbranchparent {rev} {
277 set mydbparent $rev
278
@@ -282,10 +289,19 @@
282 set pdead [expr {[$rev operation] ne "change"}]
283 set myoperation $myopstate([list $pdead $sdead])
284 return
285 }
286
 
 
 
 
 
 
 
 
 
287 # # ## ### ##### ######## #############
288 ## Type API
289
290 typemethod istrunkrevnr {revnr} {
291 return [expr {[llength [split $revnr .]] == 2}]
292
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -136,10 +136,13 @@
136 if {$myparentbranch ne ""} { trouble internal "Branch parent already defined" }
137 set myparentbranch $branch
138 return
139 }
140
141 method hasparentbranch {} { return [expr {$myparentbranch ne ""}] }
142 method hasbranches {} { return [llength $mybranches] }
143
144 method parentbranch {} { return $myparentbranch }
145 method branches {} { return $mybranches }
146
147 method addbranch {branch} {
148 lappend mybranches $branch
@@ -220,10 +223,12 @@
223 method addtag {tag} {
224 lappend mytags $tag
225 return
226 }
227
228 method tags {} { return $mytags }
229
230 method removealltags {} {
231 foreach tag $mytags { $tag destroy }
232 set mytags {}
233 return
234 }
@@ -268,11 +273,13 @@
273 }
274
275 method operation {} { return $myoperation }
276 method retype {x} { set myoperation $x ; return }
277
278 method isondefaultbranch {} { return $myisondefaultbranch }
279
280 method setondefaultbranch {x} { set myisondefaultbranch $x ; return }
281
282 method setdefaultbranchchild {rev} { set mydbchild $rev ; return }
283 method setdefaultbranchparent {rev} {
284 set mydbparent $rev
285
@@ -282,10 +289,19 @@
289 set pdead [expr {[$rev operation] ne "change"}]
290 set myoperation $myopstate([list $pdead $sdead])
291 return
292 }
293
294 method cutdefaultbranchparent {} { set mydbparent "" ; return }
295 method cutdefaultbranchchild {} { set mydbchild "" ; return }
296
297 method defaultbranchchild {} { return $mydbchild }
298 method defaultbranchparent {} { return $mydbparent }
299
300 method hasdefaultbranchchild {} { return [expr {$mydbchild ne ""}] }
301 method hasdefaultbranchparent {} { return [expr {$mydbparent ne ""}] }
302
303 # # ## ### ##### ######## #############
304 ## Type API
305
306 typemethod istrunkrevnr {revnr} {
307 return [expr {[llength [split $revnr .]] == 2}]
308

Keyboard Shortcuts

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