Commit be3e0438 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Git: Rename asyncCommand to vcsExecAbortable



This name makes it more clear what the method does.

Refactor to use VcsBaseClientImpl::vcsExec.

Change-Id: I4cf742c2b172d2589bd7d6740461e4a4c8d470ed
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent d45dea6c
...@@ -2935,34 +2935,36 @@ bool GitClient::canRebase(const QString &workingDirectory) const ...@@ -2935,34 +2935,36 @@ bool GitClient::canRebase(const QString &workingDirectory) const
void GitClient::rebase(const QString &workingDirectory, const QString &argument) void GitClient::rebase(const QString &workingDirectory, const QString &argument)
{ {
asyncCommand(workingDirectory, QStringList() << QLatin1String("rebase") << argument, true); VcsCommand *command = vcsExecAbortable(workingDirectory,
QStringList() << QLatin1String("rebase") << argument);
GitProgressParser::attachToCommand(command);
} }
void GitClient::cherryPick(const QString &workingDirectory, const QString &argument) void GitClient::cherryPick(const QString &workingDirectory, const QString &argument)
{ {
asyncCommand(workingDirectory, QStringList() << QLatin1String("cherry-pick") << argument); vcsExecAbortable(workingDirectory, QStringList() << QLatin1String("cherry-pick") << argument);
} }
void GitClient::revert(const QString &workingDirectory, const QString &argument) void GitClient::revert(const QString &workingDirectory, const QString &argument)
{ {
asyncCommand(workingDirectory, QStringList() << QLatin1String("revert") << argument); vcsExecAbortable(workingDirectory, QStringList() << QLatin1String("revert") << argument);
} }
// Executes a command asynchronously. Work tree is expected to be clean. // Executes a command asynchronously. Work tree is expected to be clean.
// Stashing is handled prior to this call. // Stashing is handled prior to this call.
void GitClient::asyncCommand(const QString &workingDirectory, const QStringList &arguments, VcsCommand *GitClient::vcsExecAbortable(const QString &workingDirectory,
bool hasProgress) const QStringList &arguments)
{ {
QTC_ASSERT(!arguments.isEmpty(), return 0);
QString abortCommand = arguments.at(0);
// Git might request an editor, so this must be done asynchronously // Git might request an editor, so this must be done asynchronously
// and without timeout VcsCommand *command = vcsExec(workingDirectory, arguments, 0, true, 0, workingDirectory);
QString gitCommand = arguments.first(); // ... and without timeout
VcsOutputWindow::appendCommand(workingDirectory, vcsBinary(), arguments); command->setDefaultTimeoutS(0);
VcsCommand *command = createCommand(workingDirectory, 0, VcsWindowOutputBind); ConflictHandler::attachToCommand(command, abortCommand);
ConflictHandler::attachToCommand(command, gitCommand);
if (hasProgress) return command;
GitProgressParser::attachToCommand(command);
command->setCookie(workingDirectory);
enqueueJob(command, arguments);
} }
bool GitClient::synchronousRevert(const QString &workingDirectory, const QString &commit) bool GitClient::synchronousRevert(const QString &workingDirectory, const QString &commit)
...@@ -3004,7 +3006,8 @@ void GitClient::interactiveRebase(const QString &workingDirectory, const QString ...@@ -3004,7 +3006,8 @@ void GitClient::interactiveRebase(const QString &workingDirectory, const QString
VcsOutputWindow::appendCommand(workingDirectory, vcsBinary(), arguments); VcsOutputWindow::appendCommand(workingDirectory, vcsBinary(), arguments);
if (fixup) if (fixup)
m_disableEditor = true; m_disableEditor = true;
asyncCommand(workingDirectory, arguments, true); VcsCommand *command = vcsExecAbortable(workingDirectory, arguments);
GitProgressParser::attachToCommand(command);
if (fixup) if (fixup)
m_disableEditor = false; m_disableEditor = false;
} }
......
...@@ -143,6 +143,8 @@ public: ...@@ -143,6 +143,8 @@ public:
Utils::FileName vcsBinary() const override; Utils::FileName vcsBinary() const override;
unsigned gitVersion(QString *errorMessage = 0) const; unsigned gitVersion(QString *errorMessage = 0) const;
VcsBase::VcsCommand *vcsExecAbortable(const QString &workingDirectory, const QStringList &arguments);
QString findRepositoryForDirectory(const QString &dir) const; QString findRepositoryForDirectory(const QString &dir) const;
QString findGitDirForRepository(const QString &repositoryDir) const; QString findGitDirForRepository(const QString &repositoryDir) const;
bool managesFile(const QString &workingDirectory, const QString &fileName) const; bool managesFile(const QString &workingDirectory, const QString &fileName) const;
...@@ -266,8 +268,7 @@ public: ...@@ -266,8 +268,7 @@ public:
void rebase(const QString &workingDirectory, const QString &argument); void rebase(const QString &workingDirectory, const QString &argument);
void cherryPick(const QString &workingDirectory, const QString &argument); void cherryPick(const QString &workingDirectory, const QString &argument);
void revert(const QString &workingDirectory, const QString &argument); void revert(const QString &workingDirectory, const QString &argument);
void asyncCommand(const QString &workingDirectory, const QStringList &arguments,
bool hasProgress = false);
bool synchronousRevert(const QString &workingDirectory, const QString &commit); bool synchronousRevert(const QString &workingDirectory, const QString &commit);
bool synchronousCherryPick(const QString &workingDirectory, const QString &commit); bool synchronousCherryPick(const QString &workingDirectory, const QString &commit);
void interactiveRebase(const QString &workingDirectory, const QString &commit, bool fixup); void interactiveRebase(const QString &workingDirectory, const QString &commit, bool fixup);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment