vcsbaseclient.h 8.88 KB
Newer Older
cerf's avatar
cerf committed
1
2
3
4
5
6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Brian McGillion & Hugues Delorme
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
cerf's avatar
cerf committed
8
9
10
11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12
13
14
15
16
17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
cerf's avatar
cerf committed
18
19
**
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
cerf's avatar
cerf committed
21
22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23
24
25
26
27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
cerf's avatar
cerf committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
cerf's avatar
cerf committed
30
31
32
33
34
35
36
37
38
39
40
41
**
**************************************************************************/

#ifndef VCSBASECLIENT_H
#define VCSBASECLIENT_H

#include "vcsbase_global.h"

#include <QtCore/QObject>
#include <QtCore/QStringList>
#include <QtCore/QPair>
#include <QtCore/QSharedPointer>
Friedemann Kleint's avatar
Friedemann Kleint committed
42
#include <QtCore/QScopedPointer>
cerf's avatar
cerf committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <QtCore/QVariant>

QT_BEGIN_NAMESPACE
class QFileInfo;
class QVariant;
QT_END_NAMESPACE

namespace Core {
class ICore;
}

namespace Utils {
struct SynchronousProcessResponse;
}

namespace VCSBase {

class VCSBaseEditorWidget;
class VCSBaseClientSettings;
class VCSJob;
Friedemann Kleint's avatar
Friedemann Kleint committed
63
class VCSBaseClientPrivate;
64
class VCSBaseEditorParameterWidget;
cerf's avatar
cerf committed
65
66
67
68
69

class VCSBASE_EXPORT VCSBaseClient : public QObject
{
    Q_OBJECT
public:
70
71
72
73
74
75
76
77
    struct VCSBASE_EXPORT StatusItem
    {
        StatusItem();
        StatusItem(const QString &s, const QString &f);
        QString flags;
        QString file;
    };

78
    explicit VCSBaseClient(VCSBaseClientSettings *settings);
cerf's avatar
cerf committed
79
80
81
82
83
    ~VCSBaseClient();
    virtual bool synchronousCreateRepository(const QString &workingDir);
    virtual bool synchronousClone(const QString &workingDir,
                                  const QString &srcLocation,
                                  const QString &dstLocation,
84
                                  const QStringList &extraOptions = QStringList());
cerf's avatar
cerf committed
85
86
87
88
89
90
    virtual bool synchronousAdd(const QString &workingDir, const QString &fileName);
    virtual bool synchronousRemove(const QString &workingDir, const QString &fileName);
    virtual bool synchronousMove(const QString &workingDir,
                                 const QString &from, const QString &to);
    virtual bool synchronousPull(const QString &workingDir,
                                 const QString &srcLocation,
91
                                 const QStringList &extraOptions = QStringList());
cerf's avatar
cerf committed
92
93
    virtual bool synchronousPush(const QString &workingDir,
                                 const QString &dstLocation,
94
                                 const QStringList &extraOptions = QStringList());
cerf's avatar
cerf committed
95
96
    void annotate(const QString &workingDir, const QString &file,
                  const QString revision = QString(), int lineNumber = -1);
97
    void diff(const QString &workingDir, const QStringList &files = QStringList(),
98
              const QStringList &extraOptions = QStringList());
cerf's avatar
cerf committed
99
    void log(const QString &workingDir, const QStringList &files = QStringList(),
100
             const QStringList &extraOptions = QStringList(),
cerf's avatar
cerf committed
101
102
103
104
105
106
107
108
109
110
             bool enableAnnotationContextMenu = false);
    void status(const QString &workingDir, const QString &file = QString());
    void statusWithSignal(const QString &repository);
    void revertFile(const QString &workingDir, const QString &file, const QString &revision = QString());
    void revertAll(const QString &workingDir, const QString &revision = QString());
    void import(const QString &repositoryRoot, const QStringList &files);
    void update(const QString &repositoryRoot, const QString &revision = QString());
    void commit(const QString &repositoryRoot,
                const QStringList &files,
                const QString &commitMessageFile,
111
                const QStringList &extraOptions = QStringList());
cerf's avatar
cerf committed
112
113
114

