diff options
author | Hugues Delorme <delorme.hugues@fougsys.fr> | 2014-05-19 18:40:37 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@digia.com> | 2014-05-26 16:48:39 +0200 |
commit | 0d0d79ce08c9db20416b716260db20a720f70f8e (patch) | |
tree | 396977df0722d037095c9ebfe314f8c1934c765f /src/plugins/subversion | |
parent | ddfc1f8d27173f80f9313fd6d43ccd47449de1fc (diff) | |
download | qt-creator-0d0d79ce08c9db20416b716260db20a720f70f8e.tar.gz |
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: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/subversion')
-rw-r--r-- | src/plugins/subversion/subversionclient.cpp | 42 | ||||
-rw-r--r-- | src/plugins/subversion/subversionclient.h | 11 | ||||
-rw-r--r-- | src/plugins/subversion/subversionconstants.h | 1 | ||||
-rw-r--r-- | src/plugins/subversion/subversionplugin.cpp | 13 | ||||
-rw-r--r-- | src/plugins/subversion/subversionplugin.h | 2 |
5 files changed, 64 insertions, 5 deletions
diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index 3b3b193fe2..2703de39e9 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -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. diff --git a/src/plugins/subversion/subversionclient.h b/src/plugins/subversion/subversionclient.h index 34e684f9e0..421797040c 100644 --- a/src/plugins/subversion/subversionclient.h +++ b/src/plugins/subversion/subversionclient.h @@ -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()); diff --git a/src/plugins/subversion/subversionconstants.h b/src/plugins/subversion/subversionconstants.h index dea1246f62..1e980b1ca7 100644 --- a/src/plugins/subversion/subversionconstants.h +++ b/src/plugins/subversion/subversionconstants.h @@ -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 diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 9ab5929512..71aa673463 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -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; } diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h index 117a7e1099..a1165187cd 100644 --- a/src/plugins/subversion/subversionplugin.h +++ b/src/plugins/subversion/subversionplugin.h @@ -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; |