forked from qt-creator/qt-creator
ClearCase: Partially move plugin pimpl to .cpp
Unfortuately, some deep accesses are not easy to get rid of. Make them available by static functions in the plugin itself. Definitely not the favorite setup, but allows to proceed with the QObject removals. Change-Id: Idc1624d2a4751b15159c3e36dcf8d2d476550167 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -60,11 +60,14 @@
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/runextensions.h>
|
||||
|
||||
#include <vcsbase/basevcseditorfactory.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/vcscommand.h>
|
||||
#include <vcsbase/vcsoutputwindow.h>
|
||||
#include <vcsbase/vcsbasesubmiteditor.h>
|
||||
#include <vcsbase/vcsbaseplugin.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
@@ -85,7 +88,6 @@
|
||||
#include <QRegExp>
|
||||
#include <QSharedPointer>
|
||||
#include <QTextCodec>
|
||||
#include <QtPlugin>
|
||||
#include <QUrl>
|
||||
#include <QUuid>
|
||||
#include <QVariant>
|
||||
@@ -121,6 +123,15 @@ static const char CMD_ID_UPDATE_VIEW[] = "ClearCase.UpdateView";
|
||||
static const char CMD_ID_CHECKIN_ALL[] = "ClearCase.CheckInAll";
|
||||
static const char CMD_ID_STATUS[] = "ClearCase.Status";
|
||||
|
||||
class ClearCaseResponse
|
||||
{
|
||||
public:
|
||||
bool error = false;
|
||||
QString stdOut;
|
||||
QString stdErr;
|
||||
QString message;
|
||||
};
|
||||
|
||||
static const VcsBaseEditorParameters editorParameters[] = {
|
||||
{
|
||||
LogOutput,
|
||||
@@ -150,6 +161,195 @@ static QString debugCodec(const QTextCodec *c)
|
||||
return c ? QString::fromLatin1(c->name()) : QString::fromLatin1("Null codec");
|
||||
}
|
||||
|
||||
class ClearCasePluginPrivate final : public VcsBase::VcsBasePluginPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
enum { SilentRun = VcsBase::VcsCommand::NoOutput | VcsBase::VcsCommand::FullySynchronously };
|
||||
|
||||
public:
|
||||
ClearCasePluginPrivate();
|
||||
~ClearCasePluginPrivate() final;
|
||||
|
||||
// IVersionControl
|
||||
QString displayName() const final;
|
||||
Core::Id id() const final;
|
||||
|
||||
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
|
||||
|
||||
bool managesDirectory(const QString &directory, QString *topLevel) const final;
|
||||
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
|
||||
|
||||
bool isConfigured() const final;
|
||||
|
||||
bool supportsOperation(Operation operation) const final;
|
||||
OpenSupportMode openSupportMode(const QString &fileName) const final;
|
||||
bool vcsOpen(const QString &fileName) final;
|
||||
SettingsFlags settingsFlags() const final;
|
||||
bool vcsAdd(const QString &fileName) final;
|
||||
bool vcsDelete(const QString &filename) final;
|
||||
bool vcsMove(const QString &from, const QString &to) final;
|
||||
bool vcsCreateRepository(const QString &directory) final;
|
||||
|
||||
bool vcsAnnotate(const QString &file, int line) final;
|
||||
|
||||
QString vcsOpenText() const final;
|
||||
QString vcsMakeWritableText() const final;
|
||||
QString vcsTopic(const QString &directory) final;
|
||||
|
||||
///
|
||||
ClearCaseSubmitEditor *openClearCaseSubmitEditor(const QString &fileName, bool isUcm);
|
||||
|
||||
const ClearCaseSettings &settings() const;
|
||||
void setSettings(const ClearCaseSettings &s);
|
||||
|
||||
// IVersionControl
|
||||
bool vcsOpen(const QString &workingDir, const QString &fileName);
|
||||
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
||||
bool vcsDelete(const QString &workingDir, const QString &fileName);
|
||||
bool vcsCheckIn(const QString &workingDir, const QStringList &files, const QString &activity,
|
||||
bool isIdentical, bool isPreserve, bool replaceActivity);
|
||||
bool vcsUndoCheckOut(const QString &workingDir, const QString &fileName, bool keep);
|
||||
bool vcsUndoHijack(const QString &workingDir, const QString &fileName, bool keep);
|
||||
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
|
||||
bool vcsSetActivity(const QString &workingDir, const QString &title, const QString &activity);
|
||||
|
||||
static ClearCasePluginPrivate *instance();
|
||||
|
||||
QString ccGetCurrentActivity() const;
|
||||
QList<QStringPair> activities(int *current = nullptr) const;
|
||||
QString ccGetPredecessor(const QString &version) const;
|
||||
QStringList ccGetActiveVobs() const;
|
||||
ViewData ccGetView(const QString &workingDir) const;
|
||||
QString ccGetComment(const QString &workingDir, const QString &fileName) const;
|
||||
bool ccFileOp(const QString &workingDir, const QString &title, const QStringList &args,
|
||||
const QString &fileName, const QString &file2 = QString());
|
||||
FileStatus vcsStatus(const QString &file) const;
|
||||
void checkAndReIndexUnknownFile(const QString &file);
|
||||
QString currentView() const { return m_viewData.name; }
|
||||
QString viewRoot() const { return m_viewData.root; }
|
||||
void refreshActivities();
|
||||
inline bool isUcm() const { return m_viewData.isUcm; }
|
||||
inline bool isDynamic() const { return m_viewData.isDynamic; }
|
||||
void setStatus(const QString &file, FileStatus::Status status, bool update = true);
|
||||
|
||||
bool ccCheckUcm(const QString &viewname, const QString &workingDir) const;
|
||||
#ifdef WITH_TESTS
|
||||
inline void setFakeCleartool(const bool b = true) { m_fakeClearTool = b; }
|
||||
#endif
|
||||
|
||||
void vcsAnnotateHelper(const QString &workingDir, const QString &file,
|
||||
const QString &revision = QString(), int lineNumber = -1) const;
|
||||
bool newActivity();
|
||||
void updateStreamAndView();
|
||||
void describe(const QString &source, const QString &changeNr);
|
||||
|
||||
protected:
|
||||
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) override;
|
||||
bool submitEditorAboutToClose() override;
|
||||
QString ccGet(const QString &workingDir, const QString &file, const QString &prefix = QString());
|
||||
QList<QStringPair> ccGetActivities() const;
|
||||
|
||||
private:
|
||||
void syncSlot();
|
||||
Q_INVOKABLE void updateStatusActions();
|
||||
|
||||
QString commitDisplayName() const final;
|
||||
void checkOutCurrentFile();
|
||||
void addCurrentFile();
|
||||
void undoCheckOutCurrent();
|
||||
void undoHijackCurrent();
|
||||
void diffActivity();
|
||||
void diffCurrentFile();
|
||||
void startCheckInAll();
|
||||
void startCheckInActivity();
|
||||
void startCheckInCurrentFile();
|
||||
void historyCurrentFile();
|
||||
void annotateCurrentFile();
|
||||
void viewStatus();
|
||||
void commitFromEditor() override;
|
||||
void diffCheckInFiles(const QStringList &);
|
||||
void updateIndex();
|
||||
void updateView();
|
||||
void projectChanged(ProjectExplorer::Project *project);
|
||||
void tasksFinished(Core::Id type);
|
||||
void closing();
|
||||
|
||||
inline bool isCheckInEditorOpen() const;
|
||||
QStringList getVobList() const;
|
||||
QString ccManagesDirectory(const QString &directory) const;
|
||||
QString ccViewRoot(const QString &directory) const;
|
||||
QString findTopLevel(const QString &directory) const;
|
||||
Core::IEditor *showOutputInEditor(const QString& title, const QString &output,
|
||||
int editorType, const QString &source,
|
||||
QTextCodec *codec) const;
|
||||
QString runCleartoolSync(const QString &workingDir, const QStringList &arguments) const;
|
||||
ClearCaseResponse runCleartool(const QString &workingDir, const QStringList &arguments,
|
||||
int timeOutS, unsigned flags,
|
||||
QTextCodec *outputCodec = nullptr) const;
|
||||
static void sync(QFutureInterface<void> &future, QStringList files);
|
||||
|
||||
void history(const QString &workingDir,
|
||||
const QStringList &file = QStringList(),
|
||||
bool enableAnnotationContextMenu = false);
|
||||
QString ccGetFileVersion(const QString &workingDir, const QString &file) const;
|
||||
void ccUpdate(const QString &workingDir, const QStringList &relativePaths = QStringList());
|
||||
void ccDiffWithPred(const QString &workingDir, const QStringList &files);
|
||||
void startCheckIn(const QString &workingDir, const QStringList &files = QStringList());
|
||||
void cleanCheckInMessageFile();
|
||||
QString ccGetFileActivity(const QString &workingDir, const QString &file);
|
||||
QStringList ccGetActivityVersions(const QString &workingDir, const QString &activity);
|
||||
void diffGraphical(const QString &file1, const QString &file2 = QString());
|
||||
QString diffExternal(QString file1, QString file2 = QString(), bool keep = false);
|
||||
QString getFile(const QString &nativeFile, const QString &prefix);
|
||||
static void rmdir(const QString &path);
|
||||
QString runExtDiff(const QString &workingDir, const QStringList &arguments, int timeOutS,
|
||||
QTextCodec *outputCodec = nullptr);
|
||||
static QString getDriveLetterOfPath(const QString &directory);
|
||||
|
||||
FileStatus::Status getFileStatus(const QString &fileName) const;
|
||||
void updateStatusForFile(const QString &absFile);
|
||||
void updateEditDerivedObjectWarning(const QString &fileName, const FileStatus::Status status);
|
||||
|
||||
ClearCaseSettings m_settings;
|
||||
|
||||
QString m_checkInMessageFileName;
|
||||
QString m_checkInView;
|
||||
QString m_topLevel;
|
||||
QString m_stream;
|
||||
ViewData m_viewData;
|
||||
QString m_intStream;
|
||||
QString m_activity;
|
||||
QString m_diffPrefix;
|
||||
|
||||
Core::CommandLocator *m_commandLocator = nullptr;
|
||||
Utils::ParameterAction *m_checkOutAction = nullptr;
|
||||
Utils::ParameterAction *m_checkInCurrentAction = nullptr;
|
||||
Utils::ParameterAction *m_undoCheckOutAction = nullptr;
|
||||
Utils::ParameterAction *m_undoHijackAction = nullptr;
|
||||
Utils::ParameterAction *m_diffCurrentAction = nullptr;
|
||||
Utils::ParameterAction *m_historyCurrentAction = nullptr;
|
||||
Utils::ParameterAction *m_annotateCurrentAction = nullptr;
|
||||
Utils::ParameterAction *m_addFileAction = nullptr;
|
||||
QAction *m_diffActivityAction = nullptr;
|
||||
QAction *m_updateIndexAction = nullptr;
|
||||
Utils::ParameterAction *m_updateViewAction = nullptr;
|
||||
Utils::ParameterAction *m_checkInActivityAction = nullptr;
|
||||
QAction *m_checkInAllAction = nullptr;
|
||||
QAction *m_statusAction = nullptr;
|
||||
|
||||
QAction *m_menuAction = nullptr;
|
||||
bool m_submitActionTriggered = false;
|
||||
QMutex *m_activityMutex;
|
||||
QList<QStringPair> m_activities;
|
||||
QSharedPointer<StatusMap> m_statusMap;
|
||||
|
||||
friend class ClearCasePlugin;
|
||||
#ifdef WITH_TESTS
|
||||
bool m_fakeClearTool = false;
|
||||
QString m_tempFile;
|
||||
#endif
|
||||
};
|
||||
|
||||
// ------------- ClearCasePlugin
|
||||
static ClearCasePluginPrivate *dd = nullptr;
|
||||
|
||||
@@ -162,12 +362,6 @@ ClearCasePluginPrivate::~ClearCasePluginPrivate()
|
||||
delete m_activityMutex;
|
||||
}
|
||||
|
||||
ClearCasePlugin::~ClearCasePlugin()
|
||||
{
|
||||
delete dd;
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
void ClearCasePluginPrivate::cleanCheckInMessageFile()
|
||||
{
|
||||
if (!m_checkInMessageFileName.isEmpty()) {
|
||||
@@ -2176,7 +2370,7 @@ void ClearCasePluginPrivate::closing()
|
||||
void ClearCasePluginPrivate::sync(QFutureInterface<void> &future, QStringList files)
|
||||
{
|
||||
ClearCasePluginPrivate *plugin = ClearCasePluginPrivate::instance();
|
||||
ClearCaseSync ccSync(plugin, plugin->m_statusMap);
|
||||
ClearCaseSync ccSync(plugin->m_statusMap);
|
||||
connect(&ccSync, &ClearCaseSync::updateStreamAndView, plugin, &ClearCasePluginPrivate::updateStreamAndView);
|
||||
ccSync.run(future, files);
|
||||
}
|
||||
@@ -2309,6 +2503,59 @@ bool ClearCasePluginPrivate::vcsCreateRepository(const QString &)
|
||||
return false;
|
||||
}
|
||||
|
||||
// ClearCasePlugin
|
||||
|
||||
ClearCasePlugin::~ClearCasePlugin()
|
||||
{
|
||||
delete dd;
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
bool ClearCasePlugin::newActivity()
|
||||
{
|
||||
return dd->newActivity();
|
||||
}
|
||||
|
||||
const QList<QStringPair> ClearCasePlugin::activities(int *current)
|
||||
{
|
||||
return dd->activities(current);
|
||||
}
|
||||
|
||||
QStringList ClearCasePlugin::ccGetActiveVobs()
|
||||
{
|
||||
return dd->ccGetActiveVobs();
|
||||
}
|
||||
|
||||
void ClearCasePlugin::refreshActivities()
|
||||
{
|
||||
dd->refreshActivities();
|
||||
}
|
||||
|
||||
const ViewData ClearCasePlugin::viewData()
|
||||
{
|
||||
return dd->m_viewData;
|
||||
}
|
||||
|
||||
void ClearCasePlugin::setStatus(const QString &file, FileStatus::Status status, bool update)
|
||||
{
|
||||
dd->setStatus(file, status, update);
|
||||
}
|
||||
|
||||
const ClearCaseSettings &ClearCasePlugin::settings()
|
||||
{
|
||||
return dd->m_settings;
|
||||
}
|
||||
|
||||
void ClearCasePlugin::setSettings(const ClearCaseSettings &s)
|
||||
{
|
||||
dd->setSettings(s);
|
||||
}
|
||||
|
||||
QSharedPointer<StatusMap> ClearCasePlugin::statusMap()
|
||||
{
|
||||
return dd->m_statusMap;
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
void ClearCasePlugin::testDiffFileResolving_data()
|
||||
@@ -2388,14 +2635,14 @@ void ClearCasePlugin::testFileStatusParsing()
|
||||
QFETCH(QString, cleartoolLsLine);
|
||||
QFETCH(int, status);
|
||||
|
||||
ClearCaseSync ccSync(dd, dd->m_statusMap);
|
||||
ClearCaseSync ccSync(dd->m_statusMap);
|
||||
ccSync.verifyParseStatus(filename, cleartoolLsLine, static_cast<FileStatus::Status>(status));
|
||||
}
|
||||
|
||||
void ClearCasePlugin::testFileNotManaged()
|
||||
{
|
||||
dd->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
|
||||
ClearCaseSync ccSync(dd, dd->m_statusMap);
|
||||
ClearCaseSync ccSync(dd->m_statusMap);
|
||||
ccSync.verifyFileNotManaged();
|
||||
}
|
||||
|
||||
@@ -2403,21 +2650,21 @@ void ClearCasePlugin::testFileCheckedOutDynamicView()
|
||||
{
|
||||
dd->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
|
||||
|
||||
ClearCaseSync ccSync(dd, dd->m_statusMap);
|
||||
ClearCaseSync ccSync(dd->m_statusMap);
|
||||
ccSync.verifyFileCheckedOutDynamicView();
|
||||
}
|
||||
|
||||
void ClearCasePlugin::testFileCheckedInDynamicView()
|
||||
{
|
||||
dd->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
|
||||
ClearCaseSync ccSync(dd, dd->m_statusMap);
|
||||
ClearCaseSync ccSync(dd->m_statusMap);
|
||||
ccSync.verifyFileCheckedInDynamicView();
|
||||
}
|
||||
|
||||
void ClearCasePlugin::testFileNotManagedDynamicView()
|
||||
{
|
||||
dd->m_statusMap = QSharedPointer<StatusMap>(new StatusMap);
|
||||
ClearCaseSync ccSync(dd, dd->m_statusMap);
|
||||
ClearCaseSync ccSync(dd->m_statusMap);
|
||||
ccSync.verifyFileNotManagedDynamicView();
|
||||
}
|
||||
|
||||
@@ -2564,3 +2811,5 @@ void ClearCasePlugin::testVcsStatusDynamicNotManaged()
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClearCase
|
||||
|
||||
#include "clearcaseplugin.moc"
|
||||
|
||||
Reference in New Issue
Block a user