From c7e7b63f155f22d4e1915f81584338dfb8631733 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 11 Sep 2018 07:19:37 -0700 Subject: [PATCH] Rename "PhabricatorAuditCommitStatusConstants" to "DiffusionCommitAuditStatus"; remove "MODERN_" Summary: Depends on D19656. Ref T13197. See PHI851. - This class is now a real object, so get rid of the "Constants" part of the name. - Rename it for greater consistency with other modern objects. - Get rid of the `MODERN_` tag now that the old constants are gone. Test Plan: Bunch of `grep`, browsed around. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13197 Differential Revision: https://secure.phabricator.com/D19657 --- src/__phutil_library_map__.php | 4 +- .../conduit/AuditQueryConduitAPIMethod.php | 10 ++--- .../query/PhabricatorCommitSearchEngine.php | 6 +-- .../DiffusionCommitAuditStatus.php} | 38 +++++++++---------- .../diffusion/query/DiffusionCommitQuery.php | 2 +- .../DiffusionCommitConcernTransaction.php | 3 +- .../DiffusionCommitStateTransaction.php | 22 +++++------ .../DiffusionCommitVerifyTransaction.php | 3 +- .../PhabricatorOwnersDetailController.php | 3 +- .../storage/PhabricatorRepositoryCommit.php | 18 ++++----- 10 files changed, 52 insertions(+), 57 deletions(-) rename src/applications/{audit/constants/PhabricatorAuditCommitStatusConstants.php => diffusion/DiffusionCommitAuditStatus.php} (76%) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 9774741060..ab454e0455 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -704,6 +704,7 @@ phutil_register_library_map(array( 'DiffusionCommitAcceptTransaction' => 'applications/diffusion/xaction/DiffusionCommitAcceptTransaction.php', 'DiffusionCommitActionTransaction' => 'applications/diffusion/xaction/DiffusionCommitActionTransaction.php', 'DiffusionCommitAffectedFilesHeraldField' => 'applications/diffusion/herald/DiffusionCommitAffectedFilesHeraldField.php', + 'DiffusionCommitAuditStatus' => 'applications/diffusion/DiffusionCommitAuditStatus.php', 'DiffusionCommitAuditTransaction' => 'applications/diffusion/xaction/DiffusionCommitAuditTransaction.php', 'DiffusionCommitAuditorsHeraldField' => 'applications/diffusion/herald/DiffusionCommitAuditorsHeraldField.php', 'DiffusionCommitAuditorsTransaction' => 'applications/diffusion/xaction/DiffusionCommitAuditorsTransaction.php', @@ -2147,7 +2148,6 @@ phutil_register_library_map(array( 'PhabricatorAuditActionConstants' => 'applications/audit/constants/PhabricatorAuditActionConstants.php', 'PhabricatorAuditApplication' => 'applications/audit/application/PhabricatorAuditApplication.php', 'PhabricatorAuditCommentEditor' => 'applications/audit/editor/PhabricatorAuditCommentEditor.php', - 'PhabricatorAuditCommitStatusConstants' => 'applications/audit/constants/PhabricatorAuditCommitStatusConstants.php', 'PhabricatorAuditController' => 'applications/audit/controller/PhabricatorAuditController.php', 'PhabricatorAuditEditor' => 'applications/audit/editor/PhabricatorAuditEditor.php', 'PhabricatorAuditInlineComment' => 'applications/audit/storage/PhabricatorAuditInlineComment.php', @@ -6066,6 +6066,7 @@ phutil_register_library_map(array( 'DiffusionCommitAcceptTransaction' => 'DiffusionCommitAuditTransaction', 'DiffusionCommitActionTransaction' => 'DiffusionCommitTransactionType', 'DiffusionCommitAffectedFilesHeraldField' => 'DiffusionCommitHeraldField', + 'DiffusionCommitAuditStatus' => 'Phobject', 'DiffusionCommitAuditTransaction' => 'DiffusionCommitActionTransaction', 'DiffusionCommitAuditorsHeraldField' => 'DiffusionCommitHeraldField', 'DiffusionCommitAuditorsTransaction' => 'DiffusionCommitTransactionType', @@ -7715,7 +7716,6 @@ phutil_register_library_map(array( 'PhabricatorAuditActionConstants' => 'Phobject', 'PhabricatorAuditApplication' => 'PhabricatorApplication', 'PhabricatorAuditCommentEditor' => 'PhabricatorEditor', - 'PhabricatorAuditCommitStatusConstants' => 'Phobject', 'PhabricatorAuditController' => 'PhabricatorController', 'PhabricatorAuditEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorAuditInlineComment' => array( diff --git a/src/applications/audit/conduit/AuditQueryConduitAPIMethod.php b/src/applications/audit/conduit/AuditQueryConduitAPIMethod.php index 6d29d2345d..d0d3779c2a 100644 --- a/src/applications/audit/conduit/AuditQueryConduitAPIMethod.php +++ b/src/applications/audit/conduit/AuditQueryConduitAPIMethod.php @@ -68,17 +68,17 @@ final class AuditQueryConduitAPIMethod extends AuditConduitAPIMethod { $status_map = array( self::AUDIT_LEGACYSTATUS_OPEN => array( - PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_AUDIT, - PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED, + DiffusionCommitAuditStatus::NEEDS_AUDIT, + DiffusionCommitAuditStatus::CONCERN_RAISED, ), self::AUDIT_LEGACYSTATUS_CONCERN => array( - PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED, + DiffusionCommitAuditStatus::CONCERN_RAISED, ), self::AUDIT_LEGACYSTATUS_ACCEPTED => array( - PhabricatorAuditCommitStatusConstants::MODERN_AUDITED, + DiffusionCommitAuditStatus::AUDITED, ), self::AUDIT_LEGACYSTATUS_PARTIAL => array( - PhabricatorAuditCommitStatusConstants::MODERN_PARTIALLY_AUDITED, + DiffusionCommitAuditStatus::PARTIALLY_AUDITED, ), ); diff --git a/src/applications/audit/query/PhabricatorCommitSearchEngine.php b/src/applications/audit/query/PhabricatorCommitSearchEngine.php index 67861b7e7d..44413946db 100644 --- a/src/applications/audit/query/PhabricatorCommitSearchEngine.php +++ b/src/applications/audit/query/PhabricatorCommitSearchEngine.php @@ -92,9 +92,9 @@ final class PhabricatorCommitSearchEngine ->setLabel(pht('Audit Status')) ->setKey('statuses') ->setAliases(array('status')) - ->setOptions(PhabricatorAuditCommitStatusConstants::newOptions()) + ->setOptions(DiffusionCommitAuditStatus::newOptions()) ->setDeprecatedOptions( - PhabricatorAuditCommitStatusConstants::newDeprecatedOptions()) + DiffusionCommitAuditStatus::newDeprecatedOptions()) ->setDescription(pht('Find commits with given audit statuses.')), id(new PhabricatorSearchDatasourceField()) ->setLabel(pht('Repositories')) @@ -162,7 +162,7 @@ final class PhabricatorCommitSearchEngine case 'active': $bucket_key = DiffusionCommitRequiredActionResultBucket::BUCKETKEY; - $open = PhabricatorAuditCommitStatusConstants::getOpenStatusConstants(); + $open = DiffusionCommitAuditStatus::getOpenStatusConstants(); $query ->setParameter('responsiblePHIDs', array($viewer_phid)) diff --git a/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php b/src/applications/diffusion/DiffusionCommitAuditStatus.php similarity index 76% rename from src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php rename to src/applications/diffusion/DiffusionCommitAuditStatus.php index 98b8324a38..ce8ec09d27 100644 --- a/src/applications/audit/constants/PhabricatorAuditCommitStatusConstants.php +++ b/src/applications/diffusion/DiffusionCommitAuditStatus.php @@ -1,16 +1,16 @@ key == self::MODERN_NONE); + return ($this->key == self::NONE); } public function isNeedsAudit() { - return ($this->key == self::MODERN_NEEDS_AUDIT); + return ($this->key == self::NEEDS_AUDIT); } public function isConcernRaised() { - return ($this->key == self::MODERN_CONCERN_RAISED); + return ($this->key == self::CONCERN_RAISED); } public function isNeedsVerification() { - return ($this->key == self::MODERN_NEEDS_VERIFICATION); + return ($this->key == self::NEEDS_VERIFICATION); } public function isPartiallyAudited() { - return ($this->key == self::MODERN_PARTIALLY_AUDITED); + return ($this->key == self::PARTIALLY_AUDITED); } public function isAudited() { - return ($this->key == self::MODERN_AUDITED); + return ($this->key == self::AUDITED); } public function getIsClosed() { @@ -116,42 +116,42 @@ final class PhabricatorAuditCommitStatusConstants extends Phobject { private static function getMap() { return array( - self::MODERN_NONE => array( + self::NONE => array( 'name' => pht('No Audits'), 'legacy' => 0, 'icon' => 'fa-check', 'color' => 'bluegrey', 'closed' => true, ), - self::MODERN_NEEDS_AUDIT => array( + self::NEEDS_AUDIT => array( 'name' => pht('Audit Required'), 'legacy' => 1, 'icon' => 'fa-exclamation-circle', 'color' => 'orange', 'closed' => false, ), - self::MODERN_CONCERN_RAISED => array( + self::CONCERN_RAISED => array( 'name' => pht('Concern Raised'), 'legacy' => 2, 'icon' => 'fa-times-circle', 'color' => 'red', 'closed' => false, ), - self::MODERN_PARTIALLY_AUDITED => array( + self::PARTIALLY_AUDITED => array( 'name' => pht('Partially Audited'), 'legacy' => 3, 'icon' => 'fa-check-circle-o', 'color' => 'yellow', 'closed' => false, ), - self::MODERN_AUDITED => array( + self::AUDITED => array( 'name' => pht('Audited'), 'legacy' => 4, 'icon' => 'fa-check-circle', 'color' => 'green', 'closed' => true, ), - self::MODERN_NEEDS_VERIFICATION => array( + self::NEEDS_VERIFICATION => array( 'name' => pht('Needs Verification'), 'legacy' => 5, 'icon' => 'fa-refresh', diff --git a/src/applications/diffusion/query/DiffusionCommitQuery.php b/src/applications/diffusion/query/DiffusionCommitQuery.php index 0a50e834c3..f2d0920b3a 100644 --- a/src/applications/diffusion/query/DiffusionCommitQuery.php +++ b/src/applications/diffusion/query/DiffusionCommitQuery.php @@ -714,7 +714,7 @@ final class DiffusionCommitQuery } if ($this->statuses !== null) { - $statuses = PhabricatorAuditCommitStatusConstants::newModernKeys( + $statuses = DiffusionCommitAuditStatus::newModernKeys( $this->statuses); $where[] = qsprintf( diff --git a/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php index 21d688a481..1f6ae72621 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitConcernTransaction.php @@ -33,8 +33,7 @@ final class DiffusionCommitConcernTransaction public function applyInternalEffects($object, $value) { // NOTE: We force the commit directly into "Concern Raised" so that we // override a possible "Needs Verification" state. - $object->setAuditStatus( - PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED); + $object->setAuditStatus(DiffusionCommitAuditStatus::CONCERN_RAISED); } public function applyExternalEffects($object, $value) { diff --git a/src/applications/diffusion/xaction/DiffusionCommitStateTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitStateTransaction.php index ad8b94f548..6fd2a6977d 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitStateTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitStateTransaction.php @@ -13,7 +13,7 @@ final class DiffusionCommitStateTransaction private function getAuditStatusObject() { $new = $this->getNewValue(); - return PhabricatorAuditCommitStatusConstants::newForStatus($new); + return DiffusionCommitAuditStatus::newForStatus($new); } public function getIcon() { @@ -28,15 +28,15 @@ final class DiffusionCommitStateTransaction $status = $this->getAuditStatusObject(); switch ($status->getKey()) { - case PhabricatorAuditCommitStatusConstants::MODERN_NONE: + case DiffusionCommitAuditStatus::NONE: return pht('This commit no longer requires audit.'); - case PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_AUDIT: + case DiffusionCommitAuditStatus::NEEDS_AUDIT: return pht('This commit now requires audit.'); - case PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED: + case DiffusionCommitAuditStatus::CONCERN_RAISED: return pht('This commit now has outstanding concerns.'); - case PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_VERIFICATION: + case DiffusionCommitAuditStatus::NEEDS_VERIFICATION: return pht('This commit now requires verification by auditors.'); - case PhabricatorAuditCommitStatusConstants::MODERN_AUDITED: + case DiffusionCommitAuditStatus::AUDITED: return pht('All concerns with this commit have now been addressed.'); } @@ -47,23 +47,23 @@ final class DiffusionCommitStateTransaction $status = $this->getAuditStatusObject(); switch ($status->getKey()) { - case PhabricatorAuditCommitStatusConstants::MODERN_NONE: + case DiffusionCommitAuditStatus::NONE: return pht( '%s no longer requires audit.', $this->renderObject()); - case PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_AUDIT: + case DiffusionCommitAuditStatus::NEEDS_AUDIT: return pht( '%s now requires audit.', $this->renderObject()); - case PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED: + case DiffusionCommitAuditStatus::CONCERN_RAISED: return pht( '%s now has outstanding concerns.', $this->renderObject()); - case PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_VERIFICATION: + case DiffusionCommitAuditStatus::NEEDS_VERIFICATION: return pht( '%s now requires verification by auditors.', $this->renderObject()); - case PhabricatorAuditCommitStatusConstants::MODERN_AUDITED: + case DiffusionCommitAuditStatus::AUDITED: return pht( 'All concerns with %s have now been addressed.', $this->renderObject()); diff --git a/src/applications/diffusion/xaction/DiffusionCommitVerifyTransaction.php b/src/applications/diffusion/xaction/DiffusionCommitVerifyTransaction.php index 5464df7fa1..f1ec5834b1 100644 --- a/src/applications/diffusion/xaction/DiffusionCommitVerifyTransaction.php +++ b/src/applications/diffusion/xaction/DiffusionCommitVerifyTransaction.php @@ -36,8 +36,7 @@ final class DiffusionCommitVerifyTransaction } public function applyInternalEffects($object, $value) { - $object->setAuditStatus( - PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_VERIFICATION); + $object->setAuditStatus(DiffusionCommitAuditStatus::NEEDS_VERIFICATION); } protected function validateAction($object, PhabricatorUser $viewer) { diff --git a/src/applications/owners/controller/PhabricatorOwnersDetailController.php b/src/applications/owners/controller/PhabricatorOwnersDetailController.php index bdc4a2e475..f71009cf19 100644 --- a/src/applications/owners/controller/PhabricatorOwnersDetailController.php +++ b/src/applications/owners/controller/PhabricatorOwnersDetailController.php @@ -71,8 +71,7 @@ final class PhabricatorOwnersDetailController 'package' => $package->getPHID(), )); - $status_concern = - PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED; + $status_concern = DiffusionCommitAuditStatus::CONCERN_RAISED; $attention_commits = id(new DiffusionCommitQuery()) ->setViewer($request->getUser()) diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php index 7b9f38c388..38a6631200 100644 --- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php +++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php @@ -27,7 +27,7 @@ final class PhabricatorRepositoryCommit protected $epoch; protected $mailKey; protected $authorPHID; - protected $auditStatus = PhabricatorAuditCommitStatusConstants::MODERN_NONE; + protected $auditStatus = DiffusionCommitAuditStatus::NONE; protected $summary = ''; protected $importStatus = 0; @@ -385,22 +385,20 @@ final class PhabricatorRepositoryCommit if ($this->isAuditStatusNeedsVerification()) { // If the change is in "Needs Verification", we keep it there as // long as any auditors still have concerns. - $status = - PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_VERIFICATION; + $status = DiffusionCommitAuditStatus::NEEDS_VERIFICATION; } else { - $status = PhabricatorAuditCommitStatusConstants::MODERN_CONCERN_RAISED; + $status = DiffusionCommitAuditStatus::CONCERN_RAISED; } } else if ($any_accept) { if ($any_need) { - $status = - PhabricatorAuditCommitStatusConstants::MODERN_PARTIALLY_AUDITED; + $status = DiffusionCommitAuditStatus::PARTIALLY_AUDITED; } else { - $status = PhabricatorAuditCommitStatusConstants::MODERN_AUDITED; + $status = DiffusionCommitAuditStatus::AUDITED; } } else if ($any_need) { - $status = PhabricatorAuditCommitStatusConstants::MODERN_NEEDS_AUDIT; + $status = DiffusionCommitAuditStatus::NEEDS_AUDIT; } else { - $status = PhabricatorAuditCommitStatusConstants::MODERN_NONE; + $status = DiffusionCommitAuditStatus::NONE; } return $this->setAuditStatus($status); @@ -531,7 +529,7 @@ final class PhabricatorRepositoryCommit public function getAuditStatusObject() { $status = $this->getAuditStatus(); - return PhabricatorAuditCommitStatusConstants::newForStatus($status); + return DiffusionCommitAuditStatus::newForStatus($status); } public function isAuditStatusNoAudit() {