Commit ff1054fc authored by Friedemann Kleint's avatar Friedemann Kleint

Subversion: Adapt to new VCSBasePlugin.

Remove logic handling several repositories.
parent 168813e9
......@@ -115,7 +115,7 @@ GitPlugin::GitPlugin() :
m_blameAction(0),
m_logProjectAction(0),
m_undoFileAction(0),
m_undoProjectAction(0),
m_undoRepositoryAction(0),
m_showAction(0),
m_stageAction(0),
m_unstageAction(0),
......@@ -282,10 +282,10 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
connect(m_logProjectAction, SIGNAL(triggered()), this, SLOT(logProject()));
gitContainer->addAction(command);
m_undoProjectAction = new QAction(tr("Undo Project Changes"), this);
command = actionManager->registerAction(m_undoProjectAction, "Git.UndoProject", globalcontext);
m_undoRepositoryAction = new QAction(tr("Undo Repository Changes"), this);
command = actionManager->registerAction(m_undoRepositoryAction, "Git.UndoRepository", globalcontext);
command->setAttribute(Core::Command::CA_UpdateText);
connect(m_undoProjectAction, SIGNAL(triggered()), this, SLOT(undoProjectChanges()));
connect(m_undoRepositoryAction, SIGNAL(triggered()), this, SLOT(undoRepositoryChanges()));
gitContainer->addAction(command);
gitContainer->addAction(createSeparator(actionManager, globalcontext, QLatin1String("Git.Sep.Global"), this));
......@@ -428,7 +428,7 @@ void GitPlugin::undoFileChanges()
m_gitClient->revert(QStringList(state.currentFile()));
}
void GitPlugin::undoProjectChanges()
void GitPlugin::undoRepositoryChanges()
{
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return)
......@@ -669,7 +669,7 @@ void GitPlugin::updateActions(VCSBase::VCSBasePlugin::ActionState as)
m_diffProjectAction->setParameter(projectName);
m_logProjectAction->setEnabled(projectEnabled);
m_logProjectAction->setParameter(projectName);
m_undoProjectAction->setEnabled(projectEnabled);
m_undoRepositoryAction->setEnabled(projectEnabled);
const bool repositoryEnabled = currentState().hasTopLevel();
m_statusRepositoryAction->setEnabled(repositoryEnabled);
......
......@@ -95,7 +95,7 @@ private slots:
void blameFile();
void logProject();
void undoFileChanges();
void undoProjectChanges();
void undoRepositoryChanges();
void stageFile();
void unstageFile();
......@@ -126,7 +126,7 @@ private:
Utils::ParameterAction *m_blameAction;
Utils::ParameterAction *m_logProjectAction;
Utils::ParameterAction *m_undoFileAction;
QAction *m_undoProjectAction;
QAction *m_undoRepositoryAction;
QAction *m_showAction;
Utils::ParameterAction *m_stageAction;
Utils::ParameterAction *m_unstageAction;
......
......@@ -30,6 +30,8 @@
#include "subversioncontrol.h"
#include "subversionplugin.h"
#include <QtCore/QFileInfo>
using namespace Subversion;
using namespace Subversion::Internal;
......@@ -66,12 +68,14 @@ bool SubversionControl::vcsOpen(const QString & /* fileName */)
bool SubversionControl::vcsAdd(const QString &fileName)
{
return m_plugin->vcsAdd(fileName);
const QFileInfo fi(fileName);
return m_plugin->vcsAdd(fi.absolutePath(), fi.fileName());
}
bool SubversionControl::vcsDelete(const QString &fileName)
{
return m_plugin->vcsDelete(fileName);
const QFileInfo fi(fileName);
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
}
bool SubversionControl::managesDirectory(const QString &directory) const
......
......@@ -28,6 +28,7 @@
**************************************************************************/
#include "subversioneditor.h"
#include "subversionplugin.h"
#include "annotationhighlighter.h"
#include "subversionconstants.h"
......@@ -36,6 +37,7 @@
#include <vcsbase/diffhighlighter.h>
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
#include <QtGui/QTextCursor>
using namespace Subversion;
......@@ -127,9 +129,10 @@ QString SubversionEditor::fileNameFromDiffSpecification(const QTextBlock &inBloc
const int tabIndex = diffFileName.lastIndexOf(QLatin1Char('\t'));
if (tabIndex != -1)
diffFileName.truncate(tabIndex);
const QString rc = findDiffFile(diffFileName, SubversionPlugin::subversionPluginInstance()->versionControl());
if (Subversion::Constants::debug)
qDebug() << Q_FUNC_INFO << diffFileName;
return diffFileName;
qDebug() << Q_FUNC_INFO << diffFileName << rc << source();
return rc;
}
}
return QString();
......
This diff is collapsed.
......@@ -33,6 +33,7 @@
#include "subversionsettings.h"
#include <vcsbase/vcsbaseplugin.h>
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
class QDir;
......@@ -48,10 +49,6 @@ namespace Utils {
class ParameterAction;
}
namespace ProjectExplorer {
class ProjectExplorerPlugin;
}
namespace VCSBase {
class VCSBaseSubmitEditor;
}
......@@ -82,7 +79,7 @@ public:
bool initialize(const QStringList &arguments, QString *error_message);
void extensionsInitialized();
void svnDiff(const QStringList &files, QString diffname = QString());
void svnDiff(const QString &workingDir, const QStringList &files, QString diffname = QString());
SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName);
......@@ -90,8 +87,8 @@ public:
void setSettings(const SubversionSettings &s);
// IVersionControl
bool vcsAdd(const QString &fileName);
bool vcsDelete(const QString &fileName);
bool vcsAdd(const QString &workingDir, const QString &fileName);
bool vcsDelete(const QString &workingDir, const QString &fileName);
bool managesDirectory(const QString &directory) const;
QString findTopLevelForDirectory(const QString &directory) const;
......@@ -112,7 +109,7 @@ private slots:
void slotDescribe();
void updateProject();
void submitCurrentLog();
void diffFiles(const QStringList &);
void diffCommitFiles(const QStringList &);
protected:
virtual void updateActions(VCSBase::VCSBasePlugin::ActionState);
......@@ -120,18 +117,17 @@ protected:
private:
inline bool isCommitEditorOpen() const;
QString currentFileName() const;
Core::IEditor * showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source,
QTextCodec *codec);
SubversionResponse runSvn(const QStringList &arguments, int timeOut,
SubversionResponse runSvn(const QString &workingDir,
const QStringList &arguments, int timeOut,
bool showStdOutInOutputWindow, QTextCodec *outputCodec = 0);
void annotate(const QString &file);
void filelog(const QString &file);
void annotate(const QString &workingDir, const QString &file);
void filelog(const QString &workingDir, const QStringList &file = QStringList());
bool managesDirectory(const QDir &directory) const;
QString findTopLevelForDirectoryI(const QString &directory) const;
QStringList currentProjectsTopLevels(QString *name = 0) const;
void startCommit(const QStringList &files);
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
void cleanCommitMessageFile();
inline SubversionControl *subVersionControl() const;
......@@ -140,20 +136,19 @@ private:
SubversionSettings m_settings;
QString m_commitMessageFileName;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
QString m_commitRepository;
Utils::ParameterAction *m_addAction;
Utils::ParameterAction *m_deleteAction;
Utils::ParameterAction *m_revertAction;
QAction *m_diffProjectAction;
Utils::ParameterAction *m_diffProjectAction;
Utils::ParameterAction *m_diffCurrentAction;
QAction *m_commitAllAction;
Utils::ParameterAction *m_commitCurrentAction;
Utils::ParameterAction *m_filelogCurrentAction;
Utils::ParameterAction *m_annotateCurrentAction;
QAction *m_statusAction;
QAction *m_updateProjectAction;
Utils::ParameterAction *m_statusProjectAction;
Utils::ParameterAction *m_updateProjectAction;
QAction *m_describeAction;
QAction *m_submitCurrentLogAction;
......
......@@ -37,6 +37,7 @@
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/ifile.h>
#include <coreplugin/iversioncontrol.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/editorconfiguration.h>
#include <projectexplorer/projectexplorer.h>
......@@ -595,6 +596,13 @@ QTextCodec *VCSBaseEditor::getCodec(const QString &source)
return sys;
}
QTextCodec *VCSBaseEditor::getCodec(const QString &workingDirectory, const QStringList &files)
{
if (files.empty())
return getCodec(workingDirectory);
return getCodec(workingDirectory + QLatin1Char('/') + files.front());
}
VCSBaseEditor *VCSBaseEditor::getVcsBaseEditor(const Core::IEditor *editor)
{
if (const TextEditor::BaseTextEditorEditable *be = qobject_cast<const TextEditor::BaseTextEditorEditable *>(editor))
......@@ -667,4 +675,33 @@ QString VCSBaseEditor::getTitleId(const QString &workingDirectory, const QString
return fileNames.join(QLatin1String(", "));
}
// Find the complete file from a diff relative specification.
QString VCSBaseEditor::findDiffFile(const QString &f, Core::IVersionControl *control /* = 0 */) const
{
// Try the file.
const QFileInfo in(f);
if (in.isAbsolute())
return in.isFile() ? f : QString();
if (in.isFile())
return in.absoluteFilePath();
// Try in source directory
if (source().isEmpty())
return QString();
const QFileInfo sourceInfo(source());
const QString sourceDir = sourceInfo.isDir() ? sourceInfo.absoluteFilePath() : sourceInfo.absolutePath();
const QFileInfo sourceFileInfo(sourceDir + QLatin1Char('/') + f);
if (sourceFileInfo.isFile())
return sourceFileInfo.absoluteFilePath();
// Try to locate via repository.
if (!control)
return QString();
const QString topLevel = control->findTopLevelForDirectory(sourceDir);
if (topLevel.isEmpty())
return QString();
const QFileInfo topLevelFileInfo(topLevel + QLatin1Char('/') + f);
if (topLevelFileInfo.isFile())
return topLevelFileInfo.absoluteFilePath();
return QString();
}
} // namespace VCSBase
......@@ -42,6 +42,10 @@ class QTextCodec;
class QTextCursor;
QT_END_NAMESPACE
namespace Core {
class IVersionControl;
}
namespace VCSBase {
struct VCSBaseEditorPrivate;
......@@ -114,6 +118,7 @@ public:
// The codec should be set on editors displaying diff or annotation
// output.
static QTextCodec *getCodec(const QString &source);
static QTextCodec *getCodec(const QString &workingDirectory, const QStringList &files);
// Utility to return the editor from the IEditor returned by the editor
// manager which is a BaseTextEditable.
......@@ -164,6 +169,12 @@ private slots:
void slotDiffBrowse(int);
void slotDiffCursorPositionChanged();
protected:
/* A helper that can be used to locate a file in a diff in case it
* is relative. Tries to derive the directory from source and
* version control. */
QString findDiffFile(const QString &f, Core::IVersionControl *control = 0) const;
private:
// Implement to return a set of change identifiers in
// annotation mode
......
......@@ -142,12 +142,12 @@ protected:
explicit VCSBasePlugin(const QString &submitEditorKind);
void initialize(Core::IVersionControl *vc);
Core::IVersionControl *versionControl() const;
public:
virtual ~VCSBasePlugin();
const VCSBasePluginState &currentState() const;
Core::IVersionControl *versionControl() const;
protected:
enum ActionState { NoVCSEnabled, OtherVCSEnabled, VCSEnabled };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment