forked from qt-creator/qt-creator
Vcs: Move createCommand and enqueueJob into VcsBaseClientImpl
Change-Id: I86a4ddfd6c53a3be61c56579d8eaf5d49258a8f1 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
@@ -603,7 +603,7 @@ static inline void msgCannotRun(const QStringList &args, const QString &workingD
|
||||
|
||||
const char *GitClient::stashNamePrefix = "stash@{";
|
||||
|
||||
GitClient::GitClient() : VcsBase::VcsBaseClientImpl(new GitSettings),
|
||||
GitClient::GitClient() : VcsBase::VcsBaseClientImpl(this, new GitSettings),
|
||||
m_cachedGitVersion(0),
|
||||
m_disableEditor(false)
|
||||
{
|
||||
@@ -1967,36 +1967,6 @@ bool GitClient::synchronousApplyPatch(const QString &workingDirectory,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Factory function to create an asynchronous command
|
||||
VcsCommand *GitClient::createCommand(const QString &workingDirectory, VcsBaseEditorWidget *editor,
|
||||
JobOutputBindMode mode)
|
||||
{
|
||||
GitEditorWidget *gitEditor = qobject_cast<GitEditorWidget *>(editor);
|
||||
auto command = new VcsCommand(vcsBinary(), workingDirectory, processEnvironment());
|
||||
command->setCodec(getSourceCodec(currentDocumentPath()));
|
||||
if (gitEditor) {
|
||||
gitEditor->setCommand(command);
|
||||
connect(command, &VcsCommand::finished,
|
||||
gitEditor, &GitEditorWidget::commandFinishedGotoLine);
|
||||
}
|
||||
if (mode & VcsWindowOutputBind) {
|
||||
command->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
|
||||
command->addFlags(VcsBasePlugin::ShowSuccessMessage);
|
||||
if (editor) // assume that the commands output is the important thing
|
||||
command->addFlags(VcsBasePlugin::SilentOutput);
|
||||
} else if (gitEditor) {
|
||||
connect(command, &VcsCommand::output, gitEditor, &GitEditorWidget::setPlainTextFiltered);
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
void GitClient::enqueueJob(VcsCommand *cmd, const QStringList &args, ExitCodeInterpreter *interpreter)
|
||||
{
|
||||
cmd->addJob(args, vcsTimeout(), interpreter);
|
||||
cmd->execute();
|
||||
}
|
||||
|
||||
// Execute a single command
|
||||
VcsCommand *GitClient::executeGit(const QString &workingDirectory,
|
||||
const QStringList &arguments,
|
||||
@@ -2016,7 +1986,7 @@ VcsCommand *GitClient::executeGit(const QString &workingDirectory,
|
||||
|
||||
QProcessEnvironment GitClient::processEnvironment() const
|
||||
{
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QProcessEnvironment environment = VcsBaseClientImpl::processEnvironment();
|
||||
QString gitPath = settings().stringValue(GitSettings::pathKey);
|
||||
if (!gitPath.isEmpty()) {
|
||||
gitPath += HostOsInfo::pathListSeparator();
|
||||
@@ -2028,8 +1998,6 @@ QProcessEnvironment GitClient::processEnvironment() const
|
||||
environment.insert(QLatin1String("HOME"), QDir::toNativeSeparators(QDir::homePath()));
|
||||
}
|
||||
environment.insert(QLatin1String("GIT_EDITOR"), m_disableEditor ? QLatin1String("true") : m_gitQtcEditor);
|
||||
// Set up SSH and C locale (required by git using perl).
|
||||
VcsBasePlugin::setProcessEnvironment(&environment, false);
|
||||
return environment;
|
||||
}
|
||||
|
||||
|
||||
@@ -376,17 +376,6 @@ private:
|
||||
void requestReload(const QString &documentId, const QString &source, const QString &title,
|
||||
std::function<DiffEditor::DiffEditorController *(Core::IDocument *)> factory) const;
|
||||
|
||||
enum JobOutputBindMode {
|
||||
NoOutputBind,
|
||||
VcsWindowOutputBind
|
||||
};
|
||||
|
||||
VcsBase::VcsCommand *createCommand(const QString &workingDirectory,
|
||||
VcsBase::VcsBaseEditorWidget *editor = 0,
|
||||
JobOutputBindMode mode = NoOutputBind);
|
||||
void enqueueJob(VcsBase::VcsCommand *cmd, const QStringList &args,
|
||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||
|
||||
VcsBase::VcsCommand *executeGit(const QString &workingDirectory,
|
||||
const QStringList &arguments,
|
||||
VcsBase::VcsBaseEditorWidget* editor = 0,
|
||||
|
||||
@@ -197,16 +197,6 @@ void GitEditorWidget::setPlainTextFiltered(const QString &text)
|
||||
textDocument()->setPlainText(modText);
|
||||
}
|
||||
|
||||
void GitEditorWidget::commandFinishedGotoLine(bool ok, int exitCode, const QVariant &v)
|
||||
{
|
||||
reportCommandFinished(ok, exitCode, v);
|
||||
if (ok && v.type() == QVariant::Int) {
|
||||
const int line = v.toInt();
|
||||
if (line >= 0)
|
||||
gotoLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
void GitEditorWidget::checkoutChange()
|
||||
{
|
||||
GitPlugin::instance()->client()->stashAndCheckout(
|
||||
|
||||
@@ -51,8 +51,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void setPlainTextFiltered(const QString &text);
|
||||
// Matches the signature of the finished signal of GitCommand
|
||||
void commandFinishedGotoLine(bool ok, int exitCode, const QVariant &v);
|
||||
|
||||
private slots:
|
||||
void checkoutChange();
|
||||
|
||||
Reference in New Issue
Block a user