Fossil SCM

More comments on sql statements, slight reordering of some tables and conditions.

aku 2007-12-08 03:39 trunk
Commit f7fe15cd0cb6cc28a32cc40c13bb12b9faccd673
--- tools/cvs2fossil/lib/c2f_pcollsym.tcl
+++ tools/cvs2fossil/lib/c2f_pcollsym.tcl
@@ -58,11 +58,11 @@
5858
-- project.
5959
6060
sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol,
6161
pid INTEGER NOT NULL REFERENCES symbol
6262
} { pid }
63
- # Index on: pid (branch successors`)
63
+ # Index on: pid (branch successors)
6464
return
6565
}
6666
6767
typemethod load {} {
6868
# Pass manager interface. Executed to load data computed by
@@ -111,21 +111,24 @@
111111
}
112112
113113
# # ## ### ##### ######## #############
114114
## Internal methods
115115
116
+ ## TODO: Move UnconvertedSymbols, BadSymbolTypes, BlockedIncludes,
117
+ ## InvalidTags to the integrity module?
118
+
116119
proc UnconvertedSymbols {} {
117120
# Paranoia - Have we left symbols without conversion
118121
# information (i.e. with type 'undefined') ?
119122
120123
set undef [project::sym undef]
121124
122125
foreach {pname sname} [state run {
123126
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
127130
}] {
128131
trouble fatal "$pname : The symbol '$sname' was left undefined"
129132
}
130133
return
131134
}
@@ -135,13 +138,13 @@
135138
# information (type out of the valid range (excluded, branch,
136139
# tag)) ?
137140
138141
foreach {pname sname} [state run {
139142
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
143146
}] {
144147
trouble fatal "$pname : The symbol '$sname' has no proper conversion type"
145148
}
146149
return
147150
}
@@ -152,16 +155,16 @@
152155
153156
set excl [project::sym excluded]
154157
155158
foreach {pname sname bname} [state run {
156159
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
163166
}] {
164167
trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it."
165168
}
166169
return
167170
}
@@ -179,13 +182,13 @@
179182
set tag [project::sym tag]
180183
181184
foreach {pname sname} [state run {
182185
SELECT P.name, S.name
183186
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
187190
}] {
188191
trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits."
189192
}
190193
return
191194
}
@@ -199,15 +202,15 @@
199202
200203
state run {
201204
DELETE FROM blocker
202205
WHERE bid IN (SELECT sid
203206
FROM symbol
204
- WhERE type = $excl);
207
+ WhERE type = $excl); -- Get excluded symbols
205208
DELETE FROM parent
206209
WHERE pid IN (SELECT sid
207210
FROM symbol
208
- WhERE type = $excl);
211
+ WhERE type = $excl); -- Get excluded symbols
209212
}
210213
return
211214
}
212215
213216
proc DeterminePreferedParents {} {
@@ -224,15 +227,16 @@
224227
# attempt to compute them.
225228
226229
foreach {s p sname pname prname votes} [state run {
227230
SELECT S.sid, P.pid, S.name, SB.name, PR.name, P.n
228231
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
+ --
234238
-- Higher votes and smaller ids (= earlier branches) last
235239
-- We simply keep the last possible parent for each
236240
-- symbol. This parent will have the max number of votes
237241
-- for its symbol and will be the earliest created branch
238242
-- possible among all with many votes.
@@ -260,16 +264,17 @@
260264
# excluded symbols, as we intentionally did not
261265
# compute a prefered parent for them, see phase I.
262266
263267
foreach {pname sname} [state run {
264268
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
271276
}] {
272277
trouble fatal "$pname : '$sname' has no prefered parent."
273278
}
274279
275280
# The reverse, having prefered parents for unknown symbols
276281
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button