Fossil SCM
Brought the variable names into alignment with the semantics, now again naming what is stored in them.
Commit
deab4d035be04cb3c33888d610944d7176cd415b
Parent
0fcfbf78284063c…
1 file changed
+59
-58
+59
-58
| --- tools/cvs2fossil/lib/c2f_prev.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | ||
| @@ -29,11 +29,11 @@ | ||
| 29 | 29 | |
| 30 | 30 | snit::type ::vc::fossil::import::cvs::project::rev { |
| 31 | 31 | # # ## ### ##### ######## ############# |
| 32 | 32 | ## Public API |
| 33 | 33 | |
| 34 | - constructor {project cstype srcid revisions {theid {}}} { | |
| 34 | + constructor {project cstype srcid items {theid {}}} { | |
| 35 | 35 | if {$theid ne ""} { |
| 36 | 36 | set myid $theid |
| 37 | 37 | } else { |
| 38 | 38 | set myid [incr mycounter] |
| 39 | 39 | } |
| @@ -42,20 +42,20 @@ | ||
| 42 | 42 | |
| 43 | 43 | set myproject $project |
| 44 | 44 | set mytype $cstype |
| 45 | 45 | set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype} |
| 46 | 46 | set mysrcid $srcid |
| 47 | - set myrevisions $revisions | |
| 47 | + set myitems $items | |
| 48 | 48 | set mypos {} ; # Commit location is not known yet. |
| 49 | 49 | |
| 50 | 50 | # Keep track of the generated changesets and of the inverse |
| 51 | - # mapping from revisions to them. | |
| 51 | + # mapping from items to them. | |
| 52 | 52 | lappend mychangesets $self |
| 53 | 53 | set myidmap($myid) $self |
| 54 | - foreach r $revisions { | |
| 55 | - set key [list $cstype $id] | |
| 56 | - set myrevmap($key) $self | |
| 54 | + foreach iid $items { | |
| 55 | + set key [list $cstype $iid] | |
| 56 | + set myitemmap($key) $self | |
| 57 | 57 | lappend mytitems $key |
| 58 | 58 | } |
| 59 | 59 | return |
| 60 | 60 | } |
| 61 | 61 | |
| @@ -89,12 +89,12 @@ | ||
| 89 | 89 | method successormap {} { |
| 90 | 90 | # NOTE / FUTURE: Possible bottleneck. |
| 91 | 91 | array set tmp {} |
| 92 | 92 | foreach {rev children} [$self nextmap] { |
| 93 | 93 | foreach child $children { |
| 94 | - # 8.5 lappend tmp($rev) {*}$myrevmap($child) | |
| 95 | - foreach cset $myrevmap($child) { | |
| 94 | + # 8.5 lappend tmp($rev) {*}$myitemmap($child) | |
| 95 | + foreach cset $myitemmap($child) { | |
| 96 | 96 | lappend tmp($rev) $cset |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 100 | 100 | } |
| @@ -105,12 +105,12 @@ | ||
| 105 | 105 | method successors {} { |
| 106 | 106 | # NOTE / FUTURE: Possible bottleneck. |
| 107 | 107 | set csets {} |
| 108 | 108 | foreach {_ children} [$self nextmap] { |
| 109 | 109 | foreach child $children { |
| 110 | - # 8.5 lappend csets {*}$myrevmap($child) | |
| 111 | - foreach cset $myrevmap($child) { | |
| 110 | + # 8.5 lappend csets {*}$myitemmap($child) | |
| 111 | + foreach cset $myitemmap($child) { | |
| 112 | 112 | lappend csets $cset |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | return [lsort -unique $csets] |
| @@ -120,12 +120,12 @@ | ||
| 120 | 120 | method predecessormap {} { |
| 121 | 121 | # NOTE / FUTURE: Possible bottleneck. |
| 122 | 122 | array set tmp {} |
| 123 | 123 | foreach {rev children} [$self premap] { |
| 124 | 124 | foreach child $children { |
| 125 | - # 8.5 lappend tmp($rev) {*}$myrevmap($child) | |
| 126 | - foreach cset $myrevmap($child) { | |
| 125 | + # 8.5 lappend tmp($rev) {*}$myitemmap($child) | |
| 126 | + foreach cset $myitemmap($child) { | |
| 127 | 127 | lappend tmp($rev) $cset |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 131 | 131 | } |
| @@ -133,19 +133,19 @@ | ||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | # item -> list (item) |
| 136 | 136 | method nextmap {} { |
| 137 | 137 | if {[llength $mynextmap]} { return $mynextmap } |
| 138 | - $mytypeobj successors tmp $myrevisions | |
| 138 | + $mytypeobj successors tmp $myitems | |
| 139 | 139 | set mynextmap [array get tmp] |
| 140 | 140 | return $mynextmap |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | # item -> list (item) |
| 144 | 144 | method premap {} { |
| 145 | 145 | if {[llength $mypremap]} { return $mypremap } |
| 146 | - $mytypeobj predecessors tmp $myrevisions | |
| 146 | + $mytypeobj predecessors tmp $myitems | |
| 147 | 147 | set mypremap [array get tmp] |
| 148 | 148 | return $mypremap |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | method breakinternaldependencies {} { |
| @@ -169,11 +169,11 @@ | ||
| 169 | 169 | |
| 170 | 170 | # Array of dependencies (parent -> child). This is pulled from |
| 171 | 171 | # the state, and limited to successors within the changeset. |
| 172 | 172 | |
| 173 | 173 | array set dependencies {} |
| 174 | - $mytypeobj internalsuccessors dependencies $myrevisions | |
| 174 | + $mytypeobj internalsuccessors dependencies $myitems | |
| 175 | 175 | if {![array size dependencies]} {return 0} ; # Nothing to break. |
| 176 | 176 | |
| 177 | 177 | log write 5 csets ...[$self str]....................................................... |
| 178 | 178 | |
| 179 | 179 | # We have internal dependencies to break. We now iterate over |
| @@ -189,11 +189,11 @@ | ||
| 189 | 189 | # CROSS position in list -> number of dependencies crossing it |
| 190 | 190 | # DEPC dependency -> positions it crosses |
| 191 | 191 | # List: RANGE Of the positions itself. |
| 192 | 192 | # A dependency is a single-element map parent -> child |
| 193 | 193 | |
| 194 | - InitializeBreakState $myrevisions | |
| 194 | + InitializeBreakState $myitems | |
| 195 | 195 | |
| 196 | 196 | set fragments {} |
| 197 | 197 | set pending [list $range] |
| 198 | 198 | set at 0 |
| 199 | 199 | array set breaks {} |
| @@ -222,11 +222,11 @@ | ||
| 222 | 222 | set breaks($best) $cross($best) |
| 223 | 223 | |
| 224 | 224 | log write 6 csets "Best break @ $best, cutting [nsp $cross($best) dependency dependencies]" |
| 225 | 225 | |
| 226 | 226 | # Note: The value of best is an abolute location in |
| 227 | - # myrevisions. Use the start of current to make it an | |
| 227 | + # myitems. Use the start of current to make it an | |
| 228 | 228 | # index absolute to current. |
| 229 | 229 | |
| 230 | 230 | set brel [expr {$best - [lindex $current 0]}] |
| 231 | 231 | set bnext $brel ; incr bnext |
| 232 | 232 | set fragbefore [lrange $current 0 $brel] |
| @@ -244,18 +244,18 @@ | ||
| 244 | 244 | incr at |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | log write 6 csets ". . .. ... ..... ........ ............." |
| 248 | 248 | |
| 249 | - # (*) We clear out the associated part of the myrevmap | |
| 249 | + # (*) We clear out the associated part of the myitemmap | |
| 250 | 250 | # in-memory index in preparation for new data. A simple unset |
| 251 | 251 | # is enough, we have no symbol changesets at this time, and |
| 252 | 252 | # thus never more than one reference in the list. |
| 253 | 253 | |
| 254 | - foreach r $myrevisions { | |
| 255 | - set key [list $mytype $r] | |
| 256 | - unset myrevmap($key) | |
| 254 | + foreach iid $myitems { | |
| 255 | + set key [list $mytype $iid] | |
| 256 | + unset myitemmap($key) | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | # Create changesets for the fragments, reusing the current one |
| 260 | 260 | # for the first fragment. We sort them in order to allow |
| 261 | 261 | # checking for gaps and nice messages. |
| @@ -271,32 +271,31 @@ | ||
| 271 | 271 | set laste $firste |
| 272 | 272 | foreach fragment [lrange $fragments 1 end] { |
| 273 | 273 | Border $fragment s e |
| 274 | 274 | integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap} |
| 275 | 275 | |
| 276 | - set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myrevisions $s $e]] | |
| 276 | + set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myitems $s $e]] | |
| 277 | 277 | |
| 278 | 278 | log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)" |
| 279 | 279 | |
| 280 | 280 | set laste $e |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | integrity assert { |
| 284 | - $laste == ([llength $myrevisions]-1) | |
| 284 | + $laste == ([llength $myitems]-1) | |
| 285 | 285 | } {Bad fragment end @ $laste, gap, or beyond end of the range} |
| 286 | 286 | |
| 287 | 287 | # Put the first fragment into the current changeset, and |
| 288 | - # update the in-memory index. We can simply (re)add the | |
| 289 | - # revisions because we cleared the previously existing | |
| 290 | - # information, see (*) above. Persistence does not matter | |
| 291 | - # here, none of the changesets has been saved to the | |
| 292 | - # persistent state yet. | |
| 293 | - | |
| 294 | - set myrevisions [lrange $myrevisions 0 $firste] | |
| 295 | - foreach r $myrevisions { | |
| 296 | - set key [list $mytype $r] | |
| 297 | - set myrevmap($key) $self | |
| 288 | + # update the in-memory index. We can simply (re)add the items | |
| 289 | + # because we cleared the previously existing information, see | |
| 290 | + # (*) above. Persistence does not matter here, none of the | |
| 291 | + # changesets has been saved to the persistent state yet. | |
| 292 | + | |
| 293 | + set myitems [lrange $myitems 0 $firste] | |
| 294 | + foreach iid $myitems { | |
| 295 | + set key [list $mytype $iid] | |
| 296 | + set myitemmap($key) $self | |
| 298 | 297 | } |
| 299 | 298 | |
| 300 | 299 | return 1 |
| 301 | 300 | } |
| 302 | 301 | |
| @@ -309,44 +308,44 @@ | ||
| 309 | 308 | state run { |
| 310 | 309 | INSERT INTO changeset (cid, pid, type, src) |
| 311 | 310 | VALUES ($myid, $pid, $tid, $mysrcid); |
| 312 | 311 | } |
| 313 | 312 | |
| 314 | - foreach rid $myrevisions { | |
| 313 | + foreach iid $myitems { | |
| 315 | 314 | state run { |
| 316 | 315 | INSERT INTO csrevision (cid, pos, rid) |
| 317 | - VALUES ($myid, $pos, $rid); | |
| 316 | + VALUES ($myid, $pos, $iid); | |
| 318 | 317 | } |
| 319 | 318 | incr pos |
| 320 | 319 | } |
| 321 | 320 | } |
| 322 | 321 | return |
| 323 | 322 | } |
| 324 | 323 | |
| 325 | - method timerange {} { return [$mytypeobj timerange $myrevisions] } | |
| 324 | + method timerange {} { return [$mytypeobj timerange $myitems] } | |
| 326 | 325 | |
| 327 | 326 | method drop {} { |
| 328 | 327 | state transaction { |
| 329 | 328 | state run { |
| 330 | 329 | DELETE FROM changeset WHERE cid = $myid; |
| 331 | 330 | DELETE FROM csrevision WHERE cid = $myid; |
| 332 | 331 | } |
| 333 | 332 | } |
| 334 | - foreach r $myrevisions { | |
| 335 | - set key [list $mytype $r] | |
| 336 | - unset myrevmap($key) | |
| 333 | + foreach iid $myitems { | |
| 334 | + set key [list $mytype $iid] | |
| 335 | + unset myitemmap($key) | |
| 337 | 336 | } |
| 338 | 337 | set pos [lsearch -exact $mychangesets $self] |
| 339 | 338 | set mychangesets [lreplace $mychangesets $pos $pos] |
| 340 | 339 | return |
| 341 | 340 | } |
| 342 | 341 | |
| 343 | 342 | typemethod split {cset args} { |
| 344 | 343 | # As part of the creation of the new changesets specified in |
| 345 | - # ARGS as sets of revisions, all subsets of CSET's revision | |
| 346 | - # set, CSET will be dropped from all databases, in and out of | |
| 347 | - # memory, and then destroyed. | |
| 344 | + # ARGS as sets of items, all subsets of CSET's item set, CSET | |
| 345 | + # will be dropped from all databases, in and out of memory, | |
| 346 | + # and then destroyed. | |
| 348 | 347 | # |
| 349 | 348 | # Note: The item lists found in args are tagged items. They |
| 350 | 349 | # have to have the same type as the changeset, being subsets |
| 351 | 350 | # of its items. This is checked in Untag1. |
| 352 | 351 | |
| @@ -354,16 +353,16 @@ | ||
| 354 | 353 | |
| 355 | 354 | $cset drop |
| 356 | 355 | $cset destroy |
| 357 | 356 | |
| 358 | 357 | set newcsets {} |
| 359 | - foreach fragmentrevisions $args { | |
| 358 | + foreach fragmentitems $args { | |
| 360 | 359 | integrity assert { |
| 361 | - [llength $fragmentrevisions] | |
| 362 | - } {Attempted to create an empty changeset, i.e. without revisions} | |
| 360 | + [llength $fragmentitems] | |
| 361 | + } {Attempted to create an empty changeset, i.e. without items} | |
| 363 | 362 | lappend newcsets [$type %AUTO% $project $cstype $cssrc \ |
| 364 | - [Untag $fragmentrevisions $cstype]] | |
| 363 | + [Untag $fragmentitems $cstype]] | |
| 365 | 364 | } |
| 366 | 365 | |
| 367 | 366 | foreach c $newcsets { $c persist } |
| 368 | 367 | return $newcsets |
| 369 | 368 | } |
| @@ -401,14 +400,14 @@ | ||
| 401 | 400 | variable mytypeobj {} ; # Reference to the container for the |
| 402 | 401 | # type dependent code. Derived from |
| 403 | 402 | # mytype. |
| 404 | 403 | variable mysrcid {} ; # Id of the metadata or symbol the cset |
| 405 | 404 | # is based on. |
| 406 | - variable myrevisions {} ; # List of the file level revisions, | |
| 405 | + variable myitems {} ; # List of the file level revisions, | |
| 407 | 406 | # tags, or branches in the cset, as |
| 408 | 407 | # ids. Not tagged. |
| 409 | - variable mytitems {} ; # As myrevisions, the tagged form. | |
| 408 | + variable mytitems {} ; # As myitems, the tagged form. | |
| 410 | 409 | variable mypremap {} ; # Dictionary mapping from the items (tagged now) |
| 411 | 410 | # to their predecessors, also tagged. A |
| 412 | 411 | # cache to avoid loading this from the |
| 413 | 412 | # state more than once. |
| 414 | 413 | variable mynextmap {} ; # Dictionary mapping from the items (tagged) |
| @@ -653,20 +652,22 @@ | ||
| 653 | 652 | return |
| 654 | 653 | } |
| 655 | 654 | |
| 656 | 655 | # # ## ### ##### ######## ############# |
| 657 | 656 | |
| 658 | - typevariable mychangesets {} ; # List of all known changesets. | |
| 659 | - typevariable myrevmap -array {} ; # Map from items (tagged) to the | |
| 660 | - # list of changesets containing | |
| 661 | - # it. Each item can be used by | |
| 662 | - # only one changeset. | |
| 663 | - typevariable myidmap -array {} ; # Map from changeset id to changeset. | |
| 664 | - | |
| 665 | - typemethod all {} { return $mychangesets } | |
| 666 | - typemethod of {id} { return $myidmap($id) } | |
| 667 | - typemethod ofrev {id} { return $myrevmap($id) } | |
| 657 | + typevariable mychangesets {} ; # List of all known changesets. | |
| 658 | + typevariable myitemmap -array {} ; # Map from items (tagged) to | |
| 659 | + # the list of changesets | |
| 660 | + # containing it. Each item can | |
| 661 | + # be used by only one | |
| 662 | + # changeset. | |
| 663 | + typevariable myidmap -array {} ; # Map from changeset id to | |
| 664 | + # changeset. | |
| 665 | + | |
| 666 | + typemethod all {} { return $mychangesets } | |
| 667 | + typemethod of {cid} { return $myidmap($cid) } | |
| 668 | + typemethod ofrev {iid} { return $myitemmap($iid) } | |
| 668 | 669 | |
| 669 | 670 | # # ## ### ##### ######## ############# |
| 670 | 671 | ## Configuration |
| 671 | 672 | |
| 672 | 673 | pragma -hastypeinfo no ; # no type introspection |
| 673 | 674 |
| --- tools/cvs2fossil/lib/c2f_prev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | |
| @@ -29,11 +29,11 @@ | |
| 29 | |
| 30 | snit::type ::vc::fossil::import::cvs::project::rev { |
| 31 | # # ## ### ##### ######## ############# |
| 32 | ## Public API |
| 33 | |
| 34 | constructor {project cstype srcid revisions {theid {}}} { |
| 35 | if {$theid ne ""} { |
| 36 | set myid $theid |
| 37 | } else { |
| 38 | set myid [incr mycounter] |
| 39 | } |
| @@ -42,20 +42,20 @@ | |
| 42 | |
| 43 | set myproject $project |
| 44 | set mytype $cstype |
| 45 | set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype} |
| 46 | set mysrcid $srcid |
| 47 | set myrevisions $revisions |
| 48 | set mypos {} ; # Commit location is not known yet. |
| 49 | |
| 50 | # Keep track of the generated changesets and of the inverse |
| 51 | # mapping from revisions to them. |
| 52 | lappend mychangesets $self |
| 53 | set myidmap($myid) $self |
| 54 | foreach r $revisions { |
| 55 | set key [list $cstype $id] |
| 56 | set myrevmap($key) $self |
| 57 | lappend mytitems $key |
| 58 | } |
| 59 | return |
| 60 | } |
| 61 | |
| @@ -89,12 +89,12 @@ | |
| 89 | method successormap {} { |
| 90 | # NOTE / FUTURE: Possible bottleneck. |
| 91 | array set tmp {} |
| 92 | foreach {rev children} [$self nextmap] { |
| 93 | foreach child $children { |
| 94 | # 8.5 lappend tmp($rev) {*}$myrevmap($child) |
| 95 | foreach cset $myrevmap($child) { |
| 96 | lappend tmp($rev) $cset |
| 97 | } |
| 98 | } |
| 99 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 100 | } |
| @@ -105,12 +105,12 @@ | |
| 105 | method successors {} { |
| 106 | # NOTE / FUTURE: Possible bottleneck. |
| 107 | set csets {} |
| 108 | foreach {_ children} [$self nextmap] { |
| 109 | foreach child $children { |
| 110 | # 8.5 lappend csets {*}$myrevmap($child) |
| 111 | foreach cset $myrevmap($child) { |
| 112 | lappend csets $cset |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | return [lsort -unique $csets] |
| @@ -120,12 +120,12 @@ | |
| 120 | method predecessormap {} { |
| 121 | # NOTE / FUTURE: Possible bottleneck. |
| 122 | array set tmp {} |
| 123 | foreach {rev children} [$self premap] { |
| 124 | foreach child $children { |
| 125 | # 8.5 lappend tmp($rev) {*}$myrevmap($child) |
| 126 | foreach cset $myrevmap($child) { |
| 127 | lappend tmp($rev) $cset |
| 128 | } |
| 129 | } |
| 130 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 131 | } |
| @@ -133,19 +133,19 @@ | |
| 133 | } |
| 134 | |
| 135 | # item -> list (item) |
| 136 | method nextmap {} { |
| 137 | if {[llength $mynextmap]} { return $mynextmap } |
| 138 | $mytypeobj successors tmp $myrevisions |
| 139 | set mynextmap [array get tmp] |
| 140 | return $mynextmap |
| 141 | } |
| 142 | |
| 143 | # item -> list (item) |
| 144 | method premap {} { |
| 145 | if {[llength $mypremap]} { return $mypremap } |
| 146 | $mytypeobj predecessors tmp $myrevisions |
| 147 | set mypremap [array get tmp] |
| 148 | return $mypremap |
| 149 | } |
| 150 | |
| 151 | method breakinternaldependencies {} { |
| @@ -169,11 +169,11 @@ | |
| 169 | |
| 170 | # Array of dependencies (parent -> child). This is pulled from |
| 171 | # the state, and limited to successors within the changeset. |
| 172 | |
| 173 | array set dependencies {} |
| 174 | $mytypeobj internalsuccessors dependencies $myrevisions |
| 175 | if {![array size dependencies]} {return 0} ; # Nothing to break. |
| 176 | |
| 177 | log write 5 csets ...[$self str]....................................................... |
| 178 | |
| 179 | # We have internal dependencies to break. We now iterate over |
| @@ -189,11 +189,11 @@ | |
| 189 | # CROSS position in list -> number of dependencies crossing it |
| 190 | # DEPC dependency -> positions it crosses |
| 191 | # List: RANGE Of the positions itself. |
| 192 | # A dependency is a single-element map parent -> child |
| 193 | |
| 194 | InitializeBreakState $myrevisions |
| 195 | |
| 196 | set fragments {} |
| 197 | set pending [list $range] |
| 198 | set at 0 |
| 199 | array set breaks {} |
| @@ -222,11 +222,11 @@ | |
| 222 | set breaks($best) $cross($best) |
| 223 | |
| 224 | log write 6 csets "Best break @ $best, cutting [nsp $cross($best) dependency dependencies]" |
| 225 | |
| 226 | # Note: The value of best is an abolute location in |
| 227 | # myrevisions. Use the start of current to make it an |
| 228 | # index absolute to current. |
| 229 | |
| 230 | set brel [expr {$best - [lindex $current 0]}] |
| 231 | set bnext $brel ; incr bnext |
| 232 | set fragbefore [lrange $current 0 $brel] |
| @@ -244,18 +244,18 @@ | |
| 244 | incr at |
| 245 | } |
| 246 | |
| 247 | log write 6 csets ". . .. ... ..... ........ ............." |
| 248 | |
| 249 | # (*) We clear out the associated part of the myrevmap |
| 250 | # in-memory index in preparation for new data. A simple unset |
| 251 | # is enough, we have no symbol changesets at this time, and |
| 252 | # thus never more than one reference in the list. |
| 253 | |
| 254 | foreach r $myrevisions { |
| 255 | set key [list $mytype $r] |
| 256 | unset myrevmap($key) |
| 257 | } |
| 258 | |
| 259 | # Create changesets for the fragments, reusing the current one |
| 260 | # for the first fragment. We sort them in order to allow |
| 261 | # checking for gaps and nice messages. |
| @@ -271,32 +271,31 @@ | |
| 271 | set laste $firste |
| 272 | foreach fragment [lrange $fragments 1 end] { |
| 273 | Border $fragment s e |
| 274 | integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap} |
| 275 | |
| 276 | set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myrevisions $s $e]] |
| 277 | |
| 278 | log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)" |
| 279 | |
| 280 | set laste $e |
| 281 | } |
| 282 | |
| 283 | integrity assert { |
| 284 | $laste == ([llength $myrevisions]-1) |
| 285 | } {Bad fragment end @ $laste, gap, or beyond end of the range} |
| 286 | |
| 287 | # Put the first fragment into the current changeset, and |
| 288 | # update the in-memory index. We can simply (re)add the |
| 289 | # revisions because we cleared the previously existing |
| 290 | # information, see (*) above. Persistence does not matter |
| 291 | # here, none of the changesets has been saved to the |
| 292 | # persistent state yet. |
| 293 | |
| 294 | set myrevisions [lrange $myrevisions 0 $firste] |
| 295 | foreach r $myrevisions { |
| 296 | set key [list $mytype $r] |
| 297 | set myrevmap($key) $self |
| 298 | } |
| 299 | |
| 300 | return 1 |
| 301 | } |
| 302 | |
| @@ -309,44 +308,44 @@ | |
| 309 | state run { |
| 310 | INSERT INTO changeset (cid, pid, type, src) |
| 311 | VALUES ($myid, $pid, $tid, $mysrcid); |
| 312 | } |
| 313 | |
| 314 | foreach rid $myrevisions { |
| 315 | state run { |
| 316 | INSERT INTO csrevision (cid, pos, rid) |
| 317 | VALUES ($myid, $pos, $rid); |
| 318 | } |
| 319 | incr pos |
| 320 | } |
| 321 | } |
| 322 | return |
| 323 | } |
| 324 | |
| 325 | method timerange {} { return [$mytypeobj timerange $myrevisions] } |
| 326 | |
| 327 | method drop {} { |
| 328 | state transaction { |
| 329 | state run { |
| 330 | DELETE FROM changeset WHERE cid = $myid; |
| 331 | DELETE FROM csrevision WHERE cid = $myid; |
| 332 | } |
| 333 | } |
| 334 | foreach r $myrevisions { |
| 335 | set key [list $mytype $r] |
| 336 | unset myrevmap($key) |
| 337 | } |
| 338 | set pos [lsearch -exact $mychangesets $self] |
| 339 | set mychangesets [lreplace $mychangesets $pos $pos] |
| 340 | return |
| 341 | } |
| 342 | |
| 343 | typemethod split {cset args} { |
| 344 | # As part of the creation of the new changesets specified in |
| 345 | # ARGS as sets of revisions, all subsets of CSET's revision |
| 346 | # set, CSET will be dropped from all databases, in and out of |
| 347 | # memory, and then destroyed. |
| 348 | # |
| 349 | # Note: The item lists found in args are tagged items. They |
| 350 | # have to have the same type as the changeset, being subsets |
| 351 | # of its items. This is checked in Untag1. |
| 352 | |
| @@ -354,16 +353,16 @@ | |
| 354 | |
| 355 | $cset drop |
| 356 | $cset destroy |
| 357 | |
| 358 | set newcsets {} |
| 359 | foreach fragmentrevisions $args { |
| 360 | integrity assert { |
| 361 | [llength $fragmentrevisions] |
| 362 | } {Attempted to create an empty changeset, i.e. without revisions} |
| 363 | lappend newcsets [$type %AUTO% $project $cstype $cssrc \ |
| 364 | [Untag $fragmentrevisions $cstype]] |
| 365 | } |
| 366 | |
| 367 | foreach c $newcsets { $c persist } |
| 368 | return $newcsets |
| 369 | } |
| @@ -401,14 +400,14 @@ | |
| 401 | variable mytypeobj {} ; # Reference to the container for the |
| 402 | # type dependent code. Derived from |
| 403 | # mytype. |
| 404 | variable mysrcid {} ; # Id of the metadata or symbol the cset |
| 405 | # is based on. |
| 406 | variable myrevisions {} ; # List of the file level revisions, |
| 407 | # tags, or branches in the cset, as |
| 408 | # ids. Not tagged. |
| 409 | variable mytitems {} ; # As myrevisions, the tagged form. |
| 410 | variable mypremap {} ; # Dictionary mapping from the items (tagged now) |
| 411 | # to their predecessors, also tagged. A |
| 412 | # cache to avoid loading this from the |
| 413 | # state more than once. |
| 414 | variable mynextmap {} ; # Dictionary mapping from the items (tagged) |
| @@ -653,20 +652,22 @@ | |
| 653 | return |
| 654 | } |
| 655 | |
| 656 | # # ## ### ##### ######## ############# |
| 657 | |
| 658 | typevariable mychangesets {} ; # List of all known changesets. |
| 659 | typevariable myrevmap -array {} ; # Map from items (tagged) to the |
| 660 | # list of changesets containing |
| 661 | # it. Each item can be used by |
| 662 | # only one changeset. |
| 663 | typevariable myidmap -array {} ; # Map from changeset id to changeset. |
| 664 | |
| 665 | typemethod all {} { return $mychangesets } |
| 666 | typemethod of {id} { return $myidmap($id) } |
| 667 | typemethod ofrev {id} { return $myrevmap($id) } |
| 668 | |
| 669 | # # ## ### ##### ######## ############# |
| 670 | ## Configuration |
| 671 | |
| 672 | pragma -hastypeinfo no ; # no type introspection |
| 673 |
| --- tools/cvs2fossil/lib/c2f_prev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | |
| @@ -29,11 +29,11 @@ | |
| 29 | |
| 30 | snit::type ::vc::fossil::import::cvs::project::rev { |
| 31 | # # ## ### ##### ######## ############# |
| 32 | ## Public API |
| 33 | |
| 34 | constructor {project cstype srcid items {theid {}}} { |
| 35 | if {$theid ne ""} { |
| 36 | set myid $theid |
| 37 | } else { |
| 38 | set myid [incr mycounter] |
| 39 | } |
| @@ -42,20 +42,20 @@ | |
| 42 | |
| 43 | set myproject $project |
| 44 | set mytype $cstype |
| 45 | set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype} |
| 46 | set mysrcid $srcid |
| 47 | set myitems $items |
| 48 | set mypos {} ; # Commit location is not known yet. |
| 49 | |
| 50 | # Keep track of the generated changesets and of the inverse |
| 51 | # mapping from items to them. |
| 52 | lappend mychangesets $self |
| 53 | set myidmap($myid) $self |
| 54 | foreach iid $items { |
| 55 | set key [list $cstype $iid] |
| 56 | set myitemmap($key) $self |
| 57 | lappend mytitems $key |
| 58 | } |
| 59 | return |
| 60 | } |
| 61 | |
| @@ -89,12 +89,12 @@ | |
| 89 | method successormap {} { |
| 90 | # NOTE / FUTURE: Possible bottleneck. |
| 91 | array set tmp {} |
| 92 | foreach {rev children} [$self nextmap] { |
| 93 | foreach child $children { |
| 94 | # 8.5 lappend tmp($rev) {*}$myitemmap($child) |
| 95 | foreach cset $myitemmap($child) { |
| 96 | lappend tmp($rev) $cset |
| 97 | } |
| 98 | } |
| 99 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 100 | } |
| @@ -105,12 +105,12 @@ | |
| 105 | method successors {} { |
| 106 | # NOTE / FUTURE: Possible bottleneck. |
| 107 | set csets {} |
| 108 | foreach {_ children} [$self nextmap] { |
| 109 | foreach child $children { |
| 110 | # 8.5 lappend csets {*}$myitemmap($child) |
| 111 | foreach cset $myitemmap($child) { |
| 112 | lappend csets $cset |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | return [lsort -unique $csets] |
| @@ -120,12 +120,12 @@ | |
| 120 | method predecessormap {} { |
| 121 | # NOTE / FUTURE: Possible bottleneck. |
| 122 | array set tmp {} |
| 123 | foreach {rev children} [$self premap] { |
| 124 | foreach child $children { |
| 125 | # 8.5 lappend tmp($rev) {*}$myitemmap($child) |
| 126 | foreach cset $myitemmap($child) { |
| 127 | lappend tmp($rev) $cset |
| 128 | } |
| 129 | } |
| 130 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 131 | } |
| @@ -133,19 +133,19 @@ | |
| 133 | } |
| 134 | |
| 135 | # item -> list (item) |
| 136 | method nextmap {} { |
| 137 | if {[llength $mynextmap]} { return $mynextmap } |
| 138 | $mytypeobj successors tmp $myitems |
| 139 | set mynextmap [array get tmp] |
| 140 | return $mynextmap |
| 141 | } |
| 142 | |
| 143 | # item -> list (item) |
| 144 | method premap {} { |
| 145 | if {[llength $mypremap]} { return $mypremap } |
| 146 | $mytypeobj predecessors tmp $myitems |
| 147 | set mypremap [array get tmp] |
| 148 | return $mypremap |
| 149 | } |
| 150 | |
| 151 | method breakinternaldependencies {} { |
| @@ -169,11 +169,11 @@ | |
| 169 | |
| 170 | # Array of dependencies (parent -> child). This is pulled from |
| 171 | # the state, and limited to successors within the changeset. |
| 172 | |
| 173 | array set dependencies {} |
| 174 | $mytypeobj internalsuccessors dependencies $myitems |
| 175 | if {![array size dependencies]} {return 0} ; # Nothing to break. |
| 176 | |
| 177 | log write 5 csets ...[$self str]....................................................... |
| 178 | |
| 179 | # We have internal dependencies to break. We now iterate over |
| @@ -189,11 +189,11 @@ | |
| 189 | # CROSS position in list -> number of dependencies crossing it |
| 190 | # DEPC dependency -> positions it crosses |
| 191 | # List: RANGE Of the positions itself. |
| 192 | # A dependency is a single-element map parent -> child |
| 193 | |
| 194 | InitializeBreakState $myitems |
| 195 | |
| 196 | set fragments {} |
| 197 | set pending [list $range] |
| 198 | set at 0 |
| 199 | array set breaks {} |
| @@ -222,11 +222,11 @@ | |
| 222 | set breaks($best) $cross($best) |
| 223 | |
| 224 | log write 6 csets "Best break @ $best, cutting [nsp $cross($best) dependency dependencies]" |
| 225 | |
| 226 | # Note: The value of best is an abolute location in |
| 227 | # myitems. Use the start of current to make it an |
| 228 | # index absolute to current. |
| 229 | |
| 230 | set brel [expr {$best - [lindex $current 0]}] |
| 231 | set bnext $brel ; incr bnext |
| 232 | set fragbefore [lrange $current 0 $brel] |
| @@ -244,18 +244,18 @@ | |
| 244 | incr at |
| 245 | } |
| 246 | |
| 247 | log write 6 csets ". . .. ... ..... ........ ............." |
| 248 | |
| 249 | # (*) We clear out the associated part of the myitemmap |
| 250 | # in-memory index in preparation for new data. A simple unset |
| 251 | # is enough, we have no symbol changesets at this time, and |
| 252 | # thus never more than one reference in the list. |
| 253 | |
| 254 | foreach iid $myitems { |
| 255 | set key [list $mytype $iid] |
| 256 | unset myitemmap($key) |
| 257 | } |
| 258 | |
| 259 | # Create changesets for the fragments, reusing the current one |
| 260 | # for the first fragment. We sort them in order to allow |
| 261 | # checking for gaps and nice messages. |
| @@ -271,32 +271,31 @@ | |
| 271 | set laste $firste |
| 272 | foreach fragment [lrange $fragments 1 end] { |
| 273 | Border $fragment s e |
| 274 | integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap} |
| 275 | |
| 276 | set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myitems $s $e]] |
| 277 | |
| 278 | log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)" |
| 279 | |
| 280 | set laste $e |
| 281 | } |
| 282 | |
| 283 | integrity assert { |
| 284 | $laste == ([llength $myitems]-1) |
| 285 | } {Bad fragment end @ $laste, gap, or beyond end of the range} |
| 286 | |
| 287 | # Put the first fragment into the current changeset, and |
| 288 | # update the in-memory index. We can simply (re)add the items |
| 289 | # because we cleared the previously existing information, see |
| 290 | # (*) above. Persistence does not matter here, none of the |
| 291 | # changesets has been saved to the persistent state yet. |
| 292 | |
| 293 | set myitems [lrange $myitems 0 $firste] |
| 294 | foreach iid $myitems { |
| 295 | set key [list $mytype $iid] |
| 296 | set myitemmap($key) $self |
| 297 | } |
| 298 | |
| 299 | return 1 |
| 300 | } |
| 301 | |
| @@ -309,44 +308,44 @@ | |
| 308 | state run { |
| 309 | INSERT INTO changeset (cid, pid, type, src) |
| 310 | VALUES ($myid, $pid, $tid, $mysrcid); |
| 311 | } |
| 312 | |
| 313 | foreach iid $myitems { |
| 314 | state run { |
| 315 | INSERT INTO csrevision (cid, pos, rid) |
| 316 | VALUES ($myid, $pos, $iid); |
| 317 | } |
| 318 | incr pos |
| 319 | } |
| 320 | } |
| 321 | return |
| 322 | } |
| 323 | |
| 324 | method timerange {} { return [$mytypeobj timerange $myitems] } |
| 325 | |
| 326 | method drop {} { |
| 327 | state transaction { |
| 328 | state run { |
| 329 | DELETE FROM changeset WHERE cid = $myid; |
| 330 | DELETE FROM csrevision WHERE cid = $myid; |
| 331 | } |
| 332 | } |
| 333 | foreach iid $myitems { |
| 334 | set key [list $mytype $iid] |
| 335 | unset myitemmap($key) |
| 336 | } |
| 337 | set pos [lsearch -exact $mychangesets $self] |
| 338 | set mychangesets [lreplace $mychangesets $pos $pos] |
| 339 | return |
| 340 | } |
| 341 | |
| 342 | typemethod split {cset args} { |
| 343 | # As part of the creation of the new changesets specified in |
| 344 | # ARGS as sets of items, all subsets of CSET's item set, CSET |
| 345 | # will be dropped from all databases, in and out of memory, |
| 346 | # and then destroyed. |
| 347 | # |
| 348 | # Note: The item lists found in args are tagged items. They |
| 349 | # have to have the same type as the changeset, being subsets |
| 350 | # of its items. This is checked in Untag1. |
| 351 | |
| @@ -354,16 +353,16 @@ | |
| 353 | |
| 354 | $cset drop |
| 355 | $cset destroy |
| 356 | |
| 357 | set newcsets {} |
| 358 | foreach fragmentitems $args { |
| 359 | integrity assert { |
| 360 | [llength $fragmentitems] |
| 361 | } {Attempted to create an empty changeset, i.e. without items} |
| 362 | lappend newcsets [$type %AUTO% $project $cstype $cssrc \ |
| 363 | [Untag $fragmentitems $cstype]] |
| 364 | } |
| 365 | |
| 366 | foreach c $newcsets { $c persist } |
| 367 | return $newcsets |
| 368 | } |
| @@ -401,14 +400,14 @@ | |
| 400 | variable mytypeobj {} ; # Reference to the container for the |
| 401 | # type dependent code. Derived from |
| 402 | # mytype. |
| 403 | variable mysrcid {} ; # Id of the metadata or symbol the cset |
| 404 | # is based on. |
| 405 | variable myitems {} ; # List of the file level revisions, |
| 406 | # tags, or branches in the cset, as |
| 407 | # ids. Not tagged. |
| 408 | variable mytitems {} ; # As myitems, the tagged form. |
| 409 | variable mypremap {} ; # Dictionary mapping from the items (tagged now) |
| 410 | # to their predecessors, also tagged. A |
| 411 | # cache to avoid loading this from the |
| 412 | # state more than once. |
| 413 | variable mynextmap {} ; # Dictionary mapping from the items (tagged) |
| @@ -653,20 +652,22 @@ | |
| 652 | return |
| 653 | } |
| 654 | |
| 655 | # # ## ### ##### ######## ############# |
| 656 | |
| 657 | typevariable mychangesets {} ; # List of all known changesets. |
| 658 | typevariable myitemmap -array {} ; # Map from items (tagged) to |
| 659 | # the list of changesets |
| 660 | # containing it. Each item can |
| 661 | # be used by only one |
| 662 | # changeset. |
| 663 | typevariable myidmap -array {} ; # Map from changeset id to |
| 664 | # changeset. |
| 665 | |
| 666 | typemethod all {} { return $mychangesets } |
| 667 | typemethod of {cid} { return $myidmap($cid) } |
| 668 | typemethod ofrev {iid} { return $myitemmap($iid) } |
| 669 | |
| 670 | # # ## ### ##### ######## ############# |
| 671 | ## Configuration |
| 672 | |
| 673 | pragma -hastypeinfo no ; # no type introspection |
| 674 |