forked from qt-creator/qt-creator
Bazaar: set global Bazaar user ID when changed
This ID is automatically set when the user settings have been changed and applied from the "Options" dialog. This calls 'bzr whoami' under the hood Merge-request: 275 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "bazaarclient.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <vcsbase/vcsbaseclientsettings.h>
|
||||
#include <vcsbase/vcsbaseplugin.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
@@ -74,6 +75,15 @@ BazaarClient::BazaarClient(const VCSBase::VCSBaseClientSettings &settings) :
|
||||
{
|
||||
}
|
||||
|
||||
bool BazaarClient::synchronousSetUserId()
|
||||
{
|
||||
QStringList args;
|
||||
args << QLatin1String("whoami")
|
||||
<< QString("%1 <%2>").arg(settings().userName()).arg(settings().email());
|
||||
QByteArray stdOut;
|
||||
return vcsFullySynchronousExec(QDir::currentPath(), args, &stdOut);
|
||||
}
|
||||
|
||||
BranchInfo BazaarClient::synchronousBranchQuery(const QString &repositoryRoot) const
|
||||
{
|
||||
QFile branchConfFile(repositoryRoot + QDir::separator() +
|
||||
|
@@ -71,6 +71,7 @@ public:
|
||||
|
||||
BazaarClient(const VCSBase::VCSBaseClientSettings &settings);
|
||||
|
||||
bool synchronousSetUserId();
|
||||
BranchInfo synchronousBranchQuery(const QString &repositoryRoot) const;
|
||||
virtual QString findTopLevelForFile(const QFileInfo &file) const;
|
||||
|
||||
|
@@ -205,7 +205,10 @@ const BazaarSettings &BazaarPlugin::settings() const
|
||||
void BazaarPlugin::setSettings(const BazaarSettings &settings)
|
||||
{
|
||||
if (settings != m_bazaarSettings) {
|
||||
const bool userIdChanged = !m_bazaarSettings.sameUserId(settings);
|
||||
m_bazaarSettings = settings;
|
||||
if (userIdChanged)
|
||||
client()->synchronousSetUserId();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -48,5 +48,10 @@ BazaarSettings& BazaarSettings::operator=(const BazaarSettings& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool BazaarSettings::sameUserId(const BazaarSettings& other) const
|
||||
{
|
||||
return userName() == other.userName() && email() == other.email();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Bazaar
|
||||
|
@@ -44,6 +44,7 @@ class BazaarSettings : public VCSBase::VCSBaseClientSettings
|
||||
public:
|
||||
BazaarSettings();
|
||||
BazaarSettings& operator=(const BazaarSettings& other);
|
||||
bool sameUserId(const BazaarSettings& other) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -427,6 +427,11 @@ void VCSBaseClient::commit(const QString &repositoryRoot,
|
||||
enqueueJob(job);
|
||||
}
|
||||
|
||||
const VCSBaseClientSettings &VCSBaseClient::settings() const
|
||||
{
|
||||
return d->m_clientSettings;
|
||||
}
|
||||
|
||||
void VCSBaseClient::settingsChanged()
|
||||
{
|
||||
if (d->m_jobManager) {
|
||||
|
@@ -105,6 +105,8 @@ public:
|
||||
|
||||
virtual QString findTopLevelForFile(const QFileInfo &file) const = 0;
|
||||
|
||||
const VCSBaseClientSettings &settings() const;
|
||||
|
||||
signals:
|
||||
void parsedStatus(const QList<QPair<QString, QString> > &statusList);
|
||||
// Passes on changed signals from VCSJob to Control
|
||||
|
Reference in New Issue
Block a user