summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcerf <delorme.hugues@gmail.com>2011-05-12 14:48:10 +0200
committerTobias Hunger <tobias.hunger@nokia.com>2011-05-12 14:48:10 +0200
commite6bbf52f2967486642de74471436707db9c7c550 (patch)
treeac8c4ef407a761118a1a7bf72808d0916f2ee447
parentc647c7b2fdd51e4cc82e3ad0f86168f9f3cd0cd4 (diff)
downloadqt-creator-e6bbf52f2967486642de74471436707db9c7c550.tar.gz
Get rid of VCSBaseClient::ExtraCommandOptions
It is replaced by QStringList, allowing a simpler approach to add extra arguments to a command. The Bazaar and Mercurial VCS plugins are impacted by this change Merge-request: 325 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
-rw-r--r--src/plugins/bazaar/bazaarclient.cpp185
-rw-r--r--src/plugins/bazaar/bazaarclient.h41
-rw-r--r--src/plugins/bazaar/bazaarplugin.cpp49
-rw-r--r--src/plugins/bazaar/clonewizard.cpp26
-rw-r--r--src/plugins/mercurial/mercurialclient.cpp66
-rw-r--r--src/plugins/mercurial/mercurialclient.h23
-rw-r--r--src/plugins/mercurial/mercurialplugin.cpp7
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.cpp14
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.h29
9 files changed, 119 insertions, 321 deletions
diff --git a/src/plugins/bazaar/bazaarclient.cpp b/src/plugins/bazaar/bazaarclient.cpp
index 4a4a8f9de9..5f69eaf0fa 100644
--- a/src/plugins/bazaar/bazaarclient.cpp
+++ b/src/plugins/bazaar/bazaarclient.cpp
@@ -45,31 +45,6 @@
#include <QtCore/QTextStream>
#include <QtCore/QtDebug>
-namespace {
-
-void addBoolArgument(const QVariant &optionValue,
- const QString &optionName,
- QStringList *arguments)
-{
- if (arguments == 0)
- return;
- Q_ASSERT(optionValue.canConvert(QVariant::Bool));
- if (optionValue.toBool())
- arguments->append(optionName);
-}
-
-void addRevisionArgument(const QVariant &optionValue, QStringList *arguments)
-{
- if (arguments == 0)
- return;
- Q_ASSERT(optionValue.canConvert(QVariant::String));
- const QString revision = optionValue.toString();
- if (!revision.isEmpty())
- (*arguments) << QLatin1String("-r") << revision;
-}
-
-} // Anonymous namespace
-
namespace Bazaar {
namespace Internal {
@@ -139,42 +114,9 @@ QString BazaarClient::vcsEditorKind(VCSCommand cmd) const
QStringList BazaarClient::cloneArguments(const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
- QStringList args;
- // Fetch extra options
- foreach (int iOption, extraOptions.keys()) {
- const QVariant iOptValue = extraOptions[iOption];
- switch (iOption) {
- case UseExistingDirCloneOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--use-existing-dir"), &args);
- break;
- case StackedCloneOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--stacked"), &args);
- break;
- case StandAloneCloneOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--standalone"), &args);
- break;
- case BindCloneOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--bind"), &args);
- break;
- case SwitchCloneOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--switch"), &args);
- break;
- case HardLinkCloneOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--hardlink"), &args);
- break;
- case NoTreeCloneOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--no-tree"), &args);
- break;
- case RevisionCloneOptionId :
- ::addRevisionArgument(iOptValue, &args);
- break;
- default :
- Q_ASSERT(false); // Invalid option !
- }
- } // end foreach ()
- // Add arguments for common options
+ QStringList args(extraOptions);
args << srcLocation;
if (!dstLocation.isEmpty())
args << dstLocation;
@@ -182,51 +124,18 @@ QStringList BazaarClient::cloneArguments(const QString &srcLocation,
}
QStringList BazaarClient::pullArguments(const QString &srcLocation,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
- // Fetch extra options
- QStringList args(commonPullOrPushArguments(extraOptions));
- foreach (int iOption, extraOptions.keys()) {
- const QVariant iOptValue = extraOptions[iOption];
- switch (iOption) {
- case RememberPullOrPushOptionId : break;
- case OverwritePullOrPushOptionId : break;
- case RevisionPullOrPushOptionId : break;
- case LocalPullOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--local"), &args);
- break;
- default :
- Q_ASSERT(false); // Invalid option !
- }
- } // end foreach ()
- // Add arguments for common options
+ QStringList args(extraOptions);
if (!srcLocation.isEmpty())
args << srcLocation;
return args;
}
QStringList BazaarClient::pushArguments(const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
- // Fetch extra options
- QStringList args(commonPullOrPushArguments(extraOptions));
- foreach (int iOption, extraOptions.keys()) {
- const QVariant iOptValue = extraOptions[iOption];
- switch (iOption) {
- case RememberPullOrPushOptionId : break;
- case OverwritePullOrPushOptionId : break;
- case RevisionPullOrPushOptionId : break;
- case UseExistingDirPushOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--use-existing-dir"), &args);
- break;
- case CreatePrefixPushOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--create-prefix"), &args);
- break;
- default :
- Q_ASSERT(false); // Invalid option !
- }
- } // end foreach ()
- // Add arguments for common options
+ QStringList args(extraOptions);
if (!dstLocation.isEmpty())
args << dstLocation;
return args;
@@ -234,38 +143,9 @@ QStringList BazaarClient::pushArguments(const QString &dstLocation,
QStringList BazaarClient::commitArguments(const QStringList &files,
const QString &commitMessageFile,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
- QStringList args;
- // Fetch extra options
- foreach (int iOption, extraOptions.keys()) {
- const QVariant iOptValue = extraOptions[iOption];
- switch (iOption) {
- case AuthorCommitOptionId :
- {
- Q_ASSERT(iOptValue.canConvert(QVariant::String));
- const QString committerInfo = iOptValue.toString();
- if (!committerInfo.isEmpty())
- args << QString("--author=%1").arg(committerInfo);
- break;
- }
- case FixesCommitOptionId :
- {
- Q_ASSERT(iOptValue.canConvert(QVariant::StringList));
- foreach (const QString& iFix, iOptValue.toStringList()) {
- if (!iFix.isEmpty())
- args << QLatin1String("--fixes") << iFix;
- }
- break;
- }
- case LocalCommitOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--local"), &args);
- break;
- default :
- Q_ASSERT(false); // Invalid option !
- }
- } // end foreach ()
- // Add arguments for common options
+ QStringList args(extraOptions);
args << QLatin1String("-F") << commitMessageFile;
args << files;
return args;
@@ -318,29 +198,16 @@ QStringList BazaarClient::annotateArguments(const QString &file,
}
QStringList BazaarClient::diffArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
- QStringList args;
- foreach (const QVariant &extraOption, extraOptions) {
- switch (extraOption.type()) {
- case QVariant::String:
- args.append(extraOption.toString());
- break;
- case QVariant::StringList:
- args.append(extraOption.toStringList());
- break;
- default:
- QTC_ASSERT(false, continue; )
- break;
- }
- }
+ QStringList args(extraOptions);
if (!files.isEmpty())
args.append(files);
return args;
}
QStringList BazaarClient::logArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
return diffArguments(files, extraOptions);
}
@@ -406,35 +273,13 @@ QPair<QString, QString> BazaarClient::parseStatusLine(const QString &line) const
return status;
}
-QStringList BazaarClient::commonPullOrPushArguments(const ExtraCommandOptions &extraOptions) const
-{
- QStringList args;
- foreach (int iOption, extraOptions.keys()) {
- const QVariant iOptValue = extraOptions[iOption];
- switch (iOption) {
- case RememberPullOrPushOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--remember"), &args);
- break;
- case OverwritePullOrPushOptionId :
- ::addBoolArgument(iOptValue, QLatin1String("--overwrite"), &args);
- break;
- case RevisionPullOrPushOptionId :
- ::addRevisionArgument(iOptValue, &args);
- break;
- default :
- break; // Unknown option, do nothing
- }
- } // end foreach ()
- return args;
-}
-
// Collect all parameters required for a diff to be able to associate them
// with a diff editor and re-run the diff with parameters.
struct BazaarDiffParameters
{
QString workingDir;
QStringList files;
- VCSBase::VCSBaseClient::ExtraCommandOptions extraOptions;
+ QStringList extraOptions;
};
// Parameter widget controlling whitespace diff mode, associated with a parameter
@@ -470,7 +315,7 @@ void BazaarDiffParameterWidget::triggerReRun()
if (!formatArguments.isEmpty()) {
const QString a = QLatin1String("--diff-options=")
+ formatArguments.join(QString(QLatin1Char(' ')));
- effectiveParameters.extraOptions.insert(42, QVariant(a));
+ effectiveParameters.extraOptions.append(a);
}
emit reRunDiff(effectiveParameters);
}
@@ -481,7 +326,7 @@ void BazaarClient::bazaarDiff(const Bazaar::Internal::BazaarDiffParameters &p)
}
void BazaarClient::initializeDiffEditor(const QString &workingDir, const QStringList &files,
- const VCSBase::VCSBaseClient::ExtraCommandOptions &extra,
+ const QStringList &extraOptions,
VCSBase::VCSBaseEditorWidget *diffEditorWidget)
{
// Wire up the parameter widget to trigger a re-run on
@@ -489,7 +334,7 @@ void BazaarClient::initializeDiffEditor(const QString &workingDir, const QString
BazaarDiffParameters parameters;
parameters.workingDir = workingDir;
parameters.files = files;
- parameters.extraOptions = extra;
+ parameters.extraOptions = extraOptions;
diffEditorWidget->setRevertDiffChunkEnabled(true);
BazaarDiffParameterWidget *pw = new BazaarDiffParameterWidget(parameters);
connect(pw, SIGNAL(reRunDiff(Bazaar::Internal::BazaarDiffParameters)),
diff --git a/src/plugins/bazaar/bazaarclient.h b/src/plugins/bazaar/bazaarclient.h
index 4cf6f484b7..39118e0ca8 100644
--- a/src/plugins/bazaar/bazaarclient.h
+++ b/src/plugins/bazaar/bazaarclient.h
@@ -44,32 +44,6 @@ class BazaarClient : public VCSBase::VCSBaseClient
{
Q_OBJECT
public:
- enum ExtraOptionId
- {
- // Clone
- UseExistingDirCloneOptionId,
- StackedCloneOptionId,
- StandAloneCloneOptionId,
- BindCloneOptionId,
- SwitchCloneOptionId,
- HardLinkCloneOptionId,
- NoTreeCloneOptionId,
- RevisionCloneOptionId,
- // Commit
- AuthorCommitOptionId,
- FixesCommitOptionId,
- LocalCommitOptionId,
- // Pull or push (common options)
- RememberPullOrPushOptionId,
- OverwritePullOrPushOptionId,
- RevisionPullOrPushOptionId,
- // Pull only
- LocalPullOptionId,
- // Push only
- UseExistingDirPushOptionId,
- CreatePrefixPushOptionId
- };
-
BazaarClient(const VCSBase::VCSBaseClientSettings &settings);
bool synchronousSetUserId();
@@ -84,14 +58,14 @@ protected:
QStringList cloneArguments(const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList pullArguments(const QString &srcLocation,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList pushArguments(const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList commitArguments(const QStringList &files,
const QString &commitMessageFile,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList importArguments(const QStringList &files) const;
QStringList updateArguments(const QString &revision) const;
QStringList revertArguments(const QString &file, const QString &revision) const;
@@ -99,18 +73,17 @@ protected:
QStringList annotateArguments(const QString &file,
const QString &revision, int lineNumber) const;
QStringList diffArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
void initializeDiffEditor(const QString &workingDir, const QStringList &files,
- const VCSBase::VCSBaseClient::ExtraCommandOptions &extra,
+ const QStringList &extraOptions,
VCSBase::VCSBaseEditorWidget *diffEditorWidget);
QStringList logArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList statusArguments(const QString &file) const;
QStringList viewArguments(const QString &revision) const;
QPair<QString, QString> parseStatusLine(const QString &line) const;
private:
- QStringList commonPullOrPushArguments(const ExtraCommandOptions &extraOptions) const;
friend class CloneWizard;
};
diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp
index bece1fd51d..0f2a1ec31d 100644
--- a/src/plugins/bazaar/bazaarplugin.cpp
+++ b/src/plugins/bazaar/bazaarplugin.cpp
@@ -319,7 +319,7 @@ void BazaarPlugin::logCurrentFile()
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
m_client->log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()),
- BazaarClient::ExtraCommandOptions(), true);
+ QStringList(), true);
}
void BazaarPlugin::revertCurrentFile()
@@ -461,11 +461,15 @@ void BazaarPlugin::pull()
PullOrPushDialog dialog(PullOrPushDialog::PullMode);
if (dialog.exec() != QDialog::Accepted)
return;
- BazaarClient::ExtraCommandOptions extraOptions;
- extraOptions[BazaarClient::RememberPullOrPushOptionId] = dialog.isRememberOptionEnabled();
- extraOptions[BazaarClient::OverwritePullOrPushOptionId] = dialog.isOverwriteOptionEnabled();
- extraOptions[BazaarClient::RevisionPullOrPushOptionId] = dialog.revision();
- extraOptions[BazaarClient::LocalPullOptionId] = dialog.isLocalOptionEnabled();
+ QStringList extraOptions;
+ if (dialog.isRememberOptionEnabled())
+ extraOptions += QLatin1String("--remember");
+ if (dialog.isOverwriteOptionEnabled())
+ extraOptions += QLatin1String("--overwrite");
+ if (dialog.isLocalOptionEnabled())
+ extraOptions += QLatin1String("--local");
+ if (!dialog.revision().isEmpty())
+ extraOptions << QLatin1String("-r") << dialog.revision();
m_client->synchronousPull(state.topLevel(), dialog.branchLocation(), extraOptions);
}
@@ -477,12 +481,17 @@ void BazaarPlugin::push()
PullOrPushDialog dialog(PullOrPushDialog::PushMode);
if (dialog.exec() != QDialog::Accepted)
return;
- BazaarClient::ExtraCommandOptions extraOptions;
- extraOptions[BazaarClient::RememberPullOrPushOptionId] = dialog.isRememberOptionEnabled();
- extraOptions[BazaarClient::OverwritePullOrPushOptionId] = dialog.isOverwriteOptionEnabled();
- extraOptions[BazaarClient::RevisionPullOrPushOptionId] = dialog.revision();
- extraOptions[BazaarClient::UseExistingDirPushOptionId] = dialog.isUseExistingDirectoryOptionEnabled();
- extraOptions[BazaarClient::CreatePrefixPushOptionId] = dialog.isCreatePrefixOptionEnabled();
+ QStringList extraOptions;
+ if (dialog.isRememberOptionEnabled())
+ extraOptions += QLatin1String("--remember");
+ if (dialog.isOverwriteOptionEnabled())
+ extraOptions += QLatin1String("--overwrite");
+ if (dialog.isUseExistingDirectoryOptionEnabled())
+ extraOptions += QLatin1String("--use-existing-dir");
+ if (dialog.isCreatePrefixOptionEnabled())
+ extraOptions += QLatin1String("--create-prefix");
+ if (!dialog.revision().isEmpty())
+ extraOptions << QLatin1String("-r") << dialog.revision();
m_client->synchronousPush(state.topLevel(), dialog.branchLocation(), extraOptions);
}
@@ -643,10 +652,18 @@ bool BazaarPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submit
}
const BazaarCommitWidget* commitWidget = commitEditor->commitWidget();
- BazaarClient::ExtraCommandOptions extraOptions;
- extraOptions[BazaarClient::AuthorCommitOptionId] = commitWidget->committer();
- extraOptions[BazaarClient::FixesCommitOptionId] = commitWidget->fixedBugs();
- extraOptions[BazaarClient::LocalCommitOptionId] = commitWidget->isLocalOptionEnabled();
+ QStringList extraOptions;
+ // Author
+ if (!commitWidget->committer().isEmpty())
+ extraOptions.append(QLatin1String("--author=") + commitWidget->committer());
+ // Fixed bugs
+ foreach (const QString &fix, commitWidget->fixedBugs()) {
+ if (!fix.isEmpty())
+ extraOptions << QLatin1String("--fixes") << fix;
+ }
+ // Whether local commit or not
+ if (commitWidget->isLocalOptionEnabled())
+ extraOptions += QLatin1String("--local");
m_client->commit(m_submitRepository, files, editorFile->fileName(), extraOptions);
}
return true;
diff --git a/src/plugins/bazaar/clonewizard.cpp b/src/plugins/bazaar/clonewizard.cpp
index 163adc2e22..0d168480c0 100644
--- a/src/plugins/bazaar/clonewizard.cpp
+++ b/src/plugins/bazaar/clonewizard.cpp
@@ -93,15 +93,23 @@ QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<
*checkoutPath = page->path() + QLatin1Char('/') + page->directory();
const CloneOptionsPanel *panel = page->cloneOptionsPanel();
- BazaarClient::ExtraCommandOptions extraOptions;
- extraOptions[BazaarClient::UseExistingDirCloneOptionId] = panel->isUseExistingDirectoryOptionEnabled();
- extraOptions[BazaarClient::StackedCloneOptionId] = panel->isStackedOptionEnabled();
- extraOptions[BazaarClient::StandAloneCloneOptionId] = panel->isStandAloneOptionEnabled();
- extraOptions[BazaarClient::BindCloneOptionId] = panel->isBindOptionEnabled();
- extraOptions[BazaarClient::SwitchCloneOptionId] = panel->isSwitchOptionEnabled();
- extraOptions[BazaarClient::HardLinkCloneOptionId] = panel->isHardLinkOptionEnabled();
- extraOptions[BazaarClient::NoTreeCloneOptionId] = panel->isNoTreeOptionEnabled();
- extraOptions[BazaarClient::RevisionCloneOptionId] = panel->revision();
+ QStringList extraOptions;
+ if (panel->isUseExistingDirectoryOptionEnabled())
+ extraOptions += QLatin1String("--use-existing-dir");
+ if (panel->isStackedOptionEnabled())
+ extraOptions += QLatin1String("--stacked");
+ if (panel->isStandAloneOptionEnabled())
+ extraOptions += QLatin1String("--standalone");
+ if (panel->isBindOptionEnabled())
+ extraOptions += QLatin1String("--bind");
+ if (panel->isSwitchOptionEnabled())
+ extraOptions += QLatin1String("--switch");
+ if (panel->isHardLinkOptionEnabled())
+ extraOptions += QLatin1String("--hardlink");
+ if (panel->isNoTreeOptionEnabled())
+ extraOptions += QLatin1String("--no-tree");
+ if (!panel->revision().isEmpty())
+ extraOptions << QLatin1String("-r") << panel->revision();
const BazaarClient *client = BazaarPlugin::instance()->client();
args << client->vcsCommandString(BazaarClient::CloneCommand)
<< client->cloneArguments(page->repository(), page->directory(), extraOptions);
diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp
index 04c9591d27..2453f89805 100644
--- a/src/plugins/mercurial/mercurialclient.cpp
+++ b/src/plugins/mercurial/mercurialclient.cpp
@@ -79,7 +79,7 @@ bool MercurialClient::manifestSync(const QString &repository, const QString &rel
bool MercurialClient::synchronousClone(const QString &workingDir,
const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions)
+ const QStringList &extraOptions)
{
Q_UNUSED(workingDir);
Q_UNUSED(extraOptions);
@@ -320,7 +320,7 @@ QString MercurialClient::vcsEditorKind(VCSCommand cmd) const
QStringList MercurialClient::cloneArguments(const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
Q_UNUSED(srcLocation);
Q_UNUSED(dstLocation);
@@ -330,7 +330,7 @@ QStringList MercurialClient::cloneArguments(const QString &srcLocation,
}
QStringList MercurialClient::pullArguments(const QString &srcLocation,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
Q_UNUSED(extraOptions);
QStringList args;
@@ -341,7 +341,7 @@ QStringList MercurialClient::pullArguments(const QString &srcLocation,
}
QStringList MercurialClient::pushArguments(const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
Q_UNUSED(extraOptions);
QStringList args;
@@ -353,36 +353,11 @@ QStringList MercurialClient::pushArguments(const QString &dstLocation,
QStringList MercurialClient::commitArguments(const QStringList &files,
const QString &commitMessageFile,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
QStringList args(QLatin1String("--noninteractive"));
- // Fetch extra options
- foreach (int iOption, extraOptions.keys())
- {
- const QVariant iOptValue = extraOptions[iOption];
- switch (iOption)
- {
- case AuthorCommitOptionId :
- {
- Q_ASSERT(iOptValue.canConvert(QVariant::String));
- const QString committerInfo = iOptValue.toString();
- if (!committerInfo.isEmpty())
- args << QLatin1String("-u") << committerInfo;
- break;
- }
- case AutoAddRemoveCommitOptionId :
- {
- Q_ASSERT(iOptValue.canConvert(QVariant::Bool));
- const bool autoAddRemove = iOptValue.toBool();
- if (autoAddRemove)
- args << QLatin1String("-A");
- break;
- }
- default :
- Q_ASSERT(false); // Invalid option !
- }
- } // end foreach ()
- // Add arguments for common options
+ if (!args.isEmpty())
+ args.append(extraOptions);
args << QLatin1String("-l") << commitMessageFile;
args << files;
return args;
@@ -435,30 +410,19 @@ QStringList MercurialClient::annotateArguments(const QString &file,
}
QStringList MercurialClient::diffArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
QStringList args;
args << QLatin1String("-g") << QLatin1String("-p") << QLatin1String("-U 8");
- foreach (const QVariant &extraOption, extraOptions) {
- switch (extraOption.type()) {
- case QVariant::String:
- args.append(extraOption.toString());
- break;
- case QVariant::StringList:
- args.append(extraOption.toStringList());
- break;
- default:
- QTC_ASSERT(false, continue; )
- break;
- }
- }
+ if (!args.isEmpty())
+ args.append(extraOptions);
if (!files.isEmpty())
args.append(files);
return args;
}
QStringList MercurialClient::logArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const
+ const QStringList &extraOptions) const
{
Q_UNUSED(extraOptions);
QStringList args;
@@ -514,7 +478,7 @@ struct MercurialDiffParameters
{
QString workingDir;
QStringList files;
- VCSBase::VCSBaseClient::ExtraCommandOptions extraOptions;
+ QStringList extraOptions;
};
// Parameter widget controlling whitespace diff mode, associated with a parameter
@@ -545,7 +509,7 @@ MercurialDiffParameterWidget::MercurialDiffParameterWidget(const MercurialDiffPa
void MercurialDiffParameterWidget::triggerReRun()
{
MercurialDiffParameters effectiveParameters = m_parameters;
- effectiveParameters.extraOptions.insert(42, QVariant(arguments()));
+ effectiveParameters.extraOptions += arguments();
emit reRunDiff(effectiveParameters);
}
@@ -555,7 +519,7 @@ void MercurialClient::mercurialDiff(const Mercurial::Internal::MercurialDiffPara
}
void MercurialClient::initializeDiffEditor(const QString &workingDir, const QStringList &files,
- const VCSBase::VCSBaseClient::ExtraCommandOptions &extra,
+ const QStringList &extraOptions,
VCSBase::VCSBaseEditorWidget *diffEditorWidget)
{
// Wire up the parameter widget to trigger a re-run on
@@ -563,7 +527,7 @@ void MercurialClient::initializeDiffEditor(const QString &workingDir, const QStr
MercurialDiffParameters parameters;
parameters.workingDir = workingDir;
parameters.files = files;
- parameters.extraOptions = extra;
+ parameters.extraOptions = extraOptions;
diffEditorWidget->setRevertDiffChunkEnabled(true);
MercurialDiffParameterWidget *pw = new MercurialDiffParameterWidget(parameters);
connect(pw, SIGNAL(reRunDiff(Mercurial::Internal::MercurialDiffParameters)),
diff --git a/src/plugins/mercurial/mercurialclient.h b/src/plugins/mercurial/mercurialclient.h
index 9b913f139a..284940b844 100644
--- a/src/plugins/mercurial/mercurialclient.h
+++ b/src/plugins/mercurial/mercurialclient.h
@@ -43,18 +43,11 @@ class MercurialClient : public VCSBase::VCSBaseClient
{
Q_OBJECT
public:
- enum ExtraOptionId
- {
- // Commit
- AuthorCommitOptionId,
- AutoAddRemoveCommitOptionId
- };
-
MercurialClient(const VCSBase::VCSBaseClientSettings &settings);
virtual bool synchronousClone(const QString &workingDir,
const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions = ExtraCommandOptions());
+ const QStringList &extraOptions = QStringList());
bool manifestSync(const QString &repository, const QString &filename);
QString branchQuerySync(const QString &repositoryRoot);
bool parentRevisionsSync(const QString &workingDirectory,
@@ -82,14 +75,14 @@ protected:
QStringList cloneArguments(const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList pullArguments(const QString &srcLocation,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList pushArguments(const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList commitArguments(const QStringList &files,
const QString &commitMessageFile,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList importArguments(const QStringList &files) const;
QStringList updateArguments(const QString &revision) const;
QStringList revertArguments(const QString &file, const QString &revision) const;
@@ -97,12 +90,12 @@ protected:
QStringList annotateArguments(const QString &file,
const QString &revision, int lineNumber) const;
QStringList diffArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
void initializeDiffEditor(const QString &workingDir, const QStringList &files,
- const VCSBase::VCSBaseClient::ExtraCommandOptions &extra,
+ const QStringList &extraOptions,
VCSBase::VCSBaseEditorWidget *ed);
QStringList logArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const;
+ const QStringList &extraOptions) const;
QStringList statusArguments(const QString &file) const;
QStringList viewArguments(const QString &revision) const;
diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp
index 733932225d..88abc9f3ce 100644
--- a/src/plugins/mercurial/mercurialplugin.cpp
+++ b/src/plugins/mercurial/mercurialplugin.cpp
@@ -318,7 +318,7 @@ void MercurialPlugin::logCurrentFile()
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return)
m_client->log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()),
- MercurialClient::ExtraCommandOptions(), true);
+ QStringList(), true);
}
void MercurialPlugin::revertCurrentFile()
@@ -668,8 +668,9 @@ bool MercurialPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *sub
if (!core->fileManager()->saveFile(editorFile))
return false;
- QHash<int, QVariant> extraOptions;
- extraOptions[MercurialClient::AuthorCommitOptionId] = commitEditor->committerInfo();
+ QStringList extraOptions;
+ if (!commitEditor->committerInfo().isEmpty())
+ extraOptions << QLatin1String("-u") << commitEditor->committerInfo();
m_client->commit(m_submitRepository, files, editorFile->fileName(),
extraOptions);
}
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index a3c0952c96..278c025d73 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -121,7 +121,7 @@ bool VCSBaseClient::synchronousCreateRepository(const QString &workingDirectory)
bool VCSBaseClient::synchronousClone(const QString &workingDir,
const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions)
+ const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(CloneCommand)
@@ -157,7 +157,7 @@ bool VCSBaseClient::synchronousMove(const QString &workingDir,
bool VCSBaseClient::synchronousPull(const QString &workingDir,
const QString &srcLocation,
- const ExtraCommandOptions &extraOptions)
+ const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(PullCommand) << pullArguments(srcLocation, extraOptions);
@@ -175,7 +175,7 @@ bool VCSBaseClient::synchronousPull(const QString &workingDir,
bool VCSBaseClient::synchronousPush(const QString &workingDir,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions)
+ const QStringList &extraOptions)
{
QStringList args;
args << vcsCommandString(PushCommand) << pushArguments(dstLocation, extraOptions);
@@ -272,7 +272,7 @@ void VCSBaseClient::annotate(const QString &workingDir, const QString &file,
}
void VCSBaseClient::diff(const QString &workingDir, const QStringList &files,
- const ExtraCommandOptions &extraOptions)
+ const QStringList &extraOptions)
{
const QString vcsCmdString = vcsCommandString(DiffCommand);
QStringList args;
@@ -291,7 +291,7 @@ void VCSBaseClient::diff(const QString &workingDir, const QStringList &files,
}
void VCSBaseClient::log(const QString &workingDir, const QStringList &files,
- const ExtraCommandOptions &extraOptions,
+ const QStringList &extraOptions,
bool enableAnnotationContextMenu)
{
const QString vcsCmdString = vcsCommandString(LogCommand);
@@ -433,7 +433,7 @@ void VCSBaseClient::update(const QString &repositoryRoot, const QString &revisio
void VCSBaseClient::commit(const QString &repositoryRoot,
const QStringList &files,
const QString &commitMessageFile,
- const ExtraCommandOptions &extraOptions)
+ const QStringList &extraOptions)
{
QStringList args(vcsCommandString(CommitCommand));
args.append(commitArguments(files, commitMessageFile, extraOptions));
@@ -457,7 +457,7 @@ void VCSBaseClient::settingsChanged()
}
void VCSBaseClient::initializeDiffEditor(const QString & /* workingDir */, const QStringList & /* files */,
- const ExtraCommandOptions & /* extraOptions */,
+ const QStringList & /* extraOptions */,
VCSBaseEditorWidget *)
{
}
diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h
index 59e66c689b..1cb04d7820 100644
--- a/src/plugins/vcsbase/vcsbaseclient.h
+++ b/src/plugins/vcsbase/vcsbaseclient.h
@@ -40,7 +40,6 @@
#include <QtCore/QPair>
#include <QtCore/QSharedPointer>
#include <QtCore/QScopedPointer>
-#include <QtCore/QHash>
#include <QtCore/QVariant>
QT_BEGIN_NAMESPACE
@@ -67,31 +66,29 @@ class VCSBASE_EXPORT VCSBaseClient : public QObject
{
Q_OBJECT
public:
- typedef QHash<int, QVariant> ExtraCommandOptions;
-
explicit VCSBaseClient(const VCSBaseClientSettings &settings);
~VCSBaseClient();
virtual bool synchronousCreateRepository(const QString &workingDir);
virtual bool synchronousClone(const QString &workingDir,
const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions = ExtraCommandOptions());
+ const QStringList &extraOptions = QStringList());
virtual bool synchronousAdd(const QString &workingDir, const QString &fileName);
virtual bool synchronousRemove(const QString &workingDir, const QString &fileName);
virtual bool synchronousMove(const QString &workingDir,
const QString &from, const QString &to);
virtual bool synchronousPull(const QString &workingDir,
const QString &srcLocation,
- const ExtraCommandOptions &extraOptions = ExtraCommandOptions());
+ const QStringList &extraOptions = QStringList());
virtual bool synchronousPush(const QString &workingDir,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions = ExtraCommandOptions());
+ const QStringList &extraOptions = QStringList());
void annotate(const QString &workingDir, const QString &file,
const QString revision = QString(), int lineNumber = -1);
void diff(const QString &workingDir, const QStringList &files = QStringList(),
- const ExtraCommandOptions &extraOptions = ExtraCommandOptions());
+ const QStringList &extraOptions = QStringList());
void log(const QString &workingDir, const QStringList &files = QStringList(),
- const ExtraCommandOptions &extraOptions = ExtraCommandOptions(),
+ const QStringList &extraOptions = QStringList(),
bool enableAnnotationContextMenu = false);
void status(const QString &workingDir, const QString &file = QString());
void statusWithSignal(const QString &repository);
@@ -102,7 +99,7 @@ public:
void commit(const QString &repositoryRoot,
const QStringList &files,
const QString &commitMessageFile,
- const ExtraCommandOptions &extraOptions = ExtraCommandOptions());
+ const QStringList &extraOptions = QStringList());
virtual QString findTopLevelForFile(const QFileInfo &file) const = 0;
@@ -141,14 +138,14 @@ protected:
virtual QStringList cloneArguments(const QString &srcLocation,
const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const = 0;
+ const QStringList &extraOptions) const = 0;
virtual QStringList pullArguments(const QString &srcLocation,
- const ExtraCommandOptions &extraOptions) const = 0;
+ const QStringList &extraOptions) const = 0;
virtual QStringList pushArguments(const QString &dstLocation,
- const ExtraCommandOptions &extraOptions) const = 0;
+ const QStringList &extraOptions) const = 0;
virtual QStringList commitArguments(const QStringList &files,
const QString &commitMessageFile,
- const ExtraCommandOptions &extraOptions) const = 0;
+ const QStringList &extraOptions) const = 0;
virtual QStringList importArguments(const QStringList &files) const = 0;
virtual QStringList updateArguments(const QString &revision) const = 0;
virtual QStringList revertArguments(const QString &file, const QString &revision) const = 0;
@@ -156,11 +153,11 @@ protected:
virtual QStringList annotateArguments(const QString &file,
const QString &revision, int lineNumber) const = 0;
virtual QStringList diffArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const = 0;
+ const QStringList &extraOptions) const = 0;
virtual void initializeDiffEditor(const QString &workingDir, const QStringList &files,
- const ExtraCommandOptions &extraOptions, VCSBaseEditorWidget *ed);
+ const QStringList &extraOptions, VCSBaseEditorWidget *ed);
virtual QStringList logArguments(const QStringList &files,
- const ExtraCommandOptions &extraOptions) const = 0;
+ const QStringList &extraOptions) const = 0;
virtual QStringList statusArguments(const QString &file) const = 0;
virtual QStringList viewArguments(const QString &revision) const = 0;