mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 07:20:57 +01:00
Reduce callsites to "ArcanistDifferentialRevisionStatus" in Phabricator
Summary: Ref T2543. These are currently numeric values, like "0" and "3". I want to replace them with strings, like "accepted", and move definitions from Arcanist to Phabricator. To set the stage for this, reduce the number of callsites where Phabricator invokes `ArcanistDifferentialRevisionStatus`. This is just the easy ones. I'll hold this until the release cut. Test Plan: - Called `differential.find`. - Called `differential.getrevision`. - Called `differential.query`. - Removed all reviewers from a revision, saw warning. - Abandoned the no-reviewers revision, no more warning. - Attached a revision to a task to get it to show the state icon with the status on a tooltip. - Viewed revision bucketing on dashboard. - Used `bin/search index` to reindex a revision. - Hit the "Land Revision" endpoint. I didn't explicitly test these cases: - Doorkeeper Asana integration, since setup takes a thousand years. - Disambiguation logic when multiple hashes match, since setup is also very involved. - Releeph because it's Releeph. Reviewers: chad Reviewed By: chad Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T2543 Differential Revision: https://secure.phabricator.com/D18339
This commit is contained in:
parent
b1e3cf627d
commit
2e36653965
15 changed files with 49 additions and 69 deletions
|
@ -88,9 +88,7 @@ final class DifferentialFindConduitAPIMethod
|
|||
'uri' => PhabricatorEnv::getProductionURI('/D'.$id),
|
||||
'dateCreated' => $revision->getDateCreated(),
|
||||
'authorPHID' => $revision->getAuthorPHID(),
|
||||
'statusName' =>
|
||||
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
|
||||
$revision->getStatus()),
|
||||
'statusName' => $revision->getStatusDisplayName(),
|
||||
'sourcePath' => $diff->getSourcePath(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -83,9 +83,7 @@ final class DifferentialGetRevisionConduitAPIMethod
|
|||
'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
|
||||
'title' => $revision->getTitle(),
|
||||
'status' => $revision->getStatus(),
|
||||
'statusName' =>
|
||||
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
|
||||
$revision->getStatus()),
|
||||
'statusName' => $revision->getStatusDisplayName(),
|
||||
'summary' => $revision->getSummary(),
|
||||
'testPlan' => $revision->getTestPlan(),
|
||||
'lineCount' => $revision->getLineCount(),
|
||||
|
|
|
@ -221,9 +221,7 @@ final class DifferentialQueryConduitAPIMethod
|
|||
'dateModified' => $revision->getDateModified(),
|
||||
'authorPHID' => $revision->getAuthorPHID(),
|
||||
'status' => $revision->getStatus(),
|
||||
'statusName' =>
|
||||
ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
|
||||
$revision->getStatus()),
|
||||
'statusName' => $revision->getStatusDisplayName(),
|
||||
'properties' => $revision->getProperties(),
|
||||
'branch' => $diff->getBranch(),
|
||||
'summary' => $revision->getSummary(),
|
||||
|
|
|
@ -76,16 +76,17 @@ final class DifferentialBranchField
|
|||
PhabricatorApplicationTransactionEditor $editor,
|
||||
array $xactions) {
|
||||
|
||||
$status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
|
||||
$revision = $this->getObject();
|
||||
|
||||
// Show the "BRANCH" section only if there's a new diff or the revision
|
||||
// is "Accepted".
|
||||
if ((!$editor->getDiffUpdateTransaction($xactions)) &&
|
||||
($this->getObject()->getStatus() != $status_accepted)) {
|
||||
$is_update = (bool)$editor->getDiffUpdateTransaction($xactions);
|
||||
$is_accepted = $revision->isAccepted();
|
||||
if (!$is_update && !$is_accepted) {
|
||||
return;
|
||||
}
|
||||
|
||||
$branch = $this->getBranchDescription($this->getObject()->getActiveDiff());
|
||||
$branch = $this->getBranchDescription($revision->getActiveDiff());
|
||||
if ($branch === null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -68,8 +68,7 @@ final class DifferentialReviewersField
|
|||
public function getWarningsForRevisionHeader(array $handles) {
|
||||
$revision = $this->getObject();
|
||||
|
||||
$status_needs_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
||||
if ($revision->getStatus() != $status_needs_review) {
|
||||
if (!$revision->isNeedsReview()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@ final class DifferentialDoorkeeperRevisionFeedStoryPublisher
|
|||
}
|
||||
|
||||
public function getActiveUserPHIDs($object) {
|
||||
$status = $object->getStatus();
|
||||
if ($status == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) {
|
||||
if ($object->isNeedsReview()) {
|
||||
return $object->getReviewerPHIDs();
|
||||
} else {
|
||||
return array();
|
||||
|
@ -44,8 +43,7 @@ final class DifferentialDoorkeeperRevisionFeedStoryPublisher
|
|||
}
|
||||
|
||||
public function getPassiveUserPHIDs($object) {
|
||||
$status = $object->getStatus();
|
||||
if ($status == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) {
|
||||
if ($object->isNeedsReview()) {
|
||||
return array();
|
||||
} else {
|
||||
return $object->getReviewerPHIDs();
|
||||
|
|
|
@ -50,8 +50,7 @@ final class DifferentialRevisionPHIDType extends PhabricatorPHIDType {
|
|||
|
||||
$icon = DifferentialRevisionStatus::getRevisionStatusIcon($status);
|
||||
$color = DifferentialRevisionStatus::getRevisionStatusColor($status);
|
||||
$name = ArcanistDifferentialRevisionStatus::getNameForRevisionStatus(
|
||||
$status);
|
||||
$name = $revision->getStatusDisplayName();
|
||||
|
||||
$handle
|
||||
->setStateIcon($icon)
|
||||
|
|
|
@ -134,13 +134,11 @@ final class DifferentialRevisionRequiredActionResultBucket
|
|||
}
|
||||
|
||||
private function filterShouldLand(array $phids) {
|
||||
$status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
|
||||
|
||||
$objects = $this->getRevisionsAuthored($this->objects, $phids);
|
||||
|
||||
$results = array();
|
||||
foreach ($objects as $key => $object) {
|
||||
if ($object->getStatus() != $status_accepted) {
|
||||
if (!$object->isAccepted()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -175,13 +173,11 @@ final class DifferentialRevisionRequiredActionResultBucket
|
|||
}
|
||||
|
||||
private function filterWaitingForReview(array $phids) {
|
||||
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
||||
|
||||
$objects = $this->getRevisionsAuthored($this->objects, $phids);
|
||||
|
||||
$results = array();
|
||||
foreach ($objects as $key => $object) {
|
||||
if ($object->getStatus() != $status_review) {
|
||||
if (!$object->isNeedsReview()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -217,16 +213,11 @@ final class DifferentialRevisionRequiredActionResultBucket
|
|||
}
|
||||
|
||||
private function filterWaitingOnOtherReviewers(array $phids) {
|
||||
$statuses = array(
|
||||
ArcanistDifferentialRevisionStatus::NEEDS_REVIEW,
|
||||
);
|
||||
$statuses = array_fuse($statuses);
|
||||
|
||||
$objects = $this->getRevisionsNotAuthored($this->objects, $phids);
|
||||
|
||||
$results = array();
|
||||
foreach ($objects as $key => $object) {
|
||||
if (!isset($statuses[$object->getStatus()])) {
|
||||
if (!$object->isNeedsReview()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,8 @@ abstract class DifferentialRevisionResultBucket
|
|||
|
||||
$objects = $this->getRevisionsNotAuthored($objects, $phids);
|
||||
|
||||
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
||||
foreach ($objects as $key => $object) {
|
||||
if ($object->getStatus() != $status_review) {
|
||||
if (!$object->isNeedsReview()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,11 +235,9 @@ final class DifferentialRevisionSearchEngine
|
|||
}
|
||||
|
||||
private function loadUnlandedDependencies(array $revisions) {
|
||||
$status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
|
||||
|
||||
$phids = array();
|
||||
foreach ($revisions as $revision) {
|
||||
if ($revision->getStatus() != $status_accepted) {
|
||||
if (!$revision->isAccepted()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@ final class DifferentialRevisionFulltextEngine
|
|||
|
||||
// If a revision needs review, the owners are the reviewers. Otherwise, the
|
||||
// owner is the author (e.g., accepted, rejected, closed).
|
||||
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
||||
if ($revision->getStatus() == $status_review) {
|
||||
if ($revision->isNeedsReview()) {
|
||||
$reviewers = $revision->getReviewerPHIDs();
|
||||
$reviewers = array_fuse($reviewers);
|
||||
|
||||
|
|
|
@ -626,6 +626,11 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
return ($this->getStatus() == $status_accepted);
|
||||
}
|
||||
|
||||
public function isNeedsReview() {
|
||||
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
|
||||
return ($this->getStatus() == $status_review);
|
||||
}
|
||||
|
||||
public function getStatusIcon() {
|
||||
$map = array(
|
||||
ArcanistDifferentialRevisionStatus::NEEDS_REVIEW
|
||||
|
|
|
@ -122,9 +122,8 @@ final class DiffusionLowLevelCommitFieldsQuery
|
|||
$revisions = array_reverse($revisions);
|
||||
|
||||
// Try to find an accepted revision first.
|
||||
$status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
|
||||
foreach ($revisions as $revision) {
|
||||
if ($revision->getStatus() == $status_accepted) {
|
||||
if ($revision->isAccepted()) {
|
||||
return $revision;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -289,31 +289,30 @@ final class DrydockLandRepositoryOperation
|
|||
);
|
||||
}
|
||||
|
||||
$status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
|
||||
if ($revision->getStatus() != $status_accepted) {
|
||||
switch ($revision->getStatus()) {
|
||||
case ArcanistDifferentialRevisionStatus::CLOSED:
|
||||
return array(
|
||||
'title' => pht('Revision Closed'),
|
||||
'body' => pht(
|
||||
'This revision has already been closed. Only open, accepted '.
|
||||
'revisions may land.'),
|
||||
);
|
||||
case ArcanistDifferentialRevisionStatus::ABANDONED:
|
||||
return array(
|
||||
'title' => pht('Revision Abandoned'),
|
||||
'body' => pht(
|
||||
'This revision has been abandoned. Only accepted revisions '.
|
||||
'may land.'),
|
||||
);
|
||||
default:
|
||||
return array(
|
||||
'title' => pht('Revision Not Accepted'),
|
||||
'body' => pht(
|
||||
'This revision is still under review. Only revisions which '.
|
||||
'have been accepted may land.'),
|
||||
);
|
||||
}
|
||||
if ($revision->isAccepted()) {
|
||||
// We can land accepted revisions, so continue below. Otherwise, raise
|
||||
// an error with tailored messaging for the most common cases.
|
||||
} else if ($revision->isAbandoned()) {
|
||||
return array(
|
||||
'title' => pht('Revision Abandoned'),
|
||||
'body' => pht(
|
||||
'This revision has been abandoned. Only accepted revisions '.
|
||||
'may land.'),
|
||||
);
|
||||
} else if ($revision->isClosed()) {
|
||||
return array(
|
||||
'title' => pht('Revision Closed'),
|
||||
'body' => pht(
|
||||
'This revision has already been closed. Only open, accepted '.
|
||||
'revisions may land.'),
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'title' => pht('Revision Not Accepted'),
|
||||
'body' => pht(
|
||||
'This revision is still under review. Only revisions which '.
|
||||
'have been accepted may land.'),
|
||||
);
|
||||
}
|
||||
|
||||
// Check for other operations. Eventually this should probably be more
|
||||
|
|
|
@ -79,8 +79,7 @@ final class DifferentialReleephRequestFieldSpecification extends Phobject {
|
|||
return null;
|
||||
}
|
||||
|
||||
$status = $this->getRevision()->getStatus();
|
||||
if ($status == ArcanistDifferentialRevisionStatus::CLOSED) {
|
||||
if ($this->getRevision()->isClosed()) {
|
||||
$verb = $tense[$this->releephAction]['past'];
|
||||
} else {
|
||||
$verb = $tense[$this->releephAction]['future'];
|
||||
|
|
Loading…
Reference in a new issue