cvsplugin.h 7.26 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
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
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** 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
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** Alternatively, 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.
23
**
hjk's avatar
hjk committed
24 25
** 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
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29 30 31 32 33 34 35

#ifndef CVSPLUGIN_H
#define CVSPLUGIN_H

#include "cvssettings.h"
#include "cvsutils.h"

36
#include <vcsbase/vcsbaseplugin.h>
37 38 39 40 41 42 43 44

QT_BEGIN_NAMESPACE
class QDir;
class QAction;
class QTextCodec;
QT_END_NAMESPACE

namespace Core {
45
class CommandLocator;
hjk's avatar
hjk committed
46 47
class IEditorFactory;
class IVersionControl;
48 49
}

hjk's avatar
hjk committed
50 51
namespace Utils { class ParameterAction; }
namespace VcsBase { class VcsBaseSubmitEditor; }
52

hjk's avatar
hjk committed
53
namespace Cvs {
54
namespace Internal {
hjk's avatar
hjk committed
55

56
struct CvsDiffParameters;
hjk's avatar
hjk committed
57 58
class CvsSubmitEditor;
class CvsControl;
59
class CvsClient;
60

hjk's avatar
hjk committed
61
struct CvsResponse
62 63
{
    enum Result { Ok, NonNullExitCode, OtherError };
hjk's avatar
hjk committed
64
    CvsResponse() : result(Ok) {}
65 66 67 68 69 70 71

    Result result;
    QString stdOut;
    QString stdErr;
    QString message;
};

hjk's avatar
hjk committed
72
class CvsPlugin : public VcsBase::VcsBasePlugin
73 74
{
    Q_OBJECT
75
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CVS.json")
76 77

public:
hjk's avatar
hjk committed
78 79
    CvsPlugin();
    ~CvsPlugin();
80

81
    bool initialize(const QStringList &arguments, QString *errorMessage);
82

hjk's avatar
hjk committed
83
    CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName);
84

hjk's avatar
hjk committed
85 86
    CvsSettings settings() const;
    void setSettings(const CvsSettings &s);
87 88

