forked from qt-creator/qt-creator
Git: De-noise code
Change-Id: Ibcae2f432b3a9262e9c7c23cf2d8f9ca018cd771 Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
This commit is contained in:
@@ -89,6 +89,7 @@ static const char noColorOption[] = "--no-color";
|
|||||||
static const char decorateOption[] = "--decorate";
|
static const char decorateOption[] = "--decorate";
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace DiffEditor;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace VcsBase;
|
using namespace VcsBase;
|
||||||
|
|
||||||
@@ -106,8 +107,7 @@ class GitDiffHandler : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GitDiffHandler(DiffEditor::DiffEditorController *controller,
|
GitDiffHandler(DiffEditorController *controller, const QString &workingDirectory);
|
||||||
const QString &workingDirectory);
|
|
||||||
|
|
||||||
// index -> working tree
|
// index -> working tree
|
||||||
void diffFile(const QString &fileName);
|
void diffFile(const QString &fileName);
|
||||||
@@ -143,7 +143,7 @@ private:
|
|||||||
QProcessEnvironment processEnvironment() const;
|
QProcessEnvironment processEnvironment() const;
|
||||||
FileName gitPath() const;
|
FileName gitPath() const;
|
||||||
|
|
||||||
QPointer<DiffEditor::DiffEditorController> m_controller;
|
QPointer<DiffEditorController> m_controller;
|
||||||
const QString m_workingDirectory;
|
const QString m_workingDirectory;
|
||||||
GitClient *m_gitClient;
|
GitClient *m_gitClient;
|
||||||
const QString m_waitMessage;
|
const QString m_waitMessage;
|
||||||
@@ -151,7 +151,7 @@ private:
|
|||||||
QString m_id;
|
QString m_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
GitDiffHandler::GitDiffHandler(DiffEditor::DiffEditorController *controller,
|
GitDiffHandler::GitDiffHandler(DiffEditorController *controller,
|
||||||
const QString &workingDirectory)
|
const QString &workingDirectory)
|
||||||
: m_controller(controller),
|
: m_controller(controller),
|
||||||
m_workingDirectory(workingDirectory),
|
m_workingDirectory(workingDirectory),
|
||||||
@@ -330,8 +330,7 @@ void GitDiffHandler::slotTextualDiffOutputReceived(const QString &contents)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
QList<DiffEditor::FileData> fileDataList
|
QList<FileData> fileDataList = DiffUtils::readPatch(contents, &ok);
|
||||||
= DiffEditor::DiffUtils::readPatch(contents, &ok);
|
|
||||||
m_controller->setDiffFiles(fileDataList, m_workingDirectory);
|
m_controller->setDiffFiles(fileDataList, m_workingDirectory);
|
||||||
m_controller->requestRestoreState();
|
m_controller->requestRestoreState();
|
||||||
deleteLater();
|
deleteLater();
|
||||||
@@ -354,7 +353,7 @@ FileName GitDiffHandler::gitPath() const
|
|||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
class GitDiffEditorReloader : public DiffEditor::DiffEditorReloader
|
class GitDiffEditorReloader : public DiffEditorReloader
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@@ -744,20 +743,20 @@ GitDiffEditorReloader *GitClient::findOrCreateDiffEditor(const QString &document
|
|||||||
const QString &title,
|
const QString &title,
|
||||||
const QString &workingDirectory) const
|
const QString &workingDirectory) const
|
||||||
{
|
{
|
||||||
DiffEditor::DiffEditorController *controller = 0;
|
DiffEditorController *controller = 0;
|
||||||
GitDiffEditorReloader *reloader = 0;
|
GitDiffEditorReloader *reloader = 0;
|
||||||
DiffEditor::DiffEditorDocument *diffEditorDocument = DiffEditor::DiffEditorManager::find(documentId);
|
DiffEditorDocument *diffEditorDocument = DiffEditorManager::find(documentId);
|
||||||
if (diffEditorDocument) {
|
if (diffEditorDocument) {
|
||||||
controller = diffEditorDocument->controller();
|
controller = diffEditorDocument->controller();
|
||||||
reloader = static_cast<GitDiffEditorReloader *>(controller->reloader());
|
reloader = static_cast<GitDiffEditorReloader *>(controller->reloader());
|
||||||
} else {
|
} else {
|
||||||
diffEditorDocument = DiffEditor::DiffEditorManager::findOrCreate(documentId, title);
|
diffEditorDocument = DiffEditorManager::findOrCreate(documentId, title);
|
||||||
QTC_ASSERT(diffEditorDocument, return 0);
|
QTC_ASSERT(diffEditorDocument, return 0);
|
||||||
controller = diffEditorDocument->controller();
|
controller = diffEditorDocument->controller();
|
||||||
|
|
||||||
connect(controller, &DiffEditor::DiffEditorController::chunkActionsRequested,
|
connect(controller, &DiffEditorController::chunkActionsRequested,
|
||||||
this, &GitClient::slotChunkActionsRequested, Qt::DirectConnection);
|
this, &GitClient::slotChunkActionsRequested, Qt::DirectConnection);
|
||||||
connect(controller, &DiffEditor::DiffEditorController::requestBranchList,
|
connect(controller, &DiffEditorController::requestBranchList,
|
||||||
this, &GitClient::branchesForCommit);
|
this, &GitClient::branchesForCommit);
|
||||||
|
|
||||||
reloader = new GitDiffEditorReloader();
|
reloader = new GitDiffEditorReloader();
|
||||||
@@ -780,7 +779,7 @@ void GitClient::slotChunkActionsRequested(QMenu *menu, bool isValid)
|
|||||||
QAction *unstageChunkAction = menu->addAction(tr("Unstage Chunk"));
|
QAction *unstageChunkAction = menu->addAction(tr("Unstage Chunk"));
|
||||||
connect(unstageChunkAction, &QAction::triggered, this, &GitClient::slotUnstageChunk);
|
connect(unstageChunkAction, &QAction::triggered, this, &GitClient::slotUnstageChunk);
|
||||||
|
|
||||||
m_contextController = qobject_cast<DiffEditor::DiffEditorController *>(sender());
|
m_contextController = qobject_cast<DiffEditorController *>(sender());
|
||||||
|
|
||||||
if (!isValid || !m_contextController) {
|
if (!isValid || !m_contextController) {
|
||||||
stageChunkAction->setEnabled(false);
|
stageChunkAction->setEnabled(false);
|
||||||
@@ -1653,14 +1652,13 @@ void GitClient::branchesForCommit(const QString &revision)
|
|||||||
arguments << QLatin1String("branch") << QLatin1String(noColorOption)
|
arguments << QLatin1String("branch") << QLatin1String(noColorOption)
|
||||||
<< QLatin1String("-a") << QLatin1String("--contains") << revision;
|
<< QLatin1String("-a") << QLatin1String("--contains") << revision;
|
||||||
|
|
||||||
DiffEditor::DiffEditorController *controller
|
auto controller = qobject_cast<DiffEditorController *>(sender());
|
||||||
= qobject_cast<DiffEditor::DiffEditorController *>(sender());
|
|
||||||
QString workingDirectory = controller->workingDirectory();
|
QString workingDirectory = controller->workingDirectory();
|
||||||
auto command = new VcsCommand(gitExecutable(), workingDirectory, processEnvironment());
|
auto command = new VcsCommand(gitExecutable(), workingDirectory, processEnvironment());
|
||||||
command->setCodec(getSourceCodec(currentDocumentPath()));
|
command->setCodec(getSourceCodec(currentDocumentPath()));
|
||||||
|
|
||||||
connect(command, &VcsCommand::output, controller,
|
connect(command, &VcsCommand::output, controller,
|
||||||
&DiffEditor::DiffEditorController::branchesForCommitReceived);
|
&DiffEditorController::branchesForCommitReceived);
|
||||||
|
|
||||||
command->addJob(arguments, -1);
|
command->addJob(arguments, -1);
|
||||||
command->setCookie(workingDirectory);
|
command->setCookie(workingDirectory);
|
||||||
|
Reference in New Issue
Block a user