Fossil SCM
Brought knowledge of the new types to the state definition, changed the creation of the initial changesets to use tags and branches.
Commit
215d2f1ad99b8705e7fe961fa169cf76430c7864
Parent
c74fe3de3fd031f…
1 file changed
+57
-56
+57
-56
| --- tools/cvs2fossil/lib/c2f_pinitcsets.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl | ||
| @@ -67,30 +67,34 @@ | ||
| 67 | 67 | state writing cstype { |
| 68 | 68 | tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 69 | 69 | name TEXT NOT NULL, |
| 70 | 70 | UNIQUE (name) |
| 71 | 71 | } |
| 72 | + # Note: Keep the labels used here in sync with the names for | |
| 73 | + # singleton helper classes for 'project::rev'. They are | |
| 74 | + # the valid type names for changesets and also hardwired | |
| 75 | + # in some code. | |
| 72 | 76 | state run { |
| 73 | 77 | INSERT INTO cstype VALUES (0,'rev'); |
| 74 | - INSERT INTO cstype VALUES (1,'sym'); | |
| 78 | + INSERT INTO cstype VALUES (1,'sym::tag'); | |
| 79 | + INSERT INTO cstype VALUES (2,'sym::branch'); | |
| 75 | 80 | } |
| 76 | 81 | |
| 77 | - # Map from changesets to the (file level) revisions they | |
| 78 | - # contain. The pos'ition provides an order of the revisions | |
| 79 | - # within a changeset. They are unique within the changeset. | |
| 80 | - # The revisions are in principle unique, if we were looking | |
| 81 | - # only at revision changesets. However a revision can appear | |
| 82 | - # in both revision and symbol changesets, and in multiple | |
| 83 | - # symbol changesets as well. So we can only say that it is | |
| 84 | - # unique within the changeset. | |
| 85 | - # | |
| 86 | - # TODO: Check if integrity checks are possible. | |
| 82 | + # Map from changesets to the (file level) revisions, tags, or | |
| 83 | + # branches they contain. The pos'ition provides an order of | |
| 84 | + # the items within a changeset. They are unique within the | |
| 85 | + # changeset. The items are in principle unique, if we were | |
| 86 | + # looking only at relevant changesets. However as they come | |
| 87 | + # from disparate sources the same id may have different | |
| 88 | + # meaning, be in different changesets and so is formally not | |
| 89 | + # unique. So we can only say that it is unique within the | |
| 90 | + # changeset. The integrity module has stronger checks. | |
| 87 | 91 | |
| 88 | 92 | state writing csrevision { |
| 89 | 93 | cid INTEGER NOT NULL REFERENCES changeset, |
| 90 | 94 | pos INTEGER NOT NULL, |
| 91 | - rid INTEGER NOT NULL REFERENCES revision, | |
| 95 | + rid INTEGER NOT NULL, -- REFERENCES revision|tag|branch | |
| 92 | 96 | UNIQUE (cid, pos), |
| 93 | 97 | UNIQUE (cid, rid) |
| 94 | 98 | } |
| 95 | 99 | |
| 96 | 100 | project::rev getcstypes |
| @@ -103,10 +107,14 @@ | ||
| 103 | 107 | # executed. |
| 104 | 108 | |
| 105 | 109 | state reading changeset |
| 106 | 110 | state reading csrevision |
| 107 | 111 | state reading cstype |
| 112 | + | |
| 113 | + # Need the types first, the constructor in the loop below uses | |
| 114 | + # them to assert the correctness of type names. | |
| 115 | + project::rev getcstypes | |
| 108 | 116 | |
| 109 | 117 | foreach {id pid cstype srcid} [state run { |
| 110 | 118 | SELECT C.cid, C.pid, CS.name, C.src |
| 111 | 119 | FROM changeset C, cstype CS |
| 112 | 120 | WHERE C.type = CS.tid |
| @@ -118,11 +126,10 @@ | ||
| 118 | 126 | WHERE C.cid = $id |
| 119 | 127 | ORDER BY C.pos |
| 120 | 128 | }] $id] |
| 121 | 129 | } |
| 122 | 130 | |
| 123 | - project::rev getcstypes | |
| 124 | 131 | project::rev loadcounter |
| 125 | 132 | return |
| 126 | 133 | } |
| 127 | 134 | |
| 128 | 135 | typemethod run {} { |
| @@ -225,71 +232,65 @@ | ||
| 225 | 232 | |
| 226 | 233 | # First process the tags, then the branches. We know that |
| 227 | 234 | # their ids do not overlap with each other. |
| 228 | 235 | |
| 229 | 236 | set lastsymbol {} |
| 230 | - set lastlod {} | |
| 231 | 237 | set lastproject {} |
| 232 | 238 | set revisions {} |
| 233 | 239 | |
| 234 | - foreach {sid rid lod pid} [state run { | |
| 235 | - SELECT S.sid, R.rid, R.lod, S.pid | |
| 236 | - FROM tag T, revision R, symbol S -- T ==> R/S, using PK indices of R, S. | |
| 237 | - WHERE T.rev = R.rid | |
| 238 | - AND T.sid = S.sid | |
| 239 | - ORDER BY S.sid, R.lod, R.date | |
| 240 | + foreach {sid rid pid} [state run { | |
| 241 | + SELECT S.sid, T.tid, S.pid | |
| 242 | + FROM tag T, symbol S -- T ==> R/S, using PK indices of R, S. | |
| 243 | + WHERE T.sid = S.sid | |
| 244 | + ORDER BY S.sid, T.tid | |
| 240 | 245 | }] { |
| 241 | - if {($lastlod != $lod) || ($lastsymbol != $sid)} { | |
| 246 | + if {$lastsymbol != $sid} { | |
| 242 | 247 | if {[llength $revisions]} { |
| 243 | 248 | incr n |
| 244 | 249 | set p [repository projectof $lastproject] |
| 245 | - project::rev %AUTO% $p sym $lastsymbol $revisions | |
| 250 | + project::rev %AUTO% $p sym::tag $lastsymbol $revisions | |
| 246 | 251 | set revisions {} |
| 247 | 252 | } |
| 248 | 253 | set lastsymbol $sid |
| 249 | - set lastlod $lod | |
| 254 | + set lastproject $pid | |
| 255 | + } | |
| 256 | + lappend revisions $rid | |
| 257 | + } | |
| 258 | + | |
| 259 | + if {[llength $revisions]} { | |
| 260 | + incr n | |
| 261 | + set p [repository projectof $lastproject] | |
| 262 | + project::rev %AUTO% $p sym::tag $lastsymbol $revisions | |
| 263 | + } | |
| 264 | + | |
| 265 | + set lastsymbol {} | |
| 266 | + set lasproject {} | |
| 267 | + set revisions {} | |
| 268 | + | |
| 269 | + foreach {sid rid pid} [state run { | |
| 270 | + SELECT S.sid, B.bid, S.pid | |
| 271 | + FROM branch B, symbol S -- B ==> R/S, using PK indices of R, S. | |
| 272 | + WHERE B.sid = S.sid | |
| 273 | + ORDER BY S.sid, B.bid | |
| 274 | + }] { | |
| 275 | + if {$lastsymbol != $sid} { | |
| 276 | + if {[llength $revisions]} { | |
| 277 | + incr n | |
| 278 | + set p [repository projectof $lastproject] | |
| 279 | + project::rev %AUTO% $p sym::branch $lastsymbol $revisions | |
| 280 | + set revisions {} | |
| 281 | + } | |
| 282 | + set lastsymbol $sid | |
| 250 | 283 | set lastproject $pid |
| 251 | 284 | } |
| 252 | 285 | lappend revisions $rid |
| 253 | 286 | } |
| 254 | 287 | |
| 255 | 288 | if {[llength $revisions]} { |
| 256 | 289 | incr n |
| 257 | 290 | set p [repository projectof $lastproject] |
| 258 | - project::rev %AUTO% $p sym $lastsymbol $revisions | |
| 259 | - } | |
| 260 | - | |
| 261 | - set lastsymbol {} | |
| 262 | - set lastlod {} | |
| 263 | - set lasproject {} | |
| 264 | - set revisions {} | |
| 265 | - | |
| 266 | - foreach {sid rid lod pid} [state run { | |
| 267 | - SELECT S.sid, R.rid, R.lod, S.pid | |
| 268 | - FROM branch B, revision R, symbol S -- B ==> R/S, using PK indices of R, S. | |
| 269 | - WHERE B.root = R.rid | |
| 270 | - AND B.sid = S.sid | |
| 271 | - ORDER BY S.sid, R.lod, R.date | |
| 272 | - }] { | |
| 273 | - if {($lastlod != $lod) || ($lastsymbol != $sid)} { | |
| 274 | - if {[llength $revisions]} { | |
| 275 | - incr n | |
| 276 | - set p [repository projectof $lastproject] | |
| 277 | - project::rev %AUTO% $p sym $lastsymbol $revisions | |
| 278 | - set revisions {} | |
| 279 | - } | |
| 280 | - set lastsymbol $sid | |
| 281 | - set lastlod $lod | |
| 282 | - set lastproject $pid | |
| 283 | - } | |
| 284 | - lappend revisions $rid | |
| 285 | - } | |
| 286 | - | |
| 287 | - if {[llength $revisions]} { | |
| 288 | - incr n | |
| 289 | - set p [repository projectof $lastproject] | |
| 290 | - project::rev %AUTO% $p sym $lastsymbol $revisions | |
| 291 | + project::rev %AUTO% $p sym::branch $lastsymbol $revisions | |
| 291 | 292 | } |
| 292 | 293 | |
| 293 | 294 | log write 4 initcsets "Created [nsp $n {symbol changeset}]" |
| 294 | 295 | return |
| 295 | 296 | } |
| 296 | 297 |
| --- tools/cvs2fossil/lib/c2f_pinitcsets.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl | |
| @@ -67,30 +67,34 @@ | |
| 67 | state writing cstype { |
| 68 | tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 69 | name TEXT NOT NULL, |
| 70 | UNIQUE (name) |
| 71 | } |
| 72 | state run { |
| 73 | INSERT INTO cstype VALUES (0,'rev'); |
| 74 | INSERT INTO cstype VALUES (1,'sym'); |
| 75 | } |
| 76 | |
| 77 | # Map from changesets to the (file level) revisions they |
| 78 | # contain. The pos'ition provides an order of the revisions |
| 79 | # within a changeset. They are unique within the changeset. |
| 80 | # The revisions are in principle unique, if we were looking |
| 81 | # only at revision changesets. However a revision can appear |
| 82 | # in both revision and symbol changesets, and in multiple |
| 83 | # symbol changesets as well. So we can only say that it is |
| 84 | # unique within the changeset. |
| 85 | # |
| 86 | # TODO: Check if integrity checks are possible. |
| 87 | |
| 88 | state writing csrevision { |
| 89 | cid INTEGER NOT NULL REFERENCES changeset, |
| 90 | pos INTEGER NOT NULL, |
| 91 | rid INTEGER NOT NULL REFERENCES revision, |
| 92 | UNIQUE (cid, pos), |
| 93 | UNIQUE (cid, rid) |
| 94 | } |
| 95 | |
| 96 | project::rev getcstypes |
| @@ -103,10 +107,14 @@ | |
| 103 | # executed. |
| 104 | |
| 105 | state reading changeset |
| 106 | state reading csrevision |
| 107 | state reading cstype |
| 108 | |
| 109 | foreach {id pid cstype srcid} [state run { |
| 110 | SELECT C.cid, C.pid, CS.name, C.src |
| 111 | FROM changeset C, cstype CS |
| 112 | WHERE C.type = CS.tid |
| @@ -118,11 +126,10 @@ | |
| 118 | WHERE C.cid = $id |
| 119 | ORDER BY C.pos |
| 120 | }] $id] |
| 121 | } |
| 122 | |
| 123 | project::rev getcstypes |
| 124 | project::rev loadcounter |
| 125 | return |
| 126 | } |
| 127 | |
| 128 | typemethod run {} { |
| @@ -225,71 +232,65 @@ | |
| 225 | |
| 226 | # First process the tags, then the branches. We know that |
| 227 | # their ids do not overlap with each other. |
| 228 | |
| 229 | set lastsymbol {} |
| 230 | set lastlod {} |
| 231 | set lastproject {} |
| 232 | set revisions {} |
| 233 | |
| 234 | foreach {sid rid lod pid} [state run { |
| 235 | SELECT S.sid, R.rid, R.lod, S.pid |
| 236 | FROM tag T, revision R, symbol S -- T ==> R/S, using PK indices of R, S. |
| 237 | WHERE T.rev = R.rid |
| 238 | AND T.sid = S.sid |
| 239 | ORDER BY S.sid, R.lod, R.date |
| 240 | }] { |
| 241 | if {($lastlod != $lod) || ($lastsymbol != $sid)} { |
| 242 | if {[llength $revisions]} { |
| 243 | incr n |
| 244 | set p [repository projectof $lastproject] |
| 245 | project::rev %AUTO% $p sym $lastsymbol $revisions |
| 246 | set revisions {} |
| 247 | } |
| 248 | set lastsymbol $sid |
| 249 | set lastlod $lod |
| 250 | set lastproject $pid |
| 251 | } |
| 252 | lappend revisions $rid |
| 253 | } |
| 254 | |
| 255 | if {[llength $revisions]} { |
| 256 | incr n |
| 257 | set p [repository projectof $lastproject] |
| 258 | project::rev %AUTO% $p sym $lastsymbol $revisions |
| 259 | } |
| 260 | |
| 261 | set lastsymbol {} |
| 262 | set lastlod {} |
| 263 | set lasproject {} |
| 264 | set revisions {} |
| 265 | |
| 266 | foreach {sid rid lod pid} [state run { |
| 267 | SELECT S.sid, R.rid, R.lod, S.pid |
| 268 | FROM branch B, revision R, symbol S -- B ==> R/S, using PK indices of R, S. |
| 269 | WHERE B.root = R.rid |
| 270 | AND B.sid = S.sid |
| 271 | ORDER BY S.sid, R.lod, R.date |
| 272 | }] { |
| 273 | if {($lastlod != $lod) || ($lastsymbol != $sid)} { |
| 274 | if {[llength $revisions]} { |
| 275 | incr n |
| 276 | set p [repository projectof $lastproject] |
| 277 | project::rev %AUTO% $p sym $lastsymbol $revisions |
| 278 | set revisions {} |
| 279 | } |
| 280 | set lastsymbol $sid |
| 281 | set lastlod $lod |
| 282 | set lastproject $pid |
| 283 | } |
| 284 | lappend revisions $rid |
| 285 | } |
| 286 | |
| 287 | if {[llength $revisions]} { |
| 288 | incr n |
| 289 | set p [repository projectof $lastproject] |
| 290 | project::rev %AUTO% $p sym $lastsymbol $revisions |
| 291 | } |
| 292 | |
| 293 | log write 4 initcsets "Created [nsp $n {symbol changeset}]" |
| 294 | return |
| 295 | } |
| 296 |
| --- tools/cvs2fossil/lib/c2f_pinitcsets.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pinitcsets.tcl | |
| @@ -67,30 +67,34 @@ | |
| 67 | state writing cstype { |
| 68 | tid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 69 | name TEXT NOT NULL, |
| 70 | UNIQUE (name) |
| 71 | } |
| 72 | # Note: Keep the labels used here in sync with the names for |
| 73 | # singleton helper classes for 'project::rev'. They are |
| 74 | # the valid type names for changesets and also hardwired |
| 75 | # in some code. |
| 76 | state run { |
| 77 | INSERT INTO cstype VALUES (0,'rev'); |
| 78 | INSERT INTO cstype VALUES (1,'sym::tag'); |
| 79 | INSERT INTO cstype VALUES (2,'sym::branch'); |
| 80 | } |
| 81 | |
| 82 | # Map from changesets to the (file level) revisions, tags, or |
| 83 | # branches they contain. The pos'ition provides an order of |
| 84 | # the items within a changeset. They are unique within the |
| 85 | # changeset. The items are in principle unique, if we were |
| 86 | # looking only at relevant changesets. However as they come |
| 87 | # from disparate sources the same id may have different |
| 88 | # meaning, be in different changesets and so is formally not |
| 89 | # unique. So we can only say that it is unique within the |
| 90 | # changeset. The integrity module has stronger checks. |
| 91 | |
| 92 | state writing csrevision { |
| 93 | cid INTEGER NOT NULL REFERENCES changeset, |
| 94 | pos INTEGER NOT NULL, |
| 95 | rid INTEGER NOT NULL, -- REFERENCES revision|tag|branch |
| 96 | UNIQUE (cid, pos), |
| 97 | UNIQUE (cid, rid) |
| 98 | } |
| 99 | |
| 100 | project::rev getcstypes |
| @@ -103,10 +107,14 @@ | |
| 107 | # executed. |
| 108 | |
| 109 | state reading changeset |
| 110 | state reading csrevision |
| 111 | state reading cstype |
| 112 | |
| 113 | # Need the types first, the constructor in the loop below uses |
| 114 | # them to assert the correctness of type names. |
| 115 | project::rev getcstypes |
| 116 | |
| 117 | foreach {id pid cstype srcid} [state run { |
| 118 | SELECT C.cid, C.pid, CS.name, C.src |
| 119 | FROM changeset C, cstype CS |
| 120 | WHERE C.type = CS.tid |
| @@ -118,11 +126,10 @@ | |
| 126 | WHERE C.cid = $id |
| 127 | ORDER BY C.pos |
| 128 | }] $id] |
| 129 | } |
| 130 | |
| 131 | project::rev loadcounter |
| 132 | return |
| 133 | } |
| 134 | |
| 135 | typemethod run {} { |
| @@ -225,71 +232,65 @@ | |
| 232 | |
| 233 | # First process the tags, then the branches. We know that |
| 234 | # their ids do not overlap with each other. |
| 235 | |
| 236 | set lastsymbol {} |
| 237 | set lastproject {} |
| 238 | set revisions {} |
| 239 | |
| 240 | foreach {sid rid pid} [state run { |
| 241 | SELECT S.sid, T.tid, S.pid |
| 242 | FROM tag T, symbol S -- T ==> R/S, using PK indices of R, S. |
| 243 | WHERE T.sid = S.sid |
| 244 | ORDER BY S.sid, T.tid |
| 245 | }] { |
| 246 | if {$lastsymbol != $sid} { |
| 247 | if {[llength $revisions]} { |
| 248 | incr n |
| 249 | set p [repository projectof $lastproject] |
| 250 | project::rev %AUTO% $p sym::tag $lastsymbol $revisions |
| 251 | set revisions {} |
| 252 | } |
| 253 | set lastsymbol $sid |
| 254 | set lastproject $pid |
| 255 | } |
| 256 | lappend revisions $rid |
| 257 | } |
| 258 | |
| 259 | if {[llength $revisions]} { |
| 260 | incr n |
| 261 | set p [repository projectof $lastproject] |
| 262 | project::rev %AUTO% $p sym::tag $lastsymbol $revisions |
| 263 | } |
| 264 | |
| 265 | set lastsymbol {} |
| 266 | set lasproject {} |
| 267 | set revisions {} |
| 268 | |
| 269 | foreach {sid rid pid} [state run { |
| 270 | SELECT S.sid, B.bid, S.pid |
| 271 | FROM branch B, symbol S -- B ==> R/S, using PK indices of R, S. |
| 272 | WHERE B.sid = S.sid |
| 273 | ORDER BY S.sid, B.bid |
| 274 | }] { |
| 275 | if {$lastsymbol != $sid} { |
| 276 | if {[llength $revisions]} { |
| 277 | incr n |
| 278 | set p [repository projectof $lastproject] |
| 279 | project::rev %AUTO% $p sym::branch $lastsymbol $revisions |
| 280 | set revisions {} |
| 281 | } |
| 282 | set lastsymbol $sid |
| 283 | set lastproject $pid |
| 284 | } |
| 285 | lappend revisions $rid |
| 286 | } |
| 287 | |
| 288 | if {[llength $revisions]} { |
| 289 | incr n |
| 290 | set p [repository projectof $lastproject] |
| 291 | project::rev %AUTO% $p sym::branch $lastsymbol $revisions |
| 292 | } |
| 293 | |
| 294 | log write 4 initcsets "Created [nsp $n {symbol changeset}]" |
| 295 | return |
| 296 | } |
| 297 |