Fossil SCM

Added code creating aggregate symbol statistics. This completes pass 2 (CollRev).

aku 2007-10-31 03:44 trunk
Commit 6f8667b03e3a644953d6bd72e7eed9ba83881b08
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -232,11 +232,12 @@
232232
}
233233
234234
method done {} {
235235
# Complete the revisions, branches, and tags. This includes
236236
# looking for a non-trunk default branch, marking its members
237
- # and linking them into the trunk.
237
+ # and linking them into the trunk, possibly excluding
238
+ # non-trunk data, and collecting aggregate symbol statistics.
238239
239240
$self DetermineRevisionOperations
240241
$self DetermineLinesOfDevelopment
241242
$self HandleNonTrunkDefaultBranch
242243
$self RemoveIrrelevantDeletions
@@ -243,10 +244,12 @@
243244
$self RemoveInitialBranchDeletions
244245
245246
if {[$myproject trunkonly]} {
246247
$self ExcludeNonTrunkInformation
247248
}
249
+
250
+ $self AggregateSymbolData
248251
return
249252
}
250253
251254
# # ## ### ##### ######## #############
252255
## State
@@ -1024,10 +1027,64 @@
10241027
}
10251028
10261029
return [list [lsort -unique -dict $revisions] [lsort -unique -dict $symbols]]
10271030
}
10281031
1032
+
1033
+ method AggregateSymbolData {} {
1034
+ # Now that the exact set of revisions (and through that
1035
+ # branches and tags) is known we can update the aggregate
1036
+ # symbol statistics.
1037
+
1038
+ foreach root [$self LinesOfDevelopment] {
1039
+ set lod [$root lod]
1040
+
1041
+ # Note: If the LOD is the trunk the count*, etc. methods
1042
+ # will do nothing, as it is always present (cannot be
1043
+ # excluded), and is always a branch too.
1044
+
1045
+ # Lines of development count as branches and have a commit
1046
+ # on them (root). If they are still attached to a tree we
1047
+ # have to compute and register possible parents.
1048
+
1049
+ $lod countasbranch
1050
+ $lod countacommit
1051
+
1052
+ if {[$root hasparentbranch]} {
1053
+ # Note lod == [$root parentbranch]
1054
+ $lod possibleparents
1055
+ }
1056
+
1057
+ # For the revisions in the line we register their branches
1058
+ # and tags as blockers for the lod, and update the type
1059
+ # counters as well. As branch symbols without commits on
1060
+ # them are not listed as lines of development, we have to
1061
+ # count them here as well, as plain branches. At last we
1062
+ # have to compute and register the possible parents of the
1063
+ # tags, in case they are later converted as branches.
1064
+
1065
+ while {$root ne ""} {
1066
+ foreach branch [$root branches] {
1067
+ $lod blockedby $branch
1068
+ $branch possibleparents
1069
+ if {[$branch haschild]} continue
1070
+ $branch countasbranch
1071
+ }
1072
+
1073
+ foreach tag [$root tags] {
1074
+ $lod blockedby $tag
1075
+ $tag possibleparents
1076
+ $tag countastag
1077
+ }
1078
+
1079
+ set root [$root child]
1080
+ }
1081
+ }
1082
+
1083
+ return
1084
+ }
1085
+
10291086
# # ## ### ##### ######## #############
10301087
## Configuration
10311088
10321089
pragma -hastypeinfo no ; # no type introspection
10331090
pragma -hasinfo no ; # no object introspection
10341091
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -232,11 +232,12 @@
232 }
233
234 method done {} {
235 # Complete the revisions, branches, and tags. This includes
236 # looking for a non-trunk default branch, marking its members
237 # and linking them into the trunk.
 
238
239 $self DetermineRevisionOperations
240 $self DetermineLinesOfDevelopment
241 $self HandleNonTrunkDefaultBranch
242 $self RemoveIrrelevantDeletions
@@ -243,10 +244,12 @@
243 $self RemoveInitialBranchDeletions
244
245 if {[$myproject trunkonly]} {
246 $self ExcludeNonTrunkInformation
247 }
 
 
248 return
249 }
250
251 # # ## ### ##### ######## #############
252 ## State
@@ -1024,10 +1027,64 @@
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
1033 pragma -hasinfo no ; # no object introspection
1034
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -232,11 +232,12 @@
232 }
233
234 method done {} {
235 # Complete the revisions, branches, and tags. This includes
236 # looking for a non-trunk default branch, marking its members
237 # and linking them into the trunk, possibly excluding
238 # non-trunk data, and collecting aggregate symbol statistics.
239
240 $self DetermineRevisionOperations
241 $self DetermineLinesOfDevelopment
242 $self HandleNonTrunkDefaultBranch
243 $self RemoveIrrelevantDeletions
@@ -243,10 +244,12 @@
244 $self RemoveInitialBranchDeletions
245
246 if {[$myproject trunkonly]} {
247 $self ExcludeNonTrunkInformation
248 }
249
250 $self AggregateSymbolData
251 return
252 }
253
254 # # ## ### ##### ######## #############
255 ## State
@@ -1024,10 +1027,64 @@
1027 }
1028
1029 return [list [lsort -unique -dict $revisions] [lsort -unique -dict $symbols]]
1030 }
1031
1032
1033 method AggregateSymbolData {} {
1034 # Now that the exact set of revisions (and through that
1035 # branches and tags) is known we can update the aggregate
1036 # symbol statistics.
1037
1038 foreach root [$self LinesOfDevelopment] {
1039 set lod [$root lod]
1040
1041 # Note: If the LOD is the trunk the count*, etc. methods
1042 # will do nothing, as it is always present (cannot be
1043 # excluded), and is always a branch too.
1044
1045 # Lines of development count as branches and have a commit
1046 # on them (root). If they are still attached to a tree we
1047 # have to compute and register possible parents.
1048
1049 $lod countasbranch
1050 $lod countacommit
1051
1052 if {[$root hasparentbranch]} {
1053 # Note lod == [$root parentbranch]
1054 $lod possibleparents
1055 }
1056
1057 # For the revisions in the line we register their branches
1058 # and tags as blockers for the lod, and update the type
1059 # counters as well. As branch symbols without commits on
1060 # them are not listed as lines of development, we have to
1061 # count them here as well, as plain branches. At last we
1062 # have to compute and register the possible parents of the
1063 # tags, in case they are later converted as branches.
1064
1065 while {$root ne ""} {
1066 foreach branch [$root branches] {
1067 $lod blockedby $branch
1068 $branch possibleparents
1069 if {[$branch haschild]} continue
1070 $branch countasbranch
1071 }
1072
1073 foreach tag [$root tags] {
1074 $lod blockedby $tag
1075 $tag possibleparents
1076 $tag countastag
1077 }
1078
1079 set root [$root child]
1080 }
1081 }
1082
1083 return
1084 }
1085
1086 # # ## ### ##### ######## #############
1087 ## Configuration
1088
1089 pragma -hastypeinfo no ; # no type introspection
1090 pragma -hasinfo no ; # no object introspection
1091
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -45,16 +45,72 @@
4545
method defid {} {
4646
set myid [incr myidcounter]
4747
return
4848
}
4949
50
- method fid {} { return $myid }
50
+ method fid {} { return $myid }
51
+ method symbol {} { return $mysymbol }
5152
5253
# Symbol acessor methods.
5354
5455
delegate method name to mysymbol
5556
delegate method id to mysymbol
57
+
58
+ # Symbol aggregation methods
59
+
60
+ delegate method countasbranch to mysymbol
61
+ delegate method countastag to mysymbol
62
+ delegate method countacommit to mysymbol
63
+
64
+ method blockedby {fsymbol} {
65
+ $mysymbol blockedby [$fsymbol symbol]
66
+ return
67
+ }
68
+
69
+ method possibleparents {} {
70
+ switch -exact -- $mytype {
71
+ branch { $self BranchParents }
72
+ tag { $self TagParents }
73
+ }
74
+ return
75
+ }
76
+
77
+ method BranchParents {} {
78
+ # The "obvious" parent of a branch is the branch holding the
79
+ # revision spawning the branch. Any other branches that are
80
+ # rooted at the same revision and were committed earlier than
81
+ # the branch are also possible parents.
82
+
83
+ $mysymbol possibleparent [[$mybranchparent lod] symbol]
84
+
85
+ foreach branch [$mybranchparent branches] {
86
+ # A branch cannot be its own parent. Nor can a branch
87
+ # created after this one be its parent. This means that we
88
+ # can abort the loop when we have reached ourselves in the
89
+ # list of branches. Here the order of file::rev.mybranches
90
+ # comes into play, as created by file::rev::sortbranches.
91
+
92
+ if {$branch eq $self} break
93
+ $mysymbol possibleparent [$branch symbol]
94
+ }
95
+ return
96
+ }
97
+
98
+ method TagParents {} {
99
+ # The "obvious" parent of a tag is the branch holding the
100
+ # revision spawning the tag. Branches that are spawned by the
101
+ # same revision are also possible parents.
102
+
103
+ $mysymbol possibleparent [[$mytagrev lod] symbol]
104
+
105
+ foreach branch [$mytagrev branches] {
106
+ $mysymbol possibleparent [$branch symbol]
107
+ }
108
+ return
109
+ }
110
+
111
+ #
56112
57113
method istrunk {} { return 0 }
58114
59115
# Branch acessor methods.
60116
@@ -75,11 +131,10 @@
75131
method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] }
76132
method haschild {} { return [expr {$mybranchchild ne ""}] }
77133
method parent {} { return $mybranchparent }
78134
method child {} { return $mybranchchild }
79135
method position {} { return $mybranchposition }
80
-
81136
82137
# Tag acessor methods.
83138
84139
method tagrevnr {} { return $mynr }
85140
method settagrev {rev} {set mytagrev $rev ; return }
86141
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -45,16 +45,72 @@
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
57 method istrunk {} { return 0 }
58
59 # Branch acessor methods.
60
@@ -75,11 +131,10 @@
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
82 # Tag acessor methods.
83
84 method tagrevnr {} { return $mynr }
85 method settagrev {rev} {set mytagrev $rev ; return }
86
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -45,16 +45,72 @@
45 method defid {} {
46 set myid [incr myidcounter]
47 return
48 }
49
50 method fid {} { return $myid }
51 method symbol {} { return $mysymbol }
52
53 # Symbol acessor methods.
54
55 delegate method name to mysymbol
56 delegate method id to mysymbol
57
58 # Symbol aggregation methods
59
60 delegate method countasbranch to mysymbol
61 delegate method countastag to mysymbol
62 delegate method countacommit to mysymbol
63
64 method blockedby {fsymbol} {
65 $mysymbol blockedby [$fsymbol symbol]
66 return
67 }
68
69 method possibleparents {} {
70 switch -exact -- $mytype {
71 branch { $self BranchParents }
72 tag { $self TagParents }
73 }
74 return
75 }
76
77 method BranchParents {} {
78 # The "obvious" parent of a branch is the branch holding the
79 # revision spawning the branch. Any other branches that are
80 # rooted at the same revision and were committed earlier than
81 # the branch are also possible parents.
82
83 $mysymbol possibleparent [[$mybranchparent lod] symbol]
84
85 foreach branch [$mybranchparent branches] {
86 # A branch cannot be its own parent. Nor can a branch
87 # created after this one be its parent. This means that we
88 # can abort the loop when we have reached ourselves in the
89 # list of branches. Here the order of file::rev.mybranches
90 # comes into play, as created by file::rev::sortbranches.
91
92 if {$branch eq $self} break
93 $mysymbol possibleparent [$branch symbol]
94 }
95 return
96 }
97
98 method TagParents {} {
99 # The "obvious" parent of a tag is the branch holding the
100 # revision spawning the tag. Branches that are spawned by the
101 # same revision are also possible parents.
102
103 $mysymbol possibleparent [[$mytagrev lod] symbol]
104
105 foreach branch [$mytagrev branches] {
106 $mysymbol possibleparent [$branch symbol]
107 }
108 return
109 }
110
111 #
112
113 method istrunk {} { return 0 }
114
115 # Branch acessor methods.
116
@@ -75,11 +131,10 @@
131 method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] }
132 method haschild {} { return [expr {$mybranchchild ne ""}] }
133 method parent {} { return $mybranchparent }
134 method child {} { return $mybranchchild }
135 method position {} { return $mybranchposition }
 
