summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@nokia.com>2013-10-15 20:03:22 +0200
committerJarek Kobus <jaroslaw.kobus@digia.com>2013-10-16 08:34:28 +0200
commit72da839bbfe2b526e95d92d9979d18477db8abb5 (patch)
tree615e4eaa8301c749012d649fff637aa45e839649
parent0f4808a6294a7fd565f0dd3988d19838d05edd8d (diff)
downloadqt-creator-72da839bbfe2b526e95d92d9979d18477db8abb5.tar.gz
Use VcsBaseClient::diff instead of cvs's one
The second step in cleaning a mess in VCS Change-Id: I3eb360825480c74242110b0da9f90b39fc4c767f Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
-rw-r--r--src/plugins/cvs/checkoutwizard.cpp2
-rw-r--r--src/plugins/cvs/cvs.pro2
-rw-r--r--src/plugins/cvs/cvs.qbs2
-rw-r--r--src/plugins/cvs/cvsclient.cpp182
-rw-r--r--src/plugins/cvs/cvsclient.h68
-rw-r--r--src/plugins/cvs/cvscontrol.cpp2
-rw-r--r--src/plugins/cvs/cvsplugin.cpp172
-rw-r--r--src/plugins/cvs/cvsplugin.h6
-rw-r--r--src/plugins/cvs/cvssettings.cpp83
-rw-r--r--src/plugins/cvs/cvssettings.h38
-rw-r--r--src/plugins/cvs/settingspage.cpp25
11 files changed, 346 insertions, 236 deletions
diff --git a/src/plugins/cvs/checkoutwizard.cpp b/src/plugins/cvs/checkoutwizard.cpp
index e2a3bb327c..85655f8aee 100644
--- a/src/plugins/cvs/checkoutwizard.cpp
+++ b/src/plugins/cvs/checkoutwizard.cpp
@@ -68,7 +68,7 @@ VcsBase::Command *CheckoutWizard::createCommand(const QList<QWizardPage*> &param
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPages.front());
QTC_ASSERT(cwp, return 0);
const CvsSettings settings = CvsPlugin::instance()->settings();
- const QString binary = settings.cvsBinaryPath;
+ const QString binary = settings.binaryPath();
QStringList args;
const QString repository = cwp->repository();
args << QLatin1String("checkout") << repository;
diff --git a/src/plugins/cvs/cvs.pro b/src/plugins/cvs/cvs.pro
index 9ecb32b06e..be1d4af402 100644
--- a/src/plugins/cvs/cvs.pro
+++ b/src/plugins/cvs/cvs.pro
@@ -2,6 +2,7 @@ include(../../qtcreatorplugin.pri)
HEADERS += annotationhighlighter.h \
cvsplugin.h \
+ cvsclient.h \
cvscontrol.h \
settingspage.h \
cvseditor.h \
@@ -14,6 +15,7 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \
cvsplugin.cpp \
+ cvsclient.cpp \
cvscontrol.cpp \
settingspage.cpp \
cvseditor.cpp \
diff --git a/src/plugins/cvs/cvs.qbs b/src/plugins/cvs/cvs.qbs
index 8d858a7b24..a1021cfc6e 100644
--- a/src/plugins/cvs/cvs.qbs
+++ b/src/plugins/cvs/cvs.qbs
@@ -20,6 +20,8 @@ QtcPlugin {
"checkoutwizardpage.cpp",
"checkoutwizardpage.h",
"cvs.qrc",
+ "cvsclient.cpp",
+ "cvsclient.h",
"cvsconstants.h",
"cvscontrol.cpp",
"cvscontrol.h",
diff --git a/src/plugins/cvs/cvsclient.cpp b/src/plugins/cvs/cvsclient.cpp
new file mode 100644
index 0000000000..2dfe577e01
--- /dev/null
+++ b/src/plugins/cvs/cvsclient.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "cvsclient.h"
+#include "cvssettings.h"
+#include "cvsconstants.h"
+
+#include <vcsbase/vcsbaseplugin.h>
+#include <vcsbase/vcsbaseeditor.h>
+#include <vcsbase/vcsbaseconstants.h>
+#include <vcsbase/vcsbaseeditorparameterwidget.h>
+#include <utils/synchronousprocess.h>
+
+#include <QDir>
+#include <QFileInfo>
+#include <QTextStream>
+#include <QDebug>
+
+namespace Cvs {
+namespace Internal {
+
+class CvsDiffExitCodeInterpreter : public Utils::ExitCodeInterpreter
+{
+ Q_OBJECT
+public:
+ CvsDiffExitCodeInterpreter(QObject *parent) : Utils::ExitCodeInterpreter(parent) {}
+ Utils::SynchronousProcessResponse::Result interpretExitCode(int code) const;
+
+};
+
+Utils::SynchronousProcessResponse::Result CvsDiffExitCodeInterpreter::interpretExitCode(int code) const
+{
+ if (code < 0 || code > 2)
+ return Utils::SynchronousProcessResponse::FinishedError;
+ return Utils::SynchronousProcessResponse::Finished;
+}
+
+// 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 CvsDiffParameters
+{
+ QString workingDir;
+ QStringList extraOptions;
+ QStringList files;
+};
+
+// Parameter widget controlling whitespace diff mode, associated with a parameter
+class CvsDiffParameterWidget : public VcsBase::VcsBaseEditorParameterWidget
+{
+ Q_OBJECT
+public:
+ explicit CvsDiffParameterWidget(CvsClient *client,
+ const CvsDiffParameters &p,
+ QWidget *parent = 0);
+ QStringList arguments() const;
+ void executeCommand();
+
+private:
+
+ CvsClient *m_client;
+ const CvsDiffParameters m_params;
+};
+
+CvsDiffParameterWidget::CvsDiffParameterWidget(CvsClient *client,
+ const CvsDiffParameters &p,
+ QWidget *parent)
+ : VcsBase::VcsBaseEditorParameterWidget(parent), m_client(client), m_params(p)
+{
+ mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace")),
+ client->settings()->boolPointer(CvsSettings::diffIgnoreWhiteSpaceKey));
+ mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines")),
+ client->settings()->boolPointer(CvsSettings::diffIgnoreBlankLinesKey));
+}
+
+QStringList CvsDiffParameterWidget::arguments() const
+{
+ QStringList args;
+ args = m_client->settings()->stringValue(CvsSettings::diffOptionsKey).split(QLatin1Char(' '), QString::SkipEmptyParts);
+ args += VcsBaseEditorParameterWidget::arguments();
+ return args;
+}
+
+void CvsDiffParameterWidget::executeCommand()
+{
+ m_client->diff(m_params.workingDir, m_params.files, m_params.extraOptions);
+}
+
+CvsClient::CvsClient(CvsSettings *settings) :
+ VcsBase::VcsBaseClient(settings)
+{
+}
+
+CvsSettings *CvsClient::settings() const
+{
+ return dynamic_cast<CvsSettings *>(VcsBase::VcsBaseClient::settings());
+}
+
+Core::Id CvsClient::vcsEditorKind(VcsCommand cmd) const
+{
+ switch (cmd) {
+ case DiffCommand:
+ return "CVS Diff Editor"; // TODO: replace by string from cvsconstants.h
+ default:
+ return Core::Id();
+ }
+}
+
+Utils::ExitCodeInterpreter *CvsClient::exitCodeInterpreter(VcsCommand cmd, QObject *parent) const
+{
+ switch (cmd) {
+ case DiffCommand:
+ return new CvsDiffExitCodeInterpreter(parent);
+ default:
+ return 0;
+ }
+}
+
+void CvsClient::diff(const QString &workingDir, const QStringList &files,
+ const QStringList &extraOptions)
+{
+ VcsBaseClient::diff(workingDir, files, extraOptions);
+}
+
+QString CvsClient::findTopLevelForFile(const QFileInfo &file) const
+{
+ Q_UNUSED(file)
+ return QString();
+}
+
+QStringList CvsClient::revisionSpec(const QString &revision) const
+{
+ Q_UNUSED(revision)
+ return QStringList();
+}
+
+VcsBase::VcsBaseClient::StatusItem CvsClient::parseStatusLine(const QString &line) const
+{
+ Q_UNUSED(line)
+ return VcsBase::VcsBaseClient::StatusItem();
+}
+
+VcsBase::VcsBaseEditorParameterWidget *CvsClient::createDiffEditor(
+ const QString &workingDir, const QStringList &files, const QStringList &extraOptions)
+{
+ Q_UNUSED(extraOptions)
+ CvsDiffParameters p;
+ p.workingDir = workingDir;
+ p.files = files;
+ p.extraOptions = extraOptions;
+ return new CvsDiffParameterWidget(this, p);
+}
+
+} // namespace Internal
+} // namespace Cvs
+
+#include "cvsclient.moc"
diff --git a/src/plugins/cvs/cvsclient.h b/src/plugins/cvs/cvsclient.h
new file mode 100644
index 0000000000..62ad232bcf
--- /dev/null
+++ b/src/plugins/cvs/cvsclient.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef CVSCLIENT_H
+#define CVSCLIENT_H
+
+#include "cvssettings.h"
+#include <vcsbase/vcsbaseclient.h>
+
+namespace Cvs {
+namespace Internal {
+
+class CvsSettings;
+
+class CvsClient : public VcsBase::VcsBaseClient
+{
+ Q_OBJECT
+
+public:
+ CvsClient(CvsSettings *settings);
+
+ CvsSettings *settings() const;
+ void diff(const QString &workingDir, const QStringList &files,
+ const QStringList &extraOptions = QStringList());
+ QString findTopLevelForFile(const QFileInfo &file) const;
+ QStringList revisionSpec(const QString &revision) const;
+ StatusItem parseStatusLine(const QString &line) const;
+
+
+protected:
+ Utils::ExitCodeInterpreter *exitCodeInterpreter(VcsCommand cmd, QObject *parent) const;
+ Core::Id vcsEditorKind(VcsCommand cmd) const;
+ VcsBase::VcsBaseEditorParameterWidget *createDiffEditor(const QString &workingDir,
+ const QStringList &files,
+ const QStringList &extraOptions);
+private:
+};
+
+} // namespace Internal
+} // namespace Cvs
+
+#endif // CVSCLIENT_H
diff --git a/src/plugins/cvs/cvscontrol.cpp b/src/plugins/cvs/cvscontrol.cpp
index af579f3e99..7ef281cd13 100644
--- a/src/plugins/cvs/cvscontrol.cpp
+++ b/src/plugins/cvs/cvscontrol.cpp
@@ -55,7 +55,7 @@ Core::Id CvsControl::id() const
bool CvsControl::isConfigured() const
{
- const QString binary = m_plugin->settings().cvsBinaryPath;
+ const QString binary = m_plugin->settings().binaryPath();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp
index 9d4a8055f7..4643b4aa7e 100644
--- a/src/plugins/cvs/cvsplugin.cpp
+++ b/src/plugins/cvs/cvsplugin.cpp
@@ -31,6 +31,7 @@
#include "settingspage.h"
#include "cvseditor.h"
#include "cvssubmiteditor.h"
+#include "cvsclient.h"
#include "cvsconstants.h"
#include "cvscontrol.h"
#include "checkoutwizard.h"
@@ -192,6 +193,7 @@ CvsPlugin::CvsPlugin() :
CvsPlugin::~CvsPlugin()
{
+ delete m_client;
cleanCommitMessageFile();
}
@@ -234,7 +236,8 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
if (!MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.cvs/CVS.mimetypes.xml"), errorMessage))
return false;
- m_settings.fromSettings(ICore::settings());
+ m_settings.readSettings(ICore::settings());
+ m_client = new CvsClient(&m_settings);
addAutoReleasedObject(new SettingsPage);
@@ -470,7 +473,8 @@ bool CvsPlugin::submitEditorAboutToClose()
editor->promptSubmit(tr("Closing CVS Editor"),
tr("Do you want to commit the change?"),
tr("The commit message check failed. Do you want to commit the change?"),
- &newSettings.promptToSubmit, !m_submitActionTriggered);
+ newSettings.boolPointer(CvsSettings::promptOnSubmitKey),
+ !m_submitActionTriggered);
m_submitActionTriggered = false;
switch (answer) {
case VcsBaseSubmitEditor::SubmitCanceled:
@@ -497,7 +501,7 @@ bool CvsPlugin::submitEditorAboutToClose()
void CvsPlugin::diffCommitFiles(const QStringList &files)
{
- cvsDiff(m_commitRepository, files);
+ m_client->diff(m_commitRepository, files);
}
static void setDiffBaseDirectory(IEditor *editor, const QString &db)
@@ -506,114 +510,6 @@ static void setDiffBaseDirectory(IEditor *editor, const QString &db)
ve->setWorkingDirectory(db);
}
-// 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 CvsDiffParameters
-{
- QString workingDir;
- QStringList arguments;
- QStringList files;
-};
-
-// Parameter widget controlling whitespace diff mode, associated with a parameter
-// struct.
-class CvsDiffParameterWidget : public VcsBaseEditorParameterWidget
-{
- Q_OBJECT
-
-public:
- explicit CvsDiffParameterWidget(const CvsDiffParameters &p, QWidget *parent = 0);
-
-signals:
- void reRunDiff(const Cvs::Internal::CvsDiffParameters &);
-
-public slots:
- void triggerReRun();
-
-private:
- const CvsDiffParameters m_parameters;
-};
-
-CvsDiffParameterWidget::CvsDiffParameterWidget(const CvsDiffParameters &p, QWidget *parent) :
- VcsBaseEditorParameterWidget(parent), m_parameters(p)
-{
- setBaseArguments(p.arguments);
- addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace"));
- addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines"));
- connect(this, SIGNAL(argumentsChanged()),
- this, SLOT(triggerReRun()));
-}
-
-void CvsDiffParameterWidget::triggerReRun()
-{
- CvsDiffParameters effectiveParameters = m_parameters;
- effectiveParameters.arguments = arguments();
- emit reRunDiff(effectiveParameters);
-}
-
-void CvsPlugin::cvsDiff(const QString &workingDir, const QStringList &files)
-{
- CvsDiffParameters p;
- p.workingDir = workingDir;
- p.files = files;
- p.arguments = m_settings.cvsDiffOptions.split(QLatin1Char(' '), QString::SkipEmptyParts);
- cvsDiff(p);
-}
-
-void CvsPlugin::cvsDiff(const Cvs::Internal::CvsDiffParameters &p)
-{
- if (Constants::debug)
- qDebug() << Q_FUNC_INFO << p.files;
- const QString source = VcsBaseEditorWidget::getSource(p.workingDir, p.files);
- QTextCodec *codec = VcsBaseEditorWidget::getCodec(p.workingDir, p.files);
- const QString id = VcsBaseEditorWidget::getTitleId(p.workingDir, p.files);
-
- QStringList args(QLatin1String("diff"));
- args.append(p.arguments);
- args.append(p.files);
-
- // CVS returns the diff exit code (1 if files differ), which is
- // undistinguishable from a "file not found" error, unfortunately.
- const CvsResponse response =
- runCvs(p.workingDir, args, m_settings.timeOutMS(), 0, codec);
- switch (response.result) {
- case CvsResponse::NonNullExitCode:
- case CvsResponse::Ok:
- break;
- case CvsResponse::OtherError:
- return;
- }
-
- QString output = fixDiffOutput(response.stdOut);
- if (output.isEmpty())
- output = tr("The files do not differ.");
- // diff of a single file? re-use an existing view if possible to support
- // the common usage pattern of continuously changing and diffing a file
- // Show in the same editor if diff has been executed before
- const QString tag = VcsBaseEditorWidget::editorTag(DiffOutput, p.workingDir, p.files);
- if (IEditor *existingEditor = VcsBaseEditorWidget::locateEditorByTag(tag)) {
- existingEditor->document()->setContents(output.toUtf8());
- EditorManager::activateEditor(existingEditor);
- setDiffBaseDirectory(existingEditor, p.workingDir);
- return;
- }
- const QString title = QString::fromLatin1("cvs diff %1").arg(id);
- IEditor *editor = showOutputInEditor(title, output, DiffOutput, source, codec);
- VcsBaseEditorWidget::tagEditor(editor, tag);
- setDiffBaseDirectory(editor, p.workingDir);
- CvsEditor *diffEditorWidget = qobject_cast<CvsEditor*>(editor->widget());
- QTC_ASSERT(diffEditorWidget, return);
-
- // Wire up the parameter widget to trigger a re-run on
- // parameter change and 'revert' from inside the diff editor.
- CvsDiffParameterWidget *pw = new CvsDiffParameterWidget(p);
- connect(pw, SIGNAL(reRunDiff(Cvs::Internal::CvsDiffParameters)),
- this, SLOT(cvsDiff(Cvs::Internal::CvsDiffParameters)));
- connect(diffEditorWidget, SIGNAL(diffChunkReverted(VcsBase::DiffChunk)),
- pw, SLOT(triggerReRun()));
- diffEditorWidget->setConfigurationWidget(pw);
-}
-
CvsSubmitEditor *CvsPlugin::openCVSSubmitEditor(const QString &fileName)
{
IEditor *editor = EditorManager::openEditor(fileName, Constants::CVSCOMMITEDITOR_ID);
@@ -678,7 +574,7 @@ void CvsPlugin::revertAll()
QStringList args;
args << QLatin1String("update") << QLatin1String("-C") << state.topLevel();
const CvsResponse revertResponse =
- runCvs(state.topLevel(), args, m_settings.timeOutMS(),
+ runCvs(state.topLevel(), args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
if (revertResponse.result == CvsResponse::Ok)
cvsVersionControl()->emitRepositoryChanged(state.topLevel());
@@ -693,7 +589,7 @@ void CvsPlugin::revertCurrentFile()
QStringList args;
args << QLatin1String("diff") << state.relativeCurrentFile();
const CvsResponse diffResponse =
- runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMS(), 0);
+ runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMs(), 0);
switch (diffResponse.result) {
case CvsResponse::Ok:
return; // Not modified, diff exit code 0
@@ -715,7 +611,7 @@ void CvsPlugin::revertCurrentFile()
args.clear();
args << QLatin1String("update") << QLatin1String("-C") << state.relativeCurrentFile();
const CvsResponse revertResponse =
- runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMS(),
+ runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
if (revertResponse.result == CvsResponse::Ok)
cvsVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
@@ -726,7 +622,7 @@ void CvsPlugin::diffProject()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasProject(), return);
const QString relativeProject = state.relativeCurrentProject();
- cvsDiff(state.currentProjectTopLevel(),
+ m_client->diff(state.currentProjectTopLevel(),
relativeProject.isEmpty() ? QStringList() : QStringList(relativeProject));
}
@@ -734,7 +630,7 @@ void CvsPlugin::diffCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
- cvsDiff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
+ m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
}
void CvsPlugin::startCommitCurrentFile()
@@ -767,7 +663,7 @@ void CvsPlugin::startCommit(const QString &workingDir, const QString &file)
// where we are, so, have stdout/stderr channels merged.
QStringList args = QStringList(QLatin1String("status"));
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(), MergeOutputChannels);
+ runCvs(workingDir, args, m_settings.timeOutMs(), MergeOutputChannels);
if (response.result != CvsResponse::Ok)
return;
// Get list of added/modified/deleted files and purge out undesired ones
@@ -815,7 +711,7 @@ bool CvsPlugin::commit(const QString &messageFile,
args << QLatin1String("-F") << messageFile;
args.append(fileList);
const CvsResponse response =
- runCvs(m_commitRepository, args, m_settings.longTimeOutMS(),
+ runCvs(m_commitRepository, args, 10 * m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
return response.result == CvsResponse::Ok ;
}
@@ -853,7 +749,7 @@ void CvsPlugin::filelog(const QString &workingDir,
args << QLatin1String("log");
args.append(file);
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt, codec);
if (response.result != CvsResponse::Ok)
return;
@@ -887,7 +783,7 @@ bool CvsPlugin::update(const QString &topLevel, const QString &file)
if (!file.isEmpty())
args.append(file);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.longTimeOutMS(),
+ runCvs(topLevel, args, 10 * m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
const bool ok = response.result == CvsResponse::Ok;
if (ok)
@@ -934,7 +830,7 @@ bool CvsPlugin::edit(const QString &topLevel, const QStringList &files)
QStringList args(QLatin1String("edit"));
args.append(files);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.timeOutMS(),
+ runCvs(topLevel, args, m_settings.timeOutMs(),
ShowStdOutInLogWindow|SshPasswordPrompt);
return response.result == CvsResponse::Ok;
}
@@ -946,7 +842,7 @@ bool CvsPlugin::diffCheckModified(const QString &topLevel, const QStringList &fi
QStringList args(QLatin1String("-q"));
args << QLatin1String("diff");
args.append(files);
- const CvsResponse response = runCvs(topLevel, args, m_settings.timeOutMS(), 0);
+ const CvsResponse response = runCvs(topLevel, args, m_settings.timeOutMs(), 0);
if (response.result == CvsResponse::OtherError)
return false;
*modified = response.result == CvsResponse::NonNullExitCode;
@@ -974,7 +870,7 @@ bool CvsPlugin::unedit(const QString &topLevel, const QStringList &files)
args.append(QLatin1String("-y"));
args.append(files);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.timeOutMS(),
+ runCvs(topLevel, args, m_settings.timeOutMs(),
ShowStdOutInLogWindow|SshPasswordPrompt);
return response.result == CvsResponse::Ok;
}
@@ -993,7 +889,7 @@ void CvsPlugin::annotate(const QString &workingDir, const QString &file,
args << QLatin1String("-r") << revision;
args << file;
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt, codec);
if (response.result != CvsResponse::Ok)
return;
@@ -1022,7 +918,7 @@ bool CvsPlugin::status(const QString &topLevel, const QString &file, const QStri
if (!file.isEmpty())
args.append(file);
const CvsResponse response =
- runCvs(topLevel, args, m_settings.timeOutMS(), 0);
+ runCvs(topLevel, args, m_settings.timeOutMs(), 0);
const bool ok = response.result == CvsResponse::Ok;
if (ok)
showOutputInEditor(title, response.stdOut, OtherContent, topLevel, 0);
@@ -1047,7 +943,7 @@ void CvsPlugin::diffRepository()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
- cvsDiff(state.topLevel(), QStringList());
+ m_client->diff(state.topLevel(), QStringList());
}
void CvsPlugin::statusRepository()
@@ -1105,7 +1001,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const
QStringList args;
args << QLatin1String("log") << (QLatin1String("-r") + changeNr) << file;
const CvsResponse logResponse =
- runCvs(toplevel, args, m_settings.timeOutMS(), SshPasswordPrompt);
+ runCvs(toplevel, args, m_settings.timeOutMs(), SshPasswordPrompt);
if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message;
return false;
@@ -1115,7 +1011,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const
*errorMessage = msgLogParsingFailed();
return false;
}
- if (m_settings.describeByCommitId) {
+ if (m_settings.boolValue(CvsSettings::describeByCommitIdKey)) {
// Run a log command over the repo, filtering by the commit date
// and commit id, collecting all files touched by the commit.
const QString commitId = fileLog.front().revisions.front().commitId;
@@ -1127,7 +1023,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const
args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS);
const CvsResponse repoLogResponse =
- runCvs(toplevel, args, m_settings.longTimeOutMS(), SshPasswordPrompt);
+ runCvs(toplevel, args, 10 * m_settings.timeOutMs(), SshPasswordPrompt);
if (repoLogResponse.result != CvsResponse::Ok) {
*errorMessage = repoLogResponse.message;
return false;
@@ -1164,7 +1060,7 @@ bool CvsPlugin::describe(const QString &repositoryPath,
QStringList args(QLatin1String("log"));
args << (QLatin1String("-r") + it->revisions.front().revision) << it->file;
const CvsResponse logResponse =
- runCvs(repositoryPath, args, m_settings.timeOutMS(), SshPasswordPrompt);
+ runCvs(repositoryPath, args, m_settings.timeOutMs(), SshPasswordPrompt);
if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message;
return false;
@@ -1177,11 +1073,11 @@ bool CvsPlugin::describe(const QString &repositoryPath,
if (!isFirstRevision(revision)) {
const QString previousRev = previousRevision(revision);
QStringList args(QLatin1String("diff"));
- args << m_settings.cvsDiffOptions << QLatin1String("-r") << previousRev
+ args << m_settings.stringValue(CvsSettings::diffOptionsKey) << QLatin1String("-r") << previousRev
<< QLatin1String("-r") << it->revisions.front().revision
<< it->file;
const CvsResponse diffResponse =
- runCvs(repositoryPath, args, m_settings.timeOutMS(), 0, codec);
+ runCvs(repositoryPath, args, m_settings.timeOutMs(), 0, codec);
switch (diffResponse.result) {
case CvsResponse::Ok:
case CvsResponse::NonNullExitCode: // Diff exit code != 0
@@ -1228,7 +1124,7 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory,
unsigned flags,
QTextCodec *outputCodec) const
{
- const QString executable = m_settings.cvsBinaryPath;
+ const QString executable = m_settings.binaryPath();
CvsResponse response;
if (executable.isEmpty()) {
response.result = CvsResponse::OtherError;
@@ -1300,7 +1196,7 @@ void CvsPlugin::setSettings(const CvsSettings &s)
{
if (s != m_settings) {
m_settings = s;
- m_settings.toSettings(ICore::settings());
+ m_settings.writeSettings(ICore::settings());
cvsVersionControl()->emitConfigurationChanged();
}
}
@@ -1316,7 +1212,7 @@ bool CvsPlugin::vcsAdd(const QString &workingDir, const QString &rawFileName)
QStringList args;
args << QLatin1String("add") << rawFileName;
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
return response.result == CvsResponse::Ok;
}
@@ -1326,7 +1222,7 @@ bool CvsPlugin::vcsDelete(const QString &workingDir, const QString &rawFileName)
QStringList args;
args << QLatin1String("remove") << QLatin1String("-f") << rawFileName;
const CvsResponse response =
- runCvs(workingDir, args, m_settings.timeOutMS(),
+ runCvs(workingDir, args, m_settings.timeOutMs(),
SshPasswordPrompt|ShowStdOutInLogWindow);
return response.result == CvsResponse::Ok;
}
@@ -1370,7 +1266,7 @@ bool CvsPlugin::managesFile(const QString &workingDirectory, const QString &file
QStringList args;
args << QLatin1String("status") << fileName;
const CvsResponse response =
- runCvs(workingDirectory, args, m_settings.timeOutMS(), SshPasswordPrompt);
+ runCvs(workingDirectory, args, m_settings.timeOutMs(), SshPasswordPrompt);
if (response.result != CvsResponse::Ok)
return false;
return !response.stdOut.contains(QLatin1String("Status: Unknown"));
@@ -1440,5 +1336,3 @@ void CvsPlugin::testLogResolving()
} // namespace Cvs
Q_EXPORT_PLUGIN(Cvs::Internal::CvsPlugin)
-
-#include "cvsplugin.moc"
diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h
index 6d8f057b83..6d8eff2263 100644
--- a/src/plugins/cvs/cvsplugin.h
+++ b/src/plugins/cvs/cvsplugin.h
@@ -56,6 +56,7 @@ namespace Internal {
struct CvsDiffParameters;
class CvsSubmitEditor;
class CvsControl;
+class CvsClient;
struct CvsResponse
{
@@ -79,8 +80,6 @@ public:
bool initialize(const QStringList &arguments, QString *errorMessage);
- void cvsDiff(const QString &workingDir, const QStringList &files);
-
CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName);
CvsSettings settings() const;
@@ -124,7 +123,6 @@ private slots:
void editCurrentFile();
void uneditCurrentFile();
void uneditCurrentRepository();
- void cvsDiff(const Cvs::Internal::CvsDiffParameters &p);
#ifdef WITH_TESTS
void testDiffFileResolving_data();
void testDiffFileResolving();
@@ -168,6 +166,8 @@ private:
inline CvsControl *cvsVersionControl() const;
CvsSettings m_settings;
+ CvsClient *m_client;
+
QString m_commitMessageFileName;
QString m_commitRepository;
diff --git a/src/plugins/cvs/cvssettings.cpp b/src/plugins/cvs/cvssettings.cpp
index 113057fc8d..e3b2828e2e 100644
--- a/src/plugins/cvs/cvssettings.cpp
+++ b/src/plugins/cvs/cvssettings.cpp
@@ -35,71 +35,34 @@
#include <QSettings>
#include <QTextStream>
-static const char groupC[] = "CVS";
-static const char commandKeyC[] = "Command";
-static const char rootC[] = "Root";
-static const char promptToSubmitKeyC[] = "PromptForSubmit";
-static const char diffOptionsKeyC[] = "DiffOptions";
-static const char describeByCommitIdKeyC[] = "DescribeByCommitId";
-static const char defaultDiffOptions[] = "-du";
-static const char timeOutKeyC[] = "TimeOut";
-
-enum { defaultTimeOutS = 30 };
-
-static QString defaultCommand()
-{
- return QLatin1String("cvs" QTC_HOST_EXE_SUFFIX);
-}
-
namespace Cvs {
namespace Internal {
-CvsSettings::CvsSettings() :
- cvsCommand(defaultCommand()),
- cvsDiffOptions(QLatin1String(defaultDiffOptions)),
- timeOutS(defaultTimeOutS),
- promptToSubmit(true),
- describeByCommitId(true)
-{
-}
+const QLatin1String CvsSettings::cvsRootKey("Root");
+const QLatin1String CvsSettings::diffOptionsKey("DiffOptions");
+const QLatin1String CvsSettings::describeByCommitIdKey("DescribeByCommitId");
+const QLatin1String CvsSettings::diffIgnoreWhiteSpaceKey("DiffIgnoreWhiteSpace");
+const QLatin1String CvsSettings::diffIgnoreBlankLinesKey("DiffIgnoreBlankLines");
-void CvsSettings::fromSettings(QSettings *settings)
+CvsSettings::CvsSettings()
{
- settings->beginGroup(QLatin1String(groupC));
- cvsCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
- cvsBinaryPath = Utils::Environment::systemEnvironment().searchInPath(cvsCommand);
- promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
- cvsRoot = settings->value(QLatin1String(rootC), QString()).toString();
- cvsDiffOptions = settings->value(QLatin1String(diffOptionsKeyC), QLatin1String(defaultDiffOptions)).toString();
- describeByCommitId = settings->value(QLatin1String(describeByCommitIdKeyC), true).toBool();
- timeOutS = settings->value(QLatin1String(timeOutKeyC), defaultTimeOutS).toInt();
- settings->endGroup();
+ setSettingsGroup(QLatin1String("CVS"));
+ declareKey(binaryPathKey, QLatin1String("cvs" QTC_HOST_EXE_SUFFIX));
+ declareKey(cvsRootKey, QLatin1String(""));
+ declareKey(diffOptionsKey, QLatin1String("-du"));
+ declareKey(describeByCommitIdKey, true);
+ declareKey(diffIgnoreWhiteSpaceKey, false);
+ declareKey(diffIgnoreBlankLinesKey, false);
}
-void CvsSettings::toSettings(QSettings *settings) const
+int CvsSettings::timeOutMs() const
{
- settings->beginGroup(QLatin1String(groupC));
- settings->setValue(QLatin1String(commandKeyC), cvsCommand);
- settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
- settings->setValue(QLatin1String(rootC), cvsRoot);
- settings->setValue(QLatin1String(diffOptionsKeyC), cvsDiffOptions);
- settings->setValue(QLatin1String(timeOutKeyC), timeOutS);
- settings->setValue(QLatin1String(describeByCommitIdKeyC), describeByCommitId);
- settings->endGroup();
-}
-
-bool CvsSettings::equals(const CvsSettings &s) const
-{
- return promptToSubmit == s.promptToSubmit
- && describeByCommitId == s.describeByCommitId
- && cvsCommand == s.cvsCommand
- && cvsRoot == s.cvsRoot
- && timeOutS == s.timeOutS
- && cvsDiffOptions == s.cvsDiffOptions;
+ return 1000 * intValue(timeoutKey);
}
QStringList CvsSettings::addOptions(const QStringList &args) const
{
+ const QString cvsRoot = stringValue(cvsRootKey);
if (cvsRoot.isEmpty())
return args;
@@ -110,5 +73,19 @@ QStringList CvsSettings::addOptions(const QStringList &args) const
return rc;
}
+void CvsSettings::readLegacySettings(const QSettings *settings)
+{
+ const QString keyRoot = settingsGroup() + QLatin1Char('/');
+ const QString oldBinaryPathKey = keyRoot + QLatin1String("Command");
+ const QString oldPromptOnSubmitKey = keyRoot + QLatin1String("PromptForSubmit");
+ const QString oldTimeoutKey = keyRoot + QLatin1String("TimeOut");
+ if (settings->contains(oldBinaryPathKey))
+ this->setValue(binaryPathKey, settings->value(oldBinaryPathKey).toString());
+ if (settings->contains(oldPromptOnSubmitKey))
+ this->setValue(promptOnSubmitKey, settings->value(oldPromptOnSubmitKey).toBool());
+ if (settings->contains(oldTimeoutKey))
+ this->setValue(timeoutKey, settings->value(oldTimeoutKey).toInt());
+}
+
} // namespace Internal
} // namespace Cvs
diff --git a/src/plugins/cvs/cvssettings.h b/src/plugins/cvs/cvssettings.h
index 4eb01fafca..25ff1cfb6a 100644
--- a/src/plugins/cvs/cvssettings.h
+++ b/src/plugins/cvs/cvssettings.h
@@ -30,44 +30,30 @@
#ifndef CVSSETTINGS_H
#define CVSSETTINGS_H
-#include <QStringList>
-
-QT_BEGIN_NAMESPACE
-class QSettings;
-QT_END_NAMESPACE
+#include <vcsbase/vcsbaseclientsettings.h>
namespace Cvs {
namespace Internal {
-struct CvsSettings
+class CvsSettings : public VcsBase::VcsBaseClientSettings
{
- CvsSettings();
+public:
+ static const QLatin1String cvsRootKey;
+ static const QLatin1String diffOptionsKey;
+ static const QLatin1String describeByCommitIdKey;
+ static const QLatin1String diffIgnoreWhiteSpaceKey;
+ static const QLatin1String diffIgnoreBlankLinesKey;
- void fromSettings(QSettings *);
- void toSettings(QSettings *) const;
+ CvsSettings();
- int timeOutMS() const { return timeOutS * 1000; }
- int longTimeOutMS() const { return timeOutS * 10000; }
+ int timeOutMs() const;
- // Add common options to the command line
QStringList addOptions(const QStringList &args) const;
- bool equals(const CvsSettings &s) const;
-
- QString cvsCommand;
- QString cvsBinaryPath;
- QString cvsRoot;
- QString cvsDiffOptions;
- int timeOutS;
- bool promptToSubmit;
- bool describeByCommitId;
+protected:
+ void readLegacySettings(const QSettings *settings);
};
-inline bool operator==(const CvsSettings &p1, const CvsSettings &p2)
- { return p1.equals(p2); }
-inline bool operator!=(const CvsSettings &p1, const CvsSettings &p2)
- { return !p1.equals(p2); }
-
} // namespace Internal
} // namespace Cvs
diff --git a/src/plugins/cvs/settingspage.cpp b/src/plugins/cvs/settingspage.cpp
index e5f051579e..2d2dcd755a 100644
--- a/src/plugins/cvs/settingspage.cpp
+++ b/src/plugins/cvs/settingspage.cpp
@@ -54,24 +54,23 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
CvsSettings SettingsPageWidget::settings() const
{
CvsSettings rc;
- rc.cvsCommand = m_ui.commandPathChooser->rawPath();
- rc.cvsBinaryPath = m_ui.commandPathChooser->path();
- rc.cvsRoot = m_ui.rootLineEdit->text();
- rc.cvsDiffOptions = m_ui.diffOptionsLineEdit->text();
- rc.timeOutS = m_ui.timeOutSpinBox->value();
- rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
- rc.describeByCommitId = m_ui.describeByCommitIdCheckBox->isChecked();
+ rc.setValue(CvsSettings::binaryPathKey, m_ui.commandPathChooser->rawPath());
+ rc.setValue(CvsSettings::cvsRootKey, m_ui.rootLineEdit->text());
+ rc.setValue(CvsSettings::diffOptionsKey, m_ui.diffOptionsLineEdit->text());
+ rc.setValue(CvsSettings::timeoutKey, m_ui.timeOutSpinBox->value());
+ rc.setValue(CvsSettings::promptOnSubmitKey, m_ui.promptToSubmitCheckBox->isChecked());
+ rc.setValue(CvsSettings::describeByCommitIdKey, m_ui.describeByCommitIdCheckBox->isChecked());
return rc;
}
void SettingsPageWidget::setSettings(const CvsSettings &s)
{
- m_ui.commandPathChooser->setPath(s.cvsCommand);
- m_ui.rootLineEdit->setText(s.cvsRoot);
- m_ui.diffOptionsLineEdit->setText(s.cvsDiffOptions);
- m_ui.timeOutSpinBox->setValue(s.timeOutS);
- m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
- m_ui.describeByCommitIdCheckBox->setChecked(s.describeByCommitId);
+ m_ui.commandPathChooser->setPath(s.binaryPath());
+ m_ui.rootLineEdit->setText(s.stringValue(CvsSettings::cvsRootKey));
+ m_ui.diffOptionsLineEdit->setText(s.stringValue(CvsSettings::diffOptionsKey));
+ m_ui.timeOutSpinBox->setValue(s.intValue(CvsSettings::timeoutKey));
+ m_ui.promptToSubmitCheckBox->setChecked(s.boolValue(CvsSettings::promptOnSubmitKey));
+ m_ui.describeByCommitIdCheckBox->setChecked(s.boolValue(CvsSettings::describeByCommitIdKey));
}
QString SettingsPageWidget::searchKeywords() const