Differential D18339 Diff 44158 src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitFieldsQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/query/lowlevel/DiffusionLowLevelCommitFieldsQuery.php
| Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | private function pickBestRevision(array $revisions) { | ||||
| assert_instances_of($revisions, 'DifferentialRevision'); | assert_instances_of($revisions, 'DifferentialRevision'); | ||||
| // If we have more than one revision of a given status, choose the most | // If we have more than one revision of a given status, choose the most | ||||
| // recently updated one. | // recently updated one. | ||||
| $revisions = msort($revisions, 'getDateModified'); | $revisions = msort($revisions, 'getDateModified'); | ||||
| $revisions = array_reverse($revisions); | $revisions = array_reverse($revisions); | ||||
| // Try to find an accepted revision first. | // Try to find an accepted revision first. | ||||
| $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; | |||||
| foreach ($revisions as $revision) { | foreach ($revisions as $revision) { | ||||
| if ($revision->getStatus() == $status_accepted) { | if ($revision->isAccepted()) { | ||||
| return $revision; | return $revision; | ||||
| } | } | ||||
| } | } | ||||
| // Try to find an open revision. | // Try to find an open revision. | ||||
| foreach ($revisions as $revision) { | foreach ($revisions as $revision) { | ||||
| if (!$revision->isClosed()) { | if (!$revision->isClosed()) { | ||||
| return $revision; | return $revision; | ||||
| } | } | ||||
| } | } | ||||
| // Settle for whatever's left. | // Settle for whatever's left. | ||||
| return head($revisions); | return head($revisions); | ||||
| } | } | ||||
| } | } | ||||