subversionplugin.h 7.17 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
** 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
** a written agreement between you and Digia.  For licensing terms and
Eike Ziller's avatar
Eike Ziller committed
13
14
** conditions see http://www.qt.io/licensing.  For further information
** use the contact form at http://www.qt.io/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
** Alternatively, this file may be used under the terms of the GNU Lesser
Eike Ziller's avatar
Eike Ziller committed
18
19
20
21
22
23
** 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.
hjk's avatar
hjk committed
24
25
26
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
27
28
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
29
****************************************************************************/
hjk's avatar
hjk committed
30

con's avatar
con committed
31
32
33
34
35
#ifndef SUBVERSIONPLUGIN_H
#define SUBVERSIONPLUGIN_H

#include "subversionsettings.h"

36
#include <vcsbase/vcsbaseplugin.h>
37
#include <QStringList>
con's avatar
con committed
38
39
40
41
42
43
44
45

QT_BEGIN_NAMESPACE
class QDir;
class QAction;
class QTextCodec;
QT_END_NAMESPACE

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

namespace Subversion {
namespace Internal {

class SubversionSubmitEditor;
55
class SubversionControl;
56
class SubversionClient;
con's avatar
con committed
57
58
59
60
61
62
63
64
65
66

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

hjk's avatar
hjk committed
67
class SubversionPlugin : public VcsBase::VcsBasePlugin
con's avatar
con committed
68
69
{
    Q_OBJECT
70
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Subversion.json")
con's avatar
con committed
71
72
73
74
75

public:
    SubversionPlugin();
    ~SubversionPlugin();

hjk's avatar
hjk committed
76
    bool initialize(const QStringList &arguments, QString *errorMessage);
con's avatar
con committed
77
78
79
80
81
82
83

    SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName);

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

    // IVersionControl
84
85
    bool vcsAdd(const QString &workingDir, const QString &fileName);
    bool vcsDelete(const QString &workingDir, const QString &fileName);
dt's avatar
dt committed
86
    bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
87
    bool managesDirectory(const QString &directory, QString *topLevel = 0) const;
88
    bool managesFile(const QString &workingDirectory, const QString &fileName) const;
Orgad Shaneh's avatar
Orgad Shaneh committed
89
90
    bool vcsCheckout(const QString &directory, const QByteArray &url);
    QString vcsGetRepositoryURL(const QString &directory);
con's avatar
con committed
91

92
    static SubversionPlugin *instance();
con's avatar
con committed
93

Tobias Hunger's avatar
Tobias Hunger committed
94
95
96
    QString monitorFile(const QString &repository) const;
    QString synchronousTopic(const QString &repository) const;

97
98
99
100
public slots:
    void vcsAnnotate(const QString &workingDir, const QString &file,
                     const QString &revision = QString(), int lineNumber = -1);

con's avatar
con committed
101
102
103
104
105
private slots:
    void addCurrentFile();
    void revertCurrentFile();
    void diffProject();
    void diffCurrentFile();
106
    void cleanCommitMessageFile();
con's avatar
con committed
107
    void startCommitAll();
108
    void startCommitProject();
con's avatar
con committed
109
    void startCommitCurrentFile();
110
    void revertAll();
con's avatar
con committed
111
112
    void filelogCurrentFile();
    void annotateCurrentFile();
113
    void annotateVersion(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber);
con's avatar
con committed
114
115
    void projectStatus();
    void describe(const QString &source, const QString &changeNr);
116
    void slotDescribe();
con's avatar
con committed
117
118
    void updateProject();
    void submitCurrentLog();
119
    void diffCommitFiles(const QStringList &);
120
121
    void logProject();
    void logRepository();
122
123
124
    void diffRepository();
    void statusRepository();
    void updateRepository();
125
126
127
#ifdef WITH_TESTS
    void testDiffFileResolving_data();
    void testDiffFileResolving();
128
    void testLogResolving();
129
#endif
130

131
protected:
Orgad Shaneh's avatar
Orgad Shaneh committed
132
    void updateActions(VcsBase::VcsBasePlugin::ActionState);
133
    bool submitEditorAboutToClose();
134

con's avatar
con committed
135
private:
136
    inline bool isCommitEditorOpen() const;
con's avatar
con committed
137
138
139
    Core::IEditor * showOutputInEditor(const QString& title, const QString &output,
                                       int editorType, const QString &source,
                                       QTextCodec *codec);
140
    // Run using the settings' authentication options.
141
142
    SubversionResponse runSvn(const QString &workingDir,
                              const QStringList &arguments, int timeOut,
143
                              unsigned flags, QTextCodec *outputCodec = 0) const;
144
145
146
147
    // Run using custom authentication options.
    SubversionResponse runSvn(const QString &workingDir,
                              const QString &userName, const QString &password,
                              const QStringList &arguments, int timeOut,
148
                              unsigned flags, QTextCodec *outputCodec = 0) const;
149

150
    void filelog(const QString &workingDir,
151
                 const QString &file = QString(),
152
                 bool enableAnnotationContextMenu = false);
153
154
    void svnStatus(const QString &workingDir, const QString &relativePath = QString());
    void svnUpdate(const QString &workingDir, const QString &relativePath = QString());
155
    bool checkSVNSubDir(const QDir &directory) const;
156
    void startCommit(const QString &workingDir, const QStringList &files = QStringList());
157
    inline SubversionControl *subVersionControl() const;
con's avatar
con committed
158

159
    const QStringList m_svnDirectories;
con's avatar
con committed
160
161

    SubversionSettings m_settings;
162
    SubversionClient *m_client;
163
    QString m_commitMessageFileName;
164
    QString m_commitRepository;
con's avatar
con committed
165

166
    Core::CommandLocator *m_commandLocator;
167
168
169
    Utils::ParameterAction *m_addAction;
    Utils::ParameterAction *m_deleteAction;
    Utils::ParameterAction *m_revertAction;
170
    Utils::ParameterAction *m_diffProjectAction;
171
    Utils::ParameterAction *m_diffCurrentAction;
172
173
    Utils::ParameterAction *m_logProjectAction;
    QAction *m_logRepositoryAction;
con's avatar
con committed
174
    QAction *m_commitAllAction;
175
    QAction *m_revertRepositoryAction;
176
177
178
    QAction *m_diffRepositoryAction;
    QAction *m_statusRepositoryAction;
    QAction *m_updateRepositoryAction;
179
180
181
    Utils::ParameterAction *m_commitCurrentAction;
    Utils::ParameterAction *m_filelogCurrentAction;
    Utils::ParameterAction *m_annotateCurrentAction;
182
183
    Utils::ParameterAction *m_statusProjectAction;
    Utils::ParameterAction *m_updateProjectAction;
184
    Utils::ParameterAction *m_commitProjectAction;
185
    QAction *m_describeAction;
con's avatar
con committed
186
187
188
189
190

    QAction *m_submitCurrentLogAction;
    QAction *m_submitDiffAction;
    QAction *m_submitUndoAction;
    QAction *m_submitRedoAction;
191
    QAction *m_menuAction;
192
    bool    m_submitActionTriggered;
con's avatar
con committed
193
194
195
196
197
198
199
200

    static SubversionPlugin *m_subversionPluginInstance;
};

} // namespace Subversion
} // namespace Internal

#endif // SUBVERSIONPLUGIN_H