    virtual QString findTopLevelForFile(const QFileInfo &file) const = 0;

115
    virtual VCSBaseClientSettings *settings() const;
116

cerf's avatar
cerf committed
117
signals:
118
    void parsedStatus(const QList<VCSBase::VCSBaseClient::StatusItem> &statusList);
cerf's avatar
cerf committed
119
120
121
122
123
    // Passes on changed signals from VCSJob to Control
    void changed(const QVariant &v);

public slots:
    void view(const QString &source, const QString &id);
124
    void handleSettingsChanged();
cerf's avatar
cerf committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149

protected:
    enum VCSCommand
    {
        CreateRepositoryCommand,
        CloneCommand,
        AddCommand,
        RemoveCommand,
        MoveCommand,
        PullCommand,
        PushCommand,
        CommitCommand,
        ImportCommand,
        UpdateCommand,
        RevertCommand,
        AnnotateCommand,
        DiffCommand,
        LogCommand,
        StatusCommand
    };
    virtual QString vcsCommandString(VCSCommand cmd) const;
    virtual QString vcsEditorKind(VCSCommand cmd) const = 0;

    virtual QStringList cloneArguments(const QString &srcLocation,
                                       const QString &dstLocation,
150
                                       const QStringList &extraOptions) const = 0;
cerf's avatar
cerf committed
151
    virtual QStringList pullArguments(const QString &srcLocation,
152
                                      const QStringList &extraOptions) const = 0;
cerf's avatar
cerf committed
153
    virtual QStringList pushArguments(const QString &dstLocation,
154
                                      const QStringList &extraOptions) const = 0;
cerf's avatar
cerf committed
155
156
    virtual QStringList commitArguments(const QStringList &files,
                                        const QString &commitMessageFile,
157
                                        const QStringList &extraOptions) const = 0;
cerf's avatar
cerf committed
158
159
160
161
162
163
    virtual QStringList importArguments(const QStringList &files) const = 0;
    virtual QStringList updateArguments(const QString &revision) const = 0;
    virtual QStringList revertArguments(const QString &file, const QString &revision) const = 0;
    virtual QStringList revertAllArguments(const QString &revision) const = 0;
    virtual QStringList annotateArguments(const QString &file,
                                          const QString &revision, int lineNumber) const = 0;
164
    virtual QStringList diffArguments(const QStringList &files,
165
                                      const QStringList &extraOptions) const = 0;
166
167
168
    virtual VCSBaseEditorParameterWidget *createDiffEditor(const QString &workingDir,
                                                           const QStringList &files,
                                                           const QStringList &extraOptions);
169
    virtual QStringList logArguments(const QStringList &files,
170
                                     const QStringList &extraOptions) const = 0;
171
172
173
    virtual VCSBaseEditorParameterWidget *createLogEditor(const QString &workingDir,
                                                          const QStringList &files,
                                                          const QStringList &extraOptions);
cerf's avatar
cerf committed
174
175
176
    virtual QStringList statusArguments(const QString &file) const = 0;
    virtual QStringList viewArguments(const QString &revision) const = 0;

177
    virtual StatusItem parseStatusLine(const QString &line) const = 0;
cerf's avatar
cerf committed
178
179
180
181

    QString vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const;
    void enqueueJob(const QSharedPointer<VCSJob> &);
    // Fully synchronous VCS execution (QProcess-based)
182
    bool vcsFullySynchronousExec(const QString &workingDir,
cerf's avatar
cerf committed
183
184
185
186
187
188
189
190
191
192
193
194
195
196
                                 const QStringList &args,
                                 QByteArray *output);
    // Synchronous VCS execution using Utils::SynchronousProcess, with
    // log windows updating (using VCSBasePlugin::runVCS with flags)
    Utils::SynchronousProcessResponse vcsSynchronousExec(const QString &workingDir,
                                                         const QStringList &args,
                                                         unsigned flags = 0,
                                                         QTextCodec *outputCodec = 0);
    VCSBase::VCSBaseEditorWidget *createVCSEditor(const QString &kind, QString title,
                                                  const QString &source, bool setSourceCodec,
                                                  const char *registerDynamicProperty,
                                                  const QString &dynamicPropertyValue) const;

private:
197
    friend class VCSBaseClientPrivate;
Friedemann Kleint's avatar
Friedemann Kleint committed
198
    QScopedPointer<VCSBaseClientPrivate> d;
199
200
201
202

    Q_PRIVATE_SLOT(d, void statusParser(QByteArray))
    Q_PRIVATE_SLOT(d, void annotateRevision(QString, QString, int))
    Q_PRIVATE_SLOT(d, void saveSettings())
cerf's avatar
cerf committed
203
204
205
206
207
};

} //namespace VCSBase

#endif // VCSBASECLIENT_H