From bd5afaf4c6a13c60cf4a58e0cc970c5ce0a438a2 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 12 Feb 2015 15:08:30 +0200 Subject: [PATCH] Gerrit: Gracefully handle error retrieving branch distance Change-Id: If4f6babe654a6f667c36ac3afb851b078439d3b6 Reviewed-by: Tobias Hunger --- src/plugins/git/gerrit/gerritpushdialog.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index f7d49cbd6a3..5ccc8f21714 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -184,9 +184,9 @@ QString GerritPushDialog::calculateChangeRange(const QString &branch) args << QLatin1String("--count"); QString number; + QString error; - if (!m_client->synchronousRevListCmd(m_workingDir, args, &number)) - reject(); + m_client->synchronousRevListCmd(m_workingDir, args, &number, &error); number.chop(1); return number; @@ -201,14 +201,16 @@ void GerritPushDialog::setChangeRange() const QString remoteBranchName = selectedRemoteBranchName(); if (remoteBranchName.isEmpty()) return; - QString remote = selectedRemoteName(); - remote += QLatin1Char('/'); - remote += remoteBranchName; const QString branch = m_ui->localBranchComboBox->currentText(); - m_ui->infoLabel->setText(tr("Number of commits between %1 and %2: %3") - .arg(branch) - .arg(remote) - .arg(calculateChangeRange(branch))); + const QString range = calculateChangeRange(branch); + if (range.isEmpty()) { + m_ui->infoLabel->hide(); + return; + } + m_ui->infoLabel->show(); + const QString remote = selectedRemoteName() + QLatin1Char('/') + remoteBranchName; + m_ui->infoLabel->setText( + tr("Number of commits between %1 and %2: %3").arg(branch, remote, range)); } bool GerritPushDialog::isValid() const