Bazaar, Cvs, Fossil, Mercurial, Perforce, Svn: Simplify returns

Change-Id: Ic0d6a7510a26a4a9db180594f140156b036c5090
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2023-08-02 11:55:45 +02:00
parent 88926ed1a8
commit d45ece1732
16 changed files with 23 additions and 32 deletions

View File

@@ -19,7 +19,7 @@ QString BazaarAnnotationHighlighter::changeNumber(const QString &block) const
const QRegularExpressionMatch match = m_changeset.match(block); const QRegularExpressionMatch match = m_changeset.match(block);
if (match.hasMatch()) if (match.hasMatch())
return match.captured(1); return match.captured(1);
return QString(); return {};
} }
} // Bazaar::Internal } // Bazaar::Internal

View File

@@ -159,7 +159,7 @@ QString BazaarCommitWidget::committer() const
const QString author = m_bazaarCommitPanel->authorLineEdit->text(); const QString author = m_bazaarCommitPanel->authorLineEdit->text();
const QString email = m_bazaarCommitPanel->emailLineEdit->text(); const QString email = m_bazaarCommitPanel->emailLineEdit->text();
if (author.isEmpty()) if (author.isEmpty())
return QString(); return {};
QString user = author; QString user = author;
if (!email.isEmpty()) { if (!email.isEmpty()) {

View File

@@ -56,7 +56,7 @@ QString BazaarEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) const
} }
} }
} }
return QString(); return {};
} }
VcsBase::BaseAnnotationHighlighter *BazaarEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const VcsBase::BaseAnnotationHighlighter *BazaarEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const

View File

@@ -112,7 +112,7 @@ PullOrPushDialog::~PullOrPushDialog() = default;
QString PullOrPushDialog::branchLocation() const QString PullOrPushDialog::branchLocation() const
{ {
if (m_defaultButton->isChecked()) if (m_defaultButton->isChecked())
return QString(); return {};
if (m_localButton->isChecked()) if (m_localButton->isChecked())
return m_localPathChooser->filePath().toString(); return m_localPathChooser->filePath().toString();
return m_urlLineEdit->text(); return m_urlLineEdit->text();

View File

@@ -90,7 +90,7 @@ QString CvsEditorWidget::changeUnderCursor(const QTextCursor &c) const
} }
break; break;
} }
return QString(); return {};
} }
VcsBase::BaseAnnotationHighlighter *CvsEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const VcsBase::BaseAnnotationHighlighter *CvsEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const

View File

@@ -29,7 +29,7 @@ QString CvsSubmitEditor::stateName(State st) const
case LocallyRemoved: case LocallyRemoved:
return m_msgRemoved; return m_msgRemoved;
} }
return QString(); return {};
} }
void CvsSubmitEditor::setStateList(const StateFilePairs &statusOutput) void CvsSubmitEditor::setStateList(const StateFilePairs &statusOutput)

View File

@@ -82,7 +82,7 @@ PullOrPushDialog::PullOrPushDialog(Mode mode, QWidget *parent)
QString PullOrPushDialog::remoteLocation() const QString PullOrPushDialog::remoteLocation() const
{ {
if (m_defaultButton->isChecked()) if (m_defaultButton->isChecked())
return QString(); return {};
if (m_localButton->isChecked()) if (m_localButton->isChecked())
return m_localPathChooser->filePath().toString(); return m_localPathChooser->filePath().toString();
return m_urlLineEdit->text(); return m_urlLineEdit->text();

View File

@@ -47,26 +47,17 @@ QString FossilJsExtension::displayName() const
QString FossilJsExtension::defaultAdminUser() const QString FossilJsExtension::defaultAdminUser() const
{ {
if (!isConfigured()) return isConfigured() ? settings().userName() : QString();
return QString();
return settings().userName();
} }
QString FossilJsExtension::defaultSslIdentityFile() const QString FossilJsExtension::defaultSslIdentityFile() const
{ {
if (!isConfigured()) return isConfigured() ? settings().sslIdentityFile().toFSPathString() : QString();
return QString();
return settings().sslIdentityFile().toFSPathString();
} }
QString FossilJsExtension::defaultLocalRepoPath() const QString FossilJsExtension::defaultLocalRepoPath() const
{ {
if (!isConfigured()) return isConfigured() ? settings().defaultRepoPath().toFSPathString() : QString();
return QString();
return settings().defaultRepoPath().toFSPathString();
} }
bool FossilJsExtension::defaultDisableAutosync() const bool FossilJsExtension::defaultDisableAutosync() const

View File

@@ -18,7 +18,7 @@ QString MercurialAnnotationHighlighter::changeNumber(const QString &block) const
const QRegularExpressionMatch match = changeset.match(block); const QRegularExpressionMatch match = changeset.match(block);
if (match.hasMatch()) if (match.hasMatch())
return match.captured(1); return match.captured(1);
return QString(); return {};
} }
} // Mercurial::Internal } // Mercurial::Internal

