Fossil SCM
More comments on sql statements, slight reordering of some tables and conditions.
Commit
f7fe15cd0cb6cc28a32cc40c13bb12b9faccd673
Parent
808fbc474536c2f…
1 file changed
+34
-29
+34
-29
| --- tools/cvs2fossil/lib/c2f_pcollsym.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pcollsym.tcl | ||
| @@ -58,11 +58,11 @@ | ||
| 58 | 58 | -- project. |
| 59 | 59 | |
| 60 | 60 | sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol, |
| 61 | 61 | pid INTEGER NOT NULL REFERENCES symbol |
| 62 | 62 | } { pid } |
| 63 | - # Index on: pid (branch successors`) | |
| 63 | + # Index on: pid (branch successors) | |
| 64 | 64 | return |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | typemethod load {} { |
| 68 | 68 | # Pass manager interface. Executed to load data computed by |
| @@ -111,21 +111,24 @@ | ||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | # # ## ### ##### ######## ############# |
| 114 | 114 | ## Internal methods |
| 115 | 115 | |
| 116 | + ## TODO: Move UnconvertedSymbols, BadSymbolTypes, BlockedIncludes, | |
| 117 | + ## InvalidTags to the integrity module? | |
| 118 | + | |
| 116 | 119 | proc UnconvertedSymbols {} { |
| 117 | 120 | # Paranoia - Have we left symbols without conversion |
| 118 | 121 | # information (i.e. with type 'undefined') ? |
| 119 | 122 | |
| 120 | 123 | set undef [project::sym undef] |
| 121 | 124 | |
| 122 | 125 | foreach {pname sname} [state run { |
| 123 | 126 | SELECT P.name, S.name |
| 124 | - FROM project P, symbol S | |
| 125 | - WHERE P.pid = S.pid | |
| 126 | - AND S.type = $undef | |
| 127 | + FROM symbol S, project P | |
| 128 | + WHERE S.type = $undef -- Restrict to undefined symbols | |
| 129 | + AND P.pid = S.pid -- Get project for symbol | |
| 127 | 130 | }] { |
| 128 | 131 | trouble fatal "$pname : The symbol '$sname' was left undefined" |
| 129 | 132 | } |
| 130 | 133 | return |
| 131 | 134 | } |
| @@ -135,13 +138,13 @@ | ||
| 135 | 138 | # information (type out of the valid range (excluded, branch, |
| 136 | 139 | # tag)) ? |
| 137 | 140 | |
| 138 | 141 | foreach {pname sname} [state run { |
| 139 | 142 | SELECT P.name, S.name |
| 140 | - FROM project P, symbol S | |
| 141 | - WHERE P.pid = S.pid | |
| 142 | - AND S.type NOT IN (0,1,2) | |
| 143 | + FROM symbol S, project P | |
| 144 | + WHERE S.type NOT IN (0,1,2) -- Restrict to symbols with bogus type codes | |
| 145 | + AND P.pid = S.pid -- Get project of symbol | |
| 143 | 146 | }] { |
| 144 | 147 | trouble fatal "$pname : The symbol '$sname' has no proper conversion type" |
| 145 | 148 | } |
| 146 | 149 | return |
| 147 | 150 | } |
| @@ -152,16 +155,16 @@ | ||
| 152 | 155 | |
| 153 | 156 | set excl [project::sym excluded] |
| 154 | 157 | |
| 155 | 158 | foreach {pname sname bname} [state run { |
| 156 | 159 | SELECT P.name, S.name, SB.name |
| 157 | - FROM project P, symbol S, blocker B, symbol SB | |
| 158 | - WHERE P.pid = S.pid | |
| 159 | - AND S.type = $excl | |
| 160 | - AND S.sid = B.sid | |
| 161 | - AND B.bid = SB.sid | |
| 162 | - AND SB.type != $excl | |
| 160 | + FROM symbol S, blocker B, symbol SB, project P | |
| 161 | + WHERE S.type = $excl -- Restrict to excluded symbols | |
| 162 | + AND S.sid = B.sid -- Get symbols blocking them | |
| 163 | + AND B.bid = SB.sid -- and | |
| 164 | + AND SB.type != $excl -- which are not excluded themselves | |
| 165 | + AND P.pid = S.pid -- Get project of symbol | |
| 163 | 166 | }] { |
| 164 | 167 | trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it." |
| 165 | 168 | } |
| 166 | 169 | return |
| 167 | 170 | } |
| @@ -179,13 +182,13 @@ | ||
| 179 | 182 | set tag [project::sym tag] |
| 180 | 183 | |
| 181 | 184 | foreach {pname sname} [state run { |
| 182 | 185 | SELECT P.name, S.name |
| 183 | 186 | FROM project P, symbol S |
| 184 | - WHERE P.pid = S.pid | |
| 185 | - AND S.type = $tag | |
| 186 | - AND S.commit_count > 0 | |
| 187 | + WHERE S.type = $tag -- Restrict to tag symbols | |
| 188 | + AND S.commit_count > 0 -- which have revisions committed to them | |
| 189 | + AND P.pid = S.pid -- Get project of symbol | |
| 187 | 190 | }] { |
| 188 | 191 | trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits." |
| 189 | 192 | } |
| 190 | 193 | return |
| 191 | 194 | } |
| @@ -199,15 +202,15 @@ | ||
| 199 | 202 | |
| 200 | 203 | state run { |
| 201 | 204 | DELETE FROM blocker |
| 202 | 205 | WHERE bid IN (SELECT sid |
| 203 | 206 | FROM symbol |
| 204 | - WhERE type = $excl); | |
| 207 | + WhERE type = $excl); -- Get excluded symbols | |
| 205 | 208 | DELETE FROM parent |
| 206 | 209 | WHERE pid IN (SELECT sid |
| 207 | 210 | FROM symbol |
| 208 | - WhERE type = $excl); | |
| 211 | + WhERE type = $excl); -- Get excluded symbols | |
| 209 | 212 | } |
| 210 | 213 | return |
| 211 | 214 | } |
| 212 | 215 | |
| 213 | 216 | proc DeterminePreferedParents {} { |
| @@ -224,15 +227,16 @@ | ||
| 224 | 227 | # attempt to compute them. |
| 225 | 228 | |
| 226 | 229 | foreach {s p sname pname prname votes} [state run { |
| 227 | 230 | SELECT S.sid, P.pid, S.name, SB.name, PR.name, P.n |
| 228 | 231 | FROM symbol S, parent P, symbol SB, project PR |
| 229 | - WHERE S.sid = P.sid | |
| 230 | - AND P.pid = SB.sid | |
| 231 | - AND S.pid = PR.pid | |
| 232 | - AND S.type != $excl | |
| 233 | - ORDER BY P.n ASC, P.pid DESC | |
| 232 | + WHERE S.type != $excl -- Restrict to wanted symbols | |
| 233 | + AND S.sid = P.sid -- Get possible parents of symbol | |
| 234 | + AND P.pid = SB.sid -- and | |
| 235 | + AND S.pid = PR.pid -- the project of the symbol | |
| 236 | + ORDER BY P.n ASC, P.pid DESC -- Sorting, see below | |
| 237 | + -- | |
| 234 | 238 | -- Higher votes and smaller ids (= earlier branches) last |
| 235 | 239 | -- We simply keep the last possible parent for each |
| 236 | 240 | -- symbol. This parent will have the max number of votes |
| 237 | 241 | -- for its symbol and will be the earliest created branch |
| 238 | 242 | -- possible among all with many votes. |
| @@ -260,16 +264,17 @@ | ||
| 260 | 264 | # excluded symbols, as we intentionally did not |
| 261 | 265 | # compute a prefered parent for them, see phase I. |
| 262 | 266 | |
| 263 | 267 | foreach {pname sname} [state run { |
| 264 | 268 | SELECT PR.name, S.name |
| 265 | - FROM project PR, symbol S LEFT OUTER JOIN preferedparent P | |
| 266 | - ON S.sid = P.sid | |
| 267 | - WHERE P.pid IS NULL | |
| 268 | - AND S.name != ':trunk:' | |
| 269 | - AND S.pid = PR.pid | |
| 270 | - AND S.type != $excl | |
| 269 | + FROM symbol S LEFT OUTER JOIN preferedparent P | |
| 270 | + ON S.sid = P.sid, -- From symbol to prefered parent | |
| 271 | + project PR | |
| 272 | + WHERE P.pid IS NULL -- restrict to symbols without a preference | |
| 273 | + AND S.type != $excl -- which are not excluded | |
| 274 | + AND S.name != ':trunk:' -- and are not a trunk | |
| 275 | + AND S.pid = PR.pid -- get project of symbol | |
| 271 | 276 | }] { |
| 272 | 277 | trouble fatal "$pname : '$sname' has no prefered parent." |
| 273 | 278 | } |
| 274 | 279 | |
| 275 | 280 | # The reverse, having prefered parents for unknown symbols |
| 276 | 281 |
| --- tools/cvs2fossil/lib/c2f_pcollsym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pcollsym.tcl | |
| @@ -58,11 +58,11 @@ | |
| 58 | -- project. |
| 59 | |
| 60 | sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol, |
| 61 | pid INTEGER NOT NULL REFERENCES symbol |
| 62 | } { pid } |
| 63 | # Index on: pid (branch successors`) |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | typemethod load {} { |
| 68 | # Pass manager interface. Executed to load data computed by |
| @@ -111,21 +111,24 @@ | |
| 111 | } |
| 112 | |
| 113 | # # ## ### ##### ######## ############# |
| 114 | ## Internal methods |
| 115 | |
| 116 | proc UnconvertedSymbols {} { |
| 117 | # Paranoia - Have we left symbols without conversion |
| 118 | # information (i.e. with type 'undefined') ? |
| 119 | |
| 120 | set undef [project::sym undef] |
| 121 | |
| 122 | foreach {pname sname} [state run { |
| 123 | SELECT P.name, S.name |
| 124 | FROM project P, symbol S |
| 125 | WHERE P.pid = S.pid |
| 126 | AND S.type = $undef |
| 127 | }] { |
| 128 | trouble fatal "$pname : The symbol '$sname' was left undefined" |
| 129 | } |
| 130 | return |
| 131 | } |
| @@ -135,13 +138,13 @@ | |
| 135 | # information (type out of the valid range (excluded, branch, |
| 136 | # tag)) ? |
| 137 | |
| 138 | foreach {pname sname} [state run { |
| 139 | SELECT P.name, S.name |
| 140 | FROM project P, symbol S |
| 141 | WHERE P.pid = S.pid |
| 142 | AND S.type NOT IN (0,1,2) |
| 143 | }] { |
| 144 | trouble fatal "$pname : The symbol '$sname' has no proper conversion type" |
| 145 | } |
| 146 | return |
| 147 | } |
| @@ -152,16 +155,16 @@ | |
| 152 | |
| 153 | set excl [project::sym excluded] |
| 154 | |
| 155 | foreach {pname sname bname} [state run { |
| 156 | SELECT P.name, S.name, SB.name |
| 157 | FROM project P, symbol S, blocker B, symbol SB |
| 158 | WHERE P.pid = S.pid |
| 159 | AND S.type = $excl |
| 160 | AND S.sid = B.sid |
| 161 | AND B.bid = SB.sid |
| 162 | AND SB.type != $excl |
| 163 | }] { |
| 164 | trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it." |
| 165 | } |
| 166 | return |
| 167 | } |
| @@ -179,13 +182,13 @@ | |
| 179 | set tag [project::sym tag] |
| 180 | |
| 181 | foreach {pname sname} [state run { |
| 182 | SELECT P.name, S.name |
| 183 | FROM project P, symbol S |
| 184 | WHERE P.pid = S.pid |
| 185 | AND S.type = $tag |
| 186 | AND S.commit_count > 0 |
| 187 | }] { |
| 188 | trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits." |
| 189 | } |
| 190 | return |
| 191 | } |
| @@ -199,15 +202,15 @@ | |
| 199 | |
| 200 | state run { |
| 201 | DELETE FROM blocker |
| 202 | WHERE bid IN (SELECT sid |
| 203 | FROM symbol |
| 204 | WhERE type = $excl); |
| 205 | DELETE FROM parent |
| 206 | WHERE pid IN (SELECT sid |
| 207 | FROM symbol |
| 208 | WhERE type = $excl); |
| 209 | } |
| 210 | return |
| 211 | } |
| 212 | |
| 213 | proc DeterminePreferedParents {} { |
| @@ -224,15 +227,16 @@ | |
| 224 | # attempt to compute them. |
| 225 | |
| 226 | foreach {s p sname pname prname votes} [state run { |
| 227 | SELECT S.sid, P.pid, S.name, SB.name, PR.name, P.n |
| 228 | FROM symbol S, parent P, symbol SB, project PR |
| 229 | WHERE S.sid = P.sid |
| 230 | AND P.pid = SB.sid |
| 231 | AND S.pid = PR.pid |
| 232 | AND S.type != $excl |
| 233 | ORDER BY P.n ASC, P.pid DESC |
| 234 | -- Higher votes and smaller ids (= earlier branches) last |
| 235 | -- We simply keep the last possible parent for each |
| 236 | -- symbol. This parent will have the max number of votes |
| 237 | -- for its symbol and will be the earliest created branch |
| 238 | -- possible among all with many votes. |
| @@ -260,16 +264,17 @@ | |
| 260 | # excluded symbols, as we intentionally did not |
| 261 | # compute a prefered parent for them, see phase I. |
| 262 | |
| 263 | foreach {pname sname} [state run { |
| 264 | SELECT PR.name, S.name |
| 265 | FROM project PR, symbol S LEFT OUTER JOIN preferedparent P |
| 266 | ON S.sid = P.sid |
| 267 | WHERE P.pid IS NULL |
| 268 | AND S.name != ':trunk:' |
| 269 | AND S.pid = PR.pid |
| 270 | AND S.type != $excl |
| 271 | }] { |
| 272 | trouble fatal "$pname : '$sname' has no prefered parent." |
| 273 | } |
| 274 | |
| 275 | # The reverse, having prefered parents for unknown symbols |
| 276 |
| --- tools/cvs2fossil/lib/c2f_pcollsym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pcollsym.tcl | |
| @@ -58,11 +58,11 @@ | |
| 58 | -- project. |
| 59 | |
| 60 | sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol, |
| 61 | pid INTEGER NOT NULL REFERENCES symbol |
| 62 | } { pid } |
| 63 | # Index on: pid (branch successors) |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | typemethod load {} { |
| 68 | # Pass manager interface. Executed to load data computed by |
| @@ -111,21 +111,24 @@ | |
| 111 | } |
| 112 | |
| 113 | # # ## ### ##### ######## ############# |
| 114 | ## Internal methods |
| 115 | |
| 116 | ## TODO: Move UnconvertedSymbols, BadSymbolTypes, BlockedIncludes, |
| 117 | ## InvalidTags to the integrity module? |
| 118 | |
| 119 | proc UnconvertedSymbols {} { |
| 120 | # Paranoia - Have we left symbols without conversion |
| 121 | # information (i.e. with type 'undefined') ? |
| 122 | |
| 123 | set undef [project::sym undef] |
| 124 | |
| 125 | foreach {pname sname} [state run { |
| 126 | SELECT P.name, S.name |
| 127 | FROM symbol S, project P |
| 128 | WHERE S.type = $undef -- Restrict to undefined symbols |
| 129 | AND P.pid = S.pid -- Get project for symbol |
| 130 | }] { |
| 131 | trouble fatal "$pname : The symbol '$sname' was left undefined" |
| 132 | } |
| 133 | return |
| 134 | } |
| @@ -135,13 +138,13 @@ | |
| 138 | # information (type out of the valid range (excluded, branch, |
| 139 | # tag)) ? |
| 140 | |
| 141 | foreach {pname sname} [state run { |
| 142 | SELECT P.name, S.name |
| 143 | FROM symbol S, project P |
| 144 | WHERE S.type NOT IN (0,1,2) -- Restrict to symbols with bogus type codes |
| 145 | AND P.pid = S.pid -- Get project of symbol |
| 146 | }] { |
| 147 | trouble fatal "$pname : The symbol '$sname' has no proper conversion type" |
| 148 | } |
| 149 | return |
| 150 | } |
| @@ -152,16 +155,16 @@ | |
| 155 | |
| 156 | set excl [project::sym excluded] |
| 157 | |
| 158 | foreach {pname sname bname} [state run { |
| 159 | SELECT P.name, S.name, SB.name |
| 160 | FROM symbol S, blocker B, symbol SB, project P |
| 161 | WHERE S.type = $excl -- Restrict to excluded symbols |
| 162 | AND S.sid = B.sid -- Get symbols blocking them |
| 163 | AND B.bid = SB.sid -- and |
| 164 | AND SB.type != $excl -- which are not excluded themselves |
| 165 | AND P.pid = S.pid -- Get project of symbol |
| 166 | }] { |
| 167 | trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it." |
| 168 | } |
| 169 | return |
| 170 | } |
| @@ -179,13 +182,13 @@ | |
| 182 | set tag [project::sym tag] |
| 183 | |
| 184 | foreach {pname sname} [state run { |
| 185 | SELECT P.name, S.name |
| 186 | FROM project P, symbol S |
| 187 | WHERE S.type = $tag -- Restrict to tag symbols |
| 188 | AND S.commit_count > 0 -- which have revisions committed to them |
| 189 | AND P.pid = S.pid -- Get project of symbol |
| 190 | }] { |
| 191 | trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits." |
| 192 | } |
| 193 | return |
| 194 | } |
| @@ -199,15 +202,15 @@ | |
| 202 | |
| 203 | state run { |
| 204 | DELETE FROM blocker |
| 205 | WHERE bid IN (SELECT sid |
| 206 | FROM symbol |
| 207 | WhERE type = $excl); -- Get excluded symbols |
| 208 | DELETE FROM parent |
| 209 | WHERE pid IN (SELECT sid |
| 210 | FROM symbol |
| 211 | WhERE type = $excl); -- Get excluded symbols |
| 212 | } |
| 213 | return |
| 214 | } |
| 215 | |
| 216 | proc DeterminePreferedParents {} { |
| @@ -224,15 +227,16 @@ | |
| 227 | # attempt to compute them. |
| 228 | |
| 229 | foreach {s p sname pname prname votes} [state run { |
| 230 | SELECT S.sid, P.pid, S.name, SB.name, PR.name, P.n |
| 231 | FROM symbol S, parent P, symbol SB, project PR |
| 232 | WHERE S.type != $excl -- Restrict to wanted symbols |
| 233 | AND S.sid = P.sid -- Get possible parents of symbol |
| 234 | AND P.pid = SB.sid -- and |
| 235 | AND S.pid = PR.pid -- the project of the symbol |
| 236 | ORDER BY P.n ASC, P.pid DESC -- Sorting, see below |
| 237 | -- |
| 238 | -- Higher votes and smaller ids (= earlier branches) last |
| 239 | -- We simply keep the last possible parent for each |
| 240 | -- symbol. This parent will have the max number of votes |
| 241 | -- for its symbol and will be the earliest created branch |
| 242 | -- possible among all with many votes. |
| @@ -260,16 +264,17 @@ | |
| 264 | # excluded symbols, as we intentionally did not |
| 265 | # compute a prefered parent for them, see phase I. |
| 266 | |
| 267 | foreach {pname sname} [state run { |
| 268 | SELECT PR.name, S.name |
| 269 | FROM symbol S LEFT OUTER JOIN preferedparent P |
| 270 | ON S.sid = P.sid, -- From symbol to prefered parent |
| 271 | project PR |
| 272 | WHERE P.pid IS NULL -- restrict to symbols without a preference |
| 273 | AND S.type != $excl -- which are not excluded |
| 274 | AND S.name != ':trunk:' -- and are not a trunk |
| 275 | AND S.pid = PR.pid -- get project of symbol |
| 276 | }] { |
| 277 | trouble fatal "$pname : '$sname' has no prefered parent." |
| 278 | } |
| 279 | |
| 280 | # The reverse, having prefered parents for unknown symbols |
| 281 |