mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-15 10:00:55 +01:00
(stable) Promote 2017 Week 49
This commit is contained in:
commit
010b6de395
8 changed files with 135 additions and 22 deletions
|
@ -1004,6 +1004,7 @@ phutil_register_library_map(array(
|
||||||
'DrydockBlueprintCustomField' => 'applications/drydock/customfield/DrydockBlueprintCustomField.php',
|
'DrydockBlueprintCustomField' => 'applications/drydock/customfield/DrydockBlueprintCustomField.php',
|
||||||
'DrydockBlueprintDatasource' => 'applications/drydock/typeahead/DrydockBlueprintDatasource.php',
|
'DrydockBlueprintDatasource' => 'applications/drydock/typeahead/DrydockBlueprintDatasource.php',
|
||||||
'DrydockBlueprintDisableController' => 'applications/drydock/controller/DrydockBlueprintDisableController.php',
|
'DrydockBlueprintDisableController' => 'applications/drydock/controller/DrydockBlueprintDisableController.php',
|
||||||
|
'DrydockBlueprintEditConduitAPIMethod' => 'applications/drydock/conduit/DrydockBlueprintEditConduitAPIMethod.php',
|
||||||
'DrydockBlueprintEditController' => 'applications/drydock/controller/DrydockBlueprintEditController.php',
|
'DrydockBlueprintEditController' => 'applications/drydock/controller/DrydockBlueprintEditController.php',
|
||||||
'DrydockBlueprintEditEngine' => 'applications/drydock/editor/DrydockBlueprintEditEngine.php',
|
'DrydockBlueprintEditEngine' => 'applications/drydock/editor/DrydockBlueprintEditEngine.php',
|
||||||
'DrydockBlueprintEditor' => 'applications/drydock/editor/DrydockBlueprintEditor.php',
|
'DrydockBlueprintEditor' => 'applications/drydock/editor/DrydockBlueprintEditor.php',
|
||||||
|
@ -6090,6 +6091,7 @@ phutil_register_library_map(array(
|
||||||
'DrydockBlueprintCustomField' => 'PhabricatorCustomField',
|
'DrydockBlueprintCustomField' => 'PhabricatorCustomField',
|
||||||
'DrydockBlueprintDatasource' => 'PhabricatorTypeaheadDatasource',
|
'DrydockBlueprintDatasource' => 'PhabricatorTypeaheadDatasource',
|
||||||
'DrydockBlueprintDisableController' => 'DrydockBlueprintController',
|
'DrydockBlueprintDisableController' => 'DrydockBlueprintController',
|
||||||
|
'DrydockBlueprintEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
|
||||||
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
|
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
|
||||||
'DrydockBlueprintEditEngine' => 'PhabricatorEditEngine',
|
'DrydockBlueprintEditEngine' => 'PhabricatorEditEngine',
|
||||||
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',
|
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
|
|
|
@ -1588,11 +1588,8 @@ final class DifferentialTransactionEditor
|
||||||
->setAuthorPHID($author_phid)
|
->setAuthorPHID($author_phid)
|
||||||
->setTransactionType(
|
->setTransactionType(
|
||||||
DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE)
|
DifferentialRevisionRequestReviewTransaction::TRANSACTIONTYPE)
|
||||||
->setOldValue(false)
|
|
||||||
->setNewValue(true);
|
->setNewValue(true);
|
||||||
|
|
||||||
$xaction = $this->populateTransaction($object, $xaction);
|
|
||||||
|
|
||||||
// If we're creating this revision and immediately moving it out of
|
// If we're creating this revision and immediately moving it out of
|
||||||
// the draft state, mark this as a create transaction so it gets
|
// the draft state, mark this as a create transaction so it gets
|
||||||
// hidden in the timeline and mail, since it isn't interesting: it
|
// hidden in the timeline and mail, since it isn't interesting: it
|
||||||
|
@ -1601,15 +1598,10 @@ final class DifferentialTransactionEditor
|
||||||
$xaction->setIsCreateTransaction(true);
|
$xaction->setIsCreateTransaction(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$object->openTransaction();
|
// Queue this transaction and apply it separately after the current
|
||||||
$object
|
// batch of transactions finishes so that Herald can fire on the new
|
||||||
->setStatus(DifferentialRevisionStatus::NEEDS_REVIEW)
|
// revision state. See T13027 for discussion.
|
||||||
->save();
|
$this->queueTransaction($xaction);
|
||||||
|
|
||||||
$xaction->save();
|
|
||||||
$object->saveTransaction();
|
|
||||||
|
|
||||||
$xactions[] = $xaction;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,15 @@ final class DifferentialRevisionRequestReviewTransaction
|
||||||
'revisions.'));
|
'revisions.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
|
// When revisions automatically promote out of "Draft" after builds finish,
|
||||||
throw new Exception(
|
// the viewer may be acting as the Harbormaster application.
|
||||||
pht(
|
if (!$viewer->isOmnipotent()) {
|
||||||
'You can not request review of this revision because you are not '.
|
if (!$this->isViewerRevisionAuthor($object, $viewer)) {
|
||||||
'the author of the revision.'));
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'You can not request review of this revision because you are not '.
|
||||||
|
'the author of the revision.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,20 +39,23 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
return $this->buildRawDiffResponse($drequest);
|
return $this->buildRawDiffResponse($drequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
$commit = id(new DiffusionCommitQuery())
|
$commits = id(new DiffusionCommitQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withRepository($repository)
|
->withRepository($repository)
|
||||||
->withIdentifiers(array($commit_identifier))
|
->withIdentifiers(array($commit_identifier))
|
||||||
->needCommitData(true)
|
->needCommitData(true)
|
||||||
->needAuditRequests(true)
|
->needAuditRequests(true)
|
||||||
->executeOne();
|
->setLimit(100)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$multiple_results = count($commits) > 1;
|
||||||
|
|
||||||
$crumbs = $this->buildCrumbs(array(
|
$crumbs = $this->buildCrumbs(array(
|
||||||
'commit' => true,
|
'commit' => !$multiple_results,
|
||||||
));
|
));
|
||||||
$crumbs->setBorder(true);
|
$crumbs->setBorder(true);
|
||||||
|
|
||||||
if (!$commit) {
|
if (!$commits) {
|
||||||
if (!$this->getCommitExists()) {
|
if (!$this->getCommitExists()) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +73,40 @@ final class DiffusionCommitController extends DiffusionController {
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->setCrumbs($crumbs)
|
->setCrumbs($crumbs)
|
||||||
->appendChild($error);
|
->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();
|
$audit_requests = $commit->getAudits();
|
||||||
|
|
|
@ -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.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -51,6 +51,17 @@ final class DrydockBlueprintEditEngine
|
||||||
return $blueprint;
|
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() {
|
protected function newObjectQuery() {
|
||||||
return new DrydockBlueprintQuery();
|
return new DrydockBlueprintQuery();
|
||||||
}
|
}
|
||||||
|
|
|
@ -630,6 +630,15 @@ abstract class PhabricatorEditEngine
|
||||||
return $this->isCreate;
|
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.
|
* Flag this workflow as a create or edit.
|
||||||
|
@ -2198,7 +2207,7 @@ abstract class PhabricatorEditEngine
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$object = $this->newEditableObject();
|
$object = $this->newEditableObjectForDocumentation();
|
||||||
$fields = $this->buildEditFields($object);
|
$fields = $this->buildEditFields($object);
|
||||||
return $this->getConduitEditTypesFromFields($fields);
|
return $this->getConduitEditTypesFromFields($fields);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
private $feedRelatedPHIDs = array();
|
private $feedRelatedPHIDs = array();
|
||||||
private $modularTypes;
|
private $modularTypes;
|
||||||
|
|
||||||
|
private $transactionQueue = array();
|
||||||
|
|
||||||
const STORAGE_ENCODING_BINARY = 'binary';
|
const STORAGE_ENCODING_BINARY = 'binary';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1174,6 +1176,8 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
'priority' => PhabricatorWorker::PRIORITY_ALERTS,
|
'priority' => PhabricatorWorker::PRIORITY_ALERTS,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$this->flushTransactionQueue($object);
|
||||||
|
|
||||||
return $xactions;
|
return $xactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3864,4 +3868,39 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
return pht('%s created an object: %s.', $author, $object);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue