Fossil SCM
Continued work on pass 4. Implemented the deletion of excluded symbols and all parts referencing them. The complex part is the regrafting of NTDB revisions should a NTDB branch be excluded. This is like 'GraftNTDB2Trunk' in 'file' when excluding everything but the trunk.
Commit
69bf6ab99bc94773551713e6479de44400d2467c
Parent
11e5d7ce42e4734…
1 file changed
+92
| --- tools/cvs2fossil/lib/c2f_pfiltersym.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl | ||
| @@ -19,10 +19,11 @@ | ||
| 19 | 19 | |
| 20 | 20 | package require Tcl 8.4 ; # Required runtime. |
| 21 | 21 | package require snit ; # OO system. |
| 22 | 22 | package require vc::tools::log ; # User feedback. |
| 23 | 23 | package require vc::fossil::import::cvs::state ; # State storage. |
| 24 | +package require vc::fossil::import::cvs::project::sym ; # Project level symbols | |
| 24 | 25 | |
| 25 | 26 | # # ## ### ##### ######## ############# ##################### |
| 26 | 27 | ## Register the pass with the management |
| 27 | 28 | |
| 28 | 29 | vc::fossil::import::cvs::pass define \ |
| @@ -85,11 +86,99 @@ | ||
| 85 | 86 | |
| 86 | 87 | # # ## ### ##### ######## ############# |
| 87 | 88 | ## Internal methods |
| 88 | 89 | |
| 89 | 90 | proc FilterExcludedSymbols {} { |
| 91 | + # We pull all the excluded symbols together into a table for | |
| 92 | + # easy reference by the upcoming DELETE and other statements. | |
| 93 | + # ('x IN table' clauses). | |
| 94 | + | |
| 95 | + set excl [project::sym excluded] | |
| 96 | + | |
| 97 | + state run { | |
| 98 | + CREATE TEMPORARY TABLE excludedsymbols AS | |
| 99 | + SELECT sid | |
| 100 | + FROM symbol | |
| 101 | + WHERE type = $excl | |
| 102 | + } | |
| 103 | + | |
| 104 | + # First we have to handle the possibility of an excluded | |
| 105 | + # NTDB. This is a special special case there we have to | |
| 106 | + # regraft the revisions which are shared between the NTDB and | |
| 107 | + # Trunk onto the trunk, preventing their deletion later. We | |
| 108 | + # have code for that in 'file', however that operated on the | |
| 109 | + # in-memory revision objects, which we do not have here. We do | |
| 110 | + # the same now without object, by directly manipulating the | |
| 111 | + # links in the database. | |
| 112 | + | |
| 113 | + array set ntdb {} | |
| 114 | + array set link {} | |
| 115 | + | |
| 116 | + foreach {id parent transfer} [state run { | |
| 117 | + SELECT R.rid, R.parent, R.dbchild | |
| 118 | + FROM revision R, symbol S | |
| 119 | + WHERE R.lod = S.sid | |
| 120 | + AND S.sid IN excludedsymbols | |
| 121 | + AND R.isdefault | |
| 122 | + }] { | |
| 123 | + set ntdb($id) $parent | |
| 124 | + if {$transfer eq ""} continue | |
| 125 | + set link($id) $transfer | |
| 126 | + } | |
| 127 | + | |
| 128 | + foreach joint [array names link] { | |
| 129 | + # The joints are the highest NTDB revisions which are | |
| 130 | + # shared with their respective trunk. We disconnect from | |
| 131 | + # their NTDB children, and make them parents of their | |
| 132 | + # 'dbchild'. The associated 'dbparent' is squashed | |
| 133 | + # instead. All parents of the joints are moved to the | |
| 134 | + # trunk as well. | |
| 135 | + | |
| 136 | + set tjoint $link($joint) | |
| 137 | + set tlod [lindex [state run { | |
| 138 | + SELECT lod FROM revision WHERE rid = $tjoint | |
| 139 | + }] 0] | |
| 140 | + | |
| 141 | + # Covnert db/parent/child into regular parent/child links. | |
| 142 | + state run { | |
| 143 | + UPDATE revision SET dbparent = NULL, parent = $joint WHERE rid = $tjoint ; | |
| 144 | + UPDATE revision SET dbchild = NULL, child = $tjoint WHERE rid = $joint ; | |
| 145 | + } | |
| 146 | + while {1} { | |
| 147 | + # Move the NTDB trunk revisions to trunk. | |
| 148 | + state run { | |
| 149 | + UPDATE revision SET lod = $tlod, isdefault = 0 WHERE rid = $joint | |
| 150 | + } | |
| 151 | + set last $joint | |
| 152 | + set joint $ntdb($joint) | |
| 153 | + if {![info exists ntdb($joint)]} break | |
| 154 | + } | |
| 155 | + | |
| 156 | + # Reached the NTDB basis in the trunk. Finalize the | |
| 157 | + # parent/child linkage and squash the branch parent symbol | |
| 158 | + # reference. | |
| 159 | + | |
| 160 | + state run { | |
| 161 | + UPDATE revision SET child = $last WHERE rid = $joint ; | |
| 162 | + UPDATE revision SET bparent = NULL WHERE rid = $last ; | |
| 163 | + } | |
| 164 | + } | |
| 165 | + | |
| 166 | + # Now that the special case is done we can simply kill all the | |
| 167 | + # revisions, tags, and branches referencing any of the | |
| 168 | + # excluded symbols in some way. This is easy as we do not have | |
| 169 | + # to select them again and again from the base tables any | |
| 170 | + # longer. | |
| 171 | + | |
| 90 | 172 | state run { |
| 173 | + DELETE FROM revision WHERE lod IN excludedsymbols; | |
| 174 | + DELETE FROM tag WHERE lod IN excludedsymbols; | |
| 175 | + DELETE FROM tag WHERE sid IN excludedsymbols; | |
| 176 | + DELETE FROM branch WHERE lod IN excludedsymbols; | |
| 177 | + DELETE FROM branch WHERE sid IN excludedsymbols; | |
| 178 | + | |
| 179 | + DROP TABLE excludedsymbols; | |
| 91 | 180 | } |
| 92 | 181 | return |
| 93 | 182 | } |
| 94 | 183 | |
| 95 | 184 | # # ## ### ##### ######## ############# |
| @@ -104,10 +193,13 @@ | ||
| 104 | 193 | |
| 105 | 194 | namespace eval ::vc::fossil::import::cvs::pass { |
| 106 | 195 | namespace export filtersym |
| 107 | 196 | namespace eval filtersym { |
| 108 | 197 | namespace import ::vc::fossil::import::cvs::state |
| 198 | + namespace eval project { | |
| 199 | + namespace import ::vc::fossil::import::cvs::project::sym | |
| 200 | + } | |
| 109 | 201 | namespace import ::vc::tools::log |
| 110 | 202 | log register filtersym |
| 111 | 203 | } |
| 112 | 204 | } |
| 113 | 205 | |
| 114 | 206 |
| --- tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| @@ -19,10 +19,11 @@ | |
| 19 | |
| 20 | package require Tcl 8.4 ; # Required runtime. |
| 21 | package require snit ; # OO system. |
| 22 | package require vc::tools::log ; # User feedback. |
| 23 | package require vc::fossil::import::cvs::state ; # State storage. |
| 24 | |
| 25 | # # ## ### ##### ######## ############# ##################### |
| 26 | ## Register the pass with the management |
| 27 | |
| 28 | vc::fossil::import::cvs::pass define \ |
| @@ -85,11 +86,99 @@ | |
| 85 | |
| 86 | # # ## ### ##### ######## ############# |
| 87 | ## Internal methods |
| 88 | |
| 89 | proc FilterExcludedSymbols {} { |
| 90 | state run { |
| 91 | } |
| 92 | return |
| 93 | } |
| 94 | |
| 95 | # # ## ### ##### ######## ############# |
| @@ -104,10 +193,13 @@ | |
| 104 | |
| 105 | namespace eval ::vc::fossil::import::cvs::pass { |
| 106 | namespace export filtersym |
| 107 | namespace eval filtersym { |
| 108 | namespace import ::vc::fossil::import::cvs::state |
| 109 | namespace import ::vc::tools::log |
| 110 | log register filtersym |
| 111 | } |
| 112 | } |
| 113 | |
| 114 |
| --- tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| @@ -19,10 +19,11 @@ | |
| 19 | |
| 20 | package require Tcl 8.4 ; # Required runtime. |
| 21 | package require snit ; # OO system. |
| 22 | package require vc::tools::log ; # User feedback. |
| 23 | package require vc::fossil::import::cvs::state ; # State storage. |
| 24 | package require vc::fossil::import::cvs::project::sym ; # Project level symbols |
| 25 | |
| 26 | # # ## ### ##### ######## ############# ##################### |
| 27 | ## Register the pass with the management |
| 28 | |
| 29 | vc::fossil::import::cvs::pass define \ |
| @@ -85,11 +86,99 @@ | |
| 86 | |
| 87 | # # ## ### ##### ######## ############# |
| 88 | ## Internal methods |
| 89 | |
| 90 | proc FilterExcludedSymbols {} { |
| 91 | # We pull all the excluded symbols together into a table for |
| 92 | # easy reference by the upcoming DELETE and other statements. |
| 93 | # ('x IN table' clauses). |
| 94 | |
| 95 | set excl [project::sym excluded] |
| 96 | |
| 97 | state run { |
| 98 | CREATE TEMPORARY TABLE excludedsymbols AS |
| 99 | SELECT sid |
| 100 | FROM symbol |
| 101 | WHERE type = $excl |
| 102 | } |
| 103 | |
| 104 | # First we have to handle the possibility of an excluded |
| 105 | # NTDB. This is a special special case there we have to |
| 106 | # regraft the revisions which are shared between the NTDB and |
| 107 | # Trunk onto the trunk, preventing their deletion later. We |
| 108 | # have code for that in 'file', however that operated on the |
| 109 | # in-memory revision objects, which we do not have here. We do |
| 110 | # the same now without object, by directly manipulating the |
| 111 | # links in the database. |
| 112 | |
| 113 | array set ntdb {} |
| 114 | array set link {} |
| 115 | |
| 116 | foreach {id parent transfer} [state run { |
| 117 | SELECT R.rid, R.parent, R.dbchild |
| 118 | FROM revision R, symbol S |
| 119 | WHERE R.lod = S.sid |
| 120 | AND S.sid IN excludedsymbols |
| 121 | AND R.isdefault |
| 122 | }] { |
| 123 | set ntdb($id) $parent |
| 124 | if {$transfer eq ""} continue |
| 125 | set link($id) $transfer |
| 126 | } |
| 127 | |
| 128 | foreach joint [array names link] { |
| 129 | # The joints are the highest NTDB revisions which are |
| 130 | # shared with their respective trunk. We disconnect from |
| 131 | # their NTDB children, and make them parents of their |
| 132 | # 'dbchild'. The associated 'dbparent' is squashed |
| 133 | # instead. All parents of the joints are moved to the |
| 134 | # trunk as well. |
| 135 | |
| 136 | set tjoint $link($joint) |
| 137 | set tlod [lindex [state run { |
| 138 | SELECT lod FROM revision WHERE rid = $tjoint |
| 139 | }] 0] |
| 140 | |
| 141 | # Covnert db/parent/child into regular parent/child links. |
| 142 | state run { |
| 143 | UPDATE revision SET dbparent = NULL, parent = $joint WHERE rid = $tjoint ; |
| 144 | UPDATE revision SET dbchild = NULL, child = $tjoint WHERE rid = $joint ; |
| 145 | } |
| 146 | while {1} { |
| 147 | # Move the NTDB trunk revisions to trunk. |
| 148 | state run { |
| 149 | UPDATE revision SET lod = $tlod, isdefault = 0 WHERE rid = $joint |
| 150 | } |
| 151 | set last $joint |
| 152 | set joint $ntdb($joint) |
| 153 | if {![info exists ntdb($joint)]} break |
| 154 | } |
| 155 | |
| 156 | # Reached the NTDB basis in the trunk. Finalize the |
| 157 | # parent/child linkage and squash the branch parent symbol |
| 158 | # reference. |
| 159 | |
| 160 | state run { |
| 161 | UPDATE revision SET child = $last WHERE rid = $joint ; |
| 162 | UPDATE revision SET bparent = NULL WHERE rid = $last ; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | # Now that the special case is done we can simply kill all the |
| 167 | # revisions, tags, and branches referencing any of the |
| 168 | # excluded symbols in some way. This is easy as we do not have |
| 169 | # to select them again and again from the base tables any |
| 170 | # longer. |
| 171 | |
| 172 | state run { |
| 173 | DELETE FROM revision WHERE lod IN excludedsymbols; |
| 174 | DELETE FROM tag WHERE lod IN excludedsymbols; |
| 175 | DELETE FROM tag WHERE sid IN excludedsymbols; |
| 176 | DELETE FROM branch WHERE lod IN excludedsymbols; |
| 177 | DELETE FROM branch WHERE sid IN excludedsymbols; |
| 178 | |
| 179 | DROP TABLE excludedsymbols; |
| 180 | } |
| 181 | return |
| 182 | } |
| 183 | |
| 184 | # # ## ### ##### ######## ############# |
| @@ -104,10 +193,13 @@ | |
| 193 | |
| 194 | namespace eval ::vc::fossil::import::cvs::pass { |
| 195 | namespace export filtersym |
| 196 | namespace eval filtersym { |
| 197 | namespace import ::vc::fossil::import::cvs::state |
| 198 | namespace eval project { |
| 199 | namespace import ::vc::fossil::import::cvs::project::sym |
| 200 | } |
| 201 | namespace import ::vc::tools::log |
| 202 | log register filtersym |
| 203 | } |
| 204 | } |
| 205 | |
| 206 |