Page MenuHomePhabricator

D8375.diff
No OneTemporary

D8375.diff

Index: src/applications/diffusion/controller/DiffusionRepositoryController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionRepositoryController.php
+++ src/applications/diffusion/controller/DiffusionRepositoryController.php
@@ -560,10 +560,16 @@
$uri);
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
- $command = csprintf(
- 'svn checkout %R %R',
- $uri,
- $repository->getCloneName());
+ if ($repository->isHosted()) {
+ $command = csprintf(
+ 'svn checkout %R %R',
+ $uri,
+ $repository->getCloneName());
+ } else {
+ $command = csprintf(
+ 'svn checkout %R',
+ $uri);
+ }
break;
}
Index: src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php
+++ src/applications/diffusion/controller/DiffusionRepositoryEditBasicController.php
@@ -36,7 +36,10 @@
$v_name = $request->getStr('name');
$v_desc = $request->getStr('description');
$v_projects = $request->getArr('projectPHIDs');
- $v_clone_name = $request->getStr('cloneName');
+
+ if ($repository->isHosted()) {
+ $v_clone_name = $request->getStr('cloneName');
+ }
if (!strlen($v_name)) {
$e_name = pht('Required');
@@ -99,16 +102,22 @@
->setName('name')
->setLabel(pht('Name'))
->setValue($v_name)
- ->setError($e_name))
- ->appendChild(
- id(new AphrontFormTextControl())
- ->setName('cloneName')
- ->setLabel(pht('Clone/Checkout As'))
- ->setValue($v_clone_name)
- ->setCaption(
- pht(
- 'Optional directory name to use when cloning or checking out '.
- 'this repository.')))
+ ->setError($e_name));
+
+ if ($repository->isHosted()) {
+ $form
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('cloneName')
+ ->setLabel(pht('Clone/Checkout As'))
+ ->setValue($v_clone_name)
+ ->setCaption(
+ pht(
+ 'Optional directory name to use when cloning or checking out '.
+ 'this repository.')));
+ }
+
+ $form
->appendChild(
id(new PhabricatorRemarkupControl())
->setName('description')
Index: src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
+++ src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
@@ -256,11 +256,13 @@
$clone_name = $repository->getDetail('clone-name');
- $view->addProperty(
- pht('Clone/Checkout As'),
- $clone_name
- ? $clone_name.'/'
- : phutil_tag('em', array(), $repository->getCloneName().'/'));
+ if ($repository->isHosted()) {
+ $view->addProperty(
+ pht('Clone/Checkout As'),
+ $clone_name
+ ? $clone_name.'/'
+ : phutil_tag('em', array(), $repository->getCloneName().'/'));
+ }
$project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$repository->getPHID(),
Index: src/applications/repository/storage/PhabricatorRepository.php
===================================================================
--- src/applications/repository/storage/PhabricatorRepository.php
+++ src/applications/repository/storage/PhabricatorRepository.php
@@ -789,7 +789,28 @@
*/
public function getCloneURIObject() {
if (!$this->isHosted()) {
- return $this->getRemoteURIObject();
+ if ($this->isSVN()) {
+ // Make sure we pick up the "Import Only" path for Subversion, so
+ // the user clones the repository starting at the correct path, not
+ // from the root.
+ $base_uri = $this->getSubversionBaseURI();
+ $base_uri = new PhutilURI($base_uri);
+ $path = $base_uri->getPath();
+ if (!$path) {
+ $path = '/';
+ }
+
+ // If the trailing "@" is not required to escape the URI, strip it for
+ // readability.
+ if (!preg_match('/@.*@/', $path)) {
+ $path = rtrim($path, '@');
+ }
+
+ $base_uri->setPath($path);
+ return $base_uri;
+ } else {
+ return $this->getRemoteURIObject();
+ }
}
// Choose the best URI: pick a read/write URI over a URI which is not
Index: src/applications/repository/storage/__tests__/PhabricatorRepositoryURITestCase.php
===================================================================
--- src/applications/repository/storage/__tests__/PhabricatorRepositoryURITestCase.php
+++ src/applications/repository/storage/__tests__/PhabricatorRepositoryURITestCase.php
@@ -90,6 +90,19 @@
$this->assertEqual('git@example.com:path.git',
$repo->getRemoteURIEnvelope()->openEnvelope());
+ // Test SVN "Import Only" paths.
+
+ $repo->setDetail('remote-uri', 'http://example.com/');
+ $repo->setVersionControlSystem($svn);
+ $repo->setDetail('svn-subpath', 'projects/example/');
+
+ $this->assertEqual('http://example.com/', $repo->getRemoteURI());
+ $this->assertEqual(
+ 'http://example.com/projects/example/',
+ $repo->getPublicCloneURI());
+ $this->assertEqual('http://example.com/',
+ $repo->getRemoteURIEnvelope()->openEnvelope());
+
}
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 10:07 PM (2 d, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6751817
Default Alt Text
D8375.diff (5 KB)

Event Timeline