forked from qt-creator/qt-creator
VCS: Replace AbstractCheckoutJob with Command
Command now provides the same functionality. Deduplicate code. Change-Id: I789f021050471281870b6ef6a81a94e66fbdf0c7 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
27e53f746f
commit
aefd61478a
@@ -33,7 +33,6 @@
|
||||
#include "gitplugin.h"
|
||||
#include "gitversioncontrol.h"
|
||||
|
||||
#include <vcsbase/checkoutjobs.h>
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
#include <vcsbase/vcsconfigurationpage.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -76,8 +75,8 @@ QList<QWizardPage*> CloneWizard::createParameterPages(const QString &path)
|
||||
return rc;
|
||||
}
|
||||
|
||||
QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath)
|
||||
VcsBase::Command *CloneWizard::createCommand(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath)
|
||||
{
|
||||
// Collect parameters for the clone command.
|
||||
const CloneWizardPage *cwp = 0;
|
||||
@@ -87,7 +86,7 @@ QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<
|
||||
break;
|
||||
}
|
||||
|
||||
QTC_ASSERT(cwp, return QSharedPointer<VcsBase::AbstractCheckoutJob>());
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
return cwp->createCheckoutJob(checkoutPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ public:
|
||||
protected:
|
||||
// BaseCheckoutWizard
|
||||
QList<QWizardPage*> createParameterPages(const QString &path);
|
||||
QSharedPointer<VcsBase::AbstractCheckoutJob> createJob(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath);
|
||||
VcsBase::Command *createCommand(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "gitplugin.h"
|
||||
#include "gitclient.h"
|
||||
|
||||
#include <vcsbase/checkoutjobs.h>
|
||||
#include <vcsbase/command.h>
|
||||
|
||||
namespace Git {
|
||||
|
||||
@@ -112,25 +112,24 @@ QString CloneWizardPage::directoryFromRepository(const QString &urlIn) const
|
||||
return url;
|
||||
}
|
||||
|
||||
QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizardPage::createCheckoutJob(QString *checkoutPath) const
|
||||
VcsBase::Command *CloneWizardPage::createCheckoutJob(QString *checkoutPath) const
|
||||
{
|
||||
const Internal::GitClient *client = Internal::GitPlugin::instance()->gitClient();
|
||||
const QString workingDirectory = path();
|
||||
const QString checkoutDir = directory();
|
||||
*checkoutPath = workingDirectory + QLatin1Char('/') + checkoutDir;
|
||||
|
||||
const QString binary = client->gitBinaryPath();
|
||||
|
||||
VcsBase::ProcessCheckoutJob *job = new VcsBase::ProcessCheckoutJob;
|
||||
const QProcessEnvironment env = client->processEnvironment();
|
||||
const QString checkoutBranch = branch();
|
||||
|
||||
QStringList args(QLatin1String("clone"));
|
||||
if (!checkoutBranch.isEmpty())
|
||||
args << QLatin1String("--branch") << checkoutBranch;
|
||||
args << repository() << checkoutDir;
|
||||
job->addStep(binary, args, workingDirectory, env);
|
||||
return QSharedPointer<VcsBase::AbstractCheckoutJob>(job);
|
||||
VcsBase::Command *command = new VcsBase::Command(client->gitBinaryPath(), workingDirectory,
|
||||
client->processEnvironment());
|
||||
command->addFlags(VcsBase::VcsBasePlugin::MergeOutputChannels);
|
||||
command->addJob(args, -1);
|
||||
return command;
|
||||
}
|
||||
|
||||
QStringList CloneWizardPage::branches(const QString &repository, int *current)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace VcsBase {
|
||||
class AbstractCheckoutJob;
|
||||
class Command;
|
||||
}
|
||||
|
||||
namespace Git {
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
explicit CloneWizardPage(QWidget *parent = 0);
|
||||
~CloneWizardPage();
|
||||
|
||||
QSharedPointer<VcsBase::AbstractCheckoutJob> createCheckoutJob(QString *checkoutPath) const;
|
||||
VcsBase::Command *createCheckoutJob(QString *checkoutPath) const;
|
||||
|
||||
protected:
|
||||
QString directoryFromRepository(const QString &r) const;
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "gitsettings.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <vcsbase/command.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
@@ -52,8 +51,9 @@ namespace Core {
|
||||
}
|
||||
|
||||
namespace VcsBase {
|
||||
class VcsBaseEditorWidget;
|
||||
class Command;
|
||||
class SubmitFileModel;
|
||||
class VcsBaseEditorWidget;
|
||||
}
|
||||
|
||||
namespace Utils {
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "../gitplugin.h"
|
||||
|
||||
#include <coreplugin/iversioncontrol.h>
|
||||
#include <vcsbase/checkoutjobs.h>
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
#include <vcsbase/vcsconfigurationpage.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -109,11 +108,11 @@ QList<QWizardPage*> GitoriousCloneWizard::createParameterPages(const QString &pa
|
||||
return rc;
|
||||
}
|
||||
|
||||
QSharedPointer<VcsBase::AbstractCheckoutJob> GitoriousCloneWizard::createJob(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath)
|
||||
VcsBase::Command *GitoriousCloneWizard::createCommand(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath)
|
||||
{
|
||||
const Git::CloneWizardPage *cwp = qobject_cast<const Git::CloneWizardPage *>(parameterPages.back());
|
||||
QTC_ASSERT(cwp, return QSharedPointer<VcsBase::AbstractCheckoutJob>());
|
||||
QTC_ASSERT(cwp, return 0);
|
||||
return cwp->createCheckoutJob(checkoutPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
protected:
|
||||
// BaseCheckoutWizard
|
||||
QList<QWizardPage*> createParameterPages(const QString &path);
|
||||
QSharedPointer<VcsBase::AbstractCheckoutJob> createJob(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath);
|
||||
VcsBase::Command *createCommand(const QList<QWizardPage*> ¶meterPages,
|
||||
QString *checkoutPath);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user