forked from qt-creator/qt-creator
VCS: Deduplicate some submit editor closing logic
Change-Id: I622f5703c222a48606fcca3b99e87f9398e6a815 Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
eaad78547c
commit
9b61e484be
@@ -206,7 +206,6 @@ public:
|
|||||||
void update();
|
void update();
|
||||||
void commit();
|
void commit();
|
||||||
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
|
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
|
||||||
void commitFromEditor() override;
|
|
||||||
void uncommit();
|
void uncommit();
|
||||||
void diffFromEditorSelected(const QStringList &files);
|
void diffFromEditorSelected(const QStringList &files);
|
||||||
|
|
||||||
@@ -242,7 +241,6 @@ public:
|
|||||||
QAction *m_menuAction = nullptr;
|
QAction *m_menuAction = nullptr;
|
||||||
|
|
||||||
FilePath m_submitRepository;
|
FilePath m_submitRepository;
|
||||||
bool m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
VcsEditorFactory logEditorFactory {
|
VcsEditorFactory logEditorFactory {
|
||||||
&logEditorParameters,
|
&logEditorParameters,
|
||||||
@@ -776,14 +774,6 @@ void BazaarPlugin::testLogResolving()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void BazaarPluginPrivate::commitFromEditor()
|
|
||||||
{
|
|
||||||
// Close the submit editor
|
|
||||||
m_submitActionTriggered = true;
|
|
||||||
QTC_ASSERT(submitEditor(), return);
|
|
||||||
EditorManager::closeDocuments({submitEditor()->document()});
|
|
||||||
}
|
|
||||||
|
|
||||||
void BazaarPluginPrivate::uncommit()
|
void BazaarPluginPrivate::uncommit()
|
||||||
{
|
{
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
@@ -801,19 +791,6 @@ bool BazaarPluginPrivate::submitEditorAboutToClose()
|
|||||||
IDocument *editorDocument = commitEditor->document();
|
IDocument *editorDocument = commitEditor->document();
|
||||||
QTC_ASSERT(editorDocument, return true);
|
QTC_ASSERT(editorDocument, return true);
|
||||||
|
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult response =
|
|
||||||
commitEditor->promptSubmit(this, !m_submitActionTriggered);
|
|
||||||
m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
switch (response) {
|
|
||||||
case VcsBaseSubmitEditor::SubmitCanceled:
|
|
||||||
return false;
|
|
||||||
case VcsBaseSubmitEditor::SubmitDiscarded:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList files = commitEditor->checkedFiles();
|
QStringList files = commitEditor->checkedFiles();
|
||||||
if (!files.empty()) {
|
if (!files.empty()) {
|
||||||
//save the commit message
|
//save the commit message
|
||||||
|
@@ -219,6 +219,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) override;
|
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) override;
|
||||||
bool submitEditorAboutToClose() override;
|
bool submitEditorAboutToClose() override;
|
||||||
|
void discardCommit() override { cleanCheckInMessageFile(); }
|
||||||
QString ccGet(const FilePath &workingDir, const QString &file, const QString &prefix = {});
|
QString ccGet(const FilePath &workingDir, const QString &file, const QString &prefix = {});
|
||||||
QList<QStringPair> ccGetActivities() const;
|
QList<QStringPair> ccGetActivities() const;
|
||||||
|
|
||||||
@@ -239,7 +240,6 @@ private:
|
|||||||
void historyCurrentFile();
|
void historyCurrentFile();
|
||||||
void annotateCurrentFile();
|
void annotateCurrentFile();
|
||||||
void viewStatus();
|
void viewStatus();
|
||||||
void commitFromEditor() override;
|
|
||||||
void diffCheckInFiles(const QStringList &);
|
void diffCheckInFiles(const QStringList &);
|
||||||
void updateIndex();
|
void updateIndex();
|
||||||
void updateView();
|
void updateView();
|
||||||
@@ -311,7 +311,6 @@ private:
|
|||||||
QAction *m_statusAction = nullptr;
|
QAction *m_statusAction = nullptr;
|
||||||
|
|
||||||
QAction *m_menuAction = nullptr;
|
QAction *m_menuAction = nullptr;
|
||||||
bool m_submitActionTriggered = false;
|
|
||||||
QMutex m_activityMutex;
|
QMutex m_activityMutex;
|
||||||
QList<QStringPair> m_activities;
|
QList<QStringPair> m_activities;
|
||||||
QSharedPointer<StatusMap> m_statusMap;
|
QSharedPointer<StatusMap> m_statusMap;
|
||||||
@@ -752,21 +751,6 @@ bool ClearCasePluginPrivate::submitEditorAboutToClose()
|
|||||||
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
||||||
return true; // Oops?!
|
return true; // Oops?!
|
||||||
|
|
||||||
// Prompt user. Force a prompt unless submit was actually invoked (that
|
|
||||||
// is, the editor was closed or shutdown).
|
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult answer =
|
|
||||||
editor->promptSubmit(this, !m_submitActionTriggered);
|
|
||||||
m_submitActionTriggered = false;
|
|
||||||
switch (answer) {
|
|
||||||
case VcsBaseSubmitEditor::SubmitCanceled:
|
|
||||||
return false; // Keep editing and change file
|
|
||||||
case VcsBaseSubmitEditor::SubmitDiscarded:
|
|
||||||
cleanCheckInMessageFile();
|
|
||||||
return true; // Cancel all
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList fileList = editor->checkedFiles();
|
const QStringList fileList = editor->checkedFiles();
|
||||||
bool closeEditor = true;
|
bool closeEditor = true;
|
||||||
if (!fileList.empty()) {
|
if (!fileList.empty()) {
|
||||||
@@ -1604,13 +1588,6 @@ void ClearCasePluginPrivate::vcsDescribe(const FilePath &source, const QString &
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearCasePluginPrivate::commitFromEditor()
|
|
||||||
{
|
|
||||||
m_submitActionTriggered = true;
|
|
||||||
QTC_ASSERT(submitEditor(), return);
|
|
||||||
EditorManager::closeDocuments({submitEditor()->document()});
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandResult ClearCasePluginPrivate::runCleartoolProc(const FilePath &workingDir,
|
CommandResult ClearCasePluginPrivate::runCleartoolProc(const FilePath &workingDir,
|
||||||
const QStringList &arguments) const
|
const QStringList &arguments) const
|
||||||
{
|
{
|
||||||
|
@@ -239,6 +239,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void updateActions(ActionState) final;
|
void updateActions(ActionState) final;
|
||||||
bool submitEditorAboutToClose() final;
|
bool submitEditorAboutToClose() final;
|
||||||
|
void discardCommit() override { cleanCommitMessageFile(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addCurrentFile();
|
void addCurrentFile();
|
||||||
@@ -254,7 +255,6 @@ private:
|
|||||||
void projectStatus();
|
void projectStatus();
|
||||||
void updateDirectory();
|
void updateDirectory();
|
||||||
void updateProject();
|
void updateProject();
|
||||||
void commitFromEditor() final;
|
|
||||||
void diffCommitFiles(const QStringList &);
|
void diffCommitFiles(const QStringList &);
|
||||||
void logProject();
|
void logProject();
|
||||||
void logRepository();
|
void logRepository();
|
||||||
@@ -327,7 +327,6 @@ private:
|
|||||||
QAction *m_statusRepositoryAction = nullptr;
|
QAction *m_statusRepositoryAction = nullptr;
|
||||||
|
|
||||||
QAction *m_menuAction = nullptr;
|
QAction *m_menuAction = nullptr;
|
||||||
bool m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
CvsSettingsPage m_settingsPage{&m_settings};
|
CvsSettingsPage m_settingsPage{&m_settings};
|
||||||
|
|
||||||
@@ -724,20 +723,6 @@ bool CvsPluginPrivate::submitEditorAboutToClose()
|
|||||||
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
||||||
return true; // Oops?!
|
return true; // Oops?!
|
||||||
|
|
||||||
// Prompt user. Force a prompt unless submit was actually invoked (that
|
|
||||||
// is, the editor was closed or shutdown).
|
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult answer =
|
|
||||||
editor->promptSubmit(this, !m_submitActionTriggered);
|
|
||||||
m_submitActionTriggered = false;
|
|
||||||
switch (answer) {
|
|
||||||
case VcsBaseSubmitEditor::SubmitCanceled:
|
|
||||||
return false; // Keep editing and change file
|
|
||||||
case VcsBaseSubmitEditor::SubmitDiscarded:
|
|
||||||
cleanCommitMessageFile();
|
|
||||||
return true; // Cancel all
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const QStringList fileList = editor->checkedFiles();
|
const QStringList fileList = editor->checkedFiles();
|
||||||
bool closeEditor = true;
|
bool closeEditor = true;
|
||||||
if (!fileList.empty()) {
|
if (!fileList.empty()) {
|
||||||
@@ -1342,13 +1327,6 @@ bool CvsPluginPrivate::describe(const FilePath &repositoryPath,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvsPluginPrivate::commitFromEditor()
|
|
||||||
{
|
|
||||||
m_submitActionTriggered = true;
|
|
||||||
QTC_ASSERT(submitEditor(), return);
|
|
||||||
EditorManager::closeDocuments({submitEditor()->document()});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run CVS. At this point, file arguments must be relative to
|
// Run CVS. At this point, file arguments must be relative to
|
||||||
// the working directory (see above).
|
// the working directory (see above).
|
||||||
CommandResult CvsPluginPrivate::runCvs(const FilePath &workingDirectory,
|
CommandResult CvsPluginPrivate::runCvs(const FilePath &workingDirectory,
|
||||||
|
@@ -251,10 +251,10 @@ public:
|
|||||||
|
|
||||||
void updateActions(VcsBasePluginPrivate::ActionState) override;
|
void updateActions(VcsBasePluginPrivate::ActionState) override;
|
||||||
bool submitEditorAboutToClose() override;
|
bool submitEditorAboutToClose() override;
|
||||||
|
void discardCommit() override { cleanCommitMessageFile(); }
|
||||||
|
|
||||||
void diffCurrentFile();
|
void diffCurrentFile();
|
||||||
void diffCurrentProject();
|
void diffCurrentProject();
|
||||||
void commitFromEditor() override;
|
|
||||||
void logFile();
|
void logFile();
|
||||||
void blameFile();
|
void blameFile();
|
||||||
void logProject();
|
void logProject();
|
||||||
@@ -363,7 +363,6 @@ public:
|
|||||||
QPointer<RemoteDialog> m_remoteDialog;
|
QPointer<RemoteDialog> m_remoteDialog;
|
||||||
FilePath m_submitRepository;
|
FilePath m_submitRepository;
|
||||||
QString m_commitMessageFileName;
|
QString m_commitMessageFileName;
|
||||||
bool m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
GitSettingsPage settingPage{&m_settings};
|
GitSettingsPage settingPage{&m_settings};
|
||||||
|
|
||||||
@@ -1381,14 +1380,6 @@ IEditor *GitPluginPrivate::openSubmitEditor(const QString &fileName, const Commi
|
|||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitPluginPrivate::commitFromEditor()
|
|
||||||
{
|
|
||||||
// Close the submit editor
|
|
||||||
m_submitActionTriggered = true;
|
|
||||||
QTC_ASSERT(submitEditor(), return);
|
|
||||||
EditorManager::closeDocuments({submitEditor()->document()});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GitPluginPrivate::submitEditorAboutToClose()
|
bool GitPluginPrivate::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
if (!isCommitEditorOpen())
|
if (!isCommitEditorOpen())
|
||||||
@@ -1404,23 +1395,7 @@ bool GitPluginPrivate::submitEditorAboutToClose()
|
|||||||
// Paranoia!
|
// Paranoia!
|
||||||
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
||||||
return true;
|
return true;
|
||||||
// Prompt user. Force a prompt unless submit was actually invoked (that
|
|
||||||
// is, the editor was closed or shutdown).
|
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult answer
|
|
||||||
= editor->promptSubmit(this, !m_submitActionTriggered, false);
|
|
||||||
m_submitActionTriggered = false;
|
|
||||||
switch (answer) {
|
|
||||||
case VcsBaseSubmitEditor::SubmitCanceled:
|
|
||||||
return false; // Keep editing and change file
|
|
||||||
case VcsBaseSubmitEditor::SubmitDiscarded:
|
|
||||||
cleanCommitMessageFile();
|
|
||||||
return true; // Cancel all
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Go ahead!
|
|
||||||
auto model = qobject_cast<SubmitFileModel *>(editor->fileModel());
|
auto model = qobject_cast<SubmitFileModel *>(editor->fileModel());
|
||||||
CommitType commitType = editor->commitType();
|
CommitType commitType = editor->commitType();
|
||||||
QString amendSHA1 = editor->amendSHA1();
|
QString amendSHA1 = editor->amendSHA1();
|
||||||
|
@@ -161,7 +161,6 @@ private:
|
|||||||
void outgoing();
|
void outgoing();
|
||||||
void commit();
|
void commit();
|
||||||
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
|
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
|
||||||
void commitFromEditor() override;
|
|
||||||
void diffFromEditorSelected(const QStringList &files);
|
void diffFromEditorSelected(const QStringList &files);
|
||||||
|
|
||||||
void createMenu(const Core::Context &context);
|
void createMenu(const Core::Context &context);
|
||||||
@@ -193,8 +192,6 @@ private:
|
|||||||
|
|
||||||
FilePath m_submitRepository;
|
FilePath m_submitRepository;
|
||||||
|
|
||||||
bool m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VcsSubmitEditorFactory submitEditorFactory {
|
VcsSubmitEditorFactory submitEditorFactory {
|
||||||
submitEditorParameters,
|
submitEditorParameters,
|
||||||
@@ -647,14 +644,6 @@ void MercurialPluginPrivate::diffFromEditorSelected(const QStringList &files)
|
|||||||
m_client.diff(m_submitRepository, files);
|
m_client.diff(m_submitRepository, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MercurialPluginPrivate::commitFromEditor()
|
|
||||||
{
|
|
||||||
// Close the submit editor
|
|
||||||
m_submitActionTriggered = true;
|
|
||||||
QTC_ASSERT(submitEditor(), return);
|
|
||||||
Core::EditorManager::closeDocuments({submitEditor()->document()});
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MercurialPluginPrivate::submitEditorAboutToClose()
|
bool MercurialPluginPrivate::submitEditorAboutToClose()
|
||||||
{
|
{
|
||||||
auto commitEditor = qobject_cast<CommitEditor *>(submitEditor());
|
auto commitEditor = qobject_cast<CommitEditor *>(submitEditor());
|
||||||
@@ -662,19 +651,6 @@ bool MercurialPluginPrivate::submitEditorAboutToClose()
|
|||||||
Core::IDocument *editorFile = commitEditor->document();
|
Core::IDocument *editorFile = commitEditor->document();
|
||||||
QTC_ASSERT(editorFile, return true);
|
QTC_ASSERT(editorFile, return true);
|
||||||
|
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult response =
|
|
||||||
commitEditor->promptSubmit(this, !m_submitActionTriggered);
|
|
||||||
m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
switch (response) {
|
|
||||||
case VcsBaseSubmitEditor::SubmitCanceled:
|
|
||||||
return false;
|
|
||||||
case VcsBaseSubmitEditor::SubmitDiscarded:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList files = commitEditor->checkedFiles();
|
const QStringList files = commitEditor->checkedFiles();
|
||||||
if (!files.empty()) {
|
if (!files.empty()) {
|
||||||
//save the commit message
|
//save the commit message
|
||||||
|
@@ -223,6 +223,7 @@ public:
|
|||||||
|
|
||||||
void updateActions(ActionState) override;
|
void updateActions(ActionState) override;
|
||||||
bool submitEditorAboutToClose() override;
|
bool submitEditorAboutToClose() override;
|
||||||
|
void discardCommit() override { cleanCommitMessageFile(); }
|
||||||
|
|
||||||
QString commitDisplayName() const final;
|
QString commitDisplayName() const final;
|
||||||
void p4Diff(const PerforceDiffParameters &p);
|
void p4Diff(const PerforceDiffParameters &p);
|
||||||
@@ -247,7 +248,6 @@ public:
|
|||||||
void logProject();
|
void logProject();
|
||||||
void logRepository();
|
void logRepository();
|
||||||
|
|
||||||
void commitFromEditor() override;
|
|
||||||
void printPendingChanges();
|
void printPendingChanges();
|
||||||
void slotSubmitDiff(const QStringList &files);
|
void slotSubmitDiff(const QStringList &files);
|
||||||
void setTopLevel(const Utils::FilePath &);
|
void setTopLevel(const Utils::FilePath &);
|
||||||
@@ -332,7 +332,6 @@ public:
|
|||||||
ParameterAction *m_logProjectAction = nullptr;
|
ParameterAction *m_logProjectAction = nullptr;
|
||||||
QAction *m_logRepositoryAction = nullptr;
|
QAction *m_logRepositoryAction = nullptr;
|
||||||
QAction *m_updateAllAction = nullptr;
|
QAction *m_updateAllAction = nullptr;
|
||||||
bool m_submitActionTriggered = false;
|
|
||||||
QString m_commitMessageFileName;
|
QString m_commitMessageFileName;
|
||||||
mutable QString m_tempFilePattern;
|
mutable QString m_tempFilePattern;
|
||||||
QAction *m_menuAction = nullptr;
|
QAction *m_menuAction = nullptr;
|
||||||
@@ -1514,13 +1513,6 @@ void PerforcePluginPrivate::vcsDescribe(const FilePath &source, const QString &n
|
|||||||
showOutputInEditor(tr("p4 describe %1").arg(n), result.stdOut, diffEditorParameters.id, source.toString(), codec);
|
showOutputInEditor(tr("p4 describe %1").arg(n), result.stdOut, diffEditorParameters.id, source.toString(), codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerforcePluginPrivate::commitFromEditor()
|
|
||||||
{
|
|
||||||
m_submitActionTriggered = true;
|
|
||||||
QTC_ASSERT(submitEditor(), return);
|
|
||||||
EditorManager::closeDocuments({submitEditor()->document()});
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerforcePluginPrivate::cleanCommitMessageFile()
|
void PerforcePluginPrivate::cleanCommitMessageFile()
|
||||||
{
|
{
|
||||||
if (!m_commitMessageFileName.isEmpty()) {
|
if (!m_commitMessageFileName.isEmpty()) {
|
||||||
@@ -1542,21 +1534,10 @@ bool PerforcePluginPrivate::submitEditorAboutToClose()
|
|||||||
QTC_ASSERT(perforceEditor, return true);
|
QTC_ASSERT(perforceEditor, return true);
|
||||||
IDocument *editorDocument = perforceEditor->document();
|
IDocument *editorDocument = perforceEditor->document();
|
||||||
QTC_ASSERT(editorDocument, return true);
|
QTC_ASSERT(editorDocument, return true);
|
||||||
// Prompt the user. Force a prompt unless submit was actually invoked (that
|
|
||||||
// is, the editor was closed or shutdown).
|
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult answer =
|
|
||||||
perforceEditor->promptSubmit(this, !m_submitActionTriggered);
|
|
||||||
m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
if (answer == VcsBaseSubmitEditor::SubmitCanceled)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!DocumentManager::saveDocument(editorDocument))
|
if (!DocumentManager::saveDocument(editorDocument))
|
||||||
return false;
|
return false;
|
||||||
if (answer == VcsBaseSubmitEditor::SubmitDiscarded) {
|
|
||||||
cleanCommitMessageFile();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Pipe file into p4 submit -i
|
// Pipe file into p4 submit -i
|
||||||
FileReader reader;
|
FileReader reader;
|
||||||
if (!reader.fetch(Utils::FilePath::fromString(m_commitMessageFileName), QIODevice::Text)) {
|
if (!reader.fetch(Utils::FilePath::fromString(m_commitMessageFileName), QIODevice::Text)) {
|
||||||
|
@@ -223,6 +223,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) override;
|
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) override;
|
||||||
bool submitEditorAboutToClose() override;
|
bool submitEditorAboutToClose() override;
|
||||||
|
void discardCommit() override { cleanCommitMessageFile(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addCurrentFile();
|
void addCurrentFile();
|
||||||
@@ -239,7 +240,6 @@ private:
|
|||||||
void projectStatus();
|
void projectStatus();
|
||||||
void slotDescribe();
|
void slotDescribe();
|
||||||
void updateProject();
|
void updateProject();
|
||||||
void commitFromEditor() override;
|
|
||||||
void diffCommitFiles(const QStringList &);
|
void diffCommitFiles(const QStringList &);
|
||||||
void logProject();
|
void logProject();
|
||||||
void logRepository();
|
void logRepository();
|
||||||
@@ -289,7 +289,6 @@ private:
|
|||||||
QAction *m_describeAction = nullptr;
|
QAction *m_describeAction = nullptr;
|
||||||
|
|
||||||
QAction *m_menuAction = nullptr;
|
QAction *m_menuAction = nullptr;
|
||||||
bool m_submitActionTriggered = false;
|
|
||||||
|
|
||||||
SubversionSettingsPage m_settingsPage{&m_settings};
|
SubversionSettingsPage m_settingsPage{&m_settings};
|
||||||
|
|
||||||
@@ -561,20 +560,6 @@ bool SubversionPluginPrivate::submitEditorAboutToClose()
|
|||||||
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
||||||
return true; // Oops?!
|
return true; // Oops?!
|
||||||
|
|
||||||
// Prompt user. Force a prompt unless submit was actually invoked (that
|
|
||||||
// is, the editor was closed or shutdown).
|
|
||||||
const VcsBaseSubmitEditor::PromptSubmitResult answer =
|
|
||||||
editor->promptSubmit(this, !m_submitActionTriggered);
|
|
||||||
m_submitActionTriggered = false;
|
|
||||||
switch (answer) {
|
|
||||||
case VcsBaseSubmitEditor::SubmitCanceled:
|
|
||||||
return false; // Keep editing and change file
|
|
||||||
case VcsBaseSubmitEditor::SubmitDiscarded:
|
|
||||||
cleanCommitMessageFile();
|
|
||||||
return true; // Cancel all
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const QStringList fileList = editor->checkedFiles();
|
const QStringList fileList = editor->checkedFiles();
|
||||||
bool closeEditor = true;
|
bool closeEditor = true;
|
||||||
if (!fileList.empty()) {
|
if (!fileList.empty()) {
|
||||||
@@ -967,13 +952,6 @@ void SubversionPluginPrivate::slotDescribe()
|
|||||||
vcsDescribe(state.topLevel(), QString::number(revision));
|
vcsDescribe(state.topLevel(), QString::number(revision));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubversionPluginPrivate::commitFromEditor()
|
|
||||||
{
|
|
||||||
m_submitActionTriggered = true;
|
|
||||||
QTC_ASSERT(submitEditor(), return);
|
|
||||||
EditorManager::closeDocuments({submitEditor()->document()});
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandResult SubversionPluginPrivate::runSvn(const FilePath &workingDir,
|
CommandResult SubversionPluginPrivate::runSvn(const FilePath &workingDir,
|
||||||
const QStringList &arguments, RunFlags flags,
|
const QStringList &arguments, RunFlags flags,
|
||||||
QTextCodec *outputCodec, int timeoutMutiplier) const
|
QTextCodec *outputCodec, int timeoutMutiplier) const
|
||||||
|
@@ -528,8 +528,24 @@ void VcsBasePluginPrivate::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *sub
|
|||||||
<< (m_submitEditor ? m_submitEditor->document()->id().name() : QByteArray())
|
<< (m_submitEditor ? m_submitEditor->document()->id().name() : QByteArray())
|
||||||
<< "closing submit editor" << submitEditor
|
<< "closing submit editor" << submitEditor
|
||||||
<< (submitEditor ? submitEditor->document()->id().name() : QByteArray());
|
<< (submitEditor ? submitEditor->document()->id().name() : QByteArray());
|
||||||
if (submitEditor == m_submitEditor)
|
if (submitEditor == m_submitEditor) {
|
||||||
|
const VcsBaseSubmitEditor::PromptSubmitResult response =
|
||||||
|
submitEditor->promptSubmit(this, !m_submitActionTriggered);
|
||||||
|
m_submitActionTriggered = false;
|
||||||
|
|
||||||
|
switch (response) {
|
||||||
|
case VcsBaseSubmitEditor::SubmitCanceled:
|
||||||
|
*result = false;
|
||||||
|
break;
|
||||||
|
case VcsBaseSubmitEditor::SubmitDiscarded:
|
||||||
|
discardCommit();
|
||||||
|
*result = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
*result = submitEditorAboutToClose();
|
*result = submitEditorAboutToClose();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsBasePluginPrivate::slotStateChanged(const Internal::State &newInternalState, Core::IVersionControl *vc)
|
void VcsBasePluginPrivate::slotStateChanged(const Internal::State &newInternalState, Core::IVersionControl *vc)
|
||||||
@@ -597,6 +613,14 @@ QString VcsBasePluginPrivate::commitDisplayName() const
|
|||||||
return tr("Commit", "name of \"commit\" action of the VCS.");
|
return tr("Commit", "name of \"commit\" action of the VCS.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsBasePluginPrivate::commitFromEditor()
|
||||||
|
{
|
||||||
|
// Close the submit editor
|
||||||
|
m_submitActionTriggered = true;
|
||||||
|
QTC_ASSERT(m_submitEditor, return);
|
||||||
|
EditorManager::closeDocuments({m_submitEditor->document()});
|
||||||
|
}
|
||||||
|
|
||||||
bool VcsBasePluginPrivate::promptBeforeCommit()
|
bool VcsBasePluginPrivate::promptBeforeCommit()
|
||||||
{
|
{
|
||||||
return DocumentManager::saveAllModifiedDocuments(tr("Save before %1?")
|
return DocumentManager::saveAllModifiedDocuments(tr("Save before %1?")
|
||||||
@@ -677,6 +701,10 @@ bool VcsBasePluginPrivate::raiseSubmitEditor() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsBasePluginPrivate::discardCommit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Find top level for version controls like git/Mercurial that have
|
// Find top level for version controls like git/Mercurial that have
|
||||||
// a directory at the top of the repository.
|
// a directory at the top of the repository.
|
||||||
// Note that checking for the existence of files is preferred over directories
|
// Note that checking for the existence of files is preferred over directories
|
||||||
|
@@ -136,7 +136,7 @@ public:
|
|||||||
// Display name of the commit action
|
// Display name of the commit action
|
||||||
virtual QString commitDisplayName() const;
|
virtual QString commitDisplayName() const;
|
||||||
|
|
||||||
virtual void commitFromEditor() = 0;
|
void commitFromEditor();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Prompt to save all files before commit:
|
// Prompt to save all files before commit:
|
||||||
@@ -165,6 +165,7 @@ protected:
|
|||||||
virtual void updateActions(ActionState as) = 0;
|
virtual void updateActions(ActionState as) = 0;
|
||||||
// Implement to start the submit process, use submitEditor() to get the submit editor instance.
|
// Implement to start the submit process, use submitEditor() to get the submit editor instance.
|
||||||
virtual bool submitEditorAboutToClose() = 0;
|
virtual bool submitEditorAboutToClose() = 0;
|
||||||
|
virtual void discardCommit();
|
||||||
|
|
||||||
// A helper to enable the VCS menu action according to state:
|
// A helper to enable the VCS menu action according to state:
|
||||||
// NoVcsEnabled -> visible, enabled if repository creation is supported
|
// NoVcsEnabled -> visible, enabled if repository creation is supported
|
||||||
@@ -183,6 +184,7 @@ private:
|
|||||||
Core::Context m_context;
|
Core::Context m_context;
|
||||||
VcsBasePluginState m_state;
|
VcsBasePluginState m_state;
|
||||||
int m_actionState = -1;
|
int m_actionState = -1;
|
||||||
|
bool m_submitActionTriggered = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
Reference in New Issue
Block a user