Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F89819
D7475.diff
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
19 KB
Referenced Files
None
Subscribers
None
D7475.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -527,6 +527,7 @@
'DiffusionRepositoryEditPolicyController' => 'applications/diffusion/controller/DiffusionRepositoryEditPolicyController.php',
'DiffusionRepositoryEditSubversionController' => 'applications/diffusion/controller/DiffusionRepositoryEditSubversionController.php',
'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php',
+ 'DiffusionRepositoryNewController' => 'applications/diffusion/controller/DiffusionRepositoryNewController.php',
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
'DiffusionRepositoryRef' => 'applications/diffusion/data/DiffusionRepositoryRef.php',
'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php',
@@ -2727,6 +2728,7 @@
0 => 'DiffusionController',
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
),
+ 'DiffusionRepositoryNewController' => 'DiffusionController',
'DiffusionSSHGitReceivePackWorkflow' => 'DiffusionSSHGitWorkflow',
'DiffusionSSHGitUploadPackWorkflow' => 'DiffusionSSHGitWorkflow',
'DiffusionSSHGitWorkflow' => 'DiffusionSSHWorkflow',
diff --git a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
--- a/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
+++ b/src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
@@ -43,7 +43,9 @@
'/diffusion/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?'
=> 'DiffusionRepositoryListController',
- 'create/' => 'DiffusionRepositoryCreateController',
+ 'new/' => 'DiffusionRepositoryNewController',
+ '(?P<edit>create)/' => 'DiffusionRepositoryCreateController',
+ '(?P<edit>import)/' => 'DiffusionRepositoryCreateController',
'(?P<callsign>[A-Z]+)/' => array(
'' => 'DiffusionRepositoryController',
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryCreateController.php
@@ -8,34 +8,41 @@
public function willProcessRequest(array $data) {
parent::willProcessRequest($data);
- $this->edit = idx($data, 'edit');
+ $this->edit = $data['edit'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
- // NOTE: We can end up here via either "Create Repository" or via
- // "Edit Remote". In the latter case, we show only a few of the pages.
+ // NOTE: We can end up here via either "Create Repository", or via
+ // "Import Repository", or via "Edit Remote". In the latter case, we show
+ // only a few of the pages.
$repository = null;
- if ($this->edit) {
- $repository = $this->getDiffusionRequest()->getRepository();
+ switch ($this->edit) {
+ case 'remote':
+ $repository = $this->getDiffusionRequest()->getRepository();
- // Make sure we have CAN_EDIT.
- PhabricatorPolicyFilter::requireCapability(
- $viewer,
- $repository,
- PhabricatorPolicyCapability::CAN_EDIT);
+ // Make sure we have CAN_EDIT.
+ PhabricatorPolicyFilter::requireCapability(
+ $viewer,
+ $repository,
+ PhabricatorPolicyCapability::CAN_EDIT);
- $this->setRepository($repository);
+ $this->setRepository($repository);
- $cancel_uri = $this->getRepositoryControllerURI($repository, 'edit/');
- } else {
- $this->requireApplicationCapability(
- DiffusionCapabilityCreateRepositories::CAPABILITY);
+ $cancel_uri = $this->getRepositoryControllerURI($repository, 'edit/');
+ break;
+ case 'import':
+ case 'create':
+ $this->requireApplicationCapability(
+ DiffusionCapabilityCreateRepositories::CAPABILITY);
- $cancel_uri = $this->getApplicationURI();
+ $cancel_uri = $this->getApplicationURI('new/');
+ break;
+ default:
+ throw new Exception("Invalid edit operation!");
}
$form = id(new PHUIPagedFormView())
@@ -49,7 +56,14 @@
->addPage('remote-uri', $this->buildRemoteURIPage())
->addPage('auth', $this->buildAuthPage());
break;
- default:
+ case 'create':
+ $title = pht('Create Repository');
+ $form
+ ->addPage('vcs', $this->buildVCSPage())
+ ->addPage('name', $this->buildNamePage())
+ ->addPage('done', $this->buildDonePage());
+ break;
+ case 'import':
$title = pht('Import Repository');
$form
->addPage('vcs', $this->buildVCSPage())
@@ -63,7 +77,10 @@
if ($request->isFormPost()) {
$form->readFromRequest($request);
if ($form->isComplete()) {
- $is_create = ($this->edit === null);
+
+ $is_create = ($this->edit === 'import' || $this->edit === 'create');
+ $is_auth = ($this->edit == 'import' || $this->edit == 'remote');
+ $is_init = ($this->edit == 'create');
if ($is_create) {
$repository = PhabricatorRepository::initializeNewRepository(
@@ -82,6 +99,7 @@
$type_ssh_keyfile = PhabricatorRepositoryTransaction::TYPE_SSH_KEYFILE;
$type_http_login = PhabricatorRepositoryTransaction::TYPE_HTTP_LOGIN;
$type_http_pass = PhabricatorRepositoryTransaction::TYPE_HTTP_PASS;
+ $type_hosting = PhabricatorRepositoryTransaction::TYPE_HOSTING;
$xactions = array();
@@ -127,35 +145,44 @@
->setNewValue($default_local_path);
}
- $xactions[] = id(clone $template)
- ->setTransactionType($type_remote_uri)
- ->setNewValue(
- $form->getPage('remote-uri')->getControl('remoteURI')->getValue());
+ if ($is_init) {
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_hosting)
+ ->setNewValue(true);
+ }
- $xactions[] = id(clone $template)
- ->setTransactionType($type_ssh_login)
- ->setNewValue(
- $form->getPage('auth')->getControl('ssh-login')->getValue());
+ if ($is_auth) {
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_remote_uri)
+ ->setNewValue(
+ $form->getPage('remote-uri')->getControl('remoteURI')
+ ->getValue());
- $xactions[] = id(clone $template)
- ->setTransactionType($type_ssh_key)
- ->setNewValue(
- $form->getPage('auth')->getControl('ssh-key')->getValue());
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_ssh_login)
+ ->setNewValue(
+ $form->getPage('auth')->getControl('ssh-login')->getValue());
- $xactions[] = id(clone $template)
- ->setTransactionType($type_ssh_keyfile)
- ->setNewValue(
- $form->getPage('auth')->getControl('ssh-keyfile')->getValue());
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_ssh_key)
+ ->setNewValue(
+ $form->getPage('auth')->getControl('ssh-key')->getValue());
+
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_ssh_keyfile)
+ ->setNewValue(
+ $form->getPage('auth')->getControl('ssh-keyfile')->getValue());
- $xactions[] = id(clone $template)
- ->setTransactionType($type_http_login)
- ->setNewValue(
- $form->getPage('auth')->getControl('http-login')->getValue());
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_http_login)
+ ->setNewValue(
+ $form->getPage('auth')->getControl('http-login')->getValue());
- $xactions[] = id(clone $template)
- ->setTransactionType($type_http_pass)
- ->setNewValue(
- $form->getPage('auth')->getControl('http-pass')->getValue());
+ $xactions[] = id(clone $template)
+ ->setTransactionType($type_http_pass)
+ ->setNewValue(
+ $form->getPage('auth')->getControl('http-pass')->getValue());
+ }
id(new PhabricatorRepositoryEditor())
->setContinueOnNoEffect(true)
@@ -202,46 +229,63 @@
private function buildVCSPage() {
+
+ $is_import = ($this->edit == 'import');
+
+ if ($is_import) {
+ $git_str = pht(
+ 'Import a Git repository (for example, a repository hosted '.
+ 'on GitHub).');
+ $hg_str = pht(
+ 'Import a Mercurial repository (for example, a repository '.
+ 'hosted on Bitbucket).');
+ $svn_str = pht('Import a Subversion repository.');
+ } else {
+ $git_str = pht('Create a new, empty Git repository.');
+ $hg_str = pht('Create a new, empty Mercurial repository.');
+ $svn_str = pht('Create a new, empty Subversion repository.');
+ }
+
+ $control = id(new AphrontFormRadioButtonControl())
+ ->setName('vcs')
+ ->setLabel(pht('Type'))
+ ->addButton(
+ PhabricatorRepositoryType::REPOSITORY_TYPE_GIT,
+ pht('Git'),
+ $git_str)
+ ->addButton(
+ PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL,
+ pht('Mercurial'),
+ $hg_str)
+ ->addButton(
+ PhabricatorRepositoryType::REPOSITORY_TYPE_SVN,
+ pht('Subversion'),
+ $svn_str);
+
+ if ($is_import) {
+ $control->addButton(
+ PhabricatorRepositoryType::REPOSITORY_TYPE_PERFORCE,
+ pht('Perforce'),
+ pht(
+ 'Perforce is not directly supported, but you can import '.
+ 'a Perforce repository as a Git repository using %s.',
+ phutil_tag(
+ 'a',
+ array(
+ 'href' =>
+ 'http://www.perforce.com/product/components/git-fusion',
+ 'target' => '_blank',
+ ),
+ pht('Perforce Git Fusion'))),
+ 'disabled',
+ $disabled = true);
+ }
+
return id(new PHUIFormPageView())
->setPageName(pht('Repository Type'))
->setUser($this->getRequest()->getUser())
->setValidateFormPageCallback(array($this, 'validateVCSPage'))
- ->addControl(
- id(new AphrontFormRadioButtonControl())
- ->setName('vcs')
- ->setLabel(pht('Type'))
- ->addButton(
- PhabricatorRepositoryType::REPOSITORY_TYPE_GIT,
- pht('Git'),
- pht(
- 'Import a Git repository (for example, a repository hosted '.
- 'on GitHub).'))
- ->addButton(
- PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL,
- pht('Mercurial'),
- pht(
- 'Import a Mercurial repository (for example, a repository '.
- 'hosted on Bitbucket).'))
- ->addButton(
- PhabricatorRepositoryType::REPOSITORY_TYPE_SVN,
- pht('Subversion'),
- pht('Import a Subversion repository.'))
- ->addButton(
- PhabricatorRepositoryType::REPOSITORY_TYPE_PERFORCE,
- pht('Perforce'),
- pht(
- 'Perforce is not directly supported, but you can import '.
- 'a Perforce repository as a Git repository using %s.',
- phutil_tag(
- 'a',
- array(
- 'href' =>
- 'http://www.perforce.com/product/components/git-fusion',
- 'target' => '_blank',
- ),
- pht('Perforce Git Fusion'))),
- 'disabled',
- $disabled = true));
+ ->addControl($control);
}
public function validateVCSPage(PHUIFormPageView $page) {
@@ -664,6 +708,32 @@
private function buildDonePage() {
+
+ $is_create = ($this->edit == 'create');
+ if ($is_create) {
+ $now_label = pht('Create Repository Now');
+ $now_caption = pht(
+ 'Create the repository right away. This will create the repository '.
+ 'using default settings.');
+
+ $wait_label = pht('Configure More Options First');
+ $wait_caption = pht(
+ 'Configure more options before creating the repository. '.
+ 'This will let you fine-tune settings. You can create the repository '.
+ 'whenever you are ready.');
+ } else {
+ $now_label = pht('Start Import Now');
+ $now_caption = pht(
+ 'Start importing the repository right away. This will import '.
+ 'the entire repository using default settings.');
+
+ $wait_label = pht('Configure More Options First');
+ $wait_caption = pht(
+ 'Configure more options before beginning the repository '.
+ 'import. This will let you fine-tune settings. You can '.
+ 'start the import whenever you are ready.');
+ }
+
return id(new PHUIFormPageView())
->setPageName(pht('Repository Ready!'))
->setValidateFormPageCallback(array($this, 'validateDonePage'))
@@ -674,17 +744,12 @@
->setLabel(pht('Start Now'))
->addButton(
'start',
- pht('Start Import Now'),
- pht(
- 'Start importing the repository right away. This will import '.
- 'the entire repository using default settings.'))
+ $now_label,
+ $now_caption)
->addButton(
'wait',
- pht('Configure More Options First'),
- pht(
- 'Configure more options before beginning the repository '.
- 'import. This will let you fine-tune settings. You can '.
- 'start the import whenever you are ready.')));
+ $wait_label,
+ $wait_caption));
}
public function validateDonePage(PHUIFormPageView $page) {
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
@@ -52,9 +52,12 @@
$policy_properties =
$this->buildPolicyProperties($repository, $policy_actions);
- $remote_properties = $this->buildRemoteProperties(
- $repository,
- $this->buildRemoteActions($repository));
+ $remote_properties = null;
+ if (!$repository->isHosted()) {
+ $remote_properties = $this->buildRemoteProperties(
+ $repository,
+ $this->buildRemoteActions($repository));
+ }
$encoding_actions = $this->buildEncodingActions($repository);
$encoding_properties =
@@ -115,8 +118,11 @@
->setHeader($header)
->addPropertyList($basic_properties)
->addPropertyList($policy_properties)
- ->addPropertyList($hosting_properties)
- ->addPropertyList($remote_properties);
+ ->addPropertyList($hosting_properties);
+
+ if ($remote_properties) {
+ $obj_box->addPropertyList($remote_properties);
+ }
if ($local_properties) {
$obj_box->addPropertyList($local_properties);
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryListController.php b/src/applications/diffusion/controller/DiffusionRepositoryListController.php
--- a/src/applications/diffusion/controller/DiffusionRepositoryListController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryListController.php
@@ -107,8 +107,8 @@
$crumbs->addAction(
id(new PHUIListItemView())
- ->setName(pht('Import Repository'))
- ->setHref($this->getApplicationURI('/create/'))
+ ->setName(pht('New Repository'))
+ ->setHref($this->getApplicationURI('new/'))
->setDisabled(!$can_create)
->setIcon('create'));
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryNewController.php b/src/applications/diffusion/controller/DiffusionRepositoryNewController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/controller/DiffusionRepositoryNewController.php
@@ -0,0 +1,81 @@
+<?php
+
+final class DiffusionRepositoryNewController
+ extends DiffusionController {
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $this->requireApplicationCapability(
+ DiffusionCapabilityCreateRepositories::CAPABILITY);
+
+ if ($request->isFormPost()) {
+ if ($request->getStr('type')) {
+ switch ($request->getStr('type')) {
+ case 'create':
+ $uri = $this->getApplicationURI('create/');
+ break;
+ case 'import':
+ default:
+ $uri = $this->getApplicationURI('import/');
+ break;
+ }
+
+ return id(new AphrontRedirectResponse())->setURI($uri);
+ }
+ }
+
+ $form = id(new AphrontFormView())
+ ->setUser($viewer)
+ ->appendChild(
+ id(new AphrontFormRadioButtonControl())
+ ->setName('type')
+ ->addButton(
+ 'create',
+ pht('Create a New Hosted Repository'),
+ array(
+ pht(
+ 'Create a new, empty repository which Phabricator will host.'),
+ phutil_tag('br'),
+ pht(
+ '%s: This feature is very new and barely works. Use it '.
+ 'at your own risk! By choosing this option, you accept great '.
+ 'mortal peril.',
+ phutil_tag('strong', array(), pht('BEWARE'))),
+ ))
+ ->addButton(
+ 'import',
+ pht('Import an Existing External Repository'),
+ pht(
+ 'Import a repository hosted somewhere else, like GitHub, '.
+ 'Bitbucket, or your organization\'s existing servers. '.
+ 'Phabricator will read changes from the repository but will '.
+ 'not host or manage it. The authoritative master version of '.
+ 'the repository will stay where it is now.')))
+ ->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->setValue(pht('Continue'))
+ ->addCancelButton($this->getApplicationURI()));
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addCrumb(
+ id(new PhabricatorCrumbView())
+ ->setName(pht('New Repository')));
+
+ $form_box = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Create or Import Repository'))
+ ->setForm($form);
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $form_box,
+ ),
+ array(
+ 'title' => pht('New Repository'),
+ 'device' => true,
+ ));
+ }
+
+}
diff --git a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
--- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
+++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php
@@ -26,7 +26,7 @@
$is_hg = false;
$is_git = false;
- $is_svn = true;
+ $is_svn = false;
$vcs = $repository->getVersionControlSystem();
$callsign = $repository->getCallsign();
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/f4/vi/jaf32yzcxmpbmpxg
Default Alt Text
D7475.diff (19 KB)
Attached To
Mode
D7475: When creating a repository in Diffusion, prompt for "Create" or "Import" first
Attached
Detach File
Event Timeline
Log In to Comment