summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-07-15 12:28:40 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2009-07-15 12:28:40 +0200
commit18f9375501926ab637ccf68ca01bc9ea615ffced (patch)
tree0369a9ec55802780d0af0fc332edb6265abbb4c4 /src/plugins
parentd53129d336408aa162207bb501235f8378b7a131 (diff)
downloadqt-creator-18f9375501926ab637ccf68ca01bc9ea615ffced.tar.gz
Add a CVS plugin for use with UNIX cvs or Tortoise CVS.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/cvs/CVS.mimetypes.xml7
-rw-r--r--src/plugins/cvs/CVS.pluginspec27
-rw-r--r--src/plugins/cvs/annotationhighlighter.cpp46
-rw-r--r--src/plugins/cvs/annotationhighlighter.h55
-rw-r--r--src/plugins/cvs/cvs.pro36
-rw-r--r--src/plugins/cvs/cvs.qrc5
-rw-r--r--src/plugins/cvs/cvsconstants.h48
-rw-r--r--src/plugins/cvs/cvscontrol.cpp98
-rw-r--r--src/plugins/cvs/cvscontrol.h70
-rw-r--r--src/plugins/cvs/cvseditor.cpp159
-rw-r--r--src/plugins/cvs/cvseditor.h69
-rw-r--r--src/plugins/cvs/cvsoutputwindow.cpp127
-rw-r--r--src/plugins/cvs/cvsoutputwindow.h84
-rw-r--r--src/plugins/cvs/cvsplugin.cpp1228
-rw-r--r--src/plugins/cvs/cvsplugin.h208
-rw-r--r--src/plugins/cvs/cvssettings.cpp108
-rw-r--r--src/plugins/cvs/cvssettings.h70
-rw-r--r--src/plugins/cvs/cvssubmiteditor.cpp70
-rw-r--r--src/plugins/cvs/cvssubmiteditor.h64
-rw-r--r--src/plugins/cvs/cvsutils.cpp238
-rw-r--r--src/plugins/cvs/cvsutils.h86
-rw-r--r--src/plugins/cvs/settingspage.cpp107
-rw-r--r--src/plugins/cvs/settingspage.h86
-rw-r--r--src/plugins/cvs/settingspage.ui130
-rw-r--r--src/plugins/plugins.pro7
25 files changed, 3233 insertions, 0 deletions
diff --git a/src/plugins/cvs/CVS.mimetypes.xml b/src/plugins/cvs/CVS.mimetypes.xml
new file mode 100644
index 0000000000..237d8aa67c
--- /dev/null
+++ b/src/plugins/cvs/CVS.mimetypes.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="application/vnd.nokia.text.cvs.submit">
+ <comment>CVS submit template</comment>
+ <sub-class-of type="text/plain"/>
+ </mime-type>
+</mime-info>
diff --git a/src/plugins/cvs/CVS.pluginspec b/src/plugins/cvs/CVS.pluginspec
new file mode 100644
index 0000000000..2e28bb38c7
--- /dev/null
+++ b/src/plugins/cvs/CVS.pluginspec
@@ -0,0 +1,27 @@
+<plugin name="CVS" version="1.2.80" compatVersion="1.2.80">
+ <vendor>Nokia Corporation</vendor>
+ <copyright>(C) 2008-2009 Nokia Corporation</copyright>
+ <license>
+Commercial Usage
+
+Licensees holding valid Qt Commercial licenses may use this plugin in
+accordance with the Qt Commercial License Agreement provided with the
+Software or, alternatively, in accordance with the terms contained in
+a written agreement between you and Nokia.
+
+GNU Lesser General Public License Usage
+
+Alternatively, this plugin may be used under the terms of the GNU Lesser
+General Public License version 2.1 as published by the Free Software
+Foundation. 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.</license>
+ <description>CVS integration.</description>
+ <url>http://www.qtsoftware.com</url>
+ <dependencyList>
+ <dependency name="TextEditor" version="1.2.80"/>
+ <dependency name="ProjectExplorer" version="1.2.80"/>
+ <dependency name="Core" version="1.2.80"/>
+ <dependency name="VCSBase" version="1.2.80"/>
+ </dependencyList>
+</plugin>
diff --git a/src/plugins/cvs/annotationhighlighter.cpp b/src/plugins/cvs/annotationhighlighter.cpp
new file mode 100644
index 0000000000..3214068de7
--- /dev/null
+++ b/src/plugins/cvs/annotationhighlighter.cpp
@@ -0,0 +1,46 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "annotationhighlighter.h"
+
+using namespace CVS;
+using namespace CVS::Internal;
+
+CVSAnnotationHighlighter::CVSAnnotationHighlighter(const ChangeNumbers &changeNumbers,
+ QTextDocument *document) :
+ VCSBase::BaseAnnotationHighlighter(changeNumbers, document),
+ m_blank(QLatin1Char(' '))
+{
+}
+
+QString CVSAnnotationHighlighter::changeNumber(const QString &block) const
+{
+ const int pos = block.indexOf(m_blank);
+ return pos > 1 ? block.left(pos) : QString();
+}
diff --git a/src/plugins/cvs/annotationhighlighter.h b/src/plugins/cvs/annotationhighlighter.h
new file mode 100644
index 0000000000..8f52c9ba56
--- /dev/null
+++ b/src/plugins/cvs/annotationhighlighter.h
@@ -0,0 +1,55 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef ANNOTATIONHIGHLIGHTER_H
+#define ANNOTATIONHIGHLIGHTER_H
+
+#include <vcsbase/baseannotationhighlighter.h>
+
+namespace CVS {
+namespace Internal {
+
+// Annotation highlighter for cvs triggering on 'changenumber '
+class CVSAnnotationHighlighter : public VCSBase::BaseAnnotationHighlighter
+{
+ Q_OBJECT
+public:
+ explicit CVSAnnotationHighlighter(const ChangeNumbers &changeNumbers,
+ QTextDocument *document = 0);
+
+private:
+ virtual QString changeNumber(const QString &block) const;
+
+ const QChar m_blank;
+};
+
+} // namespace Internal
+} // namespace CVS
+
+#endif // ANNOTATIONHIGHLIGHTER_H
diff --git a/src/plugins/cvs/cvs.pro b/src/plugins/cvs/cvs.pro
new file mode 100644
index 0000000000..86244a20aa
--- /dev/null
+++ b/src/plugins/cvs/cvs.pro
@@ -0,0 +1,36 @@
+TEMPLATE = lib
+TARGET = CVS
+
+include(../../qtcreatorplugin.pri)
+include(../../plugins/projectexplorer/projectexplorer.pri)
+include(../../plugins/texteditor/texteditor.pri)
+include(../../plugins/coreplugin/coreplugin.pri)
+include(../../plugins/vcsbase/vcsbase.pri)
+include(../../libs/utils/utils.pri)
+
+HEADERS += annotationhighlighter.h \
+ cvsplugin.h \
+ cvscontrol.h \
+ cvsoutputwindow.h \
+ settingspage.h \
+ cvseditor.h \
+ cvssubmiteditor.h \
+ cvssettings.h \
+ cvsutils.h \
+ cvsconstants.h
+
+SOURCES += annotationhighlighter.cpp \
+ cvsplugin.cpp \
+ cvscontrol.cpp \
+ cvsoutputwindow.cpp \
+ settingspage.cpp \
+ cvseditor.cpp \
+ cvssubmiteditor.cpp \
+ cvssettings.cpp \
+ cvsutils.cpp
+
+FORMS += settingspage.ui
+
+RESOURCES += cvs.qrc
+
+OTHER_FILES += CVS.pluginspec
diff --git a/src/plugins/cvs/cvs.qrc b/src/plugins/cvs/cvs.qrc
new file mode 100644
index 0000000000..63180dfae7
--- /dev/null
+++ b/src/plugins/cvs/cvs.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/trolltech.cvs" >
+ <file>CVS.mimetypes.xml</file>
+ </qresource>
+</RCC>
diff --git a/src/plugins/cvs/cvsconstants.h b/src/plugins/cvs/cvsconstants.h
new file mode 100644
index 0000000000..1a2e5248c8
--- /dev/null
+++ b/src/plugins/cvs/cvsconstants.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVS_CONSTANTS_H
+#define CVS_CONSTANTS_H
+
+namespace CVS {
+namespace Constants {
+
+const char * const CVS_SUBMIT_MIMETYPE = "application/vnd.nokia.text.cvs.submit";
+const char * const CVSEDITOR = "CVS Editor";
+const char * const CVSEDITOR_KIND = "CVS Editor";
+const char * const CVSCOMMITEDITOR = "CVS Commit Editor";
+const char * const CVSCOMMITEDITOR_KIND = "CVS Commit Editor";
+const char * const SUBMIT_CURRENT = "CVS.SubmitCurrentLog";
+const char * const DIFF_SELECTED = "CVS.DiffSelectedFilesInLog";
+enum { debug = 0 };
+
+} // namespace Constants
+} // namespace SubVersion
+
+#endif // CVS_CONSTANTS_H
diff --git a/src/plugins/cvs/cvscontrol.cpp b/src/plugins/cvs/cvscontrol.cpp
new file mode 100644
index 0000000000..49175e86c9
--- /dev/null
+++ b/src/plugins/cvs/cvscontrol.cpp
@@ -0,0 +1,98 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "cvscontrol.h"
+#include "cvsplugin.h"
+
+using namespace CVS;
+using namespace CVS::Internal;
+
+CVSControl::CVSControl(CVSPlugin *plugin) :
+ m_enabled(true),
+ m_plugin(plugin)
+{
+}
+
+QString CVSControl::name() const
+{
+ return QLatin1String("cvs");
+}
+
+bool CVSControl::isEnabled() const
+{
+ return m_enabled;
+}
+
+void CVSControl::setEnabled(bool enabled)
+{
+ if (m_enabled != enabled) {
+ m_enabled = enabled;
+ emit enabledChanged(m_enabled);
+ }
+}
+
+bool CVSControl::supportsOperation(Operation operation) const
+{
+ bool rc = true;
+ switch (operation) {
+ case AddOperation:
+ case DeleteOperation:
+ break;
+ case OpenOperation:
+ rc = false;
+ break;
+ }
+ return rc;
+}
+
+bool CVSControl::vcsOpen(const QString & /* fileName */)
+{
+ // Open for edit: N/A
+ return true;
+}
+
+bool CVSControl::vcsAdd(const QString &fileName)
+{
+ return m_plugin->vcsAdd(fileName);
+}
+
+bool CVSControl::vcsDelete(const QString &fileName)
+{
+ return m_plugin->vcsDelete(fileName);
+}
+
+bool CVSControl::managesDirectory(const QString &directory) const
+{
+ return m_plugin->managesDirectory(directory);
+}
+
+QString CVSControl::findTopLevelForDirectory(const QString &directory) const
+{
+ return m_plugin->findTopLevelForDirectory(directory);
+}
diff --git a/src/plugins/cvs/cvscontrol.h b/src/plugins/cvs/cvscontrol.h
new file mode 100644
index 0000000000..2249f1a823
--- /dev/null
+++ b/src/plugins/cvs/cvscontrol.h
@@ -0,0 +1,70 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVSCONTROL_H
+#define CVSCONTROL_H
+
+#include <coreplugin/iversioncontrol.h>
+
+namespace CVS {
+namespace Internal {
+
+class CVSPlugin;
+
+// Just a proxy for CVSPlugin
+class CVSControl : public Core::IVersionControl
+{
+ Q_OBJECT
+public:
+ explicit CVSControl(CVSPlugin *plugin);
+ virtual QString name() const;
+
+ virtual bool isEnabled() const;
+ virtual void setEnabled(bool enabled);
+
+ virtual bool managesDirectory(const QString &directory) const;
+ virtual QString findTopLevelForDirectory(const QString &directory) const;
+
+ virtual bool supportsOperation(Operation operation) const;
+ virtual bool vcsOpen(const QString &fileName);
+ virtual bool vcsAdd(const QString &fileName);
+ virtual bool vcsDelete(const QString &filename);
+
+signals:
+ void enabledChanged(bool);
+
+private:
+ bool m_enabled;
+ CVSPlugin *m_plugin;
+};
+
+} // namespace Internal
+} // namespace CVS
+
+#endif // CVSCONTROL_H
diff --git a/src/plugins/cvs/cvseditor.cpp b/src/plugins/cvs/cvseditor.cpp
new file mode 100644
index 0000000000..35b342446e
--- /dev/null
+++ b/src/plugins/cvs/cvseditor.cpp
@@ -0,0 +1,159 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "cvseditor.h"
+
+#include "annotationhighlighter.h"
+#include "cvsconstants.h"
+
+#include <utils/qtcassert.h>
+#include <vcsbase/diffhighlighter.h>
+
+#include <QtCore/QDebug>
+#include <QtGui/QTextCursor>
+
+namespace CVS {
+namespace Internal {
+
+// Match a CVS revision ("1.1.1.1")
+#define CVS_REVISION_PATTERN "[\\d\\.]+"
+#define CVS_REVISION_AT_START_PATTERN "^("CVS_REVISION_PATTERN") "
+
+CVSEditor::CVSEditor(const VCSBase::VCSBaseEditorParameters *type,
+ QWidget *parent) :
+ VCSBase::VCSBaseEditor(type, parent),
+ m_revisionPattern(QLatin1String(CVS_REVISION_AT_START_PATTERN".*$"))
+{
+ QTC_ASSERT(m_revisionPattern.isValid(), return);
+}
+
+QSet<QString> CVSEditor::annotationChanges() const
+{
+ QSet<QString> changes;
+ const QString txt = toPlainText();
+ if (txt.isEmpty())
+ return changes;
+ // Hunt for first change number in annotation: "1.1 (author)"
+ QRegExp r(QLatin1String(CVS_REVISION_AT_START_PATTERN));
+ QTC_ASSERT(r.isValid(), return changes);
+ if (r.indexIn(txt) != -1) {
+ changes.insert(r.cap(1));
+ r.setPattern(QLatin1String("\n("CVS_REVISION_PATTERN") "));
+ QTC_ASSERT(r.isValid(), return changes);
+ int pos = 0;
+ while ((pos = r.indexIn(txt, pos)) != -1) {
+ pos += r.matchedLength();
+ changes.insert(r.cap(1));
+ }
+ }
+ if (CVS::Constants::debug)
+ qDebug() << "CVSEditor::annotationChanges() returns #" << changes.size();
+ return changes;
+}
+
+QString CVSEditor::changeUnderCursor(const QTextCursor &c) const
+{
+
+ // Check for a revision number at the beginning of the line.
+ // Note that "cursor.select(QTextCursor::WordUnderCursor)" will
+ // only select the part up until the dot.
+ // Check if we are at the beginning of a line within a reasonable offset.
+ const QTextBlock block = c.block();
+ if (c.atBlockStart() || (c.position() - block.position() < 3)) {
+ const QString line = block.text();
+ if (m_revisionPattern.exactMatch(line))
+ return m_revisionPattern.cap(1);
+ }
+ return QString();
+}
+
+/* \code
+cvs diff -d -u -r1.1 -r1.2:
+--- mainwindow.cpp<\t>13 Jul 2009 13:50:15 -0000 <\t>1.1
++++ mainwindow.cpp<\t>14 Jul 2009 07:09:24 -0000<\t>1.2
+@@ -6,6 +6,5 @@
+\endcode
+*/
+
+VCSBase::DiffHighlighter *CVSEditor::createDiffHighlighter() const
+{
+ const QRegExp filePattern(QLatin1String("^[-+][-+][-+] .*1\\.[\\d\\.]+$"));
+ QTC_ASSERT(filePattern.isValid(), /**/);
+ return new VCSBase::DiffHighlighter(filePattern);
+}
+
+VCSBase::BaseAnnotationHighlighter *CVSEditor::createAnnotationHighlighter(const QSet<QString> &changes) const
+{
+ return new CVSAnnotationHighlighter(changes);
+}
+
+QString CVSEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) const
+{
+ // "+++ mainwindow.cpp<\t>13 Jul 2009 13:50:15 -0000 1.1"
+ // Go back chunks
+ const QString diffIndicator = QLatin1String("+++ ");
+ for (QTextBlock block = inBlock; block.isValid() ; block = block.previous()) {
+ QString diffFileName = block.text();
+ if (diffFileName.startsWith(diffIndicator)) {
+ diffFileName.remove(0, diffIndicator.size());
+ const int tabIndex = diffFileName.indexOf(QLatin1Char('\t'));
+ if (tabIndex != -1)
+ diffFileName.truncate(tabIndex);
+ // Add base dir
+ if (!m_diffBaseDir.isEmpty()) {
+ diffFileName.insert(0, QLatin1Char('/'));
+ diffFileName.insert(0, m_diffBaseDir);
+ }
+
+ if (CVS::Constants::debug)
+ qDebug() << "fileNameFromDiffSpecification" << m_diffBaseDir << diffFileName;
+ return diffFileName;
+ }
+ }
+ return QString();
+}
+
+QString CVSEditor::diffBaseDir() const
+{
+ return m_diffBaseDir;
+}
+
+void CVSEditor::setDiffBaseDir(const QString &d)
+{
+ m_diffBaseDir = d;
+}
+
+void CVSEditor::setDiffBaseDir(Core::IEditor *editor, const QString &db)
+{
+ if (CVSEditor *cvsEditor = qobject_cast<CVSEditor*>(editor->widget()))
+ cvsEditor->setDiffBaseDir(db);
+}
+
+}
+}
diff --git a/src/plugins/cvs/cvseditor.h b/src/plugins/cvs/cvseditor.h
new file mode 100644
index 0000000000..8acb42ae23
--- /dev/null
+++ b/src/plugins/cvs/cvseditor.h
@@ -0,0 +1,69 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVSEDITOR_H
+#define CVSEDITOR_H
+
+#include <vcsbase/vcsbaseeditor.h>
+
+#include <QtCore/QRegExp>
+
+namespace CVS {
+namespace Internal {
+
+class CVSEditor : public VCSBase::VCSBaseEditor
+{
+ Q_OBJECT
+
+public:
+ explicit CVSEditor(const VCSBase::VCSBaseEditorParameters *type,
+ QWidget *parent);
+
+ // Diff mode requires a base directory since CVS commands
+ // are run with relative paths (see plugin).
+ QString diffBaseDir() const;
+ void setDiffBaseDir(const QString &d);
+
+ static void setDiffBaseDir(Core::IEditor *editor, const QString &db);
+
+private:
+ virtual QSet<QString> annotationChanges() const;
+ virtual QString changeUnderCursor(const QTextCursor &) const;
+ virtual VCSBase::DiffHighlighter *createDiffHighlighter() const;
+ virtual VCSBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const;
+ virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileName) const;
+
+ const QRegExp m_revisionPattern;
+ QString m_diffBaseDir;
+};
+
+} // namespace Internal
+} // namespace CVS
+
+#endif // CVSEDITOR_H
diff --git a/src/plugins/cvs/cvsoutputwindow.cpp b/src/plugins/cvs/cvsoutputwindow.cpp
new file mode 100644
index 0000000000..2168a03d33
--- /dev/null
+++ b/src/plugins/cvs/cvsoutputwindow.cpp
@@ -0,0 +1,127 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "cvsoutputwindow.h"
+#include "cvsplugin.h"
+
+#include <QtGui/QListWidget>
+#include <QtCore/QDebug>
+
+using namespace CVS::Internal;
+
+CVSOutputWindow::CVSOutputWindow(CVSPlugin *cvsPlugin)
+ : m_cvsPlugin(cvsPlugin)
+{
+ m_outputListWidget = new QListWidget;
+ m_outputListWidget->setFrameStyle(QFrame::NoFrame);
+ m_outputListWidget->setWindowTitle(tr("CVS Output"));
+ m_outputListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+}
+
+CVSOutputWindow::~CVSOutputWindow()
+{
+ delete m_outputListWidget;
+}
+
+QWidget *CVSOutputWindow::outputWidget(QWidget *parent)
+{
+ m_outputListWidget->setParent(parent);
+ return m_outputListWidget;
+}
+
+QString CVSOutputWindow::name() const
+{
+ return tr("CVS");
+}
+
+void CVSOutputWindow::clearContents()
+{
+ m_outputListWidget->clear();
+}
+
+int CVSOutputWindow::priorityInStatusBar() const
+{
+ return -1;
+}
+
+void CVSOutputWindow::visibilityChanged(bool b)
+{
+ if (b)
+ m_outputListWidget->setFocus();
+}
+
+void CVSOutputWindow::append(const QString &txt, bool doPopup)
+{
+ const QStringList lines = txt.split(QLatin1Char('\n'));
+ foreach (const QString &s, lines)
+ m_outputListWidget->addItem(s);
+ m_outputListWidget->scrollToBottom();
+
+ if (doPopup)
+ popup();
+}
+
+bool CVSOutputWindow::canFocus()
+{
+ return false;
+}
+
+bool CVSOutputWindow::hasFocus()
+{
+ return m_outputListWidget->hasFocus();
+}
+
+void CVSOutputWindow::setFocus()
+{
+}
+
+bool CVSOutputWindow::canNext()
+{
+ return false;
+}
+
+bool CVSOutputWindow::canPrevious()
+{
+ return false;
+}
+
+void CVSOutputWindow::goToNext()
+{
+
+}
+
+void CVSOutputWindow::goToPrev()
+{
+
+}
+
+bool CVSOutputWindow::canNavigate()
+{
+ return false;
+}
diff --git a/src/plugins/cvs/cvsoutputwindow.h b/src/plugins/cvs/cvsoutputwindow.h
new file mode 100644
index 0000000000..badb98c92b
--- /dev/null
+++ b/src/plugins/cvs/cvsoutputwindow.h
@@ -0,0 +1,84 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVSOUTPUTWINDOW_H
+#define CVSOUTPUTWINDOW_H
+
+#include <coreplugin/ioutputpane.h>
+
+QT_BEGIN_NAMESPACE
+class QListWidget;
+QT_END_NAMESPACE
+
+namespace CVS {
+namespace Internal {
+
+class CVSPlugin;
+
+class CVSOutputWindow : public Core::IOutputPane
+{
+ Q_OBJECT
+
+public:
+ CVSOutputWindow(CVSPlugin *cvsPlugin);
+ ~CVSOutputWindow();
+
+ QWidget *outputWidget(QWidget *parent);
+ QList<QWidget*> toolBarWidgets() const {
+ return QList<QWidget *>();
+ }
+
+ QString name() const;
+ void clearContents();
+ int priorityInStatusBar() const;
+ void visibilityChanged(bool visible);
+
+ bool canFocus();
+ bool hasFocus();
+ void setFocus();
+
+ bool canNext();
+ bool canPrevious();
+ void goToNext();
+ void goToPrev();
+ bool canNavigate();
+
+public slots:
+ void append(const QString &txt, bool popup = false);
+
+private:
+
+ CVSPlugin *m_cvsPlugin;
+ QListWidget *m_outputListWidget;
+};
+
+} // namespace CVS
+} // namespace Internal
+
+#endif // CVSOUTPUTWINDOW_H
diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp
new file mode 100644
index 0000000000..c64d32b9aa
--- /dev/null
+++ b/src/plugins/cvs/cvsplugin.cpp
@@ -0,0 +1,1228 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "cvsplugin.h"
+#include "settingspage.h"
+#include "cvseditor.h"
+#include "cvsoutputwindow.h"
+#include "cvssubmiteditor.h"
+#include "cvsconstants.h"
+#include "cvscontrol.h"
+
+#include <vcsbase/basevcseditorfactory.h>
+#include <vcsbase/vcsbaseeditor.h>
+#include <vcsbase/basevcssubmiteditorfactory.h>
+#include <utils/synchronousprocess.h>
+#include <utils/parameteraction.h>
+
+#include <coreplugin/icore.h>
+#include <coreplugin/coreconstants.h>
+#include <coreplugin/filemanager.h>
+#include <coreplugin/messagemanager.h>
+#include <coreplugin/mimedatabase.h>
+#include <coreplugin/uniqueidmanager.h>
+#include <coreplugin/actionmanager/actionmanager.h>
+#include <coreplugin/editormanager/editormanager.h>
+#include <coreplugin/vcsmanager.h>
+#include <projectexplorer/projectexplorer.h>
+#include <utils/qtcassert.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QDate>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QTextCodec>
+#include <QtCore/QtPlugin>
+#include <QtGui/QAction>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMenu>
+#include <QtGui/QMessageBox>
+
+#include <limits.h>
+
+namespace CVS {
+ namespace Internal {
+
+static inline QString msgCannotFindTopLevel(const QString &f)
+{
+ return CVSPlugin::tr("Cannot find repository for '%1'").arg(f);
+}
+
+static inline QString msgLogParsingFailed()
+{
+ return CVSPlugin::tr("Parsing of the log output failed");
+}
+
+// Timeout for normal output commands
+enum { cvsShortTimeOut = 10000 };
+// Timeout for submit, update
+enum { cvsLongTimeOut = 120000 };
+
+static const char * const CMD_ID_CVS_MENU = "CVS.Menu";
+static const char * const CMD_ID_ADD = "CVS.Add";
+static const char * const CMD_ID_DELETE_FILE = "CVS.Delete";
+static const char * const CMD_ID_REVERT = "CVS.Revert";
+static const char * const CMD_ID_SEPARATOR0 = "CVS.Separator0";
+static const char * const CMD_ID_DIFF_PROJECT = "CVS.DiffAll";
+static const char * const CMD_ID_DIFF_CURRENT = "CVS.DiffCurrent";
+static const char * const CMD_ID_SEPARATOR1 = "CVS.Separator1";
+static const char * const CMD_ID_COMMIT_ALL = "CVS.CommitAll";
+static const char * const CMD_ID_COMMIT_CURRENT = "CVS.CommitCurrent";
+static const char * const CMD_ID_SEPARATOR2 = "CVS.Separator2";
+static const char * const CMD_ID_FILELOG_CURRENT = "CVS.FilelogCurrent";
+static const char * const CMD_ID_ANNOTATE_CURRENT = "CVS.AnnotateCurrent";
+static const char * const CMD_ID_SEPARATOR3 = "CVS.Separator3";
+static const char * const CMD_ID_STATUS = "CVS.Status";
+static const char * const CMD_ID_UPDATE = "CVS.Update";
+
+static const VCSBase::VCSBaseEditorParameters editorParameters[] = {
+{
+ VCSBase::RegularCommandOutput,
+ "CVS Command Log Editor", // kind
+ "CVS Command Log Editor", // context
+ "application/vnd.nokia.text.scs_cvs_commandlog",
+ "scslog"},
+{ VCSBase::LogOutput,
+ "CVS File Log Editor", // kind
+ "CVS File Log Editor", // context
+ "application/vnd.nokia.text.scs_cvs_filelog",
+ "scsfilelog"},
+{ VCSBase::AnnotateOutput,
+ "CVS Annotation Editor", // kind
+ "CVS Annotation Editor", // context
+ "application/vnd.nokia.text.scs_cvs_annotation",
+ "scsannotate"},
+{ VCSBase::DiffOutput,
+ "CVS Diff Editor", // kind
+ "CVS Diff Editor", // context
+ "text/x-patch","diff"}
+};
+
+// Utility to find a parameter set by type
+static inline const VCSBase::VCSBaseEditorParameters *findType(int ie)
+{
+ const VCSBase::EditorContentType et = static_cast<VCSBase::EditorContentType>(ie);
+ return VCSBase::VCSBaseEditor::findType(editorParameters, sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters), et);
+}
+
+static inline QString debugCodec(const QTextCodec *c)
+{
+ return c ? QString::fromAscii(c->name()) : QString::fromAscii("Null codec");
+}
+
+Core::IEditor* locateEditor(const char *property, const QString &entry)
+{
+ foreach (Core::IEditor *ed, Core::EditorManager::instance()->openedEditors())
+ if (ed->property(property).toString() == entry)
+ return ed;
+ return 0;
+}
+
+// ------------- CVSPlugin
+CVSPlugin *CVSPlugin::m_cvsPluginInstance = 0;
+
+CVSPlugin::CVSPlugin() :
+ m_versionControl(0),
+ m_changeTmpFile(0),
+ m_cvsOutputWindow(0),
+ m_projectExplorer(0),
+ m_addAction(0),
+ m_deleteAction(0),
+ m_revertAction(0),
+ m_diffProjectAction(0),
+ m_diffCurrentAction(0),
+ m_commitAllAction(0),
+ m_commitCurrentAction(0),
+ m_filelogCurrentAction(0),
+ m_annotateCurrentAction(0),
+ m_statusAction(0),
+ m_updateProjectAction(0),
+ m_submitCurrentLogAction(0),
+ m_submitDiffAction(0),
+ m_submitUndoAction(0),
+ m_submitRedoAction(0),
+ m_submitActionTriggered(false)
+{
+}
+
+CVSPlugin::~CVSPlugin()
+{
+ cleanChangeTmpFile();
+}
+
+void CVSPlugin::cleanChangeTmpFile()
+{
+ if (m_changeTmpFile) {
+ if (m_changeTmpFile->isOpen())
+ m_changeTmpFile->close();
+ delete m_changeTmpFile;
+ m_changeTmpFile = 0;
+ }
+}
+
+static const VCSBase::VCSBaseSubmitEditorParameters submitParameters = {
+ CVS::Constants::CVS_SUBMIT_MIMETYPE,
+ CVS::Constants::CVSCOMMITEDITOR_KIND,
+ CVS::Constants::CVSCOMMITEDITOR
+};
+
+static inline Core::Command *createSeparator(QObject *parent,
+ Core::ActionManager *ami,
+ const char*id,
+ const QList<int> &globalcontext)
+{
+ QAction *tmpaction = new QAction(parent);
+ tmpaction->setSeparator(true);
+ return ami->registerAction(tmpaction, id, globalcontext);
+}
+
+bool CVSPlugin::initialize(const QStringList &arguments, QString *errorMessage)
+{
+ Q_UNUSED(arguments);
+
+ typedef VCSBase::VCSSubmitEditorFactory<CVSSubmitEditor> CVSSubmitEditorFactory;
+ typedef VCSBase::VCSEditorFactory<CVSEditor> CVSEditorFactory;
+ using namespace Constants;
+
+ using namespace Core::Constants;
+ using namespace ExtensionSystem;
+
+ m_cvsPluginInstance = this;
+ Core::ICore *core = Core::ICore::instance();
+
+ if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.cvs/CVS.mimetypes.xml"), errorMessage))
+ return false;
+
+
+ m_versionControl = new CVSControl(this);
+ addAutoReleasedObject(m_versionControl);
+
+ if (QSettings *settings = core->settings())
+ m_settings.fromSettings(settings);
+
+ addAutoReleasedObject(new CoreListener(this));
+
+ addAutoReleasedObject(new SettingsPage);
+
+ addAutoReleasedObject(new CVSSubmitEditorFactory(&submitParameters));
+
+ static const char *describeSlotC = SLOT(slotDescribe(QString,QString));
+ const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters);
+ for (int i = 0; i < editorCount; i++)
+ addAutoReleasedObject(new CVSEditorFactory(editorParameters + i, this, describeSlotC));
+
+ m_cvsOutputWindow = new CVSOutputWindow(this);
+ addAutoReleasedObject(m_cvsOutputWindow);
+
+ //register actions
+ Core::ActionManager *ami = core->actionManager();
+ Core::ActionContainer *toolsContainer = ami->actionContainer(M_TOOLS);
+
+ Core::ActionContainer *cvsMenu =
+ ami->createMenu(QLatin1String(CMD_ID_CVS_MENU));
+ cvsMenu->menu()->setTitle(tr("&CVS"));
+ toolsContainer->addMenu(cvsMenu);
+ if (QAction *ma = cvsMenu->menu()->menuAction()) {
+ ma->setEnabled(m_versionControl->isEnabled());
+ connect(m_versionControl, SIGNAL(enabledChanged(bool)), ma, SLOT(setVisible(bool)));
+ }
+
+ QList<int> globalcontext;
+ globalcontext << core->uniqueIDManager()->uniqueIdentifier(C_GLOBAL);
+
+ Core::Command *command;
+ m_addAction = new Core::Utils::ParameterAction(tr("Add"), tr("Add \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
+ command = ami->registerAction(m_addAction, CMD_ID_ADD,
+ globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+#ifndef Q_WS_MAC
+ command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+A")));
+#endif
+ connect(m_addAction, SIGNAL(triggered()), this, SLOT(addCurrentFile()));
+ cvsMenu->addAction(command);
+
+ m_deleteAction = new Core::Utils::ParameterAction(tr("Delete"), tr("Delete \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
+ command = ami->registerAction(m_deleteAction, CMD_ID_DELETE_FILE,
+ globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+ connect(m_deleteAction, SIGNAL(triggered()), this, SLOT(deleteCurrentFile()));
+ cvsMenu->addAction(command);
+
+ m_revertAction = new Core::Utils::ParameterAction(tr("Revert"), tr("Revert \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
+ command = ami->registerAction(m_revertAction, CMD_ID_REVERT,
+ globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+ connect(m_revertAction, SIGNAL(triggered()), this, SLOT(revertCurrentFile()));
+ cvsMenu->addAction(command);
+
+ cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR0, globalcontext));
+
+ m_diffProjectAction = new QAction(tr("Diff Project"), this);
+ command = ami->registerAction(m_diffProjectAction, CMD_ID_DIFF_PROJECT,
+ globalcontext);
+ connect(m_diffProjectAction, SIGNAL(triggered()), this, SLOT(diffProject()));
+ cvsMenu->addAction(command);
+
+ m_diffCurrentAction = new Core::Utils::ParameterAction(tr("Diff Current File"), tr("Diff \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
+ command = ami->registerAction(m_diffCurrentAction,
+ CMD_ID_DIFF_CURRENT, globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+#ifndef Q_WS_MAC
+ command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+D")));
+#endif
+ connect(m_diffCurrentAction, SIGNAL(triggered()), this, SLOT(diffCurrentFile()));
+ cvsMenu->addAction(command);
+
+ cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR1, globalcontext));
+
+ m_commitAllAction = new QAction(tr("Commit All Files"), this);
+ command = ami->registerAction(m_commitAllAction, CMD_ID_COMMIT_ALL,
+ globalcontext);
+ connect(m_commitAllAction, SIGNAL(triggered()), this, SLOT(startCommitAll()));
+ cvsMenu->addAction(command);
+
+ m_commitCurrentAction = new Core::Utils::ParameterAction(tr("Commit Current File"), tr("Commit \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
+ command = ami->registerAction(m_commitCurrentAction,
+ CMD_ID_COMMIT_CURRENT, globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+#ifndef Q_WS_MAC
+ command->setDefaultKeySequence(QKeySequence(tr("Alt+C,Alt+C")));
+#endif
+ connect(m_commitCurrentAction, SIGNAL(triggered()), this, SLOT(startCommitCurrentFile()));
+ cvsMenu->addAction(command);
+
+ cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR2, globalcontext));
+
+ m_filelogCurrentAction = new Core::Utils::ParameterAction(tr("Filelog Current File"), tr("Filelog \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
+ command = ami->registerAction(m_filelogCurrentAction,
+ CMD_ID_FILELOG_CURRENT, globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+ connect(m_filelogCurrentAction, SIGNAL(triggered()), this,
+ SLOT(filelogCurrentFile()));
+ cvsMenu->addAction(command);
+
+ m_annotateCurrentAction = new Core::Utils::ParameterAction(tr("Annotate Current File"), tr("Annotate \"%1\""), Core::Utils::ParameterAction::EnabledWithParameter, this);
+ command = ami->registerAction(m_annotateCurrentAction,
+ CMD_ID_ANNOTATE_CURRENT, globalcontext);
+ command->setAttribute(Core::Command::CA_UpdateText);
+ connect(m_annotateCurrentAction, SIGNAL(triggered()), this,
+ SLOT(annotateCurrentFile()));
+ cvsMenu->addAction(command);
+
+ cvsMenu->addAction(createSeparator(this, ami, CMD_ID_SEPARATOR3, globalcontext));
+
+ m_statusAction = new QAction(tr("Project Status"), this);
+ command = ami->registerAction(m_statusAction, CMD_ID_STATUS,
+ globalcontext);
+ connect(m_statusAction, SIGNAL(triggered()), this, SLOT(projectStatus()));
+ cvsMenu->addAction(command);
+
+ m_updateProjectAction = new QAction(tr("Update Project"), this);
+ command = ami->registerAction(m_updateProjectAction, CMD_ID_UPDATE, globalcontext);
+ connect(m_updateProjectAction, SIGNAL(triggered()), this, SLOT(updateProject()));
+ cvsMenu->addAction(command);
+
+ // Actions of the submit editor
+ QList<int> cvscommitcontext;
+ cvscommitcontext << Core::UniqueIDManager::instance()->uniqueIdentifier(Constants::CVSCOMMITEDITOR);
+
+ m_submitCurrentLogAction = new QAction(VCSBase::VCSBaseSubmitEditor::submitIcon(), tr("Commit"), this);
+ command = ami->registerAction(m_submitCurrentLogAction, Constants::SUBMIT_CURRENT, cvscommitcontext);
+ connect(m_submitCurrentLogAction, SIGNAL(triggered()), this, SLOT(submitCurrentLog()));
+
+ m_submitDiffAction = new QAction(VCSBase::VCSBaseSubmitEditor::diffIcon(), tr("Diff Selected Files"), this);
+ command = ami->registerAction(m_submitDiffAction , Constants::DIFF_SELECTED, cvscommitcontext);
+
+ m_submitUndoAction = new QAction(tr("&Undo"), this);
+ command = ami->registerAction(m_submitUndoAction, Core::Constants::UNDO, cvscommitcontext);
+
+ m_submitRedoAction = new QAction(tr("&Redo"), this);
+ command = ami->registerAction(m_submitRedoAction, Core::Constants::REDO, cvscommitcontext);
+
+ connect(Core::ICore::instance(), SIGNAL(contextChanged(Core::IContext *)), this, SLOT(updateActions()));
+
+ return true;
+}
+
+void CVSPlugin::extensionsInitialized()
+{
+ m_projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
+ if (m_projectExplorer) {
+ connect(m_projectExplorer,
+ SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
+ m_cvsPluginInstance, SLOT(updateActions()));
+ }
+ updateActions();
+}
+
+bool CVSPlugin::editorAboutToClose(Core::IEditor *iEditor)
+{
+ if (!m_changeTmpFile || !iEditor || qstrcmp(Constants::CVSCOMMITEDITOR, iEditor->kind()))
+ return true;
+
+ Core::IFile *fileIFace = iEditor->file();
+ const CVSSubmitEditor *editor = qobject_cast<CVSSubmitEditor *>(iEditor);
+ if (!fileIFace || !editor)
+ return true;
+
+ // Submit editor closing. Make it write out the commit message
+ // and retrieve files
+ const QFileInfo editorFile(fileIFace->fileName());
+ const QFileInfo changeFile(m_changeTmpFile->fileName());
+ if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
+ return true; // Oops?!
+
+ // Prompt user. Force a prompt unless submit was actually invoked (that
+ // is, the editor was closed or shutdown).
+ CVSSettings newSettings = m_settings;
+ const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult answer =
+ 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);
+ m_submitActionTriggered = false;
+ switch (answer) {
+ case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
+ return false; // Keep editing and change file
+ case VCSBase::VCSBaseSubmitEditor::SubmitDiscarded:
+ cleanChangeTmpFile();
+ return true; // Cancel all
+ default:
+ break;
+ }
+ setSettings(newSettings); // in case someone turned prompting off
+ const QStringList fileList = editor->checkedFiles();
+ bool closeEditor = true;
+ if (!fileList.empty()) {
+ // get message & commit
+ Core::ICore::instance()->fileManager()->blockFileChange(fileIFace);
+ fileIFace->save();
+ Core::ICore::instance()->fileManager()->unblockFileChange(fileIFace);
+ closeEditor= commit(m_changeTmpFile->fileName(), fileList);
+ }
+ if (closeEditor)
+ cleanChangeTmpFile();
+ return closeEditor;
+}
+
+void CVSPlugin::diffFiles(const QStringList &files)
+{
+ cvsDiff(files);
+}
+
+void CVSPlugin::cvsDiff(const QStringList &files, QString diffname)
+{
+ if (CVS::Constants::debug)
+ qDebug() << Q_FUNC_INFO << files << diffname;
+ const QString source = files.empty() ? QString() : files.front();
+ QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(source);
+
+ if (files.count() == 1 && diffname.isEmpty())
+ diffname = QFileInfo(files.front()).fileName();
+
+ QStringList args(QLatin1String("diff"));
+ args << m_settings.cvsDiffOptions;
+
+ // CVS returns the diff exit code (1 if files differ), which is
+ // undistinguishable from a "file not found" error, unfortunately.
+ const CVSResponse response = runCVS(args, files, cvsShortTimeOut, false, 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
+ if (files.count() == 1) {
+ // Show in the same editor if diff has been executed before
+ if (Core::IEditor *editor = locateEditor("originalFileName", files.front())) {
+ editor->createNew(output);
+ Core::EditorManager::instance()->activateEditor(editor);
+ CVSEditor::setDiffBaseDir(editor, response.workingDirectory);
+ return;
+ }
+ }
+ const QString title = QString::fromLatin1("cvs diff %1").arg(diffname);
+ Core::IEditor *editor = showOutputInEditor(title, output, VCSBase::DiffOutput, source, codec);
+ if (files.count() == 1)
+ editor->setProperty("originalFileName", files.front());
+ CVSEditor::setDiffBaseDir(editor, response.workingDirectory);
+}
+
+CVSSubmitEditor *CVSPlugin::openCVSSubmitEditor(const QString &fileName)
+{
+ Core::IEditor *editor = Core::EditorManager::instance()->openEditor(fileName, QLatin1String(Constants::CVSCOMMITEDITOR_KIND));
+ CVSSubmitEditor *submitEditor = qobject_cast<CVSSubmitEditor*>(editor);
+ QTC_ASSERT(submitEditor, /**/);
+ submitEditor->registerActions(m_submitUndoAction, m_submitRedoAction, m_submitCurrentLogAction, m_submitDiffAction);
+ connect(submitEditor, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(diffFiles(QStringList)));
+
+ return submitEditor;
+}
+
+void CVSPlugin::updateActions()
+{
+ m_diffProjectAction->setEnabled(true);
+ m_commitAllAction->setEnabled(true);
+ m_statusAction->setEnabled(true);
+
+ const QString fileName = currentFileName();
+ const QString baseName = fileName.isEmpty() ? fileName : QFileInfo(fileName).fileName();
+
+ m_addAction->setParameter(baseName);
+ m_deleteAction->setParameter(baseName);
+ m_revertAction->setParameter(baseName);
+ m_diffCurrentAction->setParameter(baseName);
+ m_commitCurrentAction->setParameter(baseName);
+ m_filelogCurrentAction->setParameter(baseName);
+ m_annotateCurrentAction->setParameter(baseName);
+}
+
+void CVSPlugin::addCurrentFile()
+{
+ const QString file = currentFileName();
+ if (!file.isEmpty())
+ vcsAdd(file);
+}
+
+void CVSPlugin::deleteCurrentFile()
+{
+ const QString file = currentFileName();
+ if (file.isEmpty())
+ return;
+ if (!Core::ICore::instance()->vcsManager()->showDeleteDialog(file))
+ QMessageBox::warning(0, QLatin1String("CVS remove"), tr("The file '%1' could not be deleted.").arg(file), QMessageBox::Ok);
+}
+
+void CVSPlugin::revertCurrentFile()
+{
+ const QString file = currentFileName();
+ if (file.isEmpty())
+ return;
+
+ const CVSResponse diffResponse = runCVS(QStringList(QLatin1String("diff")), QStringList(file), cvsShortTimeOut, false);
+ switch (diffResponse.result) {
+ case CVSResponse::Ok:
+ return; // Not modified, diff exit code 0
+ case CVSResponse::NonNullExitCode: // Diff exit code != 0
+ if (diffResponse.stdOut.isEmpty()) // Paranoia: Something else failed?
+ return;
+ break;
+ case CVSResponse::OtherError:
+ return;
+ }
+
+ if (QMessageBox::warning(0, QLatin1String("CVS revert"), tr("The file has been changed. Do you want to revert it?"),
+ QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
+ return;
+
+ Core::FileChangeBlocker fcb(file);
+
+ // revert
+ QStringList args(QLatin1String("update"));
+ args.push_back(QLatin1String("-C"));
+
+ const CVSResponse revertResponse = runCVS(args, QStringList(file), cvsShortTimeOut, true);
+ if (revertResponse.result == CVSResponse::Ok) {
+ fcb.setModifiedReload(true);
+ }
+}
+
+// Get a unique set of toplevel directories for the current projects.
+// To be used for "diff all" or "commit all".
+QStringList CVSPlugin::currentProjectsTopLevels(QString *name) const
+{
+ typedef QList<ProjectExplorer::Project *> ProjectList;
+ ProjectList projects;
+ // Compile list of projects
+ if (ProjectExplorer::Project *currentProject = m_projectExplorer->currentProject()) {
+ projects.push_back(currentProject);
+ } else {
+ if (const ProjectExplorer::SessionManager *session = m_projectExplorer->session())
+ projects.append(session->projects());
+ }
+ // Get unique set of toplevels and concat project names
+ QStringList toplevels;
+ const QChar blank(QLatin1Char(' '));
+ foreach (const ProjectExplorer::Project *p, projects) {
+ if (name) {
+ if (!name->isEmpty())
+ name->append(blank);
+ name->append(p->name());
+ }
+
+ const QString projectPath = QFileInfo(p->file()->fileName()).absolutePath();
+ const QString topLevel = findTopLevelForDirectory(projectPath);
+ if (!topLevel.isEmpty() && !toplevels.contains(topLevel))
+ toplevels.push_back(topLevel);
+ }
+ return toplevels;
+}
+
+void CVSPlugin::diffProject()
+{
+ QString diffName;
+ const QStringList topLevels = currentProjectsTopLevels(&diffName);
+ if (!topLevels.isEmpty())
+ cvsDiff(topLevels, diffName);
+}
+
+void CVSPlugin::diffCurrentFile()
+{
+ cvsDiff(QStringList(currentFileName()));
+}
+
+void CVSPlugin::startCommitCurrentFile()
+{
+ const QString file = currentFileName();
+ if (!file.isEmpty())
+ startCommit(file);
+}
+
+void CVSPlugin::startCommitAll()
+{
+ // Make sure we have only repository for commit
+ const QStringList files = currentProjectsTopLevels();
+ switch (files.size()) {
+ case 0:
+ break;
+ case 1:
+ startCommit(files.front());
+ break;
+ default: {
+ const QString msg = tr("The commit list spans several repositories (%1). Please commit them one by one.").
+ arg(files.join(QString(QLatin1Char(' '))));
+ QMessageBox::warning(0, QLatin1String("cvs commit"), msg, QMessageBox::Ok);
+ }
+ break;
+ }
+}
+
+/* Start commit of files of a single repository by displaying
+ * template and files in a submit editor. On closing, the real
+ * commit will start. */
+void CVSPlugin::startCommit(const QString &source)
+{
+ if (source.isEmpty())
+ return;
+ if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
+ return;
+ if (m_changeTmpFile) {
+ showOutput(tr("Another commit is currently being executed."));
+ return;
+ }
+ const QFileInfo sourceFi(source);
+ const QString sourceDir = sourceFi.isDir() ? source : sourceFi.absolutePath();
+ const QString topLevel = findTopLevelForDirectory(sourceDir);
+ if (topLevel.isEmpty()) {
+ showOutput(msgCannotFindTopLevel(source), true);
+ return;
+ }
+ // We need the "Examining <subdir>" stderr output to tell
+ // where we are, so, have stdout/stderr channels merged.
+ QStringList args(QStringList(QLatin1String("status")));
+ if (sourceDir == topLevel) {
+ args.push_back(QString(QLatin1Char('.')));
+ } else {
+ args.push_back(QDir(topLevel).relativeFilePath(source));
+ }
+ const CVSResponse response = runCVS(topLevel, args, cvsShortTimeOut, false, 0, true);
+ if (response.result != CVSResponse::Ok)
+ return;
+ // Get list of added/modified/deleted files
+ // As we run cvs in the repository directory, we need complete
+ // the file names by the respective directory.
+ const StateList statusOutput = parseStatusOutput(topLevel, response.stdOut);
+ if (CVS::Constants::debug)
+ qDebug() << Q_FUNC_INFO << '\n' << source << "top" << topLevel;
+
+ if (statusOutput.empty()) {
+ showOutput(tr("There are no modified files."), true);
+ return;
+ }
+
+ // Create a new submit change file containing the submit template
+ QTemporaryFile *changeTmpFile = new QTemporaryFile(this);
+ changeTmpFile->setAutoRemove(true);
+ if (!changeTmpFile->open()) {
+ showOutput(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString()));
+ delete changeTmpFile;
+ return;
+ }
+ m_changeTmpFile = changeTmpFile;
+ // TODO: Retrieve submit template from
+ const QString submitTemplate;
+ // Create a submit
+ m_changeTmpFile->write(submitTemplate.toUtf8());
+ m_changeTmpFile->flush();
+ m_changeTmpFile->seek(0);
+ // Create a submit editor and set file list
+ CVSSubmitEditor *editor = openCVSSubmitEditor(m_changeTmpFile->fileName());
+ editor->setStateList(statusOutput);
+}
+
+bool CVSPlugin::commit(const QString &messageFile,
+ const QStringList &fileList)
+{
+ if (CVS::Constants::debug)
+ qDebug() << Q_FUNC_INFO << messageFile << fileList;
+ QStringList args = QStringList(QLatin1String("commit"));
+ args << QLatin1String("-F") << messageFile;
+ const CVSResponse response = runCVS(args, fileList, cvsLongTimeOut, true);
+ return response.result == CVSResponse::Ok ;
+}
+
+void CVSPlugin::filelogCurrentFile()
+{
+ const QString file = currentFileName();
+ if (!file.isEmpty())
+ filelog(file);
+}
+
+void CVSPlugin::filelog(const QString &file)
+{
+ QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(file);
+ // no need for temp file
+ const CVSResponse response = runCVS(QStringList(QLatin1String("log")), QStringList(file), cvsShortTimeOut, false, codec);
+ if (response.result != CVSResponse::Ok)
+ return;
+
+ // Re-use an existing view if possible to support
+ // the common usage pattern of continuously changing and diffing a file
+
+ if (Core::IEditor *editor = locateEditor("logFileName", file)) {
+ editor->createNew(response.stdOut);
+ Core::EditorManager::instance()->activateEditor(editor);
+ } else {
+ const QString title = QString::fromLatin1("cvs log %1").arg(QFileInfo(file).fileName());
+ Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::LogOutput, file, codec);
+ newEditor->setProperty("logFileName", file);
+ }
+}
+
+void CVSPlugin::updateProject()
+{
+ const QStringList topLevels = currentProjectsTopLevels();
+ if (!topLevels.empty()) {
+ QStringList args(QLatin1String("update"));
+ args.push_back(QLatin1String("-dR"));
+ runCVS(args, topLevels, cvsLongTimeOut, true);
+ }
+}
+
+void CVSPlugin::annotateCurrentFile()
+{
+ const QString file = currentFileName();
+ if (!file.isEmpty())
+ annotate(file);
+}
+
+void CVSPlugin::annotate(const QString &file)
+{
+ QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(file);
+ const CVSResponse response = runCVS(QStringList(QLatin1String("annotate")), QStringList(file), cvsShortTimeOut, false, codec);
+ if (response.result != CVSResponse::Ok)
+ return;
+
+ // Re-use an existing view if possible to support
+ // the common usage pattern of continuously changing and diffing a file
+
+ if (Core::IEditor *editor = locateEditor("annotateFileName", file)) {
+ editor->createNew(response.stdOut);
+ Core::EditorManager::instance()->activateEditor(editor);
+ } else {
+ const QString title = QString::fromLatin1("cvs annotate %1").arg(QFileInfo(file).fileName());
+ Core::IEditor *newEditor = showOutputInEditor(title, response.stdOut, VCSBase::AnnotateOutput, file, codec);
+ newEditor->setProperty("annotateFileName", file);
+ }
+}
+
+void CVSPlugin::projectStatus()
+{
+ if (!m_projectExplorer)
+ return;
+
+ const QStringList topLevels = currentProjectsTopLevels();
+ if (topLevels.empty())
+ return;
+
+ const CVSResponse response = runCVS(QStringList(QLatin1String("status")), topLevels, cvsShortTimeOut, false);
+ if (response.result == CVSResponse::Ok)
+ showOutputInEditor(tr("Project status"), response.stdOut, VCSBase::RegularCommandOutput, topLevels.front(), 0);
+}
+
+// Decrement version number "1.2" -> "1.1"
+static QString previousRevision(const QString &rev)
+{
+ const int dotPos = rev.lastIndexOf(QLatin1Char('.'));
+ if (dotPos == -1)
+ return rev;
+ const int minor = rev.mid(dotPos + 1).toInt();
+ return rev.left(dotPos + 1) + QString::number(minor - 1);
+}
+
+void CVSPlugin::slotDescribe(const QString &source, const QString &changeNr)
+{
+ QString errorMessage;
+ if (!describe(source, changeNr, &errorMessage))
+ showOutput(errorMessage, true);
+}
+
+bool CVSPlugin::describe(const QString &file, const QString &changeNr, QString *errorMessage)
+{
+ // In CVS, revisions of files are normally unrelated, there is
+ // no global revision/change number. The only thing that groups
+ // a commit is the "commit-id" (as shown in the log).
+ // This function makes use of it to find all files related to
+ // a commit in order to emulate a "describe global change" functionality
+ // if desired.
+ if (CVS::Constants::debug)
+ qDebug() << Q_FUNC_INFO << file << changeNr;
+ const QString toplevel = findTopLevelForDirectory(QFileInfo(file).absolutePath());
+ if (toplevel.isEmpty()) {
+ *errorMessage = msgCannotFindTopLevel(file);
+ return false;
+ }
+ // Number must be > 1
+ if (changeNr.endsWith(QLatin1Char('1'))) {
+ *errorMessage = tr("The initial revision %1 cannot be described.").arg(changeNr);
+ return false;
+ }
+ // Run log to obtain commit id and details
+ QStringList args(QLatin1String("log"));
+ args.push_back(QLatin1String("-r") + changeNr);
+ const CVSResponse logResponse = runCVS(args, QStringList(file), cvsShortTimeOut, false);
+ if (logResponse.result != CVSResponse::Ok) {
+ *errorMessage = logResponse.message;
+ return false;
+ }
+ const QList<CVS_LogEntry> fileLog = parseLogEntries(logResponse.stdOut, logResponse.workingDirectory);
+ if (fileLog.empty() || fileLog.front().revisions.empty()) {
+ *errorMessage = msgLogParsingFailed();
+ return false;
+ }
+ if (m_settings.describeByCommitId) {
+ // 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;
+ // Date range "D1<D2" in ISO format "YYYY-MM-DD"
+ const QString dateS = fileLog.front().revisions.front().date;
+ const QDate date = QDate::fromString(dateS, Qt::ISODate);
+ const QString nextDayS = date.addDays(1).toString(Qt::ISODate);
+ args.clear();
+ args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS);
+ const CVSResponse repoLogResponse = runCVS(args, QStringList(toplevel), cvsLongTimeOut, false);
+ if (repoLogResponse.result != CVSResponse::Ok) {
+ *errorMessage = repoLogResponse.message;
+ return false;
+ }
+ // Describe all files found, pass on dir to obtain correct absolute paths.
+ const QList<CVS_LogEntry> repoEntries = parseLogEntries(repoLogResponse.stdOut, QFileInfo(toplevel).absolutePath(), commitId);
+ if (repoEntries.empty()) {
+ *errorMessage = tr("Could not find commits of id '%1' on %2.").arg(commitId, dateS);
+ return false;
+ }
+ return describe(toplevel, repoEntries, errorMessage);
+ } else {
+ // Just describe that single entry
+ return describe(toplevel, fileLog, errorMessage);
+ }
+ return false;
+}
+
+// Describe a set of files and revisions by
+// concatenating log and diffs to previous revisions
+bool CVSPlugin::describe(const QString &repositoryPath, QList<CVS_LogEntry> entries,
+ QString *errorMessage)
+{
+ // Collect logs
+ QString output;
+ const QDir repository(repositoryPath);
+ QTextCodec *codec = 0;
+ const QList<CVS_LogEntry>::iterator lend = entries.end();
+ for (QList<CVS_LogEntry>::iterator it = entries.begin(); it != lend; ++it) {
+ // Before fiddling file names, try to find codec
+ if (!codec)
+ codec = VCSBase::VCSBaseEditor::getCodec(it->file);
+ // Make the files relative to the repository directory.
+ it->file = repository.relativeFilePath(it->file);
+ // Run log
+ QStringList args(QLatin1String("log"));
+ args << (QLatin1String("-r") + it->revisions.front().revision) << it->file;
+ const CVSResponse logResponse = runCVS(repositoryPath, args, cvsShortTimeOut, false);
+ if (logResponse.result != CVSResponse::Ok) {
+ *errorMessage = logResponse.message;
+ return false;
+ }
+ output += logResponse.stdOut;
+ }
+ // Collect diffs relative to repository
+ for (QList<CVS_LogEntry>::iterator it = entries.begin(); it != lend; ++it) {
+ const QString previousRev = previousRevision(it->revisions.front().revision);
+ QStringList args(QLatin1String("diff"));
+ args << m_settings.cvsDiffOptions << QLatin1String("-r") << previousRev
+ << QLatin1String("-r") << it->revisions.front().revision
+ << it->file;
+ const CVSResponse diffResponse = runCVS(repositoryPath, args, cvsShortTimeOut, false, codec);
+ switch (diffResponse.result) {
+ case CVSResponse::Ok:
+ case CVSResponse::NonNullExitCode: // Diff exit code != 0
+ if (diffResponse.stdOut.isEmpty()) {
+ *errorMessage = diffResponse.message;
+ return false; // Something else failed.
+ }
+ break;
+ case CVSResponse::OtherError:
+ *errorMessage = diffResponse.message;
+ return false;
+ }
+ output += fixDiffOutput(diffResponse.stdOut);
+ }
+
+ // Re-use an existing view if possible to support
+ // the common usage pattern of continuously changing and diffing a file
+ const QString commitId = entries.front().revisions.front().commitId;
+ if (Core::IEditor *editor = locateEditor("describeChange", commitId)) {
+ editor->createNew(output);
+ Core::EditorManager::instance()->activateEditor(editor);
+ CVSEditor::setDiffBaseDir(editor, repositoryPath);
+ } else {
+ const QString title = QString::fromLatin1("cvs describe %1").arg(commitId);
+ Core::IEditor *newEditor = showOutputInEditor(title, output, VCSBase::DiffOutput, entries.front().file, codec);
+ newEditor->setProperty("describeChange", commitId);
+ CVSEditor::setDiffBaseDir(newEditor, repositoryPath);
+ }
+ return true;
+}
+
+void CVSPlugin::submitCurrentLog()
+{
+ m_submitActionTriggered = true;
+ Core::EditorManager::instance()->closeEditors(QList<Core::IEditor*>()
+ << Core::EditorManager::instance()->currentEditor());
+}
+
+QString CVSPlugin::currentFileName() const
+{
+ const QString fileName = Core::ICore::instance()->fileManager()->currentFile();
+ if (!fileName.isEmpty()) {
+ const QFileInfo fi(fileName);
+ if (fi.exists())
+ return fi.canonicalFilePath();
+ }
+ return QString();
+}
+
+static inline QString processStdErr(QProcess &proc)
+{
+ return QString::fromLocal8Bit(proc.readAllStandardError()).remove(QLatin1Char('\r'));
+}
+
+static inline QString processStdOut(QProcess &proc, QTextCodec *outputCodec = 0)
+{
+ const QByteArray stdOutData = proc.readAllStandardOutput();
+ QString stdOut = outputCodec ? outputCodec->toUnicode(stdOutData) : QString::fromLocal8Bit(stdOutData);
+ return stdOut.remove(QLatin1Char('\r'));
+}
+
+/* Tortoise CVS does not allow for absolute path names
+ * (which it claims to be CVS standard behaviour).
+ * So, try to figure out the common root of the file arguments,
+ * remove it from the files and return it as working directory for
+ * the process. Note that it is principle possible to have
+ * projects with differing repositories open in a session,
+ * so, trying to find a common repository is not an option.
+ * Usually, there is only one file argument, which is not
+ * problematic; it is just split using QFileInfo. */
+
+// Figure out length of common start of string ("C:\a", "c:\b" -> "c:\"
+static inline int commonPartSize(const QString &s1, const QString &s2)
+{
+ const int size = qMin(s1.size(), s2.size());
+ for (int i = 0; i < size; i++)
+ if (s1.at(i) != s2.at(i))
+ return i;
+ return size;
+}
+
+static inline QString fixFileArgs(QStringList *files)
+{
+ switch (files->size()) {
+ case 0:
+ return QString();
+ case 1: { // Easy, just one
+ const QFileInfo fi(files->at(0));
+ (*files)[0] = fi.fileName();
+ return fi.absolutePath();
+ }
+ default:
+ break;
+ }
+ // Figure out common string part: "C:\foo\bar1" "C:\foo\bar2" -> "C:\foo\bar"
+ int commonLength = INT_MAX;
+ const int last = files->size() - 1;
+ for (int i = 0; i < last; i++)
+ commonLength = qMin(commonLength, commonPartSize(files->at(i), files->at(i + 1)));
+ if (!commonLength)
+ return QString();
+ // Find directory part: "C:\foo\bar" -> "C:\foo"
+ QString common = files->at(0).left(commonLength);
+ int lastSlashPos = common.lastIndexOf(QLatin1Char('/'));
+ if (lastSlashPos == -1)
+ lastSlashPos = common.lastIndexOf(QLatin1Char('\\'));
+ if (lastSlashPos == -1)
+ return QString();
+#ifdef Q_OS_UNIX
+ if (lastSlashPos == 0) // leave "/a", "/b" untouched
+ return QString();
+#endif
+ common.truncate(lastSlashPos);
+ // remove up until slash from the files
+ commonLength = lastSlashPos + 1;
+ const QStringList::iterator end = files->end();
+ for (QStringList::iterator it = files->begin(); it != end; ++it) {
+ it->remove(0, commonLength);
+ }
+ return common;
+}
+
+// Format log entry for command
+static inline QString msgExecutionLogEntry(const QString &workingDir, const QString &executable, const QStringList &arguments)
+{
+ const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm"));
+ //: <timestamp> Executing: <executable> <arguments>
+ const QString args = arguments.join(QString(QLatin1Char(' ')));
+ if (workingDir.isEmpty())
+ return CVSPlugin::tr("%1 Executing: %2 %3\n").arg(timeStamp, executable, args);
+ return CVSPlugin::tr("%1 Executing in %2: %3 %4\n").arg(timeStamp, workingDir, executable, args);
+}
+
+// Figure out a working directory for the process,
+// fix the file arguments accordingly and run CVS.
+CVSResponse CVSPlugin::runCVS(const QStringList &arguments,
+ QStringList files,
+ int timeOut,
+ bool showStdOutInOutputWindow,
+ QTextCodec *outputCodec,
+ bool mergeStderr)
+{
+ const QString workingDirectory = fixFileArgs(&files);
+ return runCVS( workingDirectory, arguments + files, timeOut, showStdOutInOutputWindow, outputCodec, mergeStderr);
+}
+
+// Run CVS. At this point, file arguments must be relative to
+// the working directory (see above).
+CVSResponse CVSPlugin::runCVS(const QString &workingDirectory,
+ const QStringList &arguments,
+ int timeOut,
+ bool showStdOutInOutputWindow, QTextCodec *outputCodec,
+ bool mergeStderr)
+{
+ const QString executable = m_settings.cvsCommand;
+ CVSResponse response;
+ if (executable.isEmpty()) {
+ response.result = CVSResponse::OtherError;
+ response.message =tr("No cvs executable specified!");
+ return response;
+ }
+ // Fix files and compile complete arguments
+ response.workingDirectory = workingDirectory;
+ const QStringList allArgs = m_settings.addOptions(arguments);
+
+ const QString outputText = msgExecutionLogEntry(response.workingDirectory, executable, allArgs);
+ showOutput(outputText, false);
+
+ if (CVS::Constants::debug)
+ qDebug() << "runCVS" << timeOut << outputText;
+
+ // Run, connect stderr to the output window
+ Core::Utils::SynchronousProcess process;
+ if (!response.workingDirectory.isEmpty())
+ process.setWorkingDirectory(response.workingDirectory);
+
+ if (mergeStderr)
+ process.setProcessChannelMode(QProcess::MergedChannels);
+
+ process.setTimeout(timeOut);
+ process.setStdOutCodec(outputCodec);
+
+ process.setStdErrBufferedSignalsEnabled(true);
+ connect(&process, SIGNAL(stdErrBuffered(QString,bool)), m_cvsOutputWindow, SLOT(append(QString,bool)));
+
+ // connect stdout to the output window if desired
+ if (showStdOutInOutputWindow) {
+ process.setStdOutBufferedSignalsEnabled(true);
+ connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_cvsOutputWindow, SLOT(append(QString,bool)));
+ }
+
+ const Core::Utils::SynchronousProcessResponse sp_resp = process.run(executable, allArgs);
+ response.result = CVSResponse::OtherError;
+ response.stdErr = sp_resp.stdErr;
+ response.stdOut = sp_resp.stdOut;
+ switch (sp_resp.result) {
+ case Core::Utils::SynchronousProcessResponse::Finished:
+ response.result = CVSResponse::Ok;
+ break;
+ case Core::Utils::SynchronousProcessResponse::FinishedError:
+ response.result = CVSResponse::NonNullExitCode;
+ response.message = tr("The process terminated with exit code %1.").arg(sp_resp.exitCode);
+ break;
+ case Core::Utils::SynchronousProcessResponse::TerminatedAbnormally:
+ response.message = tr("The process terminated abnormally.");
+ break;
+ case Core::Utils::SynchronousProcessResponse::StartFailed:
+ response.message = tr("Could not start cvs '%1'. Please check your settings in the preferences.").arg(executable);
+ break;
+ case Core::Utils::SynchronousProcessResponse::Hang:
+ response.message = tr("CVS did not respond within timeout limit (%1 ms).").arg(timeOut);
+ break;
+ }
+ if (response.result != CVSResponse::Ok)
+ m_cvsOutputWindow->append(response.message, true);
+
+ return response;
+}
+
+void CVSPlugin::showOutput(const QString &output, bool bringToForeground)
+{
+ m_cvsOutputWindow->append(output);
+ if (bringToForeground)
+ m_cvsOutputWindow->popup();
+}
+
+Core::IEditor * CVSPlugin::showOutputInEditor(const QString& title, const QString &output,
+ int editorType, const QString &source,
+ QTextCodec *codec)
+{
+ const VCSBase::VCSBaseEditorParameters *params = findType(editorType);
+ QTC_ASSERT(params, return 0);
+ const QString kind = QLatin1String(params->kind);
+ if (CVS::Constants::debug)
+ qDebug() << "CVSPlugin::showOutputInEditor" << title << kind << "source=" << source << "Size= " << output.size() << " Type=" << editorType << debugCodec(codec);
+ QString s = title;
+ Core::IEditor *editor = Core::EditorManager::instance()->newFile(kind, &s, output.toLocal8Bit());
+ CVSEditor *e = qobject_cast<CVSEditor*>(editor->widget());
+ if (!e)
+ return 0;
+ s.replace(QLatin1Char(' '), QLatin1Char('_'));
+ e->setSuggestedFileName(s);
+ if (!source.isEmpty())
+ e->setSource(source);
+ if (codec)
+ e->setCodec(codec);
+ Core::IEditor *ie = e->editableInterface();
+ Core::EditorManager::instance()->activateEditor(ie);
+ return ie;
+}
+
+CVSSettings CVSPlugin::settings() const
+{
+ return m_settings;
+}
+
+void CVSPlugin::setSettings(const CVSSettings &s)
+{
+ if (s != m_settings) {
+ m_settings = s;
+ if (QSettings *settings = Core::ICore::instance()->settings())
+ m_settings.toSettings(settings);
+ }
+}
+
+CVSPlugin *CVSPlugin::cvsPluginInstance()
+{
+ QTC_ASSERT(m_cvsPluginInstance, return m_cvsPluginInstance);
+ return m_cvsPluginInstance;
+}
+
+bool CVSPlugin::vcsAdd(const QString &rawFileName)
+{
+ const CVSResponse response = runCVS(QStringList(QLatin1String("add")), QStringList(rawFileName), cvsShortTimeOut, true);
+ return response.result == CVSResponse::Ok;
+}
+
+bool CVSPlugin::vcsDelete(const QString &rawFileName)
+{
+ QStringList args(QLatin1String("remove"));
+ args << QLatin1String("-f");
+ const CVSResponse response = runCVS(args, QStringList(rawFileName), cvsShortTimeOut, true);
+ return response.result == CVSResponse::Ok;
+}
+
+/* CVS has a "CVS" directory in each directory it manages. The top level
+ * is the first directory under the directory that does not have it. */
+bool CVSPlugin::managesDirectory(const QString &directory) const
+{
+ const QDir dir(directory);
+ const bool rc = dir.exists() && managesDirectory(dir);
+ if (CVS::Constants::debug)
+ qDebug() << "CVSPlugin::managesDirectory" << directory << rc;
+ return rc;
+}
+
+bool CVSPlugin::managesDirectory(const QDir &directory) const
+{
+ const QString cvsDir = directory.absoluteFilePath(QLatin1String("CVS"));
+ return QFileInfo(cvsDir).isDir();
+}
+
+QString CVSPlugin::findTopLevelForDirectory(const QString &directory) const
+{
+ // Debug wrapper
+ const QString rc = findTopLevelForDirectoryI(directory);
+ if (CVS::Constants::debug)
+ qDebug() << "CVSPlugin::findTopLevelForDirectory" << directory << rc;
+ return rc;
+}
+
+QString CVSPlugin::findTopLevelForDirectoryI(const QString &directory) const
+{
+ /* Recursing up, the top level is a child of the first directory that does
+ * not have a "CVS" directory. The starting directory must be a managed
+ * one. Go up and try to find the first unmanaged parent dir. */
+ QDir lastDirectory = QDir(directory);
+ if (!lastDirectory.exists() || !managesDirectory(lastDirectory))
+ return QString();
+ for (QDir parentDir = lastDirectory; parentDir.cdUp() ; lastDirectory = parentDir) {
+ if (!managesDirectory(parentDir))
+ return lastDirectory.absolutePath();
+ }
+ return QString();
+}
+
+}
+}
+Q_EXPORT_PLUGIN(CVS::Internal::CVSPlugin)
diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h
new file mode 100644
index 0000000000..ef54049e71
--- /dev/null
+++ b/src/plugins/cvs/cvsplugin.h
@@ -0,0 +1,208 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVSPLUGIN_H
+#define CVSPLUGIN_H
+
+#include "cvssettings.h"
+#include "cvsutils.h"
+
+#include <coreplugin/icorelistener.h>
+#include <extensionsystem/iplugin.h>
+
+QT_BEGIN_NAMESPACE
+class QDir;
+class QAction;
+class QTemporaryFile;
+class QTextCodec;
+QT_END_NAMESPACE
+
+namespace Core {
+ class IEditorFactory;
+ class IVersionControl;
+ namespace Utils {
+ class ParameterAction;
+ }
+}
+
+namespace ProjectExplorer {
+ class ProjectExplorerPlugin;
+}
+
+namespace CVS {
+namespace Internal {
+
+class CVSOutputWindow;
+class CVSSubmitEditor;
+
+struct CVSResponse
+{
+ enum Result { Ok, NonNullExitCode, OtherError };
+ CVSResponse() : result(Ok) {}
+
+ Result result;
+ QString stdOut;
+ QString stdErr;
+ QString message;
+ QString workingDirectory;
+};
+
+/* This plugin differs from the other VCS plugins in that it
+ * runs CVS commands from a working directory using relative
+ * path specifications, which is a requirement imposed by
+ * Tortoise CVS. This has to be taken into account; for example,
+ * the diff editor has an additional property specifying the
+ * base directory for its interaction to work. */
+
+class CVSPlugin : public ExtensionSystem::IPlugin
+{
+ Q_OBJECT
+
+public:
+ CVSPlugin();
+ ~CVSPlugin();
+
+ virtual bool initialize(const QStringList &arguments, QString *error_message);
+ virtual void extensionsInitialized();
+ virtual bool editorAboutToClose(Core::IEditor *editor);
+
+ void cvsDiff(const QStringList &files, QString diffname = QString());
+
+ CVSSubmitEditor *openCVSSubmitEditor(const QString &fileName);
+
+ CVSSettings settings() const;
+ void setSettings(const CVSSettings &s);
+
+ // IVersionControl
+ bool vcsAdd(const QString &fileName);
+ bool vcsDelete(const QString &fileName);
+ bool managesDirectory(const QString &directory) const;
+ QString findTopLevelForDirectory(const QString &directory) const;
+
+ static CVSPlugin *cvsPluginInstance();
+
+private slots:
+ void updateActions();
+ void addCurrentFile();
+ void deleteCurrentFile();
+ void revertCurrentFile();
+ void diffProject();
+ void diffCurrentFile();
+ void startCommitAll();
+ void startCommitCurrentFile();
+ void filelogCurrentFile();
+ void annotateCurrentFile();
+ void projectStatus();
+ void slotDescribe(const QString &source, const QString &changeNr);
+ void updateProject();
+ void submitCurrentLog();
+ void diffFiles(const QStringList &);
+
+private:
+ QString currentFileName() const;
+ Core::IEditor * showOutputInEditor(const QString& title, const QString &output,
+ int editorType, const QString &source,
+ QTextCodec *codec);
+ CVSResponse runCVS(const QStringList &arguments,
+ QStringList fileArguments,
+ int timeOut,
+ bool showStdOutInOutputWindow, QTextCodec *outputCodec = 0,
+ bool mergeStderr = false);
+
+ CVSResponse runCVS(const QString &workingDirectory,
+ const QStringList &arguments,
+ int timeOut,
+ bool showStdOutInOutputWindow, QTextCodec *outputCodec = 0,
+ bool mergeStderr = false);
+
+ void showOutput(const QString &output, bool bringToForeground = true);
+ void annotate(const QString &file);
+ bool describe(const QString &source, const QString &changeNr, QString *errorMessage);
+ bool describe(const QString &repository, QList<CVS_LogEntry> entries, QString *errorMessage);
+ void filelog(const QString &file);
+ bool managesDirectory(const QDir &directory) const;
+ QString findTopLevelForDirectoryI(const QString &directory) const;
+ QStringList currentProjectsTopLevels(QString *name = 0) const;
+ void startCommit(const QString &file);
+ bool commit(const QString &messageFile, const QStringList &subVersionFileList);
+ void cleanChangeTmpFile();
+
+ CVSSettings m_settings;
+ Core::IVersionControl *m_versionControl;
+ QTemporaryFile *m_changeTmpFile;
+
+ CVSOutputWindow *m_cvsOutputWindow;
+ ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
+
+ Core::Utils::ParameterAction *m_addAction;
+ Core::Utils::ParameterAction *m_deleteAction;
+ Core::Utils::ParameterAction *m_revertAction;
+ QAction *m_diffProjectAction;
+ Core::Utils::ParameterAction *m_diffCurrentAction;
+ QAction *m_commitAllAction;
+ Core::Utils::ParameterAction *m_commitCurrentAction;
+ Core::Utils::ParameterAction *m_filelogCurrentAction;
+ Core::Utils::ParameterAction *m_annotateCurrentAction;
+ QAction *m_statusAction;
+ QAction *m_updateProjectAction;
+
+ QAction *m_submitCurrentLogAction;
+ QAction *m_submitDiffAction;
+ QAction *m_submitUndoAction;
+ QAction *m_submitRedoAction;
+ bool m_submitActionTriggered;
+
+ static CVSPlugin *m_cvsPluginInstance;
+};
+
+// Just a proxy for CVSPlugin
+class CoreListener : public Core::ICoreListener
+{
+ Q_OBJECT
+public:
+ CoreListener(CVSPlugin *plugin) : m_plugin(plugin) { }
+
+ // Start commit when submit editor closes
+ bool editorAboutToClose(Core::IEditor *editor) {
+ return m_plugin->editorAboutToClose(editor);
+ }
+
+ // TODO: how to handle that ???
+ bool coreAboutToClose() {
+ return true;
+ }
+
+private:
+ CVSPlugin *m_plugin;
+};
+
+} // namespace CVS
+} // namespace Internal
+
+#endif // CVSPLUGIN_H
diff --git a/src/plugins/cvs/cvssettings.cpp b/src/plugins/cvs/cvssettings.cpp
new file mode 100644
index 0000000000..204fbf7225
--- /dev/null
+++ b/src/plugins/cvs/cvssettings.cpp
@@ -0,0 +1,108 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "cvssettings.h"
+
+#include <QtCore/QSettings>
+#include <QtCore/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 QString defaultCommand()
+{
+ QString rc;
+ rc = QLatin1String("cvs");
+#if defined(Q_OS_WIN32)
+ rc.append(QLatin1String(".exe"));
+#endif
+ return rc;
+}
+
+namespace CVS {
+ namespace Internal {
+
+CVSSettings::CVSSettings() :
+ cvsCommand(defaultCommand()),
+ cvsDiffOptions(QLatin1String(defaultDiffOptions)),
+ promptToSubmit(true),
+ describeByCommitId(true)
+{
+}
+
+void CVSSettings::fromSettings(QSettings *settings)
+{
+ settings->beginGroup(QLatin1String(groupC));
+ cvsCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
+ 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();
+ settings->endGroup();
+}
+
+void CVSSettings::toSettings(QSettings *settings) 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(describeByCommitIdKeyC), describeByCommitId);
+ settings->endGroup();
+}
+
+bool CVSSettings::equals(const CVSSettings &s) const
+{
+ return promptToSubmit == promptToSubmit
+ && describeByCommitId == s.describeByCommitId
+ && cvsCommand == s.cvsCommand
+ && cvsRoot == s.cvsRoot
+ && cvsDiffOptions == s.cvsDiffOptions;
+}
+
+QStringList CVSSettings::addOptions(const QStringList &args) const
+{
+ if (cvsRoot.isEmpty())
+ return args;
+
+ QStringList rc;
+ rc.push_back(QLatin1String("-d"));
+ rc.push_back(cvsRoot);
+ rc.append(args);
+ return rc;
+}
+
+}
+}
diff --git a/src/plugins/cvs/cvssettings.h b/src/plugins/cvs/cvssettings.h
new file mode 100644
index 0000000000..ff37307f2b
--- /dev/null
+++ b/src/plugins/cvs/cvssettings.h
@@ -0,0 +1,70 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVSSETTINGS_H
+#define CVSSETTINGS_H
+
+#include <QtCore/QStringList>
+
+QT_BEGIN_NAMESPACE
+class QSettings;
+QT_END_NAMESPACE
+
+namespace CVS {
+namespace Internal {
+
+// Todo: Add user name and password?
+struct CVSSettings
+{
+ CVSSettings();
+
+ void fromSettings(QSettings *);
+ void toSettings(QSettings *) const;
+
+ // Add common options to the command line
+ QStringList addOptions(const QStringList &args) const;
+
+ bool equals(const CVSSettings &s) const;
+
+ QString cvsCommand;
+ QString cvsRoot;
+ QString cvsDiffOptions;
+ bool promptToSubmit;
+ bool describeByCommitId;
+};
+
+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
+
+#endif // CVSSETTINGS_H
diff --git a/src/plugins/cvs/cvssubmiteditor.cpp b/src/plugins/cvs/cvssubmiteditor.cpp
new file mode 100644
index 0000000000..5e8a5a0306
--- /dev/null
+++ b/src/plugins/cvs/cvssubmiteditor.cpp
@@ -0,0 +1,70 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+
+#include "cvssubmiteditor.h"
+
+#include <utils/submiteditorwidget.h>
+#include <vcsbase/submitfilemodel.h>
+
+using namespace CVS::Internal;
+
+CVSSubmitEditor::CVSSubmitEditor(const VCSBase::VCSBaseSubmitEditorParameters *parameters,
+ QWidget *parentWidget) :
+ VCSBase::VCSBaseSubmitEditor(parameters, new Core::Utils::SubmitEditorWidget(parentWidget)),
+ m_msgAdded(tr("Added")),
+ m_msgRemoved(tr("Removed")),
+ m_msgModified(tr("Modified"))
+{
+ setDisplayName(tr("CVS Submit"));
+}
+
+QString CVSSubmitEditor::stateName(State st) const
+{
+ switch (st) {
+ case LocallyAdded:
+ return m_msgAdded;
+ case LocallyModified:
+ return m_msgModified;
+ case LocallyRemoved:
+ return m_msgRemoved;
+ }
+ return QString();
+}
+
+void CVSSubmitEditor::setStateList(const QList<StateFilePair> &statusOutput)
+{
+ typedef QList<StateFilePair>::const_iterator ConstIterator;
+ VCSBase::SubmitFileModel *model = new VCSBase::SubmitFileModel(this);
+
+ const ConstIterator cend = statusOutput.constEnd();
+ for (ConstIterator it = statusOutput.constBegin(); it != cend; ++it)
+ model->addFile(it->second, stateName(it->first), true);
+ setFileModel(model);
+}
diff --git a/src/plugins/cvs/cvssubmiteditor.h b/src/plugins/cvs/cvssubmiteditor.h
new file mode 100644
index 0000000000..0e103513e9
--- /dev/null
+++ b/src/plugins/cvs/cvssubmiteditor.h
@@ -0,0 +1,64 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVSSUBMITEDITOR_H
+#define CVSSUBMITEDITOR_H
+
+#include <QtCore/QPair>
+#include <QtCore/QStringList>
+
+#include <vcsbase/vcsbasesubmiteditor.h>
+
+namespace CVS {
+namespace Internal {
+
+class CVSSubmitEditor : public VCSBase::VCSBaseSubmitEditor
+{
+ Q_OBJECT
+public:
+ enum State { LocallyAdded, LocallyModified, LocallyRemoved };
+ // A list of state indicators and file names.
+ typedef QPair<State, QString> StateFilePair;
+
+ CVSSubmitEditor(const VCSBase::VCSBaseSubmitEditorParameters *parameters,
+ QWidget *parentWidget = 0);
+
+ void setStateList(const QList<StateFilePair> &statusOutput);
+
+private:
+ inline QString stateName(State st) const;
+ const QString m_msgAdded;
+ const QString m_msgRemoved;
+ const QString m_msgModified;
+};
+
+} // namespace Internal
+} // namespace CVS
+
+#endif // CVSSUBMITEDITOR_H
diff --git a/src/plugins/cvs/cvsutils.cpp b/src/plugins/cvs/cvsutils.cpp
new file mode 100644
index 0000000000..fcd193dd3f
--- /dev/null
+++ b/src/plugins/cvs/cvsutils.cpp
@@ -0,0 +1,238 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "cvsutils.h"
+
+#include <QtCore/QDebug>
+#include <QtCore/QRegExp>
+#include <QtCore/QStringList>
+
+namespace CVS {
+namespace Internal {
+
+CVS_Revision::CVS_Revision(const QString &rev) :
+ revision(rev)
+{
+}
+
+CVS_LogEntry::CVS_LogEntry(const QString &f) :
+ file(f)
+{
+}
+
+QDebug operator<<(QDebug d, const CVS_LogEntry &e)
+{
+ QDebug nospace = d.nospace();
+ nospace << "File: " << e.file << e.revisions.size() << '\n';
+ foreach(const CVS_Revision &r, e.revisions)
+ nospace << " " << r.revision << ' ' << r.date << ' ' << r.commitId << '\n';
+ return d;
+}
+
+/* Parse:
+\code
+RCS file: /repo/foo.h
+Working file: foo.h
+head: 1.2
+...
+----------------------------
+revision 1.2
+date: 2009-07-14 13:30:25 +0200; author: <author>; state: dead; lines: +0 -0; commitid: <id>;
+<message>
+----------------------------
+revision 1.1
+...
+=============================================================================
+\endcode */
+
+QList<CVS_LogEntry> parseLogEntries(const QString &o,
+ const QString &directory,
+ const QString filterCommitId)
+{
+ enum ParseState { FileState, RevisionState, StatusLineState };
+
+ QList<CVS_LogEntry> rc;
+ const QStringList lines = o.split(QString(QLatin1Char('\n')), QString::SkipEmptyParts);
+ ParseState state = FileState;
+
+ const QString workingFilePrefix = QLatin1String("Working file: ");
+ const QString revisionPrefix = QLatin1String("revision ");
+ const QString statusPrefix = QLatin1String("date: ");
+ const QString commitId = QLatin1String("commitid: ");
+ const QRegExp statusPattern = QRegExp(QLatin1String("^date: ([\\d\\-]+) .*commitid: ([^;]+);$"));
+ const QRegExp revisionPattern = QRegExp(QLatin1String("^revision ([\\d\\.]+)$"));
+ const QChar slash = QLatin1Char('/');
+ Q_ASSERT(statusPattern.isValid() && revisionPattern.isValid());
+ const QString fileSeparator = QLatin1String("=============================================================================");
+
+ // Parse using a state enumeration and regular expressions as not to fall for weird
+ // commit messages in state 'RevisionState'
+ foreach(const QString &line, lines) {
+ switch (state) {
+ case FileState:
+ if (line.startsWith(workingFilePrefix)) {
+ QString file = directory;
+ if (!file.isEmpty())
+ file += slash;
+ file += line.mid(workingFilePrefix.size()).trimmed();
+ rc.push_back(CVS_LogEntry(file));
+ state = RevisionState;
+ }
+ break;
+ case RevisionState:
+ if (revisionPattern.exactMatch(line)) {
+ rc.back().revisions.push_back(CVS_Revision(revisionPattern.cap(1)));
+ state = StatusLineState;
+ } else {
+ if (line == fileSeparator)
+ state = FileState;
+ }
+ break;
+ case StatusLineState:
+ if (statusPattern.exactMatch(line)) {
+ const QString commitId = statusPattern.cap(2);
+ if (filterCommitId.isEmpty() || filterCommitId == commitId) {
+ rc.back().revisions.back().date = statusPattern.cap(1);
+ rc.back().revisions.back().commitId = commitId;
+ } else {
+ rc.back().revisions.pop_back();
+ }
+ state = RevisionState;
+ }
+ }
+ }
+ // Purge out files with no matching commits
+ if (!filterCommitId.isEmpty()) {
+ for (QList<CVS_LogEntry>::iterator it = rc.begin(); it != rc.end(); ) {
+ if (it->revisions.empty()) {
+ it = rc.erase(it);
+ } else {
+ ++it;
+ }
+ }
+ }
+ return rc;
+}
+
+QString fixDiffOutput(QString d)
+{
+ if (d.isEmpty())
+ return d;
+ // Kill all lines starting with '?'
+ const QChar questionMark = QLatin1Char('?');
+ const QChar newLine = QLatin1Char('\n');
+ for (int pos = 0; pos < d.size(); ) {
+ const int endOfLinePos = d.indexOf(newLine, pos);
+ if (endOfLinePos == -1)
+ break;
+ const int nextLinePos = endOfLinePos + 1;
+ if (d.at(pos) == questionMark) {
+ d.remove(pos, nextLinePos - pos);
+ } else {
+ pos = nextLinePos;
+ }
+ }
+ return d;
+}
+
+// Parse "cvs status" output for added/modified/deleted files
+// "File: <foo> Status: Up-to-date"
+// "File: <foo> Status: Locally Modified"
+// "File: no file <foo> Status: Locally Removed"
+// "File: hup Status: Locally Added"
+// Not handled for commit purposes: "Needs Patch/Needs Merge"
+// In between, we might encounter "cvs status: Examining subdir"...
+// As we run the status command from the repository directory,
+// we need to add the full path, again.
+// stdout/stderr need to be merged to catch directories.
+
+// Parse out status keywords, return state enum or -1
+inline int stateFromKeyword(const QString &s)
+{
+ if (s == QLatin1String("Up-to-date"))
+ return -1;
+ if (s == QLatin1String("Locally Modified"))
+ return CVSSubmitEditor::LocallyModified;
+ if (s == QLatin1String("Locally Added"))
+ return CVSSubmitEditor::LocallyAdded;
+ if (s == QLatin1String("Locally Removed"))
+ return CVSSubmitEditor::LocallyRemoved;
+ return -1;
+}
+
+StateList parseStatusOutput(const QString &directory, const QString &output)
+{
+ StateList changeSet;
+ const QString fileKeyword = QLatin1String("File: ");
+ const QString statusKeyword = QLatin1String("Status: ");
+ const QString noFileKeyword = QLatin1String("no file ");
+ const QString directoryKeyword = QLatin1String("cvs status: Examining ");
+ const QString dotDir = QString(QLatin1Char('.'));
+ const QChar slash = QLatin1Char('/');
+
+ const QStringList list = output.split(QLatin1Char('\n'), QString::SkipEmptyParts);
+
+ QString path = directory;
+ if (!path.isEmpty())
+ path += slash;
+ foreach (const QString &l, list) {
+ // Status line containing file
+ if (l.startsWith(fileKeyword)) {
+ // Parse state
+ const int statusPos = l.indexOf(statusKeyword);
+ if (statusPos == -1)
+ continue;
+ const int state = stateFromKeyword(l.mid(statusPos + statusKeyword.size()).trimmed());
+ if (state == -1)
+ continue;
+ // Concatenate file name, Correct "no file <foo>"
+ QString fileName = l.mid(fileKeyword.size(), statusPos - fileKeyword.size()).trimmed();
+ if (state == CVSSubmitEditor::LocallyRemoved && fileName.startsWith(noFileKeyword))
+ fileName.remove(0, noFileKeyword.size());
+ changeSet.push_back(CVSSubmitEditor::StateFilePair(static_cast<CVSSubmitEditor::State>(state), path + fileName));
+ continue;
+ }
+ // Examining a new subdirectory
+ if (l.startsWith(directoryKeyword)) {
+ path = directory;
+ if (!path.isEmpty())
+ path += slash;
+ const QString newSubDir = l.mid(directoryKeyword.size()).trimmed();
+ if (newSubDir != dotDir) { // Skip Examining '.'
+ path += newSubDir;
+ path += slash;
+ }
+ continue;
+ }
+ }
+ return changeSet;
+}
+
+} // namespace Internal
+} // namespace CVS
diff --git a/src/plugins/cvs/cvsutils.h b/src/plugins/cvs/cvsutils.h
new file mode 100644
index 0000000000..4515c96be3
--- /dev/null
+++ b/src/plugins/cvs/cvsutils.h
@@ -0,0 +1,86 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef CVSUTILS_H
+#define CVSUTILS_H
+
+#include "cvssubmiteditor.h"
+
+#include <QtCore/QString>
+#include <QtCore/QList>
+
+QT_BEGIN_NAMESPACE
+class QDebug;
+QT_END_NAMESPACE
+
+namespace CVS {
+namespace Internal {
+
+// Utilities to parse output of a CVS log.
+
+// A revision of a file.
+struct CVS_Revision
+{
+ CVS_Revision(const QString &rev);
+
+ QString revision;
+ QString date; // ISO-Format (YYYY-MM-DD)
+ QString commitId;
+};
+
+// A log entry consisting of the file and its revisions.
+struct CVS_LogEntry
+{
+ CVS_LogEntry(const QString &file);
+
+ QString file;
+ QList<CVS_Revision> revisions;
+};
+
+QDebug operator<<(QDebug d, const CVS_LogEntry &);
+
+// Parse. Pass on a directory to obtain full paths when
+// running from the repository directory.
+QList<CVS_LogEntry> parseLogEntries(const QString &output,
+ const QString &directory = QString(),
+ const QString filterCommitId = QString());
+
+// Tortoise CVS outputs unknown files with question marks in
+// the diff output on stdout ('? foo'); remove
+QString fixDiffOutput(QString d);
+
+// Parse the status output of CVS (stdout/stderr merged
+// to catch directories).
+typedef QList<CVSSubmitEditor::StateFilePair> StateList;
+StateList parseStatusOutput(const QString &directory, const QString &output);
+
+} // namespace Internal
+} // namespace CVS
+
+#endif // CVSUTILS_H
diff --git a/src/plugins/cvs/settingspage.cpp b/src/plugins/cvs/settingspage.cpp
new file mode 100644
index 0000000000..589580859d
--- /dev/null
+++ b/src/plugins/cvs/settingspage.cpp
@@ -0,0 +1,107 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#include "settingspage.h"
+#include "cvssettings.h"
+#include "cvsplugin.h"
+
+#include <coreplugin/icore.h>
+#include <extensionsystem/pluginmanager.h>
+#include <vcsbase/vcsbaseconstants.h>
+#include <utils/pathchooser.h>
+
+#include <QtCore/QCoreApplication>
+#include <QtGui/QFileDialog>
+
+using namespace CVS::Internal;
+using namespace Core::Utils;
+
+SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
+ QWidget(parent)
+{
+ m_ui.setupUi(this);
+ m_ui.commandPathChooser->setExpectedKind(PathChooser::Command);
+ m_ui.commandPathChooser->setPromptDialogTitle(tr("CVS Command"));
+}
+
+CVSSettings SettingsPageWidget::settings() const
+{
+ CVSSettings rc;
+ rc.cvsCommand = m_ui.commandPathChooser->path();
+ rc.cvsRoot = m_ui.rootLineEdit->text();
+ rc.cvsDiffOptions = m_ui.diffOptionsLineEdit->text();
+ rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
+ rc.describeByCommitId = 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.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
+ m_ui.describeByCommitIdCheckBox->setChecked(s.describeByCommitId);
+}
+
+SettingsPage::SettingsPage()
+{
+}
+
+QString SettingsPage::id() const
+{
+ return QLatin1String("CVS");
+}
+
+QString SettingsPage::trName() const
+{
+ return tr("CVS");
+}
+
+QString SettingsPage::category() const
+{
+ return QLatin1String(VCSBase::Constants::VCS_SETTINGS_CATEGORY);
+}
+
+QString SettingsPage::trCategory() const
+{
+ return QCoreApplication::translate("VCSBase", VCSBase::Constants::VCS_SETTINGS_CATEGORY);
+}
+
+QWidget *SettingsPage::createPage(QWidget *parent)
+{
+ m_widget = new SettingsPageWidget(parent);
+ m_widget->setSettings(CVSPlugin::cvsPluginInstance()->settings());
+ return m_widget;
+}
+
+void SettingsPage::apply()
+{
+ CVSPlugin::cvsPluginInstance()->setSettings(m_widget->settings());
+}
diff --git a/src/plugins/cvs/settingspage.h b/src/plugins/cvs/settingspage.h
new file mode 100644
index 0000000000..e96f806104
--- /dev/null
+++ b/src/plugins/cvs/settingspage.h
@@ -0,0 +1,86 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** Commercial Usage
+**
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+**
+**************************************************************************/
+
+#ifndef SETTINGSPAGE_H
+#define SETTINGSPAGE_H
+
+#include "ui_settingspage.h"
+
+#include <coreplugin/dialogs/ioptionspage.h>
+
+#include <QtGui/QWidget>
+#include <QtCore/QPointer>
+#include <QtCore/QString>
+
+QT_BEGIN_NAMESPACE
+class QSettings;
+QT_END_NAMESPACE
+
+namespace CVS {
+namespace Internal {
+
+struct CVSSettings;
+
+class SettingsPageWidget : public QWidget {
+ Q_OBJECT
+public:
+ explicit SettingsPageWidget(QWidget *parent = 0);
+
+ CVSSettings settings() const;
+ void setSettings(const CVSSettings &);
+
+private:
+ Ui::SettingsPage m_ui;
+};
+
+
+class SettingsPage : public Core::IOptionsPage
+{
+ Q_OBJECT
+
+public:
+ SettingsPage();
+
+ QString id() const;
+ QString trName() const;
+ QString category() const;
+ QString trCategory() const;
+
+ QWidget *createPage(QWidget *parent);
+ void apply();
+ void finish() { }
+
+private:
+ SettingsPageWidget* m_widget;
+};
+
+} // namespace CVS
+} // namespace Internal
+
+#endif // SETTINGSPAGE_H
diff --git a/src/plugins/cvs/settingspage.ui b/src/plugins/cvs/settingspage.ui
new file mode 100644
index 0000000000..6798485edb
--- /dev/null
+++ b/src/plugins/cvs/settingspage.ui
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CVS::Internal::SettingsPage</class>
+ <widget class="QWidget" name="CVS::Internal::SettingsPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>575</width>
+ <height>437</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout_3">
+ <item row="0" column="0" colspan="2">
+ <widget class="QCheckBox" name="promptToSubmitCheckBox">
+ <property name="text">
+ <string>Prompt to submit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="describeByCommitIdCheckBox">
+ <property name="toolTip">
+ <string>When checked, all files touched by a commit will be displayed when clicking on a revision number in the annotation view (retrieved via commit id). Otherwise, only the respective file will be displayed.</string>
+ </property>
+ <property name="text">
+ <string>Describe by commit id</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="topverticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="commandLabel">
+ <property name="text">
+ <string>CVS Command:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="Core::Utils::PathChooser" name="commandPathChooser"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="rootLabel">
+ <property name="text">
+ <string>CVS Root:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="rootLineEdit"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="diffOptionsLabel">
+ <property name="text">
+ <string>Diff Options:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="diffOptionsLineEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>105</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>Core::Utils::PathChooser</class>
+ <extends>QWidget</extends>
+ <header location="global">utils/pathchooser.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index f50e27c328..4ee1549085 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -14,6 +14,7 @@ SUBDIRS = plugin_coreplugin \
plugin_perforce \
plugin_subversion \
plugin_git \
+ plugin_cvs \
plugin_cpptools \
plugin_qt4projectmanager \
# plugin_snippets \ # buggy and annoying
@@ -73,6 +74,12 @@ plugin_git.depends = plugin_vcsbase
plugin_git.depends += plugin_projectexplorer
plugin_git.depends += plugin_coreplugin
+plugin_cvs.subdir = cvs
+plugin_cvs.depends = plugin_texteditor
+plugin_cvs.depends = plugin_vcsbase
+plugin_cvs.depends += plugin_projectexplorer
+plugin_cvs.depends += plugin_coreplugin
+
plugin_subversion.subdir = subversion
plugin_subversion.depends = plugin_vcsbase
plugin_subversion.depends += plugin_projectexplorer