Fossil SCM
Reworked the in-memory databases of changesets. Objects now hold items, not only revisions. Tags, and branches are new possibilities. Lists of ids go to the type-dependent retrieval command. List of tagged items (type/id pairs) come back, and are in the API. The 1:n map revisions to changesets is now an 1:1-map tagged items to changeset.
Commit
0fcfbf78284063c4832621645afa080b30185887
Parent
b1666f8ff4a2c16…
1 file changed
+53
-33
+53
-33
| --- tools/cvs2fossil/lib/c2f_prev.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | ||
| @@ -49,11 +49,15 @@ | ||
| 49 | 49 | |
| 50 | 50 | # Keep track of the generated changesets and of the inverse |
| 51 | 51 | # mapping from revisions to them. |
| 52 | 52 | lappend mychangesets $self |
| 53 | 53 | set myidmap($myid) $self |
| 54 | - foreach r $revisions { lappend myrevmap($r) $self } | |
| 54 | + foreach r $revisions { | |
| 55 | + set key [list $cstype $id] | |
| 56 | + set myrevmap($key) $self | |
| 57 | + lappend mytitems $key | |
| 58 | + } | |
| 55 | 59 | return |
| 56 | 60 | } |
| 57 | 61 | |
| 58 | 62 | method str {} { |
| 59 | 63 | set str "<" |
| @@ -68,11 +72,11 @@ | ||
| 68 | 72 | append str "$mytype ${myid}${detail}>" |
| 69 | 73 | return $str |
| 70 | 74 | } |
| 71 | 75 | |
| 72 | 76 | method id {} { return $myid } |
| 73 | - method revisions {} { return $myrevisions } | |
| 77 | + method revisions {} { return $mytitems } | |
| 74 | 78 | method data {} { return [list $myproject $mytype $mysrcid] } |
| 75 | 79 | |
| 76 | 80 | delegate method bysymbol to mytypeobj |
| 77 | 81 | delegate method byrevision to mytypeobj |
| 78 | 82 | delegate method isbranch to mytypeobj |
| @@ -79,11 +83,11 @@ | ||
| 79 | 83 | delegate method istag to mytypeobj |
| 80 | 84 | |
| 81 | 85 | method setpos {p} { set mypos $p ; return } |
| 82 | 86 | method pos {} { return $mypos } |
| 83 | 87 | |
| 84 | - # result = dict (revision -> list (changeset)) | |
| 88 | + # result = dict (item -> list (changeset)) | |
| 85 | 89 | method successormap {} { |
| 86 | 90 | # NOTE / FUTURE: Possible bottleneck. |
| 87 | 91 | array set tmp {} |
| 88 | 92 | foreach {rev children} [$self nextmap] { |
| 89 | 93 | foreach child $children { |
| @@ -95,10 +99,11 @@ | ||
| 95 | 99 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 96 | 100 | } |
| 97 | 101 | return [array get tmp] |
| 98 | 102 | } |
| 99 | 103 | |
| 104 | + # result = list (changeset) | |
| 100 | 105 | method successors {} { |
| 101 | 106 | # NOTE / FUTURE: Possible bottleneck. |
| 102 | 107 | set csets {} |
| 103 | 108 | foreach {_ children} [$self nextmap] { |
| 104 | 109 | foreach child $children { |
| @@ -109,11 +114,11 @@ | ||
| 109 | 114 | } |
| 110 | 115 | } |
| 111 | 116 | return [lsort -unique $csets] |
| 112 | 117 | } |
| 113 | 118 | |
| 114 | - # result = dict (revision -> list (changeset)) | |
| 119 | + # result = dict (item -> list (changeset)) | |
| 115 | 120 | method predecessormap {} { |
| 116 | 121 | # NOTE / FUTURE: Possible bottleneck. |
| 117 | 122 | array set tmp {} |
| 118 | 123 | foreach {rev children} [$self premap] { |
| 119 | 124 | foreach child $children { |
| @@ -125,19 +130,19 @@ | ||
| 125 | 130 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 126 | 131 | } |
| 127 | 132 | return [array get tmp] |
| 128 | 133 | } |
| 129 | 134 | |
| 130 | - # revision -> list (revision) | |
| 135 | + # item -> list (item) | |
| 131 | 136 | method nextmap {} { |
| 132 | 137 | if {[llength $mynextmap]} { return $mynextmap } |
| 133 | 138 | $mytypeobj successors tmp $myrevisions |
| 134 | 139 | set mynextmap [array get tmp] |
| 135 | 140 | return $mynextmap |
| 136 | 141 | } |
| 137 | 142 | |
| 138 | - # revision -> list (revision) | |
| 143 | + # item -> list (item) | |
| 139 | 144 | method premap {} { |
| 140 | 145 | if {[llength $mypremap]} { return $mypremap } |
| 141 | 146 | $mytypeobj predecessors tmp $myrevisions |
| 142 | 147 | set mypremap [array get tmp] |
| 143 | 148 | return $mypremap |
| @@ -244,11 +249,14 @@ | ||
| 244 | 249 | # (*) We clear out the associated part of the myrevmap |
| 245 | 250 | # in-memory index in preparation for new data. A simple unset |
| 246 | 251 | # is enough, we have no symbol changesets at this time, and |
| 247 | 252 | # thus never more than one reference in the list. |
| 248 | 253 | |
| 249 | - foreach r $myrevisions { unset myrevmap($r) } | |
| 254 | + foreach r $myrevisions { | |
| 255 | + set key [list $mytype $r] | |
| 256 | + unset myrevmap($key) | |
| 257 | + } | |
| 250 | 258 | |
| 251 | 259 | # Create changesets for the fragments, reusing the current one |
| 252 | 260 | # for the first fragment. We sort them in order to allow |
| 253 | 261 | # checking for gaps and nice messages. |
| 254 | 262 | |
| @@ -282,11 +290,14 @@ | ||
| 282 | 290 | # information, see (*) above. Persistence does not matter |
| 283 | 291 | # here, none of the changesets has been saved to the |
| 284 | 292 | # persistent state yet. |
| 285 | 293 | |
| 286 | 294 | set myrevisions [lrange $myrevisions 0 $firste] |
| 287 | - foreach r $myrevisions { lappend myrevmap($r) $self } | |
| 295 | + foreach r $myrevisions { | |
| 296 | + set key [list $mytype $r] | |
| 297 | + set myrevmap($key) $self | |
| 298 | + } | |
| 288 | 299 | |
| 289 | 300 | return 1 |
| 290 | 301 | } |
| 291 | 302 | |
| 292 | 303 | method persist {} { |
| @@ -319,16 +330,12 @@ | ||
| 319 | 330 | DELETE FROM changeset WHERE cid = $myid; |
| 320 | 331 | DELETE FROM csrevision WHERE cid = $myid; |
| 321 | 332 | } |
| 322 | 333 | } |
| 323 | 334 | foreach r $myrevisions { |
| 324 | - if {[llength $myrevmap($r)] == 1} { | |
| 325 | - unset myrevmap($r) | |
| 326 | - } else { | |
| 327 | - set pos [lsearch -exact $myrevmap($r) $self] | |
| 328 | - set myrevmap($r) [lreplace $myrevmap($r) $pos $pos] | |
| 329 | - } | |
| 335 | + set key [list $mytype $r] | |
| 336 | + unset myrevmap($key) | |
| 330 | 337 | } |
| 331 | 338 | set pos [lsearch -exact $mychangesets $self] |
| 332 | 339 | set mychangesets [lreplace $mychangesets $pos $pos] |
| 333 | 340 | return |
| 334 | 341 | } |
| @@ -336,10 +343,14 @@ | ||
| 336 | 343 | typemethod split {cset args} { |
| 337 | 344 | # As part of the creation of the new changesets specified in |
| 338 | 345 | # ARGS as sets of revisions, all subsets of CSET's revision |
| 339 | 346 | # set, CSET will be dropped from all databases, in and out of |
| 340 | 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. | |
| 341 | 352 | |
| 342 | 353 | struct::list assign [$cset data] project cstype cssrc |
| 343 | 354 | |
| 344 | 355 | $cset drop |
| 345 | 356 | $cset destroy |
| @@ -347,11 +358,12 @@ | ||
| 347 | 358 | set newcsets {} |
| 348 | 359 | foreach fragmentrevisions $args { |
| 349 | 360 | integrity assert { |
| 350 | 361 | [llength $fragmentrevisions] |
| 351 | 362 | } {Attempted to create an empty changeset, i.e. without revisions} |
| 352 | - lappend newcsets [$type %AUTO% $project $cstype $cssrc $fragmentrevisions] | |
| 363 | + lappend newcsets [$type %AUTO% $project $cstype $cssrc \ | |
| 364 | + [Untag $fragmentrevisions $cstype]] | |
| 353 | 365 | } |
| 354 | 366 | |
| 355 | 367 | foreach c $newcsets { $c persist } |
| 356 | 368 | return $newcsets |
| 357 | 369 | } |
| @@ -359,10 +371,20 @@ | ||
| 359 | 371 | typemethod strlist {changesets} { |
| 360 | 372 | return [join [struct::list map $changesets [myproc ID]]] |
| 361 | 373 | } |
| 362 | 374 | |
| 363 | 375 | proc ID {cset} { $cset str } |
| 376 | + | |
| 377 | + proc Untag {taggeditems cstype} { | |
| 378 | + return [struct::list map $taggeditems [myproc Untag1 $cstype]] | |
| 379 | + } | |
| 380 | + | |
| 381 | + proc Untag1 {cstype theitem} { | |
| 382 | + struct::list assign $theitem t i | |
| 383 | + integrity assert {$cstype eq $t} {Item $i's type is '$t', expected '$cstype'} | |
| 384 | + return $i | |
| 385 | + } | |
| 364 | 386 | |
| 365 | 387 | # # ## ### ##### ######## ############# |
| 366 | 388 | ## State |
| 367 | 389 | |
| 368 | 390 | variable myid {} ; # Id of the cset for the persistent |
| @@ -379,20 +401,22 @@ | ||
| 379 | 401 | variable mytypeobj {} ; # Reference to the container for the |
| 380 | 402 | # type dependent code. Derived from |
| 381 | 403 | # mytype. |
| 382 | 404 | variable mysrcid {} ; # Id of the metadata or symbol the cset |
| 383 | 405 | # is based on. |
| 384 | - variable myrevisions {} ; # List of the file level revisions in | |
| 385 | - # the cset. | |
| 386 | - variable mypremap {} ; # Dictionary mapping from the revisions | |
| 387 | - # to their predecessors. Cache to avoid | |
| 388 | - # loading this from the state more than | |
| 389 | - # once. | |
| 390 | - variable mynextmap {} ; # Dictionary mapping from the revisions | |
| 391 | - # to their successors. Cache to avoid | |
| 392 | - # loading this from the state more than | |
| 393 | - # once. | |
| 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) | |
| 415 | + # to their successors (also tagged). A | |
| 416 | + # cache to avoid loading this from the | |
| 417 | + # state more than once. | |
| 394 | 418 | variable mypos {} ; # Commit position of the changeset, if |
| 395 | 419 | # known. |
| 396 | 420 | |
| 397 | 421 | # # ## ### ##### ######## ############# |
| 398 | 422 | ## Internal methods |
| @@ -630,18 +654,14 @@ | ||
| 630 | 654 | } |
| 631 | 655 | |
| 632 | 656 | # # ## ### ##### ######## ############# |
| 633 | 657 | |
| 634 | 658 | typevariable mychangesets {} ; # List of all known changesets. |
| 635 | - typevariable myrevmap -array {} ; # Map from revisions to the list | |
| 636 | - # of changesets containing | |
| 637 | - # it. NOTE: While only one | |
| 638 | - # revision changeset can contain | |
| 639 | - # the revision, there can | |
| 640 | - # however also be one or more | |
| 641 | - # additional symbol changesets | |
| 642 | - # which use it, hence a list. | |
| 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. | |
| 643 | 663 | typevariable myidmap -array {} ; # Map from changeset id to changeset. |
| 644 | 664 | |
| 645 | 665 | typemethod all {} { return $mychangesets } |
| 646 | 666 | typemethod of {id} { return $myidmap($id) } |
| 647 | 667 | typemethod ofrev {id} { return $myrevmap($id) } |
| 648 | 668 |
| --- tools/cvs2fossil/lib/c2f_prev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | |
| @@ -49,11 +49,15 @@ | |
| 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 { lappend myrevmap($r) $self } |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | method str {} { |
| 59 | set str "<" |
| @@ -68,11 +72,11 @@ | |
| 68 | append str "$mytype ${myid}${detail}>" |
| 69 | return $str |
| 70 | } |
| 71 | |
| 72 | method id {} { return $myid } |
| 73 | method revisions {} { return $myrevisions } |
| 74 | method data {} { return [list $myproject $mytype $mysrcid] } |
| 75 | |
| 76 | delegate method bysymbol to mytypeobj |
| 77 | delegate method byrevision to mytypeobj |
| 78 | delegate method isbranch to mytypeobj |
| @@ -79,11 +83,11 @@ | |
| 79 | delegate method istag to mytypeobj |
| 80 | |
| 81 | method setpos {p} { set mypos $p ; return } |
| 82 | method pos {} { return $mypos } |
| 83 | |
| 84 | # result = dict (revision -> list (changeset)) |
| 85 | method successormap {} { |
| 86 | # NOTE / FUTURE: Possible bottleneck. |
| 87 | array set tmp {} |
| 88 | foreach {rev children} [$self nextmap] { |
| 89 | foreach child $children { |
| @@ -95,10 +99,11 @@ | |
| 95 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 96 | } |
| 97 | return [array get tmp] |
| 98 | } |
| 99 | |
| 100 | method successors {} { |
| 101 | # NOTE / FUTURE: Possible bottleneck. |
| 102 | set csets {} |
| 103 | foreach {_ children} [$self nextmap] { |
| 104 | foreach child $children { |
| @@ -109,11 +114,11 @@ | |
| 109 | } |
| 110 | } |
| 111 | return [lsort -unique $csets] |
| 112 | } |
| 113 | |
| 114 | # result = dict (revision -> list (changeset)) |
| 115 | method predecessormap {} { |
| 116 | # NOTE / FUTURE: Possible bottleneck. |
| 117 | array set tmp {} |
| 118 | foreach {rev children} [$self premap] { |
| 119 | foreach child $children { |
| @@ -125,19 +130,19 @@ | |
| 125 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 126 | } |
| 127 | return [array get tmp] |
| 128 | } |
| 129 | |
| 130 | # revision -> list (revision) |
| 131 | method nextmap {} { |
| 132 | if {[llength $mynextmap]} { return $mynextmap } |
| 133 | $mytypeobj successors tmp $myrevisions |
| 134 | set mynextmap [array get tmp] |
| 135 | return $mynextmap |
| 136 | } |
| 137 | |
| 138 | # revision -> list (revision) |
| 139 | method premap {} { |
| 140 | if {[llength $mypremap]} { return $mypremap } |
| 141 | $mytypeobj predecessors tmp $myrevisions |
| 142 | set mypremap [array get tmp] |
| 143 | return $mypremap |
| @@ -244,11 +249,14 @@ | |
| 244 | # (*) We clear out the associated part of the myrevmap |
| 245 | # in-memory index in preparation for new data. A simple unset |
| 246 | # is enough, we have no symbol changesets at this time, and |
| 247 | # thus never more than one reference in the list. |
| 248 | |
| 249 | foreach r $myrevisions { unset myrevmap($r) } |
| 250 | |
| 251 | # Create changesets for the fragments, reusing the current one |
| 252 | # for the first fragment. We sort them in order to allow |
| 253 | # checking for gaps and nice messages. |
| 254 | |
| @@ -282,11 +290,14 @@ | |
| 282 | # information, see (*) above. Persistence does not matter |
| 283 | # here, none of the changesets has been saved to the |
| 284 | # persistent state yet. |
| 285 | |
| 286 | set myrevisions [lrange $myrevisions 0 $firste] |
| 287 | foreach r $myrevisions { lappend myrevmap($r) $self } |
| 288 | |
| 289 | return 1 |
| 290 | } |
| 291 | |
| 292 | method persist {} { |
| @@ -319,16 +330,12 @@ | |
| 319 | DELETE FROM changeset WHERE cid = $myid; |
| 320 | DELETE FROM csrevision WHERE cid = $myid; |
| 321 | } |
| 322 | } |
| 323 | foreach r $myrevisions { |
| 324 | if {[llength $myrevmap($r)] == 1} { |
| 325 | unset myrevmap($r) |
| 326 | } else { |
| 327 | set pos [lsearch -exact $myrevmap($r) $self] |
| 328 | set myrevmap($r) [lreplace $myrevmap($r) $pos $pos] |
| 329 | } |
| 330 | } |
| 331 | set pos [lsearch -exact $mychangesets $self] |
| 332 | set mychangesets [lreplace $mychangesets $pos $pos] |
| 333 | return |
| 334 | } |
| @@ -336,10 +343,14 @@ | |
| 336 | typemethod split {cset args} { |
| 337 | # As part of the creation of the new changesets specified in |
| 338 | # ARGS as sets of revisions, all subsets of CSET's revision |
| 339 | # set, CSET will be dropped from all databases, in and out of |
| 340 | # memory, and then destroyed. |
| 341 | |
| 342 | struct::list assign [$cset data] project cstype cssrc |
| 343 | |
| 344 | $cset drop |
| 345 | $cset destroy |
| @@ -347,11 +358,12 @@ | |
| 347 | set newcsets {} |
| 348 | foreach fragmentrevisions $args { |
| 349 | integrity assert { |
| 350 | [llength $fragmentrevisions] |
| 351 | } {Attempted to create an empty changeset, i.e. without revisions} |
| 352 | lappend newcsets [$type %AUTO% $project $cstype $cssrc $fragmentrevisions] |
| 353 | } |
| 354 | |
| 355 | foreach c $newcsets { $c persist } |
| 356 | return $newcsets |
| 357 | } |
| @@ -359,10 +371,20 @@ | |
| 359 | typemethod strlist {changesets} { |
| 360 | return [join [struct::list map $changesets [myproc ID]]] |
| 361 | } |
| 362 | |
| 363 | proc ID {cset} { $cset str } |
| 364 | |
| 365 | # # ## ### ##### ######## ############# |
| 366 | ## State |
| 367 | |
| 368 | variable myid {} ; # Id of the cset for the persistent |
| @@ -379,20 +401,22 @@ | |
| 379 | variable mytypeobj {} ; # Reference to the container for the |
| 380 | # type dependent code. Derived from |
| 381 | # mytype. |
| 382 | variable mysrcid {} ; # Id of the metadata or symbol the cset |
| 383 | # is based on. |
| 384 | variable myrevisions {} ; # List of the file level revisions in |
| 385 | # the cset. |
| 386 | variable mypremap {} ; # Dictionary mapping from the revisions |
| 387 | # to their predecessors. Cache to avoid |
| 388 | # loading this from the state more than |
| 389 | # once. |
| 390 | variable mynextmap {} ; # Dictionary mapping from the revisions |
| 391 | # to their successors. Cache to avoid |
| 392 | # loading this from the state more than |
| 393 | # once. |
| 394 | variable mypos {} ; # Commit position of the changeset, if |
| 395 | # known. |
| 396 | |
| 397 | # # ## ### ##### ######## ############# |
| 398 | ## Internal methods |
| @@ -630,18 +654,14 @@ | |
| 630 | } |
| 631 | |
| 632 | # # ## ### ##### ######## ############# |
| 633 | |
| 634 | typevariable mychangesets {} ; # List of all known changesets. |
| 635 | typevariable myrevmap -array {} ; # Map from revisions to the list |
| 636 | # of changesets containing |
| 637 | # it. NOTE: While only one |
| 638 | # revision changeset can contain |
| 639 | # the revision, there can |
| 640 | # however also be one or more |
| 641 | # additional symbol changesets |
| 642 | # which use it, hence a list. |
| 643 | typevariable myidmap -array {} ; # Map from changeset id to changeset. |
| 644 | |
| 645 | typemethod all {} { return $mychangesets } |
| 646 | typemethod of {id} { return $myidmap($id) } |
| 647 | typemethod ofrev {id} { return $myrevmap($id) } |
| 648 |
| --- tools/cvs2fossil/lib/c2f_prev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | |
| @@ -49,11 +49,15 @@ | |
| 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 | |
| 62 | method str {} { |
| 63 | set str "<" |
| @@ -68,11 +72,11 @@ | |
| 72 | append str "$mytype ${myid}${detail}>" |
| 73 | return $str |
| 74 | } |
| 75 | |
| 76 | method id {} { return $myid } |
| 77 | method revisions {} { return $mytitems } |
| 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 |
| @@ -79,11 +83,11 @@ | |
| 83 | delegate method istag to mytypeobj |
| 84 | |
| 85 | method setpos {p} { set mypos $p ; return } |
| 86 | method pos {} { return $mypos } |
| 87 | |
| 88 | # result = dict (item -> list (changeset)) |
| 89 | method successormap {} { |
| 90 | # NOTE / FUTURE: Possible bottleneck. |
| 91 | array set tmp {} |
| 92 | foreach {rev children} [$self nextmap] { |
| 93 | foreach child $children { |
| @@ -95,10 +99,11 @@ | |
| 99 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 100 | } |
| 101 | return [array get tmp] |
| 102 | } |
| 103 | |
| 104 | # result = list (changeset) |
| 105 | method successors {} { |
| 106 | # NOTE / FUTURE: Possible bottleneck. |
| 107 | set csets {} |
| 108 | foreach {_ children} [$self nextmap] { |
| 109 | foreach child $children { |
| @@ -109,11 +114,11 @@ | |
| 114 | } |
| 115 | } |
| 116 | return [lsort -unique $csets] |
| 117 | } |
| 118 | |
| 119 | # result = dict (item -> list (changeset)) |
| 120 | method predecessormap {} { |
| 121 | # NOTE / FUTURE: Possible bottleneck. |
| 122 | array set tmp {} |
| 123 | foreach {rev children} [$self premap] { |
| 124 | foreach child $children { |
| @@ -125,19 +130,19 @@ | |
| 130 | set tmp($rev) [lsort -unique $tmp($rev)] |
| 131 | } |
| 132 | return [array get tmp] |
| 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 |
| @@ -244,11 +249,14 @@ | |
| 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. |
| 262 | |
| @@ -282,11 +290,14 @@ | |
| 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 | |
| 303 | method persist {} { |
| @@ -319,16 +330,12 @@ | |
| 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 | } |
| @@ -336,10 +343,14 @@ | |
| 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 | |
| 353 | struct::list assign [$cset data] project cstype cssrc |
| 354 | |
| 355 | $cset drop |
| 356 | $cset destroy |
| @@ -347,11 +358,12 @@ | |
| 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 | } |
| @@ -359,10 +371,20 @@ | |
| 371 | typemethod strlist {changesets} { |
| 372 | return [join [struct::list map $changesets [myproc ID]]] |
| 373 | } |
| 374 | |
| 375 | proc ID {cset} { $cset str } |
| 376 | |
| 377 | proc Untag {taggeditems cstype} { |
| 378 | return [struct::list map $taggeditems [myproc Untag1 $cstype]] |
| 379 | } |
| 380 | |
| 381 | proc Untag1 {cstype theitem} { |
| 382 | struct::list assign $theitem t i |
| 383 | integrity assert {$cstype eq $t} {Item $i's type is '$t', expected '$cstype'} |
| 384 | return $i |
| 385 | } |
| 386 | |
| 387 | # # ## ### ##### ######## ############# |
| 388 | ## State |
| 389 | |
| 390 | variable myid {} ; # Id of the cset for the persistent |
| @@ -379,20 +401,22 @@ | |
| 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) |
| 415 | # to their successors (also tagged). A |
| 416 | # cache to avoid loading this from the |
| 417 | # state more than once. |
| 418 | variable mypos {} ; # Commit position of the changeset, if |
| 419 | # known. |
| 420 | |
| 421 | # # ## ### ##### ######## ############# |
| 422 | ## Internal methods |
| @@ -630,18 +654,14 @@ | |
| 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 |