forked from qt-creator/qt-creator
CheckoutWizards: Use IVersionControl::createInitialCheckoutCommand
Change-Id: I09dd38f66b9cad46d561493c2e27a833595d8728 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -42,8 +42,6 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
using namespace VcsBase;
|
||||
|
||||
namespace Bazaar {
|
||||
@@ -54,17 +52,11 @@ namespace Internal {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
|
||||
BaseCheckoutWizard(path, parent)
|
||||
BaseCheckoutWizard(Constants::VCS_ID_BAZAAR, parent)
|
||||
{
|
||||
setTitle(tr("Cloning"));
|
||||
setStartedStatus(tr("Cloning started..."));
|
||||
|
||||
const Core::IVersionControl *vc = BazaarPlugin::instance()->versionControl();
|
||||
if (!vc->isConfigured()) {
|
||||
auto configPage = new VcsConfigurationPage;
|
||||
configPage->setVersionControl(vc);
|
||||
addPage(configPage);
|
||||
}
|
||||
auto page = new CloneWizardPage;
|
||||
page->setPath(path.toString());
|
||||
addPage(page);
|
||||
@@ -75,7 +67,6 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
||||
const CloneWizardPage *cwp = find<CloneWizardPage>();
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
|
||||
const VcsBaseClientSettings &settings = BazaarPlugin::instance()->client()->settings();
|
||||
*checkoutDir = Utils::FileName::fromString(cwp->path() + QLatin1Char('/') + cwp->directory());
|
||||
|
||||
const CloneOptionsPanel *panel = cwp->cloneOptionsPanel();
|
||||
@@ -96,14 +87,9 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
||||
extraOptions += QLatin1String("--no-tree");
|
||||
if (!panel->revision().isEmpty())
|
||||
extraOptions << QLatin1String("-r") << panel->revision();
|
||||
const BazaarClient *client = BazaarPlugin::instance()->client();
|
||||
QStringList args;
|
||||
args << client->vcsCommandString(BazaarClient::CloneCommand)
|
||||
<< extraOptions << cwp->repository() << cwp->directory();
|
||||
|
||||
auto command = new VcsCommand(cwp->path(), client->processEnvironment());
|
||||
command->addJob(settings.binaryPath(), args, -1);
|
||||
return command;
|
||||
return createCommandImpl(cwp->repository(), Utils::FileName::fromString(cwp->path()),
|
||||
cwp->directory(), extraOptions);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -49,14 +49,8 @@ namespace Internal {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CheckoutWizard::CheckoutWizard(const Utils::FileName &path, QWidget *parent) :
|
||||
BaseCheckoutWizard(path, parent)
|
||||
BaseCheckoutWizard(Constants::VCS_ID_CVS, parent)
|
||||
{
|
||||
const Core::IVersionControl *vc = CvsPlugin::instance()->versionControl();
|
||||
if (!vc->isConfigured()) {
|
||||
auto configPage = new VcsConfigurationPage;
|
||||
configPage->setVersionControl(vc);
|
||||
addPage(configPage);
|
||||
}
|
||||
auto cwp = new CheckoutWizardPage;
|
||||
cwp->setPath(path.toString());
|
||||
addPage(cwp);
|
||||
@@ -69,22 +63,14 @@ VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir)
|
||||
const CheckoutWizardPage *cwp = find<CheckoutWizardPage>();
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
|
||||
const CvsSettings settings = CvsPlugin::instance()->client()->settings();
|
||||
const Utils::FileName binary = settings.binaryPath();
|
||||
QStringList args;
|
||||
*checkoutDir = Utils::FileName::fromString(cwp->path() + QLatin1Char('/') + cwp->repository());
|
||||
|
||||
// cwp->repository() contains the CVS module to check out only.
|
||||
// The CVSROOT (== actual repository) for that module is part of the CVS settings.
|
||||
// The checkout will always go into a new subfolder named after the CVS module.
|
||||
|
||||
const QString repository = cwp->repository();
|
||||
args << QLatin1String("checkout") << repository;
|
||||
const QString workingDirectory = cwp->path();
|
||||
*checkoutDir = Utils::FileName::fromString(workingDirectory + QLatin1Char('/') + repository);
|
||||
|
||||
auto command = new VcsCommand(workingDirectory, QProcessEnvironment::systemEnvironment());
|
||||
command->addJob(binary, settings.addOptions(args), -1);
|
||||
return command;
|
||||
return createCommandImpl(cwp->repository(), Utils::FileName::fromString(cwp->path()),
|
||||
cwp->repository(), QStringList());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -48,17 +48,11 @@ namespace Internal {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
|
||||
BaseCheckoutWizard(path, parent)
|
||||
BaseCheckoutWizard(Constants::VCS_ID_GIT, parent)
|
||||
{
|
||||
setTitle(tr("Cloning"));
|
||||
setStartedStatus(tr("Cloning started..."));
|
||||
|
||||
const Internal::GitVersionControl *vc = Internal::GitPlugin::instance()->gitVersionControl();
|
||||
if (!vc->isConfigured()) {
|
||||
auto configPage = new VcsConfigurationPage;
|
||||
configPage->setVersionControl(vc);
|
||||
addPage(configPage);
|
||||
}
|
||||
auto cwp = new CloneWizardPage;
|
||||
cwp->setPath(path.toString());
|
||||
addPage(cwp);
|
||||
@@ -69,7 +63,22 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
||||
// Collect parameters for the clone command.
|
||||
const CloneWizardPage *cwp = find<CloneWizardPage>();
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
return cwp->createCheckoutJob(checkoutDir);
|
||||
|
||||
const QString baseDirectory = cwp->path();
|
||||
const QString subDirectory = cwp->directory();
|
||||
|
||||
*checkoutDir = Utils::FileName::fromString(baseDirectory + QLatin1Char('/') + subDirectory);
|
||||
|
||||
const QString checkoutBranch = cwp->branch();
|
||||
|
||||
QStringList args;
|
||||
if (!checkoutBranch.isEmpty())
|
||||
args << QLatin1String("--branch") << checkoutBranch;
|
||||
if (cwp->isRecursive())
|
||||
args << QLatin1String("--recursive");
|
||||
|
||||
return createCommandImpl(cwp->repository(), Utils::FileName::fromString(baseDirectory),
|
||||
subDirectory, args);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -108,27 +108,6 @@ QString CloneWizardPage::directoryFromRepository(const QString &urlIn) const
|
||||
return url;
|
||||
}
|
||||
|
||||
VcsCommand *CloneWizardPage::createCheckoutJob(Utils::FileName *checkoutPath) const
|
||||
{
|
||||
const Internal::GitClient *client = Internal::GitPlugin::instance()->client();
|
||||
const QString workingDirectory = path();
|
||||
const QString checkoutDir = directory();
|
||||
*checkoutPath = Utils::FileName::fromString(workingDirectory + QLatin1Char('/') + checkoutDir);
|
||||
|
||||
const QString checkoutBranch = branch();
|
||||
|
||||
QStringList args(QLatin1String("clone"));
|
||||
if (!checkoutBranch.isEmpty())
|
||||
args << QLatin1String("--branch") << checkoutBranch;
|
||||
if (d->recursiveCheckBox->isChecked())
|
||||
args << QLatin1String("--recursive");
|
||||
args << QLatin1String("--progress") << repository() << checkoutDir;
|
||||
auto command = new VcsCommand(workingDirectory, client->processEnvironment());
|
||||
command->addFlags(VcsCommand::MergeOutputChannels);
|
||||
command->addJob(client->vcsBinary(), args, -1);
|
||||
return command;
|
||||
}
|
||||
|
||||
QStringList CloneWizardPage::branches(const QString &repository, int *current)
|
||||
{
|
||||
// Run git on remote repository if an URL was specified.
|
||||
@@ -142,6 +121,11 @@ QStringList CloneWizardPage::branches(const QString &repository, int *current)
|
||||
return branches;
|
||||
}
|
||||
|
||||
bool CloneWizardPage::isRecursive() const
|
||||
{
|
||||
return d->recursiveCheckBox->isChecked();
|
||||
}
|
||||
|
||||
} // namespace Git
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
@@ -48,11 +48,11 @@ public:
|
||||
explicit CloneWizardPage(QWidget *parent = 0);
|
||||
~CloneWizardPage();
|
||||
|
||||
VcsBase::VcsCommand *createCheckoutJob(Utils::FileName *checkoutPath) const;
|
||||
QStringList branches(const QString &repository, int *current) override;
|
||||
bool isRecursive() const;
|
||||
|
||||
protected:
|
||||
QString directoryFromRepository(const QString &r) const override;
|
||||
QStringList branches(const QString &repository, int *current) override;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
public:
|
||||
|
||||
@@ -50,17 +50,11 @@ namespace Internal {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) :
|
||||
BaseCheckoutWizard(path, parent)
|
||||
BaseCheckoutWizard(Constants::VCS_ID_MERCURIAL, parent)
|
||||
{
|
||||
setTitle(tr("Cloning"));
|
||||
setStartedStatus(tr("Cloning started..."));
|
||||
|
||||
const Core::IVersionControl *vc = MercurialPlugin::instance()->versionControl();
|
||||
if (!vc->isConfigured()) {
|
||||
auto configPage = new VcsConfigurationPage;
|
||||
configPage->setVersionControl(vc);
|
||||
addPage(configPage);
|
||||
}
|
||||
auto page = new CloneWizardPage;
|
||||
page->setPath(path.toString());
|
||||
addPage(page);
|
||||
@@ -71,17 +65,12 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
||||
const CloneWizardPage *cwp = find<CloneWizardPage>();
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
|
||||
const VcsBaseClientSettings &settings = MercurialPlugin::client()->settings();
|
||||
const Utils::FileName path = Utils::FileName::fromString(cwp->path());
|
||||
const QString directory = cwp->directory();
|
||||
|
||||
QString path = cwp->path();
|
||||
QString directory = cwp->directory();
|
||||
*checkoutDir = Utils::FileName::fromString(path.toString() + QLatin1Char('/') + directory);
|
||||
|
||||
QStringList args;
|
||||
args << QLatin1String("clone") << cwp->repository() << directory;
|
||||
*checkoutDir = Utils::FileName::fromString(path + QLatin1Char('/') + directory);
|
||||
auto command = new VcsCommand(path, QProcessEnvironment::systemEnvironment());
|
||||
command->addJob(settings.binaryPath(), args, -1);
|
||||
return command;
|
||||
return createCommandImpl(cwp->repository(), path, directory, QStringList());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -51,14 +51,8 @@ namespace Internal {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CheckoutWizard::CheckoutWizard(const FileName &path, QWidget *parent) :
|
||||
BaseCheckoutWizard(path, parent)
|
||||
BaseCheckoutWizard(VcsBase::Constants::VCS_ID_SUBVERSION, parent)
|
||||
{
|
||||
const Core::IVersionControl *vc = SubversionPlugin::instance()->versionControl();
|
||||
if (!vc->isConfigured()) {
|
||||
auto configPage = new VcsConfigurationPage;
|
||||
configPage->setVersionControl(vc);
|
||||
addPage(configPage);
|
||||
}
|
||||
auto cwp = new CheckoutWizardPage;
|
||||
cwp->setPath(path.toString());
|
||||
addPage(cwp);
|
||||
@@ -70,23 +64,16 @@ VcsCommand *CheckoutWizard::createCommand(FileName *checkoutDir)
|
||||
const CheckoutWizardPage *cwp = find<CheckoutWizardPage>();
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
|
||||
SubversionClient *client = SubversionPlugin::instance()->client();
|
||||
const VcsBaseClientSettings &settings = client->settings();
|
||||
const FileName binary = client->vcsBinary();
|
||||
const QString directory = cwp->directory();
|
||||
QStringList args;
|
||||
args << QLatin1String("checkout");
|
||||
args << SubversionClient::addAuthenticationOptions(settings);
|
||||
args << QLatin1String(Constants::NON_INTERACTIVE_OPTION);
|
||||
if (cwp->trustServerCert())
|
||||
args << QLatin1String("--trust-server-cert");
|
||||
args << cwp->repository() << directory;
|
||||
const QString directory = cwp->directory();
|
||||
const QString workingDirectory = cwp->path();
|
||||
|
||||
*checkoutDir = FileName::fromString(workingDirectory + QLatin1Char('/') + directory);
|
||||
|
||||
auto command = new VcsCommand(workingDirectory, QProcessEnvironment::systemEnvironment());
|
||||
command->addJob(binary, args, -1);
|
||||
return command;
|
||||
return createCommandImpl(cwp->repository(), Utils::FileName::fromString(workingDirectory),
|
||||
directory, args);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#include "basecheckoutwizard.h"
|
||||
#include "basecheckoutwizardfactory.h"
|
||||
#include "vcscommand.h"
|
||||
#include "wizard/vcsconfigurationpage.h"
|
||||
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/shellcommandpage.h>
|
||||
@@ -46,16 +50,25 @@
|
||||
|
||||
namespace VcsBase {
|
||||
|
||||
BaseCheckoutWizard::BaseCheckoutWizard(const Utils::FileName &path, QWidget *parent) :
|
||||
BaseCheckoutWizard::BaseCheckoutWizard(Core::Id vcsId, QWidget *parent) :
|
||||
Utils::Wizard(parent),
|
||||
m_progressPage(new Utils::ShellCommandPage),
|
||||
m_progressPageId(-1)
|
||||
m_progressPageId(-1),
|
||||
m_vcsId(vcsId)
|
||||
{
|
||||
Q_UNUSED(path);
|
||||
connect(this, &QWizard::currentIdChanged, this, &BaseCheckoutWizard::slotPageChanged);
|
||||
connect(m_progressPage, &Utils::ShellCommandPage::finished,
|
||||
this, &BaseCheckoutWizard::slotTerminated);
|
||||
setOption(QWizard::NoBackButtonOnLastPage);
|
||||
|
||||
const Core::IVersionControl *vc = Core::VcsManager::versionControl(vcsId);
|
||||
QTC_ASSERT(vc, return);
|
||||
|
||||
if (!vc->isConfigured()) {
|
||||
auto configPage = new VcsConfigurationPage;
|
||||
configPage->setVersionControl(vc);
|
||||
addPage(configPage);
|
||||
}
|
||||
}
|
||||
|
||||
void BaseCheckoutWizard::setTitle(const QString &title)
|
||||
@@ -97,6 +110,20 @@ Utils::FileName BaseCheckoutWizard::run()
|
||||
return Utils::FileName();
|
||||
}
|
||||
|
||||
VcsCommand *BaseCheckoutWizard::createCommandImpl(const QString &url,
|
||||
const Utils::FileName &baseDirectory,
|
||||
const QString &localName,
|
||||
const QStringList &extraArgs)
|
||||
{
|
||||
Core::IVersionControl *vc = Core::VcsManager::versionControl(m_vcsId);
|
||||
QTC_ASSERT(vc, return 0);
|
||||
QTC_ASSERT(vc->isConfigured(), return 0);
|
||||
QTC_ASSERT(vc->supportsOperation(Core::IVersionControl::InitialCheckoutOperation), return 0);
|
||||
|
||||
return static_cast<VcsCommand *>(vc->createInitialCheckoutCommand(url, baseDirectory,
|
||||
localName, extraArgs));
|
||||
}
|
||||
|
||||
void BaseCheckoutWizard::reject()
|
||||
{
|
||||
// First click kills, 2nd closes
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "vcsbase_global.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/wizard.h>
|
||||
|
||||
@@ -46,7 +48,7 @@ class VCSBASE_EXPORT BaseCheckoutWizard : public Utils::Wizard
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseCheckoutWizard(const Utils::FileName &path, QWidget *parent = 0);
|
||||
explicit BaseCheckoutWizard(Core::Id vcsId, QWidget *parent = 0);
|
||||
|
||||
void setTitle(const QString &title);
|
||||
void setStartedStatus(const QString &title);
|
||||
@@ -56,6 +58,11 @@ public:
|
||||
protected:
|
||||
virtual VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir) = 0;
|
||||
|
||||
VcsBase::VcsCommand *createCommandImpl(const QString &url,
|
||||
const Utils::FileName &baseDirectory,
|
||||
const QString &localName,
|
||||
const QStringList &extraArgs);
|
||||
|
||||
private slots:
|
||||
void slotPageChanged(int id);
|
||||
void slotTerminated(bool success);
|
||||
@@ -63,8 +70,9 @@ private slots:
|
||||
|
||||
private:
|
||||
Utils::ShellCommandPage *m_progressPage;
|
||||
int m_progressPageId;
|
||||
Utils::FileName m_checkoutDir;
|
||||
int m_progressPageId;
|
||||
Core::Id m_vcsId;
|
||||
};
|
||||
|
||||
} // namespace VcsBase
|
||||
|
||||
Reference in New Issue
Block a user