Fossil SCM
Bugfix in changeset class. Documented and fixed the SQL statements pulling the successor and predecessor information out of the state. It mishandled the Trunk <-> NTDB transitions.
Commit
184c56327e6bd64e5e87291bf9639d48c0f9afe7
Parent
17ec2d682c85343…
1 file changed
+89
-21
+89
-21
| --- tools/cvs2fossil/lib/c2f_prev.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | ||
| @@ -438,28 +438,66 @@ | ||
| 438 | 438 | |
| 439 | 439 | proc PullSuccessorRevisions {dv revisions} { |
| 440 | 440 | upvar 1 $dv dependencies |
| 441 | 441 | set theset ('[join $revisions {','}]') |
| 442 | 442 | |
| 443 | + # The following cases specify when a revision S is a successor | |
| 444 | + # of a revision R. Each of the cases translates into one of | |
| 445 | + # the branches of the SQL UNION coming below. | |
| 446 | + # | |
| 447 | + # (1) S can be a primary child of R, i.e. in the same LOD. R | |
| 448 | + # references S directly. R.child = S(.rid), if it exists. | |
| 449 | + # | |
| 450 | + # (2) S can be a secondary, i.e. branch, child of R. Here the | |
| 451 | + # link is made through the helper table | |
| 452 | + # REVISIONBRANCHCHILDREN. R.rid -> RBC.rid, RBC.brid = | |
| 453 | + # S(.rid) | |
| 454 | + # | |
| 455 | + # (3) If R is the trunk root of its file and S is the root of | |
| 456 | + # the NTDB of the same file, then S is a successor of | |
| 457 | + # R. There is no direct link between the two in the | |
| 458 | + # database. An indirect link can be made through the FILE | |
| 459 | + # they belong too, and their combination of attributes to | |
| 460 | + # identify them. We check R for trunk rootness and then | |
| 461 | + # select for the NTDB root, crossing the table with | |
| 462 | + # itself. | |
| 463 | + # | |
| 464 | + # (4) If R is the last of the NTDB revisions which belong to | |
| 465 | + # the trunk, then the primary child of the trunk root (the | |
| 466 | + # '1.2' revision) is a successor, if it exists. | |
| 467 | + | |
| 443 | 468 | foreach {rid child} [state run " |
| 444 | - -- Primary children | |
| 469 | + -- (1) Primary child | |
| 445 | 470 | SELECT R.rid, R.child |
| 446 | 471 | FROM revision R |
| 447 | - WHERE R.rid IN $theset | |
| 448 | - AND R.child IS NOT NULL | |
| 449 | - UNION | |
| 450 | - -- Transition NTDB to trunk | |
| 451 | - SELECT R.rid, R.dbchild | |
| 452 | - FROM revision R | |
| 453 | - WHERE R.rid IN $theset | |
| 454 | - AND R.dbchild IS NOT NULL | |
| 455 | - UNION | |
| 456 | - -- Secondary (branch) children | |
| 472 | + WHERE R.rid IN $theset -- Restrict to revisions of interest | |
| 473 | + AND R.child IS NOT NULL -- Has primary child | |
| 474 | + UNION | |
| 475 | + -- (2) Secondary (branch) children | |
| 457 | 476 | SELECT R.rid, B.brid |
| 458 | 477 | FROM revision R, revisionbranchchildren B |
| 459 | - WHERE R.rid IN $theset | |
| 460 | - AND R.rid = B.rid | |
| 478 | + WHERE R.rid IN $theset -- Restrict to revisions of interest | |
| 479 | + AND R.rid = B.rid -- Select subset of branch children | |
| 480 | + UNION | |
| 481 | + -- (3) NTDB root successor of Trunk root | |
| 482 | + SELECT R.rid, RX.rid | |
| 483 | + FROM revision R, revision RX | |
| 484 | + WHERE R.rid IN $theset -- Restrict to revisions of interest | |
| 485 | + AND R.parent IS NULL -- Restrict to root | |
| 486 | + AND NOT R.isdefault -- on the trunk | |
| 487 | + AND R.fid = RX.fid -- Select all revision in the same file | |
| 488 | + AND RX.parent IS NULL -- Restrict to root | |
| 489 | + AND RX.isdefault -- on the NTDB | |
| 490 | + UNION | |
| 491 | + -- (4) Child of trunk root successor of last NTDB on trunk. | |
| 492 | + SELECT R.rid, RA.child | |
| 493 | + FROM revision R, revision RA | |
| 494 | + WHERE R.rid IN $theset -- Restrict to revisions of interest | |
| 495 | + AND R.isdefault -- Restrict to NTDB | |
| 496 | + AND R.dbchild IS NOT NULL -- and last NTDB belonging to trunk | |
| 497 | + AND RA.rid = R.dbchild -- Go directly to trunk root | |
| 498 | + AND RA.child IS NOT NULL -- Has primary child. | |
| 461 | 499 | "] { |
| 462 | 500 | # Consider moving this to the integrity module. |
| 463 | 501 | if {$rid == $child} { |
| 464 | 502 | trouble internal "Revision $rid depends on itself." |
| 465 | 503 | } |
| @@ -470,22 +508,52 @@ | ||
| 470 | 508 | |
| 471 | 509 | proc PullPredecessorRevisions {dv revisions} { |
| 472 | 510 | upvar 1 $dv dependencies |
| 473 | 511 | set theset ('[join $revisions {','}]') |
| 474 | 512 | |
| 513 | + # The following cases specify when a revision P is a | |
| 514 | + # predecessor of a revision R. Each of the cases translates | |
| 515 | + # into one of the branches of the SQL UNION coming below. | |
| 516 | + # | |
| 517 | + # (1) The immediate parent R.parent of R is a predecessor of | |
| 518 | + # R. NOTE: This is true for R either primary or secondary | |
| 519 | + # child of P. It not necessary to distinguish the two | |
| 520 | + # cases, in contrast to the code retrieving the successor | |
| 521 | + # information. | |
| 522 | + # | |
| 523 | + # (2) The complement of successor case (3). The trunk root is | |
| 524 | + # a predecessor of a NTDB root. | |
| 525 | + # | |
| 526 | + # (3) The complement of successor case (4). The last NTDB | |
| 527 | + # revision belonging to the trunk is a predecessor of the | |
| 528 | + # primary child of the trunk root (The '1.2' revision). | |
| 529 | + | |
| 475 | 530 | foreach {rid parent} [state run " |
| 476 | - -- Primary parent, can be in different LOD for first in a branch | |
| 531 | + -- (1) Primary parent, can be in different LOD for first in a branch | |
| 477 | 532 | SELECT R.rid, R.parent |
| 478 | 533 | FROM revision R |
| 479 | - WHERE R.rid IN $theset | |
| 480 | - AND R.parent IS NOT NULL | |
| 534 | + WHERE R.rid IN $theset -- Restrict to revisions of interest | |
| 535 | + AND R.parent IS NOT NULL -- Has primary parent | |
| 536 | + UNION | |
| 537 | + -- (2) Trunk root predecessor of NTDB root. | |
| 538 | + SELECT R.rid, RX.rid | |
| 539 | + FROM revision R, revision RX | |
| 540 | + WHERE R.rid IN $theset -- Restrict to revisions of interest | |
| 541 | + AND R.parent IS NULL -- which are root | |
| 542 | + AND R.isdefault -- on NTDB | |
| 543 | + AND R.fid = RX.fid -- Select all revision in the same file | |
| 544 | + AND RX.parent IS NULL -- which are root | |
| 545 | + AND NOT RX.isdefault -- on the trunk | |
| 481 | 546 | UNION |
| 482 | - -- Transition trunk to NTDB | |
| 483 | - SELECT R.rid, R.dbparent | |
| 484 | - FROM revision R | |
| 485 | - WHERE R.rid IN $theset | |
| 486 | - AND R.dbparent IS NOT NULL | |
| 547 | + -- (3) Last NTDB on trunk is predecessor of child of trunk root | |
| 548 | + SELECT R.rid, RA.dbparent | |
| 549 | + FROM revision R, revision RA | |
| 550 | + WHERE R.rid IN $theset -- Restrict to revisions of interest | |
| 551 | + AND NOT R.isdefault -- not on NTDB | |
| 552 | + AND R.parent IS NOT NULL -- which are not root | |
| 553 | + AND RA.rid = R.parent -- go to their parent | |
| 554 | + AND RA.dbparent IS NOT NULL -- which has to refer to NTDB's root | |
| 487 | 555 | "] { |
| 488 | 556 | # Consider moving this to the integrity module. |
| 489 | 557 | if {$rid == $parent} { |
| 490 | 558 | trouble internal "Revision $rid depends on itself." |
| 491 | 559 | } |
| 492 | 560 |
| --- tools/cvs2fossil/lib/c2f_prev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | |
| @@ -438,28 +438,66 @@ | |
| 438 | |
| 439 | proc PullSuccessorRevisions {dv revisions} { |
| 440 | upvar 1 $dv dependencies |
| 441 | set theset ('[join $revisions {','}]') |
| 442 | |
| 443 | foreach {rid child} [state run " |
| 444 | -- Primary children |
| 445 | SELECT R.rid, R.child |
| 446 | FROM revision R |
| 447 | WHERE R.rid IN $theset |
| 448 | AND R.child IS NOT NULL |
| 449 | UNION |
| 450 | -- Transition NTDB to trunk |
| 451 | SELECT R.rid, R.dbchild |
| 452 | FROM revision R |
| 453 | WHERE R.rid IN $theset |
| 454 | AND R.dbchild IS NOT NULL |
| 455 | UNION |
| 456 | -- Secondary (branch) children |
| 457 | SELECT R.rid, B.brid |
| 458 | FROM revision R, revisionbranchchildren B |
| 459 | WHERE R.rid IN $theset |
| 460 | AND R.rid = B.rid |
| 461 | "] { |
| 462 | # Consider moving this to the integrity module. |
| 463 | if {$rid == $child} { |
| 464 | trouble internal "Revision $rid depends on itself." |
| 465 | } |
| @@ -470,22 +508,52 @@ | |
| 470 | |
| 471 | proc PullPredecessorRevisions {dv revisions} { |
| 472 | upvar 1 $dv dependencies |
| 473 | set theset ('[join $revisions {','}]') |
| 474 | |
| 475 | foreach {rid parent} [state run " |
| 476 | -- Primary parent, can be in different LOD for first in a branch |
| 477 | SELECT R.rid, R.parent |
| 478 | FROM revision R |
| 479 | WHERE R.rid IN $theset |
| 480 | AND R.parent IS NOT NULL |
| 481 | UNION |
| 482 | -- Transition trunk to NTDB |
| 483 | SELECT R.rid, R.dbparent |
| 484 | FROM revision R |
| 485 | WHERE R.rid IN $theset |
| 486 | AND R.dbparent IS NOT NULL |
| 487 | "] { |
| 488 | # Consider moving this to the integrity module. |
| 489 | if {$rid == $parent} { |
| 490 | trouble internal "Revision $rid depends on itself." |
| 491 | } |
| 492 |
| --- tools/cvs2fossil/lib/c2f_prev.tcl | |
| +++ tools/cvs2fossil/lib/c2f_prev.tcl | |
| @@ -438,28 +438,66 @@ | |
| 438 | |
| 439 | proc PullSuccessorRevisions {dv revisions} { |
| 440 | upvar 1 $dv dependencies |
| 441 | set theset ('[join $revisions {','}]') |
| 442 | |
| 443 | # The following cases specify when a revision S is a successor |
| 444 | # of a revision R. Each of the cases translates into one of |
| 445 | # the branches of the SQL UNION coming below. |
| 446 | # |
| 447 | # (1) S can be a primary child of R, i.e. in the same LOD. R |
| 448 | # references S directly. R.child = S(.rid), if it exists. |
| 449 | # |
| 450 | # (2) S can be a secondary, i.e. branch, child of R. Here the |
| 451 | # link is made through the helper table |
| 452 | # REVISIONBRANCHCHILDREN. R.rid -> RBC.rid, RBC.brid = |
| 453 | # S(.rid) |
| 454 | # |
| 455 | # (3) If R is the trunk root of its file and S is the root of |
| 456 | # the NTDB of the same file, then S is a successor of |
| 457 | # R. There is no direct link between the two in the |
| 458 | # database. An indirect link can be made through the FILE |
| 459 | # they belong too, and their combination of attributes to |
| 460 | # identify them. We check R for trunk rootness and then |
| 461 | # select for the NTDB root, crossing the table with |
| 462 | # itself. |
| 463 | # |
| 464 | # (4) If R is the last of the NTDB revisions which belong to |
| 465 | # the trunk, then the primary child of the trunk root (the |
| 466 | # '1.2' revision) is a successor, if it exists. |
| 467 | |
| 468 | foreach {rid child} [state run " |
| 469 | -- (1) Primary child |
| 470 | SELECT R.rid, R.child |
| 471 | FROM revision R |
| 472 | WHERE R.rid IN $theset -- Restrict to revisions of interest |
| 473 | AND R.child IS NOT NULL -- Has primary child |
| 474 | UNION |
| 475 | -- (2) Secondary (branch) children |
| 476 | SELECT R.rid, B.brid |
| 477 | FROM revision R, revisionbranchchildren B |
| 478 | WHERE R.rid IN $theset -- Restrict to revisions of interest |
| 479 | AND R.rid = B.rid -- Select subset of branch children |
| 480 | UNION |
| 481 | -- (3) NTDB root successor of Trunk root |
| 482 | SELECT R.rid, RX.rid |
| 483 | FROM revision R, revision RX |
| 484 | WHERE R.rid IN $theset -- Restrict to revisions of interest |
| 485 | AND R.parent IS NULL -- Restrict to root |
| 486 | AND NOT R.isdefault -- on the trunk |
| 487 | AND R.fid = RX.fid -- Select all revision in the same file |
| 488 | AND RX.parent IS NULL -- Restrict to root |
| 489 | AND RX.isdefault -- on the NTDB |
| 490 | UNION |
| 491 | -- (4) Child of trunk root successor of last NTDB on trunk. |
| 492 | SELECT R.rid, RA.child |
| 493 | FROM revision R, revision RA |
| 494 | WHERE R.rid IN $theset -- Restrict to revisions of interest |
| 495 | AND R.isdefault -- Restrict to NTDB |
| 496 | AND R.dbchild IS NOT NULL -- and last NTDB belonging to trunk |
| 497 | AND RA.rid = R.dbchild -- Go directly to trunk root |
| 498 | AND RA.child IS NOT NULL -- Has primary child. |
| 499 | "] { |
| 500 | # Consider moving this to the integrity module. |
| 501 | if {$rid == $child} { |
| 502 | trouble internal "Revision $rid depends on itself." |
| 503 | } |
| @@ -470,22 +508,52 @@ | |
| 508 | |
| 509 | proc PullPredecessorRevisions {dv revisions} { |
| 510 | upvar 1 $dv dependencies |
| 511 | set theset ('[join $revisions {','}]') |
| 512 | |
| 513 | # The following cases specify when a revision P is a |
| 514 | # predecessor of a revision R. Each of the cases translates |
| 515 | # into one of the branches of the SQL UNION coming below. |
| 516 | # |
| 517 | # (1) The immediate parent R.parent of R is a predecessor of |
| 518 | # R. NOTE: This is true for R either primary or secondary |
| 519 | # child of P. It not necessary to distinguish the two |
| 520 | # cases, in contrast to the code retrieving the successor |
| 521 | # information. |
| 522 | # |
| 523 | # (2) The complement of successor case (3). The trunk root is |
| 524 | # a predecessor of a NTDB root. |
| 525 | # |
| 526 | # (3) The complement of successor case (4). The last NTDB |
| 527 | # revision belonging to the trunk is a predecessor of the |
| 528 | # primary child of the trunk root (The '1.2' revision). |
| 529 | |
| 530 | foreach {rid parent} [state run " |
| 531 | -- (1) Primary parent, can be in different LOD for first in a branch |
| 532 | SELECT R.rid, R.parent |
| 533 | FROM revision R |
| 534 | WHERE R.rid IN $theset -- Restrict to revisions of interest |
| 535 | AND R.parent IS NOT NULL -- Has primary parent |
| 536 | UNION |
| 537 | -- (2) Trunk root predecessor of NTDB root. |
| 538 | SELECT R.rid, RX.rid |
| 539 | FROM revision R, revision RX |
| 540 | WHERE R.rid IN $theset -- Restrict to revisions of interest |
| 541 | AND R.parent IS NULL -- which are root |
| 542 | AND R.isdefault -- on NTDB |
| 543 | AND R.fid = RX.fid -- Select all revision in the same file |
| 544 | AND RX.parent IS NULL -- which are root |
| 545 | AND NOT RX.isdefault -- on the trunk |
| 546 | UNION |
| 547 | -- (3) Last NTDB on trunk is predecessor of child of trunk root |
| 548 | SELECT R.rid, RA.dbparent |
| 549 | FROM revision R, revision RA |
| 550 | WHERE R.rid IN $theset -- Restrict to revisions of interest |
| 551 | AND NOT R.isdefault -- not on NTDB |
| 552 | AND R.parent IS NOT NULL -- which are not root |
| 553 | AND RA.rid = R.parent -- go to their parent |
| 554 | AND RA.dbparent IS NOT NULL -- which has to refer to NTDB's root |
| 555 | "] { |
| 556 | # Consider moving this to the integrity module. |
| 557 | if {$rid == $parent} { |
| 558 | trouble internal "Revision $rid depends on itself." |
| 559 | } |
| 560 |