Fossil SCM
Integrate the new singletons with the main class, route the relevant places to them.
Commit
c74fe3de3fd031f4ca45685850aa0389ef910ddf
Parent
27b15b7095e1c53…
1 file changed
+32
-24
+32
-24
| --- tools/cvs2fossil/lib/c2f_prev.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | ||
| @@ -37,12 +37,15 @@ | ||
| 37 | 37 | set myid $theid |
| 38 | 38 | } else { |
| 39 | 39 | set myid [incr mycounter] |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | + integrity assert {[info exists mycstype($cstype)]} {Bad changeset type '$cstype'.} | |
| 43 | + | |
| 42 | 44 | set myproject $project |
| 43 | 45 | set mytype $cstype |
| 46 | + set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype} | |
| 44 | 47 | set mysrcid $srcid |
| 45 | 48 | set myrevisions $revisions |
| 46 | 49 | set mypos {} ; # Commit location is not known yet. |
| 47 | 50 | |
| 48 | 51 | # Keep track of the generated changesets and of the inverse |
| @@ -72,24 +75,18 @@ | ||
| 72 | 75 | |
| 73 | 76 | method id {} { return $myid } |
| 74 | 77 | method revisions {} { return $myrevisions } |
| 75 | 78 | method data {} { return [list $myproject $mytype $mysrcid] } |
| 76 | 79 | |
| 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 | |
| 79 | 84 | |
| 80 | 85 | method setpos {p} { set mypos $p ; return } |
| 81 | 86 | method pos {} { return $mypos } |
| 82 | 87 | |
| 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 | 88 | # result = dict (revision -> list (changeset)) |
| 92 | 89 | method successormap {} { |
| 93 | 90 | # NOTE / FUTURE: Possible bottleneck. |
| 94 | 91 | array set tmp {} |
| 95 | 92 | foreach {rev children} [$self nextmap] { |
| @@ -135,19 +132,19 @@ | ||
| 135 | 132 | } |
| 136 | 133 | |
| 137 | 134 | # revision -> list (revision) |
| 138 | 135 | method nextmap {} { |
| 139 | 136 | if {[llength $mynextmap]} { return $mynextmap } |
| 140 | - PullSuccessorRevisions tmp $myrevisions | |
| 137 | + $mytypeobj successors tmp $myrevisions | |
| 141 | 138 | set mynextmap [array get tmp] |
| 142 | 139 | return $mynextmap |
| 143 | 140 | } |
| 144 | 141 | |
| 145 | 142 | # revision -> list (revision) |
| 146 | 143 | method premap {} { |
| 147 | 144 | if {[llength $mypremap]} { return $mypremap } |
| 148 | - PullPredecessorRevisions tmp $myrevisions | |
| 145 | + $mytypeobj predecessors tmp $myrevisions | |
| 149 | 146 | set mypremap [array get tmp] |
| 150 | 147 | return $mypremap |
| 151 | 148 | } |
| 152 | 149 | |
| 153 | 150 | method breakinternaldependencies {} { |
| @@ -171,11 +168,11 @@ | ||
| 171 | 168 | |
| 172 | 169 | # Array of dependencies (parent -> child). This is pulled from |
| 173 | 170 | # the state, and limited to successors within the changeset. |
| 174 | 171 | |
| 175 | 172 | array set dependencies {} |
| 176 | - PullInternalSuccessorRevisions dependencies $myrevisions | |
| 173 | + $mytypeobj internalsuccessors dependencies $myrevisions | |
| 177 | 174 | if {![array size dependencies]} {return 0} ; # Nothing to break. |
| 178 | 175 | |
| 179 | 176 | log write 5 csets ...[$self str]....................................................... |
| 180 | 177 | |
| 181 | 178 | # We have internal dependencies to break. We now iterate over |
| @@ -316,18 +313,11 @@ | ||
| 316 | 313 | } |
| 317 | 314 | } |
| 318 | 315 | return |
| 319 | 316 | } |
| 320 | 317 | |
| 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] } | |
| 329 | 319 | |
| 330 | 320 | method drop {} { |
| 331 | 321 | state transaction { |
| 332 | 322 | state run { |
| 333 | 323 | DELETE FROM changeset WHERE cid = $myid; |
| @@ -381,12 +371,20 @@ | ||
| 381 | 371 | |
| 382 | 372 | variable myid {} ; # Id of the cset for the persistent |
| 383 | 373 | # state. |
| 384 | 374 | variable myproject {} ; # Reference of the project object the |
| 385 | 375 | # 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. | |
| 388 | 386 | variable mysrcid {} ; # Id of the metadata or symbol the cset |
| 389 | 387 | # is based on. |
| 390 | 388 | variable myrevisions {} ; # List of the file level revisions in |
| 391 | 389 | # the cset. |
| 392 | 390 | variable mypremap {} ; # Dictionary mapping from the revisions |
| @@ -402,11 +400,15 @@ | ||
| 402 | 400 | |
| 403 | 401 | # # ## ### ##### ######## ############# |
| 404 | 402 | ## Internal methods |
| 405 | 403 | |
| 406 | 404 | 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. | |
| 408 | 410 | |
| 409 | 411 | typemethod getcstypes {} { |
| 410 | 412 | foreach {tid name} [state run { |
| 411 | 413 | SELECT tid, name FROM cstype; |
| 412 | 414 | }] { set mycstype($name) $tid } |
| @@ -854,10 +856,16 @@ | ||
| 854 | 856 | typemethod istag {} { return 0 } |
| 855 | 857 | typemethod isbranch {} { return 0 } |
| 856 | 858 | |
| 857 | 859 | # result = list (mintime, maxtime) |
| 858 | 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 | + "] | |
| 859 | 867 | } |
| 860 | 868 | |
| 861 | 869 | # var(dv) = dict (revision -> list (revision)) |
| 862 | 870 | typemethod internalsuccessors {dv revisions} { |
| 863 | 871 | } |
| 864 | 872 |
| --- 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 |