Fossil

Check-in [f7fe15cd]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:More comments on sql statements, slight reordering of some tables and conditions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f7fe15cd0cb6cc28a32cc40c13bb12b9faccd673
User & Date: aku 2007-12-08 03:39:27
Context
2008-01-19
06:07
More comments on sql statements. check-in: 6809145e user: aku tags: trunk
2007-12-08
03:39
More comments on sql statements, slight reordering of some tables and conditions. check-in: f7fe15cd user: aku tags: trunk
02:59
Added comments explaining the select statement checking revision/file/project/metadata integrity check-in: 808fbc47 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/cvs2fossil/lib/c2f_pcollsym.tcl.

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
109
110
111
112
113
114
115



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
150
151
152
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
...
222
223
224
225
226
227
228

229
230
231
232
233

234
235
236
237
238
239
240
...
258
259
260
261
262
263
264
265
266

267

268
269
270
271
272
273
274
275
276
277
	    -- tree of the found lines of development. Actually a
	    -- forest in case of multiple projects, with one tree per
	    -- project.

	    sid INTEGER  NOT NULL  PRIMARY KEY  REFERENCES symbol,
	    pid INTEGER  NOT NULL               REFERENCES symbol
	} { pid }
	# Index on: pid (branch successors`)
	return
    }

    typemethod load {} {
	# Pass manager interface. Executed to load data computed by
	# this pass into memory when this pass is skipped instead of
	# executed.
................................................................................
	state discard preferedparent
	return
    }

    # # ## ### ##### ######## #############
    ## Internal methods




    proc UnconvertedSymbols {} {
	# Paranoia - Have we left symbols without conversion
	# information (i.e. with type 'undefined') ?

	set undef [project::sym undef]

	foreach {pname sname} [state run {
	    SELECT P.name, S.name
	    FROM   project P, symbol S
	    WHERE  P.pid = S.pid
	    AND    S.type = $undef
	}] {
	    trouble fatal "$pname : The symbol '$sname' was left undefined"
	}
	return
    }

    proc BadSymbolTypes {} {
	# Paranoia - Have we left symbols with bogus conversion
	# information (type out of the valid range (excluded, branch,
	# tag)) ?

	foreach {pname sname} [state run {
	    SELECT P.name, S.name
	    FROM   project P, symbol S
	    WHERE  P.pid = S.pid
	    AND    S.type NOT IN (0,1,2)
	}] {
	    trouble fatal "$pname : The symbol '$sname' has no proper conversion type"
	}
	return
    }

    proc BlockedExcludes {} {
................................................................................
	# Paranoia - Have we scheduled symbols for exclusion without
	# also excluding their dependent symbols ?

	set excl [project::sym excluded]

	foreach {pname sname bname} [state run {
	    SELECT P.name, S.name, SB.name
	    FROM   project P, symbol S, blocker B, symbol SB
	    WHERE  P.pid = S.pid
	    AND    S.type = $excl
	    AND    S.sid = B.sid
	    AND    B.bid = SB.sid
	    AND    SB.type != $excl

	}] {
	    trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it."
	}
	return
    }

    proc InvalidTags {} {
................................................................................
	# 'project::sym.HasCommits()'.

	set tag [project::sym tag]

	foreach {pname sname} [state run {
	    SELECT P.name, S.name
	    FROM   project P, symbol S
	    WHERE  P.pid = S.pid
	    AND    S.type = $tag
	    AND    S.commit_count > 0
	}] {
	    trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits."
	}
	return
    }

    proc DropExcludedSymbolsFromReferences {} {
................................................................................

	set excl [project::sym excluded]

	state run {
	    DELETE FROM blocker
	    WHERE bid IN (SELECT sid
			  FROM   symbol
			  WhERE  type = $excl);
	    DELETE FROM parent
	    WHERE pid IN (SELECT sid
			  FROM   symbol
			  WhERE  type = $excl);
	}
	return
    }

    proc DeterminePreferedParents {} {
	array set prefered {}

................................................................................
	#          selections. Note that we ignore excluded symbol, we
	#          do not care about their prefered parents and do not
	#          attempt to compute them.

	foreach {s p sname pname prname votes} [state run {
	    SELECT   S.sid, P.pid, S.name, SB.name, PR.name, P.n
	    FROM     symbol S, parent P, symbol SB, project PR

	    WHERE    S.sid = P.sid
	    AND      P.pid = SB.sid
	    AND      S.pid = PR.pid
	    AND      S.type != $excl
	    ORDER BY P.n ASC, P.pid DESC

	    -- Higher votes and smaller ids (= earlier branches) last
	    -- We simply keep the last possible parent for each
	    -- symbol.  This parent will have the max number of votes
	    -- for its symbol and will be the earliest created branch
	    -- possible among all with many votes.
	}] {
	    log write 9 pcollsym "Voting $votes for Parent($sname) = $pname"
................................................................................
	# Phase III: Check the result that all symbols except for
	#            trunks have a prefered parent. We also ignore
	#            excluded symbols, as we intentionally did not
	#            compute a prefered parent for them, see phase I.

	foreach {pname sname} [state run {
	    SELECT PR.name, S.name
	    FROM   project PR, symbol S LEFT OUTER JOIN preferedparent P
	    ON     S.sid = P.sid

	    WHERE  P.pid IS NULL

	    AND    S.name != ':trunk:'
	    AND    S.pid = PR.pid
	    AND    S.type != $excl
	}] {
	    trouble fatal "$pname : '$sname' has no prefered parent."
	}

	# The reverse, having prefered parents for unknown symbols
	# cannot occur.
	return







|







 







>
>
>








|
|
|













|
|
|







 







|
<
|
|
|
|
>







 







|
|
|







 







|



|







 







>
|
|
|
<
|
>







 







|
|
>
|
>
|
|
<







56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
153
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169
170
171
172
...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
...
225
226
227
228
229
230
231
232
233
234
235

236
237
238
239
240
241
242
243
244
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275

276
277
278
279
280
281
282
	    -- tree of the found lines of development. Actually a
	    -- forest in case of multiple projects, with one tree per
	    -- project.

	    sid INTEGER  NOT NULL  PRIMARY KEY  REFERENCES symbol,
	    pid INTEGER  NOT NULL               REFERENCES symbol
	} { pid }
	# Index on: pid (branch successors)
	return
    }

    typemethod load {} {
	# Pass manager interface. Executed to load data computed by
	# this pass into memory when this pass is skipped instead of
	# executed.
................................................................................
	state discard preferedparent
	return
    }

    # # ## ### ##### ######## #############
    ## Internal methods

    ## TODO: Move UnconvertedSymbols, BadSymbolTypes, BlockedIncludes,
    ##       InvalidTags to the integrity module?

    proc UnconvertedSymbols {} {
	# Paranoia - Have we left symbols without conversion
	# information (i.e. with type 'undefined') ?

	set undef [project::sym undef]

	foreach {pname sname} [state run {
	    SELECT P.name, S.name
	    FROM   symbol S, project P
	    WHERE  S.type = $undef  -- Restrict to undefined symbols
	    AND    P.pid = S.pid    -- Get project for symbol
	}] {
	    trouble fatal "$pname : The symbol '$sname' was left undefined"
	}
	return
    }

    proc BadSymbolTypes {} {
	# Paranoia - Have we left symbols with bogus conversion
	# information (type out of the valid range (excluded, branch,
	# tag)) ?

	foreach {pname sname} [state run {
	    SELECT P.name, S.name
	    FROM   symbol S, project P
	    WHERE  S.type NOT IN (0,1,2) -- Restrict to symbols with bogus type codes
	    AND    P.pid = S.pid         -- Get project of symbol
	}] {
	    trouble fatal "$pname : The symbol '$sname' has no proper conversion type"
	}
	return
    }

    proc BlockedExcludes {} {
................................................................................
	# Paranoia - Have we scheduled symbols for exclusion without
	# also excluding their dependent symbols ?

	set excl [project::sym excluded]

	foreach {pname sname bname} [state run {
	    SELECT P.name, S.name, SB.name
	    FROM   symbol S, blocker B, symbol SB, project P

	    WHERE  S.type = $excl   -- Restrict to excluded symbols
	    AND    S.sid = B.sid    -- Get symbols blocking them
	    AND    B.bid = SB.sid   -- and
	    AND    SB.type != $excl -- which are not excluded themselves
	    AND    P.pid = S.pid    -- Get project of symbol
	}] {
	    trouble fatal "$pname : The symbol '$sname' cannot be excluded as the unexcluded symbol '$bname' depends on it."
	}
	return
    }

    proc InvalidTags {} {
................................................................................
	# 'project::sym.HasCommits()'.

	set tag [project::sym tag]

	foreach {pname sname} [state run {
	    SELECT P.name, S.name
	    FROM   project P, symbol S
	    WHERE  S.type = $tag        -- Restrict to tag symbols
	    AND    S.commit_count > 0   -- which have revisions committed to them
	    AND    P.pid = S.pid        -- Get project of symbol
	}] {
	    trouble fatal "$pname : The symbol '$sname' cannot be forced to be converted as tag because it has commits."
	}
	return
    }

    proc DropExcludedSymbolsFromReferences {} {
................................................................................

	set excl [project::sym excluded]

	state run {
	    DELETE FROM blocker
	    WHERE bid IN (SELECT sid
			  FROM   symbol
			  WhERE  type = $excl); -- Get excluded symbols
	    DELETE FROM parent
	    WHERE pid IN (SELECT sid
			  FROM   symbol
			  WhERE  type = $excl); -- Get excluded symbols
	}
	return
    }

    proc DeterminePreferedParents {} {
	array set prefered {}

................................................................................
	#          selections. Note that we ignore excluded symbol, we
	#          do not care about their prefered parents and do not
	#          attempt to compute them.

	foreach {s p sname pname prname votes} [state run {
	    SELECT   S.sid, P.pid, S.name, SB.name, PR.name, P.n
	    FROM     symbol S, parent P, symbol SB, project PR
	    WHERE    S.type != $excl      -- Restrict to wanted symbols
	    AND      S.sid = P.sid        -- Get possible parents of symbol
	    AND      P.pid = SB.sid       -- and
	    AND      S.pid = PR.pid       -- the project of the symbol

	    ORDER BY P.n ASC, P.pid DESC  -- Sorting, see below
	    --
	    -- Higher votes and smaller ids (= earlier branches) last
	    -- We simply keep the last possible parent for each
	    -- symbol.  This parent will have the max number of votes
	    -- for its symbol and will be the earliest created branch
	    -- possible among all with many votes.
	}] {
	    log write 9 pcollsym "Voting $votes for Parent($sname) = $pname"
................................................................................
	# Phase III: Check the result that all symbols except for
	#            trunks have a prefered parent. We also ignore
	#            excluded symbols, as we intentionally did not
	#            compute a prefered parent for them, see phase I.

	foreach {pname sname} [state run {
	    SELECT PR.name, S.name
	    FROM   symbol S LEFT OUTER JOIN preferedparent P
	    ON     S.sid = P.sid,       -- From symbol to prefered parent
	           project PR
	    WHERE  P.pid IS NULL        -- restrict to symbols without a preference
	    AND    S.type != $excl      -- which are not excluded
	    AND    S.name != ':trunk:'  -- and are not a trunk
	    AND    S.pid = PR.pid       -- get project of symbol

	}] {
	    trouble fatal "$pname : '$sname' has no prefered parent."
	}

	# The reverse, having prefered parents for unknown symbols
	# cannot occur.
	return