File Annotation
Not logged in
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 {
adf168e23e 2007-10-24       aku: 	    rid  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)
fdbc01df95 2007-10-06       aku: 
fdbc01df95 2007-10-06       aku: 	    -- The tags and branches belonging to a revision can be
fdbc01df95 2007-10-06       aku: 	    -- determined by selecting on the backreferences in the
fdbc01df95 2007-10-06       aku: 	    -- tag and branch tables.
fdbc01df95 2007-10-06       aku: 
adf168e23e 2007-10-24       aku: 	    rev   TEXT     NOT NULL,                 -- revision number
adf168e23e 2007-10-24       aku: 	    date  INTEGER  NOT NULL,                 -- date of entry, seconds since epoch
adf168e23e 2007-10-24       aku: 	    state TEXT     NOT NULL,                 -- state of revision
adf168e23e 2007-10-24       aku: 	    mid   INTEGER  NOT NULL REFERENCES meta, -- meta data (author, commit message)
adf168e23e 2007-10-24       aku: 	    cs    INTEGER  NOT NULL,                 -- Revision content as offset and
adf168e23e 2007-10-24       aku: 	    cl    INTEGER  NOT NULL,                 -- length into the archive file.
adf168e23e 2007-10-24       aku: 
adf168e23e 2007-10-24       aku: 	    -- Derived information, and links
adf168e23e 2007-10-24       aku: 	    -- Basic: Parent/Child
adf168e23e 2007-10-24       aku: 	    -- NTDB:  DefaultParent/DefaultChild
adf168e23e 2007-10-24       aku: 	    -- Branches: Branch parent revision
adf168e23e 2007-10-24       aku: 
adf168e23e 2007-10-24       aku: 	    op        INTEGER NOT NULL,
adf168e23e 2007-10-24       aku: 	    isdefault INTEGER NOT NULL,
adf168e23e 2007-10-24       aku: 	    parent    INTEGER        REFERENCES revision,
adf168e23e 2007-10-24       aku: 	    child     INTEGER        REFERENCES revision,
adf168e23e 2007-10-24       aku: 	    dbparent  INTEGER        REFERENCES revision,
adf168e23e 2007-10-24       aku: 	    dbchild   INTEGER        REFERENCES revision,
adf168e23e 2007-10-24       aku: 	    bparent   INTEGER        REFERENCES symbol
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: 	# It is in principle possible to collapse the four tables
fdbc01df95 2007-10-06       aku: 	# above (from item to barnch) into a single table, with
fdbc01df95 2007-10-06       aku: 	# similar columns merged, and unused columns allowing NULL,
fdbc01df95 2007-10-06       aku: 	# the use determined by the type. We may do that if the
fdbc01df95 2007-10-06       aku: 	# performance is not good enough, but for now clarity of
fdbc01df95 2007-10-06       aku: 	# structure over efficiency.
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 {
fdbc01df95 2007-10-06       aku: 	    mid INTEGER  NOT NULL  PRIMARY KEY  AUTOINCREMENT,
fdbc01df95 2007-10-06       aku: 	    pid INTEGER  NOT NULL  REFERENCES project,  -- project the commit was on
67c24820c7 2007-10-14       aku: 	    bid INTEGER            REFERENCES symbol,   -- branch the commit was on, NULL for :trunk:
fdbc01df95 2007-10-06       aku: 	    aid INTEGER  NOT NULL  REFERENCES author,
fdbc01df95 2007-10-06       aku: 	    cid INTEGER  NOT NULL  REFERENCES cmessage,
fdbc01df95 2007-10-06       aku: 	    UNIQUE (pid, bid, aid, cid)
fdbc01df95 2007-10-06       aku: 	}
8a93ffa9c1 2007-10-06       aku: 
8a93ffa9c1 2007-10-06       aku: 	# Author and commit message information is fully global,
8a93ffa9c1 2007-10-06       aku: 	# i.e. per 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: 
fdbc01df95 2007-10-06       aku: 	# Consistency constraints.
fdbc01df95 2007-10-06       aku: 	#
fdbc01df95 2007-10-06       aku: 	# Items (Tags, Branches, Revisions) belong to a file to a
fdbc01df95 2007-10-06       aku: 	# project. All refer to other items, and symbols, which again
fdbc01df95 2007-10-06       aku: 	# belong to a project. The projects have to agree with each
fdbc01df95 2007-10-06       aku: 	# other. I.e. items may not refer to items or symbols which
fdbc01df95 2007-10-06       aku: 	# belong to a different project than their own.
fdbc01df95 2007-10-06       aku: 
fdbc01df95 2007-10-06       aku: 	return
fdbc01df95 2007-10-06       aku:     }
fdbc01df95 2007-10-06       aku: 
ae19c0fcb4 2007-10-13       aku:     typemethod load {} {
ae19c0fcb4 2007-10-13       aku: 	# TODO
ae19c0fcb4 2007-10-13       aku: 	return
ae19c0fcb4 2007-10-13       aku:     }
ae19c0fcb4 2007-10-13       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"
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
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