diff --git a/resources/sql/patches/20130507.releephrqsimplifycols.sql b/resources/sql/patches/20130507.releephrqsimplifycols.sql new file mode 100644 index 0000000000..ef8c8b5888 --- /dev/null +++ b/resources/sql/patches/20130507.releephrqsimplifycols.sql @@ -0,0 +1,8 @@ +ALTER TABLE {$NAMESPACE}_releeph.releeph_request + DROP COLUMN requestCommitIdentifier, + DROP COLUMN requestCommitOrdinal, + DROP COLUMN status, + DROP COLUMN committedByUserPHID, + DROP KEY `requestIdentifierBranch`, + ADD CONSTRAINT + UNIQUE KEY `requestIdentifierBranch` (`requestCommitPHID`, `branchID`); diff --git a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php index c17dbbdcb3..1e9d373bc0 100644 --- a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php +++ b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php @@ -71,7 +71,7 @@ final class ConduitAPI_releephwork_nextrequest_Method * This is easy for $needs_pick as the ordinal is stored. It is hard for * reverts, as we have to look that information up. */ - $needs_pick = msort($needs_pick, 'getRequestCommitOrdinal'); + $needs_pick = $this->sortPicks($needs_pick); $needs_revert = $this->sortReverts($needs_revert); /** @@ -95,8 +95,9 @@ final class ConduitAPI_releephwork_nextrequest_Method } elseif ($needs_pick) { $releeph_request = head($needs_pick); $action = 'pick'; - $commit_id = $releeph_request->getRequestCommitIdentifier(); - $commit_phid = $releeph_request->getRequestCommitPHID(); + $commit = $releeph_request->loadPhabricatorRepositoryCommit(); + $commit_id = $commit->getCommitIdentifier(); + $commit_phid = $commit->getPHID(); } else { // Return early if there's nothing to do! return array(); @@ -165,6 +166,18 @@ final class ConduitAPI_releephwork_nextrequest_Method ); } + private function sortPicks(array $releeph_requests) { + $surrogate = array(); + foreach ($releeph_requests as $rq) { + // TODO: it's likely that relying on the `id` column to provide + // trunk-commit-order is thoroughly broken. + $ordinal = (int) $rq->loadPhabricatorRepositoryCommit()->getID(); + $surrogate[$ordinal] = $rq; + } + ksort($surrogate); + return $surrogate; + } + /** * Sort an array of ReleephRequests, that have been picked into a branch, in * the order in which they were picked to the branch. diff --git a/src/applications/releeph/controller/request/ReleephRequestEditController.php b/src/applications/releeph/controller/request/ReleephRequestEditController.php index eefe3bf601..9ccbb23315 100644 --- a/src/applications/releeph/controller/request/ReleephRequestEditController.php +++ b/src/applications/releeph/controller/request/ReleephRequestEditController.php @@ -14,7 +14,6 @@ final class ReleephRequestEditController extends ReleephController { $phids = array(); $phids[] = $releeph_request->getRequestCommitPHID(); $phids[] = $releeph_request->getRequestUserPHID(); - $phids[] = $releeph_request->getCommittedByUserPHID(); $handles = id(new PhabricatorObjectHandleData($phids)) ->setViewer($request->getUser()) diff --git a/src/applications/releeph/editor/ReleephRequestEditor.php b/src/applications/releeph/editor/ReleephRequestEditor.php index 8cb0945e2f..9b6e31b310 100644 --- a/src/applications/releeph/editor/ReleephRequestEditor.php +++ b/src/applications/releeph/editor/ReleephRequestEditor.php @@ -44,9 +44,7 @@ final class ReleephRequestEditor extends PhabricatorEditor { $rq ->setBranchID($branch->getID()) - ->setRequestCommitIdentifier($commit->getCommitIdentifier()) ->setRequestCommitPHID($commit->getPHID()) - ->setRequestCommitOrdinal($commit->getID()) ->setInBranch(0) ->setRequestUserPHID($requestor->getPHID()) ->setUserIntent($requestor, ReleephRequest::INTENT_WANT) @@ -177,7 +175,6 @@ final class ReleephRequestEditor extends PhabricatorEditor { ->setPickStatus(ReleephRequest::PICK_OK) ->setCommitIdentifier($new_commit_id) ->setCommitPHID(null) - ->setCommittedByUserPHID($actor->getPHID()) ->save(); break; @@ -187,7 +184,6 @@ final class ReleephRequestEditor extends PhabricatorEditor { ->setPickStatus(ReleephRequest::REVERT_OK) ->setCommitIdentifier(null) ->setCommitPHID(null) - ->setCommittedByUserPHID(null) ->save(); break; @@ -254,7 +250,6 @@ final class ReleephRequestEditor extends PhabricatorEditor { ->setPickStatus(ReleephRequest::PICK_OK) ->setCommitIdentifier($commit->getCommitIdentifier()) ->setCommitPHID($commit->getPHID()) - ->setCommittedByUserPHID($actor->getPHID()) ->save(); break; @@ -264,7 +259,6 @@ final class ReleephRequestEditor extends PhabricatorEditor { ->setPickStatus(ReleephRequest::REVERT_OK) ->setCommitIdentifier(null) ->setCommitPHID(null) - ->setCommittedByUserPHID(null) ->save(); break; diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php index 30cb80c487..67ab8d79d2 100644 --- a/src/applications/releeph/storage/ReleephRequest.php +++ b/src/applications/releeph/storage/ReleephRequest.php @@ -11,13 +11,10 @@ final class ReleephRequest extends ReleephDAO { protected $pickStatus; // Information about the thing being requested - protected $requestCommitIdentifier; protected $requestCommitPHID; - protected $requestCommitOrdinal; // Information about the last commit to the releeph branch protected $commitIdentifier; - protected $committedByUserPHID; protected $commitPHID; // Pre-populated handles that we'll bulk load in ReleephBranch @@ -267,10 +264,12 @@ final class ReleephRequest extends ReleephDAO { } public function loadPhabricatorRepositoryCommitData() { - return $this->loadOneRelative( - new PhabricatorRepositoryCommitData(), - 'commitID', - 'getRequestCommitOrdinal'); + $commit = $this->loadPhabricatorRepositoryCommit(); + if ($commit) { + return $commit->loadOneRelative( + new PhabricatorRepositoryCommitData(), + 'commitID'); + } } public function loadDifferentialRevision() { diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index 74762e901d..c17ffd3d26 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1270,6 +1270,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('20130502.countdownrevamp3.sql'), ), + '20130507.releephrqsimplifycols.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('20130507.releephrqsimplifycols.sql'), + ), ); } }