Fossil SCM
Bugfix. Handle free-floating branches (their root revision was removed as unnecessary).
Commit
79c227a9c0acd62dc2d96248acdc5b95af138c13
Parent
5bbc7d4c57e5622…
4 files changed
+1
+8
-7
+8
-1
+16
-2
| --- tools/cvs2fossil/lib/c2f_file.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_file.tcl | ||
| @@ -766,10 +766,11 @@ | ||
| 766 | 766 | # use operation 'add', no need to change that. The first |
| 767 | 767 | # revision on each branch becomes a new and disconnected |
| 768 | 768 | # root. |
| 769 | 769 | |
| 770 | 770 | foreach branch [$root branches] { |
| 771 | + $branch cutbranchparent | |
| 771 | 772 | if {![$branch haschild]} continue |
| 772 | 773 | set first [$branch child] |
| 773 | 774 | $first cutfromparentbranch |
| 774 | 775 | $first cutfromparent |
| 775 | 776 | $branch cutchild |
| 776 | 777 |
| --- tools/cvs2fossil/lib/c2f_file.tcl | |
| +++ tools/cvs2fossil/lib/c2f_file.tcl | |
| @@ -766,10 +766,11 @@ | |
| 766 | # use operation 'add', no need to change that. The first |
| 767 | # revision on each branch becomes a new and disconnected |
| 768 | # root. |
| 769 | |
| 770 | foreach branch [$root branches] { |
| 771 | if {![$branch haschild]} continue |
| 772 | set first [$branch child] |
| 773 | $first cutfromparentbranch |
| 774 | $first cutfromparent |
| 775 | $branch cutchild |
| 776 |
| --- tools/cvs2fossil/lib/c2f_file.tcl | |
| +++ tools/cvs2fossil/lib/c2f_file.tcl | |
| @@ -766,10 +766,11 @@ | |
| 766 | # use operation 'add', no need to change that. The first |
| 767 | # revision on each branch becomes a new and disconnected |
| 768 | # root. |
| 769 | |
| 770 | foreach branch [$root branches] { |
| 771 | $branch cutbranchparent |
| 772 | if {![$branch haschild]} continue |
| 773 | set first [$branch child] |
| 774 | $first cutfromparentbranch |
| 775 | $first cutfromparent |
| 776 | $branch cutchild |
| 777 |
| --- tools/cvs2fossil/lib/c2f_fsym.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_fsym.tcl | ||
| @@ -119,14 +119,15 @@ | ||
| 119 | 119 | integrity assert {$mybranchchildrevnr eq ""} {Child already defined} |
| 120 | 120 | set mybranchchildrevnr $revnr |
| 121 | 121 | return |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - method setposition {n} { set mybranchposition $n ; return } | |
| 125 | - method setparent {rev} { set mybranchparent $rev ; return } | |
| 126 | - method setchild {rev} { set mybranchchild $rev ; return } | |
| 127 | - method cutchild {} { set mybranchchild "" ; return } | |
| 124 | + method setposition {n} { set mybranchposition $n ; return } | |
| 125 | + method setparent {rev} { set mybranchparent $rev ; return } | |
| 126 | + method setchild {rev} { set mybranchchild $rev ; return } | |
| 127 | + method cutchild {} { set mybranchchild "" ; return } | |
| 128 | + method cutbranchparent {} { set mybranchparent "" ; return } | |
| 128 | 129 | |
| 129 | 130 | method branchnr {} { return $mynr } |
| 130 | 131 | method parentrevnr {} { return $mybranchparentrevnr } |
| 131 | 132 | method childrevnr {} { return $mybranchchildrevnr } |
| 132 | 133 | method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] } |
| @@ -185,16 +186,16 @@ | ||
| 185 | 186 | VALUES ($myid, $fid, $lod, $sid, $rid); |
| 186 | 187 | } |
| 187 | 188 | } |
| 188 | 189 | } |
| 189 | 190 | branch { |
| 190 | - lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }] | |
| 191 | + lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }] | |
| 192 | + lappend map @P@ [expr { ($mybranchparent eq "") ? "NULL" : [$mybranchparent id] }] | |
| 191 | 193 | |
| 192 | - set rid [$mybranchparent id] | |
| 193 | 194 | set cmd { |
| 194 | 195 | INSERT INTO branch ( bid, fid, lod, sid, root, first, bra, pos ) |
| 195 | - VALUES ($myid, $fid, $lod, $sid, $rid, @F@, $mynr, $mybranchposition); | |
| 196 | + VALUES ($myid, $fid, $lod, $sid, @P@, @F@, $mynr, $mybranchposition); | |
| 196 | 197 | } |
| 197 | 198 | state transaction { |
| 198 | 199 | state run [string map $map $cmd] |
| 199 | 200 | } |
| 200 | 201 | } |
| 201 | 202 |
| --- tools/cvs2fossil/lib/c2f_fsym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_fsym.tcl | |
| @@ -119,14 +119,15 @@ | |
| 119 | integrity assert {$mybranchchildrevnr eq ""} {Child already defined} |
| 120 | set mybranchchildrevnr $revnr |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | method setposition {n} { set mybranchposition $n ; return } |
| 125 | method setparent {rev} { set mybranchparent $rev ; return } |
| 126 | method setchild {rev} { set mybranchchild $rev ; return } |
| 127 | method cutchild {} { set mybranchchild "" ; return } |
| 128 | |
| 129 | method branchnr {} { return $mynr } |
| 130 | method parentrevnr {} { return $mybranchparentrevnr } |
| 131 | method childrevnr {} { return $mybranchchildrevnr } |
| 132 | method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] } |
| @@ -185,16 +186,16 @@ | |
| 185 | VALUES ($myid, $fid, $lod, $sid, $rid); |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | branch { |
| 190 | lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }] |
| 191 | |
| 192 | set rid [$mybranchparent id] |
| 193 | set cmd { |
| 194 | INSERT INTO branch ( bid, fid, lod, sid, root, first, bra, pos ) |
| 195 | VALUES ($myid, $fid, $lod, $sid, $rid, @F@, $mynr, $mybranchposition); |
| 196 | } |
| 197 | state transaction { |
| 198 | state run [string map $map $cmd] |
| 199 | } |
| 200 | } |
| 201 |
| --- tools/cvs2fossil/lib/c2f_fsym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_fsym.tcl | |
| @@ -119,14 +119,15 @@ | |
| 119 | integrity assert {$mybranchchildrevnr eq ""} {Child already defined} |
| 120 | set mybranchchildrevnr $revnr |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | method setposition {n} { set mybranchposition $n ; return } |
| 125 | method setparent {rev} { set mybranchparent $rev ; return } |
| 126 | method setchild {rev} { set mybranchchild $rev ; return } |
| 127 | method cutchild {} { set mybranchchild "" ; return } |
| 128 | method cutbranchparent {} { set mybranchparent "" ; return } |
| 129 | |
| 130 | method branchnr {} { return $mynr } |
| 131 | method parentrevnr {} { return $mybranchparentrevnr } |
| 132 | method childrevnr {} { return $mybranchchildrevnr } |
| 133 | method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] } |
| @@ -185,16 +186,16 @@ | |
| 186 | VALUES ($myid, $fid, $lod, $sid, $rid); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | branch { |
| 191 | lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }] |
| 192 | lappend map @P@ [expr { ($mybranchparent eq "") ? "NULL" : [$mybranchparent id] }] |
| 193 | |
| 194 | set cmd { |
| 195 | INSERT INTO branch ( bid, fid, lod, sid, root, first, bra, pos ) |
| 196 | VALUES ($myid, $fid, $lod, $sid, @P@, @F@, $mynr, $mybranchposition); |
| 197 | } |
| 198 | state transaction { |
| 199 | state run [string map $map $cmd] |
| 200 | } |
| 201 | } |
| 202 |
| --- tools/cvs2fossil/lib/c2f_pcollrev.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pcollrev.tcl | ||
| @@ -182,14 +182,21 @@ | ||
| 182 | 182 | bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 183 | 183 | fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
| 184 | 184 | lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
| 185 | 185 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch |
| 186 | 186 | |
| 187 | - root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from | |
| 187 | + root INTEGER REFERENCES revision, -- Revision the branch sprouts from | |
| 188 | 188 | first INTEGER REFERENCES revision, -- First revision committed to the branch |
| 189 | 189 | bra TEXT NOT NULL, -- branch number |
| 190 | 190 | pos INTEGER NOT NULL -- creation order in root. |
| 191 | + | |
| 192 | + -- A branch can exist without root. It happens when the | |
| 193 | + -- only revision on trunk is the unnecessary dead one the | |
| 194 | + -- branch was sprouted from and it has commits. The branch | |
| 195 | + -- will exist to be the LOD of its revisions, nothing to | |
| 196 | + -- sprout from, the dead revision was removed, hence no | |
| 197 | + -- root. | |
| 191 | 198 | } |
| 192 | 199 | |
| 193 | 200 | # Project level ... |
| 194 | 201 | # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk |
| 195 | 202 | # |
| 196 | 203 |
| --- tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| @@ -182,14 +182,21 @@ | |
| 182 | bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 183 | fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
| 184 | lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
| 185 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch |
| 186 | |
| 187 | root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from |
| 188 | first INTEGER REFERENCES revision, -- First revision committed to the branch |
| 189 | bra TEXT NOT NULL, -- branch number |
| 190 | pos INTEGER NOT NULL -- creation order in root. |
| 191 | } |
| 192 | |
| 193 | # Project level ... |
| 194 | # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk |
| 195 | # |
| 196 |
| --- tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pcollrev.tcl | |
| @@ -182,14 +182,21 @@ | |
| 182 | bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, |
| 183 | fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to |
| 184 | lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk) |
| 185 | sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch |
| 186 | |
| 187 | root INTEGER REFERENCES revision, -- Revision the branch sprouts from |
| 188 | first INTEGER REFERENCES revision, -- First revision committed to the branch |
| 189 | bra TEXT NOT NULL, -- branch number |
| 190 | pos INTEGER NOT NULL -- creation order in root. |
| 191 | |
| 192 | -- A branch can exist without root. It happens when the |
| 193 | -- only revision on trunk is the unnecessary dead one the |
| 194 | -- branch was sprouted from and it has commits. The branch |
| 195 | -- will exist to be the LOD of its revisions, nothing to |
| 196 | -- sprout from, the dead revision was removed, hence no |
| 197 | -- root. |
| 198 | } |
| 199 | |
| 200 | # Project level ... |
| 201 | # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk |
| 202 | # |
| 203 |
| --- tools/cvs2fossil/lib/c2f_pfiltersym.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl | ||
| @@ -318,10 +318,18 @@ | ||
| 318 | 318 | AND S.name != ':trunk:' |
| 319 | 319 | AND T.rev = R.rid |
| 320 | 320 | }] |
| 321 | 321 | |
| 322 | 322 | set branchestoadjust [state run { |
| 323 | + SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, NULL, NULL | |
| 324 | + FROM branch B, preferedparent P, symbol S | |
| 325 | + WHERE B.sid = P.sid | |
| 326 | + AND B.lod != P.pid | |
| 327 | + AND P.pid = S.sid | |
| 328 | + AND S.name != ':trunk:' | |
| 329 | + AND B.root IS NULL -- Accept free-floating branch | |
| 330 | + UNION | |
| 323 | 331 | SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid |
| 324 | 332 | FROM branch B, preferedparent P, symbol S, revision R |
| 325 | 333 | WHERE B.sid = P.sid |
| 326 | 334 | AND B.lod != P.pid |
| 327 | 335 | AND P.pid = S.sid |
| @@ -344,11 +352,10 @@ | ||
| 344 | 352 | set fmt %[string length $tmax]s |
| 345 | 353 | set mxs [format $fmt $tmax] |
| 346 | 354 | |
| 347 | 355 | set n 0 |
| 348 | 356 | foreach {id fid lod pid preferedname revnr rid} $tagstoadjust { |
| 349 | - | |
| 350 | 357 | # BOTTLE-NECK ... |
| 351 | 358 | # |
| 352 | 359 | # The check if the candidate (pid) is truly viable is |
| 353 | 360 | # based finding the branch as possible parent, and done |
| 354 | 361 | # now instead of as part of the already complex join. |
| @@ -412,11 +419,18 @@ | ||
| 412 | 419 | # ... AND P.pid IN (SELECT BX.sid |
| 413 | 420 | # FROM branch BX |
| 414 | 421 | # WHERE BX.root = R.rid |
| 415 | 422 | # AND BX.pos > B.pos) |
| 416 | 423 | |
| 417 | - if {![state one { | |
| 424 | + # Note: rid eq "" hear means that this is a free-floating | |
| 425 | + # branch, whose original root was removed as a unnecessary | |
| 426 | + # dead revision (See 'file::RemoveIrrelevantDeletions'). | |
| 427 | + # Such a branch can be regrafted without trouble and there | |
| 428 | + # is no need to look for the new parent in its | |
| 429 | + # non-existent root. | |
| 430 | + | |
| 431 | + if {($rid ne "") && ![state one { | |
| 418 | 432 | SELECT COUNT(*) |
| 419 | 433 | FROM branch B |
| 420 | 434 | WHERE B.sid = $pid |
| 421 | 435 | AND B.root = $rid |
| 422 | 436 | AND B.pos > $pos |
| 423 | 437 |
| --- tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| @@ -318,10 +318,18 @@ | |
| 318 | AND S.name != ':trunk:' |
| 319 | AND T.rev = R.rid |
| 320 | }] |
| 321 | |
| 322 | set branchestoadjust [state run { |
| 323 | SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid |
| 324 | FROM branch B, preferedparent P, symbol S, revision R |
| 325 | WHERE B.sid = P.sid |
| 326 | AND B.lod != P.pid |
| 327 | AND P.pid = S.sid |
| @@ -344,11 +352,10 @@ | |
| 344 | set fmt %[string length $tmax]s |
| 345 | set mxs [format $fmt $tmax] |
| 346 | |
| 347 | set n 0 |
| 348 | foreach {id fid lod pid preferedname revnr rid} $tagstoadjust { |
| 349 | |
| 350 | # BOTTLE-NECK ... |
| 351 | # |
| 352 | # The check if the candidate (pid) is truly viable is |
| 353 | # based finding the branch as possible parent, and done |
| 354 | # now instead of as part of the already complex join. |
| @@ -412,11 +419,18 @@ | |
| 412 | # ... AND P.pid IN (SELECT BX.sid |
| 413 | # FROM branch BX |
| 414 | # WHERE BX.root = R.rid |
| 415 | # AND BX.pos > B.pos) |
| 416 | |
| 417 | if {![state one { |
| 418 | SELECT COUNT(*) |
| 419 | FROM branch B |
| 420 | WHERE B.sid = $pid |
| 421 | AND B.root = $rid |
| 422 | AND B.pos > $pos |
| 423 |
| --- tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl | |
| @@ -318,10 +318,18 @@ | |
| 318 | AND S.name != ':trunk:' |
| 319 | AND T.rev = R.rid |
| 320 | }] |
| 321 | |
| 322 | set branchestoadjust [state run { |
| 323 | SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, NULL, NULL |
| 324 | FROM branch B, preferedparent P, symbol S |
| 325 | WHERE B.sid = P.sid |
| 326 | AND B.lod != P.pid |
| 327 | AND P.pid = S.sid |
| 328 | AND S.name != ':trunk:' |
| 329 | AND B.root IS NULL -- Accept free-floating branch |
| 330 | UNION |
| 331 | SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid |
| 332 | FROM branch B, preferedparent P, symbol S, revision R |
| 333 | WHERE B.sid = P.sid |
| 334 | AND B.lod != P.pid |
| 335 | AND P.pid = S.sid |
| @@ -344,11 +352,10 @@ | |
| 352 | set fmt %[string length $tmax]s |
| 353 | set mxs [format $fmt $tmax] |
| 354 | |
| 355 | set n 0 |
| 356 | foreach {id fid lod pid preferedname revnr rid} $tagstoadjust { |
| 357 | # BOTTLE-NECK ... |
| 358 | # |
| 359 | # The check if the candidate (pid) is truly viable is |
| 360 | # based finding the branch as possible parent, and done |
| 361 | # now instead of as part of the already complex join. |
| @@ -412,11 +419,18 @@ | |
| 419 | # ... AND P.pid IN (SELECT BX.sid |
| 420 | # FROM branch BX |
| 421 | # WHERE BX.root = R.rid |
| 422 | # AND BX.pos > B.pos) |
| 423 | |
| 424 | # Note: rid eq "" hear means that this is a free-floating |
| 425 | # branch, whose original root was removed as a unnecessary |
| 426 | # dead revision (See 'file::RemoveIrrelevantDeletions'). |
| 427 | # Such a branch can be regrafted without trouble and there |
| 428 | # is no need to look for the new parent in its |
| 429 | # non-existent root. |
| 430 | |
| 431 | if {($rid ne "") && ![state one { |
| 432 | SELECT COUNT(*) |
| 433 | FROM branch B |
| 434 | WHERE B.sid = $pid |
| 435 | AND B.root = $rid |
| 436 | AND B.pos > $pos |
| 437 |