subversionplugin.h 7.41 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
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.
18
**
con's avatar
con committed
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
con's avatar
con 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.
**
con's avatar
con 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.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

con's avatar
con committed
33
34
35
36
37
#ifndef SUBVERSIONPLUGIN_H
#define SUBVERSIONPLUGIN_H

#include "subversionsettings.h"

38
#include <vcsbase/vcsbaseplugin.h>
39
#include <QtCore/QStringList>
con's avatar
con committed
40
41
42
43
44
45
46
47
48

QT_BEGIN_NAMESPACE
class QDir;
class QAction;
class QTextCodec;
QT_END_NAMESPACE

namespace Core {
    class IVersionControl;
49
    class IEditor;
50
51
52
}
namespace Utils {
    class ParameterAction;
con's avatar
con committed
53
54
}

55
56
57
58
namespace VCSBase {
    class VCSBaseSubmitEditor;
}

Friedemann Kleint's avatar
Friedemann Kleint committed
59
60
61
62
namespace Locator {
    class CommandLocator;
}

con's avatar
con committed
63
64
65
66
namespace Subversion {
namespace Internal {

class SubversionSubmitEditor;
67
class SubversionControl;
68
struct SubversionDiffParameters;
con's avatar
con committed
69
70
71
72
73
74
75
76
77
78

struct SubversionResponse
{
    SubversionResponse() : error(false) {}
    bool error;
    QString stdOut;
    QString stdErr;
    QString message;
};

79
class SubversionPlugin : public VCSBase::VCSBasePlugin
con's avatar
con committed
80
81
82
83
84
85
86
{
    Q_OBJECT

public:
    SubversionPlugin();
    ~SubversionPlugin();

hjk's avatar
hjk committed
87
    bool initialize(const QStringList &arguments, QString *errorMessage);
con's avatar
con committed
88

89
    void svnDiff(const QString  &workingDir, const QStringList &files, QString diffname = QString());
con's avatar
con committed
90
91
92
93
94
95
96

    SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName);

    SubversionSettings settings() const;
    void setSettings(const SubversionSettings &s);

