VCS: Introduce Base class for VCS plugins, use in git.

Fixes:
- Cannot diff a file that does not belong to a project
- Cannot commit when a temporary diff/log view is open
  due to the current file pointing to a temporary directory
- git's project-related actions not passing the correct
  relative path.

Implementation:
- Centralize code to listen for Qt Creator's relevant state changes
  in VCSBasePlugin, dispatching the changes to the instances affected.
  (avoiding multiple invocations of searches/QFileInfo on current).
- Do the same for the corelistener catching closing SubmitEditors.
- Introduce VCSBasePluginState representing the relevant state
  (current file/project).
- Call git with working directory set and relative arguments
- Remove setEnabled/isEnabled() logic of IVersionControl
- Pass toplevel from VCSManager to avoid duplicate searches.
This commit is contained in:
Friedemann Kleint
2009-12-08 14:26:41 +01:00
parent 8d6b4e51ab
commit 8097879d6d
31 changed files with 891 additions and 699 deletions

View File

@@ -33,8 +33,7 @@
#include "cvssettings.h"
#include "cvsutils.h"
#include <coreplugin/icorelistener.h>
#include <extensionsystem/iplugin.h>
#include <vcsbase/vcsbaseplugin.h>
QT_BEGIN_NAMESPACE
class QDir;
@@ -55,6 +54,10 @@ namespace ProjectExplorer {
class ProjectExplorerPlugin;
}
namespace VCSBase {
class VCSBaseSubmitEditor;
}
namespace CVS {
namespace Internal {
@@ -80,7 +83,7 @@ struct CVSResponse
* the diff editor has an additional property specifying the
* base directory for its interaction to work. */
class CVSPlugin : public ExtensionSystem::IPlugin
class CVSPlugin : public VCSBase::VCSBasePlugin
{
Q_OBJECT
@@ -90,7 +93,6 @@ public:
virtual bool initialize(const QStringList &arguments, QString *error_message);
virtual void extensionsInitialized();
virtual bool editorAboutToClose(Core::IEditor *editor);
void cvsDiff(const QStringList &files, QString diffname = QString());
@@ -108,7 +110,6 @@ public:
static CVSPlugin *cvsPluginInstance();
private slots:
void updateActions();
void addCurrentFile();
void deleteCurrentFile();
void revertCurrentFile();
@@ -124,6 +125,10 @@ private slots:
void submitCurrentLog();
void diffFiles(const QStringList &);
protected:
virtual void updateActions(VCSBase::VCSBasePlugin::ActionState);
virtual bool submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEditor);
private:
bool isCommitEditorOpen() const;
QString currentFileName() const;
@@ -152,9 +157,9 @@ private:
void startCommit(const QString &file);
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
void cleanCommitMessageFile();
inline CVSControl *cvsVersionControl() const;
CVSSettings m_settings;
CVSControl *m_versionControl;
QString m_commitMessageFileName;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
@@ -175,32 +180,12 @@ private:
QAction *m_submitDiffAction;
QAction *m_submitUndoAction;
QAction *m_submitRedoAction;
QAction *m_menuAction;
bool m_submitActionTriggered;
static CVSPlugin *m_cvsPluginInstance;
};
// Just a proxy for CVSPlugin
class CoreListener : public Core::ICoreListener
{
Q_OBJECT
public:
CoreListener(CVSPlugin *plugin) : m_plugin(plugin) { }
// Start commit when submit editor closes
bool editorAboutToClose(Core::IEditor *editor) {
return m_plugin->editorAboutToClose(editor);
}
// TODO: how to handle that ???
bool coreAboutToClose() {
return true;
}
private:
CVSPlugin *m_plugin;
};
} // namespace CVS
} // namespace Internal