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

Move Subversion repository information to the new interface

Summary: Ref T2231. Moves "UUID" and "Subpath/Import Only" to Diffusion.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2231

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

+240
+2
src/__phutil_library_map__.php
··· 510 510 'DiffusionRepositoryEditController' => 'applications/diffusion/controller/DiffusionRepositoryEditController.php', 511 511 'DiffusionRepositoryEditEncodingController' => 'applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php', 512 512 'DiffusionRepositoryEditPolicyController' => 'applications/diffusion/controller/DiffusionRepositoryEditPolicyController.php', 513 + 'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php', 513 514 'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php', 514 515 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', 515 516 'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php', ··· 2682 2683 'DiffusionRepositoryEditController' => 'DiffusionController', 2683 2684 'DiffusionRepositoryEditEncodingController' => 'DiffusionController', 2684 2685 'DiffusionRepositoryEditPolicyController' => 'DiffusionController', 2686 + 'DiffusionRepositoryEditSubversionController' => 'DiffusionController', 2685 2687 'DiffusionRepositoryListController' => 2686 2688 array( 2687 2689 0 => 'DiffusionController',
+1
src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
··· 70 70 'activate/' => 'DiffusionRepositoryEditActivateController', 71 71 'policy/' => 'DiffusionRepositoryEditPolicyController', 72 72 'branches/' => 'DiffusionRepositoryEditBranchesController', 73 + 'subversion/' => 'DiffusionRepositoryEditSubversionController', 73 74 ), 74 75 ), 75 76 'inline/' => array(
+58
src/applications/diffusion/controller/DiffusionRepositoryEditController.php
··· 61 61 $this->buildBranchesActions($repository)); 62 62 } 63 63 64 + $subversion_properties = null; 65 + if ($is_svn) { 66 + $subversion_properties = $this->buildSubversionProperties( 67 + $repository, 68 + $this->buildSubversionActions($repository)); 69 + } 70 + 64 71 $xactions = id(new PhabricatorRepositoryTransactionQuery()) 65 72 ->setViewer($user) 66 73 ->withObjectPHIDs(array($repository->getPHID())) ··· 91 98 92 99 if ($branches_properties) { 93 100 $obj_box->addPropertyList($branches_properties); 101 + } 102 + 103 + if ($subversion_properties) { 104 + $obj_box->addPropertyList($subversion_properties); 94 105 } 95 106 96 107 return $this->buildApplicationPage( ··· 330 341 return $view; 331 342 } 332 343 344 + private function buildSubversionActions(PhabricatorRepository $repository) { 345 + $viewer = $this->getRequest()->getUser(); 346 + 347 + $view = id(new PhabricatorActionListView()) 348 + ->setObjectURI($this->getRequest()->getRequestURI()) 349 + ->setUser($viewer); 350 + 351 + $can_edit = PhabricatorPolicyFilter::hasCapability( 352 + $viewer, 353 + $repository, 354 + PhabricatorPolicyCapability::CAN_EDIT); 355 + 356 + $edit = id(new PhabricatorActionView()) 357 + ->setIcon('edit') 358 + ->setName(pht('Edit Subversion Info')) 359 + ->setHref( 360 + $this->getRepositoryControllerURI($repository, 'edit/subversion/')) 361 + ->setWorkflow(!$can_edit) 362 + ->setDisabled(!$can_edit); 363 + $view->addAction($edit); 364 + 365 + return $view; 366 + } 367 + 368 + private function buildSubversionProperties( 369 + PhabricatorRepository $repository, 370 + PhabricatorActionListView $actions) { 371 + 372 + $viewer = $this->getRequest()->getUser(); 373 + 374 + $view = id(new PHUIPropertyListView()) 375 + ->setUser($viewer) 376 + ->setActionList($actions) 377 + ->addSectionHeader(pht('Subversion')); 378 + 379 + $svn_uuid = nonempty( 380 + $repository->getUUID(), 381 + phutil_tag('em', array(), pht('Not Configured'))); 382 + $view->addProperty(pht('Subversion UUID'), $svn_uuid); 383 + 384 + $svn_subpath = nonempty( 385 + $repository->getHumanReadableDetail('svn-subpath'), 386 + phutil_tag('em', array(), pht('Import Entire Repository'))); 387 + $view->addProperty(pht('Import Only'), $svn_subpath); 388 + 389 + return $view; 390 + } 333 391 334 392 }
+125
src/applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php
··· 1 + <?php 2 + 3 + final class DiffusionRepositoryEditSubversionController 4 + extends DiffusionController { 5 + 6 + public function processRequest() { 7 + $request = $this->getRequest(); 8 + $viewer = $request->getUser(); 9 + $drequest = $this->diffusionRequest; 10 + $repository = $drequest->getRepository(); 11 + 12 + $repository = id(new PhabricatorRepositoryQuery()) 13 + ->setViewer($viewer) 14 + ->requireCapabilities( 15 + array( 16 + PhabricatorPolicyCapability::CAN_VIEW, 17 + PhabricatorPolicyCapability::CAN_EDIT, 18 + )) 19 + ->withIDs(array($repository->getID())) 20 + ->executeOne(); 21 + 22 + if (!$repository) { 23 + return new Aphront404Response(); 24 + } 25 + 26 + switch ($repository->getVersionControlSystem()) { 27 + case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 28 + case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 29 + throw new Exception( 30 + pht('Git and Mercurial do not support editing SVN properties!')); 31 + case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 32 + break; 33 + default: 34 + throw new Exception( 35 + pht('Repository has unknown version control system!')); 36 + } 37 + 38 + $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/'); 39 + 40 + $v_subpath = $repository->getHumanReadableDetail('svn-subpath'); 41 + $v_uuid = $repository->getUUID(); 42 + 43 + if ($request->isFormPost()) { 44 + $v_subpath = $request->getStr('subpath'); 45 + $v_uuid = $request->getStr('uuid'); 46 + 47 + $xactions = array(); 48 + $template = id(new PhabricatorRepositoryTransaction()); 49 + 50 + $type_subpath = PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH; 51 + $type_uuid = PhabricatorRepositoryTransaction::TYPE_UUID; 52 + 53 + $xactions[] = id(clone $template) 54 + ->setTransactionType($type_subpath) 55 + ->setNewValue($v_subpath); 56 + 57 + $xactions[] = id(clone $template) 58 + ->setTransactionType($type_uuid) 59 + ->setNewValue($v_uuid); 60 + 61 + id(new PhabricatorRepositoryEditor()) 62 + ->setContinueOnNoEffect(true) 63 + ->setContentSourceFromRequest($request) 64 + ->setActor($viewer) 65 + ->applyTransactions($repository, $xactions); 66 + 67 + return id(new AphrontRedirectResponse())->setURI($edit_uri); 68 + } 69 + 70 + $content = array(); 71 + 72 + $crumbs = $this->buildCrumbs(); 73 + $crumbs->addCrumb( 74 + id(new PhabricatorCrumbView()) 75 + ->setName(pht('Edit Subversion Info'))); 76 + 77 + $title = pht('Edit Subversion Info (%s)', $repository->getName()); 78 + 79 + $policies = id(new PhabricatorPolicyQuery()) 80 + ->setViewer($viewer) 81 + ->setObject($repository) 82 + ->execute(); 83 + 84 + $form = id(new AphrontFormView()) 85 + ->setUser($viewer) 86 + ->appendRemarkupInstructions( 87 + pht( 88 + "You can set the **Repository UUID**, which will help Phabriactor ". 89 + "provide better context in some cases. You can find the UUID of a ". 90 + "repository by running `svn info`.". 91 + "\n\n". 92 + "If you want to import only part of a repository, like `trunk/`, ". 93 + "you can set a path in **Import Only**. Phabricator will ignore ". 94 + "commits which do not affect this path.")) 95 + ->appendChild( 96 + id(new AphrontFormTextControl()) 97 + ->setName('uuid') 98 + ->setLabel(pht('Repository UUID')) 99 + ->setValue($v_uuid)) 100 + ->appendChild( 101 + id(new AphrontFormTextControl()) 102 + ->setName('subpath') 103 + ->setLabel(pht('Import Only')) 104 + ->setValue($v_subpath)) 105 + ->appendChild( 106 + id(new AphrontFormSubmitControl()) 107 + ->setValue(pht('Save Subversion Info')) 108 + ->addCancelButton($edit_uri)); 109 + 110 + $form_box = id(new PHUIObjectBoxView()) 111 + ->setHeaderText($title) 112 + ->setForm($form); 113 + 114 + return $this->buildApplicationPage( 115 + array( 116 + $crumbs, 117 + $form_box, 118 + ), 119 + array( 120 + 'title' => $title, 121 + 'device' => true, 122 + )); 123 + } 124 + 125 + }
+14
src/applications/repository/editor/PhabricatorRepositoryEditor.php
··· 13 13 $types[] = PhabricatorRepositoryTransaction::TYPE_DEFAULT_BRANCH; 14 14 $types[] = PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY; 15 15 $types[] = PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY; 16 + $types[] = PhabricatorRepositoryTransaction::TYPE_UUID; 17 + $types[] = PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH; 16 18 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 17 19 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 18 20 ··· 38 40 return array_keys($object->getDetail('branch-filter', array())); 39 41 case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY: 40 42 return array_keys($object->getDetail('close-commits-filter', array())); 43 + case PhabricatorRepositoryTransaction::TYPE_UUID: 44 + return $object->getUUID(); 45 + case PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH: 46 + return $object->getDetail('svn-subpath'); 41 47 } 42 48 } 43 49 ··· 53 59 case PhabricatorRepositoryTransaction::TYPE_DEFAULT_BRANCH: 54 60 case PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY: 55 61 case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY: 62 + case PhabricatorRepositoryTransaction::TYPE_UUID: 63 + case PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH: 56 64 return $xaction->getNewValue(); 57 65 } 58 66 } ··· 83 91 $object->setDetail( 84 92 'close-commits-filter', 85 93 array_fill_keys($xaction->getNewValue(), true)); 94 + break; 95 + case PhabricatorRepositoryTransaction::TYPE_UUID: 96 + $object->setUUID($xaction->getNewValue()); 97 + break; 98 + case PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH: 99 + $object->setDetail('svn-subpath', $xaction->getNewValue()); 86 100 break; 87 101 case PhabricatorRepositoryTransaction::TYPE_ENCODING: 88 102 // Make sure the encoding is valid by converting to UTF-8. This tests
+40
src/applications/repository/storage/PhabricatorRepositoryTransaction.php
··· 10 10 const TYPE_DEFAULT_BRANCH = 'repo:default-branch'; 11 11 const TYPE_TRACK_ONLY = 'repo:track-only'; 12 12 const TYPE_AUTOCLOSE_ONLY = 'repo:autoclose-only'; 13 + const TYPE_SVN_SUBPATH = 'repo:svn-subpath'; 14 + const TYPE_UUID = 'repo:uuid'; 13 15 14 16 public function getApplicationName() { 15 17 return 'repository'; ··· 121 123 $this->renderHandleLink($author_phid), 122 124 implode(', ', $old), 123 125 implode(', ', $new)); 126 + } 127 + break; 128 + case self::TYPE_UUID: 129 + if (!strlen($new)) { 130 + return pht( 131 + '%s removed "%s" as the repository UUID.', 132 + $this->renderHandleLink($author_phid), 133 + $old); 134 + } else if (!strlen($old)) { 135 + return pht( 136 + '%s set the repository UUID to "%s".', 137 + $this->renderHandleLink($author_phid), 138 + $new); 139 + } else { 140 + return pht( 141 + '%s changed the repository UUID from "%s" to "%s".', 142 + $this->renderHandleLink($author_phid), 143 + $old, 144 + $new); 145 + } 146 + break; 147 + case self::TYPE_SVN_SUBPATH: 148 + if (!strlen($new)) { 149 + return pht( 150 + '%s removed "%s" as the Import Only path.', 151 + $this->renderHandleLink($author_phid), 152 + $old); 153 + } else if (!strlen($old)) { 154 + return pht( 155 + '%s set the repository to import only "%s".', 156 + $this->renderHandleLink($author_phid), 157 + $new); 158 + } else { 159 + return pht( 160 + '%s changed the import path from "%s" to "%s".', 161 + $this->renderHandleLink($author_phid), 162 + $old, 163 + $new); 124 164 } 125 165 break; 126 166 }