Overview
SHA1 Hash: | aa04ac9d10aab85fa43e75be859ae52c839c7ed9 |
---|---|
Date: | 2008-02-03 00:04:37 |
User: | aku |
Comment: | Extended the collection of revisions for a file with a separate blob store to manage the text ranges of revisions and their dependencies separate from the revisions. This will be used later (upcoming) to properly expand a file even if revisions were removed as irrelevant during the collection and filter passes. |
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]Added tools/cvs2fossil/lib/c2f_blobstore.tcl version [725b47dd34]
@@ -1,1 +1,155 @@ +## -*- tcl -*- +# # ## ### ##### ######## ############# ##################### +## Copyright (c) 2007 Andreas Kupries. +# +# This software is licensed as described in the file LICENSE, which +# you should have received as part of this distribution. +# +# This software consists of voluntary contributions made by many +# individuals. For exact contribution history, see the revision +# history and logs, available at http://fossil-scm.hwaci.com/fossil +# # ## ### ##### ######## ############# ##################### + +## Blob storage. Each instance stores the blob data of a single rcs +## archive file, i.e. which file, all text ranges, delta dependencies, +## and associated revisions (as object references). The data is +## persistent and used by the import pass(es) to expand the revisions +## of a file. + +# # ## ### ##### ######## ############# ##################### +## Requirements + +package require Tcl 8.4 ; # Required runtime. +package require snit ; # OO system. +package require vc::fossil::import::cvs::state ; # State storage. +package require vc::fossil::import::cvs::integrity ; # State integrity checks. +package require vc::tools::trouble ; # Error reporting. +package require vc::tools::log ; # User feedback +#package require vc::tools::misc ; # Text formatting + +# # ## ### ##### ######## ############# ##################### +## + +snit::type ::vc::fossil::import::cvs::blobstore { + # # ## ### ##### ######## ############# + ## Public API + + constructor {fid} { + set myfile $fid + array set myparent {} + array set myblob {} + return + } + + method setid {id} { + integrity assert {$myfile eq ""} {Already has an id, '$myfile'} + set myfile $id + return + } + + # Remember the file revision object for the revision REVNR. + + method add {revnr rev} { + set myblob($revnr) $rev + return + } + + # Remember that the DELTA revision is specified as a delta against + # the BASE revision. Both are specified as revision numbers. + + method delta {delta base} { + set myparent($delta) $base + return + } + + # Specify the text range in the archive file for the data of the + # revision identified by REVNR. + + method extend {revnr textrange} { + struct::list assign $textrange coff end + set clen [expr {$end - $coff}] + lappend myblob($revnr) $coff $clen + return + } + + # Write the stored information into the persistent state. + + method persist {} { + array set bids {} + state transaction { + # Phase I: Store the basic blob information. + + foreach revnr [lsort [array names myblob]] { + struct::list assign $myblob($revnr) rev coff clen + state run { + INSERT INTO blob (bid, rid, fid, coff, clen, pid) + VALUES (NULL, NULL, $myfile, $coff, $clen, NULL) + } + set current [state id] + set bids($revnr) $current + + # Ia. Set the reference to the revision of the blob, + # if applicable. We can have blobs without revisions, + # their revisions were removed as irrelevant. We need + # them however for the proper delta ordering and patch + # application when expanding a file (-> Import passes). + + set rid [$rev id] + if {$rid eq ""} continue + state run { + UPDATE blob + SET rid = $rid + WHERE bid = $current + } + } + + # Phase II: Set the parent links for deltas. + foreach revnr [array names myparent] { + set bid $bids($revnr) + set pid $bids($myparent($revnr)) + + state run { + UPDATE blob + SET pid = $pid + WHERE bid = $bid + } + } + } + return + } + + # # ## ### ##### ######## ############# + ## State + + variable myfile {} ; # Id of the file the blobs belong to. + variable myparent -array {} ; # Map delta-encoded revision numbers + # to their baseline revisions. + variable myblob -array {} ; # Map revision numbers to associated + # file revision object and text + # range. + + # # ## ### ##### ######## ############# + ## Configuration + + pragma -hastypeinfo no ; # no type introspection + pragma -hasinfo no ; # no object introspection + pragma -hastypemethods no ; # type is not relevant. + + # # ## ### ##### ######## ############# +} + +namespace eval ::vc::fossil::import::cvs { + namespace export blobstore + namespace eval blobstore { + namespace import ::vc::tools::trouble + namespace import ::vc::tools::log + namespace import ::vc::fossil::import::cvs::state + namespace import ::vc::fossil::import::cvs::integrity + } +} + +# # ## ### ##### ######## ############# ##################### +## Ready +package provide vc::fossil::import::cvs::blobstore 1.0 +return
Modified tools/cvs2fossil/lib/c2f_file.tcl from [8326ac9a4b] to [64c0d8ace6].
@@ -18,10 +18,11 @@ package require Tcl 8.4 ; # Required runtime. package require snit ; # OO system. package require struct::set ; # Set operations. package require struct::list ; # Higher order operations. +package require vc::fossil::import::cvs::blobstore ; # Blob storage. package require vc::fossil::import::cvs::file::rev ; # CVS per file revisions. package require vc::fossil::import::cvs::file::sym ; # CVS per file symbols. package require vc::fossil::import::cvs::state ; # State storage. package require vc::fossil::import::cvs::integrity ; # State integrity checks. package require vc::fossil::import::cvs::gtcore ; # Graph traversal core. @@ -41,16 +42,18 @@ set mypath $path set myusrpath $usrpath set myexecutable $executable set myproject $project set mytrunk [$myproject trunk] + set myblob [blobstore ${selfns}::%AUTO% $id] return } method setid {id} { integrity assert {$myid eq ""} {File '$mypath' already has an id, '$myid'} set myid $id + $myblob setid $id return } method id {} { return $myid } method path {} { return $mypath } @@ -94,10 +97,11 @@ foreach sym $symbols { $sym defid } state transaction { foreach rev $revisions { $rev persist } foreach sym $symbols { $sym persist } + $myblob persist } return } method drop {} { @@ -157,10 +161,21 @@ } set myaid($revnr) [$myproject defauthor $author] set myrev($revnr) [rev %AUTO% $revnr $date $state $self] + $myblob add $revnr $myrev($revnr) + + if {$next ne ""} { + # parent revision NEXT is a delta of current. + $myblob delta $next $revnr + } + foreach b $branches { + # branch child revision B is a delta of current. + $myblob delta $b $revnr + } + $self RecordBasicDependencies $revnr $next return } method defdone {} { @@ -211,10 +226,12 @@ set lod [$self GetLOD $revnr] $rev setmeta [$myproject defmeta [$lod id] $myaid($revnr) $cmid] $rev settext $textrange $rev setlod $lod + + $myblob extend $revnr $textrange # If this is revision 1.1, we have to determine whether the # file seems to have been created through 'cvs add' instead of # 'cvs import'. This can be done by looking at the un- # adulterated commit message, as CVS uses a hardwired magic @@ -575,10 +592,14 @@ variable mytrunk {} ; # Direct reference to myproject -> trunk. variable myroots {} ; # List of roots in the forest of # lod's. Object references to revisions and # branches. The latter can appear when they # are severed from their parent. + + variable myblob {} ; # Reference to the object managing the blob + # information (textrange of revisions, and + # delta dependencies) of this file. # # ## ### ##### ######## ############# ## Internal methods method RecordBranchCommits {branches} { @@ -1389,10 +1410,11 @@ # namespace import ::vc::fossil::import::cvs::file::rev # namespace import ::vc::fossil::import::cvs::file::sym namespace import ::vc::tools::misc::* namespace import ::vc::tools::trouble namespace import ::vc::tools::log + namespace import ::vc::fossil::import::cvs::blobstore namespace import ::vc::fossil::import::cvs::state namespace import ::vc::fossil::import::cvs::integrity namespace import ::vc::fossil::import::cvs::gtcore } }
Modified tools/cvs2fossil/lib/c2f_pcollrev.tcl from [1a71981488] to [e6ab3e8b4a].
@@ -143,10 +143,36 @@ coff INTEGER NOT NULL, clen INTEGER NOT NULL, UNIQUE (fid, rev) -- The DTN is unique within the revision's file. } + + # Blobs contain the information needed to extract revisions + # from rcs archive files. As such each revision has an + # associated blob. However we can have blobs without + # revisions. This happens if a logically irrelevant revision + # is removed. We may however still need its blob to correctly + # expand other revisions, both its contents and for the + # ordering. + + state extend blob { + bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + rid INTEGER REFERENCES revision, + fid INTEGER NOT NULL REFERENCES file, -- File owning blob. + + -- The text content is an (offset,length) pair into the + -- rcs archive. For deltas we additionally refer to the + -- parent blob the delta is made against. + + coff INTEGER NOT NULL, + clen INTEGER NOT NULL, + pid INTEGER REFERENCES blob, + + UNIQUE (rid) + } { fid } + # Index on owning file to collect all blobs of a file when the + # time for its expansion comes. state extend optype { oid INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL, UNIQUE(name)
Modified tools/cvs2fossil/lib/pkgIndex.tcl from [bb5f385c20] to [a73808ace1].
@@ -2,10 +2,11 @@ ## Package management. ## Index of the local packages required by cvs2fossil # # ## ### ##### ######## ############# ##################### if {![package vsatisfies [package require Tcl] 8.4]} return package ifneeded vc::fossil::import::cvs 1.0 [list source [file join $dir cvs2fossil.tcl]] +package ifneeded vc::fossil::import::cvs::blobstore 1.0 [list source [file join $dir c2f_blobstore.tcl]] package ifneeded vc::fossil::import::cvs::file 1.0 [list source [file join $dir c2f_file.tcl]] package ifneeded vc::fossil::import::cvs::file::rev 1.0 [list source [file join $dir c2f_frev.tcl]] package ifneeded vc::fossil::import::cvs::file::sym 1.0 [list source [file join $dir c2f_fsym.tcl]] package ifneeded vc::fossil::import::cvs::file::trunk 1.0 [list source [file join $dir c2f_ftrunk.tcl]] package ifneeded vc::fossil::import::cvs::fossil 1.0 [list source [file join $dir c2f_fossil.tcl]]