Fossil SCM

Completed pass 5, computing the initial set of changesets. Defined persistent structure and filled out the long-existing placeholder class (project::rev).

aku 2007-11-10 07:46 trunk
Commit 5f7acef887eeb80a876ec5f25527d17793da0119
--- tools/cvs2fossil/lib/c2f_pinitcsets.tcl
+++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl
@@ -8,22 +8,25 @@
88
# This software consists of voluntary contributions made by many
99
# individuals. For exact contribution history, see the revision
1010
# history and logs, available at http://fossil-scm.hwaci.com/fossil
1111
# # ## ### ##### ######## ############# #####################
1212
13
-## Pass V. This pass defines the first approximate set of project
14
-## level revisions, aka changesets.
13
+## Pass V. This pass creates the initial set of project level
14
+## revisions, aka changesets. Later passes will refine them, puts them
15
+## into proper order, set their dependencies, etc.
1516
1617
# # ## ### ##### ######## ############# #####################
1718
## Requirements
1819
1920
package require Tcl 8.4 ; # Required runtime.
2021
package require snit ; # OO system.
2122
package require vc::tools::misc ; # Text formatting.
2223
package require vc::tools::log ; # User feedback.
24
+package require vc::fossil::import::cvs::repository ; # Repository management.
2325
package require vc::fossil::import::cvs::state ; # State storage.
2426
package require vc::fossil::import::cvs::project::sym ; # Project level symbols
27
+package require vc::fossil::import::cvs::project::rev ; # Project level changesets
2528
2629
# # ## ### ##### ######## ############# #####################
2730
## Register the pass with the management
2831
2932
vc::fossil::import::cvs::pass define \
@@ -39,36 +42,247 @@
3942
## Public API
4043
4144
typemethod setup {} {
4245
# Define the names and structure of the persistent state of
4346
# this pass.
47
+
48
+ state reading meta
49
+ state reading revision
50
+ state reading branch
51
+ state reading tag
52
+ state reading symbol
53
+
54
+ # Data per changeset, namely the project it belongs to, how it
55
+ # was induced (revision or symbol), plus reference to the
56
+ # primary entry causing it (meta entry or symbol). An adjunct
57
+ # table translates the type id's into human readable labels.
58
+
59
+ state writing changeset {
60
+ cid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
61
+ pid INTEGER NOT NULL REFERENCES project,
62
+ type INTEGER NOT NULL REFERENCES cstype,
63
+ src INTEGER NOT NULL -- REFERENCES meta|symbol (type dependent)
64
+ }
65
+ state writing cstype {
66
+ tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
67
+ name TEXT NOT NULL,
68
+ UNIQUE (name)
69
+ }
70
+ state run {
71
+ INSERT INTO cstype VALUES (0,'rev');
72
+ INSERT INTO cstype VALUES (1,'sym');
73
+ }
74
+
75
+ # Map from changesets to the (file level) revisions they
76
+ # contain. The pos'ition provides an order of the revisions
77
+ # within a changeset. They are unique within the changeset.
78
+ # The revisions are in principle unique, if we were looking
79
+ # only at revision changesets. However a revision can appear
80
+ # in both revision and symbol changesets, and in multiple
81
+ # symbol changesets as well. So we can only say that it is
82
+ # unique within the changeset.
83
+ #
84
+ # TODO: Check if integrity checks are possible.
85
+
86
+ state writing csrevision {
87
+ cid INTEGER NOT NULL REFERENCES changeset,
88
+ pos INTEGER NOT NULL,
89
+ rid INTEGER NOT NULL REFERENCES revision,
90
+ UNIQUE (cid, pos),
91
+ UNIQUE (cid, rid)
92
+ }
93
+
94
+ project::rev getcstypes
4495
return
4596
}
4697
4798
typemethod load {} {
4899
# Pass manager interface. Executed to load data computed by
49100
# this pass into memory when this pass is skipped instead of
50101
# executed.
51
- # /TODO/
102
+ # /TODO/load changesets
103
+
104
+ project::rev getcstypes
52105
return
53106
}
54107
55108
typemethod run {} {
56109
# Pass manager interface. Executed to perform the
57110
# functionality of the pass.
111
+
112
+ set csets {}
113
+ state transaction {
114
+ CreateRevisionChangesets csets ; # Group file revisions into csets.
115
+ CreateSymbolChangesets csets ; # Create csets for tags and branches.
116
+ PersistTheChangesets $csets
117
+ }
58118
return
59119
}
60120
61121
typemethod discard {} {
62122
# Pass manager interface. Executed for all passes after the
63123
# run passes, to remove all data of this pass from the state,
64124
# as being out of date.
125
+
126
+ state discard changeset
127
+ state discard cstype
128
+ state discard csrevision
65129
return
66130
}
67131
68132
# # ## ### ##### ######## #############
69133
## Internal methods
134
+
135
+ proc CreateRevisionChangesets {cv} {
136
+ upvar 1 $cv csets
137
+
138
+ log write 3 initcsets {Create changesets based on revisions}
139
+
140
+ # To get the initial of changesets we first group all file
141
+ # level revisions using the same meta data entry together. As
142
+ # the meta data encodes not only author and log message, but
143
+ # also line of development and project we can be sure that
144
+ # revisions in different project and lines of development are
145
+ # not grouped together. In contrast to cvs2svn we do __not__
146
+ # use distance in time between revisions to break them
147
+ # apart. We have seen CVS repositories (from SF) where a
148
+ # single commit contained revisions several hours apart,
149
+ # likely due to trouble on the server hosting the repository.
150
+
151
+ # We order the revisions here by time, this will help the
152
+ # later passes (avoids joins later to get at the ordering
153
+ # info).
154
+
155
+ set n 0
156
+
157
+ set lastmeta {}
158
+ set lastproject {}
159
+ set revisions {}
160
+
161
+ # Note: We could have written this loop to create the csets
162
+ # early, extending them with all their revisions. This
163
+ # however would mean lots of (slow) method invokations
164
+ # on the csets. Doing it like this, late creation, means
165
+ # less such calls. None, but the creation itself.
166
+
167
+ foreach {mid rid pid} [state run {
168
+ SELECT M.mid, R.rid, M.pid
169
+ FROM revision R, meta M -- R ==> M, using PK index of M.
170
+ WHERE R.mid = M.mid
171
+ ORDER BY M.mid, R.date
172
+ }] {
173
+ if {$lastmeta != $mid} {
174
+ if {[llength $revisions]} {
175
+ incr n
176
+ set p [repository projectof $lastproject]
177
+ lappend csets [project::rev %AUTO% $p rev $lastmeta $revisions]
178
+ set revisions {}
179
+ }
180
+ set lastmeta $mid
181
+ set lastproject $pid
182
+ }
183
+ lappend revisions $rid
184
+ }
185
+
186
+ if {[llength $revisions]} {
187
+ incr n
188
+ set p [repository projectof $lastproject]
189
+ lappend csets [project::rev %AUTO% $p rev $lastmeta $revisions]
190
+ }
191
+
192
+ log write 4 initcsets "Created [nsp $n {revision changeset}]"
193
+ return
194
+ }
195
+
196
+ proc CreateSymbolChangesets {cv} {
197
+ upvar 1 $cv csets
198
+
199
+ log write 3 initcsets {Create changesets based on symbols}
200
+
201
+ # Tags and branches induce changesets as well, containing the
202
+ # revisions they are attached to (tags), or spawned from
203
+ # (branches).
204
+
205
+ set n 0
206
+
207
+ # First process the tags, then the branches. We know that
208
+ # their ids do not overlap with each other.
209
+
210
+ set lastsymbol {}
211
+ set lastproject {}
212
+ set revisions {}
213
+
214
+ foreach {sid rid pid} [state run {
215
+ SELECT S.sid, R.rid, S.pid
216
+ FROM tag T, revision R, symbol S -- T ==> R/S, using PK indices of R, S.
217
+ WHERE T.rev = R.rid
218
+ AND T.sid = S.sid
219
+ ORDER BY S.sid, R.date
220
+ }] {
221
+ if {$lastsymbol != $sid} {
222
+ if {[llength $revisions]} {
223
+ incr n
224
+ set p [repository projectof $lastproject]
225
+ lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
226
+ set revisions {}
227
+ }
228
+ set lastsymbol $sid
229
+ set lastproject $pid
230
+ }
231
+ lappend revisions $rid
232
+ }
233
+
234
+ if {[llength $revisions]} {
235
+ incr n
236
+ set p [repository projectof $lastproject]
237
+ lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
238
+ }
239
+
240
+ set lastsymbol {}
241
+ set lasproject {}
242
+ set revisions {}
243
+
244
+ foreach {sid rid pid} [state run {
245
+ SELECT S.sid, R.rid, S.pid
246
+ FROM branch B, revision R, symbol S -- B ==> R/S, using PK indices of R, S.
247
+ WHERE B.root = R.rid
248
+ AND B.sid = S.sid
249
+ ORDER BY S.sid, R.date
250
+ }] {
251
+ if {$lastsymbol != $sid} {
252
+ if {[llength $revisions]} {
253
+ incr n
254
+ set p [repository projectof $lastproject]
255
+ lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
256
+ set revisions {}
257
+ }
258
+ set lastsymbol $sid
259
+ set lastproject $pid
260
+ }
261
+ lappend revisions $rid
262
+ }
263
+
264
+ if {[llength $revisions]} {
265
+ incr n
266
+ set p [repository projectof $lastproject]
267
+ lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
268
+ }
269
+
270
+ log write 4 initcsets "Created [nsp $n {symbol changeset}]"
271
+ return
272
+ }
273
+
274
+ proc PersistTheChangesets {csets} {
275
+ log write 3 initcsets {Saving the created changesets to the persistent state}
276
+
277
+ foreach cset $csets {
278
+ $cset persist
279
+ }
280
+
281
+ log write 4 initcsets {Ok.}
282
+ return
283
+ }
70284
71285
# # ## ### ##### ######## #############
72286
## Configuration
73287
74288
pragma -hasinstances no ; # singleton
@@ -79,11 +293,16 @@
79293
}
80294
81295
namespace eval ::vc::fossil::import::cvs::pass {
82296
namespace export initcsets
83297
namespace eval initcsets {
298
+ namespace import ::vc::fossil::import::cvs::repository
84299
namespace import ::vc::fossil::import::cvs::state
300
+ namespace eval project {
301
+ namespace import ::vc::fossil::import::cvs::project::rev
302
+ }
303
+ namespace import ::vc::tools::misc::*
85304
namespace import ::vc::tools::log
86305
log register initcsets
87306
}
88307
}
89308
90309
--- tools/cvs2fossil/lib/c2f_pinitcsets.tcl
+++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl
@@ -8,22 +8,25 @@
8 # This software consists of voluntary contributions made by many
9 # individuals. For exact contribution history, see the revision
10 # history and logs, available at http://fossil-scm.hwaci.com/fossil
11 # # ## ### ##### ######## ############# #####################
12
13 ## Pass V. This pass defines the first approximate set of project
14 ## level revisions, aka changesets.
 
