Overview
SHA1 Hash: | 0fcfbf78284063c4832621645afa080b30185887 |
---|---|
Date: | 2007-11-29 07:24:39 |
User: | aku |
Comment: | 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. |
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 [ebc1cdf1d1] to [2ef585bdd8].
@@ -49,11 +49,15 @@ # Keep track of the generated changesets and of the inverse # mapping from revisions to them. lappend mychangesets $self set myidmap($myid) $self - foreach r $revisions { lappend myrevmap($r) $self } + foreach r $revisions { + set key [list $cstype $id] + set myrevmap($key) $self + lappend mytitems $key + } return } method str {} { set str "<" @@ -68,11 +72,11 @@ append str "$mytype ${myid}${detail}>" return $str } method id {} { return $myid } - method revisions {} { return $myrevisions } + method revisions {} { return $mytitems } method data {} { return [list $myproject $mytype $mysrcid] } delegate method bysymbol to mytypeobj delegate method byrevision to mytypeobj delegate method isbranch to mytypeobj @@ -79,11 +83,11 @@ delegate method istag to mytypeobj method setpos {p} { set mypos $p ; return } method pos {} { return $mypos } - # result = dict (revision -> list (changeset)) + # result = dict (item -> list (changeset)) method successormap {} { # NOTE / FUTURE: Possible bottleneck. array set tmp {} foreach {rev children} [$self nextmap] { foreach child $children { @@ -95,10 +99,11 @@ set tmp($rev) [lsort -unique $tmp($rev)] } return [array get tmp] } + # result = list (changeset) method successors {} { # NOTE / FUTURE: Possible bottleneck. set csets {} foreach {_ children} [$self nextmap] { foreach child $children { @@ -109,11 +114,11 @@ } } return [lsort -unique $csets] } - # result = dict (revision -> list (changeset)) + # result = dict (item -> list (changeset)) method predecessormap {} { # NOTE / FUTURE: Possible bottleneck. array set tmp {} foreach {rev children} [$self premap] { foreach child $children { @@ -125,19 +130,19 @@ set tmp($rev) [lsort -unique $tmp($rev)] } return [array get tmp] } - # revision -> list (revision) + # item -> list (item) method nextmap {} { if {[llength $mynextmap]} { return $mynextmap } $mytypeobj successors tmp $myrevisions set mynextmap [array get tmp] return $mynextmap } - # revision -> list (revision) + # item -> list (item) method premap {} { if {[llength $mypremap]} { return $mypremap } $mytypeobj predecessors tmp $myrevisions set mypremap [array get tmp] return $mypremap @@ -244,11 +249,14 @@ # (*) We clear out the associated part of the myrevmap # 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 { unset myrevmap($r) } + foreach r $myrevisions { + set key [list $mytype $r] + unset myrevmap($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. @@ -282,11 +290,14 @@ # 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 { lappend myrevmap($r) $self } + foreach r $myrevisions { + set key [list $mytype $r] + set myrevmap($key) $self + } return 1 } method persist {} { @@ -319,16 +330,12 @@ DELETE FROM changeset WHERE cid = $myid; DELETE FROM csrevision WHERE cid = $myid; } } foreach r $myrevisions { - if {[llength $myrevmap($r)] == 1} { - unset myrevmap($r) - } else { - set pos [lsearch -exact $myrevmap($r) $self] - set myrevmap($r) [lreplace $myrevmap($r) $pos $pos] - } + set key [list $mytype $r] + unset myrevmap($key) } set pos [lsearch -exact $mychangesets $self] set mychangesets [lreplace $mychangesets $pos $pos] return } @@ -336,10 +343,14 @@ 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. + # + # 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. struct::list assign [$cset data] project cstype cssrc $cset drop $cset destroy @@ -347,11 +358,12 @@ set newcsets {} foreach fragmentrevisions $args { integrity assert { [llength $fragmentrevisions] } {Attempted to create an empty changeset, i.e. without revisions} - lappend newcsets [$type %AUTO% $project $cstype $cssrc $fragmentrevisions] + lappend newcsets [$type %AUTO% $project $cstype $cssrc \ + [Untag $fragmentrevisions $cstype]] } foreach c $newcsets { $c persist } return $newcsets } @@ -359,10 +371,20 @@ typemethod strlist {changesets} { return [join [struct::list map $changesets [myproc ID]]] } proc ID {cset} { $cset str } + + proc Untag {taggeditems cstype} { + return [struct::list map $taggeditems [myproc Untag1 $cstype]] + } + + proc Untag1 {cstype theitem} { + struct::list assign $theitem t i + integrity assert {$cstype eq $t} {Item $i's type is '$t', expected '$cstype'} + return $i + } # # ## ### ##### ######## ############# ## State variable myid {} ; # Id of the cset for the persistent @@ -379,20 +401,22 @@ 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 in - # the cset. - variable mypremap {} ; # Dictionary mapping from the revisions - # to their predecessors. Cache to avoid - # loading this from the state more than - # once. - variable mynextmap {} ; # Dictionary mapping from the revisions - # to their successors. Cache to avoid - # loading this from the state more than - # once. + variable myrevisions {} ; # List of the file level revisions, + # tags, or branches in the cset, as + # ids. Not tagged. + variable mytitems {} ; # As myrevisions, 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) + # to their successors (also tagged). A + # cache to avoid loading this from the + # state more than once. variable mypos {} ; # Commit position of the changeset, if # known. # # ## ### ##### ######## ############# ## Internal methods @@ -630,18 +654,14 @@ } # # ## ### ##### ######## ############# typevariable mychangesets {} ; # List of all known changesets. - typevariable myrevmap -array {} ; # Map from revisions to the list - # of changesets containing - # it. NOTE: While only one - # revision changeset can contain - # the revision, there can - # however also be one or more - # additional symbol changesets - # which use it, hence a list. + 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) }