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.
Commit
efc78b7a429e75f24b3325cf541e87034be89662
Parent
7eaa420a232a7aa…
1 file changed
+69
| --- tools/cvs2fossil/lib/c2f_pcollsym.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pcollsym.tcl | ||
| @@ -46,10 +46,20 @@ | ||
| 46 | 46 | # pass. |
| 47 | 47 | |
| 48 | 48 | state reading symbol |
| 49 | 49 | state reading blocker |
| 50 | 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 | + } | |
| 51 | 61 | return |
| 52 | 62 | } |
| 53 | 63 | |
| 54 | 64 | typemethod load {} { |
| 55 | 65 | # TODO |
| @@ -74,10 +84,11 @@ | ||
| 74 | 84 | InvalidTags |
| 75 | 85 | } |
| 76 | 86 | |
| 77 | 87 | if {![trouble ?]} { |
| 78 | 88 | DropExcludedSymbolsFromReferences |
| 89 | + DeterminePreferedParents | |
| 79 | 90 | } |
| 80 | 91 | |
| 81 | 92 | log write 1 collsym "Collation completed" |
| 82 | 93 | return |
| 83 | 94 | } |
| @@ -84,10 +95,12 @@ | ||
| 84 | 95 | |
| 85 | 96 | typemethod discard {} { |
| 86 | 97 | # Pass manager interface. Executed for all passes after the |
| 87 | 98 | # run passes, to remove all data of this pass from the state, |
| 88 | 99 | # as being out of date. |
| 100 | + | |
| 101 | + state discard preferedparent | |
| 89 | 102 | return |
| 90 | 103 | } |
| 91 | 104 | |
| 92 | 105 | # # ## ### ##### ######## ############# |
| 93 | 106 | ## Internal methods |
| @@ -186,10 +199,66 @@ | ||
| 186 | 199 | FROM symbol |
| 187 | 200 | WhERE type = $excl); |
| 188 | 201 | } |
| 189 | 202 | return |
| 190 | 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 | + } | |
| 191 | 260 | |
| 192 | 261 | # # ## ### ##### ######## ############# |
| 193 | 262 | ## Configuration |
| 194 | 263 | |
| 195 | 264 | pragma -hasinstances no ; # singleton |
| 196 | 265 |
| --- 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 |