Commit f9bb4c59 authored by cerf's avatar cerf Committed by Tobias Hunger

Added new Bazaar plugin

Merge-request: 229
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 6c1dd96f
<plugin name=\"Bazaar\" version=\"$$QTCREATOR_VERSION\" compatVersion=\"$$QTCREATOR_VERSION\">
<vendor>Hugues Delorme</vendor>
<copyright>(C) 2010-2011 Hugues Delorme</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>
<category>Version Control</category>
<description>Bazaar integration.</description>
<url>http://qt.nokia.com</url>
<dependencyList>
<dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/>
<dependency name=\"VCSBase\" version=\"$$QTCREATOR_VERSION\"/>
</dependencyList>
</plugin>
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Hugues Delorme
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "annotationhighlighter.h"
#include "constants.h"
using namespace Bazaar::Internal;
using namespace Bazaar;
BazaarAnnotationHighlighter::BazaarAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document)
: VCSBase::BaseAnnotationHighlighter(changeNumbers, document),
m_changeset(QLatin1String(Constants::CHANGESETID12))
{
}
QString BazaarAnnotationHighlighter::changeNumber(const QString &block) const
{
if (m_changeset.indexIn(block) != -1)
return m_changeset.cap(1);
return QString();
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Hugues Delorme
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef ANNOTATIONHIGHLIGHTER_H
#define ANNOTATIONHIGHLIGHTER_H
#include <vcsbase/baseannotationhighlighter.h>
#include <QtCore/QRegExp>
namespace Bazaar {
namespace Internal {
class BazaarAnnotationHighlighter : public VCSBase::BaseAnnotationHighlighter
{
public:
explicit BazaarAnnotationHighlighter(const ChangeNumbers &changeNumbers,
QTextDocument *document = 0);
private:
virtual QString changeNumber(const QString &block) const;
QRegExp m_changeset;
};
} //namespace Internal
}// namespace Bazaar
#endif // ANNOTATIONHIGHLIGHTER_H
TARGET = Bazaar
TEMPLATE = lib
include(../../qtcreatorplugin.pri)
include(bazaar_dependencies.pri)
SOURCES += \
bazaarclient.cpp \
bazaarcontrol.cpp \
bazaarplugin.cpp \
optionspage.cpp \
bazaarsettings.cpp \
commiteditor.cpp \
bazaarcommitwidget.cpp \
bazaareditor.cpp \
annotationhighlighter.cpp \
pullorpushdialog.cpp \
branchinfo.cpp \
clonewizardpage.cpp \
clonewizard.cpp \
cloneoptionspanel.cpp
HEADERS += \
bazaarclient.h \
constants.h \
bazaarcontrol.h \
bazaarplugin.h \
optionspage.h \
bazaarsettings.h \
commiteditor.h \
bazaarcommitwidget.h \
bazaareditor.h \
annotationhighlighter.h \
pullorpushdialog.h \
branchinfo.h \
clonewizard.h \
clonewizardpage.h \
cloneoptionspanel.h
FORMS += \
optionspage.ui \
revertdialog.ui \
bazaarcommitpanel.ui \
pullorpushdialog.ui \
cloneoptionspanel.ui
RESOURCES += bazaar.qrc
<RCC>
<qresource prefix="/bazaar" >
<file>images/bazaar.png</file>
</qresource>
</RCC>
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)
This diff is collapsed.
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Hugues Delorme
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef BAZAARCLIENT_H
#define BAZAARCLIENT_H
#include "branchinfo.h"
#include <vcsbase/vcsbaseclient.h>
namespace Bazaar {
namespace Internal {
class BazaarClient : public VCSBase::VCSBaseClient
{
public:
enum ExtraOptionId
{
// Clone
UseExistingDirCloneOptionId,
StackedCloneOptionId,
StandAloneCloneOptionId,
BindCloneOptionId,
SwitchCloneOptionId,
HardLinkCloneOptionId,
NoTreeCloneOptionId,
RevisionCloneOptionId,
// Commit
AuthorCommitOptionId,
FixesCommitOptionId,
LocalCommitOptionId,
// Pull or push (common options)
RememberPullOrPushOptionId,
OverwritePullOrPushOptionId,
RevisionPullOrPushOptionId,
// Pull only
LocalPullOptionId,
// Push only
UseExistingDirPushOptionId,
CreatePrefixPushOptionId
};
BazaarClient(const VCSBase::VCSBaseClientSettings &settings);
BranchInfo synchronousBranchQuery(const QString &repositoryRoot) const;
virtual QString findTopLevelForFile(const QFileInfo &file) const;
protected:
virtual QString vcsEditorKind(VCSCommand cmd) const;
virtual QStringList cloneArguments(const QString &srcLocation,
const QString &dstLocation,
const ExtraCommandOptions &extraOptions) const;
virtual QStringList pullArguments(const QString &srcLocation,
const ExtraCommandOptions &extraOptions) const;
virtual QStringList pushArguments(const QString &dstLocation,
const ExtraCommandOptions &extraOptions) const;
virtual QStringList commitArguments(const QStringList &files,
const QString &commitMessageFile,
const ExtraCommandOptions &extraOptions) const;
virtual QStringList importArguments(const QStringList &files) const;
virtual QStringList updateArguments(const QString &revision) const;
virtual QStringList revertArguments(const QString &file, const QString &revision) const;
virtual QStringList revertAllArguments(const QString &revision) const;
virtual QStringList annotateArguments(const QString &file,
const QString &revision, int lineNumber) const;
virtual QStringList diffArguments(const QStringList &files) const;
virtual QStringList logArguments(const QStringList &files) const;
virtual QStringList statusArguments(const QString &file) const;
virtual QStringList viewArguments(const QString &revision) const;
virtual QPair<QString, QString> parseStatusLine(const QString &line) const;
private:
QStringList commonPullOrPushArguments(const ExtraCommandOptions &extraOptions) const;
friend class CloneWizard;
};
} //namespace Internal
} // namespace Bazaar
#endif // BAZAARCLIENT_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Bazaar::Internal::BazaarCommitPanel</class>
<widget class="QWidget" name="Bazaar::Internal::BazaarCommitPanel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>374</width>
<height>229</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="infoGroup">
<property name="title">
<string>General Information</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="branchLabel">
<property name="text">
<string>Branch:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="branchLineEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="isLocalCheckBox">
<property name="toolTip">
<string>Perform a local commit in a bound branch.
Local commits are not pushed to the master branch until a normal commit is performed</string>
</property>
<property name="text">
<string>Local commit</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="editGroup">
<property name="title">
<string>Commit Information</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="authorLabel">
<property name="text">
<string>Author:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="authorLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="emailLabel">
<property name="text">
<string>Email:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="emailLineEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="fixedBugsLabel">
<property name="text">
<string>Fixed bugs:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="fixedBugsLineEdit"/>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>161</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Hugues Delorme
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#include "bazaarcommitwidget.h"
#include "branchinfo.h"
#include <texteditor/texteditorsettings.h>
#include <texteditor/fontsettings.h>
#include <texteditor/texteditorconstants.h>
#include <QtGui/QSyntaxHighlighter>
#include <QtGui/QTextEdit>
#include <QtCore/QDebug>
#include <QtCore/QRegExp>
//see the git submit widget for details of the syntax Highlighter
//TODO Check to see when the Highlighter has been moved to a base class and use that instead
namespace Bazaar {
namespace Internal {
// Retrieve the comment char format from the text editor.
static QTextCharFormat commentFormat()
{
const TextEditor::FontSettings settings = TextEditor::TextEditorSettings::instance()->fontSettings();
return settings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_COMMENT));
}
// Highlighter for Bazaar submit messages. Make the first line bold, indicates
// comments as such (retrieving the format from the text editor) and marks up
// keywords (words in front of a colon as in 'Task: <bla>').
class BazaarSubmitHighlighter : QSyntaxHighlighter
{
public:
explicit BazaarSubmitHighlighter(QTextEdit *parent);
virtual void highlightBlock(const QString &text);
private:
enum State { Header, Comment, Other };
const QTextCharFormat m_commentFormat;
const QRegExp m_keywordPattern;
const QChar m_hashChar;
};
BazaarSubmitHighlighter::BazaarSubmitHighlighter(QTextEdit * parent) :
QSyntaxHighlighter(parent),
m_commentFormat(commentFormat()),
m_keywordPattern(QLatin1String("^\\w+:")),
m_hashChar(QLatin1Char('#'))
{
Q_ASSERT(m_keywordPattern.isValid());
}
void BazaarSubmitHighlighter::highlightBlock(const QString &text)
{
// figure out current state
State state = Other;
const QTextBlock block = currentBlock();
if (block.position() == 0) {
state = Header;
} else {
if (text.startsWith(m_hashChar))
state = Comment;
}
// Apply format.
switch (state) {
case Header: {
QTextCharFormat charFormat = format(0);
charFormat.setFontWeight(QFont::Bold);
setFormat(0, text.size(), charFormat);
}
break;
case Comment:
setFormat(0, text.size(), m_commentFormat);
break;
case Other:
// Format key words ("Task:") italic
if (m_keywordPattern.indexIn(text, 0, QRegExp::CaretAtZero) == 0) {
QTextCharFormat charFormat = format(0);
charFormat.setFontItalic(true);
setFormat(0, m_keywordPattern.matchedLength(), charFormat);
}
break;
}
}
BazaarCommitWidget::BazaarCommitWidget(QWidget *parent) :
Utils::SubmitEditorWidget(parent),
m_bazaarCommitPanel(new QWidget)
{
m_bazaarCommitPanelUi.setupUi(m_bazaarCommitPanel);
insertTopWidget(m_bazaarCommitPanel);
new BazaarSubmitHighlighter(descriptionEdit());
}
void BazaarCommitWidget::setFields(const BranchInfo &branch,
const QString &userName, const QString &email)
{
m_bazaarCommitPanelUi.branchLineEdit->setText(branch.branchLocation);
m_bazaarCommitPanelUi.isLocalCheckBox->setVisible(branch.isBoundToBranch);
m_bazaarCommitPanelUi.authorLineEdit->setText(userName);
m_bazaarCommitPanelUi.emailLineEdit->setText(email);
}
QString BazaarCommitWidget::committer() const
{
const QString author = m_bazaarCommitPanelUi.authorLineEdit->text();
const QString email = m_bazaarCommitPanelUi.emailLineEdit->text();
if (author.isEmpty())
return QString();
QString user = author;
if (!email.isEmpty()) {
user += QLatin1String(" <");
user += email;
user += QLatin1Char('>');
}
return user;
}
QStringList BazaarCommitWidget::fixedBugs() const
{
return m_bazaarCommitPanelUi.fixedBugsLineEdit->text().split(QRegExp("\\s+"));
}
bool BazaarCommitWidget::isLocalOptionEnabled() const
{
return m_bazaarCommitPanelUi.isLocalCheckBox->isChecked();
}
} // namespace Internal
} // namespace Bazaar
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Hugues Delorme
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** No Commercial Usage
**
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/
#ifndef BAZAARCOMMITWIDGET_H
#define BAZAARCOMMITWIDGET_H
#include "ui_bazaarcommitpanel.h"
#include <utils/submiteditorwidget.h>
namespace Bazaar {
namespace Internal {
class BranchInfo;