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.

aku 2007-10-24 08:01 trunk
Commit adf168e23e3d3812bb7c49d385a1bfd797e23a36
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -19,10 +19,11 @@
1919
package require Tcl 8.4 ; # Required runtime.
2020
package require snit ; # OO system.
2121
package require struct::set ; # Set operations.
2222
package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions.
2323
package require vc::fossil::import::cvs::file::sym ; # CVS per file symbols.
24
+package require vc::fossil::import::cvs::state ; # State storage.
2425
package require vc::tools::trouble ; # Error reporting.
2526
package require vc::tools::log ; # User feedback
2627
package require vc::tools::misc ; # Text formatting
2728
2829
# # ## ### ##### ######## ############# #####################
@@ -30,19 +31,27 @@
3031
3132
snit::type ::vc::fossil::import::cvs::file {
3233
# # ## ### ##### ######## #############
3334
## Public API
3435
35
- constructor {path usrpath executable project} {
36
+ constructor {id path usrpath executable project} {
37
+ set myid $id
3638
set mypath $path
3739
set myusrpath $usrpath
3840
set myexecutable $executable
3941
set myproject $project
4042
set mytrunk [$myproject trunk]
4143
return
4244
}
4345
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 }
4453
method path {} { return $mypath }
4554
method usrpath {} { return $myusrpath }
4655
method project {} { return $myproject }
4756
4857
delegate method commitmessageof to myproject
@@ -64,10 +73,30 @@
6473
6574
# # ## ### ##### ######## #############
6675
## Persistence (pass II)
6776
6877
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
6998
}
7099
71100
method drop {} {
72101
foreach {_ rev} [array get myrev] { $rev destroy }
73102
foreach {_ branch} [array get mybranches] { $branch destroy }
@@ -220,10 +249,11 @@
220249
}
221250
222251
# # ## ### ##### ######## #############
223252
## State
224253
254
+ variable myid {} ; # File id in the persistent state.
225255
variable mypath {} ; # Path of the file's rcs archive.
226256
variable myusrpath {} ; # Path of the file as seen by users.
227257
variable myexecutable 0 ; # Boolean flag 'file executable'.
228258
variable myproject {} ; # Reference to the project object
229259
# the file belongs to.
@@ -308,18 +338,18 @@
308338
if {[info exists mybranches($branchnr)]} {
309339
log write 1 file "In '$mypath': Branch '$branchnr' named '[$mybranches($branchnr) name]'"
310340
log write 1 file "Cannot have second name '$name', ignoring it"
311341
return
312342
}
313
- set branch [sym %AUTO% branch $branchnr [$myproject getsymbol $name]]
343
+ set branch [sym %AUTO% branch $branchnr [$myproject getsymbol $name] $self]
314344
$branch setposition [incr mybranchcnt]
315345
set mybranches($branchnr) $branch
316346
return $branch
317347
}
318348
319349
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]
321351
lappend mytags($revnr) $tag
322352
return $tag
323353
}
324354
325355
method RecordBasicDependencies {revnr next} {
@@ -378,11 +408,11 @@
378408
# If revisions were committed on the branch we store a
379409
# reference to the branch there, and further declare
380410
# the first child's parent to be branch's parent, and
381411
# list this child in the parent revision.
382412
383
- if {[$branch haschild]} {
413
+ if {[$branch haschildrev]} {
384414
set childrevnr [$branch childrevnr]
385415
set child $myrev($childrevnr)
386416
$branch setchild $child
387417
388418
$child setparentbranch $branch
@@ -670,10 +700,11 @@
670700
set vendor [$first parentbranch]
671701
if {$vendor eq ""} { trouble internal "First NTDB revision has no branch" }
672702
if {[$vendor parent] eq $rev11} {
673703
$rev11 removebranch $vendor
674704
$rev11 removechildonbranch $first
705
+ $vendor cutchild
675706
$first cutfromparentbranch
676707
lappend myroots $first
677708
}
678709
679710
# Change the type of first (typically from Change to Add):
@@ -726,11 +757,11 @@
726757
set child [$root child]
727758
$child cutfromparent
728759
lappend myroots $child
729760
}
730761
731
- # Remove the branches spawned by the revision to be
762
+ # Cut out the branches spawned by the revision to be
732763
# deleted. If the branch has revisions they should already
733764
# use operation 'add', no need to change that. The first
734765
# revision on each branch becomes a new and disconnected
735766
# root.
736767
@@ -737,10 +768,11 @@
737768
foreach branch [$root branches] {
738769
if {![$branch haschild]} continue
739770
set first [$branch child]
740771
$first cutfromparentbranch
741772
$first cutfromparent
773
+ $branch cutchild
742774
lappend myroots $first
743775
}
744776
$root removeallbranches
745777
746778
# Tagging a dead revision doesn't do anything, so remove
@@ -779,11 +811,13 @@
779811
set child [$root child]
780812
781813
ldelete myroots $root
782814
lappend myroots $child
783815
816
+ $branch cutchild
784817
$child cutfromparent
818
+
785819
$parent removebranch $branch
786820
$parent removechildonbranch $root
787821
}
788822
return
789823
}
@@ -970,10 +1004,29 @@
9701004
set root [$root child]
9711005
}
9721006
9731007
return
9741008
}
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
+ }
9751028
9761029
# # ## ### ##### ######## #############
9771030
## Configuration
9781031
9791032
pragma -hastypeinfo no ; # no type introspection
@@ -990,13 +1043,14 @@
9901043
# namespace import ::vc::fossil::import::cvs::file::rev
9911044
# namespace import ::vc::fossil::import::cvs::file::sym
9921045
namespace import ::vc::tools::misc::*
9931046
namespace import ::vc::tools::trouble
9941047
namespace import ::vc::tools::log
1048
+ namespace import ::vc::fossil::import::cvs::state
9951049
}
9961050
}
9971051
9981052
# # ## ### ##### ######## ############# #####################
9991053
## Ready
10001054
10011055
package provide vc::fossil::import::cvs::file 1.0
10021056
return
10031057
--- 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 @@
1616
## Requirements
1717
1818
package require Tcl 8.4 ; # Required runtime.
1919
package require snit ; # OO system.
2020
package require vc::tools::misc ; # Text formatting
21
+package require vc::fossil::import::cvs::state ; # State storage.
2122
2223
# # ## ### ##### ######## ############# #####################
2324
##
2425
2526
snit::type ::vc::fossil::import::cvs::file::rev {
@@ -33,10 +34,17 @@
3334
set mystate $state
3435
set myfile $thefile
3536
return
3637
}
3738
39
+ method defid {} {
40
+ set myid [incr myidcounter]
41
+ return
42
+ }
43
+
44
+ method id {} { return $myid }
45
+
3846
# Basic pieces ________________________
3947
4048
method hasmeta {} { return [expr {$mymetaid ne ""}] }
4149
method hastext {} {
4250
struct::list assign $mytext s e
@@ -330,18 +338,66 @@
330338
331339
typemethod 2branchparentrevnr {branchnr} {
332340
# Chop the last segment off
333341
return [join [lrange [split $branchnr .] 0 end-1] .]
334342
}
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
+ }
335371
336372
# # ## ### ##### ######## #############
337373
## 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
+
338391
339392
typevariable mybranchpattern {^((?:\d+\.\d+\.)+)(?:0\.)?(\d+)$}
340393
# First a nonzero even number of digit groups with trailing dot
341394
# CVS then sticks an extra 0 in here; RCS does not.
342395
# And the last digit group.
396
+
397
+ typevariable myidcounter 0 ; # Counter for revision ids.
398
+ variable myid {} ; # Revision id.
343399
344400
variable myrevnr {} ; # Revision number of the revision.
345401
variable mydate {} ; # Timestamp of the revision, seconds since epoch
346402
variable myorigdate {} ; # Original unmodified timestamp.
347403
variable mystate {} ; # State of the revision.
@@ -424,10 +480,16 @@
424480
{0 0} change
425481
{0 1} delete
426482
{1 0} add
427483
{1 1} nothing
428484
}
485
+ typevariable myopcode -array {
486
+ change 2
487
+ delete -1
488
+ add 1
489
+ nothing 0
490
+ }
429491
430492
# # ## ### ##### ######## #############
431493
## Internal methods
432494
433495
# # ## ### ##### ######## #############
@@ -442,13 +504,14 @@
442504
443505
namespace eval ::vc::fossil::import::cvs::file {
444506
namespace export rev
445507
namespace eval rev {
446508
namespace import ::vc::tools::misc::*
509
+ namespace import ::vc::fossil::import::cvs::state
447510
}
448511
}
449512
450513
# # ## ### ##### ######## ############# #####################
451514
## Ready
452515
453516
package provide vc::fossil::import::cvs::file::rev 1.0
454517
return
455518
--- 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
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -17,19 +17,21 @@
1717
1818
package require Tcl 8.4 ; # Required runtime.
1919
package require snit ; # OO system.
2020
package require vc::tools::trouble ; # Error reporting.
2121
package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions.
22
+package require vc::fossil::import::cvs::state ; # State storage.
2223
2324
# # ## ### ##### ######## ############# #####################
2425
##
2526
2627
snit::type ::vc::fossil::import::cvs::file::sym {
2728
# # ## ### ##### ######## #############
2829
## Public API
2930
30
- constructor {symtype nr symbol} {
31
+ constructor {symtype nr symbol file} {
32
+ set myfile $file
3133
set mytype $symtype
3234
set mynr $nr
3335
set mysymbol $symbol
3436
3537
switch -exact -- $mytype {
@@ -38,10 +40,17 @@
3840
default { trouble internal "Bad symbol type '$mytype'" }
3941
}
4042
return
4143
}
4244
45
+ method defid {} {
46
+ set myid [incr myidcounter]
47
+ return
48
+ }
49
+
50
+ method fid {} { return $myid }
51
+
4352
# Symbol acessor methods.
4453
4554
delegate method name to mysymbol
4655
delegate method id to mysymbol
4756
@@ -56,15 +65,17 @@
5665
}
5766
5867
method setposition {n} { set mybranchposition $n ; return }
5968
method setparent {rev} { set mybranchparent $rev ; return }
6069
method setchild {rev} { set mybranchchild $rev ; return }
70
+ method cutchild {} { set mybranchchild "" ; return }
6171
6272
method branchnr {} { return $mynr }
6373
method parentrevnr {} { return $mybranchparentrevnr }
6474
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 ""}] }
6677
method parent {} { return $mybranchparent }
6778
method child {} { return $mybranchchild }
6879
method position {} { return $mybranchposition }
6980
7081
@@ -97,16 +108,75 @@
97108
trouble fatal "For $mytype [$mysymbol name]: LOD conflict with source, '[$mylod name]' vs. '[$slod name]'"
98109
return
99110
}
100111
return
101112
}
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
+ }
102153
103154
# # ## ### ##### ######## #############
104155
## State
105156
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
+
106175
## Basic, all symbols _________________
107176
177
+ variable myfile {} ; # Reference to the file the symbol is in.
108178
variable mytype {} ; # Symbol type, 'tag', or 'branch'.
109179
variable mynr {} ; # Revision number of a 'tag', branch number
110180
# of a 'branch'.
111181
variable mysymbol {} ; # Reference to the symbol object of this
112182
# symbol at the project level.
@@ -162,14 +232,15 @@
162232
163233
namespace eval ::vc::fossil::import::cvs::file {
164234
namespace export sym
165235
namespace eval sym {
166236
namespace import ::vc::fossil::import::cvs::file::rev
237
+ namespace import ::vc::fossil::import::cvs::state
167238
namespace import ::vc::tools::trouble
168239
}
169240
}
170241
171242
# # ## ### ##### ######## ############# #####################
172243
## Ready
173244
174245
package provide vc::fossil::import::cvs::file::sym 1.0
175246
return
176247
--- 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
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -56,57 +56,64 @@
5656
# revisions and symbols. The latter can be further separated
5757
# into tags and branches. At project level the per-file
5858
# symbols information is merged.
5959
6060
# 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
8167
8268
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)
8572
8673
-- The tags and branches belonging to a revision can be
8774
-- determined by selecting on the backreferences in the
8875
-- tag and branch tables.
8976
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
9796
}
9897
9998
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.
103106
}
104107
105108
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
+
107113
sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch
114
+
108115
root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from
109116
first INTEGER REFERENCES revision, -- First revision committed to the branch
110117
bra TEXT NOT NULL -- branch number
111118
}
112119
@@ -207,21 +214,23 @@
207214
trouble fatal "$path is not a valid RCS archive ($msg)"
208215
} else {
209216
global errorInfo
210217
trouble internal $errorInfo
211218
}
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
212230
}
213231
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
223232
$file drop
224233
}
225234
}
226235
227236
repository printrevstatistics
@@ -234,12 +243,10 @@
234243
typemethod discard {} {
235244
# Pass manager interface. Executed for all passes after the
236245
# run passes, to remove all data of this pass from the state,
237246
# as being out of date.
238247
239
- state discard rcs
240
- state discard item
241248
state discard revision
242249
state discard tag
243250
state discard branch
244251
state discard symbol
245252
state discard blocker
246253
--- 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
--- tools/cvs2fossil/lib/c2f_project.tcl
+++ tools/cvs2fossil/lib/c2f_project.tcl
@@ -45,12 +45,12 @@
4545
return $mybase
4646
}
4747
4848
method setid {id} { set myid $id ; return }
4949
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]
5252
return
5353
}
5454
5555
method filenames {} {
5656
return [lsort -dict [array names myfiles]]
@@ -77,10 +77,12 @@
7777
return $mysymbols($name)
7878
}
7979
8080
# pass I persistence
8181
method persist {} {
82
+ TheFiles ; # Force id assignment.
83
+
8284
state transaction {
8385
# Project data first. Required so that we have its id
8486
# ready for the files.
8587
8688
state run {
@@ -90,28 +92,32 @@
9092
set myid [state id]
9193
9294
# Then all files, with proper backreference to their
9395
# project.
9496
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_
9799
state run {
98100
INSERT INTO file (fid, pid, name, visible, exec)
99101
VALUES (NULL, $myid, $rcs, $usr, $executable);
100102
}
103
+ $myfmap($rcs) setid [state id]
101104
}
102105
}
103106
return
104107
}
105108
106109
# pass II persistence
107110
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
+
108117
state transaction {
109118
# TODO: per project persistence (symbols, meta data)
110
- foreach f [TheFiles] {
111
- $f persist
112
- }
113119
}
114120
return
115121
}
116122
117123
# # ## ### ##### ######## #############
@@ -122,31 +128,34 @@
122128
variable mytrunk {} ; # Reference to the main line of
123129
# development for the project.
124130
variable myfiles -array {} ; # Maps the rcs archive paths to
125131
# their user-visible files.
126132
variable myfobj {} ; # File objects for the rcs archives
133
+ variable myfmap -array {} ; # Map rcs archive to their object.
127134
variable myrepository {} ; # Repository the prject belongs to.
128135
variable mysymbols -array {} ; # Map symbol names to project-level
129136
# symbol objects.
130137
131138
# # ## ### ##### ######## #############
132139
## Internal methods
133140
134141
proc TheFiles {} {
135
- upvar 1 myfiles myfiles myfobj myfobj self self
142
+ upvar 1 myfiles myfiles myfobj myfobj self self myfmap myfmap
136143
if {![llength $myfobj]} {
137144
set myfobj [EmptyFiles myfiles]
138145
}
139146
return $myfobj
140147
}
141148
142149
proc EmptyFiles {fv} {
143
- upvar 1 $fv myfiles self self
150
+ upvar 1 $fv myfiles self self myfmap myfmap
144151
set res {}
145152
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
148157
}
149158
return $res
150159
}
151160
152161
# # ## ### ##### ######## #############
153162
--- 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 @@
150150
$pr($pid) setid $pid
151151
}
152152
foreach {fid pid name visible exec} [state run {
153153
SELECT fid, pid, name, visible, exec FROM file ;
154154
}] {
155
- $pr($pid) addfile $name $visible $exec
155
+ $pr($pid) addfile $name $visible $exec $fid
156156
}
157157
}
158158
return
159159
}
160160
161161
--- 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

Keyboard Shortcuts

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