Page MenuHomePhabricator

D10872.id26114.diff
No OneTemporary

D10872.id26114.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,18 @@
$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());
+ $repository_phid = reset($repository_tokenizer);
+
if ($request->getFileExists('diff-file')) {
$diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']);
} else {
@@ -33,7 +39,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 +62,10 @@
$cancel_uri = $this->getApplicationURI();
+ if ($repository_phid) {
+ $repository_value = $this->loadViewerHandles($repository_phid);
+ }
+
$form
->setAction('/differential/diff/create/')
->setEncType('multipart/form-data')
@@ -82,6 +92,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,18 +71,39 @@
->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')) {
- $xactions = $field_list->buildFieldTransactionsFromRequest(
- new DifferentialTransaction(),
- $request);
+ $xactions = array();
+ // Make sure this xaction is first because we use a diff to
+ // automagically update things like repository which the user can
+ // override via the form.
if ($diff) {
$xactions[] = id(new DifferentialTransaction())
->setTransactionType(DifferentialTransaction::TYPE_UPDATE)
->setNewValue($diff->getPHID());
}
+ // This won't actually work if you null out the repository field
+ // because of how custom field infrastructure works. Its going to
+ // set the "old value" //right now// and see it as null, and the
+ // new value of null will make it a no op.
+ $xactions = array_merge(
+ $xactions,
+ $field_list->buildFieldTransactionsFromRequest(
+ new DifferentialTransaction(),
+ $request));
+
$comments = $request->getStr('comments');
if (strlen($comments)) {
$xactions[] = id(new DifferentialTransaction())

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 14, 4:20 AM (1 h, 27 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6756764
Default Alt Text
D10872.id26114.diff (4 KB)

Event Timeline