forked from qt-creator/qt-creator
VcsCommand: Interpret exit code locally
Don't pass it to the Process instance. Change-Id: I0891f85414d52cdab1f95cc3f37610ebe06a5955 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -58,7 +58,8 @@ public:
|
|||||||
void setupProcess(Process *process, const Job &job);
|
void setupProcess(Process *process, const Job &job);
|
||||||
void installStdCallbacks(Process *process);
|
void installStdCallbacks(Process *process);
|
||||||
EventLoopMode eventLoopMode() const;
|
EventLoopMode eventLoopMode() const;
|
||||||
void handleDone(Process *process);
|
ProcessResult handleDone(Process *process,
|
||||||
|
const ExitCodeInterpreter &exitCodeInterpreter = {}) const;
|
||||||
void startAll();
|
void startAll();
|
||||||
void startNextJob();
|
void startNextJob();
|
||||||
void processDone();
|
void processDone();
|
||||||
@@ -101,7 +102,6 @@ void VcsCommandPrivate::cleanup()
|
|||||||
|
|
||||||
void VcsCommandPrivate::setupProcess(Process *process, const Job &job)
|
void VcsCommandPrivate::setupProcess(Process *process, const Job &job)
|
||||||
{
|
{
|
||||||
process->setExitCodeInterpreter(job.exitCodeInterpreter);
|
|
||||||
process->setTimeoutS(job.timeoutS);
|
process->setTimeoutS(job.timeoutS);
|
||||||
if (!job.workingDirectory.isEmpty())
|
if (!job.workingDirectory.isEmpty())
|
||||||
process->setWorkingDirectory(job.workingDirectory);
|
process->setWorkingDirectory(job.workingDirectory);
|
||||||
@@ -158,20 +158,33 @@ EventLoopMode VcsCommandPrivate::eventLoopMode() const
|
|||||||
return EventLoopMode::Off;
|
return EventLoopMode::Off;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsCommandPrivate::handleDone(Process *process)
|
ProcessResult VcsCommandPrivate::handleDone(Process *process,
|
||||||
|
const ExitCodeInterpreter &exitCodeInterpreter) const
|
||||||
{
|
{
|
||||||
// Success/Fail message in appropriate window?
|
ProcessResult result;
|
||||||
if (process->result() == ProcessResult::FinishedWithSuccess) {
|
QString exitMessage;
|
||||||
if (m_flags & RunFlags::ShowSuccessMessage)
|
if (exitCodeInterpreter && process->error() != QProcess::FailedToStart
|
||||||
VcsOutputWindow::appendMessage(process->exitMessage());
|
&& process->exitStatus() == QProcess::NormalExit) {
|
||||||
} else if (!(m_flags & RunFlags::SuppressFailMessage)) {
|
result = exitCodeInterpreter(process->exitCode());
|
||||||
VcsOutputWindow::appendError(process->exitMessage());
|
exitMessage = Process::exitMessage(process->commandLine(), m_result,
|
||||||
|
process->exitCode(), process->timeoutS());
|
||||||
|
} else {
|
||||||
|
result = process->result();
|
||||||
|
exitMessage = process->exitMessage();
|
||||||
}
|
}
|
||||||
if (!(m_flags & RunFlags::ExpectRepoChanges))
|
// Success/Fail message in appropriate window?
|
||||||
return;
|
if (result == ProcessResult::FinishedWithSuccess) {
|
||||||
// TODO tell the document manager that the directory now received all expected changes
|
if (m_flags & RunFlags::ShowSuccessMessage)
|
||||||
// DocumentManager::unexpectDirectoryChange(d->m_workingDirectory);
|
VcsOutputWindow::appendMessage(exitMessage);
|
||||||
VcsManager::emitRepositoryChanged(process->workingDirectory());
|
} else if (!(m_flags & RunFlags::SuppressFailMessage)) {
|
||||||
|
VcsOutputWindow::appendError(exitMessage);
|
||||||
|
}
|
||||||
|
if (m_flags & RunFlags::ExpectRepoChanges) {
|
||||||
|
// TODO tell the document manager that the directory now received all expected changes
|
||||||
|
// DocumentManager::unexpectDirectoryChange(d->m_workingDirectory);
|
||||||
|
VcsManager::emitRepositoryChanged(process->workingDirectory());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsCommandPrivate::startAll()
|
void VcsCommandPrivate::startAll()
|
||||||
@@ -195,13 +208,11 @@ void VcsCommandPrivate::startNextJob()
|
|||||||
|
|
||||||
void VcsCommandPrivate::processDone()
|
void VcsCommandPrivate::processDone()
|
||||||
{
|
{
|
||||||
handleDone(m_process.get());
|
m_result = handleDone(m_process.get(), m_jobs.at(m_currentJob).exitCodeInterpreter);
|
||||||
m_stdOut += m_process->cleanedStdOut();
|
m_stdOut += m_process->cleanedStdOut();
|
||||||
m_stdErr += m_process->cleanedStdErr();
|
m_stdErr += m_process->cleanedStdErr();
|
||||||
m_result = m_process->result();
|
|
||||||
++m_currentJob;
|
++m_currentJob;
|
||||||
const bool success = m_process->result() == ProcessResult::FinishedWithSuccess;
|
if (m_currentJob < m_jobs.count() && m_result == ProcessResult::FinishedWithSuccess) {
|
||||||
if (m_currentJob < m_jobs.count() && success) {
|
|
||||||
m_process.release()->deleteLater();
|
m_process.release()->deleteLater();
|
||||||
startNextJob();
|
startNextJob();
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user