forked from qt-creator/qt-creator
VCS[hg, git]: Add support for repository creation.
Add repository creation operation to IVersionControl, implement for hg and git, add convenience slot with prompts to VCSBasePlugin. Add respective menu options and make menus are visible in case no VCS is active. Change project wizards extension page to list VCS that are capable of repository creation in a QComboBox in case the directory is not managed by another VCS (in which case it lists that one for operation 'add'). On that occasion, polish the Project selection to use a QComboBox as well and add some smartness to find the most suitable project to add via path matching.
This commit is contained in:
@@ -446,6 +446,22 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Initialize repository
|
||||
bool GitClient::synchronousInit(const QString &workingDirectory)
|
||||
{
|
||||
if (Git::Constants::debug)
|
||||
qDebug() << Q_FUNC_INFO << workingDirectory;
|
||||
QByteArray outputText;
|
||||
QByteArray errorText;
|
||||
const QStringList arguments(QLatin1String("init"));
|
||||
const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText);
|
||||
// '[Re]Initialized...'
|
||||
VCSBase::VCSBaseOutputWindow::instance()->append(QString::fromLocal8Bit(outputText));
|
||||
if (!rc)
|
||||
VCSBase::VCSBaseOutputWindow::instance()->append(QString::fromLocal8Bit(errorText));
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool GitClient::synchronousCheckout(const QString &workingDirectory,
|
||||
const QStringList &files,
|
||||
QString *errorMessage)
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
bool synchronousAdd(const QString &workingDirectory, const QStringList &files);
|
||||
bool synchronousReset(const QString &workingDirectory, const QStringList &files);
|
||||
bool synchronousReset(const QString &workingDirectory, const QStringList &files, QString *errorMessage);
|
||||
bool synchronousInit(const QString &workingDirectory);
|
||||
bool synchronousCheckout(const QString &workingDirectory, const QStringList &files, QString *errorMessage);
|
||||
bool synchronousStash(const QString &workingDirectory, QString *errorMessage);
|
||||
bool synchronousBranchCmd(const QString &workingDirectory, QStringList branchArgs,
|
||||
|
||||
@@ -122,6 +122,7 @@ GitPlugin::GitPlugin() :
|
||||
m_undoFileAction(0),
|
||||
m_logRepositoryAction(0),
|
||||
m_undoRepositoryAction(0),
|
||||
m_createRepositoryAction(0),
|
||||
m_showAction(0),
|
||||
m_stageAction(0),
|
||||
m_unstageAction(0),
|
||||
@@ -306,6 +307,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
connect(m_undoRepositoryAction, SIGNAL(triggered()), this, SLOT(undoRepositoryChanges()));
|
||||
gitContainer->addAction(command);
|
||||
|
||||
m_createRepositoryAction = new QAction(tr("Create Repository..."), this);
|
||||
command = actionManager->registerAction(m_createRepositoryAction, "Git.CreateRepository", globalcontext);
|
||||
connect(m_createRepositoryAction, SIGNAL(triggered()), this, SLOT(createRepository()));
|
||||
gitContainer->addAction(command);
|
||||
|
||||
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Global"), this));
|
||||
|
||||
m_stashAction = new QAction(tr("Stash"), this);
|
||||
@@ -677,9 +683,10 @@ void GitPlugin::stashList()
|
||||
|
||||
void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
{
|
||||
if (!VCSBase::VCSBasePlugin::enableMenuAction(as, m_menuAction))
|
||||
if (!enableMenuAction(as, m_menuAction))
|
||||
return;
|
||||
|
||||
// Note: This menu is visible if there is no repository. Only
|
||||
// 'Create Repository'/'Show' actions should be available.
|
||||
const QString fileName = currentState().currentFileName();
|
||||
m_diffAction->setParameter(fileName);
|
||||
m_logAction->setParameter(fileName);
|
||||
@@ -708,9 +715,13 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
|
||||
m_statusRepositoryAction->setEnabled(repositoryEnabled);
|
||||
m_branchListAction->setEnabled(repositoryEnabled);
|
||||
m_stashListAction->setEnabled(repositoryEnabled);
|
||||
m_stashAction->setEnabled(repositoryEnabled);
|
||||
m_pullAction->setEnabled(repositoryEnabled);
|
||||
m_commitAction->setEnabled(repositoryEnabled);
|
||||
m_stashPopAction->setEnabled(repositoryEnabled);
|
||||
m_logRepositoryAction->setEnabled(repositoryEnabled);
|
||||
m_undoRepositoryAction->setEnabled(repositoryEnabled);
|
||||
m_pushAction->setEnabled(repositoryEnabled);
|
||||
|
||||
// Prompts for repo.
|
||||
m_showAction->setEnabled(true);
|
||||
|
||||
@@ -131,6 +131,7 @@ private:
|
||||
Utils::ParameterAction *m_undoFileAction;
|
||||
QAction *m_logRepositoryAction;
|
||||
QAction *m_undoRepositoryAction;
|
||||
QAction *m_createRepositoryAction;
|
||||
|
||||
QAction *m_showAction;
|
||||
Utils::ParameterAction *m_stageAction;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "gitversioncontrol.h"
|
||||
#include "gitclient.h"
|
||||
#include "gitplugin.h"
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
@@ -52,6 +53,9 @@ bool GitVersionControl::supportsOperation(Operation operation) const
|
||||
case DeleteOperation:
|
||||
case OpenOperation:
|
||||
break;
|
||||
case CreateRepositoryOperation:
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -72,10 +76,14 @@ bool GitVersionControl::vcsDelete(const QString & /*fileName*/)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsCreateRepository(const QString &directory)
|
||||
{
|
||||
return GitPlugin::instance()->gitClient()->synchronousInit(directory);
|
||||
}
|
||||
|
||||
bool GitVersionControl::managesDirectory(const QString &directory) const
|
||||
{
|
||||
return !GitClient::findRepositoryForDirectory(directory).isEmpty();
|
||||
|
||||
}
|
||||
|
||||
QString GitVersionControl::findTopLevelForDirectory(const QString &directory) const
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
virtual bool vcsOpen(const QString &fileName);
|
||||
virtual bool vcsAdd(const QString &fileName);
|
||||
virtual bool vcsDelete(const QString &filename);
|
||||
virtual bool vcsCreateRepository(const QString &directory);
|
||||
|
||||
void emitFilesChanged(const QStringList &);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user