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

@@ -32,8 +32,7 @@
#include "subversionsettings.h"
#include <coreplugin/icorelistener.h>
#include <extensionsystem/iplugin.h>
#include <vcsbase/vcsbaseplugin.h>
QT_BEGIN_NAMESPACE
class QDir;
@@ -43,6 +42,7 @@ QT_END_NAMESPACE
namespace Core {
class IVersionControl;
class IEditor;
}
namespace Utils {
class ParameterAction;
@@ -52,6 +52,10 @@ namespace ProjectExplorer {
class ProjectExplorerPlugin;
}
namespace VCSBase {
class VCSBaseSubmitEditor;
}
namespace Subversion {
namespace Internal {
@@ -67,7 +71,7 @@ struct SubversionResponse
QString message;
};
class SubversionPlugin : public ExtensionSystem::IPlugin
class SubversionPlugin : public VCSBase::VCSBasePlugin
{
Q_OBJECT
@@ -77,7 +81,6 @@ public:
bool initialize(const QStringList &arguments, QString *error_message);
void extensionsInitialized();
bool editorAboutToClose(Core::IEditor *editor);
void svnDiff(const QStringList &files, QString diffname = QString());
@@ -95,7 +98,6 @@ public:
static SubversionPlugin *subversionPluginInstance();
private slots:
void updateActions();
void addCurrentFile();
void deleteCurrentFile();
void revertCurrentFile();
@@ -112,6 +114,10 @@ private slots:
void submitCurrentLog();
void diffFiles(const QStringList &);
protected:
virtual void updateActions(VCSBase::VCSBasePlugin::ActionState);
virtual bool submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEditor);
private:
inline bool isCommitEditorOpen() const;
QString currentFileName() const;
@@ -128,11 +134,11 @@ private:
void startCommit(const QStringList &files);
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
void cleanCommitMessageFile();
inline SubversionControl *subVersionControl() const;
const QStringList m_svnDirectories;
SubversionSettings m_settings;
SubversionControl *m_versionControl;
QString m_commitMessageFileName;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
@@ -154,32 +160,12 @@ private:
QAction *m_submitDiffAction;
QAction *m_submitUndoAction;
QAction *m_submitRedoAction;
QAction *m_menuAction;
bool m_submitActionTriggered;
static SubversionPlugin *m_subversionPluginInstance;
};
// Just a proxy for SubversionPlugin
class CoreListener : public Core::ICoreListener
{
Q_OBJECT
public:
CoreListener(SubversionPlugin *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:
SubversionPlugin *m_plugin;
};
} // namespace Subversion
} // namespace Internal