Fossil SCM
Added equivalent checks for the tag and branch based changesets.
Commit
4b15fa348d8f98e02403a50f7e822139b6669406
Parent
de10b2301e874f9…
1 file changed
+266
| --- tools/cvs2fossil/lib/c2f_integrity.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_integrity.tcl | ||
| @@ -458,19 +458,285 @@ | ||
| 458 | 458 | # database, searching for inconsistent changeset/revision |
| 459 | 459 | # information. |
| 460 | 460 | |
| 461 | 461 | upvar 1 n n ; # Counter for the checks (we print an id before |
| 462 | 462 | # the main label). |
| 463 | + | |
| 464 | + # Find all tags which are not used by at least one changeset. | |
| 465 | + CheckTag \ | |
| 466 | + {All tags have to be used by least one changeset} \ | |
| 467 | + {is not used by a changeset} { | |
| 468 | + -- Unused tags = All tags | |
| 469 | + -- - revisions used by tag changesets. | |
| 470 | + -- | |
| 471 | + -- Both sets can be computed easily, and subtracted | |
| 472 | + -- from each other. Then we can get the associated | |
| 473 | + -- file (name) for display. | |
| 474 | + | |
| 475 | + SELECT P.name, S.name | |
| 476 | + FROM project P, tag T, symbol S | |
| 477 | + WHERE T.tid IN (SELECT tid -- All tags | |
| 478 | + FROM tag | |
| 479 | + EXCEPT -- subtract | |
| 480 | + SELECT CR.rid -- tags used | |
| 481 | + FROM csrevision CR, changeset C | |
| 482 | + WHERE C.cid = CR.cid -- by any tag | |
| 483 | + AND C.type = 1) -- changeset | |
| 484 | + AND S.sid = T.sid -- get symbol of tag | |
| 485 | + AND P.pid = S.pid -- get project of symbol | |
| 486 | + } | |
| 487 | + # Find all tags which are used by more than one changeset. | |
| 488 | + CheckRev \ | |
| 489 | + {All tags have to be used by at most one changeset} \ | |
| 490 | + {is used by multiple changesets} { | |
| 491 | + -- Principle of operation: Get all tag/changeset pairs | |
| 492 | + -- for all tag changesets, group by tag to aggregate | |
| 493 | + -- the changeset, counting them. From the resulting | |
| 494 | + -- tag/count table select those with more than one | |
| 495 | + -- user, and get their associated file (name) for | |
| 496 | + -- display. | |
| 497 | + | |
| 498 | + SELECT P.name, S.name | |
| 499 | + FROM tag T, project P, symbol S, | |
| 500 | + (SELECT CR.rid AS rid, count(CR.cid) AS count | |
| 501 | + FROM csrevision CR, changeset C | |
| 502 | + WHERE C.type = 1 | |
| 503 | + AND C.cid = CR.cid | |
| 504 | + GROUP BY CR.rid) AS U | |
| 505 | + WHERE U.count > 1 | |
| 506 | + AND T.tid = U.rid | |
| 507 | + AND S.sid = T.sid -- get symbol of tag | |
| 508 | + AND P.pid = S.pid -- get project of symbol | |
| 509 | + } | |
| 510 | + if 0 { | |
| 511 | + # This check is disabled for the moment. Apparently tags | |
| 512 | + # can cross lines of development, at least if the involved | |
| 513 | + # LODs are the trunk, and the NTDB. That makes sense, as | |
| 514 | + # the NTDB revisions are initially logically a part of the | |
| 515 | + # trunk. The standard check below however does not capture | |
| 516 | + # this. When I manage to rephrase it to accept this type | |
| 517 | + # of cross-over it will be re-activated. | |
| 518 | + | |
| 519 | + # All tags have to agree on the LOD their changeset | |
| 520 | + # belongs to. In other words, all tags in a changeset have | |
| 521 | + # to refer to the same line of development. | |
| 522 | + # | |
| 523 | + # Instead of looking at all pairs of tags in all | |
| 524 | + # changesets we generate the distinct set of all LODs | |
| 525 | + # referenced by the tags of a changeset, look for those | |
| 526 | + # with cardinality > 1, and get the identifying | |
| 527 | + # information for the changesets found thusly. | |
| 528 | + CheckCS \ | |
| 529 | + {All tags in a changeset have to belong to the same LOD} \ | |
| 530 | + {: Its tags disagree about the LOD they belong to} { | |
| 531 | + SELECT T.name, C.cid | |
| 532 | + FROM changeset C, cstype T | |
| 533 | + WHERE C.cid IN (SELECT U.cid | |
| 534 | + FROM (SELECT DISTINCT CR.cid AS cid, T.lod AS lod | |
| 535 | + FROM csrevision CR, changeset C, tag T | |
| 536 | + WHERE CR.rid = T.tid | |
| 537 | + AND C.cid = CR.cid | |
| 538 | + AND C.type = 1) AS U | |
| 539 | + GROUP BY U.cid HAVING COUNT(U.lod) > 1) | |
| 540 | + AND T.tid = C.type | |
| 541 | + } | |
| 542 | + } | |
| 543 | + # All tags have to agree on the project their changeset | |
| 544 | + # belongs to. In other words, all tags in a changeset have to | |
| 545 | + # refer to the same project. | |
| 546 | + # | |
| 547 | + # Instead of looking at all pairs of tags in all changesets we | |
| 548 | + # generate the distinct set of all projects referenced by the | |
| 549 | + # tags of a changeset, look for those with cardinality > 1, | |
| 550 | + # and get the identifying information for the changesets found | |
| 551 | + # thusly. | |
| 552 | + CheckCS \ | |
| 553 | + {All tags in a changeset have to belong to the same project} \ | |
| 554 | + {: Its tags disagree about the project they belong to} { | |
| 555 | + SELECT T.name, C.cid | |
| 556 | + FROM changeset C, cstype T | |
| 557 | + WHERE C.cid IN (SELECT U.cid | |
| 558 | + FROM (SELECT DISTINCT CR.cid AS cid, F.pid AS pid | |
| 559 | + FROM csrevision CR, changeset C, tag T, file F | |
| 560 | + WHERE CR.rid = T.tid | |
| 561 | + AND C.cid = CR.cid | |
| 562 | + AND C.type = 1 | |
| 563 | + AND F.fid = T.fid) AS U | |
| 564 | + GROUP BY U.cid HAVING COUNT(U.pid) > 1) | |
| 565 | + AND T.tid = C.type | |
| 566 | + } | |
| 567 | + # All tags in a single changeset have to belong to different | |
| 568 | + # files. Conversely: No two tags of a single file are allowed | |
| 569 | + # to be in the same changeset. | |
| 570 | + # | |
| 571 | + # Instead of looking at all pairs of tags in all changesets we | |
| 572 | + # generate the distinct set of all files referenced by the | |
| 573 | + # tags of a changeset, and look for those with cardinality < | |
| 574 | + # the cardinality of the set of tags, and get the identifying | |
| 575 | + # information for the changesets found thusly. | |
| 576 | + CheckCS \ | |
| 577 | + {All tags in a changeset have to belong to different files} \ | |
| 578 | + {: Its tags share files} { | |
| 579 | + SELECT T.name, C.cid | |
| 580 | + FROM changeset C, cstype T | |
| 581 | + WHERE C.cid IN (SELECT VV.cid | |
| 582 | + FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount | |
| 583 | + FROM (SELECT DISTINCT CR.cid AS cid, T.fid AS fid | |
| 584 | + FROM csrevision CR, changeset C, tag T | |
| 585 | + WHERE CR.rid = T.tid | |
| 586 | + AND C.cid = CR.cid | |
| 587 | + AND C.type = 1 | |
| 588 | + ) AS U | |
| 589 | + GROUP BY U.cid) AS UU, | |
| 590 | + (SELECT V.cid AS cid, COUNT (V.rid) AS rcount | |
| 591 | + FROM csrevision V, changeset X | |
| 592 | + WHERE X.cid = V.cid | |
| 593 | + AND X.type = 1 | |
| 594 | + GROUP BY V.cid) AS VV | |
| 595 | + WHERE VV.cid = UU.cid | |
| 596 | + AND UU.fcount < VV.rcount) | |
| 597 | + AND T.tid = C.type | |
| 598 | + } | |
| 599 | + return | |
| 463 | 600 | } |
| 464 | 601 | |
| 465 | 602 | proc BranchChangesets {} { |
| 466 | 603 | # This code performs a number of paranoid checks of the |
| 467 | 604 | # database, searching for inconsistent changeset/revision |
| 468 | 605 | # information. |
| 469 | 606 | |
| 470 | 607 | upvar 1 n n ; # Counter for the checks (we print an id before |
| 471 | 608 | # the main label). |
| 609 | + | |
| 610 | + # Find all branches which are not used by at least one | |
| 611 | + # changeset. | |
| 612 | + CheckBranch \ | |
| 613 | + {All branches have to be used by least one changeset} \ | |
| 614 | + {is not used by a changeset} { | |
| 615 | + -- Unused branches = All branches | |
| 616 | + -- - branches used by branch changesets. | |
| 617 | + -- | |
| 618 | + -- Both sets can be computed easily, and subtracted | |
| 619 | + -- from each other. Then we can get the associated | |
| 620 | + -- file (name) for display. | |
| 621 | + | |
| 622 | + SELECT P.name, S.name | |
| 623 | + FROM project P, branch B, symbol S | |
| 624 | + WHERE B.bid IN (SELECT bid -- All branches | |
| 625 | + FROM branch | |
| 626 | + EXCEPT -- subtract | |
| 627 | + SELECT CR.rid -- branches used | |
| 628 | + FROM csrevision CR, changeset C | |
| 629 | + WHERE C.cid = CR.cid -- by any branch | |
| 630 | + AND C.type = 2) -- changeset | |
| 631 | + AND S.sid = B.sid -- get symbol of branch | |
| 632 | + AND P.pid = S.pid -- get project of symbol | |
| 633 | + } | |
| 634 | + # Find all branches which are used by more than one changeset. | |
| 635 | + CheckRev \ | |
| 636 | + {All branches have to be used by at most one changeset} \ | |
| 637 | + {is used by multiple changesets} { | |
| 638 | + -- Principle of operation: Get all branch/changeset | |
| 639 | + -- pairs for all branch changesets, group by tag to | |
| 640 | + -- aggregate the changeset, counting them. From the | |
| 641 | + -- resulting branch/count table select those with more | |
| 642 | + -- than one user, and get their associated file (name) | |
| 643 | + -- for display. | |
| 644 | + | |
| 645 | + SELECT P.name, S.name | |
| 646 | + FROM branch B, project P, symbol S, | |
| 647 | + (SELECT CR.rid AS rid, count(CR.cid) AS count | |
| 648 | + FROM csrevision CR, changeset C | |
| 649 | + WHERE C.type = 2 | |
| 650 | + AND C.cid = CR.cid | |
| 651 | + GROUP BY CR.rid ) AS U | |
| 652 | + WHERE U.count > 1 | |
| 653 | + AND B.bid = U.rid | |
| 654 | + AND S.sid = B.sid -- get symbol of branch | |
| 655 | + AND P.pid = S.pid -- get project of symbol | |
| 656 | + } | |
| 657 | + # All branches have to agree on the LOD their changeset | |
| 658 | + # belongs to. In other words, all branches in a changeset have | |
| 659 | + # to refer to the same line of development. | |
| 660 | + # | |
| 661 | + # Instead of looking at all pairs of branches in all | |
| 662 | + # changesets we generate the distinct set of all LODs | |
| 663 | + # referenced by the branches of a changeset, look for those | |
| 664 | + # with cardinality > 1, and get the identifying information | |
| 665 | + # for the changesets found thusly. | |
| 666 | + CheckCS \ | |
| 667 | + {All branches in a changeset have to belong to the same LOD} \ | |
| 668 | + {: Its branches disagree about the LOD they belong to} { | |
| 669 | + SELECT T.name, C.cid | |
| 670 | + FROM changeset C, cstype T | |
| 671 | + WHERE C.cid IN (SELECT U.cid | |
| 672 | + FROM (SELECT DISTINCT CR.cid AS cid, B.lod AS lod | |
| 673 | + FROM csrevision CR, changeset C, branch B | |
| 674 | + WHERE CR.rid = B.bid | |
| 675 | + AND C.cid = CR.cid | |
| 676 | + AND C.type = 2) AS U | |
| 677 | + GROUP BY U.cid HAVING COUNT(U.lod) > 1) | |
| 678 | + AND T.tid = C.type | |
| 679 | + } | |
| 680 | + # All branches have to agree on the project their changeset | |
| 681 | + # belongs to. In other words, all branches in a changeset have | |
| 682 | + # to refer to the same project. | |
| 683 | + # | |
| 684 | + # Instead of looking at all pairs of branches in all | |
| 685 | + # changesets we generate the distinct set of all projects | |
| 686 | + # referenced by the branches of a changeset, look for those | |
| 687 | + # with cardinality > 1, and get the identifying information | |
| 688 | + # for the changesets found thusly. | |
| 689 | + CheckCS \ | |
| 690 | + {All branches in a changeset have to belong to the same project} \ | |
| 691 | + {: Its branches disagree about the project they belong to} { | |
| 692 | + SELECT T.name, C.cid | |
| 693 | + FROM changeset C, cstype T | |
| 694 | + WHERE C.cid IN (SELECT U.cid | |
| 695 | + FROM (SELECT DISTINCT CR.cid AS cid, F.pid AS pid | |
| 696 | + FROM csrevision CR, changeset C, branch B, file F | |
| 697 | + WHERE CR.rid = B.bid | |
| 698 | + AND C.cid = CR.cid | |
| 699 | + AND C.type = 2 | |
| 700 | + AND F.fid = B.fid) AS U | |
| 701 | + GROUP BY U.cid HAVING COUNT(U.pid) > 1) | |
| 702 | + AND T.tid = C.type | |
| 703 | + } | |
| 704 | + # All branches in a single changeset have to belong to | |
| 705 | + # different files. Conversely: No two branches of a single | |
| 706 | + # file are allowed to be in the same changeset. | |
| 707 | + # | |
| 708 | + # Instead of looking at all pairs of branches in all | |
| 709 | + # changesets we generate the distinct set of all files | |
| 710 | + # referenced by the branches of a changeset, and look for | |
| 711 | + # those with cardinality < the cardinality of the set of | |
| 712 | + # branches, and get the identifying information for the | |
| 713 | + # changesets found thusly. | |
| 714 | + CheckCS \ | |
| 715 | + {All branches in a changeset have to belong to different files} \ | |
| 716 | + {: Its branches share files} { | |
| 717 | + SELECT T.name, C.cid | |
| 718 | + FROM changeset C, cstype T | |
| 719 | + WHERE C.cid IN (SELECT VV.cid | |
| 720 | + FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount | |
| 721 | + FROM (SELECT DISTINCT CR.cid AS cid, B.fid AS fid | |
| 722 | + FROM csrevision CR, changeset C, branch B | |
| 723 | + WHERE CR.rid = B.bid | |
| 724 | + AND C.cid = CR.cid | |
| 725 | + AND C.type = 2 | |
| 726 | + ) AS U | |
| 727 | + GROUP BY U.cid) AS UU, | |
| 728 | + (SELECT V.cid AS cid, COUNT (V.rid) AS rcount | |
| 729 | + FROM csrevision V, changeset X | |
| 730 | + WHERE X.cid = V.cid | |
| 731 | + AND X.type = 2 | |
| 732 | + GROUP BY V.cid) AS VV | |
| 733 | + WHERE VV.cid = UU.cid | |
| 734 | + AND UU.fcount < VV.rcount) | |
| 735 | + AND T.tid = C.type | |
| 736 | + } | |
| 737 | + return | |
| 472 | 738 | } |
| 473 | 739 | |
| 474 | 740 | proc ___UnusedChangesetChecks___ {} { |
| 475 | 741 | # This code performs a number of paranoid checks of the |
| 476 | 742 | # database, searching for inconsistent changeset/revision |
| 477 | 743 |
| --- tools/cvs2fossil/lib/c2f_integrity.tcl | |
| +++ tools/cvs2fossil/lib/c2f_integrity.tcl | |
| @@ -458,19 +458,285 @@ | |
| 458 | # database, searching for inconsistent changeset/revision |
| 459 | # information. |
| 460 | |
| 461 | upvar 1 n n ; # Counter for the checks (we print an id before |
| 462 | # the main label). |
| 463 | } |
| 464 | |
| 465 | proc BranchChangesets {} { |
| 466 | # This code performs a number of paranoid checks of the |
| 467 | # database, searching for inconsistent changeset/revision |
| 468 | # information. |
| 469 | |
| 470 | upvar 1 n n ; # Counter for the checks (we print an id before |
| 471 | # the main label). |
| 472 | } |
| 473 | |
| 474 | proc ___UnusedChangesetChecks___ {} { |
| 475 | # This code performs a number of paranoid checks of the |
| 476 | # database, searching for inconsistent changeset/revision |
| 477 |
| --- tools/cvs2fossil/lib/c2f_integrity.tcl | |
| +++ tools/cvs2fossil/lib/c2f_integrity.tcl | |
| @@ -458,19 +458,285 @@ | |
| 458 | # database, searching for inconsistent changeset/revision |
| 459 | # information. |
| 460 | |
| 461 | upvar 1 n n ; # Counter for the checks (we print an id before |
| 462 | # the main label). |
| 463 | |
| 464 | # Find all tags which are not used by at least one changeset. |
| 465 | CheckTag \ |
| 466 | {All tags have to be used by least one changeset} \ |
| 467 | {is not used by a changeset} { |
| 468 | -- Unused tags = All tags |
| 469 | -- - revisions used by tag changesets. |
| 470 | -- |
| 471 | -- Both sets can be computed easily, and subtracted |
| 472 | -- from each other. Then we can get the associated |
| 473 | -- file (name) for display. |
| 474 | |
| 475 | SELECT P.name, S.name |
| 476 | FROM project P, tag T, symbol S |
| 477 | WHERE T.tid IN (SELECT tid -- All tags |
| 478 | FROM tag |
| 479 | EXCEPT -- subtract |
| 480 | SELECT CR.rid -- tags used |
| 481 | FROM csrevision CR, changeset C |
| 482 | WHERE C.cid = CR.cid -- by any tag |
| 483 | AND C.type = 1) -- changeset |
| 484 | AND S.sid = T.sid -- get symbol of tag |
| 485 | AND P.pid = S.pid -- get project of symbol |
| 486 | } |
| 487 | # Find all tags which are used by more than one changeset. |
| 488 | CheckRev \ |
| 489 | {All tags have to be used by at most one changeset} \ |
| 490 | {is used by multiple changesets} { |
| 491 | -- Principle of operation: Get all tag/changeset pairs |
| 492 | -- for all tag changesets, group by tag to aggregate |
| 493 | -- the changeset, counting them. From the resulting |
| 494 | -- tag/count table select those with more than one |
| 495 | -- user, and get their associated file (name) for |
| 496 | -- display. |
| 497 | |
| 498 | SELECT P.name, S.name |
| 499 | FROM tag T, project P, symbol S, |
| 500 | (SELECT CR.rid AS rid, count(CR.cid) AS count |
| 501 | FROM csrevision CR, changeset C |
| 502 | WHERE C.type = 1 |
| 503 | AND C.cid = CR.cid |
| 504 | GROUP BY CR.rid) AS U |
| 505 | WHERE U.count > 1 |
| 506 | AND T.tid = U.rid |
| 507 | AND S.sid = T.sid -- get symbol of tag |
| 508 | AND P.pid = S.pid -- get project of symbol |
| 509 | } |
| 510 | if 0 { |
| 511 | # This check is disabled for the moment. Apparently tags |
| 512 | # can cross lines of development, at least if the involved |
| 513 | # LODs are the trunk, and the NTDB. That makes sense, as |
| 514 | # the NTDB revisions are initially logically a part of the |
| 515 | # trunk. The standard check below however does not capture |
| 516 | # this. When I manage to rephrase it to accept this type |
| 517 | # of cross-over it will be re-activated. |
| 518 | |
| 519 | # All tags have to agree on the LOD their changeset |
| 520 | # belongs to. In other words, all tags in a changeset have |
| 521 | # to refer to the same line of development. |
| 522 | # |
| 523 | # Instead of looking at all pairs of tags in all |
| 524 | # changesets we generate the distinct set of all LODs |
| 525 | # referenced by the tags of a changeset, look for those |
| 526 | # with cardinality > 1, and get the identifying |
| 527 | # information for the changesets found thusly. |
| 528 | CheckCS \ |
| 529 | {All tags in a changeset have to belong to the same LOD} \ |
| 530 | {: Its tags disagree about the LOD they belong to} { |
| 531 | SELECT T.name, C.cid |
| 532 | FROM changeset C, cstype T |
| 533 | WHERE C.cid IN (SELECT U.cid |
| 534 | FROM (SELECT DISTINCT CR.cid AS cid, T.lod AS lod |
| 535 | FROM csrevision CR, changeset C, tag T |
| 536 | WHERE CR.rid = T.tid |
| 537 | AND C.cid = CR.cid |
| 538 | AND C.type = 1) AS U |
| 539 | GROUP BY U.cid HAVING COUNT(U.lod) > 1) |
| 540 | AND T.tid = C.type |
| 541 | } |
| 542 | } |
| 543 | # All tags have to agree on the project their changeset |
| 544 | # belongs to. In other words, all tags in a changeset have to |
| 545 | # refer to the same project. |
| 546 | # |
| 547 | # Instead of looking at all pairs of tags in all changesets we |
| 548 | # generate the distinct set of all projects referenced by the |
| 549 | # tags of a changeset, look for those with cardinality > 1, |
| 550 | # and get the identifying information for the changesets found |
| 551 | # thusly. |
| 552 | CheckCS \ |
| 553 | {All tags in a changeset have to belong to the same project} \ |
| 554 | {: Its tags disagree about the project they belong to} { |
| 555 | SELECT T.name, C.cid |
| 556 | FROM changeset C, cstype T |
| 557 | WHERE C.cid IN (SELECT U.cid |
| 558 | FROM (SELECT DISTINCT CR.cid AS cid, F.pid AS pid |
| 559 | FROM csrevision CR, changeset C, tag T, file F |
| 560 | WHERE CR.rid = T.tid |
| 561 | AND C.cid = CR.cid |
| 562 | AND C.type = 1 |
| 563 | AND F.fid = T.fid) AS U |
| 564 | GROUP BY U.cid HAVING COUNT(U.pid) > 1) |
| 565 | AND T.tid = C.type |
| 566 | } |
| 567 | # All tags in a single changeset have to belong to different |
| 568 | # files. Conversely: No two tags of a single file are allowed |
| 569 | # to be in the same changeset. |
| 570 | # |
| 571 | # Instead of looking at all pairs of tags in all changesets we |
| 572 | # generate the distinct set of all files referenced by the |
| 573 | # tags of a changeset, and look for those with cardinality < |
| 574 | # the cardinality of the set of tags, and get the identifying |
| 575 | # information for the changesets found thusly. |
| 576 | CheckCS \ |
| 577 | {All tags in a changeset have to belong to different files} \ |
| 578 | {: Its tags share files} { |
| 579 | SELECT T.name, C.cid |
| 580 | FROM changeset C, cstype T |
| 581 | WHERE C.cid IN (SELECT VV.cid |
| 582 | FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount |
| 583 | FROM (SELECT DISTINCT CR.cid AS cid, T.fid AS fid |
| 584 | FROM csrevision CR, changeset C, tag T |
| 585 | WHERE CR.rid = T.tid |
| 586 | AND C.cid = CR.cid |
| 587 | AND C.type = 1 |
| 588 | ) AS U |
| 589 | GROUP BY U.cid) AS UU, |
| 590 | (SELECT V.cid AS cid, COUNT (V.rid) AS rcount |
| 591 | FROM csrevision V, changeset X |
| 592 | WHERE X.cid = V.cid |
| 593 | AND X.type = 1 |
| 594 | GROUP BY V.cid) AS VV |
| 595 | WHERE VV.cid = UU.cid |
| 596 | AND UU.fcount < VV.rcount) |
| 597 | AND T.tid = C.type |
| 598 | } |
| 599 | return |
| 600 | } |
| 601 | |
| 602 | proc BranchChangesets {} { |
| 603 | # This code performs a number of paranoid checks of the |
| 604 | # database, searching for inconsistent changeset/revision |
| 605 | # information. |
| 606 | |
| 607 | upvar 1 n n ; # Counter for the checks (we print an id before |
| 608 | # the main label). |
| 609 | |
| 610 | # Find all branches which are not used by at least one |
| 611 | # changeset. |
| 612 | CheckBranch \ |
| 613 | {All branches have to be used by least one changeset} \ |
| 614 | {is not used by a changeset} { |
| 615 | -- Unused branches = All branches |
| 616 | -- - branches used by branch changesets. |
| 617 | -- |
| 618 | -- Both sets can be computed easily, and subtracted |
| 619 | -- from each other. Then we can get the associated |
| 620 | -- file (name) for display. |
| 621 | |
| 622 | SELECT P.name, S.name |
| 623 | FROM project P, branch B, symbol S |
| 624 | WHERE B.bid IN (SELECT bid -- All branches |
| 625 | FROM branch |
| 626 | EXCEPT -- subtract |
| 627 | SELECT CR.rid -- branches used |
| 628 | FROM csrevision CR, changeset C |
| 629 | WHERE C.cid = CR.cid -- by any branch |
| 630 | AND C.type = 2) -- changeset |
| 631 | AND S.sid = B.sid -- get symbol of branch |
| 632 | AND P.pid = S.pid -- get project of symbol |
| 633 | } |
| 634 | # Find all branches which are used by more than one changeset. |
| 635 | CheckRev \ |
| 636 | {All branches have to be used by at most one changeset} \ |
| 637 | {is used by multiple changesets} { |
| 638 | -- Principle of operation: Get all branch/changeset |
| 639 | -- pairs for all branch changesets, group by tag to |
| 640 | -- aggregate the changeset, counting them. From the |
| 641 | -- resulting branch/count table select those with more |
| 642 | -- than one user, and get their associated file (name) |
| 643 | -- for display. |
| 644 | |
| 645 | SELECT P.name, S.name |
| 646 | FROM branch B, project P, symbol S, |
| 647 | (SELECT CR.rid AS rid, count(CR.cid) AS count |
| 648 | FROM csrevision CR, changeset C |
| 649 | WHERE C.type = 2 |
| 650 | AND C.cid = CR.cid |
| 651 | GROUP BY CR.rid ) AS U |
| 652 | WHERE U.count > 1 |
| 653 | AND B.bid = U.rid |
| 654 | AND S.sid = B.sid -- get symbol of branch |
| 655 | AND P.pid = S.pid -- get project of symbol |
| 656 | } |
| 657 | # All branches have to agree on the LOD their changeset |
| 658 | # belongs to. In other words, all branches in a changeset have |
| 659 | # to refer to the same line of development. |
| 660 | # |
| 661 | # Instead of looking at all pairs of branches in all |
| 662 | # changesets we generate the distinct set of all LODs |
| 663 | # referenced by the branches of a changeset, look for those |
| 664 | # with cardinality > 1, and get the identifying information |
| 665 | # for the changesets found thusly. |
| 666 | CheckCS \ |
| 667 | {All branches in a changeset have to belong to the same LOD} \ |
| 668 | {: Its branches disagree about the LOD they belong to} { |
| 669 | SELECT T.name, C.cid |
| 670 | FROM changeset C, cstype T |
| 671 | WHERE C.cid IN (SELECT U.cid |
| 672 | FROM (SELECT DISTINCT CR.cid AS cid, B.lod AS lod |
| 673 | FROM csrevision CR, changeset C, branch B |
| 674 | WHERE CR.rid = B.bid |
| 675 | AND C.cid = CR.cid |
| 676 | AND C.type = 2) AS U |
| 677 | GROUP BY U.cid HAVING COUNT(U.lod) > 1) |
| 678 | AND T.tid = C.type |
| 679 | } |
| 680 | # All branches have to agree on the project their changeset |
| 681 | # belongs to. In other words, all branches in a changeset have |
| 682 | # to refer to the same project. |
| 683 | # |
| 684 | # Instead of looking at all pairs of branches in all |
| 685 | # changesets we generate the distinct set of all projects |
| 686 | # referenced by the branches of a changeset, look for those |
| 687 | # with cardinality > 1, and get the identifying information |
| 688 | # for the changesets found thusly. |
| 689 | CheckCS \ |
| 690 | {All branches in a changeset have to belong to the same project} \ |
| 691 | {: Its branches disagree about the project they belong to} { |
| 692 | SELECT T.name, C.cid |
| 693 | FROM changeset C, cstype T |
| 694 | WHERE C.cid IN (SELECT U.cid |
| 695 | FROM (SELECT DISTINCT CR.cid AS cid, F.pid AS pid |
| 696 | FROM csrevision CR, changeset C, branch B, file F |
| 697 | WHERE CR.rid = B.bid |
| 698 | AND C.cid = CR.cid |
| 699 | AND C.type = 2 |
| 700 | AND F.fid = B.fid) AS U |
| 701 | GROUP BY U.cid HAVING COUNT(U.pid) > 1) |
| 702 | AND T.tid = C.type |
| 703 | } |
| 704 | # All branches in a single changeset have to belong to |
| 705 | # different files. Conversely: No two branches of a single |
| 706 | # file are allowed to be in the same changeset. |
| 707 | # |
| 708 | # Instead of looking at all pairs of branches in all |
| 709 | # changesets we generate the distinct set of all files |
| 710 | # referenced by the branches of a changeset, and look for |
| 711 | # those with cardinality < the cardinality of the set of |
| 712 | # branches, and get the identifying information for the |
| 713 | # changesets found thusly. |
| 714 | CheckCS \ |
| 715 | {All branches in a changeset have to belong to different files} \ |
| 716 | {: Its branches share files} { |
| 717 | SELECT T.name, C.cid |
| 718 | FROM changeset C, cstype T |
| 719 | WHERE C.cid IN (SELECT VV.cid |
| 720 | FROM (SELECT U.cid as cid, COUNT (U.fid) AS fcount |
| 721 | FROM (SELECT DISTINCT CR.cid AS cid, B.fid AS fid |
| 722 | FROM csrevision CR, changeset C, branch B |
| 723 | WHERE CR.rid = B.bid |
| 724 | AND C.cid = CR.cid |
| 725 | AND C.type = 2 |
| 726 | ) AS U |
| 727 | GROUP BY U.cid) AS UU, |
| 728 | (SELECT V.cid AS cid, COUNT (V.rid) AS rcount |
| 729 | FROM csrevision V, changeset X |
| 730 | WHERE X.cid = V.cid |
| 731 | AND X.type = 2 |
| 732 | GROUP BY V.cid) AS VV |
| 733 | WHERE VV.cid = UU.cid |
| 734 | AND UU.fcount < VV.rcount) |
| 735 | AND T.tid = C.type |
| 736 | } |
| 737 | return |
| 738 | } |
| 739 | |
| 740 | proc ___UnusedChangesetChecks___ {} { |
| 741 | # This code performs a number of paranoid checks of the |
| 742 | # database, searching for inconsistent changeset/revision |
| 743 |