Fossil SCM

Reworked object deletion to happen centrally after the file has been processed (drop). Simplified the code restructuring the revision tree as it now doesn't have to think about when and where to remove objects.

aku 2007-10-23 03:29 trunk
Commit a766b08198e86c8aa0ca60c9b79e02af0afefacc
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -67,10 +67,16 @@
6767
6868
method persist {} {
6969
}
7070
7171
method drop {} {
72
+ foreach {_ rev} [array get myrev] { $rev destroy }
73
+ foreach {_ branch} [array get mybranches] { $branch destroy }
74
+ foreach {_ taglist} [array get mytags] {
75
+ foreach tag $taglist { $tag destroy }
76
+ }
77
+ return
7278
}
7379
7480
# # ## ### ##### ######## #############
7581
## Implement the sink
7682
@@ -576,10 +582,20 @@
576582
577583
} else {
578584
return {}
579585
}
580586
}
587
+
588
+ # General note: In the following methods we only modify the links
589
+ # between revisions and symbols to restructure the revision
590
+ # tree. We do __not__ destroy the objects. Given the complex links
591
+ # GC is difficult at this level. It is much easier to drop
592
+ # everything when we we are done. This happens in 'drop', using
593
+ # the state variable 'myrev', 'mybranches', and 'mytags'. What we
594
+ # have to persist, performed by 'persist', we know will be
595
+ # reachable through the revisions listed in 'myroots' and their
596
+ # children and symbols.
581597
582598
method AdjustNonTrunkDefaultBranch {revlist} {
583599
set stop [$myroot child] ;# rev '1.2'
584600
585601
log write 5 file "Adjusting NTDB containing [nsp [llength $revlist] revision]"
@@ -640,11 +656,10 @@
640656
log write 3 file "Removing irrelevant revision [$rev11 revnr]"
641657
642658
# Cut out the old myroot revision.
643659
644660
ldelete myroots $rev11 ; # Not a root any longer.
645
- unset myrev([$rev11 revnr])
646661
647662
$first cutfromparent ; # Sever revision from parent revision.
648663
if {$stop ne ""} {
649664
$stop cutfromparent
650665
lappend myroots $stop ; # New root, after vendor branch
@@ -653,11 +668,10 @@
653668
# Cut out the vendor branch symbol
654669
655670
set vendor [$first parentbranch]
656671
if {$vendor eq ""} { trouble internal "First NTDB revision has no branch" }
657672
if {[$vendor parent] eq $rev11} {
658
- unset mybranches([$vendor branchnr])
659673
$rev11 removebranch $vendor
660674
$rev11 removechildonbranch $first
661675
$first cutfromparentbranch
662676
lappend myroots $first
663677
}
@@ -665,11 +679,10 @@
665679
# Change the type of first (typically from Change to Add):
666680
$first retype add
667681
668682
# Move any tags and branches from the old to the new root.
669683
$rev11 movesymbolsto $first
670
- $rev11 destroy
671684
}
672685
673686
# Mark all the special revisions as such
674687
foreach rev $revlist {
675688
log write 3 file "Revision on default branch: [$rev revnr]"
@@ -764,19 +777,15 @@
764777
set branch [$root parentbranch]
765778
set parent [$root parent]
766779
set child [$root child]
767780
768781
ldelete myroots $root
769
- unset myrev([$root revnr])
770
- $child cutfromparent
771782
lappend myroots $child
772783
773
- $parent removechildonbranch $root
784
+ $child cutfromparent
774785
$parent removebranch $branch
775
-
776
- $branch destroy
777
- $root destroy
786
+ $parent removechildonbranch $root
778787
}
779788
return
780789
}
781790
782791
method LinesOfDevelopment {} {
@@ -847,12 +856,13 @@
847856
upvar 1 $nv ntdbroot
848857
set ntdbroot $root
849858
850859
set rev [$root child]
851860
while {$rev ne ""} {
852
- # See note [x].
853861
$rev removeallbranches
862
+ # See note [x].
863
+
854864
if {[$rev isondefaultbranch]} {
855865
set rev [$rev child]
856866
} else {
857867
set rev ""
858868
}
@@ -864,20 +874,17 @@
864874
865875
if {$rev ne ""} {
866876
set lastntdb [$rev parent]
867877
$lastntdb cutfromchild
868878
while {$rev ne ""} {
869
- set next [$rev child]
870
- unset myrev([$rev revnr])
871879
$rev removealltags
880
+ $rev removeallbranches
872881
# Note [x]: We may still have had branches on the
873882
# revision. Branches without revisions committed
874883
# on them do not show up in the list of roots aka
875
- # lines of development).
876
- $root removeallbranches
877
- $rev destroy
878
- set rev $next
884
+ # lines of development.
885
+ set rev [$rev child]
879886
}
880887
}
881888
return
882889
}
883890
@@ -884,27 +891,24 @@
884891
# No NTDB stuff to deal with. First delete the branch object
885892
# itself, after cutting all the various connections.
886893
887894
set branch [$root parentbranch]
888895
if {$branch ne ""} {
889
- set bparentrev [$branch parent]
890
- $bparentrev removebranch $branch
891
- $bparentrev removechildonbranch $root
892
- $branch destroy
896
+ set branchparent [$branch parent]
897
+ $branchparent removebranch $branch
898
+ $branchparent removechildonbranch $root
893899
}
894900
895901
# The root is no such any longer either.
896902
ldelete myroots $root
897903
898904
# Now go through the line and remove all its revisions.
899905
900906
while {$root ne ""} {
901
- set next [$root child]
902
- unset myrev([$root revnr])
903907
$root removealltags
904
- # Note: See the note [x].
905908
$root removeallbranches
909
+ # Note: See the note [x].
906910
907911
# From cvs2svn: If this is the last default revision on a
908912
# non-trunk default branch followed by a 1.2 revision,
909913
# then the 1.2 revision depends on this one. FIXME: It is
910914
# questionable whether this handling is correct, since the
@@ -921,12 +925,11 @@
921925
if {[$ntdbchild hasparent]} {
922926
lappend myroots [$ntdbchild parent]
923927
}
924928
}
925929
926
- $root destroy
927
- set root $next
930
+ set root [$root child]
928931
}
929932
930933
return
931934
}
932935
933936
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -67,10 +67,16 @@
67
68 method persist {} {
69 }
70
71 method drop {} {
 
 
 
 
 
 
72 }
73
74 # # ## ### ##### ######## #############
75 ## Implement the sink
76
@@ -576,10 +582,20 @@
576
577 } else {
578 return {}
579 }
580 }
 
 
 
 
 
 
 
 
 
 
581
582 method AdjustNonTrunkDefaultBranch {revlist} {
583 set stop [$myroot child] ;# rev '1.2'
584
585 log write 5 file "Adjusting NTDB containing [nsp [llength $revlist] revision]"
@@ -640,11 +656,10 @@
640 log write 3 file "Removing irrelevant revision [$rev11 revnr]"
641
642 # Cut out the old myroot revision.
643
644 ldelete myroots $rev11 ; # Not a root any longer.
645 unset myrev([$rev11 revnr])
646
647 $first cutfromparent ; # Sever revision from parent revision.
648 if {$stop ne ""} {
649 $stop cutfromparent
650 lappend myroots $stop ; # New root, after vendor branch
@@ -653,11 +668,10 @@
653 # Cut out the vendor branch symbol
654
655 set vendor [$first parentbranch]
656 if {$vendor eq ""} { trouble internal "First NTDB revision has no branch" }
657 if {[$vendor parent] eq $rev11} {
658 unset mybranches([$vendor branchnr])
659 $rev11 removebranch $vendor
660 $rev11 removechildonbranch $first
661 $first cutfromparentbranch
662 lappend myroots $first
663 }
@@ -665,11 +679,10 @@
665 # Change the type of first (typically from Change to Add):
666 $first retype add
667
668 # Move any tags and branches from the old to the new root.
669 $rev11 movesymbolsto $first
670 $rev11 destroy
671 }
672
673 # Mark all the special revisions as such
674 foreach rev $revlist {
675 log write 3 file "Revision on default branch: [$rev revnr]"
@@ -764,19 +777,15 @@
764 set branch [$root parentbranch]
765 set parent [$root parent]
766 set child [$root child]
767
768 ldelete myroots $root
769 unset myrev([$root revnr])
770 $child cutfromparent
771 lappend myroots $child
772
773 $parent removechildonbranch $root
774 $parent removebranch $branch
775
776 $branch destroy
777 $root destroy
778 }
779 return
780 }
781
782 method LinesOfDevelopment {} {
@@ -847,12 +856,13 @@
847 upvar 1 $nv ntdbroot
848 set ntdbroot $root
849
850 set rev [$root child]
851 while {$rev ne ""} {
852 # See note [x].
853 $rev removeallbranches
 
 
854 if {[$rev isondefaultbranch]} {
855 set rev [$rev child]
856 } else {
857 set rev ""
858 }
@@ -864,20 +874,17 @@
864
865 if {$rev ne ""} {
866 set lastntdb [$rev parent]
867 $lastntdb cutfromchild
868 while {$rev ne ""} {
869 set next [$rev child]
870 unset myrev([$rev revnr])
871 $rev removealltags
 
872 # Note [x]: We may still have had branches on the
873 # revision. Branches without revisions committed
874 # on them do not show up in the list of roots aka
875 # lines of development).
876 $root removeallbranches
877 $rev destroy
878 set rev $next
879 }
880 }
881 return
882 }
883
@@ -884,27 +891,24 @@
884 # No NTDB stuff to deal with. First delete the branch object
885 # itself, after cutting all the various connections.
886
887 set branch [$root parentbranch]
888 if {$branch ne ""} {
889 set bparentrev [$branch parent]
890 $bparentrev removebranch $branch
891 $bparentrev removechildonbranch $root
892 $branch destroy
893 }
894
895 # The root is no such any longer either.
896 ldelete myroots $root
897
898 # Now go through the line and remove all its revisions.
899
900 while {$root ne ""} {
901 set next [$root child]
902 unset myrev([$root revnr])
903 $root removealltags
904 # Note: See the note [x].
905 $root removeallbranches
 
906
907 # From cvs2svn: If this is the last default revision on a
908 # non-trunk default branch followed by a 1.2 revision,
909 # then the 1.2 revision depends on this one. FIXME: It is
910 # questionable whether this handling is correct, since the
@@ -921,12 +925,11 @@
921 if {[$ntdbchild hasparent]} {
922 lappend myroots [$ntdbchild parent]
923 }
924 }
925
926 $root destroy
927 set root $next
928 }
929
930 return
931 }
932
933
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -67,10 +67,16 @@
67
68 method persist {} {
69 }
70
71 method drop {} {
72 foreach {_ rev} [array get myrev] { $rev destroy }
73 foreach {_ branch} [array get mybranches] { $branch destroy }
74 foreach {_ taglist} [array get mytags] {
75 foreach tag $taglist { $tag destroy }
76 }
77 return
78 }
79
80 # # ## ### ##### ######## #############
81 ## Implement the sink
82
@@ -576,10 +582,20 @@
582
583 } else {
584 return {}
585 }
586 }
587
588 # General note: In the following methods we only modify the links
589 # between revisions and symbols to restructure the revision
590 # tree. We do __not__ destroy the objects. Given the complex links
591 # GC is difficult at this level. It is much easier to drop
592 # everything when we we are done. This happens in 'drop', using
593 # the state variable 'myrev', 'mybranches', and 'mytags'. What we
594 # have to persist, performed by 'persist', we know will be
595 # reachable through the revisions listed in 'myroots' and their
596 # children and symbols.
597
598 method AdjustNonTrunkDefaultBranch {revlist} {
599 set stop [$myroot child] ;# rev '1.2'
600
601 log write 5 file "Adjusting NTDB containing [nsp [llength $revlist] revision]"
@@ -640,11 +656,10 @@
656 log write 3 file "Removing irrelevant revision [$rev11 revnr]"
657
658 # Cut out the old myroot revision.
659
660 ldelete myroots $rev11 ; # Not a root any longer.
 
661
662 $first cutfromparent ; # Sever revision from parent revision.
663 if {$stop ne ""} {
664 $stop cutfromparent
665 lappend myroots $stop ; # New root, after vendor branch
@@ -653,11 +668,10 @@
668 # Cut out the vendor branch symbol
669
670 set vendor [$first parentbranch]
671 if {$vendor eq ""} { trouble internal "First NTDB revision has no branch" }
672 if {[$vendor parent] eq $rev11} {
 
673 $rev11 removebranch $vendor
674 $rev11 removechildonbranch $first
675 $first cutfromparentbranch
676 lappend myroots $first
677 }
@@ -665,11 +679,10 @@
679 # Change the type of first (typically from Change to Add):
680 $first retype add
681
682 # Move any tags and branches from the old to the new root.
683 $rev11 movesymbolsto $first
 
684 }
685
686 # Mark all the special revisions as such
687 foreach rev $revlist {
688 log write 3 file "Revision on default branch: [$rev revnr]"
@@ -764,19 +777,15 @@
777 set branch [$root parentbranch]
778 set parent [$root parent]
779 set child [$root child]
780
781 ldelete myroots $root
 
 
782 lappend myroots $child
783
784 $child cutfromparent
785 $parent removebranch $branch
786 $parent removechildonbranch $root
 
 
787 }
788 return
789 }
790
791 method LinesOfDevelopment {} {
@@ -847,12 +856,13 @@
856 upvar 1 $nv ntdbroot
857 set ntdbroot $root
858
859 set rev [$root child]
860 while {$rev ne ""} {
 
861 $rev removeallbranches
862 # See note [x].
863
864 if {[$rev isondefaultbranch]} {
865 set rev [$rev child]
866 } else {
867 set rev ""
868 }
@@ -864,20 +874,17 @@
874
875 if {$rev ne ""} {
876 set lastntdb [$rev parent]
877 $lastntdb cutfromchild
878 while {$rev ne ""} {
 
 
879 $rev removealltags
880 $rev removeallbranches
881 # Note [x]: We may still have had branches on the
882 # revision. Branches without revisions committed
883 # on them do not show up in the list of roots aka
884 # lines of development.
885 set rev [$rev child]
 
 
886 }
887 }
888 return
889 }
890
@@ -884,27 +891,24 @@
891 # No NTDB stuff to deal with. First delete the branch object
892 # itself, after cutting all the various connections.
893
894 set branch [$root parentbranch]
895 if {$branch ne ""} {
896 set branchparent [$branch parent]
897 $branchparent removebranch $branch
898 $branchparent removechildonbranch $root
 
899 }
900
901 # The root is no such any longer either.
902 ldelete myroots $root
903
904 # Now go through the line and remove all its revisions.
905
906 while {$root ne ""} {
 
 
907 $root removealltags
 
908 $root removeallbranches
909 # Note: See the note [x].
910
911 # From cvs2svn: If this is the last default revision on a
912 # non-trunk default branch followed by a 1.2 revision,
913 # then the 1.2 revision depends on this one. FIXME: It is
914 # questionable whether this handling is correct, since the
@@ -921,12 +925,11 @@
925 if {[$ntdbchild hasparent]} {
926 lappend myroots [$ntdbchild parent]
927 }
928 }
929
930 set root [$root child]
 
931 }
932
933 return
934 }
935
936
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -211,13 +211,10 @@
211211
set mybranchchildren {}
212212
return
213213
}
214214
215215
method removeallbranches {} {
216
- foreach branch $mybranches {
217
- $branch destroy
218
- }
219216
set mybranches {}
220217
set mybranchchildren {}
221218
return
222219
}
223220
@@ -229,11 +226,10 @@
229226
}
230227
231228
method tags {} { return $mytags }
232229
233230
method removealltags {} {
234
- foreach tag $mytags { $tag destroy }
235231
set mytags {}
236232
return
237233
}
238234
239235
method movetagsto {rev} {
240236
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -211,13 +211,10 @@
211 set mybranchchildren {}
212 return
213 }
214
215 method removeallbranches {} {
216 foreach branch $mybranches {
217 $branch destroy
218 }
219 set mybranches {}
220 set mybranchchildren {}
221 return
222 }
223
@@ -229,11 +226,10 @@
229 }
230
231 method tags {} { return $mytags }
232
233 method removealltags {} {
234 foreach tag $mytags { $tag destroy }
235 set mytags {}
236 return
237 }
238
239 method movetagsto {rev} {
240
--- tools/cvs2fossil/lib/c2f_frev.tcl
+++ tools/cvs2fossil/lib/c2f_frev.tcl
@@ -211,13 +211,10 @@
211 set mybranchchildren {}
212 return
213 }
214
215 method removeallbranches {} {
 
 
 
216 set mybranches {}
217 set mybranchchildren {}
218 return
219 }
220
@@ -229,11 +226,10 @@
226 }
227
228 method tags {} { return $mytags }
229
230 method removealltags {} {
 
231 set mytags {}
232 return
233 }
234
235 method movetagsto {rev} {
236

Keyboard Shortcuts

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