Page MenuHomePhabricator

D7400.id16683.diff
No OneTemporary

D7400.id16683.diff

Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -510,6 +510,7 @@
'DiffusionRepositoryEditController' => 'applications/diffusion/controller/DiffusionRepositoryEditController.php',
'DiffusionRepositoryEditEncodingController' => 'applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php',
'DiffusionRepositoryEditPolicyController' => 'applications/diffusion/controller/DiffusionRepositoryEditPolicyController.php',
+ 'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php',
'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php',
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php',
@@ -2682,6 +2683,7 @@
'DiffusionRepositoryEditController' => 'DiffusionController',
'DiffusionRepositoryEditEncodingController' => 'DiffusionController',
'DiffusionRepositoryEditPolicyController' => 'DiffusionController',
+ 'DiffusionRepositoryEditSubversionController' => 'DiffusionController',
'DiffusionRepositoryListController' =>
array(
0 => 'DiffusionController',
Index: src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
===================================================================
--- src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
+++ src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
@@ -70,6 +70,7 @@
'activate/' => 'DiffusionRepositoryEditActivateController',
'policy/' => 'DiffusionRepositoryEditPolicyController',
'branches/' => 'DiffusionRepositoryEditBranchesController',
+ 'subversion/' => 'DiffusionRepositoryEditSubversionController',
),
),
'inline/' => array(
Index: src/applications/diffusion/controller/DiffusionRepositoryEditController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionRepositoryEditController.php
+++ src/applications/diffusion/controller/DiffusionRepositoryEditController.php
@@ -61,6 +61,13 @@
$this->buildBranchesActions($repository));
}
+ $subversion_properties = null;
+ if ($is_svn) {
+ $subversion_properties = $this->buildSubversionProperties(
+ $repository,
+ $this->buildSubversionActions($repository));
+ }
+
$xactions = id(new PhabricatorRepositoryTransactionQuery())
->setViewer($user)
->withObjectPHIDs(array($repository->getPHID()))
@@ -93,6 +100,10 @@
$obj_box->addPropertyList($branches_properties);
}
+ if ($subversion_properties) {
+ $obj_box->addPropertyList($subversion_properties);
+ }
+
return $this->buildApplicationPage(
array(
$crumbs,
@@ -330,5 +341,52 @@
return $view;
}
+ private function buildSubversionActions(PhabricatorRepository $repository) {
+ $viewer = $this->getRequest()->getUser();
+
+ $view = id(new PhabricatorActionListView())
+ ->setObjectURI($this->getRequest()->getRequestURI())
+ ->setUser($viewer);
+
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $repository,
+ PhabricatorPolicyCapability::CAN_EDIT);
+
+ $edit = id(new PhabricatorActionView())
+ ->setIcon('edit')
+ ->setName(pht('Edit Subversion Info'))
+ ->setHref(
+ $this->getRepositoryControllerURI($repository, 'edit/subversion/'))
+ ->setWorkflow(!$can_edit)
+ ->setDisabled(!$can_edit);
+ $view->addAction($edit);
+
+ return $view;
+ }
+
+ private function buildSubversionProperties(
+ PhabricatorRepository $repository,
+ PhabricatorActionListView $actions) {
+
+ $viewer = $this->getRequest()->getUser();
+
+ $view = id(new PHUIPropertyListView())
+ ->setUser($viewer)
+ ->setActionList($actions)
+ ->addSectionHeader(pht('Subversion'));
+
+ $svn_uuid = nonempty(
+ $repository->getUUID(),
+ phutil_tag('em', array(), pht('Not Configured')));
+ $view->addProperty(pht('Subversion UUID'), $svn_uuid);
+
+ $svn_subpath = nonempty(
+ $repository->getHumanReadableDetail('svn-subpath'),
+ phutil_tag('em', array(), pht('Import Entire Repository')));
+ $view->addProperty(pht('Import Only'), $svn_subpath);
+
+ return $view;
+ }
}
Index: src/applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php
===================================================================
--- /dev/null
+++ src/applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php
@@ -0,0 +1,125 @@
+<?php
+
+final class DiffusionRepositoryEditSubversionController
+ extends DiffusionController {
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+ $drequest = $this->diffusionRequest;
+ $repository = $drequest->getRepository();
+
+ $repository = id(new PhabricatorRepositoryQuery())
+ ->setViewer($viewer)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->withIDs(array($repository->getID()))
+ ->executeOne();
+
+ if (!$repository) {
+ return new Aphront404Response();
+ }
+
+ switch ($repository->getVersionControlSystem()) {
+ case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
+ case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
+ throw new Exception(
+ pht('Git and Mercurial do not support editing SVN properties!'));
+ case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
+ break;
+ default:
+ throw new Exception(
+ pht('Repository has unknown version control system!'));
+ }
+
+ $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
+
+ $v_subpath = $repository->getHumanReadableDetail('svn-subpath');
+ $v_uuid = $repository->getUUID();
+
+ if ($request->isFormPost()) {
+ $v_subpath = $request->getStr('subpath');
+ $v_uuid = $request->getStr('uuid');
+
+ $xactions = array();
+ $template = id(new PhabricatorRepositoryTransaction());
+
+ $type_subpath = PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH;
+ $type_uuid = PhabricatorRepositoryTransaction::TYPE_UUID;
+
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_subpath)
+ ->setNewValue($v_subpath);
+
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_uuid)
+ ->setNewValue($v_uuid);
+
+ id(new PhabricatorRepositoryEditor())
+ ->setContinueOnNoEffect(true)
+ ->setContentSourceFromRequest($request)
+ ->setActor($viewer)
+ ->applyTransactions($repository, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($edit_uri);
+ }
+
+ $content = array();
+
+ $crumbs = $this->buildCrumbs();
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName(pht('Edit Subversion Info')));
+
+ $title = pht('Edit Subversion Info (%s)', $repository->getName());
+
+ $policies = id(new PhabricatorPolicyQuery())
+ ->setViewer($viewer)
+ ->setObject($repository)
+ ->execute();
+
+ $form = id(new AphrontFormView())
+ ->setUser($viewer)
+ ->appendRemarkupInstructions(
+ pht(
+ "You can set the **Repository UUID**, which will help Phabriactor ".
+ "provide better context in some cases. You can find the UUID of a ".
+ "repository by running `svn info`.".
+ "\n\n".
+ "If you want to import only part of a repository, like `trunk/`, ".
+ "you can set a path in **Import Only**. Phabricator will ignore ".
+ "commits which do not affect this path."))
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('uuid')
+ ->setLabel(pht('Repository UUID'))
+ ->setValue($v_uuid))
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('subpath')
+ ->setLabel(pht('Import Only'))
+ ->setValue($v_subpath))
+ ->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->setValue(pht('Save Subversion Info'))
+ ->addCancelButton($edit_uri));
+
+ $form_box = id(new PHUIObjectBoxView())
+ ->setHeaderText($title)
+ ->setForm($form);
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $form_box,
+ ),
+ array(
+ 'title' => $title,
+ 'device' => true,
+ ));
+ }
+
+}
Index: src/applications/repository/editor/PhabricatorRepositoryEditor.php
===================================================================
--- src/applications/repository/editor/PhabricatorRepositoryEditor.php
+++ src/applications/repository/editor/PhabricatorRepositoryEditor.php
@@ -13,6 +13,8 @@
$types[] = PhabricatorRepositoryTransaction::TYPE_DEFAULT_BRANCH;
$types[] = PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY;
$types[] = PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY;
+ $types[] = PhabricatorRepositoryTransaction::TYPE_UUID;
+ $types[] = PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -38,6 +40,10 @@
return array_keys($object->getDetail('branch-filter', array()));
case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY:
return array_keys($object->getDetail('close-commits-filter', array()));
+ case PhabricatorRepositoryTransaction::TYPE_UUID:
+ return $object->getUUID();
+ case PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH:
+ return $object->getDetail('svn-subpath');
}
}
@@ -53,6 +59,8 @@
case PhabricatorRepositoryTransaction::TYPE_DEFAULT_BRANCH:
case PhabricatorRepositoryTransaction::TYPE_TRACK_ONLY:
case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE_ONLY:
+ case PhabricatorRepositoryTransaction::TYPE_UUID:
+ case PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH:
return $xaction->getNewValue();
}
}
@@ -84,6 +92,12 @@
'close-commits-filter',
array_fill_keys($xaction->getNewValue(), true));
break;
+ case PhabricatorRepositoryTransaction::TYPE_UUID:
+ $object->setUUID($xaction->getNewValue());
+ break;
+ case PhabricatorRepositoryTransaction::TYPE_SVN_SUBPATH:
+ $object->setDetail('svn-subpath', $xaction->getNewValue());
+ break;
case PhabricatorRepositoryTransaction::TYPE_ENCODING:
// Make sure the encoding is valid by converting to UTF-8. This tests
// that the user has mbstring installed, and also that they didn't type
Index: src/applications/repository/storage/PhabricatorRepositoryTransaction.php
===================================================================
--- src/applications/repository/storage/PhabricatorRepositoryTransaction.php
+++ src/applications/repository/storage/PhabricatorRepositoryTransaction.php
@@ -10,6 +10,8 @@
const TYPE_DEFAULT_BRANCH = 'repo:default-branch';
const TYPE_TRACK_ONLY = 'repo:track-only';
const TYPE_AUTOCLOSE_ONLY = 'repo:autoclose-only';
+ const TYPE_SVN_SUBPATH = 'repo:svn-subpath';
+ const TYPE_UUID = 'repo:uuid';
public function getApplicationName() {
return 'repository';
@@ -123,6 +125,44 @@
implode(', ', $new));
}
break;
+ case self::TYPE_UUID:
+ if (!strlen($new)) {
+ return pht(
+ '%s removed "%s" as the repository UUID.',
+ $this->renderHandleLink($author_phid),
+ $old);
+ } else if (!strlen($old)) {
+ return pht(
+ '%s set the repository UUID to "%s".',
+ $this->renderHandleLink($author_phid),
+ $new);
+ } else {
+ return pht(
+ '%s changed the repository UUID from "%s" to "%s".',
+ $this->renderHandleLink($author_phid),
+ $old,
+ $new);
+ }
+ break;
+ case self::TYPE_SVN_SUBPATH:
+ if (!strlen($new)) {
+ return pht(
+ '%s removed "%s" as the Import Only path.',
+ $this->renderHandleLink($author_phid),
+ $old);
+ } else if (!strlen($old)) {
+ return pht(
+ '%s set the repository to import only "%s".',
+ $this->renderHandleLink($author_phid),
+ $new);
+ } else {
+ return pht(
+ '%s changed the import path from "%s" to "%s".',
+ $this->renderHandleLink($author_phid),
+ $old,
+ $new);
+ }
+ break;
}
return parent::getTitle();

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 22, 2:58 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6717544
Default Alt Text
D7400.id16683.diff (12 KB)

Event Timeline