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