Commit 2dfd7349 authored by Friedemann Kleint's avatar Friedemann Kleint

Make VCS plugins keep the submit editor open if the submit fails.

parent 2fc4e900
......@@ -695,20 +695,22 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor)
const QStringList fileList = editor->checkedFiles();
if (Git::Constants::debug)
qDebug() << Q_FUNC_INFO << fileList;
bool closeEditor = true;
if (!fileList.empty()) {
// get message & commit
m_core->fileManager()->blockFileChange(fileIFace);
fileIFace->save();
m_core->fileManager()->unblockFileChange(fileIFace);
m_gitClient->addAndCommit(m_submitRepository,
editor->panelData(),
m_changeTmpFile->fileName(),
fileList,
m_submitOrigCommitFiles);
closeEditor = m_gitClient->addAndCommit(m_submitRepository,
editor->panelData(),
m_changeTmpFile->fileName(),
fileList,
m_submitOrigCommitFiles);
}
cleanChangeTmpFile();
return true;
if (closeEditor)
cleanChangeTmpFile();
return closeEditor;
}
void GitPlugin::pull()
......
......@@ -517,16 +517,14 @@ void PerforcePlugin::submit()
m_changeTmpFile = new QTemporaryFile(this);
if (!m_changeTmpFile->open()) {
showOutput(tr("Cannot create temporary file."), true);
delete m_changeTmpFile;
m_changeTmpFile = 0;
cleanChangeTmpFile();
return;
}
PerforceResponse result = runP4Cmd(QStringList()<< QLatin1String("change") << QLatin1String("-o"), QStringList(),
CommandToWindow|StdErrToWindow|ErrorToWindow);
if (result.error) {
delete m_changeTmpFile;
m_changeTmpFile = 0;
cleanChangeTmpFile();
return;
}
......@@ -539,8 +537,7 @@ void PerforcePlugin::submit()
PerforceResponse result2 = runP4Cmd(QStringList(QLatin1String("fstat")), nativeFiles,
CommandToWindow|StdErrToWindow|ErrorToWindow);
if (result2.error) {
delete m_changeTmpFile;
m_changeTmpFile = 0;
cleanChangeTmpFile();
return;
}
......@@ -552,8 +549,7 @@ void PerforcePlugin::submit()
}
if (depotFileNames.isEmpty()) {
showOutput(tr("Project has no files"));
delete m_changeTmpFile;
m_changeTmpFile = 0;
cleanChangeTmpFile();
return;
}
......@@ -959,6 +955,16 @@ void PerforcePlugin::submitCurrentLog()
em->closeEditors(QList<Core::IEditor*>() << em->currentEditor());
}
void PerforcePlugin::cleanChangeTmpFile()
{
if (m_changeTmpFile) {
if (m_changeTmpFile->isOpen())
m_changeTmpFile->close();
delete m_changeTmpFile;
m_changeTmpFile = 0;
}
}
bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
{
if (!m_changeTmpFile || !editor)
......@@ -989,14 +995,13 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
fileIFace->save();
core->fileManager()->unblockFileChange(fileIFace);
if (answer == VCSBase::VCSBaseSubmitEditor::SubmitConfirmed) {
m_changeTmpFile->seek(0);
QByteArray change = m_changeTmpFile->readAll();
m_changeTmpFile->close();
if (!checkP4Command()) {
showOutput(tr("No p4 executable specified!"), true);
delete m_changeTmpFile;
m_changeTmpFile = 0;
return false;
}
QProcess proc;
proc.setEnvironment(environment());
......@@ -1006,8 +1011,6 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
if (!proc.waitForStarted(p4Timeout)) {
showOutput(tr("Cannot execute p4 submit."), true);
QApplication::restoreOverrideCursor();
delete m_changeTmpFile;
m_changeTmpFile = 0;
return false;
}
proc.write(change);
......@@ -1016,8 +1019,6 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
if (!proc.waitForFinished()) {
showOutput(tr("Cannot execute p4 submit."), true);
QApplication::restoreOverrideCursor();
delete m_changeTmpFile;
m_changeTmpFile = 0;
return false;
}
const QString output = QString::fromUtf8(proc.readAll());
......@@ -1027,9 +1028,7 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
}
QApplication::restoreOverrideCursor();
}
m_changeTmpFile->close();
delete m_changeTmpFile;
m_changeTmpFile = 0;
cleanChangeTmpFile();
}
return true;
}
......
......@@ -167,6 +167,7 @@ private:
void showOutput(const QString &output, bool popup = false) const;
void annotate(const QString &fileName);
void filelog(const QString &fileName);
void cleanChangeTmpFile();
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
PerforceOutputWindow *m_perforceOutputWindow;
......
......@@ -153,8 +153,9 @@ void PerforceSubmitEditor::updateEntries()
const QString tab = QString(QLatin1Char('\t'));
QStringList lines = submitEditorWidget()->descriptionText().split(newLine);
while (lines.last().isEmpty())
lines.removeLast();
while (!lines.empty() && lines.last().isEmpty())
lines.removeLast();
// Description
lines.replaceInStrings(QRegExp(QLatin1String("^")), tab);
m_entries.insert(QLatin1String("Description"), newLine + lines.join(newLine) + QLatin1String("\n\n"));
......
......@@ -483,15 +483,17 @@ bool SubversionPlugin::editorAboutToClose(Core::IEditor *iEditor)
}
const QStringList fileList = editor->checkedFiles();
bool closeEditor = true;
if (!fileList.empty()) {
// get message & commit
Core::ICore::instance()->fileManager()->blockFileChange(fileIFace);
fileIFace->save();
Core::ICore::instance()->fileManager()->unblockFileChange(fileIFace);
commit(m_changeTmpFile->fileName(), fileList);
closeEditor= commit(m_changeTmpFile->fileName(), fileList);
}
cleanChangeTmpFile();
return true;
if (closeEditor)
cleanChangeTmpFile();
return closeEditor;
}
void SubversionPlugin::diffFiles(const QStringList &files)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment