11e5d7ce42 2007-11-06 aku: ## -*- tcl -*- 11e5d7ce42 2007-11-06 aku: # # ## ### ##### ######## ############# ##################### 66235f2430 2008-02-06 aku: ## Copyright (c) 2007-2008 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. 96b7bfb834 2007-11-16 aku: package require vc::fossil::import::cvs::repository ; # Repository management. 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: e288af3995 2007-12-02 aku: state use project e288af3995 2007-12-02 aku: state use file e288af3995 2007-12-02 aku: state use revision e288af3995 2007-12-02 aku: state use revisionbranchchildren e288af3995 2007-12-02 aku: state use branch e288af3995 2007-12-02 aku: state use tag e288af3995 2007-12-02 aku: state use symbol e288af3995 2007-12-02 aku: state use blocker e288af3995 2007-12-02 aku: state use parent e288af3995 2007-12-02 aku: state use author e288af3995 2007-12-02 aku: state use cmessage e288af3995 2007-12-02 aku: state use preferedparent e288af3995 2007-12-02 aku: e288af3995 2007-12-02 aku: # NOTE: So far no pass coming after this makes us of this information. e288af3995 2007-12-02 aku: state extend 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: 70acbf63ec 2008-02-06 aku: PrintSymbolTree 96b7bfb834 2007-11-16 aku: repository printrevstatistics 96b7bfb834 2007-11-16 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 70acbf63ec 2008-02-06 aku: # modified entries to violate the unique-ness constraint 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 {} { 96b7bfb834 2007-11-16 aku: log write 3 filtersym "Remove the excluded symbols and their 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: f637d42206 2008-02-24 aku: state foreachrow { f637d42206 2008-02-24 aku: SELECT R.rid AS xid, f637d42206 2008-02-24 aku: R.parent AS xparent, f637d42206 2008-02-24 aku: R.dbchild AS transfer 69bf6ab99b 2007-11-06 aku: FROM revision R, symbol S 6809145eb1 2008-01-19 aku: WHERE R.lod = S.sid -- Get symbol of line-of-development of all revisions 6809145eb1 2008-01-19 aku: AND S.sid IN excludedsymbols -- Restrict to the excluded symbols 6809145eb1 2008-01-19 aku: AND R.isdefault -- Restrict to NTDB revisions f637d42206 2008-02-24 aku: } { f637d42206 2008-02-24 aku: set ntdb($xid) $xparent f637d42206 2008-02-24 aku: if {$transfer eq ""} continue f637d42206 2008-02-24 aku: set link($xid) $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) 96b7bfb834 2007-11-16 aku: set tlod [state one { 69bf6ab99b 2007-11-06 aku: SELECT lod FROM revision WHERE rid = $tjoint 96b7bfb834 2007-11-16 aku: }] 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 { 2516f4a56d 2007-11-16 aku: CREATE TEMPORARY TABLE excludedrevisions AS 2516f4a56d 2007-11-16 aku: SELECT rid FROM revision WHERE lod IN excludedsymbols; 2516f4a56d 2007-11-16 aku: 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: 2516f4a56d 2007-11-16 aku: DELETE FROM revisionbranchchildren WHERE rid IN excludedrevisions; 2516f4a56d 2007-11-16 aku: DELETE FROM revisionbranchchildren WHERE brid IN excludedrevisions; 83d75a6c23 2008-02-03 aku: DELETE FROM blob WHERE rid IN excludedrevisions; 2516f4a56d 2007-11-16 aku: 2516f4a56d 2007-11-16 aku: DROP TABLE excludedrevisions; 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: b41127b9d8 2007-11-25 aku: set nt [expr {[llength $tagstomutate]/5}] b41127b9d8 2007-11-25 aku: set nb [expr {[llength $branchestomutate]/7}] b41127b9d8 2007-11-25 aku: b41127b9d8 2007-11-25 aku: log write 4 filtersym "Changing [nsp $nt tag] into [nsp $nt branch branches]" b41127b9d8 2007-11-25 aku: log write 4 filtersym "Changing [nsp $nb branch branches] into [nsp $nb tag]" 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: } ffafc0bd65 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 {} f637d42206 2008-02-24 aku: state foreachrow { f637d42206 2008-02-24 aku: SELECT F.fid AS id, F.name AS fn, P.name AS pn 37734390ca 2007-11-07 aku: FROM file F, project P 37734390ca 2007-11-07 aku: WHERE F.pid = P.pid f637d42206 2008-02-24 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 37734390ca 2007-11-07 aku: FROM tag T, preferedparent P, symbol S, revision R 6809145eb1 2008-01-19 aku: WHERE T.sid = P.sid -- For all tags, get left-hand of prefered parent via symbol 6809145eb1 2008-01-19 aku: AND T.lod != P.pid -- Restrict to tags whose LOD is not their prefered parent 6809145eb1 2008-01-19 aku: AND P.pid = S.sid -- Get symbol of prefered parent 6809145eb1 2008-01-19 aku: AND S.name != ':trunk:' -- Exclude trunk parentage 6809145eb1 2008-01-19 aku: AND T.rev = R.rid -- Get revision the tag is attached to. 37734390ca 2007-11-07 aku: }] 37734390ca 2007-11-07 aku: 37734390ca 2007-11-07 aku: set branchestoadjust [state run { 79c227a9c0 2007-12-01 aku: SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, NULL, NULL 79c227a9c0 2007-12-01 aku: FROM branch B, preferedparent P, symbol S 6809145eb1 2008-01-19 aku: WHERE B.sid = P.sid -- For all branches, get left-hand of prefered parent via symbol 6809145eb1 2008-01-19 aku: AND B.lod != P.pid -- Restrict to branches whose LOD is not their prefered parent 6809145eb1 2008-01-19 aku: AND P.pid = S.sid -- Get symbol of prefered parent 6809145eb1 2008-01-19 aku: AND S.name != ':trunk:' -- Exclude trunk parentage 6809145eb1 2008-01-19 aku: AND B.root IS NULL -- Accept free-floating branch 6809145eb1 2008-01-19 aku: UNION 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 6809145eb1 2008-01-19 aku: WHERE B.sid = P.sid -- For all branches, get left-hand of prefered parent via symbol 6809145eb1 2008-01-19 aku: AND B.lod != P.pid -- Restrict to branches whose LOD is not their prefered parent 6809145eb1 2008-01-19 aku: AND P.pid = S.sid -- Get symbol of prefered parent 6809145eb1 2008-01-19 aku: AND S.name != ':trunk:' -- Exclude trunk parentage 6809145eb1 2008-01-19 aku: AND B.root = R.rid -- Get root revision of the branch 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: 3a530ef947 2007-11-06 aku: log write 3 filtersym "Adjust tag parents" 3a530ef947 2007-11-06 aku: 3a530ef947 2007-11-06 aku: # Find the tags whose current parent (lod) is not the prefered 3a530ef947 2007-11-06 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: # BOTTLE-NECK ... 37734390ca 2007-11-07 aku: # 37734390ca 2007-11-07 aku: # The check if the candidate (pid) is truly viable is 6809145eb1 2008-01-19 aku: # based on 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: 96b7bfb834 2007-11-16 aku: if {![state one { 6809145eb1 2008-01-19 aku: SELECT COUNT(*) -- Count <=> Check existence. 37734390ca 2007-11-07 aku: FROM branch B 6809145eb1 2008-01-19 aku: WHERE B.sid = $pid -- Restrict to branch for that symbol 6809145eb1 2008-01-19 aku: AND B.root = $rid -- attached to that revision 96b7bfb834 2007-11-16 aku: }]} { 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: 47d52d1efd 2007-11-28 aku: log write 4 filtersym {\[[format $fmt $n]/$mxs\] $prname : Grafting tag '$tagname' on $fname/$revnr from '$oldname' onto '$preferedname'} 8ce7ffff21 2007-11-28 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: 79c227a9c0 2007-12-01 aku: # Note: rid eq "" hear means that this is a free-floating 79c227a9c0 2007-12-01 aku: # branch, whose original root was removed as a unnecessary 79c227a9c0 2007-12-01 aku: # dead revision (See 'file::RemoveIrrelevantDeletions'). 79c227a9c0 2007-12-01 aku: # Such a branch can be regrafted without trouble and there 79c227a9c0 2007-12-01 aku: # is no need to look for the new parent in its 79c227a9c0 2007-12-01 aku: # non-existent root. 79c227a9c0 2007-12-01 aku: 79c227a9c0 2007-12-01 aku: if {($rid ne "") && ![state one { 6809145eb1 2008-01-19 aku: SELECT COUNT(*) -- Count <=> Check existence. 37734390ca 2007-11-07 aku: FROM branch B 6809145eb1 2008-01-19 aku: WHERE B.sid = $pid -- Look for branch by symbol 6809145eb1 2008-01-19 aku: AND B.root = $rid -- Spawned by the given revision 6809145eb1 2008-01-19 aku: AND B.pos > $pos -- And defined before branch to mutate 96b7bfb834 2007-11-16 aku: }]} { 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: 47d52d1efd 2007-11-28 aku: log write 4 filtersym {\[[format $fmt $n]/$mxs\] $prname : Grafting branch '$braname' on $fname/$revnr from '$oldname' onto '$preferedname'} 8ce7ffff21 2007-11-28 aku: state run { UPDATE branch SET lod = $pid WHERE bid = $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 branch branches]" 37734390ca 2007-11-07 aku: return 37734390ca 2007-11-07 aku: } 37734390ca 2007-11-07 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?)" 6809145eb1 2008-01-19 aku: 6809145eb1 2008-01-19 aku: # Note: The noop information is not used anywhere. Consider 6809145eb1 2008-01-19 aku: # disabling this code, and removing the data from the state. 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 37734390ca 2007-11-07 aku: } 37734390ca 2007-11-07 aku: return 37734390ca 2007-11-07 aku: } 37734390ca 2007-11-07 aku: 70acbf63ec 2008-02-06 aku: proc maxlen {v str} { 70acbf63ec 2008-02-06 aku: upvar 1 $v n 70acbf63ec 2008-02-06 aku: set l [string length $str] 70acbf63ec 2008-02-06 aku: if {$l <= $n} return 70acbf63ec 2008-02-06 aku: set n $l 70acbf63ec 2008-02-06 aku: return 70acbf63ec 2008-02-06 aku: } 70acbf63ec 2008-02-06 aku: 70acbf63ec 2008-02-06 aku: proc PrintSymbolTree {} { 70acbf63ec 2008-02-06 aku: if {![log visible? 9]} return 70acbf63ec 2008-02-06 aku: 70acbf63ec 2008-02-06 aku: array set sym {} 70acbf63ec 2008-02-06 aku: set n 0 70acbf63ec 2008-02-06 aku: set t 0 70acbf63ec 2008-02-06 aku: set c 0 ae53becda4 2008-03-02 aku: set p 0 70acbf63ec 2008-02-06 aku: f637d42206 2008-02-24 aku: state foreachrow { f637d42206 2008-02-24 aku: SELECT S.name AS xs, f637d42206 2008-02-24 aku: A.name AS stype, f637d42206 2008-02-24 aku: S.commit_count AS cc, f637d42206 2008-02-24 aku: P.name AS xp, f637d42206 2008-02-24 aku: B.name AS ptype ae53becda4 2008-03-02 aku: FROM symbol S, preferedparent SP, symbol P, symtype A, symtype B ae53becda4 2008-03-02 aku: WHERE SP.sid = S.sid ae53becda4 2008-03-02 aku: AND P.sid = SP.pid ae53becda4 2008-03-02 aku: AND A.tid = S.type ae53becda4 2008-03-02 aku: AND B.tid = P.type f637d42206 2008-02-24 aku: } { f637d42206 2008-02-24 aku: lappend sym($xs) $xp $stype $ptype $cc f637d42206 2008-02-24 aku: maxlen n $xs 70acbf63ec 2008-02-06 aku: maxlen t $stype 70acbf63ec 2008-02-06 aku: maxlen t $ptype 70acbf63ec 2008-02-06 aku: maxlen c $cc ae53becda4 2008-03-02 aku: maxlen p $xp 70acbf63ec 2008-02-06 aku: } 70acbf63ec 2008-02-06 aku: ae53becda4 2008-03-02 aku: foreach xs [lsort -dict [array names sym]] { ae53becda4 2008-03-02 aku: struct::list assign $sym($xs) xp stype ptype cc ae53becda4 2008-03-02 aku: log write 9 filtersym {Tree: [lj $t $stype] ([dj $c $cc]) [lj $n $xs] <-- [lj $t $ptype] $xp} 11e5d7ce42 2007-11-06 aku: } 11e5d7ce42 2007-11-06 aku: return 11e5d7ce42 2007-11-06 aku: } 3a530ef947 2007-11-06 aku: ae53becda4 2008-03-02 aku: proc lj {n s} { ::format %-${n}s $s } ae53becda4 2008-03-02 aku: proc dj {n s} { ::format %-${n}d $s } 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 { 96b7bfb834 2007-11-16 aku: namespace import ::vc::fossil::import::cvs::repository 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