View File

@@ -151,7 +151,7 @@ QString MercurialCommitWidget::committer() const
const QString author = mercurialCommitPanel->m_authorLineEdit->text(); const QString author = mercurialCommitPanel->m_authorLineEdit->text();
const QString email = mercurialCommitPanel->m_emailLineEdit->text(); const QString email = mercurialCommitPanel->m_emailLineEdit->text();
if (author.isEmpty()) if (author.isEmpty())
return QString(); return {};
QString user = author; QString user = author;
if (!email.isEmpty()) { if (!email.isEmpty()) {

View File

@@ -45,7 +45,7 @@ QString MercurialEditorWidget::changeUnderCursor(const QTextCursor &cursorIn) co
if (exactIdentifier40.match(change).hasMatch()) if (exactIdentifier40.match(change).hasMatch())
return change; return change;
} }
return QString(); return {};
} }
VcsBase::BaseAnnotationHighlighter *MercurialEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const VcsBase::BaseAnnotationHighlighter *MercurialEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const

View File

@@ -46,7 +46,7 @@ QString PerforceEditorWidget::changeUnderCursor(const QTextCursor &c) const
// Any number is regarded as change number. // Any number is regarded as change number.
cursor.select(QTextCursor::WordUnderCursor); cursor.select(QTextCursor::WordUnderCursor);
if (!cursor.hasSelection()) if (!cursor.hasSelection())
return QString(); return {};
const QString change = cursor.selectedText(); const QString change = cursor.selectedText();
return m_changeNumberPattern.match(change).hasMatch() ? change : QString(); return m_changeNumberPattern.match(change).hasMatch() ? change : QString();
} }

View File

