本文整理汇总了PHP中DifferentialRevision类的典型用法代码示例。如果您正苦于以下问题:PHP DifferentialRevision类的具体用法?PHP DifferentialRevision怎么用?PHP DifferentialRevision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DifferentialRevision类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadRevisions
private function loadRevisions($phid)
{
$table = new DifferentialRevision();
$conn_r = $table->establishConnection('r');
$rows = queryfx_all($conn_r, 'SELECT revisions.* FROM %T revisions ' . 'JOIN %T comments ON comments.revisionID = revisions.id ' . 'JOIN (' . ' SELECT revisionID FROM %T WHERE objectPHID = %s ' . ' UNION ALL ' . ' SELECT id from differential_revision WHERE authorPHID = %s) rel ' . 'ON (comments.revisionID = rel.revisionID)' . 'WHERE comments.action = %s' . 'AND comments.authorPHID = %s', $table->getTableName(), id(new DifferentialComment())->getTableName(), DifferentialRevision::RELATIONSHIP_TABLE, $phid, $phid, $this->filter, $phid);
return $table->loadAllFromArray($rows);
}
示例2: readValueFromRevision
protected function readValueFromRevision(DifferentialRevision $revision)
{
if (!$revision->getPHID()) {
return array();
}
return PhabricatorEdgeQuery::loadDestinationPHIDs($revision->getPHID(), DifferentialRevisionHasTaskEdgeType::EDGECONST);
}
示例3: readValueFromRevision
protected function readValueFromRevision(DifferentialRevision $revision)
{
if (!$revision->getPHID()) {
return array();
}
return PhabricatorSubscribersQuery::loadSubscribersForPHID($revision->getPHID());
}
示例4: __construct
public function __construct(DifferentialRevision $revision, $mode)
{
$this->revision = $revision;
$this->mode = $mode;
$comments = id(new DifferentialComment())->loadAllWhere('revisionID = %d', $revision->getID());
$this->comments = $comments;
}
示例5: readValueFromRevision
protected function readValueFromRevision(DifferentialRevision $revision)
{
if (!$revision->getPHID()) {
return array();
}
$projects = PhabricatorEdgeQuery::loadDestinationPHIDs($revision->getPHID(), PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$projects = array_reverse($projects);
return $projects;
}
示例6: isActionDisabled
/**
* Check if this action should be disabled, and explain why.
*
* By default, this method checks for push permissions, and for the
* revision being Accepted.
*
* @return False for "not disabled"; human-readable text explaining why, if
* it is disabled.
*/
public function isActionDisabled(PhabricatorUser $viewer, DifferentialRevision $revision, PhabricatorRepository $repository)
{
$status = $revision->getStatus();
if ($status != ArcanistDifferentialRevisionStatus::ACCEPTED) {
return pht('Only Accepted revisions can be landed.');
}
if (!PhabricatorPolicyFilter::hasCapability($viewer, $repository, DiffusionPushCapability::CAPABILITY)) {
return pht('You do not have permissions to push to this repository.');
}
return false;
}
示例7: testReviewerStatsRequiresReview
public function testReviewerStatsRequiresReview()
{
$revision = new DifferentialRevision();
$revision->setDateCreated(1);
$revision->attachRelationships(array($this->newReviewer('R')));
$comments = array();
$stats = new DifferentialReviewerStats();
$stats->setUntil(2);
list($reviewed, $not_reviewed) = $stats->computeTimes($revision, $comments);
$this->assertEqual(array(), $reviewed);
$this->assertEqual(array('R' => array(2 - 1)), $not_reviewed);
}
示例8: readValueFromRevision
protected function readValueFromRevision(DifferentialRevision $revision)
{
$phids = array();
foreach ($revision->getReviewerStatus() as $reviewer) {
switch ($reviewer->getStatus()) {
case DifferentialReviewerStatus::STATUS_ACCEPTED:
case DifferentialReviewerStatus::STATUS_ACCEPTED_OLDER:
$phids[] = $reviewer->getReviewerPHID();
break;
}
}
return $phids;
}
示例9: hasReviewersWithStatus
protected function hasReviewersWithStatus(DifferentialRevision $revision, array $phids, array $statuses)
{
foreach ($revision->getReviewerStatus() as $reviewer) {
$reviewer_phid = $reviewer->getReviewerPHID();
if (empty($phids[$reviewer_phid])) {
continue;
}
$status = $reviewer->getStatus();
if (empty($statuses[$status])) {
continue;
}
return true;
}
return false;
}
示例10: loadFromStorage
public static function loadFromStorage(DifferentialRevision $revision, array $aux_fields)
{
$storage_keys = array_filter(mpull($aux_fields, 'getStorageKey'));
$field_data = array();
if ($storage_keys) {
$field_data = id(new DifferentialAuxiliaryField())->loadAllWhere('revisionPHID = %s AND name IN (%Ls)', $revision->getPHID(), $storage_keys);
$field_data = mpull($field_data, 'getValue', 'getName');
}
foreach ($aux_fields as $aux_field) {
$aux_field->setRevision($revision);
$key = $aux_field->getStorageKey();
if ($key) {
$aux_field->setValueFromStorage(idx($field_data, $key));
}
}
return $aux_fields;
}
示例11: commitRevisionToWorkspace
public function commitRevisionToWorkspace(DifferentialRevision $revision, ArcanistRepositoryAPI $workspace, PhabricatorUser $user)
{
$diff_id = $revision->loadActiveDiff()->getID();
$call = new ConduitCall('differential.getrawdiff', array('diffID' => $diff_id));
$call->setUser($user);
$raw_diff = $call->execute();
$future = $workspace->execFutureLocal('patch --no-commit -');
$future->write($raw_diff);
$future->resolvex();
$workspace->reloadWorkingCopy();
$call = new ConduitCall('differential.getcommitmessage', array('revision_id' => $revision->getID()));
$call->setUser($user);
$message = $call->execute();
$author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $revision->getAuthorPHID());
$author_string = sprintf('%s <%s>', $author->getRealName(), $author->loadPrimaryEmailAddress());
$author_date = $revision->getDateCreated();
$workspace->execxLocal('commit --date=%s --user=%s ' . '--message=%s', $author_date . ' 0', $author_string, $message);
}
示例12: loadUnsubmittedInlineComments
public static function loadUnsubmittedInlineComments(PhabricatorUser $viewer, DifferentialRevision $revision)
{
// TODO: This probably needs to move somewhere more central as we move
// away from DifferentialInlineCommentQuery, but
// PhabricatorApplicationTransactionCommentQuery is currently `final` and
// I'm not yet decided on how to approach that. For now, just get the PHIDs
// and then execute a PHID-based query through the standard stack.
$table = new DifferentialTransactionComment();
$conn_r = $table->establishConnection('r');
$phids = queryfx_all($conn_r, 'SELECT phid FROM %T
WHERE revisionPHID = %s
AND authorPHID = %s
AND transactionPHID IS NULL', $table->getTableName(), $revision->getPHID(), $viewer->getPHID());
$phids = ipull($phids, 'phid');
if (!$phids) {
return array();
}
return id(new PhabricatorApplicationTransactionCommentQuery())->setTemplate(new DifferentialTransactionComment())->setViewer($viewer)->withPHIDs($phids)->execute();
}
示例13: execute
protected function execute(ConduitAPIRequest $request)
{
$viewer = $request->getUser();
$diff = id(new DifferentialDiffQuery())->setViewer($viewer)->withIDs(array($request->getValue('diffid')))->executeOne();
if (!$diff) {
throw new ConduitException('ERR_BAD_DIFF');
}
$revision = DifferentialRevision::initializeNewRevision($viewer);
$revision->attachReviewerStatus(array());
$this->applyFieldEdit($request, $revision, $diff, $request->getValue('fields', array()), $message = null);
return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
}
示例14: commitRevisionToWorkspace
public function commitRevisionToWorkspace(DifferentialRevision $revision, ArcanistRepositoryAPI $workspace, PhabricatorUser $user)
{
$diff_id = $revision->loadActiveDiff()->getID();
$call = new ConduitCall('differential.getrawdiff', array('diffID' => $diff_id));
$call->setUser($user);
$raw_diff = $call->execute();
$missing_binary = "\nindex " . "0000000000000000000000000000000000000000.." . "0000000000000000000000000000000000000000\n";
if (strpos($raw_diff, $missing_binary) !== false) {
throw new Exception(pht('Patch is missing content for a binary file'));
}
$future = $workspace->execFutureLocal('apply --index -');
$future->write($raw_diff);
$future->resolvex();
$workspace->reloadWorkingCopy();
$call = new ConduitCall('differential.getcommitmessage', array('revision_id' => $revision->getID()));
$call->setUser($user);
$message = $call->execute();
$author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $revision->getAuthorPHID());
$author_string = sprintf('%s <%s>', $author->getRealName(), $author->loadPrimaryEmailAddress());
$author_date = $revision->getDateCreated();
$workspace->execxLocal('-c user.name=%s -c user.email=%s ' . 'commit --date=%s --author=%s ' . '--message=%s', $user->getRealName(), $user->loadPrimaryEmailAddress(), $author_date, $author_string, $message);
}
示例15: generateObject
public function generateObject()
{
$author = $this->loadPhabrictorUser();
$revision = DifferentialRevision::initializeNewRevision($author);
$revision->attachReviewerStatus(array());
$revision->attachActiveDiff(null);
// This could be a bit richer and more formal than it is.
$revision->setTitle($this->generateTitle());
$revision->setSummary($this->generateDescription());
$revision->setTestPlan($this->generateDescription());
$diff = $this->generateDiff($author);
$xactions = array();
$xactions[] = id(new DifferentialTransaction())->setTransactionType(DifferentialTransaction::TYPE_UPDATE)->setNewValue($diff->getPHID());
id(new DifferentialTransactionEditor())->setActor($author)->setContentSource($this->getLipsumContentSource())->applyTransactions($revision, $xactions);
return $revision;
}