File Annotation
Not logged in
11e5d7ce42 2007-11-06       aku: ## -*- tcl -*-
11e5d7ce42 2007-11-06       aku: # # ## ### ##### ######## ############# #####################
11e5d7ce42 2007-11-06       aku: ## Copyright (c) 2007 Andreas Kupries.
11e5d7ce42 2007-11-06       aku: #
11e5d7ce42 2007-11-06       aku: # This software is licensed as described in the file LICENSE, which
11e5d7ce42 2007-11-06       aku: # you should have received as part of this distribution.
11e5d7ce42 2007-11-06       aku: #
11e5d7ce42 2007-11-06       aku: # This software consists of voluntary contributions made by many
11e5d7ce42 2007-11-06       aku: # individuals.  For exact contribution history, see the revision
11e5d7ce42 2007-11-06       aku: # history and logs, available at http://fossil-scm.hwaci.com/fossil
11e5d7ce42 2007-11-06       aku: # # ## ### ##### ######## ############# #####################
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: ## Pass IV. Coming after the symbol collation pass this pass now
11e5d7ce42 2007-11-06       aku: ## removes all revisions and symbols referencing any of the excluded
11e5d7ce42 2007-11-06       aku: ## symbols from the persistent database.
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: # # ## ### ##### ######## ############# #####################
11e5d7ce42 2007-11-06       aku: ## Requirements
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: package require Tcl 8.4                               ; # Required runtime.
11e5d7ce42 2007-11-06       aku: package require snit                                  ; # OO system.
37734390ca 2007-11-07       aku: package require vc::tools::misc                       ; # Text formatting.
11e5d7ce42 2007-11-06       aku: package require vc::tools::log                        ; # User feedback.
11e5d7ce42 2007-11-06       aku: package require vc::fossil::import::cvs::state        ; # State storage.
131f051880 2007-11-09       aku: package require vc::fossil::import::cvs::integrity    ; # State storage integrity checks.
69bf6ab99b 2007-11-06       aku: package require vc::fossil::import::cvs::project::sym ; # Project level symbols
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: # # ## ### ##### ######## ############# #####################
11e5d7ce42 2007-11-06       aku: ## Register the pass with the management
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: vc::fossil::import::cvs::pass define \
11e5d7ce42 2007-11-06       aku:     FilterSymbols \
11e5d7ce42 2007-11-06       aku:     {Filter symbols, remove all excluded pieces} \
11e5d7ce42 2007-11-06       aku:     ::vc::fossil::import::cvs::pass::filtersym
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: # # ## ### ##### ######## ############# #####################
11e5d7ce42 2007-11-06       aku: ##
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: snit::type ::vc::fossil::import::cvs::pass::filtersym {
11e5d7ce42 2007-11-06       aku:     # # ## ### ##### ######## #############
11e5d7ce42 2007-11-06       aku:     ## Public API
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     typemethod setup {} {
11e5d7ce42 2007-11-06       aku: 	# Define names and structure of the persistent state of this
11e5d7ce42 2007-11-06       aku: 	# pass.
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: 	state reading symbol
11e5d7ce42 2007-11-06       aku: 	state reading blocker
11e5d7ce42 2007-11-06       aku: 	state reading parent
11e5d7ce42 2007-11-06       aku: 	state reading preferedparent
11e5d7ce42 2007-11-06       aku: 	state reading revision
11e5d7ce42 2007-11-06       aku: 	state reading branch
11e5d7ce42 2007-11-06       aku: 	state reading tag
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	state writing noop {
37734390ca 2007-11-07       aku: 	    id    INTEGER NOT NULL  PRIMARY KEY, -- tag/branch reference
37734390ca 2007-11-07       aku: 	    noop  INTEGER NOT NULL
37734390ca 2007-11-07       aku: 	}
11e5d7ce42 2007-11-06       aku: 	return
11e5d7ce42 2007-11-06       aku:     }
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     typemethod load {} {
11e5d7ce42 2007-11-06       aku: 	# Pass manager interface. Executed to load data computed by
11e5d7ce42 2007-11-06       aku: 	# this pass into memory when this pass is skipped instead of
11e5d7ce42 2007-11-06       aku: 	# executed.
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: 	# The results of this pass are fully in the persistent state,
11e5d7ce42 2007-11-06       aku: 	# there is nothing to load for the next one.
11e5d7ce42 2007-11-06       aku: 	return
11e5d7ce42 2007-11-06       aku:     }
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     typemethod run {} {
11e5d7ce42 2007-11-06       aku: 	# Pass manager interface. Executed to perform the
11e5d7ce42 2007-11-06       aku: 	# functionality of the pass.
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: 	# The removal of excluded symbols and everything referencing
11e5d7ce42 2007-11-06       aku: 	# to them is done completely in the database.
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: 	state transaction {
11e5d7ce42 2007-11-06       aku: 	    FilterExcludedSymbols
37734390ca 2007-11-07       aku: 	    MutateSymbols
37734390ca 2007-11-07       aku: 	    AdjustParents
37734390ca 2007-11-07       aku: 	    RefineSymbols
37734390ca 2007-11-07       aku: 
131f051880 2007-11-09       aku: 	    # Strict integrity enforces that all meta entries are in
131f051880 2007-11-09       aku: 	    # the same LOD as the revision using them. At this point
131f051880 2007-11-09       aku: 	    # this may not be true any longer. If a NTDB was excluded
131f051880 2007-11-09       aku: 	    # then all revisions it shared with the trunk were moved
131f051880 2007-11-09       aku: 	    # to the trunk LOD, however their meta entries will still
131f051880 2007-11-09       aku: 	    # refer to the now gone LOD symbol. This is fine however,
131f051880 2007-11-09       aku: 	    # it will not affect our ability to use the meta entries
131f051880 2007-11-09       aku: 	    # to distinguish and group revisions into changesets. It
131f051880 2007-11-09       aku: 	    # should be noted that we cannot simply switch the meta
131f051880 2007-11-09       aku: 	    # entries over to the trunk either, as that may cause the
131f051880 2007-11-09       aku: 	    # modified entries to violate the unique-ness constrain
131f051880 2007-11-09       aku: 	    # set on that table.
131f051880 2007-11-09       aku: 	    integrity metarelaxed
11e5d7ce42 2007-11-06       aku: 	}
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: 	log write 1 filtersym "Filtering completed"
11e5d7ce42 2007-11-06       aku: 	return
11e5d7ce42 2007-11-06       aku:     }
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     typemethod discard {} {
11e5d7ce42 2007-11-06       aku: 	# Pass manager interface. Executed for all passes after the
11e5d7ce42 2007-11-06       aku: 	# run passes, to remove all data of this pass from the state,
11e5d7ce42 2007-11-06       aku: 	# as being out of date.
11e5d7ce42 2007-11-06       aku: 	return
11e5d7ce42 2007-11-06       aku:     }
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     # # ## ### ##### ######## #############
11e5d7ce42 2007-11-06       aku:     ## Internal methods
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     proc FilterExcludedSymbols {} {
ffafc0bd65 2007-11-06       aku: 	log write 3 filtersym "Filter out excluded symbols and users"
ffafc0bd65 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	# We pull all the excluded symbols together into a table for
69bf6ab99b 2007-11-06       aku: 	# easy reference by the upcoming DELETE and other statements.
69bf6ab99b 2007-11-06       aku: 	# ('x IN table' clauses).
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	set excl [project::sym excluded]
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	state run {
69bf6ab99b 2007-11-06       aku: 	    CREATE TEMPORARY TABLE excludedsymbols AS
69bf6ab99b 2007-11-06       aku: 	    SELECT sid
69bf6ab99b 2007-11-06       aku: 	    FROM   symbol
69bf6ab99b 2007-11-06       aku: 	    WHERE  type = $excl
69bf6ab99b 2007-11-06       aku: 	}
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	# First we have to handle the possibility of an excluded
69bf6ab99b 2007-11-06       aku: 	# NTDB. This is a special special case there we have to
69bf6ab99b 2007-11-06       aku: 	# regraft the revisions which are shared between the NTDB and
69bf6ab99b 2007-11-06       aku: 	# Trunk onto the trunk, preventing their deletion later. We
69bf6ab99b 2007-11-06       aku: 	# have code for that in 'file', however that operated on the
69bf6ab99b 2007-11-06       aku: 	# in-memory revision objects, which we do not have here. We do
69bf6ab99b 2007-11-06       aku: 	# the same now without object, by directly manipulating the
69bf6ab99b 2007-11-06       aku: 	# links in the database.
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	array set ntdb {}
69bf6ab99b 2007-11-06       aku: 	array set link {}
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	foreach {id parent transfer} [state run {
69bf6ab99b 2007-11-06       aku: 	    SELECT R.rid, R.parent, R.dbchild
69bf6ab99b 2007-11-06       aku: 	    FROM  revision R, symbol S
69bf6ab99b 2007-11-06       aku: 	    WHERE R.lod = S.sid
69bf6ab99b 2007-11-06       aku: 	    AND   S.sid IN excludedsymbols
69bf6ab99b 2007-11-06       aku: 	    AND   R.isdefault
69bf6ab99b 2007-11-06       aku: 	}] {
69bf6ab99b 2007-11-06       aku: 	    set ntdb($id) $parent
69bf6ab99b 2007-11-06       aku: 	    if {$transfer eq ""} continue
69bf6ab99b 2007-11-06       aku: 	    set link($id) $transfer
69bf6ab99b 2007-11-06       aku: 	}
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	foreach joint [array names link] {
69bf6ab99b 2007-11-06       aku: 	    # The joints are the highest NTDB revisions which are
69bf6ab99b 2007-11-06       aku: 	    # shared with their respective trunk. We disconnect from
69bf6ab99b 2007-11-06       aku: 	    # their NTDB children, and make them parents of their
69bf6ab99b 2007-11-06       aku: 	    # 'dbchild'. The associated 'dbparent' is squashed
69bf6ab99b 2007-11-06       aku: 	    # instead. All parents of the joints are moved to the
69bf6ab99b 2007-11-06       aku: 	    # trunk as well.
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	    set tjoint $link($joint)
69bf6ab99b 2007-11-06       aku: 	    set tlod [lindex [state run {
69bf6ab99b 2007-11-06       aku: 		SELECT lod FROM revision WHERE rid = $tjoint
69bf6ab99b 2007-11-06       aku: 	    }] 0]
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	    # Covnert db/parent/child into regular parent/child links.
69bf6ab99b 2007-11-06       aku: 	    state run {
69bf6ab99b 2007-11-06       aku: 		UPDATE revision SET dbparent = NULL, parent = $joint  WHERE rid = $tjoint ;
69bf6ab99b 2007-11-06       aku: 		UPDATE revision SET dbchild  = NULL, child  = $tjoint WHERE rid = $joint  ;
69bf6ab99b 2007-11-06       aku: 	    }
69bf6ab99b 2007-11-06       aku: 	    while {1} {
69bf6ab99b 2007-11-06       aku: 		# Move the NTDB trunk revisions to trunk.
69bf6ab99b 2007-11-06       aku: 		state run {
69bf6ab99b 2007-11-06       aku: 		    UPDATE revision SET lod = $tlod, isdefault = 0 WHERE rid = $joint
69bf6ab99b 2007-11-06       aku: 		}
69bf6ab99b 2007-11-06       aku: 		set last $joint
69bf6ab99b 2007-11-06       aku: 		set joint $ntdb($joint)
69bf6ab99b 2007-11-06       aku: 		if {![info exists ntdb($joint)]} break
69bf6ab99b 2007-11-06       aku: 	    }
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	    # Reached the NTDB basis in the trunk. Finalize the
69bf6ab99b 2007-11-06       aku: 	    # parent/child linkage and squash the branch parent symbol
69bf6ab99b 2007-11-06       aku: 	    # reference.
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	    state run {
69bf6ab99b 2007-11-06       aku: 		UPDATE revision SET child   = $last WHERE rid = $joint ;
69bf6ab99b 2007-11-06       aku: 		UPDATE revision SET bparent = NULL  WHERE rid = $last  ;
69bf6ab99b 2007-11-06       aku: 	    }
69bf6ab99b 2007-11-06       aku: 	}
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	# Now that the special case is done we can simply kill all the
69bf6ab99b 2007-11-06       aku: 	# revisions, tags, and branches referencing any of the
69bf6ab99b 2007-11-06       aku: 	# excluded symbols in some way. This is easy as we do not have
69bf6ab99b 2007-11-06       aku: 	# to select them again and again from the base tables any
69bf6ab99b 2007-11-06       aku: 	# longer.
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	state run {
69bf6ab99b 2007-11-06       aku: 	    DELETE FROM revision WHERE lod IN excludedsymbols;
69bf6ab99b 2007-11-06       aku: 	    DELETE FROM tag      WHERE lod IN excludedsymbols;
69bf6ab99b 2007-11-06       aku: 	    DELETE FROM tag      WHERE sid IN excludedsymbols;
69bf6ab99b 2007-11-06       aku: 	    DELETE FROM branch   WHERE lod IN excludedsymbols;
69bf6ab99b 2007-11-06       aku: 	    DELETE FROM branch   WHERE sid IN excludedsymbols;
69bf6ab99b 2007-11-06       aku: 
69bf6ab99b 2007-11-06       aku: 	    DROP TABLE excludedsymbols;
69bf6ab99b 2007-11-06       aku: 	}
69bf6ab99b 2007-11-06       aku: 	return
69bf6ab99b 2007-11-06       aku:     }
69bf6ab99b 2007-11-06       aku: 
37734390ca 2007-11-07       aku:     proc MutateSymbols {} {
ffafc0bd65 2007-11-06       aku: 	# Next, now that we know which symbols are what we look for
ffafc0bd65 2007-11-06       aku: 	# file level tags which are actually converted as branches
37734390ca 2007-11-07       aku: 	# (project level, and vice versa), and move them to the
37734390ca 2007-11-07       aku: 	# correct tables.
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# # ## ### ##### ######## #############
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Mutate symbols, preparation"
ffafc0bd65 2007-11-06       aku: 
ffafc0bd65 2007-11-06       aku: 	set branch [project::sym branch]
37734390ca 2007-11-07       aku: 	set tag    [project::sym tag]
ffafc0bd65 2007-11-06       aku: 
ffafc0bd65 2007-11-06       aku: 	set tagstomutate [state run {
ffafc0bd65 2007-11-06       aku: 	    SELECT T.tid, T.fid, T.lod, T.sid, T.rev
ffafc0bd65 2007-11-06       aku: 	    FROM tag T, symbol S
ffafc0bd65 2007-11-06       aku: 	    WHERE T.sid = S.sid
ffafc0bd65 2007-11-06       aku: 	    AND S.type = $branch
ffafc0bd65 2007-11-06       aku: 	}]
ffafc0bd65 2007-11-06       aku: 
ffafc0bd65 2007-11-06       aku: 	set branchestomutate [state run {
ffafc0bd65 2007-11-06       aku: 	    SELECT B.bid, B.fid, B.lod, B.sid, B.root, B.first, B.bra
ffafc0bd65 2007-11-06       aku: 	    FROM branch B, symbol S
ffafc0bd65 2007-11-06       aku: 	    WHERE B.sid = S.sid
ffafc0bd65 2007-11-06       aku: 	    AND S.type = $tag
ffafc0bd65 2007-11-06       aku: 	}]
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 4 filtersym "Changing [nsp [expr {[llength $tagstomutate]/5}] tag] into branches"
37734390ca 2007-11-07       aku: 	log write 4 filtersym "Changing [nsp [expr {[llength $branchestomutate]/7}] branch branches] into tags"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# # ## ### ##### ######## #############
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Mutate tags to branches"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	foreach {id fid lod sid rev} $tagstomutate {
37734390ca 2007-11-07       aku: 	    state run {
37734390ca 2007-11-07       aku: 		DELETE FROM tag WHERE tid = $id ;
37734390ca 2007-11-07       aku: 		INSERT INTO branch (bid, fid,  lod,  sid,  root, first, bra, pos)
37734390ca 2007-11-07       aku: 		VALUES             ($id, $fid, $lod, $sid, $rev, NULL,  '',  -1);
37734390ca 2007-11-07       aku: 	    }
37734390ca 2007-11-07       aku: 	}
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Ok."
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# # ## ### ##### ######## #############
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Mutate branches to tags"
37734390ca 2007-11-07       aku: 
ffafc0bd65 2007-11-06       aku: 	foreach {id fid lod sid root first bra} $branchestomutate {
ffafc0bd65 2007-11-06       aku: 	    state run {
ffafc0bd65 2007-11-06       aku: 		DELETE FROM branch WHERE bid = $id ;
ffafc0bd65 2007-11-06       aku: 		INSERT INTO tag (tid, fid,  lod,  sid,  rev)
ffafc0bd65 2007-11-06       aku: 		VALUES          ($id, $fid, $lod, $sid, $root);
ffafc0bd65 2007-11-06       aku: 	    }
3a530ef947 2007-11-06       aku: 	}
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Ok."
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# # ## ### ##### ######## #############
3a530ef947 2007-11-06       aku: 	return
3a530ef947 2007-11-06       aku:     }
3a530ef947 2007-11-06       aku: 
3a530ef947 2007-11-06       aku:     # Adjust the parents of symbols to their preferred parents.
3a530ef947 2007-11-06       aku: 
3a530ef947 2007-11-06       aku:     # If a file level ymbol has a preferred parent that is different
3a530ef947 2007-11-06       aku:     # than its current parent, and if the preferred parent is an
3a530ef947 2007-11-06       aku:     # allowed parent of the symbol in this file, then we graft the
3a530ef947 2007-11-06       aku:     # aSymbol onto its preferred parent.
3a530ef947 2007-11-06       aku: 
37734390ca 2007-11-07       aku:     proc AdjustParents {} {
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Adjust parents, loading data in preparation"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# We pull important maps once into memory so that we do quick
37734390ca 2007-11-07       aku: 	# hash lookup later when processing the graft candidates.
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# Tag/Branch names ...
37734390ca 2007-11-07       aku: 	array set sn [state run { SELECT T.tid, S.name FROM tag T,    symbol S WHERE T.sid = S.sid }]
37734390ca 2007-11-07       aku: 	array set sn [state run { SELECT B.bid, S.name FROM branch B, symbol S WHERE B.sid = S.sid }]
37734390ca 2007-11-07       aku: 	# Symbol names ...
37734390ca 2007-11-07       aku: 	array set sx [state run { SELECT L.sid, L.name FROM symbol L }]
37734390ca 2007-11-07       aku: 	# Files and projects.
37734390ca 2007-11-07       aku: 	array set fpn {}
37734390ca 2007-11-07       aku: 	foreach {id fn pn} [state run {
37734390ca 2007-11-07       aku: 		SELECT F.fid, F.name, P.name
37734390ca 2007-11-07       aku: 		FROM   file F, project P
37734390ca 2007-11-07       aku: 		WHERE  F.pid = P.pid
37734390ca 2007-11-07       aku: 	}] { set fpn($id) [list $fn $pn] }
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	set tagstoadjust [state run {
37734390ca 2007-11-07       aku: 	    SELECT T.tid, T.fid, T.lod, P.pid, S.name, R.rev, R.rid
3a530ef947 2007-11-06       aku: 	    FROM tag T, preferedparent P, symbol S, revision R
3a530ef947 2007-11-06       aku: 	    WHERE T.sid = P.sid
3a530ef947 2007-11-06       aku: 	    AND   T.lod != P.pid
3a530ef947 2007-11-06       aku: 	    AND   P.pid = S.sid
3a530ef947 2007-11-06       aku: 	    AND   S.name != ':trunk:'
3a530ef947 2007-11-06       aku: 	    AND   T.rev = R.rid
37734390ca 2007-11-07       aku: 	}]
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	set branchestoadjust [state run {
37734390ca 2007-11-07       aku: 	    SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
37734390ca 2007-11-07       aku: 	    FROM branch B, preferedparent P, symbol S, revision R
37734390ca 2007-11-07       aku: 	    WHERE B.sid = P.sid
37734390ca 2007-11-07       aku: 	    AND   B.lod != P.pid
37734390ca 2007-11-07       aku: 	    AND   P.pid = S.sid
37734390ca 2007-11-07       aku: 	    AND   S.name != ':trunk:'
37734390ca 2007-11-07       aku: 	    AND   B.root = R.rid
37734390ca 2007-11-07       aku: 	}]
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	set tmax [expr {[llength $tagstoadjust] / 7}]
37734390ca 2007-11-07       aku: 	set bmax [expr {[llength $branchestoadjust] / 8}]
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 4 filtersym "Reparenting at most [nsp $tmax tag]"
37734390ca 2007-11-07       aku: 	log write 4 filtersym "Reparenting at most [nsp $bmax branch branches]"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Adjust tag parents"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# Find the tags whose current parent (lod) is not the prefered
37734390ca 2007-11-07       aku: 	# parent, the prefered parent is not the trunk, and the
37734390ca 2007-11-07       aku: 	# prefered parent is a possible parent per the tag's revision.
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	set fmt %[string length $tmax]s
37734390ca 2007-11-07       aku: 	set mxs [format $fmt $tmax]
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	set n 0
37734390ca 2007-11-07       aku: 	foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    # BOTTLE-NECK ...
37734390ca 2007-11-07       aku: 	    #
37734390ca 2007-11-07       aku: 	    # The check if the candidate (pid) is truly viable is
37734390ca 2007-11-07       aku: 	    # based finding the branch as possible parent, and done
37734390ca 2007-11-07       aku: 	    # now instead of as part of the already complex join.
37734390ca 2007-11-07       aku: 	    #
37734390ca 2007-11-07       aku: 	    # ... AND P.pid IN (SELECT B.sid
37734390ca 2007-11-07       aku: 	    #                   FROM branch B
37734390ca 2007-11-07       aku: 	    #                   WHERE B.root = R.rid)
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    if {![lindex [state run {
37734390ca 2007-11-07       aku: 		SELECT COUNT(*)
37734390ca 2007-11-07       aku: 		FROM branch B
37734390ca 2007-11-07       aku: 		WHERE  B.sid  = $pid
37734390ca 2007-11-07       aku: 		AND    B.root = $rid
37734390ca 2007-11-07       aku: 	    }] 0]} {
37734390ca 2007-11-07       aku: 		incr tmax -1
37734390ca 2007-11-07       aku: 		set  mxs [format $fmt $tmax]
37734390ca 2007-11-07       aku: 		continue
37734390ca 2007-11-07       aku: 	    }
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    #
37734390ca 2007-11-07       aku: 	    # BOTTLE-NECK ...
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    # The names for use in the log output are retrieved
37734390ca 2007-11-07       aku: 	    # separately, to keep the join selecting the adjustable
37734390ca 2007-11-07       aku: 	    # tags small, not burdened with the dereferencing of links
37734390ca 2007-11-07       aku: 	    # to name.
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    set tagname $sn($id)
37734390ca 2007-11-07       aku: 	    set oldname $sx($lod)
37734390ca 2007-11-07       aku: 	    struct::list assign $fpn($fid) fname prname
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    # Do the grafting.
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    log write 4 filtersym "\[[format $fmt $n]/$mxs\] $prname : Grafting tag '$tagname' on $fname/$revnr from '$oldname' onto '$preferedname'"
37734390ca 2007-11-07       aku: 	    state run { UPDATE tag SET lod = $pid WHERE tid = $id ; }
37734390ca 2007-11-07       aku: 	    incr n
37734390ca 2007-11-07       aku: 	}
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Reparented [nsp $n tag]"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Adjust branch parents"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	# Find the branches whose current parent (lod) is not the
37734390ca 2007-11-07       aku: 	# prefered parent, the prefered parent is not the trunk, and
37734390ca 2007-11-07       aku: 	# the prefered parent is a possible parent per the branch's
37734390ca 2007-11-07       aku: 	# revision.
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	set fmt %[string length $bmax]s
37734390ca 2007-11-07       aku: 	set mxs [format $fmt $bmax]
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	set n 0
37734390ca 2007-11-07       aku: 	foreach {id fid lod pos pid preferedname revnr rid} $branchestoadjust {
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    # BOTTLE-NECK ...
37734390ca 2007-11-07       aku: 	    #
37734390ca 2007-11-07       aku: 	    # The check if the candidate (pid) is truly viable is
37734390ca 2007-11-07       aku: 	    # based on the branch positions in the spawning revision,
37734390ca 2007-11-07       aku: 	    # and done now instead of as part of the already complex
37734390ca 2007-11-07       aku: 	    # join.
37734390ca 2007-11-07       aku: 	    #
37734390ca 2007-11-07       aku: 	    # ... AND P.pid IN (SELECT BX.sid
37734390ca 2007-11-07       aku: 	    #                   FROM branch BX
37734390ca 2007-11-07       aku: 	    #                   WHERE BX.root = R.rid
37734390ca 2007-11-07       aku: 	    #                   AND   BX.pos > B.pos)
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    if {![lindex [state run {
37734390ca 2007-11-07       aku: 		SELECT COUNT(*)
37734390ca 2007-11-07       aku: 		FROM branch B
37734390ca 2007-11-07       aku: 		WHERE  B.sid  = $pid
37734390ca 2007-11-07       aku: 		AND    B.root = $rid
37734390ca 2007-11-07       aku: 		AND    B.pos  > $pos
37734390ca 2007-11-07       aku: 	    }] 0]} {
37734390ca 2007-11-07       aku: 		incr bmax -1
37734390ca 2007-11-07       aku: 		set  mxs [format $fmt $bmax]
37734390ca 2007-11-07       aku: 		continue
37734390ca 2007-11-07       aku: 	    }
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	    #
37734390ca 2007-11-07       aku: 	    # BOTTLE-NECK ...
37734390ca 2007-11-07       aku: 
3a530ef947 2007-11-06       aku: 	    # The names for use in the log output are retrieved
3a530ef947 2007-11-06       aku: 	    # separately, to keep the join selecting the adjustable
3a530ef947 2007-11-06       aku: 	    # tags small, not burdened with the dereferencing of links
3a530ef947 2007-11-06       aku: 	    # to name.
3a530ef947 2007-11-06       aku: 
37734390ca 2007-11-07       aku: 	    set braname $sn($id)
37734390ca 2007-11-07       aku: 	    set oldname $sx($lod)
37734390ca 2007-11-07       aku: 	    struct::list assign $fpn($fid) fname prname
3a530ef947 2007-11-06       aku: 
3a530ef947 2007-11-06       aku: 	    # Do the grafting.
3a530ef947 2007-11-06       aku: 
37734390ca 2007-11-07       aku: 	    log write 4 filtersym "\[[format $fmt $n]/$mxs\] $prname : Grafting branch '$braname' on $fname/$revnr from '$oldname' onto '$preferedname'"
37734390ca 2007-11-07       aku: 	    state run { UPDATE tag SET lod = $pid WHERE tid = $id ; }
37734390ca 2007-11-07       aku: 	    incr n
3a530ef947 2007-11-06       aku: 	}
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Reparented [nsp $n branch branches]"
3a530ef947 2007-11-06       aku: 	return
3a530ef947 2007-11-06       aku:     }
3a530ef947 2007-11-06       aku: 
37734390ca 2007-11-07       aku:     proc RefineSymbols {} {
37734390ca 2007-11-07       aku: 	# Tags and branches are marked as normal/noop based on the op
37734390ca 2007-11-07       aku: 	# of their revision.
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 3 filtersym "Refine symbols (no-op or not?)"
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 4 filtersym "    Regular tags"
37734390ca 2007-11-07       aku: 	state run {
37734390ca 2007-11-07       aku: 	    INSERT INTO noop
37734390ca 2007-11-07       aku: 	    SELECT T.tid, 0
37734390ca 2007-11-07       aku: 	    FROM tag T, revision R
37734390ca 2007-11-07       aku: 	    WHERE T.rev  = R.rid
37734390ca 2007-11-07       aku: 	    AND   R.op  != 0 -- 0 == nothing
37734390ca 2007-11-07       aku: 	}
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 4 filtersym "    No-op tags"
37734390ca 2007-11-07       aku: 	state run {
37734390ca 2007-11-07       aku: 	    INSERT INTO noop
37734390ca 2007-11-07       aku: 	    SELECT T.tid, 1
37734390ca 2007-11-07       aku: 	    FROM tag T, revision R
37734390ca 2007-11-07       aku: 	    WHERE T.rev  = R.rid
37734390ca 2007-11-07       aku: 	    AND   R.op   = 0 -- nothing
37734390ca 2007-11-07       aku: 	}
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 4 filtersym "    Regular branches"
37734390ca 2007-11-07       aku: 	state run {
37734390ca 2007-11-07       aku: 	    INSERT INTO noop
37734390ca 2007-11-07       aku: 	    SELECT B.bid, 0
37734390ca 2007-11-07       aku: 	    FROM branch B, revision R
37734390ca 2007-11-07       aku: 	    WHERE B.root = R.rid
37734390ca 2007-11-07       aku: 	    AND   R.op  != 0 -- nothing
37734390ca 2007-11-07       aku: 	}
37734390ca 2007-11-07       aku: 
37734390ca 2007-11-07       aku: 	log write 4 filtersym "    No-op branches"
11e5d7ce42 2007-11-06       aku: 	state run {
37734390ca 2007-11-07       aku: 	    INSERT INTO noop
37734390ca 2007-11-07       aku: 	    SELECT B.bid, 1
37734390ca 2007-11-07       aku: 	    FROM branch B, revision R
37734390ca 2007-11-07       aku: 	    WHERE B.root = R.rid
37734390ca 2007-11-07       aku: 	    AND   R.op   = 0 -- nothing
11e5d7ce42 2007-11-06       aku: 	}
11e5d7ce42 2007-11-06       aku: 	return
11e5d7ce42 2007-11-06       aku:     }
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     # # ## ### ##### ######## #############
11e5d7ce42 2007-11-06       aku:     ## Configuration
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     pragma -hasinstances   no ; # singleton
11e5d7ce42 2007-11-06       aku:     pragma -hastypeinfo    no ; # no introspection
11e5d7ce42 2007-11-06       aku:     pragma -hastypedestroy no ; # immortal
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku:     # # ## ### ##### ######## #############
11e5d7ce42 2007-11-06       aku: }
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: namespace eval ::vc::fossil::import::cvs::pass {
11e5d7ce42 2007-11-06       aku:     namespace export filtersym
11e5d7ce42 2007-11-06       aku:     namespace eval filtersym {
11e5d7ce42 2007-11-06       aku: 	namespace import ::vc::fossil::import::cvs::state
131f051880 2007-11-09       aku: 	namespace import ::vc::fossil::import::cvs::integrity
69bf6ab99b 2007-11-06       aku: 	namespace eval project {
69bf6ab99b 2007-11-06       aku: 	    namespace import ::vc::fossil::import::cvs::project::sym
69bf6ab99b 2007-11-06       aku: 	}
37734390ca 2007-11-07       aku: 	namespace import ::vc::tools::misc::nsp
11e5d7ce42 2007-11-06       aku: 	namespace import ::vc::tools::log
11e5d7ce42 2007-11-06       aku: 	log register filtersym
11e5d7ce42 2007-11-06       aku:     }
11e5d7ce42 2007-11-06       aku: }
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: # # ## ### ##### ######## ############# #####################
11e5d7ce42 2007-11-06       aku: ## Ready
11e5d7ce42 2007-11-06       aku: 
11e5d7ce42 2007-11-06       aku: package provide vc::fossil::import::cvs::pass::filtersym 1.0
11e5d7ce42 2007-11-06       aku: return