1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-15 01:50:55 +01:00

(stable) Promote 2017 Week 49

This commit is contained in:
epriestley 2017-12-13 07:16:06 -08:00
commit 010b6de395
8 changed files with 135 additions and 22 deletions

View file

@ -1004,6 +1004,7 @@ phutil_register_library_map(array(
'DrydockBlueprintCustomField' => 'applications/drydock/customfield/DrydockBlueprintCustomField.php',
'DrydockBlueprintDatasource' => 'applications/drydock/typeahead/DrydockBlueprintDatasource.php',
'DrydockBlueprintDisableController' => 'applications/drydock/controller/DrydockBlueprintDisableController.php',
'DrydockBlueprintEditConduitAPIMethod' => 'applications/drydock/conduit/DrydockBlueprintEditConduitAPIMethod.php',
'DrydockBlueprintEditController' => 'applications/drydock/controller/DrydockBlueprintEditController.php',
'DrydockBlueprintEditEngine' => 'applications/drydock/editor/DrydockBlueprintEditEngine.php',
'DrydockBlueprintEditor' => 'applications/drydock/editor/DrydockBlueprintEditor.php',
@ -6090,6 +6091,7 @@ phutil_register_library_map(array(
'DrydockBlueprintCustomField' => 'PhabricatorCustomField',
'DrydockBlueprintDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockBlueprintDisableController' => 'DrydockBlueprintController',
'DrydockBlueprintEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
'DrydockBlueprintEditEngine' => 'PhabricatorEditEngine',
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',

View file

@ -1588,11 +1588,8 @@ final class DifferentialTransactionEditor
->setAuthorPHID($author_phid)
->setTransactionType(
DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE)
->setOldValue(false)
->setNewValue(true);
$xaction = $this->populateTransaction($object, $xaction);
// If we're creating this revision and immediately moving it out of
// the draft state, mark this as a create transaction so it gets
// hidden in the timeline and mail, since it isn't interesting: it
@ -1601,15 +1598,10 @@ final class DifferentialTransactionEditor
$xaction->setIsCreateTransaction(true);
}
$object->openTransaction();
$object
->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW)
->save();
$xaction->save();
$object->saveTransaction();
$xactions[] = $xaction;
// Queue this transaction and apply it separately after the current
// batch of transactions finishes so that Herald can fire on the new
// revision state. See T13027 for discussion.
$this->queueTransaction($xaction);
}
}

View file

@ -57,11 +57,15 @@ final class DifferentialRevisionRequestReviewTransaction
'revisions.'));
}
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
throw new Exception(
pht(
'You can not request review of this revision because you are not '.
'the author of the revision.'));
// When revisions automatically promote out of "Draft" after builds finish,
// the viewer may be acting as the Harbormaster application.
if (!$viewer->isOmnipotent()) {
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
throw new Exception(
pht(
'You can not request review of this revision because you are not '.
'the author of the revision.'));
}
}
}

View file

