Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/storage/DifferentialRevision.php
<?php | <?php | ||||
final class DifferentialRevision extends DifferentialDAO | final class DifferentialRevision extends DifferentialDAO | ||||
implements | implements | ||||
PhabricatorTokenReceiverInterface, | PhabricatorTokenReceiverInterface, | ||||
PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
PhabricatorFlaggableInterface, | PhabricatorFlaggableInterface, | ||||
PhrequentTrackableInterface, | PhrequentTrackableInterface, | ||||
HarbormasterBuildableInterface { | HarbormasterBuildableInterface, | ||||
PhabricatorSubscribableInterface { | |||||
protected $title = ''; | protected $title = ''; | ||||
protected $originalTitle; | protected $originalTitle; | ||||
protected $status; | protected $status; | ||||
protected $summary = ''; | protected $summary = ''; | ||||
protected $testPlan = ''; | protected $testPlan = ''; | ||||
Show All 16 Lines | final class DifferentialRevision extends DifferentialDAO | ||||
private $commits = self::ATTACHABLE; | private $commits = self::ATTACHABLE; | ||||
private $activeDiff = self::ATTACHABLE; | private $activeDiff = self::ATTACHABLE; | ||||
private $diffIDs = self::ATTACHABLE; | private $diffIDs = self::ATTACHABLE; | ||||
private $hashes = self::ATTACHABLE; | private $hashes = self::ATTACHABLE; | ||||
private $repository = self::ATTACHABLE; | private $repository = self::ATTACHABLE; | ||||
private $reviewerStatus = self::ATTACHABLE; | private $reviewerStatus = self::ATTACHABLE; | ||||
const RELATIONSHIP_TABLE = 'differential_relationship'; | |||||
const TABLE_COMMIT = 'differential_commit'; | const TABLE_COMMIT = 'differential_commit'; | ||||
const RELATION_REVIEWER = 'revw'; | const RELATION_REVIEWER = 'revw'; | ||||
const RELATION_SUBSCRIBED = 'subd'; | const RELATION_SUBSCRIBED = 'subd'; | ||||
public static function initializeNewRevision(PhabricatorUser $actor) { | public static function initializeNewRevision(PhabricatorUser $actor) { | ||||
$app = id(new PhabricatorApplicationQuery()) | $app = id(new PhabricatorApplicationQuery()) | ||||
->setViewer($actor) | ->setViewer($actor) | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | $diffs = id(new DifferentialDiffQuery()) | ||||
$diff->delete(); | $diff->delete(); | ||||
} | } | ||||
$conn_w = $this->establishConnection('w'); | $conn_w = $this->establishConnection('w'); | ||||
queryfx( | queryfx( | ||||
$conn_w, | $conn_w, | ||||
'DELETE FROM %T WHERE revisionID = %d', | 'DELETE FROM %T WHERE revisionID = %d', | ||||
self::RELATIONSHIP_TABLE, | |||||
$this->getID()); | |||||
queryfx( | |||||
$conn_w, | |||||
'DELETE FROM %T WHERE revisionID = %d', | |||||
self::TABLE_COMMIT, | self::TABLE_COMMIT, | ||||
$this->getID()); | $this->getID()); | ||||
$comments = id(new DifferentialCommentQuery()) | $comments = id(new DifferentialCommentQuery()) | ||||
->withRevisionIDs(array($this->getID())) | ->withRevisionIDs(array($this->getID())) | ||||
->execute(); | ->execute(); | ||||
foreach ($comments as $comment) { | foreach ($comments as $comment) { | ||||
$comment->delete(); | $comment->delete(); | ||||
Show All 27 Lines | public function delete() { | ||||
return $result; | return $result; | ||||
} | } | ||||
public function loadRelationships() { | public function loadRelationships() { | ||||
if (!$this->getID()) { | if (!$this->getID()) { | ||||
$this->relationships = array(); | $this->relationships = array(); | ||||
return; | return; | ||||
} | } | ||||
// Read "subscribed" and "unsubscribed" data out of the old relationship | $data = array(); | ||||
epriestley: I'll fix this, no longer accurate. | |||||
// table. | |||||
$data = queryfx_all( | $subscriber_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( | ||||
$this->establishConnection('r'), | $this->getPHID(), | ||||
'SELECT * FROM %T WHERE revisionID = %d | PhabricatorEdgeConfig::TYPE_OBJECT_HAS_SUBSCRIBER); | ||||
AND relation != %s ORDER BY sequence', | $subscriber_phids = array_reverse($subscriber_phids); | ||||
self::RELATIONSHIP_TABLE, | foreach ($subscriber_phids as $phid) { | ||||
$this->getID(), | $data[] = array( | ||||
self::RELATION_REVIEWER); | 'relation' => self::RELATION_SUBSCRIBED, | ||||
'objectPHID' => $phid, | |||||
'reasonPHID' => null, | |||||
); | |||||
} | |||||
// Read "reviewer" data out of the new table. | |||||
$reviewer_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( | $reviewer_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( | ||||
$this->getPHID(), | $this->getPHID(), | ||||
PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER); | PhabricatorEdgeConfig::TYPE_DREV_HAS_REVIEWER); | ||||
$reviewer_phids = array_reverse($reviewer_phids); | $reviewer_phids = array_reverse($reviewer_phids); | ||||
foreach ($reviewer_phids as $phid) { | foreach ($reviewer_phids as $phid) { | ||||
$data[] = array( | $data[] = array( | ||||
'relation' => self::RELATION_REVIEWER, | 'relation' => self::RELATION_REVIEWER, | ||||
'objectPHID' => $phid, | 'objectPHID' => $phid, | ||||
'reasonPHID' => null, | 'reasonPHID' => null, | ||||
); | ); | ||||
} | } | ||||
Show All 18 Lines | private function getRelatedPHIDs($relation) { | ||||
return ipull($this->getRawRelations($relation), 'objectPHID'); | return ipull($this->getRawRelations($relation), 'objectPHID'); | ||||
} | } | ||||
public function getRawRelations($relation) { | public function getRawRelations($relation) { | ||||
return idx($this->relationships, $relation, array()); | return idx($this->relationships, $relation, array()); | ||||
} | } | ||||
public function loadUnsubscribedPHIDs() { | |||||
return PhabricatorEdgeQuery::loadDestinationPHIDs( | |||||
$this->phid, | |||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_UNSUBSCRIBER); | |||||
} | |||||
public function getPrimaryReviewer() { | public function getPrimaryReviewer() { | ||||
$reviewers = $this->getReviewers(); | $reviewers = $this->getReviewers(); | ||||
$last = $this->lastReviewerPHID; | $last = $this->lastReviewerPHID; | ||||
if (!$last || !in_array($last, $reviewers)) { | if (!$last || !in_array($last, $reviewers)) { | ||||
return head($this->getReviewers()); | return head($this->getReviewers()); | ||||
} | } | ||||
return $last; | return $last; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | /* -( HarbormasterBuildableInterface )------------------------------------- */ | ||||
public function getHarbormasterBuildablePHID() { | public function getHarbormasterBuildablePHID() { | ||||
return $this->loadActiveDiff()->getPHID(); | return $this->loadActiveDiff()->getPHID(); | ||||
} | } | ||||
public function getHarbormasterContainerPHID() { | public function getHarbormasterContainerPHID() { | ||||
return $this->getPHID(); | return $this->getPHID(); | ||||
} | } | ||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */ | |||||
public function isAutomaticallySubscribed($phid) { | |||||
// TODO: Reviewers are also automatically subscribed, but that data may | |||||
// not always be loaded, so be conservative for now. All the editing code | |||||
// has checks around this already. | |||||
return ($phid == $this->getAuthorPHID()); | |||||
} | |||||
public function shouldShowSubscribersProperty() { | |||||
// TODO: For now, Differential has its own stuff. | |||||
return false; | |||||
} | |||||
public function shouldAllowSubscription($phid) { | |||||
// TODO: For now, Differential has its own stuff. | |||||
return false; | |||||
} | |||||
} | } |
I'll fix this, no longer accurate.