Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15467865
D7409.id16734.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D7409.id16734.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -510,6 +510,7 @@
'DiffusionRepositoryEditBranchesController' => 'applications/diffusion/controller/DiffusionRepositoryEditBranchesController.php',
'DiffusionRepositoryEditController' => 'applications/diffusion/controller/DiffusionRepositoryEditController.php',
'DiffusionRepositoryEditEncodingController' => 'applications/diffusion/controller/DiffusionRepositoryEditEncodingController.php',
+ 'DiffusionRepositoryEditLocalController' => 'applications/diffusion/controller/DiffusionRepositoryEditLocalController.php',
'DiffusionRepositoryEditMainController' => 'applications/diffusion/controller/DiffusionRepositoryEditMainController.php',
'DiffusionRepositoryEditPolicyController' => 'applications/diffusion/controller/DiffusionRepositoryEditPolicyController.php',
'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php',
@@ -2686,6 +2687,7 @@
'DiffusionRepositoryEditBranchesController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditController' => 'DiffusionController',
'DiffusionRepositoryEditEncodingController' => 'DiffusionRepositoryEditController',
+ 'DiffusionRepositoryEditLocalController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditMainController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditPolicyController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditSubversionController' => 'DiffusionRepositoryEditController',
Index: src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
===================================================================
--- src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
+++ src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
@@ -73,6 +73,7 @@
'subversion/' => 'DiffusionRepositoryEditSubversionController',
'actions/' => 'DiffusionRepositoryEditActionsController',
'(?P<edit>remote)/' => 'DiffusionRepositoryCreateController',
+ 'local/' => 'DiffusionRepositoryEditLocalController',
),
),
'inline/' => array(
Index: src/applications/diffusion/controller/DiffusionRepositoryEditLocalController.php
===================================================================
--- /dev/null
+++ src/applications/diffusion/controller/DiffusionRepositoryEditLocalController.php
@@ -0,0 +1,111 @@
+<?php
+
+final class DiffusionRepositoryEditLocalController
+ extends DiffusionRepositoryEditController {
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $user = $request->getUser();
+ $drequest = $this->diffusionRequest;
+ $repository = $drequest->getRepository();
+
+ $repository = id(new PhabricatorRepositoryQuery())
+ ->setViewer($user)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->withIDs(array($repository->getID()))
+ ->executeOne();
+
+ if (!$repository) {
+ return new Aphront404Response();
+ }
+
+ $edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
+
+ $v_local = $repository->getHumanReadableDetail('local-path');
+ $e_local = true;
+ $errors = array();
+
+ if ($request->isFormPost()) {
+ $v_local = $request->getStr('local');
+
+ if (!strlen($v_local)) {
+ $e_local = pht('Required');
+ $errors[] = pht('You must specify a local path.');
+ }
+
+ if (!$errors) {
+ $xactions = array();
+ $template = id(new PhabricatorRepositoryTransaction());
+
+ $type_local = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
+
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_local)
+ ->setNewValue($v_local);
+
+ try {
+ id(new PhabricatorRepositoryEditor())
+ ->setContinueOnNoEffect(true)
+ ->setContentSourceFromRequest($request)
+ ->setActor($user)
+ ->applyTransactions($repository, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($edit_uri);
+ } catch (Exception $ex) {
+ $errors[] = $ex->getMessage();
+ }
+ }
+ }
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName(pht('Edit Local')));
+
+ $title = pht('Edit %s', $repository->getName());
+
+ $error_view = null;
+ if ($errors) {
+ $error_view = id(new AphrontErrorView())
+ ->setTitle(pht('Form Errors'))
+ ->setErrors($errors);
+ }
+
+ $form = id(new AphrontFormView())
+ ->setUser($user)
+ ->appendRemarkupInstructions(
+ pht(
+ 'You can adjust the local path for this repository here. This is '.
+ 'an advanced setting and you usually should not change it.'))
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('local')
+ ->setLabel(pht('Local Path'))
+ ->setValue($v_local)
+ ->setError($e_local))
+ ->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->setValue(pht('Save Local'))
+ ->addCancelButton($edit_uri));
+
+ $object_box = id(new PHUIObjectBoxView())
+ ->setHeaderText($title)
+ ->setForm($form)
+ ->setFormError($error_view);
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $object_box,
+ ),
+ array(
+ 'title' => $title,
+ 'device' => true,
+ ));
+ }
+
+}
Index: src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
+++ src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
@@ -19,12 +19,16 @@
$is_hg = false;
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
+ $has_local = true;
$is_git = true;
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
+ // TOOD: This will be true for hosted SVN repositories.
+ $has_local = false;
$is_svn = true;
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
+ $has_local = true;
$is_hg = true;
break;
}
@@ -75,6 +79,13 @@
$this->buildSubversionActions($repository));
}
+ $local_properties = null;
+ if ($has_local) {
+ $local_properties = $this->buildLocalProperties(
+ $repository,
+ $this->buildLocalActions($repository));
+ }
+
$actions_properties = $this->buildActionsProperties(
$repository,
$this->buildActionsActions($repository));
@@ -105,8 +116,13 @@
->setHeader($header)
->addPropertyList($basic_properties)
->addPropertyList($policy_properties)
- ->addPropertyList($remote_properties)
- ->addPropertyList($encoding_properties);
+ ->addPropertyList($remote_properties);
+
+ if ($local_properties) {
+ $obj_box->addPropertyList($local_properties);
+ }
+
+ $obj_box->addPropertyList($encoding_properties);
if ($branches_properties) {
$obj_box->addPropertyList($branches_properties);
@@ -440,9 +456,43 @@
$view->addProperty(
pht('Remote URI'),
- $repository->getDetail('remote-uri'));
+ $repository->getHumanReadableDetail('remote-uri'));
return $view;
}
+ private function buildLocalActions(PhabricatorRepository $repository) {
+ $viewer = $this->getRequest()->getUser();
+
+ $view = id(new PhabricatorActionListView())
+ ->setObjectURI($this->getRequest()->getRequestURI())
+ ->setUser($viewer);
+
+ $edit = id(new PhabricatorActionView())
+ ->setIcon('edit')
+ ->setName(pht('Edit Local'))
+ ->setHref(
+ $this->getRepositoryControllerURI($repository, 'edit/local/'));
+ $view->addAction($edit);
+
+ return $view;
+ }
+
+ private function buildLocalProperties(
+ PhabricatorRepository $repository,
+ PhabricatorActionListView $actions) {
+
+ $viewer = $this->getRequest()->getUser();
+
+ $view = id(new PHUIPropertyListView())
+ ->setUser($viewer)
+ ->setActionList($actions)
+ ->addSectionHeader(pht('Local'));
+
+ $view->addProperty(
+ pht('Local Path'),
+ $repository->getHumanReadableDetail('local-path'));
+
+ return $view;
+ }
}
Index: src/applications/repository/editor/PhabricatorRepositoryEditor.php
===================================================================
--- src/applications/repository/editor/PhabricatorRepositoryEditor.php
+++ src/applications/repository/editor/PhabricatorRepositoryEditor.php
@@ -23,6 +23,7 @@
$types[] = PhabricatorRepositoryTransaction::TYPE_SSH_KEYFILE;
$types[] = PhabricatorRepositoryTransaction::TYPE_HTTP_LOGIN;
$types[] = PhabricatorRepositoryTransaction::TYPE_HTTP_PASS;
+ $types[] = PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH;
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -69,6 +70,8 @@
return $object->getDetail('http-login');
case PhabricatorRepositoryTransaction::TYPE_HTTP_PASS:
return $object->getDetail('http-pass');
+ case PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH:
+ return $object->getDetail('local-path');
}
}
@@ -92,6 +95,7 @@
case PhabricatorRepositoryTransaction::TYPE_SSH_KEYFILE:
case PhabricatorRepositoryTransaction::TYPE_HTTP_LOGIN:
case PhabricatorRepositoryTransaction::TYPE_HTTP_PASS:
+ case PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH:
return $xaction->getNewValue();
case PhabricatorRepositoryTransaction::TYPE_NOTIFY:
case PhabricatorRepositoryTransaction::TYPE_AUTOCLOSE:
@@ -156,6 +160,9 @@
case PhabricatorRepositoryTransaction::TYPE_HTTP_PASS:
$object->setDetail('http-pass', $xaction->getNewValue());
break;
+ case PhabricatorRepositoryTransaction::TYPE_LOCAL_PATH:
+ $object->setDetail('local-path', $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
@@ -20,6 +20,7 @@
const TYPE_SSH_KEYFILE = 'repo:ssh-keyfile';
const TYPE_HTTP_LOGIN = 'repo:http-login';
const TYPE_HTTP_PASS = 'repo:http-pass';
+ const TYPE_LOCAL_PATH = 'repo:local-path';
public function getApplicationName() {
return 'repository';
@@ -231,6 +232,12 @@
return pht(
'%s updated the HTTP password for this repository.',
$this->renderHandleLink($author_phid));
+ case self::TYPE_LOCAL_PATH:
+ return pht(
+ '%s changed the local path from "%s" to "%s".',
+ $this->renderHandleLink($author_phid),
+ $old,
+ $new);
}
return parent::getTitle();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 4, 6:15 PM (1 d, 20 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7721747
Default Alt Text
D7409.id16734.diff (11 KB)
Attached To
Mode
D7409: Move editing "Local Path" to modern UI/controller/etc
Attached
Detach File
Event Timeline
Log In to Comment