forked from qt-creator/qt-creator
MergeTool: De-pointer process
Get rid of unused m_merging field. Change-Id: I0e6d80f6422881ad37982a6946fa3916b4574094 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -30,9 +30,7 @@
|
|||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
#include <utils/commandline.h>
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcprocess.h>
|
|
||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@@ -45,32 +43,26 @@ namespace Git {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
MergeTool::MergeTool(QObject *parent) : QObject(parent)
|
MergeTool::MergeTool(QObject *parent) : QObject(parent)
|
||||||
{ }
|
|
||||||
|
|
||||||
MergeTool::~MergeTool()
|
|
||||||
{
|
{
|
||||||
delete m_process;
|
connect(&m_process, &QtcProcess::done, this, &MergeTool::done);
|
||||||
|
connect(&m_process, &QtcProcess::readyReadStandardOutput, this, &MergeTool::readData);
|
||||||
|
Environment env = Environment::systemEnvironment();
|
||||||
|
env.set("LANG", "C");
|
||||||
|
env.set("LANGUAGE", "C");
|
||||||
|
m_process.setEnvironment(env);
|
||||||
|
m_process.setProcessMode(ProcessMode::Writer);
|
||||||
|
m_process.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeTool::start(const FilePath &workingDirectory, const QStringList &files)
|
void MergeTool::start(const FilePath &workingDirectory, const QStringList &files)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << "mergetool" << "-y" << files;
|
arguments << "mergetool" << "-y" << files;
|
||||||
Environment env = Environment::systemEnvironment();
|
const CommandLine cmd = {GitClient::instance()->vcsBinary(), arguments};
|
||||||
env.set("LANG", "C");
|
|
||||||
env.set("LANGUAGE", "C");
|
|
||||||
m_process = new QtcProcess;
|
|
||||||
connect(m_process, &QtcProcess::done, this, &MergeTool::done);
|
|
||||||
connect(m_process, &QtcProcess::readyReadStandardOutput, this, &MergeTool::readData);
|
|
||||||
m_process->setProcessMode(ProcessMode::Writer);
|
|
||||||
m_process->setWorkingDirectory(workingDirectory);
|
|
||||||
m_process->setEnvironment(env);
|
|
||||||
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
|
||||||
const Utils::FilePath binary = GitClient::instance()->vcsBinary();
|
|
||||||
const CommandLine cmd = {binary, arguments};
|
|
||||||
VcsOutputWindow::appendCommand(workingDirectory, cmd);
|
VcsOutputWindow::appendCommand(workingDirectory, cmd);
|
||||||
m_process->setCommand(cmd);
|
m_process.setCommand(cmd);
|
||||||
m_process->start();
|
m_process.setWorkingDirectory(workingDirectory);
|
||||||
|
m_process.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeTool::FileState MergeTool::parseStatus(const QString &line, QString &extraInfo)
|
MergeTool::FileState MergeTool::parseStatus(const QString &line, QString &extraInfo)
|
||||||
@@ -141,8 +133,7 @@ QString MergeTool::stateName(MergeTool::FileState state, const QString &extraInf
|
|||||||
|
|
||||||
void MergeTool::chooseAction()
|
void MergeTool::chooseAction()
|
||||||
{
|
{
|
||||||
m_merging = (m_mergeType == NormalMerge);
|
if (m_mergeType == NormalMerge)
|
||||||
if (m_merging)
|
|
||||||
return;
|
return;
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setWindowTitle(tr("Merge Conflict"));
|
msgBox.setWindowTitle(tr("Merge Conflict"));
|
||||||
@@ -199,7 +190,7 @@ void MergeTool::prompt(const QString &title, const QString &question)
|
|||||||
|
|
||||||
void MergeTool::readData()
|
void MergeTool::readData()
|
||||||
{
|
{
|
||||||
QString newData = QString::fromLocal8Bit(m_process->readAllStandardOutput());
|
QString newData = QString::fromLocal8Bit(m_process.readAllStandardOutput());
|
||||||
newData.remove('\r');
|
newData.remove('\r');
|
||||||
VcsOutputWindow::append(newData);
|
VcsOutputWindow::append(newData);
|
||||||
QString data = m_unfinishedLine + newData;
|
QString data = m_unfinishedLine + newData;
|
||||||
@@ -223,7 +214,7 @@ void MergeTool::readData()
|
|||||||
tr("Merge tool is not configured."),
|
tr("Merge tool is not configured."),
|
||||||
tr("Run git config --global merge.tool <tool> "
|
tr("Run git config --global merge.tool <tool> "
|
||||||
"to configure it, then try again.")));
|
"to configure it, then try again.")));
|
||||||
m_process->kill();
|
m_process.stop();
|
||||||
} else {
|
} else {
|
||||||
m_unfinishedLine = data;
|
m_unfinishedLine = data;
|
||||||
}
|
}
|
||||||
@@ -247,13 +238,13 @@ void MergeTool::readLine(const QString &line)
|
|||||||
|
|
||||||
void MergeTool::done()
|
void MergeTool::done()
|
||||||
{
|
{
|
||||||
const bool success = m_process->result() == ProcessResult::FinishedWithSuccess;
|
const bool success = m_process.result() == ProcessResult::FinishedWithSuccess;
|
||||||
if (success)
|
if (success)
|
||||||
VcsOutputWindow::appendMessage(m_process->exitMessage());
|
VcsOutputWindow::appendMessage(m_process.exitMessage());
|
||||||
else
|
else
|
||||||
VcsOutputWindow::appendError(m_process->exitMessage());
|
VcsOutputWindow::appendError(m_process.exitMessage());
|
||||||
|
|
||||||
const FilePath workingDirectory = m_process->workingDirectory();
|
const FilePath workingDirectory = m_process.workingDirectory();
|
||||||
GitClient::instance()->continueCommandIfNeeded(workingDirectory, success);
|
GitClient::instance()->continueCommandIfNeeded(workingDirectory, success);
|
||||||
GitPlugin::emitRepositoryChanged(workingDirectory);
|
GitPlugin::emitRepositoryChanged(workingDirectory);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
@@ -261,7 +252,7 @@ void MergeTool::done()
|
|||||||
|
|
||||||
void MergeTool::write(const QString &str)
|
void MergeTool::write(const QString &str)
|
||||||
{
|
{
|
||||||
m_process->write(str);
|
m_process.write(str);
|
||||||
VcsOutputWindow::append(str);
|
VcsOutputWindow::append(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
@@ -32,12 +34,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QMessageBox;
|
class QMessageBox;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils
|
|
||||||
{
|
|
||||||
class FilePath;
|
|
||||||
class QtcProcess;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -56,7 +52,6 @@ class MergeTool : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MergeTool(QObject *parent = nullptr);
|
explicit MergeTool(QObject *parent = nullptr);
|
||||||
~MergeTool() override;
|
|
||||||
void start(const Utils::FilePath &workingDirectory, const QStringList &files = {});
|
void start(const Utils::FilePath &workingDirectory, const QStringList &files = {});
|
||||||
|
|
||||||
enum MergeType {
|
enum MergeType {
|
||||||
@@ -79,7 +74,7 @@ private:
|
|||||||
void chooseAction();
|
void chooseAction();
|
||||||
void addButton(QMessageBox *msgBox, const QString &text, char key);
|
void addButton(QMessageBox *msgBox, const QString &text, char key);
|
||||||
|
|
||||||
Utils::QtcProcess *m_process = nullptr;
|
Utils::QtcProcess m_process;
|
||||||
MergeType m_mergeType = NormalMerge;
|
MergeType m_mergeType = NormalMerge;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
FileState m_localState = UnknownState;
|
FileState m_localState = UnknownState;
|
||||||
@@ -87,7 +82,6 @@ private:
|
|||||||
FileState m_remoteState = UnknownState;
|
FileState m_remoteState = UnknownState;
|
||||||
QString m_remoteInfo;
|
QString m_remoteInfo;
|
||||||
QString m_unfinishedLine;
|
QString m_unfinishedLine;
|
||||||
bool m_merging = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user