@@ -30,9 +30,9 @@
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]
@@ -43,18 +43,18 @@
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
}
@@ -90,10 +90,10 @@
# 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)]
@@ -106,10 +106,10 @@
# 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
}
}
}
@@ -121,10 +121,10 @@
# 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)]
@@ -134,17 +134,17 @@
# 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
}
@@ -170,9 +170,9 @@
# 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].......................................................
@@ -190,9 +190,9 @@
# 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
@@ -223,9 +223,9 @@
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
@@ -245,16 +245,16 @@
}
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
@@ -272,30 +272,29 @@
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
}
@@ -310,20 +309,20 @@
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 {
@@ -330,11 +329,11 @@
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
@@ -341,11 +340,11 @@
}
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.
@@ -355,14 +354,14 @@
$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
@@ -402,12 +401,12 @@
# 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.
@@ -654,18 +653,20 @@
}
# # ## ### ##### ######## #############
- 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