PushToGerrit: Fix support for multiple projects on the same remote

Use case: A project has a legacy repo and a new repo. Both are used as
remotes in the same local directory. If the legacy repo's remote name is
less than the current repo (legacy < origin) then only legacy appears.

Change-Id: Ie02cbee3142c4d2628cb51cbcad50cf903a75bb0
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2017-09-10 15:37:50 +03:00
committed by Orgad Shaneh
parent 8037d5e02f
commit 3b4c6ed5bd
3 changed files with 13 additions and 4 deletions

View File

@@ -26,7 +26,6 @@
#include "gerritpushdialog.h"
#include "ui_gerritpushdialog.h"
#include "branchcombobox.h"
#include "gerritserver.h"
#include "../gitplugin.h"
#include "../gitclient.h"
@@ -129,6 +128,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir));
m_ui->remoteComboBox->setRepository(workingDir);
m_ui->remoteComboBox->setParameters(parameters);
m_ui->remoteComboBox->setAllowDups(true);
PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView);
delegate->setParent(this);

View File

@@ -80,6 +80,11 @@ void GerritRemoteChooser::setFallbackEnabled(bool value)
m_enableFallback = value;
}
void GerritRemoteChooser::setAllowDups(bool value)
{
m_allowDups = value;
}
bool GerritRemoteChooser::setCurrentRemote(const QString &remoteName)
{
for (int i = 0, total = m_remoteComboBox->count(); i < total; ++i) {
@@ -118,9 +123,11 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
void GerritRemoteChooser::addRemote(const GerritServer &server, const QString &name)
{
for (auto remote : m_remotes) {
if (remote.second == server)
return;
if (!m_allowDups) {
for (auto remote : m_remotes) {
if (remote.second == server)
return;
}
}
m_remoteComboBox->addItem(server.host + QString(" (%1)").arg(name));
m_remotes.push_back({ name, server });

View File

@@ -48,6 +48,7 @@ public:
void setRepository(const QString &repository);
void setParameters(QSharedPointer<GerritParameters> parameters);
void setFallbackEnabled(bool value);
void setAllowDups(bool value);
bool setCurrentRemote(const QString &remoteName);
bool updateRemotes(bool forceReload);
@@ -68,6 +69,7 @@ private:
QToolButton *m_resetRemoteButton = nullptr;
bool m_updatingRemotes = false;
bool m_enableFallback = false;
bool m_allowDups = false;
using NameAndServer = std::pair<QString, GerritServer>;
std::vector<NameAndServer> m_remotes;
};