From 0cdfac0cb5ee692576276393e4999d91a6689e25 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 8 Dec 2022 20:41:43 +0100 Subject: [PATCH] GitClient: Introduce execWithEditor() Change-Id: I3a7edde4b978cb8e99fe0020d69a0a5e3e09c0fb Reviewed-by: Orgad Shaneh --- src/plugins/git/gitclient.cpp | 8 ++++---- src/plugins/vcsbase/vcsbaseclient.cpp | 10 ++++++++++ src/plugins/vcsbase/vcsbaseclient.h | 3 +++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 48af388b374..57fd4d1eb1f 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -1197,7 +1197,7 @@ void GitClient::log(const FilePath &workingDirectory, const QString &fileName, if (!fileName.isEmpty()) arguments << "--" << fileName; - vcsExec(workingDir, arguments, editor); + vcsExecWithEditor(workingDir, arguments, editor); } void GitClient::reflog(const FilePath &workingDirectory, const QString &ref) @@ -1226,7 +1226,7 @@ void GitClient::reflog(const FilePath &workingDirectory, const QString &ref) if (logCount > 0) arguments << "-n" << QString::number(logCount); - vcsExec(workingDir, arguments, editor); + vcsExecWithEditor(workingDir, arguments, editor); } // Do not show "0000" or "^32ae4" @@ -1342,7 +1342,7 @@ VcsBaseEditorWidget *GitClient::annotate( arguments << revision; arguments << "--" << file; editor->setDefaultLineNumber(lineNumber); - vcsExec(workingDir, arguments, editor); + vcsExecWithEditor(workingDir, arguments, editor); return editor; } @@ -3229,7 +3229,7 @@ void GitClient::subversionLog(const FilePath &workingDirectory) const VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, sourceFile, codecFor(CodecNone), "svnLog", sourceFile); editor->setWorkingDirectory(workingDirectory); - vcsExec(workingDirectory, arguments, editor); + vcsExecWithEditor(workingDirectory, arguments, editor); } void GitClient::subversionDeltaCommit(const FilePath &workingDirectory) const diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 5be5dc3c58a..a622016d5d7 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -192,6 +192,16 @@ void VcsBaseClientImpl::vcsExec(const FilePath &workingDirectory, command->start(); } +void VcsBaseClientImpl::vcsExecWithEditor(const Utils::FilePath &workingDirectory, + const QStringList &arguments, + VcsBaseEditorWidget *editor) const +{ + VcsCommand *command = createCommand(workingDirectory, editor, NoOutputBind); + command->setCodec(editor->codec()); + command->addJob({vcsBinary(), arguments}, vcsTimeoutS()); + command->start(); +} + int VcsBaseClientImpl::vcsTimeoutS() const { return m_baseSettings->timeout.value(); diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index af76df5d243..e22fb509ebf 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -99,6 +99,9 @@ public: VcsBaseEditorWidget *editor = nullptr, bool useOutputToWindow = false, RunFlags additionalFlags = RunFlags::None) const; + void vcsExecWithEditor(const Utils::FilePath &workingDirectory, + const QStringList &arguments, + VcsBaseEditorWidget *editor) const; protected: void resetCachedVcsInfo(const Utils::FilePath &workingDir);