Fossil SCM
Extended handling of id's for files so that we have them for backreferences from symbols and revisions. Completed persistence of revisions and symbols at file-level and fixed small problem with left-over links to branches.
Commit
adf168e23e3d3812bb7c49d385a1bfd797e23a36
Parent
fa643aa91d93c6c…
6 files changed
+59
-5
+63
+73
-2
+51
-44
+20
-11
+1
-1
+59
-5
| --- tools/cvs2fossil/lib/c2f_file.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_file.tcl | ||
| @@ -19,10 +19,11 @@ | ||
| 19 | 19 | package require Tcl 8.4 ; # Required runtime. |
| 20 | 20 | package require snit ; # OO system. |
| 21 | 21 | package require struct::set ; # Set operations. |
| 22 | 22 | package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions. |
| 23 | 23 | package require vc::fossil::import::cvs::file::sym ; # CVS per file symbols. |
| 24 | +package require vc::fossil::import::cvs::state ; # State storage. | |
| 24 | 25 | package require vc::tools::trouble ; # Error reporting. |
| 25 | 26 | package require vc::tools::log ; # User feedback |
| 26 | 27 | package require vc::tools::misc ; # Text formatting |
| 27 | 28 | |
| 28 | 29 | # # ## ### ##### ######## ############# ##################### |
| @@ -30,19 +31,27 @@ | ||
| 30 | 31 | |
| 31 | 32 | snit::type ::vc::fossil::import::cvs::file { |
| 32 | 33 | # # ## ### ##### ######## ############# |
| 33 | 34 | ## Public API |
| 34 | 35 | |
| 35 | - constructor {path usrpath executable project} { | |
| 36 | + constructor {id path usrpath executable project} { | |
| 37 | + set myid $id | |
| 36 | 38 | set mypath $path |
| 37 | 39 | set myusrpath $usrpath |
| 38 | 40 | set myexecutable $executable |
| 39 | 41 | set myproject $project |
| 40 | 42 | set mytrunk [$myproject trunk] |
| 41 | 43 | return |
| 42 | 44 | } |
| 43 | 45 | |
| 46 | + method setid {id} { | |
| 47 | + if {$myid ne ""} { trouble internal "File '$mypath' already has an id, '$myid'" } | |
| 48 | + set myid $id | |
| 49 | + return | |
| 50 | + } | |
| 51 | + | |
| 52 | + method id {} { return $myid } | |
| 44 | 53 | method path {} { return $mypath } |
| 45 | 54 | method usrpath {} { return $myusrpath } |
| 46 | 55 | method project {} { return $myproject } |
| 47 | 56 | |
| 48 | 57 | delegate method commitmessageof to myproject |
| @@ -64,10 +73,30 @@ | ||
| 64 | 73 | |
| 65 | 74 | # # ## ### ##### ######## ############# |
| 66 | 75 | ## Persistence (pass II) |
| 67 | 76 | |
| 68 | 77 | method persist {} { |
| 78 | + # First collect the reachable revisions and symbols, then | |
| 79 | + # assign id's to all. They are sorted so that we will have ids | |
| 80 | + # which sort in order of creation. Then we can save them. This | |
| 81 | + # is done bottom up. Revisions, then symbols. __NOTE__ This | |
| 82 | + # works only because sqlite is not checking foreign key | |
| 83 | + # references during insert. This allows to have dangling | |
| 84 | + # references which are fixed later. The longest dangling | |
| 85 | + # references are for the project level symbols, these we do | |
| 86 | + # not save here, but at the end of the pass. What we need are | |
| 87 | + # the ids, hence the two phases. | |
| 88 | + | |
| 89 | + struct::list assign [$self Active] revisions symbols | |
| 90 | + foreach rev $revisions { $rev defid } | |
| 91 | + foreach sym $symbols { $sym defid } | |
| 92 | + | |
| 93 | + state transaction { | |
| 94 | + foreach rev $revisions { $rev persist } | |
| 95 | + foreach sym $symbols { $sym persist } | |
| 96 | + } | |
| 97 | + return | |
| 69 | 98 | } |
| 70 | 99 | |
| 71 | 100 | method drop {} { |
| 72 | 101 | foreach {_ rev} [array get myrev] { $rev destroy } |
| 73 | 102 | foreach {_ branch} [array get mybranches] { $branch destroy } |
| @@ -220,10 +249,11 @@ | ||
| 220 | 249 | } |
| 221 | 250 | |
| 222 | 251 | # # ## ### ##### ######## ############# |
| 223 | 252 | ## State |
| 224 | 253 | |
| 254 | + variable myid {} ; # File id in the persistent state. | |
| 225 | 255 | variable mypath {} ; # Path of the file's rcs archive. |
| 226 | 256 | variable myusrpath {} ; # Path of the file as seen by users. |
| 227 | 257 | variable myexecutable 0 ; # Boolean flag 'file executable'. |
| 228 | 258 | variable myproject {} ; # Reference to the project object |
| 229 | 259 | # the file belongs to. |
| @@ -308,18 +338,18 @@ | ||
| 308 | 338 | if {[info exists mybranches($branchnr)]} { |
| 309 | 339 | log write 1 file "In '$mypath': Branch '$branchnr' named '[$mybranches($branchnr) name]'" |
| 310 | 340 | log write 1 file "Cannot have second name '$name', ignoring it" |
| 311 | 341 | return |
| 312 | 342 | } |
| 313 | - set branch [sym %AUTO% branch $branchnr [$myproject getsymbol $name]] | |
| 343 | + set branch [sym %AUTO% branch $branchnr [$myproject getsymbol $name] $self] | |
| 314 | 344 | $branch setposition [incr mybranchcnt] |
| 315 | 345 | set mybranches($branchnr) $branch |
| 316 | 346 | return $branch |
| 317 | 347 | } |
| 318 | 348 | |
| 319 | 349 | method AddTag {name revnr} { |
| 320 | - set tag [sym %AUTO% tag $revnr [$myproject getsymbol $name]] | |
| 350 | + set tag [sym %AUTO% tag $revnr [$myproject getsymbol $name] $self] | |
| 321 | 351 | lappend mytags($revnr) $tag |
| 322 | 352 | return $tag |
| 323 | 353 | } |
| 324 | 354 | |
| 325 | 355 | method RecordBasicDependencies {revnr next} { |
| @@ -378,11 +408,11 @@ | ||
| 378 | 408 | # If revisions were committed on the branch we store a |
| 379 | 409 | # reference to the branch there, and further declare |
| 380 | 410 | # the first child's parent to be branch's parent, and |
| 381 | 411 | # list this child in the parent revision. |
| 382 | 412 | |
| 383 | - if {[$branch haschild]} { | |
| 413 | + if {[$branch haschildrev]} { | |
| 384 | 414 | set childrevnr [$branch childrevnr] |
| 385 | 415 | set child $myrev($childrevnr) |
| 386 | 416 | $branch setchild $child |
| 387 | 417 | |
| 388 | 418 | $child setparentbranch $branch |
| @@ -670,10 +700,11 @@ | ||
| 670 | 700 | set vendor [$first parentbranch] |
| 671 | 701 | if {$vendor eq ""} { trouble internal "First NTDB revision has no branch" } |
| 672 | 702 | if {[$vendor parent] eq $rev11} { |
| 673 | 703 | $rev11 removebranch $vendor |
| 674 | 704 | $rev11 removechildonbranch $first |
| 705 | + $vendor cutchild | |
| 675 | 706 | $first cutfromparentbranch |
| 676 | 707 | lappend myroots $first |
| 677 | 708 | } |
| 678 | 709 | |
| 679 | 710 | # Change the type of first (typically from Change to Add): |
| @@ -726,11 +757,11 @@ | ||
| 726 | 757 | set child [$root child] |
| 727 | 758 | $child cutfromparent |
| 728 | 759 | lappend myroots $child |
| 729 | 760 | } |
| 730 | 761 | |
| 731 | - # Remove the branches spawned by the revision to be | |
| 762 | + # Cut out the branches spawned by the revision to be | |
| 732 | 763 | # deleted. If the branch has revisions they should already |
| 733 | 764 | # use operation 'add', no need to change that. The first |
| 734 | 765 | # revision on each branch becomes a new and disconnected |
| 735 | 766 | # root. |
| 736 | 767 | |
| @@ -737,10 +768,11 @@ | ||
| 737 | 768 | foreach branch [$root branches] { |
| 738 | 769 | if {![$branch haschild]} continue |
| 739 | 770 | set first [$branch child] |
| 740 | 771 | $first cutfromparentbranch |
| 741 | 772 | $first cutfromparent |
| 773 | + $branch cutchild | |
| 742 | 774 | lappend myroots $first |
| 743 | 775 | } |
| 744 | 776 | $root removeallbranches |
| 745 | 777 | |
| 746 | 778 | # Tagging a dead revision doesn't do anything, so remove |
| @@ -779,11 +811,13 @@ | ||
| 779 | 811 | set child [$root child] |
| 780 | 812 | |
| 781 | 813 | ldelete myroots $root |
| 782 | 814 | lappend myroots $child |
| 783 | 815 | |
| 816 | + $branch cutchild | |
| 784 | 817 | $child cutfromparent |
| 818 | + | |
| 785 | 819 | $parent removebranch $branch |
| 786 | 820 | $parent removechildonbranch $root |
| 787 | 821 | } |
| 788 | 822 | return |
| 789 | 823 | } |
| @@ -970,10 +1004,29 @@ | ||
| 970 | 1004 | set root [$root child] |
| 971 | 1005 | } |
| 972 | 1006 | |
| 973 | 1007 | return |
| 974 | 1008 | } |
| 1009 | + | |
| 1010 | + method Active {} { | |
| 1011 | + set revisions {} | |
| 1012 | + set symbols {} | |
| 1013 | + | |
| 1014 | + foreach root [$self LinesOfDevelopment] { | |
| 1015 | + if {[$root hasparentbranch]} { lappend symbols [$root parentbranch] } | |
| 1016 | + while {$root ne ""} { | |
| 1017 | + lappend revisions $root | |
| 1018 | + foreach tag [$root tags] { lappend symbols $tag } | |
| 1019 | + foreach branch [$root branches] { lappend symbols $branch } | |
| 1020 | + set lod [$root lod] | |
| 1021 | + if {![$lod istrunk]} { lappend symbols $lod } | |
| 1022 | + set root [$root child] | |
| 1023 | + } | |
| 1024 | + } | |
| 1025 | + | |
| 1026 | + return [list [lsort -unique -dict $revisions] [lsort -unique -dict $symbols]] | |
| 1027 | + } | |
| 975 | 1028 | |
| 976 | 1029 | # # ## ### ##### ######## ############# |
| 977 | 1030 | ## Configuration |
| 978 | 1031 | |
| 979 | 1032 | pragma -hastypeinfo no ; # no type introspection |
| @@ -990,13 +1043,14 @@ | ||
| 990 | 1043 | # namespace import ::vc::fossil::import::cvs::file::rev |
| 991 | 1044 | # namespace import ::vc::fossil::import::cvs::file::sym |
| 992 | 1045 | namespace import ::vc::tools::misc::* |
| 993 | 1046 | namespace import ::vc::tools::trouble |
| 994 | 1047 | namespace import ::vc::tools::log |
| 1048 | + namespace import ::vc::fossil::import::cvs::state | |
| 995 | 1049 | } |
| 996 | 1050 | } |
| 997 | 1051 | |
| 998 | 1052 | # # ## ### ##### ######## ############# ##################### |
| 999 | 1053 | ## Ready |
| 1000 | 1054 | |
| 1001 | 1055 | package provide vc::fossil::import::cvs::file 1.0 |
| 1002 | 1056 | return |
| 1003 | 1057 |
| --- tools/cvs2fossil/lib/c2f_file.tcl | |
| +++ tools/cvs2fossil/lib/c2f_file.tcl | |
| @@ -19,10 +19,11 @@ | |
| 19 | package require Tcl 8.4 ; # Required runtime. |
| 20 | package require snit ; # OO system. |
| 21 | package require struct::set ; # Set operations. |
| 22 | package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions. |
| 23 | package require vc::fossil::import::cvs::file::sym ; # CVS per file symbols. |
| 24 | package require vc::tools::trouble ; # Error reporting. |
| 25 | package require vc::tools::log ; # User feedback |
| 26 | package require vc::tools::misc ; # Text formatting |
| 27 | |
| 28 | # # ## ### ##### ######## ############# ##################### |
| @@ -30,19 +31,27 @@ | |
| 30 | |
| 31 | snit::type ::vc::fossil::import::cvs::file { |
| 32 | # # ## ### ##### ######## ############# |
| 33 | ## Public API |
| 34 | |
| 35 | constructor {path usrpath executable project} { |
| 36 | set mypath $path |
| 37 | set myusrpath $usrpath |
| 38 | set myexecutable $executable |
| 39 | set myproject $project |
| 40 | set mytrunk [$myproject trunk] |
| 41 | return |
| 42 | } |
| 43 | |
| 44 | method path {} { return $mypath } |
| 45 | method usrpath {} { return $myusrpath } |
| 46 | method project {} { return $myproject } |
| 47 | |
| 48 | delegate method commitmessageof to myproject |
| @@ -64,10 +73,30 @@ | |
| 64 | |
| 65 | # # ## ### ##### ######## ############# |
| 66 | ## Persistence (pass II) |
| 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 } |
| @@ -220,10 +249,11 @@ | |
| 220 | } |
| 221 | |
| 222 | # # ## ### ##### ######## ############# |
| 223 | ## State |
| 224 | |
| 225 | variable mypath {} ; # Path of the file's rcs archive. |
| 226 | variable myusrpath {} ; # Path of the file as seen by users. |
| 227 | variable myexecutable 0 ; # Boolean flag 'file executable'. |
| 228 | variable myproject {} ; # Reference to the project object |
| 229 | # the file belongs to. |
| @@ -308,18 +338,18 @@ | |
| 308 | if {[info exists mybranches($branchnr)]} { |
| 309 | log write 1 file "In '$mypath': Branch '$branchnr' named '[$mybranches($branchnr) name]'" |
| 310 | log write 1 file "Cannot have second name '$name', ignoring it" |
| 311 | return |
| 312 | } |
| 313 | set branch [sym %AUTO% branch $branchnr [$myproject getsymbol $name]] |
| 314 | $branch setposition [incr mybranchcnt] |
| 315 | set mybranches($branchnr) $branch |
| 316 | return $branch |
| 317 | } |
| 318 | |
| 319 | method AddTag {name revnr} { |
| 320 | set tag [sym %AUTO% tag $revnr [$myproject getsymbol $name]] |
| 321 | lappend mytags($revnr) $tag |
| 322 | return $tag |
| 323 | } |
| 324 | |
| 325 | method RecordBasicDependencies {revnr next} { |
| @@ -378,11 +408,11 @@ | |
| 378 | # If revisions were committed on the branch we store a |
| 379 | # reference to the branch there, and further declare |
| 380 | # the first child's parent to be branch's parent, and |
| 381 | # list this child in the parent revision. |
| 382 | |
| 383 | if {[$branch haschild]} { |
| 384 | set childrevnr [$branch childrevnr] |
| 385 | set child $myrev($childrevnr) |
| 386 | $branch setchild $child |
| 387 | |
| 388 | $child setparentbranch $branch |
| @@ -670,10 +700,11 @@ | |
| 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 | } |
| 678 | |
| 679 | # Change the type of first (typically from Change to Add): |
| @@ -726,11 +757,11 @@ | |
| 726 | set child [$root child] |
| 727 | $child cutfromparent |
| 728 | lappend myroots $child |
| 729 | } |
| 730 | |
| 731 | # Remove the branches spawned by the revision to be |
| 732 | # deleted. If the branch has revisions they should already |
| 733 | # use operation 'add', no need to change that. The first |
| 734 | # revision on each branch becomes a new and disconnected |
| 735 | # root. |
| 736 | |
| @@ -737,10 +768,11 @@ | |
| 737 | foreach branch [$root branches] { |
| 738 | if {![$branch haschild]} continue |
| 739 | set first [$branch child] |
| 740 | $first cutfromparentbranch |
| 741 | $first cutfromparent |
| 742 | lappend myroots $first |
| 743 | } |
| 744 | $root removeallbranches |
| 745 | |
| 746 | # Tagging a dead revision doesn't do anything, so remove |
| @@ -779,11 +811,13 @@ | |
| 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 | } |
| @@ -970,10 +1004,29 @@ | |
| 970 | set root [$root child] |
| 971 | } |
| 972 | |
| 973 | return |
| 974 | } |
| 975 | |
| 976 | # # ## ### ##### ######## ############# |
| 977 | ## Configuration |
| 978 | |
| 979 | pragma -hastypeinfo no ; # no type introspection |
| @@ -990,13 +1043,14 @@ | |
| 990 | # namespace import ::vc::fossil::import::cvs::file::rev |
| 991 | # namespace import ::vc::fossil::import::cvs::file::sym |
| 992 | namespace import ::vc::tools::misc::* |
| 993 | namespace import ::vc::tools::trouble |
| 994 | namespace import ::vc::tools::log |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | # # ## ### ##### ######## ############# ##################### |
| 999 | ## Ready |
| 1000 | |
| 1001 | package provide vc::fossil::import::cvs::file 1.0 |
| 1002 | return |
| 1003 |
| --- tools/cvs2fossil/lib/c2f_file.tcl | |
| +++ tools/cvs2fossil/lib/c2f_file.tcl | |
| @@ -19,10 +19,11 @@ | |
| 19 | package require Tcl 8.4 ; # Required runtime. |
| 20 | package require snit ; # OO system. |
| 21 | package require struct::set ; # Set operations. |
| 22 | package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions. |
| 23 | package require vc::fossil::import::cvs::file::sym ; # CVS per file symbols. |
| 24 | package require vc::fossil::import::cvs::state ; # State storage. |
| 25 | package require vc::tools::trouble ; # Error reporting. |
| 26 | package require vc::tools::log ; # User feedback |
| 27 | package require vc::tools::misc ; # Text formatting |
| 28 | |
| 29 | # # ## ### ##### ######## ############# ##################### |
| @@ -30,19 +31,27 @@ | |
| 31 | |
| 32 | snit::type ::vc::fossil::import::cvs::file { |
| 33 | # # ## ### ##### ######## ############# |
| 34 | ## Public API |
| 35 | |
| 36 | constructor {id path usrpath executable project} { |
| 37 | set myid $id |
| 38 | set mypath $path |
| 39 | set myusrpath $usrpath |
| 40 | set myexecutable $executable |
| 41 | set myproject $project |
| 42 | set mytrunk [$myproject trunk] |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | method setid {id} { |
| 47 | if {$myid ne ""} { trouble internal "File '$mypath' already has an id, '$myid'" } |
| 48 | set myid $id |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | method id {} { return $myid } |
| 53 | method path {} { return $mypath } |
| 54 | method usrpath {} { return $myusrpath } |
| 55 | method project {} { return $myproject } |
| 56 | |
| 57 | delegate method commitmessageof to myproject |
| @@ -64,10 +73,30 @@ | |
| 73 | |
| 74 | # # ## ### ##### ######## ############# |
| 75 | ## Persistence (pass II) |
| 76 | |
| 77 | method persist {} { |
| 78 | # First collect the reachable revisions and symbols, then |
| 79 | # assign id's to all. They are sorted so that we will have ids |
| 80 | # which sort in order of creation. Then we can save them. This |
| 81 | # is done bottom up. Revisions, then symbols. __NOTE__ This |
| 82 | # works only because sqlite is not checking foreign key |
| 83 | # references during insert. This allows to have dangling |
| 84 | # references which are fixed later. The longest dangling |
| 85 | # references are for the project level symbols, these we do |
| 86 | # not save here, but at the end of the pass. What we need are |
| 87 | # the ids, hence the two phases. |
| 88 | |
| 89 | struct::list assign [$self Active] revisions symbols |
| 90 | foreach rev $revisions { $rev defid } |
| 91 | foreach sym $symbols { $sym defid } |
| 92 | |
| 93 | state transaction { |
| 94 | foreach rev $revisions { $rev persist } |
| 95 | foreach sym $symbols { $sym persist } |
| 96 | } |
| 97 | return |
| 98 | } |
| 99 | |
| 100 | method drop {} { |
| 101 | foreach {_ rev} [array get myrev] { $rev destroy } |
| 102 | foreach {_ branch} [array get mybranches] { $branch destroy } |
| @@ -220,10 +249,11 @@ | |
| 249 | } |
| 250 | |
| 251 | # # ## ### ##### ######## ############# |
| 252 | ## State |
| 253 | |
| 254 | variable myid {} ; # File id in the persistent state. |
| 255 | variable mypath {} ; # Path of the file's rcs archive. |
| 256 | variable myusrpath {} ; # Path of the file as seen by users. |
| 257 | variable myexecutable 0 ; # Boolean flag 'file executable'. |
| 258 | variable myproject {} ; # Reference to the project object |
| 259 | # the file belongs to. |
| @@ -308,18 +338,18 @@ | |
| 338 | if {[info exists mybranches($branchnr)]} { |
| 339 | log write 1 file "In '$mypath': Branch '$branchnr' named '[$mybranches($branchnr) name]'" |
| 340 | log write 1 file "Cannot have second name '$name', ignoring it" |
| 341 | return |
| 342 | } |
| 343 | set branch [sym %AUTO% branch $branchnr [$myproject getsymbol $name] $self] |
| 344 | $branch setposition [incr mybranchcnt] |
| 345 | set mybranches($branchnr) $branch |
| 346 | return $branch |
| 347 | } |
| 348 | |
| 349 | method AddTag {name revnr} { |
| 350 | set tag [sym %AUTO% tag $revnr [$myproject getsymbol $name] $self] |
| 351 | lappend mytags($revnr) $tag |
| 352 | return $tag |
| 353 | } |
| 354 | |
| 355 | method RecordBasicDependencies {revnr next} { |
| @@ -378,11 +408,11 @@ | |
| 408 | # If revisions were committed on the branch we store a |
| 409 | # reference to the branch there, and further declare |
| 410 | # the first child's parent to be branch's parent, and |
| 411 | # list this child in the parent revision. |
| 412 | |
| 413 | if {[$branch haschildrev]} { |
| 414 | set childrevnr [$branch childrevnr] |
| 415 | set child $myrev($childrevnr) |
| 416 | $branch setchild $child |
| 417 | |
| 418 | $child setparentbranch $branch |
| @@ -670,10 +700,11 @@ | |
| 700 | set vendor [$first parentbranch] |
| 701 | if {$vendor eq ""} { trouble internal "First NTDB revision has no branch" } |
| 702 | if {[$vendor parent] eq $rev11} { |
| 703 | $rev11 removebranch $vendor |
| 704 | $rev11 removechildonbranch $first |
| 705 | $vendor cutchild |
| 706 | $first cutfromparentbranch |
| 707 | lappend myroots $first |
| 708 | } |
| 709 | |
| 710 | # Change the type of first (typically from Change to Add): |
| @@ -726,11 +757,11 @@ | |
| 757 | set child [$root child] |
| 758 | $child cutfromparent |
| 759 | lappend myroots $child |
| 760 | } |
| 761 | |
| 762 | # Cut out the branches spawned by the revision to be |
| 763 | # deleted. If the branch has revisions they should already |
| 764 | # use operation 'add', no need to change that. The first |
| 765 | # revision on each branch becomes a new and disconnected |
| 766 | # root. |
| 767 | |
| @@ -737,10 +768,11 @@ | |
| 768 | foreach branch [$root branches] { |
| 769 | if {![$branch haschild]} continue |
| 770 | set first [$branch child] |
| 771 | $first cutfromparentbranch |
| 772 | $first cutfromparent |
| 773 | $branch cutchild |
| 774 | lappend myroots $first |
| 775 | } |
| 776 | $root removeallbranches |
| 777 | |
| 778 | # Tagging a dead revision doesn't do anything, so remove |
| @@ -779,11 +811,13 @@ | |
| 811 | set child [$root child] |
| 812 | |
| 813 | ldelete myroots $root |
| 814 | lappend myroots $child |
| 815 | |
| 816 | $branch cutchild |
| 817 | $child cutfromparent |
| 818 | |
| 819 | $parent removebranch $branch |
| 820 | $parent removechildonbranch $root |
| 821 | } |
| 822 | return |
| 823 | } |
| @@ -970,10 +1004,29 @@ | |
| 1004 | set root [$root child] |
| 1005 | } |
| 1006 | |
| 1007 | return |
| 1008 | } |
| 1009 | |
| 1010 | method Active {} { |
| 1011 | set revisions {} |
| 1012 | set symbols {} |
| 1013 | |
| 1014 | foreach root [$self LinesOfDevelopment] { |
| 1015 | if {[$root hasparentbranch]} { lappend symbols [$root parentbranch] } |
| 1016 | while {$root ne ""} { |
| 1017 | lappend revisions $root |
| 1018 | foreach tag [$root tags] { lappend symbols $tag } |
| 1019 | foreach branch [$root branches] { lappend symbols $branch } |
| 1020 | set lod [$root lod] |
| 1021 | if {![$lod istrunk]} { lappend symbols $lod } |
| 1022 | set root [$root child] |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | return [list [lsort -unique -dict $revisions] [lsort -unique -dict $symbols]] |
| 1027 | } |
| 1028 | |
| 1029 | # # ## ### ##### ######## ############# |
| 1030 | ## Configuration |
| 1031 | |
| 1032 | pragma -hastypeinfo no ; # no type introspection |
| @@ -990,13 +1043,14 @@ | |
| 1043 | # namespace import ::vc::fossil::import::cvs::file::rev |
| 1044 | # namespace import ::vc::fossil::import::cvs::file::sym |
| 1045 | namespace import ::vc::tools::misc::* |
| 1046 | namespace import ::vc::tools::trouble |
| 1047 | namespace import ::vc::tools::log |
| 1048 | namespace import ::vc::fossil::import::cvs::state |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | # # ## ### ##### ######## ############# ##################### |
| 1053 | ## Ready |
| 1054 | |
| 1055 | package provide vc::fossil::import::cvs::file 1.0 |
| 1056 | return |
| 1057 |
| --- tools/cvs2fossil/lib/c2f_frev.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_frev.tcl | ||
| @@ -16,10 +16,11 @@ | ||
| 16 | 16 | ## Requirements |
| 17 | 17 | |
| 18 | 18 | package require Tcl 8.4 ; # Required runtime. |
| 19 | 19 | package require snit ; # OO system. |
| 20 | 20 | package require vc::tools::misc ; # Text formatting |
| 21 | +package require vc::fossil::import::cvs::state ; # State storage. | |
| 21 | 22 | |
| 22 | 23 | # # ## ### ##### ######## ############# ##################### |
| 23 | 24 | ## |
| 24 | 25 | |
| 25 | 26 | snit::type ::vc::fossil::import::cvs::file::rev { |
| @@ -33,10 +34,17 @@ | ||
| 33 | 34 | set mystate $state |
| 34 | 35 | set myfile $thefile |
| 35 | 36 | return |
| 36 | 37 | } |
| 37 | 38 | |
| 39 | + method defid {} { | |
| 40 | + set myid [incr myidcounter] | |
| 41 | + return | |
| 42 | + } | |
| 43 | + | |
| 44 | + method id {} { return $myid } | |
| 45 | + | |
| 38 | 46 | # Basic pieces ________________________ |
| 39 | 47 | |
| 40 | 48 | method hasmeta {} { return [expr {$mymetaid ne ""}] } |
| 41 | 49 | method hastext {} { |
| 42 | 50 | struct::list assign $mytext s e |
| @@ -330,18 +338,66 @@ | ||
| 330 | 338 | |
| 331 | 339 | typemethod 2branchparentrevnr {branchnr} { |
| 332 | 340 | # Chop the last segment off |
| 333 | 341 | return [join [lrange [split $branchnr .] 0 end-1] .] |
| 334 | 342 | } |
| 343 | + | |
| 344 | + # # ## ### ##### ######## ############# | |
| 345 | + | |
| 346 | + method persist {} { | |
| 347 | + set fid [$myfile id] | |
| 348 | + set op $myopcode($myoperation) | |
| 349 | + set idb $myisondefaultbranch | |
| 350 | + | |
| 351 | + struct::list assign $mytext cs cl | |
| 352 | + set cl [expr {$cl - $cs}] | |
| 353 | + | |
| 354 | + lappend map @L@ [expr { [$mylod istrunk] ? "NULL" : [$mylod id] }] | |
| 355 | + lappend map @P@ [expr { ($myparent eq "") ? "NULL" : [$myparent id] }] | |
| 356 | + lappend map @C@ [expr { ($mychild eq "") ? "NULL" : [$mychild id] }] | |
| 357 | + lappend map @DP [expr { ($mydbparent eq "") ? "NULL" : [$mydbparent id] }] | |
| 358 | + lappend map @DC [expr { ($mydbchild eq "") ? "NULL" : [$mydbchild id] }] | |
| 359 | + lappend map @BP [expr { ($myparentbranch eq "") ? "NULL" : [$myparentbranch id] }] | |
| 360 | + | |
| 361 | + set cmd { | |
| 362 | + INSERT INTO revision ( rid, fid, lod, rev, date, state, mid, cs, cl, op, isdefault, parent, child, dbparent, dbchild, bparent) | |
| 363 | + VALUES ($myid, $fid, @L@, $myrevnr, $mydate, $mystate, $mymetaid, $cs, $cl, $op, $idb, @P@, @C@, @DP, @DC, @BP); | |
| 364 | + } | |
| 365 | + | |
| 366 | + state transaction { | |
| 367 | + state run [string map $map $cmd] | |
| 368 | + } | |
| 369 | + return | |
| 370 | + } | |
| 335 | 371 | |
| 336 | 372 | # # ## ### ##### ######## ############# |
| 337 | 373 | ## State |
| 374 | + | |
| 375 | + # Persistent: myid - revision.rid | |
| 376 | + # myfile - revision.fid | |
| 377 | + # mylod - revision.lod | |
| 378 | + # myrevnr - revision.rev | |
| 379 | + # mydate - revision.date | |
| 380 | + # mystate - revision.state | |
| 381 | + # mymetaid - revision.mid | |
| 382 | + # mytext - revision.{cs,cl} | |
| 383 | + # myparent - revision.parent | |
| 384 | + # mychild - revision.child | |
| 385 | + # myparentbranch - revision.bparent | |
| 386 | + # myoperation - revision.op | |
| 387 | + # myisondefaultbranch - revision.isdefault | |
| 388 | + # mydbparent - revision.dbparent | |
| 389 | + # mydbchild - revision.dbchild | |
| 390 | + | |
| 338 | 391 | |
| 339 | 392 | typevariable mybranchpattern {^((?:\d+\.\d+\.)+)(?:0\.)?(\d+)$} |
| 340 | 393 | # First a nonzero even number of digit groups with trailing dot |
| 341 | 394 | # CVS then sticks an extra 0 in here; RCS does not. |
| 342 | 395 | # And the last digit group. |
| 396 | + | |
| 397 | + typevariable myidcounter 0 ; # Counter for revision ids. | |
| 398 | + variable myid {} ; # Revision id. | |
| 343 | 399 | |
| 344 | 400 | variable myrevnr {} ; # Revision number of the revision. |
| 345 | 401 | variable mydate {} ; # Timestamp of the revision, seconds since epoch |
| 346 | 402 | variable myorigdate {} ; # Original unmodified timestamp. |
| 347 | 403 | variable mystate {} ; # State of the revision. |
| @@ -424,10 +480,16 @@ | ||
| 424 | 480 | {0 0} change |
| 425 | 481 | {0 1} delete |
| 426 | 482 | {1 0} add |
| 427 | 483 | {1 1} nothing |
| 428 | 484 | } |
| 485 | + typevariable myopcode -array { | |
| 486 | + change 2 | |
| 487 | + delete -1 | |
| 488 | + add 1 | |
| 489 | + nothing 0 | |
| 490 | + } | |
| 429 | 491 | |
| 430 | 492 | # # ## ### ##### ######## ############# |
| 431 | 493 | ## Internal methods |
| 432 | 494 | |
| 433 | 495 | # # ## ### ##### ######## ############# |
| @@ -442,13 +504,14 @@ | ||
| 442 | 504 | |
| 443 | 505 | namespace eval ::vc::fossil::import::cvs::file { |
| 444 | 506 | namespace export rev |
| 445 | 507 | namespace eval rev { |
| 446 | 508 | namespace import ::vc::tools::misc::* |
| 509 | + namespace import ::vc::fossil::import::cvs::state | |
| 447 | 510 | } |
| 448 | 511 | } |
| 449 | 512 | |
| 450 | 513 | # # ## ### ##### ######## ############# ##################### |
| 451 | 514 | ## Ready |
| 452 | 515 | |
| 453 | 516 | package provide vc::fossil::import::cvs::file::rev 1.0 |
| 454 | 517 | return |
| 455 | 518 |
| --- tools/cvs2fossil/lib/c2f_frev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_frev.tcl | |
| @@ -16,10 +16,11 @@ | |
| 16 | ## Requirements |
| 17 | |
| 18 | package require Tcl 8.4 ; # Required runtime. |
| 19 | package require snit ; # OO system. |
| 20 | package require vc::tools::misc ; # Text formatting |
| 21 | |
| 22 | # # ## ### ##### ######## ############# ##################### |
| 23 | ## |
| 24 | |
| 25 | snit::type ::vc::fossil::import::cvs::file::rev { |
| @@ -33,10 +34,17 @@ | |
| 33 | set mystate $state |
| 34 | set myfile $thefile |
| 35 | return |
| 36 | } |
| 37 | |
| 38 | # Basic pieces ________________________ |
| 39 | |
| 40 | method hasmeta {} { return [expr {$mymetaid ne ""}] } |
| 41 | method hastext {} { |
| 42 | struct::list assign $mytext s e |
| @@ -330,18 +338,66 @@ | |
| 330 | |
| 331 | typemethod 2branchparentrevnr {branchnr} { |
| 332 | # Chop the last segment off |
| 333 | return [join [lrange [split $branchnr .] 0 end-1] .] |
| 334 | } |
| 335 | |
| 336 | # # ## ### ##### ######## ############# |
| 337 | ## State |
| 338 | |
| 339 | typevariable mybranchpattern {^((?:\d+\.\d+\.)+)(?:0\.)?(\d+)$} |
| 340 | # First a nonzero even number of digit groups with trailing dot |
| 341 | # CVS then sticks an extra 0 in here; RCS does not. |
| 342 | # And the last digit group. |
| 343 | |
| 344 | variable myrevnr {} ; # Revision number of the revision. |
| 345 | variable mydate {} ; # Timestamp of the revision, seconds since epoch |
| 346 | variable myorigdate {} ; # Original unmodified timestamp. |
| 347 | variable mystate {} ; # State of the revision. |
| @@ -424,10 +480,16 @@ | |
| 424 | {0 0} change |
| 425 | {0 1} delete |
| 426 | {1 0} add |
| 427 | {1 1} nothing |
| 428 | } |
| 429 | |
| 430 | # # ## ### ##### ######## ############# |
| 431 | ## Internal methods |
| 432 | |
| 433 | # # ## ### ##### ######## ############# |
| @@ -442,13 +504,14 @@ | |
| 442 | |
| 443 | namespace eval ::vc::fossil::import::cvs::file { |
| 444 | namespace export rev |
| 445 | namespace eval rev { |
| 446 | namespace import ::vc::tools::misc::* |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | # # ## ### ##### ######## ############# ##################### |
| 451 | ## Ready |
| 452 | |
| 453 | package provide vc::fossil::import::cvs::file::rev 1.0 |
| 454 | return |
| 455 |
| --- tools/cvs2fossil/lib/c2f_frev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_frev.tcl | |
| @@ -16,10 +16,11 @@ | |
| 16 | ## Requirements |
| 17 | |
| 18 | package require Tcl 8.4 ; # Required runtime. |
| 19 | package require snit ; # OO system. |
| 20 | package require vc::tools::misc ; # Text formatting |
| 21 | package require vc::fossil::import::cvs::state ; # State storage. |
| 22 | |
| 23 | # # ## ### ##### ######## ############# ##################### |
| 24 | ## |
| 25 | |
| 26 | snit::type ::vc::fossil::import::cvs::file::rev { |
| @@ -33,10 +34,17 @@ | |
| 34 | set mystate $state |
| 35 | set myfile $thefile |
| 36 | return |
| 37 | } |
| 38 | |
| 39 | method defid {} { |
| 40 | set myid [incr myidcounter] |
| 41 | return |
| 42 | } |
| 43 | |
| 44 | method id {} { return $myid } |
| 45 | |
| 46 | # Basic pieces ________________________ |
| 47 | |
| 48 | method hasmeta {} { return [expr {$mymetaid ne ""}] } |
| 49 | method hastext {} { |
| 50 | struct::list assign $mytext s e |
| @@ -330,18 +338,66 @@ | |
| 338 | |
| 339 | typemethod 2branchparentrevnr {branchnr} { |
| 340 | # Chop the last segment off |
| 341 | return [join [lrange [split $branchnr .] 0 end-1] .] |
| 342 | } |
| 343 | |
| 344 | # # ## ### ##### ######## ############# |
| 345 | |
| 346 | method persist {} { |
| 347 | set fid [$myfile id] |
| 348 | set op $myopcode($myoperation) |
| 349 | set idb $myisondefaultbranch |
| 350 | |
| 351 | struct::list assign $mytext cs cl |
| 352 | set cl [expr {$cl - $cs}] |
| 353 | |
| 354 | lappend map @L@ [expr { [$mylod istrunk] ? "NULL" : [$mylod id] }] |
| 355 | lappend map @P@ [expr { ($myparent eq "") ? "NULL" : [$myparent id] }] |
| 356 | lappend map @C@ [expr { ($mychild eq "") ? "NULL" : [$mychild id] }] |
| 357 | lappend map @DP [expr { ($mydbparent eq "") ? "NULL" : [$mydbparent id] }] |
| 358 | lappend map @DC [expr { ($mydbchild eq "") ? "NULL" : [$mydbchild id] }] |
| 359 | lappend map @BP [expr { ($myparentbranch eq "") ? "NULL" : [$myparentbranch id] }] |
| 360 | |
| 361 | set cmd { |
| 362 | INSERT INTO revision ( rid, fid, lod, rev, date, state, mid, cs, cl, op, isdefault, parent, child, dbparent, dbchild, bparent) |
| 363 | VALUES ($myid, $fid, @L@, $myrevnr, $mydate, $mystate, $mymetaid, $cs, $cl, $op, $idb, @P@, @C@, @DP, @DC, @BP); |
| 364 | } |
| 365 | |
| 366 | state transaction { |
| 367 | state run [string map $map $cmd] |
| 368 | } |
| 369 | return |
| 370 | } |
| 371 | |
| 372 | # # ## ### ##### ######## ############# |
| 373 | ## State |
| 374 | |
| 375 | # Persistent: myid - revision.rid |
| 376 | # myfile - revision.fid |
| 377 | # mylod - revision.lod |
| 378 | # myrevnr - revision.rev |
| 379 | # mydate - revision.date |
| 380 | # mystate - revision.state |
| 381 | # mymetaid - revision.mid |
| 382 | # mytext - revision.{cs,cl} |
| 383 | # myparent - revision.parent |
| 384 | # mychild - revision.child |
| 385 | # myparentbranch - revision.bparent |
| 386 | # myoperation - revision.op |
| 387 | # myisondefaultbranch - revision.isdefault |
| 388 | # mydbparent - revision.dbparent |
| 389 | # mydbchild - revision.dbchild |
| 390 | |
| 391 | |
| 392 | typevariable mybranchpattern {^((?:\d+\.\d+\.)+)(?:0\.)?(\d+)$} |
| 393 | # First a nonzero even number of digit groups with trailing dot |
| 394 | # CVS then sticks an extra 0 in here; RCS does not. |
| 395 | # And the last digit group. |
| 396 | |
| 397 | typevariable myidcounter 0 ; # Counter for revision ids. |
| 398 | variable myid {} ; # Revision id. |
| 399 | |
| 400 | variable myrevnr {} ; # Revision number of the revision. |
| 401 | variable mydate {} ; # Timestamp of the revision, seconds since epoch |
| 402 | variable myorigdate {} ; # Original unmodified timestamp. |
| 403 | variable mystate {} ; # State of the revision. |
| @@ -424,10 +480,16 @@ | |
| 480 | {0 0} change |
| 481 | {0 1} delete |
| 482 | {1 0} add |
| 483 | {1 1} nothing |
| 484 | } |
| 485 | typevariable myopcode -array { |
| 486 | change 2 |
| 487 | delete -1 |
| 488 | add 1 |
| 489 | nothing 0 |
| 490 | } |
| 491 | |
| 492 | # # ## ### ##### ######## ############# |
| 493 | ## Internal methods |
| 494 | |
| 495 | # # ## ### ##### ######## ############# |
| @@ -442,13 +504,14 @@ | |
| 504 | |
| 505 | namespace eval ::vc::fossil::import::cvs::file { |
| 506 | namespace export rev |
| 507 | namespace eval rev { |
| 508 | namespace import ::vc::tools::misc::* |
| 509 | namespace import ::vc::fossil::import::cvs::state |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | # # ## ### ##### ######## ############# ##################### |
| 514 | ## Ready |
| 515 | |
| 516 | package provide vc::fossil::import::cvs::file::rev 1.0 |
| 517 | return |
| 518 |
+73
-2
| --- tools/cvs2fossil/lib/c2f_fsym.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_fsym.tcl | ||
| @@ -17,19 +17,21 @@ | ||
| 17 | 17 | |
| 18 | 18 | package require Tcl 8.4 ; # Required runtime. |
| 19 | 19 | package require snit ; # OO system. |
| 20 | 20 | package require vc::tools::trouble ; # Error reporting. |
| 21 | 21 | package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions. |
| 22 | +package require vc::fossil::import::cvs::state ; # State storage. | |
| 22 | 23 | |
| 23 | 24 | # # ## ### ##### ######## ############# ##################### |
| 24 | 25 | ## |
| 25 | 26 | |
| 26 | 27 | snit::type ::vc::fossil::import::cvs::file::sym { |
| 27 | 28 | # # ## ### ##### ######## ############# |
| 28 | 29 | ## Public API |
| 29 | 30 | |
| 30 | - constructor {symtype nr symbol} { | |
| 31 | + constructor {symtype nr symbol file} { | |
| 32 | + set myfile $file | |
| 31 | 33 | set mytype $symtype |
| 32 | 34 | set mynr $nr |
| 33 | 35 | set mysymbol $symbol |
| 34 | 36 | |
| 35 | 37 | switch -exact -- $mytype { |
| @@ -38,10 +40,17 @@ | ||
| 38 | 40 | default { trouble internal "Bad symbol type '$mytype'" } |
| 39 | 41 | } |
| 40 | 42 | return |
| 41 | 43 | } |
| 42 | 44 | |
| 45 | + method defid {} { | |
| 46 | + set myid [incr myidcounter] | |
| 47 | + return | |
| 48 | + } | |
| 49 | + | |
| 50 | + method fid {} { return $myid } | |
| 51 | + | |
| 43 | 52 | # Symbol acessor methods. |
| 44 | 53 | |
| 45 | 54 | delegate method name to mysymbol |
| 46 | 55 | delegate method id to mysymbol |
| 47 | 56 | |
| @@ -56,15 +65,17 @@ | ||
| 56 | 65 | } |
| 57 | 66 | |
| 58 | 67 | method setposition {n} { set mybranchposition $n ; return } |
| 59 | 68 | method setparent {rev} { set mybranchparent $rev ; return } |
| 60 | 69 | method setchild {rev} { set mybranchchild $rev ; return } |
| 70 | + method cutchild {} { set mybranchchild "" ; return } | |
| 61 | 71 | |
| 62 | 72 | method branchnr {} { return $mynr } |
| 63 | 73 | method parentrevnr {} { return $mybranchparentrevnr } |
| 64 | 74 | method childrevnr {} { return $mybranchchildrevnr } |
| 65 | - method haschild {} { return [expr {$mybranchchildrevnr ne ""}] } | |
| 75 | + method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] } | |
| 76 | + method haschild {} { return [expr {$mybranchchild ne ""}] } | |
| 66 | 77 | method parent {} { return $mybranchparent } |
| 67 | 78 | method child {} { return $mybranchchild } |
| 68 | 79 | method position {} { return $mybranchposition } |
| 69 | 80 | |
| 70 | 81 | |
| @@ -97,16 +108,75 @@ | ||
| 97 | 108 | trouble fatal "For $mytype [$mysymbol name]: LOD conflict with source, '[$mylod name]' vs. '[$slod name]'" |
| 98 | 109 | return |
| 99 | 110 | } |
| 100 | 111 | return |
| 101 | 112 | } |
| 113 | + | |
| 114 | + # # ## ### ##### ######## ############# | |
| 115 | + | |
| 116 | + method persist {} { | |
| 117 | + # Save the information we need after the collection pass. | |
| 118 | + | |
| 119 | + # NOTE: mybranchposition is currently not saved. This can | |
| 120 | + # likely be figured out later from the id itself. If yes, we | |
| 121 | + # can also get rid of 'sortbranches' (cvs::file) and the | |
| 122 | + # associated information. | |
| 123 | + | |
| 124 | + set fid [$myfile id] | |
| 125 | + set sid [$mysymbol id] | |
| 126 | + | |
| 127 | + lappend map @L@ [expr { [$mylod istrunk] ? "NULL" : [$mylod id] }] | |
| 128 | + | |
| 129 | + switch -exact -- $mytype { | |
| 130 | + tag { | |
| 131 | + set rid [$mytagrev id] | |
| 132 | + set cmd { | |
| 133 | + INSERT INTO tag ( tid, fid, lod, sid, rev) | |
| 134 | + VALUES ($myid, $fid, @L@, $sid, $rid); | |
| 135 | + } | |
| 136 | + } | |
| 137 | + branch { | |
| 138 | + lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }] | |
| 139 | + | |
| 140 | + set rid [$mybranchparent id] | |
| 141 | + set cmd { | |
| 142 | + INSERT INTO branch ( bid, fid, lod, sid, root, first, bra ) | |
| 143 | + VALUES ($myid, $fid, @L@, $sid, $rid, @F@, $mynr); | |
| 144 | + } | |
| 145 | + } | |
| 146 | + } | |
| 147 | + | |
| 148 | + state transaction { | |
| 149 | + state run [string map $map $cmd] | |
| 150 | + } | |
| 151 | + return | |
| 152 | + } | |
| 102 | 153 | |
| 103 | 154 | # # ## ### ##### ######## ############# |
| 104 | 155 | ## State |
| 105 | 156 | |
| 157 | + # Persistent: | |
| 158 | + # Tag: myid - tag.tid | |
| 159 | + # myfile - tag.fid | |
| 160 | + # mylod - tag.lod | |
| 161 | + # mysymbol - tag.sid | |
| 162 | + # mytagrev - tag.rev | |
| 163 | + # | |
| 164 | + # Branch: myid - branch.bid | |
| 165 | + # myfile - branch.fid | |
| 166 | + # mylod - branch.lod | |
| 167 | + # mysymbol - branch.sid | |
| 168 | + # mybranchparent - branch.root | |
| 169 | + # mybranchchild - branch.first | |
| 170 | + # mynr - branch.bra | |
| 171 | + | |
| 172 | + typevariable myidcounter 0 ; # Counter for symbol ids. | |
| 173 | + variable myid {} ; # Symbol id. | |
| 174 | + | |
| 106 | 175 | ## Basic, all symbols _________________ |
| 107 | 176 | |
| 177 | + variable myfile {} ; # Reference to the file the symbol is in. | |
| 108 | 178 | variable mytype {} ; # Symbol type, 'tag', or 'branch'. |
| 109 | 179 | variable mynr {} ; # Revision number of a 'tag', branch number |
| 110 | 180 | # of a 'branch'. |
| 111 | 181 | variable mysymbol {} ; # Reference to the symbol object of this |
| 112 | 182 | # symbol at the project level. |
| @@ -162,14 +232,15 @@ | ||
| 162 | 232 | |
| 163 | 233 | namespace eval ::vc::fossil::import::cvs::file { |
| 164 | 234 | namespace export sym |
| 165 | 235 | namespace eval sym { |
| 166 | 236 | namespace import ::vc::fossil::import::cvs::file::rev |
| 237 | + namespace import ::vc::fossil::import::cvs::state | |
| 167 | 238 | namespace import ::vc::tools::trouble |
| 168 | 239 | } |
| 169 | 240 | } |
| 170 | 241 | |
| 171 | 242 | # # ## ### ##### ######## ############# ##################### |
| 172 | 243 | ## Ready |
| 173 | 244 | |
| 174 | 245 | package provide vc::fossil::import::cvs::file::sym 1.0 |
| 175 | 246 | return |
| 176 | 247 |
| --- tools/cvs2fossil/lib/c2f_fsym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_fsym.tcl | |
| @@ -17,19 +17,21 @@ | |
| 17 | |
| 18 | package require Tcl 8.4 ; # Required runtime. |
| 19 | package require snit ; # OO system. |
| 20 | package require vc::tools::trouble ; # Error reporting. |
| 21 | package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions. |
| 22 | |
| 23 | # # ## ### ##### ######## ############# ##################### |
| 24 | ## |
| 25 | |
| 26 | snit::type ::vc::fossil::import::cvs::file::sym { |
| 27 | # # ## ### ##### ######## ############# |
| 28 | ## Public API |
| 29 | |
| 30 | constructor {symtype nr symbol} { |
| 31 | set mytype $symtype |
| 32 | set mynr $nr |
| 33 | set mysymbol $symbol |
| 34 | |
| 35 | switch -exact -- $mytype { |
| @@ -38,10 +40,17 @@ | |
| 38 | default { trouble internal "Bad symbol type '$mytype'" } |
| 39 | } |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | # Symbol acessor methods. |
| 44 | |
| 45 | delegate method name to mysymbol |
| 46 | delegate method id to mysymbol |
| 47 | |
| @@ -56,15 +65,17 @@ | |
| 56 | } |
| 57 | |
| 58 | method setposition {n} { set mybranchposition $n ; return } |
| 59 | method setparent {rev} { set mybranchparent $rev ; return } |
| 60 | method setchild {rev} { set mybranchchild $rev ; return } |
| 61 | |
| 62 | method branchnr {} { return $mynr } |
| 63 | method parentrevnr {} { return $mybranchparentrevnr } |
| 64 | method childrevnr {} { return $mybranchchildrevnr } |
| 65 | method haschild {} { return [expr {$mybranchchildrevnr ne ""}] } |
| 66 | method parent {} { return $mybranchparent } |
| 67 | method child {} { return $mybranchchild } |
| 68 | method position {} { return $mybranchposition } |
| 69 | |
| 70 | |
| @@ -97,16 +108,75 @@ | |
| 97 | trouble fatal "For $mytype [$mysymbol name]: LOD conflict with source, '[$mylod name]' vs. '[$slod name]'" |
| 98 | return |
| 99 | } |
| 100 | return |
| 101 | } |
| 102 | |
| 103 | # # ## ### ##### ######## ############# |
| 104 | ## State |
| 105 | |
| 106 | ## Basic, all symbols _________________ |
| 107 | |
| 108 | variable mytype {} ; # Symbol type, 'tag', or 'branch'. |
| 109 | variable mynr {} ; # Revision number of a 'tag', branch number |
| 110 | # of a 'branch'. |
| 111 | variable mysymbol {} ; # Reference to the symbol object of this |
| 112 | # symbol at the project level. |
| @@ -162,14 +232,15 @@ | |
| 162 | |
| 163 | namespace eval ::vc::fossil::import::cvs::file { |
| 164 | namespace export sym |
| 165 | namespace eval sym { |
| 166 | namespace import ::vc::fossil::import::cvs::file::rev |
| 167 | namespace import ::vc::tools::trouble |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | # # ## ### ##### ######## ############# ##################### |
| 172 | ## Ready |
| 173 | |
| 174 | package provide vc::fossil::import::cvs::file::sym 1.0 |
| 175 | return |
| 176 |
| --- tools/cvs2fossil/lib/c2f_fsym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_fsym.tcl | |
| @@ -17,19 +17,21 @@ | |
| 17 | |
| 18 | package require Tcl 8.4 ; # Required runtime. |
| 19 | package require snit ; # OO system. |
| 20 | package require vc::tools::trouble ; # Error reporting. |
| 21 | package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions. |
| 22 | package require vc::fossil::import::cvs::state ; # State storage. |
| 23 | |
| 24 | # # ## ### ##### ######## ############# ##################### |
| 25 | ## |
| 26 | |
| 27 | snit::type ::vc::fossil::import::cvs::file::sym { |
| 28 | # # ## ### ##### ######## ############# |
| 29 | ## Public API |
| 30 | |
| 31 | constructor {symtype nr symbol file} { |
| 32 | set myfile $file |
| 33 | set mytype $symtype |
| 34 | set mynr $nr |
| 35 | set mysymbol $symbol |
| 36 | |
| 37 | switch -exact -- $mytype { |
| @@ -38,10 +40,17 @@ | |
| 40 | default { trouble internal "Bad symbol type '$mytype'" } |
| 41 | } |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | method defid {} { |
| 46 | set myid [incr myidcounter] |
| 47 | return |
| 48 | } |
| 49 | |
| 50 | method fid {} { return $myid } |
| 51 | |
| 52 | # Symbol acessor methods. |
| 53 | |
| 54 | delegate method name to mysymbol |
| 55 | delegate method id to mysymbol |
| 56 | |
| @@ -56,15 +65,17 @@ | |
| 65 | } |
| 66 | |
| 67 | method setposition {n} { set mybranchposition $n ; return } |
| 68 | method setparent {rev} { set mybranchparent $rev ; return } |
| 69 | method setchild {rev} { set mybranchchild $rev ; return } |
| 70 | method cutchild {} { set mybranchchild "" ; return } |
| 71 | |
| 72 | method branchnr {} { return $mynr } |
| 73 | method parentrevnr {} { return $mybranchparentrevnr } |
| 74 | method childrevnr {} { return $mybranchchildrevnr } |
| 75 | method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] } |
| 76 | method haschild {} { return [expr {$mybranchchild ne ""}] } |
| 77 | method parent {} { return $mybranchparent } |
| 78 | method child {} { return $mybranchchild } |
| 79 | method position {} { return $mybranchposition } |
| 80 | |
| 81 | |
| @@ -97,16 +108,75 @@ | |
| 108 | trouble fatal "For $mytype [$mysymbol name]: LOD conflict with source, '[$mylod name]' vs. '[$slod name]'" |
| 109 | return |
| 110 | } |
| 111 | return |
| 112 | } |
| 113 | |
| 114 | # # ## ### ##### ######## ############# |
| 115 | |
| 116 | method persist {} { |
| 117 | # Save the information we need after the collection pass. |
| 118 | |
| 119 | # NOTE: mybranchposition is currently not saved. This can |
| 120 | # likely be figured out later from the id itself. If yes, we |
| 121 | # can also get rid of 'sortbranches' (cvs::file) and the |
| 122 | # associated information. |
| 123 | |
| 124 | set fid [$myfile id] |
| 125 | set sid [$mysymbol id] |
| 126 | |
| 127 | lappend map @L@ [expr { [$mylod istrunk] ? "NULL" : [$mylod id] }] |
| 128 | |
| 129 | switch -exact -- $mytype { |
| 130 | tag { |
| 131 | set rid [$mytagrev id] |
| 132 | set cmd { |
| 133 | INSERT INTO tag ( tid, fid, lod, sid, rev) |
| 134 | VALUES ($myid, $fid, @L@, $sid, $rid); |
| 135 | } |
| 136 | } |
| 137 | branch { |
| 138 | lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }] |
| 139 | |
| 140 | set rid [$mybranchparent id] |
| 141 | set cmd { |
| 142 | INSERT INTO branch ( bid, fid, lod, sid, root, first, bra ) |
| 143 | VALUES ($myid, $fid, @L@, $sid, $rid, @F@, $mynr); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | state transaction { |
| 149 | state run [string map $map $cmd] |
| 150 | } |
| 151 | return |
| 152 | } |
| 153 | |
| 154 | # # ## ### ##### ######## ############# |
| 155 | ## State |
| 156 | |
| 157 | # Persistent: |
| 158 | # Tag: myid - tag.tid |
| 159 | # myfile - tag.fid |
| 160 | # mylod - tag.lod |
| 161 | # mysymbol - tag.sid |
| 162 | # mytagrev - tag.rev |
| 163 | # |
| 164 | # Branch: myid - branch.bid |
| 165 | # myfile - branch.fid |
| 166 | # mylod - branch.lod |
| 167 | # mysymbol - branch.sid |
| 168 | # mybranchparent - branch.root |
| 169 | # mybranchchild - branch.first |
| 170 | # mynr - branch.bra |
| 171 | |
| 172 | typevariable myidcounter 0 ; # Counter for symbol ids. |
| 173 | variable myid {} ; # Symbol id. |
| 174 | |
| 175 | ## Basic, all symbols _________________ |
| 176 | |
| 177 | variable myfile {} ; # Reference to the file the symbol is in. |
| 178 | variable mytype {} ; # Symbol type, 'tag', or 'branch'. |
| 179 | variable mynr {} ; # Revision number of a 'tag', branch number |
| 180 | # of a 'branch'. |
| 181 | variable mysymbol {} ; # Reference to the symbol object of this |
| 182 | # symbol at the project level. |
| @@ -162,14 +232,15 @@ | |
| 232 | |
| 233 | namespace eval ::vc::fossil::import::cvs::file { |
| 234 | namespace export sym |
| 235 | namespace eval sym { |
| 236 | namespace import ::vc::fossil::import::cvs::file::rev |
| 237 | namespace import ::vc::fossil::import::cvs::state |
| 238 | namespace import ::vc::tools::trouble |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | # # ## ### ##### ######## ############# ##################### |
| 243 | ## Ready |
| 244 | |
| 245 | package provide vc::fossil::import::cvs::file::sym 1.0 |
| 246 | return |
| 247 |
+51
-44
| --- tools/cvs2fossil/lib/c2f_pcollrev.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pcollrev.tcl | ||
| @@ -56,57 +56,64 @@ | ||
| 56 | 56 | # revisions and symbols. The latter can be further separated |
| 57 | 57 | # into tags and branches. At project level the per-file |
| 58 | 58 | # symbols information is merged. |
| 59 | 59 | |
| 60 | 60 | # File level ... |
| 61 | - # Event, Revision, Symbol, Branch, Tag | |
| 62 | - # | |
| 63 | - # Tag <- Symbol <- Event | |
| 64 | - # Branch <- Symbol <- Event | |
| 65 | - # Revision <- Event | |
| 66 | - # | |
| 67 | - # Head revision, Principal branch, Comment | |
| 68 | - | |
| 69 | - state writing rcs { | |
| 70 | - fid INTEGER NOT NULL REFERENCES file, -- RCS inherit from FILE | |
| 71 | - head INTEGER NOT NULL REFERENCES revision, | |
| 72 | - principal INTEGER NOT NULL REFERENCES branch, | |
| 73 | - comment TEXT NOT NULL | |
| 74 | - } | |
| 75 | - | |
| 76 | - state writing item { | |
| 77 | - iid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | |
| 78 | - type INTEGER NOT NULL, -- enum { tag = 1, branch, revision } | |
| 79 | - fid INTEGER NOT NULL REFERENCES file -- File the item belongs to | |
| 80 | - } | |
| 61 | + # Revisions, Branches, Tags | |
| 62 | + # | |
| 63 | + # Pseudo class hierarchy | |
| 64 | + # Tag <- Symbol <- Event | |
| 65 | + # Branch <- Symbol <- Event | |
| 66 | + # Revision <- Event | |
| 81 | 67 | |
| 82 | 68 | state writing revision { |
| 83 | - iid INTEGER NOT NULL REFERENCES item, -- REVISION inherit from ITEM | |
| 84 | - lod INTEGER NOT NULL REFERENCES symbol, -- Line of development | |
| 69 | + rid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | |
| 70 | + fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to | |
| 71 | + lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) | |
| 85 | 72 | |
| 86 | 73 | -- The tags and branches belonging to a revision can be |
| 87 | 74 | -- determined by selecting on the backreferences in the |
| 88 | 75 | -- tag and branch tables. |
| 89 | 76 | |
| 90 | - rev TEXT NOT NULL, -- revision number | |
| 91 | - date INTEGER NOT NULL, -- date of entry, seconds since epoch | |
| 92 | - state TEXT NOT NULL, -- state of revision | |
| 93 | - mid INTEGER NOT NULL REFERENCES meta, -- meta data (author, commit message) | |
| 94 | - next INTEGER NOT NULL REFERENCES revision, -- next in chain of revisions. | |
| 95 | - cs INTEGER NOT NULL, -- Revision content as offset and length | |
| 96 | - cl INTEGER NOT NULL -- into the archive file. | |
| 77 | + rev TEXT NOT NULL, -- revision number | |
| 78 | + date INTEGER NOT NULL, -- date of entry, seconds since epoch | |
| 79 | + state TEXT NOT NULL, -- state of revision | |
| 80 | + mid INTEGER NOT NULL REFERENCES meta, -- meta data (author, commit message) | |
| 81 | + cs INTEGER NOT NULL, -- Revision content as offset and | |
| 82 | + cl INTEGER NOT NULL, -- length into the archive file. | |
| 83 | + | |
| 84 | + -- Derived information, and links | |
| 85 | + -- Basic: Parent/Child | |
| 86 | + -- NTDB: DefaultParent/DefaultChild | |
| 87 | + -- Branches: Branch parent revision | |
| 88 | + | |
| 89 | + op INTEGER NOT NULL, | |
| 90 | + isdefault INTEGER NOT NULL, | |
| 91 | + parent INTEGER REFERENCES revision, | |
| 92 | + child INTEGER REFERENCES revision, | |
| 93 | + dbparent INTEGER REFERENCES revision, | |
| 94 | + dbchild INTEGER REFERENCES revision, | |
| 95 | + bparent INTEGER REFERENCES symbol | |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | 98 | state writing tag { |
| 100 | - iid INTEGER NOT NULL REFERENCES item, -- TAG inherit from ITEM | |
| 101 | - sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag | |
| 102 | - rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged. | |
| 99 | + tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | |
| 100 | + fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to | |
| 101 | + lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) | |
| 102 | + | |
| 103 | + sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag | |
| 104 | + | |
| 105 | + rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged. | |
| 103 | 106 | } |
| 104 | 107 | |
| 105 | 108 | state writing branch { |
| 106 | - iid INTEGER NOT NULL REFERENCES item, -- BRANCH inherit from ITEM | |
| 109 | + bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | |
| 110 | + fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to | |
| 111 | + lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) | |
| 112 | + | |
| 107 | 113 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch |
| 114 | + | |
| 108 | 115 | root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from |
| 109 | 116 | first INTEGER REFERENCES revision, -- First revision committed to the branch |
| 110 | 117 | bra TEXT NOT NULL -- branch number |
| 111 | 118 | } |
| 112 | 119 | |
| @@ -207,21 +214,23 @@ | ||
| 207 | 214 | trouble fatal "$path is not a valid RCS archive ($msg)" |
| 208 | 215 | } else { |
| 209 | 216 | global errorInfo |
| 210 | 217 | trouble internal $errorInfo |
| 211 | 218 | } |
| 219 | + } else { | |
| 220 | + # We persist the core of the data collected about | |
| 221 | + # each file immediately after it has been parsed | |
| 222 | + # and wrangled into shape, and then drop it from | |
| 223 | + # memory. This is done to keep the amount of | |
| 224 | + # required memory within sensible limits. Without | |
| 225 | + # doing it this way we would easily gobble up 1G | |
| 226 | + # of RAM or more with all the objects (revisions | |
| 227 | + # and file-level symbols). | |
| 228 | + | |
| 229 | + $file persist | |
| 212 | 230 | } |
| 213 | 231 | |
| 214 | - # We persist the core of the data collected about each | |
| 215 | - # file immediately after it has been parsed and | |
| 216 | - # wrangled into shape, and then drop it from | |
| 217 | - # memory. This is done to keep the memory requirements | |
| 218 | - # within limits, i.e. without doing it this way it is | |
| 219 | - # easy to blow 1G of RAM with all the objects | |
| 220 | - # (revisions and file-level symbols). | |
| 221 | - | |
| 222 | - $file persist | |
| 223 | 232 | $file drop |
| 224 | 233 | } |
| 225 | 234 | } |
| 226 | 235 | |
| 227 | 236 | repository printrevstatistics |
| @@ -234,12 +243,10 @@ | ||
| 234 | 243 | typemethod discard {} { |
| 235 | 244 | # Pass manager interface. Executed for all passes after the |
| 236 | 245 | # run passes, to remove all data of this pass from the state, |
| 237 | 246 | # as being out of date. |
| 238 | 247 | |
| 239 | - state discard rcs | |
| 240 | - state discard item | |
| 241 | 248 | state discard revision |
| 242 | 249 | state discard tag |
| 243 | 250 | state discard branch |
| 244 | 251 | state discard symbol |
| 245 | 252 | state discard blocker |
| 246 | 253 |
| --- tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| @@ -56,57 +56,64 @@ | |
| 56 | # revisions and symbols. The latter can be further separated |
| 57 | # into tags and branches. At project level the per-file |
| 58 | # symbols information is merged. |
| 59 | |
| 60 | # File level ... |
| 61 | # Event, Revision, Symbol, Branch, Tag |
| 62 | # |
| 63 | # Tag <- Symbol <- Event |
| 64 | # Branch <- Symbol <- Event |
| 65 | # Revision <- Event |
| 66 | # |
| 67 | # Head revision, Principal branch, Comment |
| 68 | |
| 69 | state writing rcs { |
| 70 | fid INTEGER NOT NULL REFERENCES file, -- RCS inherit from FILE |
| 71 | head INTEGER NOT NULL REFERENCES revision, |
| 72 | principal INTEGER NOT NULL REFERENCES branch, |
| 73 | comment TEXT NOT NULL |
| 74 | } |
| 75 | |
| 76 | state writing item { |
| 77 | iid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 78 | type INTEGER NOT NULL, -- enum { tag = 1, branch, revision } |
| 79 | fid INTEGER NOT NULL REFERENCES file -- File the item belongs to |
| 80 | } |
| 81 | |
| 82 | state writing revision { |
| 83 | iid INTEGER NOT NULL REFERENCES item, -- REVISION inherit from ITEM |
| 84 | lod INTEGER NOT NULL REFERENCES symbol, -- Line of development |
| 85 | |
| 86 | -- The tags and branches belonging to a revision can be |
| 87 | -- determined by selecting on the backreferences in the |
| 88 | -- tag and branch tables. |
| 89 | |
| 90 | rev TEXT NOT NULL, -- revision number |
| 91 | date INTEGER NOT NULL, -- date of entry, seconds since epoch |
| 92 | state TEXT NOT NULL, -- state of revision |
| 93 | mid INTEGER NOT NULL REFERENCES meta, -- meta data (author, commit message) |
| 94 | next INTEGER NOT NULL REFERENCES revision, -- next in chain of revisions. |
| 95 | cs INTEGER NOT NULL, -- Revision content as offset and length |
| 96 | cl INTEGER NOT NULL -- into the archive file. |
| 97 | } |
| 98 | |
| 99 | state writing tag { |
| 100 | iid INTEGER NOT NULL REFERENCES item, -- TAG inherit from ITEM |
| 101 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag |
| 102 | rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged. |
| 103 | } |
| 104 | |
| 105 | state writing branch { |
| 106 | iid INTEGER NOT NULL REFERENCES item, -- BRANCH inherit from ITEM |
| 107 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch |
| 108 | root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from |
| 109 | first INTEGER REFERENCES revision, -- First revision committed to the branch |
| 110 | bra TEXT NOT NULL -- branch number |
| 111 | } |
| 112 | |
| @@ -207,21 +214,23 @@ | |
| 207 | trouble fatal "$path is not a valid RCS archive ($msg)" |
| 208 | } else { |
| 209 | global errorInfo |
| 210 | trouble internal $errorInfo |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | # We persist the core of the data collected about each |
| 215 | # file immediately after it has been parsed and |
| 216 | # wrangled into shape, and then drop it from |
| 217 | # memory. This is done to keep the memory requirements |
| 218 | # within limits, i.e. without doing it this way it is |
| 219 | # easy to blow 1G of RAM with all the objects |
| 220 | # (revisions and file-level symbols). |
| 221 | |
| 222 | $file persist |
| 223 | $file drop |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | repository printrevstatistics |
| @@ -234,12 +243,10 @@ | |
| 234 | typemethod discard {} { |
| 235 | # Pass manager interface. Executed for all passes after the |
| 236 | # run passes, to remove all data of this pass from the state, |
| 237 | # as being out of date. |
| 238 | |
| 239 | state discard rcs |
| 240 | state discard item |
| 241 | state discard revision |
| 242 | state discard tag |
| 243 | state discard branch |
| 244 | state discard symbol |
| 245 | state discard blocker |
| 246 |
| --- tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| @@ -56,57 +56,64 @@ | |
| 56 | # revisions and symbols. The latter can be further separated |
| 57 | # into tags and branches. At project level the per-file |
| 58 | # symbols information is merged. |
| 59 | |
| 60 | # File level ... |
| 61 | # Revisions, Branches, Tags |
| 62 | # |
| 63 | # Pseudo class hierarchy |
| 64 | # Tag <- Symbol <- Event |
| 65 | # Branch <- Symbol <- Event |
| 66 | # Revision <- Event |
| 67 | |
| 68 | state writing revision { |
| 69 | rid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 70 | fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
| 71 | lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
| 72 | |
| 73 | -- The tags and branches belonging to a revision can be |
| 74 | -- determined by selecting on the backreferences in the |
| 75 | -- tag and branch tables. |
| 76 | |
| 77 | rev TEXT NOT NULL, -- revision number |
| 78 | date INTEGER NOT NULL, -- date of entry, seconds since epoch |
| 79 | state TEXT NOT NULL, -- state of revision |
| 80 | mid INTEGER NOT NULL REFERENCES meta, -- meta data (author, commit message) |
| 81 | cs INTEGER NOT NULL, -- Revision content as offset and |
| 82 | cl INTEGER NOT NULL, -- length into the archive file. |
| 83 | |
| 84 | -- Derived information, and links |
| 85 | -- Basic: Parent/Child |
| 86 | -- NTDB: DefaultParent/DefaultChild |
| 87 | -- Branches: Branch parent revision |
| 88 | |
| 89 | op INTEGER NOT NULL, |
| 90 | isdefault INTEGER NOT NULL, |
| 91 | parent INTEGER REFERENCES revision, |
| 92 | child INTEGER REFERENCES revision, |
| 93 | dbparent INTEGER REFERENCES revision, |
| 94 | dbchild INTEGER REFERENCES revision, |
| 95 | bparent INTEGER REFERENCES symbol |
| 96 | } |
| 97 | |
| 98 | state writing tag { |
| 99 | tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 100 | fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
| 101 | lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
| 102 | |
| 103 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag |
| 104 | |
| 105 | rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged. |
| 106 | } |
| 107 | |
| 108 | state writing branch { |
| 109 | bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 110 | fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
| 111 | lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
| 112 | |
| 113 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch |
| 114 | |
| 115 | root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from |
| 116 | first INTEGER REFERENCES revision, -- First revision committed to the branch |
| 117 | bra TEXT NOT NULL -- branch number |
| 118 | } |
| 119 | |
| @@ -207,21 +214,23 @@ | |
| 214 | trouble fatal "$path is not a valid RCS archive ($msg)" |
| 215 | } else { |
| 216 | global errorInfo |
| 217 | trouble internal $errorInfo |
| 218 | } |
| 219 | } else { |
| 220 | # We persist the core of the data collected about |
| 221 | # each file immediately after it has been parsed |
| 222 | # and wrangled into shape, and then drop it from |
| 223 | # memory. This is done to keep the amount of |
| 224 | # required memory within sensible limits. Without |
| 225 | # doing it this way we would easily gobble up 1G |
| 226 | # of RAM or more with all the objects (revisions |
| 227 | # and file-level symbols). |
| 228 | |
| 229 | $file persist |
| 230 | } |
| 231 | |
| 232 | $file drop |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | repository printrevstatistics |
| @@ -234,12 +243,10 @@ | |
| 243 | typemethod discard {} { |
| 244 | # Pass manager interface. Executed for all passes after the |
| 245 | # run passes, to remove all data of this pass from the state, |
| 246 | # as being out of date. |
| 247 | |
| 248 | state discard revision |
| 249 | state discard tag |
| 250 | state discard branch |
| 251 | state discard symbol |
| 252 | state discard blocker |
| 253 |
+20
-11
| --- tools/cvs2fossil/lib/c2f_project.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_project.tcl | ||
| @@ -45,12 +45,12 @@ | ||
| 45 | 45 | return $mybase |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | method setid {id} { set myid $id ; return } |
| 49 | 49 | |
| 50 | - method addfile {rcs usr executable} { | |
| 51 | - set myfiles($rcs) [list $usr $executable] | |
| 50 | + method addfile {rcs usr executable {fid {}}} { | |
| 51 | + set myfiles($rcs) [list $usr $executable $fid] | |
| 52 | 52 | return |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | method filenames {} { |
| 56 | 56 | return [lsort -dict [array names myfiles]] |
| @@ -77,10 +77,12 @@ | ||
| 77 | 77 | return $mysymbols($name) |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | # pass I persistence |
| 81 | 81 | method persist {} { |
| 82 | + TheFiles ; # Force id assignment. | |
| 83 | + | |
| 82 | 84 | state transaction { |
| 83 | 85 | # Project data first. Required so that we have its id |
| 84 | 86 | # ready for the files. |
| 85 | 87 | |
| 86 | 88 | state run { |
| @@ -90,28 +92,32 @@ | ||
| 90 | 92 | set myid [state id] |
| 91 | 93 | |
| 92 | 94 | # Then all files, with proper backreference to their |
| 93 | 95 | # project. |
| 94 | 96 | |
| 95 | - foreach {rcs item} [array get myfiles] { | |
| 96 | - struct::list assign $item usr executable | |
| 97 | + foreach rcs [lsort -dict [array names myfiles]] { | |
| 98 | + struct::list assign $myfiles($rcs) usr executable _fid_ | |
| 97 | 99 | state run { |
| 98 | 100 | INSERT INTO file (fid, pid, name, visible, exec) |
| 99 | 101 | VALUES (NULL, $myid, $rcs, $usr, $executable); |
| 100 | 102 | } |
| 103 | + $myfmap($rcs) setid [state id] | |
| 101 | 104 | } |
| 102 | 105 | } |
| 103 | 106 | return |
| 104 | 107 | } |
| 105 | 108 | |
| 106 | 109 | # pass II persistence |
| 107 | 110 | method persistrev {} { |
| 111 | + # Note: The per file information (incl. revisions and symbols) | |
| 112 | + # has already been saved and dropped, immediately after | |
| 113 | + # processing it, to keep out use of memory under control. Now | |
| 114 | + # we just have to save the remaining project level parts to | |
| 115 | + # fix the left-over dangling references. | |
| 116 | + | |
| 108 | 117 | state transaction { |
| 109 | 118 | # TODO: per project persistence (symbols, meta data) |
| 110 | - foreach f [TheFiles] { | |
| 111 | - $f persist | |
| 112 | - } | |
| 113 | 119 | } |
| 114 | 120 | return |
| 115 | 121 | } |
| 116 | 122 | |
| 117 | 123 | # # ## ### ##### ######## ############# |
| @@ -122,31 +128,34 @@ | ||
| 122 | 128 | variable mytrunk {} ; # Reference to the main line of |
| 123 | 129 | # development for the project. |
| 124 | 130 | variable myfiles -array {} ; # Maps the rcs archive paths to |
| 125 | 131 | # their user-visible files. |
| 126 | 132 | variable myfobj {} ; # File objects for the rcs archives |
| 133 | + variable myfmap -array {} ; # Map rcs archive to their object. | |
| 127 | 134 | variable myrepository {} ; # Repository the prject belongs to. |
| 128 | 135 | variable mysymbols -array {} ; # Map symbol names to project-level |
| 129 | 136 | # symbol objects. |
| 130 | 137 | |
| 131 | 138 | # # ## ### ##### ######## ############# |
| 132 | 139 | ## Internal methods |
| 133 | 140 | |
| 134 | 141 | proc TheFiles {} { |
| 135 | - upvar 1 myfiles myfiles myfobj myfobj self self | |
| 142 | + upvar 1 myfiles myfiles myfobj myfobj self self myfmap myfmap | |
| 136 | 143 | if {![llength $myfobj]} { |
| 137 | 144 | set myfobj [EmptyFiles myfiles] |
| 138 | 145 | } |
| 139 | 146 | return $myfobj |
| 140 | 147 | } |
| 141 | 148 | |
| 142 | 149 | proc EmptyFiles {fv} { |
| 143 | - upvar 1 $fv myfiles self self | |
| 150 | + upvar 1 $fv myfiles self self myfmap myfmap | |
| 144 | 151 | set res {} |
| 145 | 152 | foreach rcs [lsort -dict [array names myfiles]] { |
| 146 | - struct::list assign $myfiles($rcs) f executable | |
| 147 | - lappend res [file %AUTO% $rcs $f $executable $self] | |
| 153 | + struct::list assign $myfiles($rcs) f executable fid | |
| 154 | + set file [file %AUTO% $fid $rcs $f $executable $self] | |
| 155 | + lappend res $file | |
| 156 | + set myfmap($rcs) $file | |
| 148 | 157 | } |
| 149 | 158 | return $res |
| 150 | 159 | } |
| 151 | 160 | |
| 152 | 161 | # # ## ### ##### ######## ############# |
| 153 | 162 |
| --- tools/cvs2fossil/lib/c2f_project.tcl | |
| +++ tools/cvs2fossil/lib/c2f_project.tcl | |
| @@ -45,12 +45,12 @@ | |
| 45 | return $mybase |
| 46 | } |
| 47 | |
| 48 | method setid {id} { set myid $id ; return } |
| 49 | |
| 50 | method addfile {rcs usr executable} { |
| 51 | set myfiles($rcs) [list $usr $executable] |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | method filenames {} { |
| 56 | return [lsort -dict [array names myfiles]] |
| @@ -77,10 +77,12 @@ | |
| 77 | return $mysymbols($name) |
| 78 | } |
| 79 | |
| 80 | # pass I persistence |
| 81 | method persist {} { |
| 82 | state transaction { |
| 83 | # Project data first. Required so that we have its id |
| 84 | # ready for the files. |
| 85 | |
| 86 | state run { |
| @@ -90,28 +92,32 @@ | |
| 90 | set myid [state id] |
| 91 | |
| 92 | # Then all files, with proper backreference to their |
| 93 | # project. |
| 94 | |
| 95 | foreach {rcs item} [array get myfiles] { |
| 96 | struct::list assign $item usr executable |
| 97 | state run { |
| 98 | INSERT INTO file (fid, pid, name, visible, exec) |
| 99 | VALUES (NULL, $myid, $rcs, $usr, $executable); |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | return |
| 104 | } |
| 105 | |
| 106 | # pass II persistence |
| 107 | method persistrev {} { |
| 108 | state transaction { |
| 109 | # TODO: per project persistence (symbols, meta data) |
| 110 | foreach f [TheFiles] { |
| 111 | $f persist |
| 112 | } |
| 113 | } |
| 114 | return |
| 115 | } |
| 116 | |
| 117 | # # ## ### ##### ######## ############# |
| @@ -122,31 +128,34 @@ | |
| 122 | variable mytrunk {} ; # Reference to the main line of |
| 123 | # development for the project. |
| 124 | variable myfiles -array {} ; # Maps the rcs archive paths to |
| 125 | # their user-visible files. |
| 126 | variable myfobj {} ; # File objects for the rcs archives |
| 127 | variable myrepository {} ; # Repository the prject belongs to. |
| 128 | variable mysymbols -array {} ; # Map symbol names to project-level |
| 129 | # symbol objects. |
| 130 | |
| 131 | # # ## ### ##### ######## ############# |
| 132 | ## Internal methods |
| 133 | |
| 134 | proc TheFiles {} { |
| 135 | upvar 1 myfiles myfiles myfobj myfobj self self |
| 136 | if {![llength $myfobj]} { |
| 137 | set myfobj [EmptyFiles myfiles] |
| 138 | } |
| 139 | return $myfobj |
| 140 | } |
| 141 | |
| 142 | proc EmptyFiles {fv} { |
| 143 | upvar 1 $fv myfiles self self |
| 144 | set res {} |
| 145 | foreach rcs [lsort -dict [array names myfiles]] { |
| 146 | struct::list assign $myfiles($rcs) f executable |
| 147 | lappend res [file %AUTO% $rcs $f $executable $self] |
| 148 | } |
| 149 | return $res |
| 150 | } |
| 151 | |
| 152 | # # ## ### ##### ######## ############# |
| 153 |
| --- tools/cvs2fossil/lib/c2f_project.tcl | |
| +++ tools/cvs2fossil/lib/c2f_project.tcl | |
| @@ -45,12 +45,12 @@ | |
| 45 | return $mybase |
| 46 | } |
| 47 | |
| 48 | method setid {id} { set myid $id ; return } |
| 49 | |
| 50 | method addfile {rcs usr executable {fid {}}} { |
| 51 | set myfiles($rcs) [list $usr $executable $fid] |
| 52 | return |
| 53 | } |
| 54 | |
| 55 | method filenames {} { |
| 56 | return [lsort -dict [array names myfiles]] |
| @@ -77,10 +77,12 @@ | |
| 77 | return $mysymbols($name) |
| 78 | } |
| 79 | |
| 80 | # pass I persistence |
| 81 | method persist {} { |
| 82 | TheFiles ; # Force id assignment. |
| 83 | |
| 84 | state transaction { |
| 85 | # Project data first. Required so that we have its id |
| 86 | # ready for the files. |
| 87 | |
| 88 | state run { |
| @@ -90,28 +92,32 @@ | |
| 92 | set myid [state id] |
| 93 | |
| 94 | # Then all files, with proper backreference to their |
| 95 | # project. |
| 96 | |
| 97 | foreach rcs [lsort -dict [array names myfiles]] { |
| 98 | struct::list assign $myfiles($rcs) usr executable _fid_ |
| 99 | state run { |
| 100 | INSERT INTO file (fid, pid, name, visible, exec) |
| 101 | VALUES (NULL, $myid, $rcs, $usr, $executable); |
| 102 | } |
| 103 | $myfmap($rcs) setid [state id] |
| 104 | } |
| 105 | } |
| 106 | return |
| 107 | } |
| 108 | |
| 109 | # pass II persistence |
| 110 | method persistrev {} { |
| 111 | # Note: The per file information (incl. revisions and symbols) |
| 112 | # has already been saved and dropped, immediately after |
| 113 | # processing it, to keep out use of memory under control. Now |
| 114 | # we just have to save the remaining project level parts to |
| 115 | # fix the left-over dangling references. |
| 116 | |
| 117 | state transaction { |
| 118 | # TODO: per project persistence (symbols, meta data) |
| 119 | } |
| 120 | return |
| 121 | } |
| 122 | |
| 123 | # # ## ### ##### ######## ############# |
| @@ -122,31 +128,34 @@ | |
| 128 | variable mytrunk {} ; # Reference to the main line of |
| 129 | # development for the project. |
| 130 | variable myfiles -array {} ; # Maps the rcs archive paths to |
| 131 | # their user-visible files. |
| 132 | variable myfobj {} ; # File objects for the rcs archives |
| 133 | variable myfmap -array {} ; # Map rcs archive to their object. |
| 134 | variable myrepository {} ; # Repository the prject belongs to. |
| 135 | variable mysymbols -array {} ; # Map symbol names to project-level |
| 136 | # symbol objects. |
| 137 | |
| 138 | # # ## ### ##### ######## ############# |
| 139 | ## Internal methods |
| 140 | |
| 141 | proc TheFiles {} { |
| 142 | upvar 1 myfiles myfiles myfobj myfobj self self myfmap myfmap |
| 143 | if {![llength $myfobj]} { |
| 144 | set myfobj [EmptyFiles myfiles] |
| 145 | } |
| 146 | return $myfobj |
| 147 | } |
| 148 | |
| 149 | proc EmptyFiles {fv} { |
| 150 | upvar 1 $fv myfiles self self myfmap myfmap |
| 151 | set res {} |
| 152 | foreach rcs [lsort -dict [array names myfiles]] { |
| 153 | struct::list assign $myfiles($rcs) f executable fid |
| 154 | set file [file %AUTO% $fid $rcs $f $executable $self] |
| 155 | lappend res $file |
| 156 | set myfmap($rcs) $file |
| 157 | } |
| 158 | return $res |
| 159 | } |
| 160 | |
| 161 | # # ## ### ##### ######## ############# |
| 162 |
| --- tools/cvs2fossil/lib/c2f_repository.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_repository.tcl | ||
| @@ -150,11 +150,11 @@ | ||
| 150 | 150 | $pr($pid) setid $pid |
| 151 | 151 | } |
| 152 | 152 | foreach {fid pid name visible exec} [state run { |
| 153 | 153 | SELECT fid, pid, name, visible, exec FROM file ; |
| 154 | 154 | }] { |
| 155 | - $pr($pid) addfile $name $visible $exec | |
| 155 | + $pr($pid) addfile $name $visible $exec $fid | |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | return |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 |
| --- tools/cvs2fossil/lib/c2f_repository.tcl | |
| +++ tools/cvs2fossil/lib/c2f_repository.tcl | |
| @@ -150,11 +150,11 @@ | |
| 150 | $pr($pid) setid $pid |
| 151 | } |
| 152 | foreach {fid pid name visible exec} [state run { |
| 153 | SELECT fid, pid, name, visible, exec FROM file ; |
| 154 | }] { |
| 155 | $pr($pid) addfile $name $visible $exec |
| 156 | } |
| 157 | } |
| 158 | return |
| 159 | } |
| 160 | |
| 161 |
| --- tools/cvs2fossil/lib/c2f_repository.tcl | |
| +++ tools/cvs2fossil/lib/c2f_repository.tcl | |
| @@ -150,11 +150,11 @@ | |
| 150 | $pr($pid) setid $pid |
| 151 | } |
| 152 | foreach {fid pid name visible exec} [state run { |
| 153 | SELECT fid, pid, name, visible, exec FROM file ; |
| 154 | }] { |
| 155 | $pr($pid) addfile $name $visible $exec $fid |
| 156 | } |
| 157 | } |
| 158 | return |
| 159 | } |
| 160 | |
| 161 |