Page MenuHomePhabricator

D8820.id20929.diff
No OneTemporary

D8820.id20929.diff

diff --git a/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php b/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php
--- a/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php
+++ b/src/applications/releeph/conduit/ConduitAPI_releeph_queryrequests_Method.php
@@ -45,10 +45,8 @@
$releephRequests = $query->execute();
foreach ($releephRequests as $releephRequest) {
- $branch = $releephRequest->loadReleephBranch();
- if (!$branch) {
- continue;
- }
+ $branch = $releephRequest->getBranch();
+
$request_commit_phid = $releephRequest->getRequestCommitPHID();
$revisionPHID =
$query->getRevisionPHID($request_commit_phid);
diff --git a/src/applications/releeph/conduit/ConduitAPI_releeph_request_Method.php b/src/applications/releeph/conduit/ConduitAPI_releeph_request_Method.php
--- a/src/applications/releeph/conduit/ConduitAPI_releeph_request_Method.php
+++ b/src/applications/releeph/conduit/ConduitAPI_releeph_request_Method.php
@@ -10,7 +10,7 @@
public function defineParamTypes() {
return array(
'branchPHID' => 'required string',
- 'things' => 'required string',
+ 'things' => 'required list<string>',
'fields' => 'dict<string, string>',
);
}
@@ -35,15 +35,17 @@
->executeOne();
$branch_phid = $request->getValue('branchPHID');
- $releeph_branch = id(new ReleephBranch())
- ->loadOneWhere('phid = %s', $branch_phid);
+ $releeph_branch = id(new ReleephBranchQuery())
+ ->setViewer($user)
+ ->withPHIDs(array($branch_phid))
+ ->executeOne();
if (!$releeph_branch) {
throw id(new ConduitException("ERR_BRANCH"))->setErrorDescription(
"No ReleephBranch found with PHID {$branch_phid}!");
}
- $releeph_project = $releeph_branch->loadReleephProject();
+ $releeph_project = $releeph_branch->getProduct();
// Find the requested commit identifiers
$requested_commits = array();
diff --git a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getbranchcommitmessage_Method.php b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getbranchcommitmessage_Method.php
--- a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getbranchcommitmessage_Method.php
+++ b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getbranchcommitmessage_Method.php
@@ -26,10 +26,14 @@
}
protected function execute(ConduitAPIRequest $request) {
- $branch = id(new ReleephBranch())
- ->loadOneWhere('phid = %s', $request->getValue('branchPHID'));
+ $viewer = $request->getUser();
- $project = $branch->loadReleephProject();
+ $branch = id(new ReleephBranchQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($request->getValue('branchPHID')))
+ ->executeOne();
+
+ $project = $branch->getProduct();
$creator_phid = $branch->getCreatedByUserPHID();
$cut_phid = $branch->getCutPointCommitPHID();
diff --git a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getcommitmessage_Method.php b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getcommitmessage_Method.php
--- a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getcommitmessage_Method.php
+++ b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_getcommitmessage_Method.php
@@ -29,8 +29,12 @@
}
protected function execute(ConduitAPIRequest $request) {
- $releeph_request = id(new ReleephRequest())
- ->loadOneWhere('phid = %s', $request->getValue('requestPHID'));
+ $viewer = $request->getUser();
+
+ $releeph_request = id(new ReleephRequestQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($request->getValue('requestPHID')))
+ ->executeOne();
$action = $request->getValue('action');
@@ -38,8 +42,8 @@
$commit_message = array();
- $project = $releeph_request->loadReleephProject();
- $branch = $releeph_request->loadReleephBranch();
+ $branch = $releeph_request->getBranch();
+ $project = $branch->getProduct();
$selector = $project->getReleephFieldSelector();
$fields = $selector->getFieldSpecifications();
diff --git a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php
--- a/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php
+++ b/src/applications/releeph/conduit/work/ConduitAPI_releephwork_nextrequest_Method.php
@@ -38,10 +38,12 @@
$viewer = $request->getUser();
$seen = $request->getValue('seen');
- $branch = id(new ReleephBranch())
- ->loadOneWhere('phid = %s', $request->getValue('branchPHID'));
+ $branch = id(new ReleephBranchQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($request->getValue('branchPHID')))
+ ->executeOne();
- $project = $branch->loadReleephProject();
+ $project = $branch->getProduct();
$needs_pick = array();
$needs_revert = array();
diff --git a/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php b/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php
--- a/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php
+++ b/src/applications/releeph/differential/DifferentialReleephRequestFieldSpecification.php
@@ -195,7 +195,7 @@
$rqs_seen = array();
$groups = array();
foreach ($releeph_requests as $releeph_request) {
- $releeph_branch = $releeph_request->loadReleephBranch();
+ $releeph_branch = $releeph_request->getBranch();
$branch_name = $releeph_branch->getName();
$rq_id = 'RQ'.$releeph_request->getID();
@@ -252,7 +252,7 @@
return;
}
- $releeph_branch = head($releeph_requests)->loadReleephBranch();
+ $releeph_branch = head($releeph_requests)->getBranch();
if (!$this->isCommitOnBranch($repo, $commit, $releeph_branch)) {
return;
}
@@ -297,10 +297,12 @@
private function loadReleephRequests() {
if (!$this->releephPHIDs) {
return array();
- } else {
- return id(new ReleephRequest())
- ->loadAllWhere('phid IN (%Ls)', $this->releephPHIDs);
}
+
+ return id(new ReleephRequestQuery())
+ ->setViewer($this->getViewer())
+ ->withPHIDs($this->releephPHIDs)
+ ->execute();
}
private function isCommitOnBranch(PhabricatorRepository $repo,
diff --git a/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php b/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php
--- a/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php
+++ b/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php
@@ -204,8 +204,8 @@
protected function getMailTo(PhabricatorLiskDAO $object) {
$to_phids = array();
- $releeph_project = $object->loadReleephProject();
- foreach ($releeph_project->getPushers() as $phid) {
+ $product = $object->getBranch()->getProduct();
+ foreach ($product->getPushers() as $phid) {
$to_phids[] = $phid;
}
@@ -227,8 +227,8 @@
$body = parent::buildMailBody($object, $xactions);
$rq = $object;
- $releeph_branch = $rq->loadReleephBranch();
- $releeph_project = $releeph_branch->loadReleephProject();
+ $releeph_branch = $rq->getBranch();
+ $releeph_project = $releeph_branch->getProduct();
/**
* If any of the events we are emailing about were about a pick failure
diff --git a/src/applications/releeph/query/ReleephRequestQuery.php b/src/applications/releeph/query/ReleephRequestQuery.php
--- a/src/applications/releeph/query/ReleephRequestQuery.php
+++ b/src/applications/releeph/query/ReleephRequestQuery.php
@@ -89,18 +89,6 @@
public function willFilterPage(array $requests) {
- // TODO: These should be serviced by the query, but are not currently
- // denormalized anywhere. For now, filter them here instead.
-
- $keep_status = array_fuse($this->getKeepStatusConstants());
- if ($keep_status) {
- foreach ($requests as $key => $request) {
- if (empty($keep_status[$request->getStatus()])) {
- unset($requests[$key]);
- }
- }
- }
-
if ($this->severities) {
$severities = array_fuse($this->severities);
foreach ($requests as $key => $request) {
@@ -133,6 +121,20 @@
$request->attachBranch($branch);
}
+ // TODO: These should be serviced by the query, but are not currently
+ // denormalized anywhere. For now, filter them here instead. Note that
+ // we must perform this filtering *after* querying and attaching branches,
+ // because request status depends on the product.
+
+ $keep_status = array_fuse($this->getKeepStatusConstants());
+ if ($keep_status) {
+ foreach ($requests as $key => $request) {
+ if (empty($keep_status[$request->getStatus()])) {
+ unset($requests[$key]);
+ }
+ }
+ }
+
return $requests;
}
diff --git a/src/applications/releeph/storage/ReleephBranch.php b/src/applications/releeph/storage/ReleephBranch.php
--- a/src/applications/releeph/storage/ReleephBranch.php
+++ b/src/applications/releeph/storage/ReleephBranch.php
@@ -94,21 +94,13 @@
public function getURI($path = null) {
$components = array(
- '/releeph',
- rawurlencode($this->loadReleephProject()->getName()),
- rawurlencode($this->getBasename()),
- $path
+ '/releeph/branch',
+ $this->getID(),
+ $path,
);
return implode('/', $components);
}
- public function loadReleephProject() {
- return $this->loadOneRelative(
- new ReleephProject(),
- 'id',
- 'getReleephProjectID');
- }
-
public function isActive() {
return $this->getIsActive();
}
diff --git a/src/applications/releeph/storage/ReleephProject.php b/src/applications/releeph/storage/ReleephProject.php
--- a/src/applications/releeph/storage/ReleephProject.php
+++ b/src/applications/releeph/storage/ReleephProject.php
@@ -42,7 +42,7 @@
public function getURI($path = null) {
$components = array(
- '/releeph/project',
+ '/releeph/product',
$this->getID(),
$path
);
diff --git a/src/applications/releeph/storage/ReleephRequest.php b/src/applications/releeph/storage/ReleephRequest.php
--- a/src/applications/releeph/storage/ReleephRequest.php
+++ b/src/applications/releeph/storage/ReleephRequest.php
@@ -52,18 +52,15 @@
* passes on this request.
*/
public function getPusherIntent() {
- $project = $this->loadReleephProject();
- if (!$project) {
- return null;
- }
+ $product = $this->getBranch()->getProduct();
- if (!$project->getPushers()) {
+ if (!$product->getPushers()) {
return self::INTENT_WANT;
}
$found_pusher_want = false;
foreach ($this->userIntents as $phid => $intent) {
- if ($project->isAuthoritativePHID($phid)) {
+ if ($product->isAuthoritativePHID($phid)) {
if ($intent == self::INTENT_PASS) {
return self::INTENT_PASS;
}
@@ -210,20 +207,6 @@
/* -( Loading external objects )------------------------------------------- */
- public function loadReleephBranch() {
- return $this->loadOneRelative(
- new ReleephBranch(),
- 'id',
- 'getBranchID');
- }
-
- public function loadReleephProject() {
- $branch = $this->loadReleephBranch();
- if ($branch) {
- return $branch->loadReleephProject();
- }
- }
-
public function loadPhabricatorRepositoryCommit() {
return $this->loadOneRelative(
new PhabricatorRepositoryCommit(),

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 27, 1:25 PM (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6731100
Default Alt Text
D8820.id20929.diff (11 KB)

Event Timeline