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:
cerf
2011-03-15 15:47:45 +01:00
committed by Tobias Hunger
parent 12c7c72e83
commit 455a85bd86
7 changed files with 28 additions and 1 deletions

View File

@@ -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() +

View File

@@ -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;

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -44,6 +44,7 @@ class BazaarSettings : public VCSBase::VCSBaseClientSettings
public:
BazaarSettings();
BazaarSettings& operator=(const BazaarSettings& other);
bool sameUserId(const BazaarSettings& other) const;
};
} // namespace Internal

View File

@@ -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) {

View File

@@ -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