Fossil SCM

Completed pass 3, CollateSymbols. Added code determining for each symbol the prefered parent from all possible parents. This is the symbol with the lowest id among the set with the maximum number of occurences as a parent.

aku 2007-11-06 04:39 trunk
Commit efc78b7a429e75f24b3325cf541e87034be89662
--- tools/cvs2fossil/lib/c2f_pcollsym.tcl
+++ tools/cvs2fossil/lib/c2f_pcollsym.tcl
@@ -46,10 +46,20 @@
4646
# pass.
4747
4848
state reading symbol
4949
state reading blocker
5050
state reading parent
51
+
52
+ state writing preferedparent {
53
+ -- For each symbol the prefered parent. This describes the
54
+ -- tree of the found lines of development. Actually a
55
+ -- forest in case of multiple projects, with one tree per
56
+ -- project.
57
+
58
+ sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol,
59
+ pid INTEGER NOT NULL REFERENCES symbol
60
+ }
5161
return
5262
}
5363
5464
typemethod load {} {
5565
# TODO
@@ -74,10 +84,11 @@
7484
InvalidTags
7585
}
7686
7787
if {![trouble ?]} {
7888
DropExcludedSymbolsFromReferences
89
+ DeterminePreferedParents
7990
}
8091
8192
log write 1 collsym "Collation completed"
8293
return
8394
}
@@ -84,10 +95,12 @@
8495
8596
typemethod discard {} {
8697
# Pass manager interface. Executed for all passes after the
8798
# run passes, to remove all data of this pass from the state,
8899
# as being out of date.
100
+
101
+ state discard preferedparent
89102
return
90103
}
91104
92105
# # ## ### ##### ######## #############
93106
## Internal methods
@@ -186,10 +199,66 @@
186199
FROM symbol
187200
WhERE type = $excl);
188201
}
189202
return
190203
}
204
+
205
+ proc DeterminePreferedParents {} {
206
+ array set prefered {}
207
+
208
+ # Phase I: Pull the possible parents, using sorting to put the
209
+ # prefered parent of each symbol last among all
210
+ # candidates, allowing us get the prefered one by
211
+ # each candidate overwriting all previous selections.
212
+
213
+ foreach {s p sname pname prname} [state run {
214
+ SELECT S.sid, P.pid, S.name, SB.name, PR.name
215
+ FROM symbol S, parent P, symbol SB, project PR
216
+ WHERE S.sid = P.sid
217
+ AND P.pid = SB.sid
218
+ AND S.pid = PR.pid
219
+ ORDER BY P.n ASC, P.pid DESC
220
+ -- Higher votes and smaller ids (= earlier branches) last
221
+ -- We simply keep the last possible parent for each
222
+ -- symbol. This parent will have the max number of votes
223
+ -- for its symbol and will be the earliest created branch
224
+ -- possible among all with many votes.
225
+ }] {
226
+ set prefered($s) [list $p $sname $pname $prname]
227
+ }
228
+
229
+ # Phase II: Write the found preferences back into the table
230
+ # this pass defined for it.
231
+
232
+ foreach {s x} [array get prefered] {
233
+ struct::list assign $x p sname pname prname
234
+ state run {
235
+ INSERT INTO preferedparent (sid, pid)
236
+ VALUES ($s, $p);
237
+ }
238
+
239
+ log write 3 pcollsym "$prname : '$sname's prefered parent is '$pname'"
240
+ }
241
+
242
+ # Phase III: Check the result that all symbols except for
243
+ # trunks have a prefered parent.
244
+
245
+ foreach {pname sname} [state run {
246
+ SELECT S.name, PR.name
247
+ FROM project PR, symbol S LEFT OUTER JOIN preferedparent P
248
+ ON S.sid = P.sid
249
+ WHERE P.pid IS NULL
250
+ AND S.name != ':trunk:'
251
+ AND S.pid = PR.pid
252
+ }] {
253
+ trouble fatal "$prname : '$sname' has no prefered parent."
254
+ }
255
+
256
+ # The reverse, having prefered parents for unknown symbols
257
+ # cannot occur.
258
+ return
259
+ }
191260
192261
# # ## ### ##### ######## #############
193262
## Configuration
194263
195264
pragma -hasinstances no ; # singleton
196265
--- tools/cvs2fossil/lib/c2f_pcollsym.tcl
+++ tools/cvs2fossil/lib/c2f_pcollsym.tcl
@@ -46,10 +46,20 @@
46 # pass.
47
48 state reading symbol
49 state reading blocker
50 state reading parent
 
 
 
 
 
 
 
 
 
 
51 return
52 }
53
54 typemethod load {} {
55 # TODO
@@ -74,10 +84,11 @@
74 InvalidTags
75 }
76
77 if {![trouble ?]} {
78 DropExcludedSymbolsFromReferences
 
79 }
80
81 log write 1 collsym "Collation completed"
82 return
83 }
@@ -84,10 +95,12 @@
84
85 typemethod discard {} {
86 # Pass manager interface. Executed for all passes after the
87 # run passes, to remove all data of this pass from the state,
88 # as being out of date.
 
 
89 return
90 }
91
92 # # ## ### ##### ######## #############
93 ## Internal methods
@@ -186,10 +199,66 @@
186 FROM symbol
187 WhERE type = $excl);
188 }
189 return
190 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
192 # # ## ### ##### ######## #############
193 ## Configuration
194
195 pragma -hasinstances no ; # singleton
196
--- tools/cvs2fossil/lib/c2f_pcollsym.tcl
+++ tools/cvs2fossil/lib/c2f_pcollsym.tcl
@@ -46,10 +46,20 @@
46 # pass.
47
48 state reading symbol
49 state reading blocker
50 state reading parent
51
52 state writing preferedparent {
53 -- For each symbol the prefered parent. This describes the
54 -- tree of the found lines of development. Actually a
55 -- forest in case of multiple projects, with one tree per
56 -- project.
57
58 sid INTEGER NOT NULL PRIMARY KEY REFERENCES symbol,
59 pid INTEGER NOT NULL REFERENCES symbol
60 }
61 return
62 }
63
64 typemethod load {} {
65 # TODO
@@ -74,10 +84,11 @@
84 InvalidTags
85 }
86
87 if {![trouble ?]} {
88 DropExcludedSymbolsFromReferences
89 DeterminePreferedParents
90 }
91
92 log write 1 collsym "Collation completed"
93 return
94 }
@@ -84,10 +95,12 @@
95
96 typemethod discard {} {
97 # Pass manager interface. Executed for all passes after the
98 # run passes, to remove all data of this pass from the state,
99 # as being out of date.
100
101 state discard preferedparent
102 return
103 }
104
105 # # ## ### ##### ######## #############
106 ## Internal methods
@@ -186,10 +199,66 @@
199 FROM symbol
200 WhERE type = $excl);
201 }
202 return
203 }
204
205 proc DeterminePreferedParents {} {
206 array set prefered {}
207
208 # Phase I: Pull the possible parents, using sorting to put the
209 # prefered parent of each symbol last among all
210 # candidates, allowing us get the prefered one by
211 # each candidate overwriting all previous selections.
212
213 foreach {s p sname pname prname} [state run {
214 SELECT S.sid, P.pid, S.name, SB.name, PR.name
215 FROM symbol S, parent P, symbol SB, project PR
216 WHERE S.sid = P.sid
217 AND P.pid = SB.sid
218 AND S.pid = PR.pid
219 ORDER BY P.n ASC, P.pid DESC
220 -- Higher votes and smaller ids (= earlier branches) last
221 -- We simply keep the last possible parent for each
222 -- symbol. This parent will have the max number of votes
223 -- for its symbol and will be the earliest created branch
224 -- possible among all with many votes.
225 }] {
226 set prefered($s) [list $p $sname $pname $prname]
227 }
228
229 # Phase II: Write the found preferences back into the table
230 # this pass defined for it.
231
232 foreach {s x} [array get prefered] {
233 struct::list assign $x p sname pname prname
234 state run {
235 INSERT INTO preferedparent (sid, pid)
236 VALUES ($s, $p);
237 }
238
239 log write 3 pcollsym "$prname : '$sname's prefered parent is '$pname'"
240 }
241
242 # Phase III: Check the result that all symbols except for
243 # trunks have a prefered parent.
244
245 foreach {pname sname} [state run {
246 SELECT S.name, PR.name
247 FROM project PR, symbol S LEFT OUTER JOIN preferedparent P
248 ON S.sid = P.sid
249 WHERE P.pid IS NULL
250 AND S.name != ':trunk:'
251 AND S.pid = PR.pid
252 }] {
253 trouble fatal "$prname : '$sname' has no prefered parent."
254 }
255
256 # The reverse, having prefered parents for unknown symbols
257 # cannot occur.
258 return
259 }
260
261 # # ## ### ##### ######## #############
262 ## Configuration
263
264 pragma -hasinstances no ; # singleton
265

Keyboard Shortcuts

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