Add a CVS plugin for use with UNIX cvs or Tortoise CVS.

This commit is contained in:
Friedemann Kleint
2009-07-15 12:28:40 +02:00
parent d53129d336
commit 18f9375501
25 changed files with 3233 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

36
src/plugins/cvs/cvs.pro Normal file
View File

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

5
src/plugins/cvs/cvs.qrc Normal file
View File

@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/trolltech.cvs" >
<file>CVS.mimetypes.xml</file>
</qresource>
</RCC>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

208
src/plugins/cvs/cvsplugin.h Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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