@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.

Allow configuration of a "staging area" for each repository

Summary:
Ref T8238. This allows configuration of a "staging area" for Git repositories, which is the URI to some Git repository (possibly the same repository).

If a staging area is configured, `arc` will push a copy of anything it creates a diff for there (see next revision). This primarily makes handoff to build systems easier.

This is a bit leaky and I intend for it to eventually be positioned as a less-preferred solution, but from the perspective of build systems it's the same as the real (virtual ref) solution that I want to build.

Test Plan: Ran `arc diff` with various flags, saw appropriate changes copied into the staging area. See also discussion in T8238.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: cburroughs, epriestley

Maniphest Tasks: T8238

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

+212 -14
+12 -12
resources/celerity/map.php
··· 7 7 */ 8 8 return array( 9 9 'names' => array( 10 - 'core.pkg.css' => '4e7df908', 10 + 'core.pkg.css' => '439658b5', 11 11 'core.pkg.js' => '328799d0', 12 12 'darkconsole.pkg.js' => 'e7393ebb', 13 13 'differential.pkg.css' => 'bb338e4b', ··· 134 134 'rsrc/css/phui/phui-document.css' => '94d5dcd8', 135 135 'rsrc/css/phui/phui-feed-story.css' => 'c9f3a0b5', 136 136 'rsrc/css/phui/phui-fontkit.css' => 'dd8ddf27', 137 - 'rsrc/css/phui/phui-form-view.css' => '808329f2', 137 + 'rsrc/css/phui/phui-form-view.css' => '79793450', 138 138 'rsrc/css/phui/phui-form.css' => 'f535f938', 139 139 'rsrc/css/phui/phui-header-view.css' => '75aaf372', 140 140 'rsrc/css/phui/phui-icon.css' => 'bc766998', ··· 443 443 'rsrc/js/core/behavior-device.js' => 'a205cf28', 444 444 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e', 445 445 'rsrc/js/core/behavior-error-log.js' => '6882e80a', 446 - 'rsrc/js/core/behavior-fancy-datepicker.js' => '510b5809', 446 + 'rsrc/js/core/behavior-fancy-datepicker.js' => '2d4029a8', 447 447 'rsrc/js/core/behavior-file-tree.js' => '88236f00', 448 448 'rsrc/js/core/behavior-form.js' => '5c54cbf3', 449 449 'rsrc/js/core/behavior-gesture.js' => '3ab51e2c', ··· 576 576 'javelin-behavior-durable-column' => '16c695bf', 577 577 'javelin-behavior-error-log' => '6882e80a', 578 578 'javelin-behavior-event-all-day' => '38dcf3c8', 579 - 'javelin-behavior-fancy-datepicker' => '510b5809', 579 + 'javelin-behavior-fancy-datepicker' => '2d4029a8', 580 580 'javelin-behavior-global-drag-and-drop' => 'c8e57404', 581 581 'javelin-behavior-herald-rule-editor' => '7ebaeed3', 582 582 'javelin-behavior-high-security-warning' => 'a464fe03', ··· 776 776 'phui-font-icon-base-css' => '3dad2ae3', 777 777 'phui-fontkit-css' => 'dd8ddf27', 778 778 'phui-form-css' => 'f535f938', 779 - 'phui-form-view-css' => '808329f2', 779 + 'phui-form-view-css' => '79793450', 780 780 'phui-header-view-css' => '75aaf372', 781 781 'phui-icon-view-css' => 'bc766998', 782 782 'phui-image-mask-css' => '5a8b09c8', ··· 1042 1042 'javelin-install', 1043 1043 'javelin-event', 1044 1044 ), 1045 + '2d4029a8' => array( 1046 + 'javelin-behavior', 1047 + 'javelin-util', 1048 + 'javelin-dom', 1049 + 'javelin-stratcom', 1050 + 'javelin-vector', 1051 + ), 1045 1052 '331b1611' => array( 1046 1053 'javelin-install', 1047 1054 ), ··· 1166 1173 'javelin-install', 1167 1174 'javelin-typeahead-source', 1168 1175 'javelin-util', 1169 - ), 1170 - '510b5809' => array( 1171 - 'javelin-behavior', 1172 - 'javelin-util', 1173 - 'javelin-dom', 1174 - 'javelin-stratcom', 1175 - 'javelin-vector', 1176 1176 ), 1177 1177 '519705ea' => array( 1178 1178 'javelin-install',
+2
src/__phutil_library_map__.php
··· 595 595 'DiffusionRepositoryEditEncodingController' => 'applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php', 596 596 'DiffusionRepositoryEditHostingController' => 'applications/diffusion/controller/DiffusionRepositoryEditHostingController.php', 597 597 'DiffusionRepositoryEditMainController' => 'applications/diffusion/controller/DiffusionRepositoryEditMainController.php', 598 + 'DiffusionRepositoryEditStagingController' => 'applications/diffusion/controller/DiffusionRepositoryEditStagingController.php', 598 599 'DiffusionRepositoryEditStorageController' => 'applications/diffusion/controller/DiffusionRepositoryEditStorageController.php', 599 600 'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php', 600 601 'DiffusionRepositoryEditUpdateController' => 'applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php', ··· 3831 3832 'DiffusionRepositoryEditEncodingController' => 'DiffusionRepositoryEditController', 3832 3833 'DiffusionRepositoryEditHostingController' => 'DiffusionRepositoryEditController', 3833 3834 'DiffusionRepositoryEditMainController' => 'DiffusionRepositoryEditController', 3835 + 'DiffusionRepositoryEditStagingController' => 'DiffusionRepositoryEditController', 3834 3836 'DiffusionRepositoryEditStorageController' => 'DiffusionRepositoryEditController', 3835 3837 'DiffusionRepositoryEditSubversionController' => 'DiffusionRepositoryEditController', 3836 3838 'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryEditController',
+1
src/applications/diffusion/application/PhabricatorDiffusionApplication.php
··· 101 101 '(?P<serve>serve)/' => 'DiffusionRepositoryEditHostingController', 102 102 'update/' => 'DiffusionRepositoryEditUpdateController', 103 103 'symbol/' => 'DiffusionRepositorySymbolsController', 104 + 'staging/' => 'DiffusionRepositoryEditStagingController', 104 105 ), 105 106 'pathtree/(?P<dblob>.*)' => 'DiffusionPathTreeController', 106 107 'mirror/' => array(
+53
src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
··· 30 30 31 31 $has_branches = ($is_git || $is_hg); 32 32 $has_local = $repository->usesLocalWorkingCopy(); 33 + $supports_staging = $repository->supportsStaging(); 33 34 34 35 $crumbs = $this->buildApplicationCrumbs($is_main = true); 35 36 ··· 92 93 $this->buildStorageActions($repository)); 93 94 } 94 95 96 + $staging_properties = null; 97 + if ($supports_staging) { 98 + $staging_properties = $this->buildStagingProperties( 99 + $repository, 100 + $this->buildStagingActions($repository)); 101 + } 102 + 95 103 $actions_properties = $this->buildActionsProperties( 96 104 $repository, 97 105 $this->buildActionsActions($repository)); ··· 155 163 $boxes[] = id(new PHUIObjectBoxView()) 156 164 ->setHeaderText(pht('Storage')) 157 165 ->addPropertyList($storage_properties); 166 + } 167 + 168 + if ($staging_properties) { 169 + $boxes[] = id(new PHUIObjectBoxView()) 170 + ->setHeaderText(pht('Staging')) 171 + ->addPropertyList($staging_properties); 158 172 } 159 173 160 174 $boxes[] = id(new PHUIObjectBoxView()) ··· 605 619 $view->addProperty( 606 620 pht('Storage Path'), 607 621 $repository->getHumanReadableDetail('local-path')); 622 + 623 + return $view; 624 + } 625 + 626 + 627 + private function buildStagingActions(PhabricatorRepository $repository) { 628 + $viewer = $this->getViewer(); 629 + 630 + $view = id(new PhabricatorActionListView()) 631 + ->setObjectURI($this->getRequest()->getRequestURI()) 632 + ->setUser($viewer); 633 + 634 + $edit = id(new PhabricatorActionView()) 635 + ->setIcon('fa-pencil') 636 + ->setName(pht('Edit Staging')) 637 + ->setHref( 638 + $this->getRepositoryControllerURI($repository, 'edit/staging/')); 639 + $view->addAction($edit); 640 + 641 + return $view; 642 + } 643 + 644 + private function buildStagingProperties( 645 + PhabricatorRepository $repository, 646 + PhabricatorActionListView $actions) { 647 + $viewer = $this->getViewer(); 648 + 649 + $view = id(new PHUIPropertyListView()) 650 + ->setUser($viewer) 651 + ->setActionList($actions); 652 + 653 + $staging_uri = $repository->getStagingURI(); 654 + if (!$staging_uri) { 655 + $staging_uri = phutil_tag('em', array(), pht('No Staging Area')); 656 + } 657 + 658 + $view->addProperty( 659 + pht('Staging Area'), 660 + $staging_uri); 608 661 609 662 return $view; 610 663 }
+92
src/applications/diffusion/controller/DiffusionRepositoryEditStagingController.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositoryEditStagingController 4 + extends DiffusionRepositoryEditController { 5 + 6 + protected function processDiffusionRequest(AphrontRequest $request) { 7 + $user = $request->getUser(); 8 + $drequest = $this->diffusionRequest; 9 + $repository = $drequest->getRepository(); 10 + 11 + $repository = id(new PhabricatorRepositoryQuery()) 12 + ->setViewer($user) 13 + ->requireCapabilities( 14 + array( 15 + PhabricatorPolicyCapability::CAN_VIEW, 16 + PhabricatorPolicyCapability::CAN_EDIT, 17 + )) 18 + ->withIDs(array($repository->getID())) 19 + ->executeOne(); 20 + if (!$repository) { 21 + return new Aphront404Response(); 22 + } 23 + 24 + if (!$repository->supportsStaging()) { 25 + return new Aphront404Response(); 26 + } 27 + 28 + $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); 29 + 30 + $v_area = $repository->getHumanReadableDetail('staging-uri'); 31 + if ($request->isFormPost()) { 32 + $v_area = $request->getStr('area'); 33 + 34 + $xactions = array(); 35 + $template = id(new PhabricatorRepositoryTransaction()); 36 + 37 + $type_encoding = PhabricatorRepositoryTransaction::TYPE_STAGING_URI; 38 + 39 + $xactions[] = id(clone $template) 40 + ->setTransactionType($type_encoding) 41 + ->setNewValue($v_area); 42 + 43 + id(new PhabricatorRepositoryEditor()) 44 + ->setContinueOnNoEffect(true) 45 + ->setContentSourceFromRequest($request) 46 + ->setActor($user) 47 + ->applyTransactions($repository, $xactions); 48 + 49 + return id(new AphrontRedirectResponse())->setURI($edit_uri); 50 + } 51 + 52 + $crumbs = $this->buildApplicationCrumbs(); 53 + $crumbs->addTextCrumb(pht('Edit Staging')); 54 + 55 + $title = pht('Edit %s', $repository->getName()); 56 + 57 + $form = id(new AphrontFormView()) 58 + ->setUser($user) 59 + ->appendRemarkupInstructions( 60 + pht( 61 + "To make it easier to run integration tests and builds on code ". 62 + "under review, you can configure a **Staging Area**. When `arc` ". 63 + "creates a diff, it will push a copy of the changes to the ". 64 + "configured staging area with a corresponding tag.". 65 + "\n\n". 66 + "IMPORTANT: This feature is new, experimental, and not supported. ". 67 + "Use it at your own risk.")) 68 + ->appendChild( 69 + id(new AphrontFormTextControl()) 70 + ->setLabel(pht('Staging Area URI')) 71 + ->setName('area') 72 + ->setValue($v_area)) 73 + ->appendChild( 74 + id(new AphrontFormSubmitControl()) 75 + ->setValue(pht('Save')) 76 + ->addCancelButton($edit_uri)); 77 + 78 + $object_box = id(new PHUIObjectBoxView()) 79 + ->setHeaderText($title) 80 + ->setForm($form); 81 + 82 + return $this->buildApplicationPage( 83 + array( 84 + $crumbs, 85 + $object_box, 86 + ), 87 + array( 88 + 'title' => $title, 89 + )); 90 + } 91 + 92 + }
+8
src/applications/repository/editor/PhabricatorRepositoryEditor.php
··· 43 43 $types[] = PhabricatorRepositoryTransaction::TYPE_SERVICE; 44 44 $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE; 45 45 $types[] = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES; 46 + $types[] = PhabricatorRepositoryTransaction::TYPE_STAGING_URI; 46 47 47 48 $types[] = PhabricatorTransactions::TYPE_EDGE; 48 49 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; ··· 104 105 return $object->getSymbolLanguages(); 105 106 case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: 106 107 return $object->getSymbolSources(); 108 + case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: 109 + return $object->getDetail('staging-uri'); 107 110 } 108 111 } 109 112 ··· 139 142 case PhabricatorRepositoryTransaction::TYPE_SERVICE: 140 143 case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: 141 144 case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: 145 + case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: 142 146 return $xaction->getNewValue(); 143 147 case PhabricatorRepositoryTransaction::TYPE_NOTIFY: 144 148 case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE: ··· 219 223 case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: 220 224 $object->setDetail('symbol-sources', $xaction->getNewValue()); 221 225 return; 226 + case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: 227 + $object->setDetail('staging-uri', $xaction->getNewValue()); 228 + return; 222 229 case PhabricatorRepositoryTransaction::TYPE_ENCODING: 223 230 // Make sure the encoding is valid by converting to UTF-8. This tests 224 231 // that the user has mbstring installed, and also that they didn't type ··· 330 337 case PhabricatorRepositoryTransaction::TYPE_SERVICE: 331 338 case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES: 332 339 case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE: 340 + case PhabricatorRepositoryTransaction::TYPE_STAGING_URI: 333 341 PhabricatorPolicyFilter::requireCapability( 334 342 $this->requireActor(), 335 343 $object,
+21
src/applications/repository/storage/PhabricatorRepository.php
··· 136 136 'isHosted' => $this->isHosted(), 137 137 'isImporting' => $this->isImporting(), 138 138 'encoding' => $this->getDetail('encoding'), 139 + 'staging' => array( 140 + 'supported' => $this->supportsStaging(), 141 + 'prefix' => 'phabricator', 142 + 'uri' => $this->getStagingURI(), 143 + ), 139 144 ); 140 145 } 141 146 ··· 1794 1799 1795 1800 public function getSymbolLanguages() { 1796 1801 return $this->getDetail('symbol-languages', array()); 1802 + } 1803 + 1804 + 1805 + /* -( Staging )-------------------------------------------------------------*/ 1806 + 1807 + 1808 + public function supportsStaging() { 1809 + return $this->isGit(); 1810 + } 1811 + 1812 + 1813 + public function getStagingURI() { 1814 + if (!$this->supportsStaging()) { 1815 + return null; 1816 + } 1817 + return $this->getDetail('staging-uri', null); 1797 1818 } 1798 1819 1799 1820
+23 -2
src/applications/repository/storage/PhabricatorRepositoryTransaction.php
··· 27 27 const TYPE_SERVICE = 'repo:service'; 28 28 const TYPE_SYMBOLS_SOURCES = 'repo:symbol-source'; 29 29 const TYPE_SYMBOLS_LANGUAGE = 'repo:symbol-language'; 30 + const TYPE_STAGING_URI = 'repo:staging-uri'; 30 31 31 32 // TODO: Clean up these legacy transaction types. 32 33 const TYPE_SSH_LOGIN = 'repo:ssh-login'; ··· 412 413 413 414 case self::TYPE_SYMBOLS_LANGUAGE: 414 415 return pht('%s changed indexed languages from %s to %s.', 416 + $this->renderHandleLink($author_phid), 417 + $old ? implode(', ', $old) : pht('Any'), 418 + $new ? implode(', ', $new) : pht('Any')); 419 + 420 + case self::TYPE_STAGING_URI: 421 + if (!$old) { 422 + return pht( 423 + '%s set "%s" as the staging area for this repository.', 415 424 $this->renderHandleLink($author_phid), 416 - $old ? implode(', ', $old) : pht('Any'), 417 - $new ? implode(', ', $new) : pht('Any')); 425 + $new); 426 + } else if (!$new) { 427 + return pht( 428 + '%s removed "%s" as the staging area for this repository.', 429 + $this->renderHandleLink($author_phid), 430 + $old); 431 + } else { 432 + return pht( 433 + '%s changed the staging area for this repository from '. 434 + '"%s" to "%s".', 435 + $this->renderHandleLink($author_phid), 436 + $old, 437 + $new); 438 + } 418 439 } 419 440 420 441 return parent::getTitle();