Differences From:
File
tools/cvs2fossil/lib/c2f_pinitcsets.tcl
part of check-in
[08ebab80cd]
- Rewrote the algorithm for breaking internal dependencies to my liking. The complex part handling multiple splits has moved from the pass code to the changeset class itself, reusing the state computed for the first split. The state is a bit more complex to allow for its incremental update after a break has been done. Factored major pieces into separate procedures to keep the highlevel code readable. Added lots of official log output to help debugging in case of trouble.
by
aku on
2007-11-10 23:44:29.
[view]
To:
File
tools/cvs2fossil/lib/c2f_pinitcsets.tcl
part of check-in
[24c0b662de]
- Reworked the in-memory storage of changesets in pass 5 and supporting classes, and added loading of changesets from the persistent state for when the pass is skipped.
by
aku on
2007-11-13 05:09:07.
[view]
@@ -99,9 +99,26 @@
typemethod load {} {
# Pass manager interface. Executed to load data computed by
# this pass into memory when this pass is skipped instead of
# executed.
- # /TODO/load changesets
+
+ state reading changeset
+ state reading csrevision
+ state reading cstype
+
+ foreach {id pid cstype srcid} [state run {
+ SELECT C.cid, C.pid, C.type, C.src
+ FROM changeset C
+ ORDER BY C.cid
+ }] {
+ set r [project::rev %AUTO% [repository projectof $pid] $cstype $srcid [state run {
+ SELECT C.rid
+ FROM csrevision C
+ WHERE C.cid = $id
+ ORDER BY C.pos
+ }]]
+ $r setid $id
+ }
project::rev getcstypes
return
}
@@ -109,14 +126,13 @@
typemethod run {} {
# Pass manager interface. Executed to perform the
# functionality of the pass.
- set csets {}
state transaction {
- CreateRevisionChangesets csets ; # Group file revisions into csets.
- BreakInternalDependencies csets ; # Split the csets based on internal conflicts.
- CreateSymbolChangesets csets ; # Create csets for tags and branches.
- PersistTheChangesets $csets
+ CreateRevisionChangesets ; # Group file revisions into csets.
+ BreakInternalDependencies ; # Split the csets based on internal conflicts.
+ CreateSymbolChangesets ; # Create csets for tags and branches.
+ PersistTheChangesets
}
return
}
@@ -133,11 +149,9 @@
# # ## ### ##### ######## #############
## Internal methods
- proc CreateRevisionChangesets {cv} {
- upvar 1 $cv csets
-
+ proc CreateRevisionChangesets {} {
log write 3 initcsets {Create changesets based on revisions}
# To get the initial of changesets we first group all file
# level revisions using the same meta data entry together. As
@@ -175,9 +189,9 @@
if {$lastmeta != $mid} {
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
- lappend csets [project::rev %AUTO% $p rev $lastmeta $revisions]
+ project::rev %AUTO% $p rev $lastmeta $revisions
set revisions {}
}
set lastmeta $mid
set lastproject $pid
@@ -187,18 +201,16 @@
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
- lappend csets [project::rev %AUTO% $p rev $lastmeta $revisions]
+ project::rev %AUTO% $p rev $lastmeta $revisions
}
log write 4 initcsets "Created [nsp $n {revision changeset}]"
return
}
- proc CreateSymbolChangesets {cv} {
- upvar 1 $cv csets
-
+ proc CreateSymbolChangesets {} {
log write 3 initcsets {Create changesets based on symbols}
# Tags and branches induce changesets as well, containing the
# revisions they are attached to (tags), or spawned from
@@ -223,9 +235,9 @@
if {$lastsymbol != $sid} {
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
- lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
+ project::rev %AUTO% $p sym $lastsymbol $revisions
set revisions {}
}
set lastsymbol $sid
set lastproject $pid
@@ -235,9 +247,9 @@
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
- lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
+ project::rev %AUTO% $p sym $lastsymbol $revisions
}
set lastsymbol {}
set lasproject {}
@@ -253,9 +265,9 @@
if {$lastsymbol != $sid} {
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
- lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
+ project::rev %AUTO% $p sym $lastsymbol $revisions
set revisions {}
}
set lastsymbol $sid
set lastproject $pid
@@ -265,18 +277,16 @@
if {[llength $revisions]} {
incr n
set p [repository projectof $lastproject]
- lappend csets [project::rev %AUTO% $p sym $lastsymbol $revisions]
+ project::rev %AUTO% $p sym $lastsymbol $revisions
}
log write 4 initcsets "Created [nsp $n {symbol changeset}]"
return
}
- proc BreakInternalDependencies {cv} {
- upvar 1 $cv csets
-
+ proc BreakInternalDependencies {} {
# This code operates on the revision changesets created by
# 'CreateRevisionChangesets'. As such it has to follow after
# it, before the symbol changesets are made. The changesets
# are inspected for internal conflicts and any such are broken
@@ -284,24 +294,24 @@
# fragments. The results are changesets which have no internal
# dependencies, only external ones.
log write 3 initcsets {Break internal dependencies}
- set old [llength $csets]
+ set old [llength [project::rev all]]
- foreach cset $csets {
- $cset breakinternaldependencies csets
+ foreach cset [project::rev all] {
+ $cset breakinternaldependencies
}
- set n [expr {[llength $csets] - $old}]
+ set n [expr {[llength [project::rev all]] - $old}]
log write 4 initcsets "Created [nsp $n {additional revision changeset}]"
log write 4 initcsets Ok.
return
}
- proc PersistTheChangesets {csets} {
- log write 3 initcsets "Saving [nsp [llength $csets] {initial changeset}] to the persistent state"
+ proc PersistTheChangesets {} {
+ log write 3 initcsets "Saving [nsp [llength [project::rev all]] {initial changeset}] to the persistent state"
- foreach cset $csets {
+ foreach cset [project::rev all] {
$cset persist
}
log write 4 initcsets Ok.