forked from qt-creator/qt-creator
Bazaar: fix jumping to the changes from the blame view
Merge-request: 273 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
@@ -40,7 +40,7 @@ using namespace Bazaar;
|
||||
BazaarAnnotationHighlighter::BazaarAnnotationHighlighter(const ChangeNumbers &changeNumbers,
|
||||
QTextDocument *document)
|
||||
: VCSBase::BaseAnnotationHighlighter(changeNumbers, document),
|
||||
m_changeset(QLatin1String(Constants::CHANGESETID12))
|
||||
m_changeset(QLatin1String(Constants::CHANGESET_ID))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,10 @@
|
||||
#include "bazaarclient.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <vcsbase/diffhighlighter.h>
|
||||
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QTextCursor>
|
||||
#include <QtGui/QTextBlock>
|
||||
@@ -47,15 +49,14 @@
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
# define BZR_CHANGE_PATTERN "[0-9]+"
|
||||
|
||||
using namespace Bazaar::Internal;
|
||||
using namespace Bazaar;
|
||||
|
||||
BazaarEditor::BazaarEditor(const VCSBase::VCSBaseEditorParameters *type, QWidget *parent)
|
||||
: VCSBase::VCSBaseEditorWidget(type, parent),
|
||||
m_exactIdentifier12(QLatin1String(Constants::CHANGEIDEXACT12)),
|
||||
m_exactIdentifier40(QLatin1String(Constants::CHANGEIDEXACT40)),
|
||||
m_changesetIdentifier12(QLatin1String(Constants::CHANGESETID12)),
|
||||
m_changesetIdentifier40(QLatin1String(Constants::CHANGESETID40)),
|
||||
m_exactChangesetId(QLatin1String(Constants::CHANGESET_ID_EXACT)),
|
||||
m_diffIdentifier(QLatin1String(Constants::DIFFIDENTIFIER))
|
||||
{
|
||||
setAnnotateRevisionTextFormat(tr("Annotate %1"));
|
||||
@@ -65,16 +66,22 @@ BazaarEditor::BazaarEditor(const VCSBase::VCSBaseEditorParameters *type, QWidget
|
||||
QSet<QString> BazaarEditor::annotationChanges() const
|
||||
{
|
||||
QSet<QString> changes;
|
||||
const QString data = toPlainText();
|
||||
if (data.isEmpty())
|
||||
const QString txt = toPlainText();
|
||||
if (txt.isEmpty())
|
||||
return changes;
|
||||
|
||||
int position = 0;
|
||||
while ((position = m_changesetIdentifier12.indexIn(data, position)) != -1) {
|
||||
changes.insert(m_changesetIdentifier12.cap(1));
|
||||
position += m_changesetIdentifier12.matchedLength();
|
||||
QRegExp changeNumRx(QLatin1String("^("BZR_CHANGE_PATTERN") "));
|
||||
QTC_ASSERT(changeNumRx.isValid(), return changes);
|
||||
if (changeNumRx.indexIn(txt) != -1) {
|
||||
changes.insert(changeNumRx.cap(1));
|
||||
changeNumRx.setPattern(QLatin1String("\n("BZR_CHANGE_PATTERN") "));
|
||||
QTC_ASSERT(changeNumRx.isValid(), return changes);
|
||||
int pos = 0;
|
||||
while ((pos = changeNumRx.indexIn(txt, pos)) != -1) {
|
||||
pos += changeNumRx.matchedLength();
|
||||
changes.insert(changeNumRx.cap(1));
|
||||
}
|
||||
}
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
@@ -84,9 +91,7 @@ QString BazaarEditor::changeUnderCursor(const QTextCursor &cursorIn) const
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
if (cursor.hasSelection()) {
|
||||
const QString change = cursor.selectedText();
|
||||
if (m_exactIdentifier12.exactMatch(change))
|
||||
return change;
|
||||
if (m_exactIdentifier40.exactMatch(change))
|
||||
if (m_exactChangesetId.exactMatch(change))
|
||||
return change;
|
||||
}
|
||||
return QString();
|
||||
|
||||
@@ -54,10 +54,7 @@ private:
|
||||
virtual VCSBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const;
|
||||
virtual QString fileNameFromDiffSpecification(const QTextBlock &diffFileSpec) const;
|
||||
|
||||
const QRegExp m_exactIdentifier12;
|
||||
const QRegExp m_exactIdentifier40;
|
||||
const QRegExp m_changesetIdentifier12;
|
||||
const QRegExp m_changesetIdentifier40;
|
||||
const QRegExp m_exactChangesetId;
|
||||
const QRegExp m_diffIdentifier;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,10 +42,8 @@ const char * const BAZAARREPO = ".bzr";
|
||||
const char * const BAZAARDEFAULT = "bzr";
|
||||
|
||||
//changeset identifiers
|
||||
const char * const CHANGESETID12 = " ([a-f0-9]{12,12}) "; //match 12 hex chars and capture
|
||||
const char * const CHANGESETID40 = " ([a-f0-9]{40,40}) ";
|
||||
const char * const CHANGEIDEXACT12 = "[a-f0-9]{12,12}"; //match 12 hex chars a
|
||||
const char * const CHANGEIDEXACT40 = "[a-f0-9]{40,40}";
|
||||
const char * const CHANGESET_ID = "([0-9]+)"; // match and capture
|
||||
const char * const CHANGESET_ID_EXACT = "[0-9]+"; // match
|
||||
const char * const DIFFIDENTIFIER = "^[-+]{3,3} [ab]{1,1}.*"; // match e.g. +++ b/filename
|
||||
|
||||
//BaseEditorParameters
|
||||
|
||||
Reference in New Issue
Block a user