1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef IVERSIONCONTROL_H
35 #define IVERSIONCONTROL_H
37 #include "core_global.h"
39 #include <QtCore/QObject>
40 #include <QtCore/QString>
41 #include <QtCore/QFlags>
45 class CORE_EXPORT IVersionControl : public QObject
48 Q_ENUMS(SettingsFlag Operation)
53 Q_DECLARE_FLAGS(SettingsFlags, SettingsFlag)
56 AddOperation, DeleteOperation, OpenOperation, MoveOperation,
57 CreateRepositoryOperation,
61 GetRepositoryRootOperation
64 explicit IVersionControl(QObject *parent = 0) : QObject(parent) {}
65 virtual ~IVersionControl() {}
67 virtual QString displayName() const = 0;
70 * Returns whether files in this directory should be managed with this
72 * If \a topLevel is non-null, it should return the topmost directory,
73 * for which this IVersionControl should be used. The VcsManager assumes
74 * that all files in the returned directory are managed by the same IVersionControl.
77 virtual bool managesDirectory(const QString &filename, QString *topLevel = 0) const = 0;
80 * Called to query whether a VCS supports the respective operations.
82 virtual bool supportsOperation(Operation operation) const = 0;
85 * Called prior to save, if the file is read only. Should be implemented if
86 * the scc requires a operation before editing the file, e.g. 'p4 edit'
88 * \note The EditorManager calls this for the editors.
90 virtual bool vcsOpen(const QString &fileName) = 0;
96 virtual SettingsFlags settingsFlags() const { return 0; }
99 * Called after a file has been added to a project If the version control
100 * needs to know which files it needs to track you should reimplement this
101 * function, e.g. 'p4 add', 'cvs add', 'svn add'.
103 * \note This function should be called from IProject subclasses after
104 * files are added to the project.
106 virtual bool vcsAdd(const QString &filename) = 0;
109 * Called after a file has been removed from the project (if the user
110 * wants), e.g. 'p4 delete', 'svn delete'.
112 virtual bool vcsDelete(const QString &filename) = 0;
115 * Called to rename a file, should do the actual on disk renaming
116 * (e.g. git mv, svn move, p4 move)
118 virtual bool vcsMove(const QString &from, const QString &to) = 0;
121 * Called to initialize the version control system in a directory.
123 virtual bool vcsCreateRepository(const QString &directory) = 0;
126 * Called to clone/checkout the version control system in a directory.
128 virtual bool vcsCheckout(const QString &directory, const QByteArray &url) = 0;
131 * Called to get the version control repository root.
133 virtual QString vcsGetRepositoryURL(const QString &director) = 0;
136 * Create a snapshot of the current state and return an identifier or
137 * an empty string in case of failure.
139 virtual QString vcsCreateSnapshot(const QString &topLevel) = 0;
144 virtual QStringList vcsSnapshots(const QString &topLevel) = 0;
147 * Restore a snapshot.
149 virtual bool vcsRestoreSnapshot(const QString &topLevel, const QString &name) = 0;
154 virtual bool vcsRemoveSnapshot(const QString &topLevel, const QString &name) = 0;
157 * Display annotation for a file and scroll to line
159 virtual bool vcsAnnotate(const QString &file, int line) = 0;
162 void repositoryChanged(const QString &repository);
163 void filesChanged(const QStringList &files);
165 // TODO: ADD A WAY TO DETECT WHETHER A FILE IS MANAGED, e.g
166 // virtual bool sccManaged(const QString &filename) = 0;
169 Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IVersionControl::SettingsFlags)
173 #endif // IVERSIONCONTROL_H