Commit 0d0d79ce authored by Hugues Delorme's avatar Hugues Delorme Committed by Tobias Hunger

Svn: Asynchronous exec of commit operations

Use VcsBase::Command to implement the SVN commit operation, allowing
asynchronous execution (so the user can do something else while
committing)

Change-Id: Ic5513676d4dfea1920bb6610efa33788878a2a83
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent ddfc1f8d
......@@ -29,7 +29,9 @@
#include "subversionclient.h"
#include "subversionsettings.h"
#include "subversionconstants.h"
#include <vcsbase/command.h>
#include <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseeditorparameterwidget.h>
......@@ -104,6 +106,35 @@ SubversionSettings *SubversionClient::settings() const
return dynamic_cast<SubversionSettings *>(VcsBase::VcsBaseClient::settings());
}
VcsBase::Command *SubversionClient::createCommitCmd(const QString &repositoryRoot,
const QStringList &files,
const QString &commitMessageFile,
const QStringList &extraOptions) const
{
const QStringList svnExtraOptions =
QStringList(extraOptions)
<< authenticationOptions(SubversionClient::CommitCommand)
<< QLatin1String(Constants::NON_INTERACTIVE_OPTION)
<< QLatin1String("--file") << commitMessageFile;
VcsBase::Command *cmd = createCommand(repositoryRoot);
QStringList args(vcsCommandString(CommitCommand));
cmd->addJob(args << svnExtraOptions << files);
return cmd;
}
void SubversionClient::commit(const QString &repositoryRoot,
const QStringList &files,
const QString &commitMessageFile,
const QStringList &extraOptions)
{
if (Subversion::Constants::debug)
qDebug() << Q_FUNC_INFO << commitMessageFile << files;
VcsBase::Command *cmd = createCommitCmd(repositoryRoot, files, commitMessageFile, extraOptions);
cmd->execute();
}
Core::Id SubversionClient::vcsEditorKind(VcsCommand cmd) const
{
switch (cmd) {
......@@ -141,6 +172,17 @@ SubversionClient::Version SubversionClient::svnVersion()
return v;
}
QStringList SubversionClient::authenticationOptions(VcsCommand cmd) const
{
const bool hasAuth = settings()->hasAuthentication();
const QString userName = hasAuth ? settings()->stringValue(SubversionSettings::userKey) : QString();
const QString password = hasAuth ? settings()->stringValue(SubversionSettings::passwordKey) : QString();
QStringList args(vcsCommandString(cmd));
args = SubversionClient::addAuthenticationOptions(args, userName, password);
args.removeFirst();
return args;
}
// Add authorization options to the command line arguments.
// SVN pre 1.5 does not accept "--userName" for "add", which is most likely
// an oversight. As no password is needed for the option, generally omit it.
......
......@@ -46,6 +46,16 @@ public:
SubversionClient(SubversionSettings *settings);
SubversionSettings *settings() const;
VcsBase::Command *createCommitCmd(const QString &repositoryRoot,
const QStringList &files,
const QString &commitMessageFile,
const QStringList &extraOptions = QStringList()) const;
void commit(const QString &repositoryRoot,
const QStringList &files,
const QString &commitMessageFile,
const QStringList &extraOptions = QStringList());
void diff(const QString &workingDir, const QStringList &files,
const QStringList &extraOptions = QStringList());
QString findTopLevelForFile(const QFileInfo &file) const;
......@@ -62,6 +72,7 @@ public:
Version svnVersion();
// Add authorization options to the command line arguments.
QStringList authenticationOptions(VcsCommand cmd) const;
static QStringList addAuthenticationOptions(const QStringList &args,
const QString &userName = QString(),
const QString &password = QString());
......
......@@ -41,6 +41,7 @@ const char SUBVERSIONCOMMITEDITOR_ID[] = "Subversion Commit Editor";
const char SUBVERSIONCOMMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Subversion Commit Editor");
const char SUBMIT_CURRENT[] = "Subversion.SubmitCurrentLog";
const char DIFF_SELECTED[] = "Subversion.DiffSelectedFilesInLog";
const char NON_INTERACTIVE_OPTION[] = "--non-interactive";
enum { debug = 0 };
} // namespace Constants
......
......@@ -39,6 +39,7 @@
#include "checkoutwizard.h"
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/command.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
......@@ -493,11 +494,15 @@ bool SubversionPlugin::submitEditorAboutToClose()
if (!fileList.empty()) {
// get message & commit
closeEditor = DocumentManager::saveDocument(editorDocument);
if (closeEditor)
closeEditor = commit(m_commitMessageFileName, fileList);
if (closeEditor) {
VcsBase::Command *commitCmd = m_client->createCommitCmd(m_commitRepository,
fileList,
m_commitMessageFileName);
QObject::connect(commitCmd, SIGNAL(success(QVariant)),
this, SLOT(cleanCommitMessageFile()));
commitCmd->execute();
}
}
if (closeEditor)
cleanCommitMessageFile();
return closeEditor;
}
......
......@@ -102,6 +102,7 @@ private slots:
void revertCurrentFile();
void diffProject();
void diffCurrentFile();
void cleanCommitMessageFile();
void startCommitAll();
void startCommitProject();
void startCommitCurrentFile();
......@@ -153,7 +154,6 @@ private:
bool checkSVNSubDir(const QDir &directory, const QString &fileName = QString()) const;
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
void cleanCommitMessageFile();
inline SubversionControl *subVersionControl() const;
const QStringList m_svnDirectories;
......
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