forked from qt-creator/qt-creator
Git: Make GitClient and VcsBaseClient more similar
Use the same signature for the createCommand method in both. Change-Id: I948a9fd1af2850730736731c53ee8d1b0b9b30bc Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -1984,21 +1984,18 @@ bool GitClient::synchronousApplyPatch(const QString &workingDirectory,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Factory function to create an asynchronous command
|
// Factory function to create an asynchronous command
|
||||||
VcsCommand *GitClient::createCommand(const QString &workingDirectory,
|
VcsCommand *GitClient::createCommand(const QString &workingDirectory, VcsBaseEditorWidget *editor,
|
||||||
VcsBaseEditorWidget* editor,
|
JobOutputBindMode mode)
|
||||||
bool useOutputToWindow,
|
|
||||||
int editorLineNumber)
|
|
||||||
{
|
{
|
||||||
GitEditorWidget *gitEditor = qobject_cast<GitEditorWidget *>(editor);
|
GitEditorWidget *gitEditor = qobject_cast<GitEditorWidget *>(editor);
|
||||||
auto command = new VcsCommand(vcsBinary(), workingDirectory, processEnvironment());
|
auto command = new VcsCommand(vcsBinary(), workingDirectory, processEnvironment());
|
||||||
command->setCodec(getSourceCodec(currentDocumentPath()));
|
command->setCodec(getSourceCodec(currentDocumentPath()));
|
||||||
command->setCookie(QVariant(editorLineNumber));
|
|
||||||
if (gitEditor) {
|
if (gitEditor) {
|
||||||
gitEditor->setCommand(command);
|
gitEditor->setCommand(command);
|
||||||
connect(command, &VcsCommand::finished,
|
connect(command, &VcsCommand::finished,
|
||||||
gitEditor, &GitEditorWidget::commandFinishedGotoLine);
|
gitEditor, &GitEditorWidget::commandFinishedGotoLine);
|
||||||
}
|
}
|
||||||
if (useOutputToWindow) {
|
if (mode & VcsWindowOutputBind) {
|
||||||
command->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
|
command->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
|
||||||
command->addFlags(VcsBasePlugin::ShowSuccessMessage);
|
command->addFlags(VcsBasePlugin::ShowSuccessMessage);
|
||||||
if (editor) // assume that the commands output is the important thing
|
if (editor) // assume that the commands output is the important thing
|
||||||
@@ -2019,7 +2016,9 @@ VcsCommand *GitClient::executeGit(const QString &workingDirectory,
|
|||||||
int editorLineNumber)
|
int editorLineNumber)
|
||||||
{
|
{
|
||||||
VcsOutputWindow::appendCommand(workingDirectory, vcsBinary(), arguments);
|
VcsOutputWindow::appendCommand(workingDirectory, vcsBinary(), arguments);
|
||||||
VcsCommand *command = createCommand(workingDirectory, editor, useOutputToWindow, editorLineNumber);
|
VcsCommand *command = createCommand(workingDirectory, editor,
|
||||||
|
useOutputToWindow ? VcsWindowOutputBind : NoOutputBind);
|
||||||
|
command->setCookie(editorLineNumber);
|
||||||
command->addJob(arguments, vcsTimeout() * 1000);
|
command->addJob(arguments, vcsTimeout() * 1000);
|
||||||
command->addFlags(additionalFlags);
|
command->addFlags(additionalFlags);
|
||||||
command->execute();
|
command->execute();
|
||||||
@@ -3134,7 +3133,7 @@ void GitClient::asyncCommand(const QString &workingDirectory, const QStringList
|
|||||||
// and without timeout
|
// and without timeout
|
||||||
QString gitCommand = arguments.first();
|
QString gitCommand = arguments.first();
|
||||||
VcsOutputWindow::appendCommand(workingDirectory, settings()->binaryPath(), arguments);
|
VcsOutputWindow::appendCommand(workingDirectory, settings()->binaryPath(), arguments);
|
||||||
VcsCommand *command = createCommand(workingDirectory, 0, true);
|
VcsCommand *command = createCommand(workingDirectory, 0, VcsWindowOutputBind);
|
||||||
new ConflictHandler(command, workingDirectory, gitCommand);
|
new ConflictHandler(command, workingDirectory, gitCommand);
|
||||||
if (hasProgress)
|
if (hasProgress)
|
||||||
command->setProgressParser(new GitProgressParser);
|
command->setProgressParser(new GitProgressParser);
|
||||||
|
|||||||
@@ -377,10 +377,14 @@ private:
|
|||||||
void requestReload(const QString &documentId, const QString &source, const QString &title,
|
void requestReload(const QString &documentId, const QString &source, const QString &title,
|
||||||
std::function<DiffEditor::DiffEditorController *(Core::IDocument *)> factory) const;
|
std::function<DiffEditor::DiffEditorController *(Core::IDocument *)> factory) const;
|
||||||
|
|
||||||
|
enum JobOutputBindMode {
|
||||||
|
NoOutputBind,
|
||||||
|
VcsWindowOutputBind
|
||||||
|
};
|
||||||
|
|
||||||
VcsBase::VcsCommand *createCommand(const QString &workingDirectory,
|
VcsBase::VcsCommand *createCommand(const QString &workingDirectory,
|
||||||
VcsBase::VcsBaseEditorWidget* editor = 0,
|
VcsBase::VcsBaseEditorWidget *editor = 0,
|
||||||
bool useOutputToWindow = false,
|
JobOutputBindMode mode = NoOutputBind);
|
||||||
int editorLineNumber = -1);
|
|
||||||
|
|
||||||
VcsBase::VcsCommand *executeGit(const QString &workingDirectory,
|
VcsBase::VcsCommand *executeGit(const QString &workingDirectory,
|
||||||
const QStringList &arguments,
|
const QStringList &arguments,
|
||||||
|
|||||||
Reference in New Issue
Block a user