Fossil SCM

Pass 4 nearly completed. Rewrite symbol mutation, completed adjustment of symbol parents, added symbol refinement (noop or not flags). Now only missing piece is replication of the pass 2 paranoia checks. Note: Checks in the adjustment of parents are a bottleneck. May need indices, or something we can do in memory.

aku 2007-11-07 06:22 trunk
Commit 37734390caae38e38b6b9f4df3e4fbb3befba82a
--- tools/cvs2fossil/lib/c2f_pfiltersym.tcl
+++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl
@@ -17,10 +17,11 @@
1717
# # ## ### ##### ######## ############# #####################
1818
## Requirements
1919
2020
package require Tcl 8.4 ; # Required runtime.
2121
package require snit ; # OO system.
22
+package require vc::tools::misc ; # Text formatting.
2223
package require vc::tools::log ; # User feedback.
2324
package require vc::fossil::import::cvs::state ; # State storage.
2425
package require vc::fossil::import::cvs::project::sym ; # Project level symbols
2526
2627
# # ## ### ##### ######## ############# #####################
@@ -47,10 +48,15 @@
4748
state reading parent
4849
state reading preferedparent
4950
state reading revision
5051
state reading branch
5152
state reading tag
53
+
54
+ state writing noop {
55
+ id INTEGER NOT NULL PRIMARY KEY, -- tag/branch reference
56
+ noop INTEGER NOT NULL
57
+ }
5258
return
5359
}
5460
5561
typemethod load {} {
5662
# Pass manager interface. Executed to load data computed by
@@ -69,14 +75,13 @@
6975
# The removal of excluded symbols and everything referencing
7076
# to them is done completely in the database.
7177
7278
state transaction {
7379
FilterExcludedSymbols
74
- MutateTagsToBranch
75
- MutateBranchesToTag
76
- AdjustTagParents
77
- AdjustBranchParents
80
+ MutateSymbols
81
+ AdjustParents
82
+ RefineSymbols
7883
7984
# Consider a rerun of the pass 2 paranoia checks.
8085
}
8186
8287
log write 1 filtersym "Filtering completed"
@@ -187,55 +192,69 @@
187192
DROP TABLE excludedsymbols;
188193
}
189194
return
190195
}
191196
192
- proc MutateTagsToBranch {} {
193
- log write 3 filtersym "Mutate tags to branches"
194
-
197
+ proc MutateSymbols {} {
195198
# Next, now that we know which symbols are what we look for
196199
# file level tags which are actually converted as branches
197
- # (project level), and put them into the correct table.
200
+ # (project level, and vice versa), and move them to the
201
+ # correct tables.
202
+
203
+ # # ## ### ##### ######## #############
204
+
205
+ log write 3 filtersym "Mutate symbols, preparation"
198206
199207
set branch [project::sym branch]
208
+ set tag [project::sym tag]
200209
201
- foreach {id fid lod sid rev} [state run {
210
+ set tagstomutate [state run {
202211
SELECT T.tid, T.fid, T.lod, T.sid, T.rev
203212
FROM tag T, symbol S
204213
WHERE T.sid = S.sid
205214
AND S.type = $branch
206
- }] {
207
- state run {
208
- DELETE FROM tag WHERE tid = $id ;
209
- INSERT INTO branch (bid, fid, lod, sid, root, first, bra)
210
- VALUES ($id, $fid, $lod, $sid, $rev, NULL, '');
211
- }
212
- }
213
- return
214
- }
215
-
216
- proc MutateBranchesToTag {} {
217
- log write 3 filtersym "Mutate branches to tags"
218
-
219
- # Next, now that we know which symbols are what we look for
220
- # file level branches which are actually converted as tags
221
- # (project level), and put them into the correct table.
222
-
223
- set tag [project::sym tag]
224
-
225
- foreach {id fid lod sid root first bra} [state run {
215
+ }]
216
+
217
+ set branchestomutate [state run {
226218
SELECT B.bid, B.fid, B.lod, B.sid, B.root, B.first, B.bra
227219
FROM branch B, symbol S
228220
WHERE B.sid = S.sid
229221
AND S.type = $tag
230
- }] {
222
+ }]
223
+
224
+ log write 4 filtersym "Changing [nsp [expr {[llength $tagstomutate]/5}] tag] into branches"
225
+ log write 4 filtersym "Changing [nsp [expr {[llength $branchestomutate]/7}] branch branches] into tags"
226
+
227
+ # # ## ### ##### ######## #############
228
+
229
+ log write 3 filtersym "Mutate tags to branches"
230
+
231
+ foreach {id fid lod sid rev} $tagstomutate {
232
+ state run {
233
+ DELETE FROM tag WHERE tid = $id ;
234
+ INSERT INTO branch (bid, fid, lod, sid, root, first, bra, pos)
235
+ VALUES ($id, $fid, $lod, $sid, $rev, NULL, '', -1);
236
+ }
237
+ }
238
+
239
+ log write 3 filtersym "Ok."
240
+
241
+ # # ## ### ##### ######## #############
242
+
243
+ log write 3 filtersym "Mutate branches to tags"
244
+
245
+ foreach {id fid lod sid root first bra} $branchestomutate {
231246
state run {
232247
DELETE FROM branch WHERE bid = $id ;
233248
INSERT INTO tag (tid, fid, lod, sid, rev)
234249
VALUES ($id, $fid, $lod, $sid, $root);
235250
}
236251
}
252
+
253
+ log write 3 filtersym "Ok."
254
+
255
+ # # ## ### ##### ######## #############
237256
return
238257
}
239258
240259
# Adjust the parents of symbols to their preferred parents.
241260
@@ -242,56 +261,210 @@
242261
# If a file level ymbol has a preferred parent that is different
243262
# than its current parent, and if the preferred parent is an
244263
# allowed parent of the symbol in this file, then we graft the
245264
# aSymbol onto its preferred parent.
246265
247
- proc AdjustTagParents {} {
248
- log write 3 filtersym "Adjust tag parents"
249
-
250
- # Find the tags whose current parent (lod) is not the prefered
251
- # parent, the prefered parent is not the trunk, and the
252
- # prefered parent is a possible parent per the tag's file ().
253
-
254
- foreach {id fid lod pid preferedname revnr} [state run {
255
- SELECT T.tid, T.fid, T.lod, P.pid, S.name, R.rev
266
+ proc AdjustParents {} {
267
+ log write 3 filtersym "Adjust parents, loading data in preparation"
268
+
269
+ # We pull important maps once into memory so that we do quick
270
+ # hash lookup later when processing the graft candidates.
271
+
272
+ # Tag/Branch names ...
273
+ array set sn [state run { SELECT T.tid, S.name FROM tag T, symbol S WHERE T.sid = S.sid }]
274
+ array set sn [state run { SELECT B.bid, S.name FROM branch B, symbol S WHERE B.sid = S.sid }]
275
+ # Symbol names ...
276
+ array set sx [state run { SELECT L.sid, L.name FROM symbol L }]
277
+ # Files and projects.
278
+ array set fpn {}
279
+ foreach {id fn pn} [state run {
280
+ SELECT F.fid, F.name, P.name
281
+ FROM file F, project P
282
+ WHERE F.pid = P.pid
283
+ }] { set fpn($id) [list $fn $pn] }
284
+
285
+ set tagstoadjust [state run {
286
+ SELECT T.tid, T.fid, T.lod, P.pid, S.name, R.rev, R.rid
256287
FROM tag T, preferedparent P, symbol S, revision R
257288
WHERE T.sid = P.sid
258289
AND T.lod != P.pid
259290
AND P.pid = S.sid
260291
AND S.name != ':trunk:'
261292
AND T.rev = R.rid
262
- AND P.pid IN (SELECT B.sid FROM branch B WHERE B.root = R.rid)
263
- }] {
293
+ }]
294
+
295
+ set branchestoadjust [state run {
296
+ SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
297
+ FROM branch B, preferedparent P, symbol S, revision R
298
+ WHERE B.sid = P.sid
299
+ AND B.lod != P.pid
300
+ AND P.pid = S.sid
301
+ AND S.name != ':trunk:'
302
+ AND B.root = R.rid
303
+ }]
304
+
305
+ set tmax [expr {[llength $tagstoadjust] / 7}]
306
+ set bmax [expr {[llength $branchestoadjust] / 8}]
307
+
308
+ log write 4 filtersym "Reparenting at most [nsp $tmax tag]"
309
+ log write 4 filtersym "Reparenting at most [nsp $bmax branch branches]"
310
+
311
+ log write 3 filtersym "Adjust tag parents"
312
+
313
+ # Find the tags whose current parent (lod) is not the prefered
314
+ # parent, the prefered parent is not the trunk, and the
315
+ # prefered parent is a possible parent per the tag's revision.
316
+
317
+ set fmt %[string length $tmax]s
318
+ set mxs [format $fmt $tmax]
319
+
320
+ set n 0
321
+ foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {
322
+
323
+ # BOTTLE-NECK ...
324
+ #
325
+ # The check if the candidate (pid) is truly viable is
326
+ # based finding the branch as possible parent, and done
327
+ # now instead of as part of the already complex join.
328
+ #
329
+ # ... AND P.pid IN (SELECT B.sid
330
+ # FROM branch B
331
+ # WHERE B.root = R.rid)
332
+
333
+ if {![lindex [state run {
334
+ SELECT COUNT(*)
335
+ FROM branch B
336
+ WHERE B.sid = $pid
337
+ AND B.root = $rid
338
+ }] 0]} {
339
+ incr tmax -1
340
+ set mxs [format $fmt $tmax]
341
+ continue
342
+ }
343
+
344
+ #
345
+ # BOTTLE-NECK ...
346
+
347
+ # The names for use in the log output are retrieved
348
+ # separately, to keep the join selecting the adjustable
349
+ # tags small, not burdened with the dereferencing of links
350
+ # to name.
351
+
352
+ set tagname $sn($id)
353
+ set oldname $sx($lod)
354
+ struct::list assign $fpn($fid) fname prname
355
+
356
+ # Do the grafting.
357
+
358
+ log write 4 filtersym "\[[format $fmt $n]/$mxs\] $prname : Grafting tag '$tagname' on $fname/$revnr from '$oldname' onto '$preferedname'"
359
+ state run { UPDATE tag SET lod = $pid WHERE tid = $id ; }
360
+ incr n
361
+ }
362
+
363
+ log write 3 filtersym "Reparented [nsp $n tag]"
364
+
365
+ log write 3 filtersym "Adjust branch parents"
366
+
367
+ # Find the branches whose current parent (lod) is not the
368
+ # prefered parent, the prefered parent is not the trunk, and
369
+ # the prefered parent is a possible parent per the branch's
370
+ # revision.
371
+
372
+ set fmt %[string length $bmax]s
373
+ set mxs [format $fmt $bmax]
374
+
375
+ set n 0
376
+ foreach {id fid lod pos pid preferedname revnr rid} $branchestoadjust {
377
+
378
+ # BOTTLE-NECK ...
379
+ #
380
+ # The check if the candidate (pid) is truly viable is
381
+ # based on the branch positions in the spawning revision,
382
+ # and done now instead of as part of the already complex
383
+ # join.
384
+ #
385
+ # ... AND P.pid IN (SELECT BX.sid
386
+ # FROM branch BX
387
+ # WHERE BX.root = R.rid
388
+ # AND BX.pos > B.pos)
389
+
390
+ if {![lindex [state run {
391
+ SELECT COUNT(*)
392
+ FROM branch B
393
+ WHERE B.sid = $pid
394
+ AND B.root = $rid
395
+ AND B.pos > $pos
396
+ }] 0]} {
397
+ incr bmax -1
398
+ set mxs [format $fmt $bmax]
399
+ continue
400
+ }
401
+
402
+ #
403
+ # BOTTLE-NECK ...
404
+
264405
# The names for use in the log output are retrieved
265406
# separately, to keep the join selecting the adjustable
266407
# tags small, not burdened with the dereferencing of links
267408
# to name.
268409
269
- set tagname [lindex [state run {
270
- SELECT S.name FROM tag T, symbol S WHERE T.sid = S.sid AND T.tid = $id
271
- }] 0]
272
- set oldname [lindex [state run {
273
- SELECT L.name FROM symbol L WHERE L.sid = $lod
274
- }] 0]
275
- struct::list assign [state run {
276
- SELECT F.name, P.name
277
- FROM file F, project P
278
- WHERE F.fid = $fid AND F.pid = P.pid
279
- }] fname prname
410
+ set braname $sn($id)
411
+ set oldname $sx($lod)
412
+ struct::list assign $fpn($fid) fname prname
280413
281414
# Do the grafting.
282415
283
- log write 3 filtersym "$prname : Grafting tag '$tagname' on $fname/$revnr from '$oldname' onto '$preferedname'"
284
- state run {
285
- UPDATE tag SET lod = $pid WHERE tid = $id ;
286
- }
416
+ log write 4 filtersym "\[[format $fmt $n]/$mxs\] $prname : Grafting branch '$braname' on $fname/$revnr from '$oldname' onto '$preferedname'"
417
+ state run { UPDATE tag SET lod = $pid WHERE tid = $id ; }
418
+ incr n
287419
}
420
+
421
+ log write 3 filtersym "Reparented [nsp $n branch branches]"
288422
return
289423
}
290424
291
- proc AdjustBranchParents {} {
292
- log write 3 filtersym "Adjust branch parents"
425
+ proc RefineSymbols {} {
426
+ # Tags and branches are marked as normal/noop based on the op
427
+ # of their revision.
428
+
429
+ log write 3 filtersym "Refine symbols (no-op or not?)"
430
+
431
+ log write 4 filtersym " Regular tags"
432
+ state run {
433
+ INSERT INTO noop
434
+ SELECT T.tid, 0
435
+ FROM tag T, revision R
436
+ WHERE T.rev = R.rid
437
+ AND R.op != 0 -- 0 == nothing
438
+ }
439
+
440
+ log write 4 filtersym " No-op tags"
441
+ state run {
442
+ INSERT INTO noop
443
+ SELECT T.tid, 1
444
+ FROM tag T, revision R
445
+ WHERE T.rev = R.rid
446
+ AND R.op = 0 -- nothing
447
+ }
448
+
449
+ log write 4 filtersym " Regular branches"
450
+ state run {
451
+ INSERT INTO noop
452
+ SELECT B.bid, 0
453
+ FROM branch B, revision R
454
+ WHERE B.root = R.rid
455
+ AND R.op != 0 -- nothing
456
+ }
457
+
458
+ log write 4 filtersym " No-op branches"
459
+ state run {
460
+ INSERT INTO noop
461
+ SELECT B.bid, 1
462
+ FROM branch B, revision R
463
+ WHERE B.root = R.rid
464
+ AND R.op = 0 -- nothing
465
+ }
293466
return
294467
}
295468
296469
# # ## ### ##### ######## #############
297470
## Configuration
@@ -308,10 +481,11 @@
308481
namespace eval filtersym {
309482
namespace import ::vc::fossil::import::cvs::state
310483
namespace eval project {
311484
namespace import ::vc::fossil::import::cvs::project::sym
312485
}
486
+ namespace import ::vc::tools::misc::nsp
313487
namespace import ::vc::tools::log
314488
log register filtersym
315489
}
316490
}
317491
318492
--- tools/cvs2fossil/lib/c2f_pfiltersym.tcl
+++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl
@@ -17,10 +17,11 @@
17 # # ## ### ##### ######## ############# #####################
18 ## Requirements
19
20 package require Tcl 8.4 ; # Required runtime.
21 package require snit ; # OO system.
 
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 # # ## ### ##### ######## ############# #####################
@@ -47,10 +48,15 @@
47 state reading parent
48 state reading preferedparent
49 state reading revision
50 state reading branch
51 state reading tag
 
 
 
 
 
52 return
53 }
54
55 typemethod load {} {
56 # Pass manager interface. Executed to load data computed by
@@ -69,14 +75,13 @@
69 # The removal of excluded symbols and everything referencing
70 # to them is done completely in the database.
71
72 state transaction {
73 FilterExcludedSymbols
74 MutateTagsToBranch
75 MutateBranchesToTag
76 AdjustTagParents
77 AdjustBranchParents
78
79 # Consider a rerun of the pass 2 paranoia checks.
80 }
81
82 log write 1 filtersym "Filtering completed"
@@ -187,55 +192,69 @@
187 DROP TABLE excludedsymbols;
188 }
189 return
190 }
191
192 proc MutateTagsToBranch {} {
193 log write 3 filtersym "Mutate tags to branches"
194
195 # Next, now that we know which symbols are what we look for
196 # file level tags which are actually converted as branches
197 # (project level), and put them into the correct table.
 
 
 
 
 
198
199 set branch [project::sym branch]
 
200
201 foreach {id fid lod sid rev} [state run {
202 SELECT T.tid, T.fid, T.lod, T.sid, T.rev
203 FROM tag T, symbol S
204 WHERE T.sid = S.sid
205 AND S.type = $branch
206 }] {
207 state run {
208 DELETE FROM tag WHERE tid = $id ;
209 INSERT INTO branch (bid, fid, lod, sid, root, first, bra)
210 VALUES ($id, $fid, $lod, $sid, $rev, NULL, '');
211 }
212 }
213 return
214 }
215
216 proc MutateBranchesToTag {} {
217 log write 3 filtersym "Mutate branches to tags"
218
219 # Next, now that we know which symbols are what we look for
220 # file level branches which are actually converted as tags
221 # (project level), and put them into the correct table.
222
223 set tag [project::sym tag]
224
225 foreach {id fid lod sid root first bra} [state run {
226 SELECT B.bid, B.fid, B.lod, B.sid, B.root, B.first, B.bra
227 FROM branch B, symbol S
228 WHERE B.sid = S.sid
229 AND S.type = $tag
230 }] {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231 state run {
232 DELETE FROM branch WHERE bid = $id ;
233 INSERT INTO tag (tid, fid, lod, sid, rev)
234 VALUES ($id, $fid, $lod, $sid, $root);
235 }
236 }
 
 
 
 
237 return
238 }
239
240 # Adjust the parents of symbols to their preferred parents.
241
@@ -242,56 +261,210 @@
242 # If a file level ymbol has a preferred parent that is different
243 # than its current parent, and if the preferred parent is an
244 # allowed parent of the symbol in this file, then we graft the
245 # aSymbol onto its preferred parent.
246
247 proc AdjustTagParents {} {
248 log write 3 filtersym "Adjust tag parents"
249
250 # Find the tags whose current parent (lod) is not the prefered
251 # parent, the prefered parent is not the trunk, and the
252 # prefered parent is a possible parent per the tag's file ().
253
254 foreach {id fid lod pid preferedname revnr} [state run {
255 SELECT T.tid, T.fid, T.lod, P.pid, S.name, R.rev
 
 
 
 
 
 
 
 
 
 
 
 
256 FROM tag T, preferedparent P, symbol S, revision R
257 WHERE T.sid = P.sid
258 AND T.lod != P.pid
259 AND P.pid = S.sid
260 AND S.name != ':trunk:'
261 AND T.rev = R.rid
262 AND P.pid IN (SELECT B.sid FROM branch B WHERE B.root = R.rid)
263 }] {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264 # The names for use in the log output are retrieved
265 # separately, to keep the join selecting the adjustable
266 # tags small, not burdened with the dereferencing of links
267 # to name.
268
269 set tagname [lindex [state run {
270 SELECT S.name FROM tag T, symbol S WHERE T.sid = S.sid AND T.tid = $id
271 }] 0]
272 set oldname [lindex [state run {
273 SELECT L.name FROM symbol L WHERE L.sid = $lod
274 }] 0]
275 struct::list assign [state run {
276 SELECT F.name, P.name
277 FROM file F, project P
278 WHERE F.fid = $fid AND F.pid = P.pid
279 }] fname prname
280
281 # Do the grafting.
282
283 log write 3 filtersym "$prname : Grafting tag '$tagname' on $fname/$revnr from '$oldname' onto '$preferedname'"
284 state run {
285 UPDATE tag SET lod = $pid WHERE tid = $id ;
286 }
287 }
 
 
288 return
289 }
290
291 proc AdjustBranchParents {} {
292 log write 3 filtersym "Adjust branch parents"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293 return
294 }
295
296 # # ## ### ##### ######## #############
297 ## Configuration
@@ -308,10 +481,11 @@
308 namespace eval filtersym {
309 namespace import ::vc::fossil::import::cvs::state
310 namespace eval project {
311 namespace import ::vc::fossil::import::cvs::project::sym
312 }
 
313 namespace import ::vc::tools::log
314 log register filtersym
315 }
316 }
317
318
--- tools/cvs2fossil/lib/c2f_pfiltersym.tcl
+++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl
@@ -17,10 +17,11 @@
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::state ; # State storage.
25 package require vc::fossil::import::cvs::project::sym ; # Project level symbols
26
27 # # ## ### ##### ######## ############# #####################
@@ -47,10 +48,15 @@
48 state reading parent
49 state reading preferedparent
50 state reading revision
51 state reading branch
52 state reading tag
53
54 state writing noop {
55 id INTEGER NOT NULL PRIMARY KEY, -- tag/branch reference
56 noop INTEGER NOT NULL
57 }
58 return
59 }
60
61 typemethod load {} {
62 # Pass manager interface. Executed to load data computed by
@@ -69,14 +75,13 @@
75 # The removal of excluded symbols and everything referencing
76 # to them is done completely in the database.
77
78 state transaction {
79 FilterExcludedSymbols
80 MutateSymbols
81 AdjustParents
82 RefineSymbols
 
83
84 # Consider a rerun of the pass 2 paranoia checks.
85 }
86
87 log write 1 filtersym "Filtering completed"
@@ -187,55 +192,69 @@
192 DROP TABLE excludedsymbols;
193 }
194 return
195 }
196
197 proc MutateSymbols {} {
 
 
198 # Next, now that we know which symbols are what we look for
199 # file level tags which are actually converted as branches
200 # (project level, and vice versa), and move them to the
201 # correct tables.
202
203 # # ## ### ##### ######## #############
204
205 log write 3 filtersym "Mutate symbols, preparation"
206
207 set branch [project::sym branch]
208 set tag [project::sym tag]
209
210 set tagstomutate [state run {
211 SELECT T.tid, T.fid, T.lod, T.sid, T.rev
212 FROM tag T, symbol S
213 WHERE T.sid = S.sid
214 AND S.type = $branch
215 }]
216
217 set branchestomutate [state run {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218 SELECT B.bid, B.fid, B.lod, B.sid, B.root, B.first, B.bra
219 FROM branch B, symbol S
220 WHERE B.sid = S.sid
221 AND S.type = $tag
222 }]
223
224 log write 4 filtersym "Changing [nsp [expr {[llength $tagstomutate]/5}] tag] into branches"
225 log write 4 filtersym "Changing [nsp [expr {[llength $branchestomutate]/7}] branch branches] into tags"
226
227 # # ## ### ##### ######## #############
228
229 log write 3 filtersym "Mutate tags to branches"
230
231 foreach {id fid lod sid rev} $tagstomutate {
232 state run {
233 DELETE FROM tag WHERE tid = $id ;
234 INSERT INTO branch (bid, fid, lod, sid, root, first, bra, pos)
235 VALUES ($id, $fid, $lod, $sid, $rev, NULL, '', -1);
236 }
237 }
238
239 log write 3 filtersym "Ok."
240
241 # # ## ### ##### ######## #############
242
243 log write 3 filtersym "Mutate branches to tags"
244
245 foreach {id fid lod sid root first bra} $branchestomutate {
246 state run {
247 DELETE FROM branch WHERE bid = $id ;
248 INSERT INTO tag (tid, fid, lod, sid, rev)
249 VALUES ($id, $fid, $lod, $sid, $root);
250 }
251 }
252
253 log write 3 filtersym "Ok."
254
255 # # ## ### ##### ######## #############
256 return
257 }
258
259 # Adjust the parents of symbols to their preferred parents.
260
@@ -242,56 +261,210 @@
261 # If a file level ymbol has a preferred parent that is different
262 # than its current parent, and if the preferred parent is an
263 # allowed parent of the symbol in this file, then we graft the
264 # aSymbol onto its preferred parent.
265
266 proc AdjustParents {} {
267 log write 3 filtersym "Adjust parents, loading data in preparation"
268
269 # We pull important maps once into memory so that we do quick
270 # hash lookup later when processing the graft candidates.
271
272 # Tag/Branch names ...
273 array set sn [state run { SELECT T.tid, S.name FROM tag T, symbol S WHERE T.sid = S.sid }]
274 array set sn [state run { SELECT B.bid, S.name FROM branch B, symbol S WHERE B.sid = S.sid }]
275 # Symbol names ...
276 array set sx [state run { SELECT L.sid, L.name FROM symbol L }]
277 # Files and projects.
278 array set fpn {}
279 foreach {id fn pn} [state run {
280 SELECT F.fid, F.name, P.name
281 FROM file F, project P
282 WHERE F.pid = P.pid
283 }] { set fpn($id) [list $fn $pn] }
284
285 set tagstoadjust [state run {
286 SELECT T.tid, T.fid, T.lod, P.pid, S.name, R.rev, R.rid
287 FROM tag T, preferedparent P, symbol S, revision R
288 WHERE T.sid = P.sid
289 AND T.lod != P.pid
290 AND P.pid = S.sid
291 AND S.name != ':trunk:'
292 AND T.rev = R.rid
293 }]
294
295 set branchestoadjust [state run {
296 SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
297 FROM branch B, preferedparent P, symbol S, revision R
298 WHERE B.sid = P.sid
299 AND B.lod != P.pid
300 AND P.pid = S.sid
301 AND S.name != ':trunk:'
302 AND B.root = R.rid
303 }]
304
305 set tmax [expr {[llength $tagstoadjust] / 7}]
306 set bmax [expr {[llength $branchestoadjust] / 8}]
307
308 log write 4 filtersym "Reparenting at most [nsp $tmax tag]"
309 log write 4 filtersym "Reparenting at most [nsp $bmax branch branches]"
310
311 log write 3 filtersym "Adjust tag parents"
312
313 # Find the tags whose current parent (lod) is not the prefered
314 # parent, the prefered parent is not the trunk, and the
315 # prefered parent is a possible parent per the tag's revision.
316
317 set fmt %[string length $tmax]s
318 set mxs [format $fmt $tmax]
319
320 set n 0
321 foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {
322
323 # BOTTLE-NECK ...
324 #
325 # The check if the candidate (pid) is truly viable is
326 # based finding the branch as possible parent, and done
327 # now instead of as part of the already complex join.
328 #
329 # ... AND P.pid IN (SELECT B.sid
330 # FROM branch B
331 # WHERE B.root = R.rid)
332
333 if {![lindex [state run {
334 SELECT COUNT(*)
335 FROM branch B
336 WHERE B.sid = $pid
337 AND B.root = $rid
338 }] 0]} {
339 incr tmax -1
340 set mxs [format $fmt $tmax]
341 continue
342 }
343
344 #
345 # BOTTLE-NECK ...
346
347 # The names for use in the log output are retrieved
348 # separately, to keep the join selecting the adjustable
349 # tags small, not burdened with the dereferencing of links
350 # to name.
351
352 set tagname $sn($id)
353 set oldname $sx($lod)
354 struct::list assign $fpn($fid) fname prname
355
356 # Do the grafting.
357
358 log write 4 filtersym "\[[format $fmt $n]/$mxs\] $prname : Grafting tag '$tagname' on $fname/$revnr from '$oldname' onto '$preferedname'"
359 state run { UPDATE tag SET lod = $pid WHERE tid = $id ; }
360 incr n
361 }
362
363 log write 3 filtersym "Reparented [nsp $n tag]"
364
365 log write 3 filtersym "Adjust branch parents"
366
367 # Find the branches whose current parent (lod) is not the
368 # prefered parent, the prefered parent is not the trunk, and
369 # the prefered parent is a possible parent per the branch's
370 # revision.
371
372 set fmt %[string length $bmax]s
373 set mxs [format $fmt $bmax]
374
375 set n 0
376 foreach {id fid lod pos pid preferedname revnr rid} $branchestoadjust {
377
378 # BOTTLE-NECK ...
379 #
380 # The check if the candidate (pid) is truly viable is
381 # based on the branch positions in the spawning revision,
382 # and done now instead of as part of the already complex
383 # join.
384 #
385 # ... AND P.pid IN (SELECT BX.sid
386 # FROM branch BX
387 # WHERE BX.root = R.rid
388 # AND BX.pos > B.pos)
389
390 if {![lindex [state run {
391 SELECT COUNT(*)
392 FROM branch B
393 WHERE B.sid = $pid
394 AND B.root = $rid
395 AND B.pos > $pos
396 }] 0]} {
397 incr bmax -1
398 set mxs [format $fmt $bmax]
399 continue
400 }
401
402 #
403 # BOTTLE-NECK ...
404
405 # The names for use in the log output are retrieved
406 # separately, to keep the join selecting the adjustable
407 # tags small, not burdened with the dereferencing of links
408 # to name.
409
410 set braname $sn($id)
411 set oldname $sx($lod)
412 struct::list assign $fpn($fid) fname prname
 
 
 
 
 
 
 
 
413
414 # Do the grafting.
415
416 log write 4 filtersym "\[[format $fmt $n]/$mxs\] $prname : Grafting branch '$braname' on $fname/$revnr from '$oldname' onto '$preferedname'"
417 state run { UPDATE tag SET lod = $pid WHERE tid = $id ; }
418 incr n
 
419 }
420
421 log write 3 filtersym "Reparented [nsp $n branch branches]"
422 return
423 }
424
425 proc RefineSymbols {} {
426 # Tags and branches are marked as normal/noop based on the op
427 # of their revision.
428
429 log write 3 filtersym "Refine symbols (no-op or not?)"
430
431 log write 4 filtersym " Regular tags"
432 state run {
433 INSERT INTO noop
434 SELECT T.tid, 0
435 FROM tag T, revision R
436 WHERE T.rev = R.rid
437 AND R.op != 0 -- 0 == nothing
438 }
439
440 log write 4 filtersym " No-op tags"
441 state run {
442 INSERT INTO noop
443 SELECT T.tid, 1
444 FROM tag T, revision R
445 WHERE T.rev = R.rid
446 AND R.op = 0 -- nothing
447 }
448
449 log write 4 filtersym " Regular branches"
450 state run {
451 INSERT INTO noop
452 SELECT B.bid, 0
453 FROM branch B, revision R
454 WHERE B.root = R.rid
455 AND R.op != 0 -- nothing
456 }
457
458 log write 4 filtersym " No-op branches"
459 state run {
460 INSERT INTO noop
461 SELECT B.bid, 1
462 FROM branch B, revision R
463 WHERE B.root = R.rid
464 AND R.op = 0 -- nothing
465 }
466 return
467 }
468
469 # # ## ### ##### ######## #############
470 ## Configuration
@@ -308,10 +481,11 @@
481 namespace eval filtersym {
482 namespace import ::vc::fossil::import::cvs::state
483 namespace eval project {
484 namespace import ::vc::fossil::import::cvs::project::sym
485 }
486 namespace import ::vc::tools::misc::nsp
487 namespace import ::vc::tools::log
488 log register filtersym
489 }
490 }
491
492

Keyboard Shortcuts

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