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

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