2011-02-28 13:40:04 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 Brian McGillion and Hugues Delorme
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2011-02-28 13:40:04 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-02-28 13:40:04 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-02-28 13:40:04 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-02-28 13:40:04 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
|
#ifndef VCSBASECLIENT_H
|
|
|
|
|
#define VCSBASECLIENT_H
|
|
|
|
|
|
|
|
|
|
#include "vcsbase_global.h"
|
|
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QStringList>
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2015-01-20 17:42:16 +01:00
|
|
|
#include <functional>
|
|
|
|
|
|
2011-02-28 13:40:04 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QFileInfo;
|
2013-03-25 11:36:51 +01:00
|
|
|
class QVariant;
|
|
|
|
|
class QProcessEnvironment;
|
2011-02-28 13:40:04 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2015-02-26 09:33:24 +01:00
|
|
|
namespace Core { class Id; }
|
|
|
|
|
|
2011-02-28 13:40:04 +01:00
|
|
|
namespace Utils {
|
|
|
|
|
struct SynchronousProcessResponse;
|
2013-09-24 16:40:10 +02:00
|
|
|
class ExitCodeInterpreter;
|
2011-02-28 13:40:04 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2014-08-27 18:55:41 +02:00
|
|
|
class VcsCommand;
|
2012-01-07 12:31:48 +01:00
|
|
|
class VcsBaseEditorWidget;
|
|
|
|
|
class VcsBaseClientSettings;
|
|
|
|
|
class VcsJob;
|
|
|
|
|
class VcsBaseClientPrivate;
|
|
|
|
|
class VcsBaseEditorParameterWidget;
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
class VCSBASE_EXPORT VcsBaseClient : public QObject
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-09-16 15:00:41 +02:00
|
|
|
|
2011-02-28 13:40:04 +01:00
|
|
|
public:
|
2011-12-08 13:07:00 +01:00
|
|
|
class VCSBASE_EXPORT StatusItem
|
2011-08-22 15:33:03 +00:00
|
|
|
{
|
2011-12-08 13:07:00 +01:00
|
|
|
public:
|
2012-01-07 03:35:54 +01:00
|
|
|
StatusItem() {}
|
2011-08-22 15:33:03 +00:00
|
|
|
StatusItem(const QString &s, const QString &f);
|
|
|
|
|
QString flags;
|
|
|
|
|
QString file;
|
|
|
|
|
};
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
explicit VcsBaseClient(VcsBaseClientSettings *settings);
|
|
|
|
|
~VcsBaseClient();
|
2011-08-23 10:38:44 +00:00
|
|
|
virtual bool synchronousCreateRepository(const QString &workingDir,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-02-28 13:40:04 +01:00
|
|
|
virtual bool synchronousClone(const QString &workingDir,
|
|
|
|
|
const QString &srcLocation,
|
|
|
|
|
const QString &dstLocation,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-08-23 10:38:44 +00:00
|
|
|
virtual bool synchronousAdd(const QString &workingDir, const QString &fileName,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
|
|
|
|
virtual bool synchronousRemove(const QString &workingDir, const QString &fileName,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-02-28 13:40:04 +01:00
|
|
|
virtual bool synchronousMove(const QString &workingDir,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QString &from, const QString &to,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-02-28 13:40:04 +01:00
|
|
|
virtual bool synchronousPull(const QString &workingDir,
|
|
|
|
|
const QString &srcLocation,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-02-28 13:40:04 +01:00
|
|
|
virtual bool synchronousPush(const QString &workingDir,
|
|
|
|
|
const QString &dstLocation,
|
2011-05-12 14:48:10 +02:00
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-08-23 10:38:44 +00:00
|
|
|
virtual void annotate(const QString &workingDir, const QString &file,
|
2014-05-05 16:59:56 +03:00
|
|
|
const QString &revision = QString(), int lineNumber = -1,
|
2011-08-23 10:38:44 +00:00
|
|
|
const QStringList &extraOptions = QStringList());
|
|
|
|
|
virtual void diff(const QString &workingDir, const QStringList &files = QStringList(),
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
|
|
|
|
virtual void log(const QString &workingDir, const QStringList &files = QStringList(),
|
|
|
|
|
const QStringList &extraOptions = QStringList(),
|
|
|
|
|
bool enableAnnotationContextMenu = false);
|
|
|
|
|
virtual void status(const QString &workingDir, const QString &file = QString(),
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-08-22 15:33:03 +00:00
|
|
|
virtual void emitParsedStatus(const QString &repository,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-08-23 10:38:44 +00:00
|
|
|
virtual void revertFile(const QString &workingDir, const QString &file,
|
|
|
|
|
const QString &revision = QString(),
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
|
|
|
|
virtual void revertAll(const QString &workingDir, const QString &revision = QString(),
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
|
|
|
|
virtual void import(const QString &repositoryRoot, const QStringList &files,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
|
|
|
|
virtual void update(const QString &repositoryRoot, const QString &revision = QString(),
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
|
|
|
|
virtual void commit(const QString &repositoryRoot, const QStringList &files,
|
|
|
|
|
const QString &commitMessageFile,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
|
virtual QString findTopLevelForFile(const QFileInfo &file) const = 0;
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
virtual VcsBaseClientSettings *settings() const;
|
2013-08-28 21:27:47 +03:00
|
|
|
virtual QProcessEnvironment processEnvironment() const;
|
2011-03-15 15:47:45 +01:00
|
|
|
|
2015-03-25 12:30:07 +01:00
|
|
|
Utils::FileName vcsBinary() const;
|
|
|
|
|
int vcsTimeout() const;
|
|
|
|
|
|
2011-02-28 13:40:04 +01:00
|
|
|
signals:
|
2012-01-07 12:31:48 +01:00
|
|
|
void parsedStatus(const QList<VcsBase::VcsBaseClient::StatusItem> &statusList);
|
|
|
|
|
// Passes on changed signals from VcsJob to Control
|
2011-02-28 13:40:04 +01:00
|
|
|
void changed(const QVariant &v);
|
|
|
|
|
|
|
|
|
|
public slots:
|
2011-08-23 10:38:44 +00:00
|
|
|
virtual void view(const QString &source, const QString &id,
|
|
|
|
|
const QStringList &extraOptions = QStringList());
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
|
protected:
|
2014-08-27 18:55:41 +02:00
|
|
|
enum VcsCommandTag
|
2011-02-28 13:40:04 +01:00
|
|
|
{
|
|
|
|
|
CreateRepositoryCommand,
|
|
|
|
|
CloneCommand,
|
|
|
|
|
AddCommand,
|
|
|
|
|
RemoveCommand,
|
|
|
|
|
MoveCommand,
|
|
|
|
|
PullCommand,
|
|
|
|
|
PushCommand,
|
|
|
|
|
CommitCommand,
|
|
|
|
|
ImportCommand,
|
|
|
|
|
UpdateCommand,
|
|
|
|
|
RevertCommand,
|
|
|
|
|
AnnotateCommand,
|
|
|
|
|
DiffCommand,
|
|
|
|
|
LogCommand,
|
|
|
|
|
StatusCommand
|
|
|
|
|
};
|
2014-08-27 18:55:41 +02:00
|
|
|
virtual QString vcsCommandString(VcsCommandTag cmd) const;
|
|
|
|
|
virtual Core::Id vcsEditorKind(VcsCommandTag cmd) const = 0;
|
|
|
|
|
virtual Utils::ExitCodeInterpreter *exitCodeInterpreter(VcsCommandTag cmd, QObject *parent) const;
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2011-08-23 10:38:44 +00:00
|
|
|
virtual QStringList revisionSpec(const QString &revision) const = 0;
|
2015-01-20 17:42:16 +01:00
|
|
|
|
|
|
|
|
typedef std::function<VcsBaseEditorParameterWidget *()> ParameterWidgetCreator;
|
|
|
|
|
void setDiffParameterWidgetCreator(ParameterWidgetCreator creator);
|
|
|
|
|
void setLogParameterWidgetCreator(ParameterWidgetCreator creator);
|
|
|
|
|
|
2011-08-22 15:33:03 +00:00
|
|
|
virtual StatusItem parseStatusLine(const QString &line) const = 0;
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
|
QString vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const;
|
|
|
|
|
// Fully synchronous VCS execution (QProcess-based)
|
2015-03-25 12:30:07 +01:00
|
|
|
bool vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
|
2013-10-02 00:18:39 +03:00
|
|
|
QByteArray *output) const;
|
2011-02-28 13:40:04 +01:00
|
|
|
// Synchronous VCS execution using Utils::SynchronousProcess, with
|
2012-01-07 12:31:48 +01:00
|
|
|
// log windows updating (using VcsBasePlugin::runVcs with flags)
|
2011-02-28 13:40:04 +01:00
|
|
|
Utils::SynchronousProcessResponse vcsSynchronousExec(const QString &workingDir,
|
|
|
|
|
const QStringList &args,
|
|
|
|
|
unsigned flags = 0,
|
2014-05-19 18:26:02 +02:00
|
|
|
QTextCodec *outputCodec = 0) const;
|
2014-08-27 18:55:41 +02:00
|
|
|
VcsBaseEditorWidget *createVcsEditor(Core::Id kind, QString title,
|
|
|
|
|
const QString &source, bool setSourceCodec,
|
|
|
|
|
const char *registerDynamicProperty,
|
|
|
|
|
const QString &dynamicPropertyValue) const;
|
2011-02-28 13:40:04 +01:00
|
|
|
|
2011-10-05 15:32:16 +00:00
|
|
|
enum JobOutputBindMode {
|
|
|
|
|
NoOutputBind,
|
|
|
|
|
VcsWindowOutputBind
|
|
|
|
|
};
|
2014-08-27 18:55:41 +02:00
|
|
|
|
|
|
|
|
VcsCommand *createCommand(const QString &workingDirectory,
|
2015-03-25 12:30:07 +01:00
|
|
|
VcsBaseEditorWidget *editor = 0,
|
|
|
|
|
JobOutputBindMode mode = NoOutputBind) const;
|
2014-08-27 18:55:41 +02:00
|
|
|
void enqueueJob(VcsCommand *cmd, const QStringList &args, Utils::ExitCodeInterpreter *interpreter = 0);
|
2011-10-05 15:32:16 +00:00
|
|
|
|
2011-09-13 15:05:50 +00:00
|
|
|
void resetCachedVcsInfo(const QString &workingDir);
|
|
|
|
|
|
2011-02-28 13:40:04 +01:00
|
|
|
private:
|
2015-01-21 10:16:17 +01:00
|
|
|
void statusParser(const QString&);
|
|
|
|
|
void annotateRevision(const QString&, const QString&, const QString&, int);
|
|
|
|
|
void saveSettings();
|
|
|
|
|
void commandFinishedGotoLine(QWidget*);
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
friend class VcsBaseClientPrivate;
|
|
|
|
|
VcsBaseClientPrivate *d;
|
2011-02-28 13:40:04 +01:00
|
|
|
};
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
} //namespace VcsBase
|
2011-02-28 13:40:04 +01:00
|
|
|
|
|
|
|
|
#endif // VCSBASECLIENT_H
|