forked from qt-creator/qt-creator
Git: Use StashGuard inside RebaseManager
If the rebase succeeds without conflicts, pop Change-Id: I4f0c6ad3061f4f69f7e5c9450f972cce5c15227d Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
fb40fd8297
commit
5d325f6b1a
@@ -344,10 +344,17 @@ class RebaseManager : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RebaseManager(QObject *parent) : QObject(parent)
|
||||
RebaseManager(GitClient::StashGuard &stashGuard, QObject *parent) :
|
||||
QObject(parent),
|
||||
m_stashGuard(&stashGuard)
|
||||
{
|
||||
}
|
||||
|
||||
~RebaseManager()
|
||||
{
|
||||
delete m_stashGuard;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void readStdErr(const QString &error)
|
||||
{
|
||||
@@ -361,6 +368,7 @@ public slots:
|
||||
{
|
||||
Q_UNUSED(ok);
|
||||
if (exitCode != 0 && !m_commit.isEmpty()) {
|
||||
m_stashGuard->preventPop();
|
||||
GitPlugin::instance()->gitClient()->handleMergeConflicts(
|
||||
workingDirectory.toString(), m_commit, QLatin1String("rebase"));
|
||||
}
|
||||
@@ -368,6 +376,7 @@ public slots:
|
||||
|
||||
private:
|
||||
QString m_commit;
|
||||
GitClient::StashGuard *m_stashGuard;
|
||||
};
|
||||
|
||||
Core::IEditor *locateEditor(const char *property, const QString &entry)
|
||||
@@ -2534,16 +2543,17 @@ bool GitClient::synchronousCherryPick(const QString &workingDirectory, const QSt
|
||||
return executeAndHandleConflicts(workingDirectory, arguments, command);
|
||||
}
|
||||
|
||||
void GitClient::interactiveRebase(const QString &workingDirectory, const QString &commit)
|
||||
void GitClient::interactiveRebase(const QString &workingDirectory, const QString &commit,
|
||||
StashGuard &stashGuard)
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("rebase") << QLatin1String("-i") << commit;
|
||||
arguments << QLatin1String("rebase") << QLatin1String("-i") << commit + QLatin1Char('^');
|
||||
outputWindow()->appendCommand(workingDirectory, settings()->stringValue(GitSettings::binaryPathKey), arguments);
|
||||
VcsBase::Command *command = createCommand(workingDirectory, 0, true);
|
||||
command->addJob(arguments, -1);
|
||||
command->execute();
|
||||
command->setCookie(workingDirectory);
|
||||
RebaseManager *rebaseManager = new RebaseManager(command);
|
||||
RebaseManager *rebaseManager = new RebaseManager(stashGuard, command);
|
||||
connect(command, SIGNAL(errorText(QString)), rebaseManager, SLOT(readStdErr(QString)));
|
||||
connect(command, SIGNAL(finished(bool,int,QVariant)),
|
||||
rebaseManager, SLOT(finished(bool,int,QVariant)));
|
||||
|
||||
@@ -237,7 +237,8 @@ public:
|
||||
const QString &topicBranch = QString());
|
||||
bool synchronousRevert(const QString &workingDirectory, const QString &commit);
|
||||
bool synchronousCherryPick(const QString &workingDirectory, const QString &commit);
|
||||
void interactiveRebase(const QString &workingDirectory, const QString &commit);
|
||||
void interactiveRebase(const QString &workingDirectory, const QString &commit,
|
||||
StashGuard &stashGuard);
|
||||
void synchronousAbortCommand(const QString &workingDir, const QString &abortCommand);
|
||||
|
||||
// git svn support (asynchronous).
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QScopedPointer>
|
||||
|
||||
static const unsigned minimumRequiredVersion = 0x010702;
|
||||
|
||||
@@ -758,17 +759,17 @@ void GitPlugin::startRebase()
|
||||
QString workingDirectory = currentState().currentDirectoryOrTopLevel();
|
||||
if (workingDirectory.isEmpty() || !m_gitClient->canRebase(workingDirectory))
|
||||
return;
|
||||
GitClient::StashGuard stashGuard(workingDirectory, QLatin1String("Rebase-i"));
|
||||
if (stashGuard.stashingFailed())
|
||||
QScopedPointer<GitClient::StashGuard> stashGuard(
|
||||
new GitClient::StashGuard(workingDirectory, QLatin1String("Rebase-i")));
|
||||
if (stashGuard->stashingFailed())
|
||||
return;
|
||||
stashGuard.preventPop();
|
||||
LogChangeDialog dialog(false);
|
||||
dialog.setWindowTitle(tr("Interactive Rebase"));
|
||||
if (!dialog.runDialog(workingDirectory))
|
||||
return;
|
||||
const QString change = dialog.commit();
|
||||
if (!change.isEmpty())
|
||||
m_gitClient->interactiveRebase(workingDirectory, change + QLatin1Char('^'));
|
||||
m_gitClient->interactiveRebase(workingDirectory, change, *stashGuard.take());
|
||||
}
|
||||
|
||||
void GitPlugin::startChangeRelatedAction()
|
||||
|
||||
Reference in New Issue
Block a user