Fossil SCM

Integrate the new singletons with the main class, route the relevant places to them.

aku 2007-11-29 06:10 trunk
Commit c74fe3de3fd031f4ca45685850aa0389ef910ddf
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -37,12 +37,15 @@
3737
set myid $theid
3838
} else {
3939
set myid [incr mycounter]
4040
}
4141
42
+ integrity assert {[info exists mycstype($cstype)]} {Bad changeset type '$cstype'.}
43
+
4244
set myproject $project
4345
set mytype $cstype
46
+ set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype}
4447
set mysrcid $srcid
4548
set myrevisions $revisions
4649
set mypos {} ; # Commit location is not known yet.
4750
4851
# Keep track of the generated changesets and of the inverse
@@ -72,24 +75,18 @@
7275
7376
method id {} { return $myid }
7477
method revisions {} { return $myrevisions }
7578
method data {} { return [list $myproject $mytype $mysrcid] }
7679
77
- method bysymbol {} { return [expr {$mytype eq "sym"}] }
78
- method byrevision {} { return [expr {$mytype eq "rev"}] }
80
+ delegate method bysymbol to mytypeobj
81
+ delegate method byrevision to mytypeobj
82
+ delegate method isbranch to mytypeobj
83
+ delegate method istag to mytypeobj
7984
8085
method setpos {p} { set mypos $p ; return }
8186
method pos {} { return $mypos }
8287
83
- method isbranch {} {
84
- error NOT-USED
85
- return [expr {($mytype eq "sym") &&
86
- ($mybranchcode == [state one {
87
- SELECT type FROM symbol WHERE sid = $mysrcid
88
- }])}]
89
- }
90
-
9188
# result = dict (revision -> list (changeset))
9289
method successormap {} {
9390
# NOTE / FUTURE: Possible bottleneck.
9491
array set tmp {}
9592
foreach {rev children} [$self nextmap] {
@@ -135,19 +132,19 @@
135132
}
136133
137134
# revision -> list (revision)
138135
method nextmap {} {
139136
if {[llength $mynextmap]} { return $mynextmap }
140
- PullSuccessorRevisions tmp $myrevisions
137
+ $mytypeobj successors tmp $myrevisions
141138
set mynextmap [array get tmp]
142139
return $mynextmap
143140
}
144141
145142
# revision -> list (revision)
146143
method premap {} {
147144
if {[llength $mypremap]} { return $mypremap }
148
- PullPredecessorRevisions tmp $myrevisions
145
+ $mytypeobj predecessors tmp $myrevisions
149146
set mypremap [array get tmp]
150147
return $mypremap
151148
}
152149
153150
method breakinternaldependencies {} {
@@ -171,11 +168,11 @@
171168
172169
# Array of dependencies (parent -> child). This is pulled from
173170
# the state, and limited to successors within the changeset.
174171
175172
array set dependencies {}
176
- PullInternalSuccessorRevisions dependencies $myrevisions
173
+ $mytypeobj internalsuccessors dependencies $myrevisions
177174
if {![array size dependencies]} {return 0} ; # Nothing to break.
178175
179176
log write 5 csets ...[$self str].......................................................
180177
181178
# We have internal dependencies to break. We now iterate over
@@ -316,18 +313,11 @@
316313
}
317314
}
318315
return
319316
}
320317
321
- method timerange {} {
322
- set theset ('[join $myrevisions {','}]')
323
- return [state run "
324
- SELECT MIN(R.date), MAX(R.date)
325
- FROM revision R
326
- WHERE R.rid IN $theset
327
- "]
328
- }
318
+ method timerange {} { return [$mytypeobj timerange $myrevisions] }
329319
330320
method drop {} {
331321
state transaction {
332322
state run {
333323
DELETE FROM changeset WHERE cid = $myid;
@@ -381,12 +371,20 @@
381371
382372
variable myid {} ; # Id of the cset for the persistent
383373
# state.
384374
variable myproject {} ; # Reference of the project object the
385375
# changeset belongs to.
386
- variable mytype {} ; # rev or sym, where the cset originated
387
- # from.
376
+ variable mytype {} ; # What the changeset is based on
377
+ # (revisions, tags, or branches).
378
+ # Values: See mycstype. Note that we
379
+ # have to keep the names of the helper
380
+ # singletons in sync with the contents
381
+ # of state table 'cstype', and various
382
+ # other places using them hardwired.
383
+ variable mytypeobj {} ; # Reference to the container for the
384
+ # type dependent code. Derived from
385
+ # mytype.
388386
variable mysrcid {} ; # Id of the metadata or symbol the cset
389387
# is based on.
390388
variable myrevisions {} ; # List of the file level revisions in
391389
# the cset.
392390
variable mypremap {} ; # Dictionary mapping from the revisions
@@ -402,11 +400,15 @@
402400
403401
# # ## ### ##### ######## #############
404402
## Internal methods
405403
406404
typevariable mycounter 0 ; # Id counter for csets. Last id used.
407
- typevariable mycstype -array {} ; # Map cstypes to persistent ids.
405
+ typevariable mycstype -array {} ; # Map cstypes (names) to persistent
406
+ # ids. Note that we have to keep
407
+ # the names in the table 'cstype'
408
+ # in sync with the names of the
409
+ # helper singletons.
408410
409411
typemethod getcstypes {} {
410412
foreach {tid name} [state run {
411413
SELECT tid, name FROM cstype;
412414
}] { set mycstype($name) $tid }
@@ -854,10 +856,16 @@
854856
typemethod istag {} { return 0 }
855857
typemethod isbranch {} { return 0 }
856858
857859
# result = list (mintime, maxtime)
858860
typemethod timerange {items} {
861
+ set theset ('[join $items {','}]')
862
+ return [state run "
863
+ SELECT MIN(R.date), MAX(R.date)
864
+ FROM revision R
865
+ WHERE R.rid IN $theset
866
+ "]
859867
}
860868
861869
# var(dv) = dict (revision -> list (revision))
862870
typemethod internalsuccessors {dv revisions} {
863871
}
864872
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -37,12 +37,15 @@
37 set myid $theid
38 } else {
39 set myid [incr mycounter]
40 }
41
 
 
42 set myproject $project
43 set mytype $cstype
 
44 set mysrcid $srcid
45 set myrevisions $revisions
46 set mypos {} ; # Commit location is not known yet.
47
48 # Keep track of the generated changesets and of the inverse
@@ -72,24 +75,18 @@
72
73 method id {} { return $myid }
74 method revisions {} { return $myrevisions }
75 method data {} { return [list $myproject $mytype $mysrcid] }
76
77 method bysymbol {} { return [expr {$mytype eq "sym"}] }
78 method byrevision {} { return [expr {$mytype eq "rev"}] }
 
 
79
80 method setpos {p} { set mypos $p ; return }
81 method pos {} { return $mypos }
82
83 method isbranch {} {
84 error NOT-USED
85 return [expr {($mytype eq "sym") &&
86 ($mybranchcode == [state one {
87 SELECT type FROM symbol WHERE sid = $mysrcid
88 }])}]
89 }
90
91 # result = dict (revision -> list (changeset))
92 method successormap {} {
93 # NOTE / FUTURE: Possible bottleneck.
94 array set tmp {}
95 foreach {rev children} [$self nextmap] {
@@ -135,19 +132,19 @@
135 }
136
137 # revision -> list (revision)
138 method nextmap {} {
139 if {[llength $mynextmap]} { return $mynextmap }
140 PullSuccessorRevisions tmp $myrevisions
141 set mynextmap [array get tmp]
142 return $mynextmap
143 }
144
145 # revision -> list (revision)
146 method premap {} {
147 if {[llength $mypremap]} { return $mypremap }
148 PullPredecessorRevisions tmp $myrevisions
149 set mypremap [array get tmp]
150 return $mypremap
151 }
152
153 method breakinternaldependencies {} {
@@ -171,11 +168,11 @@
171
172 # Array of dependencies (parent -> child). This is pulled from
173 # the state, and limited to successors within the changeset.
174
175 array set dependencies {}
176 PullInternalSuccessorRevisions dependencies $myrevisions
177 if {![array size dependencies]} {return 0} ; # Nothing to break.
178
179 log write 5 csets ...[$self str].......................................................
180
181 # We have internal dependencies to break. We now iterate over
@@ -316,18 +313,11 @@
316 }
317 }
318 return
319 }
320
321 method timerange {} {
322 set theset ('[join $myrevisions {','}]')
323 return [state run "
324 SELECT MIN(R.date), MAX(R.date)
325 FROM revision R
326 WHERE R.rid IN $theset
327 "]
328 }
329
330 method drop {} {
331 state transaction {
332 state run {
333 DELETE FROM changeset WHERE cid = $myid;
@@ -381,12 +371,20 @@
381
382 variable myid {} ; # Id of the cset for the persistent
383 # state.
384 variable myproject {} ; # Reference of the project object the
385 # changeset belongs to.
386 variable mytype {} ; # rev or sym, where the cset originated
387 # from.
 
 
 
 
 
 
 
 
388 variable mysrcid {} ; # Id of the metadata or symbol the cset
389 # is based on.
390 variable myrevisions {} ; # List of the file level revisions in
391 # the cset.
392 variable mypremap {} ; # Dictionary mapping from the revisions
@@ -402,11 +400,15 @@
402
403 # # ## ### ##### ######## #############
404 ## Internal methods
405
406 typevariable mycounter 0 ; # Id counter for csets. Last id used.
407 typevariable mycstype -array {} ; # Map cstypes to persistent ids.
 
 
 
 
408
409 typemethod getcstypes {} {
410 foreach {tid name} [state run {
411 SELECT tid, name FROM cstype;
412 }] { set mycstype($name) $tid }
@@ -854,10 +856,16 @@
854 typemethod istag {} { return 0 }
855 typemethod isbranch {} { return 0 }
856
857 # result = list (mintime, maxtime)
858 typemethod timerange {items} {
 
 
 
 
 
 
859 }
860
861 # var(dv) = dict (revision -> list (revision))
862 typemethod internalsuccessors {dv revisions} {
863 }
864
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -37,12 +37,15 @@
37 set myid $theid
38 } else {
39 set myid [incr mycounter]
40 }
41
42 integrity assert {[info exists mycstype($cstype)]} {Bad changeset type '$cstype'.}
43
44 set myproject $project
45 set mytype $cstype
46 set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype}
47 set mysrcid $srcid
48 set myrevisions $revisions
49 set mypos {} ; # Commit location is not known yet.
50
51 # Keep track of the generated changesets and of the inverse
@@ -72,24 +75,18 @@
75
76 method id {} { return $myid }
77 method revisions {} { return $myrevisions }
78 method data {} { return [list $myproject $mytype $mysrcid] }
79
80 delegate method bysymbol to mytypeobj
81 delegate method byrevision to mytypeobj
82 delegate method isbranch to mytypeobj
83 delegate method istag to mytypeobj
84
85 method setpos {p} { set mypos $p ; return }
86 method pos {} { return $mypos }
87
 
 
 
 
 
 
 
 
88 # result = dict (revision -> list (changeset))
89 method successormap {} {
90 # NOTE / FUTURE: Possible bottleneck.
91 array set tmp {}
92 foreach {rev children} [$self nextmap] {
@@ -135,19 +132,19 @@
132 }
133
134 # revision -> list (revision)
135 method nextmap {} {
136 if {[llength $mynextmap]} { return $mynextmap }
137 $mytypeobj successors tmp $myrevisions
138 set mynextmap [array get tmp]
139 return $mynextmap
140 }
141
142 # revision -> list (revision)
143 method premap {} {
144 if {[llength $mypremap]} { return $mypremap }
145 $mytypeobj predecessors tmp $myrevisions
146 set mypremap [array get tmp]
147 return $mypremap
148 }
149
150 method breakinternaldependencies {} {
@@ -171,11 +168,11 @@
168
169 # Array of dependencies (parent -> child). This is pulled from
170 # the state, and limited to successors within the changeset.
171
172 array set dependencies {}
173 $mytypeobj internalsuccessors dependencies $myrevisions
174 if {![array size dependencies]} {return 0} ; # Nothing to break.
175
176 log write 5 csets ...[$self str].......................................................
177
178 # We have internal dependencies to break. We now iterate over
@@ -316,18 +313,11 @@
313 }
314 }
315 return
316 }
317
318 method timerange {} { return [$mytypeobj timerange $myrevisions] }
 
 
 
 
 
 
 
319
320 method drop {} {
321 state transaction {
322 state run {
323 DELETE FROM changeset WHERE cid = $myid;
@@ -381,12 +371,20 @@
371
372 variable myid {} ; # Id of the cset for the persistent
373 # state.
374 variable myproject {} ; # Reference of the project object the
375 # changeset belongs to.
376 variable mytype {} ; # What the changeset is based on
377 # (revisions, tags, or branches).
378 # Values: See mycstype. Note that we
379 # have to keep the names of the helper
380 # singletons in sync with the contents
381 # of state table 'cstype', and various
382 # other places using them hardwired.
383 variable mytypeobj {} ; # Reference to the container for the
384 # type dependent code. Derived from
385 # mytype.
386 variable mysrcid {} ; # Id of the metadata or symbol the cset
387 # is based on.
388 variable myrevisions {} ; # List of the file level revisions in
389 # the cset.
390 variable mypremap {} ; # Dictionary mapping from the revisions
@@ -402,11 +400,15 @@
400
401 # # ## ### ##### ######## #############
402 ## Internal methods
403
404 typevariable mycounter 0 ; # Id counter for csets. Last id used.
405 typevariable mycstype -array {} ; # Map cstypes (names) to persistent
406 # ids. Note that we have to keep
407 # the names in the table 'cstype'
408 # in sync with the names of the
409 # helper singletons.
410
411 typemethod getcstypes {} {
412 foreach {tid name} [state run {
413 SELECT tid, name FROM cstype;
414 }] { set mycstype($name) $tid }
@@ -854,10 +856,16 @@
856 typemethod istag {} { return 0 }
857 typemethod isbranch {} { return 0 }
858
859 # result = list (mintime, maxtime)
860 typemethod timerange {items} {
861 set theset ('[join $items {','}]')
862 return [state run "
863 SELECT MIN(R.date), MAX(R.date)
864 FROM revision R
865 WHERE R.rid IN $theset
866 "]
867 }
868
869 # var(dv) = dict (revision -> list (revision))
870 typemethod internalsuccessors {dv revisions} {
871 }
872

Keyboard Shortcuts

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