@ -39,20 +39,23 @@ final class DiffusionCommitController extends DiffusionController {
return $this->buildRawDiffResponse($drequest);
}
$commit = id(new DiffusionCommitQuery())
$commits = id(new DiffusionCommitQuery())
->setViewer($viewer)
->withRepository($repository)
->withIdentifiers(array($commit_identifier))
->needCommitData(true)
->needAuditRequests(true)
->executeOne();
->setLimit(100)
->execute();
$multiple_results = count($commits) > 1;
$crumbs = $this->buildCrumbs(array(
'commit' => true,
'commit' => !$multiple_results,
));
$crumbs->setBorder(true);
if (!$commit) {
if (!$commits) {
if (!$this->getCommitExists()) {
return new Aphront404Response();
}
@ -70,7 +73,40 @@ final class DiffusionCommitController extends DiffusionController {
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($error);
} else if ($multiple_results) {
$warning_message =
pht(
'The identifier %s is ambiguous and matches more than one commit.',
phutil_tag(
'strong',
array(),
$commit_identifier));
$error = id(new PHUIInfoView())
->setTitle(pht('Ambiguous Commit'))
->setSeverity(PHUIInfoView::SEVERITY_WARNING)
->appendChild($warning_message);
$list = id(new DiffusionCommitListView())
->setViewer($viewer)
->setCommits($commits)
->setNoDataString(pht('No recent commits.'));
$crumbs->addTextCrumb(pht('Ambiguous Commit'));
$matched_commits = id(new PHUITwoColumnView())
->setFooter(array(
$error,
$list,
));
return $this->newPage()
->setTitle(pht('Ambiguous Commit'))
->setCrumbs($crumbs)
->appendChild($matched_commits);
} else {
$commit = head($commits);
}
$audit_requests = $commit->getAudits();

View file

@ -0,0 +1,20 @@
<?php
final class DrydockBlueprintEditConduitAPIMethod
extends PhabricatorEditEngineAPIMethod {
public function getAPIMethodName() {
return 'drydock.blueprint.edit';
}
public function newEditEngine() {
return new DrydockBlueprintEditEngine();
}
public function getMethodSummary() {
return pht(
'WARNING: Apply transactions to edit an existing blueprint. This method '.
'can not create new blueprints.');
}
}

View file

@ -51,6 +51,17 @@ final class DrydockBlueprintEditEngine
return $blueprint;
}
protected function newEditableObjectForDocumentation() {
// In order to generate the proper list of fields/transactions for a
// blueprint, a blueprint's type needs to be known upfront, and there's
// currently no way to pre-specify the type. Hardcoding an implementation
// here prevents the fatal on the Conduit API page and allows transactions
// to be edited.
$impl = new DrydockWorkingCopyBlueprintImplementation();
$this->setBlueprintImplementation($impl);
return $this->newEditableObject();
}
protected function newObjectQuery() {
return new DrydockBlueprintQuery();
}

View file

@ -630,6 +630,15 @@ abstract class PhabricatorEditEngine
return $this->isCreate;
}
/**
* Initialize a new object for documentation creation.
*
* @return object Newly initialized object.
* @task load
*/
protected function newEditableObjectForDocumentation() {
return $this->newEditableObject();
}
/**
* Flag this workflow as a create or edit.
@ -2198,7 +2207,7 @@ abstract class PhabricatorEditEngine
return array();
}
$object = $this->newEditableObject();
$object = $this->newEditableObjectForDocumentation();
$fields = $this->buildEditFields($object);
return $this->getConduitEditTypesFromFields($fields);
}

View file

@ -70,6 +70,8 @@ abstract class PhabricatorApplicationTransactionEditor
private $feedRelatedPHIDs = array();
private $modularTypes;
private $transactionQueue = array();
const STORAGE_ENCODING_BINARY = 'binary';
/**
@ -1174,6 +1176,8 @@ abstract class PhabricatorApplicationTransactionEditor
'priority' => PhabricatorWorker::PRIORITY_ALERTS,
));
$this->flushTransactionQueue($object);
return $xactions;
}
@ -3864,4 +3868,39 @@ abstract class PhabricatorApplicationTransactionEditor
return pht('%s created an object: %s.', $author, $object);
}
/* -( Queue )-------------------------------------------------------------- */
protected function queueTransaction(
PhabricatorApplicationTransaction $xaction) {
$this->transactionQueue[] = $xaction;
return $this;
}
private function flushTransactionQueue($object) {
if (!$this->transactionQueue) {
return;
}
$xactions = $this->transactionQueue;
$this->transactionQueue = array();
$editor = $this->newQueueEditor();
return $editor->applyTransactions($object, $xactions);
}
private function newQueueEditor() {
$editor = id(newv(get_class($this), array()))
->setActor($this->getActor())
->setContentSource($this->getContentSource())
->setContinueOnNoEffect($this->getContinueOnNoEffect())
->setContinueOnMissingFields($this->getContinueOnMissingFields());
if ($this->actingAsPHID !== null) {
$editor->setActingAsPHID($this->actingAsPHID);
}
return $editor;
}
}