Overview
SHA1 Hash: | deab4d035be04cb3c33888d610944d7176cd415b |
---|---|
Date: | 2007-11-29 07:36:27 |
User: | aku |
Comment: | Brought the variable names into alignment with the semantics, now again naming what is stored in them. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified tools/cvs2fossil/lib/c2f_prev.tcl from [2ef585bdd8] to [01c2b1ab5b].
@@ -29,11 +29,11 @@ snit::type ::vc::fossil::import::cvs::project::rev { # # ## ### ##### ######## ############# ## Public API - constructor {project cstype srcid revisions {theid {}}} { + constructor {project cstype srcid items {theid {}}} { if {$theid ne ""} { set myid $theid } else { set myid [incr mycounter] } @@ -42,20 +42,20 @@ set myproject $project set mytype $cstype set mytypeobj ::vc::fossil::import::cvs::project::rev::${cstype} set mysrcid $srcid - set myrevisions $revisions + set myitems $items set mypos {} ; # Commit location is not known yet. # Keep track of the generated changesets and of the inverse - # mapping from revisions to them. + # mapping from items to them. lappend mychangesets $self set myidmap($myid) $self - foreach r $revisions { - set key [list $cstype $id] - set myrevmap($key) $self + foreach iid $items { + set key [list $cstype $iid] + set myitemmap($key) $self lappend mytitems $key } return } @@ -89,12 +89,12 @@ method successormap {} { # NOTE / FUTURE: Possible bottleneck. array set tmp {} foreach {rev children} [$self nextmap] { foreach child $children { - # 8.5 lappend tmp($rev) {*}$myrevmap($child) - foreach cset $myrevmap($child) { + # 8.5 lappend tmp($rev) {*}$myitemmap($child) + foreach cset $myitemmap($child) { lappend tmp($rev) $cset } } set tmp($rev) [lsort -unique $tmp($rev)] } @@ -105,12 +105,12 @@ method successors {} { # NOTE / FUTURE: Possible bottleneck. set csets {} foreach {_ children} [$self nextmap] { foreach child $children { - # 8.5 lappend csets {*}$myrevmap($child) - foreach cset $myrevmap($child) { + # 8.5 lappend csets {*}$myitemmap($child) + foreach cset $myitemmap($child) { lappend csets $cset } } } return [lsort -unique $csets] @@ -120,12 +120,12 @@ method predecessormap {} { # NOTE / FUTURE: Possible bottleneck. array set tmp {} foreach {rev children} [$self premap] { foreach child $children { - # 8.5 lappend tmp($rev) {*}$myrevmap($child) - foreach cset $myrevmap($child) { + # 8.5 lappend tmp($rev) {*}$myitemmap($child) + foreach cset $myitemmap($child) { lappend tmp($rev) $cset } } set tmp($rev) [lsort -unique $tmp($rev)] } @@ -133,19 +133,19 @@ } # item -> list (item) method nextmap {} { if {[llength $mynextmap]} { return $mynextmap } - $mytypeobj successors tmp $myrevisions + $mytypeobj successors tmp $myitems set mynextmap [array get tmp] return $mynextmap } # item -> list (item) method premap {} { if {[llength $mypremap]} { return $mypremap } - $mytypeobj predecessors tmp $myrevisions + $mytypeobj predecessors tmp $myitems set mypremap [array get tmp] return $mypremap } method breakinternaldependencies {} { @@ -169,11 +169,11 @@ # Array of dependencies (parent -> child). This is pulled from # the state, and limited to successors within the changeset. array set dependencies {} - $mytypeobj internalsuccessors dependencies $myrevisions + $mytypeobj internalsuccessors dependencies $myitems if {![array size dependencies]} {return 0} ; # Nothing to break. log write 5 csets ...[$self str]....................................................... # We have internal dependencies to break. We now iterate over @@ -189,11 +189,11 @@ # CROSS position in list -> number of dependencies crossing it # DEPC dependency -> positions it crosses # List: RANGE Of the positions itself. # A dependency is a single-element map parent -> child - InitializeBreakState $myrevisions + InitializeBreakState $myitems set fragments {} set pending [list $range] set at 0 array set breaks {} @@ -222,11 +222,11 @@ set breaks($best) $cross($best) log write 6 csets "Best break @ $best, cutting [nsp $cross($best) dependency dependencies]" # Note: The value of best is an abolute location in - # myrevisions. Use the start of current to make it an + # myitems. Use the start of current to make it an # index absolute to current. set brel [expr {$best - [lindex $current 0]}] set bnext $brel ; incr bnext set fragbefore [lrange $current 0 $brel] @@ -244,18 +244,18 @@ incr at } log write 6 csets ". . .. ... ..... ........ ............." - # (*) We clear out the associated part of the myrevmap + # (*) We clear out the associated part of the myitemmap # in-memory index in preparation for new data. A simple unset # is enough, we have no symbol changesets at this time, and # thus never more than one reference in the list. - foreach r $myrevisions { - set key [list $mytype $r] - unset myrevmap($key) + foreach iid $myitems { + set key [list $mytype $iid] + unset myitemmap($key) } # Create changesets for the fragments, reusing the current one # for the first fragment. We sort them in order to allow # checking for gaps and nice messages. @@ -271,32 +271,31 @@ set laste $firste foreach fragment [lrange $fragments 1 end] { Border $fragment s e integrity assert {$laste == ($s - 1)} {Bad fragment border <$laste | $s>, gap or overlap} - set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myrevisions $s $e]] + set new [$type %AUTO% $myproject $mytype $mysrcid [lrange $myitems $s $e]] log write 4 csets "Breaking [$self str ] @ $laste, new [$new str], cutting $breaks($laste)" set laste $e } integrity assert { - $laste == ([llength $myrevisions]-1) + $laste == ([llength $myitems]-1) } {Bad fragment end @ $laste, gap, or beyond end of the range} # Put the first fragment into the current changeset, and - # update the in-memory index. We can simply (re)add the - # revisions because we cleared the previously existing - # information, see (*) above. Persistence does not matter - # here, none of the changesets has been saved to the - # persistent state yet. - - set myrevisions [lrange $myrevisions 0 $firste] - foreach r $myrevisions { - set key [list $mytype $r] - set myrevmap($key) $self + # update the in-memory index. We can simply (re)add the items + # because we cleared the previously existing information, see + # (*) above. Persistence does not matter here, none of the + # changesets has been saved to the persistent state yet. + + set myitems [lrange $myitems 0 $firste] + foreach iid $myitems { + set key [list $mytype $iid] + set myitemmap($key) $self } return 1 } @@ -309,44 +308,44 @@ state run { INSERT INTO changeset (cid, pid, type, src) VALUES ($myid, $pid, $tid, $mysrcid); } - foreach rid $myrevisions { + foreach iid $myitems { state run { INSERT INTO csrevision (cid, pos, rid) - VALUES ($myid, $pos, $rid); + VALUES ($myid, $pos, $iid); } incr pos } } return } - method timerange {} { return [$mytypeobj timerange $myrevisions] } + method timerange {} { return [$mytypeobj timerange $myitems] } method drop {} { state transaction { state run { DELETE FROM changeset WHERE cid = $myid; DELETE FROM csrevision WHERE cid = $myid; } } - foreach r $myrevisions { - set key [list $mytype $r] - unset myrevmap($key) + foreach iid $myitems { + set key [list $mytype $iid] + unset myitemmap($key) } set pos [lsearch -exact $mychangesets $self] set mychangesets [lreplace $mychangesets $pos $pos] return } typemethod split {cset args} { # As part of the creation of the new changesets specified in - # ARGS as sets of revisions, all subsets of CSET's revision - # set, CSET will be dropped from all databases, in and out of - # memory, and then destroyed. + # ARGS as sets of items, all subsets of CSET's item set, CSET + # will be dropped from all databases, in and out of memory, + # and then destroyed. # # Note: The item lists found in args are tagged items. They # have to have the same type as the changeset, being subsets # of its items. This is checked in Untag1. @@ -354,16 +353,16 @@ $cset drop $cset destroy set newcsets {} - foreach fragmentrevisions $args { + foreach fragmentitems $args { integrity assert { - [llength $fragmentrevisions] - } {Attempted to create an empty changeset, i.e. without revisions} + [llength $fragmentitems] + } {Attempted to create an empty changeset, i.e. without items} lappend newcsets [$type %AUTO% $project $cstype $cssrc \ - [Untag $fragmentrevisions $cstype]] + [Untag $fragmentitems $cstype]] } foreach c $newcsets { $c persist } return $newcsets } @@ -401,14 +400,14 @@ variable mytypeobj {} ; # Reference to the container for the # type dependent code. Derived from # mytype. variable mysrcid {} ; # Id of the metadata or symbol the cset # is based on. - variable myrevisions {} ; # List of the file level revisions, + variable myitems {} ; # List of the file level revisions, # tags, or branches in the cset, as # ids. Not tagged. - variable mytitems {} ; # As myrevisions, the tagged form. + variable mytitems {} ; # As myitems, the tagged form. variable mypremap {} ; # Dictionary mapping from the items (tagged now) # to their predecessors, also tagged. A # cache to avoid loading this from the # state more than once. variable mynextmap {} ; # Dictionary mapping from the items (tagged) @@ -653,20 +652,22 @@ return } # # ## ### ##### ######## ############# - typevariable mychangesets {} ; # List of all known changesets. - typevariable myrevmap -array {} ; # Map from items (tagged) to the - # list of changesets containing - # it. Each item can be used by - # only one changeset. - typevariable myidmap -array {} ; # Map from changeset id to changeset. - - typemethod all {} { return $mychangesets } - typemethod of {id} { return $myidmap($id) } - typemethod ofrev {id} { return $myrevmap($id) } + typevariable mychangesets {} ; # List of all known changesets. + typevariable myitemmap -array {} ; # Map from items (tagged) to + # the list of changesets + # containing it. Each item can + # be used by only one + # changeset. + typevariable myidmap -array {} ; # Map from changeset id to + # changeset. + + typemethod all {} { return $mychangesets } + typemethod of {cid} { return $myidmap($cid) } + typemethod ofrev {iid} { return $myitemmap($iid) } # # ## ### ##### ######## ############# ## Configuration pragma -hastypeinfo no ; # no type introspection