    // IVersionControl
97
    bool vcsAdd(const QString &workingDir, const QString &fileName);
98
99
    bool vcsAdd14(const QString &workingDir, const QString &fileName);
    bool vcsAdd15(const QString &workingDir, const QString &fileName);
100
    bool vcsDelete(const QString &workingDir, const QString &fileName);
dt's avatar
dt committed
101
    bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
102
    bool managesDirectory(const QString &directory, QString *topLevel = 0) const;
103
104
    virtual bool vcsCheckout(const QString &directory, const QByteArray &url);
    virtual QString vcsGetRepositoryURL(const QString &directory);
con's avatar
con committed
105

106
    static SubversionPlugin *instance();
con's avatar
con committed
107

108
109
110
111
112
    // Add authorization options to the command line arguments.
    static QStringList addAuthenticationOptions(const QStringList &args,
                                                const QString &userName = QString(),
                                                const QString &password = QString());

113
114
115
public slots:
    void vcsAnnotate(const QString &workingDir, const QString &file,
                     const QString &revision = QString(), int lineNumber = -1);
116
    void svnDiff(const Subversion::Internal::SubversionDiffParameters &p);
117

con's avatar
con committed
118
119
120
121
122
123
private slots:
    void addCurrentFile();
    void revertCurrentFile();
    void diffProject();
    void diffCurrentFile();
    void startCommitAll();
124
    void startCommitProject();
con's avatar
con committed
125
    void startCommitCurrentFile();
126
    void revertAll();
con's avatar
con committed
127
128
    void filelogCurrentFile();
    void annotateCurrentFile();
129
    void annotateVersion(const QString &file, const QString &revision, int lineNumber);
con's avatar
con committed
130
131
    void projectStatus();
    void describe(const QString &source, const QString &changeNr);
132
    void slotDescribe();
con's avatar
con committed
133
134
    void updateProject();
    void submitCurrentLog();
135
    void diffCommitFiles(const QStringList &);
136
137
    void logProject();
    void logRepository();
138
139
140
    void diffRepository();
    void statusRepository();
    void updateRepository();
141

142
143
144
145
protected:
    virtual void updateActions(VCSBase::VCSBasePlugin::ActionState);
    virtual bool submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEditor);

con's avatar
con committed
146
private:
147
    inline bool isCommitEditorOpen() const;
con's avatar
con committed
148
149
150
    Core::IEditor * showOutputInEditor(const QString& title, const QString &output,
                                       int editorType, const QString &source,
                                       QTextCodec *codec);
151
    // Run using the settings' authentication options.
152
153
    SubversionResponse runSvn(const QString &workingDir,
                              const QStringList &arguments, int timeOut,
154
                              unsigned flags, QTextCodec *outputCodec = 0);
155
156
157
158
159
160
    // Run using custom authentication options.
    SubversionResponse runSvn(const QString &workingDir,
                              const QString &userName, const QString &password,
                              const QStringList &arguments, int timeOut,
                              unsigned flags, QTextCodec *outputCodec = 0);

161
162
163
    void filelog(const QString &workingDir,
                 const QStringList &file = QStringList(),
                 bool enableAnnotationContextMenu = false);
164
165
    void svnStatus(const QString &workingDir, const QStringList &relativePath = QStringList());
    void svnUpdate(const QString &workingDir, const QStringList &relativePaths = QStringList());
166
    bool checkSVNSubDir(const QDir &directory, const QString &fileName = QString()) const;
167
    void startCommit(const QString &workingDir, const QStringList &files = QStringList());
con's avatar
con committed
168
    bool commit(const QString &messageFile, const QStringList &subVersionFileList);
169
    void cleanCommitMessageFile();
170
    inline SubversionControl *subVersionControl() const;
con's avatar
con committed
171

172
    const QStringList m_svnDirectories;
con's avatar
con committed
173
174

    SubversionSettings m_settings;
175
    QString m_commitMessageFileName;
176
    QString m_commitRepository;
con's avatar
con committed
177

Friedemann Kleint's avatar
Friedemann Kleint committed
178
    Locator::CommandLocator *m_commandLocator;
179
180
181
    Utils::ParameterAction *m_addAction;
    Utils::ParameterAction *m_deleteAction;
    Utils::ParameterAction *m_revertAction;
182
    Utils::ParameterAction *m_diffProjectAction;
183
    Utils::ParameterAction *m_diffCurrentAction;
184
185
    Utils::ParameterAction *m_logProjectAction;
    QAction *m_logRepositoryAction;
con's avatar
con committed
186
    QAction *m_commitAllAction;
187
    QAction *m_revertRepositoryAction;
188
189
190
    QAction *m_diffRepositoryAction;
    QAction *m_statusRepositoryAction;
    QAction *m_updateRepositoryAction;
191
192
193
    Utils::ParameterAction *m_commitCurrentAction;
    Utils::ParameterAction *m_filelogCurrentAction;
    Utils::ParameterAction *m_annotateCurrentAction;
194
195
    Utils::ParameterAction *m_statusProjectAction;
    Utils::ParameterAction *m_updateProjectAction;
196
    Utils::ParameterAction *m_commitProjectAction;
197
    QAction *m_describeAction;
con's avatar
con committed
198
199
200
201
202

    QAction *m_submitCurrentLogAction;
    QAction *m_submitDiffAction;
    QAction *m_submitUndoAction;
    QAction *m_submitRedoAction;
203
    QAction *m_menuAction;
204
    bool    m_submitActionTriggered;
con's avatar
con committed
205
206
207
208
209
210
211
212

    static SubversionPlugin *m_subversionPluginInstance;
};

} // namespace Subversion
} // namespace Internal

#endif // SUBVERSIONPLUGIN_H