Page MenuHomePhabricator

D10872.id26118.diff
No OneTemporary

D10872.id26118.diff

diff --git a/src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php b/src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php
--- a/src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php
+++ b/src/applications/differential/conduit/DifferentialCreateRawDiffConduitAPIMethod.php
@@ -61,6 +61,7 @@
id(new DifferentialDiffEditor())
->setActor($viewer)
->setContentSourceFromConduitRequest($request)
+ ->setLookupRepository(false) // respect user choice
->applyTransactions($diff, $xactions);
return $this->buildDiffInfoDictionary($diff);
diff --git a/src/applications/differential/controller/DifferentialDiffCreateController.php b/src/applications/differential/controller/DifferentialDiffCreateController.php
--- a/src/applications/differential/controller/DifferentialDiffCreateController.php
+++ b/src/applications/differential/controller/DifferentialDiffCreateController.php
@@ -7,12 +7,20 @@
$request = $this->getRequest();
$diff = null;
+ $repository_phid = null;
+ $repository_value = array();
$errors = array();
$e_diff = null;
$e_file = null;
$validation_exception = null;
if ($request->isFormPost()) {
+ $repository_tokenizer = $request->getArr(
+ id(new DifferentialRepositoryField())->getFieldKey());
+ if ($repository_tokenizer) {
+ $repository_phid = reset($repository_tokenizer);
+ }
+
if ($request->getFileExists('diff-file')) {
$diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
} else {
@@ -33,7 +41,7 @@
'differential.createrawdiff',
array(
'diff' => $diff,
- ));
+ 'repositoryPHID' => $repository_phid,));
$call->setUser($request->getUser());
$result = $call->execute();
$path = id(new PhutilURI($result['uri']))->getPath();
@@ -56,6 +64,10 @@
$cancel_uri = $this->getApplicationURI();
+ if ($repository_phid) {
+ $repository_value = $this->loadViewerHandles(array($repository_phid));
+ }
+
$form
->setAction('/differential/diff/create/')
->setEncType('multipart/form-data')
@@ -82,6 +94,13 @@
->setName('diff-file')
->setError($e_file))
->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setName(id(new DifferentialRepositoryField())->getFieldKey())
+ ->setLabel(pht('Repository'))
+ ->setDatasource(new DiffusionRepositoryDatasource())
+ ->setValue($repository_value)
+ ->setLimit(1))
+ ->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($cancel_uri)
->setValue(pht('Create Diff')));
diff --git a/src/applications/differential/controller/DifferentialDiffViewController.php b/src/applications/differential/controller/DifferentialDiffViewController.php
--- a/src/applications/differential/controller/DifferentialDiffViewController.php
+++ b/src/applications/differential/controller/DifferentialDiffViewController.php
@@ -80,6 +80,9 @@
->setAction('/differential/revision/edit/')
->addHiddenInput('diffID', $diff->getID())
->addHiddenInput('viaDiffView', 1)
+ ->addHiddenInput(
+ id(new DifferentialRepositoryField())->getFieldKey(),
+ $diff->getRepositoryPHID())
->appendRemarkupInstructions(
pht(
'Review the diff for correctness. When you are satisfied, either '.
diff --git a/src/applications/differential/controller/DifferentialRevisionEditController.php b/src/applications/differential/controller/DifferentialRevisionEditController.php
--- a/src/applications/differential/controller/DifferentialRevisionEditController.php
+++ b/src/applications/differential/controller/DifferentialRevisionEditController.php
@@ -71,16 +71,41 @@
->setViewer($viewer)
->readFieldsFromStorage($revision);
+ if ($request->getStr('viaDiffView') && $diff) {
+ $repo_key = id(new DifferentialRepositoryField())->getFieldKey();
+ $repository_field = idx(
+ $field_list->getFields(),
+ $repo_key);
+ if ($repository_field) {
+ $repository_field->setValue($request->getStr($repo_key));
+ }
+ }
+
$validation_exception = null;
if ($request->isFormPost() && !$request->getStr('viaDiffView')) {
+
+ $editor = id(new DifferentialTransactionEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true);
+
$xactions = $field_list->buildFieldTransactionsFromRequest(
new DifferentialTransaction(),
$request);
if ($diff) {
+ $repository_phid = null;
+ $repository_tokenizer = $request->getArr(
+ id(new DifferentialRepositoryField())->getFieldKey());
+ if ($repository_tokenizer) {
+ $repository_phid = reset($repository_tokenizer);
+ }
+
$xactions[] = id(new DifferentialTransaction())
->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
->setNewValue($diff->getPHID());
+
+ $editor->setRepositoryPHIDOverride($repository_phid);
}
$comments = $request->getStr('comments');
@@ -92,11 +117,6 @@
->setContent($comments));
}
- $editor = id(new DifferentialTransactionEditor())
- ->setActor($viewer)
- ->setContentSourceFromRequest($request)
- ->setContinueOnNoEffect(true);
-
try {
$editor->applyTransactions($revision, $xactions);
$revision_uri = '/D'.$revision->getID();
diff --git a/src/applications/differential/editor/DifferentialDiffEditor.php b/src/applications/differential/editor/DifferentialDiffEditor.php
--- a/src/applications/differential/editor/DifferentialDiffEditor.php
+++ b/src/applications/differential/editor/DifferentialDiffEditor.php
@@ -4,6 +4,12 @@
extends PhabricatorApplicationTransactionEditor {
private $diffDataDict;
+ private $lookupRepository = true;
+
+ public function setLookupRepository($bool) {
+ $this->lookupRepository = $bool;
+ return $this;
+ }
public function getEditorApplicationClass() {
return 'PhabricatorDifferentialApplication';
@@ -80,7 +86,7 @@
// is old, or couldn't figure out which repository the working copy
// belongs to), apply heuristics to try to figure it out.
- if (!$object->getRepositoryPHID()) {
+ if ($this->lookupRepository && !$object->getRepositoryPHID()) {
$repository = id(new DifferentialRepositoryLookup())
->setDiff($object)
->setViewer($this->getActor())
diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -6,6 +6,7 @@
private $heraldEmailPHIDs;
private $changedPriorToCommitURI;
private $isCloseByCommit;
+ private $repositoryPHIDOverride = false;
public function getEditorApplicationClass() {
return 'PhabricatorDifferentialApplication';
@@ -45,6 +46,11 @@
return $this->changedPriorToCommitURI;
}
+ public function setRepositoryPHIDOverride($phid_or_null) {
+ $this->repositoryPHIDOverride = $phid_or_null;
+ return $this;
+ }
+
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
@@ -205,7 +211,11 @@
$diff = $this->requireDiff($xaction->getNewValue());
$object->setLineCount($diff->getLineCount());
- $object->setRepositoryPHID($diff->getRepositoryPHID());
+ if ($this->repositoryPHIDOverride !== false) {
+ $object->setRepositoryPHID($this->repositoryPHIDOverride);
+ } else {
+ $object->setRepositoryPHID($diff->getRepositoryPHID());
+ }
$object->setArcanistProjectPHID($diff->getArcanistProjectPHID());
$object->attachActiveDiff($diff);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 2, 7:19 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6741475
Default Alt Text
D10872.id26118.diff (7 KB)

Event Timeline