    // IVersionControl
89 90
    bool vcsAdd(const QString &workingDir, const QString &fileName);
    bool vcsDelete(const QString &workingDir, const QString &fileName);
91
    bool managesDirectory(const QString &directory, QString *topLevel = 0) const;
92
    bool managesFile(const QString &workingDirectory, const QString &fileName) const;
93 94
    // cvs 'edit' is used to implement 'open' (cvsnt).
    bool edit(const QString &topLevel, const QStringList &files);
95

hjk's avatar
hjk committed
96
    static CvsPlugin *instance();
97

98
public slots:
99 100
    void vcsAnnotate(const QString &workingDirectory, const QString &file,
                     const QString &revision, int lineNumber);
101

102 103 104 105 106
private slots:
    void addCurrentFile();
    void revertCurrentFile();
    void diffProject();
    void diffCurrentFile();
107
    void revertAll();
108 109 110 111 112 113 114 115
    void startCommitAll();
    void startCommitCurrentFile();
    void filelogCurrentFile();
    void annotateCurrentFile();
    void projectStatus();
    void slotDescribe(const QString &source, const QString &changeNr);
    void updateProject();
    void submitCurrentLog();
116
    void diffCommitFiles(const QStringList &);
117 118
    void logProject();
    void logRepository();
119 120 121 122 123 124 125
    void commitProject();
    void diffRepository();
    void statusRepository();
    void updateRepository();
    void editCurrentFile();
    void uneditCurrentFile();
    void uneditCurrentRepository();
126 127 128
#ifdef WITH_TESTS
    void testDiffFileResolving_data();
    void testDiffFileResolving();
129
    void testLogResolving();
130
#endif
131

132
protected:
133
    void updateActions(VcsBase::VcsBasePlugin::ActionState);
134
    bool submitEditorAboutToClose();
135

136
private:
137
    bool isCommitEditorOpen() const;
hjk's avatar
hjk committed
138 139 140
    Core::IEditor *showOutputInEditor(const QString& title, const QString &output,
                                      int editorType, const QString &source,
                                      QTextCodec *codec);
141

hjk's avatar
hjk committed
142
    CvsResponse runCvs(const QString &workingDirectory,
143 144
                       const QStringList &arguments,
                       int timeOut,
145 146
                       unsigned flags,
                       QTextCodec *outputCodec = 0) const;
147

148 149
    void annotate(const QString &workingDir, const QString &file,
                  const QString &revision = QString(), int lineNumber= -1);
150
    bool describe(const QString &source, const QString &changeNr, QString *errorMessage);
151
    bool describe(const QString &toplevel, const QString &source, const QString &changeNr, QString *errorMessage);
hjk's avatar
hjk committed
152
    bool describe(const QString &repository, QList<CvsLogEntry> entries, QString *errorMessage);
153
    void filelog(const QString &workingDir,
154
                 const QString &file = QString(),
155
                 bool enableAnnotationContextMenu = false);
156
    bool unedit(const QString &topLevel, const QStringList &files);
157 158
    bool status(const QString &topLevel, const QString &file, const QString &title);
    bool update(const QString &topLevel, const QString &file);
159
    bool checkCVSDirectory(const QDir &directory) const;
160 161
    // Quick check if files are modified
    bool diffCheckModified(const QString &topLevel, const QStringList &files, bool *modified);
162
    QString findTopLevelForDirectoryI(const QString &directory) const;
163
    void startCommit(const QString &workingDir, const QString &file = QString());
164
    bool commit(const QString &messageFile, const QStringList &subVersionFileList);
165
    void cleanCommitMessageFile();
hjk's avatar
hjk committed
166
    inline CvsControl *cvsVersionControl() const;
167

hjk's avatar
hjk committed
168
    CvsSettings m_settings;
169 170
    CvsClient *m_client;

171
    QString m_commitMessageFileName;
172
    QString m_commitRepository;
173

174
    Core::CommandLocator *m_commandLocator;
175 176 177
    Utils::ParameterAction *m_addAction;
    Utils::ParameterAction *m_deleteAction;
    Utils::ParameterAction *m_revertAction;
178 179 180
    Utils::ParameterAction *m_editCurrentAction;
    Utils::ParameterAction *m_uneditCurrentAction;
    QAction *m_uneditRepositoryAction;
181
    Utils::ParameterAction *m_diffProjectAction;
182
    Utils::ParameterAction *m_diffCurrentAction;
183 184
    Utils::ParameterAction *m_logProjectAction;
    QAction *m_logRepositoryAction;
185
    QAction *m_commitAllAction;
186
    QAction *m_revertRepositoryAction;
187 188 189
    Utils::ParameterAction *m_commitCurrentAction;
    Utils::ParameterAction *m_filelogCurrentAction;
    Utils::ParameterAction *m_annotateCurrentAction;
190 191
    Utils::ParameterAction *m_statusProjectAction;
    Utils::ParameterAction *m_updateProjectAction;
192 193 194 195
    Utils::ParameterAction *m_commitProjectAction;
    QAction *m_diffRepositoryAction;
    QAction *m_updateRepositoryAction;
    QAction *m_statusRepositoryAction;
196 197 198 199 200

    QAction *m_submitCurrentLogAction;
    QAction *m_submitDiffAction;
    QAction *m_submitUndoAction;
    QAction *m_submitRedoAction;
201
    QAction *m_menuAction;
202 203
    bool    m_submitActionTriggered;

hjk's avatar
hjk committed
204
    static CvsPlugin *m_cvsPluginInstance;
205 206
};

hjk's avatar
hjk committed
207
} // namespace Cvs
208 209 210
} // namespace Internal

#endif // CVSPLUGIN_H