Overview
SHA1 Hash: | 67c24820c7b09159891f4e2fd32053ab6f16c9be |
---|---|
Date: | 2007-10-14 01:58:07 |
User: | aku |
Comment: | Reworked the whole handling of meta data (author, commit message, plus project/branch information), so that revisions now store only the meta id, everything else is stored centrally. All the relevant pieces (author, cmessage, symbols, projects) now also get numeric ids assigned early instead of when being saved to the state. Project ids are loaded from the state now too. |
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_file.tcl from [f6e7796985] to [2626e348fd].
@@ -66,11 +66,11 @@ ## Implement the sink method begin {} {#ignore} method sethead {revnr} { - set myhead $revnr + set myheadrevnr $revnr return } method setprincipalbranch {branchnr} { set myprincipal $branchnr @@ -101,18 +101,18 @@ # We do nothing at the boundary of admin and revision data } method def {revnr date author state next branches} { $self RecordBranchCommits $branches - $myproject author $author if {[info exists myrev($revnr)]} { trouble fatal "File $mypath contains duplicate definitions for revision $revnr." return } - set myrev($revnr) [rev %AUTO% $revnr $date $author $state $self] + set myaid($revnr) [$myproject defauthor $author] + set myrev($revnr) [rev %AUTO% $revnr $date $state $self] RecordBasicDependencies $revnr $next return } @@ -129,17 +129,16 @@ return } method setdesc {d} {# ignore} - method extend {revnr commitmsg deltarange} { - set cm [string trim $commitmsg] - $myproject cmessage $cm + method extend {revnr commitmsg textrange} { + set cmid [$myproject defcmessage [string trim $commitmsg]] set rev $myrev($revnr) - if {[$rev hascommitmsg]} { + if {[$rev hasmeta]} { # Apparently repositories exist in which the delta data # for revision 1.1 is provided several times, at least # twice. The actual cause of this duplication is not # known. Speculation centers on RCS/CVS bugs, or from # manual edits of the repository which borked the @@ -152,19 +151,18 @@ log write 1 file "In file $mypath : Duplicate delta data for revision $revnr" log write 1 file "Ignoring the duplicate" return } - # Extend the revision with the new information. The revision - # object uses this to complete its meta data set. - - $rev setcommitmsg $cm - $rev settext $deltarange - - if {![rev istrunkrevnr $revnr]} { - $rev setbranchname [[$self Rev2Branch $revnr] name] + if {[rev istrunkrevnr $revnr]} { + set branchid {} + } else { + set branchid [[$self Rev2Branch $revnr] id] } + + $rev setmeta [$myproject defmeta $branchid $myaid($revnr) $cmid] + $rev settext $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 @@ -196,11 +194,16 @@ variable myrev -array {} ; # Maps revision number to the # associated revision object. variable myrevisions {} ; # Same as myrev, but a list, # giving us the order of # revisions. - variable myhead {} ; # Head revision (revision number) + variable myaid -array {} ; # Map revision numbers to the id + # of the author who committed + # it. This is later aggregated + # with commit message, branch name + # and project id for a meta id. + variable myheadrevnr {} ; # Head revision (revision number) variable myprincipal {} ; # Principal branch (branch number). # Contrary to the name this is the # default branch. variable mydependencies {} ; # Dictionary parent -> child, # records primary dependencies. @@ -225,13 +228,10 @@ # order of definition. This also defines # their order of creation, which is the # reverse of definition. I.e. a smaller # number means 'Defined earlier', means # 'Created later'. - - ### TODO ### - ### RCS mode info (kb, kkb, ...) # # ## ### ##### ######## ############# ## Internal methods method RecordBranchCommits {branches} {
Modified tools/cvs2fossil/lib/c2f_frev.tcl from [a8af3a8bac] to [6007a4dcd0].
@@ -23,27 +23,24 @@ snit::type ::vc::fossil::import::cvs::file::rev { # # ## ### ##### ######## ############# ## Public API - constructor {revnr date author state thefile} { + constructor {revnr date state thefile} { set myrevnr $revnr set mydate $date set myorigdate $date - set myauthor $author set mystate $state set myfile $thefile return } # Basic pieces ________________________ - method hascommitmsg {} { return $myhascm } - - method setcommitmsg {cm} { set mycommitmsg $cm ; set myhascm 1 ; return } - method settext {text} { set mytext $text ; return } - method setbranchname {name} { set mybranchname $name ; return } + method hasmeta {} { return [expr {$mymetaid ne ""}] } + method setmeta {meta} { set mymetaid $meta ; return } + method settext {text} { set mytext $text ; return } method revnr {} { return $myrevnr } # Basic parent/child linkage __________ @@ -162,20 +159,21 @@ variable myrevnr {} ; # Revision number of the revision. variable mydate {} ; # Timestamp of the revision, seconds since epoch variable myorigdate {} ; # Original unmodified timestamp. variable mystate {} ; # State of the revision. variable myfile {} ; # Ref to the file object the revision belongs to. - variable myhascm 0 ; # Bool flag, set when the commit msg was set. variable mytext {} ; # Range of the (delta) text for this revision in the file. - # The meta data block used later to group revisions into changesets. - # The project name factors into this as well, but is not stored - # here. The name is acessible via myfile's project. - - variable myauthor {} ; # Name of the user who committed the revision. - variable mycommitmsg {} ; # The message entered as part of the commit. - variable mybranchname {} ; # The name of the branch the revision was committed on. + variable mymetaid {} ; # Id of the meta data group the revision + # belongs to. This is later used to put + # the file revisions into preliminary + # changesets (aka project revisions). + # This id encodes 4 pieces of data, + # namely: the project and branch the + # revision was committed to, the author + # who did the commit, and the message + # used. # Basic parent/child linkage (lines of development) variable myparent {} ; # Ref to parent revision object. Link required because of # ; # 'cvsadmin -o', which can create arbitrary gaps in the
Modified tools/cvs2fossil/lib/c2f_fsym.tcl from [f9d277d79e] to [64ff544fa2].
@@ -41,10 +41,11 @@ } # Symbol acessor methods. delegate method name to mysymbol + delegate method id to mysymbol # Branch acessor methods. method setchildrevnr {revnr} { if {$mybranchchildrevnr ne ""} { trouble internal "Child already defined" }
Modified tools/cvs2fossil/lib/c2f_pcollrev.tcl from [7b2a655d25] to [47f6b87c0b].
@@ -150,14 +150,13 @@ } state writing meta { mid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, pid INTEGER NOT NULL REFERENCES project, -- project the commit was on - bid INTEGER NOT NULL REFERENCES symbol, -- branch the commit was on + bid INTEGER REFERENCES symbol, -- branch the commit was on, NULL for :trunk: aid INTEGER NOT NULL REFERENCES author, cid INTEGER NOT NULL REFERENCES cmessage, - UNIQUE (pid, bid, aid, cid) } # Author and commit message information is fully global, # i.e. per repository.
Modified tools/cvs2fossil/lib/c2f_project.tcl from [6a6663cbeb] to [821db50884].
@@ -40,10 +40,12 @@ method printbase {} { if {$mybase eq ""} {return <Repository>} return $mybase } + method setid {id} { set myid $id ; return } + method addfile {rcs usr executable} { set myfiles($rcs) [list $usr $executable] return } @@ -53,16 +55,21 @@ method files {} { return [TheFiles] } - delegate method author to myrepository - delegate method cmessage to myrepository + delegate method defauthor to myrepository + delegate method defcmessage to myrepository + + method defmeta {bid aid cid} { + return [$myrepository defmeta $myid $bid $aid $cid] + } method getsymbol {name} { if {![info exists mysymbols($name)]} { - set mysymbols($name) [sym %AUTO% $name] + set mysymbols($name) \ + [sym %AUTO% $name [$myrepository defsymbol $myid $name]] } return $mysymbols($name) } # pass I persistence @@ -73,20 +80,20 @@ state run { INSERT INTO project (pid, name) VALUES (NULL, $mybase); } - set pid [state id] + set myid [state id] # Then all files, with proper backreference to their # project. foreach {rcs item} [array get myfiles] { struct::list assign $item usr executable state run { - INSERT INTO file (fid, pid, name, visible, exec) - VALUES (NULL, $pid, $rcs, $usr, $executable); + INSERT INTO file (fid, pid, name, visible, exec) + VALUES (NULL, $myid, $rcs, $usr, $executable); } } } return } @@ -104,10 +111,11 @@ # # ## ### ##### ######## ############# ## State variable mybase {} ; # Project directory + variable myid {} ; # Project id in the persistent state. variable myfiles -array {} ; # Maps rcs archive to their user files. variable myfobj {} ; # File objects for the rcs archives variable myrepository {} ; # Repository the prject belongs to. variable mysymbols -array {} ; # Map symbol names to project-level symbol objects.
Modified tools/cvs2fossil/lib/c2f_psym.tcl from [30d811a682] to [e2a62e00ad].
@@ -23,21 +23,26 @@ snit::type ::vc::fossil::import::cvs::project::sym { # # ## ### ##### ######## ############# ## Public API - constructor {name} { + constructor {name id} { set myname $name + set myid $id return } - method name {} { return $myname } + method name {} { return $myname } + method id {} { return $myid } # # ## ### ##### ######## ############# ## State - variable myname {} + variable myname {} ; # The symbol's name + variable myid {} ; # Repository wide numeric id of the symbol. + # This implicitly encodes the project as + # well. # # ## ### ##### ######## ############# ## Internal methods # # ## ### ##### ######## #############
Modified tools/cvs2fossil/lib/c2f_repository.tcl from [0384f35a62] to [ef903ed612].
@@ -70,18 +70,42 @@ } } return } - typemethod author {a} { - set myauthor($a) "" - return - } - - typemethod cmessage {cm} { - set mycmsg($cm) "" - return + typemethod defauthor {a} { + if {![info exists myauthor($a)]} { + set myauthor($a) [incr myauthorcnt] + log write 6 repository "author '$a' = $myauthor($a)" + } + return $myauthor($a) + } + + typemethod defcmessage {cm} { + if {![info exists mycmsg($cm)]} { + set mycmsg($cm) [incr mycmsgcnt] + log write 6 repository "cmessage '$cm' = $mycmsg($cm)" + } + return $mycmsg($cm) + } + + typemethod defsymbol {pid name} { + set key [list $pid $name] + if {![info exists mysymbol($key)]} { + set mysymbol($key) [incr mysymbolcnt] + log write 6 repository "symbol ($key) = $mysymbol($key)" + } + return $mysymbol($key) + } + + typemethod defmeta {pid bid aid cid} { + set key [list $pid $bid $aid $cid] + if {![info exists mymeta($key)]} { + set mymeta($key) [incr mymetacnt] + log write 6 repository "meta ($key) = $mymeta($key)" + } + return $mymeta($key) } # pass I results typemethod printstatistics {} { set prlist [TheProjects] @@ -141,10 +165,11 @@ foreach {pid name} [state run { SELECT pid, name FROM project ; }] { lappend myprojpaths $name lappend myprojects [set pr($pid) [project %AUTO% $name $type]] + $pr($pid) setid $pid } foreach {fid pid name visible exec} [state run { SELECT fid, pid, name, visible, exec FROM file ; }] { $pr($pid) addfile $name $visible $exec @@ -163,23 +188,42 @@ # pass II persistence typemethod persistrev {} { state transaction { SaveAuthors SaveCommitMessages + # TODO: Save symbols of all projects (before the revisions + # in the projects, as they are referenced by the meta + # tuples) + SaveMeta foreach p [TheProjects] { $p persistrev } } return } # # ## ### ##### ######## ############# ## State typevariable mybase {} ; # Base path to CVS repository. - typevariable myprojpaths {} ; # Paths to all declared projects, relative to mybase. - typevariable myprojects {} ; # Objects for all declared projects. - typevariable myauthor -array {} ; # Names of all authors found, later with id. - typevariable mycmsg -array {} ; # All commit messages found, later with id. + typevariable myprojpaths {} ; # List of paths to all declared + # projects, relative to mybase. + typevariable myprojects {} ; # List of objects for all + # declared projects. + typevariable myauthor -array {} ; # Names of all authors found, + # maps to their ids. + typevariable myauthorcnt 0 ; # Counter for author ids. + typevariable mycmsg -array {} ; # All commit messages found, + # maps to their ids. + typevariable mycmsgcnt 0 ; # Counter for message ids. + typevariable mymeta -array {} ; # Maps all meta data tuples + # (project, branch, author, + # cmessage) to their ids. + typevariable mymetacnt 0 ; # Counter for meta ids. + typevariable mysymbol -array {} ; # Map symbols identified by + # project and name to their + # id. This information is not + # saved directly. + typevariable mysymbolcnt 0 ; # Counter for symbol ids. # # ## ### ##### ######## ############# ## Internal methods proc .BaseLength {p} { @@ -237,30 +281,46 @@ return $res } proc SaveAuthors {} { ::variable myauthor - foreach a [lsort -dict [array names myauthor]] { + foreach {name aid} [array get myauthor] { state run { - INSERT INTO author (aid, name) - VALUES (NULL, $a); - } - # Save id for use by the project/file persistence code. - set myauthor($a) [state id] + INSERT INTO author ( aid, name) + VALUES ($aid, $name); + } } return } proc SaveCommitMessages {} { ::variable mycmsg - foreach t [lsort -dict [array names mycmsg]] { + foreach {text cid} [array get mycmsg] { state run { - INSERT INTO cmessage (cid, text) - VALUES (NULL, $t); + INSERT INTO cmessage ( cid, text) + VALUES ($cid, $text); } - # Save id for use by the project/file persistence code. - set mycmsg($t) [state id] + } + return + } + + proc SaveMeta {} { + ::variable mymeta + foreach {key mid} [array get mymeta] { + struct::list assign $key pid bid aid cid + if {$bid eq ""} { + # Trunk. Encoded as NULL. + state run { + INSERT INTO meta ( mid, pid, bid, aid, cid) + VALUES ($mid, $pid, NULL, $aid, $cid); + } + } else { + state run { + INSERT INTO meta ( mid, pid, bid, aid, cid) + VALUES ($mid, $pid, $bid, $aid, $cid); + } + } } return } # # ## ### ##### ######## #############