cvsplugin.h 7.44 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
Eike Ziller's avatar
Eike Ziller committed
3 4
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11
** 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
Eike Ziller's avatar
Eike Ziller committed
12 13
** a written agreement between you and The Qt Company.  For licensing terms and
** conditions see http://www.qt.io/terms-conditions.  For further information
Eike Ziller's avatar
Eike Ziller committed
14
** 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.
24
**
Eike Ziller's avatar
Eike Ziller committed
25 26
** In addition, as a special exception, The Qt Company gives you certain additional
** rights.  These rights are described in The Qt Company 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
****************************************************************************/
30 31 32 33 34 35 36

#ifndef CVSPLUGIN_H
#define CVSPLUGIN_H

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

37
#include <vcsbase/vcsbaseplugin.h>
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;
hjk's avatar
hjk committed
47
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 82
    CvsClient *client() const;

Orgad Shaneh's avatar
Orgad Shaneh committed
83
    bool initialize(const QStringList &arguments, QString *errorMessage);
84

hjk's avatar
hjk committed
85
    CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName);
86 87

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

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

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

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

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

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

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

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

hjk's avatar
hjk committed
169
    CvsSettings m_settings;
170
    CvsClient *m_client = nullptr;
171

172
    QString m_commitMessageFileName;
173
    QString m_commitRepository;
174

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

    QAction *m_submitCurrentLogAction;
    QAction *m_submitDiffAction;
    QAction *m_submitUndoAction;
    QAction *m_submitRedoAction;
204
    QAction *m_menuAction;
205 206
    bool    m_submitActionTriggered;

hjk's avatar
hjk committed
207
    static CvsPlugin *m_cvsPluginInstance;
208 209
};

hjk's avatar
hjk committed
210
} // namespace Cvs
211 212 213
} // namespace Internal

#endif // CVSPLUGIN_H