@@ -1589,7 +1589,7 @@ QString PerforcePluginPrivate::clientFilePath(const QString &serverFilePath)
const PerforceResponse response = runP4Cmd(m_settings.topLevelSymLinkTarget(), args, const PerforceResponse response = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
ShowBusyCursor|RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow); ShowBusyCursor|RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (response.error) if (response.error)
return QString(); return {};
const QRegularExpression r("\\.\\.\\.\\sclientFile\\s(.+?)\n"); const QRegularExpression r("\\.\\.\\.\\sclientFile\\s(.+?)\n");
const QRegularExpressionMatch match = r.match(response.stdOut); const QRegularExpressionMatch match = r.match(response.stdOut);
@@ -1604,14 +1604,14 @@ QString PerforcePluginPrivate::pendingChangesData()
const PerforceResponse userResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args, const PerforceResponse userResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow); RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (userResponse.error) if (userResponse.error)
return QString(); return {};
const QRegularExpression r("User\\sname:\\s(\\S+?)\\s*?\n"); const QRegularExpression r("User\\sname:\\s(\\S+?)\\s*?\n");
QTC_ASSERT(r.isValid(), return QString()); QTC_ASSERT(r.isValid(), return QString());
const QRegularExpressionMatch match = r.match(userResponse.stdOut); const QRegularExpressionMatch match = r.match(userResponse.stdOut);
const QString user = match.hasMatch() ? match.captured(1).trimmed() : QString(); const QString user = match.hasMatch() ? match.captured(1).trimmed() : QString();
if (user.isEmpty()) if (user.isEmpty())
return QString(); return {};
args.clear(); args.clear();
args << QLatin1String("changes") << QLatin1String("-s") << QLatin1String("pending") << QLatin1String("-u") << user; args << QLatin1String("changes") << QLatin1String("-s") << QLatin1String("pending") << QLatin1String("-u") << user;
const PerforceResponse dataResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args, const PerforceResponse dataResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
@@ -1644,7 +1644,7 @@ QString PerforcePlugin::fileNameFromPerforceName(const QString& perforceName,
const PerforceResponse response = dd->runP4Cmd(dd->m_settings.topLevelSymLinkTarget(), args, flags); const PerforceResponse response = dd->runP4Cmd(dd->m_settings.topLevelSymLinkTarget(), args, flags);
if (response.error) { if (response.error) {
*errorMessage = msgWhereFailed(perforceName, response.message); *errorMessage = msgWhereFailed(perforceName, response.message);
return QString(); return {};
} }
QString output = response.stdOut; QString output = response.stdOut;
@@ -1656,7 +1656,7 @@ QString PerforcePlugin::fileNameFromPerforceName(const QString& perforceName,
if (output.isEmpty()) { if (output.isEmpty()) {
//: File is not managed by Perforce //: File is not managed by Perforce
*errorMessage = msgWhereFailed(perforceName, Tr::tr("The file is not mapped")); *errorMessage = msgWhereFailed(perforceName, Tr::tr("The file is not mapped"));
return QString(); return {};
} }
const QString p4fileSpec = output.mid(output.lastIndexOf(QLatin1Char(' ')) + 1); const QString p4fileSpec = output.mid(output.lastIndexOf(QLatin1Char(' ')) + 1);
return dd->m_settings.mapToFileSystem(p4fileSpec); return dd->m_settings.mapToFileSystem(p4fileSpec);

View File

@@ -89,7 +89,7 @@ Id SubversionClient::vcsEditorKind(VcsCommandTag cmd) const
case VcsBaseClient::LogCommand: return Constants::SUBVERSION_LOG_EDITOR_ID; case VcsBaseClient::LogCommand: return Constants::SUBVERSION_LOG_EDITOR_ID;
case VcsBaseClient::AnnotateCommand: return Constants::SUBVERSION_BLAME_EDITOR_ID; case VcsBaseClient::AnnotateCommand: return Constants::SUBVERSION_BLAME_EDITOR_ID;
default: default:
return Id(); return {};
} }
} }

View File

@@ -46,7 +46,7 @@ QString SubversionEditorWidget::changeUnderCursor(const QTextCursor &c) const
// Any number is regarded as change number. // Any number is regarded as change number.
cursor.select(QTextCursor::LineUnderCursor); cursor.select(QTextCursor::LineUnderCursor);
if (!cursor.hasSelection()) if (!cursor.hasSelection())
return QString(); return {};
const QString change = cursor.selectedText(); const QString change = cursor.selectedText();
const int pos = c.position() - cursor.selectionStart() + 1; const int pos = c.position() - cursor.selectionStart() + 1;
// Annotation output has number, log output has revision numbers, // Annotation output has number, log output has revision numbers,
@@ -72,7 +72,7 @@ QString SubversionEditorWidget::changeUnderCursor(const QTextCursor &c) const
if (pos > start && pos <= end) if (pos > start && pos <= end)
return rev; return rev;
} }
return QString(); return {};
} }
VcsBase::BaseAnnotationHighlighter *SubversionEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const VcsBase::BaseAnnotationHighlighter *SubversionEditorWidget::createAnnotationHighlighter(const QSet<QString> &changes) const

View File

@@ -994,7 +994,7 @@ QString SubversionPluginPrivate::monitorFile(const FilePath &repository) const
return fi.absoluteFilePath(); return fi.absoluteFilePath();
} }
} }
return QString(); return {};
} }
QString SubversionPluginPrivate::synchronousTopic(const FilePath &repository) const QString SubversionPluginPrivate::synchronousTopic(const FilePath &repository) const