fdbc01df95 2007-10-06 aku: ## -*- tcl -*- fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# ##################### fdbc01df95 2007-10-06 aku: ## Copyright (c) 2007 Andreas Kupries. fdbc01df95 2007-10-06 aku: # fdbc01df95 2007-10-06 aku: # This software is licensed as described in the file LICENSE, which fdbc01df95 2007-10-06 aku: # you should have received as part of this distribution. fdbc01df95 2007-10-06 aku: # fdbc01df95 2007-10-06 aku: # This software consists of voluntary contributions made by many fdbc01df95 2007-10-06 aku: # individuals. For exact contribution history, see the revision fdbc01df95 2007-10-06 aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# ##################### fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: ## Pass II. This pass parses the colected rcs archives and extracts fdbc01df95 2007-10-06 aku: ## all the information they contain (revisions, and symbols). fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# ##################### fdbc01df95 2007-10-06 aku: ## Requirements fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: package require Tcl 8.4 ; # Required runtime. fdbc01df95 2007-10-06 aku: package require snit ; # OO system. fdbc01df95 2007-10-06 aku: package require fileutil::traverse ; # Directory traversal. fdbc01df95 2007-10-06 aku: package require fileutil ; # File & path utilities. fdbc01df95 2007-10-06 aku: package require vc::tools::trouble ; # Error reporting. fdbc01df95 2007-10-06 aku: package require vc::tools::log ; # User feedback. fdbc01df95 2007-10-06 aku: package require vc::fossil::import::cvs::pass ; # Pass management. fdbc01df95 2007-10-06 aku: package require vc::fossil::import::cvs::repository ; # Repository management. 8a93ffa9c1 2007-10-06 aku: package require vc::fossil::import::cvs::state ; # State storage. 8a93ffa9c1 2007-10-06 aku: package require vc::rcs::parser ; # Rcs archive data extraction. fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# ##################### fdbc01df95 2007-10-06 aku: ## Register the pass with the management fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: vc::fossil::import::cvs::pass define \ fdbc01df95 2007-10-06 aku: CollectRev \ fdbc01df95 2007-10-06 aku: {Collect revisions and symbols} \ fdbc01df95 2007-10-06 aku: ::vc::fossil::import::cvs::pass::collrev fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# ##################### fdbc01df95 2007-10-06 aku: ## fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: snit::type ::vc::fossil::import::cvs::pass::collrev { fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# fdbc01df95 2007-10-06 aku: ## Public API fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: typemethod setup {} { fdbc01df95 2007-10-06 aku: # Define names and structure of the persistent state of this fdbc01df95 2007-10-06 aku: # pass. fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state reading project fdbc01df95 2007-10-06 aku: state reading file fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # We deal with per project and per file data, the first fdbc01df95 2007-10-06 aku: # collated from the second. fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # Per file we have general information, ..., and then fdbc01df95 2007-10-06 aku: # revisions and symbols. The latter can be further separated fdbc01df95 2007-10-06 aku: # into tags and branches. At project level the per-file fdbc01df95 2007-10-06 aku: # symbols information is merged. fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # File level ... adf168e23e 2007-10-24 aku: # Revisions, Branches, Tags fdbc01df95 2007-10-06 aku: # adf168e23e 2007-10-24 aku: # Pseudo class hierarchy adf168e23e 2007-10-24 aku: # Tag <- Symbol <- Event adf168e23e 2007-10-24 aku: # Branch <- Symbol <- Event adf168e23e 2007-10-24 aku: # Revision <- Event fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing revision { 2c08006d9d 2007-10-25 aku: -- Revisions. Identified by a global numeric id each 2c08006d9d 2007-10-25 aku: -- belongs to a single file, identified by its id. It 2c08006d9d 2007-10-25 aku: -- further has a dotted revision number (DTN). 2c08006d9d 2007-10-25 aku: -- 2c08006d9d 2007-10-25 aku: -- Constraint: The dotted revision number is unique within 2c08006d9d 2007-10-25 aku: -- the file. See end of definition. 2c08006d9d 2007-10-25 aku: adf168e23e 2007-10-24 aku: rid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 2c08006d9d 2007-10-25 aku: fid INTEGER NOT NULL REFERENCES file, -- File owning revision. 2c08006d9d 2007-10-25 aku: rev TEXT NOT NULL, -- Dotted Rev Number. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- All revisions belong to a line-of-development, 2c08006d9d 2007-10-25 aku: -- identified by a symbol (project level). During data 2c08006d9d 2007-10-25 aku: -- collection it was a file-level branch symbol. 2c08006d9d 2007-10-25 aku: -- 2c08006d9d 2007-10-25 aku: -- Constraint: All the LOD symbols are in the same project 2c08006d9d 2007-10-25 aku: -- as the file itself. This cannot be 2c08006d9d 2007-10-25 aku: -- expressed in CREATE TABLE syntax. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: lod INTEGER NOT NULL REFERENCES symbol, -- Line of development 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- The revisions in a file are organized in a forest of 2c08006d9d 2007-10-25 aku: -- trees, with the main lines defined through the parent / 2c08006d9d 2007-10-25 aku: -- child references. A revision without a parent is the 2c08006d9d 2007-10-25 aku: -- root of a tree, and a revision without a child is a 2c08006d9d 2007-10-25 aku: -- leaf. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- Constraints: All revisions coupled through parent/child 2c08006d9d 2007-10-25 aku: -- refer to the same LOD symbol. The parent 2c08006d9d 2007-10-25 aku: -- of a child of X is X. The child of a 2c08006d9d 2007-10-25 aku: -- parent of X is X. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: parent INTEGER REFERENCES revision, 2c08006d9d 2007-10-25 aku: child INTEGER REFERENCES revision, 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- The representation of a branch in a tree is the 2c08006d9d 2007-10-25 aku: -- exception to the three constraints above. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- The beginning of a branch is represented by a non-NULL 2c08006d9d 2007-10-25 aku: -- bparent of a revision. This revision B is the first on 2c08006d9d 2007-10-25 aku: -- the branch. Its parent P is the revision the branch is 2c08006d9d 2007-10-25 aku: -- rooted in, and it is not the child of P. B and P refer 2c08006d9d 2007-10-25 aku: -- to different LOD symbols. The bparent of B is also its 2c08006d9d 2007-10-25 aku: -- LOD, and the LOD of its children. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: bparent INTEGER REFERENCES symbol, 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- Lastly we keep information is about non-trunk default 2c08006d9d 2007-10-25 aku: -- branches (NTDB) in the revisions. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- All revisions on the NTDB have 'isdefault' TRUE, 2c08006d9d 2007-10-25 aku: -- everyone else FALSE. The last revision X on the NTDB 2c08006d9d 2007-10-25 aku: -- which is still considered to be on the trunk as well 2c08006d9d 2007-10-25 aku: -- has a non-NULL 'dbchild' which refers to the root of 2c08006d9d 2007-10-25 aku: -- the trunk. The root also has a non-NULL dbparent 2c08006d9d 2007-10-25 aku: -- refering to X. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: isdefault INTEGER NOT NULL, 2c08006d9d 2007-10-25 aku: dbparent INTEGER REFERENCES revision, 2c08006d9d 2007-10-25 aku: dbchild INTEGER REFERENCES revision, 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- The main payload of the revision are the date/time it 2c08006d9d 2007-10-25 aku: -- was entered, its state, operation (= type/class), text 2c08006d9d 2007-10-25 aku: -- content, and meta data (author, log message, branch, 2c08006d9d 2007-10-25 aku: -- project). The last is encoded as single id, see table 2c08006d9d 2007-10-25 aku: -- 'meta'. The date/time is given in seconds since the 2c08006d9d 2007-10-25 aku: -- epoch, for easy comparison. The text content is an 2c08006d9d 2007-10-25 aku: -- (offset,length) pair into the rcs archive. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: op INTEGER NOT NULL, 2c08006d9d 2007-10-25 aku: date INTEGER NOT NULL, 2c08006d9d 2007-10-25 aku: state TEXT NOT NULL, 2c08006d9d 2007-10-25 aku: mid INTEGER NOT NULL REFERENCES meta, 2c08006d9d 2007-10-25 aku: coff INTEGER NOT NULL, 2c08006d9d 2007-10-25 aku: clen INTEGER NOT NULL, 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: UNIQUE (fid, rev) -- The DTN is unique within the revision's file. fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing tag { adf168e23e 2007-10-24 aku: tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, adf168e23e 2007-10-24 aku: fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to adf168e23e 2007-10-24 aku: lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) adf168e23e 2007-10-24 aku: adf168e23e 2007-10-24 aku: sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the tag adf168e23e 2007-10-24 aku: adf168e23e 2007-10-24 aku: rev INTEGER NOT NULL REFERENCES revision -- The revision being tagged. fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing branch { adf168e23e 2007-10-24 aku: bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, adf168e23e 2007-10-24 aku: fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to adf168e23e 2007-10-24 aku: lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) adf168e23e 2007-10-24 aku: fdbc01df95 2007-10-06 aku: sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch adf168e23e 2007-10-24 aku: fdbc01df95 2007-10-06 aku: root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from fdbc01df95 2007-10-06 aku: first INTEGER REFERENCES revision, -- First revision committed to the branch fdbc01df95 2007-10-06 aku: bra TEXT NOT NULL -- branch number fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # Project level ... fdbc01df95 2007-10-06 aku: # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk fdbc01df95 2007-10-06 aku: # fdbc01df95 2007-10-06 aku: # pTrunk <- pLineOfDevelopment fdbc01df95 2007-10-06 aku: # pBranch <- pSymbol, pLineOfDevelopment fdbc01df95 2007-10-06 aku: # pTag <- pSymbol, pLineOfDevelopment fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing symbol { fdbc01df95 2007-10-06 aku: sid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, fdbc01df95 2007-10-06 aku: pid INTEGER NOT NULL REFERENCES project, -- Project the symbol belongs to fdbc01df95 2007-10-06 aku: name TEXT NOT NULL, fdbc01df95 2007-10-06 aku: type INTEGER NOT NULL, -- enum { tag = 1, branch, undefined } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: tag_count INTEGER NOT NULL, -- How often the symbol is used as tag. fdbc01df95 2007-10-06 aku: branch_count INTEGER NOT NULL, -- How often the symbol is used as branch fdbc01df95 2007-10-06 aku: commit_count INTEGER NOT NULL, -- How often a file was committed on the symbol fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: UNIQUE (pid, name) -- Symbols are unique within the project fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing blocker { fdbc01df95 2007-10-06 aku: sid INTEGER NOT NULL REFERENCES symbol, -- fdbc01df95 2007-10-06 aku: bid INTEGER NOT NULL REFERENCES symbol, -- Sprouted from sid, blocks it. fdbc01df95 2007-10-06 aku: UNIQUE (sid, bid) fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing parent { fdbc01df95 2007-10-06 aku: sid INTEGER NOT NULL REFERENCES symbol, -- fdbc01df95 2007-10-06 aku: pid INTEGER NOT NULL REFERENCES symbol, -- Possible parent of sid fdbc01df95 2007-10-06 aku: UNIQUE (sid, pid) fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing meta { 2c08006d9d 2007-10-25 aku: -- Meta data of revisions. See revision.mid for the 2c08006d9d 2007-10-25 aku: -- reference. Many revisions can share meta data. This is 2c08006d9d 2007-10-25 aku: -- actually one of the criterions used to sort revisions 2c08006d9d 2007-10-25 aku: -- into changesets. 2c08006d9d 2007-10-25 aku: fdbc01df95 2007-10-06 aku: mid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- Meta data belongs to a specific project, stronger, to a 2c08006d9d 2007-10-25 aku: -- branch in that project. It further has a log message, 2c08006d9d 2007-10-25 aku: -- and its author. This is unique with the project and 2c08006d9d 2007-10-25 aku: -- branch. 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: pid INTEGER NOT NULL REFERENCES project, -- 2c08006d9d 2007-10-25 aku: bid INTEGER NOT NULL REFERENCES symbol, -- 2c08006d9d 2007-10-25 aku: aid INTEGER NOT NULL REFERENCES author, -- 2c08006d9d 2007-10-25 aku: cid INTEGER NOT NULL REFERENCES cmessage, -- fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: UNIQUE (pid, bid, aid, cid) 2c08006d9d 2007-10-25 aku: 2c08006d9d 2007-10-25 aku: -- Constraints: The project of the meta data of a revision 2c08006d9d 2007-10-25 aku: -- X is the same as the project of X itself. 2c08006d9d 2007-10-25 aku: -- 2c08006d9d 2007-10-25 aku: -- ............ The branch of the meta data of a revision 2c08006d9d 2007-10-25 aku: -- X is the same as the line of development 2c08006d9d 2007-10-25 aku: -- of X itself. fdbc01df95 2007-10-06 aku: } 8a93ffa9c1 2007-10-06 aku: 2c08006d9d 2007-10-25 aku: # Authors and commit messages are fully global, i.e. per 2c08006d9d 2007-10-25 aku: # repository. fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing author { fdbc01df95 2007-10-06 aku: aid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, fdbc01df95 2007-10-06 aku: name TEXT NOT NULL UNIQUE fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: state writing cmessage { fdbc01df95 2007-10-06 aku: cid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, fdbc01df95 2007-10-06 aku: text TEXT NOT NULL UNIQUE fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: ae19c0fcb4 2007-10-13 aku: return ae19c0fcb4 2007-10-13 aku: } ae19c0fcb4 2007-10-13 aku: ae19c0fcb4 2007-10-13 aku: typemethod load {} { ae19c0fcb4 2007-10-13 aku: # TODO fdbc01df95 2007-10-06 aku: return fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: typemethod run {} { ae19c0fcb4 2007-10-13 aku: # Pass manager interface. Executed to perform the ae19c0fcb4 2007-10-13 aku: # functionality of the pass. ae19c0fcb4 2007-10-13 aku: 8a93ffa9c1 2007-10-06 aku: set rbase [repository base?] 8a93ffa9c1 2007-10-06 aku: foreach project [repository projects] { 8a93ffa9c1 2007-10-06 aku: set base [file join $rbase [$project base]] 8a93ffa9c1 2007-10-06 aku: log write 1 collrev "Processing $base" 8a93ffa9c1 2007-10-06 aku: 8a93ffa9c1 2007-10-06 aku: foreach file [$project files] { 8a93ffa9c1 2007-10-06 aku: set path [$file path] 8a93ffa9c1 2007-10-06 aku: log write 2 collrev "Parsing $path" be891232a2 2007-10-12 aku: if {[catch { be891232a2 2007-10-12 aku: parser process [file join $base $path] $file be891232a2 2007-10-12 aku: } msg]} { be891232a2 2007-10-12 aku: global errorCode be891232a2 2007-10-12 aku: if {$errorCode eq "vc::rcs::parser"} { be891232a2 2007-10-12 aku: trouble fatal "$path is not a valid RCS archive ($msg)" be891232a2 2007-10-12 aku: } else { be891232a2 2007-10-12 aku: global errorInfo be891232a2 2007-10-12 aku: trouble internal $errorInfo be891232a2 2007-10-12 aku: } adf168e23e 2007-10-24 aku: } else { adf168e23e 2007-10-24 aku: # We persist the core of the data collected about adf168e23e 2007-10-24 aku: # each file immediately after it has been parsed adf168e23e 2007-10-24 aku: # and wrangled into shape, and then drop it from adf168e23e 2007-10-24 aku: # memory. This is done to keep the amount of adf168e23e 2007-10-24 aku: # required memory within sensible limits. Without adf168e23e 2007-10-24 aku: # doing it this way we would easily gobble up 1G adf168e23e 2007-10-24 aku: # of RAM or more with all the objects (revisions adf168e23e 2007-10-24 aku: # and file-level symbols). adf168e23e 2007-10-24 aku: adf168e23e 2007-10-24 aku: $file persist be891232a2 2007-10-12 aku: } 3a00ac5aa2 2007-10-23 aku: 3a00ac5aa2 2007-10-23 aku: $file drop 8a93ffa9c1 2007-10-06 aku: } 8a93ffa9c1 2007-10-06 aku: } 8a93ffa9c1 2007-10-06 aku: 8a93ffa9c1 2007-10-06 aku: repository printrevstatistics 8a93ffa9c1 2007-10-06 aku: repository persistrev 8a93ffa9c1 2007-10-06 aku: fdbc01df95 2007-10-06 aku: log write 1 collrev "Scan completed" 2434ad3bfe 2007-10-26 aku: Paranoia ae19c0fcb4 2007-10-13 aku: return ae19c0fcb4 2007-10-13 aku: } ae19c0fcb4 2007-10-13 aku: ae19c0fcb4 2007-10-13 aku: typemethod discard {} { ae19c0fcb4 2007-10-13 aku: # Pass manager interface. Executed for all passes after the ae19c0fcb4 2007-10-13 aku: # run passes, to remove all data of this pass from the state, ae19c0fcb4 2007-10-13 aku: # as being out of date. ae19c0fcb4 2007-10-13 aku: ae19c0fcb4 2007-10-13 aku: state discard revision ae19c0fcb4 2007-10-13 aku: state discard tag ae19c0fcb4 2007-10-13 aku: state discard branch ae19c0fcb4 2007-10-13 aku: state discard symbol ae19c0fcb4 2007-10-13 aku: state discard blocker ae19c0fcb4 2007-10-13 aku: state discard parent ae19c0fcb4 2007-10-13 aku: state discard meta ae19c0fcb4 2007-10-13 aku: state discard author ae19c0fcb4 2007-10-13 aku: state discard cmessage 2434ad3bfe 2007-10-26 aku: return 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: 2434ad3bfe 2007-10-26 aku: proc Paranoia {} { 2434ad3bfe 2007-10-26 aku: # This code performs a number of paranoid checks of the 2434ad3bfe 2007-10-26 aku: # database for inconsistent cross-references. 2434ad3bfe 2007-10-26 aku: log write 4 collrev {Check database consistency} 2434ad3bfe 2007-10-26 aku: 831e8f360d 2007-10-27 aku: set n 0 ; # Counter for the checks (we print an id before the 831e8f360d 2007-10-27 aku: # main label). 2434ad3bfe 2007-10-26 aku: 2434ad3bfe 2007-10-26 aku: # Find all revisions which disagree with their line of 2434ad3bfe 2007-10-26 aku: # development about the project they are owned by. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {Revisions and their LODs have to be in the same project} \ 2434ad3bfe 2007-10-26 aku: {disagrees with its LOD about owning project} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, file F, symbol S 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.lod = S.sid 2434ad3bfe 2007-10-26 aku: AND F.pid != S.pid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: # Find all revisions which disgree with their meta data about 2434ad3bfe 2007-10-26 aku: # the project they are owned by. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {Revisions and their meta data have to be in the same project} \ 2434ad3bfe 2007-10-26 aku: {disagrees with its meta data about owning project} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, file F, meta M 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.mid = M.mid 2434ad3bfe 2007-10-26 aku: AND F.pid != M.pid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: # Find all revisions which disgree with their meta data about 2434ad3bfe 2007-10-26 aku: # the branch/line of development they belong to. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {Revisions and their meta data have to be in the same LOD} \ 2434ad3bfe 2007-10-26 aku: {disagrees with its meta data about owning LOD} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, meta M, file F 2434ad3bfe 2007-10-26 aku: WHERE R.mid = M.mid 2434ad3bfe 2007-10-26 aku: AND R.lod != M.bid 2434ad3bfe 2007-10-26 aku: AND R.fid = F.fid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions with a primary child which disagrees 70d4a81162 2007-10-26 aku: # about the file they belong to. 70d4a81162 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Revisions and their primary children have to be in the same file} \ 70d4a81162 2007-10-26 aku: {disagrees with its primary child about the owning file} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision C, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.child IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.child = C.rid 2434ad3bfe 2007-10-26 aku: AND C.fid != R.fid 70d4a81162 2007-10-26 aku: ; 70d4a81162 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: 70d4a81162 2007-10-26 aku: # Find all revisions with a branch parent symbol whose parent 70d4a81162 2007-10-26 aku: # disagrees about the file they belong to. 70d4a81162 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Revisions and their branch children have to be in the same file} \ 70d4a81162 2007-10-26 aku: {at the beginning of its branch and its parent disagree about the owning file} { 70d4a81162 2007-10-26 aku: SELECT F.name, R.rev 70d4a81162 2007-10-26 aku: FROM revision R, revision P, file F 70d4a81162 2007-10-26 aku: WHERE R.fid = F.fid 70d4a81162 2007-10-26 aku: AND R.bparent IS NOT NULL 70d4a81162 2007-10-26 aku: AND R.parent = P.rid 70d4a81162 2007-10-26 aku: AND R.fid != P.fid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: # Find all revisions with a non-NTDB child which disagrees 2434ad3bfe 2007-10-26 aku: # about the file they belong to. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {Revisions and their non-NTDB children have to be in the same file} \ 2434ad3bfe 2007-10-26 aku: {disagrees with its non-NTDB child about the owning file} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision C, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.dbchild IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.dbchild = C.rid 2434ad3bfe 2007-10-26 aku: AND C.fid != R.fid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions which have a primary child, but the child 70d4a81162 2007-10-26 aku: # does not have them as parent. 2434ad3bfe 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Revisions have to be parents of their primary children} \ 70d4a81162 2007-10-26 aku: {is not the parent of its primary child} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision C, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.child IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.child = C.rid 2434ad3bfe 2007-10-26 aku: AND C.parent != R.rid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions which have a primrary child, but the 70d4a81162 2007-10-26 aku: # child has a branch parent symbol making them brach starters. 2434ad3bfe 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Primary children of revisions must not start branches} \ 70d4a81162 2007-10-26 aku: {is parent of a primary child which is the beginning of a branch} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision C, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.child IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.child = C.rid 2434ad3bfe 2007-10-26 aku: AND C.bparent IS NOT NULL 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions without branch parent symbol which have a 70d4a81162 2007-10-26 aku: # parent, but the parent does not have them as primary child. 2434ad3bfe 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Revisions have to be primary children of their parents, if any} \ 2434ad3bfe 2007-10-26 aku: {is not the child of its parent} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision P, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.bparent IS NULL 2434ad3bfe 2007-10-26 aku: AND R.parent IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.parent = P.rid 2434ad3bfe 2007-10-26 aku: AND P.child != R.rid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions with a branch parent symbol which do not 70d4a81162 2007-10-26 aku: # have a parent. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {Branch starting revisions have to have a parent} \ 2434ad3bfe 2007-10-26 aku: {at the beginning of its branch has no parent} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.bparent IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.parent IS NULL 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions with a branch parent symbol whose parent 70d4a81162 2007-10-26 aku: # has them as primary child. 2434ad3bfe 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Branch starting revisions must not be primary children of their parents} \ 70d4a81162 2007-10-26 aku: {at the beginning of its branch is the primary child of its parent} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision P, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.bparent IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.parent IS NOT NULL 2e7cbb2829 2007-10-26 aku: AND R.parent = P.rid 2e7cbb2829 2007-10-26 aku: AND P.child = R.rid 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: # Find all revisions with a non-NTDB child which are not on 2434ad3bfe 2007-10-26 aku: # the NTDB. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {NTDB to trunk transition has to begin on NTDB} \ 2434ad3bfe 2007-10-26 aku: {has a non-NTDB child, yet is not on the NTDB} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.dbchild IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND NOT R.isdefault 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: # Find all revisions with a NTDB parent which are on the NTDB. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {NTDB to trunk transition has to end on non-NTDB} \ 2434ad3bfe 2007-10-26 aku: {has a NTDB parent, yet is on the NTDB} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.dbparent IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.isdefault 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: # Find all revisions with a child which disagrees about the 2434ad3bfe 2007-10-26 aku: # line of development they belong to. 2434ad3bfe 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Revisions and their primary children have to be in the same LOD} \ 70d4a81162 2007-10-26 aku: {and its primary child disagree about their LOD} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision C, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.child IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.child = C.rid 2434ad3bfe 2007-10-26 aku: AND C.lod != R.lod 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: # Find all revisions with a non-NTDB child which agrees about 2434ad3bfe 2007-10-26 aku: # the line of development they belong to. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {NTDB and trunk revisions have to be in different LODs} \ 2434ad3bfe 2007-10-26 aku: {on NTDB and its non-NTDB child wrongly agree about their LOD} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision C, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.dbchild IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.dbchild = C.rid 2434ad3bfe 2007-10-26 aku: AND C.lod = R.lod 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions with a branch parent symbol which is not 70d4a81162 2007-10-26 aku: # their LOD. 2434ad3bfe 2007-10-26 aku: Check \ 70d4a81162 2007-10-26 aku: {Branch starting revisions have to have their LOD as branch parent symbol} \ 70d4a81162 2007-10-26 aku: {at the beginning of its branch does not have the branch symbol as its LOD} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.bparent IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.lod != R.bparent 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 70d4a81162 2007-10-26 aku: # Find all revisions with a branch parent symbol whose parent 70d4a81162 2007-10-26 aku: # is in the same line of development. 2434ad3bfe 2007-10-26 aku: Check \ 2434ad3bfe 2007-10-26 aku: {Revisions and their branch children have to be in different LODs} \ 2434ad3bfe 2007-10-26 aku: {at the beginning of its branch and its parent wrongly agree about their LOD} { 2434ad3bfe 2007-10-26 aku: SELECT F.name, R.rev 2434ad3bfe 2007-10-26 aku: FROM revision R, revision P, file F 2434ad3bfe 2007-10-26 aku: WHERE R.fid = F.fid 2434ad3bfe 2007-10-26 aku: AND R.bparent IS NOT NULL 2434ad3bfe 2007-10-26 aku: AND R.parent = P.rid 2434ad3bfe 2007-10-26 aku: AND R.lod = P.lod 2434ad3bfe 2007-10-26 aku: ; 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: return 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: 2434ad3bfe 2007-10-26 aku: proc Check {header label sql} { 2434ad3bfe 2007-10-26 aku: upvar 1 n n 2434ad3bfe 2007-10-26 aku: set ok 1 2434ad3bfe 2007-10-26 aku: foreach {fname revnr} [state run $sql] { 2434ad3bfe 2007-10-26 aku: set ok 0 2434ad3bfe 2007-10-26 aku: trouble fatal "$fname <$revnr> $label" 2434ad3bfe 2007-10-26 aku: } 2434ad3bfe 2007-10-26 aku: log write 5 collrev "\[[format %02d [incr n]]\] [expr {$ok ? "Ok " : "Failed"}] ... $header" fdbc01df95 2007-10-06 aku: return fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# fdbc01df95 2007-10-06 aku: ## Internal methods fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# fdbc01df95 2007-10-06 aku: ## Configuration fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: pragma -hasinstances no ; # singleton fdbc01df95 2007-10-06 aku: pragma -hastypeinfo no ; # no introspection fdbc01df95 2007-10-06 aku: pragma -hastypedestroy no ; # immortal fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: namespace eval ::vc::fossil::import::cvs::pass { fdbc01df95 2007-10-06 aku: namespace export collrev fdbc01df95 2007-10-06 aku: namespace eval collrev { ec053168a8 2007-10-06 aku: namespace import ::vc::rcs::parser fdbc01df95 2007-10-06 aku: namespace import ::vc::fossil::import::cvs::repository fdbc01df95 2007-10-06 aku: namespace import ::vc::fossil::import::cvs::state fdbc01df95 2007-10-06 aku: namespace import ::vc::tools::trouble fdbc01df95 2007-10-06 aku: namespace import ::vc::tools::log fdbc01df95 2007-10-06 aku: log register collrev fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: } fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: # # ## ### ##### ######## ############# ##################### fdbc01df95 2007-10-06 aku: ## Ready fdbc01df95 2007-10-06 aku: fdbc01df95 2007-10-06 aku: package provide vc::fossil::import::cvs::pass::collrev 1.0 fdbc01df95 2007-10-06 aku: return