15
16 # # ## ### ##### ######## ############# #####################
17 ## Requirements
18
19 package require Tcl 8.4 ; # Required runtime.
20 package require snit ; # OO system.
21 package require vc::tools::misc ; # Text formatting.
22 package require vc::tools::log ; # User feedback.
 
23 package require vc::fossil::import::cvs::state ; # State storage.
24 package require vc::fossil::import::cvs::project::sym ; # Project level symbols
 
25
26 # # ## ### ##### ######## ############# #####################
27 ## Register the pass with the management
28
29 vc::fossil::import::cvs::pass define \
@@ -39,36 +42,247 @@
39 ## Public API
40
41 typemethod setup {} {
42 # Define the names and structure of the persistent state of
43 # this pass.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44 return
45 }
46
47 typemethod load {} {
48 # Pass manager interface. Executed to load data computed by
49 # this pass into memory when this pass is skipped instead of
50 # executed.
51 # /TODO/
 
 
52 return
53 }
54
55 typemethod run {} {
56 # Pass manager interface. Executed to perform the
57 # functionality of the pass.
 
 
 
 
 
 
 
58 return
59 }
60
61 typemethod discard {} {
62 # Pass manager interface. Executed for all passes after the
63 # run passes, to remove all data of this pass from the state,
64 # as being out of date.
 
 
 
 
65 return
66 }
67
68 # # ## ### ##### ######## #############
69 ## Internal methods
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
71 # # ## ### ##### ######## #############
72 ## Configuration
73
74 pragma -hasinstances no ; # singleton
@@ -79,11 +293,16 @@
79 }
80
81 namespace eval ::vc::fossil::import::cvs::pass {
82 namespace export initcsets
83 namespace eval initcsets {
 
84 namespace import ::vc::fossil::import::cvs::state
 
 
 
 
85 namespace import ::vc::tools::log
86 log register initcsets
87 }
88 }
89
90
--- tools/cvs2fossil/lib/c2f_pinitcsets.tcl
+++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl
@@ -8,22 +8,25 @@
8 # This software consists of voluntary contributions made by many
9 # individuals. For exact contribution history, see the revision
10 # history and logs, available at http://fossil-scm.hwaci.com/fossil
11 # # ## ### ##### ######## ############# #####################
12
13 ## Pass V. This pass creates the initial set of project level
14 ## revisions, aka changesets. Later passes will refine them, puts them
15 ## into proper order, set their dependencies, etc.
16
17 # # ## ### ##### ######## ############# #####################
18 ## Requirements
19
20 package require Tcl 8.4 ; # Required runtime.
21 package require snit ; # OO system.
22 package require vc::tools::misc ; # Text formatting.
23 package require vc::tools::log ; # User feedback.
24 package require vc::fossil::import::cvs::repository ; # Repository management.
25 package require vc::fossil::import::cvs::state ; # State storage.
26 package require vc::fossil::import::cvs::project::sym ; # Project level symbols
27 package require vc::fossil::import::cvs::project::rev ; # Project level changesets
28
29 # # ## ### ##### ######## ############# #####################
30 ## Register the pass with the management
31
32 vc::fossil::import::cvs::pass define \
@@ -39,36 +42,247 @@
42 ## Public API
43
44 typemethod setup {} {
45 # Define the names and structure of the persistent state of
46 # this pass.
47
48 state reading meta
49 state reading revision
50 state reading branch
51 state reading tag
52 state reading symbol
53
54 # Data per changeset, namely the project it belongs to, how it
55 # was induced (revision or symbol), plus reference to the
56 # primary entry causing it (meta entry or symbol). An adjunct
57 # table translates the type id's into human readable labels.
58
59 state writing changeset {
60 cid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
61 pid INTEGER NOT NULL REFERENCES project,
62 type INTEGER NOT NULL REFERENCES cstype,
63 src INTEGER NOT NULL -- REFERENCES meta|symbol (type dependent)
64 }
65 state writing cstype {
66 tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
67 name TEXT NOT NULL,
68 UNIQUE (name)
69 }
70 state run {
71 INSERT INTO cstype VALUES (0,'rev');
72 INSERT INTO cstype VALUES (1,'sym');
73 }
74
75 # Map from changesets to the (file level) revisions they
76 # contain. The pos'ition provides an order of the revisions
77 # within a changeset. They are unique within the changeset.
78 # The revisions are in principle unique, if we were looking
79 # only at revision changesets. However a revision can appear
80 # in both revision and symbol changesets, and in multiple
81 # symbol changesets as well. So we can only say that it is
82 # unique within the changeset.
83 #
84 # TODO: Check if integrity checks are possible.
85
86 state writing csrevision {
87 cid INTEGER NOT NULL REFERENCES changeset,
88 pos INTEGER NOT NULL,
89 rid INTEGER NOT NULL REFERENCES revision,
90 UNIQUE (cid, pos),
91 UNIQUE (cid, rid)
92 }
93
94 project::rev getcstypes
95 return
96 }
97
98 typemethod load {} {
99 # Pass manager interface. Executed to load data computed by
100 # this pass into memory when this pass is skipped instead of
101 # executed.
102 # /TODO/load changesets
103
104 project::rev getcstypes
105 return
106 }
107
108 typemethod run {} {
109 # Pass manager interface. Executed to perform the
110 # functionality of the pass.
111
112 set csets {}
113 state transaction {
114 CreateRevisionChangesets csets ; # Group file revisions into csets.
115 CreateSymbolChangesets csets ; # Create csets for tags and branches.
116 PersistTheChangesets $csets
117 }
118 return
119 }
120
121 typemethod discard {} {
122 # Pass manager interface. Executed for all passes after the
123 # run passes, to remove all data of this pass from the state,
124 # as being out of date.
125
126 state discard changeset
127 state discard cstype
128 state discard csrevision
129 return
130 }
131
132 # # ## ### ##### ######## #############
133 ## Internal methods
134
135 proc CreateRevisionChangesets {cv} {
136 upvar 1 $cv csets
137
138 log write 3 initcsets {Create changesets based on revisions}
139
140 # To get the initial of changesets we first group all file
141 # level revisions using the same meta data entry together. As
142 # the meta data encodes not only author and log message, but
143 # also line of development and project we can be sure that
144 # revisions in different project and lines of development are
145 # not grouped together. In contrast to cvs2svn we do __not__
146 # use distance in time between revisions to break them
147 # apart. We have seen CVS repositories (from SF) where a
148 # single commit contained revisions several hours apart,
149 # likely due to trouble on the server hosting the repository.
150
151 # We order the revisions here by time, this will help the
152 # later passes (avoids joins later to get at the ordering
153 # info).
154
155 set n 0
156
157 set lastmeta {}
158 set lastproject {}
159 set revisions {}
160
161 # Note: We could have written this loop to create the csets
162 # early, extending them with all their revisions. This
163 # however would mean lots of (slow) method invokations
164 # on the csets. Doing it like this, late creation, means
165 # less such calls. None, but the creation itself.
166
167 foreach {mid rid pid} [state run {
168 SELECT M.mid, R.rid, M.pid
169 FROM revision R, meta M -- R ==> M, using PK index of M.
170 WHERE R.mid = M.mid
171 ORDER BY M.mid, R.date
172 }] {
173 if {$lastmeta != $mid} {
174 if {[llength $revisions]} {
175 incr n
176 set p [repository projectof $lastproject]
177 lappend csets [project::rev %AUTO% $p rev $lastmeta $revisions]
178 set revisions {}
179 }
180 set lastmeta $mid
181 set lastproject $pid
182 }
183 lappend revisions $rid
184 }
185
186 if {[llength $revisions]} {
187 incr n
188 set p [repository projectof $lastproject]
189 lappend csets [project::rev %AUTO% $p rev $lastmeta $revisions]
190 }
191
192 log write 4 initcsets "Created [nsp $n {revision changeset}]"
193 return
194 }
195
196 proc CreateSymbolChangesets {cv} {
197 upvar 1 $cv csets
198
199 log write 3 initcsets {Create changesets based on symbols}
200
201 # Tags and branches induce changesets as well, containing the
202 # revisions they are attached to (tags), or spawned from
203 # (branches).
204
205 set n 0
206
207 # First process the tags, then the branches. We know that
208 # their ids do not overlap with each other.
209
210 set lastsymbol {}
211 set lastproject {}
212 set revisions {}
213
214 foreach {sid rid pid} [state run {
215 SELECT S.sid, R.rid, S.pid
216 FROM tag T, revision R, symbol S -- T ==> R/S, using PK indices of R, S.
217 WHERE T.rev = R.rid
218 AND T.sid = S.sid
219 ORDER BY S.sid, R.date
220 }] {
221 if {$lastsymbol != $sid} {
222 if {[llength $revisions]} {
223 incr n
224 set p [repository projectof $lastproject]
225 lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
226 set revisions {}
227 }
228 set lastsymbol $sid
229 set lastproject $pid
230 }
231 lappend revisions $rid
232 }
233
234 if {[llength $revisions]} {
235 incr n
236 set p [repository projectof $lastproject]
237 lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
238 }
239
240 set lastsymbol {}
241 set lasproject {}
242 set revisions {}
243
244 foreach {sid rid pid} [state run {
245 SELECT S.sid, R.rid, S.pid
246 FROM branch B, revision R, symbol S -- B ==> R/S, using PK indices of R, S.
247 WHERE B.root = R.rid
248 AND B.sid = S.sid
249 ORDER BY S.sid, R.date
250 }] {
251 if {$lastsymbol != $sid} {
252 if {[llength $revisions]} {
253 incr n
254 set p [repository projectof $lastproject]
255 lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
256 set revisions {}
257 }
258 set lastsymbol $sid
259 set lastproject $pid
260 }
261 lappend revisions $rid
262 }
263
264 if {[llength $revisions]} {
265 incr n
266 set p [repository projectof $lastproject]
267 lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
268 }
269
270 log write 4 initcsets "Created [nsp $n {symbol changeset}]"
271 return
272 }
273
274 proc PersistTheChangesets {csets} {
275 log write 3 initcsets {Saving the created changesets to the persistent state}
276
277 foreach cset $csets {
278 $cset persist
279 }
280
281 log write 4 initcsets {Ok.}
282 return
283 }
284
285 # # ## ### ##### ######## #############
286 ## Configuration
287
288 pragma -hasinstances no ; # singleton
@@ -79,11 +293,16 @@
293 }
294
295 namespace eval ::vc::fossil::import::cvs::pass {
296 namespace export initcsets
297 namespace eval initcsets {
298 namespace import ::vc::fossil::import::cvs::repository
299 namespace import ::vc::fossil::import::cvs::state
300 namespace eval project {
301 namespace import ::vc::fossil::import::cvs::project::rev
302 }
303 namespace import ::vc::tools::misc::*
304 namespace import ::vc::tools::log
305 log register initcsets
306 }
307 }
308
309
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -8,48 +8,95 @@
88
# This software consists of voluntary contributions made by many
99
# individuals. For exact contribution history, see the revision
1010
# history and logs, available at http://fossil-scm.hwaci.com/fossil
1111
# # ## ### ##### ######## ############# #####################
1212
13
-## Revisions per project, aka Changesets.
13
+## Revisions per project, aka Changesets. These objects are first used
14
+## in pass 5, which creates the initial set covering the repository.
1415
1516
# # ## ### ##### ######## ############# #####################
1617
## Requirements
1718
18
-package require Tcl 8.4 ; # Required runtime.
19
-package require snit ; # OO system.
19
+package require Tcl 8.4 ; # Required runtime.
20
+package require snit ; # OO system.
21
+package require vc::fossil::import::cvs::state ; # State storage.
2022
2123
# # ## ### ##### ######## ############# #####################
2224
##
2325
2426
snit::type ::vc::fossil::import::cvs::project::rev {
2527
# # ## ### ##### ######## #############
2628
## Public API
2729
28
- constructor {} {
30
+ constructor {project cstype srcid revisions} {
31
+ set myid [incr mycounter]
32
+ set myproject $project
33
+ set mytype $cstype
34
+ set mysrcid $srcid
35
+ set myrevisions $revisions
36
+ return
37
+ }
38
+
39
+ method persist {} {
40
+ set tid $mycstype($mytype)
41
+ set pid [$myproject id]
42
+ set pos 0
43
+
44
+ state transaction {
45
+ state run {
46
+ INSERT INTO changeset (cid, pid, type, src)
47
+ VALUES ($myid, $pid, $tid, $mysrcid);
48
+ }
49
+
50
+ foreach rid $myrevisions {
51
+ state run {
52
+ INSERT INTO csrevision (cid, pos, rid)
53
+ VALUES ($myid, $pos, $rid);
54
+ }
55
+ incr pos
56
+ }
57
+ }
2958
return
3059
}
3160
3261
# # ## ### ##### ######## #############
3362
## State
3463
64
+ variable myid ; # Id of the cset for the persistent state.
65
+ variable myproject ; # Reference of the project object the changeset belongs to.
66
+ variable mytype ; # rev or sym, where the cset originated from.
67
+ variable mysrcid ; # id of the metadata or symbol the cset is based on.
68
+ variable myrevisions ; # List of the file level revisions in the cset.
69
+
3570
# # ## ### ##### ######## #############
3671
## Internal methods
72
+
73
+ typevariable mycounter 0 ; # Id counter for csets.
74
+ typevariable mycstype -array {} ; # Map cstypes to persistent ids.
75
+
76
+ typemethod getcstypes {} {
77
+ foreach {tid name} [state run {
78
+ SELECT tid, name FROM cstype;
79
+ }] { set mycstype($name) $tid }
80
+ return
81
+ }
3782
3883
# # ## ### ##### ######## #############
3984
## Configuration
4085
4186
pragma -hastypeinfo no ; # no type introspection
4287
pragma -hasinfo no ; # no object introspection
43
- pragma -hastypemethods no ; # type is not relevant.
4488
pragma -simpledispatch yes ; # simple fast dispatch
4589
4690
# # ## ### ##### ######## #############
4791
}
4892
4993
namespace eval ::vc::fossil::import::cvs::project {
5094
namespace export rev
95
+ namespace eval rev {
96
+ namespace import ::vc::fossil::import::cvs::state
97
+ }
5198
}
5299
53100
# # ## ### ##### ######## ############# #####################
54101
## Ready
55102
56103
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -8,48 +8,95 @@
8 # This software consists of voluntary contributions made by many
9 # individuals. For exact contribution history, see the revision
10 # history and logs, available at http://fossil-scm.hwaci.com/fossil
11 # # ## ### ##### ######## ############# #####################
12
13 ## Revisions per project, aka Changesets.
 
14
15 # # ## ### ##### ######## ############# #####################
16 ## Requirements
17
18 package require Tcl 8.4 ; # Required runtime.
19 package require snit ; # OO system.
 
20
21 # # ## ### ##### ######## ############# #####################
22 ##
23
24 snit::type ::vc::fossil::import::cvs::project::rev {
25 # # ## ### ##### ######## #############
26 ## Public API
27
28 constructor {} {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29 return
30 }
31
32 # # ## ### ##### ######## #############
33 ## State
34
 
 
 
 
 
 
35 # # ## ### ##### ######## #############
36 ## Internal methods
 
 
 
 
 
 
 
 
 
 
37
38 # # ## ### ##### ######## #############
39 ## Configuration
40
41 pragma -hastypeinfo no ; # no type introspection
42 pragma -hasinfo no ; # no object introspection
43 pragma -hastypemethods no ; # type is not relevant.
44 pragma -simpledispatch yes ; # simple fast dispatch
45
46 # # ## ### ##### ######## #############
47 }
48
49 namespace eval ::vc::fossil::import::cvs::project {
50 namespace export rev
 
 
 
51 }
52
53 # # ## ### ##### ######## ############# #####################
54 ## Ready
55
56
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -8,48 +8,95 @@
8 # This software consists of voluntary contributions made by many
9 # individuals. For exact contribution history, see the revision
10 # history and logs, available at http://fossil-scm.hwaci.com/fossil
11 # # ## ### ##### ######## ############# #####################
12
13 ## Revisions per project, aka Changesets. These objects are first used
14 ## in pass 5, which creates the initial set covering the repository.
15
16 # # ## ### ##### ######## ############# #####################
17 ## Requirements
18
19 package require Tcl 8.4 ; # Required runtime.
20 package require snit ; # OO system.
21 package require vc::fossil::import::cvs::state ; # State storage.
22
23 # # ## ### ##### ######## ############# #####################
24 ##
25
26 snit::type ::vc::fossil::import::cvs::project::rev {
27 # # ## ### ##### ######## #############
28 ## Public API
29
30 constructor {project cstype srcid revisions} {
31 set myid [incr mycounter]
32 set myproject $project
33 set mytype $cstype
34 set mysrcid $srcid
35 set myrevisions $revisions
36 return
37 }
38
39 method persist {} {
40 set tid $mycstype($mytype)
41 set pid [$myproject id]
42 set pos 0
43
44 state transaction {
45 state run {
46 INSERT INTO changeset (cid, pid, type, src)
47 VALUES ($myid, $pid, $tid, $mysrcid);
48 }
49
50 foreach rid $myrevisions {
51 state run {
52 INSERT INTO csrevision (cid, pos, rid)
53 VALUES ($myid, $pos, $rid);
54 }
55 incr pos
56 }
57 }
58 return
59 }
60
61 # # ## ### ##### ######## #############
62 ## State
63
64 variable myid ; # Id of the cset for the persistent state.
65 variable myproject ; # Reference of the project object the changeset belongs to.
66 variable mytype ; # rev or sym, where the cset originated from.
67 variable mysrcid ; # id of the metadata or symbol the cset is based on.
68 variable myrevisions ; # List of the file level revisions in the cset.
69
70 # # ## ### ##### ######## #############
71 ## Internal methods
72
73 typevariable mycounter 0 ; # Id counter for csets.
74 typevariable mycstype -array {} ; # Map cstypes to persistent ids.
75
76 typemethod getcstypes {} {
77 foreach {tid name} [state run {
78 SELECT tid, name FROM cstype;
79 }] { set mycstype($name) $tid }
80 return
81 }
82
83 # # ## ### ##### ######## #############
84 ## Configuration
85
86 pragma -hastypeinfo no ; # no type introspection
87 pragma -hasinfo no ; # no object introspection
 
88 pragma -simpledispatch yes ; # simple fast dispatch
89
90 # # ## ### ##### ######## #############
91 }
92
93 namespace eval ::vc::fossil::import::cvs::project {
94 namespace export rev
95 namespace eval rev {
96 namespace import ::vc::fossil::import::cvs::state
97 }
98 }
99
100 # # ## ### ##### ######## ############# #####################
101 ## Ready
102
103
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -217,10 +217,14 @@
217217
foreach project [TheProjects] {
218218
$project determinesymboltypes
219219
}
220220
return
221221
}
222
+
223
+ typemethod projectof {pid} {
224
+ return $myprojmap($pid)
225
+ }
222226
223227
# # ## ### ##### ######## #############
224228
## State
225229
226230
typevariable mybase {} ; # Base path to CVS repository.
227231
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -217,10 +217,14 @@
217 foreach project [TheProjects] {
218 $project determinesymboltypes
219 }
220 return
221 }
 
 
 
 
222
223 # # ## ### ##### ######## #############
224 ## State
225
226 typevariable mybase {} ; # Base path to CVS repository.
227
--- tools/cvs2fossil/lib/c2f_repository.tcl
+++ tools/cvs2fossil/lib/c2f_repository.tcl
@@ -217,10 +217,14 @@
217 foreach project [TheProjects] {
218 $project determinesymboltypes
219 }
220 return
221 }
222
223 typemethod projectof {pid} {
224 return $myprojmap($pid)
225 }
226
227 # # ## ### ##### ######## #############
228 ## State
229
230 typevariable mybase {} ; # Base path to CVS repository.
231

Keyboard Shortcuts

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