Commit b669ba9d authored by Tobias Hunger's avatar Tobias Hunger

Subversion: Fix argument order when using --username and --password

These need to go after the subcommand, not after the "svn"

Task-number: QTCREATORBUG-13066
Change-Id: Id3de0af8b7b2f07159d5ddb1af2e5fa00dd0dbb3
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 5a1ffe6f
......@@ -76,19 +76,14 @@ VcsCommand *CheckoutWizard::createCommand(FileName *checkoutDir)
const QString directory = cwp->directory();
QStringList args;
args << QLatin1String("checkout");
args << SubversionClient::addAuthenticationOptions(settings) << cwp->repository() << directory;
args << QLatin1String(Constants::NON_INTERACTIVE_OPTION);
if (cwp->trustServerCert())
args << QLatin1String("--trust-server-cert");
args << cwp->repository() << directory;
const QString workingDirectory = cwp->path();
*checkoutDir = FileName::fromString(workingDirectory + QLatin1Char('/') + directory);
if (settings.hasAuthentication()) {
const QString user = settings.stringValue(SubversionSettings::userKey);
const QString pwd = settings.stringValue(SubversionSettings::passwordKey);
args = SubversionClient::addAuthenticationOptions(args, user, pwd);
}
VcsCommand *command = new VcsCommand(binary, workingDirectory,
QProcessEnvironment::systemEnvironment());
command->addJob(args, -1);
......
......@@ -117,7 +117,7 @@ VcsCommand *SubversionClient::createCommitCmd(const QString &repositoryRoot,
{
const QStringList svnExtraOptions =
QStringList(extraOptions)
<< authenticationOptions(SubversionClient::CommitCommand)
<< SubversionClient::addAuthenticationOptions(*settings())
<< QLatin1String(Constants::NON_INTERACTIVE_OPTION)
<< QLatin1String("--encoding") << QLatin1String("utf8")
<< QLatin1String("--file") << commitMessageFile;
......@@ -178,28 +178,18 @@ SubversionClient::Version SubversionClient::svnVersion()
return v;
}
QStringList SubversionClient::authenticationOptions(VcsCommandTag cmd) const
{
const bool hasAuth = settings()->hasAuthentication();
const QString userName = hasAuth ? settings()->stringValue(SubversionSettings::userKey) : QString();
const QString password = hasAuth ? settings()->stringValue(SubversionSettings::passwordKey) : QString();
QStringList args(vcsCommandString(cmd));
args = SubversionClient::addAuthenticationOptions(args, userName, password);
args.removeFirst();
return args;
}
// Add authorization options to the command line arguments.
// SVN pre 1.5 does not accept "--userName" for "add", which is most likely
// an oversight. As no password is needed for the option, generally omit it.
QStringList SubversionClient::addAuthenticationOptions(const QStringList &args,
const QString &userName,
const QString &password)
QStringList SubversionClient::addAuthenticationOptions(const SubversionSettings &settings)
{
if (!settings.hasAuthentication())
return QStringList();
const QString userName = settings.stringValue(SubversionSettings::userKey);
const QString password = settings.stringValue(SubversionSettings::passwordKey);
if (userName.isEmpty())
return args;
if (!args.empty() && args.front() == QLatin1String("add"))
return args;
return QStringList();
QStringList rc;
rc.push_back(QLatin1String("--username"));
rc.push_back(userName);
......@@ -207,7 +197,6 @@ QStringList SubversionClient::addAuthenticationOptions(const QStringList &args,
rc.push_back(QLatin1String("--password"));
rc.push_back(password);
}
rc.append(args);
return rc;
}
......@@ -233,14 +222,10 @@ QString SubversionClient::synchronousTopic(const QString &repository)
void SubversionClient::diff(const QString &workingDir, const QStringList &files,
const QStringList &extraOptions)
{
QStringList args(extraOptions);
QStringList args;
args << addAuthenticationOptions(*settings());
args.append(QLatin1String("--internal-diff"));
const bool hasAuth = settings()->hasAuthentication();
const QString userName = hasAuth ? settings()->stringValue(SubversionSettings::userKey) : QString();
const QString password = hasAuth ? settings()->stringValue(SubversionSettings::passwordKey) : QString();
args = addAuthenticationOptions(args, userName, password);
args << extraOptions;
VcsBaseClient::diff(workingDir, files, args);
}
......
......@@ -76,10 +76,7 @@ public:
Version svnVersion();
// Add authorization options to the command line arguments.
QStringList authenticationOptions(VcsCommandTag cmd) const;
static QStringList addAuthenticationOptions(const QStringList &args,
const QString &userName = QString(),
const QString &password = QString());
static QStringList addAuthenticationOptions(const SubversionSettings &settings);
QString synchronousTopic(const QString &repository);
......
This diff is collapsed.
......@@ -137,15 +137,9 @@ private:
Core::IEditor * showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source,
QTextCodec *codec);
// Run using the settings' authentication options.
SubversionResponse runSvn(const QString &workingDir,
const QStringList &arguments, int timeOut,
unsigned flags, QTextCodec *outputCodec = 0) const;
// Run using custom authentication options.
SubversionResponse runSvn(const QString &workingDir,
const QString &userName, const QString &password,
const QStringList &arguments, int timeOut,
unsigned flags, QTextCodec *outputCodec = 0) const;
void filelog(const QString &workingDir,
const QString &file = QString(),
......
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