Commit 75e7d30d authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

VCS[git]: Reorganize menu action creation/Start SVN submenu.

Create actions with convenient factory functions, do enabling per
file/project/repository centrally.
parent a61728f6
......@@ -1035,6 +1035,8 @@ QStringList GitClient::processEnvironment() const
ProjectExplorer::Environment environment = ProjectExplorer::Environment::systemEnvironment();
if (m_settings.adoptPath)
environment.set(QLatin1String("PATH"), m_settings.path);
// git svn runs perl which barfs at non-C locales.
environment.set(QLatin1String("LANG"), QString(QLatin1Char('C')));
return environment.toStringList();
}
......@@ -1447,6 +1449,33 @@ void GitClient::pull(const QString &workingDirectory)
connectRepositoryChanged(workingDirectory, cmd);
}
// Subversion: git svn
void GitClient::subversionFetch(const QString &workingDirectory)
{
QStringList args;
args << QLatin1String("svn") << QLatin1String("fetch");
GitCommand *cmd = executeGit(workingDirectory, args, 0, true, GitCommand::ReportStderr);
connectRepositoryChanged(workingDirectory, cmd);
}
void GitClient::subversionLog(const QString &workingDirectory)
{
if (Git::Constants::debug)
qDebug() << "subversionLog" << workingDirectory;
QStringList arguments;
arguments << QLatin1String("svn") << QLatin1String("log");
if (m_settings.logCount > 0)
arguments << (QLatin1String("--limit=") + QString::number(m_settings.logCount));
// Create a command editor, no highlighting or interaction.
const QString title = tr("Git SVN Log");
const QString editorId = QLatin1String(Git::Constants::C_GIT_COMMAND_LOG_EDITOR);
const QString sourceFile = VCSBase::VCSBaseEditor::getSource(workingDirectory, QStringList());
VCSBase::VCSBaseEditor *editor = createVCSEditor(editorId, title, sourceFile, false, "svnLog", sourceFile);
executeGit(workingDirectory, arguments, editor);
}
void GitClient::push(const QString &workingDirectory)
{
executeGit(workingDirectory, QStringList(QLatin1String("push")), 0, true, GitCommand::ReportStderr);
......
......@@ -154,6 +154,10 @@ public:
void pull(const QString &workingDirectory);
void push(const QString &workingDirectory);
// git svn support (asynchronous).
void subversionFetch(const QString &workingDirectory);
void subversionLog(const QString &workingDirectory);
void stashPop(const QString &workingDirectory);
void revert(const QStringList &files);
void branchList(const QString &workingDirectory);
......
This diff is collapsed.
......@@ -40,6 +40,8 @@
#include <QtCore/QProcess>
#include <QtCore/QStringList>
#include <QtCore/QPointer>
#include <QtCore/QPair>
#include <QtCore/QVector>
QT_BEGIN_NAMESPACE
class QFile;
......@@ -50,6 +52,9 @@ QT_END_NAMESPACE
namespace Core {
class IEditorFactory;
class ICore;
class Command;
class ActionManager;
class ActionContainer;
}
namespace Utils {
class ParameterAction;
......@@ -70,6 +75,11 @@ struct GitSettings;
class StashDialog;
class BranchDialog;
typedef void (GitClient::*GitClientMemberFunc)(const QString &);
typedef QPair<QAction *, Core::Command* > ActionCommandPair;
typedef QPair<Utils::ParameterAction *, Core::Command* > ParameterActionCommandPair;
class GitPlugin : public VCSBase::VCSBasePlugin
{
Q_OBJECT
......@@ -96,23 +106,21 @@ private slots:
void diffRepository();
void submitEditorDiff(const QStringList &unstaged, const QStringList &staged);
void submitCurrentLog();
void statusRepository();
void logFile();
void blameFile();
void logProject();
void undoFileChanges();
void logRepository();
void undoRepositoryChanges();
void stageFile();
void unstageFile();
void cleanProject();
void cleanRepository();
void gitClientMemberFuncRepositoryAction();
void showCommit();
void startCommit();
void stash();
void stashSnapshot();
void stashPop();
void branchList();
void stashList();
void pull();
......@@ -123,6 +131,41 @@ protected:
virtual bool submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEditor);
private:
inline ParameterActionCommandPair
createParameterAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator);
inline ParameterActionCommandPair
createFileAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator,
const char *pluginSlot);
inline ParameterActionCommandPair
createProjectAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator);
inline ParameterActionCommandPair
createProjectAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &defaultText, const QString &parameterText,
const QString &id, const QList<int> &context, bool addToLocator,
const char *pluginSlot);
inline ActionCommandPair createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context, bool addToLocator);
inline ActionCommandPair createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context,
bool addToLocator, const char *pluginSlot);
inline ActionCommandPair createRepositoryAction(Core::ActionManager *am, Core::ActionContainer *ac,
const QString &text, const QString &id,
const QList<int> &context,
bool addToLocator, GitClientMemberFunc);
bool isCommitEditorOpen() const;
Core::IEditor *openSubmitEditor(const QString &fileName, const CommitData &cd);
void cleanCommitMessageFile();
......@@ -131,38 +174,20 @@ private:
static GitPlugin *m_instance;
Core::ICore *m_core;
Locator::CommandLocator *m_commandLocator;
Utils::ParameterAction *m_diffAction;
Utils::ParameterAction *m_diffProjectAction;
QAction *m_diffRepositoryAction;
QAction *m_statusRepositoryAction;
Utils::ParameterAction *m_logAction;
Utils::ParameterAction *m_blameAction;
Utils::ParameterAction *m_logProjectAction;
Utils::ParameterAction *m_undoFileAction;
QAction *m_logRepositoryAction;
QAction *m_undoRepositoryAction;
QAction *m_createRepositoryAction;
QAction *m_showAction;
Utils::ParameterAction *m_stageAction;
Utils::ParameterAction *m_unstageAction;
QAction *m_commitAction;
QAction *m_pullAction;
QAction *m_pushAction;
Utils::ParameterAction *m_cleanProjectAction;
QAction *m_cleanRepositoryAction;
QAction *m_submitCurrentAction;
QAction *m_diffSelectedFilesAction;
QAction *m_undoAction;
QAction *m_redoAction;
QAction *m_stashAction;
QAction *m_stashSnapshotAction;
QAction *m_stashPopAction;
QAction *m_stashListAction;
QAction *m_branchListAction;
QAction *m_menuAction;
QVector<Utils::ParameterAction *> m_fileActions;
QVector<Utils::ParameterAction *> m_projectActions;
QVector<QAction *> m_repositoryActions;
GitClient *m_gitClient;
ChangeSelectionDialog *m_changeSelectionDialog;
QPointer<StashDialog> m_stashDialog;
......
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