diff options
author | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-06-08 15:04:04 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@theqtcompany.com> | 2015-06-10 13:04:42 +0000 |
commit | f2be7976963a443abd1dae47123b47dec48cf97a (patch) | |
tree | bac8170a592065154de0799bd3533a48bf4e7194 /src/plugins/vcsbase | |
parent | ccbc7f9ec1ce205b6a0574200bc8d71c912a9881 (diff) |
ShellCommand: Allow setting working directory per job
Change-Id: I6d541f87b76bdc7f1503f202792079f833e8932c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/vcsbase')
-rw-r--r-- | src/plugins/vcsbase/vcsbaseclient.cpp | 5 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseclient.h | 1 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcscommand.cpp | 17 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcscommand.h | 6 |
4 files changed, 18 insertions, 11 deletions
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 327d1dfa6e..36df6fb2f0 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -155,9 +155,10 @@ VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory, } void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args, + const QString &workingDirectory, Utils::ExitCodeInterpreter *interpreter) { - cmd->addJob(vcsBinary(), args, vcsTimeoutS(), interpreter); + cmd->addJob(vcsBinary(), args, vcsTimeoutS(), workingDirectory, interpreter); cmd->execute(); } @@ -470,7 +471,7 @@ void VcsBaseClient::diff(const QString &workingDir, const QStringList &files, QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VcsBaseEditor::getCodec(source); VcsCommand *command = createCommand(workingDir, editor); command->setCodec(codec); - enqueueJob(command, args, exitCodeInterpreter(DiffCommand, command)); + enqueueJob(command, args, workingDir, exitCodeInterpreter(DiffCommand, command)); } void VcsBaseClient::log(const QString &workingDir, const QStringList &files, diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index 8fdf6971f2..f88b2440a0 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -91,6 +91,7 @@ public: JobOutputBindMode mode = NoOutputBind) const; void enqueueJob(VcsCommand *cmd, const QStringList &args, + const QString &workingDirectory = QString(), Utils::ExitCodeInterpreter *interpreter = 0); virtual QProcessEnvironment processEnvironment() const; diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index 578c911b80..e888e96ca9 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -93,30 +93,33 @@ const QProcessEnvironment VcsCommand::processEnvironment() const Utils::SynchronousProcessResponse VcsCommand::runCommand(const Utils::FileName &binary, const QStringList &arguments, int timeoutS, + const QString &workingDirectory, Utils::ExitCodeInterpreter *interpreter) { Utils::SynchronousProcessResponse response - = Core::ShellCommand::runCommand(binary, arguments, timeoutS, interpreter); - emitRepositoryChanged(); + = Core::ShellCommand::runCommand(binary, arguments, timeoutS, workingDirectory, + interpreter); + emitRepositoryChanged(workingDirectory); return response; } bool VcsCommand::runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments, - int timeoutS, QByteArray *outputData, QByteArray *errorData) + int timeoutS, QByteArray *outputData, QByteArray *errorData, + const QString &workingDirectory) { bool result = Core::ShellCommand::runFullySynchronous(binary, arguments, timeoutS, - outputData, errorData); - emitRepositoryChanged(); + outputData, errorData, workingDirectory); + emitRepositoryChanged(workingDirectory); return result; } -void VcsCommand::emitRepositoryChanged() +void VcsCommand::emitRepositoryChanged(const QString &workingDirectory) { if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges)) return; // TODO tell the document manager that the directory now received all expected changes // Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory); - Core::VcsManager::emitRepositoryChanged(defaultWorkingDirectory()); + Core::VcsManager::emitRepositoryChanged(workDirectory(workingDirectory)); } unsigned VcsCommand::processFlags() const diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h index e813e9c115..e3e9053b6b 100644 --- a/src/plugins/vcsbase/vcscommand.h +++ b/src/plugins/vcsbase/vcscommand.h @@ -53,13 +53,15 @@ public: Utils::SynchronousProcessResponse runCommand(const Utils::FileName &binary, const QStringList &arguments, int timeoutS, + const QString &workDirectory = QString(), Utils::ExitCodeInterpreter *interpreter = 0); bool runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments, - int timeoutS, QByteArray *outputData, QByteArray *errorData); + int timeoutS, QByteArray *outputData, QByteArray *errorData, + const QString &workingDirectory = QString()); private: unsigned processFlags() const; - void emitRepositoryChanged(); + void emitRepositoryChanged(const QString &workingDirectory); void coreAboutToClose(); |