@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add an "Onto Branch" selector control to "Land Revision" dialog

Summary:
Ref T9952. This adds a typeahead so you can pick a branch to target.

It does not choose a default branch, the user must pick a branch explicitly.

Test Plan:
- Landed rGITTESTd587fada48fc to `master` (by typing "master").
- Landed rGITTEST86c339b2ef01 to `notmaster` (by typing "notmaster").

{F1020531}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9952

Differential Revision: https://secure.phabricator.com/D14733

+78 -23
+74 -23
src/applications/differential/controller/DifferentialRevisionOperationController.php
··· 27 27 ->addCancelButton($detail_uri); 28 28 } 29 29 30 + $diff = $revision->getActiveDiff(); 31 + $repository = $revision->getRepository(); 32 + 33 + $ref_types = array( 34 + PhabricatorRepositoryRefCursor::TYPE_BRANCH, 35 + ); 36 + 37 + $e_ref = true; 38 + 39 + $errors = array(); 30 40 if ($request->isFormPost()) { 31 - // NOTE: The operation is locked to the current active diff, so if the 32 - // revision is updated before the operation applies nothing sneaky 33 - // occurs. 41 + 42 + $ref_phid = head($request->getArr('refPHIDs')); 43 + if (!strlen($ref_phid)) { 44 + $e_ref = pht('Required'); 45 + $errors[] = pht( 46 + 'You must select a branch to land this revision onto.'); 47 + } else { 48 + $ref = id(new PhabricatorRepositoryRefCursorQuery()) 49 + ->setViewer($viewer) 50 + ->withPHIDs(array($ref_phid)) 51 + ->withRepositoryPHIDs(array($repository->getPHID())) 52 + ->withRefTypes($ref_types) 53 + ->executeOne(); 54 + if (!$ref) { 55 + $e_ref = pht('Invalid'); 56 + $errors[] = pht( 57 + 'You must select a branch from this repository to land this '. 58 + 'revision onto.'); 59 + } 60 + } 34 61 35 - $diff = $revision->getActiveDiff(); 36 - $repository = $revision->getRepository(); 62 + if (!$errors) { 63 + // NOTE: The operation is locked to the current active diff, so if the 64 + // revision is updated before the operation applies nothing sneaky 65 + // occurs. 37 66 38 - $operation = DrydockRepositoryOperation::initializeNewOperation($op) 39 - ->setAuthorPHID($viewer->getPHID()) 40 - ->setObjectPHID($revision->getPHID()) 41 - ->setRepositoryPHID($repository->getPHID()) 42 - ->setRepositoryTarget('branch:master') 43 - ->setProperty('differential.diffPHID', $diff->getPHID()); 67 + $target = 'branch:'.$ref->getRefName(); 68 + 69 + $operation = DrydockRepositoryOperation::initializeNewOperation($op) 70 + ->setAuthorPHID($viewer->getPHID()) 71 + ->setObjectPHID($revision->getPHID()) 72 + ->setRepositoryPHID($repository->getPHID()) 73 + ->setRepositoryTarget($target) 74 + ->setProperty('differential.diffPHID', $diff->getPHID()); 44 75 45 - $operation->save(); 46 - $operation->scheduleUpdate(); 76 + $operation->save(); 77 + $operation->scheduleUpdate(); 47 78 48 - return id(new AphrontRedirectResponse()) 49 - ->setURI($detail_uri); 79 + return id(new AphrontRedirectResponse()) 80 + ->setURI($detail_uri); 81 + } 50 82 } 51 83 52 - return $this->newDialog() 53 - ->setTitle(pht('Land Revision')) 54 - ->appendParagraph( 84 + $ref_datasource = id(new DiffusionRefDatasource()) 85 + ->setParameters( 86 + array( 87 + 'repositoryPHIDs' => array($repository->getPHID()), 88 + 'refTypes' => $ref_types, 89 + )); 90 + 91 + $form = id(new AphrontFormView()) 92 + ->setUser($viewer) 93 + ->appendRemarkupInstructions( 55 94 pht( 56 95 'In theory, this will do approximately what `arc land` would do. '. 57 - 'In practice, that is almost certainly not what it will actually '. 58 - 'do.')) 59 - ->appendParagraph( 96 + 'In practice, you will have a riveting adventure instead.')) 97 + ->appendControl( 98 + id(new AphrontFormTokenizerControl()) 99 + ->setLabel(pht('Onto Branch')) 100 + ->setName('refPHIDs') 101 + ->setLimit(1) 102 + ->setError($e_ref) 103 + ->setDatasource($ref_datasource)) 104 + ->appendRemarkupInstructions( 60 105 pht( 61 - 'THIS FEATURE IS EXPERIMENTAL AND DANGEROUS! USE IT AT YOUR '. 62 - 'OWN RISK!')) 106 + '(WARNING) THIS FEATURE IS EXPERIMENTAL AND DANGEROUS! USE IT AT '. 107 + 'YOUR OWN RISK!')); 108 + 109 + return $this->newDialog() 110 + ->setWidth(AphrontDialogView::WIDTH_FORM) 111 + ->setTitle(pht('Land Revision')) 112 + ->setErrors($errors) 113 + ->appendForm($form) 63 114 ->addCancelButton($detail_uri) 64 115 ->addSubmitButton(pht('Mutate Repository Unpredictably')); 65 116 }
+4
src/applications/repository/phid/PhabricatorRepositoryRefCursorPHIDType.php
··· 9 9 return pht('Repository Ref'); 10 10 } 11 11 12 + public function getTypeIcon() { 13 + return 'fa-code-fork'; 14 + } 15 + 12 16 public function newObject() { 13 17 return new PhabricatorRepositoryRefCursor(); 14 18 }