136
137 # Tag acessor methods.
138
139 method tagrevnr {} { return $mynr }
140 method settagrev {rev} {set mytagrev $rev ; return }
141
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -186,18 +186,25 @@
186186
187187
UNIQUE (pid, name) -- Symbols are unique within the project
188188
}
189189
190190
state writing blocker {
191
+ -- For each symbol we save which other symbols are
192
+ -- blocking its removal (if the user asks for it).
193
+
191194
sid INTEGER NOT NULL REFERENCES symbol, --
192195
bid INTEGER NOT NULL REFERENCES symbol, -- Sprouted from sid, blocks it.
193196
UNIQUE (sid, bid)
194197
}
195198
196199
state writing parent {
200
+ -- For each symbol we save which other symbols can act as
201
+ -- a possible parent in some file, and how often.
202
+
197203
sid INTEGER NOT NULL REFERENCES symbol, --
198204
pid INTEGER NOT NULL REFERENCES symbol, -- Possible parent of sid
205
+ n INTEGER NOT NULL, -- How often pid can act as parent.
199206
UNIQUE (sid, pid)
200207
}
201208
202209
state writing meta {
203210
-- Meta data of revisions. See revision.mid for the
@@ -283,10 +290,12 @@
283290
$file persist
284291
}
285292
286293
$file drop
287294
}
295
+
296
+ $project purgeghostsymbols
288297
}
289298
290299
repository printrevstatistics
291300
repository persistrev
292301
@@ -312,11 +321,11 @@
312321
return
313322
}
314323
315324
proc Paranoia {} {
316325
# This code performs a number of paranoid checks of the
317
- # database for inconsistent cross-references.
326
+ # database, searching for inconsistent cross-references.
318327
log write 4 collrev {Check database consistency}
319328
320329
set n 0 ; # Counter for the checks (we print an id before the
321330
# main label).
322331
323332
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -186,18 +186,25 @@
186
187 UNIQUE (pid, name) -- Symbols are unique within the project
188 }
189
190 state writing blocker {
 
 
 
191 sid INTEGER NOT NULL REFERENCES symbol, --
192 bid INTEGER NOT NULL REFERENCES symbol, -- Sprouted from sid, blocks it.
193 UNIQUE (sid, bid)
194 }
195
196 state writing parent {
 
 
 
197 sid INTEGER NOT NULL REFERENCES symbol, --
198 pid INTEGER NOT NULL REFERENCES symbol, -- Possible parent of sid
 
199 UNIQUE (sid, pid)
200 }
201
202 state writing meta {
203 -- Meta data of revisions. See revision.mid for the
@@ -283,10 +290,12 @@
283 $file persist
284 }
285
286 $file drop
287 }
 
 
288 }
289
290 repository printrevstatistics
291 repository persistrev
292
@@ -312,11 +321,11 @@
312 return
313 }
314
315 proc Paranoia {} {
316 # This code performs a number of paranoid checks of the
317 # database for inconsistent cross-references.
318 log write 4 collrev {Check database consistency}
319
320 set n 0 ; # Counter for the checks (we print an id before the
321 # main label).
322
323
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -186,18 +186,25 @@
186
187 UNIQUE (pid, name) -- Symbols are unique within the project
188 }
189
190 state writing blocker {
191 -- For each symbol we save which other symbols are
192 -- blocking its removal (if the user asks for it).
193
194 sid INTEGER NOT NULL REFERENCES symbol, --
195 bid INTEGER NOT NULL REFERENCES symbol, -- Sprouted from sid, blocks it.
196 UNIQUE (sid, bid)
197 }
198
199 state writing parent {
200 -- For each symbol we save which other symbols can act as
201 -- a possible parent in some file, and how often.
202
203 sid INTEGER NOT NULL REFERENCES symbol, --
204 pid INTEGER NOT NULL REFERENCES symbol, -- Possible parent of sid
205 n INTEGER NOT NULL, -- How often pid can act as parent.
206 UNIQUE (sid, pid)
207 }
208
209 state writing meta {
210 -- Meta data of revisions. See revision.mid for the
@@ -283,10 +290,12 @@
290 $file persist
291 }
292
293 $file drop
294 }
295
296 $project purgeghostsymbols
297 }
298
299 repository printrevstatistics
300 repository persistrev
301
@@ -312,11 +321,11 @@
321 return
322 }
323
324 proc Paranoia {} {
325 # This code performs a number of paranoid checks of the
326 # database, searching for inconsistent cross-references.
327 log write 4 collrev {Check database consistency}
328
329 set n 0 ; # Counter for the checks (we print an id before the
330 # main label).
331
332
--- tools/cvs2fossil/lib/c2f_project.tcl
+++ tools/cvs2fossil/lib/c2f_project.tcl
@@ -19,10 +19,11 @@
1919
package require snit ; # OO system.
2020
package require vc::fossil::import::cvs::file ; # CVS archive file.
2121
package require vc::fossil::import::cvs::state ; # State storage.
2222
package require vc::fossil::import::cvs::project::sym ; # Per project symbols.
2323
package require vc::fossil::import::cvs::project::trunk ; # Per project trunk, main lod
24
+package require vc::tools::log ; # User feedback
2425
package require struct::list ; # Advanced list operations..
2526
2627
# # ## ### ##### ######## ############# #####################
2728
##
2829
@@ -32,10 +33,11 @@
3233
3334
constructor {path r} {
3435
set mybase $path
3536
set myrepository $r
3637
set mytrunk [trunk %AUTO% $self]
38
+ set mysymbol([$mytrunk name]) $mytrunk
3739
return
3840
}
3941
4042
method base {} { return $mybase }
4143
method trunk {} { return $mytrunk }
@@ -75,10 +77,25 @@
7577
set mysymbol($name) \
7678
[sym %AUTO% $name [$myrepository defsymbol $myid $name] $self]
7779
}
7880
return $mysymbol($name)
7981
}
82
+
83
+ method purgeghostsymbols {} {
84
+ set changes 1
85
+ while {$changes} {
86
+ set changes 0
87
+ foreach {name symbol} [array get mysymbol] {
88
+ if {![$symbol isghost]} continue
89
+ log write 3 project "$mybase: Deleting ghost symbol '$name'"
90
+ $symbol destroy
91
+ unset mysymbol($name)
92
+ set changes 1
93
+ }
94
+ }
95
+ return
96
+ }
8097
8198
# pass I persistence
8299
method persist {} {
83100
TheFiles ; # Force id assignment.
84101
@@ -177,10 +194,11 @@
177194
}
178195
179196
namespace eval ::vc::fossil::import::cvs {
180197
namespace export project
181198
namespace eval project {
199
+ namespace import ::vc::tools::log
182200
namespace import ::vc::fossil::import::cvs::file
183201
namespace import ::vc::fossil::import::cvs::state
184202
# Import not required, already a child namespace.
185203
# namespace import ::vc::fossil::import::cvs::project::sym
186204
}
187205
--- tools/cvs2fossil/lib/c2f_project.tcl
+++ tools/cvs2fossil/lib/c2f_project.tcl
@@ -19,10 +19,11 @@
19 package require snit ; # OO system.
20 package require vc::fossil::import::cvs::file ; # CVS archive file.
21 package require vc::fossil::import::cvs::state ; # State storage.
22 package require vc::fossil::import::cvs::project::sym ; # Per project symbols.
23 package require vc::fossil::import::cvs::project::trunk ; # Per project trunk, main lod
 
24 package require struct::list ; # Advanced list operations..
25
26 # # ## ### ##### ######## ############# #####################
27 ##
28
@@ -32,10 +33,11 @@
32
33 constructor {path r} {
34 set mybase $path
35 set myrepository $r
36 set mytrunk [trunk %AUTO% $self]
 
37 return
38 }
39
40 method base {} { return $mybase }
41 method trunk {} { return $mytrunk }
@@ -75,10 +77,25 @@
75 set mysymbol($name) \
76 [sym %AUTO% $name [$myrepository defsymbol $myid $name] $self]
77 }
78 return $mysymbol($name)
79 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
81 # pass I persistence
82 method persist {} {
83 TheFiles ; # Force id assignment.
84
@@ -177,10 +194,11 @@
177 }
178
179 namespace eval ::vc::fossil::import::cvs {
180 namespace export project
181 namespace eval project {
 
182 namespace import ::vc::fossil::import::cvs::file
183 namespace import ::vc::fossil::import::cvs::state
184 # Import not required, already a child namespace.
185 # namespace import ::vc::fossil::import::cvs::project::sym
186 }
187
--- tools/cvs2fossil/lib/c2f_project.tcl
+++ tools/cvs2fossil/lib/c2f_project.tcl
@@ -19,10 +19,11 @@
19 package require snit ; # OO system.
20 package require vc::fossil::import::cvs::file ; # CVS archive file.
21 package require vc::fossil::import::cvs::state ; # State storage.
22 package require vc::fossil::import::cvs::project::sym ; # Per project symbols.
23 package require vc::fossil::import::cvs::project::trunk ; # Per project trunk, main lod
24 package require vc::tools::log ; # User feedback
25 package require struct::list ; # Advanced list operations..
26
27 # # ## ### ##### ######## ############# #####################
28 ##
29
@@ -32,10 +33,11 @@
33
34 constructor {path r} {
35 set mybase $path
36 set myrepository $r
37 set mytrunk [trunk %AUTO% $self]
38 set mysymbol([$mytrunk name]) $mytrunk
39 return
40 }
41
42 method base {} { return $mybase }
43 method trunk {} { return $mytrunk }
@@ -75,10 +77,25 @@
77 set mysymbol($name) \
78 [sym %AUTO% $name [$myrepository defsymbol $myid $name] $self]
79 }
80 return $mysymbol($name)
81 }
82
83 method purgeghostsymbols {} {
84 set changes 1
85 while {$changes} {
86 set changes 0
87 foreach {name symbol} [array get mysymbol] {
88 if {![$symbol isghost]} continue
89 log write 3 project "$mybase: Deleting ghost symbol '$name'"
90 $symbol destroy
91 unset mysymbol($name)
92 set changes 1
93 }
94 }
95 return
96 }
97
98 # pass I persistence
99 method persist {} {
100 TheFiles ; # Force id assignment.
101
@@ -177,10 +194,11 @@
194 }
195
196 namespace eval ::vc::fossil::import::cvs {
197 namespace export project
198 namespace eval project {
199 namespace import ::vc::tools::log
200 namespace import ::vc::fossil::import::cvs::file
201 namespace import ::vc::fossil::import::cvs::state
202 # Import not required, already a child namespace.
203 # namespace import ::vc::fossil::import::cvs::project::sym
204 }
205
--- tools/cvs2fossil/lib/c2f_psym.tcl
+++ tools/cvs2fossil/lib/c2f_psym.tcl
@@ -15,10 +15,11 @@
1515
# # ## ### ##### ######## ############# #####################
1616
## Requirements
1717
1818
package require Tcl 8.4 ; # Required runtime.
1919
package require snit ; # OO system.
20
+package require struct::set ; # Set handling.
2021
package require vc::fossil::import::cvs::state ; # State storage.
2122
2223
# # ## ### ##### ######## ############# #####################
2324
##
2425
@@ -35,22 +36,68 @@
3536
3637
method name {} { return $myname }
3738
method id {} { return $myid }
3839
3940
# # ## ### ##### ######## #############
41
+ ## Symbol statistics
42
+
43
+ method countasbranch {} { incr mybranchcount ; return }
44
+ method countastag {} { incr mytagcount ; return }
45
+ method countacommit {} { incr mycommitcount ; return }
46
+
47
+ method blockedby {symbol} {
48
+ # Remember the symbol as preventing the removal of this
49
+ # symbol. Ot is a tag or branch that spawned from a revision
50
+ # on this symbol.
51
+
52
+ struct::set include myblockers $symbol
53
+ return
54
+ }
55
+
56
+ method possibleparent {symbol} {
57
+ if {[info exists mypparent($symbol)]} {
58
+ incr mypparent($symbol)
59
+ } else {
60
+ set mypparent($symbol) 1
61
+ }
62
+ return
63
+ }
64
+
65
+ method isghost {} {
66
+ # Checks if this symbol (as line of development) never
67
+ # existed.
68
+
69
+ if {$mycommitcount > 0} { return 0 }
70
+ if {[llength $myblockers]} { return 0 }
71
+ if {[array size mypparent] > 0} { return 0 }
72
+
73
+ return 1
74
+ }
75
+
76
+ # # ## ### ##### ######## #############
4077
4178
method persistrev {} {
4279
set pid [$myproject id]
4380
44
- # TODO: Compute the various counts. All the necessary
45
- # TODO: information is already in the database. Actually it
46
- # TODO: never was in memory.
47
-
4881
state transaction {
4982
state run {
50
- INSERT INTO symbol ( sid, pid, name, type, tag_count, branch_count, commit_count)
51
- VALUES ($myid, $pid, $myname, $myundef, 0, 0, 0);
83
+ INSERT INTO symbol ( sid, pid, name, type, tag_count, branch_count, commit_count)
84
+ VALUES ($myid, $pid, $myname, $myundef, $mytagcount, $mybranchcount, $mycommitcount);
85
+ }
86
+ foreach symbol $myblockers {
87
+ set bid [$symbol id]
88
+ state run {
89
+ INSERT INTO blocker (sid, bid)
90
+ VALUES ($myid, $bid);
91
+ }
92
+ }
93
+ foreach {symbol count} [array get mypparent] {
94
+ set pid [$symbol id]
95
+ state run {
96
+ INSERT INTO parent (sid, pid, n)
97
+ VALUES ($myid, $pid, $count);
98
+ }
5299
}
53100
}
54101
return
55102
}
56103
@@ -61,10 +108,21 @@
61108
# containing the symbol.
62109
variable myname {} ; # The symbol's name
63110
variable myid {} ; # Repository wide numeric id of the
64111
# symbol. This implicitly encodes the
65112
# project as well.
113
+
114
+ variable mybranchcount 0 ; # Count how many uses as branch.
115
+ variable mytagcount 0 ; # Count how many uses as tag.
116
+ variable mycommitcount 0 ; # Count how many files did a commit on the symbol.
117
+
118
+ variable myblockers {} ; # List (Set) of the symbols which block
119
+ # the exclusion of this symbol.
120
+
121
+ variable mypparent -array {} ; # Maps from symbols to the number
122
+ # of files in which it could have
123
+ # been a parent of this symbol.
66124
67125
typevariable mytag 1 ; # Code for symbols which are tags.
68126
typevariable mybranch 2 ; # Code for symbols which are branches.
69127
typevariable myundef 3 ; # Code for symbols of unknown type.
70128
71129
--- tools/cvs2fossil/lib/c2f_psym.tcl
+++ tools/cvs2fossil/lib/c2f_psym.tcl
@@ -15,10 +15,11 @@
15 # # ## ### ##### ######## ############# #####################
16 ## Requirements
17
18 package require Tcl 8.4 ; # Required runtime.
19 package require snit ; # OO system.
 
20 package require vc::fossil::import::cvs::state ; # State storage.
21
22 # # ## ### ##### ######## ############# #####################
23 ##
24
@@ -35,22 +36,68 @@
35
36 method name {} { return $myname }
37 method id {} { return $myid }
38
39 # # ## ### ##### ######## #############
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
41 method persistrev {} {
42 set pid [$myproject id]
43
44 # TODO: Compute the various counts. All the necessary
45 # TODO: information is already in the database. Actually it
46 # TODO: never was in memory.
47
48 state transaction {
49 state run {
50 INSERT INTO symbol ( sid, pid, name, type, tag_count, branch_count, commit_count)
51 VALUES ($myid, $pid, $myname, $myundef, 0, 0, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52 }
53 }
54 return
55 }
56
@@ -61,10 +108,21 @@
61 # containing the symbol.
62 variable myname {} ; # The symbol's name
63 variable myid {} ; # Repository wide numeric id of the
64 # symbol. This implicitly encodes the
65 # project as well.
 
 
 
 
 
 
 
 
 
 
 
66
67 typevariable mytag 1 ; # Code for symbols which are tags.
68 typevariable mybranch 2 ; # Code for symbols which are branches.
69 typevariable myundef 3 ; # Code for symbols of unknown type.
70
71
--- tools/cvs2fossil/lib/c2f_psym.tcl
+++ tools/cvs2fossil/lib/c2f_psym.tcl
@@ -15,10 +15,11 @@
15 # # ## ### ##### ######## ############# #####################
16 ## Requirements
17
18 package require Tcl 8.4 ; # Required runtime.
19 package require snit ; # OO system.
20 package require struct::set ; # Set handling.
21 package require vc::fossil::import::cvs::state ; # State storage.
22
23 # # ## ### ##### ######## ############# #####################
24 ##
25
@@ -35,22 +36,68 @@
36
37 method name {} { return $myname }
38 method id {} { return $myid }
39
40 # # ## ### ##### ######## #############
41 ## Symbol statistics
42
43 method countasbranch {} { incr mybranchcount ; return }
44 method countastag {} { incr mytagcount ; return }
45 method countacommit {} { incr mycommitcount ; return }
46
47 method blockedby {symbol} {
48 # Remember the symbol as preventing the removal of this
49 # symbol. Ot is a tag or branch that spawned from a revision
50 # on this symbol.
51
52 struct::set include myblockers $symbol
53 return
54 }
55
56 method possibleparent {symbol} {
57 if {[info exists mypparent($symbol)]} {
58 incr mypparent($symbol)
59 } else {
60 set mypparent($symbol) 1
61 }
62 return
63 }
64
65 method isghost {} {
66 # Checks if this symbol (as line of development) never
67 # existed.
68
69 if {$mycommitcount > 0} { return 0 }
70 if {[llength $myblockers]} { return 0 }
71 if {[array size mypparent] > 0} { return 0 }
72
73 return 1
74 }
75
76 # # ## ### ##### ######## #############
77
78 method persistrev {} {
79 set pid [$myproject id]
80
 
 
 
 
81 state transaction {
82 state run {
83 INSERT INTO symbol ( sid, pid, name, type, tag_count, branch_count, commit_count)
84 VALUES ($myid, $pid, $myname, $myundef, $mytagcount, $mybranchcount, $mycommitcount);
85 }
86 foreach symbol $myblockers {
87 set bid [$symbol id]
88 state run {
89 INSERT INTO blocker (sid, bid)
90 VALUES ($myid, $bid);
91 }
92 }
93 foreach {symbol count} [array get mypparent] {
94 set pid [$symbol id]
95 state run {
96 INSERT INTO parent (sid, pid, n)
97 VALUES ($myid, $pid, $count);
98 }
99 }
100 }
101 return
102 }
103
@@ -61,10 +108,21 @@
108 # containing the symbol.
109 variable myname {} ; # The symbol's name
110 variable myid {} ; # Repository wide numeric id of the
111 # symbol. This implicitly encodes the
112 # project as well.
113
114 variable mybranchcount 0 ; # Count how many uses as branch.
115 variable mytagcount 0 ; # Count how many uses as tag.
116 variable mycommitcount 0 ; # Count how many files did a commit on the symbol.
117
118 variable myblockers {} ; # List (Set) of the symbols which block
119 # the exclusion of this symbol.
120
121 variable mypparent -array {} ; # Maps from symbols to the number
122 # of files in which it could have
123 # been a parent of this symbol.
124
125 typevariable mytag 1 ; # Code for symbols which are tags.
126 typevariable mybranch 2 ; # Code for symbols which are branches.
127 typevariable myundef 3 ; # Code for symbols of unknown type.
128
129
--- tools/cvs2fossil/lib/c2f_ptrunk.tcl
+++ tools/cvs2fossil/lib/c2f_ptrunk.tcl
@@ -24,23 +24,41 @@
2424
snit::type ::vc::fossil::import::cvs::project::trunk {
2525
# # ## ### ##### ######## #############
2626
## Public API
2727
2828
constructor {project} {
29
- set myid [[$project getsymbol $myname] id]
29
+ set mysymbol [$project getsymbol $myname]
30
+ set myid [$mysymbol id]
3031
return
3132
}
33
+
34
+ destructor {
35
+ $mysymbol destroy
36
+ }
3237
3338
method name {} { return $myname }
3439
method id {} { return $myid }
3540
method istrunk {} { return 1 }
41
+ method symbol {} { return $self }
42
+
43
+ method countasbranch {} {}
44
+ method countastag {} {}
45
+ method countacommit {} {}
46
+
47
+ method blockedby {symbol} {}
48
+ method possibleparent {symbol} {}
49
+
50
+ method isghost {} { return 0 }
51
+
52
+ delegate method persistrev to mysymbol
3653
3754
# # ## ### ##### ######## #############
3855
## State
3956
40
- typevariable myname :trunk: ; # Name shared by all trunk symbols.
41
- variable myid {} ; # The trunk's symbol id.
57
+ typevariable myname :trunk: ; # Name shared by all trunk symbols.
58
+ variable myid {} ; # The trunk's symbol id.
59
+ variable mysymbol {} ; # The symbol underneath the trunk.
4260
4361
# # ## ### ##### ######## #############
4462
## Internal methods
4563
4664
# # ## ### ##### ######## #############
@@ -47,11 +65,10 @@
4765
## Configuration
4866
4967
pragma -hastypeinfo no ; # no type introspection
5068
pragma -hasinfo no ; # no object introspection
5169
pragma -hastypemethods no ; # type is not relevant.
52
- pragma -simpledispatch yes ; # simple fast dispatch
5370
5471
# # ## ### ##### ######## #############
5572
}
5673
5774
namespace eval ::vc::fossil::import::cvs::project {
5875
--- tools/cvs2fossil/lib/c2f_ptrunk.tcl
+++ tools/cvs2fossil/lib/c2f_ptrunk.tcl
@@ -24,23 +24,41 @@
24 snit::type ::vc::fossil::import::cvs::project::trunk {
25 # # ## ### ##### ######## #############
26 ## Public API
27
28 constructor {project} {
29 set myid [[$project getsymbol $myname] id]
 
30 return
31 }
 
 
 
 
32
33 method name {} { return $myname }
34 method id {} { return $myid }
35 method istrunk {} { return 1 }
 
 
 
 
 
 
 
 
 
 
 
 
36
37 # # ## ### ##### ######## #############
38 ## State
39
40 typevariable myname :trunk: ; # Name shared by all trunk symbols.
41 variable myid {} ; # The trunk's symbol id.
 
42
43 # # ## ### ##### ######## #############
44 ## Internal methods
45
46 # # ## ### ##### ######## #############
@@ -47,11 +65,10 @@
47 ## Configuration
48
49 pragma -hastypeinfo no ; # no type introspection
50 pragma -hasinfo no ; # no object introspection
51 pragma -hastypemethods no ; # type is not relevant.
52 pragma -simpledispatch yes ; # simple fast dispatch
53
54 # # ## ### ##### ######## #############
55 }
56
57 namespace eval ::vc::fossil::import::cvs::project {
58
--- tools/cvs2fossil/lib/c2f_ptrunk.tcl
+++ tools/cvs2fossil/lib/c2f_ptrunk.tcl
@@ -24,23 +24,41 @@
24 snit::type ::vc::fossil::import::cvs::project::trunk {
25 # # ## ### ##### ######## #############
26 ## Public API
27
28 constructor {project} {
29 set mysymbol [$project getsymbol $myname]
30 set myid [$mysymbol id]
31 return
32 }
33
34 destructor {
35 $mysymbol destroy
36 }
37
38 method name {} { return $myname }
39 method id {} { return $myid }
40 method istrunk {} { return 1 }
41 method symbol {} { return $self }
42
43 method countasbranch {} {}
44 method countastag {} {}
45 method countacommit {} {}
46
47 method blockedby {symbol} {}
48 method possibleparent {symbol} {}
49
50 method isghost {} { return 0 }
51
52 delegate method persistrev to mysymbol
53
54 # # ## ### ##### ######## #############
55 ## State
56
57 typevariable myname :trunk: ; # Name shared by all trunk symbols.
58 variable myid {} ; # The trunk's symbol id.
59 variable mysymbol {} ; # The symbol underneath the trunk.
60
61 # # ## ### ##### ######## #############
62 ## Internal methods
63
64 # # ## ### ##### ######## #############
@@ -47,11 +65,10 @@
65 ## Configuration
66
67 pragma -hastypeinfo no ; # no type introspection
68 pragma -hasinfo no ; # no object introspection
69 pragma -hastypemethods no ; # type is not relevant.
 
70
71 # # ## ### ##### ######## #############
72 }
73
74 namespace eval ::vc::fossil::import::cvs::project {
75

Keyboard Shortcuts

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