Commit 3b4c6ed5 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

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's avatarTobias Hunger <tobias.hunger@qt.io>
parent 8037d5e0
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "gerritpushdialog.h" #include "gerritpushdialog.h"
#include "ui_gerritpushdialog.h" #include "ui_gerritpushdialog.h"
#include "branchcombobox.h" #include "branchcombobox.h"
#include "gerritserver.h"
#include "../gitplugin.h" #include "../gitplugin.h"
#include "../gitclient.h" #include "../gitclient.h"
...@@ -129,6 +128,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev ...@@ -129,6 +128,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir)); m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir));
m_ui->remoteComboBox->setRepository(workingDir); m_ui->remoteComboBox->setRepository(workingDir);
m_ui->remoteComboBox->setParameters(parameters); m_ui->remoteComboBox->setParameters(parameters);
m_ui->remoteComboBox->setAllowDups(true);
PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView); PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView);
delegate->setParent(this); delegate->setParent(this);
......
...@@ -80,6 +80,11 @@ void GerritRemoteChooser::setFallbackEnabled(bool value) ...@@ -80,6 +80,11 @@ void GerritRemoteChooser::setFallbackEnabled(bool value)
m_enableFallback = value; m_enableFallback = value;
} }
void GerritRemoteChooser::setAllowDups(bool value)
{
m_allowDups = value;
}
bool GerritRemoteChooser::setCurrentRemote(const QString &remoteName) bool GerritRemoteChooser::setCurrentRemote(const QString &remoteName)
{ {
for (int i = 0, total = m_remoteComboBox->count(); i < total; ++i) { for (int i = 0, total = m_remoteComboBox->count(); i < total; ++i) {
...@@ -118,9 +123,11 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload) ...@@ -118,9 +123,11 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
void GerritRemoteChooser::addRemote(const GerritServer &server, const QString &name) void GerritRemoteChooser::addRemote(const GerritServer &server, const QString &name)
{ {
for (auto remote : m_remotes) { if (!m_allowDups) {
if (remote.second == server) for (auto remote : m_remotes) {
return; if (remote.second == server)
return;
}
} }
m_remoteComboBox->addItem(server.host + QString(" (%1)").arg(name)); m_remoteComboBox->addItem(server.host + QString(" (%1)").arg(name));
m_remotes.push_back({ name, server }); m_remotes.push_back({ name, server });
......
...@@ -48,6 +48,7 @@ public: ...@@ -48,6 +48,7 @@ public:
void setRepository(const QString &repository); void setRepository(const QString &repository);
void setParameters(QSharedPointer<GerritParameters> parameters); void setParameters(QSharedPointer<GerritParameters> parameters);
void setFallbackEnabled(bool value); void setFallbackEnabled(bool value);
void setAllowDups(bool value);
bool setCurrentRemote(const QString &remoteName); bool setCurrentRemote(const QString &remoteName);
bool updateRemotes(bool forceReload); bool updateRemotes(bool forceReload);
...@@ -68,6 +69,7 @@ private: ...@@ -68,6 +69,7 @@ private:
QToolButton *m_resetRemoteButton = nullptr; QToolButton *m_resetRemoteButton = nullptr;
bool m_updatingRemotes = false; bool m_updatingRemotes = false;
bool m_enableFallback = false; bool m_enableFallback = false;
bool m_allowDups = false;
using NameAndServer = std::pair<QString, GerritServer>; using NameAndServer = std::pair<QString, GerritServer>;
std::vector<NameAndServer> m_remotes; std::vector<NameAndServer> m_remotes;
}; };
......
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