Commit 21ab4c42 authored by Tobias Hunger's avatar Tobias Hunger

VCS: Offer to save-all before commit

Task-number: QTCREATORBUG-3857
Change-Id: I3ff3d90803eec4134b9da4af5567753ad7bffafb
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 1e3b5418
......@@ -509,6 +509,9 @@ void BazaarPlugin::createSubmitEditorActions()
void BazaarPlugin::commit()
{
if (!promptBeforeCommit()))
return;
if (raiseSubmitEditor())
return;
......
......@@ -837,6 +837,11 @@ void ClearCasePlugin::updateActions(VcsBasePlugin::ActionState as)
updateStatusActions();
}
QString ClearCasePlugin::commitDisplayName() const
{
return tr("check in", "\"commit\" action for ClearCase.");
}
void ClearCasePlugin::checkOutCurrentFile()
{
const VcsBasePluginState state = currentState();
......@@ -1206,6 +1211,9 @@ void ClearCasePlugin::startCheckInActivity()
* check in will start. */
void ClearCasePlugin::startCheckIn(const QString &workingDir, const QStringList &files)
{
if (!promptBeforeCommit())
return;
if (raiseSubmitEditor())
return;
......
......@@ -199,6 +199,7 @@ private:
void syncSlot();
Q_INVOKABLE void updateStatusActions();
QString commitDisplayName() const final;
void checkOutCurrentFile();
void addCurrentFile();
void undoCheckOutCurrent();
......
......@@ -651,6 +651,9 @@ void CvsPlugin::startCommitAll()
* commit will start. */
void CvsPlugin::startCommit(const QString &workingDir, const QString &file)
{
if (!promptBeforeCommit())
return;
if (raiseSubmitEditor())
return;
if (isCommitEditorOpen()) {
......
......@@ -926,6 +926,9 @@ void GitPlugin::gitGui()
void GitPlugin::startCommit(CommitType commitType)
{
if (!promptBeforeCommit())
return;
if (raiseSubmitEditor())
return;
if (isCommitEditorOpen()) {
......
......@@ -37,12 +37,12 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/id.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/locator/commandlocator.h>
......@@ -494,6 +494,9 @@ void MercurialPlugin::createSubmitEditorActions()
void MercurialPlugin::commit()
{
if (!promptBeforeCommit())
return;
if (raiseSubmitEditor())
return;
......
......@@ -556,6 +556,8 @@ void PerforcePlugin::printOpenedFileList()
void PerforcePlugin::startSubmitProject()
{
if (!promptBeforeCommit())
return;
if (raiseSubmitEditor())
return;
......@@ -1225,6 +1227,11 @@ void PerforceDiffConfig::triggerReRun()
emit reRunDiff(effectiveParameters);
}
QString PerforcePlugin::commitDisplayName() const
{
return tr("submit", "\"commit\" action for perforce");
}
void PerforcePlugin::p4Diff(const QString &workingDir, const QStringList &files)
{
PerforceDiffParameters p;
......
......@@ -113,6 +113,7 @@ private slots:
#endif
private:
QString commitDisplayName() const final;
void p4Diff(const PerforceDiffParameters &p);
void openCurrentFile();
......
......@@ -642,6 +642,9 @@ void SubversionPlugin::startCommitProject()
* commit will start. */
void SubversionPlugin::startCommit(const QString &workingDir, const QStringList &files)
{
if (!promptBeforeCommit())
return;
if (raiseSubmitEditor())
return;
if (isCommitEditorOpen()) {
......
......@@ -641,6 +641,16 @@ bool VcsBasePlugin::enableMenuAction(ActionState as, QAction *menuAction) const
return true;
}
QString VcsBasePlugin::commitDisplayName() const
{
return tr("commit", "name of \"commit\" action of the VCS.");
}
bool VcsBasePlugin::promptBeforeCommit()
{
return DocumentManager::saveAllModifiedDocuments(tr("Save before %1?").arg(commitDisplayName());
}
void VcsBasePlugin::promptToDeleteCurrentFile()
{
const VcsBasePluginState state = currentState();
......
......@@ -178,6 +178,11 @@ public:
const QProcessEnvironment &env = QProcessEnvironment());
protected:
// Display name of the commit action:
virtual QString commitDisplayName() const;
// Prompt to save all files before commit:
bool promptBeforeCommit();
// Convenience slot for "Delete current file" action. Prompts to
// delete the file via VcsManager.
void promptToDeleteCurrentFile();
......
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