forked from qt-creator/qt-creator
Vcs: Split up VcsCommand
Move the biggest chunk into Utils::ShellCommand, add some Qt Creator specific magic in Core::ShellCommand and leave the rest in VcsBase::VcsCommand. Change-Id: I5fe6f7076e96023ad2164bcfaacfb3b65a7ff8a8 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -33,114 +33,37 @@
|
||||
|
||||
#include "vcsbase_global.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMutex;
|
||||
class QStringList;
|
||||
class QVariant;
|
||||
class QProcessEnvironment;
|
||||
template <typename T>
|
||||
class QFutureInterface;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
struct SynchronousProcessResponse;
|
||||
class ExitCodeInterpreter;
|
||||
class FileName;
|
||||
}
|
||||
#include <coreplugin/shellcommand.h>
|
||||
|
||||
namespace VcsBase {
|
||||
|
||||
namespace Internal { class VcsCommandPrivate; }
|
||||
|
||||
class VCSBASE_EXPORT ProgressParser
|
||||
{
|
||||
public:
|
||||
ProgressParser();
|
||||
virtual ~ProgressParser();
|
||||
|
||||
protected:
|
||||
virtual void parseProgress(const QString &text) = 0;
|
||||
void setProgressAndMaximum(int value, int maximum);
|
||||
|
||||
private:
|
||||
void setFuture(QFutureInterface<void> *future);
|
||||
|
||||
QFutureInterface<void> *m_future;
|
||||
QMutex *m_futureMutex;
|
||||
friend class VcsCommand;
|
||||
};
|
||||
|
||||
class VCSBASE_EXPORT VcsCommand : public QObject
|
||||
class VCSBASE_EXPORT VcsCommand : public Core::ShellCommand
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VcsCommand(const QString &workingDirectory,
|
||||
const QProcessEnvironment &environment);
|
||||
~VcsCommand();
|
||||
enum VcsRunFlags {
|
||||
SshPasswordPrompt = 0x1000, // Disable terminal on UNIX to force graphical prompt.
|
||||
ExpectRepoChanges = 0x2000, // Expect changes in repository by the command
|
||||
};
|
||||
|
||||
QString displayName() const;
|
||||
void setDisplayName(const QString &name);
|
||||
VcsCommand(const QString &workingDirectory, const QProcessEnvironment &environment);
|
||||
|
||||
void addJob(const Utils::FileName &binary, const QStringList &arguments, Utils::ExitCodeInterpreter *interpreter = 0);
|
||||
void addJob(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||
void execute();
|
||||
void abort();
|
||||
bool lastExecutionSuccess() const;
|
||||
int lastExecutionExitCode() const;
|
||||
const QProcessEnvironment processEnvironment() const;
|
||||
|
||||
const QString &workingDirectory() const;
|
||||
const QProcessEnvironment &processEnvironment() const;
|
||||
|
||||
int defaultTimeoutS() const;
|
||||
void setDefaultTimeoutS(int timeout);
|
||||
|
||||
unsigned flags() const;
|
||||
void addFlags(unsigned f);
|
||||
|
||||
const QVariant &cookie() const;
|
||||
void setCookie(const QVariant &cookie);
|
||||
|
||||
QTextCodec *codec() const;
|
||||
void setCodec(QTextCodec *codec);
|
||||
|
||||
void setProgressParser(ProgressParser *parser);
|
||||
void setProgressiveOutput(bool progressive);
|
||||
|
||||
Utils::SynchronousProcessResponse runVcs(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||
// Make sure to not pass through the event loop at all:
|
||||
bool runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||
QByteArray *outputData, QByteArray *errorData);
|
||||
Utils::SynchronousProcessResponse runCommand(const Utils::FileName &binary,
|
||||
const QStringList &arguments, int timeoutS,
|
||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||
|
||||
bool runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments,
|
||||
int timeoutS, QByteArray *outputData, QByteArray *errorData);
|
||||
private:
|
||||
void run(QFutureInterface<void> &future);
|
||||
Utils::SynchronousProcessResponse runSynchronous(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||
unsigned processFlags() const;
|
||||
void emitRepositoryChanged();
|
||||
|
||||
public slots:
|
||||
void cancel();
|
||||
|
||||
signals:
|
||||
void output(const QString &);
|
||||
void errorText(const QString &);
|
||||
void finished(bool ok, int exitCode, const QVariant &cookie);
|
||||
void success(const QVariant &cookie);
|
||||
|
||||
private slots:
|
||||
void bufferedOutput(const QString &text);
|
||||
void bufferedError(const QString &text);
|
||||
void coreAboutToClose();
|
||||
|
||||
signals:
|
||||
void terminate(); // Internal
|
||||
|
||||
private:
|
||||
class Internal::VcsCommandPrivate *const d;
|
||||
bool m_preventRepositoryChanged;
|
||||
};
|
||||
|
||||
} // namespace VcsBase
|
||||
|
||||
Reference in New Issue
Block a user